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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2928
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include "gripes.h" |
4055
|
29 #include "oct-obj.h" |
2928
|
30 #include "ov.h" |
|
31 #include "ov-cx-mat.h" |
|
32 #include "ov-typeinfo.h" |
|
33 #include "ops.h" |
|
34 #include "xdiv.h" |
|
35 #include "xpow.h" |
|
36 |
3203
|
37 // unary complex matrix ops. |
|
38 |
4550
|
39 DEFNDUNOP_OP (not, complex_matrix, complex_array, !) |
4965
|
40 DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */) |
4550
|
41 DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -) |
3203
|
42 |
|
43 DEFUNOP (transpose, complex_matrix) |
|
44 { |
|
45 CAST_UNOP_ARG (const octave_complex_matrix&); |
|
46 |
4673
|
47 if (v.ndims () > 2) |
|
48 { |
|
49 error ("transpose not defined for N-d objects"); |
|
50 return octave_value (); |
|
51 } |
|
52 else |
|
53 return octave_value (v.complex_matrix_value().transpose ()); |
3203
|
54 } |
|
55 |
|
56 DEFUNOP (hermitian, complex_matrix) |
|
57 { |
|
58 CAST_UNOP_ARG (const octave_complex_matrix&); |
|
59 |
4673
|
60 if (v.ndims () > 2) |
|
61 { |
|
62 error ("complex-conjugate transpose not defined for N-d objects"); |
|
63 return octave_value (); |
|
64 } |
|
65 else |
|
66 return octave_value (v.complex_matrix_value().hermitian ()); |
3203
|
67 } |
|
68 |
|
69 DEFNCUNOP_METHOD (incr, complex_matrix, increment) |
|
70 DEFNCUNOP_METHOD (decr, complex_matrix, decrement) |
|
71 |
2928
|
72 // complex matrix by complex matrix ops. |
|
73 |
4550
|
74 DEFNDBINOP_OP (add, complex_matrix, complex_matrix, complex_array, complex_array, +) |
|
75 DEFNDBINOP_OP (sub, complex_matrix, complex_matrix, complex_array, complex_array, -) |
4543
|
76 |
2928
|
77 DEFBINOP_OP (mul, complex_matrix, complex_matrix, *) |
5785
|
78 |
|
79 DEFBINOP (div, complex_matrix, complex_matrix) |
|
80 { |
|
81 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); |
|
82 MatrixType typ = v2.matrix_type (); |
|
83 |
|
84 ComplexMatrix ret = xdiv (v1.complex_matrix_value (), |
|
85 v2.complex_matrix_value (), typ); |
|
86 |
|
87 v2.matrix_type (typ); |
|
88 return ret; |
|
89 } |
2928
|
90 |
|
91 DEFBINOPX (pow, complex_matrix, complex_matrix) |
|
92 { |
|
93 error ("can't do A ^ B for A and B both matrices"); |
|
94 return octave_value (); |
|
95 } |
|
96 |
5785
|
97 DEFBINOP (ldiv, complex_matrix, complex_matrix) |
|
98 { |
|
99 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); |
|
100 MatrixType typ = v1.matrix_type (); |
|
101 |
|
102 ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (), |
|
103 v2.complex_matrix_value (), typ); |
|
104 |
|
105 v1.matrix_type (typ); |
|
106 return ret; |
|
107 } |
2928
|
108 |
4550
|
109 DEFNDBINOP_FN (lt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_lt) |
|
110 DEFNDBINOP_FN (le, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_le) |
|
111 DEFNDBINOP_FN (eq, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_eq) |
|
112 DEFNDBINOP_FN (ge, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ge) |
|
113 DEFNDBINOP_FN (gt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_gt) |
|
114 DEFNDBINOP_FN (ne, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ne) |
2928
|
115 |
4550
|
116 DEFNDBINOP_FN (el_mul, complex_matrix, complex_matrix, complex_array, complex_array, product) |
|
117 DEFNDBINOP_FN (el_div, complex_matrix, complex_matrix, complex_array, complex_array, quotient) |
|
118 DEFNDBINOP_FN (el_pow, complex_matrix, complex_matrix, complex_array, complex_array, elem_xpow) |
2928
|
119 |
|
120 DEFBINOP (el_ldiv, complex_matrix, complex_matrix) |
|
121 { |
|
122 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); |
|
123 |
4550
|
124 return octave_value (quotient (v2.complex_array_value (), v1.complex_array_value ())); |
2928
|
125 } |
|
126 |
4550
|
127 DEFNDBINOP_FN (el_and, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_and) |
|
128 DEFNDBINOP_FN (el_or, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_or) |
2928
|
129 |
4915
|
130 DEFNDCATOP_FN (cm_cm, complex_matrix, complex_matrix, complex_array, complex_array, concat) |
|
131 |
4686
|
132 DEFNDASSIGNOP_FN (assign, complex_matrix, complex_matrix, complex_array, assign) |
2928
|
133 |
|
134 void |
|
135 install_cm_cm_ops (void) |
|
136 { |
3538
|
137 INSTALL_UNOP (op_not, octave_complex_matrix, not); |
4965
|
138 INSTALL_UNOP (op_uplus, octave_complex_matrix, uplus); |
3538
|
139 INSTALL_UNOP (op_uminus, octave_complex_matrix, uminus); |
|
140 INSTALL_UNOP (op_transpose, octave_complex_matrix, transpose); |
|
141 INSTALL_UNOP (op_hermitian, octave_complex_matrix, hermitian); |
3203
|
142 |
3538
|
143 INSTALL_NCUNOP (op_incr, octave_complex_matrix, incr); |
|
144 INSTALL_NCUNOP (op_decr, octave_complex_matrix, decr); |
3203
|
145 |
3538
|
146 INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex_matrix, add); |
|
147 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex_matrix, sub); |
|
148 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex_matrix, mul); |
|
149 INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex_matrix, div); |
|
150 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex_matrix, pow); |
|
151 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex_matrix, ldiv); |
|
152 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex_matrix, lt); |
|
153 INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex_matrix, le); |
|
154 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex_matrix, eq); |
|
155 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex_matrix, ge); |
|
156 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex_matrix, gt); |
|
157 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex_matrix, ne); |
|
158 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex_matrix, el_mul); |
|
159 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex_matrix, el_div); |
|
160 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex_matrix, el_pow); |
|
161 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex_matrix, el_ldiv); |
|
162 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex_matrix, el_and); |
|
163 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex_matrix, el_or); |
2928
|
164 |
4915
|
165 INSTALL_CATOP (octave_complex_matrix, octave_complex_matrix, cm_cm); |
|
166 |
3538
|
167 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex_matrix, assign); |
2928
|
168 } |
|
169 |
|
170 /* |
|
171 ;;; Local Variables: *** |
|
172 ;;; mode: C++ *** |
|
173 ;;; End: *** |
|
174 */ |