Mat
is an immutable container for 2D homogeneous data (a "matrix"). It is
backed by a single array. Data is stored in row-major order.
Several element access methods are provided.
The at
method returns an instance of a org.saddle.scalar.Scalar, which
behaves much like an Option
in that it can be either an instance of
org.saddle.scalar.NA or a org.saddle.scalar.Value case class:
val m = Mat(2,2,Array(1,2,3,4))
m.at(0,0) == Value(1)
The method raw
accesses the underlying value directly.
val m = Mat(2,2,Array(1,2,3,4))
m.raw(0,0) == 1d
Mat
may be used in arithmetic expressions which operate on two Mat
s or
on a Mat
and a primitive value. A fe examples:
val m = Mat(2,2,Array(1,2,3,4))
m * m == Mat(2,2,Array(1,4,9,16))
m dot m == Mat(2,2,Array(7d,10,15,22))
m * 3 == Mat(2, 2, Array(3,6,9,12))
Note, Mat is generally compatible with EJML's DenseMatrix. It may be convenient to induce this conversion to do more complex linear algebra, or to work with a mutable data structure.
Attributes
- A
Type of elements within the Mat
- Companion:
- object
- Graph
- Supertypes
Members list
Value members
Concrete methods
Return scalar value of matrix at offset from zero in row-major order
Return scalar value of matrix at offset from zero in row-major order
Attributes
- i
index
Return scalar value of Mat at at row/column
Return scalar value of Mat at at row/column
Attributes
- c
col index
- r
row index
Access a slice of the Mat by integer offsets
Access a slice of the Mat by integer offsets
Attributes
- c
Array of col offsets
- r
Array of row offsets
Access a slice of the Mat by integer offsets
Access a slice of the Mat by integer offsets
Attributes
- c
Integer col offset
- r
Array of row offsets
Access a slice of the Mat by integer offsets
Access a slice of the Mat by integer offsets
Attributes
- c
Array of col offsets
- r
Integer row offset
Access a slice of the Mat by Slice parameters
Access a slice of the Mat by Slice parameters
Attributes
- c
Slice to apply to cols
- r
Slice to apply to rows
Returns a specific column of the Mat as a Vec
Returns a specific column of the Mat as a Vec
Attributes
- c
Column index
Access Mat columns at a particular integer offsets
Access Mat columns at a particular integer offsets
Attributes
- locs
a sequence of integer offsets
Access Mat columns at a particular integer offsets
Access Mat columns at a particular integer offsets
Attributes
- locs
an array of integer offsets
Access mat columns specified by a slice
Access mat columns specified by a slice
Attributes
- slice
a slice specifier
Returns columns of Mat as an indexed sequence of Vec instances
Returns columns of Mat as an indexed sequence of Vec instances
Attributes
Returns columns of Mat as an indexed sequence of Vec instances
Returns columns of Mat as an indexed sequence of Vec instances
Attributes
Yields column indices where column has some NA value
Yields column indices where column has some NA value
Attributes
Concatenate this Mat to an other Mat vertically, i.e. concatenate as lists of rows
Concatenate this Mat to an other Mat vertically, i.e. concatenate as lists of rows
Attributes
Returns (a copy of) the contents of matrix as a single array in row-major order
Returns (a copy of) the contents of matrix as a single array in row-major order
Attributes
Yields a matrix without those cols that have NA
Yields a matrix without those cols that have NA
Attributes
Yields a matrix without those rows that have NA
Yields a matrix without those rows that have NA
Attributes
Row-by-row equality check of all values.
Row-by-row equality check of all values.
Attributes
- Definition Classes
- Any
Default hashcode is simple rolling prime multiplication of sums of hashcodes for all values.
Default hashcode is simple rolling prime multiplication of sums of hashcodes for all values.
Attributes
- Definition Classes
- Any
Returns true if the matrix is empty
Returns true if the matrix is empty
Attributes
Returns true if rows == cols
Returns true if rows == cols
Attributes
Returns total number of entries in the matrix
Returns total number of entries in the matrix
Attributes
Maps a function over each col in the matrix f must return a Vec with numRows elements
Maps a function over each col in the matrix f must return a Vec with numRows elements
Attributes
Maps a function over each row in the matrix f must return a Vec with numCols elements
Maps a function over each row in the matrix f must return a Vec with numCols elements
Attributes
In place mutate cols of the matrix
In place mutate cols of the matrix
Attributes
In place mutate rows of the matrix
In place mutate rows of the matrix
Attributes
Pretty-printer for Mat, which simply outputs the result of stringify.
Pretty-printer for Mat, which simply outputs the result of stringify.
Attributes
- nrows
Number of elements to display
Return unboxed value of matrix at an offset from zero in row-major order
Return unboxed value of matrix at an offset from zero in row-major order
Attributes
- i
index
Return unboxed value of matrix at row/column
Return unboxed value of matrix at row/column
Attributes
- c
col index
- r
row index
Reduces each col with a function f must return a scalar
Reduces each col with a function f must return a scalar
Attributes
Reduces each row with a function f must return a scalar
Reduces each row with a function f must return a scalar
Attributes
Changes the shape of matrix without changing the underlying data
Changes the shape of matrix without changing the underlying data
Backing array will be shared between the two instances!
Attributes
Rounds elements in the matrix (which must be numeric) to a significance level
Rounds elements in the matrix (which must be numeric) to a significance level
Attributes
- sig
Significance level to round to (e.g., 2 decimal places)
Returns a specific row of the Mat as a Vec
Returns a specific row of the Mat as a Vec
Attributes
- r
Row index
Access Mat rows at a particular integer offsets
Access Mat rows at a particular integer offsets
Attributes
- locs
a sequence of integer offsets
Access Mat rows at a particular integer offsets
Access Mat rows at a particular integer offsets
Attributes
- locs
an array of integer offsets
Access Mat rows specified by a slice
Access Mat rows specified by a slice
Attributes
- slice
a slice specifier
Returns rows of matrix as an indexed sequence of Vec instances
Returns rows of matrix as an indexed sequence of Vec instances
Attributes
Returns rows of matrix as an indexed sequence of Vec instances
Returns rows of matrix as an indexed sequence of Vec instances
Attributes
Yields row indices where row has some NA value
Yields row indices where row has some NA value
Attributes
Creates a string representation of Mat
Creates a string representation of Mat
Attributes
- ncols
Max number of cols to include
- nrows
Max number of rows to include
Create Mat comprised of same values in specified columns
Create Mat comprised of same values in specified columns
Attributes
Create Mat comprised of same values in specified columns
Create Mat comprised of same values in specified columns
Attributes
Create Mat comprised of same values in specified rows
Create Mat comprised of same values in specified rows
Attributes
Returns the backing array of this Mat Mutations to this array are visible to this Mat
Returns the backing array of this Mat Mutations to this array are visible to this Mat
Elements are laid out in row-major order
Attributes
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
Concatenate all rows into a single row-wise Vec instance
Concatenate all rows into a single row-wise Vec instance
Underlying array is shared between the two instances
Attributes
Create Mat comprised of same values without the specified columns
Create Mat comprised of same values without the specified columns
Attributes
- locs
Col locations to exclude
Create Mat comprised of same values without the specified columns
Create Mat comprised of same values without the specified columns
Attributes
- locs
Col locations to exclude
Create Mat comprised of same values without the specified rows
Create Mat comprised of same values without the specified rows
Attributes
- locs
Row locations to exclude
Create Mat comprised of same values without the specified rows
Create Mat comprised of same values without the specified rows
Attributes
- locs
Row locations to exclude
Inherited methods
Integer modulus of division
Integer modulus of division
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance (divisor)
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Bit-wise AND
Bit-wise AND
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Logical AND
Logical AND
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Multiplication
Multiplication
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Exponentiation
Exponentiation
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance (exponent)
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Addition
Addition
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Subtraction
Subtraction
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Division
Division
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance (divisor)
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Less-than comparison operator
Less-than comparison operator
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Bit-shift left
Bit-shift left
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Less-than-or-equal-to comparison operator
Less-than-or-equal-to comparison operator
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Element-wise inequality operator
Element-wise inequality operator
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Element-wise equality operator
Element-wise equality operator
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Greater-than comparison operator
Greater-than comparison operator
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Greater-than-or-equal-to comparison operator
Greater-than-or-equal-to comparison operator
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Bit-shift right (arithmetic)
Bit-shift right (arithmetic)
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Bit-shift right (logical)
Bit-shift right (logical)
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Bit-wise EXCLUSIVE OR
Bit-wise EXCLUSIVE OR
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Dot (inner) product
Dot (inner) product
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Outer product
Outer product
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Logical EXCLUSIVE OR
Logical EXCLUSIVE OR
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Bit-wise OR
Bit-wise OR
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps
Logical OR
Logical OR
Attributes
- B
type of the other operand
- That
result type of operation
- op
implicit evidence for operation between this and other
- other
other operand instance
- Inherited from:
- NumericOps