programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
61  short int n_row_blocks;
63  short int n_col_blocks;
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 /*----------------------------------------------------------------------------*/
144 /*----------------------------------------------------------------------------*/
145 
146 cs_sdm_t *
148  int n_max_rows,
149  int n_max_cols);
150 
151 /*----------------------------------------------------------------------------*/
160 /*----------------------------------------------------------------------------*/
161 
162 cs_sdm_t *
163 cs_sdm_square_create(int n_max_rows);
164 
165 /*----------------------------------------------------------------------------*/
174 /*----------------------------------------------------------------------------*/
175 
176 cs_sdm_t *
177 cs_sdm_create_copy(const cs_sdm_t *m);
178 
179 /*----------------------------------------------------------------------------*/
188 /*----------------------------------------------------------------------------*/
189 
190 cs_sdm_t *
191 cs_sdm_create_transpose(cs_sdm_t *mat);
192 
193 /*----------------------------------------------------------------------------*/
204 /*----------------------------------------------------------------------------*/
205 
206 cs_sdm_t *
207 cs_sdm_block_create(short int n_max_blocks_by_row,
208  short int n_max_blocks_by_col,
209  const short int max_row_block_sizes[],
210  const short int max_col_block_sizes[]);
211 
212 /*----------------------------------------------------------------------------*/
224 /*----------------------------------------------------------------------------*/
225 
226 static inline void
227 cs_sdm_map_array(int n_max_rows,
228  int n_max_cols,
229  cs_sdm_t *m,
230  cs_real_t *array)
231 {
232  assert(array != NULL && m != NULL); /* Sanity check */
233 
234  m->flag = CS_SDM_SHARED_VAL;
235  m->n_rows = m->n_max_rows = n_max_rows;
236  m->n_cols = m->n_max_cols = n_max_cols;
237  m->val = array;
238  m->block_desc = NULL;
239 }
240 
241 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 cs_sdm_t *
252 cs_sdm_free(cs_sdm_t *mat);
253 
254 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
265 static inline void
266 cs_sdm_init(int n_rows,
267  int n_cols,
268  cs_sdm_t *mat)
269 {
270  assert(mat != NULL);
271 
272  mat->n_rows = n_rows;
273  mat->n_cols = n_cols;
274  memset(mat->val, 0, n_rows*n_cols*sizeof(cs_real_t));
275 }
276 
277 /*----------------------------------------------------------------------------*/
285 /*----------------------------------------------------------------------------*/
286 
287 static inline void
289  cs_sdm_t *mat)
290 {
291  assert(mat != NULL);
292 
293  mat->n_rows = mat->n_cols = n_rows; /* square matrix */
294  memset(mat->val, 0, n_rows*n_rows*sizeof(cs_real_t));
295 }
296 
297 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 void
311 cs_sdm_block_init(cs_sdm_t *m,
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[]);
316 
317 /*----------------------------------------------------------------------------*/
325 /*----------------------------------------------------------------------------*/
326 
327 static inline void
328 cs_sdm_copy(cs_sdm_t *recv,
329  const cs_sdm_t *send)
330 {
331  /* Sanity check */
332  assert(recv->n_max_rows >= send->n_max_rows);
333  assert(recv->n_max_cols >= send->n_max_cols);
334 
335  recv->flag = send->flag;
336  recv->n_rows = send->n_rows;
337  recv->n_cols = send->n_cols;
338 
339  /* Copy values */
340  memcpy(recv->val, send->val, sizeof(cs_real_t)*send->n_rows*send->n_cols);
341 }
342 
343 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 static inline cs_sdm_t *
356 cs_sdm_get_block(const cs_sdm_t *m,
357  short int row_block_id,
358  short int col_block_id)
359 {
360  /* Sanity checks */
361  assert(m != NULL);
362  assert(m->flag & CS_SDM_BY_BLOCK && m->block_desc != NULL);
363  assert(col_block_id < m->block_desc->n_col_blocks);
364  assert(row_block_id < m->block_desc->n_row_blocks);
365 
366  const cs_sdm_block_t *bd = m->block_desc;
367 
368  return bd->blocks + row_block_id*bd->n_col_blocks + col_block_id;
369 }
370 
371 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 static inline void
382 cs_sdm_get_col(const cs_sdm_t *m,
383  int col_id,
384  cs_real_t *col_vals)
385 {
386  /* Sanity checks */
387  assert(m != NULL && col_vals != NULL);
388  assert(col_id < m->n_cols);
389 
390  const cs_real_t *_col = m->val + col_id;
391  for(int i = 0; i < m->n_rows; i++, _col += m->n_cols)
392  col_vals[i] = *_col;
393 }
394 
395 /*----------------------------------------------------------------------------*/
408 /*----------------------------------------------------------------------------*/
409 
410 static inline void
411 cs_sdm_copy_block(const cs_sdm_t *m,
412  const short int r_id,
413  const short int c_id,
414  const short int nr,
415  const short int nc,
416  cs_sdm_t *b)
417 {
418  /* Sanity checks */
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);
424 
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);
428 }
429 
430 /*----------------------------------------------------------------------------*/
439 /*----------------------------------------------------------------------------*/
440 
441 static inline void
442 cs_sdm_transpose_and_update(const cs_sdm_t *m,
443  cs_sdm_t *mt)
444 {
445  assert(m != NULL && mt != NULL);
446  assert(m->n_rows == mt->n_cols && m->n_cols == mt->n_rows);
447 
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];
452  }
453 }
454 
455 /*----------------------------------------------------------------------------*/
465 /*----------------------------------------------------------------------------*/
466 
467 void
468 cs_sdm_multiply(const cs_sdm_t *a,
469  const cs_sdm_t *b,
470  cs_sdm_t *c);
471 
472 /*----------------------------------------------------------------------------*/
484 /*----------------------------------------------------------------------------*/
485 
486 static inline void
487 cs_sdm_multiply_r1c3_rowrow(const cs_sdm_t *a,
488  const cs_sdm_t *b,
489  cs_sdm_t *c)
490 {
491  /* Sanity check */
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);
496 
497  c->val[0] += a->val[0]*b->val[0] + a->val[1]*b->val[1] + a->val[2]*b->val[2];
498 }
499 
500 /*----------------------------------------------------------------------------*/
512 /*----------------------------------------------------------------------------*/
513 
514 void
515 cs_sdm_multiply_rowrow(const cs_sdm_t *a,
516  const cs_sdm_t *b,
517  cs_sdm_t *c);
518 
519 /*----------------------------------------------------------------------------*/
532 /*----------------------------------------------------------------------------*/
533 
534 void
535 cs_sdm_multiply_rowrow_sym(const cs_sdm_t *a,
536  const cs_sdm_t *b,
537  cs_sdm_t *c);
538 
539 /*----------------------------------------------------------------------------*/
551 /*----------------------------------------------------------------------------*/
552 
553 void
554 cs_sdm_block_multiply_rowrow(const cs_sdm_t *a,
555  const cs_sdm_t *b,
556  cs_sdm_t *c);
557 
558 /*----------------------------------------------------------------------------*/
571 /*----------------------------------------------------------------------------*/
572 
573 void
574 cs_sdm_block_multiply_rowrow_sym(const cs_sdm_t *a,
575  const cs_sdm_t *b,
576  cs_sdm_t *c);
577 
578 /*----------------------------------------------------------------------------*/
587 /*----------------------------------------------------------------------------*/
588 
589 void
590 cs_sdm_square_matvec(const cs_sdm_t *mat,
591  const cs_real_t *vec,
592  cs_real_t *mv);
593 
594 /*----------------------------------------------------------------------------*/
603 /*----------------------------------------------------------------------------*/
604 
605 void
606 cs_sdm_matvec(const cs_sdm_t *mat,
607  const cs_real_t *vec,
608  cs_real_t *mv);
609 
610 /*----------------------------------------------------------------------------*/
617 /*----------------------------------------------------------------------------*/
618 
619 void
620 cs_sdm_block_add(cs_sdm_t *mat,
621  const cs_sdm_t *add);
622 
623 /*----------------------------------------------------------------------------*/
630 /*----------------------------------------------------------------------------*/
631 
632 void
633 cs_sdm_add(cs_sdm_t *mat,
634  const cs_sdm_t *add);
635 
636 /*----------------------------------------------------------------------------*/
644 /*----------------------------------------------------------------------------*/
645 
646 void
647 cs_sdm_add_mult(cs_sdm_t *mat,
649  const cs_sdm_t *add);
650 
651 /*----------------------------------------------------------------------------*/
659 /*----------------------------------------------------------------------------*/
660 
661 void
662 cs_sdm_square_add_transpose(cs_sdm_t *mat,
663  cs_sdm_t *tr);
664 
665 /*----------------------------------------------------------------------------*/
671 /*----------------------------------------------------------------------------*/
672 
673 void
674 cs_sdm_square_asymm(cs_sdm_t *mat);
675 
676 /*----------------------------------------------------------------------------*/
693 /*----------------------------------------------------------------------------*/
694 
695 void
697  cs_real_t Qt[9],
698  cs_real_t R[6]);
699 
700 /*----------------------------------------------------------------------------*/
714 /*----------------------------------------------------------------------------*/
715 
716 void
717 cs_sdm_33_ldlt_compute(const cs_sdm_t *m,
718  cs_real_t facto[6]);
719 
720 /*----------------------------------------------------------------------------*/
734 /*----------------------------------------------------------------------------*/
735 
736 void
737 cs_sdm_44_ldlt_compute(const cs_sdm_t *m,
738  cs_real_t facto[10]);
739 
740 /*----------------------------------------------------------------------------*/
754 /*----------------------------------------------------------------------------*/
755 
756 void
757 cs_sdm_66_ldlt_compute(const cs_sdm_t *m,
758  cs_real_t facto[21]);
759 
760 /*----------------------------------------------------------------------------*/
775 /*----------------------------------------------------------------------------*/
776 
777 void
778 cs_sdm_ldlt_compute(const cs_sdm_t *m,
779  cs_real_t *facto,
780  cs_real_t *dkk);
781 
782 /*----------------------------------------------------------------------------*/
792 /*----------------------------------------------------------------------------*/
793 
794 void
795 cs_sdm_33_ldlt_solve(const cs_real_t facto[6],
796  const cs_real_t rhs[3],
797  cs_real_t sol[3]);
798 
799 /*----------------------------------------------------------------------------*/
809 /*----------------------------------------------------------------------------*/
810 
811 void
812 cs_sdm_44_ldlt_solve(const cs_real_t facto[10],
813  const cs_real_t rhs[4],
814  cs_real_t x[4]);
815 
816 /*----------------------------------------------------------------------------*/
826 /*----------------------------------------------------------------------------*/
827 
828 void
829 cs_sdm_66_ldlt_solve(const cs_real_t f[21],
830  const cs_real_t b[3],
831  cs_real_t x[3]);
832 
833 /*----------------------------------------------------------------------------*/
845 /*----------------------------------------------------------------------------*/
846 
847 void
848 cs_sdm_ldlt_solve(int n_rows,
849  const cs_real_t *facto,
850  const cs_real_t *rhs,
851  cs_real_t *sol);
852 
853 /*----------------------------------------------------------------------------*/
859 /*----------------------------------------------------------------------------*/
860 
861 void
862 cs_sdm_simple_dump(const cs_sdm_t *mat);
863 
864 /*----------------------------------------------------------------------------*/
873 /*----------------------------------------------------------------------------*/
874 
875 void
876 cs_sdm_dump(cs_lnum_t parent_id,
877  const cs_lnum_t *row_ids,
878  const cs_lnum_t *col_ids,
879  const cs_sdm_t *mat);
880 
881 /*----------------------------------------------------------------------------*/
888 /*----------------------------------------------------------------------------*/
889 
890 void
891 cs_sdm_block_dump(cs_lnum_t parent_id,
892  const cs_sdm_t *mat);
893 
894 /*----------------------------------------------------------------------------*/
895 
897 
898 #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: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
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
Definition: cs_sdm.h:74
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
Definition: cs_sdm.h:58
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_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
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
cs_real_t * val
Definition: cs_sdm.h:86
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
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