This class defines a set of static methods for calculations with vectors and matrices using native Java arrays
without any enclosing object structures. Matrices are simple two-dimensional arrays A[r][c], where r
is the (vertical) row index and c is the (horizontal) column index (as
common in linear algebra). This means that matrices are really vectors of row vectors. Only arrays of type
float and double are supported. All matrices are assumed to be rectangular (i.e., all rows are of
equal length).
Note: Methods named with a trailing 'D' (e.g., multiplyD(double, double[])) operate destructively,
i.e., modify one of the supplied arguments.
- Version:
- 2022/08/29
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThrown when the dimensions of matrix/vector arguments do not match.static classThrown when a non-square matrix is encountered where a square matrix is assumed.static classThrown when source and target objects are identical but shouldn't.static classThrown when the length of some vector is zero. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault matrix symmetry tolerance.static charLeading delimiter used for lists of vector and matrix elements bytoString()methods.static LocaleLocale used for printing decimal numbers bytoString()methods.static charTrailing delimiter used for lists of vector and matrix elements bytoString()methods.static charCharacter used to separate successive vector and matrix elements bytoString()methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic double[][]add(double[][] A, double[][] B) Calculates and returns the sum of the specifieddoublematrix (non-destructively).static double[]add(double[] a, double[] b) Calculates and returns the sum of the specifieddoublevectors (non-destructively).static float[][]add(float[][] A, float[][] B) Calculates and returns the sum of the specifiedfloatmatrix (non-destructively).static float[]add(float[] a, float[] b) Calculates and returns the sum of the specifiedfloatvectors (non-destructively).static voidaddD(double[][] A, double[][] B) Adds the elements of the firstdoublematrix to the second vector (destructively).static voidaddD(double[] a, double[] b) Adds the elements of the firstdoublevector to the second vector (destructively).static voidaddD(float[][] A, float[][] B) Adds the elements of the firstfloatmatrix to the second vector (destructively).static voidaddD(float[] a, float[] b) Adds the elements of the firstfloatvector to the second vector (destructively).static voidcopyD(double[] source, double[] target) Copy data from onedouble[]vector to another.static voidcopyD(float[] source, float[] target) Copy data from onefloat[]vector to another.static doubledeterminant(double[][] A) Calculates and returns the determinant of the givendouble[][]matrix.static doubleCalculates and returns the determinant of the givenRealMatrix.static doubledeterminant2x2(double[][] A) Calculates and returns the determinant of the given 2x2double[][]matrix.static floatdeterminant2x2(float[][] A) Calculates and returns the determinant of the given 2x2float[][]matrix.static doubledeterminant3x3(double[][] A) Calculates and returns the determinant of the given 3x3double[][]matrix.static floatdeterminant3x3(float[][] A) Calculates and returns the determinant of the given 3x3float[][]matrix.double[][]diagMatrix(double[] d) Creates and returns a diagonal matrix from the specified vector.static doubledistL2(double[] a, double[] b) Calculates the L2 distance between two vectors (points) in n-dimensional space.static floatdistL2(float[] a, float[] b) Calculates the L2 distance between two vectors (points) in n-dimensional space.static doubledistL2squared(double[] a, double[] b) Calculates the squared L2 distance between two vectors (points) in n-dimensional space.static floatdistL2squared(float[] a, float[] b) Calculates the squared L2 distance between two vectors (points) in n-dimensional space.static doubledotProduct(double[] a, double[] b) Calculates and returns the dot (inner or scalar) product of two vectors, which must have the same length.static double[]duplicate(double[] a) Returns a copy of the givendouble[]vector.static double[][]duplicate(double[][] A) Returns a copy of the givendouble[][]matrix.static float[]duplicate(float[] a) Returns a copy of the givenfloat[]vector.static float[][]duplicate(float[][] A) Returns a copy of the givenfloat[][]matrix.static voidfillD(double[][] A, double val) Fills the givendoublematrix with the specified value (destructively).static voidfillD(double[] x, double val) Fills the givendoublevector with the specified value (destructively).static voidfillD(float[][] A, float val) Fills the givenfloatmatrix with the specified value (destructively).static voidfillD(float[] x, float val) Fills the givenfloatvector with the specified value (destructively).static double[]flatten(double[][] A) Returns the values of the specified matrix as adouble[]with elements arranged in row-major order.static float[]flatten(float[][] A) Returns the values of the specified matrix as afloat[]with elements arranged in row-major order.static double[]Returns the values of the specified matrix as adouble[]with elements arranged in row-major order.static double[][]fromLongBits(long[][] A) Converts along[][]with 64-bitdoublerepresentations to the equivalentdouble[][].static double[]getColumn(double[][] A, int c) Returns a particular column of the specifieddoublematrix as adoublevector.static float[]getColumn(float[][] A, int c) Returns a particular column of the specifiedfloatmatrix as afloatvector.static double[]getDiagonal(double[][] A) Returns a vector with the diagonal elements of the specified matrix.static float[]getDiagonal(float[][] A) Returns a vector with the diagonal elements of the specified matrix.static RealVectorReturns a vector with the diagonal elements of the specified matrix.static intgetNumberOfColumns(double[][] A) Returns the number of columns of the specifieddoublematrix.static intgetNumberOfColumns(float[][] A) Returns the number of columns of the specifiedfloatmatrix.static intReturns the number of columns of the specifiedRealMatrix.static intgetNumberOfRows(double[][] A) Returns the number of rows of the specifieddoublematrix.static intgetNumberOfRows(float[][] A) Returns the number of rows of the specifiedfloatmatrix.static intReturns the number of rows of the specifiedRealMatrix.static double[]getRow(double[][] A, int r) Returns a particular row of the specifieddoublematrix as adoublevector.static float[]getRow(float[][] A, int r) Returns a particular row of the specifiedfloatmatrix as afloatvector.static double[][]idMatrix(int size) Creates and returns a new identity matrix of the specified size.static intidxMax(double[] a) Returns the index of the largest element in the specified vector.static intidxMax(float[] a) Returns the index of the largest element in the specified vector.static intidxMin(double[] a) Returns the index of the smallest element in the specified vector.static intidxMin(float[] a) Returns the index of the smallest element in the specified vector.static double[][]inverse(double[][] A) Calculates and returns the inverse of the given matrix, which must be square.static float[][]inverse(float[][] A) Calculates and returns the inverse of the given matrix, which must be square.static booleanChecks is the given square matrix is positive definite.static booleanisPositiveDefinite(RealMatrix A, double tolerance) Checks is the given square matrix is positive definite, using the specified symmetry tolerance value.static booleanisRectangular(double[][] A) Checks if all rows of the given matrix have the same length.static booleanisRectangular(float[][] A) Checks if all rows of the given matrix have the same length.static booleanisSingular(double[][] A) Checks is the given squaredouble[][]matrix is non-singular.static booleanChecks is the given square matrix is non-singular.static booleanisSquare(double[][] A) Checks it the given matrix has the same number of rows and columns.static booleanisSquare(float[][] A) Checks it the given matrix has the same number of rows and columns.static booleanisSymmetric(double[][] A) Checks is the given square matrix is symmetric, using the default tolerance value (Arithmetic.EPSILON_DOUBLE).static booleanisSymmetric(double[][] A, double relTolerance) Checks is the given square matrix is symmetric using the specified relative tolerance.static booleanChecks is the given square matrix is symmetric, using the default tolerance value (Arithmetic.EPSILON_DOUBLE).static booleanisSymmetric(RealMatrix A, double relTolerance) Checks is the given square matrix is symmetric using the specified relative tolerance.static booleanisZero(double[] a) Checks if all elements of the specifieddouble[]vector are zero using the default tolerance value (Arithmetic.EPSILON_DOUBLE).static booleanisZero(double[][] A) Checks if all elements of the specifieddouble[][]matrix are zero using default tolerance value (Arithmetic.EPSILON_DOUBLE).static booleanisZero(double[][] A, double tolerance) Checks if all elements of the specifieddouble[][]matrix are zero using the specified tolerance value.static booleanisZero(double[] a, double tolerance) Checks if all elements of the specifieddouble[]vector are zero using the specified tolerance value.static booleanisZero(float[] a) Checks if all elements of the specifiedfloat[]vector are zero using the default tolerance value (Arithmetic.EPSILON_DOUBLE).static booleanisZero(float[] a, float tolerance) Checks if all elements of the specifiedfloat[]vector are zero using the specified tolerance value.static double[]join(double[]... as) Joins (concatenates) a sequence of vectors into a single vector.static float[]join(float[]... as) Joins (concatenates) a sequence of vectors into a single vector.static double[]lerp(double[] a, double[] b, double t) Performs linear interpolation between two vectorsaandb, which must have the same length.static float[]lerp(float[] a, float[] b, float t) Performs linear interpolation between two vectorsaandb, which must have the same length.static double[][]makeDoubleMatrix(int rows, int cols, double... values) Creates and returns adouble[][]matrix containing the specified values.static double[]makeDoubleVector(double... values) Creates and returns adouble[]vector from the specified values.static float[][]makeFloatMatrix(int rows, int cols, float... values) Creates and returns afloat[][]matrix containing the specified values.static float[]makeFloatVector(float... values) Creates and returns afloat[]vector from the specified values.static RealMatrixmakeRealMatrix(int rows, int cols, double... values) Creates and returns aRealMatrixcontaining the specifieddoublevalues.static RealVectormakeRealVector(double... values) Creates and returns aRealVectorfrom the specifieddoublevalues.static doublemax(double[] a) Returns the largest value in the specifieddouble[]vector.static doublemax(double[][] A) Returns the largest value in the specifieddouble[][]matrix.static floatmax(float[] a) Returns the largest value in the specifiedfloat[]vector.static floatmax(float[][] A) Returns the largest value in the specifiedfloat[][]matrix.static doublemin(double[] a) Returns the smallest value in the specified vector.static floatmin(float[] a) Returns the smallest value in the specified vector.static double[]multiply(double[][] A, double[] x) Multiplies a matrix A with a vector x "from the right", i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector.static double[][]multiply(double[][] A, double[][] B) Returns the product of twodouble[][]matrices A, B as a newdouble[][]matrix.static double[]multiply(double[] x, double[][] A) Multiplies a vector x with a matrix A "from the left", i.e., y = x * A, where x is treated as a row vector and the result y is also a row vector.static double[]multiply(double s, double[] x) Multiplies adouble[]vector by a scalar and returns a newdouble[]vector (non-destructive).static double[][]multiply(double s, double[][] A) Multiplies adouble[][]matrix by a scalar and returns a newdouble[][]matrix (non-destructive).static float[]multiply(float[][] A, float[] x) Multiplies a matrix A with a vector x from the right, i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector.static float[][]multiply(float[][] A, float[][] B) Returns the product of twofloat[][]matrices A, B as a newfloat[][]matrix.static float[]multiply(float s, float[] x) Multiplies afloat[]vector by a scalar and returns a newfloat[]vector (non-destructive).static float[][]multiply(float s, float[][] A) Multiplies afloat[][]matrix by a scalar and returns a newfloat[][]matrix (non-destructive).static voidmultiplyD(double[][] A, double[][] B, double[][] C) Calculates the product of twodouble[][]matrices A, B and places the results in the thirddouble[][]matrix C, which is modified (destructively).static voidmultiplyD(double[][] A, double[] x, double[] y) Multiplies a matrix A with a vector x "from the right", i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector.static voidmultiplyD(double[] x, double[][] A, double[] y) Destructive version ofmultiply(double[], double[][]).static voidmultiplyD(double s, double[] x) Multiplies adouble[]vector by a scalar.static voidmultiplyD(double s, double[][] A) Multiplies adouble[][]matrix by a scalar.static voidmultiplyD(float[][] A, float[][] B, float[][] C) Calculates the product of twofloat[][]matrices A, B and places the results in the thirdfloat[][]matrix C, which is modified (destructively).static voidmultiplyD(float[][] A, float[] x, float[] y) Multiplies a matrix A with a vector x "from the right", i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector.static voidmultiplyD(float s, float[] x) Multiplies afloat[]vector by a scalar.static voidmultiplyD(float s, float[][] A) Multiplies afloat[][]matrix by a scalar.static doublenorm(double[][] A) Calculates and returns the Froebenius norm of the given matrix.static double[]normalize(double[] a) Normalizes the specifieddouble[]vector to unit (L2) norm and returns the result as a newdouble[]vector.static float[]normalize(float[] a) Normalizes the specifiedfloat[]vector to unit (L2) norm and returns the result as a newfloat[]vector.static voidnormalizeD(double[] a) Normalizes the specifieddouble[]vector to unit (L2) norm.static voidnormalizeD(float[] a) Normalizes the specifiedfloat[]vector to unit (L2) norm.static doublenormL1(double[] a) Calculates and returns the L1 norm of the given vector.static floatnormL1(float[] a) Calculates and returns the L1 norm of the given vector.static doublenormL2(double[] a) Calculates and returns the L2 norm of the given vector.static floatnormL2(float[] x) Calculates and returns the L2 norm of the given vector.static doublenormL2squared(double[] a) Calculates and returns the squared L2 norm of the given vector.static doublenormL2squared(float[] a) Calculates and returns the squared L2 norm of the given vector.static double[][]outerProduct(double[] a, double[] b) Calculates and returns the outer product of two vectors, which is a matrix of size (m,n), where m is the length of the first vector and m is the length of the second vector.static voidprintToStream(double[][] A, PrintStream strm) Outputs a string representation of the given matrix to the specified output stream.static voidprintToStream(double[] a, PrintStream strm) Outputs a string representation of the given vector to the specified output stream.static voidprintToStream(float[][] A, PrintStream strm) Outputs a string representation of the given matrix to the specified output stream.static voidprintToStream(float[] a, PrintStream strm) Outputs a string representation of the given vector to the specified output stream.static voidprintToStream(long[][] A, PrintStream strm) static booleansameSize(double[][] A, double[][] B) Checks if the given matrices have the same size.static booleansameSize(double[] a, double[] b) Checks if the given vectors have the same length.static booleansameSize(float[][] A, float[][] B) Checks if the given matrices have the same size.static booleansameSize(float[] a, float[] b) Checks if the given vectors have the same length.static double[]solve(double[][] A, double[] b) Finds the exact solution x for the linear system of equations A * x = b.static RealVectorsolve(RealMatrix A, RealVector b) Finds the exact solution x for the linear system of equations A * x = b.static double[]sort(double[] a) Returns a sorted copy of the givendouble[]vector.static float[]sort(float[] a) Returns a sorted copy of the givenfloat[]vector.static double[]subtract(double[] a, double[] b) Calculates and returns the difference (a - b) of the specifieddoublevectors (non-destructively).static float[]subtract(float[] a, float[] b) Calculates and returns the difference (a - b) of the specifiedfloatvectors (non-destructively).static doublesum(double[] a) Calculates and returns the sum of the elements in the specifieddouble[]vector.static doublesum(double[][] A) Calculates and returns the sum of the elements in the specifieddouble[][]matrix.static doublesum(float[] a) Calculates and returns the sum of the elements in the specifiedfloat[]vector.static doublesum(float[][] A) Calculates and returns the sum of the elements in the specifiedfloat[][]matrix.static doublesumColumn(double[][] A, int col) Calculates the sum of the elements in the specified matrix column.static doublesumColumn(float[][] A, int col) Calculates the sum of the elements in the specified matrix column.static double[]sumColumns(double[][] A) Calculates the sums of all matrix columns and returns them as a vector with one element per column.static float[]sumColumns(float[][] A) Calculates the sums of all matrix columns and returns them as a vector with one element per column.static doublesumRow(double[][] A, int row) Calculates the sum of the elements in the specified matrix row.static doublesumRow(float[][] A, int row) Calculates the sum of the elements in the specified matrix row.static double[]sumRows(double[][] A) Calculates the sums of all matrix rows and returns them as a vector with one element per row.static float[]sumRows(float[][] A) Calculates the sums of all matrix rows and returns them as a vector with one element per row.static double[]toCartesian(double[] ah) Converts a homogeneous vector to its equivalent Cartesian vector, which is one element shorter.static double[]toDouble(float[] a) Converts afloat[]to adouble[].static double[][]toDouble(float[][] A) Converts afloat[][]to adouble[][].static float[]toFloat(double[] a) Converts adouble[]to afloat[].static float[][]toFloat(double[][] A) Converts adouble[][]to afloat[][].static double[]toHomogeneous(double[] ac) Converts a Cartesian vector to an equivalent homogeneous vector by attaching an additional 1-element.static long[][]toLongBits(double[][] A) Converts adouble[][]to along[][]whose elements contain the 64-bit representation of the originaldoublevalues.static StringtoString(double[] a) Returns a string representation of the specified vector.static StringtoString(double[][] A) Returns a string representation of the specified matrix.static StringtoString(float[] a) Returns a string representation of the specified vector.static StringtoString(float[][] A) Returns a string representation of the specified matrix.static StringtoString(long[][] A) Returns a string representation of the specified matrix withlongelements.static StringReturns a string representation of the specified matrix.static StringReturns a string representation of the specified vector.static doubletrace(double[][] A) Calculates and returns the trace of the givendouble[][]matrix.static floattrace(float[][] A) Calculates and returns the trace of the givenfloat[][]matrix.static double[][]transpose(double[][] A) Returns the transpose of the givendouble[][]matrix.static float[][]transpose(float[][] A) Returns the transpose of the givenfloat[][]matrix.static double[]zeroVector(int length) Creates and returns a new zero-valueddouble[]vector of the specified length.
-
Field Details
-
PrintLocale
Locale used for printing decimal numbers bytoString()methods. -
SeparationChar
Character used to separate successive vector and matrix elements bytoString()methods. -
LeftDelimitChar
Leading delimiter used for lists of vector and matrix elements bytoString()methods. -
RightDelimitChar
Trailing delimiter used for lists of vector and matrix elements bytoString()methods. -
DefaultSymmetryTolerance
Default matrix symmetry tolerance.- See Also:
-
-
Method Details
-
makeDoubleMatrix
Creates and returns a
double[][]matrix containing the specified values. Throws aIllegalArgumentExceptionif the number of supplied values does not exactly match the matrix size. Example for creating a 2x3 matrix:double[][] A = makeDoubleMatrix(2, 3, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 );See also
flatten(double[][]).- Parameters:
rows- the number of matrix rowscols- the number of matrix columnsvalues- a sequence of matrix values in row-major order (may also be passed as adouble[])- Returns:
- a
double[][]matrix
-
makeFloatMatrix
Creates and returns a
float[][]matrix containing the specified values. Throws aIllegalArgumentExceptionif the number of supplied values does not exactly match the matrix size. Example for creating a 2x3 matrix:float[][] A = makeFloatMatrix(2, 3, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f );See also
flatten(float[][]).- Parameters:
rows- the number of matrix rowscols- the number of matrix columnsvalues- a sequence of matrix values in row-major order (may also be passed as afloat[])- Returns:
- a
float[][]matrix
-
makeRealMatrix
Creates and returns a
RealMatrixcontaining the specifieddoublevalues. CallsmakeDoubleMatrix(int, int, double...). Example for creating a 2x3 matrix:RealMatrix A = makeRealMatrix(2, 3, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 );See also
flatten(RealMatrix).- Parameters:
rows- the number of matrix rowscols- the number of matrix columnsvalues- a sequence of matrix values in row-major order (may also be passed as adouble[])- Returns:
- a
RealMatrix
-
flatten
Returns the values of the specified matrix as adouble[]with elements arranged in row-major order. The matrix must be fully rectangular (all rows of same length). See alsomakeDoubleMatrix(int, int, double...).- Parameters:
A- a matrix- Returns:
- a
double[]with the matrix elements
-
flatten
Returns the values of the specified matrix as afloat[]with elements arranged in row-major order. The matrix must be fully rectangular (all rows of same length). See alsomakeFloatMatrix(int, int, float...).- Parameters:
A- a matrix- Returns:
- a
float[]with the matrix elements
-
flatten
Returns the values of the specified matrix as adouble[]with elements arranged in row-major order. See alsomakeRealMatrix(int, int, double...).- Parameters:
A- a matrix- Returns:
- a
double[]with the matrix elements
-
makeDoubleVector
Creates and returns adouble[]vector from the specified values.- Parameters:
values- a sequence of vector values (may also be passed as a singledouble[])- Returns:
- a
double[]
-
makeFloatVector
Creates and returns afloat[]vector from the specified values.- Parameters:
values- a sequence of vector values (may also be passed as a singlefloat[])- Returns:
- a
float[]
-
makeRealVector
Creates and returns aRealVectorfrom the specifieddoublevalues.- Parameters:
values- a sequence of vector values (may also be passed as a singledouble[])- Returns:
- a
RealVector
-
zeroVector
Creates and returns a new zero-valueddouble[]vector of the specified length. Throws an exception if the length is less than 1.- Parameters:
length- the length of the vector- Returns:
- a
double[]with zero values
-
idMatrix
Creates and returns a new identity matrix of the specified size. Throws an exception if the size is less than 1.- Parameters:
size- the size of the matrix- Returns:
- an identity matrix
-
getNumberOfRows
Returns the number of rows of the specifieddoublematrix.- Parameters:
A- adouble[][]matrix- Returns:
- the number of rows
-
getNumberOfColumns
Returns the number of columns of the specifieddoublematrix.- Parameters:
A- adouble[][]matrix- Returns:
- the number of columns
-
getNumberOfRows
Returns the number of rows of the specifiedfloatmatrix.- Parameters:
A- afloat[][]matrix- Returns:
- the number of rows
-
getNumberOfColumns
Returns the number of columns of the specifiedfloatmatrix.- Parameters:
A- afloat[][]matrix- Returns:
- the number of columns
-
getNumberOfRows
Returns the number of rows of the specifiedRealMatrix.- Parameters:
A- aRealMatrix- Returns:
- the number of rows
-
getNumberOfColumns
Returns the number of columns of the specifiedRealMatrix.- Parameters:
A- aRealMatrix- Returns:
- the number of columns
-
getRow
Returns a particular row of the specifieddoublematrix as adoublevector.- Parameters:
A- adouble[][]matrixr- the row index (starting with 0)- Returns:
- a
doublevector
-
getRow
Returns a particular row of the specifiedfloatmatrix as afloatvector.- Parameters:
A- afloat[][]matrixr- the row index (starting with 0)- Returns:
- a
floatvector
-
getColumn
Returns a particular column of the specifieddoublematrix as adoublevector.- Parameters:
A- adouble[][]matrixc- the column index (starting with 0)- Returns:
- a
doublevector
-
getColumn
Returns a particular column of the specifiedfloatmatrix as afloatvector.- Parameters:
A- afloat[][]matrixc- the column index (starting with 0)- Returns:
- a
floatvector
-
isRectangular
Checks if all rows of the given matrix have the same length.- Parameters:
A- afloat[][]matrix- Returns:
- true iff the matrix is rectangular
-
isRectangular
Checks if all rows of the given matrix have the same length.- Parameters:
A- adouble[][]matrix- Returns:
- true iff the matrix is rectangular
-
isSquare
Checks it the given matrix has the same number of rows and columns.- Parameters:
A- adouble[][]matrix- Returns:
- true iff the matrix is square
-
isSquare
Checks it the given matrix has the same number of rows and columns.- Parameters:
A- afloat[][]matrix- Returns:
- true iff the matrix is square
-
getDiagonal
Returns a vector with the diagonal elements of the specified matrix.- Parameters:
A- a squaredouble[][]matrix- Returns:
- the vector of diagonal elements
-
getDiagonal
Returns a vector with the diagonal elements of the specified matrix.- Parameters:
A- a squarefloat[][]matrix- Returns:
- the vector of diagonal elements
-
getDiagonal
Returns a vector with the diagonal elements of the specified matrix.- Parameters:
A- a squareRealMatrix- Returns:
- the
RealVectorof diagonal elements
-
diagMatrix
Creates and returns a diagonal matrix from the specified vector. See alsogetDiagonal(double[][]).- Parameters:
d- vector of diagonal matrix elements- Returns:
- a diagonal matrix
-
isSingular
Checks is the given squaredouble[][]matrix is non-singular.- Parameters:
A- a squaredouble[][]matrix- Returns:
- true if the matrix is singular
- Throws:
Matrix.NonsquareMatrixException- if the matrix is not square
-
isSingular
Checks is the given square matrix is non-singular.- Parameters:
A- a squareRealMatrix- Returns:
- true if the matrix is singular
- Throws:
Matrix.NonsquareMatrixException- if the matrix is not square
-
isSymmetric
Checks is the given square matrix is symmetric using the specified relative tolerance.- Parameters:
A- a square matrixrelTolerance- relative symmetry tolerance- Returns:
- true if the matrix is symmetric
-
isSymmetric
Checks is the given square matrix is symmetric, using the default tolerance value (Arithmetic.EPSILON_DOUBLE).- Parameters:
A- a square matrix- Returns:
- true if the matrix is symmetric
-
isSymmetric
Checks is the given square matrix is symmetric using the specified relative tolerance.- Parameters:
A- a square matrixrelTolerance- relative symmetry tolerance- Returns:
- true if the matrix is symmetric
-
isSymmetric
Checks is the given square matrix is symmetric, using the default tolerance value (Arithmetic.EPSILON_DOUBLE).- Parameters:
A- a square matrix- Returns:
- true if the matrix is symmetric
-
isPositiveDefinite
Checks is the given square matrix is positive definite, using the specified symmetry tolerance value.- Parameters:
A- a square matrixtolerance- the absolute positivity and relative symmetry tolerance- Returns:
- true if the matrix is positive definite
-
isPositiveDefinite
Checks is the given square matrix is positive definite.- Parameters:
A- a square matrix- Returns:
- true if the matrix is positive definite
-
sameSize
Checks if the given vectors have the same length.- Parameters:
a- first vectorb- second vector- Returns:
- true iff both vectors have the same length
-
sameSize
Checks if the given vectors have the same length.- Parameters:
a- first vectorb- second vector- Returns:
- true iff both vectors have the same length
-
sameSize
Checks if the given matrices have the same size.- Parameters:
A- first matrixB- second matrix- Returns:
- true iff both matrices have the same size
-
sameSize
Checks if the given matrices have the same size.- Parameters:
A- first matrixB- second matrix- Returns:
- true iff both matrices have the same size
-
duplicate
Returns a copy of the givendouble[]vector.- Parameters:
a- adouble[]vector- Returns:
- a copy of the vector
-
duplicate
Returns a copy of the givenfloat[]vector.- Parameters:
a- afloat[]vector- Returns:
- a copy of the vector
-
duplicate
Returns a copy of the givendouble[][]matrix.- Parameters:
A- adouble[][]matrix- Returns:
- a copy of the matrix
-
duplicate
Returns a copy of the givenfloat[][]matrix.- Parameters:
A- afloat[][]matrix- Returns:
- a copy of the matrix
-
copyD
Copy data from onefloat[]vector to another. The two vectors must have the same length (not checked).- Parameters:
source- the source vector (unmodified)target- the target vector (modified)
-
copyD
Copy data from onedouble[]vector to another. The two vectors must have the same length (not checked).- Parameters:
source- the source vector (unmodified)target- the target vector (modified)
-
toFloat
Converts adouble[]to afloat[].- Parameters:
a- the originaldouble[]array- Returns:
- a copy of the array of type
float[]
-
toFloat
Converts adouble[][]to afloat[][].- Parameters:
A- the originaldouble[][]array- Returns:
- a copy of the array of type
float[][]
-
toLongBits
Converts adouble[][]to along[][]whose elements contain the 64-bit representation of the originaldoublevalues. Its printed representation is comparatively compact (seetoString(long[][])). This is useful for defining literaldoublearrays without losing any precision (by avoiding conversion to decimal representation). Note that thelongare bit representations and cannot be used to perform any arithmetic calculations.- Parameters:
A- the originaldoublearray- Returns:
- a copy of the array of type
float[][] - See Also:
-
fromLongBits
Converts along[][]with 64-bitdoublerepresentations to the equivalentdouble[][]. This is useful for defining literaldoublearrays without losing any precision (by avoiding conversion to decimal representation).- Parameters:
A- alongarray- Returns:
- the equivalent
doublearray - See Also:
-
toDouble
Converts afloat[]to adouble[].- Parameters:
a- the originalfloat[]array- Returns:
- a copy of the array of type
double[]
-
toDouble
Converts afloat[][]to adouble[][].- Parameters:
A- the originalfloat[][]array- Returns:
- a copy of the array of type
double[][]
-
fillD
Fills the givendoublevector with the specified value (destructively).- Parameters:
x- a vector (which is modified)val- the fill value
-
fillD
Fills the givenfloatvector with the specified value (destructively).- Parameters:
x- a vector (which is modified)val- the fill value
-
fillD
Fills the givendoublematrix with the specified value (destructively).- Parameters:
A- a matrix (which is modified)val- the fill value
-
fillD
Fills the givenfloatmatrix with the specified value (destructively).- Parameters:
A- a matrix (which is modified)val- the fill value
-
add
Calculates and returns the sum of the specifieddoublevectors (non-destructively). An exception is thrown if the vectors are of different lengths. None of the arguments is modified.- Parameters:
a- the first vectorb- the second vector- Returns:
- a new
doublevector
-
addD
Adds the elements of the firstdoublevector to the second vector (destructively). An exception is thrown if the vectors are of different lengths. The second vector is modified.- Parameters:
a- the first vectorb- the second vector
-
add
Calculates and returns the sum of the specifiedfloatvectors (non-destructively). An exception is thrown if the vectors are of different lengths. None of the arguments is modified.- Parameters:
a- the first vectorb- the second vector- Returns:
- a new
floatvector
-
addD
Adds the elements of the firstfloatvector to the second vector (destructively). An exception is thrown if the vectors are of different lengths. The second vector is modified.- Parameters:
a- the first vectorb- the second vector
-
add
Calculates and returns the sum of the specifieddoublematrix (non-destructively). An exception is thrown if the matrices are of different size. None of the arguments is modified.- Parameters:
A- the first matrixB- the second matrix- Returns:
- a new
doublematrix
-
addD
Adds the elements of the firstdoublematrix to the second vector (destructively). An exception is thrown if the matrices are of different size. The second matrix is modified.- Parameters:
A- the first matrixB- the second matrix
-
add
Calculates and returns the sum of the specifiedfloatmatrix (non-destructively). An exception is thrown if the matrices are of different size. None of the arguments is modified.- Parameters:
A- the first matrixB- the second matrix- Returns:
- a new
floatmatrix
-
addD
Adds the elements of the firstfloatmatrix to the second vector (destructively). An exception is thrown if the matrices are of different size. The second matrix is modified.- Parameters:
A- the first matrixB- the second matrix
-
subtract
Calculates and returns the difference (a - b) of the specifieddoublevectors (non-destructively). An exception is thrown if the vectors are of different lengths. None of the arguments is modified.- Parameters:
a- the first vectorb- the second vector- Returns:
- a new
doublevector
-
subtract
Calculates and returns the difference (a - b) of the specifiedfloatvectors (non-destructively). An exception is thrown if the vectors are of different lengths. None of the arguments is modified.- Parameters:
a- the first vectorb- the second vector- Returns:
- a new
floatvector
-
multiply
Multiplies adouble[]vector by a scalar and returns a newdouble[]vector (non-destructive).- Parameters:
s- a scalarx- a vector- Returns:
- a new vector
-
multiplyD
Multiplies adouble[]vector by a scalar. Destructive, i.e., the specified vector is modified.- Parameters:
s- a scalarx- a vector
-
multiply
Multiplies adouble[][]matrix by a scalar and returns a newdouble[][]matrix (non-destructive).- Parameters:
s- a scalarA- a matrix- Returns:
- a new matrix
-
multiplyD
Multiplies adouble[][]matrix by a scalar. Destructive, i.e., the specified matrix is modified.- Parameters:
s- a scalarA- a matrix
-
multiply
Multiplies afloat[]vector by a scalar and returns a newfloat[]vector (non-destructive).- Parameters:
s- a scalarx- a vector- Returns:
- a new vector
-
multiplyD
Multiplies afloat[]vector by a scalar. Destructive, i.e., the specified vector is modified.- Parameters:
s- a scalarx- a matrix
-
multiply
Multiplies afloat[][]matrix by a scalar and returns a newfloat[][]matrix (non-destructive).- Parameters:
s- a scalarA- a matrix- Returns:
- a new matrix
-
multiplyD
Multiplies afloat[][]matrix by a scalar. Destructive, i.e., the specified matrix is modified.- Parameters:
s- a scalarA- a matrix
-
multiply
Multiplies a vector x with a matrix A "from the left", i.e., y = x * A, where x is treated as a row vector and the result y is also a row vector.- Parameters:
x- a (row) vector of length mA- a matrix of size (m,n)- Returns:
- a (row) vector of length n
-
multiplyD
Destructive version ofmultiply(double[], double[][]).- Parameters:
x- a (row) vector of length mA- matrix of size (m,n)y- a (row) vector of length n
-
multiply
Multiplies a matrix A with a vector x "from the right", i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector.- Parameters:
A- a matrix of size (m,n)x- a (column) vector of length n- Returns:
- a (column) vector of length m
-
multiplyD
Multiplies a matrix A with a vector x "from the right", i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector. The result is placed in the vector passed as the last argument, which is modified. Destructive version ofmultiply(double[][], double[]). An exception is thrown if any matrix or vector dimensions do not match or if the two vectors are the same.- Parameters:
A- matrix of size (m,n)x- a (column) vector of length ny- a (column) vector of length m
-
multiply
Multiplies a matrix A with a vector x from the right, i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector.- Parameters:
A- a matrix of size (m,n)x- a (column) vector of length n- Returns:
- a (column) vector of length m
-
multiplyD
Multiplies a matrix A with a vector x "from the right", i.e., y = A * x, where x is treated as a column vector and the result y is also a column vector. The result is placed in the vector passed as the last argument, which is modified. Destructive version ofmultiply(float[][], float[]). An exception is thrown if any matrix or vector dimensions do not match or if the two vectors are the same.- Parameters:
A- matrix of size (m,n)x- a (column) vector of length ny- a (column) vector of length m
-
multiply
Returns the product of twodouble[][]matrices A, B as a newdouble[][]matrix. Non-destructive, i.e., none of the arguments is modified.- Parameters:
A- first matrixB- second matrix- Returns:
- the matrix product A * B
-
multiplyD
public static void multiplyD(double[][] A, double[][] B, double[][] C) throws Matrix.SameSourceTargetException, Matrix.IncompatibleDimensionsException Calculates the product of twodouble[][]matrices A, B and places the results in the thirddouble[][]matrix C, which is modified (destructively). An exception is thrown if any matrix dimensions do not match or if the target matrix is the same as one of the source matrices.- Parameters:
A- first matrixB- second matrixC- the result matrix- Throws:
Matrix.SameSourceTargetException- if the target matrix is the same as one of the source matricesMatrix.IncompatibleDimensionsException- if any matrix dimensions do not match
-
multiply
Returns the product of twofloat[][]matrices A, B as a newfloat[][]matrix. Non-destructive, i.e., none of the arguments is modified.- Parameters:
A- first matrixB- second matrix- Returns:
- the matrix product A * B
-
multiplyD
Calculates the product of twofloat[][]matrices A, B and places the results in the thirdfloat[][]matrix C, which is modified (destructively). An exception is thrown if any matrix dimensions do not match or if the target matrix is the same as one of the source matrices.- Parameters:
A- first matrixB- second matrixC- the result matrix
-
dotProduct
Calculates and returns the dot (inner or scalar) product of two vectors, which must have the same length. Throws an exceptions if vector dimensions do not match.- Parameters:
a- first vectorb- second vector- Returns:
- the dot product
-
outerProduct
Calculates and returns the outer product of two vectors, which is a matrix of size (m,n), where m is the length of the first vector and m is the length of the second vector.- Parameters:
a- first (column) vector (of length m)b- second (row) vector (of length n)- Returns:
- the outer product (matrix)
-
normL1
Calculates and returns the L1 norm of the given vector.- Parameters:
a- a vector- Returns:
- the L1 norm of the vector
-
normL1
Calculates and returns the L1 norm of the given vector.- Parameters:
a- a vector- Returns:
- the L1 norm of the vector
-
normL2
Calculates and returns the L2 norm of the given vector.- Parameters:
a- a vector- Returns:
- the L2 norm of the vector
-
normL2squared
Calculates and returns the squared L2 norm of the given vector. The squared norm is less costly to calculate (no square root needed) than the L2 norm and is thus often used for efficiency.- Parameters:
a- a vector- Returns:
- the squared L2 norm of the vector
-
normL2
Calculates and returns the L2 norm of the given vector.- Parameters:
x- a vector- Returns:
- the L2 norm of the vector
-
normL2squared
Calculates and returns the squared L2 norm of the given vector. The squared norm is less costly to calculate (no square root needed) than the L2 norm and is thus often used for efficiency.- Parameters:
a- a vector- Returns:
- the squared L2 norm of the vector
-
normalize
Normalizes the specifieddouble[]vector to unit (L2) norm and returns the result as a newdouble[]vector.- Parameters:
a- a vector- Returns:
- the normalized vector
-
normalizeD
Normalizes the specifieddouble[]vector to unit (L2) norm. The vector is modified (destructively).- Parameters:
a- a vector
-
normalize
Normalizes the specifiedfloat[]vector to unit (L2) norm and returns the result as a newfloat[]vector.- Parameters:
a- a vector- Returns:
- the normalized vector
-
normalizeD
Normalizes the specifiedfloat[]vector to unit (L2) norm. The vector is modified (destructively).- Parameters:
a- a vector
-
distL2
Calculates the L2 distance between two vectors (points) in n-dimensional space. Both vectors must have the same number of elements.- Parameters:
a- first vectorb- second vector- Returns:
- the distance
-
distL2squared
Calculates the squared L2 distance between two vectors (points) in n-dimensional space. Both vectors must have the same number of elements.- Parameters:
a- first vectorb- second vector- Returns:
- the squared distance
-
distL2
Calculates the L2 distance between two vectors (points) in n-dimensional space. Both vectors must have the same number of elements.- Parameters:
a- first vectorb- second vector- Returns:
- the distance
-
distL2squared
Calculates the squared L2 distance between two vectors (points) in n-dimensional space. Both vectors must have the same number of elements.- Parameters:
a- first vectorb- second vector- Returns:
- the squared distance
-
norm
Calculates and returns the Froebenius norm of the given matrix.- Parameters:
A- a matrix- Returns:
- the norm of the matrix
-
sum
Calculates and returns the sum of the elements in the specifieddouble[]vector.- Parameters:
a- a vector- Returns:
- the sum of vector elements
-
sum
Calculates and returns the sum of the elements in the specifieddouble[][]matrix.- Parameters:
A- a matrix- Returns:
- the sum of matrix elements
-
sum
Calculates and returns the sum of the elements in the specifiedfloat[]vector.- Parameters:
a- a vector- Returns:
- the sum of vector elements
-
sum
Calculates and returns the sum of the elements in the specifiedfloat[][]matrix.- Parameters:
A- a matrix- Returns:
- the sum of matrix elements
-
sumRow
Calculates the sum of the elements in the specified matrix row.- Parameters:
A- a matrixrow- the row index- Returns:
- the sum of the row's elements
-
sumRow
Calculates the sum of the elements in the specified matrix row.- Parameters:
A- a matrixrow- the row index- Returns:
- the sum of the row's elements
-
sumColumn
Calculates the sum of the elements in the specified matrix column.- Parameters:
A- a matrixcol- the column index- Returns:
- the sum of the column's elements
-
sumColumn
Calculates the sum of the elements in the specified matrix column.- Parameters:
A- a matrixcol- the column index- Returns:
- the sum of the column's elements
-
sumRows
Calculates the sums of all matrix rows and returns them as a vector with one element per row.- Parameters:
A- a matrix of size (M,N)- Returns:
- a vector of length M containing the sums of all matrix columns
-
sumRows
Calculates the sums of all matrix rows and returns them as a vector with one element per row.- Parameters:
A- a matrix of size (M,N)- Returns:
- a vector of length M containing the sums of all matrix columns
-
sumColumns
Calculates the sums of all matrix columns and returns them as a vector with one element per column.- Parameters:
A- a matrix of size (M,N)- Returns:
- a vector of length N containing the sums of all matrix rows
-
sumColumns
Calculates the sums of all matrix columns and returns them as a vector with one element per column.- Parameters:
A- a matrix of size (M,N)- Returns:
- a vector of length N containing the sums of all matrix rows
-
idxMin
Returns the index of the smallest element in the specified vector. If the smallest value is not unique, the lowest index is returned. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the index of the smallest value
-
idxMin
Returns the index of the smallest element in the specified vector. If the smallest value is not unique, the lowest index is returned. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the index of the smallest value
-
idxMax
Returns the index of the largest element in the specified vector. If the largest value is not unique, the lowest index is returned. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the index of the largest value
-
idxMax
Returns the index of the largest element in the specified vector. If the largest value is not unique, the lowest index is returned. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the index of the largest value
-
min
Returns the smallest value in the specified vector. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the largest value
-
min
Returns the smallest value in the specified vector. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the largest value
-
max
Returns the largest value in the specifieddouble[]vector. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the largest value
-
max
Returns the largest value in the specifiedfloat[]vector. An exception is thrown if the vector has zero length.- Parameters:
a- a vector- Returns:
- the largest value
-
max
Returns the largest value in the specifieddouble[][]matrix.- Parameters:
A- a matrix- Returns:
- the largest matrix value
-
max
Returns the largest value in the specifiedfloat[][]matrix.- Parameters:
A- a matrix- Returns:
- the largest matrix value
-
join
Joins (concatenates) a sequence of vectors into a single vector.- Parameters:
as- a sequence of vectors (at least one vector)- Returns:
- a vector containing all elements of the input vectors
-
join
Joins (concatenates) a sequence of vectors into a single vector.- Parameters:
as- a sequence of vectors (at least one vector)- Returns:
- a vector containing all elements of the input vectors
-
lerp
Performs linear interpolation between two vectorsaandb, which must have the same length. Returns a new vectorc = a + t * (b - a).- Parameters:
a- first vector (to be interpolated from)b- second vector (to be interpolated to)t- interpolation coefficient, expected to be in [0,1]- Returns:
- the interpolated vector
-
lerp
Performs linear interpolation between two vectorsaandb, which must have the same length. Returns a new vectorc = a + t * (b - a).- Parameters:
a- first vector (to be interpolated from)b- second vector (to be interpolated to)t- interpolation coefficient, expected to be in [0,1]- Returns:
- the interpolated vector
-
toHomogeneous
Converts a Cartesian vector to an equivalent homogeneous vector by attaching an additional 1-element. The resulting homogeneous vector is one element longer than the specified Cartesian vector. See alsotoCartesian(double[]).- Parameters:
ac- a Cartesian vector- Returns:
- an equivalent homogeneous vector
-
toCartesian
Converts a homogeneous vector to its equivalent Cartesian vector, which is one element shorter. See alsotoHomogeneous(double[]).- Parameters:
ah- a homogeneous vector- Returns:
- the equivalent Cartesian vector
- Throws:
DivideByZeroException- if the last vector element is zero
-
determinant
Calculates and returns the determinant of the givenRealMatrix. Throws an exception if the matrix is non-square.- Parameters:
A- a square matrix- Returns:
- the determinant
-
determinant
Calculates and returns the determinant of the givendouble[][]matrix. Throws an exception if the matrix is non-square.- Parameters:
A- a square matrix- Returns:
- the determinant
-
determinant2x2
Calculates and returns the determinant of the given 2x2double[][]matrix. This method is hard-coded for the specific matrix size for better performance than the general method (determinant(double[][])). Throws an exception if the matrix is not 2x2.- Parameters:
A- a 2x2 matrix- Returns:
- the determinant
-
determinant2x2
Calculates and returns the determinant of the given 2x2float[][]matrix. Throws an exception if the matrix is not 2x2.- Parameters:
A- a 2x2 matrix- Returns:
- the determinant
-
determinant3x3
Calculates and returns the determinant of the given 3x3double[][]matrix. This method is hard-coded for the specific matrix size for better performance than the general method (determinant(double[][])). Throws an exception if the matrix is not 3x3.- Parameters:
A- a 3x3 matrix- Returns:
- the determinant
-
determinant3x3
Calculates and returns the determinant of the given 3x3float[][]matrix. Throws an exception if the matrix is not 3x3.- Parameters:
A- a 3x3 matrix- Returns:
- the determinant
-
trace
Calculates and returns the trace of the givendouble[][]matrix. Throws an exception if the matrix is non-square.- Parameters:
A- a square matrix- Returns:
- the trace
-
trace
Calculates and returns the trace of the givenfloat[][]matrix. Throws an exception if the matrix is non-square.- Parameters:
A- a square matrix- Returns:
- the trace
-
transpose
Returns the transpose of the givendouble[][]matrix. The original matrix is not modified.- Parameters:
A- a matrix- Returns:
- the transpose of the matrix
-
transpose
Returns the transpose of the givenfloat[][]matrix. The original matrix is not modified.- Parameters:
A- a matrix- Returns:
- the transpose of the matrix
-
isZero
Checks if all elements of the specifieddouble[]vector are zero using the specified tolerance value.- Parameters:
a- a vectortolerance- the tolerance value- Returns:
- true if all vector elements are smaller than the tolerance
-
isZero
Checks if all elements of the specifieddouble[]vector are zero using the default tolerance value (Arithmetic.EPSILON_DOUBLE).- Parameters:
a- a vector- Returns:
- true if all vector elements are smaller than the tolerance
-
isZero
Checks if all elements of the specifiedfloat[]vector are zero using the specified tolerance value.- Parameters:
a- a vectortolerance- the tolerance value- Returns:
- true if all vector elements are smaller than the tolerance
-
isZero
Checks if all elements of the specifiedfloat[]vector are zero using the default tolerance value (Arithmetic.EPSILON_DOUBLE).- Parameters:
a- a vector- Returns:
- true if all vector elements are smaller than the tolerance
-
isZero
Checks if all elements of the specifieddouble[][]matrix are zero using the specified tolerance value.- Parameters:
A- a matrixtolerance- the tolerance value- Returns:
- true if all matrix elements are smaller than the tolerance
-
isZero
Checks if all elements of the specifieddouble[][]matrix are zero using default tolerance value (Arithmetic.EPSILON_DOUBLE).- Parameters:
A- a matrix- Returns:
- true if all matrix elements are smaller than the tolerance
-
sort
Returns a sorted copy of the givendouble[]vector. Elements are sorted by increasing value (smallest first).- Parameters:
a- adouble[]vector- Returns:
- a sorted copy of the vector
-
sort
Returns a sorted copy of the givenfloat[]vector. Elements are sorted by increasing value (smallest first).- Parameters:
a- afloat[]vector- Returns:
- a sorted copy of the vector
-
inverse
Calculates and returns the inverse of the given matrix, which must be square. Exceptions are thrown if the supplied matrix is not square or ill-conditioned (singular).- Parameters:
A- a square matrix- Returns:
- the inverse matrix
- Throws:
Matrix.NonsquareMatrixException- if the supplied matrix is not square
-
inverse
Calculates and returns the inverse of the given matrix, which must be square. Exceptions are thrown if the supplied matrix is not square or ill-conditioned (singular).- Parameters:
A- a square matrix- Returns:
- the inverse matrix
- Throws:
Matrix.NonsquareMatrixException- if the supplied matrix is not square
-
solve
Finds the exact solution x for the linear system of equations A * x = b. Returns the solution vector x ornullif the supplied matrix is ill-conditioned (i.e., singular). Exceptions are thrown if A is not square or dimensions are incompatible. Callssolve(RealMatrix, RealVector).- Parameters:
A- a square matrix of size n x nb- a vector of length n- Returns:
- the solution vector (x) of length n or
nullif no solution possible
-
solve
Finds the exact solution x for the linear system of equations A * x = b. Returns the solution vector x ornullif the supplied matrix is ill-conditioned (i.e., singular). Exceptions are thrown if A is not square or dimensions are incompatible. UsesLUDecompositionfrom the Apache Commons Math library.- Parameters:
A- a square matrix of size n x nb- a vector of length n- Returns:
- the solution vector (x) of length n or
nullif no solution possible
-
toString
Returns a string representation of the specified vector.- Parameters:
a- a vector- Returns:
- the string representation
-
toString
Returns a string representation of the specified vector.- Parameters:
a- a vector- Returns:
- the string representation
-
toString
Returns a string representation of the specified vector.- Parameters:
a- a vector- Returns:
- the string representation
-
toString
Returns a string representation of the specified matrix.- Parameters:
A- a matrix- Returns:
- the string representation
-
toString
Returns a string representation of the specified matrix.- Parameters:
A- a matrix- Returns:
- the string representation
-
toString
Returns a string representation of the specified matrix withlongelements.- Parameters:
A- a matrix- Returns:
- the string representation
-
toString
Returns a string representation of the specified matrix.- Parameters:
A- a matrix- Returns:
- the string representation
-
printToStream
Outputs a string representation of the given vector to the specified output stream.- Parameters:
a- the vectorstrm- the output stream- See Also:
-
printToStream
Outputs a string representation of the given matrix to the specified output stream.- Parameters:
A- the matrixstrm- the output stream- See Also:
-
printToStream
Outputs a string representation of the given vector to the specified output stream.- Parameters:
a- the vectorstrm- the output stream- See Also:
-
printToStream
Outputs a string representation of the given matrix to the specified output stream.- Parameters:
A- the matrixstrm- the output stream- See Also:
-
printToStream
-