Bachelor's degree final project  v1.0
Faculty of Mathematics, University of Barcelona
Functions
src/utils.c File Reference

Set of different function for linear systems. More...

#include "utils.h"
+ Include dependency graph for utils.c:

Functions

double euclidian_norm (size_t n, double *const x)
 Derive the euclidian norm of a vector, that is, $ \displaystyle || x ||_2 = \biggl(\sum_{i = 0}^{n-1} x_i^2\biggr)^{\frac 12} $.
double inner_product (size_t n, double *const x)
 Derive the ordinary inner product of a vector, that is, $ \displaystyle \langle x, x \rangle = \sum_{i = 0}^{n-1} x_i^2 $.
void copy_vector (size_t n, double *const x, double *const y)
 Copy the vector x in y.
void copy_matrix (size_t m, size_t n, double **const A, double **const B)
 Copy the matrix A in B.
void print_matrix (size_t m, size_t n, double **const A, char *const name)
 Display in stdout a matrix m-by-n.
void print_vector (size_t idx, size_t n, double *const v, char *const name)
 Display in stdout a n-dimensional vector starting by an index.
double * malloc_vector (size_t n)
 Malloc a n-dimensional vector.
void free_vector (double *p)
 Free a vector.
double ** malloc_matrix (size_t m, size_t n)
 Malloc a m-by-n matrix.
void free_matrix (size_t m, double **p)
 Free a matrix with m rows.
void allocated_vector (void *p, size_t n)
void free_vector2 (void *p, size_t n)
void allocated_matrix (void **p, size_t m, size_t n)
void free_matrix2 (void **p, size_t m, size_t n)

Detailed Description

Set of different function for linear systems.

Author:
Joan
Date:
04/12/2013 (start)

Function Documentation

void allocated_matrix ( void **  p,
size_t  m,
size_t  n 
)

References free_vector2().

+ Here is the call graph for this function:

void allocated_vector ( void *  p,
size_t  n 
)
void copy_matrix ( size_t  m,
size_t  n,
double **const  A,
double **const  B 
)

Copy the matrix A in B.

Parameters:
[in]mRows
[in]mColumns
[in]ASource matrix
[out]BDestination matrix
Precondition:
The pointers are not NULL
Warning:
The pointers should not be the same

References pic::n.

+ Here is the caller graph for this function:

void copy_vector ( size_t  n,
double *const  x,
double *const  y 
)

Copy the vector x in y.

Parameters:
[in]nDimension
[in]xSource vector
[out]yDestination vector
Precondition:
The pointers are not NULL
Warning:
The pointers should not be the same

References pic::n.

double euclidian_norm ( size_t  n,
double *const  x 
)

Derive the euclidian norm of a vector, that is, $ \displaystyle || x ||_2 = \biggl(\sum_{i = 0}^{n-1} x_i^2\biggr)^{\frac 12} $.

Parameters:
[in]nDimension of vector
[in]xInput vector
Returns:
Euclidian norm
Postcondition:
Thre result is greater than or equal to zero
Note:
If the pointer is NULL, the result is zero

References pic::n.

+ Here is the caller graph for this function:

void free_matrix ( size_t  m,
double **  p 
)

Free a matrix with m rows.

Parameters:
[in]mRows

+ Here is the caller graph for this function:

void free_matrix2 ( void **  p,
size_t  m,
size_t  n 
)

References free_vector2().

+ Here is the call graph for this function:

void free_vector ( double *  p)

Free a vector.

Parameters:
[in]pPointer

+ Here is the caller graph for this function:

void free_vector2 ( void *  p,
size_t  n 
)

+ Here is the caller graph for this function:

double inner_product ( size_t  n,
double *const  x 
)

Derive the ordinary inner product of a vector, that is, $ \displaystyle \langle x, x \rangle = \sum_{i = 0}^{n-1} x_i^2 $.

Parameters:
[in]nDimension of vector
[in]xInput vector
Returns:
Inner product
Postcondition:
The result is greater than or equal to zero
Note:
If the pointer is NULL, the result is zero

References pic::n.

+ Here is the caller graph for this function:

double** malloc_matrix ( size_t  m,
size_t  n 
)

Malloc a m-by-n matrix.

Parameters:
[in]mRows
[in]nColumns
Returns:
Pointer to a matrix
Note:
The return value could be NULL

+ Here is the caller graph for this function:

double* malloc_vector ( size_t  n)

Malloc a n-dimensional vector.

Parameters:
[in]nEnd index
Returns:
Pointer to a malloc vector
Note:
The return value could be NULL

+ Here is the caller graph for this function:

void print_matrix ( size_t  m,
size_t  n,
double **const  A,
char *const  name 
)

Display in stdout a matrix m-by-n.

Parameters:
[in]mRows
[in]nColumns
[in]AMatrix m-by-n
[in]nameName of the matrix in stdout
Precondition:
The dimension are not zeros and the pointers are not NULL

References pic::n.

void print_vector ( size_t  idx,
size_t  n,
double *const  v,
char *const  name 
)

Display in stdout a n-dimensional vector starting by an index.

Parameters:
[in]idxStart index
[in]nEnd index
[in]vVector
[in]nameName of the vector in stdout
Precondition:
The idx is less than n and the pointers are not NULL

References pic::n.

+ Here is the caller graph for this function: