Class Array
- java.lang.Object
-
- org.jquantlib.math.matrixutilities.Cells<Address.ArrayAddress>
-
- org.jquantlib.math.matrixutilities.Array
-
-
Constructor Summary
Constructors Constructor and Description Array()Default constructorArray(Array array)Creates a Matrix given a double[][] arrayArray(Array array, java.util.Set<Address.Flags> flags)Creates a Matrix given a double[][] arrayArray(double[] array)Creates an Array given a double[] arrayArray(double[] array, int size)Creates an Array given a double[] array and the desired number of elementsArray(double[] array, int size, java.util.Set<Address.Flags> flags)Creates an Array given a double[] array and the desired number of elementsArray(double[] array, java.util.Set<Address.Flags> flags)Creates an Array given a double[] arrayArray(int size)Builds an Array ofsizeArray(int size, java.util.Set<Address.Flags> flags)Builds an Array ofsizeArray(java.util.Set<Address.Flags> flags)Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description int_(int index)Deprecated.Arrayabs()AppliesMath.abs(double)to every element ofthisinstance.doubleaccumulate()Accumulate values in a range.doubleaccumulate(double init)Accumulate values in a range.doubleaccumulate(int first, int last, double init)Accumulate values in a range.Arrayadd(Array another)Addsthisinstance andanotherinstance of<T>.Arrayadd(double scalar)Adds ascalarto every element ofthisinstance of<T>.ArrayaddAssign(Array another)Addsthisinstance andanotherinstance of<T>.ArrayaddAssign(double scalar)Adds ascalarto every element ofthisinstance of<T>.ArrayadjacentDifference()Return differences between adjacent values.ArrayadjacentDifference(int from, int to)Return differences between adjacent values.ArrayadjacentDifference(int from, int to, Ops.BinaryDoubleOp f)Return differences between adjacent values.ArrayadjacentDifference(Ops.BinaryDoubleOp f)Return differences between adjacent values.intbegin()Arrayclone()Arraydiv(Array another)Dividesthisinstance byanotherinstance of<T>.Arraydiv(double scalar)Divides every element ofthisinstance of<T>by ascalar.ArraydivAssign(Array another)Dividesthisinstance byanotherinstance of<T>.ArraydivAssign(double scalar)Divides every element ofthisinstance of<T>by ascalar.doubledotProduct(Array another)The inner product generalizes the dot product to abstract vector spaces and is normally denoted by .doubledotProduct(Array another, int from, int to)The inner product generalizes the dot product to abstract vector spaces and is normally denoted by .intend()Arrayexp()AppliesMath.exp(double)to every element ofthisinstance.Arrayfill(Array another)Arrayfill(double scalar)doublefirst()doubleget(int pos)Retrieves an element ofthisMatrixdoubleinnerProduct(Array another)The inner product generalizes the dot product to abstract vector spaces and is normally denoted by .doubleinnerProduct(Array another, int from, int to)The inner product generalizes the dot product to abstract vector spaces and is normally denoted by .java.util.Iterator<java.lang.Double>iterator()doublelast()Arraylog()AppliesMath.log(double)to every element ofthisinstance.intlowerBound(double val)Finds the first position in which val could be inserted without changing the ordering.intlowerBound(double val, Ops.BinaryDoublePredicate f)Finds the first position in which val could be inserted without changing the ordering.intlowerBound(int from, int to, double val)Finds the first position in which val could be inserted without changing the ordering.intlowerBound(int from, int to, double val, Ops.BinaryDoublePredicate f)Finds the first position in which val could be inserted without changing the ordering.doublemax()Return the maximum element in a range using comparison functor.doublemax(int from, int to)Return the maximum element in a range using comparison functor.doublemin()Return the minimum element in a range using comparison functor.doublemin(int from, int to)Return the minimum element in a range using comparison functor.Arraymul(Array another)Multipliesthisinstance byanotherinstance of<T>.Arraymul(double scalar)Multiplies every element ofthisinstance of<T>by ascalar.Arraymul(Matrix matrix)Vectorial multiplication ofthisinstance by aMatrix.ArraymulAssign(Array another)Multipliesthisinstance byanotherinstance of<T>.ArraymulAssign(double scalar)Multiplies every element ofthisinstance of<T>by ascalar.Arraynegative()Unary negative function applied to every element ofthisinstanceMatrixouterProduct(Array another)In linear algebra, the outer product typically refers to the tensor product of two vectors.MatrixouterProduct(Array another, int from, int to)In linear algebra, the outer product typically refers to the tensor product of two vectors.Arrayrange(int col0)Arrayrange(int col0, int col1)voidset(int pos, double value)Stores a value into an element ofthisMatrixArraysort()Arraysqr()AppliesMath#sqr(double)to every element ofthisinstance.Arraysqrt()AppliesMath.sqrt(double)to every element ofthisinstance.Arraysub(Array another)Subtractsthisinstance byanotherinstance of<T>.Arraysub(double scalar)Subtracts ascalarto every element ofthisinstance of<T>.ArraysubAssign(Array another)Returns the result of a subtraction ofthisArray andanotherArrayArraysubAssign(double scalar)Subtracts ascalarto every element ofthisinstance of<T>.Arrayswap(Array another)ArraytoFortran()ArraytoJava()java.lang.StringtoString()Arraytransform(int from, int to, Ops.DoubleOp f)Perform an operation on a sequence in a range [first,last)Arraytransform(Ops.DoubleOp f)Perform an operation on a sequence in a range [first,last)intupperBound(double val)Finds the last position in which val could be inserted in a sequence [begin(), end()] without changing the ordering.intupperBound(double val, Ops.BinaryDoublePredicate f)Finds the last position in which val could be inserted in a sequence [begin(), end()] without changing the ordering.intupperBound(int from, int to, double val)Finds the last position in which val could be inserted in a sequence [first,last] without changing the ordering.intupperBound(int from, int to, double val, Ops.BinaryDoublePredicate f)Finds the last position in which val could be inserted in a sequence [first,last] without changing the ordering.-
Methods inherited from class org.jquantlib.math.matrixutilities.Cells
cols, columns, empty, flags, requireFlags, rows, size
-
-
-
-
Constructor Detail
-
Array
public Array()
Default constructorBuilds an Array which contains only one element.
-
Array
public Array(java.util.Set<Address.Flags> flags)
Default constructorBuilds an Array which contains only one element.
- Parameters:
flags- is aSet<Address.Flags>- See Also:
Address.Flags
-
Array
public Array(int size)
Builds an Array ofsize- Parameters:
size- is the size ofthisArray- Throws:
java.lang.IllegalArgumentException- if size are less than zero
-
Array
public Array(int size, java.util.Set<Address.Flags> flags)Builds an Array ofsize- Parameters:
size- is the size ofthisArrayflags- is aSet<Address.Flags>- Throws:
java.lang.IllegalArgumentException- if size are less than zero- See Also:
Address.Flags
-
Array
public Array(double[] array)
Creates an Array given a double[] array- Parameters:
$- is a unidimensional array
-
Array
public Array(double[] array, java.util.Set<Address.Flags> flags)Creates an Array given a double[] array- Parameters:
$- is a unidimensional arrayflags- is aSet<Address.Flags>- See Also:
Address.Flags
-
Array
public Array(double[] array, int size)Creates an Array given a double[] array and the desired number of elements- Parameters:
$- is a unidimensional arraysize- is the desired number of elements to be taken, counted from the first position
-
Array
public Array(double[] array, int size, java.util.Set<Address.Flags> flags)Creates an Array given a double[] array and the desired number of elements- Parameters:
$- is a unidimensional arraysize- is the desired number of elements to be taken, counted from the first positionflags- is aSet<Address.Flags>- See Also:
Address.Flags
-
Array
public Array(Array array)
Creates a Matrix given a double[][] array- Parameters:
$-
-
Array
public Array(Array array, java.util.Set<Address.Flags> flags)
Creates a Matrix given a double[][] array- Parameters:
$-flags- is aSet<Address.Flags>- See Also:
Address.Flags
-
-
Method Detail
-
clone
public Array clone()
- Overrides:
clonein classCells<Address.ArrayAddress>
-
_
@Deprecated public int _(int index)
Deprecated.This is a convenience method intended to return the physical address of an element.The use of this method is highly discouraged
- Parameters:
index- is a logical address of an element- Returns:
- the physical address to an element
- See Also:
Cells.$
-
begin
public int begin()
-
end
public int end()
-
first
public double first()
-
last
public double last()
-
get
public double get(int pos)
Retrieves an element ofthisMatrixThis method is provided for performance reasons. See methods
#getAddress(int)and#getAddress(int, int)for more details- Parameters:
dim- coordinatecol- coordinate- Returns:
- the contents of a given cell
- See Also:
#getAddress(int),#getAddress(int, int)
-
set
public void set(int pos, double value)Stores a value into an element ofthisMatrixThis method is provided for performance reasons. See methods
#getAddress(int)and#getAddress(int, int)for more details- Parameters:
dim- coordinatecol- coordinate- See Also:
#getAddress(int),#getAddress(int, int)
-
addAssign
public Array addAssign(double scalar)
Description copied from interface:AlgebraAdds ascalarto every element ofthisinstance of<T>.
-
subAssign
public Array subAssign(double scalar)
Description copied from interface:AlgebraSubtracts ascalarto every element ofthisinstance of<T>.
-
subAssign
public Array subAssign(Array another)
Returns the result of a subtraction ofthisArray andanotherArray
-
mulAssign
public Array mulAssign(double scalar)
Description copied from interface:AlgebraMultiplies every element ofthisinstance of<T>by ascalar.
-
divAssign
public Array divAssign(double scalar)
Description copied from interface:AlgebraDivides every element ofthisinstance of<T>by ascalar.
-
addAssign
public Array addAssign(Array another)
Description copied from interface:AlgebraAddsthisinstance andanotherinstance of<T>.
-
mulAssign
public Array mulAssign(Array another)
Description copied from interface:AlgebraMultipliesthisinstance byanotherinstance of<T>.
-
divAssign
public Array divAssign(Array another)
Description copied from interface:AlgebraDividesthisinstance byanotherinstance of<T>.
-
add
public Array add(double scalar)
Description copied from interface:AlgebraAdds ascalarto every element ofthisinstance of<T>.
-
sub
public Array sub(double scalar)
Description copied from interface:AlgebraSubtracts ascalarto every element ofthisinstance of<T>.
-
mul
public Array mul(double scalar)
Description copied from interface:AlgebraMultiplies every element ofthisinstance of<T>by ascalar.
-
negative
public Array negative()
Description copied from interface:AlgebraUnary negative function applied to every element ofthisinstance
-
div
public Array div(double scalar)
Description copied from interface:AlgebraDivides every element ofthisinstance of<T>by ascalar.
-
add
public Array add(Array another)
Description copied from interface:AlgebraAddsthisinstance andanotherinstance of<T>.
-
sub
public Array sub(Array another)
Description copied from interface:AlgebraSubtractsthisinstance byanotherinstance of<T>.
-
mul
public Array mul(Array another)
Description copied from interface:AlgebraMultipliesthisinstance byanotherinstance of<T>.
-
div
public Array div(Array another)
Description copied from interface:AlgebraDividesthisinstance byanotherinstance of<T>.
-
mul
public Array mul(Matrix matrix)
Description copied from interface:AlgebraVectorial multiplication ofthisinstance by aMatrix.
-
min
public double min()
Description copied from interface:AlgebraReturn the minimum element in a range using comparison functor.- Specified by:
minin interfaceAlgebra<Array>- Returns:
- the minimum value computed
- See Also:
- std::min_element
-
min
public double min(int from, int to)Description copied from interface:AlgebraReturn the minimum element in a range using comparison functor.- Specified by:
minin interfaceAlgebra<Array>- Parameters:
from- is the initial index, inclusiveto- is the final index, exclusive- Returns:
- the minimum value computed
- See Also:
- std::min_element
-
max
public double max()
Description copied from interface:AlgebraReturn the maximum element in a range using comparison functor.- Specified by:
maxin interfaceAlgebra<Array>- Returns:
- the maximum value computed
- See Also:
- std::max_element
-
max
public double max(int from, int to)Description copied from interface:AlgebraReturn the maximum element in a range using comparison functor.- Specified by:
maxin interfaceAlgebra<Array>- Parameters:
from- is the initial index, inclusiveto- is the final index, exclusive- Returns:
- the maximum value computed
- See Also:
- std::max_element
-
abs
public Array abs()
Description copied from interface:AlgebraAppliesMath.abs(double)to every element ofthisinstance.
-
sqr
public Array sqr()
Description copied from interface:AlgebraAppliesMath#sqr(double)to every element ofthisinstance.
-
sqrt
public Array sqrt()
Description copied from interface:AlgebraAppliesMath.sqrt(double)to every element ofthisinstance.
-
log
public Array log()
Description copied from interface:AlgebraAppliesMath.log(double)to every element ofthisinstance.
-
exp
public Array exp()
Description copied from interface:AlgebraAppliesMath.exp(double)to every element ofthisinstance.
-
dotProduct
public double dotProduct(Array another)
Description copied from interface:AlgebraThe inner product generalizes the dot product to abstract vector spaces and is normally denoted by .As we are working in space (real numbers), it's sufficient to understand that both inner product and dot operator give equivalent results.
- Specified by:
dotProductin interfaceAlgebra<Array>- Parameters:
another- Iterator- Returns:
- the inner product between this Matrix and another Matrix
- See Also:
- Inner Product
-
dotProduct
public double dotProduct(Array another, int from, int to)
Description copied from interface:AlgebraThe inner product generalizes the dot product to abstract vector spaces and is normally denoted by .As we are working in space (real numbers), it's sufficient to understand that both inner product and dot operator give equivalent results.
- Specified by:
dotProductin interfaceAlgebra<Array>- Parameters:
another- Iteratorfrom- is the start element, inclusiveto- is the end element, exclusive- Returns:
- the inner product between this Matrix and another Matrix
- See Also:
- Inner Product
-
innerProduct
public double innerProduct(Array another)
Description copied from interface:AlgebraThe inner product generalizes the dot product to abstract vector spaces and is normally denoted by .As we are working in space (real numbers), it's sufficient to understand that both inner product and dot operator give equivalent results.
- Specified by:
innerProductin interfaceAlgebra<Array>- Parameters:
another- Iterator- Returns:
- the inner product between this Matrix and another Matrix
- See Also:
- Inner Product
-
innerProduct
public double innerProduct(Array another, int from, int to)
Description copied from interface:AlgebraThe inner product generalizes the dot product to abstract vector spaces and is normally denoted by .As we are working in space (real numbers), it's sufficient to understand that both inner product and dot operator give equivalent results.
- Specified by:
innerProductin interfaceAlgebra<Array>- Parameters:
another- Iteratorfrom- is the start element, inclusiveto- is the end element, exclusive- Returns:
- the inner product between this Matrix and another Matrix
- See Also:
- Inner Product
-
outerProduct
public Matrix outerProduct(Array another)
Description copied from interface:AlgebraIn linear algebra, the outer product typically refers to the tensor product of two vectors. The result of applying the outer product to a pair of vectors is a matrix. The name contrasts with the inner product, which takes as input a pair of vectors and produces a scalar.Given a vector with ''m'' elements and a vector with ''n'' elements, their outer product is defined as the matrix obtained by multiplying each element of by each element of :
Note that .
- Specified by:
outerProductin interfaceAlgebra<Array>- Parameters:
another- Iterator- Returns:
- the outer product between this Matrix and another Matrix
- See Also:
- Outer Product
-
outerProduct
public Matrix outerProduct(Array another, int from, int to)
Description copied from interface:AlgebraIn linear algebra, the outer product typically refers to the tensor product of two vectors. The result of applying the outer product to a pair of vectors is a matrix. The name contrasts with the inner product, which takes as input a pair of vectors and produces a scalar.Given a vector with ''m'' elements and a vector with ''n'' elements, their outer product is defined as the matrix obtained by multiplying each element of by each element of :
Note that .
- Specified by:
outerProductin interfaceAlgebra<Array>- Parameters:
another- Iteratorfrom- is the start element, inclusiveto- is the end element, exclusive- Returns:
- the outer product between this Matrix and another Matrix
- See Also:
- Outer Product
-
accumulate
public double accumulate()
Description copied from interface:AlgebraAccumulate values in a range.Accumulates the values in the range [begin,end+1). The initial value is zero. The values are processed in order.
- Specified by:
accumulatein interfaceAlgebra<Array>- Returns:
- the final sum
- See Also:
- std::accumulate
-
accumulate
public double accumulate(double init)
Description copied from interface:AlgebraAccumulate values in a range.Accumulates the values in the range [begin(),end()+1). The initial value is init. The values are processed in order.
- Specified by:
accumulatein interfaceAlgebra<Array>- Parameters:
init- is the starting value to add other values to.- Returns:
- the final sum
- See Also:
- std::accumulate
-
accumulate
public double accumulate(int first, int last, double init)Description copied from interface:AlgebraAccumulate values in a range.Accumulates the values in the range [first,last). The initial value is init. The values are processed in order.
- Specified by:
accumulatein interfaceAlgebra<Array>init- is the starting value to add other values to.- Returns:
- the final sum
- See Also:
- std::accumulate
-
adjacentDifference
public final Array adjacentDifference()
Description copied from interface:AlgebraReturn differences between adjacent values.Computes the difference between adjacent values in the range [first,last) using subtraction to compute differences and returns the results as an Array.
- Specified by:
adjacentDifferencein interfaceAlgebra<Array>- Returns:
- an array which contains the computed adjacent differences.
- See Also:
- std::adjacent_difference
-
adjacentDifference
public final Array adjacentDifference(int from, int to)
Description copied from interface:AlgebraReturn differences between adjacent values.Computes the difference between adjacent values in the range [first,last) using subtraction to compute differences and returns the results as an Array.
- Specified by:
adjacentDifferencein interfaceAlgebra<Array>- Returns:
- an array which contains the computed adjacent differences.
- See Also:
- std::adjacent_difference
-
adjacentDifference
public Array adjacentDifference(Ops.BinaryDoubleOp f)
Description copied from interface:AlgebraReturn differences between adjacent values.Computes the difference between adjacent values in the range [begin(),end()+1) using a function for computing the differences and returns the results as an Array.
- Specified by:
adjacentDifferencein interfaceAlgebra<Array>- Parameters:
f- is a function- Returns:
- an array which contains the computed adjacent differences.
- See Also:
- std::adjacent_difference
-
adjacentDifference
public Array adjacentDifference(int from, int to, Ops.BinaryDoubleOp f)
Description copied from interface:AlgebraReturn differences between adjacent values.Computes the difference between adjacent values in the range [first,last) using a function for computing the differences and returns the results as an Array.
- Specified by:
adjacentDifferencein interfaceAlgebra<Array>f- is a function- Returns:
- an array which contains the computed adjacent differences.
- See Also:
- std::adjacent_difference
-
transform
public Array transform(Ops.DoubleOp f)
Description copied from interface:AlgebraPerform an operation on a sequence in a range [first,last)Applies the operator to each element in the input range and assigns the results to itself. Evaluates input[first+N] = unary_op(array[first+N]) for each
Nin the range [0, end()-begin() ).- Specified by:
transformin interfaceAlgebra<Array>- Returns:
this, i.e: performs the transformation in place- See Also:
- std::transform
-
transform
public Array transform(int from, int to, Ops.DoubleOp f)
Description copied from interface:AlgebraPerform an operation on a sequence in a range [first,last)Applies the operator to each element in the input range and assigns the results to itself. Evaluates input[first+N] = unary_op(array[first+N]) for each
Nin the range [0, last-first).- Specified by:
transformin interfaceAlgebra<Array>- Parameters:
from- is the start of range, inclusiveto- is the end of range, exclusivef- is an unary function to be applied- Returns:
this, i.e: performs the transformation in place- See Also:
- std::transform
-
lowerBound
public int lowerBound(double val)
Description copied from interface:AlgebraFinds the first position in which val could be inserted without changing the ordering.- Specified by:
lowerBoundin interfaceAlgebra<Array>- Returns:
- an index pointing to the first element "not less than"
val, or end() if every element is less thanval. - See Also:
- std::lower_bound
-
lowerBound
public int lowerBound(int from, int to, double val)Description copied from interface:AlgebraFinds the first position in which val could be inserted without changing the ordering.- Specified by:
lowerBoundin interfaceAlgebra<Array>- Returns:
- an index pointing to the first element "not less than"
val, or end() if every element is less thanval. - See Also:
- std::lower_bound
-
lowerBound
public int lowerBound(double val, Ops.BinaryDoublePredicate f)Description copied from interface:AlgebraFinds the first position in which val could be inserted without changing the ordering.- Specified by:
lowerBoundin interfaceAlgebra<Array>f- is a BinaryDoublePredicate which defines the comparison function- Returns:
- an index pointing to the first element "not less than"
val, or end() if every element is less thanval. - See Also:
- std::lower_bound
-
lowerBound
public int lowerBound(int from, int to, double val, Ops.BinaryDoublePredicate f)Description copied from interface:AlgebraFinds the first position in which val could be inserted without changing the ordering.- Specified by:
lowerBoundin interfaceAlgebra<Array>f- is a BinaryDoublePredicate which defines the comparison function- Returns:
- an index pointing to the first element "not less than"
val, or end() if every element is less thanval. - See Also:
- std::lower_bound
-
upperBound
public int upperBound(double val)
Description copied from interface:AlgebraFinds the last position in which val could be inserted in a sequence [begin(), end()] without changing the ordering.- Specified by:
upperBoundin interfaceAlgebra<Array>- Returns:
- an index pointing to the first element greater than
val, or end() if no elements are greater thanval. - See Also:
- std::upper_bound
-
upperBound
public int upperBound(int from, int to, double val)Description copied from interface:AlgebraFinds the last position in which val could be inserted in a sequence [first,last] without changing the ordering.- Specified by:
upperBoundin interfaceAlgebra<Array>- Parameters:
from- element, inclusiveto- element, inclusive- Returns:
- an index pointing to the first element greater than
val, or end() if no elements are greater thanval. - See Also:
- std::upper_bound
-
upperBound
public int upperBound(double val, Ops.BinaryDoublePredicate f)Description copied from interface:AlgebraFinds the last position in which val could be inserted in a sequence [begin(), end()] without changing the ordering.- Specified by:
upperBoundin interfaceAlgebra<Array>f- is a BinaryDoublePredicate which defines the comparison function- Returns:
- an index pointing to the first element greater than
val, or end() if no elements are greater thanval. - See Also:
- std::upper_bound
-
upperBound
public int upperBound(int from, int to, double val, Ops.BinaryDoublePredicate f)Description copied from interface:AlgebraFinds the last position in which val could be inserted in a sequence [first,last] without changing the ordering.- Specified by:
upperBoundin interfaceAlgebra<Array>- Parameters:
from- element, inclusiveto- element, inclusivef- is a BinaryDoublePredicate which defines the comparison function- Returns:
- an index pointing to the first element greater than
val, or end() if no elements are greater thanval. - See Also:
- std::upper_bound
-
range
public Array range(int col0)
-
range
public Array range(int col0, int col1)
-
toFortran
public Array toFortran()
-
toJava
public Array toJava()
-
fill
public Array fill(double scalar)
-
sort
public Array sort()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
iterator
public java.util.Iterator<java.lang.Double> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Double>
-
-
DataMelt 3.0 © DataMelt by jWork.ORG