Problem with using ADD_VALUES
Matthew Knepley
knepley at gmail.com
Mon Aug 6 06:26:15 CDT 2007
1) You could use MatZeroEntries() to zero out the matrix
2) You could call MatAssembly*(m, MAT_ASSEMBLY_FLUSH) in
between INSERT and ADD.
MAtt
On 8/6/07, Ben Tay <zonexo at gmail.com> wrote:
> Hi,
>
> I am trying to insert values into a matrix. I used to use INSERT_VALUES
> with MatSetValues or MatSetValue. However, since I need to add values to
> the same II,JJ location more than 1 time, I have to use ADD_VALUES with
> MatSetValues.
>
> However I got this error message:
>
> Object is in wrong state!
> Cannot mix add values and insert values!
>
> My code is something like this:
>
> call MatSetValues(A_mat,1,II,1,JJ,0.,INSERT_VALUES,ierr) ->
> to reset values at II,JJ to zero 1st
>
> ...
>
> do JJ=1,5
>
> call
> MatSetValues(A_mat,1,II,1,int_A(m,JJ)-1,big_A(m,JJ),ADD_VALUES,ierr)
> -> to put values into the matrix, with the possibility
> of adding values to the same II,JJ locations more than once.
>
> end do
>
> How can I solve this problem?
>
> Thanks.
>
>
--
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