Mat

slash.matrix.Mat
See theMat companion object
opaque class Mat[M <: Int, N <: Int](val values: DoubleArray)(using x$2: ValueOf[M], x$3: ValueOf[N])

Attributes

Companion
object
Source
Mat.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Types

opaque type MN

Attributes

Source
Mat.scala

Value members

Concrete methods

inline def *(s: Double): Mat[M, N]

Multiply a matrix by a scalar, C = A * s

Multiply a matrix by a scalar, C = A * s

Value parameters

s

scalar

Attributes

Returns

A * s

Source
Mat.scala
def *[V <: Int](thatMatrix: Mat[N, V])(using ValueOf[V]): Mat[M, V]

Attributes

Source
Mat.scala
inline def *=(s: Double): Mat[M, N]

Attributes

Source
Mat.scala
inline def +(B: Mat[M, N]): Mat[M, N]

Attributes

Source
Mat.scala
inline def +(s: Double): Mat[M, N]

Add a scalar to a matrix, C = A + s

Add a scalar to a matrix, C = A + s

Value parameters

s

scalar

Attributes

Returns

A + s

Source
Mat.scala
inline def +=(B: Mat[M, N]): Mat[M, N]

Attributes

Source
Mat.scala
inline def +=(s: Double): Mat[M, N]

Attributes

Source
Mat.scala
inline def -(B: Mat[M, N]): Mat[M, N]

Attributes

Source
Mat.scala
inline def -(s: Double): Mat[M, N]

Attributes

Source
Mat.scala
inline def -=(B: Mat[M, N]): Mat[M, N]

Attributes

Source
Mat.scala
inline def -=(s: Double): Mat[M, N]

Attributes

Source
Mat.scala
def add(B: Mat[M, N]): Mat[M, N]

A = A + B

A = A + B

Value parameters

B

another matrix

Attributes

Returns

A + B

Source
Mat.scala
def addScalar(d: Double)(using ValueOf[N]): Mat[M, N]

A = A + d

A = A + d

Value parameters

d

a scalar

Attributes

Returns

A + d

Source
Mat.scala
inline def apply(r: Int, c: Int): Double

Get a single element.

Get a single element.

Value parameters

c

Column index.

r

Row index.

Attributes

Returns

A(i,j)

Source
Mat.scala

Attributes

Source
Mat.scala
def asVector: Vec[M * N]
Extension method from slash.matrix

Attributes

Source
package.scala
def cast[M <: Int, N <: Int](using ValueOf[M], ValueOf[N]): Mat[M, N]
Extension method from slash.matrix

Attributes

Source
package.scala

Get column dimension.

Get column dimension.

Attributes

Returns

n, the number of columns.

Source
Mat.scala

Make a one-dimensional column packed copy of the internal array.

Make a one-dimensional column packed copy of the internal array.

Attributes

Returns

Mat elements packed in a one-dimensional array by columns.

Source
Mat.scala
inline def columnVector(column: Int): Vec[M]

Value parameters

column

the column of the matrix to return as a vector.

Attributes

Returns

a copy of the specified matrix column in Vec[M] format.

Source
Mat.scala

Attributes

Returns

a copy of this matrix in the form of an array of column vectors.

Source
Mat.scala
inline def concatenateColumns[N1 <: Int](m: Mat[M, N1])(using ValueOf[N1], ValueOf[N + N1]): Mat[M, N + N1]

Attributes

Source
Mat.scala
inline def concatenateColumns(m: Mat[_ <: Int, _ <: Int]): DoubleArray

Attributes

Source
Mat.scala
inline def concatenateRows[M1 <: Int](m: Mat[M1, N])(using ValueOf[M1], ValueOf[M + M1]): Mat[M + M1, N]

Attributes

Source
Mat.scala
inline def concatenateRows(m: Mat[_ <: Int, _ <: Int]): DoubleArray

Attributes

Source
Mat.scala
def cond: Double
Extension method from slash.matrix

Mat condition (2 norm)

Mat condition (2 norm)

Attributes

Returns

ratio of largest to smallest singular value.

Source
package.scala
def copy: Mat[M, N]

Make a deep copy of a matrix

Make a deep copy of a matrix

Attributes

Source
Mat.scala
inline def copyAsVector[MN <: Int](using (MN == (M * N)) =:= true): Vec[MN]
Extension method from slash.matrix

Attributes

Source
package.scala
inline def copyValues: DoubleArray

Copy the internal two-dimensional array.

Copy the internal two-dimensional array.

Attributes

Returns

Two-dimensional array copy of matrix elements.

Source
Mat.scala
def csv: String

Attributes

Source
Mat.scala
def csv(alignment: (Mat[_ <: Int, _ <: Int], MatFormat) => Array[Array[String]], sb: StringBuilder): String

Attributes

Source
Mat.scala
Extension method from slash.matrix

Mat determinant https://en.wikipedia.org/wiki/Determinant the determinant is nonzero if and only if the matrix is invertible and the linear map represented by the matrix is an isomorphism

