473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Strange behaviour of Numeric Float32 array?

Hi,

the code:

from Numeric import *

def my_minimum(a):
n=shape(a)[0]
x = 1.0e20
for i in range(n):
if a[i] < x:
x = a[i]
return x

def strange(a):
a[3] = -6303.0
h = my_minimum(a)
for i in range(10):
print i,a[i],
a[i] = a[i] - h
print a[i],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
Jul 12 '06 #1
0 1135

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
Hi, I don't understand this strange behaviour: I compile this code : #include <Python.h> #include"Numeric/arrayobject.h" static PyObject *
45
by: Jordan Rastrick | last post by:
Can anybody please give me a decent justification for this: class A(object): def __init__(self, a): self.a = a def __eq__(self, other): return self.a == other.a s = A(3)
5
by: Levent | last post by:
Hi, When compiled with gcc 3.3.3 and lower on various systems (tried cygwin, linux, aix) the following code behaves strangely: #include <iostream> class Foo { public: typedef int subs;
3
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
3
by: Trevor.Dhu | last post by:
I am just starting to use python, and as such my question may well be a bit simplistic. I am currently trying to write what should be a very basic set of routines for reading and writing to a...
33
by: Lalatendu Das | last post by:
Dear friends, I am getting a problem in the code while interacting with a nested Do-while loop It is skipping a scanf () function which it should not. I have written the whole code below. Please...
0
by: David Socha | last post by:
I am looking for a way to determine the maxium array size I can allocate for arrays of Float32 values (or Int32, or Int8, ...) at an arbitrary point in the program's execution. This is needed...
8
by: mantrid | last post by:
Hello Im having problems working out why the following code does not work. I dont think its the sql as the error occurs on the first update which ever one is put there ($q1 or $q2). Ive swapped...
3
by: Iljya | last post by:
Hello, I need to pickle the type numpy.float32 but encounter an error when I try to do so. I am able to pickle the array itself, it is specifically the type that I cannot pickle. I am using:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.