GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
op-cm-cm.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include "gripes.h"
28 #include "oct-obj.h"
29 #include "ov.h"
30 #include "ov-cx-mat.h"
31 #include "ov-flt-cx-mat.h"
32 #include "ov-typeinfo.h"
33 #include "ov-null-mat.h"
34 #include "ops.h"
35 #include "xdiv.h"
36 #include "xpow.h"
37 
38 // unary complex matrix ops.
39 
40 DEFNDUNOP_OP (not, complex_matrix, complex_array, !)
41 DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */)
42 DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -)
43 
44 DEFUNOP (transpose, complex_matrix)
45 {
47 
48  if (v.ndims () > 2)
49  {
50  error ("transpose not defined for N-d objects");
51  return octave_value ();
52  }
53  else
54  return octave_value (v.complex_matrix_value ().transpose ());
55 }
56 
57 DEFUNOP (hermitian, complex_matrix)
58 {
60 
61  if (v.ndims () > 2)
62  {
63  error ("complex-conjugate transpose not defined for N-d objects");
64  return octave_value ();
65  }
66  else
67  return octave_value (v.complex_matrix_value ().hermitian ());
68 }
69 
70 DEFNCUNOP_METHOD (incr, complex_matrix, increment)
71 DEFNCUNOP_METHOD (decr, complex_matrix, decrement)
72 DEFNCUNOP_METHOD (changesign, complex_matrix, changesign)
73 
74 // complex matrix by complex matrix ops.
75 
76 DEFNDBINOP_OP (add, complex_matrix, complex_matrix, complex_array,
77  complex_array, +)
78 DEFNDBINOP_OP (sub, complex_matrix, complex_matrix, complex_array,
79  complex_array, -)
80 
81 DEFBINOP_OP (mul, complex_matrix, complex_matrix, *)
82 
83 DEFBINOP (div, complex_matrix, complex_matrix)
84 {
86  MatrixType typ = v2.matrix_type ();
87 
89  v2.complex_matrix_value (), typ);
90 
91  v2.matrix_type (typ);
92  return ret;
93 }
94 
95 DEFBINOPX (pow, complex_matrix, complex_matrix)
96 {
97  error ("can't do A ^ B for A and B both matrices");
98  return octave_value ();
99 }
100 
101 DEFBINOP (ldiv, complex_matrix, complex_matrix)
102 {
104  MatrixType typ = v1.matrix_type ();
105 
107  v2.complex_matrix_value (), typ);
108 
109  v1.matrix_type (typ);
110  return ret;
111 }
112 
113 DEFBINOP (trans_mul, complex_matrix, complex_matrix)
114 {
119 }
120 
121 DEFBINOP (mul_trans, complex_matrix, complex_matrix)
122 {
127 }
128 
129 DEFBINOP (herm_mul, complex_matrix, complex_matrix)
130 {
135 }
136 
137 DEFBINOP (mul_herm, complex_matrix, complex_matrix)
138 {
143 }
144 
145 DEFBINOP (trans_ldiv, complex_matrix, complex_matrix)
146 {
148  MatrixType typ = v1.matrix_type ();
149 
152 
153  v1.matrix_type (typ);
154  return ret;
155 }
156 
157 DEFBINOP (herm_ldiv, complex_matrix, complex_matrix)
158 {
160  MatrixType typ = v1.matrix_type ();
161 
163  v2.complex_matrix_value (), typ,
165 
166  v1.matrix_type (typ);
167  return ret;
168 }
169 
170 DEFNDCMPLXCMPOP_FN (lt, complex_matrix, complex_matrix, complex_array,
171  complex_array, mx_el_lt)
172 DEFNDCMPLXCMPOP_FN (le, complex_matrix, complex_matrix, complex_array,
173  complex_array, mx_el_le)
174 DEFNDCMPLXCMPOP_FN (eq, complex_matrix, complex_matrix, complex_array,
175  complex_array, mx_el_eq)
176 DEFNDCMPLXCMPOP_FN (ge, complex_matrix, complex_matrix, complex_array,
177  complex_array, mx_el_ge)
178 DEFNDCMPLXCMPOP_FN (gt, complex_matrix, complex_matrix, complex_array,
179  complex_array, mx_el_gt)
180 DEFNDCMPLXCMPOP_FN (ne, complex_matrix, complex_matrix, complex_array,
181  complex_array, mx_el_ne)
182 
183 DEFNDBINOP_FN (el_mul, complex_matrix, complex_matrix, complex_array,
184  complex_array, product)
185 DEFNDBINOP_FN (el_div, complex_matrix, complex_matrix, complex_array,
186  complex_array, quotient)
187 DEFNDBINOP_FN (el_pow, complex_matrix, complex_matrix, complex_array,
188  complex_array, elem_xpow)
189 
190 DEFBINOP (el_ldiv, complex_matrix, complex_matrix)
191 {
193 
195  v1.complex_array_value ()));
196 }
197 
198 DEFNDBINOP_FN (el_and, complex_matrix, complex_matrix, complex_array,
199  complex_array, mx_el_and)
200 DEFNDBINOP_FN (el_or, complex_matrix, complex_matrix, complex_array,
201  complex_array, mx_el_or)
202 
203 DEFNDCATOP_FN (cm_cm, complex_matrix, complex_matrix, complex_array,
204  complex_array, concat)
205 
206 DEFNDASSIGNOP_FN (assign, complex_matrix, complex_matrix, complex_array, assign)
207 
208 DEFNULLASSIGNOP_FN (null_assign, complex_matrix, delete_elements)
209 
210 DEFNDASSIGNOP_OP (assign_add, complex_matrix, complex_matrix, complex_array, +=)
211 DEFNDASSIGNOP_OP (assign_sub, complex_matrix, complex_matrix, complex_array, -=)
212 DEFNDASSIGNOP_FNOP (assign_el_mul, complex_matrix, complex_matrix,
213  complex_array, product_eq)
214 DEFNDASSIGNOP_FNOP (assign_el_div, complex_matrix, complex_matrix,
215  complex_array, quotient_eq)
216 
217 CONVDECL (complex_matrix_to_float_complex_matrix)
218 {
220 
221  return
223  (FloatComplexNDArray (v.complex_array_value ()));
224 }
225 
226 void
228 {
234 
238 
246  trans_mul);
248  mul_trans);
250  herm_mul);
252  mul_herm);
254  trans_ldiv);
256  herm_ldiv);
257 
265  el_mul);
267  el_div);
269  el_pow);
271  el_ldiv);
273  el_and);
275 
277 
279  assign);
280 
282  null_assign);
284  null_assign);
286  null_assign);
287 
289  assign_add);
291  assign_sub);
293  assign_el_mul);
295  assign_el_div);
296 
298  complex_matrix_to_float_complex_matrix);
299 }