help-octave
[Top][All Lists]
Advanced

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

Re: 2.1.33 changelogs/cells


From: Paul Kienzle
Subject: Re: 2.1.33 changelogs/cells
Date: Thu, 22 Feb 2001 15:58:50 +0000
User-agent: Mutt/1.2.5i

I clipped the cellget code from a more extensive (but still not complete)
cell-array support patch that I posted last year to Octave sources:

   http://www.octave.org/mailing-lists/octave-sources/2000/154

I'm not entirely certain that the function I define here will work without
the rest of my patch but it probably will, and it is a quick way to get
primitive cell support without building a patched version of Octave.  

My patch does the sort of operations you would expect on cell arrays using
(), but none of the operations which use {}.  Extening it will require changes
to the parser to distinguish () from {}, changes to ov.h and ov-base.h
to add the new type of dereferencing and changes to the parse tree to splice
cell-dereferences into function arguments like all_va_args does presently,
and to processing them intelligently when not in a function call.

I'm hoping somebody ambitious will pick up my patch and extend it where
needed, because I won't be doing so.  By the way, in my patch I overload
the nth function for lists instead of calling it cellget.  Lists would
also benefit from syntactic sugar for dereference.

Paul Kienzle
address@hidden

On Thu, Feb 22, 2001 at 04:36:13PM +0100, Gabor Zoltan Csejtey wrote:
> Hi,
> 
> There was an untested code of cellget on this list earlier:
> Some code from ov-list.cc was copied and modified to ov-cell.cc in the
> source directory of octave.
> 
> Question:  how to put this function into the octave info file?
> 
> Here's what you need to put in the ov-cell.cc file.
> 
> /*
> Date: Thu, 15 Feb 2001 17:20:56 +0000
> From: Paul Kienzle <address@hidden>
> Subject: Re: extract from cell?
> Sender: address@hidden
> 
> You could use the following untested function based on nth from ov-list.cc:
> - Paul
> */
> 
> DEFUN (cellget, args, ,
>   "-*- texinfo -*-\n\
> @deftypefn {Built-in Function} {} cellget (@var{cell}, @var{i}, @var{j})\n\
> Return the @var{i,j}-th element of @var{cell}.\n\
> @end deftypefn")
> {
>   octave_value retval;
>   int i=-1,j=-1;
>   
>   if (args.length() < 2 || args.length() > 3)
>     {
>       print_usage ("cellget");
>       return retval;
>     }
>   
>   i = args(1).int_value (true);
>   if (error_state || i < 1)
>     {
>       error ("cellget: second argument must be a positive integer");
>       return retval;
>     }
>   
>   if (args.length() == 3) 
>     {
>       j = args(2).int_value (true);
>       if (error_state || j < 1)
>         {
>           error ("cellget: third argument must be a positive integer");
>           return retval;
>         }
>     }
>   
>   Cell cell = args(0).cell_value ();
>   
>   if (! error_state)
>     {
>       int nr = cell.rows();
>       int nc = cell.columns();
>       
>       if (j == -1) 
>         if (nr == 1)
>           if (i <= nc)
>             retval = cell(0,i-1);
>           else
>             error ("cellget: index = %d out of range", i);
>         else if (nc == 1)
>           if (i <= nr)
>             retval = cell(i-1,0);
>           else
>             error ("cellget: index = %d out of range", i);
>         else
>           error ("cellget: single index not valid for 2-D cell array");
>       else if (i <= nr && j <= nc)
>         retval = cell(i-1, j-1);
>       else
>         error ("cellget: index = %d,%d out of range", i, j);
>     }
>   else
>     error ("cellget: first argument must be a cell");
> 
>   return retval;
> }
> 
> Gabor
> 
>       Date: Thu, 22 Feb 2001 16:13:10 +0100
>       From: Daniel Heiserer <address@hidden>
> 
>       Hi,
>       is there some way to find out what has changed from 2.1.33 to
>       2.1.33 without examining the diff file?
> 
>       Can 2.1.33 return the content of a cell correctly?
> 
>       If not what has to be done?
> 
>       I had the problem that I was not able to extract elements from
>       a cell into a matrix again.
> 
>       e.g. a={rand(3)};
> 
>       c=a{1};
>       c =
>       {
>         [1,1] =
> 
>                0.15108  0.67447  0.70927  0.93837
>                0.20088  0.30963  0.26579  0.68902
>                0.78126  0.19126  0.25733  0.74309
>                0.53532  0.61626  0.59922  0.21876
> 
>       }
> 
> 
> 
>       -- 
>       Mit freundlichen Gruessen
>                                                                               
>                 Daniel Heiserer
>       --------------------------------------------------------------
>       Dipl.-Phys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
>       Abteilung EK-20
>       Tel.: 089-382-21187, Fax.: 089-382-42820
>       mailto:address@hidden 
>       Lageplan Standort FIZ:
>       http://www.stadtplandienst.de/query?ORT=M&STR=Knorrstr.&HNR=147
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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