MatGetSubMatrix_MPIDense()

Matthew Knepley knepley at gmail.com
Tue Jan 20 19:34:46 CST 2009


That fixes a bug since the the data is actually stored with leading
dimension lda, rather
than nlrows.

  Matt

On Tue, Jan 20, 2009 at 7:27 PM, Yujie <recrusader at gmail.com> wrote:
> Dear Barry and Matthew:
>
> I always fingure out what's wrong with MatGetSubMatrix_MPIDense() in my
> application. Because I use other pacakges based on PETSc, it is difficult to
> change my PETSc2.3.3 to 3.0.0. I have to debug my codes to find something.
>
> Now, I have confirmed the question is in "*bv++ = av[irow[j] - rstart];" of
>
> (PETSC2.3.3)
>
> /* Now extract the data pointers and do the copy, column at a time */
> 245: newmatd = (Mat_MPIDense*)newmat->data;
> 246: bv = ((Mat_SeqDense *)newmatd->A->data)->v;
> 247:
> 248: for (i=0; i<ncols; i++) {
> 249: av = v + nlrows*icol[i];
> 250: for (j=0; j<nrows; j++) {
> 251: *bv++ = av[irow[j] - rstart];
> 252: }
> 253: }
>
> The codes generate an error of segmentation violation.
>
> I have checkec PETsc3.0.0 version. the corresponding codes are:
>
> 220: /* Now extract the data pointers and do the copy, column at a time */
> 221: newmatd = (Mat_MPIDense*)newmat->data;
> 222: bv = ((Mat_SeqDense *)newmatd->A->data)->v;
> 223:
> 224: for (i=0; i<ncols; i++) {
> 225: av = v + ((Mat_SeqDense *)newmatd->A->data)->lda*icol[i];
> 226: for (j=0; j<nrows; j++) {
> 227: *bv++ = av[irow[j] - rstart];
> 228: }
> 229: }
>
> why change "nlrows" to "((Mat_SeqDense *)newmatd->A->data)->lda"? After I
> revise the codes in PETsc2.3.3, the error disappears. However, the results
> from my codes become wrong. Could you give me some advice? thanks a lot.
>
> Regards,
>
> Yujie
>
>



-- 
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



More information about the petsc-users mailing list