octave-maintainers
[Top][All Lists]
Advanced

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

Re: Request for indexing fix


From: David Bateman
Subject: Re: Request for indexing fix
Date: Thu, 14 Jun 2007 02:04:35 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

John W. Eaton wrote:
> On 14-Jun-2007, David Bateman wrote:
> 
> | Matlab allows the following code
> | 
> | x = randn(2,2,2);
> | idx(1:3) = {1};
> | idx(1) =';';
> | x(idx{:})
> | 
> | This is a really nice feature and I used it in the spline code I
> | committed. However, it seems that Octave doesn't allow this, and so the
> | ND spline code is in fact partially broken. I therefore suggest the
> | attached patch. One point however is that this means that x(':',1,1)
> | will give the same result, and without access to matlab at the moment
> | I'm unsure what matlab in fact does in this case.
> 
> I was hoping that indexing with char variables only worked for the
> special case of ':', but unfortunately not.  Compare
> 
>   x = 1:100;
> 
>   x(char (57))  -->  57
>   x(char (58))  -->  1:100

Is that with matlab? If so then the proposed patch is compatible,

> 
> It seems like another "diag" problem to me.  Did they really think
> this through before they implemented it?  So although it may seem
> convenient in some instances, I have to disagree that this is a nice
> feature.
> 
> If it is necessary to have, then I suppose we can do it and I think
> your patch is sufficient.  If there are any complaints about it (maybe
> there will be none, which is probably what the MathWorks were betting
> on) we can just say "blame Matlab".

Well I could replace

idx(1) = ":"

with

idx(1) = 1:size(x,1);

but if matlab accepts the previous version, this will probably come up
again as a bug sometime in the future. Tell me what you want to do and
I'll make the fix either way...

D.




> 
> jwe
> 



reply via email to

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