Update solver.py to control the symmetry of the sparse matrix and Schur matrix
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
Activity
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 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.
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.
- Resolved by POIREL Louis
added 1 commit
- 18ff4659 - Update solver.py space and parentheses in a condition