LADEL main
Sparse LDL factorization package with rank 1 and rowadd/rowdel updates
ladel_etree.c
Go to the documentation of this file.
1#include "ladel_types.h"
2#include "ladel_global.h"
3#include "ladel_constants.h"
4#include "ladel_debug_print.h"
5
7{
8 if (!M || !sym || !work) return FAIL;
9
10 ladel_int *etree = sym->etree;
11 ladel_int index, row, col, next;
12 ladel_int *ancestor = work->array_int_ncol1;
13
14 for (col = 0; col < M->ncol; col++)
15 {
16 etree[col] = NONE;
17 ancestor[col] = NONE;
18 LADEL_FOR(index, M, col)
19 {
20 row = M->i[index];
21 for (; row < col; row = next)
22 {
23 next = ancestor[row];
24 ancestor[row] = col;
25 if (next == NONE)
26 {
27 etree[row] = col;
28 break;
29 }
30 }
31 }
32 }
33
34 return SUCCESS;
35}
36
37#ifdef LADEL_SIMPLE_COL_COUNTS
39{
40 if (!M || !sym || !work) return FAIL;
41
42 ladel_int *etree = sym->etree, *col_counts = sym->col_counts;
43
44 ladel_int index, row, col, next, ncol = M->ncol;
45 ladel_int *touched = work->array_int_ncol1;
46
47 for (col = 0; col < ncol; col++)
48 {
49 col_counts[col] = 0;
50 touched[col] = NONE;
51 }
52
53 for (col = 0; col < ncol; col++)
54 {
55 etree[col] = NONE;
56 touched[col] = col;
57 LADEL_FOR(index, M, col)
58 {
59 row = M->i[index];
60 for (; row < col && touched[row] != col; row = next)
61 {
62 col_counts[row]++;
63 touched[row] = col;
64 next = etree[row];
65 if (next == NONE)
66 {
67 etree[row] = col;
68 break;
69 }
70 }
71 }
72 }
73
74 for (col = 1; col < ncol; col++) col_counts[col] += col_counts[col-1];
75 return col_counts[ncol-1];
76}
77#endif
#define NONE
Indicates a root (a node without parent), or an untouched node.
#define SUCCESS
For status returns.
#define FAIL
For status returns.
#define LADEL_FOR(index, M, col)
Loop through a column of a sparse matrix.
Constants and macros used in LADEL.
Routines to print out matrices and vectors.
ladel_int ladel_etree_and_col_counts(ladel_sparse_matrix *M, ladel_symbolics *sym, ladel_work *work)
Computes the elimination tree and column counts of a matrix.
Definition: ladel_etree.c:38
ladel_int ladel_etree(ladel_sparse_matrix *M, ladel_symbolics *sym, ladel_work *work)
Computes the elimination tree of a matrix.
Definition: ladel_etree.c:6
Memory allocation routines.
Structures and types used in LADEL routines.
int64_t ladel_int
Type for integer numbers (default: int64_t)
Definition: ladel_types.h:24
Sparse matrix in compressed column storage.
Definition: ladel_types.h:35
ladel_int ncol
number of columns
Definition: ladel_types.h:38
ladel_int * i
row pointers (size nzmax)
Definition: ladel_types.h:41
Structure capturing symbolic information used for and during the factorization.
Definition: ladel_types.h:54
ladel_int * etree
eliminations tree
Definition: ladel_types.h:56
ladel_int * col_counts
column counts, stored as column pointers
Definition: ladel_types.h:58
Workspace required for various routines in LADEL.
Definition: ladel_types.h:109
ladel_int * array_int_ncol1
An array of ncol integers.
Definition: ladel_types.h:116