[petsc-dev] What was the 64-bit problem with pow()?

Jed Brown jed at 59A2.org
Wed Jun 1 03:48:28 CDT 2011


On Wed, Jun 1, 2011 at 04:56, Matthew Knepley <knepley at gmail.com> wrote:

> I did not want to downcast because PetscPow() works for (Scalar, Int) and
> (Scalar, Real) so automatically casting to (int) is not right.


1. There is no PetscPow()  :-)

2. In C, PetscPowScalar *always* has arguments (PetscScalar, PetscScalar),
*not* (PetscScalar,PetscReal), (PetscScalar, int), or other variants. The
fact that it "works" with other combinations is only because of C's
automatic promotion rules. C++ has different promotion rules and overloads
the name for (PetscScalar, int).

This still isn't (PetscScalar, PetscInt). Indeed, if PetscInt is int64_t,
then PetscPowScalar(some_scalar, some_int) fails. That is the problem you
fixed by introducing PowInt. But PowInt is always defined to be int, either
by explicit typedef (with PETC_USE_64BIT_INDICES) or indirectly (because
PetscInt was already typedef'd to int). So "typedef int PowInt" will always
be equivalent to what you have.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110601/b7c6cbf4/attachment.html>


More information about the petsc-dev mailing list