Mat determinant https://en.wikipedia.org/wiki/Determinant the determinant is nonzero if and only if the matrix is invertible and the linear map represented by the matrix is an isomorphism

Attributes

Returns

the determinant of this matrix.

Source
package.scala
def diagonalVector(using ValueOf[Min[M, N]]): Vec[Min[M, N]]

Attributes

Source
Mat.scala
def dim: String

Attributes

Source
Mat.scala
def flatten: Vec[M * N]
Extension method from slash.matrix

values as a Vector.

values as a Vector.

Attributes

Source
package.scala
def inverse: Mat[MN, MN]
Extension method from slash.matrix

https://en.wikipedia.org/wiki/Invertible_matrix

https://en.wikipedia.org/wiki/Invertible_matrix

Computes the inverse of Square Mat m.

Attributes

Returns

the inverse of matrix m

Throws
RuntimeException

"Mat is singular." )

Source
package.scala
def leftInverse: Mat[N, M]
Extension method from slash.matrix

Solve b * m = I[N, N] m = Mat[M, N] with M > N and Rank = N, has a left inverse b = Mat[N, M] such that b * m = I[N, N]

Solve b * m = I[N, N] m = Mat[M, N] with M > N and Rank = N, has a left inverse b = Mat[N, M] such that b * m = I[N, N]

Attributes

Returns

b = Mat[N, M] the Left Inverse of Mat m.

Source
package.scala
inline def lindex(r: Int, c: Int): Int

Attributes

Source
Mat.scala
def lowerTriangular: Mat[M, N]

Attributes

Source
Mat.scala
def norm1: Double

One norm

One norm

Attributes

Returns

maximum column sum.

Source
Mat.scala
def norm2: Double
Extension method from slash.matrix

Two norm

Two norm

Attributes

Returns

maximum singular value.

Source
package.scala

Frobenius norm

Frobenius norm

Attributes

Returns

sqrt of sum of squares of all elements.

Source
Mat.scala

Infinity norm

Infinity norm

Attributes

Returns

maximum row sum.

Source
Mat.scala
def rank: Int
Extension method from slash.matrix

Mat rank

Mat rank

Attributes

Returns

effective numerical rank, obtained from SV.

Source
package.scala
def render(format: MatFormat, alignment: (Mat[_ <: Int, _ <: Int], MatFormat) => Array[Array[String]], sb: StringBuilder): StringBuilder

Attributes

Source
Mat.scala
def reshape[R <: Int, C <: Int](using ValueOf[R], ValueOf[C]): Mat[R, C]
Extension method from slash.matrix

cast matrix as Mat[R,C]

cast matrix as Mat[R,C]

Value parameters

C

new horizontal dimension

R

new vertical dimension

Attributes

Returns

same values, but recast to RxC

Source
package.scala
def rightInverse(using ValueOf[Min[M, M]]): Mat[N, M]
Extension method from slash.matrix

m = Mat[M, N] with M < N and Rank = M, has a right inverse b = Mat[N, M] such that m * b = Identity[M, M]

m = Mat[M, N] with M < N and Rank = M, has a right inverse b = Mat[N, M] such that m * b = Identity[M, M]

Attributes

Returns

the Right Inverse of Mat a.

Source
package.scala

Get row dimension.

Get row dimension.

Attributes

Returns

m, the number of rows.

Source
Mat.scala

Make a one-dimensional row packed copy of the internal array.

Make a one-dimensional row packed copy of the internal array.

Attributes

Returns

Mat elements packed in a one-dimensional array by rows.

Source
Mat.scala
inline def rowVector(row: Int): Vec[N]

Value parameters

row

the row of the matrix to return as a vector.

Attributes

Returns

a copy of the specified matrix row in Vec[N] format.

Source
Mat.scala
def rowVectors: NArray[Vec[N]]

Attributes

Returns

a copy of this matrix in the form of an array of row vectors.

Source
Mat.scala
def setMatrix[M1 <: Int, N1 <: Int](r0: Int, c0: Int, thatMatrix: Mat[M1, N1])(using ValueOf[M1], ValueOf[N1]): Unit

Set a submatrix.

Set a submatrix.

Type parameters

M1

Row dimension of thatMatrix

N1

Column dimension of thatMatrix

Value parameters

ValueOf[M1]

Row dimension of thatMatrix

ValueOf[N1]

Column dimension of thatMatrix

c0

Initial column index

r0

Initial row index

thatMatrix

a metrix of lesser or equal dimension to this matrix

Attributes

Source
Mat.scala
def setMatrix[M1 <: Int, N1 <: Int](rowIndices: IntArray, columnIndices: IntArray, thatMatrix: Mat[M1, N1]): Unit

Set a submatrix.

Set a submatrix.

Value parameters

columnIndices

Array of column indices.

rowIndices

Array of row indices.

thatMatrix

A(r(:),c(:))

