comparison src/ov.h @ 7800:5861b95e9879

support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 07 May 2008 16:33:15 +0200
parents 82be108cc558
children 8447a5024650
comparison
equal deleted inserted replaced
7799:199181592240 7800:5861b95e9879
108 op_struct_ref, 108 op_struct_ref,
109 num_binary_ops, 109 num_binary_ops,
110 unknown_binary_op 110 unknown_binary_op
111 }; 111 };
112 112
113 enum compound_binary_op
114 {
115 // ** compound operations **
116 op_trans_mul,
117 op_mul_trans,
118 op_herm_mul,
119 op_mul_herm,
120 num_compound_binary_ops,
121 unknown_compound_binary_op
122 };
123
113 enum assign_op 124 enum assign_op
114 { 125 {
115 op_asn_eq, 126 op_asn_eq,
116 op_add_eq, 127 op_add_eq,
117 op_sub_eq, 128 op_sub_eq,
134 static std::string unary_op_as_string (unary_op); 145 static std::string unary_op_as_string (unary_op);
135 static std::string unary_op_fcn_name (unary_op); 146 static std::string unary_op_fcn_name (unary_op);
136 147
137 static std::string binary_op_as_string (binary_op); 148 static std::string binary_op_as_string (binary_op);
138 static std::string binary_op_fcn_name (binary_op); 149 static std::string binary_op_fcn_name (binary_op);
150
151 static std::string binary_op_fcn_name (compound_binary_op);
139 152
140 static std::string assign_op_as_string (assign_op); 153 static std::string assign_op_as_string (assign_op);
141 154
142 static octave_value empty_conv (const std::string& type, 155 static octave_value empty_conv (const std::string& type,
143 const octave_value& rhs = octave_value ()); 156 const octave_value& rhs = octave_value ());
892 905
893 friend OCTINTERP_API octave_value do_binary_op (binary_op op, 906 friend OCTINTERP_API octave_value do_binary_op (binary_op op,
894 const octave_value& a, 907 const octave_value& a,
895 const octave_value& b); 908 const octave_value& b);
896 909
910 friend OCTINTERP_API octave_value do_binary_op (compound_binary_op op,
911 const octave_value& a,
912 const octave_value& b);
913
897 friend OCTINTERP_API octave_value do_cat_op (const octave_value& a, 914 friend OCTINTERP_API octave_value do_cat_op (const octave_value& a,
898 const octave_value& b, 915 const octave_value& b,
899 const Array<octave_idx_type>& ra_idx); 916 const Array<octave_idx_type>& ra_idx);
900 917
901 const octave_base_value& get_rep (void) const { return *rep; } 918 const octave_base_value& get_rep (void) const { return *rep; }
1041 1058
1042 extern OCTINTERP_API octave_value 1059 extern OCTINTERP_API octave_value
1043 do_binary_op (octave_value::binary_op op, 1060 do_binary_op (octave_value::binary_op op,
1044 const octave_value& a, const octave_value& b); 1061 const octave_value& a, const octave_value& b);
1045 1062
1063 extern OCTINTERP_API octave_value
1064 do_binary_op (octave_value::compound_binary_op op,
1065 const octave_value& a, const octave_value& b);
1066
1046 #define OV_UNOP_FN(name) \ 1067 #define OV_UNOP_FN(name) \
1047 inline octave_value \ 1068 inline octave_value \
1048 name (const octave_value& a) \ 1069 name (const octave_value& a) \
1049 { \ 1070 { \
1050 return do_unary_op (octave_value::name, a); \ 1071 return do_unary_op (octave_value::name, a); \
1114 OV_BINOP_FN (op_el_ldiv) 1135 OV_BINOP_FN (op_el_ldiv)
1115 OV_BINOP_FN (op_el_and) 1136 OV_BINOP_FN (op_el_and)
1116 OV_BINOP_FN (op_el_or) 1137 OV_BINOP_FN (op_el_or)
1117 1138
1118 OV_BINOP_FN (op_struct_ref) 1139 OV_BINOP_FN (op_struct_ref)
1140
1141 #define OV_COMP_BINOP_FN(name) \
1142 inline octave_value \
1143 name (const octave_value& a1, const octave_value& a2) \
1144 { \
1145 return do_binary_op (octave_value::name, a1, a2); \
1146 }
1147
1148 OV_COMP_BINOP_FN (op_trans_mul)
1149 OV_COMP_BINOP_FN (op_mul_trans)
1150 OV_COMP_BINOP_FN (op_herm_mul)
1151 OV_COMP_BINOP_FN (op_mul_herm)
1119 1152
1120 extern OCTINTERP_API void install_types (void); 1153 extern OCTINTERP_API void install_types (void);
1121 1154
1122 // FIXME -- these trait classes probably belong somehwere else... 1155 // FIXME -- these trait classes probably belong somehwere else...
1123 1156