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-m-cs.h" |
|
32 #include "mx-cs-m.h" |
|
33 |
|
34 #include "gripes.h" |
|
35 #include "ov.h" |
|
36 #include "ov-re-mat.h" |
|
37 #include "ov-cx-mat.h" |
|
38 #include "ov-complex.h" |
|
39 #include "ov-typeinfo.h" |
|
40 #include "ops.h" |
|
41 #include "xdiv.h" |
|
42 #include "xpow.h" |
|
43 |
|
44 // matrix by complex scalar ops. |
|
45 |
|
46 DEFBINOP_OP (add, matrix, complex, +) |
|
47 DEFBINOP_OP (sub, matrix, complex, -) |
|
48 DEFBINOP_OP (mul, matrix, complex, *) |
|
49 |
|
50 DEFBINOP (div, matrix, complex) |
|
51 { |
|
52 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
53 |
|
54 Complex d = v2.complex_value (); |
|
55 |
|
56 if (d == 0.0) |
|
57 gripe_divide_by_zero (); |
|
58 |
|
59 return octave_value (v1.matrix_value () / d); |
|
60 } |
|
61 |
|
62 DEFBINOP_FN (pow, matrix, complex, xpow) |
|
63 |
|
64 DEFBINOP (ldiv, matrix, complex) |
|
65 { |
|
66 BINOP_NONCONFORMANT ("operator \\"); |
|
67 } |
|
68 |
|
69 DEFBINOP_FN (lt, matrix, complex, mx_el_lt) |
|
70 DEFBINOP_FN (le, matrix, complex, mx_el_le) |
|
71 DEFBINOP_FN (eq, matrix, complex, mx_el_eq) |
|
72 DEFBINOP_FN (ge, matrix, complex, mx_el_ge) |
|
73 DEFBINOP_FN (gt, matrix, complex, mx_el_gt) |
|
74 DEFBINOP_FN (ne, matrix, complex, mx_el_ne) |
|
75 |
|
76 DEFBINOP_OP (el_mul, matrix, complex, *) |
|
77 |
|
78 DEFBINOP (el_div, matrix, complex) |
|
79 { |
|
80 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
81 |
|
82 Complex d = v2.complex_value (); |
|
83 |
|
84 if (d == 0.0) |
|
85 gripe_divide_by_zero (); |
|
86 |
|
87 return octave_value (v1.matrix_value () / d); |
|
88 } |
|
89 |
|
90 DEFBINOP_FN (el_pow, matrix, complex, elem_xpow) |
|
91 |
|
92 DEFBINOP (el_ldiv, matrix, complex) |
|
93 { |
|
94 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
95 |
|
96 return x_el_div (v2.complex_value (), v1.matrix_value ()); |
|
97 } |
|
98 |
|
99 DEFBINOP_FN (el_and, matrix, complex, mx_el_and) |
|
100 DEFBINOP_FN (el_or, matrix, complex, mx_el_or) |
|
101 |
|
102 DEFCONV (complex_matrix_conv, matrix, complex_matrix) |
|
103 { |
|
104 CAST_CONV_ARG (const octave_matrix&); |
|
105 |
|
106 return new octave_complex_matrix (ComplexMatrix (v.matrix_value ())); |
|
107 } |
|
108 |
|
109 void |
|
110 install_m_cs_ops (void) |
|
111 { |
3538
|
112 INSTALL_BINOP (op_add, octave_matrix, octave_complex, add); |
|
113 INSTALL_BINOP (op_sub, octave_matrix, octave_complex, sub); |
|
114 INSTALL_BINOP (op_mul, octave_matrix, octave_complex, mul); |
|
115 INSTALL_BINOP (op_div, octave_matrix, octave_complex, div); |
|
116 INSTALL_BINOP (op_pow, octave_matrix, octave_complex, pow); |
|
117 INSTALL_BINOP (op_ldiv, octave_matrix, octave_complex, ldiv); |
|
118 INSTALL_BINOP (op_lt, octave_matrix, octave_complex, lt); |
|
119 INSTALL_BINOP (op_le, octave_matrix, octave_complex, le); |
|
120 INSTALL_BINOP (op_eq, octave_matrix, octave_complex, eq); |
|
121 INSTALL_BINOP (op_ge, octave_matrix, octave_complex, ge); |
|
122 INSTALL_BINOP (op_gt, octave_matrix, octave_complex, gt); |
|
123 INSTALL_BINOP (op_ne, octave_matrix, octave_complex, ne); |
|
124 INSTALL_BINOP (op_el_mul, octave_matrix, octave_complex, el_mul); |
|
125 INSTALL_BINOP (op_el_div, octave_matrix, octave_complex, el_div); |
|
126 INSTALL_BINOP (op_el_pow, octave_matrix, octave_complex, el_pow); |
|
127 INSTALL_BINOP (op_el_ldiv, octave_matrix, octave_complex, el_ldiv); |
|
128 INSTALL_BINOP (op_el_and, octave_matrix, octave_complex, el_and); |
|
129 INSTALL_BINOP (op_el_or, octave_matrix, octave_complex, el_or); |
2928
|
130 |
|
131 INSTALL_ASSIGNCONV (octave_matrix, octave_complex, octave_complex_matrix); |
|
132 |
3538
|
133 INSTALL_WIDENOP (op_octave_matrix, octave_complex_matrix, complex_matrix_conv); |
2928
|
134 } |
|
135 |
|
136 /* |
|
137 ;;; Local Variables: *** |
|
138 ;;; mode: C++ *** |
|
139 ;;; End: *** |
|
140 */ |