<div class="gmail_quote">On Mon, May 30, 2011 at 16:16, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com">knepley@gmail.com</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 Sun, May 29, 2011 at 2:19 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org" target="_blank">jed@59a2.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<a href="http://petsc.cs.iit.edu/petsc/petsc-dev/rev/f7baf28c7a57" target="_blank">http://petsc.cs.iit.edu/petsc/petsc-dev/rev/f7baf28c7a57</a><div><br></div><div>The second argument to pow() and variants that might be called through PetscPowScalar() has scalar type. Int should be promoted to scalar. Does it just need "1.0*i" to deal with some C++ case where promotion is not automatic? Casting to a specific sort of int here is really weird.</div>


</blockquote></div><br></div>From the signature and compiler error, that second argument 'p' is PetscInt. If PetscInt is 64-bit, there is no overloaded<div>method. I did not promote it to Scalar because that seriously slows down the code.</div>
</blockquote><div><br></div><div>C++ has overloaded std::pow() to accept an integer power. C does not have a "pow" with an integer exponent, but many compilers generate special case code if the argument is known at compile time (not in this case, but can see it's an int if it checks before promotion).</div>
<div><br></div><div>I guess the question is: what is PetscPowScalar() supposed to be? I have always thought it was a wrapper for the math.h pow() specified by the C standard, but polymorphic to operate on arbitrary PetscScalar. If you want a (scalar)^(integer) function, maybe it should be called PetscPowScalarInt(). I don't think the PowInt typedef is a good general solution.</div>
</div>