[petsc-users] [Ext] Question on SLEPc + computing SVD with a "matrix free" matrix

Jose E. Roman jroman at dsic.upv.es
Thu Jun 25 01:37:25 CDT 2020


Here is an example that creates a shell matrix with a C struct as a context:
https://www.mcs.anl.gov/petsc/petsc-current/src/mat/tests/ex203.c.html

Or if you use Fortran:
https://www.mcs.anl.gov/petsc/petsc-current/src/mat/tutorials/ex6f.F90.html

Jose


> El 25 jun 2020, a las 8:28, Ernesto Prudencio <EPrudencio at slb.com> escribió:
> 
> I didn't know about this "shell matrix" concept. I will take a look.
> 
> Best,
> 
> Ernesto.
> 
> 
> Schlumberger-Private
> 
> -----Original Message-----
> From: Jose E. Roman [mailto:jroman at dsic.upv.es] 
> Sent: Thursday, June 25, 2020 1:26 AM
> To: Ernesto Prudencio <EPrudencio at slb.com>
> Cc: petsc-users at mcs.anl.gov
> Subject: Re: [Ext] [petsc-users] Question on SLEPc + computing SVD with a "matrix free" matrix
> 
> Another alternative is to create a shell matrix C with a user context that contains both A and B, then MatMult(C) calls MatMult(A) and MatMultTranspose(C) calls MatMult(B).
> 
> 
>> El 25 jun 2020, a las 8:23, Ernesto Prudencio <EPrudencio at slb.com> escribió:
>> 
>> Thank you, Jose.
>> 
>> However, in the case of a "matrix free" matrix, the APIs on PETSc seem to allow just the implementation of A.v, not of A' . w
>> 
>> One could create another "matrix free" matrix B which could make the role of computing z = B . w = A' . w. But how could one force the routine MatMultTranspose(A, w, z) to call the routine for B? Here I am assuming that MatMultTranspose(A, w, z) is the routine that SLEPc calls internally in its algorithms when the user sets for implicit transpose.
>> 
>> I see two possibilities (for brain storming, since I don't know if such approaches would be acceptable for the PETSc team and/or the SLEPc team):
>> 1) PETSc could add an entry for a second routine that computes [ A' . w ] when calling MatMFFDSetFunction()
>> 2) SLEPc could add an entry for the routine for computing [ A' . w ] when the matrix A is "matrix free"
>> 
>> Thanks again,
>> 
>> Ernesto.
>> 
>> 
>> Schlumberger-Private
>> 
>> -----Original Message-----
>> From: Jose E. Roman [mailto:jroman at dsic.upv.es] 
>> Sent: Thursday, June 25, 2020 1:01 AM
>> To: Ernesto Prudencio <EPrudencio at slb.com>
>> Cc: petsc-users at mcs.anl.gov
>> Subject: [Ext] Re: [petsc-users] Question on SLEPc + computing SVD with a "matrix free" matrix
>> 
>> Yes, you have to set it with SVDSetImplicitTranspose(), but then the matrix-free matrix should implement both "A.v" and "A'.v" operations.
>> Jose
>> 
>> 
>>> El 24 jun 2020, a las 23:25, Ernesto Prudencio via petsc-users <petsc-users at mcs.anl.gov> escribió:
>>> 
>>> Hi,
>>> 
>>> Is it possible to compute a SVD for a “matrix free” matrix?
>>> 
>>> At first, it seems it would be ok with a MatCreateMFFD() and MatMFFDSetFunction(), because one could then provide the routine that computes “A . v” for any given v, which is an operation needed by SLEPc. However, one would also need to set up the SVD object in SLEPc with an implicit transpose. Would that be possible?
>>> 
>>> Thanks in advance,
>>> 
>>> Ernesto.
>>> 
>>> Schlumberger-Private



More information about the petsc-users mailing list