1

I am referring to the The Compute Step section in Eigen documentation:

In the compute() function, the matrix is generally factorized:

....

For this class of solvers precisely, the compute step is further subdivided into analyzePattern() and factorize().

The goal of analyzePattern() is to reorder the nonzero elements of the matrix, such that the factorization step creates less fill-in. This step exploits only the structure of the matrix. Hence, the results of this step can be used for other linear systems where the matrix has the same structure. ....

In factorize(), the factors of the coefficient matrix are computed. This step should be called each time the values of the matrix change. However, the structural pattern of the matrix should not change between multiple calls.

The documentation for analyzePattern()

Compute the column permutation to minimize the fill-in

  • Apply this permutation to the input matrix -
  • Compute the column elimination tree on the permuted matrix
  • Postorder the elimination tree and the column permutation

and factorize()

Numerical factorization Interleaved with the symbolic factorization On exit, info is

= 0: successful factorization

0: if info = i, and i is

<= A->ncol: U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.

A->ncol: number of bytes allocated when memory allocation failure occurred, plus A->ncol. If lwork = -1, it is the estimated amount of space needed, plus A->ncol.

My question is, do we know the relative cost of calling analyzePattern() and factorize()?

This question is important to me because my application has a stable matrix structure but constantly changing coefficient matrix. Example: in FEM model, FEM users often leave the element connection unchanged, but always change the element sizes in order to get the best design.

So if analyzePattern() is a lot expensive than factorize(), then I can take advantage of this fact and rewrite my code. If no, I can just stick to the compute() function and rerun analyzePattern() every time the element sizes change.

Graviton
  • 81,782
  • 146
  • 424
  • 602
  • 1
    Why not measure the difference for your specific pattern and decide based on that? – Avi Ginsburg Mar 07 '17 at 09:24
  • @AviGinsburg, I can. But I guess it will benefit the internet at large if the performance of these two functions are documented ( as a SO Q&A) on the Internet. – Graviton Mar 07 '17 at 09:27

1 Answers1

1

That depends a lot on the structure of the matrix. In my experience, the symbolic part is usually much cheaper than the numerical part, however, according to a comment to this answer, it is sometimes the converse. So I'm afraid you'll never know for sure until you bench.

Community
  • 1
  • 1
ggael
  • 28,425
  • 2
  • 65
  • 71
  • may I ask, what do you use sparse solver for? Mine is finite element model. – Graviton Mar 08 '17 at 00:29
  • 1
    Same here, but the structure will still depend a lot on the dimension of the domain (1D, 2D, 3D) and kinds of elements. – ggael Mar 08 '17 at 14:27