Class CRArray<A>

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

public class CRArray<A> extends Object
References an index in an array. Used to abstract reading and writing array types.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Reference to the array
    int
    First index in the sub array
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    CRArray(A array, int offset)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static CRArray<double[]>
    arrayD(double... values)
     
    byte
    b(int index)
    Array access for type byte
    void
    b(int index, byte value)
    Array access for type double
    Creates a copy of the original array and this wrapper.
    double
    d(int index)
    Array access for type double
    void
    d(int index, double value)
    Array access for type double
    float
    f(int index)
    Array access for type float
    void
    f(int index, float value)
    Array access for type double
    int
    i(int index)
    Array access for type int
    void
    i(int index, int value)
    Array access for type double
    boolean
    isEquals(CRArray<?> compare, int length, double tol)
    Checks to see if the two arrays are equals to each other to within the specified tolerance and over the specified number of elements
    boolean
     
    void
     
    void
    read(A src, int offset, int length)
    Copies the passed in array into the referenced array
    reserve(int length)
    Ensure that the array has at least this many elements in it
    short
    s(int index)
    Array access for type short
    void
    s(int index, 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.
    toStringD(String format, int length)
    Converts the array into a String using the provided printf format for each element
    wrap(A array, int offset)
     
    void
    write(A dest, int offset, int length)
    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

    • a

      public A a
      Reference to the array
    • offset

      public int offset
      First index in the sub array
  • Constructor Details

    • CRArray

      public CRArray(A array, int offset)
    • CRArray

      public CRArray()
  • Method Details

    • arrayD

      public static CRArray<double[]> arrayD(double... values)
    • wrap

      public CRArray<A> wrap(A array, int offset)
    • isInvalid

      public boolean isInvalid()
    • markInvalid

      public void markInvalid()
    • write

      public void write(A dest, int offset, int length)
      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
      length - Number of elements to copy
    • read

      public void read(A src, int offset, int length)
      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
      length - Number of elements to copy
    • setOffset

      public CRArray<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 index, double value)
      Array access for type double
    • d

      public double d(int index)
      Array access for type double
    • f

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

      public float f(int index)
      Array access for type float
    • i

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

      public int i(int index)
      Array access for type int
    • s

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

      public short s(int index)
      Array access for type short
    • b

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

      public byte b(int index)
      Array access for type byte
    • reserve

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

      public String toStringD(String format, int length)
      Converts the array into a String using the provided printf format for each element
      Parameters:
      format - How each element is converted into a string
      length - Number of elements
      Returns:
      The string
    • isEquals

      public boolean isEquals(CRArray<?> compare, int length, double tol)
      Checks to see if the two arrays are equals to each other to within the specified tolerance and over the specified number of elements
      Parameters:
      compare - Array to compare against
      length - Number of elements to compare
      tol - Tolerance for equality
      Returns:
      true if equal
    • copy

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