48 #define CS_SDM_BY_BLOCK (1 << 0) 49 #define CS_SDM_SYMMETRIC (1 << 1) 50 #define CS_SDM_SHARED_VAL (1 << 2) 208 short int n_max_blocks_by_col,
209 const short int max_row_block_sizes[],
210 const short int max_col_block_sizes[]);
232 assert(array != NULL && m != NULL);
238 m->block_desc = NULL;
274 memset(mat->val, 0, n_rows*n_cols*
sizeof(
cs_real_t));
293 mat->n_rows = mat->n_cols =
n_rows;
294 memset(mat->val, 0, n_rows*n_rows*
sizeof(
cs_real_t));
312 short int n_blocks_by_row,
313 short int n_blocks_by_col,
314 const short int row_block_sizes[],
315 const short int col_block_sizes[]);
329 const cs_sdm_t *send)
332 assert(recv->n_max_rows >= send->n_max_rows);
333 assert(recv->n_max_cols >= send->n_max_cols);
335 recv->flag = send->flag;
336 recv->n_rows = send->n_rows;
337 recv->n_cols = send->n_cols;
340 memcpy(recv->val, send->val,
sizeof(
cs_real_t)*send->n_rows*send->n_cols);
355 static inline cs_sdm_t *
357 short int row_block_id,
358 short int col_block_id)
387 assert(m != NULL && col_vals != NULL);
388 assert(col_id < m->
n_cols);
391 for(
int i = 0; i < m->n_rows; i++, _col += m->n_cols)
412 const short int r_id,
413 const short int c_id,
419 assert(m != NULL && b != NULL);
420 assert(r_id >= 0 && c_id >= 0);
421 assert((r_id + nr) <= m->n_rows);
422 assert((c_id + nc) <= m->n_cols);
423 assert(nr == b->n_rows && nc == b->n_cols);
425 const cs_real_t *_start = m->val + c_id + r_id*m->n_cols;
426 for (
short int i = 0; i < nr; i++, _start += m->n_cols)
427 memcpy(b->val + i*nc, _start,
sizeof(
cs_real_t)*nc);
445 assert(m != NULL && mt != NULL);
446 assert(m->n_rows == mt->n_cols && m->n_cols == mt->n_rows);
448 for (
short int i = 0; i < m->n_rows; i++) {
449 const cs_real_t *m_i = m->val + i*m->n_cols;
450 for (
short int j = 0; j < m->n_cols; j++)
451 mt->val[j*mt->n_cols + i] += m_i[j];
492 assert(a != NULL && b != NULL && c != NULL);
493 assert(a->n_cols == 3 && b->n_cols == 3 &&
494 a->n_rows == 1 && c->n_rows == 1 &&
495 c->n_cols == 1 && b->n_rows == 1);
497 c->val[0] += a->val[0]*b->val[0] + a->val[1]*b->val[1] + a->val[2]*b->val[2];
621 const cs_sdm_t *add);
634 const cs_sdm_t *add);
649 const cs_sdm_t *add);
879 const cs_sdm_t *mat);
892 const cs_sdm_t *mat);
cs_flag_t flag
Definition: cs_sdm.h:76
void cs_sdm_33_ldlt_compute(const cs_sdm_t *m, cs_real_t facto[6])
LDL^T: Modified Cholesky decomposition of a 3x3 SPD matrix. For more reference, see for instance http...
Definition: cs_sdm.c:946
cs_sdm_t * cs_sdm_free(cs_sdm_t *mat)
Free a cs_sdm_t structure.
Definition: cs_sdm.c:293
static cs_sdm_t * cs_sdm_get_block(const cs_sdm_t *m, short int row_block_id, short int col_block_id)
Get a specific block in a cs_sdm_t structure defined by block.
Definition: cs_sdm.h:356
cs_sdm_t * cs_sdm_create_transpose(cs_sdm_t *mat)
Define a new matrix by adding the given matrix with its transpose. Keep the transposed matrix for a f...
Definition: cs_sdm.c:200
void cs_sdm_66_ldlt_solve(const cs_real_t f[21], const cs_real_t b[3], cs_real_t x[3])
Solve a 6x6 matrix with a modified Cholesky decomposition (L.D.L^T) The solution should be already al...
Definition: cs_sdm.c:1321
short int n_col_blocks
Definition: cs_sdm.h:63
void cs_sdm_square_add_transpose(cs_sdm_t *mat, cs_sdm_t *tr)
Define a new matrix by adding the given matrix with its transpose. Keep the transposed matrix for a f...
Definition: cs_sdm.c:791
void cs_sdm_ldlt_compute(const cs_sdm_t *m, cs_real_t *facto, cs_real_t *dkk)
LDL^T: Modified Cholesky decomposition of a SPD matrix. For more reference, see for instance http://m...
Definition: cs_sdm.c:1140
int n_max_cols
Definition: cs_sdm.h:83
cs_sdm_t * cs_sdm_create(cs_flag_t flag, int n_max_rows, int n_max_cols)
Allocate and initialize a cs_sdm_t structure Most generic function to create a cs_sdm_t structure...
Definition: cs_sdm.c:141
static void cs_sdm_init(int n_rows, int n_cols, cs_sdm_t *mat)
Initialize a cs_sdm_t structure Case of a square matrix.
Definition: cs_sdm.h:266
cs_sdm_t * cs_sdm_create_copy(const cs_sdm_t *m)
Allocate a cs_sdm_t structure and initialized it with the copy of the matrix m in input...
Definition: cs_sdm.c:177
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
Definition: cs_field_pointer.h:83
void cs_sdm_block_dump(cs_lnum_t parent_id, const cs_sdm_t *mat)
Dump a small dense matrix defined by blocks.
Definition: cs_sdm.c:1502
short int n_max_blocks_by_col
Definition: cs_sdm.h:62
void cs_sdm_33_ldlt_solve(const cs_real_t facto[6], const cs_real_t rhs[3], cs_real_t sol[3])
Solve a 3x3 matrix with a modified Cholesky decomposition (L.D.L^T) The solution should be already al...
Definition: cs_sdm.c:1262
void cs_sdm_block_init(cs_sdm_t *m, short int n_blocks_by_row, short int n_blocks_by_col, const short int row_block_sizes[], const short int col_block_sizes[])
Initialize the pattern of cs_sdm_t structure defined by block The matrix should have been allocated b...
Definition: cs_sdm.c:325
static void cs_sdm_copy(cs_sdm_t *recv, const cs_sdm_t *send)
Copy a cs_sdm_t structure into another cs_sdm_t structure which has been already allocated.
Definition: cs_sdm.h:328
void cs_sdm_add_mult(cs_sdm_t *mat, cs_real_t alpha, const cs_sdm_t *add)
Add two small dense matrices: loc += alpha*add.
Definition: cs_sdm.c:764
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
static void cs_sdm_map_array(int n_max_rows, int n_max_cols, cs_sdm_t *m, cs_real_t *array)
Map an array into a predefined cs_sdm_t structure. This array is shared and the lifecycle of this arr...
Definition: cs_sdm.h:227
#define CS_SDM_BY_BLOCK
Definition: cs_sdm.h:48
void cs_sdm_block_multiply_rowrow_sym(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Compute a row-row matrix product of a and b. It is basically equal to the classical a*b^T...
Definition: cs_sdm.c:574
static void cs_sdm_get_col(const cs_sdm_t *m, int col_id, cs_real_t *col_vals)
Get a copy of a column in a preallocated vector.
Definition: cs_sdm.h:382
#define CS_SDM_SHARED_VAL
Definition: cs_sdm.h:50
int n_cols
Definition: cs_sdm.h:84
double precision, save a
Definition: cs_fuel_incl.f90:146
void cs_sdm_44_ldlt_compute(const cs_sdm_t *m, cs_real_t facto[10])
LDL^T: Modified Cholesky decomposition of a 4x4 SPD matrix. For more reference, see for instance http...
Definition: cs_sdm.c:993
cs_sdm_t * cs_sdm_square_create(int n_max_rows)
Allocate and initialize a cs_sdm_t structure Case of a square matrix.
Definition: cs_sdm.c:160
void cs_sdm_dump(cs_lnum_t parent_id, const cs_lnum_t *row_ids, const cs_lnum_t *col_ids, const cs_sdm_t *mat)
Dump a small dense matrix.
Definition: cs_sdm.c:1456
void cs_sdm_66_ldlt_compute(const cs_sdm_t *m, cs_real_t facto[21])
LDL^T: Modified Cholesky decomposition of a 6x6 SPD matrix. For more reference, see for instance http...
Definition: cs_sdm.c:1050
cs_sdm_block_t * block_desc
Definition: cs_sdm.h:89
void cs_sdm_ldlt_solve(int n_rows, const cs_real_t *facto, const cs_real_t *rhs, cs_real_t *sol)
Solve a SPD matrix with a L.D.L^T (Modified Cholesky decomposition) The solution should be already al...
Definition: cs_sdm.c:1358
static void cs_sdm_transpose_and_update(const cs_sdm_t *m, cs_sdm_t *mt)
transpose and copy a matrix into another one already shaped sub-matrix starting from (r_id...
Definition: cs_sdm.h:442
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void cs_sdm_multiply_rowrow_sym(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Compute a row-row matrix product of a and b. It is basically equal to the classical a*b^T...
Definition: cs_sdm.c:471
void cs_sdm_block_multiply_rowrow(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Compute a row-row matrix product of a and b. It is basically equal to the classical a*b^T...
Definition: cs_sdm.c:519
cs_sdm_t * cs_sdm_block_create(short int n_max_blocks_by_row, short int n_max_blocks_by_col, const short int max_row_block_sizes[], const short int max_col_block_sizes[])
Allocate and initialize a cs_sdm_t structure.
Definition: cs_sdm.c:235
#define END_C_DECLS
Definition: cs_defs.h:454
void cs_sdm_multiply_rowrow(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Compute a row-row matrix product of a and b. It is basically equal to the classical a*b^T...
Definition: cs_sdm.c:425
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_sdm_33_sym_qr_compute(const cs_real_t m[9], cs_real_t Qt[9], cs_real_t R[6])
Decompose a matrix into the matrix product Q.R Case of a 3x3 symmetric matrix.
Definition: cs_sdm.c:881
void cs_sdm_add(cs_sdm_t *mat, const cs_sdm_t *add)
Add two small dense matrices: loc += add.
Definition: cs_sdm.c:741
void cs_sdm_matvec(const cs_sdm_t *mat, const cs_real_t *vec, cs_real_t *mv)
Compute a dense matrix-vector product for a rectangular matrix mv has been previously allocated...
Definition: cs_sdm.c:666
void() cs_sdm_product_t(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Generic prototype for computing a local dense matrix-product c = a*b where c has been previously allo...
Definition: cs_sdm.h:109
double precision, dimension(:,:,:), allocatable nc
Definition: atimbr.f90:110
cs_real_t * val
Definition: cs_sdm.h:86
void() cs_sdm_matvec_t(const cs_sdm_t *mat, const cs_real_t *vec, cs_real_t *mv)
Generic prototype for computing a dense matrix-vector product mv has been previously allocated...
Definition: cs_sdm.h:125
static void cs_sdm_multiply_r1c3_rowrow(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Compute a row-row matrix product of a and b. It is basically equal to the classical a*b^T...
Definition: cs_sdm.h:487
cs_sdm_t * blocks
Definition: cs_sdm.h:68
void cs_sdm_square_asymm(cs_sdm_t *mat)
Set the given matrix into its anti-symmetric part.
Definition: cs_sdm.c:834
static void cs_sdm_copy_block(const cs_sdm_t *m, const short int r_id, const short int c_id, const short int nr, const short int nc, cs_sdm_t *b)
copy a block of a matrix into a sub-matrix starting from (r_id, c_id) with a size of nr rows and nc c...
Definition: cs_sdm.h:411
void cs_sdm_44_ldlt_solve(const cs_real_t facto[10], const cs_real_t rhs[4], cs_real_t x[4])
Solve a 4x4 matrix with a modified Cholesky decomposition (L.D.L^T) The solution should be already al...
Definition: cs_sdm.c:1290
int n_max_rows
Definition: cs_sdm.h:79
void cs_sdm_multiply(const cs_sdm_t *a, const cs_sdm_t *b, cs_sdm_t *c)
Compute a local dense matrix-product c = a*b c has been previously allocated.
Definition: cs_sdm.c:382
void cs_sdm_square_matvec(const cs_sdm_t *mat, const cs_real_t *vec, cs_real_t *mv)
Compute a dense matrix-vector product for a small square matrix mv has been previously allocated...
Definition: cs_sdm.c:630
void cs_sdm_simple_dump(const cs_sdm_t *mat)
Dump a small dense matrix.
Definition: cs_sdm.c:1427
short int n_max_blocks_by_row
Definition: cs_sdm.h:60
void cs_sdm_block_add(cs_sdm_t *mat, const cs_sdm_t *add)
Add two matrices defined by block: loc += add.
Definition: cs_sdm.c:705
short int n_row_blocks
Definition: cs_sdm.h:61
int n_rows
Definition: cs_sdm.h:80
double precision, save b
Definition: cs_fuel_incl.f90:146
static void cs_sdm_square_init(int n_rows, cs_sdm_t *mat)
Initialize a cs_sdm_t structure Case of a square matrix.
Definition: cs_sdm.h:288