Shriram Srinivasan <[email protected]> writes: > Hi, > I have a petsc Vec object ( say length 3). I want to use its entries as > the column of a Petsc Mat (say 3x3).
PETSc Mat and Vec are not really meant for such small sizes. Some people like template libraries like Eigen if they have lots of complicated expressions involving tiny matrices/tensors, otherwise it's common to write the small loops or even unroll (you want the compiler to perform aggressive transformations on sizes this small). If you were thinking of much larger values for "3", the MatDense format uses column-oriented storage so you can use VecGetArrayRead(), then copy those columns into the contiguous storage used by MatDense. > Is there an obvious way to do this ? > I could only think of first copying the entries of the Vec into an > array with VecGetValues, and then use it to set the values of the column > of the Mat. > In case it is relevant, I am doing a sweep of a direction splitting > method over a square, and I want to store the solution (vector) of each > one dimensional problem in a Mat. > > Thanks, > Shriram
pgp_DuYvDwepm.pgp
Description: PGP signature
