programmer's documentation
Functions
cs_cdo_toolbox.c File Reference
#include "cs_defs.h"
#include <stdlib.h>
#include <assert.h>
#include <float.h>
#include <limits.h>
#include <string.h>
#include <bft_mem.h>
#include <bft_printf.h>
#include "cs_cdo.h"
#include "cs_blas.h"
#include "cs_math.h"
#include "cs_sort.h"
#include "cs_cdo_toolbox.h"
Include dependency graph for cs_cdo_toolbox.c:

Functions

static cs_data_info_t _init_dinfo (cs_datatype_t datatype)
 Intialize by default a cs_data_info_t structure according to the datatype. More...
 
static void _compute_info_double (cs_lnum_t n_elts, const cs_real_t data[], cs_data_info_t *info)
 Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley) More...
 
static void _compute_info_int32 (cs_lnum_t n_elts, const cs_lnum_t data[], cs_data_info_t *info)
 Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley) More...
 
double cs_euclidean_norm (int len, const double v[])
 Compute the euclidean norm 2 of a vector of size len This algorithm tries to reduce round-off error thanks to intermediate sums. More...
 
double cs_weighted_sum_square (cs_lnum_t n, const double *restrict x, const double *restrict weight)
 Compute the weighted sum of square values of an array. More...
 
void cs_tmpbuf_alloc (size_t bufsize, cs_tmpbuf_t **p_tb)
 Allocate or reallocate a temporary buffer structure. More...
 
cs_tmpbuf_tcs_tmpbuf_free (cs_tmpbuf_t *tb)
 Free a temporary buffer structure. More...
 
cs_data_info_t cs_analysis_data (cs_lnum_t n_elts, int stride, cs_datatype_t datatype, const void *indata, _Bool do_abs)
 Compute some simple statistics from an array. More...
 
void cs_data_info_dump (const char *name, FILE *f, cs_lnum_t n_elts, cs_datatype_t datatype, const cs_data_info_t dinfo)
 Dump a cs_data_info_t structure. More...
 
cs_connect_index_tcs_index_create (int n)
 Create an index structure of size n. More...
 
cs_connect_index_tcs_index_map (int n, int *idx, int *ids)
 Map arrays into an index structure of size n (owner = false) More...
 
void cs_index_free (cs_connect_index_t **pidx)
 Destroy a cs_connect_index_t structure. More...
 
cs_connect_index_tcs_index_compose (int nc, const cs_connect_index_t *a2b, const cs_connect_index_t *b2c)
 From 2 indexes : A -> B and B -> C create a new index A -> C. More...
 
cs_connect_index_tcs_index_transpose (int nb, const cs_connect_index_t *a2b)
 From a cs_connect_index_t A -> B create a new index B -> A. More...
 
void cs_index_sort (cs_connect_index_t *x)
 Sort each sub-list related to an entry in a cs_connect_index_t structure. More...
 
void cs_index_dump (const char *name, FILE *_f, cs_connect_index_t *x)
 Dump a cs_connect_index_t structure to a file or into the standard output. More...
 
cs_locmat_tcs_locmat_create (int n_max_ent)
 Allocate and initialize a cs_locmat_t structure. More...
 
cs_locmat_tcs_locmat_free (cs_locmat_t *lm)
 Free a cs_locmat_t structure. More...
 
void cs_locmat_copy (cs_locmat_t *recv, const cs_locmat_t *send)
 Copy a cs_locmat_t structure into another cs_locmat_t structure which has been already allocated. More...
 
void cs_locmat_matvec (const cs_locmat_t *loc, const cs_real_t *vec, cs_real_t *matvec)
 Compute a local dense matrix-vector product matvec has been previously allocated. More...
 
void cs_locmat_add (cs_locmat_t *loc, const cs_locmat_t *add)
 Add two local dense matrices: loc += add. More...
 
void cs_locmat_mult_add (cs_locmat_t *loc, double alpha, const cs_locmat_t *add)
 Give the result of the following operation: loc = loc + alpha*add. More...
 
void cs_locmat_add_transpose (cs_locmat_t *loc, cs_locmat_t *tr)
 Define a new matrix by adding a local matrix with its transpose. Keep the transposed matrix for future use. More...
 
void cs_locmat_dump (int parent_id, const cs_locmat_t *lm)
 Dump a local discrete Hodge operator. More...
 
