Package org.la4j
Class Vectors
- java.lang.Object
-
- org.la4j.Vectors
-
public final class Vectors extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static VectorFactory<BasicVector>BASICstatic VectorFactory<CompressedVector>COMPRESSEDstatic VectorFunctionDEC_FUNCTIONDecreases each element of vectors by1.static VectorFactory<BasicVector>DENSEstatic doubleEPSstatic VectorFactory<?>[]FACTORIESstatic VectorFunctionINC_FUNCTIONIncreases each element of vector by1.static VectorFunctionINV_FUNCTIONInverts each element of vector.static VectorPredicateNEGATIVE_VECTORChecks whether the vector is a negative vector.static VectorPredicatePOSITIVE_VECTORChecks whether the vector is a positive vector.static intROUND_FACTORstatic VectorFactory<CompressedVector>SPARSEstatic VectorPredicateZERO_VECTORChecks whether the vector is a zero vector.
-
Constructor Summary
Constructors Constructor Description Vectors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static VectorProcedureasAccumulatorProcedure(VectorAccumulator accumulator)Creates an accumulator procedure that adapts a vector accumulator for procedure interface.static VectorFunctionasConstFunction(double arg)Creates a const function that evaluates it's argument to givenvalue.static VectorFunctionasDivFunction(double arg)Creates a div function that divides it's argument by givenvalue.static VectorFunctionasMinusFunction(double arg)Creates a minus function that subtracts givenvaluefrom it's argument.static VectorFunctionasModFunction(double arg)Creates a mod function that calculates the modulus of it's argument and givenvalue.static VectorFunctionasMulFunction(double arg)Creates a mul function that multiplies givenvalueby it's argument.static VectorFunctionasPlusFunction(double arg)Creates a plus function that adds givenvalueto it's argument.static VectorAccumulatorasProductAccumulator(double neutral)Creates a product vector accumulator that calculates the product of all elements in the vector.static VectorAccumulatorasProductFunctionAccumulator(double neutral, VectorFunction function)Creates a product function accumulator, that calculates the product of all elements in the vector after applying givenfunctionto each of them.static VectorAccumulatorasSumAccumulator(double neutral)Creates a sum vector accumulator that calculates the sum of all elements in the vector.static VectorAccumulatorasSumFunctionAccumulator(double neutral, VectorFunction function)Creates a sum function accumulator, that calculates the sum of all elements in the vector after applying givenfunctionto each of them.static VectorAccumulatormkEuclideanNormAccumulator()Makes an Euclidean norm accumulator that allows to useVector.fold(org.la4j.vector.functor.VectorAccumulator)method for norm calculation.static VectorAccumulatormkInfinityNormAccumulator()Makes an Infinity norm accumulator that allows to useVector.fold(org.la4j.vector.functor.VectorAccumulator)method for norm calculation.static VectorAccumulatormkManhattanNormAccumulator()Makes a Manhattan norm accumulator that allows to useVector.fold(org.la4j.vector.functor.VectorAccumulator)method for norm calculation.static VectorAccumulatormkMaxAccumulator()Makes a maximum vector accumulator that accumulates the maximum across vector elements.static VectorAccumulatormkMinAccumulator()Makes a minimum vector accumulator that accumulates the minimum across vector elements.
-
-
-
Field Detail
-
EPS
public static final double EPS
-
ROUND_FACTOR
public static final int ROUND_FACTOR
-
BASIC
public static final VectorFactory<BasicVector> BASIC
-
COMPRESSED
public static final VectorFactory<CompressedVector> COMPRESSED
-
FACTORIES
public static final VectorFactory<?>[] FACTORIES
-
DENSE
public static final VectorFactory<BasicVector> DENSE
-
SPARSE
public static final VectorFactory<CompressedVector> SPARSE
-
ZERO_VECTOR
public static final VectorPredicate ZERO_VECTOR
Checks whether the vector is a zero vector.
-
POSITIVE_VECTOR
public static final VectorPredicate POSITIVE_VECTOR
Checks whether the vector is a positive vector.
-
NEGATIVE_VECTOR
public static final VectorPredicate NEGATIVE_VECTOR
Checks whether the vector is a negative vector.
-
INC_FUNCTION
public static final VectorFunction INC_FUNCTION
Increases each element of vector by1.
-
DEC_FUNCTION
public static final VectorFunction DEC_FUNCTION
Decreases each element of vectors by1.
-
INV_FUNCTION
public static final VectorFunction INV_FUNCTION
Inverts each element of vector.
-
-
Method Detail
-
asConstFunction
public static VectorFunction asConstFunction(double arg)
Creates a const function that evaluates it's argument to givenvalue.- Parameters:
arg- a const value- Returns:
- a closure object that does
_
-
asPlusFunction
public static VectorFunction asPlusFunction(double arg)
Creates a plus function that adds givenvalueto it's argument.- Parameters:
arg- a value to be added to function's argument- Returns:
- a closure object that does
_ + _
-
asMinusFunction
public static VectorFunction asMinusFunction(double arg)
Creates a minus function that subtracts givenvaluefrom it's argument.- Parameters:
arg- a value to be subtracted from function's argument- Returns:
- a closure that does
_ - _
-
asMulFunction
public static VectorFunction asMulFunction(double arg)
Creates a mul function that multiplies givenvalueby it's argument.- Parameters:
arg- a value to be multiplied by function's argument- Returns:
- a closure that does
_ * _
-
asDivFunction
public static VectorFunction asDivFunction(double arg)
Creates a div function that divides it's argument by givenvalue.- Parameters:
arg- a divisor value- Returns:
- a closure that does
_ / _
-
asModFunction
public static VectorFunction asModFunction(double arg)
Creates a mod function that calculates the modulus of it's argument and givenvalue.- Parameters:
arg- a divisor value- Returns:
- a closure that does
_ % _
-
asSumAccumulator
public static VectorAccumulator asSumAccumulator(double neutral)
Creates a sum vector accumulator that calculates the sum of all elements in the vector.- Parameters:
neutral- the neutral value- Returns:
- a sum accumulator
-
asProductAccumulator
public static VectorAccumulator asProductAccumulator(double neutral)
Creates a product vector accumulator that calculates the product of all elements in the vector.- Parameters:
neutral- the neutral value- Returns:
- a product accumulator
-
mkMinAccumulator
public static VectorAccumulator mkMinAccumulator()
Makes a minimum vector accumulator that accumulates the minimum across vector elements.- Returns:
- a minimum vector accumulator
-
mkMaxAccumulator
public static VectorAccumulator mkMaxAccumulator()
Makes a maximum vector accumulator that accumulates the maximum across vector elements.- Returns:
- a maximum vector accumulator
-
mkEuclideanNormAccumulator
public static VectorAccumulator mkEuclideanNormAccumulator()
Makes an Euclidean norm accumulator that allows to useVector.fold(org.la4j.vector.functor.VectorAccumulator)method for norm calculation.- Returns:
- an Euclidean norm accumulator
-
mkManhattanNormAccumulator
public static VectorAccumulator mkManhattanNormAccumulator()
Makes a Manhattan norm accumulator that allows to useVector.fold(org.la4j.vector.functor.VectorAccumulator)method for norm calculation.- Returns:
- a Manhattan norm accumulator
-
mkInfinityNormAccumulator
public static VectorAccumulator mkInfinityNormAccumulator()
Makes an Infinity norm accumulator that allows to useVector.fold(org.la4j.vector.functor.VectorAccumulator)method for norm calculation.- Returns:
- an Infinity norm accumulator
-
asSumFunctionAccumulator
public static VectorAccumulator asSumFunctionAccumulator(double neutral, VectorFunction function)
Creates a sum function accumulator, that calculates the sum of all elements in the vector after applying givenfunctionto each of them.- Parameters:
neutral- the neutral valuefunction- the vector function- Returns:
- a sum function accumulator
-
asProductFunctionAccumulator
public static VectorAccumulator asProductFunctionAccumulator(double neutral, VectorFunction function)
Creates a product function accumulator, that calculates the product of all elements in the vector after applying givenfunctionto each of them.- Parameters:
neutral- the neutral valuefunction- the vector function- Returns:
- a product function accumulator
-
asAccumulatorProcedure
public static VectorProcedure asAccumulatorProcedure(VectorAccumulator accumulator)
Creates an accumulator procedure that adapts a vector accumulator for procedure interface. This is useful for reusing a single accumulator for multiple fold operations in multiple vectors.- Parameters:
accumulator- the vector accumulator- Returns:
- an accumulator procedure
-
-