#include <string>
#include <vector>
#include <list>
#include "lo-mappers.h"
#include "oct-map.h"
#include "defun-dld.h"
#include "parse.h"
#include "variables.h"
#include "ov-colon.h"
#include "unwind-prot.h"
#include "ov-fcn-handle.h"
Go to the source code of this file.
Defines | |
#define | BSXDEF(T) |
#define | BSXEND(T) |
#define | BSXINIT(T, CLS, EXTRACTOR) |
#define | BSXLOOP(T, CLS, EXTRACTOR) |
#define | REGISTER_OP_HANDLER(OP, BTYP, NDA, FUNOP) bsxfun_handler_table[OP][BTYP] = bsxfun_forward_op<NDA, FUNOP> |
#define | REGISTER_REL_HANDLER(REL, BTYP, NDA, FUNREL) bsxfun_handler_table[REL][BTYP] = bsxfun_forward_rel<NDA, FUNREL> |
#define | REGISTER_STD_HANDLERS(BTYP, NDA) |
Typedefs | |
typedef octave_value(* | bsxfun_handler )(const octave_value &, const octave_value &) |
Enumerations | |
enum | bsxfun_builtin_op { bsxfun_builtin_plus = 0, bsxfun_builtin_minus, bsxfun_builtin_times, bsxfun_builtin_divide, bsxfun_builtin_max, bsxfun_builtin_min, bsxfun_builtin_eq, bsxfun_builtin_ne, bsxfun_builtin_lt, bsxfun_builtin_le, bsxfun_builtin_gt, bsxfun_builtin_ge, bsxfun_builtin_and, bsxfun_builtin_or, bsxfun_builtin_power, bsxfun_builtin_unknown, bsxfun_num_builtin_ops = bsxfun_builtin_unknown } |
Functions | |
static bsxfun_builtin_op | bsxfun_builtin_lookup (const std::string &name) |
template<class NDA , NDA(bsxfun_op)(const NDA &, const NDA &) > | |
static octave_value | bsxfun_forward_op (const octave_value &x, const octave_value &y) |
template<class NDA , boolNDArray(bsxfun_rel)(const NDA &, const NDA &) > | |
static octave_value | bsxfun_forward_rel (const octave_value &x, const octave_value &y) |
DEFUN_DLD (bsxfun, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} bsxfun (@var{f}, @var{A}, @var{B})\n\ The binary singleton expansion function applier performs broadcasting,\n\ that is, applies a binary function @var{f} element-by-element to two\n\ array arguments @var{A} and @var{B}, and expands as necessary\n\ singleton dimensions in either input argument. @var{f} is a function\n\ handle, inline function, or string containing the name of the function\n\ to evaluate. The function @var{f} must be capable of accepting two\n\ column-vector arguments of equal length, or one column vector argument\n\ and a scalar.\n\ \n\ The dimensions of @var{A} and @var{B} must be equal or singleton. The\n\ singleton dimensions of the arrays will be expanded to the same\n\ dimensionality as the other array.\n\ @seealso{arrayfun, cellfun}\n\ @end deftypefn") | |
template<class NDA , class CNDA > | |
static octave_value | do_bsxfun_real_pow (const octave_value &x, const octave_value &y) |
static void | maybe_fill_table (void) |
static octave_value | maybe_optimized_builtin (const std::string &name, const octave_value &a, const octave_value &b) |
static bool | maybe_update_column (octave_value &Ac, const octave_value &A, const dim_vector &dva, const dim_vector &dvc, octave_idx_type i, octave_value_list &idx) |
static void | update_index (Array< int > &idx, const dim_vector &dv, octave_idx_type i) |
Variables | |
const char * | bsxfun_builtin_names [] |
bsxfun_handler | bsxfun_handler_table [bsxfun_num_builtin_ops][btyp_num_types] |
#define BSXDEF | ( | T | ) |
T result_ ## T; \ bool have_ ## T = false;
Referenced by DEFUN_DLD().
#define BSXEND | ( | T | ) |
(have_ ## T) \ retval (0) = result_ ## T;
Referenced by DEFUN_DLD().
#define BSXINIT | ( | T, | ||
CLS, | ||||
EXTRACTOR | ||||
) |
(result_type == CLS) \
{ \
have_ ## T = true; \
result_ ## T = \
tmp (0). EXTRACTOR ## _array_value (); \
result_ ## T .resize (dvc); \
}
Referenced by DEFUN_DLD().
#define BSXLOOP | ( | T, | ||
CLS, | ||||
EXTRACTOR | ||||
) |
(have_ ## T) \ { \ if (tmp (0).class_name () != CLS) \ { \ have_ ## T = false; \ C = result_ ## T; \ C = do_cat_op (C, tmp (0), ra_idx); \ } \ else \ result_ ## T .insert \ (tmp(0). EXTRACTOR ## _array_value (), \ ra_idx); \ }
Referenced by DEFUN_DLD().
#define REGISTER_OP_HANDLER | ( | OP, | ||
BTYP, | ||||
NDA, | ||||
FUNOP | ||||
) | bsxfun_handler_table[OP][BTYP] = bsxfun_forward_op<NDA, FUNOP> |
Referenced by maybe_fill_table().
#define REGISTER_REL_HANDLER | ( | REL, | ||
BTYP, | ||||
NDA, | ||||
FUNREL | ||||
) | bsxfun_handler_table[REL][BTYP] = bsxfun_forward_rel<NDA, FUNREL> |
Referenced by maybe_fill_table().
#define REGISTER_STD_HANDLERS | ( | BTYP, | ||
NDA | ||||
) |
REGISTER_OP_HANDLER (bsxfun_builtin_plus, BTYP, NDA, bsxfun_add); \ REGISTER_OP_HANDLER (bsxfun_builtin_minus, BTYP, NDA, bsxfun_sub); \ REGISTER_OP_HANDLER (bsxfun_builtin_times, BTYP, NDA, bsxfun_mul); \ REGISTER_OP_HANDLER (bsxfun_builtin_divide, BTYP, NDA, bsxfun_div); \ REGISTER_OP_HANDLER (bsxfun_builtin_max, BTYP, NDA, bsxfun_max); \ REGISTER_OP_HANDLER (bsxfun_builtin_min, BTYP, NDA, bsxfun_min); \ REGISTER_REL_HANDLER (bsxfun_builtin_eq, BTYP, NDA, bsxfun_eq); \ REGISTER_REL_HANDLER (bsxfun_builtin_ne, BTYP, NDA, bsxfun_ne); \ REGISTER_REL_HANDLER (bsxfun_builtin_lt, BTYP, NDA, bsxfun_lt); \ REGISTER_REL_HANDLER (bsxfun_builtin_le, BTYP, NDA, bsxfun_le); \ REGISTER_REL_HANDLER (bsxfun_builtin_gt, BTYP, NDA, bsxfun_gt); \ REGISTER_REL_HANDLER (bsxfun_builtin_ge, BTYP, NDA, bsxfun_ge)
Referenced by maybe_fill_table().
typedef octave_value(* bsxfun_handler)(const octave_value &, const octave_value &) |
enum bsxfun_builtin_op |
static bsxfun_builtin_op bsxfun_builtin_lookup | ( | const std::string & | name | ) | [static] |
Definition at line 84 of file bsxfun.cc.
Referenced by maybe_optimized_builtin().
static octave_value bsxfun_forward_op | ( | const octave_value & | x, | |
const octave_value & | y | |||
) | [static] |
Definition at line 99 of file bsxfun.cc.
References octave_value().
static octave_value bsxfun_forward_rel | ( | const octave_value & | x, | |
const octave_value & | y | |||
) | [static] |
Definition at line 108 of file bsxfun.cc.
References octave_value().
DEFUN_DLD | ( | bsxfun | , | |
args | ||||
) |
Definition at line 312 of file bsxfun.cc.
References A, octave_value_list::array_value(), B, BSXDEF, BSXEND, BSXINIT, BSXLOOP, complex, ComplexNDArray, octave_value::dims(), do_cat_op(), octave_value::do_multi_index_op(), octave_value_list::empty(), error(), error_state, symbol_table::find_function(), FloatComplexNDArray, octave_value::function_value(), octave_value::is_builtin_function(), octave_value::is_defined(), octave_value::is_function_handle(), octave_value::is_object(), octave_value::is_string(), octave_value::is_undefined(), dim_vector::length(), maybe_optimized_builtin(), maybe_update_column(), octave_function::name(), NDArray, dim_vector::numel(), print_usage(), octave_value_list::resize(), Array< T >::resize(), octave_value::resize(), dim_vector::resize(), octave_value::string_value(), and update_index().
static octave_value do_bsxfun_real_pow | ( | const octave_value & | x, | |
const octave_value & | y | |||
) | [static] |
Definition at line 118 of file bsxfun.cc.
References octave_value().
static void maybe_fill_table | ( | void | ) | [static] |
Definition at line 128 of file bsxfun.cc.
References bsxfun_builtin_and, bsxfun_builtin_eq, bsxfun_builtin_ge, bsxfun_builtin_gt, bsxfun_builtin_le, bsxfun_builtin_lt, bsxfun_builtin_ne, bsxfun_builtin_or, bsxfun_builtin_power, bsxfun_handler_table, btyp_bool, btyp_char, btyp_complex, btyp_double, btyp_float, btyp_float_complex, btyp_int16, btyp_int32, btyp_int64, btyp_int8, btyp_uint16, btyp_uint32, btyp_uint64, btyp_uint8, REGISTER_OP_HANDLER, REGISTER_REL_HANDLER, and REGISTER_STD_HANDLERS.
Referenced by maybe_optimized_builtin().
static octave_value maybe_optimized_builtin | ( | const std::string & | name, | |
const octave_value & | a, | |||
const octave_value & | b | |||
) | [static] |
Definition at line 190 of file bsxfun.cc.
References bsxfun_builtin_lookup(), bsxfun_builtin_unknown, bsxfun_handler_table, btyp_complex, btyp_double, btyp_float, btyp_float_complex, btyp_unknown, octave_value::builtin_type(), and maybe_fill_table().
Referenced by DEFUN_DLD().
static bool maybe_update_column | ( | octave_value & | Ac, | |
const octave_value & | A, | |||
const dim_vector & | dva, | |||
const dim_vector & | dvc, | |||
octave_idx_type | i, | |||
octave_value_list & | idx | |||
) | [static] |
Definition at line 224 of file bsxfun.cc.
References dim_vector::length(), octave_value(), and octave_value::single_subsref().
Referenced by DEFUN_DLD().
static void update_index | ( | Array< int > & | idx, | |
const dim_vector & | dv, | |||
octave_idx_type | i | |||
) | [static] |
Definition at line 300 of file bsxfun.cc.
References dim_vector::length().
Referenced by DEFUN_DLD().
const char* bsxfun_builtin_names[] |
bsxfun_handler bsxfun_handler_table[bsxfun_num_builtin_ops][btyp_num_types] |
Definition at line 95 of file bsxfun.cc.
Referenced by maybe_fill_table(), and maybe_optimized_builtin().