Matrix

problemutils.classes.Matrix
See theMatrix companion object
case class Matrix[A] extends IterableOnce[A]

A generic Matrix class. Useful for working with 2D structures.

Type parameters

A

The type of elements in the matrix. When A is a scala.Numeric type, a number of extension methods are made available which allow for basic mathematical matrix operations.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait IterableOnce[A]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def *(other: Matrix[A])(using Numeric[A]): Matrix[A]
def +(other: Matrix[A])(using Numeric[A]): Matrix[A]
def -(other: Matrix[A])(using Numeric[A]): Matrix[A]
def appendedBottom(other: Matrix[A]): Matrix[A]
def appendedLeft(other: Matrix[A]): Matrix[A]
def appendedRight(other: Matrix[A]): Matrix[A]
def appendedTop(other: Matrix[A]): Matrix[A]
def apply(index: (Int, Int)): A

Returns the element at the given position (row, col)

Returns the element at the given position (row, col)

Attributes

def col(col: Int): Vector[A]

Returns the column at the given index

Returns the column at the given index

Attributes

def cols: Vector[Vector[A]]
def count(f: A => Boolean): Int
def determinant(using Numeric[A]): Double

Computes the determinant of this matrix.

Computes the determinant of this matrix.

Attributes

def determinantOption(using Numeric[A]): Option[Double]
def diagonal: Vector[A]
def diagonalProduct(using Numeric[A]): A
def dropCol(col: Int): Matrix[A]
def dropRow(row: Int): Matrix[A]
def exists(f: A => Boolean): Boolean
def filterCol(f: Vector[A] => Boolean): Matrix[A]
def filterRow(f: Vector[A] => Boolean): Matrix[A]
def find(pred: A => Boolean): Option[A]
def forall(f: A => Boolean): Boolean
def foreach[U](f: A => U): Unit
def indexOutsideBounds(index: Pos2D): Boolean
def indexWhere(pred: A => Boolean): Option[(Int, Int)]
def indices: Matrix[(Int, Int)]
def isSquare: Boolean
def isSymmetric: Boolean

Returns true if this matrix is equal to its own transpose.

Returns true if this matrix is equal to its own transpose.

Attributes

override def iterator: Iterator[A]

Attributes

Definition Classes
IterableOnce
def map[B](f: A => B): Matrix[B]
def mkString: String
def mkString(sep: String): String
def mkString(sep: String, rowSep: String): String
def mkString(start: String, sep: String, end: String): String
def oppositeDiagonal: Vector[A]
def product(using Numeric[A]): A
def range: Matrix[Int]
def reshape(height: Int, width: Int): Matrix[A]
def rotateLeft: Matrix[A]
def row(row: Int): Vector[A]

Returns the row at the given index

Returns the row at the given index

Attributes

def rows: Vector[Vector[A]]
def slice(index: (Int, Int))(height: Int, width: Int): Matrix[A]
def sum(using Numeric[A]): A
def swapCols(a: Int, b: Int): Matrix[A]
def swapRows(a: Int, b: Int): Matrix[A]
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
def toVector: Vector[A]
def trace(using Numeric[A]): A

Computes the trace of this matrix.

Computes the trace of this matrix.

Attributes

def traceOption(using Numeric[A]): Option[A]
def transpose: Matrix[A]

Returns the transpose of this matrix.

Returns the transpose of this matrix.

Attributes

def updated(row: Int, col: Int)(value: A): Matrix[A]
def zip[B](other: Matrix[B]): Matrix[(A, B)]
def zipWithRange: Matrix[(A, Int)]

Inherited methods

def knownSize: Int

Attributes

Inherited from:
IterableOnce
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def stepper[S <: Stepper[_]](implicit shape: StepperShape[A, S]): S

Attributes

Inherited from:
IterableOnce

Concrete fields

val dimensions: (Int, Int)

The height and width of this matrix.

The height and width of this matrix.

Attributes

val height: Int
val size: Int

The "area", or height x width, of this matrix.

The "area", or height x width, of this matrix.

Attributes

val width: Int