Package org.ejml

Class UtilEjml

java.lang.Object
org.ejml.UtilEjml

public class UtilEjml extends Object
Various functions that are useful but don't have a clear location that they belong in.
  • 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

      public static void checkSameInstance(Object a, Object b)
    • reshapeOrDeclare

      public static DMatrixRMaj reshapeOrDeclare(@Nullable @Nullable DMatrixRMaj a, 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:
      a - (Input/Output) matrix which is to be checked. Can be null.
      rows - Desired number of rows
      cols - Desired number of cols
      Returns:
      modified matrix or new matrix
    • reshapeOrDeclare

      public static FMatrixRMaj reshapeOrDeclare(@Nullable @Nullable FMatrixRMaj a, 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:
      a - (Input/Output) matrix which is to be checked. Can be null.
      rows - Desired number of rows
      cols - Desired number of cols
      Returns:
      modified matrix or new matrix
    • reshapeOrDeclare

      public static BMatrixRMaj reshapeOrDeclare(@Nullable @Nullable BMatrixRMaj a, 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:
      a - (Input/Output) matrix which is to be checked. Can be null.
      rows - Desired number of rows
      cols - Desired number of cols
      Returns:
      modified matrix or new matrix
    • reshapeOrDeclare

      public static ZMatrixRMaj reshapeOrDeclare(@Nullable @Nullable ZMatrixRMaj a, 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:
      a - (Input/Output) matrix which is to be checked. Can be null.
      rows - Desired number of rows
      cols - Desired number of cols
      Returns:
      modified matrix or new matrix
    • reshapeOrDeclare

      public static CMatrixRMaj reshapeOrDeclare(@Nullable @Nullable CMatrixRMaj a, 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:
      a - (Input/Output) matrix which is to be checked. Can be null.
      rows - Desired number of rows
      cols - Desired number of cols
      Returns:
      modified matrix or new matrix
    • reshapeOrDeclare

      public static <T extends ReshapeMatrix> T reshapeOrDeclare(@Nullable T target, T reference)
      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

      public static void checkSameShape(Matrix a, Matrix b, boolean allowedSameInstance)
    • checkSameShape

      public static void checkSameShape(Matrix a, Matrix b, Matrix c)
    • safe

      public 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 modified
    • safe

      public static <D extends ReshapeMatrix> LinearSolverDense<D> safe(LinearSolverDense<D> solver)
    • 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

      public static DMatrixRMaj parse_DDRM(String s, int numColumns)
      Give a string of numbers it returns a DenseMatrix
    • parse_FDRM

      public static FMatrixRMaj parse_FDRM(String s, int numColumns)
      Give a string of numbers it returns a DenseMatrix
    • sortByIndex

      public static Integer[] sortByIndex(double[] data, int size)
    • parse_DSCC

      public static DMatrixSparseCSC parse_DSCC(String s, int numColumns)
    • parse_FSCC

      public static FMatrixSparseCSC parse_FSCC(String s, int numColumns)
    • shuffled

      public static int[] shuffled(int N, Random rand)
    • shuffled

      public static int[] shuffled(int N, int shuffleUpTo, Random rand)
    • shuffledSorted

      public static int[] shuffledSorted(int N, int shuffleUpTo, Random rand)
    • shuffle

      public static void shuffle(int[] list, int N, int start, int end, Random rand)
    • pivotVector

      public static int[] pivotVector(int[] pivots, int length, @Nullable @Nullable IGrowArray storage)
    • permutationSign

      public static int permutationSign(int[] p, int N, int[] work)
    • randomVector_F64

      public static double[] randomVector_F64(Random rand, int length)
    • randomVector_F32

      public static float[] randomVector_F32(Random rand, int length)
    • stringShapes

      public static String stringShapes(Matrix A, Matrix B, Matrix C)
    • stringShapes

      public static String stringShapes(Matrix A, Matrix B)
    • fancyStringF

      public static String fancyStringF(double value, DecimalFormat format, int length, int significant)
      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 formatted
      format - default format before exponential
      length - Maximum number of characters it can take.
      significant - Number of significant decimal digits to show at a minimum.
      Returns:
      formatted string
    • fancyString

      public static String fancyString(double value, DecimalFormat format, int length, int significant)
    • fancyString

      public static String fancyString(double value, DecimalFormat format, boolean hasSpace, int length, int significant)
    • adjust

      public static int[] adjust(@Nullable @Nullable IGrowArray gwork, int desired)
      Resizes the array to ensure that it is at least of length desired and returns its internal array
    • adjust

      public static int[] adjust(@Nullable @Nullable IGrowArray gwork, int desired, int zeroToM)
    • adjustClear

      public static int[] adjustClear(@Nullable @Nullable IGrowArray gwork, int desired)
    • adjustFill

      public static int[] adjustFill(@Nullable @Nullable IGrowArray gwork, int desired, int value)
    • adjust

      public static double[] adjust(@Nullable @Nullable DGrowArray gwork, int desired)
      Resizes the array to ensure that it is at least of length desired and returns its internal array
    • adjust

      public static float[] adjust(@Nullable @Nullable FGrowArray gwork, int desired)
      Resizes the array to ensure that it is at least of length desired and returns its internal array
    • hasNullableArgument

      public static boolean hasNullableArgument(Method func)
      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

      public static void printTime(String message, UtilEjml.Process timer)
    • printTime

      public static void printTime(String pre, String message, UtilEjml.Process timer)
    • assertEq

      public static void assertEq(int valA, int valB)
      Intended for checking preconditions. Throws an exception if the two values are not equal.
    • assertEq

      public static void assertEq(int valA, int valB, String message)
      Intended for checking preconditions. Throws an exception if the two values are not equal.
    • assertTrue

      public static void assertTrue(boolean value, String message)
      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

      public static void assertShape(int valA, int valB, String message)
      Intended for checking matrix shape preconditions. Throws an exception if the two values are not equal.
    • assertShape

      public static void assertShape(boolean value, String message)
      Intended for checking matrix shape preconditions. Throws an exception if the input is not true
    • checkReshapeSolve

      public static void checkReshapeSolve(int numRowsA, int numColsA, ReshapeMatrix B, ReshapeMatrix X)
      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 matrix
      numColsA - Number of columns in A matrix