Flint2-0.1.0.5: Haskell bindings for the flint library for number theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Number.Flint.Padic.Mat

Synopsis

Matrices over p-adic numbers

Constructors

Macros

padic_mat :: Ptr CPadicMat -> IO (Ptr CFmpzMat) Source #

padic_mat A

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.

padic_mat_entry :: Ptr CPadicMat -> CLong -> CLong -> IO (Ptr CFmpz) Source #

padic_mat_entry A i j

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.

padic_mat_get_val :: Ptr CPadicMat -> IO CLong Source #

padic_mat_get_val A

Returns the valuation of the matrix.

padic_mat_get_prec :: Ptr CPadicMat -> IO CLong Source #

padic_mat_get_prec A

Returns the \(p\)-adic precision of the matrix.

padic_mat_nrows :: Ptr CPadicMat -> IO CLong Source #

padic_mat_nrows A

Returns the number of rows of the matrix \(A\).

padic_mat_ncols :: Ptr CPadicMat -> IO CLong Source #

padic_mat_ncols A

Returns the number of columns of the matrix \(A\).

Memory management

padic_mat_init :: Ptr CPadicMat -> CLong -> CLong -> CLong -> IO () Source #

padic_mat_init A r c

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

padic_mat_init2 :: Ptr CPadicMat -> CLong -> CLong -> CLong -> IO () Source #

padic_mat_init2 A r c prec

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

padic_mat_clear :: Ptr CPadicMat -> IO () Source #

padic_mat_clear A

Clears the matrix \(A\).

_padic_mat_canonicalise :: Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

_padic_mat_canonicalise A ctx

Ensures that the matrix \(A\) is in canonical form.

_padic_mat_reduce :: Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

_padic_mat_reduce A ctx

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

padic_mat_reduce :: Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_reduce A ctx

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

padic_mat_is_empty :: Ptr CPadicMat -> IO CInt Source #

padic_mat_is_empty A

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

padic_mat_is_square :: Ptr CPadicMat -> IO CInt Source #

padic_mat_is_square A

Returns whether the matrix \(A\) is square.

padic_mat_is_canonical :: Ptr CPadicMat -> Ptr CFmpz -> IO CInt Source #

padic_mat_is_canonical A p

Returns whether the matrix \(A\) is in canonical form.

Basic assignment

padic_mat_set :: Ptr CPadicMat -> Ptr CPadicMat -> IO () Source #

padic_mat_set B A

Sets \(B\) to a copy of \(A\), respecting the precision of \(B\).

padic_mat_swap :: Ptr CPadicMat -> Ptr CPadicMat -> IO () Source #

padic_mat_swap A B

Swaps the two matrices \(A\) and \(B\). This is done efficiently by swapping pointers.

padic_mat_swap_entrywise :: Ptr CPadicMat -> Ptr CPadicMat -> IO () Source #

padic_mat_swap_entrywise mat1 mat2

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

padic_mat_zero :: Ptr CPadicMat -> IO () Source #

padic_mat_zero A

Sets the matrix \(A\) to zero.

padic_mat_one :: Ptr CPadicMat -> IO () Source #

padic_mat_one A

Sets the matrix \(A\) to the identity matrix. If the precision is negative then the matrix will be the zero matrix.

Conversions

padic_mat_set_fmpq_mat :: Ptr CPadicMat -> Ptr CFmpqMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_set_fmpq_mat B A ctx

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

padic_mat_get_fmpq_mat :: Ptr CFmpqMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_get_fmpq_mat B A ctx

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

Entries

padic_mat_get_entry_padic :: Ptr CPadic -> Ptr CPadicMat -> CLong -> CLong -> Ptr CPadicCtx -> IO () Source #

padic_mat_get_entry_padic rop op i j ctx

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

padic_mat_set_entry_padic :: Ptr CPadicMat -> CLong -> CLong -> Ptr CPadic -> Ptr CPadicCtx -> IO () Source #

padic_mat_set_entry_padic rop i j op ctx

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

Comparison

