GNU Octave  4.0.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-2015 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 
235  INSTALL_NCUNOP (op_incr, octave_complex_matrix, incr);
236  INSTALL_NCUNOP (op_decr, octave_complex_matrix, decr);
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 }
ComplexColumnVector quotient_eq(ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:149
ComplexColumnVector product(const ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:149
octave_value op_mul_trans(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1357
octave_value op_uplus(const octave_value &a)
Definition: ov.h:1294
#define DEFBINOP(name, t1, t2)
Definition: ops.h:279
#define DEFUNOP(name, t)
Definition: ops.h:231
virtual MatrixType matrix_type(void) const
Definition: ov-base.cc:347
octave_value op_el_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1342
#define INSTALL_NCUNOP(op, t, f)
Definition: ops.h:42
#define DEFBINOPX(name, t1, t2)
Definition: ops.h:276
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1335
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-ch-mat.h:130
#define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop)
Definition: ops.h:146
#define DEFNULLASSIGNOP_FN(name, t, f)
Definition: ops.h:116
octave_value op_el_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1343
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)
Definition: symrcm.cc:382
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:664
boolMatrix mx_el_le(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:90
void error(const char *fmt,...)
Definition: error.cc:476
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1328
const octave_base_value const Array< octave_idx_type > &ra_idx octave_int16_scalar & v1
void install_cm_cm_ops(void)
Definition: op-cm-cm.cc:227
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:330
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-ch-mat.h:124
#define INSTALL_ASSIGNOP(op, t1, t2, f)
Definition: ops.h:55
MatrixType matrix_type(void) const
Definition: ov-base-mat.h:120
#define CAST_BINOP_ARGS(t1, t2)
Definition: ops.h:79
ComplexMatrix mul_trans(const ComplexMatrix &m, const SparseComplexMatrix &a)
Definition: CSparse.cc:7415
#define INSTALL_CONVOP(t1, t2, f)
Definition: ops.h:68
#define DEFBINOP_OP(name, t1, t2, op)
Definition: ops.h:282
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1326
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1345
ComplexColumnVector quotient(const ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:149
#define INSTALL_BINOP(op, t1, t2, f)
Definition: ops.h:46
boolMatrix mx_el_ge(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:90
#define CAST_CONV_ARG(t)
Definition: ops.h:83
octave_value op_not(const octave_value &a)
Definition: ov.h:1293
ComplexMatrix herm_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition: CSparse.cc:7451
boolMatrix mx_el_gt(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:90
octave_value op_trans_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1356
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1297
octave_value elem_xpow(double a, const SparseMatrix &b)
Definition: sparse-xpow.cc:258
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1344
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
ComplexMatrix mul_herm(const ComplexMatrix &m, const SparseComplexMatrix &a)
Definition: CSparse.cc:7421
octave_value op_mul_herm(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1359
Matrix xleftdiv(const SparseMatrix &a, const Matrix &b, MatrixType &typ)
Definition: sparse-xdiv.cc:466
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:90
virtual ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-base.cc:593
octave_value op_le(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1334
octave_value op_lt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1333
#define INSTALL_CATOP(t1, t2, f)
Definition: ops.h:51
octave_value op_el_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1341
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
Definition: CMatrix.cc:3686
const octave_char_matrix & v2
boolMatrix mx_el_or(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:87
virtual ComplexNDArray complex_array_value(bool=false) const
Definition: ov-base.cc:611
void assign(octave_value::assign_op, const octave_value &)
Definition: oct-lvalue.cc:33
#define DEFNDASSIGNOP_FN(name, t1, t2, e, f)
Definition: ops.h:125
Matrix xdiv(const Matrix &a, const SparseMatrix &b, MatrixType &typ)
Definition: sparse-xdiv.cc:135
octave_value op_ne(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1338
ComplexMatrix trans_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition: CSparse.cc:7445
boolMatrix mx_el_and(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:87
#define DEFNDASSIGNOP_OP(name, t1, t2, f, op)
Definition: ops.h:135
octave_value op_add(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1323
#define INSTALL_UNOP(op, t, f)
Definition: ops.h:38
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1329
#define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:337
octave_value op_sub(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1324
boolMatrix mx_el_lt(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:90
#define CAST_UNOP_ARG(t)
Definition: ops.h:76
octave_value op_el_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1340
octave_value op_herm_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1358
#define DEFNDUNOP_OP(name, t, e, op)
Definition: ops.h:241
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1298
octave_value op_ge(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1336
#define DEFNDBINOP_OP(name, t1, t2, e1, e2, op)
Definition: ops.h:313
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:364
boolMatrix mx_el_eq(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:90
octave_value op_uminus(const octave_value &a)
Definition: ov.h:1295
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1325
ComplexColumnVector product_eq(ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:149
octave_value op_gt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1337
#define CONVDECL(name)
Definition: ops.h:166
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
#define DEFNCUNOP_METHOD(name, t, method)
Definition: ops.h:264