public class VectorFactory extends Object
Modifier and Type | Method and Description |
---|---|
static Vector |
concat(Collection<Vector> vectors)
Concatenates an array of vectors into one vector.
|
static SparseVector |
concat(SparseVector... vectors)
Concatenates an array of sparse vectors into one sparse vector.
|
static Vector |
concat(Vector... vectors)
Concatenates an array of vectors into one vector.
|
static Vector[] |
cumsum(Vector[] arr)
Gets the cumulative sums.
|
static Vector |
diagonal(Matrix A)
Gets the diagonal of a matrix as a vector.
|
static SparseVector |
diagonal(SparseMatrix A)
Gets the diagonal of a sparse matrix as a sparse vector.
|
static SparseVector |
foreach(SparseVector vector,
UnivariateRealFunction f)
Constructs a new vector in which each entry is the result of applying a
function to the corresponding entry of a sparse vector.
|
static Vector |
foreach(Vector vector,
UnivariateRealFunction f)
Constructs a new vector in which each entry is the result of applying a
function to the corresponding entry of a vector.
|
static Vector |
foreachColumn(Matrix matrix,
RealScalarFunction f)
Constructs a vector in which each entry is the result of applying a
RealScalarFunction to each column of an input matrix. |
static Vector |
foreachRow(Matrix matrix,
RealScalarFunction f)
Constructs a vector in which each entry is the result of applying a
RealScalarFunction to each row of an input matrix. |
static Vector |
foreachVector(Collection<Vector> vectors,
RealScalarFunction f)
Applies a
RealScalarFunction on each input vector. |
static Vector[] |
foreachVector(Collection<Vector> vectors,
RealVectorFunction f)
Applies a real vector function on each input vector.
|
static Vector |
foreachVector(Vector[] vectors,
RealScalarFunction f)
Applies a
RealScalarFunction on each input vector. |
static Vector[] |
foreachVector(Vector[] vectors,
RealVectorFunction f)
Applies a real vector function on each input vector.
|
static Vector[] |
get0s(int dimension,
int n)
Gets
n 0 vectors. |
static Vector |
getCoordinate(Collection<Vector> vectors,
int i)
Gets the vector entries from a particular coordinate.
|
static Vector |
getCoordinate(Vector[] vectors,
int i)
Gets the vector entries from a particular coordinate.
|
static List<Vector> |
getOffsetVectors(Vector v0,
Vector dv,
int a,
int b)
Given the reference vector
v0 , the delta dv , and
the range [a, b] , the offset vectors are:
v0 + a * dv, v0 + (a + 1) * dv, ..., v0 + b * dv. |
static Vector |
subDiagonal(Matrix A)
Gets the sub-diagonal of a matrix as a vector.
|
static SparseVector |
subDiagonal(SparseMatrix A)
Gets the sub-diagonal of a sparse matrix as a sparse vector.
|
static SparseVector |
subVector(SparseVector vector,
int from,
int to)
Gets a sub-vector from a sparse vector.
|
static Vector |
subVector(Vector vector,
int[] indices)
Gets a sub-vector from a vector according to a given array
of ordered indices (repetition allowed).
|
static Vector |
subVector(Vector vector,
int from,
int to)
Gets a sub-vector from a vector.
|
static Vector |
subVector(Vector vector,
List<Integer> indices)
Gets a sub-vector from a vector according to a given array
of ordered indices (repetition allowed).
|
static Vector |
superDiagonal(Matrix A)
Gets the super-diagonal of a matrix as a vector.
|
static SparseVector |
superDiagonal(SparseMatrix A)
Gets the super-diagonal of a sparse matrix as a sparse vector.
|
public static Vector concat(Vector... vectors)
vectors
- an array of vectors, e.g., \((v_1, v_2, v_3, ...)\).public static Vector concat(Collection<Vector> vectors)
vectors
- an array of vectors, e.g., \((v_1, v_2, v_3, ...)\).public static SparseVector concat(SparseVector... vectors)
vectors
- an array of sparse vectors, e.g., \((v_1, v_2, v_3, ...)\).public static Vector foreach(Vector vector, UnivariateRealFunction f)
f
- the function to be applied to each entry of a vectorvector
- a vectorpublic static SparseVector foreach(SparseVector vector, UnivariateRealFunction f)
f
- the function to be applied to each entry of a vectorvector
- a sparse vectorpublic static Vector subVector(Vector vector, int from, int to)
vector
- a vectorfrom
- the beginning indexto
- the ending indexv[from : to]
public static SparseVector subVector(SparseVector vector, int from, int to)
vector
- a sparse vectorfrom
- the beginning indexto
- the ending indexv[from : to]
public static Vector subVector(Vector vector, List<Integer> indices)
vector
- a vectorindices
- the list of ordered indices (repetition allowed)public static Vector subVector(Vector vector, int[] indices)
vector
- a vectorindices
- the array of ordered indices (repetition allowed)public static Vector diagonal(Matrix A)
A
- a matrixpublic static SparseVector diagonal(SparseMatrix A)
A
- a sparse matrixpublic static Vector superDiagonal(Matrix A)
A
- a matrixpublic static SparseVector superDiagonal(SparseMatrix A)
A
- a sparse matrixpublic static Vector subDiagonal(Matrix A)
A
- a matrixpublic static SparseVector subDiagonal(SparseMatrix A)
A
- a sparse matrixpublic static Vector foreachRow(Matrix matrix, RealScalarFunction f)
RealScalarFunction
to each row of an input matrix.matrix
- the input matrixf
- the real scalar functionpublic static Vector foreachColumn(Matrix matrix, RealScalarFunction f)
RealScalarFunction
to each column of an input matrix.matrix
- the input matrixf
- the real scalar functionpublic static Vector foreachVector(Vector[] vectors, RealScalarFunction f)
RealScalarFunction
on each input vector.vectors
- the input vectorsf
- the real scalar functionf
on the vectorspublic static Vector foreachVector(Collection<Vector> vectors, RealScalarFunction f)
RealScalarFunction
on each input vector.vectors
- the input vectorsf
- the real scalar functionf
on the vectorspublic static Vector[] foreachVector(Vector[] vectors, RealVectorFunction f)
vectors
- the input vectorsf
- the real vector functionpublic static Vector[] foreachVector(Collection<Vector> vectors, RealVectorFunction f)
vectors
- the input vectorsf
- the real vector functionpublic static Vector getCoordinate(Vector[] vectors, int i)
vectors
- the input vectorsi
- the index to a vector entry; the coordinate indexpublic static Vector getCoordinate(Collection<Vector> vectors, int i)
vectors
- the input vectorsi
- the index to a vector entry; the coordinate indexpublic static List<Vector> getOffsetVectors(Vector v0, Vector dv, int a, int b)
v0
, the delta dv
, and
the range [a, b]
, the offset vectors are:
v0 + a * dv, v0 + (a + 1) * dv, ..., v0 + b * dv.
v0
- the reference vector v0
dv
- the change (base offset) made to the vector at each step dv
a
- the minimum multiple of dv
that is added to v0
b
- the maximum multiple of dv
that is added to v0
public static Vector[] cumsum(Vector[] arr)
arr
- an array of vectorspublic static Vector[] get0s(int dimension, int n)
n
0 vectors.dimension
- the dimension of the vectorsn
- the number of 0 vectorsn
0 vectorsCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.