Matrix

ai.dragonfly.math.matrix.Matrix$
See theMatrix companion class
object Matrix

Jama = Java Matrix class.

The Java Matrix Class provides the fundamental operations of numerical linear algebra. Various constructors create Matrices from two dimensional arrays of double precision floating point numbers. Various "gets" and "sets" provide access to submatrices and matrix elements. Several methods implement basic matrix arithmetic, including matrix addition and multiplication, matrix norms, and element-by-element array operations. Methods for reading and printing matrices are also included. All the operations in this version of the Matrix Class involve real matrices. Complex matrices may be handled in a future version.

Five fundamental matrix decompositions, which consist of pairs or triples of matrices, permutation vectors, and the like, produce results in five decomposition classes. These decompositions are accessed by the Matrix class to compute solutions of simultaneous linear equations, determinants, inverses and other matrix functions. The five decompositions are:

  • Cholesky Decomposition of symmetric, positive definite matrices.
  • LU Decomposition of rectangular matrices.
  • QR Decomposition of rectangular matrices.
  • Singular Value Decomposition of rectangular matrices.
  • Eigenvalue Decomposition of both symmetric and nonsymmetric square matrices.
Example of use:

Solve a linear system A x = b and compute the residual norm, ||b - A x||.

double[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
Matrix A = new Matrix(vals);
Matrix b = Matrix.random(3,1);
Matrix x = A.solve(b);
Matrix r = A.times(x).minus(b);
double rnorm = r.normInfinity;
*

Attributes

Version:

5 August 1998

Companion:
class
Source:
Matrix.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Matrix.type

Members list

Concise view

Value members

Concrete methods

def apply[M <: Int, N <: Int](values: Array[Array[Double]])(using ValueOf[M], ValueOf[N]): Matrix[M, N]

Construct a matrix from a 2-D array.

Construct a matrix from a 2-D array.

Attributes

values

Two-dimensional array of doubles.

Throws:
IllegalArgumentException

All rows must have the same length

Source:
Matrix.scala
def apply[M <: Int, N <: Int](value: Double)(using ValueOf[M], ValueOf[N]): Matrix[M, N]

Construct an MxN constant matrix.

Construct an MxN constant matrix.

Attributes

M

the number of rows

N

the number of columns

value

Fill the matrix with this scalar value.

Returns:

an MxN constant matrix.

Source:
Matrix.scala
def apply[M <: Int, N <: Int](vals: Array[Double])(using ValueOf[M], ValueOf[N]): Matrix[M, N]

Construct a matrix from a one-dimensional packed array

Construct a matrix from a one-dimensional packed array

Attributes

m

Number of rows.

vals

One-dimensional array of doubles, packed by columns (ala Fortran).

Throws:
IllegalArgumentException

Array length must be a multiple of m.

Source:
Matrix.scala
def constructWithCopy[M <: Int, N <: Int](values: Array[Array[Double]])(using ValueOf[M], ValueOf[N]): Matrix[M, N]

Construct a matrix from a copy of a 2-D array.

Construct a matrix from a copy of a 2-D array.

Attributes

values

Two-dimensional array of doubles.

Throws:
IllegalArgumentException

All rows must have the same length

Source:
Matrix.scala
def diagonal[M <: Int, N <: Int](value: Double)(using ValueOf[M], ValueOf[N]): Matrix[M, N]

Generate identity matrix scaled by value parameter.

Generate identity matrix scaled by value parameter.

Attributes

columns

Number of colums.

rows

Number of rows.

value

scalar multiplier.

Returns:

An MxN matrix with ones on the diagonal and zeros elsewhere.

Source:
Matrix.scala
def diagonal[D <: Int](v: Vec[D])(using ValueOf[D]): Matrix[D, D]

Generate a square matrix with the supplied vector along the diagonal.

Generate a square matrix with the supplied vector along the diagonal.

Attributes

v

a vector

Source:
Matrix.scala
def diagonal[M <: Int, N <: Int, D <: Int](v: Vec[D])(using ValueOf[M], ValueOf[N], ValueOf[D]): Matrix[M, N]

Attributes

Source:
Matrix.scala
def identity[M <: Int, N <: Int](using ValueOf[M], ValueOf[N]): Matrix[M, N]

Generate identity matrix

Generate identity matrix

Attributes

M

the number of rows

N

the number of columns

Returns:

An MxN matrix with ones on the diagonal and zeros elsewhere.

Source:
Matrix.scala
def random[M <: Int, N <: Int](maxNorm: Double, r: Random)(using ValueOf[M], ValueOf[N]): Matrix[M, N]

Generate matrix with random elements

Generate matrix with random elements

Attributes

M

the number of rows

N

the number of columns

maxNorm

optional Maximum random generated value allowed.

r

optional random instance.

Returns:

An MxN matrix with uniformly distributed random elements.

Source:
Matrix.scala
def zeros[M <: Int, N <: Int](using ValueOf[M], ValueOf[N]): Matrix[M, N]

Construct an MxN matrix of zeros.

Construct an MxN matrix of zeros.

Attributes

M

the number of rows

N

the number of columns

Source:
Matrix.scala