Mercurial > hg > octave-terminal
changeset 2915:649549662cf6
[project @ 1997-04-30 20:51:40 by jwe]
author | jwe |
---|---|
date | Wed, 30 Apr 1997 20:53:14 +0000 |
parents | d6a3e3723736 |
children | 4e7bea116f24 |
files | src/oct-stream.cc src/op-b-b.cc src/op-bm-bm.cc src/op-cm-cm.cc src/op-cm-cs.cc src/op-cm-m.cc src/op-cm-s.cc src/op-cs-cm.cc src/op-cs-cs.cc src/op-cs-m.cc src/op-cs-s.cc src/op-m-cm.cc src/op-m-cs.cc src/op-m-m.cc src/op-m-s.cc src/op-s-cm.cc src/op-s-cs.cc src/op-s-m.cc src/op-s-s.cc src/op-str-str.cc src/pr-output.cc |
diffstat | 21 files changed, 337 insertions(+), 1891 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -2589,7 +2589,7 @@ if (! conv_err) retval = do_get_info (int_fid); else - ::error ("file id must be valid integer"); + ::error ("file id must be a file object or integer value"); return retval; } @@ -2729,7 +2729,7 @@ int int_fid = convert_to_valid_int (fid, conv_err); if (conv_err) - ::error ("file id must be a string or integer value"); + ::error ("file id must be a file object, string, or integer value"); else retval = int_fid; }
--- a/src/op-b-b.cc +++ b/src/op-b-b.cc @@ -32,28 +32,14 @@ #include "ov.h" #include "ov-bool.h" #include "ov-typeinfo.h" -#include "op-b-b.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // bool by bool ops. -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_bool&, const octave_bool&); - - return octave_value (v1.bool_value () == v2.bool_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_bool&, const octave_bool&); - - return octave_value (v1.bool_value () != v2.bool_value ()); -} +DEFBINOP_OP (eq, bool, bool, ==) +DEFBINOP_OP (ne, bool, bool, !=) void install_b_b_ops (void)
--- a/src/op-bm-bm.cc +++ b/src/op-bm-bm.cc @@ -32,28 +32,14 @@ #include "ov.h" #include "ov-bool-mat.h" #include "ov-typeinfo.h" -#include "op-b-b.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // bool matrix by bool matrix ops. -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_bool_matrix&, const octave_bool_matrix&); - - return octave_value (v1.bool_matrix_value () == v2.bool_matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_bool_matrix&, const octave_bool_matrix&); - - return octave_value (v1.bool_matrix_value () != v2.bool_matrix_value ()); -} +DEFBINOP_OP (eq, bool_matrix, bool_matrix, ==) +DEFBINOP_OP (ne, bool_matrix, bool_matrix, !=) void install_bm_bm_ops (void)
--- a/src/op-cm-cm.cc +++ b/src/op-cm-cm.cc @@ -32,139 +32,37 @@ #include "ov.h" #include "ov-cx-mat.h" #include "ov-typeinfo.h" -#include "op-cm-cm.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex matrix by complex matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return octave_value (v1.complex_matrix_value () - + v2.complex_matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return octave_value (v1.complex_matrix_value () - - v2.complex_matrix_value ()); -} +DEFBINOP_OP (add, complex_matrix, complex_matrix, +) +DEFBINOP_OP (sub, complex_matrix, complex_matrix, -) +DEFBINOP_OP (mul, complex_matrix, complex_matrix, *) +DEFBINOP_FN (div, complex_matrix, complex_matrix, xdiv) -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return octave_value (v1.complex_matrix_value () - * v2.complex_matrix_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return xdiv (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -pow (const octave_value&, const octave_value&) +DEFBINOPX (pow, complex_matrix, complex_matrix) { error ("can't do A ^ B for A and B both matrices"); return octave_value (); } -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return xleftdiv (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_lt (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_le (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_eq (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_ge (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} +DEFBINOP_FN (ldiv, complex_matrix, complex_matrix, xleftdiv) -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_gt (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_ne (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); +DEFBINOP_FN (lt, complex_matrix, complex_matrix, mx_el_lt) +DEFBINOP_FN (le, complex_matrix, complex_matrix, mx_el_le) +DEFBINOP_FN (eq, complex_matrix, complex_matrix, mx_el_eq) +DEFBINOP_FN (ge, complex_matrix, complex_matrix, mx_el_ge) +DEFBINOP_FN (gt, complex_matrix, complex_matrix, mx_el_gt) +DEFBINOP_FN (ne, complex_matrix, complex_matrix, mx_el_ne) - return octave_value (product (v1.complex_matrix_value (), - v2.complex_matrix_value ())); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); +DEFBINOP_FN (el_mul, complex_matrix, complex_matrix, product) +DEFBINOP_FN (el_div, complex_matrix, complex_matrix, quotient) +DEFBINOP_FN (el_pow, complex_matrix, complex_matrix, elem_xpow) - return octave_value (quotient (v1.complex_matrix_value (), - v2.complex_matrix_value ())); -} - -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return elem_xpow (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex_matrix, complex_matrix) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); @@ -172,31 +70,10 @@ v1.complex_matrix_value ())); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); - - return mx_el_and (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); +DEFBINOP_FN (el_and, complex_matrix, complex_matrix, mx_el_and) +DEFBINOP_FN (el_or, complex_matrix, complex_matrix, mx_el_or) - return mx_el_or (v1.complex_matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) -{ - CAST_BINOP_ARGS (octave_complex_matrix&, const octave_complex_matrix&); - - v1.assign (idx, v2.complex_matrix_value ()); - return octave_value (); -} +DEFASSIGNOP_FN (assign, complex_matrix, complex_matrix, assign) void install_cm_cm_ops (void)
--- a/src/op-cm-cs.cc +++ b/src/op-cm-cs.cc @@ -33,39 +33,17 @@ #include "ov-cx-mat.h" #include "ov-complex.h" #include "ov-typeinfo.h" -#include "op-cm-cs.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex matrix by complex scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return octave_value (v1.complex_matrix_value () + v2.complex_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); +DEFBINOP_OP (add, complex_matrix, complex, +) +DEFBINOP_OP (sub, complex_matrix, complex, -) +DEFBINOP_OP (mul, complex_matrix, complex, *) - return octave_value (v1.complex_matrix_value () - v2.complex_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return octave_value (v1.complex_matrix_value () * v2.complex_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex_matrix, complex) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); @@ -77,79 +55,23 @@ return octave_value (v1.complex_matrix_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return xpow (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -ldiv (const octave_value& v1, const octave_value&) -{ - gripe_nonconformant ("operator \\", v1.rows (), v1.columns (), 1, 1); - return octave_value (); -} +DEFBINOP_FN (pow, complex_matrix, complex, xpow) -static octave_value -lt (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, complex_matrix, complex) { - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return mx_el_lt (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return mx_el_le (v1.complex_matrix_value (), v2.complex_value ()); + BINOP_NONCONFORMANT ("operator \\"); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return mx_el_eq (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return mx_el_ge (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); +DEFBINOP_FN (lt, complex_matrix, complex, mx_el_lt) +DEFBINOP_FN (le, complex_matrix, complex, mx_el_le) +DEFBINOP_FN (eq, complex_matrix, complex, mx_el_eq) +DEFBINOP_FN (ge, complex_matrix, complex, mx_el_ge) +DEFBINOP_FN (gt, complex_matrix, complex, mx_el_gt) +DEFBINOP_FN (ne, complex_matrix, complex, mx_el_ne) - return mx_el_gt (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return mx_el_ne (v1.complex_matrix_value (), v2.complex_value ()); -} +DEFBINOP_OP (el_mul, complex_matrix, complex, *) -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return octave_value (v1.complex_matrix_value () * v2.complex_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, complex_matrix, complex) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); @@ -161,47 +83,19 @@ return octave_value (v1.complex_matrix_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); +DEFBINOP_FN (el_pow, complex_matrix, complex, elem_xpow) - return elem_xpow (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex_matrix, complex) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); return x_el_div (v2.complex_value (), v1.complex_matrix_value ()); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); - - return mx_el_and (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); +DEFBINOP_FN (el_and, complex_matrix, complex, mx_el_and) +DEFBINOP_FN (el_or, complex_matrix, complex, mx_el_or) - return mx_el_or (v1.complex_matrix_value (), v2.complex_value ()); -} - -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) -{ - CAST_BINOP_ARGS (octave_complex_matrix&, const octave_complex&); - - v1.assign (idx, v2.complex_matrix_value ()); - return octave_value (); -} +DEFASSIGNOP_FN (assign, complex_matrix, complex, assign) void install_cm_cs_ops (void)
--- a/src/op-cm-m.cc +++ b/src/op-cm-m.cc @@ -36,165 +36,53 @@ #include "ov-cx-mat.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" -#include "op-cm-m.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex matrix by matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return octave_value (v1.complex_matrix_value () + v2.matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); +DEFBINOP_OP (add, complex_matrix, matrix, +) +DEFBINOP_OP (sub, complex_matrix, matrix, -) +DEFBINOP_OP (mul, complex_matrix, matrix, *) - return octave_value (v1.complex_matrix_value () - v2.matrix_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return octave_value (v1.complex_matrix_value () * v2.matrix_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex_matrix, matrix) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); return xdiv (v1.complex_matrix_value (), v2.matrix_value ()); } -static octave_value -pow (const octave_value&, const octave_value&) +DEFBINOPX (pow, complex_matrix, matrix) { error ("can't do A ^ B for A and B both matrices"); return octave_value (); } -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return xleftdiv (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_lt (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_le (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_eq (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_ge (v1.complex_matrix_value (), v2.matrix_value ()); -} +DEFBINOP_FN (ldiv, complex_matrix, matrix, xleftdiv) -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_gt (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_ne (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); +DEFBINOP_FN (lt, complex_matrix, matrix, mx_el_lt) +DEFBINOP_FN (le, complex_matrix, matrix, mx_el_le) +DEFBINOP_FN (eq, complex_matrix, matrix, mx_el_eq) +DEFBINOP_FN (ge, complex_matrix, matrix, mx_el_ge) +DEFBINOP_FN (gt, complex_matrix, matrix, mx_el_gt) +DEFBINOP_FN (ne, complex_matrix, matrix, mx_el_ne) - return product (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return quotient (v1.complex_matrix_value (), v2.matrix_value ()); -} +DEFBINOP_FN (el_mul, complex_matrix, matrix, product) +DEFBINOP_FN (el_div, complex_matrix, matrix, quotient) +DEFBINOP_FN (el_pow, complex_matrix, matrix, elem_xpow) -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return elem_xpow (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex_matrix, matrix) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); return quotient (v2.matrix_value (), v1.complex_matrix_value ()); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); - - return mx_el_and (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&); +DEFBINOP_FN (el_and, complex_matrix, matrix, mx_el_and) +DEFBINOP_FN (el_or, complex_matrix, matrix, mx_el_or) - return mx_el_or (v1.complex_matrix_value (), v2.matrix_value ()); -} - -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) -{ - CAST_BINOP_ARGS (octave_complex_matrix&, const octave_matrix&); - - v1.assign (idx, v2.complex_matrix_value ()); - return octave_value (); -} +DEFASSIGNOP_FN (assign, complex_matrix, matrix, assign) void install_cm_m_ops (void)
--- a/src/op-cm-s.cc +++ b/src/op-cm-s.cc @@ -35,39 +35,17 @@ #include "ov-cx-mat.h" #include "ov-scalar.h" #include "ov-typeinfo.h" -#include "op-cm-s.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex matrix by scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return octave_value (v1.complex_matrix_value () + v2.double_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); +DEFBINOP_OP (add, complex_matrix, scalar, +) +DEFBINOP_OP (sub, complex_matrix, scalar, -) +DEFBINOP_OP (mul, complex_matrix, scalar, *) - return octave_value (v1.complex_matrix_value () - v2.double_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return octave_value (v1.complex_matrix_value () * v2.double_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex_matrix, scalar) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); @@ -79,79 +57,23 @@ return octave_value (v1.complex_matrix_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return xpow (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -ldiv (const octave_value& v1, const octave_value&) -{ - gripe_nonconformant ("operator \\", v1.rows (), v1.columns (), 1, 1); - return octave_value (); -} +DEFBINOP_FN (pow, complex_matrix, scalar, xpow) -static octave_value -lt (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, complex_matrix, scalar) { - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return mx_el_lt (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return mx_el_le (v1.complex_matrix_value (), v2.double_value ()); + BINOP_NONCONFORMANT ("operator \\"); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return mx_el_eq (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return mx_el_ge (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); +DEFBINOP_FN (lt, complex_matrix, scalar, mx_el_lt) +DEFBINOP_FN (le, complex_matrix, scalar, mx_el_le) +DEFBINOP_FN (eq, complex_matrix, scalar, mx_el_eq) +DEFBINOP_FN (ge, complex_matrix, scalar, mx_el_ge) +DEFBINOP_FN (gt, complex_matrix, scalar, mx_el_gt) +DEFBINOP_FN (ne, complex_matrix, scalar, mx_el_ne) - return mx_el_gt (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return mx_el_ne (v1.complex_matrix_value (), v2.double_value ()); -} +DEFBINOP_OP (el_mul, complex_matrix, scalar, *) -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return octave_value (v1.complex_matrix_value () * v2.double_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, complex_matrix, scalar) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); @@ -163,47 +85,19 @@ return octave_value (v1.complex_matrix_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); +DEFBINOP_FN (el_pow, complex_matrix, scalar, elem_xpow) - return elem_xpow (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex_matrix, scalar) { CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); return x_el_div (v2.double_value (), v1.complex_matrix_value ()); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); - - return mx_el_and (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); +DEFBINOP_FN (el_and, complex_matrix, scalar, mx_el_and) +DEFBINOP_FN (el_or, complex_matrix, scalar, mx_el_or) - return mx_el_or (v1.complex_matrix_value (), v2.double_value ()); -} - -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) -{ - CAST_BINOP_ARGS (octave_complex_matrix&, const octave_scalar&); - - v1.assign (idx, v2.complex_matrix_value ()); - return octave_value (); -} +DEFASSIGNOP_FN (assign, complex_matrix, scalar, assign) void install_cm_s_ops (void)
--- a/src/op-cs-cm.cc +++ b/src/op-cs-cm.cc @@ -33,54 +33,24 @@ #include "ov-complex.h" #include "ov-cx-mat.h" #include "ov-typeinfo.h" -#include "op-cs-cm.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex scalar by complex matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); +DEFBINOP_OP (add, complex, complex_matrix, +) +DEFBINOP_OP (sub, complex, complex_matrix, -) +DEFBINOP_OP (mul, complex, complex_matrix, *) - return octave_value (v1.complex_value () + v2.complex_matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex, complex_matrix) { - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return octave_value (v1.complex_value () - v2.complex_matrix_value ()); + BINOP_NONCONFORMANT ("operator /"); } -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return octave_value (v1.complex_value () * v2.complex_matrix_value ()); -} +DEFBINOP_FN (pow, complex, complex_matrix, xpow) -static octave_value -div (const octave_value&, const octave_value& v2) -{ - gripe_nonconformant ("operator /", 1, 1, v2.rows (), v2.columns ()); - return octave_value (); -} - -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return xpow (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, complex, complex_matrix) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); @@ -92,80 +62,18 @@ return octave_value (v2.complex_matrix_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_lt (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_le (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_eq (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_ge (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); +DEFBINOP_FN (lt, complex, complex_matrix, mx_el_lt) +DEFBINOP_FN (le, complex, complex_matrix, mx_el_le) +DEFBINOP_FN (eq, complex, complex_matrix, mx_el_eq) +DEFBINOP_FN (ge, complex, complex_matrix, mx_el_ge) +DEFBINOP_FN (gt, complex, complex_matrix, mx_el_gt) +DEFBINOP_FN (ne, complex, complex_matrix, mx_el_ne) - return mx_el_gt (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_ne (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return octave_value (v1.complex_value () * v2.complex_matrix_value ()); -} +DEFBINOP_OP (el_mul, complex, complex_matrix, *) +DEFBINOP_FN (el_div, complex, complex_matrix, x_el_div) +DEFBINOP_FN (el_pow, complex, complex_matrix, elem_xpow) -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return x_el_div (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return elem_xpow (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex, complex_matrix) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); @@ -177,24 +85,10 @@ return octave_value (v2.complex_matrix_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_and (v1.complex_value (), v2.complex_matrix_value ()); -} +DEFBINOP_FN (el_and, complex, complex_matrix, mx_el_and) +DEFBINOP_FN (el_or, complex, complex_matrix, mx_el_or) -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); - - return mx_el_or (v1.complex_value (), v2.complex_matrix_value ()); -} - -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, complex, complex_matrix) { CAST_CONV_ARG (const octave_complex&);
--- a/src/op-cs-cs.cc +++ b/src/op-cs-cs.cc @@ -33,39 +33,17 @@ #include "ov-complex.h" #include "ov-cx-mat.h" #include "ov-typeinfo.h" -#include "op-cs-cs.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex scalar by complex scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); - - return octave_value (v1.complex_value () + v2.complex_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); +DEFBINOP_OP (add, complex, complex, +) +DEFBINOP_OP (sub, complex, complex, -) +DEFBINOP_OP (mul, complex, complex, *) - return octave_value (v1.complex_value () - v2.complex_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); - - return octave_value (v1.complex_value () * v2.complex_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); @@ -77,16 +55,9 @@ return octave_value (v1.complex_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); +DEFBINOP_FN (pow, complex, complex, xpow) - return xpow (v1.complex_value (), v2.complex_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); @@ -98,64 +69,51 @@ return octave_value (v2.complex_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) +DEFBINOP (lt, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return real (v1.complex_value ()) < real (v2.complex_value ()); } -static octave_value -le (const octave_value& a1, const octave_value& a2) +DEFBINOP (le, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return real (v1.complex_value ()) <= real (v2.complex_value ()); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) +DEFBINOP (eq, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return v1.complex_value () == v2.complex_value (); } -static octave_value -ge (const octave_value& a1, const octave_value& a2) +DEFBINOP (ge, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return real (v1.complex_value ()) >= real (v2.complex_value ()); } -static octave_value -gt (const octave_value& a1, const octave_value& a2) +DEFBINOP (gt, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return real (v1.complex_value ()) > real (v2.complex_value ()); } -static octave_value -ne (const octave_value& a1, const octave_value& a2) +DEFBINOP (ne, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return v1.complex_value () != v2.complex_value (); } -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); +DEFBINOP_OP (el_mul, complex, complex, *) - return octave_value (v1.complex_value () * v2.complex_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); @@ -167,16 +125,9 @@ return octave_value (v1.complex_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); +DEFBINOP_FN (el_pow, complex, complex, xpow) - return xpow (v1.complex_value (), v2.complex_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); @@ -188,24 +139,21 @@ return octave_value (v2.complex_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_and, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return v1.complex_value () != 0.0 && v2.complex_value () != 0.0; } -static octave_value -el_or (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_or, complex, complex) { CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); return v1.complex_value () != 0.0 || v2.complex_value () != 0.0; } -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, complex, complex_matrix) { CAST_CONV_ARG (const octave_complex&);
--- a/src/op-cs-m.cc +++ b/src/op-cs-m.cc @@ -37,54 +37,24 @@ #include "ov-cx-mat.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" -#include "op-cs-m.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex scalar by matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); +DEFBINOP_OP (add, complex, matrix, +) +DEFBINOP_OP (sub, complex, matrix, -) +DEFBINOP_OP (mul, complex, matrix, *) - return octave_value (v1.complex_value () + v2.matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex, matrix) { - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return octave_value (v1.complex_value () - v2.matrix_value ()); + BINOP_NONCONFORMANT ("operator /"); } -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return octave_value (v1.complex_value () * v2.matrix_value ()); -} +DEFBINOP_FN (pow, complex, matrix, xpow) -static octave_value -div (const octave_value&, const octave_value& v2) -{ - gripe_nonconformant ("operator /", 1, 1, v2.rows (), v2.columns ()); - return octave_value (); -} - -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return xpow (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, complex, matrix) { CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); @@ -96,80 +66,18 @@ return octave_value (v2.matrix_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_lt (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_le (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_eq (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_ge (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); +DEFBINOP_FN (lt, complex, matrix, mx_el_lt) +DEFBINOP_FN (le, complex, matrix, mx_el_le) +DEFBINOP_FN (eq, complex, matrix, mx_el_eq) +DEFBINOP_FN (ge, complex, matrix, mx_el_ge) +DEFBINOP_FN (gt, complex, matrix, mx_el_gt) +DEFBINOP_FN (ne, complex, matrix, mx_el_ne) - return mx_el_gt (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_ne (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return octave_value (v1.complex_value () * v2.matrix_value ()); -} +DEFBINOP_OP (el_mul, complex, matrix, *) +DEFBINOP_FN (el_div, complex, matrix, x_el_div) +DEFBINOP_FN (el_pow, complex, matrix, elem_xpow) -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return x_el_div (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return elem_xpow (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex, matrix) { CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); @@ -181,24 +89,10 @@ return octave_value (v2.matrix_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_and (v1.complex_value (), v2.matrix_value ()); -} +DEFBINOP_FN (el_and, complex, matrix, mx_el_and) +DEFBINOP_FN (el_or, complex, matrix, mx_el_or) -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); - - return mx_el_or (v1.complex_value (), v2.matrix_value ()); -} - -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, complex, complex_matrix) { CAST_CONV_ARG (const octave_complex&);
--- a/src/op-cs-s.cc +++ b/src/op-cs-s.cc @@ -34,39 +34,17 @@ #include "ov-cx-mat.h" #include "ov-scalar.h" #include "ov-typeinfo.h" -#include "op-cs-s.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // complex scalar by scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); - - return octave_value (v1.complex_value () + v2.double_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); +DEFBINOP_OP (add, complex, scalar, +) +DEFBINOP_OP (sub, complex, scalar, -) +DEFBINOP_OP (mul, complex, scalar, *) - return octave_value (v1.complex_value () - v2.double_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); - - return octave_value (v1.complex_value () * v2.double_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); @@ -78,16 +56,9 @@ return octave_value (v1.complex_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); +DEFBINOP_FN (pow, complex, scalar, xpow) - return xpow (v1.complex_value (), v2.double_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); @@ -99,64 +70,51 @@ return octave_value (v2.complex_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) +DEFBINOP (lt, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return real (v1.complex_value ()) < v2.double_value (); } -static octave_value -le (const octave_value& a1, const octave_value& a2) +DEFBINOP (le, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return real (v1.complex_value ()) <= v2.double_value (); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) +DEFBINOP (eq, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return v1.complex_value () == v2.double_value (); } -static octave_value -ge (const octave_value& a1, const octave_value& a2) +DEFBINOP (ge, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return real (v1.complex_value ()) >= v2.double_value (); } -static octave_value -gt (const octave_value& a1, const octave_value& a2) +DEFBINOP (gt, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return real (v1.complex_value ()) > v2.double_value (); } -static octave_value -ne (const octave_value& a1, const octave_value& a2) +DEFBINOP (ne, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return v1.complex_value () != v2.double_value (); } -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); +DEFBINOP_OP (el_mul, complex, scalar, *) - return octave_value (v1.complex_value () * v2.double_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); @@ -168,16 +126,9 @@ return octave_value (v1.complex_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); +DEFBINOP_FN (el_pow, complex, scalar, xpow) - return xpow (v1.complex_value (), v2.double_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); @@ -189,24 +140,21 @@ return octave_value (v2.complex_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_and, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return v1.complex_value () != 0.0 && v2.double_value (); } -static octave_value -el_or (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_or, complex, scalar) { CAST_BINOP_ARGS (const octave_complex&, const octave_scalar&); return v1.complex_value () != 0.0 || v2.double_value (); } -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, complex, complex_matrix) { CAST_CONV_ARG (const octave_complex&);
--- a/src/op-m-cm.cc +++ b/src/op-m-cm.cc @@ -36,158 +36,53 @@ #include "ov-re-mat.h" #include "ov-cx-mat.h" #include "ov-typeinfo.h" -#include "op-m-cm.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // matrix by complex matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return octave_value (v1.matrix_value () + v2.complex_matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); +DEFBINOP_OP (add, matrix, complex_matrix, +) +DEFBINOP_OP (sub, matrix, complex_matrix, -) +DEFBINOP_OP (mul, matrix, complex_matrix, *) - return octave_value (v1.matrix_value () - v2.complex_matrix_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return octave_value (v1.matrix_value () * v2.complex_matrix_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, matrix, complex_matrix) { CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); return xdiv (v1.matrix_value (), v2.complex_matrix_value ()); } -static octave_value -pow (const octave_value&, const octave_value&) +DEFBINOPX (pow, matrix, complex_matrix) { error ("can't do A ^ B for A and B both matrices"); return octave_value (); } -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return xleftdiv (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_lt (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_le (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_eq (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_ge (v1.matrix_value (), v2.complex_matrix_value ()); -} +DEFBINOP_FN (ldiv, matrix, complex_matrix, xleftdiv) -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_gt (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_ne (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); +DEFBINOP_FN (lt, matrix, complex_matrix, mx_el_lt) +DEFBINOP_FN (le, matrix, complex_matrix, mx_el_le) +DEFBINOP_FN (eq, matrix, complex_matrix, mx_el_eq) +DEFBINOP_FN (ge, matrix, complex_matrix, mx_el_ge) +DEFBINOP_FN (gt, matrix, complex_matrix, mx_el_gt) +DEFBINOP_FN (ne, matrix, complex_matrix, mx_el_ne) - return product (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return quotient (v1.matrix_value (), v2.complex_matrix_value ()); -} +DEFBINOP_FN (el_mul, matrix, complex_matrix, product) +DEFBINOP_FN (el_div, matrix, complex_matrix, quotient) +DEFBINOP_FN (el_pow, matrix, complex_matrix, elem_xpow) -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return elem_xpow (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, matrix, complex_matrix) { CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); return quotient (v2.complex_matrix_value (), v1.matrix_value ()); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_and (v1.matrix_value (), v2.complex_matrix_value ()); -} +DEFBINOP_FN (el_and, matrix, complex_matrix, mx_el_and) +DEFBINOP_FN (el_or, matrix, complex_matrix, mx_el_or) -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); - - return mx_el_or (v1.matrix_value (), v2.complex_matrix_value ()); -} - -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, matrix, complex_matrix) { CAST_CONV_ARG (const octave_matrix&);
--- a/src/op-m-cs.cc +++ b/src/op-m-cs.cc @@ -37,39 +37,17 @@ #include "ov-cx-mat.h" #include "ov-complex.h" #include "ov-typeinfo.h" -#include "op-m-cs.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // matrix by complex scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return octave_value (v1.matrix_value () + v2.complex_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); +DEFBINOP_OP (add, matrix, complex, +) +DEFBINOP_OP (sub, matrix, complex, -) +DEFBINOP_OP (mul, matrix, complex, *) - return octave_value (v1.matrix_value () - v2.complex_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return octave_value (v1.matrix_value () * v2.complex_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, matrix, complex) { CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); @@ -81,79 +59,23 @@ return octave_value (v1.matrix_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return xpow (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value -ldiv (const octave_value& v1, const octave_value&) -{ - gripe_nonconformant ("operator \\", v1.rows (), v1.columns (), 1, 1); - return octave_value (); -} +DEFBINOP_FN (pow, matrix, complex, xpow) -static octave_value -lt (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, matrix, complex) { - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_lt (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_le (v1.matrix_value (), v2.complex_value ()); + BINOP_NONCONFORMANT ("operator \\"); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_eq (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_ge (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); +DEFBINOP_FN (lt, matrix, complex, mx_el_lt) +DEFBINOP_FN (le, matrix, complex, mx_el_le) +DEFBINOP_FN (eq, matrix, complex, mx_el_eq) +DEFBINOP_FN (ge, matrix, complex, mx_el_ge) +DEFBINOP_FN (gt, matrix, complex, mx_el_gt) +DEFBINOP_FN (ne, matrix, complex, mx_el_ne) - return mx_el_gt (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_ne (v1.matrix_value (), v2.complex_value ()); -} +DEFBINOP_OP (el_mul, matrix, complex, *) -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return octave_value (v1.matrix_value () * v2.complex_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, matrix, complex) { CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); @@ -165,40 +87,19 @@ return octave_value (v1.matrix_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); +DEFBINOP_FN (el_pow, matrix, complex, elem_xpow) - return elem_xpow (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, matrix, complex) { CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); return x_el_div (v2.complex_value (), v1.matrix_value ()); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_and (v1.matrix_value (), v2.complex_value ()); -} +DEFBINOP_FN (el_and, matrix, complex, mx_el_and) +DEFBINOP_FN (el_or, matrix, complex, mx_el_or) -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); - - return mx_el_or (v1.matrix_value (), v2.complex_value ()); -} - -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, matrix, complex_matrix) { CAST_CONV_ARG (const octave_matrix&);
--- a/src/op-m-m.cc +++ b/src/op-m-m.cc @@ -32,165 +32,53 @@ #include "ov.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" -#include "op-m-m.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // matrix by matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return octave_value (v1.matrix_value () + v2.matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); +DEFBINOP_OP (add, matrix, matrix, +) +DEFBINOP_OP (sub, matrix, matrix, -) +DEFBINOP_OP (mul, matrix, matrix, *) - return octave_value (v1.matrix_value () - v2.matrix_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return octave_value (v1.matrix_value () * v2.matrix_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, matrix, matrix) { CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); return xdiv (v1.matrix_value (), v2.matrix_value ()); } -static octave_value -pow (const octave_value&, const octave_value&) +DEFBINOPX (pow, matrix, matrix) { error ("can't do A ^ B for A and B both matrices"); return octave_value (); } -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return xleftdiv (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_lt (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_le (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_eq (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_ge (v1.matrix_value (), v2.matrix_value ()); -} +DEFBINOP_FN (ldiv, matrix, matrix, xleftdiv) -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_gt (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_ne (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); +DEFBINOP_FN (lt, matrix, matrix, mx_el_lt) +DEFBINOP_FN (le, matrix, matrix, mx_el_le) +DEFBINOP_FN (eq, matrix, matrix, mx_el_eq) +DEFBINOP_FN (ge, matrix, matrix, mx_el_ge) +DEFBINOP_FN (gt, matrix, matrix, mx_el_gt) +DEFBINOP_FN (ne, matrix, matrix, mx_el_ne) - return octave_value (product (v1.matrix_value (), v2.matrix_value ())); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return octave_value (quotient (v1.matrix_value (), v2.matrix_value ())); -} +DEFBINOP_FN (el_mul, matrix, matrix, product) +DEFBINOP_FN (el_div, matrix, matrix, quotient) +DEFBINOP_FN (el_pow, matrix, matrix, elem_xpow) -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return elem_xpow (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, matrix, matrix) { CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); return octave_value (quotient (v2.matrix_value (), v1.matrix_value ())); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); - - return mx_el_and (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); +DEFBINOP_FN (el_and, matrix, matrix, mx_el_and) +DEFBINOP_FN (el_or, matrix, matrix, mx_el_or) - return mx_el_or (v1.matrix_value (), v2.matrix_value ()); -} - -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) -{ - CAST_BINOP_ARGS (octave_matrix&, const octave_matrix&); - - v1.assign (idx, v2.matrix_value ()); - return octave_value (); -} +DEFASSIGNOP_FN (assign, matrix, matrix, assign) void install_m_m_ops (void)
--- a/src/op-m-s.cc +++ b/src/op-m-s.cc @@ -33,39 +33,17 @@ #include "ov-re-mat.h" #include "ov-scalar.h" #include "ov-typeinfo.h" -#include "op-m-s.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // matrix by scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return octave_value (v1.matrix_value () + v2.double_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); +DEFBINOP_OP (add, matrix, scalar, +) +DEFBINOP_OP (sub, matrix, scalar, -) +DEFBINOP_OP (mul, matrix, scalar, *) - return octave_value (v1.matrix_value () - v2.double_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return octave_value (v1.matrix_value () * v2.double_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, matrix, scalar) { CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); @@ -77,79 +55,23 @@ return octave_value (v1.matrix_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return xpow (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -ldiv (const octave_value& v1, const octave_value&) -{ - gripe_nonconformant ("operator \\", v1.rows (), v1.columns (), 1, 1); - return octave_value (); -} +DEFBINOP_FN (pow, matrix, scalar, xpow) -static octave_value -lt (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, matrix, scalar) { - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return mx_el_lt (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return mx_el_le (v1.matrix_value (), v2.double_value ()); + BINOP_NONCONFORMANT ("operator \\"); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return mx_el_eq (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return mx_el_ge (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); +DEFBINOP_FN (lt, matrix, scalar, mx_el_lt) +DEFBINOP_FN (le, matrix, scalar, mx_el_le) +DEFBINOP_FN (eq, matrix, scalar, mx_el_eq) +DEFBINOP_FN (ge, matrix, scalar, mx_el_ge) +DEFBINOP_FN (gt, matrix, scalar, mx_el_gt) +DEFBINOP_FN (ne, matrix, scalar, mx_el_ne) - return mx_el_gt (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return mx_el_ne (v1.matrix_value (), v2.double_value ()); -} +DEFBINOP_OP (el_mul, matrix, scalar, *) -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return octave_value (v1.matrix_value () * v2.double_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, matrix, scalar) { CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); @@ -161,47 +83,19 @@ return octave_value (v1.matrix_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); +DEFBINOP_FN (el_pow, matrix, scalar, elem_xpow) - return elem_xpow (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, matrix, scalar) { CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); return x_el_div (v2.double_value (), v1.matrix_value ()); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); - - return mx_el_and (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_matrix&, const octave_scalar&); +DEFBINOP_FN (el_and, matrix, scalar, mx_el_and) +DEFBINOP_FN (el_or, matrix, scalar, mx_el_or) - return mx_el_or (v1.matrix_value (), v2.double_value ()); -} - -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) -{ - CAST_BINOP_ARGS (octave_matrix&, const octave_scalar&); - - v1.assign (idx, v2.matrix_value ()); - return octave_value (); -} +DEFASSIGNOP_FN (assign, matrix, scalar, assign) void install_m_s_ops (void)
--- a/src/op-s-cm.cc +++ b/src/op-s-cm.cc @@ -35,54 +35,24 @@ #include "ov-scalar.h" #include "ov-cx-mat.h" #include "ov-typeinfo.h" -#include "op-s-cm.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // scalar by complex matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); +DEFBINOP_OP (add, scalar, complex_matrix, +) +DEFBINOP_OP (sub, scalar, complex_matrix, -) +DEFBINOP_OP (mul, scalar, complex_matrix, *) - return octave_value (v1.double_value () + v2.complex_matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, scalar, complex_matrix) { - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return octave_value (v1.double_value () - v2.complex_matrix_value ()); + BINOP_NONCONFORMANT ("operator /"); } -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return octave_value (v1.double_value () * v2.complex_matrix_value ()); -} +DEFBINOP_FN (pow, scalar, complex_matrix, xpow) -static octave_value -div (const octave_value&, const octave_value& v2) -{ - gripe_nonconformant ("operator /", 1, 1, v2.rows (), v2.columns ()); - return octave_value (); -} - -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return xpow (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, scalar, complex_matrix) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); @@ -94,80 +64,18 @@ return octave_value (v2.complex_matrix_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return mx_el_lt (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return mx_el_le (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return mx_el_eq (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return mx_el_ge (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); +DEFBINOP_FN (lt, scalar, complex_matrix, mx_el_lt) +DEFBINOP_FN (le, scalar, complex_matrix, mx_el_le) +DEFBINOP_FN (eq, scalar, complex_matrix, mx_el_eq) +DEFBINOP_FN (ge, scalar, complex_matrix, mx_el_ge) +DEFBINOP_FN (gt, scalar, complex_matrix, mx_el_gt) +DEFBINOP_FN (ne, scalar, complex_matrix, mx_el_ne) - return mx_el_gt (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return mx_el_ne (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return octave_value (v1.double_value () * v2.complex_matrix_value ()); -} +DEFBINOP_OP (el_mul, scalar, complex_matrix, *) +DEFBINOP_FN (el_div, scalar, complex_matrix, x_el_div) +DEFBINOP_FN (el_pow, scalar, complex_matrix, elem_xpow) -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return x_el_div (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); - - return elem_xpow (v1.double_value (), v2.complex_matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, scalar, complex_matrix) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); @@ -179,28 +87,25 @@ return octave_value (v2.complex_matrix_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_and, scalar, complex_matrix) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); return mx_el_and (v1.double_value (), v2.complex_matrix_value ()); } -static octave_value -el_or (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_or, scalar, complex_matrix) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&); return mx_el_or (v1.double_value (), v2.complex_matrix_value ()); } -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, scalar, complex_matrix) { CAST_CONV_ARG (const octave_scalar&); - return new octave_complex_matrix (v.complex_matrix_value ()); + return new octave_complex_matrix (ComplexMatrix (v.matrix_value ())); } void
--- a/src/op-s-cs.cc +++ b/src/op-s-cs.cc @@ -34,39 +34,17 @@ #include "ov-complex.h" #include "ov-cx-mat.h" #include "ov-typeinfo.h" -#include "op-s-cs.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // scalar by complex scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - - return octave_value (v1.double_value () + v2.complex_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); +DEFBINOP_OP (add, scalar, complex, +) +DEFBINOP_OP (sub, scalar, complex, -) +DEFBINOP_OP (mul, scalar, complex, *) - return octave_value (v1.double_value () - v2.complex_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - - return octave_value (v1.double_value () * v2.complex_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); @@ -78,16 +56,9 @@ return octave_value (v1.double_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); +DEFBINOP_FN (pow, scalar, complex, xpow) - return xpow (v1.double_value (), v2.complex_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); @@ -99,64 +70,51 @@ return octave_value (v2.complex_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - - return octave_value (v1.double_value () < v2.double_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) +DEFBINOP (lt, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - return octave_value (v1.double_value () <= v2.double_value ()); + return v1.double_value () < real (v2.complex_value ()); } -static octave_value -eq (const octave_value& a1, const octave_value& a2) +DEFBINOP (le, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - return octave_value (v1.double_value () == v2.complex_value ()); + return v1.double_value () <= real (v2.complex_value ()); } -static octave_value -ge (const octave_value& a1, const octave_value& a2) +DEFBINOP (eq, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - return octave_value (v1.double_value () >= v2.double_value ()); + return v1.double_value () == v2.complex_value (); } -static octave_value -gt (const octave_value& a1, const octave_value& a2) +DEFBINOP (ge, scalar, complex) +{ + CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); + + return v1.double_value () >= real (v2.complex_value ()); +} + +DEFBINOP (gt, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - return octave_value (v1.double_value () > v2.double_value ()); + return v1.double_value () > real (v2.complex_value ()); } -static octave_value -ne (const octave_value& a1, const octave_value& a2) +DEFBINOP (ne, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); - return octave_value (v1.double_value () != v2.complex_value ()); + return v1.double_value () != v2.complex_value (); } -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); +DEFBINOP_OP (el_mul, scalar, complex, *) - return octave_value (v1.double_value () * v2.complex_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); @@ -168,16 +126,9 @@ return octave_value (v1.double_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); +DEFBINOP_FN (el_pow, scalar, complex, xpow) - return xpow (v1.double_value (), v2.complex_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); @@ -189,24 +140,21 @@ return octave_value (v2.complex_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_and, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); return octave_value (v1.double_value () && (v2.complex_value () != 0.0)); } -static octave_value -el_or (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_or, scalar, complex) { CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); return octave_value (v1.double_value () || (v2.complex_value () != 0.0)); } -static octave_value * -complex_matrix_conv (const octave_value& a) +DEFCONV (complex_matrix_conv, scalar, complex_matrix) { CAST_CONV_ARG (const octave_scalar&);
--- a/src/op-s-m.cc +++ b/src/op-s-m.cc @@ -33,54 +33,24 @@ #include "ov-scalar.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" -#include "op-s-m.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // scalar by matrix ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); +DEFBINOP_OP (add, scalar, matrix, +) +DEFBINOP_OP (sub, scalar, matrix, -) +DEFBINOP_OP (mul, scalar, matrix, *) - return octave_value (v1.double_value () + v2.matrix_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, scalar, matrix) { - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return octave_value (v1.double_value () - v2.matrix_value ()); + BINOP_NONCONFORMANT ("operator /"); } -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return octave_value (v1.double_value () * v2.matrix_value ()); -} +DEFBINOP_FN (pow, scalar, matrix, xpow) -static octave_value -div (const octave_value&, const octave_value& v2) -{ - gripe_nonconformant ("operator /", 1, 1, v2.rows (), v2.columns ()); - return octave_value (); -} - -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return xpow (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, scalar, matrix) { CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); @@ -92,80 +62,18 @@ return octave_value (v2.matrix_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_lt (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_le (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_eq (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_ge (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); +DEFBINOP_FN (lt, scalar, matrix, mx_el_lt) +DEFBINOP_FN (le, scalar, matrix, mx_el_le) +DEFBINOP_FN (eq, scalar, matrix, mx_el_eq) +DEFBINOP_FN (ge, scalar, matrix, mx_el_ge) +DEFBINOP_FN (gt, scalar, matrix, mx_el_gt) +DEFBINOP_FN (ne, scalar, matrix, mx_el_ne) - return mx_el_gt (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_ne (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return octave_value (v1.double_value () * v2.matrix_value ()); -} +DEFBINOP_OP (el_mul, scalar, matrix, *) +DEFBINOP_FN (el_div, scalar, matrix, x_el_div) +DEFBINOP_FN (el_pow, scalar, matrix, elem_xpow) -static octave_value -el_div (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return x_el_div (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return elem_xpow (v1.double_value (), v2.matrix_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, scalar, matrix) { CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); @@ -177,24 +85,10 @@ return octave_value (v2.matrix_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_and (v1.double_value (), v2.matrix_value ()); -} +DEFBINOP_FN (el_and, scalar, matrix, mx_el_and) +DEFBINOP_FN (el_or, scalar, matrix, mx_el_or) -static octave_value -el_or (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_matrix&); - - return mx_el_or (v1.double_value (), v2.matrix_value ()); -} - -static octave_value * -matrix_conv (const octave_value& a) +DEFCONV (matrix_conv, scalar, matrix) { CAST_CONV_ARG (const octave_scalar&);
--- a/src/op-s-s.cc +++ b/src/op-s-s.cc @@ -33,39 +33,17 @@ #include "ov-scalar.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" -#include "op-s-s.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" // scalar by scalar ops. -static octave_value -add (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () + v2.double_value ()); -} - -static octave_value -sub (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); +DEFBINOP_OP (add, scalar, scalar, +) +DEFBINOP_OP (sub, scalar, scalar, -) +DEFBINOP_OP (mul, scalar, scalar, *) - return octave_value (v1.double_value () - v2.double_value ()); -} - -static octave_value -mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () * v2.double_value ()); -} - -static octave_value -div (const octave_value& a1, const octave_value& a2) +DEFBINOP (div, scalar, scalar) { CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); @@ -77,16 +55,9 @@ return octave_value (v1.double_value () / d); } -static octave_value -pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); +DEFBINOP_FN (pow, scalar, scalar, xpow) - return xpow (v1.double_value (), v2.double_value ()); -} - -static octave_value -ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (ldiv, scalar, scalar) { CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); @@ -98,64 +69,16 @@ return octave_value (v2.double_value () / d); } -static octave_value -lt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () < v2.double_value ()); -} - -static octave_value -le (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () <= v2.double_value ()); -} - -static octave_value -eq (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () == v2.double_value ()); -} - -static octave_value -ge (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); +DEFBINOP_OP (lt, scalar, scalar, <) +DEFBINOP_OP (le, scalar, scalar, <=) +DEFBINOP_OP (eq, scalar, scalar, ==) +DEFBINOP_OP (ge, scalar, scalar, >=) +DEFBINOP_OP (gt, scalar, scalar, >) +DEFBINOP_OP (ne, scalar, scalar, !=) - return octave_value (v1.double_value () >= v2.double_value ()); -} - -static octave_value -gt (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () > v2.double_value ()); -} +DEFBINOP_OP (el_mul, scalar, scalar, *) -static octave_value -ne (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () != v2.double_value ()); -} - -static octave_value -el_mul (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); - - return octave_value (v1.double_value () * v2.double_value ()); -} - -static octave_value -el_div (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_div, scalar, scalar) { CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); @@ -167,16 +90,9 @@ return octave_value (v1.double_value () / d); } -static octave_value -el_pow (const octave_value& a1, const octave_value& a2) -{ - CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); +DEFBINOP_FN (el_pow, scalar, scalar, xpow) - return xpow (v1.double_value (), v2.double_value ()); -} - -static octave_value -el_ldiv (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_ldiv, scalar, scalar) { CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); @@ -188,8 +104,7 @@ return octave_value (v2.double_value () / d); } -static octave_value -el_and (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_and, scalar, scalar) { CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); @@ -198,8 +113,7 @@ return octave_value (result); } -static octave_value -el_or (const octave_value& a1, const octave_value& a2) +DEFBINOP (el_or, scalar, scalar) { CAST_BINOP_ARGS (const octave_scalar&, const octave_scalar&); @@ -208,8 +122,7 @@ return octave_value (result); } -static octave_value * -matrix_conv (const octave_value& a) +DEFCONV (matrix_conv, scalar, matrix) { CAST_CONV_ARG (const octave_scalar&);
--- a/src/op-str-str.cc +++ b/src/op-str-str.cc @@ -36,8 +36,7 @@ // string by string ops. -static octave_value -eq (const octave_value& a1, const octave_value& a2) +DEFBINOP (eq, char_matrix_str, char_matrix_str) { CAST_BINOP_ARGS (const octave_char_matrix_str&, const octave_char_matrix_str&); @@ -67,8 +66,7 @@ } } -static octave_value -ne (const octave_value& a1, const octave_value& a2) +DEFBINOP (ne, char_matrix_str, char_matrix_str) { CAST_BINOP_ARGS (const octave_char_matrix_str&, const octave_char_matrix_str&); @@ -95,9 +93,7 @@ } } -static octave_value -assign (octave_value& a1, const octave_value_list& idx, - const octave_value& a2) +DEFASSIGNOP (assign, char_matrix_str, char_matrix_str) { CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_char_matrix_str&);
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -1074,7 +1074,7 @@ if (total_width > max_width && Vsplit_long_rows) { if (col != 0 && ! compact_format) - os << "\n"; + os << "\n\n"; int num_cols = lim - col; @@ -1086,6 +1086,9 @@ os << " Columns " << col + 1 << " and " << lim << ":\n"; else os << " Columns " << col + 1 << " through " << lim << ":\n"; + + if (! compact_format) + os << "\n"; } }