Package org.nuiton.math.matrix
Class DoubleSparseHashVector
java.lang.Object
org.nuiton.math.matrix.DoubleSparseHashVector
- All Implemented Interfaces:
SparseVector,Vector
public class DoubleSparseHashVector extends Object implements SparseVector
Permet de stocker des données differente de la valeur par defaut (0.0) dans
une Map<int, double>. L'implantation pcj ne supporte pas la modification
de la valeur par defaut.
Created: 05 septembre 2012
- Version:
- $Revision$ Last update: $Date$ by : $Author$
- Author:
- Benjamin POUSSIN <poussin@codelutin.com>
-
Field Summary
Fields Modifier and Type Field Description protected intcapacityprotected OpenIntDoubleHashMapdataprotected doubledefaultValue -
Constructor Summary
Constructors Constructor Description DoubleSparseHashVector()DoubleSparseHashVector(int capacity)DoubleSparseHashVector(int capacity, double defaultValue) -
Method Summary
Modifier and Type Method Description voidadd(Vector v)Ajoute les valeurs du vector passé en argument a ce vector.protected voidcheckPos(int pos)booleanequals(Object o)int[]getAssignedPosition()Return an orderer array of position assigned, this array can be longer than realy assigned value, you must used getNumberOfAssignedValue to know number of significant position in arraydouble[]getAssignedValue()Return an array in same order that getAssignedPosition.doublegetDefaultValue()Value to used if not un assigned valueStringgetInfo()return information on this vector.doublegetMaxOccurence()Deprecated.doublegetMaxOccurrence()Retourne la valeur la plus utilise dans le vectorintgetNumberOfAssignedValue()Returne number of assigned value, assigned value is value stored in memorydoublegetValue(int pos)inthashCode()voidinit(int capacity)Init vector, before this method call, vector is in indetermined state.booleanisImplementedAdd(Vector v)Permet de savoir si add est implanté par ce vector.booleanisImplementedMap()Permet de savoir si map est implanté par ce vector.booleanisImplementedMinus(Vector v)Permet de savoir si minus est implanté par ce vector.booleanisImplementedPaste(Vector v)Permet de savoir si paste est implanté par ce vector.VectorIteratoriterator()Retourne un objet Inc pret a etre utilisé pour boucler sur tous les element de la matrice.VectorIteratoriteratorNotZero()Retourne un objet Inc pret a etre utilisé pour boucler sur tous les element different de 0 de la matrice.voidmap(MapFunction f)applique a chaque valeur du vector laMapFunction.voidminus(Vector v)Soustrait les valeurs du vector passé en argument a ce vector.voidpaste(Vector v)Copie les valeurs du vector passé en argument dans ce vector.voidsetValue(int pos, double value)intsize()
-
Field Details
-
defaultValue
protected double defaultValue -
data
-
capacity
protected int capacity
-
-
Constructor Details
-
DoubleSparseHashVector
public DoubleSparseHashVector() -
DoubleSparseHashVector
public DoubleSparseHashVector(int capacity) -
DoubleSparseHashVector
public DoubleSparseHashVector(int capacity, double defaultValue)
-
-
Method Details
-
init
public void init(int capacity)Description copied from interface:VectorInit vector, before this method call, vector is in indetermined state. multiple call to init method must be permit. Only first call must do some work, extra call must do nothing -
getInfo
Description copied from interface:Vectorreturn information on this vector. This information depends on implementation example: - size - max occurence number - ... -
getNumberOfAssignedValue
public int getNumberOfAssignedValue()Description copied from interface:VectorReturne number of assigned value, assigned value is value stored in memory- Specified by:
getNumberOfAssignedValuein interfaceVector
-
size
public int size() -
getMaxOccurence
Deprecated.- Specified by:
getMaxOccurencein interfaceVector
-
getMaxOccurrence
public double getMaxOccurrence()Description copied from interface:VectorRetourne la valeur la plus utilise dans le vector- Specified by:
getMaxOccurrencein interfaceVector- Returns:
-
checkPos
protected void checkPos(int pos) -
getValue
public double getValue(int pos) -
setValue
public void setValue(int pos, double value) -
equals
-
hashCode
public int hashCode() -
isImplementedPaste
Description copied from interface:VectorPermet de savoir si paste est implanté par ce vector.- Specified by:
isImplementedPastein interfaceVector- Parameters:
v- vector to test- Returns:
trueif operation is supported
-
isImplementedAdd
Description copied from interface:VectorPermet de savoir si add est implanté par ce vector.- Specified by:
isImplementedAddin interfaceVector- Parameters:
v- vector to test- Returns:
trueif operation is supported
-
isImplementedMinus
Description copied from interface:VectorPermet de savoir si minus est implanté par ce vector.- Specified by:
isImplementedMinusin interfaceVector- Parameters:
v- vector to test- Returns:
trueif operation is supported
-
isImplementedMap
public boolean isImplementedMap()Description copied from interface:VectorPermet de savoir si map est implanté par ce vector.- Specified by:
isImplementedMapin interfaceVector- Returns:
trueif operation is supported
-
paste
Description copied from interface:VectorCopie les valeurs du vector passé en argument dans ce vector. -
add
Description copied from interface:VectorAjoute les valeurs du vector passé en argument a ce vector. -
minus
Description copied from interface:VectorSoustrait les valeurs du vector passé en argument a ce vector. -
map
Description copied from interface:Vectorapplique a chaque valeur du vector laMapFunction. ATTENTION cette function ne doit pas converser d'etat interne qui modifierait son comportement a chaque execution, sinon cette methode ne fonctionne pas, car pour les Vector implanter a base de Map la fonction n'est appliqué qu'au defaultValue et au valeur deja existante -
getAssignedPosition
public int[] getAssignedPosition()Description copied from interface:SparseVectorReturn an orderer array of position assigned, this array can be longer than realy assigned value, you must used getNumberOfAssignedValue to know number of significant position in array- Specified by:
getAssignedPositionin interfaceSparseVector- Returns:
-
getAssignedValue
public double[] getAssignedValue()Description copied from interface:SparseVectorReturn an array in same order that getAssignedPosition. This array contains values. This array can be longer than realy assigned value, you must used getNumberOfAssignedValue to know number of significant position in array- Specified by:
getAssignedValuein interfaceSparseVector- Returns:
-
getDefaultValue
public double getDefaultValue()Description copied from interface:SparseVectorValue to used if not un assigned value- Specified by:
getDefaultValuein interfaceSparseVector- Returns:
-
iterator
Description copied from interface:VectorRetourne un objet Inc pret a etre utilisé pour boucler sur tous les element de la matrice. -
iteratorNotZero
Description copied from interface:VectorRetourne un objet Inc pret a etre utilisé pour boucler sur tous les element different de 0 de la matrice.- Specified by:
iteratorNotZeroin interfaceVector- Returns:
- un objet Inc pret à être utilisé
-