![]() |
Bachelor's degree final project
v1.0
Faculty of Mathematics, University of Barcelona
|
Implements differents functions for the pic struct. More...
#include "pic.h"
Defines | |
#define | _DEFAULT_MAX_ITERATIONS 80 |
Maximum number of newton iterations. | |
#define | _MAX_LENGTH_STRING_INPUT 128 |
Functions | |
unsigned int | pic_get_max_iterations () |
Get maximum number of iterations. | |
unsigned int | pic_set_max_iterations (unsigned int max_iter) |
Set maximum number of iterations. | |
size_t | pic_get_mesh_size (struct pic *const p) |
size_t | pic_get_dimension_size (struct pic *const p) |
int | pic_set_function_pointer (struct pic *const p, void(*f)(size_t, size_t, double *const, double *const, double **const, double, double)) |
int | pic_set_function_solve (struct pic *const p, _SOLVE_PROTOTYPE) |
struct pic * | pic_create (size_t n, size_t N, double w, double *const X, _FUNCTION_PROTOTYPE, _SOLVE_PROTOTYPE) |
Function that initializes a struct pic. | |
void * | _pic_realloc (struct pic *const p, size_t n, size_t N, short unsigned int autonomous) |
int | pic_set_mesh_size (struct pic *const p, size_t N) |
Set the mesh size. | |
int | pic_set_dimension_size (struct pic *const p, size_t n) |
Set the dimension. | |
void * | _init_pic (struct pic *const p) |
void | pic_destroy (struct pic *p) |
Function that frees the memory space pointed to by the differents pointers of struct pic. | |
int | _get_fourier_coef_index (char **const c) |
double * | pic_load_fourier_coef (size_t n, size_t N, FILE *const f) |
Function that load the Fourier coefficients from a given file. | |
double * | pic_loadas_fourier_coef (size_t n, size_t N, char *const name) |
Function that load the Fourier coefficients from a given file by name. | |
int | pic_save_fourier_coef (struct pic *const p, FILE *const f) |
Function that saves the Fourier coefficients in a given file. | |
int | pic_saveas_fourier_coef (struct pic *const p, char *const name) |
Function that saves the Fourier coefficients in a given file by name. | |
int | pic_save_curve (struct pic *const p, FILE *const f) |
Function that saves the values of the solution curve in a given file. | |
int | pic_saveas_curve (struct pic *const p, char *const name) |
Function that saves the values of the solution curve in a given file by name. | |
int | pic_saveas_differential (struct pic *const p, char *const name) |
Function that saves the values of the differential of Newton method in a given file by name. | |
int | pic_save_differential (struct pic *const p, FILE *const f) |
Function that saves the values of the differential of Newton method in a given file. | |
int | pic_saveas_differential_indexs (struct pic *const p, char *const name) |
Function that saves the values of the differential of Newton method in a given file by name from its indexs. | |
int | pic_save_differential_indexs (struct pic *const p, FILE *const f) |
Function that saves the values of the differential of Newton method in a given file from its indexs. | |
void * | pic_error (struct pic *const p, size_t N, size_t *const idx, double *const max) |
Function that compute the maximum error for a solution previously computed. | |
void | pic_x (size_t n, size_t N, double *const X, double *const x) |
Function that compute the Discrete Fourier Transform. | |
size_t | _pic_estimate_mesh_size (struct pic *const p, double tol, double **A, double *h) |
size_t | pic_estimate_mesh_size (struct pic *const p, double tol) |
void * | pic_execute (struct pic *const p, double tol) |
Function that compute the Discrete Fourier Transform. | |
double ** | pic_differential (struct pic *const p, size_t *const m, size_t *const n) |
Return a differential matrix for the current pic struct's values. | |
size_t | pic_get_n (struct pic *const p) |
size_t | pic_get_N (struct pic *const p) |
double * | pic_get_x (struct pic *const p) |
double * | pic_get_X (struct pic *const p) |
double ** | pic_get_DF (struct pic *const p) |
double | pic_get_w (struct pic *const p) |
Implements differents functions for the pic struct.
#define _DEFAULT_MAX_ITERATIONS 80 |
Maximum number of newton iterations.
#define _MAX_LENGTH_STRING_INPUT 128 |
int _get_fourier_coef_index | ( | char **const | c | ) |
size_t _pic_estimate_mesh_size | ( | struct pic *const | p, |
double | tol, | ||
double ** | A, | ||
double * | h | ||
) |
References free_matrix(), free_vector(), malloc_matrix(), malloc_vector(), pic::n, pic::N, print_vector(), qrsis(), and pic::X.
void * _pic_realloc | ( | struct pic *const | p, |
size_t | n, | ||
size_t | N, | ||
short unsigned int | autonomous | ||
) |
[in] | p | Pointer to a pic struct |
[in] | n | Space's dimension of the function ![]() |
[in] | N | Mesh size of the ![]() |
[in] | autonomous |
NULL | If memory space has not been reallocated or the pointer to a pic struct is NULL |
1 | Otherwise |
References pic::autonomous, pic::DF, pic::n, pic::N, pic::x, and pic::X.
struct pic* pic_create | ( | size_t | n, |
size_t | N, | ||
double | w, | ||
double *const | X, | ||
_FUNCTION_PROTOTYPE | , | ||
_SOLVE_PROTOTYPE | |||
) | [read] |
Function that initializes a struct pic.
[in] | n | Space's dimension of the function ![]() |
[in] | N | Mesh size of the ![]() |
[in] | w | Real number densely filling the circumference |
[in] | X | Seed of the newton method. The size has to be n(2N+1) |
[in] | f | Function pointer |
[in] | solve | Function pointer for solves a linear system equations |
NULL | If memory space has not been allocated |
p | Pointer to struct pic |
References pic::autonomous, pic::DF, pic::f, pic::n, pic::N, PIC_NAUTONOMOUS, pic::solve, solve(), SOLVE_WITH_LU, pic::w, pic::x, and pic::X.
void pic_destroy | ( | struct pic * | p | ) |
double** pic_differential | ( | struct pic *const | p, |
size_t *const | m, | ||
size_t *const | n | ||
) |
Return a differential matrix for the current pic struct's values.
[in] | p | Pointer to a pic struct |
[out] | m | Number of differential matrix's rows |
[out] | n | Number of differential matrix's columns |
References pic::autonomous, pic::DF, pic::f, pic::n, pic::N, newton_differential(), pic::w, pic::x, and pic::X.
Function that compute the maximum error for a solution previously computed.
[in] | p | Pointer to struct pic |
[in] | N | Mesh size that we want to check the error of the solution (e.g. 2*(p->N)) |
[out] | idx | Index where the maximum is reached |
[out] | max | Maximum value of error |
NULL | if some problem occurred |
1 | otherwise |
References dft_r2r_1d(), pic::f, malloc_vector(), pic::n, pic::N, pic::w, and pic::X.
size_t pic_estimate_mesh_size | ( | struct pic *const | p, |
double | tol | ||
) |
References _pic_estimate_mesh_size().
void* pic_execute | ( | struct pic *const | p, |
double | tol | ||
) |
Function that compute the Discrete Fourier Transform.
[in] | p | Pointer to the pic struct |
[in] | tol | Tolerance for the result |
References _init_pic(), pic::autonomous, pic::DF, pic::f, pic::n, pic::N, newton_execute(), pic_error(), pic_estimate_mesh_size(), pic_set_mesh_size(), pic_x(), pic::solve, pic::w, pic::x, and pic::X.
double** pic_get_DF | ( | struct pic *const | p | ) |
[in] | p | Pointer to a pic struct |
References pic::DF.
size_t pic_get_dimension_size | ( | struct pic *const | p | ) |
[in] | p | Pointer to a pic struct |
References pic::n.
unsigned int pic_get_max_iterations | ( | ) |
Get maximum number of iterations.
size_t pic_get_mesh_size | ( | struct pic *const | p | ) |
[in] | p | Pointer to a pic struct |
References pic::N.
[in] | p | Pointer to a pic struct |
References pic::n.
[in] | p | Pointer to a pic struct |
References pic::N.
[in] | p | Pointer to a pic struct |
References pic::w.
[in] | p | Pointer to a pic struct |
References pic::x.
[in] | p | Pointer to a pic struct |
References pic::X.
double* pic_load_fourier_coef | ( | size_t | n, |
size_t | N, | ||
FILE *const | f | ||
) |
Function that load the Fourier coefficients from a given file.
[in] | n | Dimension of each coefficient |
[in] | N | Number of coefficient |
[in] | f | Pointer to a file |
References _MAX_LENGTH_STRING_INPUT, and pic::n.
double* pic_loadas_fourier_coef | ( | size_t | n, |
size_t | N, | ||
char *const | name | ||
) |
Function that load the Fourier coefficients from a given file by name.
[in] | n | Dimension of each coefficient |
[in] | N | Number of coefficient |
[in] | f | Pointer to a file |
References pic::f, and pic_load_fourier_coef().
int pic_save_curve | ( | struct pic *const | p, |
FILE *const | f | ||
) |
Function that saves the values of the solution curve in a given file.
[in] | p | Pointer to struct pic |
[in] | f | Output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::n, pic::N, and pic::x.
int pic_save_differential | ( | struct pic *const | p, |
FILE *const | f | ||
) |
Function that saves the values of the differential of Newton method in a given file.
[in] | p | Pointer to struct pic |
[in] | f | Output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::DF, pic::n, pic::N, and save_matrix().
int pic_save_differential_indexs | ( | struct pic *const | p, |
FILE *const | f | ||
) |
Function that saves the values of the differential of Newton method in a given file from its indexs.
[in] | p | Pointer to struct pic |
[in] | f | Output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::DF, pic::n, pic::N, and save_matrix_indexs().
int pic_save_fourier_coef | ( | struct pic *const | p, |
FILE *const | f | ||
) |
Function that saves the Fourier coefficients in a given file.
[in] | p | Pointer to struct pic |
[in] | f | Output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::n, pic::N, and pic::X.
int pic_saveas_curve | ( | struct pic *const | p, |
char *const | name | ||
) |
Function that saves the values of the solution curve in a given file by name.
[in] | p | Pointer to struct pic |
[in] | name | Name of the output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::f, and pic_save_curve().
int pic_saveas_differential | ( | struct pic *const | p, |
char *const | name | ||
) |
Function that saves the values of the differential of Newton method in a given file by name.
[in] | p | Pointer to struct pic |
[in] | name | Name of the output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::DF, pic::n, pic::N, and saveas_matrix().
int pic_saveas_differential_indexs | ( | struct pic *const | p, |
char *const | name | ||
) |
Function that saves the values of the differential of Newton method in a given file by name from its indexs.
[in] | p | Pointer to struct pic |
[in] | name | Name of the output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::DF, pic::n, pic::N, and saveas_matrix_indexs().
int pic_saveas_fourier_coef | ( | struct pic *const | p, |
char *const | name | ||
) |
Function that saves the Fourier coefficients in a given file by name.
[in] | p | Pointer to struct pic |
[in] | f | Output file |
0 | If some error has occurred in some moment of the process |
1 | Otherwise |
References pic::f, and pic_save_fourier_coef().
int pic_set_dimension_size | ( | struct pic *const | p, |
size_t | n | ||
) |
Set the dimension.
[in] | p | Pointer to a pic struct |
[in] | N | New dimension |
References _pic_realloc(), pic::autonomous, pic::n, and pic::N.
int pic_set_function_pointer | ( | struct pic *const | p, |
void(*)(size_t, size_t, double *const, double *const, double **const, double, double) | f | ||
) |
References pic::f.
int pic_set_function_solve | ( | struct pic *const | p, |
_SOLVE_PROTOTYPE | |||
) |
[in] | p | Pointer to a pic struct |
[in] | f | Pointer to a function pointer |
0 | if some argument is NULL |
1 | Otherwise |
References pic::solve, and solve().
unsigned int pic_set_max_iterations | ( | unsigned int | max_iter | ) |
Set maximum number of iterations.
[in] | max_iter | New value |
int pic_set_mesh_size | ( | struct pic *const | p, |
size_t | N | ||
) |
Set the mesh size.
[in] | p | Pointer to a pic struct |
[in] | N | New mesh size |
References _pic_realloc(), pic::autonomous, pic::n, and pic::N.
void pic_x | ( | size_t | n, |
size_t | N, | ||
double *const | X, | ||
double *const | x | ||
) |
Function that compute the Discrete Fourier Transform.
[in] | n | Space's dimension |
[in] | N | Mesh size |
[in] | X | Fourier coefficients, that is, n(2N+1) components |
[in] | x | Discrete Fourier Transform for each mesh's element, that is, n(2N+1) components |
References dft_r2r_1d().