LinearAlgebra[Modular][Mod] - apply 'mod' to input with optional evaluation list producing a mod m Matrix or Vector as output
|
Calling Sequence
|
|
Mod(m, A, eval, dtype, order)
Mod(m, A, eval, B)
|
|
Parameters
|
|
m
|
-
|
modulus
|
A
|
-
|
input object; can contain Matrices, Vectors, sets or lists, and a subspec
|
eval
|
-
|
(optional) equation or set or list of equations for the evaluation
|
dtype
|
-
|
(optional) datatype of output object
|
order
|
-
|
(optional) ordering of output object (default is C_order)
|
B
|
-
|
output object (copy to), including subspec
|
|
|
|
|
Description
|
|
•
|
The Mod function applies 'mod' with respect to the input modulus m, and optional evaluation list eval, to the input object A. This produces a new mod m Matrix or Vector with the specified datatype dtype and order order, or places the result in an existing mod m Matrix or Vector B.
|
•
|
Allowable formats for A include Matrices or Vectors, sets or lists of Vectors, or sets or lists of sets or lists (though a set of sets format is not typically useful). Input Matrices or Vectors must be rectangular and can have datatype integer[4]/integer[8], float[8], or anything.
|
|
The data is interpreted in different ways based on the input, that is, what type of mod mobject is produced in each case by default.
|
|
In the case where the input is a Matrix or Vector, the output is the same type, with the same number of rows and columns, but with the specified datatype and ordering.
|
|
If the input is a set or list of Vectors, the output is a Matrix. All input Vectors must have the same number of elements and orientation. If they are column Vectors, they correspond to the columns in the output. If they are row Vectors, they correspond to the rows in the output.
|
|
If the input is a nested set or list, each set or list in the outer set or list corresponds to a row of the output. In this case, it is not required that all elements of the outer set or list have the same number of elements, as the output Matrix is chosen to be large enough to contain the longest of these as a row, and any rows with additional elements are zero padded.
|
|
If the input is a simple set or list, the output is a column Vector.
|
•
|
Now that the default format has been described, the resulting object can be modified by using a subspec, so that only certain rows or columns are used, and the default output can be transposed.
|
•
|
If no evaluation eval is provided, the input can contain integers or fractions only (or floats for input float[8] datatype).
|
|
Note: The float[8] datatype is provided primarily for conversion from a float[8] mod p Matrix or Vector to one of the other datatypes. It is assumed that the closest integer to each float in the input is what is required.
|
•
|
If an evaluation list, eval, is specified, the inputs must be rational polynomials in terms of the indeterminates in the evaluation list.
|
|
The input can also contain univariate modp1 polynomials, but the modulus must match the input modulus , and the evaluation eval must contain an equation with the indeterminate of the modp1 polynomials on the left-hand side. Special evaluation rules, such as , are not applied to modp1 polynomials.
|
•
|
The first calling sequence results in a new mod m Matrix or Vector, which is output by the call. The second calling sequence computes the Mod into an existing object, which can also be a sub-Vector or sub-Matrix.
|
•
|
This command is part of the LinearAlgebra[Modular] package, so it can be used in the form Mod(..) only after executing the command with(LinearAlgebra[Modular]). However, it can always be used in the form LinearAlgebra[Modular][Mod](..).
|
|
|
Examples
|
|
Conversion of a integer Matrix to a mod m integer[] Matrix.
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
Conversion of a list of lists of rationals to a mod m float[8] Matrix.
>
|
|
| (3) |
>
|
|
| (4) |
Evaluation of a list of polynomials to a row vector.
>
|
|
| (5) |
>
|
|
| (6) |
Evaluation of a list of Vectors of modp1 polynomials to a new Matrix, and to an existing Matrix with sub-specification.
>
|
|
| (7) |
>
|
|
| (8) |
>
|
|
>
|
|
>
|
|
| (9) |
Extended evaluation syntax.
>
|
|
| (10) |
>
|
|
| (11) |
Floating-point input. This is not a good choice, notice the rounding.
>
|
|
| (12) |
>
|
|
| (13) |
|
|