[petsc-users] Problem in MatSetValues

Matthew Knepley knepley at gmail.com
Mon Mar 11 08:28:12 CDT 2019


On Mon, Mar 11, 2019 at 9:22 AM Eda Oktay <eda.oktay at metu.edu.tr> wrote:

> Dear Matt,
>
> I understood that you are right. I changed sizeof(values) with ncols, it
> gives matrix correctly.
>
> However, now I get an error in EPSGetEigenpair:
>

You have to check how many _eigenvalues_ converged. It sounds like it is
less than 2.

  Matt


> 0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Argument out of range
> [0]PETSC ERROR: Argument 2 out of range
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
> for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.10.3, Dec, 18, 2018
> [0]PETSC ERROR: ./ENYENI_FINAL on a arch-linux2-c-debug named
> 70a.wls.metu.edu.tr by edaoktay Mon Mar 11 16:17:25 2019
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
> --with-fc=gfortran --with-cxx-dialect=C++11 --download-openblas
> --download-metis --download-parmetis --download-superlu_dist
> --download-slepc --download-mpich
> [0]PETSC ERROR: #1 EPSGetEigenpair() line 398 in
> /home/edaoktay/petsc-3.10.3/arch-linux2-c-debug/externalpackages/git.slepc/src/eps/interface/epssolve.c
>
> I understood from this error that the matrix does not converge. However, I
> tested in MATLAB and it converges. The matrix is true now, so this cannot
> be from the matrix.
>
> Thanks,
>
> Eda
>
> Eda Oktay <eda.oktay at metu.edu.tr>, 11 Mar 2019 Pzt, 16:07 tarihinde şunu
> yazdı:
>
>> Dear Matt,
>>
>> I printed in wrong state, ncols gives right solution.
>>
>> But I still can't understand the first problem.
>>
>> Eda
>>
>> Eda Oktay <eda.oktay at metu.edu.tr>, 11 Mar 2019 Pzt, 16:05 tarihinde şunu
>> yazdı:
>>
>>> Dear Matt,
>>>
>>> Thank you for answering. First of all, sizeof(vals) returns to number of
>>> entries, I checked. Secondly, I found a problem:
>>>
>>> ncols gives me 6.95328e-310. However, I checked the matrix L, it was
>>> computed properly.
>>>
>>> Why can ncols give such a value?
>>>
>>> Thanks,
>>>
>>> Eda
>>>
>>> Matthew Knepley <knepley at gmail.com>, 11 Mar 2019 Pzt, 15:56 tarihinde
>>> şunu yazdı:
>>>
>>>> On Mon, Mar 11, 2019 at 8:27 AM Eda Oktay via petsc-users <
>>>> petsc-users at mcs.anl.gov> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have a following part of a code which tries to change the nonzero
>>>>> values of matrix L with -1. However in MatSetValues line, something happens
>>>>> and some of the values in matrix turns into 1.99665e-314 instead of -1.
>>>>> Type of arr is defined as PetscScalar and arr is produced correctly. What
>>>>> can be the problem, is there a mistake about types?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Eda
>>>>>
>>>>>
>>>>> for(rw = mm; rw<nn; ++rw){
>>>>>
>>>>>             ierr = MatGetRow(L,rw,&ncols,&cols,&vals);CHKERRQ(ierr);
>>>>>
>>>>>             s = sizeof(vals);
>>>>>
>>>>
>>>> This is wrong. sizeof(vals) gives bytes, not entries. Why don't you
>>>> just use ncols here?
>>>>
>>>>   Matt
>>>>
>>>>
>>>>>             ierr = PetscMalloc1(s,&arr);CHKERRQ(ierr);
>>>>>
>>>>>             for(j=0;j<s;++j){
>>>>>
>>>>>                 arr[j]=-1.0;
>>>>>             }
>>>>>             ierr =
>>>>> MatSetValues(NSymmA,1,&rw,ncols,cols,arr,INSERT_VALUES);CHKERRQ(ierr);
>>>>>             ierr =
>>>>> MatRestoreRow(L,rw,&ncols,&cols,&vals);CHKERRQ(ierr);
>>>>>         }
>>>>>
>>>>
>>>>
>>>> --
>>>> 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/>
>>>>
>>>

-- 
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-users/attachments/20190311/81e7a6da/attachment.html>


More information about the petsc-users mailing list