Module documentation¶

We represent a matrix over $$\mathbf{Q}_p$$ as a product $$p^v M$$, where $$p$$ is a prime number, $$v \in \mathbf{Z}$$ and $$M$$ a matrix over $$\mathbf{Z}$$. We say this matrix is in canonical form if either $$M$$ is zero, in which case we choose $$v = 0$$, too, or if $$M$$ contains at least one $$p$$-adic unit. We say this matrix is reduced modulo $$p^N$$ if it is canonical form and if all coefficients of $$M$$ lie in the range $$[0, p^{N-v})$$.

Macros¶

Returns a pointer to the unit part of the matrix, which is a matrix over $$\mathbf{Z}$$.

The return value can be used as an argument to the functions in the fmpz_mat module.

Returns a pointer to unit part of the entry in position $$(i, j)$$. Note that this is not necessarily a unit.

The return value can be used as an argument to the functions in the fmpz module.

Allow access (as L-value or R-value) to val field of $$A$$. This function is implemented as a macro.

Allow access (as L-value or R-value) to prec field of $$A$$. This function is implemented as a macro.

Returns the valuation of the matrix.

Returns the $$p$$-adic precision of the matrix.

Returns the valuation of the matrix.

This is implemented as a macro and can be used as an lvalue as well as an rvalue.

Returns the number of rows of the matrix $$A$$.

Returns the number of columns of the matrix $$A$$.

Memory management¶

Initialises the matrix $$A$$ as a zero matrix with the specified numbers of rows and columns and precision PADIC_DEFAULT_PREC.

Initialises the matrix $$A$$ as a zero matrix with the specified numbers of rows and columns and the given precision.

Clears the matrix $$A$$.

Ensures that the matrix $$A$$ is in canonical form.

Ensures that the matrix $$A$$ is reduced modulo $$p^N$$, assuming that it is in canonical form already.

Ensures that the matrix $$A$$ is reduced modulo $$p^N$$, without assuming that it is necessarily in canonical form.

Returns whether the matrix $$A$$ is empty, that is, whether it has zero rows or zero columns.

Returns whether the matrix $$A$$ is square.

Returns whether the matrix $$A$$ is in canonical form.

Basic assignment¶

Sets $$B$$ to a copy of $$A$$, respecting the precision of $$B$$.

Swaps the two matrices $$A$$ and $$B$$. This is done efficiently by swapping pointers.

Swaps two matrices by swapping the individual entries rather than swapping the contents of the structs.

Sets the matrix $$A$$ to zero.

Sets the matrix $$A$$ to the identity matrix. If the precision is negative then the matrix will be the zero matrix.

Conversions¶

Sets the $$p$$-adic matrix $$B$$ to the rational matrix $$A$$, reduced according to the given context.

Sets the rational matrix $$B$$ to the $$p$$-adic matrices $$A$$; no reduction takes place.

Entries¶

Because of the choice of the data structure, representing the matrix as $$p^v M$$, setting an entry of the matrix might lead to changes in all entries in the matrix $$M$$. Also, a specific entry is not readily available as a $$p$$-adic number. Thus, there are separate functions available for getting and setting entries.

Sets rop to the entry in position $$(i, j)$$ in the matrix op.

Sets the entry in position $$(i, j)$$ in the matrix to rop.

Comparison¶

Returns whether the two matrices $$A$$ and $$B$$ are equal.

Returns whether the matrix $$A$$ is zero.

Input and output¶

Prints a simple representation of the matrix $$A$$ to the output stream file. The format is the number of rows, a space, the number of columns, two spaces, followed by a list of all the entries, one row after the other.

In the current implementation, always returns $$1$$.

Prints a pretty representation of the matrix $$A$$ to the output stream file.

In the current implementation, always returns $$1$$.

Random matrix generation¶

Sets $$A$$ to a random matrix.

The valuation will be in the range $$[- \lceil N/10\rceil, N)$$, $$[N - \lceil -N/10\rceil, N)$$, or $$[-10, 0)$$ as $$N$$ is positive, negative or zero.

Transpose¶

Sets $$B$$ to $$A^t$$.

Sets $$C$$ to the exact sum $$A + B$$, ensuring that the result is in canonical form.

Sets $$C$$ to the sum $$A + B$$ modulo $$p^N$$.

Sets $$C$$ to the exact difference $$A - B$$, ensuring that the result is in canonical form.

Sets $$C$$ to $$A - B$$, ensuring that the result is reduced.

Sets $$B$$ to $$-A$$ in canonical form.

Sets $$B$$ to $$-A$$, ensuring the result is reduced.

Scalar operations¶

Sets $$B$$ to $$c A$$, ensuring that the result is in canonical form.

Sets $$B$$ to $$c A$$, ensuring that the result is reduced.

Sets $$B$$ to $$c A$$, ensuring that the result is in canonical form.

Sets $$B$$ to $$c A$$, ensuring that the result is reduced.

Sets $$B$$ to $$c^{-1} A$$, assuming that $$c \neq 0$$. Ensures that the result $$B$$ is reduced.
Sets $$C$$ to the product $$A B$$ of the two matrices $$A$$ and $$B$$, ensuring that $$C$$ is in canonical form.
Sets $$C$$ to the product $$A B$$ of the two matrices $$A$$ and $$B$$, ensuring that $$C$$ is reduced.