Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined (bsxfun_h)
00023 #define bsxfun_h 1
00024
00025 #include <algorithm>
00026
00027 #include "Array.h"
00028 #include "dim-vector.h"
00029 #include "lo-error.h"
00030
00031 inline
00032 bool
00033 is_valid_bsxfun (const std::string& name, const dim_vector& dx,
00034 const dim_vector& dy)
00035 {
00036 for (int i = 0; i < std::min (dx.length (), dy.length ()); i++)
00037 {
00038 octave_idx_type xk = dx(i), yk = dy(i);
00039
00040 if (! ( (xk == yk) || (xk == 1 && yk > 1) || (xk > 1 && yk == 1)))
00041 return false;
00042 }
00043
00044 (*current_liboctave_warning_with_id_handler)
00045 ("Octave:broadcast", "%s: automatic broadcasting operation applied", name.c_str ());
00046
00047 return true;
00048 }
00049
00050
00051
00052
00053 inline
00054 bool
00055 is_valid_inplace_bsxfun (const std::string& name, const dim_vector& dr,
00056 const dim_vector& dx)
00057 {
00058 octave_idx_type drl = dr.length (), dxl = dx.length ();
00059 if (drl < dxl)
00060 return false;
00061
00062 for (int i = 0; i < drl; i++)
00063 {
00064 octave_idx_type rk = dr(i), xk = dx(i);
00065
00066
00067 if (! ( (rk == xk) || (rk > 1 && xk == 1)))
00068 return false;
00069 }
00070
00071 (*current_liboctave_warning_with_id_handler)
00072 ("Octave:broadcast", "%s: automatic broadcasting operation applied", name.c_str ());
00073
00074 return true;
00075 }
00076
00077 #include "bsxfun-defs.cc"
00078
00079 #endif