Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A CaVec
represents a vector of real or complex numbers, implemented
as an array of coefficients of type CCa
.
Most functions are provided in two versions: an underscore method
which operates directly on pre-allocated arrays of coefficients
(taking Ptr CCa
arguments), and a non-underscore method which
takes CaVec
input and performs automatic memory management.
Unlike CaPoly
, a CaVec
is not normalised by removing zero
coefficients; it retains the exact length assigned by the user.
Synopsis
- data CaVec = CaVec !(ForeignPtr CCaVec)
- type CCaVec = CFlint CaVec
- newCaVec :: CLong -> CaCtx -> IO CaVec
- withCaVec :: CaVec -> (Ptr CCaVec -> IO a) -> IO (CaVec, a)
- withNewCaVec :: CLong -> CaCtx -> (Ptr CCaVec -> IO a) -> IO (CaCtx, (CaVec, a))
- _ca_vec_init :: CLong -> Ptr CCaCtx -> IO (Ptr CCa)
- ca_vec_init :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO ()
- _ca_vec_clear :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_clear :: Ptr CCaVec -> Ptr CCaCtx -> IO ()
- _ca_vec_swap :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_swap :: Ptr CCaVec -> Ptr CCaVec -> Ptr CCaCtx -> IO ()
- ca_vec_entry_ptr :: Ptr CCaVec -> CLong -> Ptr CCa
- ca_vec_length :: Ptr CCaVec -> Ptr CCaCtx -> IO CLong
- _ca_vec_fit_length :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_set_length :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO ()
- _ca_vec_set :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_set :: Ptr CCaVec -> Ptr CCaVec -> Ptr CCaCtx -> IO ()
- _ca_vec_zero :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_zero :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_print :: Ptr CCaVec -> Ptr CCaCtx -> IO ()
- ca_vec_printn :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_append :: Ptr CCaVec -> Ptr CCa -> Ptr CCaCtx -> IO ()
- _ca_vec_neg :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- ca_vec_neg :: Ptr CCaVec -> Ptr CCaVec -> Ptr CCaCtx -> IO ()
- _ca_vec_add :: Ptr CCa -> Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- _ca_vec_sub :: Ptr CCa -> Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- _ca_vec_scalar_mul_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO ()
- _ca_vec_scalar_div_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO ()
- _ca_vec_scalar_addmul_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO ()
- _ca_vec_scalar_submul_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO ()
- _ca_vec_check_is_zero :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO (Ptr CTruth)
- _ca_vec_is_fmpq_vec :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO CInt
- _ca_vec_fmpq_vec_is_fmpz_vec :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO CInt
- _ca_vec_fmpq_vec_get_fmpz_vec_den :: Ptr CFmpz -> Ptr CFmpz -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
- _ca_vec_set_fmpz_vec_div_fmpz :: Ptr CCa -> Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CCaCtx -> IO ()
Vectors of real and complex numbers
Types, macros and constants
Instances
Memory management
_ca_vec_init :: CLong -> Ptr CCaCtx -> IO (Ptr CCa) Source #
_ca_vec_init len ctx
Returns a pointer to an array of len coefficients initialized to zero.
ca_vec_init :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO () Source #
ca_vec_init vec len ctx
Initializes vec to a length len vector. All entries are set to zero.
_ca_vec_clear :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_clear vec len ctx
Clears all len entries in vec and frees the pointer vec itself.
ca_vec_clear :: Ptr CCaVec -> Ptr CCaCtx -> IO () Source #
ca_vec_clear vec ctx
Clears the vector vec.
_ca_vec_swap :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_swap vec1 vec2 len ctx
Swaps the entries in vec1 and vec2 efficiently.
ca_vec_swap :: Ptr CCaVec -> Ptr CCaVec -> Ptr CCaCtx -> IO () Source #
ca_vec_swap vec1 vec2 ctx
Swaps the vectors vec1 and vec2 efficiently.
Entry
Length
ca_vec_length :: Ptr CCaVec -> Ptr CCaCtx -> IO CLong Source #
ca_vec_length vec ctx
Returns the length of vec.
_ca_vec_fit_length :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_fit_length vec len ctx
Allocates space in vec for len elements.
ca_vec_set_length :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO () Source #
ca_vec_set_length vec len ctx
Sets the length of vec to len. If vec is shorter on input, it will be zero-extended. If vec is longer on input, it will be truncated.
Assignment
_ca_vec_set :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_set res src len ctx
Sets res to a copy of src of length len.
ca_vec_set :: Ptr CCaVec -> Ptr CCaVec -> Ptr CCaCtx -> IO () Source #
ca_vec_set res src ctx
Sets res to a copy of src.
Special vectors
_ca_vec_zero :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_zero res len ctx
Sets the len entries in res to zeros.
ca_vec_zero :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO () Source #
ca_vec_zero res len ctx
Sets res to the length len zero vector.
Input and output
ca_vec_print :: Ptr CCaVec -> Ptr CCaCtx -> IO () Source #
ca_vec_print vec ctx
Prints vec to standard output. The coefficients are printed on separate lines.
ca_vec_printn :: Ptr CCaVec -> CLong -> Ptr CCaCtx -> IO () Source #
ca_vec_printn poly digits ctx
Prints a decimal representation of vec with precision specified by digits. The coefficients are comma-separated and the whole list is enclosed in square brackets.
List operations
ca_vec_append :: Ptr CCaVec -> Ptr CCa -> Ptr CCaCtx -> IO () Source #
ca_vec_append vec f ctx
Appends f to the end of vec.
Arithmetic
_ca_vec_neg :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_neg res src len ctx
ca_vec_neg :: Ptr CCaVec -> Ptr CCaVec -> Ptr CCaCtx -> IO () Source #
ca_vec_neg res src ctx
Sets res to the negation of src.
_ca_vec_add :: Ptr CCa -> Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_add res vec1 vec2 len ctx
_ca_vec_sub :: Ptr CCa -> Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_sub res vec1 vec2 len ctx
Sets res to the sum or difference of vec1 and vec2, all vectors having length len.
_ca_vec_scalar_mul_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #
_ca_vec_scalar_mul_ca res src len c ctx
Sets res to src multiplied by c, all vectors having length len.
_ca_vec_scalar_div_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #
_ca_vec_scalar_div_ca res src len c ctx
Sets res to src divided by c, all vectors having length len.
_ca_vec_scalar_addmul_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #
_ca_vec_scalar_addmul_ca res src len c ctx
Adds src multiplied by c to the vector res, all vectors having length len.
_ca_vec_scalar_submul_ca :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #
_ca_vec_scalar_submul_ca res src len c ctx
Subtracts src multiplied by c from the vector res, all vectors having length len.
Comparisons and properties
_ca_vec_check_is_zero :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO (Ptr CTruth) Source #
_ca_vec_check_is_zero vec len ctx
Returns whether vec is the zero vector.
Internal representation
_ca_vec_is_fmpq_vec :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO CInt Source #
_ca_vec_is_fmpq_vec vec len ctx
Checks if all elements of vec are structurally rational numbers.
_ca_vec_fmpq_vec_is_fmpz_vec :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO CInt Source #
_ca_vec_fmpq_vec_is_fmpz_vec vec len ctx
Assuming that all elements of vec are structurally rational numbers, checks if all elements are integers.
_ca_vec_fmpq_vec_get_fmpz_vec_den :: Ptr CFmpz -> Ptr CFmpz -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #
_ca_vec_fmpq_vec_get_fmpz_vec_den c den vec len ctx
Assuming that all elements of vec are structurally rational numbers, converts them to a vector of integers c on a common denominator den.