octave-maintainers
[Top][All Lists]
Advanced

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

Re: How to use the OO features of Octave


From: David Bateman
Subject: Re: How to use the OO features of Octave
Date: Tue, 23 Sep 2008 23:08:04 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080725)

David Bateman wrote:
David Bateman wrote:
John W. Eaton wrote:
>
>      args(2) = num_indices;
>      args(1) = index_position;
>      args(0) = *indexed_object;


shouldn't args(1) be

args(1) = index_position + 1;

due to the 1-based indexing of Octave?

D.


Also shouldn't we subtract one from the return value of the feval call?

D.



Ok, I see the return value should be minus one, but index_pos definitely needs to be. As far as I can see a pretty generic NDArray end method would look like


function r = end (obj, index_pos, num_indices)
  ++index_pos;
  dv = size (obj.x);
  for i = num_indices + 1 : length (dv)
    dv(num_indices) *= dv(i);
  endfor
  if (index_pos < length (dv))
    r = dv (index_pos);
  elseif
    r = 1;
  endif
endfunction


though the "++index_pos;" should go away if F__end__ was adapted to pass "index_pos + 1". However, this doesn't work correctly with the toy class What I see is

a = gf (floor(4*rand(3,3,2)),2);

a(1,1:end)

ans =
GF(2^2) array. Primitive Polynomial = D^2+D+1 (decimal 7)

Array elements =

0

and

a(1,1,1:end)

ans =
GF(2^2) array. Primitive Polynomial = D^2+D+1 (decimal 7)

Array elements =

0

Not sure what is going wrong but the first of the above should produce 6 elements and the second 2 elements, but both produce 1. Any ideas?

On a related note "a(:)" on the class object works correctly, but "a(1,:)" and "a(:,1)" etc don't

D.




reply via email to

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