From: Paul K. <pki...@us...> - 2005-11-21 01:55:40
|
On Nov 18, 2005, at 10:31 PM, William Poetra Yoga H wrote: > --- Paul Kienzle <pki...@us...> wrote: > >> I'm not sure that use of cell2mat and cellfun improves either speed or >> readability. >> > > While speed may suffer a bit, I think it's more readable (no need to > loop by > ourselves). > >> Regardless, the following test looks incorrect: >> >> + if (! all (cellfun ("ndims", varargin))) >> + error ("All of the arguments to blkdiag must be two dimensional >> matrices"); >> + endif >> > > Sorry, my fault. I didn't check for n-dimensional arrays (which should > return > an error). Btw, thanks, (I think) I found a few bugs in cellfun. > > The new diff to blkdiag.m is attached. Please send the new version of blkdiag to John Eaton for inclusion in Octave. You should use @ndims rather than 'ndims'. Please add some test cases to the end, such as %!assert(blkdiag(1,ones(2),1),[1,0,0,0;0,1,1,0;0,1,1,0;0,0,0,1]) Thanks, - Paul |