MatrixFactory

trait MatrixFactory[R <: Int, C <: Int, T](using x$1: Numeric[T])(using x$2: ValueOf[R], x$3: ValueOf[C])

Central entry point for creating Matrices. Modules implementing the Matrix trait should also provide an instance of this type class.

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def builder: Builder[R, C, T]

Returns a new Builder instance.

Returns a new Builder instance.

Concrete methods

def fromTuple[MatrixTuple <: Tuple, RowTuple <: Tuple](matrixTuple: MatrixTuple)(using matrixReader: MatrixTupleReader[MatrixTuple, RowTuple], rowReader: RowTupleReader[RowTuple, T])(using Size[MatrixTuple] =:= R, Size[RowTuple] =:= C): Matrix[R, C, T]

Creates a Matrix with the specified elements that are structured row by row by tuples.

Creates a Matrix with the specified elements that are structured row by row by tuples.

Dimensions will be checked at compile-time.

When invoking this method the following import has to be in place:

import matr.TupleSupport.given

The creation of i.e. a 2x3 Matrix looks like this:

val m = MatrixFactory[2, 3, Int].fromTuple(
 (11, 12, 13),
 (21, 22, 23)
)
def identity(using IsSquare[R, C]): Matrix[R, C, T]

Creates the identity Matrix.

Creates the identity Matrix.

def ones: Matrix[R, C, T]

Creates a Matrix of ones.

Creates a Matrix of ones.

def rowMajor(elements: T*): Matrix[R, C, T]

Creates a Matrix containing the specified elements, assuming row-major order. Dimensions will be checked at runtime.

Creates a Matrix containing the specified elements, assuming row-major order. Dimensions will be checked at runtime.

def tabulate(fillElem: (Int, Int) => T): Matrix[R, C, T]

Creates a Matrix containing the elements returned by the specified function.

Creates a Matrix containing the elements returned by the specified function.

Value parameters:
fillElem

function returning the element at the specified position (row index, column index)

def zeros: Matrix[R, C, T]

Creates a Matrix of zeros.

Creates a Matrix of zeros.