Class DoubleMatrixFactory

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

public class DoubleMatrixFactory extends Object implements MatrixFactoryI
A factory for creating DoubleMatrix and DoubleVector. The newMatrix(Object[][]) and newVector(Object...) methods can optionally accept Boolean values, which are converted to 1.0 (true) and 0.0 (false). This feature is set using the DoubleMatrixFactory(boolean) constructor.
See Also:
  • Constructor Details

    • DoubleMatrixFactory

      public DoubleMatrixFactory(boolean treat_booleans_as_doubles)
      Constructor that allows the factory to accept Boolean values.
      Parameters:
      treat_booleans_as_doubles - if true, Boolean values are accepted and converted to 1.0 (true) and 0.0 (false).
      Since:
      Jep 4.1
    • DoubleMatrixFactory

      public DoubleMatrixFactory()
      Default constructor. Boolean values cannot be used in matrix or vector creation.
  • Method Details

    • isTreatBooleansAsDouble

      public boolean isTreatBooleansAsDouble()
    • newMatrix

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

      public DoubleVector newVector(double[] data)
    • newMatrix

      public DoubleMatrix 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 DoubleVector 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 DoubleMatrix 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 DoubleMatrix 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 DoubleVector 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 DoubleMatrix 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 DoubleMatrix 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'.