Class VectorMathOperation
- java.lang.Object
-
- dev.nm.algebra.linear.vector.doubles.dense.VectorMathOperation
-
public class VectorMathOperation extends Object
-
-
Constructor Summary
Constructors Constructor Description VectorMathOperation()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Vector
abs(Vector v)
Computes the absolute values of a vector, element-by-element.DenseVector
add(Vector v1, double c)
Adds a constant to a vector, element-by-element.DenseVector
add(Vector v1, Vector v2)
Adds two vectors, element-by-element.double
angle(Vector v1, Vector v2)
Computes the angle between two vectors.static Vector
cos(Vector v)
Computes the cosine of a vector, element-by-element.DenseVector
divide(Vector v1, Vector v2)
A vector is divided by another vector, element-by-element.static Vector
exp(Vector v)
Computes the exponential of a vector, element-by-element.double
innerProduct(Vector v1, Vector v2)
Computes the inner or dot product of two vectors.static Vector
log(Vector v)
Computes the log of a vector, element-by-element.DenseVector
minus(Vector v1, double c)
Subtracts a constant from a vector, element-by-element.DenseVector
minus(Vector v1, Vector v2)
A vector subtracts another vector, element-by-element.DenseVector
multiply(Vector v1, Vector v2)
Multiplies two vectors, element-by-element.double
norm(Vector v1)
Computes the norm of a vector.double
norm(Vector v1, double p)
Computes the norm of a vector.DenseVector
opposite(Vector v1)
Multiples a vector by -1, element-by-element.DenseVector
pow(Vector v1, double c)
Takes a power of a vector, element-by-element.static Vector
rbinom(int n, int nTrials, Vector p)
Generatesn
random binomial numbers.static Vector
rbinom(int n, int nTrials, Vector p, RandomLongGenerator uniform)
Generatesn
random binomial numbers.static Vector
rnorm(int n)
Generatesn
random standard Normals.static Vector
rnorm(int n, RandomStandardNormalGenerator z)
Generatesn
random standard Normals.DenseVector
scaled(Vector v1, double c)
Scales a vector, element-by-element.DenseVector
scaled(Vector v1, Real c)
Scales a vector, element-by-element.static Vector
sin(Vector v)
Computes the sine of a vector, element-by-element.static Vector
sqrt(Vector v)
Computes the square roots of a vector, element-by-element.static Vector
squared(Vector v)
Computes the squares of a vector, element-by-element.static double
sum(Vector v)
Computes the sum of all vector elements.
-
-
-
Method Detail
-
add
public DenseVector add(Vector v1, Vector v2)
Adds two vectors, element-by-element.- Parameters:
v1
- a vectorv2
- a vector- Returns:
- \(v1 + v2\)
-
minus
public DenseVector minus(Vector v1, Vector v2)
A vector subtracts another vector, element-by-element.- Parameters:
v1
- a vectorv2
- a vector- Returns:
- \(v1 - v2\)
-
multiply
public DenseVector multiply(Vector v1, Vector v2)
Multiplies two vectors, element-by-element.- Parameters:
v1
- a vectorv2
- a vector- Returns:
- \(v1 * v2\)
-
divide
public DenseVector divide(Vector v1, Vector v2)
A vector is divided by another vector, element-by-element.- Parameters:
v1
- a vectorv2
- a vector- Returns:
- \(v1 / v2\)
-
innerProduct
public double innerProduct(Vector v1, Vector v2)
Computes the inner or dot product of two vectors.- Parameters:
v1
- a vectorv2
- a vector- Returns:
- \(<v1, v2>\)
-
pow
public DenseVector pow(Vector v1, double c)
Takes a power of a vector, element-by-element.- Parameters:
v1
- a vectorc
- a constant- Returns:
- \(v1 ^ c\)
-
scaled
public DenseVector scaled(Vector v1, double c)
Scales a vector, element-by-element.- Parameters:
v1
- a vectorc
- a constant- Returns:
- \(v1 * c\)
-
add
public DenseVector add(Vector v1, double c)
Adds a constant to a vector, element-by-element.- Parameters:
v1
- a vectorc
- a constant- Returns:
- \(v1 + c\)
-
minus
public DenseVector minus(Vector v1, double c)
Subtracts a constant from a vector, element-by-element.- Parameters:
v1
- a vectorc
- a constant- Returns:
- \(v1 - c\)
-
scaled
public DenseVector scaled(Vector v1, Real c)
Scales a vector, element-by-element.- Parameters:
v1
- a vectorc
- a constant- Returns:
- \(v1 * c\)
-
opposite
public DenseVector opposite(Vector v1)
Multiples a vector by -1, element-by-element.- Parameters:
v1
- a vector- Returns:
- \(-v1\)
-
angle
public double angle(Vector v1, Vector v2)
Computes the angle between two vectors.- Parameters:
v1
- a vectorv2
- a vector- Returns:
- the angle between
v1
andv2
-
norm
public double norm(Vector v1, double p)
Computes the norm of a vector.- Parameters:
v1
- a vectorp
- the norm degree- Returns:
- the p-th norm of a vector
-
norm
public double norm(Vector v1)
Computes the norm of a vector.- Parameters:
v1
- a vector- Returns:
- \(|v1|\)
-
sum
public static double sum(Vector v)
Computes the sum of all vector elements.- Parameters:
v
- a vector- Returns:
- the element sum
-
squared
public static Vector squared(Vector v)
Computes the squares of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the squares
-
sqrt
public static Vector sqrt(Vector v)
Computes the square roots of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the square roots
-
abs
public static Vector abs(Vector v)
Computes the absolute values of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the absolute values
-
sin
public static Vector sin(Vector v)
Computes the sine of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the sine
-
cos
public static Vector cos(Vector v)
Computes the cosine of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the cosine
-
exp
public static Vector exp(Vector v)
Computes the exponential of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the exponential
-
log
public static Vector log(Vector v)
Computes the log of a vector, element-by-element.- Parameters:
v
- a vector- Returns:
- the log
-
rnorm
public static Vector rnorm(int n, RandomStandardNormalGenerator z)
Generatesn
random standard Normals.- Parameters:
n
- a number or a countz
- a standard random Normal generator- Returns:
n
random standard Normals
-
rnorm
public static Vector rnorm(int n)
Generatesn
random standard Normals.- Parameters:
n
- a number or a count- Returns:
n
random standard Normals
-
rbinom
public static Vector rbinom(int n, int nTrials, Vector p, RandomLongGenerator uniform)
Generatesn
random binomial numbers.- Parameters:
n
- a number or a countnTrials
- the number of trials, a natural numberp
- the success probability in each trial, [0, 1]uniform
- a uniform random number generator- Returns:
n
random binomial Normals
-
-