Package org.nuiton.math.matrix
Class MatrixFactory
java.lang.Object
org.nuiton.math.matrix.MatrixFactory
public class MatrixFactory extends Object
Cette classe permet de creer des matrices, toutes les creations de matrice
doivent etre faite a travers cette classe. Cette classe permet de modifier la
representation interne des matrices de facon simple.
Created: 11 octobre 2005 20:15:20 CEST
- Version:
- $Revision$ Last update: $Date$ by : $Author$
- Author:
- Benjamin POUSSIN <poussin@codelutin.com>
-
Field Summary
Fields Modifier and Type Field Description protected static SemanticMapperdefaultSemanticMapperprotected static Class<?>defaultSparseVectorClassprotected static intdefaultThresholdSparseif we try to allocate matrix with more that this threshold, sparse matrix is usedprotected static booleandefaultUseLazyVectorIf true, createVector return all time LazyVector to prevent memory allocation when not necessary.protected static Class<?>defaultVectorClassValeur par defaut si aucun type de Vector n'est donnéprotected Class<?>sparseVectorClassprotected intthresholdSparseprotected booleanuseLazyVectorprotected Class<?>vectorClass -
Constructor Summary
Constructors Modifier Constructor Description protectedMatrixFactory(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector) -
Method Summary
Modifier and Type Method Description MatrixNDcreate(double[] values, int[] dim)Convert a double array into matrix.MatrixNDcreate(int[] dim)MatrixNDcreate(File file)Create new Matrix from file.MatrixNDcreate(Reader reader)Create new Matrix from file.MatrixNDcreate(String name, int[] dim)MatrixNDcreate(String name, int[] dim, String[] dimNames)MatrixNDcreate(String name, int[] dim, String[] dimNames, Vector data)Create new matrix and force backend to be data.MatrixNDcreate(String name, List<?>[] semantics)MatrixNDcreate(String name, List<?>[] semantics, String[] dimNames)MatrixNDcreate(String name, List<?>[] semantics, String[] dimNames, Vector data)Create new matrix and force backend to be data.MatrixNDcreate(List<?>[] semantics)MatrixNDcreate(MatrixND matrix)Create new matrix by copying matrix in argumentMatrixNDcreate(MatrixND matrix, Vector data)Create new matrix by copying matrix in argument, and force backend to be data.MatrixProxycreateProxy(String name, int[] dim, String[] dimNames, MatrixProvider matrixProvider)MatrixProxycreateProxy(String name, int[] dim, MatrixProvider matrixProvider)MatrixProxycreateProxy(String name, List<?>[] semantics, String[] dimNames, MatrixProvider matrixProvider)MatrixProxycreateProxy(String name, List<?>[] semantics, MatrixProvider matrixProvider)MatrixProxycreateProxy(List<?>[] semantics, MatrixProvider matrixProvider)protected VectorcreateVector(int length)cree un nouveau Vector.static Class<?>getDefaultVectorClass()static MatrixFactorygetInstance()Utilise par defautdefaultVectorClass.static MatrixFactorygetInstance(Class<?> vectorClass)Retourne une factory utilisant vectorClass comme classe de base a l'implantation des matrices, aussi bien pour les matrices dense que les matrices creuse.static MatrixFactorygetInstance(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse)Retourne une factory utilisant, par defaut on utilise les LazyVectorstatic MatrixFactorygetInstance(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector)Retourne une factory utilisant vectorClass comme classe de base a l'implantation des matrices.static SemanticMappergetSemanticMapper()Class<?>getSparseVectorClass()intgetThresholdSparse()Class<?>getVectorClass()static voidinitMatrixFactoryThreadLocal(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector)Initialise une factory pour le thread courant avec le vectorClass passe en parametre.booleanisUseLazyVector()MatrixNDmatrixId(int size)Crée une nouvelle matrice identité.static voidremoveMatrixFactoryThreadLocal()Retire la factory pour le thread courantstatic voidsetDefaultSparseVectorClass(Class<?> defaultSparseVectorClass)static voidsetDefaultThresholdSparse(int defaultThresholdSparse)static voidsetDefaultUseLazyVector(boolean useLazyVector)static voidsetDefaultVectorClass(Class<?> vectorClass)static voidsetSemanticMapper(SemanticMapper semanticMapper)
-
Field Details
-
defaultUseLazyVector
protected static boolean defaultUseLazyVectorIf true, createVector return all time LazyVector to prevent memory allocation when not necessary. LazyVector init real vector only when necessary -
defaultVectorClass
Valeur par defaut si aucun type de Vector n'est donné -
defaultSparseVectorClass
-
defaultThresholdSparse
protected static int defaultThresholdSparseif we try to allocate matrix with more that this threshold, sparse matrix is used -
vectorClass
-
sparseVectorClass
-
thresholdSparse
protected int thresholdSparse -
useLazyVector
protected boolean useLazyVector -
defaultSemanticMapper
-
-
Constructor Details
-
Method Details
-
getVectorClass
-
getSparseVectorClass
-
getThresholdSparse
public int getThresholdSparse() -
isUseLazyVector
public boolean isUseLazyVector() -
setDefaultVectorClass
-
setDefaultSparseVectorClass
-
setDefaultThresholdSparse
public static void setDefaultThresholdSparse(int defaultThresholdSparse) -
setDefaultUseLazyVector
public static void setDefaultUseLazyVector(boolean useLazyVector) -
getDefaultVectorClass
-
setSemanticMapper
-
getSemanticMapper
-
getInstance
Retourne une factory utilisant vectorClass comme classe de base a l'implantation des matrices, aussi bien pour les matrices dense que les matrices creuse. Par defaut on utilise les LazyVector- Parameters:
vectorClass- vector class implementation- Returns:
- factory
-
getInstance
public static MatrixFactory getInstance(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse)Retourne une factory utilisant, par defaut on utilise les LazyVector- Parameters:
vectorClass- vector class implementation for dense matrixsparseVectorClass- vector class implementation for sparse matrixthresholdSparse- threshold to determine usage of dense or sparse matrix- Returns:
- factory
-
getInstance
public static MatrixFactory getInstance(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector)Retourne une factory utilisant vectorClass comme classe de base a l'implantation des matrices.- Parameters:
vectorClass- vector class implementation for dense matrixsparseVectorClass- vector class implementation for sparse matrixthresholdSparse- threshold to determine usage of dense or sparse matrixuseLazyVector- if true use LazyVector- Returns:
- factory
-
getInstance
Utilise par defautdefaultVectorClass. Si une factory a ete initialisee pour le thread local, alors celle-ci sera reutilise, sinon une nouvelle est cree avec le backend par defaut- Returns:
- factory
-
initMatrixFactoryThreadLocal
public static void initMatrixFactoryThreadLocal(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector)Initialise une factory pour le thread courant avec le vectorClass passe en parametre.- Parameters:
vectorClass- vector class implementation for dense matrixsparseVectorClass- vector class implementation for sparse matrixthresholdSparse- threshold to determine usage of dense or sparse matrixuseLazyVector- if true use LazyVector
-
removeMatrixFactoryThreadLocal
public static void removeMatrixFactoryThreadLocal()Retire la factory pour le thread courant -
create
Create new Matrix from file. File contains data as describe for export/import CSV ND- Parameters:
file-- Returns:
- Throws:
IOException- Since:
- 2.5.2
-
create
Create new Matrix from file. File contains data as describe for export/import CSV ND- Parameters:
reader-- Returns:
- Throws:
IOException- Since:
- 2.5.2
-
create
-
create
Convert a double array into matrix.- Parameters:
values- The values to fill the matrixdim- An array representing the dimensions of the matrix- Returns:
- a 2D matrix filled with the values, null if the dimension is more than 2
-
create
-
create
-
create
-
create
Create new matrix and force backend to be data.- Parameters:
name- matrix's name (can be null)dim- matrix's dimension (must be provided)dimNames- dimensions' name (can be null)data- backend used to new matrix- Returns:
- new Matrix with specified backend
-
create
-
create
-
create
Create new matrix and force backend to be data.- Parameters:
name- matrix's name (can be null)semantics- semantiques (must be provided)dimNames- dimensions' name (can be null)data- backend used to new matrix- Returns:
- new Matrix with specified backend
-
create
Create new matrix by copying matrix in argument- Parameters:
matrix-- Returns:
-
create
Create new matrix by copying matrix in argument, and force backend to be data.- Parameters:
matrix- matrix to copieddata- backend used to new matrix
-
matrixId
Crée une nouvelle matrice identité. Une matrice identité est une matrice à 2 dimensions dont tous les éléments de la diagonal vaut 1- Parameters:
size- la taille de la matrice- Returns:
- une nouvelle matrice identité
-
createVector
cree un nouveau Vector. Si la taille demandee est inferieur au seuil alors on cree une matrice plaine, sinon on cree une matrice creuse.- Parameters:
length-- Returns:
-
createProxy
-
createProxy
-
createProxy
public MatrixProxy createProxy(String name, int[] dim, String[] dimNames, MatrixProvider matrixProvider) -
createProxy
-
createProxy
public MatrixProxy createProxy(String name, List<?>[] semantics, String[] dimNames, MatrixProvider matrixProvider)
-