Package org.jblas
Class MatrixFunctions
- java.lang.Object
-
- org.jblas.MatrixFunctions
-
public class MatrixFunctions extends java.lang.Object
This class provides the functions from java.lang.Math for matrices. The functions are applied to each element of the matrix.- Author:
- Mikio Braun
-
-
Constructor Summary
Constructors Constructor Description MatrixFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
abs(double x)
static float
abs(float x)
static DoubleMatrix
abs(DoubleMatrix x)
Returns a copy of this matrix where all elements are set to their absolute values.static FloatMatrix
abs(FloatMatrix x)
Returns a copy of this matrix where all elements are set to their absolute values.static ComplexDoubleMatrix
absi(ComplexDoubleMatrix x)
static ComplexFloatMatrix
absi(ComplexFloatMatrix x)
static DoubleMatrix
absi(DoubleMatrix x)
Sets all elements in this matrix to their absolute values.static FloatMatrix
absi(FloatMatrix x)
Sets all elements in this matrix to their absolute values.static double
acos(double x)
static float
acos(float x)
static DoubleMatrix
acos(DoubleMatrix x)
Returns a copy of this matrix where the trigonometric acos function is applied element wise.static FloatMatrix
acos(FloatMatrix x)
Returns a copy of this matrix where the trigonometric acos function is applied element wise.static DoubleMatrix
acosi(DoubleMatrix x)
Applies the trigonometric arccosine function element wise on this matrix.static FloatMatrix
acosi(FloatMatrix x)
Applies the trigonometric arccosine function element wise on this matrix.static double
asin(double x)
static float
asin(float x)
static DoubleMatrix
asin(DoubleMatrix x)
static FloatMatrix
asin(FloatMatrix x)
static DoubleMatrix
asini(DoubleMatrix x)
Applies the trigonometric arcsine function element wise on this matrix.static FloatMatrix
asini(FloatMatrix x)
Applies the trigonometric arcsine function element wise on this matrix.static double
atan(double x)
static float
atan(float x)
static DoubleMatrix
atan(DoubleMatrix x)
static FloatMatrix
atan(FloatMatrix x)
static DoubleMatrix
atani(DoubleMatrix x)
Applies the trigonometric arctangend function element wise on this matrix.static FloatMatrix
atani(FloatMatrix x)
Applies the trigonometric arctangend function element wise on this matrix.static double
cbrt(double x)
static float
cbrt(float x)
static DoubleMatrix
cbrt(DoubleMatrix x)
static FloatMatrix
cbrt(FloatMatrix x)
static DoubleMatrix
cbrti(DoubleMatrix x)
Applies the cube root function element wise on this matrix.static FloatMatrix
cbrti(FloatMatrix x)
Applies the cube root function element wise on this matrix.static double
ceil(double x)
static float
ceil(float x)
static DoubleMatrix
ceil(DoubleMatrix x)
static FloatMatrix
ceil(FloatMatrix x)
static DoubleMatrix
ceili(DoubleMatrix x)
Element-wise round up by applying the ceil function on each element.static FloatMatrix
ceili(FloatMatrix x)
Element-wise round up by applying the ceil function on each element.static double
cos(double x)
static float
cos(float x)
static DoubleMatrix
cos(DoubleMatrix x)
static FloatMatrix
cos(FloatMatrix x)
static double
cosh(double x)
static float
cosh(float x)
static DoubleMatrix
cosh(DoubleMatrix x)
static FloatMatrix
cosh(FloatMatrix x)
static DoubleMatrix
coshi(DoubleMatrix x)
Applies the hyperbolic cosine function element-wise on this matrix.static FloatMatrix
coshi(FloatMatrix x)
Applies the hyperbolic cosine function element-wise on this matrix.static DoubleMatrix
cosi(DoubleMatrix x)
Applies the cosine function element-wise on this matrix.static FloatMatrix
cosi(FloatMatrix x)
Applies the cosine function element-wise on this matrix.static FloatMatrix
doubleToFloat(DoubleMatrix dm)
static double
exp(double x)
static float
exp(float x)
static DoubleMatrix
exp(DoubleMatrix x)
static FloatMatrix
exp(FloatMatrix x)
static DoubleMatrix
expi(DoubleMatrix x)
Applies the exponential function element-wise on this matrix.static FloatMatrix
expi(FloatMatrix x)
Applies the exponential function element-wise on this matrix.static DoubleMatrix
expm(DoubleMatrix A)
Calculate matrix exponential of a square matrix.static FloatMatrix
expm(FloatMatrix A)
Calculate matrix exponential of a square matrix.static DoubleMatrix
floatToDouble(FloatMatrix fm)
static double
floor(double x)
static float
floor(float x)
static DoubleMatrix
floor(DoubleMatrix x)
static FloatMatrix
floor(FloatMatrix x)
static DoubleMatrix
floori(DoubleMatrix x)
Element-wise round down by applying the floor function on each element.static FloatMatrix
floori(FloatMatrix x)
Element-wise round down by applying the floor function on each element.static double
log(double x)
static float
log(float x)
static DoubleMatrix
log(DoubleMatrix x)
static FloatMatrix
log(FloatMatrix x)
static double
log10(double x)
static float
log10(float x)
static DoubleMatrix
log10(DoubleMatrix x)
static FloatMatrix
log10(FloatMatrix x)
static DoubleMatrix
log10i(DoubleMatrix x)
Applies the logarithm with basis to 10 element-wise on this matrix.static FloatMatrix
log10i(FloatMatrix x)
Applies the logarithm with basis to 10 element-wise on this matrix.static DoubleMatrix
logi(DoubleMatrix x)
Applies the natural logarithm function element-wise on this matrix.static FloatMatrix
logi(FloatMatrix x)
Applies the natural logarithm function element-wise on this matrix.static double
pow(double x, double y)
static DoubleMatrix
pow(double b, DoubleMatrix x)
static float
pow(float x, float y)
static FloatMatrix
pow(float b, FloatMatrix x)
static DoubleMatrix
pow(DoubleMatrix x, double e)
static DoubleMatrix
pow(DoubleMatrix x, DoubleMatrix e)
static FloatMatrix
pow(FloatMatrix x, float e)
static FloatMatrix
pow(FloatMatrix x, FloatMatrix e)
static DoubleMatrix
powi(double base, DoubleMatrix x)
static FloatMatrix
powi(float base, FloatMatrix x)
static DoubleMatrix
powi(DoubleMatrix x, double d)
Element-wise power function.static DoubleMatrix
powi(DoubleMatrix x, DoubleMatrix e)
static FloatMatrix
powi(FloatMatrix x, float d)
Element-wise power function.static FloatMatrix
powi(FloatMatrix x, FloatMatrix e)
static double
signum(double x)
static float
signum(float x)
static DoubleMatrix
signum(DoubleMatrix x)
static FloatMatrix
signum(FloatMatrix x)
static DoubleMatrix
signumi(DoubleMatrix x)
static FloatMatrix
signumi(FloatMatrix x)
static double
sin(double x)
static float
sin(float x)
static DoubleMatrix
sin(DoubleMatrix x)
static FloatMatrix
sin(FloatMatrix x)
static double
sinh(double x)
static float
sinh(float x)
static DoubleMatrix
sinh(DoubleMatrix x)
static FloatMatrix
sinh(FloatMatrix x)
static DoubleMatrix
sinhi(DoubleMatrix x)
static FloatMatrix
sinhi(FloatMatrix x)
static DoubleMatrix
sini(DoubleMatrix x)
static FloatMatrix
sini(FloatMatrix x)
static double
sqrt(double x)
static float
sqrt(float x)
static DoubleMatrix
sqrt(DoubleMatrix x)
static FloatMatrix
sqrt(FloatMatrix x)
static DoubleMatrix
sqrti(DoubleMatrix x)
static FloatMatrix
sqrti(FloatMatrix x)
static double
tan(double x)
static float
tan(float x)
static DoubleMatrix
tan(DoubleMatrix x)
static FloatMatrix
tan(FloatMatrix x)
static double
tanh(double x)
static float
tanh(float x)
static DoubleMatrix
tanh(DoubleMatrix x)
static FloatMatrix
tanh(FloatMatrix x)
static DoubleMatrix
tanhi(DoubleMatrix x)
static FloatMatrix
tanhi(FloatMatrix x)
static DoubleMatrix
tani(DoubleMatrix x)
static FloatMatrix
tani(FloatMatrix x)
-
-
-
Constructor Detail
-
MatrixFunctions
public MatrixFunctions()
-
-
Method Detail
-
absi
public static DoubleMatrix absi(DoubleMatrix x)
Sets all elements in this matrix to their absolute values. Note that this operation is in-place.- Returns:
- this matrix
- See Also:
abs(DoubleMatrix)
-
absi
public static ComplexDoubleMatrix absi(ComplexDoubleMatrix x)
-
acosi
public static DoubleMatrix acosi(DoubleMatrix x)
Applies the trigonometric arccosine function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
acos(DoubleMatrix)
-
asini
public static DoubleMatrix asini(DoubleMatrix x)
Applies the trigonometric arcsine function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
asin(DoubleMatrix)
-
atani
public static DoubleMatrix atani(DoubleMatrix x)
Applies the trigonometric arctangend function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
atan(DoubleMatrix)
-
cbrti
public static DoubleMatrix cbrti(DoubleMatrix x)
Applies the cube root function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
cbrt(DoubleMatrix)
-
ceili
public static DoubleMatrix ceili(DoubleMatrix x)
Element-wise round up by applying the ceil function on each element. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
ceil(DoubleMatrix)
-
cosi
public static DoubleMatrix cosi(DoubleMatrix x)
Applies the cosine function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
cos(DoubleMatrix)
-
coshi
public static DoubleMatrix coshi(DoubleMatrix x)
Applies the hyperbolic cosine function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
cosh(DoubleMatrix)
-
expi
public static DoubleMatrix expi(DoubleMatrix x)
Applies the exponential function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
exp(DoubleMatrix)
-
floori
public static DoubleMatrix floori(DoubleMatrix x)
Element-wise round down by applying the floor function on each element. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
floor(DoubleMatrix)
-
logi
public static DoubleMatrix logi(DoubleMatrix x)
Applies the natural logarithm function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
log(DoubleMatrix)
-
log10i
public static DoubleMatrix log10i(DoubleMatrix x)
Applies the logarithm with basis to 10 element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
log10(DoubleMatrix)
-
powi
public static DoubleMatrix powi(DoubleMatrix x, double d)
Element-wise power function. Replaces each element with its power of d.Note that this is an in-place operation.- Parameters:
d
- the exponent- Returns:
- this matrix
- See Also:
pow(DoubleMatrix,double)
-
powi
public static DoubleMatrix powi(double base, DoubleMatrix x)
-
powi
public static DoubleMatrix powi(DoubleMatrix x, DoubleMatrix e)
-
signumi
public static DoubleMatrix signumi(DoubleMatrix x)
-
sini
public static DoubleMatrix sini(DoubleMatrix x)
-
sinhi
public static DoubleMatrix sinhi(DoubleMatrix x)
-
sqrti
public static DoubleMatrix sqrti(DoubleMatrix x)
-
tani
public static DoubleMatrix tani(DoubleMatrix x)
-
tanhi
public static DoubleMatrix tanhi(DoubleMatrix x)
-
abs
public static DoubleMatrix abs(DoubleMatrix x)
Returns a copy of this matrix where all elements are set to their absolute values.- Returns:
- copy of this matrix
- See Also:
absi(DoubleMatrix)
-
acos
public static DoubleMatrix acos(DoubleMatrix x)
Returns a copy of this matrix where the trigonometric acos function is applied element wise.- Returns:
- copy of this matrix
- See Also:
acosi(DoubleMatrix)
-
asin
public static DoubleMatrix asin(DoubleMatrix x)
-
atan
public static DoubleMatrix atan(DoubleMatrix x)
-
cbrt
public static DoubleMatrix cbrt(DoubleMatrix x)
-
ceil
public static DoubleMatrix ceil(DoubleMatrix x)
-
cos
public static DoubleMatrix cos(DoubleMatrix x)
-
cosh
public static DoubleMatrix cosh(DoubleMatrix x)
-
exp
public static DoubleMatrix exp(DoubleMatrix x)
-
floor
public static DoubleMatrix floor(DoubleMatrix x)
-
log
public static DoubleMatrix log(DoubleMatrix x)
-
log10
public static DoubleMatrix log10(DoubleMatrix x)
-
pow
public static double pow(double x, double y)
-
pow
public static DoubleMatrix pow(DoubleMatrix x, double e)
-
pow
public static DoubleMatrix pow(double b, DoubleMatrix x)
-
pow
public static DoubleMatrix pow(DoubleMatrix x, DoubleMatrix e)
-
signum
public static DoubleMatrix signum(DoubleMatrix x)
-
sin
public static DoubleMatrix sin(DoubleMatrix x)
-
sinh
public static DoubleMatrix sinh(DoubleMatrix x)
-
sqrt
public static DoubleMatrix sqrt(DoubleMatrix x)
-
tan
public static DoubleMatrix tan(DoubleMatrix x)
-
tanh
public static DoubleMatrix tanh(DoubleMatrix x)
-
abs
public static double abs(double x)
-
acos
public static double acos(double x)
-
asin
public static double asin(double x)
-
atan
public static double atan(double x)
-
cbrt
public static double cbrt(double x)
-
ceil
public static double ceil(double x)
-
cos
public static double cos(double x)
-
cosh
public static double cosh(double x)
-
exp
public static double exp(double x)
-
floor
public static double floor(double x)
-
log
public static double log(double x)
-
log10
public static double log10(double x)
-
signum
public static double signum(double x)
-
sin
public static double sin(double x)
-
sinh
public static double sinh(double x)
-
sqrt
public static double sqrt(double x)
-
tan
public static double tan(double x)
-
tanh
public static double tanh(double x)
-
expm
public static DoubleMatrix expm(DoubleMatrix A)
Calculate matrix exponential of a square matrix. A scaled Pade approximation algorithm is used. The algorithm has been directly translated from Golub & Van Loan "Matrix Computations", algorithm 11.3.1. Special Horner techniques from 11.2 are also used to minimize the number of matrix multiplications.- Parameters:
A
- square matrix- Returns:
- matrix exponential of A
-
floatToDouble
public static DoubleMatrix floatToDouble(FloatMatrix fm)
-
doubleToFloat
public static FloatMatrix doubleToFloat(DoubleMatrix dm)
-
absi
public static FloatMatrix absi(FloatMatrix x)
Sets all elements in this matrix to their absolute values. Note that this operation is in-place.- Returns:
- this matrix
- See Also:
abs(FloatMatrix)
-
absi
public static ComplexFloatMatrix absi(ComplexFloatMatrix x)
-
acosi
public static FloatMatrix acosi(FloatMatrix x)
Applies the trigonometric arccosine function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
acos(FloatMatrix)
-
asini
public static FloatMatrix asini(FloatMatrix x)
Applies the trigonometric arcsine function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
asin(FloatMatrix)
-
atani
public static FloatMatrix atani(FloatMatrix x)
Applies the trigonometric arctangend function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
atan(FloatMatrix)
-
cbrti
public static FloatMatrix cbrti(FloatMatrix x)
Applies the cube root function element wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
cbrt(FloatMatrix)
-
ceili
public static FloatMatrix ceili(FloatMatrix x)
Element-wise round up by applying the ceil function on each element. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
ceil(FloatMatrix)
-
cosi
public static FloatMatrix cosi(FloatMatrix x)
Applies the cosine function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
cos(FloatMatrix)
-
coshi
public static FloatMatrix coshi(FloatMatrix x)
Applies the hyperbolic cosine function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
cosh(FloatMatrix)
-
expi
public static FloatMatrix expi(FloatMatrix x)
Applies the exponential function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
exp(FloatMatrix)
-
floori
public static FloatMatrix floori(FloatMatrix x)
Element-wise round down by applying the floor function on each element. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
floor(FloatMatrix)
-
logi
public static FloatMatrix logi(FloatMatrix x)
Applies the natural logarithm function element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
log(FloatMatrix)
-
log10i
public static FloatMatrix log10i(FloatMatrix x)
Applies the logarithm with basis to 10 element-wise on this matrix. Note that this is an in-place operation.- Returns:
- this matrix
- See Also:
log10(FloatMatrix)
-
powi
public static FloatMatrix powi(FloatMatrix x, float d)
Element-wise power function. Replaces each element with its power of d.Note that this is an in-place operation.- Parameters:
d
- the exponent- Returns:
- this matrix
- See Also:
pow(FloatMatrix,float)
-
powi
public static FloatMatrix powi(float base, FloatMatrix x)
-
powi
public static FloatMatrix powi(FloatMatrix x, FloatMatrix e)
-
signumi
public static FloatMatrix signumi(FloatMatrix x)
-
sini
public static FloatMatrix sini(FloatMatrix x)
-
sinhi
public static FloatMatrix sinhi(FloatMatrix x)
-
sqrti
public static FloatMatrix sqrti(FloatMatrix x)
-
tani
public static FloatMatrix tani(FloatMatrix x)
-
tanhi
public static FloatMatrix tanhi(FloatMatrix x)
-
abs
public static FloatMatrix abs(FloatMatrix x)
Returns a copy of this matrix where all elements are set to their absolute values.- Returns:
- copy of this matrix
- See Also:
absi(FloatMatrix)
-
acos
public static FloatMatrix acos(FloatMatrix x)
Returns a copy of this matrix where the trigonometric acos function is applied element wise.- Returns:
- copy of this matrix
- See Also:
acosi(FloatMatrix)
-
asin
public static FloatMatrix asin(FloatMatrix x)
-
atan
public static FloatMatrix atan(FloatMatrix x)
-
cbrt
public static FloatMatrix cbrt(FloatMatrix x)
-
ceil
public static FloatMatrix ceil(FloatMatrix x)
-
cos
public static FloatMatrix cos(FloatMatrix x)
-
cosh
public static FloatMatrix cosh(FloatMatrix x)
-
exp
public static FloatMatrix exp(FloatMatrix x)
-
floor
public static FloatMatrix floor(FloatMatrix x)
-
log
public static FloatMatrix log(FloatMatrix x)
-
log10
public static FloatMatrix log10(FloatMatrix x)
-
pow
public static float pow(float x, float y)
-
pow
public static FloatMatrix pow(FloatMatrix x, float e)
-
pow
public static FloatMatrix pow(float b, FloatMatrix x)
-
pow
public static FloatMatrix pow(FloatMatrix x, FloatMatrix e)
-
signum
public static FloatMatrix signum(FloatMatrix x)
-
sin
public static FloatMatrix sin(FloatMatrix x)
-
sinh
public static FloatMatrix sinh(FloatMatrix x)
-
sqrt
public static FloatMatrix sqrt(FloatMatrix x)
-
tan
public static FloatMatrix tan(FloatMatrix x)
-
tanh
public static FloatMatrix tanh(FloatMatrix x)
-
abs
public static float abs(float x)
-
acos
public static float acos(float x)
-
asin
public static float asin(float x)
-
atan
public static float atan(float x)
-
cbrt
public static float cbrt(float x)
-
ceil
public static float ceil(float x)
-
cos
public static float cos(float x)
-
cosh
public static float cosh(float x)
-
exp
public static float exp(float x)
-
floor
public static float floor(float x)
-
log
public static float log(float x)
-
log10
public static float log10(float x)
-
signum
public static float signum(float x)
-
sin
public static float sin(float x)
-
sinh
public static float sinh(float x)
-
sqrt
public static float sqrt(float x)
-
tan
public static float tan(float x)
-
tanh
public static float tanh(float x)
-
expm
public static FloatMatrix expm(FloatMatrix A)
Calculate matrix exponential of a square matrix. A scaled Pade approximation algorithm is used. The algorithm has been directly translated from Golub & Van Loan "Matrix Computations", algorithm 11.3f.1. Special Horner techniques from 11.2f are also used to minimize the number of matrix multiplications.- Parameters:
A
- square matrix- Returns:
- matrix exponential of A
-
-