Class CommonOps_FDRM


  • public class CommonOps_FDRM
    extends java.lang.Object

    Common matrix operations are contained here. Which specific underlying algorithm is used is not specified just the out come of the operation. Nor should calls to these functions reply on the underlying implementation. Which algorithm is used can depend on the matrix being passed in.

    For more exotic and specialized generic operations see SpecializedOps_FDRM.

    See Also:
    MatrixMatrixMult_FDRM, MatrixVectorMult_FDRM, SpecializedOps_FDRM, MatrixFeatures_FDRM
    • Constructor Summary

      Constructors 
      Constructor Description
      CommonOps_FDRM()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void abs​(org.ejml.data.FMatrixD1 a)
      Performs absolute value of a matrix:

      a = abs(a)
      aij = abs(aij)
      static void abs​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 c)
      Performs absolute value of a matrix:

      c = abs(a)
      cij = abs(aij)
      static void add​(float alpha, org.ejml.data.FMatrixD1 a, float beta, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the following operation:

      c = α * a + β * b
      cij = α * aij + β * bij
      static void add​(float alpha, org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the following operation:

      c = α * a + b
      cij = α * aij + bij
      static void add​(org.ejml.data.FMatrixD1 a, float val)
      Performs an in-place scalar addition:

      a = a + val
      aij = aij + val
      static void add​(org.ejml.data.FMatrixD1 a, float val, org.ejml.data.FMatrixD1 c)
      Performs scalar addition:

      c = a + val
      cij = aij + val
      static void add​(org.ejml.data.FMatrixD1 a, float beta, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the following operation:

      c = a + β * b
      cij = aij + β * bij
      static void add​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the following operation:

      c = a + b
      cij = aij + bij
      static void addEquals​(org.ejml.data.FMatrixD1 a, float beta, org.ejml.data.FMatrixD1 b)
      Performs the following operation:

      a = a + β * b
      aij = aij + β * bij
      static void addEquals​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Performs the following operation:

      a = a + b
      aij = aij + bij
      static void changeSign​(org.ejml.data.FMatrixD1 a)
      Changes the sign of every element in the matrix.

      aij = -aij
      static <T extends org.ejml.data.FMatrixD1>
      T
      changeSign​(T input, T output)
      Changes the sign of every element in the matrix.

      outputij = -inputij
      static org.ejml.data.FMatrixRMaj[] columnsToVector​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj[] v)
      Converts the columns in a matrix into a set of vectors.
      static void concatColumns​(org.ejml.data.FMatrixRMaj a, org.ejml.data.FMatrixRMaj b, org.ejml.data.FMatrixRMaj output)
      output = [a , b]
      static org.ejml.data.FMatrixRMaj concatColumnsMulti​(org.ejml.data.FMatrixRMaj... m)
      Concatinates all the matrices together along their columns.
      static void concatRows​(org.ejml.data.FMatrixRMaj a, org.ejml.data.FMatrixRMaj b, org.ejml.data.FMatrixRMaj output)
      output = [a ; b]
      static org.ejml.data.FMatrixRMaj concatRowsMulti​(org.ejml.data.FMatrixRMaj... m)
      Concatinates all the matrices together along their columns.
      static int countTrue​(org.ejml.data.BMatrixRMaj A)
      Counts the number of elements in A which are true
      static float det​(org.ejml.data.FMatrixRMaj mat)
      Returns the determinant of the matrix.
      static org.ejml.data.FMatrixRMaj diag​(float... diagEl)
      Creates a new square matrix whose diagonal elements are specified by diagEl and all the other elements are zero.

      aij = 0 if i ≤ j
      aij = diag[i] if i = j
      static org.ejml.data.FMatrixRMaj diag​(org.ejml.data.FMatrixRMaj ret, int width, float... diagEl)  
      static org.ejml.data.FMatrixRMaj diagR​(int numRows, int numCols, float... diagEl)
      Creates a new rectangular matrix whose diagonal elements are specified by diagEl and all the other elements are zero.

      aij = 0 if i ≤ j
      aij = diag[i] if i = j
      static void divide​(float alpha, org.ejml.data.FMatrixD1 a)
      Performs an in-place element by element scalar division with the scalar on top.

      aij = α/aij
      static void divide​(float alpha, org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Performs an element by element scalar division with the scalar on top.

      bij = α/aij
      static void divide​(org.ejml.data.FMatrixD1 a, float alpha)
      Performs an in-place element by element scalar division with the scalar on bottom.

      aij = aij
      static void divide​(org.ejml.data.FMatrixD1 a, float alpha, org.ejml.data.FMatrixD1 b)
      Performs an element by element scalar division with the scalar on botton.

      bij = aij
      static void divideCols​(org.ejml.data.FMatrixRMaj A, float[] values)
      Divides every element in column i by value[i].
      static void divideRows​(float[] values, org.ejml.data.FMatrixRMaj A)
      Divides every element in row i by value[i].
      static void divideRowsCols​(float[] diagA, int offsetA, org.ejml.data.FMatrixRMaj B, float[] diagC, int offsetC)
      Equivalent to multiplying a matrix B by the inverse of two diagonal matrices.
      static float dot​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Computes the dot product or inner product between two vectors.
      static void elementDiv​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Performs the an element by element division operation:

      aij = aij / bij
      static void elementDiv​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the an element by element division operation:

      cij = aij / bij
      static void elementExp​(org.ejml.data.FMatrixD1 A, org.ejml.data.FMatrixD1 C)
      Element-wise exp operation
      cij = (float)Math.log(aij)
      static org.ejml.data.BMatrixRMaj elementLessThan​(org.ejml.data.FMatrixRMaj A, float value, org.ejml.data.BMatrixRMaj output)
      Applies the > operator to each element in A.
      static org.ejml.data.BMatrixRMaj elementLessThan​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj B, org.ejml.data.BMatrixRMaj output)
      Applies the < operator to each element in A.
      static org.ejml.data.BMatrixRMaj elementLessThanOrEqual​(org.ejml.data.FMatrixRMaj A, float value, org.ejml.data.BMatrixRMaj output)
      Applies the ≥ operator to each element in A.
      static org.ejml.data.BMatrixRMaj elementLessThanOrEqual​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj B, org.ejml.data.BMatrixRMaj output)
      Applies the A ≤ B operator to each element.
      static void elementLog​(org.ejml.data.FMatrixD1 A, org.ejml.data.FMatrixD1 C)
      Element-wise log operation
      cij = (float)Math.log(aij)
      static float elementMax​(org.ejml.data.FMatrixD1 a)
      Returns the value of the element in the matrix that has the largest value.

      Max{ aij } for all i and j
      static float elementMaxAbs​(org.ejml.data.FMatrixD1 a)
      Returns the absolute value of the element in the matrix that has the largest absolute value.

      Max{ |aij| } for all i and j
      static float elementMin​(org.ejml.data.FMatrixD1 a)
      Returns the value of the element in the matrix that has the minimum value.

      Min{ aij } for all i and j
      static float elementMinAbs​(org.ejml.data.FMatrixD1 a)
      Returns the absolute value of the element in the matrix that has the smallest absolute value.

      Min{ |aij| } for all i and j
      static org.ejml.data.BMatrixRMaj elementMoreThan​(org.ejml.data.FMatrixRMaj A, float value, org.ejml.data.BMatrixRMaj output)
      Applies the > operator to each element in A.
      static org.ejml.data.BMatrixRMaj elementMoreThanOrEqual​(org.ejml.data.FMatrixRMaj A, float value, org.ejml.data.BMatrixRMaj output)
      Applies the ≥ operator to each element in A.
      static void elementMult​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Performs the an element by element multiplication operation:

      aij = aij * bij
      static void elementMult​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the an element by element multiplication operation:

      cij = aij * bij
      static void elementPower​(float a, org.ejml.data.FMatrixD1 B, org.ejml.data.FMatrixD1 C)
      Element-wise power operation
      cij = a ^ bij
      static void elementPower​(org.ejml.data.FMatrixD1 A, float b, org.ejml.data.FMatrixD1 C)
      Element-wise power operation
      cij = aij ^ b
      static void elementPower​(org.ejml.data.FMatrixD1 A, org.ejml.data.FMatrixD1 B, org.ejml.data.FMatrixD1 C)
      Element-wise power operation
      cij = aij ^ bij
      static org.ejml.data.FMatrixRMaj elements​(org.ejml.data.FMatrixRMaj A, org.ejml.data.BMatrixRMaj marked, org.ejml.data.FMatrixRMaj output)
      Returns a row matrix which contains all the elements in A which are flagged as true in 'marked'
      static float elementSum​(org.ejml.data.FMatrixD1 mat)
      Computes the sum of all the elements in the matrix:

      sum(i=1:m , j=1:n ; aij)
      static float elementSumAbs​(org.ejml.data.FMatrixD1 mat)
      Computes the sum of the absolute value all the elements in the matrix:

      sum(i=1:m , j=1:n ; |aij|)
      static void extract​(org.ejml.data.FMatrix src, int srcY0, int srcY1, int srcX0, int srcX1, org.ejml.data.FMatrix dst)
      Extract where the destination is reshaped to match the extracted region
      static void extract​(org.ejml.data.FMatrix src, int srcY0, int srcY1, int srcX0, int srcX1, org.ejml.data.FMatrix dst, int dstY0, int dstX0)
      Extracts a submatrix from 'src' and inserts it in a submatrix in 'dst'.
      static void extract​(org.ejml.data.FMatrix src, int srcY0, int srcX0, org.ejml.data.FMatrix dst)
      Extracts a submatrix from 'src' and inserts it in a submatrix in 'dst'.
      static void extract​(org.ejml.data.FMatrixRMaj src, int[] rows, int rowsSize, int[] cols, int colsSize, org.ejml.data.FMatrixRMaj dst)
      Extracts out a matrix from source given a sub matrix with arbitrary rows and columns specified in two array lists
      static void extract​(org.ejml.data.FMatrixRMaj src, int[] indexes, int length, org.ejml.data.FMatrixRMaj dst)
      Extracts the elements from the source matrix by their 1D index.
      static org.ejml.data.FMatrixRMaj extract​(org.ejml.data.FMatrixRMaj src, int srcY0, int srcY1, int srcX0, int srcX1)
      Creates a new matrix which is the specified submatrix of 'src'
      static org.ejml.data.FMatrixRMaj extractColumn​(org.ejml.data.FMatrixRMaj a, int column, org.ejml.data.FMatrixRMaj out)
      Extracts the column from a matrix.
      static void extractDiag​(org.ejml.data.FMatrixRMaj src, org.ejml.data.FMatrixRMaj dst)
      Extracts the diagonal elements 'src' write it to the 'dst' vector.
      static org.ejml.data.FMatrixRMaj extractRow​(org.ejml.data.FMatrixRMaj a, int row, org.ejml.data.FMatrixRMaj out)
      Extracts the row from a matrix.
      static void fill​(org.ejml.data.FMatrixD1 a, float value)
      Sets every element in the matrix to the specified value.

      aij = value
      static org.ejml.data.FMatrixRMaj identity​(int width)
      Creates an identity matrix of the specified size.

      aij = 0 if i ≠ j
      aij = 1 if i = j
      static org.ejml.data.FMatrixRMaj identity​(int numRows, int numCols)
      Creates a rectangular matrix which is zero except along the diagonals.
      static void insert​(org.ejml.data.FMatrixRMaj src, org.ejml.data.FMatrixRMaj dst, int[] rows, int rowsSize, int[] cols, int colsSize)
      Inserts into the specified elements of dst the source matrix.
      static void insert​(org.ejml.data.FMatrix src, org.ejml.data.FMatrix dest, int destY0, int destX0)
      Inserts matrix 'src' into matrix 'dest' with the (0,0) of src at (row,col) in dest.
      static boolean invert​(org.ejml.data.FMatrixRMaj mat)
      Performs a matrix inversion operation on the specified matrix and stores the results in the same matrix.

      a = a-1
      static boolean invert​(org.ejml.data.FMatrixRMaj mat, org.ejml.data.FMatrixRMaj result)
      Performs a matrix inversion operation that does not modify the original and stores the results in another matrix.
      static boolean invertSPD​(org.ejml.data.FMatrixRMaj mat, org.ejml.data.FMatrixRMaj result)
      Matrix inverse for symmetric positive definite matrices.
      static void kron​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj B, org.ejml.data.FMatrixRMaj C)
      The Kronecker product of two matrices is defined as:
      Cij = aijB
      where Cij is a sub matrix inside of C ∈ ℜ m*k × n*l, A ∈ ℜ m × n, and B ∈ ℜ k × l.
      static org.ejml.data.FMatrixRMaj maxCols​(org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Finds the element with the minimum value along column in the input matrix and returns the results in a vector:

      bj = min(i=1:m ; aij)
      static org.ejml.data.FMatrixRMaj maxRows​(org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Finds the element with the maximum value along each row in the input matrix and returns the results in a vector:

      bj = max(i=1:n ; aji)
      static org.ejml.data.FMatrixRMaj minCols​(org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Finds the element with the minimum value along column in the input matrix and returns the results in a vector:

      bj = min(i=1:m ; aij)
      static org.ejml.data.FMatrixRMaj minRows​(org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Finds the element with the minimum value along each row in the input matrix and returns the results in a vector:

      bj = min(i=1:n ; aji)
      static void mult​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = α * a * b

      cij = α ∑k=1:n { * aik * bkj}
      static void mult​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = a * b

      cij = ∑k=1:n { aik * bkj}
      static void multAdd​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + α * a * b
      cij = cij + α * ∑k=1:n { aik * bkj}
      static void multAdd​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + a * b
      cij = cij + ∑k=1:n { aik * bkj}
      static void multAddTransA​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + α * aT * b
      cij =cij + α * ∑k=1:n { aki * bkj}
      static void multAddTransA​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + aT * b
      cij = cij + ∑k=1:n { aki * bkj}
      static void multAddTransAB​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + α * aT * bT
      cij = cij + α * ∑k=1:n { aki * bjk}
      static void multAddTransAB​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + aT * bT
      cij = cij + ∑k=1:n { aki * bjk}
      static void multAddTransB​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + α * a * bT
      cij = cij + α * ∑k=1:n { aik * bjk}
      static void multAddTransB​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = c + a * bT
      cij = cij + ∑k=1:n { aik * bjk}
      static void multCols​(org.ejml.data.FMatrixRMaj A, float[] values)
      Multiplies every element in column i by value[i].
      static void multInner​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row c)
      Computes the matrix multiplication inner product:

      c = aT * a

      cij = ∑k=1:n { aki * akj}
      static void multOuter​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row c)
      Computes the matrix multiplication outer product:

      c = a * aT

      cij = ∑k=1:m { aik * ajk}
      static void multRows​(float[] values, org.ejml.data.FMatrixRMaj A)
      Multiplies every element in row i by value[i].
      static void multTransA​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = α * aT * b

      cij = α ∑k=1:n { aki * bkj}
      static void multTransA​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = aT * b

      cij = ∑k=1:n { aki * bkj}
      static void multTransAB​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = α * aT * bT
      cij = α ∑k=1:n { aki * bjk}
      static void multTransAB​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = aT * bT
      cij = ∑k=1:n { aki * bjk}
      static void multTransB​(float alpha, org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = α * a * bT
      cij = α ∑k=1:n { aik * bjk}
      static void multTransB​(org.ejml.data.FMatrix1Row a, org.ejml.data.FMatrix1Row b, org.ejml.data.FMatrix1Row c)
      Performs the following operation:

      c = a * bT
      cij = ∑k=1:n { aik * bjk}
      static org.ejml.data.FMatrixRMaj permuteRowInv​(int[] pinv, org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Applies the row permutation specified by the vector to the input matrix and save the results in the output matrix.
      static void pinv​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj invA)
      Computes the Moore-Penrose pseudo-inverse:

      pinv(A) = (ATA)-1 AT
      or
      pinv(A) = AT(AAT)-1
      static void removeColumns​(org.ejml.data.FMatrixRMaj A, int col0, int col1)
      Removes columns from the matrix.
      static org.ejml.data.FMatrixRMaj[] rowsToVector​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj[] v)
      Converts the rows in a matrix into a set of vectors.
      static org.ejml.data.FMatrixRMaj rref​(org.ejml.data.FMatrixRMaj A, int numUnknowns, org.ejml.data.FMatrixRMaj reduced)
      Puts the augmented system matrix into reduced row echelon form (RREF) using Gauss-Jordan elimination with row (partial) pivots.
      static void scale​(float alpha, org.ejml.data.FMatrixD1 a)
      Performs an in-place element by element scalar multiplication.

      aij = α*aij
      static void scale​(float alpha, org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Performs an element by element scalar multiplication.

      bij = α*aij
      static void scaleCol​(float alpha, org.ejml.data.FMatrixRMaj A, int col)
      In-place scaling of a column in A
      static void scaleRow​(float alpha, org.ejml.data.FMatrixRMaj A, int row)
      In-place scaling of a row in A
      static void setIdentity​(org.ejml.data.FMatrix1Row mat)
      Sets all the diagonal elements equal to one and everything else equal to zero.
      static boolean solve​(org.ejml.data.FMatrixRMaj a, org.ejml.data.FMatrixRMaj b, org.ejml.data.FMatrixRMaj x)
      Solves for x in the following equation:

      A*x = b
      static boolean solveSPD​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj b, org.ejml.data.FMatrixRMaj x)
      Linear solver for systems which are symmetric positive definite.
      A*x = b
      static void subtract​(float val, org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 c)
      Performs matrix scalar subtraction:

      c = val - a
      cij = val - aij
      static void subtract​(org.ejml.data.FMatrixD1 a, float val, org.ejml.data.FMatrixD1 c)
      Performs matrix scalar subtraction:

      c = a - val
      cij = aij - val
      static void subtract​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b, org.ejml.data.FMatrixD1 c)
      Performs the following subtraction operation:

      c = a - b
      cij = aij - bij
      static void subtractEquals​(org.ejml.data.FMatrixD1 a, org.ejml.data.FMatrixD1 b)
      Performs the following subtraction operation:

      a = a - b
      aij = aij - bij
      static org.ejml.data.FMatrixRMaj sumCols​(org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Computes the sum of each column in the input matrix and returns the results in a vector:

      bj = sum(i=1:m ; aij)
      static org.ejml.data.FMatrixRMaj sumRows​(org.ejml.data.FMatrixRMaj input, org.ejml.data.FMatrixRMaj output)
      Computes the sum of each row in the input matrix and returns the results in a vector:

      bj = sum(i=1:n ; aji)
      static void symmLowerToFull​(org.ejml.data.FMatrixRMaj A)
      Given a symmetric matrix which is represented by a lower triangular matrix convert it back into a full symmetric matrix.
      static void symmUpperToFull​(org.ejml.data.FMatrixRMaj A)
      Given a symmetric matrix which is represented by a lower triangular matrix convert it back into a full symmetric matrix.
      static float trace​(org.ejml.data.FMatrix1Row a)
      This computes the trace of the matrix:

      trace = ∑i=1:n { aii }
      where n = min(numRows,numCols)
      static void transpose​(org.ejml.data.FMatrixRMaj mat)
      Performs an "in-place" transpose.
      static org.ejml.data.FMatrixRMaj transpose​(org.ejml.data.FMatrixRMaj A, org.ejml.data.FMatrixRMaj A_tran)
      Transposes matrix 'a' and stores the results in 'b':

      bij = aji
      where 'b' is the transpose of 'a'.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CommonOps_FDRM

        public CommonOps_FDRM()
    • Method Detail

      • mult

        public static void mult​(org.ejml.data.FMatrix1Row a,
                                org.ejml.data.FMatrix1Row b,
                                org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = a * b

        cij = ∑k=1:n { aik * bkj}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • mult

        public static void mult​(float alpha,
                                org.ejml.data.FMatrix1Row a,
                                org.ejml.data.FMatrix1Row b,
                                org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = α * a * b

        cij = α ∑k=1:n { * aik * bkj}

        Parameters:
        alpha - Scaling factor.
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multTransA

        public static void multTransA​(org.ejml.data.FMatrix1Row a,
                                      org.ejml.data.FMatrix1Row b,
                                      org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = aT * b

        cij = ∑k=1:n { aki * bkj}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multTransA

        public static void multTransA​(float alpha,
                                      org.ejml.data.FMatrix1Row a,
                                      org.ejml.data.FMatrix1Row b,
                                      org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = α * aT * b

        cij = α ∑k=1:n { aki * bkj}

        Parameters:
        alpha - Scaling factor.
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multTransB

        public static void multTransB​(org.ejml.data.FMatrix1Row a,
                                      org.ejml.data.FMatrix1Row b,
                                      org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = a * bT
        cij = ∑k=1:n { aik * bjk}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multTransB

        public static void multTransB​(float alpha,
                                      org.ejml.data.FMatrix1Row a,
                                      org.ejml.data.FMatrix1Row b,
                                      org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = α * a * bT
        cij = α ∑k=1:n { aik * bjk}

        Parameters:
        alpha - Scaling factor.
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multTransAB

        public static void multTransAB​(org.ejml.data.FMatrix1Row a,
                                       org.ejml.data.FMatrix1Row b,
                                       org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = aT * bT
        cij = ∑k=1:n { aki * bjk}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multTransAB

        public static void multTransAB​(float alpha,
                                       org.ejml.data.FMatrix1Row a,
                                       org.ejml.data.FMatrix1Row b,
                                       org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = α * aT * bT
        cij = α ∑k=1:n { aki * bjk}

        Parameters:
        alpha - Scaling factor.
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • dot

        public static float dot​(org.ejml.data.FMatrixD1 a,
                                org.ejml.data.FMatrixD1 b)

        Computes the dot product or inner product between two vectors. If the two vectors are columns vectors then it is defined as:
        dot(a,b) = a<sup>T</sup> * b
        If the vectors are column or row or both is ignored by this function.

        Parameters:
        a - Vector
        b - Vector
        Returns:
        Dot product of the two vectors
      • multInner

        public static void multInner​(org.ejml.data.FMatrix1Row a,
                                     org.ejml.data.FMatrix1Row c)

        Computes the matrix multiplication inner product:

        c = aT * a

        cij = ∑k=1:n { aki * akj}

        Is faster than using a generic matrix multiplication by taking advantage of symmetry. For vectors there is an even faster option, see VectorVectorMult_FDRM.innerProd(FMatrixD1, FMatrixD1)

        Parameters:
        a - The matrix being multiplied. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multOuter

        public static void multOuter​(org.ejml.data.FMatrix1Row a,
                                     org.ejml.data.FMatrix1Row c)

        Computes the matrix multiplication outer product:

        c = a * aT

        cij = ∑k=1:m { aik * ajk}

        Is faster than using a generic matrix multiplication by taking advantage of symmetry.

        Parameters:
        a - The matrix being multiplied. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAdd

        public static void multAdd​(org.ejml.data.FMatrix1Row a,
                                   org.ejml.data.FMatrix1Row b,
                                   org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + a * b
        cij = cij + ∑k=1:n { aik * bkj}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAdd

        public static void multAdd​(float alpha,
                                   org.ejml.data.FMatrix1Row a,
                                   org.ejml.data.FMatrix1Row b,
                                   org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + α * a * b
        cij = cij + α * ∑k=1:n { aik * bkj}

        Parameters:
        alpha - scaling factor.
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAddTransA

        public static void multAddTransA​(org.ejml.data.FMatrix1Row a,
                                         org.ejml.data.FMatrix1Row b,
                                         org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + aT * b
        cij = cij + ∑k=1:n { aki * bkj}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAddTransA

        public static void multAddTransA​(float alpha,
                                         org.ejml.data.FMatrix1Row a,
                                         org.ejml.data.FMatrix1Row b,
                                         org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + α * aT * b
        cij =cij + α * ∑k=1:n { aki * bkj}

        Parameters:
        alpha - scaling factor
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAddTransB

        public static void multAddTransB​(org.ejml.data.FMatrix1Row a,
                                         org.ejml.data.FMatrix1Row b,
                                         org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + a * bT
        cij = cij + ∑k=1:n { aik * bjk}

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAddTransB

        public static void multAddTransB​(float alpha,
                                         org.ejml.data.FMatrix1Row a,
                                         org.ejml.data.FMatrix1Row b,
                                         org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + α * a * bT
        cij = cij + α * ∑k=1:n { aik * bjk}

        Parameters:
        alpha - Scaling factor.
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • multAddTransAB

        public static void multAddTransAB​(org.ejml.data.FMatrix1Row a,
                                          org.ejml.data.FMatrix1Row b,
                                          org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + aT * bT
        cij = cij + ∑k=1:n { aki * bjk}

        Parameters:
        a - The left matrix in the multiplication operation. Not Modified.
        b - The right matrix in the multiplication operation. Not Modified.
        c - Where the results of the operation are stored. Modified.
      • multAddTransAB

        public static void multAddTransAB​(float alpha,
                                          org.ejml.data.FMatrix1Row a,
                                          org.ejml.data.FMatrix1Row b,
                                          org.ejml.data.FMatrix1Row c)

        Performs the following operation:

        c = c + α * aT * bT
        cij = cij + α * ∑k=1:n { aki * bjk}

        Parameters:
        alpha - Scaling factor.
        a - The left matrix in the multiplication operation. Not Modified.
        b - The right matrix in the multiplication operation. Not Modified.
        c - Where the results of the operation are stored. Modified.
      • solve

        public static boolean solve​(org.ejml.data.FMatrixRMaj a,
                                    org.ejml.data.FMatrixRMaj b,
                                    org.ejml.data.FMatrixRMaj x)

        Solves for x in the following equation:

        A*x = b

        If the system could not be solved then false is returned. If it returns true that just means the algorithm finished operating, but the results could still be bad because 'A' is singular or nearly singular.

        If repeat calls to solve are being made then one should consider using LinearSolverFactory_FDRM instead.

        It is ok for 'b' and 'x' to be the same matrix.

        Parameters:
        a - A matrix that is m by n. Not modified.
        b - A matrix that is n by k. Not modified.
        x - A matrix that is m by k. Modified.
        Returns:
        true if it could invert the matrix false if it could not.
      • solveSPD

        public static boolean solveSPD​(org.ejml.data.FMatrixRMaj A,
                                       org.ejml.data.FMatrixRMaj b,
                                       org.ejml.data.FMatrixRMaj x)

        Linear solver for systems which are symmetric positive definite.
        A*x = b

        Parameters:
        A - A matrix that is n by n and SPD. Not modified.
        b - A matrix that is n by k. Not modified.
        x - A matrix that is n by k. Modified.
        Returns:
        true if it could invert the matrix false if it could not.
        See Also:
        UnrolledCholesky_FDRM, LinearSolverFactory_FDRM
      • transpose

        public static void transpose​(org.ejml.data.FMatrixRMaj mat)

        Performs an "in-place" transpose.

        For square matrices the transpose is truly in-place and does not require additional memory. For non-square matrices, internally a temporary matrix is declared and transpose(FMatrixRMaj, FMatrixRMaj) is invoked.

        Parameters:
        mat - The matrix that is to be transposed. Modified.
      • transpose

        public static org.ejml.data.FMatrixRMaj transpose​(org.ejml.data.FMatrixRMaj A,
                                                          org.ejml.data.FMatrixRMaj A_tran)

        Transposes matrix 'a' and stores the results in 'b':

        bij = aji
        where 'b' is the transpose of 'a'.

        Parameters:
        A - The original matrix. Not modified.
        A_tran - Where the transpose is stored. If null a new matrix is created. Modified.
        Returns:
        The transposed matrix.
      • trace

        public static float trace​(org.ejml.data.FMatrix1Row a)

        This computes the trace of the matrix:

        trace = ∑i=1:n { aii }
        where n = min(numRows,numCols)

        Parameters:
        a - A square matrix. Not modified.
      • det

        public static float det​(org.ejml.data.FMatrixRMaj mat)
        Returns the determinant of the matrix. If the inverse of the matrix is also needed, then using LUDecomposition_F32 directly (or any similar algorithm) can be more efficient.
        Parameters:
        mat - The matrix whose determinant is to be computed. Not modified.
        Returns:
        The determinant.
      • invert

        public static boolean invert​(org.ejml.data.FMatrixRMaj mat)

        Performs a matrix inversion operation on the specified matrix and stores the results in the same matrix.

        a = a-1

        If the algorithm could not invert the matrix then false is returned. If it returns true that just means the algorithm finished. The results could still be bad because the matrix is singular or nearly singular.

        Parameters:
        mat - The matrix that is to be inverted. Results are stored here. Modified.
        Returns:
        true if it could invert the matrix false if it could not.
      • invert

        public static boolean invert​(org.ejml.data.FMatrixRMaj mat,
                                     org.ejml.data.FMatrixRMaj result)

        Performs a matrix inversion operation that does not modify the original and stores the results in another matrix. The two matrices must have the same dimension.

        b = a-1

        If the algorithm could not invert the matrix then false is returned. If it returns true that just means the algorithm finished. The results could still be bad because the matrix is singular or nearly singular.

        For medium to large matrices there might be a slight performance boost to using LinearSolverFactory_FDRM instead.

        Parameters:
        mat - The matrix that is to be inverted. Not modified.
        result - Where the inverse matrix is stored. Modified.
        Returns:
        true if it could invert the matrix false if it could not.
      • invertSPD

        public static boolean invertSPD​(org.ejml.data.FMatrixRMaj mat,
                                        org.ejml.data.FMatrixRMaj result)
        Matrix inverse for symmetric positive definite matrices. For small matrices an unrolled cholesky is used. Otherwise a standard decomposition.
        Parameters:
        mat - (Input) SPD matrix
        result - (Output) Inverted matrix.
        Returns:
        true if it could invert the matrix false if it could not.
        See Also:
        UnrolledCholesky_FDRM, LinearSolverFactory_FDRM.chol(int)
      • pinv

        public static void pinv​(org.ejml.data.FMatrixRMaj A,
                                org.ejml.data.FMatrixRMaj invA)

        Computes the Moore-Penrose pseudo-inverse:

        pinv(A) = (ATA)-1 AT
        or
        pinv(A) = AT(AAT)-1

        Internally it uses SolvePseudoInverseSvd_FDRM to compute the inverse. For performance reasons, this should only be used when a matrix is singular or nearly singular.

        Parameters:
        A - A m by n Matrix. Not modified.
        invA - Where the computed pseudo inverse is stored. n by m. Modified.
      • columnsToVector

        public static org.ejml.data.FMatrixRMaj[] columnsToVector​(org.ejml.data.FMatrixRMaj A,
                                                                  org.ejml.data.FMatrixRMaj[] v)
        Converts the columns in a matrix into a set of vectors.
        Parameters:
        A - Matrix. Not modified.
        v -
        Returns:
        An array of vectors.
      • rowsToVector

        public static org.ejml.data.FMatrixRMaj[] rowsToVector​(org.ejml.data.FMatrixRMaj A,
                                                               org.ejml.data.FMatrixRMaj[] v)
        Converts the rows in a matrix into a set of vectors.
        Parameters:
        A - Matrix. Not modified.
        v -
        Returns:
        An array of vectors.
      • setIdentity

        public static void setIdentity​(org.ejml.data.FMatrix1Row mat)
        Sets all the diagonal elements equal to one and everything else equal to zero. If this is a square matrix then it will be an identity matrix.
        Parameters:
        mat - A square matrix.
        See Also:
        identity(int)
      • identity

        public static org.ejml.data.FMatrixRMaj identity​(int width)

        Creates an identity matrix of the specified size.

        aij = 0 if i ≠ j
        aij = 1 if i = j

        Parameters:
        width - The width and height of the identity matrix.
        Returns:
        A new instance of an identity matrix.
      • identity

        public static org.ejml.data.FMatrixRMaj identity​(int numRows,
                                                         int numCols)
        Creates a rectangular matrix which is zero except along the diagonals.
        Parameters:
        numRows - Number of rows in the matrix.
        numCols - NUmber of columns in the matrix.
        Returns:
        A matrix with diagonal elements equal to one.
      • diag

        public static org.ejml.data.FMatrixRMaj diag​(float... diagEl)

        Creates a new square matrix whose diagonal elements are specified by diagEl and all the other elements are zero.

        aij = 0 if i ≤ j
        aij = diag[i] if i = j

        Parameters:
        diagEl - Contains the values of the diagonal elements of the resulting matrix.
        Returns:
        A new matrix.
        See Also:
        diagR(int, int, float...)
      • diag

        public static org.ejml.data.FMatrixRMaj diag​(org.ejml.data.FMatrixRMaj ret,
                                                     int width,
                                                     float... diagEl)
        See Also:
        diag(float...)
      • diagR

        public static org.ejml.data.FMatrixRMaj diagR​(int numRows,
                                                      int numCols,
                                                      float... diagEl)

        Creates a new rectangular matrix whose diagonal elements are specified by diagEl and all the other elements are zero.

        aij = 0 if i ≤ j
        aij = diag[i] if i = j

        Parameters:
        numRows - Number of rows in the matrix.
        numCols - Number of columns in the matrix.
        diagEl - Contains the values of the diagonal elements of the resulting matrix.
        Returns:
        A new matrix.
        See Also:
        diag(float...)
      • kron

        public static void kron​(org.ejml.data.FMatrixRMaj A,
                                org.ejml.data.FMatrixRMaj B,
                                org.ejml.data.FMatrixRMaj C)

        The Kronecker product of two matrices is defined as:
        Cij = aijB
        where Cij is a sub matrix inside of C ∈ ℜ m*k × n*l, A ∈ ℜ m × n, and B ∈ ℜ k × l.

        Parameters:
        A - The left matrix in the operation. Not modified.
        B - The right matrix in the operation. Not modified.
        C - Where the results of the operation are stored. Modified.
      • extract

        public static void extract​(org.ejml.data.FMatrix src,
                                   int srcY0,
                                   int srcY1,
                                   int srcX0,
                                   int srcX1,
                                   org.ejml.data.FMatrix dst,
                                   int dstY0,
                                   int dstX0)

        Extracts a submatrix from 'src' and inserts it in a submatrix in 'dst'.

        si-y0 , j-x0 = oij for all y0 ≤ i < y1 and x0 ≤ j < x1

        where 'sij' is an element in the submatrix and 'oij' is an element in the original matrix.

        Parameters:
        src - The original matrix which is to be copied. Not modified.
        srcX0 - Start column.
        srcX1 - Stop column+1.
        srcY0 - Start row.
        srcY1 - Stop row+1.
        dst - Where the submatrix are stored. Modified.
        dstY0 - Start row in dst.
        dstX0 - start column in dst.
      • extract

        public static void extract​(org.ejml.data.FMatrix src,
                                   int srcY0,
                                   int srcY1,
                                   int srcX0,
                                   int srcX1,
                                   org.ejml.data.FMatrix dst)
        Extract where the destination is reshaped to match the extracted region
        Parameters:
        src - The original matrix which is to be copied. Not modified.
        srcX0 - Start column.
        srcX1 - Stop column+1.
        srcY0 - Start row.
        srcY1 - Stop row+1.
        dst - Where the submatrix are stored. Modified.
      • extract

        public static void extract​(org.ejml.data.FMatrix src,
                                   int srcY0,
                                   int srcX0,
                                   org.ejml.data.FMatrix dst)

        Extracts a submatrix from 'src' and inserts it in a submatrix in 'dst'. Uses the shape of dst to determine the size of the matrix extracted.

        Parameters:
        src - The original matrix which is to be copied. Not modified.
        srcY0 - Start row in src.
        srcX0 - Start column in src.
        dst - Where the matrix is extracted into.
      • extract

        public static org.ejml.data.FMatrixRMaj extract​(org.ejml.data.FMatrixRMaj src,
                                                        int srcY0,
                                                        int srcY1,
                                                        int srcX0,
                                                        int srcX1)

        Creates a new matrix which is the specified submatrix of 'src'

        si-y0 , j-x0 = oij for all y0 ≤ i < y1 and x0 ≤ j < x1

        where 'sij' is an element in the submatrix and 'oij' is an element in the original matrix.

        Parameters:
        src - The original matrix which is to be copied. Not modified.
        srcX0 - Start column.
        srcX1 - Stop column+1.
        srcY0 - Start row.
        srcY1 - Stop row+1.
        Returns:
        Extracted submatrix.
      • extract

        public static void extract​(org.ejml.data.FMatrixRMaj src,
                                   int[] rows,
                                   int rowsSize,
                                   int[] cols,
                                   int colsSize,
                                   org.ejml.data.FMatrixRMaj dst)
        Extracts out a matrix from source given a sub matrix with arbitrary rows and columns specified in two array lists
        Parameters:
        src - Source matrix. Not modified.
        rows - array of row indexes
        rowsSize - maximum element in row array
        cols - array of column indexes
        colsSize - maximum element in column array
        dst - output matrix. Must be correct shape.
      • extract

        public static void extract​(org.ejml.data.FMatrixRMaj src,
                                   int[] indexes,
                                   int length,
                                   org.ejml.data.FMatrixRMaj dst)
        Extracts the elements from the source matrix by their 1D index.
        Parameters:
        src - Source matrix. Not modified.
        indexes - array of row indexes
        length - maximum element in row array
        dst - output matrix. Must be a vector of the correct length.
      • insert

        public static void insert​(org.ejml.data.FMatrixRMaj src,
                                  org.ejml.data.FMatrixRMaj dst,
                                  int[] rows,
                                  int rowsSize,
                                  int[] cols,
                                  int colsSize)
        Inserts into the specified elements of dst the source matrix.
         for i in len(rows):
           for j in len(cols):
              dst(rows[i],cols[j]) = src(i,j)
         
        Parameters:
        src - Source matrix. Not modified.
        dst - output matrix. Must be correct shape.
        rows - array of row indexes
        rowsSize - maximum element in row array
        cols - array of column indexes
        colsSize - maximum element in column array
      • extractDiag

        public static void extractDiag​(org.ejml.data.FMatrixRMaj src,
                                       org.ejml.data.FMatrixRMaj dst)

        Extracts the diagonal elements 'src' write it to the 'dst' vector. 'dst' can either be a row or column vector.

        Parameters:
        src - Matrix whose diagonal elements are being extracted. Not modified.
        dst - A vector the results will be written into. Modified.
      • extractRow

        public static org.ejml.data.FMatrixRMaj extractRow​(org.ejml.data.FMatrixRMaj a,
                                                           int row,
                                                           org.ejml.data.FMatrixRMaj out)
        Extracts the row from a matrix.
        Parameters:
        a - Input matrix
        row - Which row is to be extracted
        out - output. Storage for the extracted row. If null then a new vector will be returned.
        Returns:
        The extracted row.
      • extractColumn

        public static org.ejml.data.FMatrixRMaj extractColumn​(org.ejml.data.FMatrixRMaj a,
                                                              int column,
                                                              org.ejml.data.FMatrixRMaj out)
        Extracts the column from a matrix.
        Parameters:
        a - Input matrix
        column - Which column is to be extracted
        out - output. Storage for the extracted column. If null then a new vector will be returned.
        Returns:
        The extracted column.
      • removeColumns

        public static void removeColumns​(org.ejml.data.FMatrixRMaj A,
                                         int col0,
                                         int col1)
        Removes columns from the matrix.
        Parameters:
        A - Matrix. Modified
        col0 - First column
        col1 - Last column, inclusive.
      • insert

        public static void insert​(org.ejml.data.FMatrix src,
                                  org.ejml.data.FMatrix dest,
                                  int destY0,
                                  int destX0)
        Inserts matrix 'src' into matrix 'dest' with the (0,0) of src at (row,col) in dest. This is equivalent to calling extract(src,0,src.numRows,0,src.numCols,dest,destY0,destX0).
        Parameters:
        src - matrix that is being copied into dest. Not modified.
        dest - Where src is being copied into. Modified.
        destY0 - Start row for the copy into dest.
        destX0 - Start column for the copy into dest.
      • elementMax

        public static float elementMax​(org.ejml.data.FMatrixD1 a)

        Returns the value of the element in the matrix that has the largest value.

        Max{ aij } for all i and j

        Parameters:
        a - A matrix. Not modified.
        Returns:
        The max element value of the matrix.
      • elementMaxAbs

        public static float elementMaxAbs​(org.ejml.data.FMatrixD1 a)

        Returns the absolute value of the element in the matrix that has the largest absolute value.

        Max{ |aij| } for all i and j

        Parameters:
        a - A matrix. Not modified.
        Returns:
        The max abs element value of the matrix.
      • elementMin

        public static float elementMin​(org.ejml.data.FMatrixD1 a)

        Returns the value of the element in the matrix that has the minimum value.

        Min{ aij } for all i and j

        Parameters:
        a - A matrix. Not modified.
        Returns:
        The value of element in the matrix with the minimum value.
      • elementMinAbs

        public static float elementMinAbs​(org.ejml.data.FMatrixD1 a)

        Returns the absolute value of the element in the matrix that has the smallest absolute value.

        Min{ |aij| } for all i and j

        Parameters:
        a - A matrix. Not modified.
        Returns:
        The max element value of the matrix.
      • elementMult

        public static void elementMult​(org.ejml.data.FMatrixD1 a,
                                       org.ejml.data.FMatrixD1 b)

        Performs the an element by element multiplication operation:

        aij = aij * bij

        Parameters:
        a - The left matrix in the multiplication operation. Modified.
        b - The right matrix in the multiplication operation. Not modified.
      • elementMult

        public static void elementMult​(org.ejml.data.FMatrixD1 a,
                                       org.ejml.data.FMatrixD1 b,
                                       org.ejml.data.FMatrixD1 c)

        Performs the an element by element multiplication operation:

        cij = aij * bij

        Parameters:
        a - The left matrix in the multiplication operation. Not modified.
        b - The right matrix in the multiplication operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • elementDiv

        public static void elementDiv​(org.ejml.data.FMatrixD1 a,
                                      org.ejml.data.FMatrixD1 b)

        Performs the an element by element division operation:

        aij = aij / bij

        Parameters:
        a - The left matrix in the division operation. Modified.
        b - The right matrix in the division operation. Not modified.
      • elementDiv

        public static void elementDiv​(org.ejml.data.FMatrixD1 a,
                                      org.ejml.data.FMatrixD1 b,
                                      org.ejml.data.FMatrixD1 c)

        Performs the an element by element division operation:

        cij = aij / bij

        Parameters:
        a - The left matrix in the division operation. Not modified.
        b - The right matrix in the division operation. Not modified.
        c - Where the results of the operation are stored. Modified.
      • elementSum

        public static float elementSum​(org.ejml.data.FMatrixD1 mat)

        Computes the sum of all the elements in the matrix:

        sum(i=1:m , j=1:n ; aij)

        Parameters:
        mat - An m by n matrix. Not modified.
        Returns:
        The sum of the elements.
      • elementSumAbs

        public static float elementSumAbs​(org.ejml.data.FMatrixD1 mat)

        Computes the sum of the absolute value all the elements in the matrix:

        sum(i=1:m , j=1:n ; |aij|)

        Parameters:
        mat - An m by n matrix. Not modified.
        Returns:
        The sum of the absolute value of each element.
      • elementPower

        public static void elementPower​(org.ejml.data.FMatrixD1 A,
                                        org.ejml.data.FMatrixD1 B,
                                        org.ejml.data.FMatrixD1 C)

        Element-wise power operation
        cij = aij ^ bij

        Parameters:
        A - left side
        B - right side
        C - output (modified)
      • elementPower

        public static void elementPower​(float a,
                                        org.ejml.data.FMatrixD1 B,
                                        org.ejml.data.FMatrixD1 C)

        Element-wise power operation
        cij = a ^ bij

        Parameters:
        a - left scalar
        B - right side
        C - output (modified)
      • elementPower

        public static void elementPower​(org.ejml.data.FMatrixD1 A,
                                        float b,
                                        org.ejml.data.FMatrixD1 C)

        Element-wise power operation
        cij = aij ^ b

        Parameters:
        A - left side
        b - right scalar
        C - output (modified)
      • elementLog

        public static void elementLog​(org.ejml.data.FMatrixD1 A,
                                      org.ejml.data.FMatrixD1 C)

        Element-wise log operation
        cij = (float)Math.log(aij)

        Parameters:
        A - input
        C - output (modified)
      • elementExp

        public static void elementExp​(org.ejml.data.FMatrixD1 A,
                                      org.ejml.data.FMatrixD1 C)

        Element-wise exp operation
        cij = (float)Math.log(aij)

        Parameters:
        A - input
        C - output (modified)
      • multRows

        public static void multRows​(float[] values,
                                    org.ejml.data.FMatrixRMaj A)
        Multiplies every element in row i by value[i].
        Parameters:
        values - array. Not modified.
        A - Matrix. Modified.
      • divideRows

        public static void divideRows​(float[] values,
                                      org.ejml.data.FMatrixRMaj A)
        Divides every element in row i by value[i].
        Parameters:
        values - array. Not modified.
        A - Matrix. Modified.
      • multCols

        public static void multCols​(org.ejml.data.FMatrixRMaj A,
                                    float[] values)
        Multiplies every element in column i by value[i].
        Parameters:
        A - Matrix. Modified.
        values - array. Not modified.
      • divideCols

        public static void divideCols​(org.ejml.data.FMatrixRMaj A,
                                      float[] values)
        Divides every element in column i by value[i].
        Parameters:
        A - Matrix. Modified.
        values - array. Not modified.
      • divideRowsCols

        public static void divideRowsCols​(float[] diagA,
                                          int offsetA,
                                          org.ejml.data.FMatrixRMaj B,
                                          float[] diagC,
                                          int offsetC)
        Equivalent to multiplying a matrix B by the inverse of two diagonal matrices. B = inv(A)*B*inv(C), where A=diag(a) and C=diag(c).
        Parameters:
        diagA - Array of length offsteA + B.numRows
        offsetA - First index in A
        B - Rectangular matrix
        diagC - Array of length indexC + B.numCols
        offsetC - First index in C
      • sumRows

        public static org.ejml.data.FMatrixRMaj sumRows​(org.ejml.data.FMatrixRMaj input,
                                                        org.ejml.data.FMatrixRMaj output)

        Computes the sum of each row in the input matrix and returns the results in a vector:

        bj = sum(i=1:n ; aji)

        Parameters:
        input - INput matrix whose rows are summed.
        output - Optional storage for output. Reshaped into a column. Modified.
        Returns:
        Vector containing the sum of each row in the input.
      • minRows

        public static org.ejml.data.FMatrixRMaj minRows​(org.ejml.data.FMatrixRMaj input,
                                                        org.ejml.data.FMatrixRMaj output)

        Finds the element with the minimum value along each row in the input matrix and returns the results in a vector:

        bj = min(i=1:n ; aji)

        Parameters:
        input - Input matrix
        output - Optional storage for output. Reshaped into a column. Modified.
        Returns:
        Vector containing the sum of each row in the input.
      • maxRows

        public static org.ejml.data.FMatrixRMaj maxRows​(org.ejml.data.FMatrixRMaj input,
                                                        org.ejml.data.FMatrixRMaj output)

        Finds the element with the maximum value along each row in the input matrix and returns the results in a vector:

        bj = max(i=1:n ; aji)

        Parameters:
        input - Input matrix
        output - Optional storage for output. Reshaped into a column. Modified.
        Returns:
        Vector containing the sum of each row in the input.
      • sumCols

        public static org.ejml.data.FMatrixRMaj sumCols​(org.ejml.data.FMatrixRMaj input,
                                                        org.ejml.data.FMatrixRMaj output)

        Computes the sum of each column in the input matrix and returns the results in a vector:

        bj = sum(i=1:m ; aij)

        Parameters:
        input - Input matrix
        output - Optional storage for output. Reshaped into a row vector. Modified.
        Returns:
        Vector containing the sum of each column
      • minCols

        public static org.ejml.data.FMatrixRMaj minCols​(org.ejml.data.FMatrixRMaj input,
                                                        org.ejml.data.FMatrixRMaj output)

        Finds the element with the minimum value along column in the input matrix and returns the results in a vector:

        bj = min(i=1:m ; aij)

        Parameters:
        input - Input matrix
        output - Optional storage for output. Reshaped into a row vector. Modified.
        Returns:
        Vector containing the minimum of each column
      • maxCols

        public static org.ejml.data.FMatrixRMaj maxCols​(org.ejml.data.FMatrixRMaj input,
                                                        org.ejml.data.FMatrixRMaj output)

        Finds the element with the minimum value along column in the input matrix and returns the results in a vector:

        bj = min(i=1:m ; aij)

        Parameters:
        input - Input matrix
        output - Optional storage for output. Reshaped into a row vector. Modified.
        Returns:
        Vector containing the maximum of each column
      • addEquals

        public static void addEquals​(org.ejml.data.FMatrixD1 a,
                                     org.ejml.data.FMatrixD1 b)

        Performs the following operation:

        a = a + b
        aij = aij + bij

        Parameters:
        a - A Matrix. Modified.
        b - A Matrix. Not modified.
      • addEquals

        public static void addEquals​(org.ejml.data.FMatrixD1 a,
                                     float beta,
                                     org.ejml.data.FMatrixD1 b)

        Performs the following operation:

        a = a + β * b
        aij = aij + β * bij

        Parameters:
        beta - The number that matrix 'b' is multiplied by.
        a - A Matrix. Modified.
        b - A Matrix. Not modified.
      • add

        public static void add​(org.ejml.data.FMatrixD1 a,
                               org.ejml.data.FMatrixD1 b,
                               org.ejml.data.FMatrixD1 c)

        Performs the following operation:

        c = a + b
        cij = aij + bij

        Matrix C can be the same instance as Matrix A and/or B.

        Parameters:
        a - A Matrix. Not modified.
        b - A Matrix. Not modified.
        c - A Matrix where the results are stored. Modified.
      • add

        public static void add​(org.ejml.data.FMatrixD1 a,
                               float beta,
                               org.ejml.data.FMatrixD1 b,
                               org.ejml.data.FMatrixD1 c)

        Performs the following operation:

        c = a + β * b
        cij = aij + β * bij

        Matrix C can be the same instance as Matrix A and/or B.

        Parameters:
        a - A Matrix. Not modified.
        beta - Scaling factor for matrix b.
        b - A Matrix. Not modified.
        c - A Matrix where the results are stored. Modified.
      • add

        public static void add​(float alpha,
                               org.ejml.data.FMatrixD1 a,
                               float beta,
                               org.ejml.data.FMatrixD1 b,
                               org.ejml.data.FMatrixD1 c)

        Performs the following operation:

        c = α * a + β * b
        cij = α * aij + β * bij

        Matrix C can be the same instance as Matrix A and/or B.

        Parameters:
        alpha - A scaling factor for matrix a.
        a - A Matrix. Not modified.
        beta - A scaling factor for matrix b.
        b - A Matrix. Not modified.
        c - A Matrix where the results are stored. Modified.
      • add

        public static void add​(float alpha,
                               org.ejml.data.FMatrixD1 a,
                               org.ejml.data.FMatrixD1 b,
                               org.ejml.data.FMatrixD1 c)

        Performs the following operation:

        c = α * a + b
        cij = α * aij + bij

        Matrix C can be the same instance as Matrix A and/or B.

        Parameters:
        alpha - A scaling factor for matrix a.
        a - A Matrix. Not modified.
        b - A Matrix. Not modified.
        c - A Matrix where the results are stored. Modified.
      • add

        public static void add​(org.ejml.data.FMatrixD1 a,
                               float val)

        Performs an in-place scalar addition:

        a = a + val
        aij = aij + val

        Parameters:
        a - A matrix. Modified.
        val - The value that's added to each element.
      • add

        public static void add​(org.ejml.data.FMatrixD1 a,
                               float val,
                               org.ejml.data.FMatrixD1 c)

        Performs scalar addition:

        c = a + val
        cij = aij + val

        Parameters:
        a - A matrix. Not modified.
        c - A matrix. Modified.
        val - The value that's added to each element.
      • subtract

        public static void subtract​(org.ejml.data.FMatrixD1 a,
                                    float val,
                                    org.ejml.data.FMatrixD1 c)

        Performs matrix scalar subtraction:

        c = a - val
        cij = aij - val

        Parameters:
        a - (input) A matrix. Not modified.
        val - (input) The value that's subtracted to each element.
        c - (Output) A matrix. Modified.
      • subtract

        public static void subtract​(float val,
                                    org.ejml.data.FMatrixD1 a,
                                    org.ejml.data.FMatrixD1 c)

        Performs matrix scalar subtraction:

        c = val - a
        cij = val - aij

        Parameters:
        val - (input) The value that's subtracted to each element.
        a - (input) A matrix. Not modified.
        c - (Output) A matrix. Modified.
      • subtractEquals

        public static void subtractEquals​(org.ejml.data.FMatrixD1 a,
                                          org.ejml.data.FMatrixD1 b)

        Performs the following subtraction operation:

        a = a - b
        aij = aij - bij

        Parameters:
        a - A Matrix. Modified.
        b - A Matrix. Not modified.
      • subtract

        public static void subtract​(org.ejml.data.FMatrixD1 a,
                                    org.ejml.data.FMatrixD1 b,
                                    org.ejml.data.FMatrixD1 c)

        Performs the following subtraction operation:

        c = a - b
        cij = aij - bij

        Matrix C can be the same instance as Matrix A and/or B.

        Parameters:
        a - A Matrix. Not modified.
        b - A Matrix. Not modified.
        c - A Matrix. Modified.
      • scale

        public static void scale​(float alpha,
                                 org.ejml.data.FMatrixD1 a)

        Performs an in-place element by element scalar multiplication.

        aij = α*aij

        Parameters:
        a - The matrix that is to be scaled. Modified.
        alpha - the amount each element is multiplied by.
      • scale

        public static void scale​(float alpha,
                                 org.ejml.data.FMatrixD1 a,
                                 org.ejml.data.FMatrixD1 b)

        Performs an element by element scalar multiplication.

        bij = α*aij

        Parameters:
        alpha - the amount each element is multiplied by.
        a - The matrix that is to be scaled. Not modified.
        b - Where the scaled matrix is stored. Modified.
      • scaleRow

        public static void scaleRow​(float alpha,
                                    org.ejml.data.FMatrixRMaj A,
                                    int row)
        In-place scaling of a row in A
        Parameters:
        alpha - scale factor
        A - matrix
        row - which row in A
      • scaleCol

        public static void scaleCol​(float alpha,
                                    org.ejml.data.FMatrixRMaj A,
                                    int col)
        In-place scaling of a column in A
        Parameters:
        alpha - scale factor
        A - matrix
        col - which row in A
      • divide

        public static void divide​(float alpha,
                                  org.ejml.data.FMatrixD1 a)

        Performs an in-place element by element scalar division with the scalar on top.

        aij = α/aij

        Parameters:
        a - The matrix whose elements are divide the scalar. Modified.
        alpha - top value in division
      • divide

        public static void divide​(org.ejml.data.FMatrixD1 a,
                                  float alpha)

        Performs an in-place element by element scalar division with the scalar on bottom.

        aij = aij

        Parameters:
        a - The matrix whose elements are to be divided. Modified.
        alpha - the amount each element is divided by.
      • divide

        public static void divide​(float alpha,
                                  org.ejml.data.FMatrixD1 a,
                                  org.ejml.data.FMatrixD1 b)

        Performs an element by element scalar division with the scalar on top.

        bij = α/aij

        Parameters:
        alpha - The numerator.
        a - The matrix whose elements are the divisor. Not modified.
        b - Where the results are stored. Modified.
      • divide

        public static void divide​(org.ejml.data.FMatrixD1 a,
                                  float alpha,
                                  org.ejml.data.FMatrixD1 b)

        Performs an element by element scalar division with the scalar on botton.

        bij = aij

        Parameters:
        a - The matrix whose elements are to be divided. Not modified.
        alpha - the amount each element is divided by.
        b - Where the results are stored. Modified.
      • changeSign

        public static void changeSign​(org.ejml.data.FMatrixD1 a)

        Changes the sign of every element in the matrix.

        aij = -aij

        Parameters:
        a - A matrix. Modified.
      • changeSign

        public static <T extends org.ejml.data.FMatrixD1> T changeSign​(T input,
                                                                       @Nullable
                                                                       T output)

        Changes the sign of every element in the matrix.

        outputij = -inputij

        Parameters:
        input - A matrix. Modified.
      • fill

        public static void fill​(org.ejml.data.FMatrixD1 a,
                                float value)

        Sets every element in the matrix to the specified value.

        aij = value

        Parameters:
        a - A matrix whose elements are about to be set. Modified.
        value - The value each element will have.
      • rref

        public static org.ejml.data.FMatrixRMaj rref​(org.ejml.data.FMatrixRMaj A,
                                                     int numUnknowns,
                                                     org.ejml.data.FMatrixRMaj reduced)

        Puts the augmented system matrix into reduced row echelon form (RREF) using Gauss-Jordan elimination with row (partial) pivots. A matrix is said to be in RREF is the following conditions are true:

        1. If a row has non-zero entries, then the first non-zero entry is 1. This is known as the leading one.
        2. If a column contains a leading one then all other entries in that column are zero.
        3. If a row contains a leading 1, then each row above contains a leading 1 further to the left.

        [1] Page 19 in, Otter Bretscherm "Linear Algebra with Applications" Prentice-Hall Inc, 1997

        Parameters:
        A - Input matrix. Unmodified.
        numUnknowns - Number of unknowns/columns that are reduced. Set to -1 to default to Math.min(A.numRows,A.numCols), which works for most systems.
        reduced - Storage for reduced echelon matrix. If null then a new matrix is returned. Modified.
        Returns:
        Reduced echelon form of A
        See Also:
        RrefGaussJordanRowPivot_FDRM
      • elementLessThan

        public static org.ejml.data.BMatrixRMaj elementLessThan​(org.ejml.data.FMatrixRMaj A,
                                                                float value,
                                                                org.ejml.data.BMatrixRMaj output)
        Applies the > operator to each element in A. Results are stored in a boolean matrix.
        Parameters:
        A - Input matrx
        value - value each element is compared against
        output - (Optional) Storage for results. Can be null. Is reshaped.
        Returns:
        Boolean matrix with results
      • elementLessThanOrEqual

        public static org.ejml.data.BMatrixRMaj elementLessThanOrEqual​(org.ejml.data.FMatrixRMaj A,
                                                                       float value,
                                                                       org.ejml.data.BMatrixRMaj output)
        Applies the ≥ operator to each element in A. Results are stored in a boolean matrix.
        Parameters:
        A - Input matrix
        value - value each element is compared against
        output - (Optional) Storage for results. Can be null. Is reshaped.
        Returns:
        Boolean matrix with results
      • elementMoreThan

        public static org.ejml.data.BMatrixRMaj elementMoreThan​(org.ejml.data.FMatrixRMaj A,
                                                                float value,
                                                                org.ejml.data.BMatrixRMaj output)
        Applies the > operator to each element in A. Results are stored in a boolean matrix.
        Parameters:
        A - Input matrix
        value - value each element is compared against
        output - (Optional) Storage for results. Can be null. Is reshaped.
        Returns:
        Boolean matrix with results
      • elementMoreThanOrEqual

        public static org.ejml.data.BMatrixRMaj elementMoreThanOrEqual​(org.ejml.data.FMatrixRMaj A,
                                                                       float value,
                                                                       org.ejml.data.BMatrixRMaj output)
        Applies the ≥ operator to each element in A. Results are stored in a boolean matrix.
        Parameters:
        A - Input matrix
        value - value each element is compared against
        output - (Optional) Storage for results. Can be null. Is reshaped.
        Returns:
        Boolean matrix with results
      • elementLessThan

        public static org.ejml.data.BMatrixRMaj elementLessThan​(org.ejml.data.FMatrixRMaj A,
                                                                org.ejml.data.FMatrixRMaj B,
                                                                org.ejml.data.BMatrixRMaj output)
        Applies the < operator to each element in A. Results are stored in a boolean matrix.
        Parameters:
        A - Input matrix
        B - Input matrix
        output - (Optional) Storage for results. Can be null. Is reshaped.
        Returns:
        Boolean matrix with results
      • elementLessThanOrEqual

        public static org.ejml.data.BMatrixRMaj elementLessThanOrEqual​(org.ejml.data.FMatrixRMaj A,
                                                                       org.ejml.data.FMatrixRMaj B,
                                                                       org.ejml.data.BMatrixRMaj output)
        Applies the A ≤ B operator to each element. Results are stored in a boolean matrix.
        Parameters:
        A - Input matrix
        B - Input matrix
        output - (Optional) Storage for results. Can be null. Is reshaped.
        Returns:
        Boolean matrix with results
      • elements

        public static org.ejml.data.FMatrixRMaj elements​(org.ejml.data.FMatrixRMaj A,
                                                         org.ejml.data.BMatrixRMaj marked,
                                                         org.ejml.data.FMatrixRMaj output)
        Returns a row matrix which contains all the elements in A which are flagged as true in 'marked'
        Parameters:
        A - Input matrix
        marked - Input matrix marking elements in A
        output - Storage for output row vector. Can be null. Will be reshaped.
        Returns:
        Row vector with marked elements
      • countTrue

        public static int countTrue​(org.ejml.data.BMatrixRMaj A)
        Counts the number of elements in A which are true
        Parameters:
        A - input matrix
        Returns:
        number of true elements
      • concatColumns

        public static void concatColumns​(org.ejml.data.FMatrixRMaj a,
                                         org.ejml.data.FMatrixRMaj b,
                                         org.ejml.data.FMatrixRMaj output)
        output = [a , b]
      • concatColumnsMulti

        public static org.ejml.data.FMatrixRMaj concatColumnsMulti​(org.ejml.data.FMatrixRMaj... m)

        Concatinates all the matrices together along their columns. If the rows do not match the upper elements are set to zero.

        A = [ m[0] , ... , m[n-1] ]
        Parameters:
        m - Set of matrices
        Returns:
        Resulting matrix
      • concatRows

        public static void concatRows​(org.ejml.data.FMatrixRMaj a,
                                      org.ejml.data.FMatrixRMaj b,
                                      org.ejml.data.FMatrixRMaj output)
        output = [a ; b]
      • concatRowsMulti

        public static org.ejml.data.FMatrixRMaj concatRowsMulti​(org.ejml.data.FMatrixRMaj... m)

        Concatinates all the matrices together along their columns. If the rows do not match the upper elements are set to zero.

        A = [ m[0] ; ... ; m[n-1] ]
        Parameters:
        m - Set of matrices
        Returns:
        Resulting matrix
      • permuteRowInv

        public static org.ejml.data.FMatrixRMaj permuteRowInv​(int[] pinv,
                                                              org.ejml.data.FMatrixRMaj input,
                                                              org.ejml.data.FMatrixRMaj output)
        Applies the row permutation specified by the vector to the input matrix and save the results in the output matrix. output[perm[j],:] = input[j,:]
        Parameters:
        pinv - (Input) Inverse permutation vector. Specifies new order of the rows.
        input - (Input) Matrix which is to be permuted
        output - (Output) Matrix which has the permutation stored in it. Is reshaped.
      • abs

        public static void abs​(org.ejml.data.FMatrixD1 a,
                               org.ejml.data.FMatrixD1 c)

        Performs absolute value of a matrix:

        c = abs(a)
        cij = abs(aij)

        Parameters:
        a - A matrix. Not modified.
        c - A matrix. Modified.
      • abs

        public static void abs​(org.ejml.data.FMatrixD1 a)

        Performs absolute value of a matrix:

        a = abs(a)
        aij = abs(aij)

        Parameters:
        a - A matrix. Modified.
      • symmLowerToFull

        public static void symmLowerToFull​(org.ejml.data.FMatrixRMaj A)
        Given a symmetric matrix which is represented by a lower triangular matrix convert it back into a full symmetric matrix.
        Parameters:
        A - (Input) Lower triangular matrix (Output) symmetric matrix
      • symmUpperToFull

        public static void symmUpperToFull​(org.ejml.data.FMatrixRMaj A)
        Given a symmetric matrix which is represented by a lower triangular matrix convert it back into a full symmetric matrix.
        Parameters:
        A - (Input) Lower triangular matrix (Output) symmetric matrix