Class SequenceMatrixFactory

java.lang.Object
com.singularsys.extensions.matrix.sequencemat.SequenceMatrixFactory
All Implemented Interfaces:
MatrixFactoryI, JepComponent, Serializable

public class SequenceMatrixFactory extends Object implements MatrixFactoryI
A MatrixFactory which is used to create a SequenceMatrix (stored internally as a 1D array of double values) or DoubleVector. Since version 4.1 the newMatrix(Object[][]) and newVector(Object...) methods accept Boolean values, which are converted to 1.0 (true) and 0.0 (false).
See Also:
  • Constructor Details

    • SequenceMatrixFactory

      public SequenceMatrixFactory(boolean treat_doubles_as_booleans)
    • SequenceMatrixFactory

      public SequenceMatrixFactory()
  • Method Details

    • newMatrix

      public SequenceMatrix newMatrix(double[][] data)
    • newVector

      public DoubleVector newVector(double[] data)
    • newMatrix

      public MatrixI newMatrix(Object[][] data) throws EvaluationException
      Description copied from interface: MatrixFactoryI
      Create a new MatrixI using the given data
      Specified by:
      newMatrix in interface MatrixFactoryI
      Parameters:
      data -
      Returns:
      a new MatrixI the precise type depends on the implementing class
      Throws:
      EvaluationException
    • newVector

      public VectorI newVector(Object... data) throws EvaluationException
      Description copied from interface: MatrixFactoryI
      Create a new VectorI using the given data
      Specified by:
      newVector in interface MatrixFactoryI
      Parameters:
      data -
      Returns:
      a new VectorI the precise type depends on the implementing class
      Throws:
      EvaluationException
    • newVector

      public VectorI newVector(Collection<?> set) throws EvaluationException
      Description copied from interface: MatrixFactoryI
      Create a new VectorI from a collection. Default implementation simple calls newVector(set.toArray()). Implementing classes can override this method to provide more efficient implementations.
      Specified by:
      newVector in interface MatrixFactoryI
      Parameters:
      set - any collection including Lists.
      Returns:
      a new vector
      Throws:
      EvaluationException
    • elementValue

      public Double elementValue(Object o)
      Description copied from interface: MatrixFactoryI
      Converts the argument to the type of elements of the matrix
      Specified by:
      elementValue in interface MatrixFactoryI
      Parameters:
      o -
      Returns:
      the element value or null if it cannot be converted
    • identity

      public MatrixI identity(int size)
      Description copied from interface: MatrixFactoryI
      Create a square identity matrix
      Specified by:
      identity in interface MatrixFactoryI
      Parameters:
      size - size
      Returns:
      a size by size identity matrix
    • identity

      public MatrixI identity(int rows, int cols)
      Description copied from interface: MatrixFactoryI
      Create an identity matrix.
      Specified by:
      identity in interface MatrixFactoryI
      Parameters:
      rows -
      cols -
      Returns:
      a rows by cols identity matrix
    • zeroVec

      public VectorI zeroVec(int size)
      Description copied from interface: MatrixFactoryI
      Create a vector with zeros
      Specified by:
      zeroVec in interface MatrixFactoryI
      Parameters:
      size -
      Returns:
      a vector of zeros
    • zeroMat

      public MatrixI zeroMat(int rows, int cols)
      Description copied from interface: MatrixFactoryI
      Create an zero matrix.
      Specified by:
      zeroMat in interface MatrixFactoryI
      Parameters:
      rows -
      cols -
      Returns:
      a rows by cols matrix
    • zeroMat

      public MatrixI zeroMat(Dimensions dimensions) throws EvaluationException
      Description copied from interface: MatrixFactoryI
      Create a matrix with zero elements
      Specified by:
      zeroMat in interface MatrixFactoryI
      Parameters:
      dimensions - dimensions specifying the size of a matrix.
      Returns:
      a matrix filled with zeros
      Throws:
      EvaluationException - if the dimensions are not of order 2
    • init

      public void init(Jep jep)
      Description copied from interface: JepComponent
      Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.
      Specified by:
      init in interface JepComponent
      Parameters:
      jep - the current Jep instance
    • getLightWeightInstance

      public JepComponent getLightWeightInstance()
      Returns this
      Specified by:
      getLightWeightInstance in interface JepComponent
      Returns:
      either a new instance, null or 'this'.