scalar, Vector, and Matrix multiplication
Multiply(m, A, B, order, 'sparse')
Multiply(m, A, B, C, 'sparse')
scalar, Matrix, or Vector including subspec
Matrix or Vector, including subspec
(optional) ordering of output object; C_order or Fortran_order
(optional) controls behavior of operation
output Matrix or Vector, including subspec
The Multiply function performs the operation A*B placing the output in a new object, or in C, depending on calling sequence. All Matrices or Vectors must have the same datatype. Multiply can perform Matrix-Matrix, Matrix-Vector, Vector-Matrix, scalar-Matrix, Vector-Vector, or scalar-Vector multiplication with output as a scalar,Vector or Matrix. The output depends on the input specification.
The first calling sequence returns a scalar or new mod m Matrix or Vector for the result with the specified ordering order, or the ordering of the input objects A and B.
Note: If A and B are both Matrices or Vectors and have a different ordering, order must be specified.
The remaining calling sequence places the output of the computation into C, returning NULL.
Scalar multiplication can be performed by setting A to a scalar value in the range 1..m−1, and specifying B as a mod m Matrix or Vector. In this case, C can be specified as the same Matrix or Vector as B as long as the operation is performed with direct overlap. For example, if B and C are the same Matrix, the operation involving the entry Bi,j must have the result going to Ci,j.
If the optional keyword, 'sparse', is specified, it only applies to scalar multiplication if the multiplier is not 1 or m−1 and the datatype is a hardware datatype. It indicates that the algorithm checks for zero entries before performing multiplications. This typically provides an efficiency gain when matrices have 10% or more entries in B equal to zero. This is not implemented for the integer datatype, as it typically provides very little gain for that case.
Note: If sparse does not apply but it has been specified, the option is ignored.
For multiplication of two mod m Matrices or Vectors, the number of columns in A must be equal to the number of rows in B, and the result has dimensions equal to rows⁡A⁢x⁢cols⁡B.
For example, if A is a row Vector, and B is a column Vector, the result is a zero dimensional value representing the dot product of A and B. In this case, the output of the first calling sequence is a scalar value. For the second calling sequence, the entry in C into which this value is placed is determined by the sub-Matrix or sub-Vector specification for C.
Alternatively, if A is a column Vector, and B is a row Vector, the result is a Matrix which represents the outer product of A and B.
The Multiply function allows the use of sub-Matrix and sub-Vector specifications for both input and output Vectors/Matrices. For example, the function can be used to multiply a row of a Matrix to the transpose of a row in another Matrix, placing the result in a specified entry of a third Matrix.
Note: For scalar multiplication, B and C are allowed direct overlap. If both A and B are mod m Matrices or Vectors and if either overlap with C, the behavior of Multiply is undefined.
This command is part of the LinearAlgebra[Modular] package, so it can be used in the form Multiply(..) only after executing the command with(LinearAlgebra[Modular]). However, it can always be used in the form LinearAlgebra[Modular][Multiply](..).
A ≔ Mod⁡13,Vectorrow⁡4,i→rand⁡,integer
B ≔ Mod⁡13,Vectorcolumn⁡4,i→rand⁡,integer
The inner product.
The outer product.
The inner product into existing Matrix.
C ≔ Create⁡13,2,2,integer
A ≔ Mod⁡13,Matrix⁡3,4,i,j→rand⁡,integer
B ≔ Mod⁡13,Vectorrow⁡3,i→rand⁡,integer
Scalar multiplication of A into A.
Multiplication of the third row of A to the transpose of A, with result being placed in a specified location of a new Matrix.
C ≔ Create⁡13,2,6,integer
Download Help Document
What kind of issue would you like to report? (Optional)