Mentions légales du service

Skip to content
Snippets Groups Projects

Update solver.py to control the symmetry of the sparse matrix and Schur matrix

Closed POIREL Louis requested to merge lpoirel/pastix:patch-2 into master
1 unresolved thread

Added a symmetry option to the object constructor:

  • False/0 -> general matrix (LU)
  • True/1 -> symmetric (LDLT, not implemented so fall back to LU)
  • 2 -> SPD (LLT)

By default, even when a symmetric factorization is used, a full S (L and U) is returned. To override and get only the L part of S, use schur(full_matrix=False)

Merge request reports

Checking pipeline status.

Approval is optional

Closed by Mathieu FavergeMathieu Faverge 7 years ago (Feb 6, 2018 11:07am UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
27 29 self.iparm[iparm.verbose] = verbose.Yes
28 30 else: # 1 or True or anything else, default value
29 31 self.iparm[iparm.verbose] = verbose.No
32
33 self.sym = kwargs.setdefault("symmetry", 0)
34 if not self.sym: # 0 or False, general
35 self.factotype = factotype.LU
36 elif self.sym==2: # Symmetric positive definite
37 self.factotype = factotype.LLT
38 else: # 1 or True, symmetric
39 self.factotype = factotype.LDLT # Not implemented
40 print("LDLT not supported yet in Pastix, fall back to LU")
41 self.factotype = factotype.LU
42 self.iparm[iparm.factorization] = self.factotype
43
  • Why using symmetry for the kwargs, and not factorization to use names from iparm ?

  • And to go further the symmetry is already stored in the spm.

  • Author Contributor

    because it is easier to understand symmetry = True/False (/2 pour SPD) than symmetry = 0 -> SPD 1 -> symmetric 2 -> general 3 -> hermitian

    I think it is more pythonic to give a named parameter in the constructor than to force the user to go look through enum.py to change the iparm himself.

    For me, spm is the internal format and I don't want to know anything about it to perform a solve on a scipy matrix.

  • yes, but what I say is just give the parameter name, the enum names it corresponds to. Otherwise, you get lost in the code, if you name it one factorization, once symmetry, once toto, once titi, it makes the code readability harder.

    And second, you could use the type of the matrix to configure the default, that is overwritten by the factorization parameter.

  • Author Contributor

    I think the factorization type in the solver is only a consequence of the symmetry of the problem. As a user, I don't care what type of factorization you do, but I am OK with giving you hints on my problem to help the solver go faster. As a user, I won't know what value to put in a parameter named "factotype". Whereas it is quite easier to give a "symmetry" boolean value.

    As for the type of the matrix, the Solver class will only be called on scipy matrices. Spm is only the internal format. I don't know how to handle spm. The sym attribute of Solver is not about the format of the matrix, but about which methods can be called.

    A typical user will just want to give a full scipy matrix (L+U), a rhs and get the solution. If it helps the solver go faster, he might be OK with telling the solver that the matrix is symmetric. But a typical python user will not want to provide only half the entries of A to call a symmetric factorization.

  • Please register or sign in to reply
  • Mathieu Faverge
  • POIREL Louis added 1 commit

    added 1 commit

    • 18ff4659 - Update solver.py space and parentheses in a condition

    Compare with previous version

  • Integrated in pastix/pastix!103

  • Please register or sign in to reply
    Loading