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
-
Field Summary
Modifier and TypeFieldDescriptionstatic double
static float
static float
static float
static float
static int
static double
static double
static double
static float
static float
static double
static double
static float
static double
static final float[]
static final double[]
static final int[]
-
Constructor Summary
-
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 void
assertEq
(int valA, int valB) Intended for checking preconditions.static void
Intended for checking preconditions.static void
assertShape
(boolean value, String message) Intended for checking matrix shape preconditions.static void
assertShape
(int valA, int valB, String message) Intended for checking matrix shape preconditions.static void
assertTrue
(boolean value) Intended for checking preconditions.static void
assertTrue
(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 void
checkReshapeSolve
(int numRowsA, int numColsA, ReshapeMatrix B, ReshapeMatrix X) Checks the size of inputs to the standard size function.static void
checkSameInstance
(Object a, Object b) static void
checkSameShape
(Matrix a, Matrix b, boolean allowedSameInstance) static void
checkSameShape
(Matrix a, Matrix b, Matrix c) static void
checkTooLarge
(int rows, int cols) static void
checkTooLargeComplex
(int rows, int cols) static void
checkValidMatrixShape
(int rows, int cols) Ensures that the matrix shape is valid.static void
checkValidMatrixShapeComplex
(int rows, int cols) Ensures that the matrix shape is valid.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.static String
fancyString
(double value, DecimalFormat format, boolean hasSpace, int length, int significant) static String
fancyString
(double value, DecimalFormat format, int length, int significant) static String
fancyStringF
(double value, DecimalFormat format, int length, int significant) Fixed length fancy formatting for doubles.static boolean
hasNullableArgument
(Method func) Returns true if any of the matrix arguments has @Nullablestatic boolean
isIdentical
(double a, double b, double tol) static boolean
isIdentical
(float a, float b, float tol) static boolean
isUncountable
(double val) static boolean
isUncountable
(float val) static double
max
(double[] array, int start, int length) static float
max
(float[] array, int start, int length) static void
memset
(double[] data, double val, int length) static void
memset
(int[] data, int val, int length) static DMatrixRMaj
parse_DDRM
(String s, int numColumns) Give a string of numbers it returns a DenseMatrixstatic DMatrixSparseCSC
parse_DSCC
(String s, int numColumns) static FMatrixRMaj
parse_FDRM
(String s, int numColumns) Give a string of numbers it returns a DenseMatrixstatic FMatrixSparseCSC
parse_FSCC
(String s, int numColumns) static int
permutationSign
(int[] p, int N, int[] work) static int[]
pivotVector
(int[] pivots, int length, @Nullable IGrowArray storage) static void
printTime
(String pre, String message, UtilEjml.Process timer) static void
printTime
(String message, UtilEjml.Process timer) static float[]
randomVector_F32
(Random rand, int length) static double[]
randomVector_F64
(Random rand, int length) static BMatrixRMaj
reshapeOrDeclare
(@Nullable BMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static CMatrixRMaj
reshapeOrDeclare
(@Nullable CMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static DMatrixRMaj
reshapeOrDeclare
(@Nullable DMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static DMatrixSparseCSC
reshapeOrDeclare
(@Nullable DMatrixSparseCSC target, int rows, int cols, int nz_length) static FMatrixRMaj
reshapeOrDeclare
(@Nullable FMatrixRMaj a, int rows, int cols) If the input matrix is null a new matrix is created and returned.static FMatrixSparseCSC
reshapeOrDeclare
(@Nullable FMatrixSparseCSC target, int rows, int cols, int nz_length) static ZMatrixRMaj
reshapeOrDeclare
(@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> void
setnull
(T[] array) static void
static int[]
static int[]
static int[]
shuffledSorted
(int N, int shuffleUpTo, Random rand) static Integer[]
sortByIndex
(double[] data, int size) static String
stringShapes
(Matrix A, Matrix B) static String
stringShapes
(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
-