Nonsense.

On Tue, Feb 11, 2014 at 6:54 PM, Stefan Karpinski <[email protected]>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 Tue, Feb 11, 2014 at 9:06 PM, Kevin Squire <[email protected]>wrote:
>
>> 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 <
>>> [email protected]> 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) vector, deleting, and
>>>> then reshaping back.  Since the reshaping cheap and in-place, this is
>>>> reasonably efficient.
>>>>
>>>
>>> Unfortunately, that doesn't actually work.  It used to be that Julia
>>> would throw an error when trying to modify the size of a vector which was
>>> an alias for a multidimensional array (when did that change?).  Now, it
>>> just makes a copy:
>>>
>>> julia> A = [1 2 3]
>>> 1x3 Array{Int64,2}:
>>>  1  2  3
>>>
>>> julia> pointer(A)
>>> Ptr{Int64} @0x0000000004db2550
>>>
>>> julia> a = reshape(A, 3)
>>> 3-element Array{Int64,1}:
>>>  1
>>>  2
>>>  3
>>>
>>> julia> pointer(a)
>>> Ptr{Int64} @0x0000000004db2550
>>>
>>> julia> deleteat!(a, 2)
>>> 2-element Array{Int64,1}:
>>>  1
>>>  3
>>>
>>> julia> pointer(a)
>>> Ptr{Int64} @0x000000000396ebd8
>>>
>>> julia> a = rand(3)
>>> 3-element Array{Float64,1}:
>>>  0.91121
>>>  0.274773
>>>  0.248093
>>>
>>> julia> pointer(a)
>>> Ptr{Float64} @0x0000000011df0a60
>>>
>>> julia> deleteat!(a, 2)
>>> 2-element Array{Float64,1}:
>>>  0.91121
>>>  0.248093
>>>
>>> julia> pointer(a)
>>> Ptr{Float64} @0x0000000011df0a60
>>>
>>> Cheers,
>>>    Kevin
>>>
>>
>

Reply via email to