But if it does not makes sense from your point to give a full matrix, why 
does it make more sense to return a diagonal matrix? It is still lots of 
heap allocated memory. So you replace a large performance trap with a 
smaller one. What has been gained? We would still have to teach people the 
eye should not be used because there is a faster alternative.

Am Montag, 29. August 2016 18:04:15 UTC+2 schrieb Chris Rackauckas:
>
> As Julio asks, why should the default be a dense identity matrix? Who 
> actually wants to use that? I agree `I` should be in more visible in the 
> docs and in most cases it's the better option. But if you actually want a 
> matrix as an array instead of just an operator (this is reasonable, because 
> maybe you're going to modify it), then a Diagonal matrix is sufficient for 
> storing any identity matrix and should be the only thing used in most 
> cases. If you really want a dense matrix from it, you could always call 
> full(A). But there's almost no reason to have a dense identity matrix, and 
> so Julia shouldn't be defaulting to it because it's just a performance trap 
> for new users coming from MATLAB.
>
> On Monday, August 29, 2016 at 8:31:13 AM UTC-7, Kristoffer Carlsson wrote:
>>
>> What is the confusion? Use eye(n) if you want a dense identity matrix. 
>> Use I if you want something that acts like an identity element. Use 
>> Diagonal(ones(n)) if you want a diagonal identity matrix. I see no reason 
>> at all why eye should be changed.
>>
>> On Monday, August 29, 2016 at 4:32:34 PM UTC+2, Chris Rackauckas wrote:
>>>
>>> But you don't want a sparse matrix. It would not be an efficient way to 
>>> actually use it since sparse matrices have a bit of overhead due to their 
>>> table structure. Even better would be a Diagonal since it's just an array 
>>> with dispatches to act like a diagonal matrix. But best would be to use the 
>>> UniformScaling operator `I` which acts like eye in cases like A-λI but 
>>> isn't actually saving a matrix and doesn't actually require iterating over 
>>> two arrays at once. I think that amount of confusion in this thread is a 
>>> good indicator that eye should be changed.
>>>
>>> On Monday, August 29, 2016 at 7:25:49 AM UTC-7, Kristoffer Carlsson 
>>> wrote:
>>>>
>>>> You mean a sparse matrix?
>>>
>>>

Reply via email to