bayesnet.jayes.factor
Class SparseFactor
- java.lang.Object
-
- bayesnet.jayes.factor.AbstractFactor
-
- bayesnet.jayes.factor.SparseFactor
-
- All Implemented Interfaces:
- java.lang.Cloneable
public class SparseFactor extends AbstractFactor implements java.lang.Cloneable
-
-
Constructor Summary
Constructors Constructor and Description SparseFactor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description SparseFactorclone()voidcopyValues(IArrayWrapper other)voidfill(double d)static SparseFactorfromFactor(AbstractFactor f)intgetOverhead()static booleanisSuitable(int futureLength, AbstractFactor... multiplicationCandidates)approximates whether creating a sparse factor will save memory compared to a dense factorvoidmultiplyCompatible(AbstractFactor compatible)multiply the factors.int[]prepareMultiplication(AbstractFactor compatible)voidsetDimensions(int... dimensions)voidsparsify(AbstractFactor... compatible)Prepares the factor in the sense that it's internal structures are optimized according to the zero/non-zero structure of the factors that will be multiplied in.-
Methods inherited from class bayesnet.jayes.factor.AbstractFactor
getDimensionIDs, getDimensions, getValue, getValues, isLogScale, marginalizeAllBut, multiplyCompatibleToLog, multiplyPrepared, resetSelections, select, setDimensionIDs, setLogScale, setValues, sumPrepared
-
-
-
-
Method Detail
-
setDimensions
public void setDimensions(int... dimensions)
- Overrides:
setDimensionsin classAbstractFactor
-
copyValues
public void copyValues(IArrayWrapper other)
- Specified by:
copyValuesin classAbstractFactor
-
multiplyCompatible
public void multiplyCompatible(AbstractFactor compatible)
Description copied from class:AbstractFactormultiply the factors. Only compatible factors are allowed, meaning ones that have a subset of the variables of this factor (assume consistent Dimension ID / size pairs)- Overrides:
multiplyCompatiblein classAbstractFactor
-
prepareMultiplication
public int[] prepareMultiplication(AbstractFactor compatible)
- Specified by:
prepareMultiplicationin classAbstractFactor
-
sparsify
public void sparsify(AbstractFactor... compatible)
Prepares the factor in the sense that it's internal structures are optimized according to the zero/non-zero structure of the factors that will be multiplied in. This method should always and only be called once before any call that modifies this factor's values- Parameters:
compatible- a Factor with compatible dimensions
-
fill
public void fill(double d)
- Specified by:
fillin classAbstractFactor
-
getOverhead
public int getOverhead()
- Specified by:
getOverheadin classAbstractFactor- Returns:
- approximated memory requirements on top of the value array
-
clone
public SparseFactor clone()
- Overrides:
clonein classAbstractFactor
-
isSuitable
public static boolean isSuitable(int futureLength, AbstractFactor... multiplicationCandidates)approximates whether creating a sparse factor will save memory compared to a dense factor- Parameters:
futureLength- the length that the new factor's value array would have in a dense factormultiplicationCandidates-- Returns:
-
fromFactor
public static SparseFactor fromFactor(AbstractFactor f)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG