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 "ov-scalar.h"
#include "ov-float.h"
#include "ov-complex.h"
#include "ov-flt-complex.h"
#include "ov-bool.h"
#include "ov-int8.h"
#include "ov-int16.h"
#include "ov-int32.h"
#include "ov-int64.h"
#include "ov-uint8.h"
#include "ov-uint16.h"
#include "ov-uint32.h"
#include "ov-uint64.h"
Include dependency graph for cellfun.cc:

Defines

#define BTYP_BRANCH(X, Y)

Functions

 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}, @dots{}] =} 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\ \n\ @item islogical\n\ Return 1 for logical elements.\n\ \n\ @item isreal\n\ Return 1 for real elements.\n\ \n\ @item length\n\ Return a vector of the lengths of cell elements.\n\ \n\ @item ndims\n\ Return the number of dimensions of each element.\n\ \n\ @item prodofsize\n\ Return the product of dimensions of each element.\n\ \n\ @item size\n\ Return the size along the @var{k}-th dimension.\n\ \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 arguments given by @var{C}, @var{D}, etc. Equally the\n\ function 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\ The number of output arguments of @code{cellfun} matches the number of output\n\ arguments of the function. The outputs of the function will be collected\n\ into the output arguments of @code{cellfun} like this:\n\ \n\ @example\n\ @group\n\ function [a, b] = twoouts (x)\n\ a = x;\n\ b = x*x;\n\ endfunction\n\ [aa, bb] = cellfun(@@twoouts, @{1, 2, 3@})\n\ @result{}\n\ aa = \n\ 1 2 3\n\ bb =\n\ 1 4 9\n\ @end group\n\ @end example\n\ \n\ Note that per default the output argument(s) are arrays of the same size as\n\ the input arguments. Input arguments that are singleton (1x1) cells will be\n\ automatically expanded to the size of the other arguments.\n\ \n\ If the parameter 'UniformOutput' is set to true (the default), then the\n\ function must return scalars which will be concatenated into the return\n\ array(s). If 'UniformOutput' is false, the outputs are concatenated into a\n\ cell array (or cell arrays). 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\ @noindent\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{arrayfun, structfun, spfun}\n\ @end deftypefn")
 DEFUN_DLD (num2cell, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{C} =} num2cell (@var{A})\n\ @deftypefnx {Loadable Function} {@var{C} =} num2cell (@var{A}, @var{dim})\n\ Convert the numeric matrix @var{A} to a cell array. If @var{dim} is\n\ defined, the value @var{C} is of dimension 1 in this dimension and the\n\ elements of @var{A} are placed into @var{C} in slices. For example:\n\ \n\ @example\n\ @group\n\ num2cell([1,2;3,4])\n\ @result{} ans =\n\ @{\n\ [1,1] = 1\n\ [2,1] = 3\n\ [1,2] = 2\n\ [2,2] = 4\n\ @}\n\ num2cell([1,2;3,4],1)\n\ @result{} ans =\n\ @{\n\ [1,1] =\n\ 1\n\ 3\n\ [1,2] =\n\ 2\n\ 4\n\ @}\n\ @end group\n\ @end example\n\ \n\ @seealso{mat2cell}\n\ @end deftypefn")
template<class ArrayND >
Cell do_mat2cell_nd (const ArrayND &a, const Array< octave_idx_type > *d, int nd)
template<class ArrayND >
Cell do_mat2cell (const ArrayND &a, const Array< octave_idx_type > *d, int nd)
Cell do_mat2cell (octave_value &a, const Array< octave_idx_type > *d, int nd)
 DEFUN_DLD (mat2cell, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{C} =} mat2cell (@var{A}, @var{m}, @var{n})\n\ @deftypefnx {Loadable Function} {@var{C} =} mat2cell (@var{A}, @var{d1}, @var{d2}, @dots{})\n\ @deftypefnx {Loadable Function} {@var{C} =} 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\ 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}, @var{dim})\n\ Given an array @var{x}, this function produces a cell array of slices from\n\ the array determined by the index vectors @var{lb}, @var{ub}, for lower and\n\ upper bounds, respectively. In other words, it is equivalent to the\n\ 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(:,@dots{},lb(i):ub(i),@dots{},:);\n\ endfor\n\ @end group\n\ @end example\n\ \n\ The position of the index is determined by @var{dim}. If not specified,\n\ slicing is done along the first non-singleton dimension.\n\ @end deftypefn")
 DEFUN_DLD (cellindexmat, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{y} =} cellindexmat (@var{x}, @var{varargin})\n\ Given a cell array of matrices @var{x}, this function computes\n\ \n\ @example\n\ @group\n\ Y = cell (size (X));\n\ for i = 1:numel (X)\n\ Y@{i@} = X@{i@}(varargin@{:@});\n\ endfor\n\ @end group\n\ @end example\n\ @seealso{cellfun, cellslices}\n\ @end deftypefn")

Define Documentation

#define BTYP_BRANCH (   X,
  Y 
)
Value:
case btyp_ ## X: \
            retval = do_mat2cell (a.Y ## _value (), d, nargin - 1); \
          break

Function Documentation

DEFUN_DLD ( cellfun  ,
args  ,
nargout   
)
DEFUN_DLD ( cellslices  ,
args   
)
DEFUN_DLD ( cellindexmat  ,
args   
)
DEFUN_DLD ( num2cell  ,
args   
)
DEFUN_DLD ( mat2cell  ,
args   
)
Cell do_mat2cell ( octave_value a,
const Array< octave_idx_type > *  d,
int  nd 
)
template<class ArrayND >
Cell do_mat2cell ( const ArrayND &  a,
const Array< octave_idx_type > *  d,
int  nd 
)
template<class ArrayND >
Cell do_mat2cell_nd ( const ArrayND &  a,
const Array< octave_idx_type > *  d,
int  nd 
)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines