2928
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if defined (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "mx-cm-s.h" |
|
32 |
|
33 #include "gripes.h" |
|
34 #include "ov.h" |
|
35 #include "ov-cx-mat.h" |
|
36 #include "ov-scalar.h" |
|
37 #include "ov-typeinfo.h" |
|
38 #include "ops.h" |
|
39 #include "xdiv.h" |
|
40 #include "xpow.h" |
|
41 |
|
42 // complex matrix by scalar ops. |
|
43 |
|
44 DEFBINOP_OP (add, complex_matrix, scalar, +) |
|
45 DEFBINOP_OP (sub, complex_matrix, scalar, -) |
|
46 DEFBINOP_OP (mul, complex_matrix, scalar, *) |
|
47 |
|
48 DEFBINOP (div, complex_matrix, scalar) |
|
49 { |
|
50 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); |
|
51 |
|
52 double d = v2.double_value (); |
|
53 |
|
54 if (d == 0.0) |
|
55 gripe_divide_by_zero (); |
|
56 |
|
57 return octave_value (v1.complex_matrix_value () / d); |
|
58 } |
|
59 |
|
60 DEFBINOP_FN (pow, complex_matrix, scalar, xpow) |
|
61 |
|
62 DEFBINOP (ldiv, complex_matrix, scalar) |
|
63 { |
|
64 BINOP_NONCONFORMANT ("operator \\"); |
|
65 } |
|
66 |
|
67 DEFBINOP_FN (lt, complex_matrix, scalar, mx_el_lt) |
|
68 DEFBINOP_FN (le, complex_matrix, scalar, mx_el_le) |
|
69 DEFBINOP_FN (eq, complex_matrix, scalar, mx_el_eq) |
|
70 DEFBINOP_FN (ge, complex_matrix, scalar, mx_el_ge) |
|
71 DEFBINOP_FN (gt, complex_matrix, scalar, mx_el_gt) |
|
72 DEFBINOP_FN (ne, complex_matrix, scalar, mx_el_ne) |
|
73 |
|
74 DEFBINOP_OP (el_mul, complex_matrix, scalar, *) |
|
75 |
|
76 DEFBINOP (el_div, complex_matrix, scalar) |
|
77 { |
|
78 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); |
|
79 |
|
80 double d = v2.double_value (); |
|
81 |
|
82 if (d == 0.0) |
|
83 gripe_divide_by_zero (); |
|
84 |
|
85 return octave_value (v1.complex_matrix_value () / d); |
|
86 } |
|
87 |
|
88 DEFBINOP_FN (el_pow, complex_matrix, scalar, elem_xpow) |
|
89 |
|
90 DEFBINOP (el_ldiv, complex_matrix, scalar) |
|
91 { |
|
92 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); |
|
93 |
|
94 return x_el_div (v2.double_value (), v1.complex_matrix_value ()); |
|
95 } |
|
96 |
|
97 DEFBINOP_FN (el_and, complex_matrix, scalar, mx_el_and) |
|
98 DEFBINOP_FN (el_or, complex_matrix, scalar, mx_el_or) |
|
99 |
|
100 DEFASSIGNOP_FN (assign, complex_matrix, scalar, assign) |
|
101 |
|
102 void |
|
103 install_cm_s_ops (void) |
|
104 { |
3538
|
105 INSTALL_BINOP (op_add, octave_complex_matrix, octave_scalar, add); |
|
106 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_scalar, sub); |
|
107 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_scalar, mul); |
|
108 INSTALL_BINOP (op_div, octave_complex_matrix, octave_scalar, div); |
|
109 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_scalar, pow); |
|
110 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_scalar, ldiv); |
|
111 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_scalar, lt); |
|
112 INSTALL_BINOP (op_le, octave_complex_matrix, octave_scalar, le); |
|
113 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_scalar, eq); |
|
114 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_scalar, ge); |
|
115 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_scalar, gt); |
|
116 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_scalar, ne); |
|
117 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_scalar, el_mul); |
|
118 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_scalar, el_div); |
|
119 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_scalar, el_pow); |
|
120 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_scalar, el_ldiv); |
|
121 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_scalar, el_and); |
|
122 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_scalar, el_or); |
2928
|
123 |
3538
|
124 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_scalar, assign); |
2928
|
125 } |
|
126 |
|
127 /* |
|
128 ;;; Local Variables: *** |
|
129 ;;; mode: C++ *** |
|
130 ;;; End: *** |
|
131 */ |