PaStiX Handbook  6.2.1
symbol_check.c
Go to the documentation of this file.
1 /**
2  *
3  * @file symbol_check.c
4  *
5  * PaStiX routines to check the correctness of the symbol structure.
6  *
7  * @copyright 1999-2021 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.2.0
11  * @author Francois Pellegrini
12  * @author David Goudin
13  * @author Pascal Henon
14  * @author Francois Pellegrini
15  * @author Pierre Ramet
16  * @author Mathieu Faverge
17  * @date 2021-01-03
18  *
19  **/
20 #include "common.h"
21 #include "symbol/symbol.h"
22 
23 /**
24  *******************************************************************************
25  *
26  * @ingroup pastix_symbol
27  *
28  * @brief Checks the consistency of the given symbolic block matrix.
29  *
30  * Because of incomplete factorization, from version 1.0, no check is performed
31  * regarding the existence of facing blocks in facing columns.
32  *
33  * @todo Complete test set to check the brow information
34  *
35  *******************************************************************************
36  *
37  * @param[in] symbptr
38  * The symbol structure to check.
39  *
40  *******************************************************************************
41  *
42  * @retval 0 if the symbol matrix is correct
43  * @retval 1 if incorrect
44  *
45  *******************************************************************************/
46 int
47 pastixSymbolCheck(const symbol_matrix_t * const symbptr)
48 {
49  pastix_int_t baseval; /* Base value */
50  const symbol_cblk_t *cblktax; /* Based access to cblktab */
51  pastix_int_t cblkmax; /* Maximum column block index */
52  pastix_int_t cblknum; /* Based number of current column block */
53  const symbol_blok_t *bloktax; /* Based access to bloktab */
54  pastix_int_t blokmax; /* Maximum block index */
55  pastix_int_t bloknum; /* Based number of current block */
56  pastix_int_t nodemax; /* Maximum node index */
57 
58  baseval = symbptr->baseval;
59  cblktax = symbptr->cblktab - baseval;
60  cblkmax = symbptr->cblknbr + (baseval - 1);
61  bloktax = symbptr->bloktab - baseval;
62  blokmax = symbptr->bloknbr + baseval;
63  nodemax = symbptr->nodenbr;
64 
65  for (cblknum = bloknum = baseval;
66  cblknum <= cblkmax; cblknum ++) {
67  if ((cblktax[cblknum].fcolnum < baseval) ||
68  (cblktax[cblknum].lcolnum > nodemax) ||
69  (cblktax[cblknum].bloknum > blokmax) ||
70  (cblktax[cblknum].fcolnum > cblktax[cblknum].lcolnum) ||
71  ((cblktax[cblknum].brownum != -1) &&
72  (cblktax[cblknum + 1].brownum < cblktax[cblknum].brownum))||
73  (cblktax[cblknum + 1].fcolnum-1 != cblktax[cblknum].lcolnum) ||
74  (cblktax[cblknum + 1].bloknum <= cblktax[cblknum].bloknum))
75  {
76  pastix_print_error( "symbolCheck: invalid column block array" );
77  assert(0);
78  return (1);
79  }
80 
81  if ((bloktax[bloknum].frownum != cblktax[cblknum].fcolnum) ||
82  (bloktax[bloknum].lrownum != cblktax[cblknum].lcolnum) ||
83  (bloktax[bloknum].fcblknm != cblknum)) {
84  pastix_print_error( "symbolCheck: invalid diagonal block" );
85  assert(0);
86  return (1);
87  }
88 
89  for (bloknum ++; bloknum < cblktax[cblknum + 1].bloknum; bloknum ++) {
90  if ((bloktax[bloknum].lcblknm != cblknum) ||
91  (bloktax[bloknum].fcblknm < baseval) ||
92  (bloktax[bloknum].fcblknm > cblkmax) ||
93  (bloktax[bloknum].frownum <= bloktax[bloknum - 1].lrownum) ||
94  (bloktax[bloknum].fcblknm < bloktax[bloknum - 1].fcblknm)) {
95  pastix_print_error( "symbolCheck: invalid block array" );
96  assert(0);
97  return (1);
98  }
99  }
100  }
101 
102  assert( (cblktax[cblknum].brownum == -1) ||
103  (cblktax[cblknum].brownum == (symbptr->bloknbr - symbptr->cblknbr)) );
104 
105  /* Check that schur starts within the symbol */
106  if ( (symbptr->schurfcol < 0) || (symbptr->schurfcol > (symbptr->nodenbr + 1)) ) {
107  pastix_print_error( "symbolCheck: invalid schurfcol" );
108  assert(0);
109  return (1);
110  }
111  return (0);
112 }
symbol_matrix_s
Symbol matrix structure.
Definition: symbol.h:75
symbol_matrix_s::schurfcol
pastix_int_t schurfcol
Definition: symbol.h:80
symbol_matrix_s::bloktab
symbol_blok_t * bloktab
Definition: symbol.h:82
symbol_cblk_s::fcolnum
pastix_int_t fcolnum
Definition: symbol.h:44
symbol_matrix_s::nodenbr
pastix_int_t nodenbr
Definition: symbol.h:79
symbol_matrix_s::cblknbr
pastix_int_t cblknbr
Definition: symbol.h:77
symbol_matrix_s::baseval
pastix_int_t baseval
Definition: symbol.h:76
symbol_matrix_s::bloknbr
pastix_int_t bloknbr
Definition: symbol.h:78
symbol_cblk_s::bloknum
pastix_int_t bloknum
Definition: symbol.h:46
symbol_cblk_s::brownum
pastix_int_t brownum
Definition: symbol.h:47
symbol.h
symbol_cblk_s::lcolnum
pastix_int_t lcolnum
Definition: symbol.h:45
pastixSymbolCheck
int pastixSymbolCheck(const symbol_matrix_t *symbptr)
Checks the consistency of the given symbolic block matrix.
Definition: symbol_check.c:47
symbol_matrix_s::cblktab
symbol_cblk_t * cblktab
Definition: symbol.h:81
symbol_blok_s
Symbol block structure.
Definition: symbol.h:57
symbol_cblk_s
Symbol column block structure.
Definition: symbol.h:43