[wpimath] Split WPIMathJNI into logical chunks (#5552)

This makes things easier to find, and speeds up compilation.
This commit is contained in:
Tyler Veness
2023-08-29 09:00:19 -07:00
committed by GitHub
parent ea17f90f87
commit b7657a8e28
11 changed files with 651 additions and 530 deletions

View File

@@ -43,6 +43,8 @@ public final class WPIMathJNI {
libraryLoaded = true;
}
// DARE wrappers
/**
* Computes the unique stabilizing solution X to the discrete-time algebraic Riccati equation.
*
@@ -208,6 +210,8 @@ public final class WPIMathJNI {
int inputs,
double[] S);
// Eigen wrappers
/**
* Computes the matrix exp.
*
@@ -227,6 +231,35 @@ public final class WPIMathJNI {
*/
public static native void pow(double[] src, int rows, double exponent, double[] dst);
/**
* Performs an inplace rank one update (or downdate) of an upper triangular Cholesky decomposition
* matrix.
*
* @param mat Array of elements of the matrix to be updated.
* @param lowerTriangular Whether mat is lower triangular.
* @param rows How many rows there are.
* @param vec Vector to use for the rank update.
* @param sigma Sigma value to use for the rank update.
*/
public static native void rankUpdate(
double[] mat, int rows, double[] vec, double sigma, boolean lowerTriangular);
/**
* Solves the least-squares problem Ax=B using a QR decomposition with full pivoting.
*
* @param A Array of elements of the A matrix.
* @param Arows Number of rows of the A matrix.
* @param Acols Number of rows of the A matrix.
* @param B Array of elements of the B matrix.
* @param Brows Number of rows of the B matrix.
* @param Bcols Number of rows of the B matrix.
* @param dst Array to store solution in. If A is m-n and B is m-p, dst is n-p.
*/
public static native void solveFullPivHouseholderQr(
double[] A, int Arows, int Acols, double[] B, int Brows, int Bcols, double[] dst);
// Pose3d wrappers
/**
* Obtain a Pose3d from a (constant curvature) velocity.
*
@@ -299,6 +332,8 @@ public final class WPIMathJNI {
double endQy,
double endQz);
// StateSpaceUtil wrappers
/**
* Returns true if (A, B) is a stabilizable pair.
*
@@ -314,6 +349,8 @@ public final class WPIMathJNI {
*/
public static native boolean isStabilizable(int states, int inputs, double[] A, double[] B);
// Trajectory wrappers
/**
* Loads a Pathweaver JSON.
*
@@ -348,19 +385,6 @@ public final class WPIMathJNI {
*/
public static native String serializeTrajectory(double[] elements);
/**
* Performs an inplace rank one update (or downdate) of an upper triangular Cholesky decomposition
* matrix.
*
* @param mat Array of elements of the matrix to be updated.
* @param lowerTriangular Whether mat is lower triangular.
* @param rows How many rows there are.
* @param vec Vector to use for the rank update.
* @param sigma Sigma value to use for the rank update.
*/
public static native void rankUpdate(
double[] mat, int rows, double[] vec, double sigma, boolean lowerTriangular);
public static class Helper {
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
@@ -372,18 +396,4 @@ public final class WPIMathJNI {
extractOnStaticLoad.set(load);
}
}
/**
* Solves the least-squares problem Ax=B using a QR decomposition with full pivoting.
*
* @param A Array of elements of the A matrix.
* @param Arows Number of rows of the A matrix.
* @param Acols Number of rows of the A matrix.
* @param B Array of elements of the B matrix.
* @param Brows Number of rows of the B matrix.
* @param Bcols Number of rows of the B matrix.
* @param dst Array to store solution in. If A is m-n and B is m-p, dst is n-p.
*/
public static native void solveFullPivHouseholderQr(
double[] A, int Arows, int Acols, double[] B, int Brows, int Bcols, double[] dst);
}