Inefficient handling of sparse matrices by the norm function
David Bateman
adb014 at gmail.com
Thu Dec 6 13:43:35 CST 2007
Jason Riedy wrote:
> And Nir Krakauer writes:
>
>> octave-2.9.15:3> tic; anorm2 = max(max(abs(A))); toc %does the same
>> thing
>>
>
> That is not the inf-norm of a matrix A. Try max(sum(abs(A),2)).
>
> On a highly loaded laptop:
> octave:1> A = spdiag(rand(4E4, 1));
> octave:2> tic; anorm = norm(A, 'inf'); toc
> Elapsed time is 17.899139 seconds.
> octave:3> tic; anorm = max(sum(abs(A),2)); toc
> Elapsed time is 16.222046 seconds.
>
> Considering I have multiple compiles running, the difference
> well within noise.
>
> I'm sure MATLAB(tm)'s sparse routines often are faster,
> particularly in special cases. That's what happens with more
> developer time and funding.
>
Yes, but still pathetic.. The issue is that the sum function is
converting the matrix to full before doing the summation. I'm working on
a patch
D.
More information about the Bug-octave
mailing list