> I see what you mean about the multidimensionality I am happy to be helpful. :-)
> should ArrayComprehension(...) + ArrayComprehension(...) work to add the corresponding elements? That is a good point. As far as I know, the addition of two ArrayComprehension doesn't make sense. So it would possibly not support such type of operations. However, its output, if it is expanded to be an Array, supports these vetorized operations. That is to say, we can perform ArrayComprehension().doit() + ArrayComprehension().doit() if neither of them has symbolic dimensions. Frankly, based on the argumentation of Aaron, I am a little bit confused about defining this class then. Maybe a multidimensional list? 在 2019年6月5日星期三 UTC+2上午7:10:06,Aaron Meurer写道: > > Does it support vectorized operations, e.g., should > ArrayComprehension(...) + ArrayComprehension(...) work to add the > corresponding elements? If so, then it's an array. If not, then it's > more like a list or tuple. > > Aaron Meurer > > On Tue, Jun 4, 2019 at 6:52 AM Chris Smith <[email protected] <javascript:>> > wrote: > >> > >> As you can see, `ArrayComprehension` is more likely to be a such > structure: [[[...]...]...]. > > > > > > Ahh...I see what you mean about the multidimensionality, now. It is a > reshaped list comprehension: > > > > >>> reshape([i + j for i in range(4) for j in range(3) for k in > range(2)], [[2]]*3) > > [[[0, 0], [1, 1], [2, 2]], [[1, 1], [2, 2], [3, 3]], [[2, 2], [3, > 3], [4, 4]], [[3, 3], [4, 4], [5, 5]]] > > >>> _==S(str(ArrayComprehension(i+j > ,(i,0,3),(j,0,2),(k,0,1)).doit())) > > True > > > > So I see the reason not to call it a List. > > > > On Tuesday, June 4, 2019 at 4:23:20 AM UTC-5, Zhiqi KANG wrote: > >> > >> Hi, > >> > >> As far as I know, the difference between `ArrayComprehension` and > `list` lies in the notion of multidimensionality. > >> > >> First of all, for clarification, > >> > >> > `List(i + j, (i,0,3), (j,0,4))` is the unevaluated form of `[i + j > for i in range(4) for j in range(5)]`. > >> > >> is not quite true regarding the implementation of `ArrayComprehension`. > In fact, `ArrayComprehension(i + j, (i,0,3), (j,0,4))` will be like `[[i + > j for i in range(5)] for j in range(4)]`. Not to mention the different > order of dimensions because the limits in `ArrayComprehension` are executed > from left to right, the resulting output is a multidimensional list. So > each time there is one more limit, the dimension of output list will +1. As > you can see, `ArrayComprehension` is more likely to be a such structure: > [[[...]...]...]. This multidimensionality comes from Table in Wolfram > Mathematica, which is the the example of the implementation of > `ArrayComprehension`. > >> > >> Secondly, the implementation follows the example of `Array` module in > SymPy, which means the properties and functions like `shape`, `rank()` have > been already implemented.Plus, its output is of type > `ImmutableDenseNDimArray`. Since an array has by default a notion of > multidimensionality, it would be more coherent to call it as an array. > That's why its name is `ArrayComprehension` rather than > `ListComprehension`. > >> > >> However, it is no doubt that `ArrayComprehension` resembles a lot to > list. It would be a good idea to have something similar to list implemented > in SymPy, in order to add a notion of 'immutable' to list. Either renaming > ArrayComprehension or creating a new module to do so is faisible. > >> > >> That's what I have understood while implementing `ArrayComprehension`. > I hope that it could help make some concepts clear. > >> > >> Zhiqi > >> > >> > >> 在 2019年6月4日星期二 UTC+2上午5:46:03,Chris Smith写道: > >>> > >>> From discussion at #16926 where I suggest that perhaps we should be > naming ArrayComprehension as List and it was said, > >>> > >>> > [ArrayComprehension] is supposed to be a multidimensional list > comprehension > >>> > >>> It looks like an unevaluated List to me: `List(i + j, (i,0,3), > (j,0,4))` is the unevaluated form of `[i + j for i in range(4) for j in > range(5)]`. (For comparison, Integral and Sum are examples of an > unevaluated Expr, which, after a doit and the right conditions, lose the > wrapper and become other Expr.) > >>> > >>> An evaluated form would be `List([1, 2, 3, 4])` where the `[]` would > be necessary to distinguish between the evaluated and comprehension form. > >>> > >>> Are we going to regret introducing an object that is so closely > related to a list or will we always want a list to be an unsympified object > in SymPy? > >>> > >>> /c > > > > -- > > 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] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at https://groups.google.com/group/sympy. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/fbf59f35-2dc2-4d48-a79b-3643276ec8dc%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > -- 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 https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b8f994c3-5d3d-4e65-a770-22d448b7e958%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
