<div dir="ltr">"<meta charset="utf-8">C++ templates are pretty much inadequate for this because you would want to<br>flatten the recursive types (not to mention the error message and<br>compilation time insanity)."<br>
<br><div>Lets take the error message and compilation time insanity as an aside for now.</div><div><br></div><div>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. </div>
<div><br></div><div>A</div><div><br><div class="gmail_quote">On Fri, Jul 2, 2010 at 9:45 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, 29 Jun 2010 15:26:38 -0500, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>
> I am not so sure here. Our problem is not with type parametrization so much<br>
> I think (since MatScalar is there)<br>
> but with mixing this with another value type. I suspect that a templated<br>
> version would have 1G of compiler<br>
> errors right now.<br>
<br>
</div>PETSc's philosophy often involves moving the solver to the highest level<br>
of control (instead of rolling loops around the solver as an ad-hoc way<br>
to answer a question of interest). If you have matrices/vectors with<br>
different scalar type/precision, then you would naturally want entries<br>
of mixed type within single matrices and vectors (and usually mixed type<br>
within blocks associated with nodes/cells of your discretization). C++<br>
templates are pretty much inadequate for this because you would want to<br>
flatten the recursive types (not to mention the error message and<br>
compilation time insanity).<br>
<font color="#888888"><br>
Jed<br>
</font></blockquote></div><br></div></div>