Re: [julia-users] Size(A,n) where n > ndims(A)

2014-05-13 Thread Stefan Karpinski
Yes, I agree that this bit is inconsistent. On Tue, May 13, 2014 at 9:20 AM, Milan Bouchet-Valat wrote: > Le lundi 12 mai 2014 à 23:11 -0700, Ganesh Rapolu a écrit : > > I don't have any experience with tensors but it seems, at least on the > surface, that the convenience is not worth allowing

Re: [julia-users] Size(A,n) where n > ndims(A)

2014-05-13 Thread Milan Bouchet-Valat
Le lundi 12 mai 2014 à 23:11 -0700, Ganesh Rapolu a écrit : > I don't have any experience with tensors but it seems, at least on the > surface, that the convenience is not worth allowing the bugs that > could be prevented by enforcing 1 <= n <= ndims(A). > > However if that was the correct way to

Re: [julia-users] Size(A,n) where n > ndims(A)

2014-05-13 Thread Tim Holy
The current behavior is useful in a number of contexts; for example, you can write algorithms that take either a Vector or Matrix input without having to reshape to a matrix. Note that you can index a vector as v[i,1] without error, too. But if you have a compelling example of where this leads

Re: [julia-users] Size(A,n) where n > ndims(A)

2014-05-12 Thread Ganesh Rapolu
I don't have any experience with tensors but it seems, at least on the surface, that the convenience is not worth allowing the bugs that could be prevented by enforcing 1 <= n <= ndims(A). However if that was the correct way to do things, then I would expect this to work (viewing a scalar as a

Re: [julia-users] Size(A,n) where n > ndims(A)

2014-05-12 Thread Stefan Karpinski
Pull request: https://github.com/JuliaLang/julia/pull/6828. On Tue, May 13, 2014 at 1:35 AM, Stefan Karpinski wrote: > The idea is that you can treat lower dimensional tensors as if they were > higher dimensional with trailing singleton dimensions. Thus, if you have a > vector – i.e. an array wi

Re: [julia-users] Size(A,n) where n > ndims(A)

2014-05-12 Thread Stefan Karpinski
The idea is that you can treat lower dimensional tensors as if they were higher dimensional with trailing singleton dimensions. Thus, if you have a vector – i.e. an array with a single dimension – but you want to treat it as a matrix, you can do m, n = size(x,1), size(x,2) and it will work. Speak

[julia-users] Size(A,n) where n > ndims(A)

2014-05-12 Thread Ganesh Rapolu
For an array A if n > ndims(A), then size(A,n) currently returns 1. Is this an error or is there some reasoning behind this? It does the right thing (gives an error saying "dimension out of range") when n <= 0. Also I wanted to add that I am enjoying Julia a lot! You guys did a great job with th