[Numpy-discussion] C-API: How is data filling done in PyArray_SimpleNewFromData ?
Raspaud Martin
martin.raspaud at smhi.se
Tue Oct 27 08:43:54 EDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I’m using numpy v1.2.0, and I have the following codes that provide
different results :
- ---------------------
cal = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_FLOAT);
for(i=0;i<dims[0];i++)
for(j=0;j<dims[1];j++)
{
*((npy_float *)PyArray_GETPTR2(cal,i,j))=(npy_float)in[i][j];
}
- ---------------------
and
- ---------------------
cal = (PyArrayObject *)PyArray_SimpleNewFromData(2,dims,NPY_FLOAT,in);
- ---------------------
As you probably guessed, "in" is a 2D array of floats of dimensions "dims".
My questions are thus:
- - Why do the two methods provide different results ?
- - How do I get the second to behave like the first ?
Thanks,
Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJK5usJAAoJEBdvyODiyJI4YWwH/1VyfpeVVfI0/VfcVJ4L064z
cWbqI4WOpDeYZmFIKLQfuVWwlEkQzbe7AQTxDiy3kR1iL93d6af0+YiLCaURdx9X
yv3P7VE+i5clr6jqpESLngkl15LT8aJBzlI/UJL6UnrVBiKYAQ0XSFVdAWChOLE/
VtnEMNxbb5ZHqAwBhmjD/fldG9OwSODpq0yOudVgk1VWTQd1M4AESypY7QGFPod2
Exu83zm3ZVLzOvHjBE8yVOjVTlgm2hPBWMDySazz6owMh3XBCMMMz9rN3H4XQ0CJ
2R3bN22sJm363D2DlauHoTAMuAz8958fPzMFYVFxdSXZBH2V6Ck8Q3fi4MA/fnI=
=h7J3
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20091027/34122264/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: martin_raspaud.vcf
Type: text/x-vcard
Size: 260 bytes
Desc: martin_raspaud.vcf
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20091027/34122264/attachment.vcf>
More information about the NumPy-Discussion
mailing list