cs_locdec_tcs_locdec_create (int n_max_rows, int n_max_cols)
 Allocate and initialize a cs_locdec_t structure. More...
 
cs_locdec_tcs_locdec_free (cs_locdec_t *m)
 Free a cs_locdec_t structure. More...
 

Function Documentation

◆ _compute_info_double()

static void _compute_info_double ( cs_lnum_t  n_elts,
const cs_real_t  data[],
cs_data_info_t info 
)
static

Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley)

Parameters
[in]n_eltsnumber of couples in data
[in]databuffer containing input data
[in,out]infopointer to a cs_data_info_t structure

◆ _compute_info_int32()

static void _compute_info_int32 ( cs_lnum_t  n_elts,
const cs_lnum_t  data[],
cs_data_info_t info 
)
static

Compute simple information about an array of data. >> Algorithm from Mark Hoemmen (U.C. Berkeley)

Parameters
[in]n_eltsnumber of couples in data
[in]databuffer containing input data
[in,out]infopointer to a cs_data_info_t structure

◆ _init_dinfo()

static cs_data_info_t _init_dinfo ( cs_datatype_t  datatype)
static

Intialize by default a cs_data_info_t structure according to the datatype.

Parameters
[in]datatype
Returns
a cs_data_info_t structure

◆ cs_analysis_data()

cs_data_info_t cs_analysis_data ( cs_lnum_t  n_elts,
int  stride,
cs_datatype_t  datatype,
const void *  indata,
_Bool  do_abs 
)

Compute some simple statistics from an array.

Parameters
[in]n_eltsnumber of couples in data
[in]stridesize of a couple of data
[in]datatypedatatype
[in]indatabuffer containing input data
[in]do_absanalyse the absolute value of indata
Returns
a cs_data_info_t structure

◆ cs_data_info_dump()

void cs_data_info_dump ( const char *  name,
FILE *  f,
cs_lnum_t  n_elts,
cs_datatype_t  datatype,
const cs_data_info_t  dinfo 
)

Dump a cs_data_info_t structure.

Parameters
[in]namefilename if not NULL
[in]foutput file if not NULL
[in]n_eltsnumber of couples in data
[in]datatypedatatype
[in]dinfocs_data_info_t structure

◆ cs_euclidean_norm()

double cs_euclidean_norm ( int  len,
const double  v[] 
)

Compute the euclidean norm 2 of a vector of size len This algorithm tries to reduce round-off error thanks to intermediate sums.

Parameters
[in]lenvector dimension
[in]vvector
Returns
the euclidean norm of a vector

◆ cs_index_compose()

cs_connect_index_t* cs_index_compose ( int  nc,
const cs_connect_index_t a2b,
const cs_connect_index_t b2c 
)

From 2 indexes : A -> B and B -> C create a new index A -> C.

Parameters
[in]ncnumber of elements in C set
[in]a2bpointer to the index A -> B
[in]b2cpointer to the index B -> C
Returns
a pointer to the cs_connect_index_t structure A -> C

◆ cs_index_create()

cs_connect_index_t* cs_index_create ( int  n)

Create an index structure of size n.

Parameters
[in]nnumber of entries of the indexed list
Returns
a pointer to a cs_connect_index_t

◆ cs_index_dump()

void cs_index_dump ( const char *  name,
FILE *  _f,
cs_connect_index_t x 
)

Dump a cs_connect_index_t structure to a file or into the standard output.

Parameters
[in]namename of the dump file. Can be set to NULL
[in]_fpointer to a FILE structure. Can be set to NULL.
[in]xpointer to a cs_connect_index_t structure

◆ cs_index_free()

void cs_index_free ( cs_connect_index_t **  pidx)

Destroy a cs_connect_index_t structure.

Parameters
[in]pidxpointer of pointer to a cs_connect_index_t structure

◆ cs_index_map()

cs_connect_index_t* cs_index_map ( int  n,
int *  idx,
int *  ids 
)

Map arrays into an index structure of size n (owner = false)

Parameters
[in]nnumber of entries of the indexed list
[in]idxarray of size n+1
[in]idsarray of size idx[n]
Returns
a pointer to a cs_connect_index_t

◆ cs_index_sort()

void cs_index_sort ( cs_connect_index_t x)

Sort each sub-list related to an entry in a cs_connect_index_t structure.

Sort each list related to an entry in a cs_connect_index_t structure.

Parameters
[in]xpointer to a cs_connect_index_t structure

◆ cs_index_transpose()

cs_connect_index_t* cs_index_transpose ( int  nb,
const cs_connect_index_t a2b 
)

From a cs_connect_index_t A -> B create a new index B -> A.

From a cs_connect_index_t struct. A -> B create a new index B -> A.

Parameters
[in]nbsize of the "b" set
[in]a2bpointer to the index A -> B
Returns
a new pointer to the cs_connect_index_t structure B -> A

◆ cs_locdec_create()

cs_locdec_t* cs_locdec_create ( int  n_max_rows,
int  n_max_cols 
)

Allocate and initialize a cs_locdec_t structure.

Parameters
[in]n_max_rowsmax number of rows
[in]n_max_colsmax number of columns
Returns
a new allocated cs_locdec_t structure

◆ cs_locdec_free()

cs_locdec_t* cs_locdec_free ( cs_locdec_t m)

Free a cs_locdec_t structure.

Parameters
[in,out]mpointer to a cs_locdec_t structure to free
Returns
a NULL pointer

◆ cs_locmat_add()

void cs_locmat_add ( cs_locmat_t loc,
const cs_locmat_t add 
)

Add two local dense matrices: loc += add.

Parameters
[in,out]loclocal matrix storing the result
[in]addvalues to add to loc

◆ cs_locmat_add_transpose()

void cs_locmat_add_transpose ( cs_locmat_t loc,
cs_locmat_t tr 
)

Define a new matrix by adding a local matrix with its transpose. Keep the transposed matrix for future use.

Parameters
[in,out]loclocal matrix to transpose and add
[in,out]trtransposed of the local matrix

◆ cs_locmat_copy()

void cs_locmat_copy ( cs_locmat_t recv,
const cs_locmat_t send 
)

Copy a cs_locmat_t structure into another cs_locmat_t structure which has been already allocated.

Parameters
[in,out]recvpointer to a cs_locmat_t struct.
[in]sendpointer to a cs_locmat_t struct.

◆ cs_locmat_create()

cs_locmat_t* cs_locmat_create ( int  n_max_ent)

Allocate and initialize a cs_locmat_t structure.

Parameters
[in]n_max_entmax number of entities
Returns
a new allocated cs_locmat_t structure

◆ cs_locmat_dump()

void cs_locmat_dump ( int  parent_id,
const cs_locmat_t lm 
)

Dump a local discrete Hodge operator.

Parameters
[in]parent_idid of the related parent entity
[in]lmpointer to the cs_sla_locmat_t struct.

◆ cs_locmat_free()

cs_locmat_t* cs_locmat_free ( cs_locmat_t lm)

Free a cs_locmat_t structure.

Parameters
[in]lmpointer to a cs_locmat_t struct. to free
Returns
a NULL pointer

◆ cs_locmat_matvec()

void cs_locmat_matvec ( const cs_locmat_t loc,
const cs_real_t vec,
cs_real_t matvec 
)

Compute a local dense matrix-vector product matvec has been previously allocated.

Parameters
[in]loclocal matrix to use
[in]veclocal vector to use
[in,out]matvecresult of the local matrix-vector product

◆ cs_locmat_mult_add()

void cs_locmat_mult_add ( cs_locmat_t loc,
double  alpha,
const cs_locmat_t add 
)

Give the result of the following operation: loc = loc + alpha*add.

Parameters
[in,out]loclocal matrix storing the result
[in]alphamultiplicative coefficient
[in]addvalues to add to loc

◆ cs_tmpbuf_alloc()

void cs_tmpbuf_alloc ( size_t  bufsize,
cs_tmpbuf_t **  p_tb 
)

Allocate or reallocate a temporary buffer structure.

Parameters
[in]bufsizereference size
[in,out]p_tbpointer to the temporary structure to allocate

◆ cs_tmpbuf_free()

cs_tmpbuf_t* cs_tmpbuf_free ( cs_tmpbuf_t tb)

Free a temporary buffer structure.

Parameters
[in]tbpointer to the temporary structure to free
Returns
NULL pointer

◆ cs_weighted_sum_square()

double cs_weighted_sum_square ( cs_lnum_t  n,
const double *restrict  x,
const double *restrict  weight 
)

Compute the weighted sum of square values of an array.

Parameters
[in]nsize of arrays x and weight
[in]xarray of floating-point values
[in]weightfloating-point values of weights
Returns
the result of this operation