Lines Matching +full:- +full:j

11   PetscScalar *a;     /* non-zeros by column */
12 PetscInt *i, *j; /* offsets of nonzeros by column, non-zero indices by column */ member
17 PC_CP *cp = (PC_CP *)pc->data; in PCSetUp_CP()
18 PetscInt i, j, *colcnt; in PCSetUp_CP() local
20 Mat_SeqAIJ *aij = (Mat_SeqAIJ *)pc->pmat->data; in PCSetUp_CP()
23 PetscCall(PetscObjectTypeCompare((PetscObject)pc->pmat, MATSEQAIJ, &flg)); in PCSetUp_CP()
26 PetscCall(MatGetLocalSize(pc->pmat, &cp->m, &cp->n)); in PCSetUp_CP()
27 PetscCheck(cp->m == cp->n, PETSC_COMM_SELF, PETSC_ERR_SUP, "Currently only for square matrices"); in PCSetUp_CP()
29 if (!cp->work) PetscCall(MatCreateVecs(pc->pmat, &cp->work, NULL)); in PCSetUp_CP()
30 if (!cp->d) PetscCall(PetscMalloc1(cp->n, &cp->d)); in PCSetUp_CP()
31 if (cp->a && pc->flag != SAME_NONZERO_PATTERN) { in PCSetUp_CP()
32 PetscCall(PetscFree3(cp->a, cp->i, cp->j)); in PCSetUp_CP()
33 cp->a = NULL; in PCSetUp_CP()
37 if (!cp->a) PetscCall(PetscMalloc3(aij->nz, &cp->a, cp->n + 1, &cp->i, aij->nz, &cp->j)); in PCSetUp_CP()
38 PetscCall(PetscCalloc1(cp->n, &colcnt)); in PCSetUp_CP()
40 for (i = 0; i < aij->nz; i++) colcnt[aij->j[i]]++; in PCSetUp_CP()
41 cp->i[0] = 0; in PCSetUp_CP()
42 for (i = 0; i < cp->n; i++) cp->i[i + 1] = cp->i[i] + colcnt[i]; in PCSetUp_CP()
43 PetscCall(PetscArrayzero(colcnt, cp->n)); in PCSetUp_CP()
44 for (i = 0; i < cp->m; i++) { /* over rows */ in PCSetUp_CP()
45 for (j = aij->i[i]; j < aij->i[i + 1]; j++) { /* over columns in row */ in PCSetUp_CP()
46 cp->j[cp->i[aij->j[j]] + colcnt[aij->j[j]]] = i; in PCSetUp_CP()
47 cp->a[cp->i[aij->j[j]] + colcnt[aij->j[j]]++] = aij->a[j]; in PCSetUp_CP()
53 for (i = 0; i < cp->n; i++) { /* over columns */ in PCSetUp_CP()
54 cp->d[i] = 0.; in PCSetUp_CP()
55 …for (j = cp->i[i]; j < cp->i[i + 1]; j++) cp->d[i] += cp->a[j] * cp->a[j]; /* over rows in column … in PCSetUp_CP()
56 cp->d[i] = 1.0 / cp->d[i]; in PCSetUp_CP()
63 PC_CP *cp = (PC_CP *)pc->data; in PCApply_CP()
65 PetscInt i, j; in PCApply_CP() local
68 PetscCall(VecCopy(bb, cp->work)); in PCApply_CP()
69 PetscCall(VecGetArray(cp->work, &b)); in PCApply_CP()
72 for (i = 0; i < cp->n; i++) { /* over columns */ in PCApply_CP()
74 … for (j = cp->i[i]; j < cp->i[i + 1]; j++) xt += cp->a[j] * b[cp->j[j]]; /* over rows in column */ in PCApply_CP()
75 xt *= cp->d[i]; in PCApply_CP()
77 …for (j = cp->i[i]; j < cp->i[i + 1]; j++) b[cp->j[j]] -= xt * cp->a[j]; /* over rows in column upd… in PCApply_CP()
79 for (i = cp->n - 1; i > -1; i--) { /* over columns */ in PCApply_CP()
81 … for (j = cp->i[i]; j < cp->i[i + 1]; j++) xt += cp->a[j] * b[cp->j[j]]; /* over rows in column */ in PCApply_CP()
82 xt *= cp->d[i]; in PCApply_CP()
84 …for (j = cp->i[i]; j < cp->i[i + 1]; j++) b[cp->j[j]] -= xt * cp->a[j]; /* over rows in column upd… in PCApply_CP()
87 PetscCall(VecRestoreArray(cp->work, &b)); in PCApply_CP()
94 PC_CP *cp = (PC_CP *)pc->data; in PCReset_CP()
97 PetscCall(PetscFree(cp->d)); in PCReset_CP()
98 PetscCall(VecDestroy(&cp->work)); in PCReset_CP()
99 PetscCall(PetscFree3(cp->a, cp->i, cp->j)); in PCReset_CP()
105 PC_CP *cp = (PC_CP *)pc->data; in PCDestroy_CP()
109 PetscCall(PetscFree(cp->d)); in PCDestroy_CP()
110 PetscCall(PetscFree3(cp->a, cp->i, cp->j)); in PCDestroy_CP()
111 PetscCall(PetscFree(pc->data)); in PCDestroy_CP()
116 …PCCP - a "column-projection" preconditioner. Iteratively projects the current residual onto the on…
124 min || b - A(x + dx_i e_i ||_2
130 min || r - (dx_i) A e_i ||_2
132 or min || r - (dx_i) A_i ||_2
136 dx_i = (A_i^T A_i)^(-1) A_i^T r
138 This is equivalent to using Gauss-Seidel on the normal equations
146 or sequentially (similar to Gauss-Seidel/SOR). This is only coded for SOR type.
163 pc->data = (void *)cp; in PCCreate_CP()
165 pc->ops->apply = PCApply_CP; in PCCreate_CP()
166 pc->ops->applytranspose = PCApply_CP; in PCCreate_CP()
167 pc->ops->setup = PCSetUp_CP; in PCCreate_CP()
168 pc->ops->reset = PCReset_CP; in PCCreate_CP()
169 pc->ops->destroy = PCDestroy_CP; in PCCreate_CP()
170 pc->ops->view = NULL; in PCCreate_CP()
171 pc->ops->applyrichardson = NULL; in PCCreate_CP()