Contents

la_matrix_product(_:_:)

Declaration

func la_matrix_product(_ matrix_left: la_object_t, _ matrix_right: la_object_t) -> la_object_t

Discussion

Compute a matrix product.

Left splat operands are treated as 1 x rows(matrix_right) vectors and right splat operands are treated as cols(matrix_left) x 1 vectors.

For convenience, in certain situations vector operands may be implicitly transposed. Specifically,

If cols(matrix_left) == rows(matrix_right) rows(matrix_left) x cols(matrix_right) = matrix_left * matrix_right Else if cols(matrix_left) == 1 and rows(matrix_left) == rows(matrix_right) 1 x cols(matrix_right) = transpose(matrix_left) * matrix_right Else if rows(matrix_right) == 1 and cols(matrix_left) == cols(matrix_right) rows(matrix_left) x 1 = matrix_left * transpose(matrix_right) Else result has the status LA_DIMENSION_MISMATCH_ERROR.

If either operand is not a vector or matrix or splat, or if both operands are splats, the result has the status LA_INVALID_PARAMETER_ERROR.

Otherwise the result is a matrix with 1 row if matrix_left is vector or splat and rows(matrix_left) otherwise, and 1 column if matrix_right is vector or splat and cols(matrix_right) otherwise.

If cols(matrix_left) == rows(matrix_right), the i,jth element of the matrix is: sum_{k=0…cols(matrix_left)} matrix_left[i,k] * matrix_right[k,j] If cols(matrix_left) == 1 and rows(matrix_left) == rows(matrix_right), the 0,jth element of matrix is: sum_{k=0…rows(matrix_right)} matrix_left[k,0] * matrix_right[k,j] If rows(matrix_right) == 1 and cols(matrix_left) == cols(matrix_right), the i,0th element of matrix is: sum_{k=0…cols(matrix_left)} matrix_left[i,k] * matrix_right[0,k]

See Also

Functions