[petsc-dev] [petsc-users] ublas sparse matrix bindings?

Aron Ahmadia aja2111 at columbia.edu
Sat Jul 3 07:41:53 CDT 2010


"C++ templates are pretty much inadequate for this because you would want to
flatten the recursive types (not to mention the error message and
compilation time insanity)."

Lets take the error message and compilation time insanity as an aside for
now.

I am not sure I  understand your argument here (I apologize if I talk past
you, please feel free to clarify).  I am surmising from the rest of your
paragraph that you feel it would be most beneficial to users to have the
full flexibility of mixed-precision with matrices/vectors, i.e. A = A1 + A2,
where A1 is single-precision and A2 is double-precision.  The layer at which
you express your linear algebra algorithms should be unaware of the data
that composes a given matrix A.  Dynamic polymorphism (what PETSc uses)
combined with template programming has the potential to allow this sort of
mixed-precision abstraction.  You could do this in C, but I think you would
be copy-pastaing a lot of low-level code, i.e. you would have to write
separate routines ahead of time for every scalar type you would like to
support if you would like to be able to use them simultaneously.

A

On Fri, Jul 2, 2010 at 9:45 PM, Jed Brown <jed at 59a2.org> wrote:

> On Tue, 29 Jun 2010 15:26:38 -0500, Matthew Knepley <knepley at gmail.com>
> wrote:
> > I am not so sure here. Our problem is not with type parametrization so
> much
> > I think (since MatScalar is there)
> > but with mixing this with another value type. I suspect that a templated
> > version would have 1G of compiler
> > errors right now.
>
> PETSc's philosophy often involves moving the solver to the highest level
> of control (instead of rolling loops around the solver as an ad-hoc way
> to answer a question of interest).  If you have matrices/vectors with
> different scalar type/precision, then you would naturally want entries
> of mixed type within single matrices and vectors (and usually mixed type
> within blocks associated with nodes/cells of your discretization).  C++
> templates are pretty much inadequate for this because you would want to
> flatten the recursive types (not to mention the error message and
> compilation time insanity).
>
> Jed
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20100703/fa48efaf/attachment.html>


More information about the petsc-dev mailing list