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

Utilities. More...

#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
#include "load.h"
#include "save.h"
+ Include dependency graph for utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define inline   static
#define SWAP(a, b)   typeof(a) _SWAPPING_VAR; _SWAPPING_VAR = a; a = b; b = _SWAPPING_VAR
 A macro that swaps two generic values.
#define free_mem(a)
 Used to help ensure everything malloc'ed gets freed.

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.
int qrsis (int n, int m, double **a, double *b, double tol)

Detailed Description

Utilities.

Author:
Joan Gimeno
Date:
12/11/2013 (start)

Define Documentation

#define free_mem (   a)

Used to help ensure everything malloc'ed gets freed.

#define inline   static
#define SWAP (   a,
 
)    typeof(a) _SWAPPING_VAR; _SWAPPING_VAR = a; a = b; b = _SWAPPING_VAR

A macro that swaps two generic values.


Function Documentation

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_vector ( double *  p)

Free a vector.

Parameters:
[in]pPointer

+ 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:

int qrsis ( int  n,
int  m,
double **  a,
double *  b,
double  tol 
)

References pic::n, qrdes(), resq(), and resr().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: