Class CRMatrix<A>

java.lang.Object
org.ddogleg.chainrule.CRMatrix<A>

public class CRMatrix<A> extends Object
References an index in an array that represents a 2D matrix. Dense row major format.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    Rows and columns in the 2D matrix
    Reference to the array
    int
    First index in the sub array
    int
    Rows and columns in the 2D matrix
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    CRMatrix(A array, int offset, int rows, int cols)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    b(int row, int col)
    Array access for type byte
    void
    b(int row, int col, byte value)
    Array access for type double
    Creates a copy of the original array and this wrapper.
    static CRMatrix<double[]>
    createD(int rows, int cols)
     
    double
    d(int row, int col)
    Array access for type double
    void
    d(int row, int col, double value)
    Array access for type double
    int
    Number of elements in the matrix
    float
    f(int row, int col)
    Array access for type float
    void
    f(int row, int col, float value)
    Array access for type double
    int
    i(int row, int col)
    Array access for type int
    void
    i(int row, int col, int value)
    Array access for type double
    boolean
    isEquals(CRMatrix<?> compare, double tol)
     
    boolean
    True if this is an invalid matrix.
    boolean
    true if one element is NaN in the matrix
    void
    Marks the matrix as invalid
    void
    read(A src, int offset)
    Copies the passed in array into the referenced array
    reserve(int length)
    Ensure that the array has at least this many elements in it
    void
    Resets the matrix with zeros for rows and cols
    reshape(int rows, int cols)
    Resizes the array and makes sure the data array is large enough
    short
    s(int row, int col)
    Array access for type short
    void
    s(int row, int col, short value)
    Array access for type double
    setOffset(int offset)
    Assigns a new value to the offset and returns a reference to 'this' allowing operations to be chained.
    Sets the value of this to be identical to 'src' and returns a refernece to 'this'
    void
    shape(int rows, int cols)
     
    toStringD(String format)
     
    toStringM(String format)
    Creates a string representation of a 2D matrix.
    void
    wrap(A array, int offset, int rows, int cols)
     
    void
    write(A dest, int offset)
    Copies values into the passed in 'dest' array

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • data

      public A data
      Reference to the array
    • offset

      public int offset
      First index in the sub array
    • rows

      public int rows
      Rows and columns in the 2D matrix
    • cols

      public int cols
      Rows and columns in the 2D matrix
  • Constructor Details

    • CRMatrix

      public CRMatrix(A array, int offset, int rows, int cols)
    • CRMatrix

      public CRMatrix()
  • Method Details

    • createD

      public static CRMatrix<double[]> createD(int rows, int cols)
    • isInvalid

      public boolean isInvalid()
      True if this is an invalid matrix. Can be used to indicate if this matrix should not be used
    • markInvalid

      public void markInvalid()
      Marks the matrix as invalid
    • reset

      public void reset()
      Resets the matrix with zeros for rows and cols
    • setTo

      public CRMatrix<A> setTo(CRMatrix<A> src)
      Sets the value of this to be identical to 'src' and returns a refernece to 'this'
    • reserve

      public CRMatrix<A> reserve(int length)
      Ensure that the array has at least this many elements in it
    • reshape

      public CRMatrix<A> reshape(int rows, int cols)
      Resizes the array and makes sure the data array is large enough
    • wrap

      public void wrap(A array, int offset, int rows, int cols)
    • write

      public void write(A dest, int offset)
      Copies values into the passed in 'dest' array
      Parameters:
      dest - Reference to the destination array
      offset - Offset in the dest array where it should start writing
    • read

      public void read(A src, int offset)
      Copies the passed in array into the referenced array
      Parameters:
      src - Reference to the source array
      offset - Offset in the src array where it should start
    • setOffset

      public CRMatrix<A> setOffset(int offset)
      Assigns a new value to the offset and returns a reference to 'this' allowing operations to be chained.
    • d

      public void d(int row, int col, double value)
      Array access for type double
    • d

      public double d(int row, int col)
      Array access for type double
    • f

      public void f(int row, int col, float value)
      Array access for type double
    • f

      public float f(int row, int col)
      Array access for type float
    • i

      public void i(int row, int col, int value)
      Array access for type double
    • i

      public int i(int row, int col)
      Array access for type int
    • s

      public void s(int row, int col, short value)
      Array access for type double
    • s

      public short s(int row, int col)
      Array access for type short
    • b

      public void b(int row, int col, byte value)
      Array access for type double
    • b

      public byte b(int row, int col)
      Array access for type byte
    • toStringD

      public String toStringD(String format)
    • toStringM

      public String toStringM(String format)
      Creates a string representation of a 2D matrix. zeros are printed as dots.
    • isEquals

      public boolean isEquals(CRMatrix<?> compare, double tol)
    • isNaN

      public boolean isNaN()
      true if one element is NaN in the matrix
    • copy

      public CRMatrix<A> copy()
      Creates a copy of the original array and this wrapper. Uses reflections.
    • elementCount

      public int elementCount()
      Number of elements in the matrix
    • shape

      public void shape(int rows, int cols)