MatrixOperationsBase
public protocol MatrixOperationsBase : MatrixBase
A matrix declaring the full suite of mathematical operations (addition, scalar addition, multiplication, scalar multiplication, etc).
-
The type returned by adding or subtracting two matrices.
Declaration
Swift
associatedtype MatrixAdditionType : MatrixBase where Self.ElementType == Self.MatrixAdditionType.ElementType, Self.MatrixAdditionType.ElementType == Self.MatrixMultiplicationType.ElementType -
The type returned by multiplying two matrices.
Declaration
Swift
associatedtype MatrixMultiplicationType : MatrixBase -
The type returned by transposing this matrix.
Declaration
Swift
associatedtype MatrixTransposeType : MatrixBase -
Adds
selfandmatrixcomponent-wise.Declaration
Swift
func add<M>(by matrix: M) throws -> MatrixAdditionType where M : MatrixBase, Self.ElementType == M.ElementTypeParameters
matrixThe matrix to add to this matrix.
Return Value
The result of adding
selfandmatrix. -
Subtracts
selfandmatrixcomponent-wise.Declaration
Swift
func subtract<M>(by matrix: M) throws -> MatrixAdditionType where M : MatrixBase, Self.ElementType == M.ElementTypeParameters
matrixThe matrix to subtract from this matrix.
Return Value
The result of subracting
matrixandself. -
Performs matrix multiplication on
selfandmatrix(not component-wise).Throws
MatrixError.incorrectDimensionsifself.dimensions.columndoes not equalmatrix.dimensions.row.Declaration
Swift
func multiply<M>(by matrix: M) throws -> MatrixMultiplicationType where M : MatrixBase, Self.ElementType == M.ElementTypeParameters
matrixThe matrix to multiply with this matrix.
Return Value
The result of multiplying
selfandmatrix. -
Returns the transpose of this matrix. Transposing a matrix turns rows to columns and vice versa.
Declaration
Swift
func transpose() -> MatrixTransposeTypeReturn Value
A matrix whose rows are the columns of self and vice versa.
-
Adds a matrix and a scalar.
Declaration
Swift
static func + (lhs: Self, rhs: ElementType) -> SelfParameters
lhsThe current matrix.
rhsThe scalar to add to the elements.
Return Value
A matrix with dimensions equal to lhs.dimensions with rhs added to all elements.
-
Adds a scalar and a matrix.
Declaration
Swift
static func + (lhs: ElementType, rhs: Self) -> SelfParameters
lhsThe scalar to add to the elements.
rhsThe current matrix.
Return Value
A matrix with dimensions equal to rhs.dimensions with lhs added to all elements.
-
Subtracts a scalar from a matrix.
Declaration
Swift
static func - (lhs: Self, rhs: ElementType) -> SelfParameters
lhsThe current matrix.
rhsThe scalar to subtract from the elements.
Return Value
A matrix with dimensions equal to lhs.dimensions with rhs subtracted from all elements.
-
Subtracts a matrix from a scalar.
Declaration
Swift
static func - (lhs: ElementType, rhs: Self) -> SelfParameters
lhsThe scalar from which to subtract the matrix’s elements.
rhsThe current matrix.
Return Value
A matrix with dimensions equal to rhs.dimensions with all elements subtracted from lhs.
-
Multiplies a matrix by a scalar.
Declaration
Swift
static func * (lhs: Self, rhs: ElementType) -> SelfParameters
lhsThe current matrix.
rhsThe scalar to multiply the elements of the matrix by.
Return Value
A matrix with dimensions equal to lhs.dimensions with all elements multiplied by rhs.
-
Multiplies a scalar by a matrix.
Declaration
Swift
static func * (lhs: ElementType, rhs: Self) -> SelfParameters
lhsThe scalar to multiply the elements of the matrix by.
rhsThe current matrix.
Return Value
A matrix with dimensions equal to rhs.dimensions with all elements multiplied by lhs.
-
Adds and assigns a scalar and a matrix.
Declaration
Swift
static func += (lhs: inout Self, rhs: ElementType)Parameters
lhsThe matrix to add and assign.
-
Subtracts and assigns a scalar and a matrix.
Declaration
Swift
static func -= (lhs: inout Self, rhs: ElementType)Parameters
lhsThe matrix to subtract and assign.
-
Multiplies and assigns a scalar and a matrix.
Declaration
Swift
static func *= (lhs: inout Self, rhs: ElementType)Parameters
lhsThe matrix to multiply and assign.
MatrixOperationsBase Protocol Reference