Libpolycomp
1.0
A compression/decompression library that implements the polynomial compression and other simple compression schemes
|
Functions | |
pcomp_chebyshev_t * | pcomp_init_chebyshev (size_t num_of_samples, pcomp_transform_direction_t dir) |
Allocate a new instance of the pcomp_chebyshev_t structure on the heap. More... | |
void | pcomp_free_chebyshev (pcomp_chebyshev_t *plan) |
Free the memory allocated by a previous call to pcomp_init_chebyshev. More... | |
size_t | pcomp_chebyshev_num_of_samples (const pcomp_chebyshev_t *plan) |
Return the number of samples in a Chebyshev transform. More... | |
pcomp_transform_direction_t | pcomp_chebyshev_direction (const pcomp_chebyshev_t *plan) |
Return the direction of a Chebyshev transform. More... | |
int | pcomp_run_chebyshev (pcomp_chebyshev_t *plan, pcomp_transform_direction_t dir, double *output, const double *input) |
Compute a forward/backward Chebyshev discrete transform. More... | |
const double * | pcomp_chebyshev_input (const pcomp_chebyshev_t *plan) |
Return the input data used in the last call to pcomp_run_chebyshev. More... | |
const double * | pcomp_chebyshev_output (const pcomp_chebyshev_t *plan) |
Return the output (Chebyshev transform) of the last call to pcomp_run_chebyshev. More... | |
The following set of routines compute the Chebyshev transform of a set of floating-point numbers. They form a tiny wrapper around analogous functions of the FFTW library, with the main purpose of using the correct normalization constants in the forward and inverse transforms.
The definition of the forward transform ( ) is the following:
where
The backward transform is defined by the following equation:
To compute the Chebyshev transform of an array of numbers, the user must allocate a pcomp_chebyshev_t structure using the function pcomp_init_chebyshev. Such structure contains the details about the transform to compute, i.e., the number of elements and the direction (either forward or backward). The computation of the transform is done by the function pcomp_run_chebyshev.
Since the forward and backward transforms differ only by the multiplicative constant, the function pcomp_run_chebyshev is not too picky and allows the caller to specify the direction of the transform. It is therefore possible to use the same pcomp_chebyshev_t object to compute both the forward and the backward transform (with two separate calls to pcomp_run_chebyshev).
pcomp_transform_direction_t pcomp_chebyshev_direction | ( | const pcomp_chebyshev_t * | plan | ) |
Return the direction of a Chebyshev transform.
[in] | plan | Pointer to the Chebyshev plan. |
const double* pcomp_chebyshev_input | ( | const pcomp_chebyshev_t * | plan | ) |
Return the input data used in the last call to pcomp_run_chebyshev.
If pcomp_run_chebyshev was never called, the array returned by this function contains garbage.
[in] | plan | Pointer to a Chebyshev plan created by pcomp_init_chebyshev |
size_t pcomp_chebyshev_num_of_samples | ( | const pcomp_chebyshev_t * | plan | ) |
const double* pcomp_chebyshev_output | ( | const pcomp_chebyshev_t * | plan | ) |
Return the output (Chebyshev transform) of the last call to pcomp_run_chebyshev.
If pcomp_run_chebyshev was never called, the array returned by this function contains garbage.
[in] | plan | Pointer to a Chebyshev plan created by pcomp_init_chebyshev |
void pcomp_free_chebyshev | ( | pcomp_chebyshev_t * | plan | ) |
Free the memory allocated by a previous call to pcomp_init_chebyshev.
[in] | plan | Pointer to the structure to be freed. |
pcomp_chebyshev_t* pcomp_init_chebyshev | ( | size_t | num_of_samples, |
pcomp_transform_direction_t | dir | ||
) |
Allocate a new instance of the pcomp_chebyshev_t structure on the heap.
Despite the fact that this function takes the parameter dir, the function which actually computes the Chebyshev transform (pcomp_run_chebyshev) allow to specify the desired direction. The purpose of having dir encoded in pcomp_chebyshev_t is that sometimes it is useful to keep it memorized in the structure itself.
[in] | num_of_samples | Number of floating-point numbers that will be transformed |
[in] | dir | Direction of the transform (either forward or backward). This is used to determine the normalization constant of the transform:
|
int pcomp_run_chebyshev | ( | pcomp_chebyshev_t * | plan, |
pcomp_transform_direction_t | dir, | ||
double * | output, | ||
const double * | input | ||
) |
Compute a forward/backward Chebyshev discrete transform.
[in] | plan | Pointer to a Chebyshev plan created by pcomp_init_chebyshev |
[in] | dir | Direction of the transform. This parameter overrides the internal direction of plan (returned by pcomp_chebyshev_direction). |
[out] | output | Pointer to an array of double values that will contain the Chebyshev transform of input. It must have room for a number of elements at least equal to the return value of pcomp_num_of_samples. |
[in] | input | Array of double values to be transformed. The function will use the first N elements, where N is the return value of pcomp_num_of_samples. |