jhplot.math
Class LinearAlgebra
- java.lang.Object
-
- jhplot.math.DoubleArray
-
- jhplot.math.LinearAlgebra
-
public class LinearAlgebra extends DoubleArray
A collection of static methods for performing math operations on matrices and arrays. Advanced Linear Algebra methods (decompositions, norm, ...) are just call for JAMA routines.
-
-
Constructor Summary
Constructors Constructor and Description LinearAlgebra()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static CholeskyDecomposition
cholesky(double[][] v)
static double
cond(double[][] v)
static double
det(double[][] v)
static double[][]
divide(double[][] v1, double v)
Divide each element of a matrix by a scalarstatic double[][]
divide(double[][] v1, double[]... v2)
static double[]
divide(double[] v1, double v)
Divide each element of an array by a scalar.static double[]
divide(double[] v1, double[] v2)
Element-wise ratio of two arrays.static double[][]
divideLU(double[][] v1, double[]... v2)
static double[][]
divideQR(double[][] v1, double[]... v2)
static EigenvalueDecomposition
eigen(double[][] v)
static double[][]
inverse(double[][] v1)
static double[][]
inverseLU(double[][] v1)
static double[][]
inverseQR(double[][] v1)
static LUDecomposition
LU(double[][] v)
static double[][]
minus(double[][] v1, double v2)
Subtract a scalar from each element of a matrix.static double[][]
minus(double[][] v1, double[][] v2)
Element-wise subtraction of two matrices.static double[]
minus(double[] v1, double v)
Subtracts a scalar value from each element of an arraystatic double[]
minus(double[] v1, double[] v2)
Element-wise subtraction of two arrays.static double[]
minus(double v, double[] v1)
Subtracts each element of an array from a scalar value.static double[][]
minus(double v2, double[][] v1)
Subtract each element of a matrix from a scalar.static double
norm1(double[][] v)
static double
norm2(double[][] v)
static double
normF(double[][] v)
static double
normInf(double[][] v)
static double[]
plus(double[]... v)
Element-wise sum of any number of arrays.static double[][]
plus(double[][] v1, double v2)
Add a scalar to each element of a matrix.static double[][]
plus(double[][] v1, double[][] v2)
Element-wise sum of two matricesstatic double[]
plus(double[] v1, double v)
Add a scalar value to each element of an array.static QRDecomposition
QR(double[][] v)
static double[][]
raise(double[][] v, double n)
Raise each element of a matrix to a scalar powerstatic double[]
raise(double[] v1, double n)
Raise each element of an array to a scalar power.static int
rank(double[][] v)
static SingularValueDecomposition
singular(double[][] v)
static double[][]
solve(double[][] A, double[][] B)
static double[][]
solveTranspose(double[][] A, double[][] B)
static double[]
times(double[]... v)
Element-wise product of any number of arrays.static double[][]
times(double[][] v1, double v)
Multiply each element in a matrix by a scalarstatic double[]
times(double[][] v1, double[] v2)
Product of a matrix and a vector (array) according to the rules of linear algebra.static double[][]
times(double[][] v1, double[][] v2)
Matrix multiplication according to the rules of linear algebra.static double[]
times(double[] v1, double v)
Multiply each element of an array by a scalar.static double
trace(double[][] v)
-
Methods inherited from class jhplot.math.DoubleArray
add, add, buildXY, buildXY, checkColumnDimension, checkLength, checkRowDimension, columnVector, copy, copy, cumProduct, cumProduct, cumSum, cumSum, delete, deleteColumns, deleteColumnsRange, deleteRange, deleteRows, deleteRowsRange, diagonal, diagonal, f, f, fill, fill, findex, getColumnCopy, getColumnCopy, getColumnDimension, getColumnsCopy, getColumnsRangeCopy, getCopy, getDiagonal, getRangeCopy, getRowCopy, getRowsCopy, getRowsRangeCopy, getSubMatrixRangeCopy, identity, increment, increment, increment, increment, insert, insertColumns, insertRows, isColumnDimension, isLength, isRowDimension, main, max, max, maxIndex, maxIndex, merge, mergeColumns, mergeRows, min, min, minIndex, minIndex, one, one, one, one, product, product, random, random, random, random, random, resize, rowVector, sort, sort, sum, sum, throwError, toString, toString, transpose
-
-
-
-
Method Detail
-
minus
public static double[] minus(double[] v1, double[] v2)
Element-wise subtraction of two arrays. Arrays must be same size.- Parameters:
v1
- Minuend.v2
- Subtrahend- Returns:
- Array v1 - v2
-
minus
public static double[] minus(double[] v1, double v)
Subtracts a scalar value from each element of an array- Parameters:
v1
- Minuend Array.v
- Subtrahend scalar- Returns:
- Array v1 - v
-
minus
public static double[] minus(double v, double[] v1)
Subtracts each element of an array from a scalar value.- Parameters:
v
- Scalar Minuendv1
- Subtrahend array- Returns:
- Array v - v1
-
minus
public static double[][] minus(double[][] v1, double[][] v2)
Element-wise subtraction of two matrices. Matrices must be same size.- Parameters:
v1
- Minuend matrixv2
- Subtrahend matrix- Returns:
- Matrix v1 - v2
-
minus
public static double[][] minus(double[][] v1, double v2)
Subtract a scalar from each element of a matrix.- Parameters:
v1
- Minuend matrixv2
- Scalar subtrahend- Returns:
- Matrix v1 - v2
-
minus
public static double[][] minus(double v2, double[][] v1)
Subtract each element of a matrix from a scalar.- Parameters:
v2
- Scalar minuendv1
- Matrix subtrahend- Returns:
- Matrix v2 - v1
-
plus
public static double[] plus(double[]... v)
Element-wise sum of any number of arrays. Each array must be of same length.- Parameters:
v
- Any number of arrays- Returns:
- Element-wise sum of input arrays.
-
plus
public static double[] plus(double[] v1, double v)
Add a scalar value to each element of an array.- Parameters:
v1
- Arrayv
- Scalar- Returns:
- v1 + v
-
plus
public static double[][] plus(double[][] v1, double[][] v2)
Element-wise sum of two matrices- Parameters:
v1
- Matrixv2
- Matrix- Returns:
- Matrix v1 + v2
-
plus
public static double[][] plus(double[][] v1, double v2)
Add a scalar to each element of a matrix.- Parameters:
v1
- Matrixv2
- Scalar- Returns:
- Matrix v1 + v2
-
times
public static double[] times(double[]... v)
Element-wise product of any number of arrays. Each array must be same size.- Parameters:
v
- Any number of arrays.- Returns:
- Array. i'th element = v1(i)*v2(i)*v3(i)...
-
divide
public static double[] divide(double[] v1, double[] v2)
Element-wise ratio of two arrays.- Parameters:
v1
- Numeratorsv2
- Denominators- Returns:
- Array. i'th element = v1(i)/v2(i)
-
times
public static double[] times(double[] v1, double v)
Multiply each element of an array by a scalar.- Parameters:
v1
- Arrayv
- Scalar- Returns:
- v1 * v
-
times
public static double[][] times(double[][] v1, double v)
Multiply each element in a matrix by a scalar- Parameters:
v1
- Matrixv
- Scalar- Returns:
- v1 * v
-
divide
public static double[] divide(double[] v1, double v)
Divide each element of an array by a scalar.- Parameters:
v1
- Numerator Arrayv
- Scalar denominator- Returns:
- Array. i'th element is v1(i)/v
-
divide
public static double[][] divide(double[][] v1, double v)
Divide each element of a matrix by a scalar- Parameters:
v1
- Matrix numeratorv
- Scalar denominator- Returns:
- Matrix v1 / v
-
raise
public static double[] raise(double[] v1, double n)
Raise each element of an array to a scalar power.- Parameters:
v1
- Arrayn
- Scalar exponent- Returns:
- Array. i'th element is v(i)^n
-
raise
public static double[][] raise(double[][] v, double n)
Raise each element of a matrix to a scalar power- Parameters:
v
- Matrixn
- exponent- Returns:
- Matrix
-
times
public static double[][] times(double[][] v1, double[][] v2)
Matrix multiplication according to the rules of linear algebra. Matrices must be same size.- Parameters:
v1
- Matrixv2
- Matrix- Returns:
- Matrix v1 * v2
-
times
public static double[] times(double[][] v1, double[] v2)
Product of a matrix and a vector (array) according to the rules of linear algebra. Number of columns in v1 must equal number of elements in v2.- Parameters:
v1
- m x n Matrixv2
- n element array- Returns:
- m element array v1 * v2
- See Also:
times(double[][], double[][])
-
divideLU
public static double[][] divideLU(double[][] v1, double[]... v2)
-
divideQR
public static double[][] divideQR(double[][] v1, double[]... v2)
-
divide
public static double[][] divide(double[][] v1, double[]... v2)
-
inverseLU
public static double[][] inverseLU(double[][] v1)
-
inverseQR
public static double[][] inverseQR(double[][] v1)
-
inverse
public static double[][] inverse(double[][] v1)
-
solve
public static double[][] solve(double[][] A, double[][] B)
-
solveTranspose
public static double[][] solveTranspose(double[][] A, double[][] B)
-
eigen
public static EigenvalueDecomposition eigen(double[][] v)
-
QR
public static QRDecomposition QR(double[][] v)
-
LU
public static LUDecomposition LU(double[][] v)
-
cholesky
public static CholeskyDecomposition cholesky(double[][] v)
-
singular
public static SingularValueDecomposition singular(double[][] v)
-
cond
public static double cond(double[][] v)
-
det
public static double det(double[][] v)
-
rank
public static int rank(double[][] v)
-
trace
public static double trace(double[][] v)
-
norm1
public static double norm1(double[][] v)
-
norm2
public static double norm2(double[][] v)
-
normF
public static double normF(double[][] v)
-
normInf
public static double normInf(double[][] v)
-
-
DMelt 3.0 © DataMelt by jWork.ORG