LinearAlgebra[Modular][Multiply] - scalar, Vector, and Matrix multiplication
|
Calling Sequence
|
|
Multiply(m, A, B, order, 'sparse')
Multiply(m, A, B, C, 'sparse')
|
|
Parameters
|
|
m
|
-
|
modulus
|
A
|
-
|
scalar, Matrix, or Vector including subspec
|
B
|
-
|
Matrix or Vector, including subspec
|
order
|
-
|
(optional) ordering of output object; C_order or Fortran_order
|
sparse
|
-
|
(optional) controls behavior of operation
|
C
|
-
|
output Matrix or Vector, including subspec
|
|
|
|
|
Description
|
|
•
|
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.
|
|
If the optional keyword, 'sparse', is specified, it only applies to scalar multiplication if the multiplier is not or 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 .
|
|
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](..).
|
|
|
Examples
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
The inner product.
>
|
|
| (3) |
The outer product.
>
|
|
| (4) |
The inner product into existing Matrix.
>
|
|
| (5) |
>
|
|
>
|
|
| (6) |
Matrix-Vector multiplication.
>
|
|
| (7) |
>
|
|
| (8) |
Vector-Matrix multiplication.
>
|
|
| (9) |
>
|
|
| (10) |
Scalar multiplication of A into A.
>
|
|
>
|
|
| (11) |
Multiplication of the third row of A to the transpose of A, with result being placed in a specified location of a new Matrix.
>
|
|
| (12) |
>
|
|
>
|
|
| (13) |
|
|