MatrixType

public protocol MatrixType : Equatable

Protocol for Matrix types.

  • The scalar value associated with each element of this matrix.

    Declaration

    Swift

    associatedtype Scalar : DivisibleArithmetic, Real
  • Gets the identity matrix for this matrix type.

    Declaration

    Swift

    static var identity: Self { get }
  • Gets the number of rows in this matrix.

    Declaration

    Swift

    var rowCount: Int { get }
  • Gets the number of columns in this matrix.

    Declaration

    Swift

    var columnCount: Int { get }
  • Gets or sets the scalar value on a given column/row in this matrix.

    Declaration

    Swift

    subscript(column: Int, row: Int) -> Scalar { get set }
  • init(rowMajorValues:) Default implementation

    Initializes a matrix with a flat list of values that are read in [row-major order].

    The list should have at least rowCount * columnCount elements.

    Precondition

    values.count >= rowCount * columnCount

    Default Implementation

    Initializes a matrix with a flat list of values that are read in [row-major order].

    The list should have at least rowCount * columnCount elements.

    Precondition

    values.count >= rowCount * columnCount

    Declaration

    Swift

    init(rowMajorValues values: [Scalar])
  • init(columnMajorValues:) Default implementation

    Initializes a matrix with a flat list of values that are read in [column-major order].

    The list should have at least rowCount * columnCount elements.

    Precondition

    values.count >= rowCount * columnCount

    Default Implementation

    Initializes a matrix with a flat list of values that are read in [column-major order].

    The list should have at least rowCount * columnCount elements.

    Precondition

    values.count >= rowCount * columnCount

    Declaration

    Swift

    init(columnMajorValues values: [Scalar])
  • rowMajorValues() Default implementation

    Returns a flat array of each scalar value from this matrix ordered as a row major list.

    Default Implementation

    Returns a flat array of each scalar value from this matrix ordered as a row major list.

    Declaration

    Swift

    func rowMajorValues() -> [Scalar]
  • columnMajorValues() Default implementation

    Returns a flat array of each scalar value from this matrix ordered as a column major list.

    Default Implementation

    Returns a flat array of each scalar value from this matrix ordered as a column major list.

    Declaration

    Swift

    func columnMajorValues() -> [Scalar]
  • Negates (i.e. flips) the signs of all the values of this matrix.

    Declaration

    Swift

    prefix static func - (value: Self) -> Self
  • Performs a matrix addition between lhs and rhs and returns the result.

    Declaration

    Swift

    static func + (lhs: Self, rhs: Self) -> Self
  • Performs a matrix subtraction between lhs and rhs and returns the result.

    Declaration

    Swift

    static func - (lhs: Self, rhs: Self) -> Self
  • +=(_:_:) Default implementation

    Performs a matrix addition between lhs and rhs and stores the result back into lhs.

    Default Implementation

    Performs a matrix addition between lhs and rhs and stores the result back into lhs.

    Declaration

    Swift

    static func += (lhs: inout Self, rhs: Self)
  • -=(_:_:) Default implementation

    Performs a matrix subtraction between lhs and rhs and stores the result back into lhs.

    Default Implementation

    Performs a matrix subtraction between lhs and rhs and stores the result back into lhs.

    Declaration

    Swift

    static func -= (lhs: inout Self, rhs: Self)
  • Performs a scalar multiplication between lhs and rhs and returns the result.

    Declaration

    Swift

    static func * (lhs: Self, rhs: Scalar) -> Self
  • Performs a scalar division between the elements of lhs and rhs and returns the result.

    Declaration

    Swift

    static func / (lhs: Self, rhs: Scalar) -> Self
  • *=(_:_:) Default implementation

    Performs a scalar multiplication between lhs and rhs and stores the result back into lhs.

    Default Implementation

    Performs a scalar multiplication between lhs and rhs and stores the result back into lhs.

    Declaration

    Swift

    static func *= (lhs: inout Self, rhs: Scalar)
  • /=(_:_:) Default implementation

    Performs a scalar division between the elements of lhs and rhs and stores the result back into lhs.

    Default Implementation

    Performs a scalar division between the elements of lhs and rhs and stores the result back into lhs.

    Declaration

    Swift

    static func /= (lhs: inout Self, rhs: Scalar)