_Matrix

it.grypho.scala.leonardo.matrix._Matrix
See the_Matrix companion object
case class _Matrix(rows: Int, cols: Int, elems: Vector[_Expression]) extends _ElementWise, _MatrixShaped

A symbolic matrix whose elements are arbitrary expressions.

This is the AST-side matrix; the fully-reduced counterpart is _MatrixValue (a dense Array[Double] in core). Elements may be numbers, variables, functions, functionals, or any other _Expression.

eval reduces every element: when all of them fold to _Number values the matrix collapses to a single _MatrixValue; otherwise it stays symbolic with each element as far reduced as it goes (the dual-evaluation contract, applied element-wise).

Marked _ElementWise: derive/simplify/expand/integrate distribute over the elements (e.g. d/dx [a_ij] = [d(a_ij)/dx]), which is valid because the matrix is a plain container with no coupling between cells.

children / rebuild expose the elements to generic traversals, so substitute and dependsOn work through matrix elements without matrix-specific cases.

Value parameters

cols

number of columns (must be positive)

elems

row-major element vector; must have exactly rows * cols entries

rows

number of rows (must be positive)

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait _ElementWise
trait _Expression
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def apply(i: Int, j: Int): _Expression

Returns the element at zero-based row i and column j.

Returns the element at zero-based row i and column j.

Value parameters

i

zero-based row index

j

zero-based column index

Attributes

Returns

the expression stored at position (i, j)

override def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

Definition Classes
override def eval(env: Environment): Either[_Expression, _Value]

Reduces this expression in the given environment.

Reduces this expression in the given environment.

Value parameters

env

variable bindings and display precision

Attributes

Returns

Right(v) when all free variables resolved to concrete values; Left(e) when reduction is partial or impossible

Definition Classes
override def rebuild(c: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Definition Classes
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

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Inherited fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes

Inherited from:
_Expression