R
Rolf Wester
Hi,
the code:
from Numeric import *
def my_minimum(a):
n=shape(a)[0]
x = 1.0e20
for i in range(n):
if a < x:
x = a
return x
def strange(a):
a[3] = -6303.0
h = my_minimum(a)
for i in range(10):
print i,a,
a = a - h
print a,h
a = zeros(10,Float32)
strange(a)
b = zeros(10,Float64)
strange(b)
produces the output:
0 0.0 6303.0 -6303.0
1 0.0 6303.0 -6303.0
2 0.0 6303.0 -6303.0
3 -6303.0 0.0 0.0
4 0.0 0.0 0.0
5 0.0 0.0 0.0
6 0.0 0.0 0.0
7 0.0 0.0 0.0
8 0.0 0.0 0.0
9 0.0 0.0 0.0
0 0.0 6303.0 -6303.0
1 0.0 6303.0 -6303.0
2 0.0 6303.0 -6303.0
3 -6303.0 0.0 -6303.0
4 0.0 6303.0 -6303.0
5 0.0 6303.0 -6303.0
6 0.0 6303.0 -6303.0
7 0.0 6303.0 -6303.0
8 0.0 6303.0 -6303.0
9 0.0 6303.0 -6303.0
Can anybody tell me why in the Float32 version h is changed?
Thank you in advance.
Regards
Rolf
the code:
from Numeric import *
def my_minimum(a):
n=shape(a)[0]
x = 1.0e20
for i in range(n):
if a < x:
x = a
return x
def strange(a):
a[3] = -6303.0
h = my_minimum(a)
for i in range(10):
print i,a,
a = a - h
print a,h
a = zeros(10,Float32)
strange(a)
b = zeros(10,Float64)
strange(b)
produces the output:
0 0.0 6303.0 -6303.0
1 0.0 6303.0 -6303.0
2 0.0 6303.0 -6303.0
3 -6303.0 0.0 0.0
4 0.0 0.0 0.0
5 0.0 0.0 0.0
6 0.0 0.0 0.0
7 0.0 0.0 0.0
8 0.0 0.0 0.0
9 0.0 0.0 0.0
0 0.0 6303.0 -6303.0
1 0.0 6303.0 -6303.0
2 0.0 6303.0 -6303.0
3 -6303.0 0.0 -6303.0
4 0.0 6303.0 -6303.0
5 0.0 6303.0 -6303.0
6 0.0 6303.0 -6303.0
7 0.0 6303.0 -6303.0
8 0.0 6303.0 -6303.0
9 0.0 6303.0 -6303.0
Can anybody tell me why in the Float32 version h is changed?
Thank you in advance.
Regards
Rolf