Thanks Matt and Jed. After further analysis, it turns out that the operation I must perform is even more complicated than what I initially described. So direct assembly seems to be the only option. I ended up using MatGetRow and MatSetValues.
On Thu, Jul 17, 2014 at 10:53 AM, Matthew Knepley <[email protected]> wrote: > On Thu, Jul 17, 2014 at 6:35 AM, Italo Tasso < > [email protected]> wrote: > >> I have two matrices: matrix A is 4n x 4n and matrix C is n x n. I want to >> set the values of A using the values of C, like this: >> >> A[4i+k][4j+k] = C[i][j] >> 0 < i < n >> 0 < j < n >> 0 < k < 3 >> >> How can I do this efficiently? >> > > The best way to do it is to assemble directly into the big matrix. You can > do this by explicitly > translating indices, or use something like this > > > http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html > > 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 >
