[wpimath] Add Vector overload for times and div (#2686)

This commit is contained in:
Matt
2020-09-03 20:48:43 -07:00
committed by GitHub
parent 502f5c8b5f
commit 8edc17dac9
2 changed files with 18 additions and 4 deletions

View File

@@ -9,7 +9,6 @@ package edu.wpi.first.wpiutil.math;
import java.util.Objects;
import org.ejml.MatrixDimensionException;
import org.ejml.data.DMatrixRMaj;
import org.ejml.dense.row.CommonOps_DDRM;
@@ -227,7 +226,7 @@ public class Matrix<R extends Num, C extends Num> {
* @param value The scalar value to multiply by.
* @return A new matrix with all the elements multiplied by the given value.
*/
public final Matrix<R, C> times(double value) {
public Matrix<R, C> times(double value) {
return new Matrix<>(this.m_storage.scale(value));
}
@@ -293,7 +292,7 @@ public class Matrix<R extends Num, C extends Num> {
* @param value The value to divide by.
* @return The resultant matrix.
*/
public final Matrix<R, C> div(int value) {
public Matrix<R, C> div(int value) {
return new Matrix<>(this.m_storage.divide((double) value));
}
@@ -303,7 +302,7 @@ public class Matrix<R extends Num, C extends Num> {
* @param value The value to divide by.
* @return The resultant matrix.
*/
public final Matrix<R, C> div(double value) {
public Matrix<R, C> div(double value) {
return new Matrix<>(this.m_storage.divide(value));
}

View File

@@ -52,4 +52,19 @@ public class Vector<R extends Num> extends Matrix<R, N1> {
public Vector(Matrix<R, N1> other) {
super(other);
}
@Override
public Vector<R> times(double value) {
return new Vector<>(this.m_storage.scale(value));
}
@Override
public Vector<R> div(int value) {
return new Vector<>(this.m_storage.divide(value));
}
@Override
public Vector<R> div(double value) {
return new Vector<>(this.m_storage.divide(value));
}
}