9 for (index = 0; index < size; index++) y[index] = x[p[index]];
15 for (index = 0; index < size; index++) y[pinv[index]] = x[index];
21 for (index = 0; index < size; index++) pinv[p[index]] = index;
26 if (*a > *b)
return 1;
32 ladel_int row, index, index_temp, xnz = x->
p[col+1] - x->
p[col];
38 if (xnz > x->
nrow / 5)
43 temp[row] = x->
x[index];
46 for (index_temp = 0; index_temp < x->
nrow; index_temp++)
48 if (temp[index_temp] != 0.0)
50 x->
i[index] = index_temp;
51 x->
x[index] = temp[index_temp];
52 temp[index_temp] = 0.0;
63 temp[row] = x->
x[index];
65 qsort(x->
i + x->
p[col], xnz,
sizeof(
ladel_int), (int (*) (
const void *,
const void *)) ladel_int_compare);
69 x->
x[index] = temp[row];
77 if (!M || !Mpp)
return;
83 ladel_int col, pcol, prow, index, pindex, prev_col_count, ncol = M->
ncol;
85 for (index = 0; index < ncol; index++) col_counts[index] = 0;
86 for (col = 0; col < ncol; col++) pinv[p[col]] = col;
87 for (col = 0; col < ncol; col++)
92 prow = pinv[M->
i[index]];
97 for (col = 1; col < ncol; col++)
99 prev_col_count = col_counts[col-1];
100 col_counts[col-1] = Mpp->
p[col-1];
101 Mpp->
p[col] = prev_col_count;
102 col_counts[col] += prev_col_count;
104 Mpp->
p[ncol] = col_counts[ncol-1];
105 col_counts[ncol-1] = Mpp->
p[ncol-1];
107 for (col = 0; col < ncol; col++)
112 prow = pinv[M->
i[index]];
115 pindex = col_counts[prow]++;
116 Mpp->
i[pindex] = pcol;
119 pindex = col_counts[pcol]++;
120 Mpp->
i[pindex] = prow;
122 if (M->
values) Mpp->
x[pindex] = M->
x[index];
#define LADEL_FOR(index, M, col)
Loop through a column of a sparse matrix.
#define LADEL_MAX(a, b)
Return the maximum of two numbers.
Constants and macros used in LADEL.
void ladel_sparse_copy(ladel_sparse_matrix *M, ladel_sparse_matrix *M_copy)
Copies a matrix (preallocated)
Memory allocation routines.
void ladel_permute_vector(ladel_double *x, ladel_int *p, ladel_int size, ladel_double *y)
Compute y, where .
void ladel_inverse_permute_vector(ladel_double *x, ladel_int *pinv, ladel_int size, ladel_double *y)
Compute y, where .
void ladel_permute_symmetric_matrix(ladel_sparse_matrix *M, ladel_int *p, ladel_sparse_matrix *Mpp, ladel_work *work)
Compute .
void ladel_invert_permutation_vector(ladel_int *p, ladel_int *pinv, ladel_int size)
Invert a permutation vector, such that .
void ladel_permute_sparse_vector(ladel_sparse_matrix *x, ladel_int col, ladel_int *p, ladel_work *work)
Permute x(:,col) in place, such that on output .
Structures and types used in LADEL routines.
int64_t ladel_int
Type for integer numbers (default: int64_t)
double ladel_double
Type for floating point numbers (default: double)
Sparse matrix in compressed column storage.
ladel_int ncol
number of columns
ladel_double * x
numerical values (size nzmax)
ladel_int * p
column pointers (size ncol+1)
ladel_int values
has numerical values
ladel_int nrow
number of rows
ladel_int * i
row pointers (size nzmax)
Workspace required for various routines in LADEL.
ladel_int * array_int_ncol2
An array of ncol integers.
ladel_int * array_int_ncol1
An array of ncol integers.
ladel_double * array_double_all_zeros_ncol1
An array of ncol doubles, on input and output this should be all zeros.