SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.vector.doubles.dense.operation
Class CreateVector

java.lang.Object
  extended by com.numericalmethod.suanshu.vector.doubles.dense.operation.CreateVector

public class CreateVector
extends java.lang.Object

These are the utility functions that create new instances of vectors from existing ones.


Method Summary
static DenseVector concat(java.util.Collection<Vector> vectors)
          Concatenate an array of vectors into one vector.
static DenseVector concat(Vector... vectors)
          Concatenate an array of vectors into one vector.
static DenseVector diagonal(Matrix A)
          Get the diagonal of a matrix as a vector.
static DenseVector foreach(Vector vector, UnivariateRealFunction f)
          Construct a new vector in which each entry is the result of applying a function to the corresponding entry of a vector.
static DenseVector foreachColumn(Matrix matrix, RealScalarFunction f)
          Construct a vector in which each entry is the result of applying a RealScalarFunction to each column of an input matrix.
static DenseVector foreachRow(Matrix matrix, RealScalarFunction f)
          Construct a vector in which each entry is the result of applying a RealScalarFunction to each row of an input matrix.
static DenseVector foreachVector(java.util.Collection<Vector> vectors, RealScalarFunction f)
          Apply a RealScalarFunction on each input vector.
static Vector[] foreachVector(java.util.Collection<Vector> vectors, RealVectorFunction f)
          Apply a real vector function on each input vector.
static DenseVector foreachVector(Vector[] vectors, RealScalarFunction f)
          Apply a RealScalarFunction on each input vector.
static Vector[] foreachVector(Vector[] vectors, RealVectorFunction f)
          Apply a real vector function on each input vector.
static DenseVector getCoordinate(java.util.Collection<Vector> vectors, int i)
          Get the vector entries from a particular coordinate.
static DenseVector getCoordinate(Vector[] vectors, int i)
          Get the vector entries from a particular coordinate.
static java.util.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 DenseVector subDiagonal(Matrix A)
          Get the sub-diagonal of a matrix as a vector.
static DenseVector subVector(Vector vector, int[] indices)
          Get a sub-vector from a vector according to a given array of ordered indices (repetition allowed).
static DenseVector subVector(Vector vector, int from, int to)
          Get a sub-vector from a vector.
static DenseVector superDiagonal(Matrix A)
          Get the super-diagonal of a matrix as a vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

concat

public static DenseVector concat(Vector... vectors)
Concatenate an array of vectors into one vector.

Parameters:
vectors - an array of vector, e.g., \((v_1, v_2, v_3, ...)\).
Returns:
\(c(v_1, v_2, v_3, ...)\)

concat

public static DenseVector concat(java.util.Collection<Vector> vectors)
Concatenate an array of vectors into one vector.

Parameters:
vectors - an array of vector, e.g., \((v_1, v_2, v_3, ...)\).
Returns:
\(c(v_1, v_2, v_3, ...)\)

foreach

public static DenseVector foreach(Vector vector,
                                  UnivariateRealFunction f)
Construct a new vector in which each entry is the result of applying a function to the corresponding entry of a vector.

Parameters:
f - the function to be applied to each entry of a vector
vector - a vector
Returns:
[f(vi)] for all is

subVector

public static DenseVector subVector(Vector vector,
                                    int from,
                                    int to)
Get a sub-vector from a vector.

Parameters:
vector - a vector
from - the beginning index
to - the ending index
Returns:
v[from : to]

subVector

public static DenseVector subVector(Vector vector,
                                    int[] indices)
Get a sub-vector from a vector according to a given array of ordered indices (repetition allowed).

Parameters:
vector - a vector
indices - the array of ordered indices (repetition allowed)
Returns:
a sub-vector

diagonal

public static DenseVector diagonal(Matrix A)
Get the diagonal of a matrix as a vector.

Parameters:
A - a matrix
Returns:
a vector whose entries are Ai

superDiagonal

public static DenseVector superDiagonal(Matrix A)
Get the super-diagonal of a matrix as a vector.

Parameters:
A - a matrix
Returns:
a vector whose entries are Ai,i+1

subDiagonal

public static DenseVector subDiagonal(Matrix A)
Get the sub-diagonal of a matrix as a vector.

Parameters:
A - a matrix
Returns:
a vector whose entries are Ai+1,i

foreachRow

public static DenseVector foreachRow(Matrix matrix,
                                     RealScalarFunction f)
Construct a vector in which each entry is the result of applying a RealScalarFunction to each row of an input matrix.

Parameters:
matrix - the input matrix
f - the real scalar function
Returns:
the vector containing the results

foreachColumn

public static DenseVector foreachColumn(Matrix matrix,
                                        RealScalarFunction f)
Construct a vector in which each entry is the result of applying a RealScalarFunction to each column of an input matrix.

Parameters:
matrix - the input matrix
f - the real scalar function
Returns:
the vector containing the results

foreachVector

public static DenseVector foreachVector(Vector[] vectors,
                                        RealScalarFunction f)
Apply a RealScalarFunction on each input vector.

Parameters:
vectors - the input vectors
f - the real scalar function
Returns:
the values after applying f on the vectors

foreachVector

public static DenseVector foreachVector(java.util.Collection<Vector> vectors,
                                        RealScalarFunction f)
Apply a RealScalarFunction on each input vector.

Parameters:
vectors - the input vectors
f - the real scalar function
Returns:
the values after applying f on the vectors

foreachVector

public static Vector[] foreachVector(Vector[] vectors,
                                     RealVectorFunction f)
Apply a real vector function on each input vector.

Parameters:
vectors - the input vectors
f - the real vector function
Returns:
the output vectors after applying the function

foreachVector

public static Vector[] foreachVector(java.util.Collection<Vector> vectors,
                                     RealVectorFunction f)
Apply a real vector function on each input vector.

Parameters:
vectors - the input vectors
f - the real vector function
Returns:
the output vectors after applying the function

getCoordinate

public static DenseVector getCoordinate(Vector[] vectors,
                                        int i)
Get the vector entries from a particular coordinate.

Parameters:
vectors - the input vectors
i - the index to a vector entry; the coordinate index
Returns:
a vector composed of the entries from a particular coordinate

getCoordinate

public static DenseVector getCoordinate(java.util.Collection<Vector> vectors,
                                        int i)
Get the vector entries from a particular coordinate.

Parameters:
vectors - the input vectors
i - the index to a vector entry; the coordinate index
Returns:
a vector composed of the entries from a particular coordinate

getOffsetVectors

public static java.util.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.

Parameters:
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
Returns:
a list containing the vector

SuanShu, a Java numerical and statistical library

Copyright © 2012 Numerical Method Inc. Ltd. All Rights Reserved.