Inefficient handling of sparse matrices by the norm function

Jason Riedy ejr at cs.berkeley.edu
Wed Dec 5 19:03:14 CST 2007


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.

Jason


More information about the Bug-octave mailing list