Hello,

the code I wrote to add N-dim arrays to SymPy is (almost) ready. The only 
point is the order of the constructor arguments.

https://github.com/sympy/sympy/pull/10180

Four classes are provided:

   - MutableDenseNDimArray
   - MutableSparseNDimArray
   - ImmutableDenseNDimArray
   - ImmutableSparseNDimArray

Immutable ones are SymPy objects (they subclass *Expr*), mutable ones are 
not. The structure loosely reflects the matrix module.



*The remaining issue: argument order*Currently the dimensions should 
preceed the iterable, that is, construction would be like:

In [1]: from sympy.tensor.array import *

In [2]: from sympy import *

In [3]: a = ImmutableDenseNDimArray(2, 3, 4, range(2*3*4))

In [4]: a
Out[4]: [[[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]], [[12, 13, 14, 15], [
16, 17, 18, 19], [20, 21, 22, 23]]]



SymPy matrices specify dimensions before the iterable:


In [5]: Matrix(2, 3, range(6))
Out[5]: 
Matrix([
[0, 1, 2],
[3, 4, 5]])


I thought it would be a good idea to preserve that order. Unfortunately, 
being the number of dimensions variable, one cannot (prior to Python 3.5) 
use the shortened form *ImmutableDenseNDimArray(*dims, iterable)*.

*Do you think we should postpone the dimensions?*

That is:

ImmutableDenseNDimArray(iterable, *dims)

instead of

ImmutableDenseNDimArray(dim1, dim2, ... , iterable)

Consider that the different standard used in matrices could be resolved by 
adding a new argument order in the matrix construction, e.g. by allowing an 
expression like *Matrix(range(6), 2, 3)* to mean *Matrix(2, 3, range(6))*.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/0e7a8ec8-2de0-4be3-b526-fa67ddbcf1e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to