Fixed. Cheers.
On Sunday, August 6, 2017 at 12:23:57 PM UTC+10, Michael Jones wrote:
>
> Great. Hope it helps. I had a typo in power 0 (which is never called.
> Change the return to 1.0.
>
> On Sat, Aug 5, 2017 at 6:50 PM wrote:
>
>> Thanks, Michael.
>>
>> I've created a
Great. Hope it helps. I had a typo in power 0 (which is never called.
Change the return to 1.0.
On Sat, Aug 5, 2017 at 6:50 PM wrote:
> Thanks, Michael.
>
> I've created a tiny project with those files here:
> https://github.com/cpmech/go-fast-math-experiments
>
> The output
Thanks, Peter.
I actually don't mind a larger code if the performance can be improved.
Also, we probably do computations more often with smaller integers (at
least in my applications); that's why I overlooked the case greater than
10...
But now I'm using your (+Michael Jones and others)
Dorival,
There is a great deal to learn from this issue. Some interesting issues:
Exponentiation by arbitrary real or complex powers is a little complicated
to evaluate quickly with accuracy. Other than special cases, you're forced
toward x**y ==> Exp(y*Log(x)), where each of Exp() and Log() are
Dorival Pedroso,
PowP has a lot of code. PowG is simpler and it is modestly slower for small
values of n and much faster for larger values of n.
func PowG(x float64, n uint32) float64 {
y := 1.0
for i := n; i > 0; i >>= 1 {
if i&1 == 1 {
y *= x
}
x *=
Since my ASM skills are limited, for positive integers, I'm planning on
using:
// PowP computes real raised to positive integer xⁿ
func PowP(x float64, n uint32) (r float64) {
if n == 0 {
return 1.0
}
if n == 1 {
return x
}
if n == 2 {
return x * x
}
if n == 3 {
return x * x * x
}
if n == 4 {
r
again i'm wrong :(
On Friday, August 4, 2017 at 10:30:14 AM UTC+3, Sebastien Binet wrote:
>
>
>
> On Fri, Aug 4, 2017 at 9:24 AM, wrote:
>
>> Ok,
>> i'm not right,pow in C is :
>> float powf(float x, float y);
>>long double powl(long double
>>
>> use float32 pow for
On Fri, Aug 4, 2017 at 9:24 AM, wrote:
> Ok,
> i'm not right,pow in C is :
> float powf(float x, float y);
>long double powl(long double
>
> use float32 pow for proper comparison or use powl for C double wersion.
>
C'pow is with doubles (like Go's math.Pow):
Ok,
i'm not right,pow in C is :
float powf(float x, float y);
long double powl(long double
use float32 pow for proper comparison or use powl for C double wersion.
This is demonstartion how when you use go long time, you lose ability to
read other languages :)
On Friday, August 4,
You are comparing apples to oranges( integer vs float64 pow),
use integer pow and compare again:
func Pow(a, b int) int {
p := 1
for b > 0 {
if b&1 != 0 {
p *= a
}
b >>= 1
a *= a
10 matches
Mail list logo