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 Vectorabs(Vector v)Computes the absolute values of a vector, element-by-element.DenseVectoradd(Vector v1, double c)Adds a constant to a vector, element-by-element.DenseVectoradd(Vector v1, Vector v2)Adds two vectors, element-by-element.doubleangle(Vector v1, Vector v2)Computes the angle between two vectors.static Vectorcos(Vector v)Computes the cosine of a vector, element-by-element.DenseVectordivide(Vector v1, Vector v2)A vector is divided by another vector, element-by-element.static Vectorexp(Vector v)Computes the exponential of a vector, element-by-element.doubleinnerProduct(Vector v1, Vector v2)Computes the inner or dot product of two vectors.static Vectorlog(Vector v)Computes the log of a vector, element-by-element.DenseVectorminus(Vector v1, double c)Subtracts a constant from a vector, element-by-element.DenseVectorminus(Vector v1, Vector v2)A vector subtracts another vector, element-by-element.DenseVectormultiply(Vector v1, Vector v2)Multiplies two vectors, element-by-element.doublenorm(Vector v1)Computes the norm of a vector.doublenorm(Vector v1, double p)Computes the norm of a vector.DenseVectoropposite(Vector v1)Multiples a vector by -1, element-by-element.DenseVectorpow(Vector v1, double c)Takes a power of a vector, element-by-element.static Vectorrbinom(int n, int nTrials, Vector p)Generatesnrandom binomial numbers.static Vectorrbinom(int n, int nTrials, Vector p, RandomLongGenerator uniform)Generatesnrandom binomial numbers.static Vectorrnorm(int n)Generatesnrandom standard Normals.static Vectorrnorm(int n, RandomStandardNormalGenerator z)Generatesnrandom standard Normals.DenseVectorscaled(Vector v1, double c)Scales a vector, element-by-element.DenseVectorscaled(Vector v1, Real c)Scales a vector, element-by-element.static Vectorsin(Vector v)Computes the sine of a vector, element-by-element.static Vectorsqrt(Vector v)Computes the square roots of a vector, element-by-element.static Vectorsquared(Vector v)Computes the squares of a vector, element-by-element.static doublesum(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
v1andv2
-
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)
Generatesnrandom standard Normals.- Parameters:
n- a number or a countz- a standard random Normal generator- Returns:
nrandom standard Normals
-
rnorm
public static Vector rnorm(int n)
Generatesnrandom standard Normals.- Parameters:
n- a number or a count- Returns:
nrandom standard Normals
-
rbinom
public static Vector rbinom(int n, int nTrials, Vector p, RandomLongGenerator uniform)
Generatesnrandom 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:
nrandom binomial Normals
-
-