← Back to team overview

dolfin team mailing list archive

Re: assemebling process for a trilinearform

 

On Tue, Jan 22, 2008 at 03:19:20PM +0100, Martin Sandve Alnæs wrote:
> 2008/1/22, Anders Logg <logg@xxxxxxxxx>:
> > On Tue, Jan 22, 2008 at 03:05:45PM +0100, Anne Voigt wrote:
> > > Thank you for the fast answer.
> > >
> > > Am Dienstag, den 22.01.2008, 11:38 +0100 schrieb Anders Logg:
> > > > On Tue, Jan 22, 2008 at 11:09:27AM +0100, Anne Voigt wrote:
> > > > >
> > > > > Thank you. I now try to write my own Tensor by deriving from the
> > > > > GenericTensor class. Could you write me some information about the interface?
> > > > > Especially what the parameters of the function
> > > > > GenericTensor::get(..) and GenericTensor::set(..) are? It is not clear
> > > > > for me and I cannot find a documentation about it.
> > > > >
> > > > > Regards,
> > > > > Anne
> > > >
> > > >   virtual void set(const real* block,
> > > >                    const uint* num_rows,
> > > >                    const uint* const * rows) = 0;
> > > >
> > > > block is an array with values to be set
> > > >
> > > > num_rows is an array of length rank()
> > > >
> > > > num_rows[i] is the number of "rows" to be set for axis i
> > > >
> > > > rows[i] is an array with the "rows" to be set for axis i
> > > >
> > > > the length of the array block is num_rows[0]*num_rows[1]*...
> > > >
> > > > For a matrix (rank = 2), the values will be set according to
> > > >
> > > >   for (int i = 0; i < num_rows[0]; ++i)
> > > >     for (int j = 0; j < num_rows[1]; ++j)
> > > >       A[rows[i], rows[j]] = block[i*num_rows[1] + j];
> > >
> > > When I understood it correctly, the last line should be:
> > >
> > > A[rows[0][i], rows[1][j]] = block[i*num_rows[1] + j];
> > >
> > > Is this correct or did I a mistake?
> >
> > Correct, my mistake.
> 
> Of course, you didn't literally mean to write "A[i,j]" in C++, which
> won't do what it looks like, and can be difficult to debug, since it
> actually compiles. The binary operator "," evaluates to one (the
> first?) of the values.

Yes, good point. It's partly pseudo-code.

-- 
Anders


References