Class DoubleMatrixFactory
java.lang.Object
com.singularsys.extensions.matrix.doublemat.DoubleMatrixFactory
- All Implemented Interfaces:
MatrixFactoryI,JepComponent,Serializable
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 Summary
ConstructorsConstructorDescriptionDefault constructor.DoubleMatrixFactory(boolean treat_booleans_as_doubles) Constructor that allows the factory to acceptBooleanvalues. -
Method Summary
Modifier and TypeMethodDescriptionConverts the argument to the type of elements of the matrixReturns thisidentity(int size) Create a square identity matrixidentity(int rows, int cols) Create an identity matrix.voidInitialize the component.booleannewMatrix(double[][] data) Create a new MatrixI using the given datanewVector(double[] data) Create a new VectorI using the given datanewVector(Collection<?> set) Create a new VectorI from a collection.zeroMat(int rows, int cols) Create an zero matrix.zeroMat(Dimensions dimensions) Create a matrix with zero elementszeroVec(int size) Create a vector with zerosMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.singularsys.extensions.matrix.MatrixFactoryI
duplicate, duplicate, zeroVec
-
Constructor Details
-
DoubleMatrixFactory
public DoubleMatrixFactory(boolean treat_booleans_as_doubles) Constructor that allows the factory to acceptBooleanvalues.- Parameters:
treat_booleans_as_doubles- if true,Booleanvalues 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
-
newVector
-
newMatrix
Description copied from interface:MatrixFactoryICreate a new MatrixI using the given data- Specified by:
newMatrixin interfaceMatrixFactoryI- Parameters:
data-- Returns:
- a new MatrixI the precise type depends on the implementing class
- Throws:
EvaluationException
-
newVector
Description copied from interface:MatrixFactoryICreate a new VectorI using the given data- Specified by:
newVectorin interfaceMatrixFactoryI- Parameters:
data-- Returns:
- a new VectorI the precise type depends on the implementing class
- Throws:
EvaluationException
-
newVector
Description copied from interface:MatrixFactoryICreate a new VectorI from a collection. Default implementation simple callsnewVector(set.toArray()). Implementing classes can override this method to provide more efficient implementations.- Specified by:
newVectorin interfaceMatrixFactoryI- Parameters:
set- any collection including Lists.- Returns:
- a new vector
- Throws:
EvaluationException
-
elementValue
Description copied from interface:MatrixFactoryIConverts the argument to the type of elements of the matrix- Specified by:
elementValuein interfaceMatrixFactoryI- Parameters:
o-- Returns:
- the element value or null if it cannot be converted
-
identity
Description copied from interface:MatrixFactoryICreate a square identity matrix- Specified by:
identityin interfaceMatrixFactoryI- Parameters:
size- size- Returns:
- a size by size identity matrix
-
identity
Description copied from interface:MatrixFactoryICreate an identity matrix.- Specified by:
identityin interfaceMatrixFactoryI- Parameters:
rows-cols-- Returns:
- a
rowsbycolsidentity matrix
-
zeroVec
Description copied from interface:MatrixFactoryICreate a vector with zeros- Specified by:
zeroVecin interfaceMatrixFactoryI- Parameters:
size-- Returns:
- a vector of zeros
-
zeroMat
Description copied from interface:MatrixFactoryICreate an zero matrix.- Specified by:
zeroMatin interfaceMatrixFactoryI- Parameters:
rows-cols-- Returns:
- a rows by cols matrix
-
zeroMat
Description copied from interface:MatrixFactoryICreate a matrix with zero elements- Specified by:
zeroMatin interfaceMatrixFactoryI- 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
Description copied from interface:JepComponentInitialize 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:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getLightWeightInstance
Returns this- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-