mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[build] Apply spotless for java formatting (#1768)
Update checkstyle config to be compatible with spotless. Co-authored-by: Austin Shalit <austinshalit@gmail.com>
This commit is contained in:
@@ -4,14 +4,12 @@
|
||||
|
||||
package edu.wpi.first.math;
|
||||
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
|
||||
import edu.wpi.first.wpiutil.math.Matrix;
|
||||
import edu.wpi.first.wpiutil.math.Num;
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
|
||||
public final class Drake {
|
||||
private Drake() {
|
||||
}
|
||||
private Drake() {}
|
||||
|
||||
/**
|
||||
* Solves the discrete alegebraic Riccati equation.
|
||||
@@ -24,14 +22,16 @@ public final class Drake {
|
||||
*/
|
||||
@SuppressWarnings({"LocalVariableName", "ParameterName"})
|
||||
public static SimpleMatrix discreteAlgebraicRiccatiEquation(
|
||||
SimpleMatrix A,
|
||||
SimpleMatrix B,
|
||||
SimpleMatrix Q,
|
||||
SimpleMatrix R) {
|
||||
SimpleMatrix A, SimpleMatrix B, SimpleMatrix Q, SimpleMatrix R) {
|
||||
var S = new SimpleMatrix(A.numRows(), A.numCols());
|
||||
WPIMathJNI.discreteAlgebraicRiccatiEquation(A.getDDRM().getData(), B.getDDRM().getData(),
|
||||
Q.getDDRM().getData(), R.getDDRM().getData(), A.numCols(), B.numCols(),
|
||||
S.getDDRM().getData());
|
||||
WPIMathJNI.discreteAlgebraicRiccatiEquation(
|
||||
A.getDDRM().getData(),
|
||||
B.getDDRM().getData(),
|
||||
Q.getDDRM().getData(),
|
||||
R.getDDRM().getData(),
|
||||
A.numCols(),
|
||||
B.numCols(),
|
||||
S.getDDRM().getData());
|
||||
return S;
|
||||
}
|
||||
|
||||
@@ -45,12 +45,14 @@ public final class Drake {
|
||||
* @return Solution of DARE.
|
||||
*/
|
||||
@SuppressWarnings({"ParameterName", "MethodTypeParameterName"})
|
||||
public static <States extends Num, Inputs extends Num> Matrix<States, States>
|
||||
discreteAlgebraicRiccatiEquation(Matrix<States, States> A,
|
||||
Matrix<States, Inputs> B,
|
||||
Matrix<States, States> Q,
|
||||
Matrix<Inputs, Inputs> R) {
|
||||
return new Matrix<>(discreteAlgebraicRiccatiEquation(A.getStorage(), B.getStorage(),
|
||||
Q.getStorage(), R.getStorage()));
|
||||
public static <States extends Num, Inputs extends Num>
|
||||
Matrix<States, States> discreteAlgebraicRiccatiEquation(
|
||||
Matrix<States, States> A,
|
||||
Matrix<States, Inputs> B,
|
||||
Matrix<States, States> Q,
|
||||
Matrix<Inputs, Inputs> R) {
|
||||
return new Matrix<>(
|
||||
discreteAlgebraicRiccatiEquation(
|
||||
A.getStorage(), B.getStorage(), Q.getStorage(), R.getStorage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,30 +7,24 @@ package edu.wpi.first.math;
|
||||
public final class MathSharedStore {
|
||||
private static MathShared mathShared;
|
||||
|
||||
private MathSharedStore() {
|
||||
}
|
||||
private MathSharedStore() {}
|
||||
|
||||
/**
|
||||
* get the MathShared object.
|
||||
*/
|
||||
/** get the MathShared object. */
|
||||
public static synchronized MathShared getMathShared() {
|
||||
if (mathShared == null) {
|
||||
mathShared = new MathShared() {
|
||||
@Override
|
||||
public void reportError(String error, StackTraceElement[] stackTrace) {
|
||||
}
|
||||
mathShared =
|
||||
new MathShared() {
|
||||
@Override
|
||||
public void reportError(String error, StackTraceElement[] stackTrace) {}
|
||||
|
||||
@Override
|
||||
public void reportUsage(MathUsageId id, int count) {
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void reportUsage(MathUsageId id, int count) {}
|
||||
};
|
||||
}
|
||||
return mathShared;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the MathShared object.
|
||||
*/
|
||||
/** set the MathShared object. */
|
||||
public static synchronized void setMathShared(MathShared shared) {
|
||||
mathShared = shared;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
package edu.wpi.first.math;
|
||||
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
|
||||
public final class WPIMathJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
static RuntimeLoader<WPIMathJNI> loader = null;
|
||||
@@ -16,8 +15,9 @@ public final class WPIMathJNI {
|
||||
static {
|
||||
if (Helper.getExtractOnStaticLoad()) {
|
||||
try {
|
||||
loader = new RuntimeLoader<>("wpimathjni", RuntimeLoader.getDefaultExtractionRoot(),
|
||||
WPIMathJNI.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
"wpimathjni", RuntimeLoader.getDefaultExtractionRoot(), WPIMathJNI.class);
|
||||
loader.loadLibrary();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -36,8 +36,9 @@ public final class WPIMathJNI {
|
||||
if (libraryLoaded) {
|
||||
return;
|
||||
}
|
||||
loader = new RuntimeLoader<>("wpimathjni", RuntimeLoader.getDefaultExtractionRoot(),
|
||||
WPIMathJNI.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
"wpimathjni", RuntimeLoader.getDefaultExtractionRoot(), WPIMathJNI.class);
|
||||
loader.loadLibrary();
|
||||
libraryLoaded = true;
|
||||
}
|
||||
@@ -45,53 +46,47 @@ public final class WPIMathJNI {
|
||||
/**
|
||||
* Solves the discrete alegebraic Riccati equation.
|
||||
*
|
||||
* @param A Array containing elements of A in row-major order.
|
||||
* @param B Array containing elements of B in row-major order.
|
||||
* @param Q Array containing elements of Q in row-major order.
|
||||
* @param R Array containing elements of R in row-major order.
|
||||
* @param A Array containing elements of A in row-major order.
|
||||
* @param B Array containing elements of B in row-major order.
|
||||
* @param Q Array containing elements of Q in row-major order.
|
||||
* @param R Array containing elements of R in row-major order.
|
||||
* @param states Number of states in A matrix.
|
||||
* @param inputs Number of inputs in B matrix.
|
||||
* @param S Array storage for DARE solution.
|
||||
* @param S Array storage for DARE solution.
|
||||
*/
|
||||
public static native void discreteAlgebraicRiccatiEquation(
|
||||
double[] A,
|
||||
double[] B,
|
||||
double[] Q,
|
||||
double[] R,
|
||||
int states,
|
||||
int inputs,
|
||||
double[] S);
|
||||
double[] A, double[] B, double[] Q, double[] R, int states, int inputs, double[] S);
|
||||
|
||||
/**
|
||||
* Computes the matrix exp.
|
||||
*
|
||||
* @param src Array of elements of the matrix to be exponentiated.
|
||||
* @param src Array of elements of the matrix to be exponentiated.
|
||||
* @param rows How many rows there are.
|
||||
* @param dst Array where the result will be stored.
|
||||
* @param dst Array where the result will be stored.
|
||||
*/
|
||||
public static native void exp(double[] src, int rows, double[] dst);
|
||||
|
||||
/**
|
||||
* Computes the matrix pow.
|
||||
*
|
||||
* @param src Array of elements of the matrix to be raised to a power.
|
||||
* @param rows How many rows there are.
|
||||
* @param src Array of elements of the matrix to be raised to a power.
|
||||
* @param rows How many rows there are.
|
||||
* @param exponent The exponent.
|
||||
* @param dst Array where the result will be stored.
|
||||
* @param dst Array where the result will be stored.
|
||||
*/
|
||||
public static native void pow(double[] src, int rows, double exponent, double[] dst);
|
||||
|
||||
/**
|
||||
* Returns true if (A, B) is a stabilizable pair.
|
||||
*
|
||||
* <p>(A,B) is stabilizable if and only if the uncontrollable eigenvalues of A, if
|
||||
* any, have absolute values less than one, where an eigenvalue is
|
||||
* uncontrollable if rank(lambda * I - A, B) < n where n is number of states.
|
||||
* <p>(A,B) is stabilizable if and only if the uncontrollable eigenvalues of A, if any, have
|
||||
* absolute values less than one, where an eigenvalue is uncontrollable if rank(lambda * I - A, B)
|
||||
* < n where n is number of states.
|
||||
*
|
||||
* @param states the number of states of the system.
|
||||
* @param inputs the number of inputs to the system.
|
||||
* @param A System matrix.
|
||||
* @param B Input matrix.
|
||||
* @param A System matrix.
|
||||
* @param B Input matrix.
|
||||
* @return If the system is stabilizable.
|
||||
*/
|
||||
public static native boolean isStabilizable(int states, int inputs, double[] A, double[] B);
|
||||
|
||||
Reference in New Issue
Block a user