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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2928
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2928
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "gripes.h" |
4055
|
28 #include "oct-obj.h" |
2928
|
29 #include "ov.h" |
|
30 #include "ov-cx-mat.h" |
|
31 #include "ov-complex.h" |
|
32 #include "ov-typeinfo.h" |
|
33 #include "ops.h" |
|
34 #include "xdiv.h" |
|
35 #include "xpow.h" |
|
36 |
|
37 // complex matrix by complex scalar ops. |
|
38 |
4550
|
39 DEFNDBINOP_OP (add, complex_matrix, complex, complex_array, complex, +) |
|
40 DEFNDBINOP_OP (sub, complex_matrix, complex, complex_array, complex, -) |
|
41 DEFNDBINOP_OP (mul, complex_matrix, complex, complex_array, complex, *) |
2928
|
42 |
|
43 DEFBINOP (div, complex_matrix, complex) |
|
44 { |
|
45 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
46 |
|
47 Complex d = v2.complex_value (); |
|
48 |
|
49 if (d == 0.0) |
|
50 gripe_divide_by_zero (); |
|
51 |
4550
|
52 return octave_value (v1.complex_array_value () / d); |
2928
|
53 } |
|
54 |
|
55 DEFBINOP_FN (pow, complex_matrix, complex, xpow) |
|
56 |
|
57 DEFBINOP (ldiv, complex_matrix, complex) |
|
58 { |
3766
|
59 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
60 |
|
61 ComplexMatrix m1 = v1.complex_matrix_value (); |
|
62 ComplexMatrix m2 = v2.complex_matrix_value (); |
5785
|
63 MatrixType typ = v1.matrix_type (); |
3766
|
64 |
5785
|
65 ComplexMatrix ret = xleftdiv (m1, m2, typ); |
|
66 v1.matrix_type (typ); |
|
67 return ret; |
2928
|
68 } |
|
69 |
4550
|
70 DEFNDBINOP_FN (lt, complex_matrix, complex, complex_array, complex, mx_el_lt) |
|
71 DEFNDBINOP_FN (le, complex_matrix, complex, complex_array, complex, mx_el_le) |
|
72 DEFNDBINOP_FN (eq, complex_matrix, complex, complex_array, complex, mx_el_eq) |
|
73 DEFNDBINOP_FN (ge, complex_matrix, complex, complex_array, complex, mx_el_ge) |
|
74 DEFNDBINOP_FN (gt, complex_matrix, complex, complex_array, complex, mx_el_gt) |
|
75 DEFNDBINOP_FN (ne, complex_matrix, complex, complex_array, complex, mx_el_ne) |
2928
|
76 |
4550
|
77 DEFNDBINOP_OP (el_mul, complex_matrix, complex, complex_array, complex, *) |
2928
|
78 |
|
79 DEFBINOP (el_div, complex_matrix, complex) |
|
80 { |
|
81 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
82 |
|
83 Complex d = v2.complex_value (); |
|
84 |
|
85 if (d == 0.0) |
|
86 gripe_divide_by_zero (); |
|
87 |
4550
|
88 return octave_value (v1.complex_array_value () / d); |
2928
|
89 } |
|
90 |
4550
|
91 DEFNDBINOP_FN (el_pow, complex_matrix, complex, complex_array, complex, elem_xpow) |
2928
|
92 |
|
93 DEFBINOP (el_ldiv, complex_matrix, complex) |
|
94 { |
|
95 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
96 |
4550
|
97 return x_el_div (v2.complex_value (), v1.complex_array_value ()); |
2928
|
98 } |
|
99 |
4550
|
100 DEFNDBINOP_FN (el_and, complex_matrix, complex, complex_array, complex, mx_el_and) |
|
101 DEFNDBINOP_FN (el_or, complex_matrix, complex, complex_array, complex, mx_el_or) |
2928
|
102 |
4915
|
103 DEFNDCATOP_FN (cm_cs, complex_matrix, complex, complex_array, complex_array, concat) |
|
104 |
4686
|
105 DEFNDASSIGNOP_FN (assign, complex_matrix, complex, complex_array, assign) |
2928
|
106 |
|
107 void |
|
108 install_cm_cs_ops (void) |
|
109 { |
3538
|
110 INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex, add); |
|
111 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex, sub); |
|
112 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex, mul); |
|
113 INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex, div); |
|
114 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex, pow); |
|
115 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex, ldiv); |
|
116 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex, lt); |
|
117 INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex, le); |
|
118 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex, eq); |
|
119 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex, ge); |
|
120 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex, gt); |
|
121 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex, ne); |
|
122 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex, el_mul); |
|
123 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex, el_div); |
|
124 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex, el_pow); |
|
125 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex, el_ldiv); |
|
126 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex, el_and); |
|
127 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex, el_or); |
2928
|
128 |
4915
|
129 INSTALL_CATOP (octave_complex_matrix, octave_complex, cm_cs); |
|
130 |
3538
|
131 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex, assign); |
2928
|
132 } |
|
133 |
|
134 /* |
|
135 ;;; Local Variables: *** |
|
136 ;;; mode: C++ *** |
|
137 ;;; End: *** |
|
138 */ |