padic_mat_equal :: Ptr CPadicMat -> Ptr CPadicMat -> IO CInt Source #

padic_mat_equal A B

Returns whether the two matrices \(A\) and \(B\) are equal.

padic_mat_is_zero :: Ptr CPadicMat -> IO CInt Source #

padic_mat_is_zero A

Returns whether the matrix \(A\) is zero.

Input and output

padic_mat_fprint :: Ptr CFile -> Ptr CPadicMat -> Ptr CPadicCtx -> IO CInt Source #

padic_mat_fprint file A ctx

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\).

padic_mat_fprint_pretty :: Ptr CFile -> Ptr CPadicMat -> Ptr CPadicCtx -> IO CInt Source #

padic_mat_fprint_pretty file A ctx

Prints a pretty representation of the matrix \(A\) to the output stream file.

In the current implementation, always returns \(1\).

padic_mat_print :: Ptr CPadicMat -> Ptr CPadicCtx -> IO CInt Source #

padic_mat_print file A ctx

Prints a simple representation of the matrix \(A\) to stdout. 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\).

padic_mat_print_pretty :: Ptr CPadicMat -> Ptr CPadicCtx -> IO CInt Source #

padic_mat_print_pretty file A ctx

Prints a pretty representation of the matrix \(A\) to stdout.

In the current implementation, always returns \(1\).

Random matrix generation

padic_mat_randtest :: Ptr CPadicMat -> Ptr CFRandState -> Ptr CPadicCtx -> IO () Source #

padic_mat_randtest A state ctx

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

padic_mat_transpose :: Ptr CPadicMat -> Ptr CPadicMat -> IO () Source #

padic_mat_transpose B A

Sets \(B\) to \(A^t\).

Addition and subtraction

_padic_mat_add :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

_padic_mat_add C A B ctx

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

padic_mat_add :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_add C A B ctx

Sets \(C\) to the sum \(A + B\) modulo \(p^N\).

_padic_mat_sub :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

_padic_mat_sub C A B ctx

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

padic_mat_sub :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_sub C A B ctx

Sets \(C\) to \(A - B\), ensuring that the result is reduced.

_padic_mat_neg :: Ptr CPadicMat -> Ptr CPadicMat -> IO () Source #

_padic_mat_neg B A

Sets \(B\) to \(-A\) in canonical form.

padic_mat_neg :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_neg B A ctx

Sets \(B\) to \(-A\), ensuring the result is reduced.

Scalar operations

_padic_mat_scalar_mul_padic :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadic -> Ptr CPadicCtx -> IO () Source #

_padic_mat_scalar_mul_padic B A c ctx

Sets \(B\) to \(c A\), ensuring that the result is in canonical form.

padic_mat_scalar_mul_padic :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadic -> Ptr CPadicCtx -> IO () Source #

padic_mat_scalar_mul_padic B A c ctx

Sets \(B\) to \(c A\), ensuring that the result is reduced.

_padic_mat_scalar_mul_fmpz :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CFmpz -> Ptr CPadicCtx -> IO () Source #

_padic_mat_scalar_mul_fmpz B A c ctx

Sets \(B\) to \(c A\), ensuring that the result is in canonical form.

padic_mat_scalar_mul_fmpz :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CFmpz -> Ptr CPadicCtx -> IO () Source #

padic_mat_scalar_mul_fmpz B A c ctx

Sets \(B\) to \(c A\), ensuring that the result is reduced.

padic_mat_scalar_div_fmpz :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CFmpz -> Ptr CPadicCtx -> IO () Source #

padic_mat_scalar_div_fmpz B A c ctx

Sets \(B\) to \(c^{-1} A\), assuming that \(c \neq 0\). Ensures that the result \(B\) is reduced.

Multiplication

padic_mat_mul :: Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicMat -> Ptr CPadicCtx -> IO () Source #

padic_mat_mul C A B ctx

Sets \(C\) to the product \(A B\) of the two matrices \(A\) and \(B\), ensuring that \(C\) is reduced.