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