Attributes

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def setMatrix[M1 <: Int, N1 <: Int](rowIndices: IntArray, c0: Int, thatMatrix: Mat[M1, N1])(using ValueOf[M1], ValueOf[N1]): Unit

Set a submatrix.

Set a submatrix.

Value parameters

c0

Initial column index

c1

Final column index

rowIndices

Array of row indices.

thatMatrix

A(r(:),j0:j1)

Attributes

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def setMatrix[M1 <: Int, N1 <: Int](r0: Int, columnIndices: IntArray, thatMatrix: Mat[M1, N1])(using ValueOf[M1], ValueOf[N1]): Unit

Set a submatrix.

Set a submatrix.

Value parameters

columnIndices

Array of column indices.

r0

Initial row index

r1

Final row index

thatMatrix

A(i0:i1,c(:))

Attributes

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def solve[V <: Int](b: Mat[MN, V])(using ValueOf[V]): Mat[MN, V]
Extension method from slash.matrix

Solve a * x = b

Solve a * x = b

Value parameters

b

right hand side

Attributes

Returns

x = Mat[MN, V] such that a * x = b

Source
package.scala
def solve[V <: Int](b: Mat[M, V])(using ValueOf[V]): Mat[N, V]
Extension method from slash.matrix

Solve a * x = b

Solve a * x = b

Value parameters

b

right hand side

Attributes

Returns

least squares solution x = Mat[M, V] such that a * x = b

Source
package.scala
def strictEquals(obj: Any): Boolean

Attributes

Source
Mat.scala
def subMatrix[M1 <: Int, N1 <: Int](r0: Int, c0: Int)(using ValueOf[M1], ValueOf[N1]): Mat[M1, N1]

Get a submatrix.

Get a submatrix.

Type parameters

M1

the number of rows

N1

the number of columns

Value parameters

c0

Initial column index

r0

Initial row index

Attributes

Returns

A(i0:i1,j0:j1)

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def subMatrix[M1 <: Int, N1 <: Int](rowIndices: IntArray, columnIndices: IntArray)(using ValueOf[M1], ValueOf[N1]): Mat[M1, N1]

Get a submatrix.

Get a submatrix.

Value parameters

columnIndices

Array of column indices.

rowIndices

Array of row indices.

Attributes

Returns

A(r(:),c(:))

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def subMatrix[M1 <: Int, N1 <: Int](r0: Int, columnIndices: IntArray)(using ValueOf[M1], ValueOf[N1]): Mat[M1, N1]

Get a submatrix.

Get a submatrix.

Value parameters

columnIndices

Array of column indices.

r0

Initial row index

Attributes

Returns

A(i0:i1,c(:))

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def subMatrix[M1 <: Int, N1 <: Int](rowIndices: IntArray, c0: Int)(using ValueOf[M1], ValueOf[N1]): Mat[M1, N1]

Get a submatrix.

Get a submatrix.

Value parameters

c0

Initial column index

c1

Final column index

r

Array of row indices.

Attributes

Returns

A(r(:),j0:j1)

Throws
ArrayIndexOutOfBoundsException

Submatrix indices

Source
Mat.scala
def subtract(B: Mat[M, N]): Mat[M, N]

A = A - B

A = A - B

Value parameters

B

another matrix

Attributes

Returns

A - B

Source
Mat.scala
def times(s: Double): Mat[M, N]

Multiply a matrix by a scalar in place, A = s*A

Multiply a matrix by a scalar in place, A = s*A

Value parameters

s

scalar

Attributes

Returns

replace A by s*A

Source
Mat.scala
def times[V <: Int](b: Mat[N, V])(using ValueOf[V]): Mat[M, V]

Linear algebraic matrix multiplication, A * B

Linear algebraic matrix multiplication, A * B

Value parameters

b

another matrix

Attributes

Returns

Mat product, A * B

Throws
IllegalArgumentException

Mat inner dimensions must agree.

Source
Mat.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
Mat.scala
def trace: Double

Mat trace.

Mat trace.

Attributes

Returns

sum of the diagonal elements.

Source
Mat.scala
def transpose: Mat[N, M]

Mat transpose.

Mat transpose.

Attributes

Returns

Máµ€

Source
Mat.scala
def tsv: String

Attributes

Source
Mat.scala
def tsv(alignment: (Mat[_ <: Int, _ <: Int], MatFormat) => Array[Array[String]], sb: StringBuilder): String

Attributes

Source
Mat.scala
inline def unary_-: Mat[M, N]

Unary minus

Unary minus

Attributes

Returns

-A

Source
Mat.scala
inline def update(r: Int, c: Int, value: Double): Unit

Set a single element.

Set a single element.

Value parameters

c

Column index.

r

Row index.

value

values(i,j).

Attributes

Source
Mat.scala
def upperTriangular: Mat[M, N]

Attributes

Source
Mat.scala

Concrete fields

val MxN: Int

Attributes

Source
Mat.scala
val columns: Int

Attributes

Source
Mat.scala
val rows: Int

Attributes

Source
Mat.scala

Attributes

Source
Mat.scala