[IronPython] n-dimensional array

Aravin avinhan at gmail.com
Mon Nov 16 08:30:33 CET 2009


Thank you Michael for your quick response.

I started to write my own implementation of an n-dimensional array.
Currently I have only implemented __getitem__. You can pass in slice like in
numpy. E.g.

>>>from IronMath import ndarray
>>>a = ndarray(range(36), (6,6))
>>>print a
[[0,	1,	2,	3,	4,	5],
[6,	7,	8,	9,	10,	11],
[12,	13,	14,	15,	16,	17],
[18,	19,	20,	21,	22,	23],
[24,	25,	26,	27,	28,	29],
[30,	31,	32,	33,	34,	35]]
>>>b = a[1:5:2, :]
>>>print b
[[6,	7,	8,	9,	10,	11],
[18,	19,	20,	21,	22,	23]]
>>>b.Shape
(2, 6)
>>>b.Shape = (3,4)
>>>print b
[[6,	7,	8,	9],
[10,	11,	18,	19],
[20,	21,	22,	23]]
>>>c = b[:, [0,2,3]]
>>>print c
[[6,	8,	9],
[10,	18,	19],
[20,	22,	23]]


Im using a List<object> to hold the values internally. I'm not sure if this
is the best possible way in terms of speed. I'm also attaching the source
for the ndarray class. Can someone give me some pointers on optimization
aspects? Should I make it generic like ndarray<T>?

I know this class has a long way to go, but if anyone is interested in it
maybe I can set up a project on CodePlex and work on it? It could become a
base for a math library for IronPython.

Regards,
Aravin


-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Friday, November 13, 2009 7:18 PM
To: Discussion of IronPython
Subject: Re: [IronPython] n-dimensional array

Aravin wrote:
>
> Hello everyone,
>
> I'm developing an application for my research project. I'm using 
> IronPython as a scripting engine to allow easy data manipulation like 
> Matlab. I require a high performance n-dimensional array class. Does 
> anyone know of any .net library which provides a powerful 
> n-dimensional array?
>
> I would like to do slicing operations on the array like in NumPy. 
> (A[:2, :5] etc.)
>
I doubt you will find a .NET library that supports slicing in the same 
way as numpy...

You might try looking at Math.NET though:

http://www.mathdotnet.com/About.aspx

> And also things like ones(.) zeros(.). I tried to use NumPy with 
> Ironclad but im having some issues
>

Have you reported those issues?

All the best,

Michael Foord
>
> and would prefer if I could have a .net/ Ironpython ndarray library. 
> Can you please recommend me any such library? Thanks
>
> Aravin
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ndarray.cs
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20091116/97080401/attachment.ksh>


More information about the Ironpython-users mailing list