programmer's documentation
cs_sdm.h
Go to the documentation of this file.
1 #ifndef __CS_SDM_H__
2 #define __CS_SDM_H__
3 
4 /*============================================================================
5  * Set of operations to handle Small Dense Matrices (SDM)
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------
29  * Standard C library headers
30  *----------------------------------------------------------------------------*/
31 
32 #include <stdio.h>
33 #include <string.h>
34 #include <math.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 #define CS_SDM_BY_BLOCK (1 << 0) /* Matrix is defined by block */
49 #define CS_SDM_SYMMETRIC (1 << 1) /* Matrix is symmetric by construction */
50 #define CS_SDM_SHARED_VAL (1 << 2) /* Matrix is not owner of its values */
51 
52 /*============================================================================
53  * Type definitions
54  *============================================================================*/
55 
56 typedef struct _cs_sdm_t cs_sdm_t;
57 
58 typedef struct {
59 
64 
65  /* Allocated to n_max_blocks_by_row*n_max_blocks_by_col
66  Cast in cs_sdm_t where values are shared with the master cs_sdm_t struct.
67  */
68  cs_sdm_t *blocks;
69 
71 
72 /* Structure enabling the repeated usage of Small Dense Matrices (SDM) during
73  the building of the linear system by a cellwise process */
74 struct _cs_sdm_t {
75 
76  cs_flag_t flag; /* Metadata */
77 
78  /* Row-related members */
79  int n_max_rows; // max number of entities by primal cells
80  int n_rows; // current number of entities
81 
82  /* Column-related members. Not useful if the matrix is square */
83  int n_max_cols; // max number of entries in a column
84  int n_cols; // current number of columns
85 
86  cs_real_t *val; // small dense matrix (size: n_max_rows*n_max_cols)
87 
88  /* Structure describing the matrix in terms of blocks */
90 
91 };
92 
93 /*============================================================================
94  * Prototypes for pointer of functions
95  *============================================================================*/
96 
97 /*----------------------------------------------------------------------------*/
106 /*----------------------------------------------------------------------------*/
107 
108 typedef void
109 (cs_sdm_product_t) (const cs_sdm_t *a,
110  const cs_sdm_t *b,
111  cs_sdm_t *c);
112 
113 /*----------------------------------------------------------------------------*/
122 /*----------------------------------------------------------------------------*/
123 
124 typedef void
125 (cs_sdm_matvec_t) (const cs_sdm_t *mat,
126  const cs_real_t *vec,
127  cs_real_t *mv);
128 
129 /*============================================================================
130  * Public function prototypes
131  *============================================================================*/
132 
133 /*----------------------------------------------------------------------------*/
145 /*----------------------------------------------------------------------------*/
146 
147 static inline cs_real_t
149  const cs_real_t x[],
150  const cs_real_t y[])
151 {
152  cs_real_t dp = 0;
153 
154  if (x == NULL || y == NULL)
155  return dp;
156 
157  for (int i = 0; i < n; i++)
158  dp += x[i]*y[i];
159 
160  return dp;
161 }
162 
163 /*----------------------------------------------------------------------------*/
174 /*----------------------------------------------------------------------------*/
175 
176 static inline void
178  const cs_real_t s,
179  const cs_real_t x[],
180  cs_real_t y[])
181 {
182  if (x == NULL || y == NULL)
183  return;
184 
185  for (int i = 0; i < n; i++)
186  y[i] = s * x[i];
187 }
188 
189 /*----------------------------------------------------------------------------*/
200 /*----------------------------------------------------------------------------*/
201 
202 static inline void
204  const cs_real_t s,
205  const cs_real_t x[],
206  cs_real_t y[])
207 {
208  if (x == NULL || y == NULL)
209  return;
210 
211  for (int i = 0; i < n; i++)
212  y[i] += s * x[i];
213 }
214 
215 /*----------------------------------------------------------------------------*/
226 /*----------------------------------------------------------------------------*/
227 
228 cs_sdm_t *
230  int n_max_rows,
231  int n_max_cols);
232 
233 /*----------------------------------------------------------------------------*/
242 /*----------------------------------------------------------------------------*/
243 
244 cs_sdm_t *
245 cs_sdm_square_create(int n_max_rows);
246 
247 /*----------------------------------------------------------------------------*/
256 /*----------------------------------------------------------------------------*/
257 
258 cs_sdm_t *
259 cs_sdm_create_copy(const cs_sdm_t *m);
260 
261 /*----------------------------------------------------------------------------*/
270 /*----------------------------------------------------------------------------*/
271 
272 cs_sdm_t *
273 cs_sdm_create_transpose(cs_sdm_t *mat);
274 
275 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 cs_sdm_t *
289 cs_sdm_block_create(int n_max_blocks_by_row,
290  int n_max_blocks_by_col,
291  const short int max_row_block_sizes[],
292  const short int max_col_block_sizes[]);
293 
294 /*----------------------------------------------------------------------------*/
306 /*----------------------------------------------------------------------------*/
307 
308 static inline void
309 cs_sdm_map_array(int n_max_rows,
310  int n_max_cols,
311  cs_sdm_t *m,
312  cs_real_t *array)
313 {
314  assert(array != NULL && m != NULL); /* Sanity check */
315 
316  m->flag = CS_SDM_SHARED_VAL;
317  m->n_rows = m->n_max_rows = n_max_rows;
318  m->n_cols = m->n_max_cols = n_max_cols;
319  m->val = array;
320  m->block_desc = NULL;
321 }
322 
323 /*----------------------------------------------------------------------------*/
331 /*----------------------------------------------------------------------------*/
332 
333 cs_sdm_t *
334 cs_sdm_free(cs_sdm_t *mat);
335 
336 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 
347 static inline void
349  int n_cols,
350  cs_sdm_t *mat)
351 {
352  assert(mat != NULL);
353 
354  mat->n_rows = n_rows;
355  mat->n_cols = n_cols;
356  memset(mat->val, 0, n_rows*n_cols*sizeof(cs_real_t));
357 }
358 
359 /*----------------------------------------------------------------------------*/
367 /*----------------------------------------------------------------------------*/
368 
369 static inline void
371  cs_sdm_t *mat)
372 {
373  assert(mat != NULL);
374 
375  mat->n_rows = mat->n_cols = n_rows; /* square matrix */
376  memset(mat->val, 0, n_rows*n_rows*sizeof(cs_real_t));
377 }
378 
379 /*----------------------------------------------------------------------------*/
390 /*----------------------------------------------------------------------------*/
391 
392 void
393 cs_sdm_block_init(cs_sdm_t *m,
394  int n_row_blocks,
395  int n_col_blocks,
396  const short int row_block_sizes[],
397  const short int col_block_sizes[]);
398 
399 /*----------------------------------------------------------------------------*/
407 /*----------------------------------------------------------------------------*/
408 
409 static inline void
410 cs_sdm_copy(cs_sdm_t *recv,
411  const cs_sdm_t *send)
412 {
413  /* Sanity check */
414  assert(recv->n_max_rows >= send->n_rows);
415  assert(recv->n_max_cols >= send->n_cols);
416 
417  recv->flag = send->flag;
418  recv->n_rows = send->n_rows;
419  recv->n_cols = send->n_cols;
420 
421  /* Copy values */
422  memcpy(recv->val, send->val, sizeof(cs_real_t)*send->n_rows*send->n_cols);
423 }
424 
425 /*----------------------------------------------------------------------------*/
435 /*----------------------------------------------------------------------------*/
436 
437 static inline cs_sdm_t *
438 cs_sdm_get_block(const cs_sdm_t *m,
439  int row_block_id,
440  int col_block_id)
441 {
442  /* Sanity checks */
443  assert(m != NULL);
444  assert(m->flag & CS_SDM_BY_BLOCK && m->block_desc != NULL);
445  assert(col_block_id < m->block_desc->n_col_blocks);
446  assert(row_block_id < m->block_desc->n_row_blocks);
447 
448  const cs_sdm_block_t *bd = m->block_desc;
449 
450  return bd->blocks + row_block_id*bd->n_col_blocks + col_block_id;
451 }
452 
453 /*----------------------------------------------------------------------------*/
461 /*----------------------------------------------------------------------------*/
462 
463 static inline void
464 cs_sdm_get_col(const cs_sdm_t *m,
465  int col_id,
466  cs_real_t *col_vals)
467 {
468  /* Sanity checks */
469  assert(m != NULL && col_vals != NULL);
470  assert(col_id < m->n_cols);
471 
472  const cs_real_t *_col = m->val + col_id;
473  for(int i = 0; i < m->n_rows; i++, _col += m->n_cols)
474  col_vals[i] = *_col;
475 }
476 
477 /*----------------------------------------------------------------------------*/
490 /*----------------------------------------------------------------------------*/
491 
492 static inline void
493 cs_sdm_copy_block(const cs_sdm_t *m,
494  const short int r_id,
495  const short int c_id,
496  const short int nr,
497  const short int nc,
498  cs_sdm_t *b)
499 {
500  /* Sanity checks */
501  assert(m != NULL && b != NULL);
502  assert(r_id >= 0 && c_id >= 0);
503  assert((r_id + nr) <= m->n_rows);
504  assert((c_id + nc) <= m->n_cols);
505  assert(nr == b->n_rows && nc == b->n_cols);
506 
507  const cs_real_t *_start = m->val + c_id + r_id*m->n_cols;
508  for (short int i = 0; i < nr; i++, _start += m->n_cols)
509  memcpy(b->val + i*nc, _start, sizeof(cs_real_t)*nc);
510 }
511 
512 /*----------------------------------------------------------------------------*/
521 /*----------------------------------------------------------------------------*/
522 
523 static inline void
524 cs_sdm_transpose_and_update(const cs_sdm_t *m,
525  cs_sdm_t *mt)
526 {
527  assert(m != NULL && mt != NULL);
528  assert(m->n_rows == mt->n_cols && m->n_cols == mt->n_rows);
529 
530  for (short int i = 0; i < m->n_rows; i++) {
531  const cs_real_t *m_i = m->val + i*m->n_cols;
532  for (short int j = 0; j < m->n_cols; j++)
533  mt->val[j*mt->n_cols + i] += m_i[j];
534  }
535 }
536 
537 /*----------------------------------------------------------------------------*/
547 /*----------------------------------------------------------------------------*/
548 
549 void
550 cs_sdm_multiply(const cs_sdm_t *a,
551  const cs_sdm_t *b,
552  cs_sdm_t *c);
553 
554 /*----------------------------------------------------------------------------*/
566 /*----------------------------------------------------------------------------*/
567 
568 static inline void
569 cs_sdm_multiply_r1c3_rowrow(const cs_sdm_t *a,
570  const cs_sdm_t *b,
571  cs_sdm_t *c)
572 {
573  /* Sanity check */
574  assert(a != NULL && b != NULL && c != NULL);
575  assert(a->n_cols == 3 && b->n_cols == 3 &&
576  a->n_rows == 1 && c->n_rows == 1 &&
577  c->n_cols == 1 && b->n_rows == 1);
578 
579  c->val[0] += a->val[0]*b->val[0] + a->val[1]*b->val[1] + a->val[2]*b->val[2];
580 }
581 
582 /*----------------------------------------------------------------------------*/
594 /*----------------------------------------------------------------------------*/
595 
596 void
597 cs_sdm_multiply_rowrow(const cs_sdm_t *a,
598  const cs_sdm_t *b,
599  cs_sdm_t *c);
600 
601 /*----------------------------------------------------------------------------*/
614 /*----------------------------------------------------------------------------*/
615 
616 void
617 cs_sdm_multiply_rowrow_sym(const cs_sdm_t *a,
618  const cs_sdm_t *b,
619  cs_sdm_t *c);
620 
621 /*----------------------------------------------------------------------------*/
633 /*----------------------------------------------------------------------------*/
634 
635 void
636 cs_sdm_block_multiply_rowrow(const cs_sdm_t *a,
637  const cs_sdm_t *b,
638  cs_sdm_t *c);
639 
640 /*----------------------------------------------------------------------------*/
653 /*----------------------------------------------------------------------------*/
654 
655 void
656 cs_sdm_block_multiply_rowrow_sym(const cs_sdm_t *a,
657  const cs_sdm_t *b,
658  cs_sdm_t *c);
659 
660 /*----------------------------------------------------------------------------*/
669 /*----------------------------------------------------------------------------*/
670 
671 void
672 cs_sdm_square_matvec(const cs_sdm_t *mat,
673  const cs_real_t *vec,
674  cs_real_t *mv);
675 
676 /*----------------------------------------------------------------------------*/
685 /*----------------------------------------------------------------------------*/
686 
687 void
688 cs_sdm_matvec(const cs_sdm_t *mat,
689  const cs_real_t *vec,
690  cs_real_t *mv);
691 
692 /*----------------------------------------------------------------------------*/
702 /*----------------------------------------------------------------------------*/
703 
704 void
705 cs_sdm_update_matvec(const cs_sdm_t *mat,
706  const cs_real_t *vec,
707  cs_real_t *mv);
708 
709 /*----------------------------------------------------------------------------*/
720 /*----------------------------------------------------------------------------*/
721 
722 void
723 cs_sdm_matvec_transposed(const cs_sdm_t *mat,
724  const cs_real_t *vec,
725  cs_real_t *mv);
726 
727 /*----------------------------------------------------------------------------*/
734 /*----------------------------------------------------------------------------*/
735 
736 void
737 cs_sdm_block_add(cs_sdm_t *mat,
738  const cs_sdm_t *add);
739 
740 /*----------------------------------------------------------------------------*/
748 /*----------------------------------------------------------------------------*/
749 
750 void
751 cs_sdm_block_add_mult(cs_sdm_t *mat,
752  cs_real_t mult_coef,
753  const cs_sdm_t *add);
754 
755 /*----------------------------------------------------------------------------*/
765 /*----------------------------------------------------------------------------*/
766 
767 void
768 cs_sdm_block_matvec(const cs_sdm_t *mat,
769  const cs_real_t *vec,
770  cs_real_t *mv);
771 
772 /*----------------------------------------------------------------------------*/
779 /*----------------------------------------------------------------------------*/
780 
781 void
782 cs_sdm_add(cs_sdm_t *mat,
783  const cs_sdm_t *add);
784 
785 /*----------------------------------------------------------------------------*/
793 /*----------------------------------------------------------------------------*/
794 
795 void
796 cs_sdm_add_mult(cs_sdm_t *mat,
798  const cs_sdm_t *add);
799 
800 /*----------------------------------------------------------------------------*/
808 /*----------------------------------------------------------------------------*/
809 
810 void
811 cs_sdm_square_add_transpose(cs_sdm_t *mat,
812  cs_sdm_t *tr);
813 
814 /*----------------------------------------------------------------------------*/
820 /*----------------------------------------------------------------------------*/
821 
822 void
823 cs_sdm_square_asymm(cs_sdm_t *mat);
824 
825 /*----------------------------------------------------------------------------*/
842 /*----------------------------------------------------------------------------*/
843 
844 void
846  cs_real_t Qt[9],
847  cs_real_t R[6]);
848 
849 /*----------------------------------------------------------------------------*/
863 /*----------------------------------------------------------------------------*/
864 
865 void
866 cs_sdm_33_ldlt_compute(const cs_sdm_t *m,
867  cs_real_t facto[6]);
868 
869 /*----------------------------------------------------------------------------*/
883 /*----------------------------------------------------------------------------*/
884 
885 void
886 cs_sdm_44_ldlt_compute(const cs_sdm_t *m,
887  cs_real_t facto[10]);
888 
889 /*----------------------------------------------------------------------------*/
903 /*----------------------------------------------------------------------------*/
904 
905 void
906 cs_sdm_66_ldlt_compute(const cs_sdm_t *m,
907  cs_real_t facto[21]);
908 
909 /*----------------------------------------------------------------------------*/
924 /*----------------------------------------------------------------------------*/
925 
926 void
927 cs_sdm_ldlt_compute(const cs_sdm_t *m,
928  cs_real_t *facto,
929  cs_real_t *dkk);
930 
931 /*----------------------------------------------------------------------------*/
941 /*----------------------------------------------------------------------------*/
942 
943 void
944 cs_sdm_33_ldlt_solve(const cs_real_t facto[6],
945  const cs_real_t rhs[3],
946  cs_real_t sol[3]);
947 
948 /*----------------------------------------------------------------------------*/
958 /*----------------------------------------------------------------------------*/
959 
960 void
961 cs_sdm_44_ldlt_solve(const cs_real_t facto[10],
962  const cs_real_t rhs[4],
963  cs_real_t x[4]);
964 
965 /*----------------------------------------------------------------------------*/
975 /*----------------------------------------------------------------------------*/
976 
977 void
978 cs_sdm_66_ldlt_solve(const cs_real_t f[21],
979  const cs_real_t b[6],
980  cs_real_t x[6]);
981 
982 /*----------------------------------------------------------------------------*/
994 /*----------------------------------------------------------------------------*/
995 
996 void
998  const cs_real_t *facto,
999  const cs_real_t *rhs,
1000  cs_real_t *sol);
1001 
1002 /*----------------------------------------------------------------------------*/
1008 /*----------------------------------------------------------------------------*/
1009 
1010 void
1011 cs_sdm_simple_dump(const cs_sdm_t *mat);
1012 
1013 /*----------------------------------------------------------------------------*/
1022 /*----------------------------------------------------------------------------*/
1023 
1024 void
1025 cs_sdm_dump(cs_lnum_t parent_id,
1026  const cs_lnum_t *row_ids,
1027  const cs_lnum_t *col_ids,
1028  const cs_sdm_t *mat);
1029 
1030 /*----------------------------------------------------------------------------*/
1043 /*----------------------------------------------------------------------------*/
1044 
1045 void
1046 cs_sdm_fprintf(FILE *fp,
1047  const char *fname,
1048  cs_real_t thd,
1049  const cs_sdm_t *m);
1050 
1051 /*----------------------------------------------------------------------------*/
1058 /*----------------------------------------------------------------------------*/
1059 
1060 void
1061 cs_sdm_block_dump(cs_lnum_t parent_id,
1062  const cs_sdm_t *mat);
1063 
1064 /*----------------------------------------------------------------------------*/
1077 /*----------------------------------------------------------------------------*/
1078 
1079 void
1080 cs_sdm_block_fprintf(FILE *fp,
1081  const char *fname,
1082  cs_real_t thd,
1083  const cs_sdm_t *m);
1084 
1085 /*----------------------------------------------------------------------------*/
1086 
1088 
1089 #endif /* __CS_SDM_H__ */
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:1101
cs_sdm_t * cs_sdm_free(cs_sdm_t *mat)
Free a cs_sdm_t structure.
Definition: cs_sdm.c:290
void cs_sdm_66_ldlt_solve(const cs_real_t f[21], const cs_real_t b[6], cs_real_t x[6])
Solve a 6x6 matrix with a modified Cholesky decomposition (L.D.L^T) The solution should be already al...
Definition: cs_sdm.c:1476
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:197
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:947
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:1295
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:138
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:348
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:174
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
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:1712
int n_col_blocks
Definition: cs_sdm.h:63
void cs_sdm_update_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 and i...
Definition: cs_sdm.c:706
void cs_sdm_block_add_mult(cs_sdm_t *mat, cs_real_t mult_coef, const cs_sdm_t *add)
Add two matrices defined by block: loc += mult_coef * add.
Definition: cs_sdm.c:805
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:1417
int n_max_blocks_by_row
Definition: cs_sdm.h:60
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:410
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:920
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
void cs_sdm_fprintf(FILE *fp, const char *fname, cs_real_t thd, const cs_sdm_t *m)
Print a cs_sdm_t structure not defined by block Print into the file f if given otherwise open a new f...
Definition: cs_sdm.c:1663
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:309
#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:571
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:464
#define CS_SDM_SHARED_VAL
Definition: cs_sdm.h:50
static cs_sdm_t * cs_sdm_get_block(const cs_sdm_t *m, int row_block_id, int col_block_id)
Get a specific block in a cs_sdm_t structure defined by block.
Definition: cs_sdm.h:438
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:1148
static cs_real_t cs_sdm_dot(int n, const cs_real_t x[], const cs_real_t y[])
Basic dot product for a small vector For very small array sizes (3, 4, 6) prefer functions in cs_math...
Definition: cs_sdm.h:148
void cs_sdm_block_fprintf(FILE *fp, const char *fname, cs_real_t thd, const cs_sdm_t *m)
Print a cs_sdm_t structure which is defined by block Print into the file f if given otherwise open a ...
Definition: cs_sdm.c:1767
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:157
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:1611
void cs_sdm_block_init(cs_sdm_t *m, int n_row_blocks, int n_col_blocks, 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:322
int n_row_blocks
Definition: cs_sdm.h:61
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:1205
cs_sdm_block_t * block_desc
Definition: cs_sdm.h:89
cs_sdm_t * cs_sdm_block_create(int n_max_blocks_by_row, 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:232
int n_max_blocks_by_col
Definition: cs_sdm.h:62
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:1513
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:524
Definition: cs_sdm.h:74
Definition: cs_sdm.h:58
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void cs_sdm_block_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 defined by block mv has been previousl...
Definition: cs_sdm.c:845
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:468
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:516
#define END_C_DECLS
Definition: cs_defs.h:462
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:422
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:1036
void cs_sdm_add(cs_sdm_t *mat, const cs_sdm_t *add)
Add two small dense matrices: loc += add.
Definition: cs_sdm.c:897
static void cs_sdm_scalvect(int n, const cs_real_t s, const cs_real_t x[], cs_real_t y[])
Multiply a small vector by a scalar coefficient: y = s x For very small array sizes (3...
Definition: cs_sdm.h:177
void cs_sdm_matvec_transposed(const cs_sdm_t *mat, const cs_real_t *vec, cs_real_t *mv)
Compute a dense matrix-vector product for a rectangular matrix which is transposed. mv has been previously allocated. mv is updated inside this function. Don&#39;t forget to initialize mv if needed.
Definition: cs_sdm.c:739
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:664
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_add_scalvect(int n, const cs_real_t s, const cs_real_t x[], cs_real_t y[])
Multiply a small vector by a scalar coefficient: y += s x For very small array sizes (3...
Definition: cs_sdm.h:203
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:569
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:990
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:493
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:1445
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:379
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:628
void cs_sdm_simple_dump(const cs_sdm_t *mat)
Dump a small dense matrix.
Definition: cs_sdm.c:1582
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:769
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:370