Skip to content

Commit

Permalink
Sort Java native declarations by JNI definition order
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Aug 19, 2023
1 parent f02fcf1 commit b0e199a
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions wpimath/src/main/java/edu/wpi/first/math/WPIMathJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static synchronized void forceLoad() throws IOException {
libraryLoaded = true;
}

// DARE wrappers

/**
* Computes the unique stabilizing solution X to the discrete-time algebraic Riccati equation.
*
Expand Down Expand Up @@ -208,6 +210,8 @@ public static native void dareABQRN(
int inputs,
double[] S);

// Eigen wrappers

/**
* Computes the matrix exp.
*
Expand All @@ -227,6 +231,36 @@ public static native void dareABQRN(
*/
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.
*
Expand Down Expand Up @@ -299,6 +333,8 @@ public static native double[] logPose3d(
double endQy,
double endQz);

// StateSpaceUtil wrappers

/**
* Returns true if (A, B) is a stabilizable pair.
*
Expand All @@ -314,6 +350,8 @@ public static native double[] logPose3d(
*/
public static native boolean isStabilizable(int states, int inputs, double[] A, double[] B);

// Trajectory wrappers

/**
* Loads a Pathweaver JSON.
*
Expand Down Expand Up @@ -348,19 +386,6 @@ public static native double[] logPose3d(
*/
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);

Expand All @@ -372,18 +397,4 @@ public static void setExtractOnStaticLoad(boolean load) {
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);
}

0 comments on commit b0e199a

Please sign in to comment.