[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use a cell argument in oct function?
From: |
Paul Thomas |
Subject: |
Re: use a cell argument in oct function? |
Date: |
Fri, 05 Mar 2004 21:48:57 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 |
Michael,
One of the demos in my long overdue cookbook on dynamically linked
functions is
#include <octave/oct.h>
#include <octave/Cell.h>
DEFUN_DLD (celldemo, args, ,
"The 'celldemo'.\n\
newcell=celldemo(oldcell), where\n\
oldcell(0,0) = a real scalar value ")
{
octave_value_list retval; //holder for return value
if ( !args(0).is_cell() ) //test if cell
{
error ( "argument must be a cell");
return octave_value (-1);
}
Cell c0 ( args(0).cell_value() ); //assign to cell c0
if ( !c0 (0,0).is_real_scalar() ) //is c0{1,1} a real scalar?
{
error ( "element (1,1) must be a real scalar" );
return octave_value (-1);
}
double r = c0(0,0).double_value();
Cell c1 ( 1 , 2 ); //construct 1x2 cell
c1(0,0) = r; //1st element =
original scalar
c1(0,1) = ColumnVector ( 10 , 1/r ); //2nd element = column
value
return retval.append ( octave_value (c1) ); //return new cell.
}
I hope it helps
Paul T
Michael Creel wrote:
Hello,
I need to pass a cell array as one of the arguments of an oct function, and
operate upon its elements inside the oct function. I need something like
const int n = args(1).int_value();
but for a cell array rather than an int. The possibility seems to de defined,
in ov-base.h, but I can't figure out how to use it.
TIA, Michael
-------------------------------------------------------------
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
-------------------------------------------------------------