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

Data.Number.Flint.Support.Mpf.Mat

Synopsis

Matrices of MPF floating-point numbers

data MpfMat Source #

Constructors

MpfMat !(ForeignPtr CMpfMat) 

data CMpfMat Source #

Constructors

CMpfMat (Ptr CMpf) CLong CLong (Ptr (Ptr CMpf)) 

Instances

Instances details
Storable CMpfMat Source # 
Instance details

Defined in Data.Number.Flint.Support.Mpf.Mat.FFI

withMpfMat :: MpfMat -> (Ptr CMpfMat -> IO a) -> IO (MpfMat, a) Source #

Memory management

mpf_mat_init :: Ptr CMpfMat -> CLong -> CLong -> CFBitCnt -> IO () Source #

mpf_mat_init mat rows cols prec

Initialises a matrix with the given number of rows and columns and the given precision for use. The precision is at least the precision of the entries.

mpf_mat_clear :: Ptr CMpfMat -> IO () Source #

mpf_mat_clear mat

Clears the given matrix.

Basic assignment and manipulation

mpf_mat_set :: Ptr CMpfMat -> Ptr CMpfMat -> IO () Source #

mpf_mat_set mat1 mat2

Sets mat1 to a copy of mat2. The dimensions of mat1 and mat2 must be the same.

mpf_mat_swap :: Ptr CMpfMat -> Ptr CMpfMat -> IO () Source #

mpf_mat_swap mat1 mat2

Swaps two matrices. The dimensions of mat1 and mat2 are allowed to be different.

mpf_mat_swap_entrywise :: Ptr CMpfMat -> Ptr CMpfMat -> IO () Source #

mpf_mat_swap_entrywise mat1 mat2

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

mpf_mat_entry :: Ptr CMpfMat -> CLong -> CLong -> IO (Ptr CMpf) Source #

mpf_mat_entry mat i j

Returns a reference to the entry of mat at row \(i\) and column \(j\). Both \(i\) and \(j\) must not exceed the dimensions of the matrix. The return value can be used to either retrieve or set the given entry.

mpf_mat_zero :: Ptr CMpfMat -> IO () Source #

mpf_mat_zero mat

Sets all entries of mat to 0.

mpf_mat_one :: Ptr CMpfMat -> IO () Source #

mpf_mat_one mat

Sets mat to the unit matrix, having ones on the main diagonal and zeroes elsewhere. If mat is nonsquare, it is set to the truncation of a unit matrix.

Random matrix generation

mpf_mat_randtest :: Ptr CMpfMat -> Ptr CFRandState -> CFBitCnt -> IO () Source #

mpf_mat_randtest mat state bits

Sets the entries of mat to random numbers in the interval \([0, 1)\) with bits significant bits in the mantissa or less if their precision is smaller.

Input and output

mpf_mat_print :: Ptr CMpfMat -> IO () Source #

mpf_mat_print mat

Prints the given matrix to the stream stdout.

Comparison

mpf_mat_equal :: Ptr CMpfMat -> Ptr CMpfMat -> IO CInt Source #

mpf_mat_equal mat1 mat2

Returns a non-zero value if mat1 and mat2 have the same dimensions and entries, and zero otherwise.

mpf_mat_approx_equal :: Ptr CMpfMat -> Ptr CMpfMat -> CFBitCnt -> IO CInt Source #

mpf_mat_approx_equal mat1 mat2 bits

Returns a non-zero value if mat1 and mat2 have the same dimensions and the first bits bits of their entries are equal, and zero otherwise.

mpf_mat_is_zero :: Ptr CMpfMat -> IO CInt Source #

mpf_mat_is_zero mat

Returns a non-zero value if all entries mat are zero, and otherwise returns zero.

mpf_mat_is_empty :: Ptr CMpfMat -> IO CInt Source #

mpf_mat_is_empty mat

Returns a non-zero value if the number of rows or the number of columns in mat is zero, and otherwise returns zero.

mpf_mat_is_square :: Ptr CMpfMat -> IO CInt Source #

mpf_mat_is_square mat

Returns a non-zero value if the number of rows is equal to the number of columns in mat, and otherwise returns zero.

Matrix multiplication

mpf_mat_mul :: Ptr CMpfMat -> Ptr CMpfMat -> Ptr CMpfMat -> IO () Source #

mpf_mat_mul C A B

Sets C to the matrix product \(C = A B\). The matrices must have compatible dimensions for matrix multiplication (an exception is raised otherwise). Aliasing is allowed.

Gram-Schmidt Orthogonalisation and QR Decomposition

mpf_mat_gso :: Ptr CMpfMat -> Ptr CMpfMat -> IO () Source #

mpf_mat_gso B A

Takes a subset of \(R^m\) \(S = {a_1, a_2, \ldots ,a_n}\) (as the columns of a \(m x n\) matrix A) and generates an orthonormal set \(S' = {b_1, b_2, \ldots ,b_n}\) (as the columns of the \(m x n\) matrix B) that spans the same subspace of \(R^m\) as \(S\).

This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of https://people.inf.ethz.ch/gander/papers/qrneu.pdf

mpf_mat_qr :: Ptr CMpfMat -> Ptr CMpfMat -> Ptr CMpfMat -> IO () Source #

mpf_mat_qr Q R A

Computes the \(QR\) decomposition of a matrix A using the Gram-Schmidt process. (Sets Q and R such that \(A = QR\) where R is an upper triangular matrix and Q is an orthogonal matrix.)

This uses an algorithm of Schwarz-Rutishauser. See pp. 9 of https://people.inf.ethz.ch/gander/papers/qrneu.pdf