org.saddle

Mat

trait Mat[A] extends NumericOps[Mat[A]] with Serializable

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 Scalar, which behaves much like an Option in that it can be either an instance of org.saddle.scalar.NA or a 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 arithemetic expressions which operate on two Mats 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.

A

Type of elements within the Mat

Linear Supertypes
Serializable, Serializable, NumericOps[Mat[A]], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Mat
  2. Serializable
  3. Serializable
  4. NumericOps
  5. AnyRef
  6. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def map[B](f: (A) ⇒ B)(implicit arg0: ST[B]): Mat[B]

    Maps a function over each element in the matrix

  2. abstract def numCols: Int

    Returns number of columns in the matrix shape

  3. abstract def numRows: Int

    Returns number of rows in the matrix shape

  4. abstract def reshape(r: Int, c: Int): Mat[A]

    Changes the shape of matrix without changing the underlying data

  5. abstract def scalarTag: ScalarTag[A]

  6. abstract def takeRows(locs: Array[Int]): Mat[A]

    Create Mat comprised of same values in specified rows

  7. abstract def toVec: Vec[A]

    Concatenate all rows into a single row-wise Vec instance

  8. abstract def transpose: Mat[A]

    Transpose of original matrix

  9. abstract def withoutRows(locs: Array[Int]): Mat[A]

    Create Mat comprised of same values without the specified rows

    Create Mat comprised of same values without the specified rows

    locs

    Row locations to exclude

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def %[B, That](other: B)(implicit op: BinOp[Mod, Mat[A], B, That]): That

    Integer modulus of division

    Integer modulus of division

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance (divisor)

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  5. def &[B, That](other: B)(implicit op: BinOp[BitAnd, Mat[A], B, That]): That

    Bit-wise AND

    Bit-wise AND

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  6. def &&[B, That](other: B)(implicit op: BinOp[AndOp, Mat[A], B, That]): That

    Logical AND

    Logical AND

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  7. def *[B, That](other: B)(implicit op: BinOp[Multiply, Mat[A], B, That]): That

    Multiplication

    Multiplication

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  8. def **[B, That](other: B)(implicit op: BinOp[Power, Mat[A], B, That]): That

    Exponentiation

    Exponentiation

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance (exponent)

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  9. def +[B, That](other: B)(implicit op: BinOp[Add, Mat[A], B, That]): That

    Addition

    Addition

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  10. def -[B, That](other: B)(implicit op: BinOp[Subtract, Mat[A], B, That]): That

    Subtraction

    Subtraction

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  11. def /[B, That](other: B)(implicit op: BinOp[Divide, Mat[A], B, That]): That

    Division

    Division

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance (divisor)

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  12. def <[B, That](other: B)(implicit op: BinOp[LtOp, Mat[A], B, That]): That

    Less-than comparison operator

    Less-than comparison operator

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  13. def <<[B, That](other: B)(implicit op: BinOp[BitShl, Mat[A], B, That]): That

    Bit-shift left

    Bit-shift left

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  14. def <=[B, That](other: B)(implicit op: BinOp[LteOp, Mat[A], B, That]): That

    Less-than-or-equal-to comparison operator

    Less-than-or-equal-to comparison operator

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  15. def <>[B, That](other: B)(implicit op: BinOp[NeqOp, Mat[A], B, That]): That

    Element-wise inequality operator

    Element-wise inequality operator

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  16. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  18. def =?[B, That](other: B)(implicit op: BinOp[EqOp, Mat[A], B, That]): That

    Element-wise equality operator

    Element-wise equality operator

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  19. def >[B, That](other: B)(implicit op: BinOp[GtOp, Mat[A], B, That]): That

    Greater-than comparison operator

    Greater-than comparison operator

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  20. def >=[B, That](other: B)(implicit op: BinOp[GteOp, Mat[A], B, That]): That

    Greater-than-or-equal-to comparison operator

    Greater-than-or-equal-to comparison operator

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  21. def >>[B, That](other: B)(implicit op: BinOp[BitShr, Mat[A], B, That]): That

    Bit-shift right (arithmetic)

    Bit-shift right (arithmetic)

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  22. def >>>[B, That](other: B)(implicit op: BinOp[BitUShr, Mat[A], B, That]): That

    Bit-shift right (logical)

    Bit-shift right (logical)

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  23. def T: Mat[A]

    Transpose of original matrix

  24. def ^[B, That](other: B)(implicit op: BinOp[BitXor, Mat[A], B, That]): That

    Bit-wise EXCLUSIVE OR

    Bit-wise EXCLUSIVE OR

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  25. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  26. def at(r: Slice[Int], c: Slice[Int])(implicit st: ScalarTag[A]): Mat[A]

    Access a slice of the Mat by Slice parameters

    Access a slice of the Mat by Slice parameters

    r

    Slice to apply to rows

    c

    Slice to apply to cols

  27. def at(r: Int, c: Array[Int])(implicit st: ScalarTag[A]): Vec[A]

    Access a slice of the Mat by integer offsets

    Access a slice of the Mat by integer offsets

    r

    Integer row offset

    c

    Array of col offsets

  28. def at(r: Array[Int], c: Int)(implicit st: ScalarTag[A]): Vec[A]

    Access a slice of the Mat by integer offsets

    Access a slice of the Mat by integer offsets

    r

    Array of row offsets

    c

    Integer col offset

  29. def at(r: Array[Int], c: Array[Int])(implicit st: ScalarTag[A]): Mat[A]

    Access a slice of the Mat by integer offsets

    Access a slice of the Mat by integer offsets

    r

    Array of row offsets

    c

    Array of col offsets

  30. def at(r: Int, c: Int)(implicit st: ScalarTag[A]): Scalar[A]

    Return scalar value of Mat at at row/column

    Return scalar value of Mat at at row/column

    r

    row index

    c

    col index

  31. def at(i: Int)(implicit st: ScalarTag[A]): Scalar[A]

    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

    i

    index

  32. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  33. def col(slice: Slice[Int]): Mat[A]

    Access mat columns specified by a slice

    Access mat columns specified by a slice

    slice

    a slice specifier

  34. def col(locs: Array[Int])(implicit ev: ST[A]): Mat[A]

    Access Mat columns at a particular integer offsets

    Access Mat columns at a particular integer offsets

    locs

    an array of integer offsets

  35. def col(locs: Int*)(implicit ev: ST[A]): Mat[A]

    Access Mat columns at a particular integer offsets

    Access Mat columns at a particular integer offsets

    locs

    a sequence of integer offsets

  36. def col(c: Int)(implicit ev: ST[A]): Vec[A]

    Returns a specific column of the Mat as a Vec

    Returns a specific column of the Mat as a Vec

    c

    Column index

  37. def cols(seq: IndexedSeq[Int])(implicit ev: ST[A]): IndexedSeq[Vec[A]]

    Returns columns of Mat as an indexed sequence of Vec instances

  38. def cols()(implicit ev: ST[A]): IndexedSeq[Vec[A]]

    Returns columns of Mat as an indexed sequence of Vec instances

  39. def colsWithNA(implicit ev: ST[A]): Set[Int]

    Yields column indices where column has some NA value

  40. def contents: Array[A]

    Returns (a copy of) the contents of matrix as a single array in row-major order

  41. def dot[B, That](other: B)(implicit op: BinOp[InnerProd, Mat[A], B, That]): That

    Dot (inner) product

    Dot (inner) product

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  42. def dropColsWithNA(implicit ev: ST[A]): Mat[A]

    Yields a matrix without those cols that have NA

  43. def dropRowsWithNA(implicit ev: ST[A]): Mat[A]

    Yields a matrix without those rows that have NA

  44. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  45. def equals(o: Any): Boolean

    Row-by-row equality check of all values.

    Row-by-row equality check of all values. NB: to avoid boxing, overwrite in child classes

    Definition Classes
    Mat → AnyRef → Any
  46. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  47. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  48. def hashCode(): Int

    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.

    Definition Classes
    Mat → AnyRef → Any
  49. def isEmpty: Boolean

    Returns true if the matrix is empty

  50. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  51. def isSquare: Boolean

    Returns true if rows == cols

  52. def length: Int

    Returns total number of entries in the matrix

  53. def mult[B](m: Mat[B])(implicit evA: NUM[A], evB: NUM[B]): Mat[Double]

    Multiplies this matrix against another

  54. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  55. final def notify(): Unit

    Definition Classes
    AnyRef
  56. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  57. def outer[B, That](other: B)(implicit op: BinOp[OuterProd, Mat[A], B, That]): That

    Outer product

    Outer product

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  58. def print(nrows: Int = 8, ncols: Int = 8, stream: OutputStream = System.out): Unit

    Pretty-printer for Mat, which simply outputs the result of stringify.

    Pretty-printer for Mat, which simply outputs the result of stringify.

    nrows

    Number of elements to display

  59. def raw(r: Int, c: Int): A

    Return unboxed value of matrix at row/column

    Return unboxed value of matrix at row/column

    r

    row index

    c

    col index

  60. def raw(i: Int): A

    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

    i

    index

  61. def roundTo(sig: Int = 2)(implicit ev: NUM[A]): Mat[Double]

    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

    sig

    Significance level to round to (e.g., 2 decimal places)

  62. def row(slice: Slice[Int]): Mat[A]

    Access Mat rows specified by a slice

    Access Mat rows specified by a slice

    slice

    a slice specifier

  63. def row(locs: Array[Int])(implicit ev: ST[A]): Mat[A]

    Access Mat rows at a particular integer offsets

    Access Mat rows at a particular integer offsets

    locs

    an array of integer offsets

  64. def row(locs: Int*)(implicit ev: ST[A]): Mat[A]

    Access Mat rows at a particular integer offsets

    Access Mat rows at a particular integer offsets

    locs

    a sequence of integer offsets

  65. def row(r: Int)(implicit ev: ST[A]): Vec[A]

    Returns a specific row of the Mat as a Vec

    Returns a specific row of the Mat as a Vec

    r

    Row index

  66. def rows(seq: IndexedSeq[Int])(implicit ev: ST[A]): IndexedSeq[Vec[A]]

    Returns rows of matrix as an indexed sequence of Vec instances

  67. def rows()(implicit ev: ST[A]): IndexedSeq[Vec[A]]

    Returns rows of matrix as an indexed sequence of Vec instances

  68. def rowsWithNA(implicit ev: ST[A]): Set[Int]

    Yields row indices where row has some NA value

  69. def stringify(nrows: Int = 8, ncols: Int = 8): String

    Creates a string representation of Mat

    Creates a string representation of Mat

    nrows

    Max number of rows to include

    ncols

    Max number of cols to include

  70. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  71. def takeCols(locs: Int*): Mat[A]

    Create Mat comprised of same values in specified columns

  72. def takeCols(locs: Array[Int]): Mat[A]

    Create Mat comprised of same values in specified columns

  73. def takeRows(locs: Int*): Mat[A]

    Create Mat comprised of same values in specified rows

  74. def toString(): String

    Definition Classes
    Mat → AnyRef → Any
  75. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  76. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  77. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  78. def withoutCols(locs: Int*): Mat[A]

    Create Mat comprised of same values without the specified columns

    Create Mat comprised of same values without the specified columns

    locs

    Col locations to exclude

  79. def withoutCols(locs: Array[Int]): Mat[A]

    Create Mat comprised of same values without the specified columns

    Create Mat comprised of same values without the specified columns

    locs

    Col locations to exclude

  80. def withoutRows(locs: Int*): Mat[A]

    Create Mat comprised of same values without the specified rows

    Create Mat comprised of same values without the specified rows

    locs

    Row locations to exclude

  81. def xor[B, That](other: B)(implicit op: BinOp[XorOp, Mat[A], B, That]): That

    Logical EXCLUSIVE OR

    Logical EXCLUSIVE OR

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  82. def |[B, That](other: B)(implicit op: BinOp[BitOr, Mat[A], B, That]): That

    Bit-wise OR

    Bit-wise OR

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps
  83. def ||[B, That](other: B)(implicit op: BinOp[OrOp, Mat[A], B, That]): That

    Logical OR

    Logical OR

    B

    type of the other operand

    That

    result type of operation

    other

    other operand instance

    op

    implicit evidence for operation between this and other

    Definition Classes
    NumericOps

Inherited from Serializable

Inherited from Serializable

Inherited from NumericOps[Mat[A]]

Inherited from AnyRef

Inherited from Any