mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpimath] Add Vector overload for times and div (#2686)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user