[petsc-dev] Matrix Manipulation Question

Barry Smith bsmith at petsc.dev
Tue Apr 11 13:09:56 CDT 2023


   There is a bug in the design of MATLRC, it should have a MatLRCSetMats() that takes Mat U, Vec c, Mat V.  

   Then the convenience constructor MatCreateLRC() would call this method so no code duplication.

   Your code would then properly be 

   
  TSComputeIJacobian(ts, ..., A0, B, ...)
>   MatSetType(A0, MATLRC)
>   MatLRCSetMats(A0, U, NULL, V)

  convenience constructors should NEVER be the only way to get data into an object. That "need the information when you instantiate the object" model of OOP is horrible and sadly kind of tied into some languages OOP model. We don't do this. 

  Just fix the MATLRC API.

  Barry


> On Apr 11, 2023, at 1:34 PM, Matthew Knepley <knepley at gmail.com> wrote:
> 
> I want to modify the Jacobian inside an IJacobian call. Right now I just have
> 
>   TSComputeIJacobian(ts, ..., A, B, ...)
> 
> but I want to do
> 
>   TSComputeIJacobian(ts, ..., A0, B, ...)
>   MatCreateLRC(A0, U, NULL, V, &A)
> 
> However, the MatCreateLRC() needs a Mat *, so what I really want is to do something like
> 
>   TSComputeIJacobian(ts, ..., A, B, ...)
>   MatCreateLRC(A, U, NULL, V, &Anew)
>   <copy implementation of Anew into A>
> 
> Isn't there a function for this?
> 
>   Thanks,
> 
>      Matt
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
> 
> https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20230411/659ef5fe/attachment.html>


More information about the petsc-dev mailing list