Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Stefan Karpinski
On Mon, Sep 29, 2014 at 6:25 PM, Art Kuo wrote: > I am interpreting this to mean that LLVM can't optimize as well if it > doesn't know the size of the array. I would be tempted to say that arrays > should ideally be kept fast when people aren't resizing, but nevertheless > allow resizing with per

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Tim Holy
I think the point is this: rather than implementing it for arrays, with the risk of performance problems that Stefan highlighted, why not implement it for array views? If we do it through views (which don't modify the underlying memory), we can give users this behavior and guarantee that we won'

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Art Kuo
I am interpreting this to mean that LLVM can't optimize as well if it doesn't know the size of the array. I would be tempted to say that arrays should ideally be kept fast when people aren't resizing, but nevertheless allow resizing with perhaps a sizable performance penalty when it is used. As

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Stefan Karpinski
An important but non-obvious consideration is that resizeability of arrays makes it much harder to eliminate bounds checks. As it is, there are cases where code for vectors is slower than code for arrays with any other dimensionality because only vectors can change size. Adding this one feature

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Tim Holy
On Monday, September 29, 2014 10:00:28 AM Art Kuo wrote: > Third, consider > implementing A[:, ![3,5]] if possible. We're now very close to having this be possible. See #8501. --Tim

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Viral Shah
For operations that require lots of additions/deletions of rows from matrices, perhaps we should have something like ChainedVectors. https://github.com/tanmaykm/ChainedVectors.jl I don't know how important it is to put in all that effort into a data structure that supports this effectively, and

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-09-29 Thread Art Kuo
I would like to revive this discussion. I understand that it's not terribly efficient to add/delete a row from a matrix, but this is a case where some syntactic sugar could really help. Here are a couple arguments for it. 1. Control systems people use this feature in Matlab a lot. This is a

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Jason Pries
You are correct. That's essentially what I'm doing ATM. That particular step has never been a bottle-neck in any of my Matlab code. Doing things in place in nice when you can, but I'm not going to ruminate over it too much. On Wednesday, February 12, 2014 4:45:36 PM UTC-5, Steven G. Johnson wrot

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Steven G. Johnson
On Wednesday, February 12, 2014 3:41:21 PM UTC-5, Jason Pries wrote: > > FWIW, The place I use this the most is when solving PDEs using finite > elements with Dirichlet/Periodic boundary conditions. If I want to preserve > the symmetry of the matrix before factorization, I end up needing to del

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Stefan Karpinski
Interesting. Now that's a compelling use case. On Wed, Feb 12, 2014 at 3:41 PM, Jason Pries wrote: > FWIW, The place I use this the most is when solving PDEs using finite > elements with Dirichlet/Periodic boundary conditions. If I want to preserve > the symmetry of the matrix before factorizat

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Jason Pries
FWIW, The place I use this the most is when solving PDEs using finite elements with Dirichlet/Periodic boundary conditions. If I want to preserve the symmetry of the matrix before factorization, I end up needing to delete some rows and columns. I could write the code to create the matrix the way

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Stefan Karpinski
The reason for "special cases" is that arrays in Julia really serve two very different purposes: a highly flexible array/stack/dequeue data structure and tensors of arbitrary dimension for linear algebra. The array/stack/dequeue use case requires the ability to grow and shrink and remove elements f

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Iain Dunning
I'm sure you know this, but I think you are failing to acknowledge in this discussion is that everything is a tradeoff when dealing with memory representations of tensors. The reality is always going to be that the machine organizes everything internally one way, and languages paper over that t

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Don Gateley
On Wednesday, February 12, 2014 8:32:42 AM UTC-8, Stefan Karpinski wrote: > > On Wed, Feb 12, 2014 at 3:28 AM, Don Gateley > > wrote: > >> Nonsense. >> > > It would be much more helpful (not to mention polite) to make an actual > counter argument. Given a convincing argument for a feature like

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Stefan Karpinski
On Wed, Feb 12, 2014 at 3:28 AM, Don Gateley wrote: > Nonsense. > It would be much more helpful (not to mention polite) to make an actual counter argument. Given a convincing argument for a feature like this, it may very well get implemented and included in the language. Given "Nonsense", I for

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Andreas Lobinger
Hello colleagues, i couldn't track down, where the Nonsense applies, but in general (also in Matlab) it's better for organizing the data in a fixed array and track down, what you access from that. This helps the computer/language system. However, it's not fully uncommon to formulate algorithms

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-12 Thread Don Gateley
Nonsense. On Tue, Feb 11, 2014 at 6:54 PM, Stefan Karpinski wrote: > It could be made to work but it's generally not a good idea to delete > random slices of arrays generally isn't a good idea for performance > reasons. It's better to design an algorithm that doesn't need to do this. > > > On Tu

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-11 Thread Stefan Karpinski
It could be made to work but it's generally not a good idea to delete random slices of arrays generally isn't a good idea for performance reasons. It's better to design an algorithm that doesn't need to do this. On Tue, Feb 11, 2014 at 9:06 PM, Kevin Squire wrote: > This thread has a few more de

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-11 Thread Kevin Squire
This thread has a few more details on why deleting from the middle of an array isn't easy: https://groups.google.com/forum/#!topic/julia-users/B4OUYPFM5L8 Kevin On Tuesday, February 11, 2014 4:55:02 PM UTC-8, Kevin Squire wrote: > > On Tue, Feb 11, 2014 at 4:45 PM, Steven G. Johnson > wrote: >

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-11 Thread Kevin Squire
On Tue, Feb 11, 2014 at 4:45 PM, Steven G. Johnson wrote: > On Friday, November 30, 2012 7:46:46 AM UTC-5, Stefan Karpinski wrote: >> >> To clarify [1 2 3] is a row-matrix, rather than a vector and cannot have >> an element excised from it. > > > You could delete by reshaping to a column (1d) vect

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-11 Thread Steven G. Johnson
On Friday, November 30, 2012 7:46:46 AM UTC-5, Stefan Karpinski wrote: > > To clarify [1 2 3] is a row-matrix, rather than a vector and cannot have > an element excised from it. You could delete by reshaping to a column (1d) vector, deleting, and then reshaping back. Since the reshaping chea

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-11 Thread Don Gateley
On Friday, November 30, 2012 4:46:46 AM UTC-8, Stefan Karpinski wrote: > > To clarify [1 2 3] is a row-matrix, rather than a vector and cannot have > an element excised from it. > > Is that an architectural problem or just implementation lag?

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-10 Thread Kevin Squire
On Mon, Feb 10, 2014 at 10:45 AM, Steven G. Johnson wrote: > On Monday, February 10, 2014 1:42:56 PM UTC-5, Steven G. Johnson wrote: >> >> On Thursday, November 29, 2012 3:24:50 PM UTC-5, Jeff Bezanson wrote: >>> >>> We have del(x, i) and del(x, i:j). We could add del(x, I) where I is a >>> vector

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-10 Thread Steven G. Johnson
On Monday, February 10, 2014 1:42:56 PM UTC-5, Steven G. Johnson wrote: > > > > On Thursday, November 29, 2012 3:24:50 PM UTC-5, Jeff Bezanson wrote: >> >> We have del(x, i) and del(x, i:j). We could add del(x, I) where I is a >> vector, but we can't do it any faster than >> for i in I del(x,i)

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-10 Thread Steven G. Johnson
On Thursday, November 29, 2012 3:24:50 PM UTC-5, Jeff Bezanson wrote: > > We have del(x, i) and del(x, i:j). We could add del(x, I) where I is a > vector, but we can't do it any faster than > for i in I del(x,i) end Why can't it be done faster? Presumably you could move all of the non-delete

Re: [julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-10 Thread Tim Holy
On Sunday, February 09, 2014 09:22:55 PM Jason Pries wrote: > but this isn't ideal since (I assume) it involves allocating > additional memory for A[!I,!J] as an intermediate step. In Matlab, it allocates new memory for the array, too: >> format debug >> A = zeros(5,3) A = Structure address =

[julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-10 Thread RecentConvert
I ran into this same problem recently as well. This is a hard Matlab habit to break and none of the solutions is intuitive. My solution involves preallocating a boolean array and then looping through the actual data checking which values I need to keep. At the end I use the boolean array to fil

[julia-users] Re: Howto: Julia x[I] = [] ?? vs Matlab x(I) = []

2014-02-09 Thread Jason Pries
I recently ran into this issue. For future reference, this functionality seems to have been renamed to splice! julia> x = [1,2,3] 3-element Array{Int64,1}: 1 2 3 julia> splice!(x,2) 2 julia> x 2-element Array{Int64,1}: 1 3 I use the idiom A(I,:) = []; A(:,J) = []; a lot in Mat