Navigation

Operators and Keywords

Function List:

C++ API

cellfun.cc File Reference

#include <string>
#include <vector>
#include <list>
#include <memory>
#include "lo-mappers.h"
#include "oct-locbuf.h"
#include "Cell.h"
#include "oct-map.h"
#include "defun-dld.h"
#include "parse.h"
#include "variables.h"
#include "ov-colon.h"
#include "unwind-prot.h"
#include "gripes.h"
#include "utils.h"

Include dependency graph for cellfun.cc:


Classes

class  scalar_col_helper
class  scalar_col_helper_def
struct  scalar_query_helper< T >
class  scalar_col_helper_nda< NDA >

Defines

#define DEF_QUERY_HELPER(T, TEST, QUERY)

Functions

 DEF_QUERY_HELPER (double, val.is_real_scalar(), val.scalar_value())
 DEF_QUERY_HELPER (Complex, val.is_complex_scalar(), val.complex_value())
 DEF_QUERY_HELPER (float, val.is_single_type()&&val.is_real_scalar(), val.float_scalar_value())
 DEF_QUERY_HELPER (FloatComplex, val.is_single_type()&&val.is_complex_scalar(), val.float_complex_value())
 DEF_QUERY_HELPER (bool, val.is_bool_scalar(), val.bool_value())
scalar_col_helpermake_col_helper (const octave_value &val, const dim_vector &dims)
 DEFUN_DLD (cellfun, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} cellfun (@var{name}, @var{c})\n\ @deftypefnx {Loadable Function} {} cellfun (\"size\", @var{c}, @var{k})\n\ @deftypefnx {Loadable Function} {} cellfun (\"isclass\", @var{c}, @var{class})\n\ @deftypefnx {Loadable Function} {} cellfun (@var{func}, @var{c})\n\ @deftypefnx {Loadable Function} {} cellfun (@var{func}, @var{c}, @var{d})\n\ @deftypefnx {Loadable Function} {[@var{a}, @var{b}] =} cellfun (@dots{})\n\ @deftypefnx {Loadable Function} {} cellfun (@dots{}, 'ErrorHandler', @var{errfunc})\n\ @deftypefnx {Loadable Function} {} cellfun (@dots{}, 'UniformOutput', @var{val})\n\ \n\ Evaluate the function named @var{name} on the elements of the cell array\n\ @var{c}. Elements in @var{c} are passed on to the named function\n\ individually. The function @var{name} can be one of the functions\n\ \n\ @table @code\n\ @item isempty\n\ Return 1 for empty elements.\n\ @item islogical\n\ Return 1 for logical elements.\n\ @item isreal\n\ Return 1 for real elements.\n\ @item length\n\ Return a vector of the lengths of cell elements.\n\ @item ndims\n\ Return the number of dimensions of each element.\n\ @item prodofsize\n\ Return the product of dimensions of each element.\n\ @item size\n\ Return the size along the @var{k}-th dimension.\n\ @item isclass\n\ Return 1 for elements of @var{class}.\n\ @end table\n\ \n\ Additionally, @code{cellfun} accepts an arbitrary function @var{func}\n\ in the form of an inline function, function handle, or the name of a\n\ function (in a character string). In the case of a character string\n\ argument, the function must accept a single argument named @var{x}, and\n\ it must return a string value. The function can take one or more arguments,\n\ with the inputs args given by @var{c}, @var{d}, etc. Equally the function\n\ can return one or more output arguments. For example\n\ \n\ @example\n\ @group\n\ cellfun (@@atan2, @{1, 0@}, @{0, 1@})\n\ @result{}ans = [1.57080 0.00000]\n\ @end group\n\ @end example\n\ \n\ Note that the default output argument is an array of the same size as the\n\ input arguments.\n\ Input arguments that are singleton (1x1) cells will be automatically expanded\n\ to the size of the other arguments.\n\ \n\ If the parameter 'UniformOutput' is set to true (the default), then the function\n\ must return a single element which will be concatenated into the\n\ return value. If 'UniformOutput' is false, the outputs are concatenated in\n\ a cell array. For example\n\ \n\ @example\n\ @group\n\ cellfun (\"tolower(x)\", @{\"Foo\", \"Bar\", \"FooBar\"@},\n\ \"UniformOutput\",false)\n\ @result{} ans = @{\"foo\", \"bar\", \"foobar\"@}\n\ @end group\n\ @end example\n\ \n\ Given the parameter 'ErrorHandler', then @var{errfunc} defines a function to\n\ call in case @var{func} generates an error. The form of the function is\n\ \n\ @example\n\ function [@dots{}] = errfunc (@var{s}, @dots{})\n\ @end example\n\ \n\ where there is an additional input argument to @var{errfunc} relative to\n\ @var{func}, given by @var{s}. This is a structure with the elements\n\ 'identifier', 'message' and 'index', giving respectively the error\n\ identifier, the error message, and the index into the input arguments\n\ of the element that caused the error. For example\n\ \n\ @example\n\ @group\n\ function y = foo (s, x), y = NaN; endfunction\n\ cellfun (@@factorial, @{-1,2@},'ErrorHandler',@@foo)\n\ @result{} ans = [NaN 2]\n\ @end group\n\ @end example\n\ \n\ @seealso{isempty, islogical, isreal, length, ndims, numel, size}\n\ @end deftypefn")
 DEFUN_DLD (num2cell, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{c} =} num2cell (@var{m})\n\ @deftypefnx {Loadable Function} {@var{c} =} num2cell (@var{m}, @var{dim})\n\ Convert the matrix @var{m} to a cell array. If @var{dim} is defined, the\n\ value @var{c} is of dimension 1 in this dimension and the elements of\n\ @var{m} are placed in slices in @var{c}.\n\ @seealso{mat2cell}\n\ @end deftypefn")
 DEFUN_DLD (mat2cell, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{b} =} mat2cell (@var{a}, @var{m}, @var{n})\n\ @deftypefnx {Loadable Function} {@var{b} =} mat2cell (@var{a}, @var{d1}, @var{d2}, @dots{})\n\ @deftypefnx {Loadable Function} {@var{b} =} mat2cell (@var{a}, @var{r})\n\ Convert the matrix @var{a} to a cell array. If @var{a} is 2-D, then\n\ it is required that @code{sum (@var{m}) == size (@var{a}, 1)} and\n\ @code{sum (@var{n}) == size (@var{a}, 2)}. Similarly, if @var{a} is\n\ a multi-dimensional and the number of dimensional arguments is equal\n\ to the dimensions of @var{a}, then it is required that @code{sum (@var{di})\n\ == size (@var{a}, i)}.\n\ \n\ Given a single dimensional argument @var{r}, the other dimensional\n\ arguments are assumed to equal @code{size (@var{a},@var{i})}.\n\ \n\ An example of the use of mat2cell is\n\ \n\ @example\n\ mat2cell (reshape(1:16,4,4),[3,1],[3,1])\n\ @result{} @{\n\ [1,1] =\n\ \n\ 1 5 9\n\ 2 6 10\n\ 3 7 11\n\ \n\ [2,1] =\n\ \n\ 4 8 12\n\ \n\ [1,2] =\n\ \n\ 13\n\ 14\n\ 15\n\ \n\ [2,2] = 16\n\ @}\n\ @end example\n\ @seealso{num2cell, cell2mat}\n\ @end deftypefn")
 DEFUN_DLD (cellslices, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{sl} =} cellslices (@var{x}, @var{lb}, @var{ub})\n\ Given a vector @var{x}, this function produces a cell array of slices from the vector\n\ determined by the index vectors @var{lb}, @var{ub}, for lower and upper bounds, respectively.\n\ In other words, it is equivalent to the following code:\n\ \n\ @example\n\ @group\n\ n = length (lb);\n\ sl = cell (1, n);\n\ for i = 1:length (lb)\n\ sl@{i@} = x(lb(i):ub(i));\n\ endfor\n\ @end group\n\ @end example\n\ \n\ If @var{X} is a matrix or array, indexing is done along the last dimension.\n\ @seealso{mat2cell}\n\ @end deftypefn")

Define Documentation

#define DEF_QUERY_HELPER ( T,
TEST,
QUERY   ) 

Value:

template <> \
struct scalar_query_helper<T> \
{ \
  static bool has_value (const octave_value& val) \
    { return TEST; } \
  static T get_value (const octave_value& val) \
    { return QUERY; } \
}


Function Documentation

DEF_QUERY_HELPER ( bool  ,
val.  is_bool_scalar(),
val.  bool_value() 
)

DEF_QUERY_HELPER ( FloatComplex  ,
val.  is_single_type)&&val.is_complex_scalar(,
val.  float_complex_value() 
)

DEF_QUERY_HELPER ( float  ,
val.  is_single_type)&&val.is_real_scalar(,
val.  float_scalar_value() 
)

DEF_QUERY_HELPER ( Complex  ,
val.  is_complex_scalar(),
val.  complex_value() 
)

DEF_QUERY_HELPER ( double  ,
val.  is_real_scalar(),
val.  scalar_value() 
)

DEFUN_DLD ( cellslices  ,
args   
)

DEFUN_DLD ( mat2cell  ,
args   
)

DEFUN_DLD ( num2cell  ,
args   
)

DEFUN_DLD ( cellfun  ,
args  ,
nargout   
)

scalar_col_helper* make_col_helper ( const octave_value val,
const dim_vector dims 
)