Package org.ejml
Class UtilEjml
java.lang.Object
org.ejml.UtilEjml
Various functions that are useful but don't have a clear location that they belong in.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic doublestatic floatstatic floatstatic floatstatic floatstatic intstatic doublestatic doublestatic doublestatic floatstatic floatstatic doublestatic doublestatic floatstatic doublestatic final float[]static final double[]static final int[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]adjust(@Nullable DGrowArray gwork, int desired) Resizes the array to ensure that it is at least of length desired and returns its internal arraystatic float[]adjust(@Nullable FGrowArray gwork, int desired) Resizes the array to ensure that it is at least of length desired and returns its internal arraystatic int[]adjust(@Nullable IGrowArray gwork, int desired) Resizes the array to ensure that it is at least of length desired and returns its internal arraystatic int[]adjust(@Nullable IGrowArray gwork, int desired, int zeroToM) static int[]adjustClear(@Nullable IGrowArray gwork, int desired) static int[]adjustFill(@Nullable IGrowArray gwork, int desired, int value) static voidassertEq(int valA, int valB) Intended for checking preconditions.static voidIntended for checking preconditions.static voidassertShape(boolean value, String message) Intended for checking matrix shape preconditions.static voidassertShape(int valA, int valB, String message) Intended for checking matrix shape preconditions.static voidassertTrue(boolean value) Intended for checking preconditions.static voidassertTrue(boolean value, String message) Intended for checking preconditions.static GrowArray<FGrowArray>checkDeclare_F32(@Nullable GrowArray<FGrowArray> workspace) static GrowArray<DGrowArray>checkDeclare_F64(@Nullable GrowArray<DGrowArray> workspace) static voidcheckReshapeSolve(int numRowsA, int numColsA, ReshapeMatrix B, ReshapeMatrix X) Checks the size of inputs to the standard size function.static voidcheckSameInstance(Object a, Object b) static voidcheckSameShape(Matrix a, Matrix b, boolean allowedSameInstance) static voidcheckSameShape(Matrix a, Matrix b, Matrix c) static voidcheckTooLarge(int rows, int cols) static voidcheckTooLargeComplex(int rows, int cols) static voidcheckValidMatrixShape(int rows, int cols) Ensures that the matrix shape is valid.static voidcheckValidMatrixShapeComplex(int rows, int cols) Ensures that the matrix shape is valid.static booleanexceedsMaxMatrixSize(int numRows, int numCols) Checks to see if a matrix of this size will exceed the maximum possible value an integer can store, which is the max possible array size in Java.static StringfancyString(double value, DecimalFormat format, boolean hasSpace, int length, int significant) static StringfancyString(double value, DecimalFormat format, int length, int significant) static StringfancyStringF(double value, DecimalFormat format, int length, int significant) Fixed length fancy formatting for doubles.static booleanhasNullableArgument(Method func) Returns true if any of the matrix arguments has @Nullablestatic booleanisIdentical(double a, double b, double tol) static booleanisIdentical(float a, float b, float tol) static booleanisUncountable(double val) static booleanisUncountable(float val) static doublemax(double[] array, int start, int length) static floatmax(float[] array, int start, int length) static voidmemset(double[] data, double val, int length) static voidmemset(int[] data, int val, int length) static DMatrixRMajparse_DDRM(String s, int numColumns) Give a string of numbers it returns a DenseMatrixstatic DMatrixSparseCSCparse_DSCC(String s, int numColumns) static FMatrixRMajparse_FDRM(String s, int numColumns) Give a string of numbers it returns a DenseMatrixstatic FMatrixSparseCSCparse_FSCC(String s, int numColumns) static intpermutationSign(int[] p, int N, int[] work) static int[]pivotVector(int[] pivots, int length, @Nullable IGrowArray storage) static voidprintTime(String pre, String message, UtilEjml.EjmlProcess timer) static voidprintTime(String message, UtilEjml.EjmlProcess timer) static float[]randomVector_F32(Random rand, int length) static double[]randomVector_F64(Random rand, int length) static BMatrixRMajreshapeOrDeclare(@Nullable BMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static CMatrixRMajreshapeOrDeclare(@Nullable CMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static DMatrixRMajreshapeOrDeclare(@Nullable DMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static DMatrixSparseCSCreshapeOrDeclare(@Nullable DMatrixSparseCSC target, int rows, int cols, int nz_length) static FMatrixRMajreshapeOrDeclare(@Nullable FMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static FMatrixSparseCSCreshapeOrDeclare(@Nullable FMatrixSparseCSC target, int rows, int cols, int nz_length) static ZMatrixRMajreshapeOrDeclare(@Nullable ZMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static <T extends MatrixSparse>
TreshapeOrDeclare(T target, MatrixSparse reference) static <T extends ReshapeMatrix>
TreshapeOrDeclare(T target, T reference) If the input matrix is null a new matrix is created and returned.static <T extends ReshapeMatrix>
TreshapeOrDeclare(T target, T reference, int rows, int cols) If the input matrix is null a new matrix is created and returned.static <S extends Matrix,D extends Matrix>
LinearSolver<S,D> safe(LinearSolver<S, D> solver) Wraps a linear solver of any type with a safe solver the ensures inputs are not modifiedstatic <D extends ReshapeMatrix>
LinearSolverDense<D>safe(LinearSolverDense<D> solver) static <T> voidsetnull(T[] array) static voidstatic int[]static int[]static int[]shuffledSorted(int N, int shuffleUpTo, Random rand) static Integer[]sortByIndex(double[] data, int size) static StringstringShapes(Matrix A, Matrix B) static StringstringShapes(Matrix A, Matrix B, Matrix C)
-
Field Details
-
EPS
public static double EPS -
F_EPS
public static float F_EPS -
PI
public static double PI -
PI2
public static double PI2 -
PId2
public static double PId2 -
F_PI
public static float F_PI -
F_PI2
public static float F_PI2 -
F_PId2
public static float F_PId2 -
TEST_F32
public static float TEST_F32 -
TEST_F64
public static double TEST_F64 -
TESTP_F32
public static float TESTP_F32 -
TESTP_F64
public static double TESTP_F64 -
TEST_F32_SQ
public static float TEST_F32_SQ -
TEST_F64_SQ
public static double TEST_F64_SQ -
maxInverseSize
public static int maxInverseSize -
ZERO_LENGTH_I32
public static final int[] ZERO_LENGTH_I32 -
ZERO_LENGTH_F32
public static final float[] ZERO_LENGTH_F32 -
ZERO_LENGTH_F64
public static final double[] ZERO_LENGTH_F64
-
-
Constructor Details
-
UtilEjml
public UtilEjml()
-
-
Method Details
-
checkSameInstance
-
reshapeOrDeclare
If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
a- (Input/Output) matrix which is to be checked. Can be null.rows- Desired number of rowscols- Desired number of cols- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
a- (Input/Output) matrix which is to be checked. Can be null.rows- Desired number of rowscols- Desired number of cols- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
a- (Input/Output) matrix which is to be checked. Can be null.rows- Desired number of rowscols- Desired number of cols- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
a- (Input/Output) matrix which is to be checked. Can be null.rows- Desired number of rowscols- Desired number of cols- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
a- (Input/Output) matrix which is to be checked. Can be null.rows- Desired number of rowscols- Desired number of cols- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
target- (Input/Output) matrix which is to be checked. Can be null.reference- (Input) Refernece matrix who's shape will be matched- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
public static <T extends MatrixSparse> T reshapeOrDeclare(@Nullable T target, MatrixSparse reference) -
reshapeOrDeclare
public static <T extends ReshapeMatrix> T reshapeOrDeclare(@Nullable T target, T reference, int rows, int cols) If the input matrix is null a new matrix is created and returned. If it exists it will be reshaped and returned.- Parameters:
target- (Input/Output) matrix which is to be checked. Can be null.reference- (Input) Refernece matrix who's shape will be matched- Returns:
- modified matrix or new matrix
-
reshapeOrDeclare
public static DMatrixSparseCSC reshapeOrDeclare(@Nullable @Nullable DMatrixSparseCSC target, int rows, int cols, int nz_length) -
reshapeOrDeclare
public static FMatrixSparseCSC reshapeOrDeclare(@Nullable @Nullable FMatrixSparseCSC target, int rows, int cols, int nz_length) -
checkSameShape
-
checkSameShape
-
safe
Wraps a linear solver of any type with a safe solver the ensures inputs are not modified -
safe
-
checkValidMatrixShape
public static void checkValidMatrixShape(int rows, int cols) Ensures that the matrix shape is valid. This means that an array that's large enough can be declared and that neither rows or columns are negative. -
checkValidMatrixShapeComplex
public static void checkValidMatrixShapeComplex(int rows, int cols) Ensures that the matrix shape is valid. This means that an array that's large enough can be declared and that neither rows or columns are negative. -
checkTooLarge
public static void checkTooLarge(int rows, int cols) -
checkTooLargeComplex
public static void checkTooLargeComplex(int rows, int cols) -
isUncountable
public static boolean isUncountable(double val) -
isUncountable
public static boolean isUncountable(float val) -
isIdentical
public static boolean isIdentical(double a, double b, double tol) -
isIdentical
public static boolean isIdentical(float a, float b, float tol) -
memset
public static void memset(double[] data, double val, int length) -
memset
public static void memset(int[] data, int val, int length) -
setnull
public static <T> void setnull(T[] array) -
max
public static double max(double[] array, int start, int length) -
max
public static float max(float[] array, int start, int length) -
parse_DDRM
Give a string of numbers it returns a DenseMatrix -
parse_FDRM
Give a string of numbers it returns a DenseMatrix -
sortByIndex
-
parse_DSCC
-
parse_FSCC
-
shuffled
-
shuffled
-
shuffledSorted
-
shuffle
-
pivotVector
-
permutationSign
public static int permutationSign(int[] p, int N, int[] work) -
randomVector_F64
-
randomVector_F32
-
stringShapes
-
stringShapes
-
fancyStringF
Fixed length fancy formatting for doubles. If possible decimal notation is used. If all the significant digits can't be shown then it will switch to exponential notation. If not all the space is needed then it will be filled in to ensure it has the specified length.- Parameters:
value- value being formattedformat- default format before exponentiallength- Maximum number of characters it can take.significant- Number of significant decimal digits to show at a minimum.- Returns:
- formatted string
-
fancyString
-
fancyString
public static String fancyString(double value, DecimalFormat format, boolean hasSpace, int length, int significant) -
adjust
Resizes the array to ensure that it is at least of length desired and returns its internal array -
adjust
-
adjustClear
-
adjustFill
-
adjust
Resizes the array to ensure that it is at least of length desired and returns its internal array -
adjust
Resizes the array to ensure that it is at least of length desired and returns its internal array -
hasNullableArgument
Returns true if any of the matrix arguments has @Nullable -
checkDeclare_F32
public static GrowArray<FGrowArray> checkDeclare_F32(@Nullable @Nullable GrowArray<FGrowArray> workspace) -
checkDeclare_F64
public static GrowArray<DGrowArray> checkDeclare_F64(@Nullable @Nullable GrowArray<DGrowArray> workspace) -
exceedsMaxMatrixSize
public static boolean exceedsMaxMatrixSize(int numRows, int numCols) Checks to see if a matrix of this size will exceed the maximum possible value an integer can store, which is the max possible array size in Java. -
printTime
-
printTime
-
assertEq
public static void assertEq(int valA, int valB) Intended for checking preconditions. Throws an exception if the two values are not equal. -
assertEq
Intended for checking preconditions. Throws an exception if the two values are not equal. -
assertTrue
Intended for checking preconditions. Throws an exception if the input is not true -
assertTrue
public static void assertTrue(boolean value) Intended for checking preconditions. Throws an exception if the input is not true -
assertShape
Intended for checking matrix shape preconditions. Throws an exception if the two values are not equal. -
assertShape
Intended for checking matrix shape preconditions. Throws an exception if the input is not true -
checkReshapeSolve
Checks the size of inputs to the standard size function. Throws exception if B is incorrect. Reshapes X.- Parameters:
numRowsA- Number of rows in A matrixnumColsA- Number of columns in A matrix
-