octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improved triu.m and tril.m


From: Marco Caliari
Subject: Re: Improved triu.m and tril.m
Date: Fri, 23 Oct 2009 09:52:50 +0200 (CEST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

using cellslices + vertcat + reshape is faster still:

 m = min (nc, nr+k);
 ii = max (1, (1:m) - k);

 sl(2,:) = cellslices (x(:), ii, nr*ones (1, m));
 sl(1,:) = cellslices (zeros (nr, 1), ones (1, m), ii - 1);

 retval = reshape (vertcat (sl{:}), nr, nc);

Great, even if, it does not work for me... I think the problem is related to what I get with 3.2.3

octave:1> cellslices([1,2],1,0)
error: subscript indices must be either positive integers or logicals.

Maybe the result should be

{
  [1,1] = [](1x0)
}

Also this appears strange to me

octave:1> cellslices([1,2,3],[2,3],[1,1])
error: invalid range used as index.

Out of interest, do you depend on triu/tril efficiency in an application?

Not really. I had a code with fft and matrix manipulations and it was slower in Octave than in Matlab just because of a final triu.

Cheers,

Marco


reply via email to

[Prev in Thread] Current Thread [Next in Thread]