Package org.nuiton.math.matrix
Class MatrixFactory
java.lang.Object
org.nuiton.math.matrix.MatrixFactory
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
FieldsModifier and TypeFieldDescriptionprotected static SemanticMapperprotected static Class<?>protected static intif we try to allocate matrix with more that this threshold, sparse matrix is usedprotected static booleanIf true, createVector return all time LazyVector to prevent memory allocation when not necessary.protected static Class<?>Valeur par defaut si aucun type de Vector n'est donnéprotected Class<?>protected intprotected booleanprotected Class<?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMatrixFactory(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector) -
Method Summary
Modifier and TypeMethodDescriptioncreate(double[] values, int[] dim) Convert a double array into matrix.create(int[] dim) Create new Matrix from file.Create new Matrix from file.Create new matrix and force backend to be data.Create new matrix and force backend to be data.Create new matrix by copying matrix in argumentCreate new matrix by copying matrix in argument, and force backend to be data.createProxy(String name, int[] dim, String[] dimNames, MatrixProvider matrixProvider) createProxy(String name, int[] dim, MatrixProvider matrixProvider) createProxy(String name, List<?>[] semantics, String[] dimNames, MatrixProvider matrixProvider) createProxy(String name, List<?>[] semantics, MatrixProvider matrixProvider) createProxy(List<?>[] semantics, MatrixProvider matrixProvider) protected VectorcreateVector(long length) cree un nouveau Vector.static Class<?>static MatrixFactoryUtilise 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 SemanticMapperClass<?>intClass<?>static voidinitMatrixFactoryThreadLocal(Class<?> vectorClass, Class<?> sparseVectorClass, int thresholdSparse, boolean useLazyVector) Initialise une factory pour le thread courant avec le vectorClass passe en parametre.booleanmatrixId(int size) Crée une nouvelle matrice identité.static voidRetire 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
-
MatrixFactory
-
-
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)
-