|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lnsc.LinearAlgebra
Set of linear algebra functions for vectors and matrices.
Method Summary | |
static double[][][] |
add3DMatrices(double[][][] m1,
double[][][] m2)
Computes the element wise addition of two 3D matrices. |
static double[][][] |
adde3DMatrices(double[][][] m,
double[][][] ma)
Computes the addition of a 3Dmatrix to another one. |
static double[][] |
addeMatrices(double[][] m,
double[][] ma)
Computes the addition of a matrix to another one. |
static double[] |
addeVectors(double[] v,
double[] va)
Computes the addition of a vector to another one. |
static double[][] |
addMatrices(double[][] m1,
double[][] m2)
Computes the addition of two matrices. |
static double[] |
addVectors(double[] v1,
double[] v2)
Computes the addition of two vectors. |
static double[][][] |
appendMatrixBelow(double[][][] m1,
double[][][] m2)
Creates a new matrix made of two matrices one above the other. |
static double[][] |
appendMatrixBelow(double[][] m1,
double[][] m2)
Creates a new matrix made of two matrices one above the other. |
static double[][] |
appendMatrixBesides(double[][] m1,
double[][] m2)
Creates a new matrix made of two matrices one beside the other. |
static double[][] |
appendNewColumns(double[][] m,
int count)
Creates a new matrix which is like the original but with a few more columns (0's initialized). |
static double[][] |
batchSubVectors(double[][] setA,
double[][] setB)
Applies subVectors(double[], double[]) on a batch of vector pairs. |
static double[] |
concatenateCols(double[][] m)
Creates a new vector from the concatenation of the columns of the given matrix. |
static double[] |
concatenateRows(double[][] m)
Creates a new vector from the concatenation of the rows of the given matrix. |
static double[] |
concatenateVectors(double[] v1,
double[] v2)
Create a vector that is the concatenation of two other vectors. |
static double[][] |
copyMatrix(double[][] m)
Creates a copy of a given matrix. |
static double[] |
copyVector(double[] v)
Creates a copy of a given vector. |
static double[][] |
cutInCols(double[] v,
int rows)
Creates a matrix from a vector by cutting in columns. |
static double[][] |
cutInRows(double[] v,
int cols)
Creates a matrix from a vector by cutting in rows. |
static void |
eMatrix(double[][] target,
double[][] source)
Copies a matrix into another matrix. |
static double[][] |
extractColumns(double[][] m,
int start,
int count)
Creates a new matrix which is like the original but with only the requested middle columns. |
static int[][] |
extractColumns(int[][] m,
int start,
int count)
Creates a new matrix which is like the original but with only the requested middle columns. |
static double[][] |
extractRows(double[][] m,
int start,
int count)
Creates a new matrix which is like the original but with only the requested middle rows. |
static int[][] |
extractRows(int[][] m,
int start,
int count)
Creates a new matrix which is like the original but with only the requested middle rows. |
static double[] |
extractVector(double[] v,
int start,
int stop)
Creates a vector by extract a contiguous portion of a larger vector. |
static boolean |
is3DMatrix(java.lang.Object m)
Checks whether a given object is of type double[][][] and
whether sub matrices are of the same dimensions. |
static boolean |
isMatrix(java.lang.Object m)
Checks whether a given object is of type double[][] and
whether sub vectors are of the same length. |
static boolean |
isMatrix(java.lang.Object m,
int rows,
int cols)
Checks whether a given object is of type double[rows][cols] . |
static boolean |
isSquareMatrix(double[][] m)
Check whether the matrix is a 2D squared matrix (row = col). |
static boolean |
isSquareMatrix(double[][][] m)
Check whether the matrix is a 3D squared matrix (row = col = slabs). |
static boolean |
isSquareMatrix(double[][][][] m)
Check whether the matrix is a 4D squared matrix (row = col = slabs = hyperslabs). |
static boolean |
isVector(java.lang.Object v)
Checks whether a given object is of type double[] . |
static boolean |
isVector(java.lang.Object v,
int size)
Checks whether a given object is of type double[size] . |
static double[][] |
multMatrixMatrix(double[][] m1,
double[][] m2)
Computes the multiplication of two matrices. |
static double[] |
multMatrixVector(double[][] m,
double[] v)
Computes the multiplication of a matrix times a column vector. |
static double[][][] |
multScalar3DMatrix(double s,
double[][][] m)
Computes the multiplication of a matrix times a scalar. |
static double[][] |
multScalarMatrix(double s,
double[][] m)
Computes the multiplication of a matrix times a scalar. |
static double[] |
multScalarVector(double s,
double[] v)
Computes the multiplication of a vector times a scalar. |
static double[] |
multVectorMatrix(double[] v,
double[][] m)
Computes the multiplication of a matrix times a vector. |
static double[][] |
multVectorVector(double[] v1,
double[] v2)
Computes the multiplication of a vector times a vector. |
static void |
normalizeVector(double[] v)
Normalize a vector so that its (euclidien) norm sum to 1. |
static void |
overwriteSubMatrix(int startRow,
int startCol,
double[][] source,
double[][] target)
Copies a sub matrix into a large matrix at a given position. |
static void |
overwriteSubVector(int start,
double[] source,
double[] target)
Copies a sub vector into a large vector at a given position. |
static void |
overwriteSubVector(int start,
int length,
double[] source,
double[] target)
Copies a sub vector into another vector at a given position. |
static double[] |
rotateVector(double[] v,
double angle)
Computes the 2D rotated vector by the given angle. |
static double |
sign(double x)
Returns the sign of a number. |
static double[][] |
subMatrices(double[][] m1,
double[][] m2)
Computes the subtraction of two matrices. |
static double[] |
subVectors(double[] v1,
double[] v2)
Computes the subtraction of two vectors. |
static double[][] |
sumMatrices(double[][][] Ms)
Sums elementwise a vector of matrices. |
static double |
sumSquares(double[] v)
Computes the sum of the squares of each element of a vector. |
static double |
sumSquares(double[][] m)
Computes the sum of the squares of each element of a matrix. |
static double |
sumSquares(double[][][] m)
Computes the sum of the squares of each element of a 3D matrix. |
static java.lang.String |
toString(double[] v)
Generates a Object.toString() representation of a
vector. |
static java.lang.String |
toString(double[][] m)
Generates a Object.toString() representation of a
matrix (as defined by isMatrix(java.lang.Object) ). |
static java.lang.String |
toString(double[][][] m)
Generates a Object.toString() representation of a
3D matrix of integer (as defined by is3DMatrix(java.lang.Object) ). |
static java.lang.String |
toString(int[] v)
Generates a Object.toString() representation of a
vector of integer. |
static java.lang.String |
toString(int[][] m)
Generates a Object.toString() representation of a
matrix of integer (as defined by isMatrix(java.lang.Object) ). |
static double[][] |
transposeMatrix(double[][] m)
Creates the transposed matrix. |
static double[][][][] |
transposeMatrix(double[][][][] m,
int[] transposeOrder)
|
static double[][][] |
transposeMatrix(double[][][] m,
int[] transposeOrder)
|
static double |
weightedSum(double[] ws,
double[] Ss)
Computes a weighted sum of scalars. |
static double[] |
weightedSum(double[] ws,
double[][] Vs)
Computes a weighted summation of vectors. |
static double[][] |
weightedSum(double[] ws,
double[][][] Ms)
Computes a weighted summation of matrices. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static final double[][][] add3DMatrices(double[][][] m1, double[][][] m2)
m1
- The first 3D matrixm2
- The second 3D matrix.
m1+m2
;public static final double[][][] adde3DMatrices(double[][][] m, double[][][] ma)
m
- The source and target 3D matrix.ma
- The 3D matrix to add to it
m+=ma
(m);public static final double[][] addeMatrices(double[][] m, double[][] ma)
m
- The source and target matrix.ma
- The matrix to add to it
m+=ma
(m);public static final double[] addeVectors(double[] v, double[] va)
v
- The source and target vector.va
- The vector to add to it
v+=va
(v);public static final double[][] addMatrices(double[][] m1, double[][] m2)
m1
- The first matrixm2
- The second matrix.
m1+m2
;public static final double[] addVectors(double[] v1, double[] v2)
v1
- The first vector.v2
- The second vector.
v1+v2
;public static final double[][][] appendMatrixBelow(double[][][] m1, double[][][] m2)
m1
- The upper matrix (or block).m2
- The lower matrix (or block).
public static final double[][] appendMatrixBelow(double[][] m1, double[][] m2)
m1
- The upper matrix.m2
- The lower matrix.
public static final double[][] appendMatrixBesides(double[][] m1, double[][] m2)
m1
- The left matrix.m2
- The right matrix.
public static final double[][] appendNewColumns(double[][] m, int count)
m
- The matrix.count
- The number of new columns.
public static final double[][] batchSubVectors(double[][] setA, double[][] setB)
subVectors(double[], double[])
on a batch of vector pairs. That is,
SetA[0]-SetB[0], SetA[1]-SetB[1], ...
setA
- Array of first vectors in substraction.setB
- Array of second vectors in subtraction.
public static final double[] concatenateCols(double[][] m)
cutInCols(double[], int)
.
m
- The matrix to convert.
public static final double[] concatenateRows(double[][] m)
cutInRows(double[], int)
.
m
- The matrix to convert.
public static final double[] concatenateVectors(double[] v1, double[] v2)
v1
- The first vector.v2
- The second vector.
[v1|v2]
.public static final double[][] copyMatrix(double[][] m)
m
- The matrix to be copied.
public static final double[] copyVector(double[] v)
v
- The vector to be copied.
public static final double[][] cutInCols(double[] v, int rows)
concatenateCols(double[][])
.
v
- The vector to convert.rows
- Length of each columns extracted from the vector.
public static final double[][] cutInRows(double[] v, int cols)
concatenateRows(double[][])
.
v
- The vector to convert.cols
- Length of each rows extracted from the vector.
public static final void eMatrix(double[][] target, double[][] source)
target
- Matrix that will be overwitten.source
- Matrix that will be read.public static final double[][] extractColumns(double[][] m, int start, int count)
m
- A matrix.start
- First column to kept.count
- The number of column to kept.
public static final int[][] extractColumns(int[][] m, int start, int count)
m
- A matrix.start
- First column to kept.count
- The number of column to kept.
public static final double[][] extractRows(double[][] m, int start, int count)
m
- A matrix.start
- First column to kept.count
- The number of column to kept.
public static final int[][] extractRows(int[][] m, int start, int count)
m
- A matrix.start
- First column to kept.count
- The number of column to kept.
public static final double[] extractVector(double[] v, int start, int stop)
v
- The source vector.start
- Index from where to begin the extraction, that
is, index of the first element of the new vector.stop
- Index from where to stop the extraction, that
is, index of the last element of the new vector.
v'=v[start..stop]
.public static final boolean is3DMatrix(java.lang.Object m)
double[][][]
and
whether sub matrices are of the same dimensions.
m
- Object to be tested.
true
is the object is of type
double[slab][colx][coly]
.public static final boolean isMatrix(java.lang.Object m)
double[][]
and
whether sub vectors are of the same length.
m
- Object to be tested.
true
is the object is of type
double[row][col]
.public static final boolean isMatrix(java.lang.Object m, int rows, int cols)
double[rows][cols]
.
m
- Object to be tested.rows
- Number of rows to check for.cols
- Number of columns to check for.
true
is the object is of type
double[rows][cols]
.public static boolean isSquareMatrix(double[][] m)
m
- The matrix to check
true
if the number of rows equals the number of columns.public static boolean isSquareMatrix(double[][][] m)
m
- The matrix to check
true
if the number of rows equals the number
of columns and the number of slabs.public static boolean isSquareMatrix(double[][][][] m)
m
- The matrix to check
true
if the number of rows equals the number
of columns, the number of slabs and the number of hyperslabs.public static final boolean isVector(java.lang.Object v)
double[]
.
v
- Object to be tested.
true
is the object is of type
double[]
.public static final boolean isVector(java.lang.Object v, int size)
double[size]
.
v
- Object to be tested.size
- Size to check for.
true
is the object is of type
double[size]
.public static final double[][] multMatrixMatrix(double[][] m1, double[][] m2)
m1
- The first matrix.m2
- The second matrix.
public static final double[] multMatrixVector(double[][] m, double[] v)
m
- The matrix.v
- The vector.
public static final double[][][] multScalar3DMatrix(double s, double[][][] m)
s
- The scalar.m
- The 3D matrix.
public static final double[][] multScalarMatrix(double s, double[][] m)
s
- The scalar.m
- The matrix.
public static final double[] multScalarVector(double s, double[] v)
s
- The scalar.v
- The vector.
public static final double[] multVectorMatrix(double[] v, double[][] m)
v
- The vector.m
- The matrix.
public static final double[][] multVectorVector(double[] v1, double[] v2)
v1
- The first (column) vector.v2
- The second (row) vector.
public static void normalizeVector(double[] v)
v
- The vector to normalize.public static final void overwriteSubMatrix(int startRow, int startCol, double[][] source, double[][] target)
startRow
- Index of the first row to overwrite.startCol
- Index of the second row to overwrite.source
- Small matrix that will be read.target
- Large matrix that will be partly overwritten.public static final void overwriteSubVector(int start, double[] source, double[] target)
start
- Index of the first element to overwrite.source
- Small vector that will be read.target
- Large vector that will be partly overwritten.public static final void overwriteSubVector(int start, int length, double[] source, double[] target)
start
- Index of the first element to overwritelength
- Length of the source vector to readsource
- Small vector that will be read.target
- Large vector that will be partly overwritten.public static final double[] rotateVector(double[] v, double angle)
v
- The vector to rotate.angle
- The angle of rotation in radian.
public static double sign(double x)
x
- The number to return the sign of.
-1
for negative, 1
for positive,
0
otherwise.public static final double[][] subMatrices(double[][] m1, double[][] m2)
m1
- The first matrix.m2
- The second matrix.
m1-m2
;public static final double[] subVectors(double[] v1, double[] v2)
v1
- The first vector.v2
- The second vector.
v1-v2
;public static double[][] sumMatrices(double[][][] Ms)
Ms
- Array of matrices.
public static double sumSquares(double[] v)
v
- The vector to compute the norm.
public static double sumSquares(double[][] m)
m
- The matrix to compute the norm.
public static double sumSquares(double[][][] m)
m
- The 3D matrix to compute the norm.
public static final java.lang.String toString(double[] v)
Object.toString()
representation of a
vector.
public static final java.lang.String toString(double[][] m)
Object.toString()
representation of a
matrix (as defined by isMatrix(java.lang.Object)
).
public static final java.lang.String toString(double[][][] m)
Object.toString()
representation of a
3D matrix of integer (as defined by is3DMatrix(java.lang.Object)
).
public static final java.lang.String toString(int[] v)
Object.toString()
representation of a
vector of integer.
public static final java.lang.String toString(int[][] m)
Object.toString()
representation of a
matrix of integer (as defined by isMatrix(java.lang.Object)
).
public static double[][] transposeMatrix(double[][] m)
m
- The matrix to be transposed.
public static double[][][][] transposeMatrix(double[][][][] m, int[] transposeOrder)
public static double[][][] transposeMatrix(double[][][] m, int[] transposeOrder)
public static double weightedSum(double[] ws, double[] Ss)
ws
- Vector of scalars (or weights)Ss
- Vector of scalars.
public static double[] weightedSum(double[] ws, double[][] Vs)
multScalarVector(double, double[])
of each
vector multiplied by its associated scalar and then call
#sumVectors
.
ws
- Vector of scalars (or weights)Vs
- Vector of vectors.
public static double[][] weightedSum(double[] ws, double[][][] Ms)
multScalarMatrix(double, double[][])
of each
matrix multiplied by its associated scalar and then call
sumMatrices(double[][][])
.
ws
- Vector of scalars (or weights)Ms
- Vector of matrices.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |