0

如何cholmod_factor在超节点 LL^T 因式分解中乘以 L?我不希望转换为单纯的,因为超节点表示会导致更快的反解,并且我不希望复制该因子,因为两个副本可能不适合 RAM。

4

1 回答 1

1

我最终从t_cholmod_change_factor.c. 我转述评论并在下面添加一些细节:

超节点 Cholesky 因式分解表示为超节点块的集合。超节点块的条目按列主要顺序排列,如下面的 6x4 超节点:

t - - -    (row s[pi[snode+0]])
t t - -    (row s[pi[snode+1]])
t t t -    (row s[pi[snode+2]])
t t t t    (row s[pi[snode+3]])
r r r r    (row s[pi[snode+4]])
r r r r    (row s[pi[snode+5]])
  • 有未使用的条目(由连字符表示)以使矩阵成为矩形。
  • 列索引是连续的。
  • 第一ncols行索引是那些相同的连续列索引。后面的行索引可以引用t三角形下方的任何行。
  • 成员对super每个超级节点都有一个条目;它指的是由超级节点表示的第一列。
  • 成员对pi每个超级节点都有一个条目;它指的是s成员中的第一个索引,您可以在其中查找行号。
  • 成员对px每个超级节点都有一个条目;它指的x是存储条目的成员中的第一个索引。同样,这不是打包存储。

以下用于乘以 a 的代码cholmod_factor *L似乎有效(我只关心int索引和双精度实数条目):

cholmod_dense *mul_L(cholmod_factor *L, cholmod_dense *d) {
  int rows = d->nrow, cols = d->ncol;
  cholmod_dense *ans = cholmod_allocate_dense(rows, cols, rows,
      CHOLMOD_REAL, &comm);
  memset(ans->x, 0, 8 * rows * cols);

  FOR(i, L->nsuper) {
    int *sup = (int *)L->super;
    int *pi = (int *)L->pi;
    int *px = (int *)L->px;
    double *x = (double *)L->x;
    int *ss = (int *)L->s;

    int r0 =  pi[i], r1 =  pi[i+1], nrow = r1 - r0;
    int c0 = sup[i], c1 = sup[i+1], ncol = c1 - c0;
    int px0 = px[i];

    /* TODO: Use BLAS instead. */
    for (int j = 0; j < ncol; j++) {
      for (int k = j; k < nrow; k++) {
        for (int l = 0; l < cols; l++) {
          ((double *)ans->x)[l * rows + ss[r0 + k]] +=
              x[px0 + k + j * nrow] * ((double *)d->x)[l*rows+c0 + j];
        }
      }
    }
  }
  return ans;
}
于 2014-08-04T23:48:07.670 回答