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-fcm-fcm.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, float_complex_matrix, float_complex_array, !)
41 DEFNDUNOP_OP (uplus, float_complex_matrix, float_complex_array, /* no-op */)
42 DEFNDUNOP_OP (uminus, float_complex_matrix, float_complex_array, -)
43 
44 DEFUNOP (transpose, float_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.float_complex_matrix_value ().transpose ());
55 }
56 
57 DEFUNOP (hermitian, float_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.float_complex_matrix_value ().hermitian ());
68 }
69 
70 DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
71 DEFNCUNOP_METHOD (decr, float_complex_matrix, decrement)
72 DEFNCUNOP_METHOD (changesign, float_complex_matrix, changesign)
73 
74 // complex matrix by complex matrix ops.
75 
76 DEFNDBINOP_OP (add, float_complex_matrix, float_complex_matrix,
77  float_complex_array, float_complex_array, +)
78 DEFNDBINOP_OP (sub, float_complex_matrix, float_complex_matrix,
79  float_complex_array, float_complex_array, -)
80 
81 DEFBINOP_OP (mul, float_complex_matrix, float_complex_matrix, *)
82 
83 DEFBINOP (div, float_complex_matrix, float_complex_matrix)
84 {
87  MatrixType typ = v2.matrix_type ();
88 
91 
92  v2.matrix_type (typ);
93  return ret;
94 }
95 
96 DEFBINOPX (pow, float_complex_matrix, float_complex_matrix)
97 {
98  error ("can't do A ^ B for A and B both matrices");
99  return octave_value ();
100 }
101 
102 DEFBINOP (ldiv, float_complex_matrix, float_complex_matrix)
103 {
106  MatrixType typ = v1.matrix_type ();
107 
110 
111  v1.matrix_type (typ);
112  return ret;
113 }
114 
115 DEFBINOP (trans_mul, float_complex_matrix, float_complex_matrix)
116 {
122 }
123 
124 DEFBINOP (mul_trans, float_complex_matrix, float_complex_matrix)
125 {
131 }
132 
133 DEFBINOP (herm_mul, float_complex_matrix, float_complex_matrix)
134 {
140 }
141 
142 DEFBINOP (mul_herm, float_complex_matrix, float_complex_matrix)
143 {
149 }
150 
151 DEFBINOP (trans_ldiv, float_complex_matrix, float_complex_matrix)
152 {
155  MatrixType typ = v1.matrix_type ();
156 
159  typ, blas_trans);
160 
161  v1.matrix_type (typ);
162  return ret;
163 }
164 
165 DEFBINOP (herm_ldiv, float_complex_matrix, float_complex_matrix)
166 {
169  MatrixType typ = v1.matrix_type ();
170 
173  typ, blas_conj_trans);
174 
175  v1.matrix_type (typ);
176  return ret;
177 }
178 
179 DEFNDCMPLXCMPOP_FN (lt, float_complex_matrix, float_complex_matrix,
180  float_complex_array, float_complex_array, mx_el_lt)
181 DEFNDCMPLXCMPOP_FN (le, float_complex_matrix, float_complex_matrix,
182  float_complex_array, float_complex_array, mx_el_le)
183 DEFNDCMPLXCMPOP_FN (eq, float_complex_matrix, float_complex_matrix,
184  float_complex_array, float_complex_array, mx_el_eq)
185 DEFNDCMPLXCMPOP_FN (ge, float_complex_matrix, float_complex_matrix,
186  float_complex_array, float_complex_array, mx_el_ge)
187 DEFNDCMPLXCMPOP_FN (gt, float_complex_matrix, float_complex_matrix,
188  float_complex_array, float_complex_array, mx_el_gt)
189 DEFNDCMPLXCMPOP_FN (ne, float_complex_matrix, float_complex_matrix,
190  float_complex_array, float_complex_array, mx_el_ne)
191 
192 DEFNDBINOP_FN (el_mul, float_complex_matrix, float_complex_matrix,
193  float_complex_array, float_complex_array, product)
194 DEFNDBINOP_FN (el_div, float_complex_matrix, float_complex_matrix,
195  float_complex_array, float_complex_array, quotient)
196 DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex_matrix,
197  float_complex_array, float_complex_array, elem_xpow)
198 
199 DEFBINOP (el_ldiv, float_complex_matrix, float_complex_matrix)
200 {
203 
206 }
207 
208 DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex_matrix,
209  float_complex_array, float_complex_array, mx_el_and)
210 DEFNDBINOP_FN (el_or, float_complex_matrix, float_complex_matrix,
211  float_complex_array, float_complex_array, mx_el_or)
212 
213 DEFNDCATOP_FN (fcm_fcm, float_complex_matrix, float_complex_matrix,
214  float_complex_array, float_complex_array, concat)
215 
216 DEFNDCATOP_FN (cm_fcm, complex_matrix, float_complex_matrix,
217  float_complex_array, float_complex_array, concat)
218 
219 DEFNDCATOP_FN (fcm_cm, float_complex_matrix, complex_matrix,
220  float_complex_array, float_complex_array, concat)
221 
222 DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex_matrix,
223  float_complex_array, assign)
224 DEFNDASSIGNOP_FN (dbl_clx_assign, float_complex_matrix, complex_matrix,
225  float_complex_array, assign)
226 DEFNDASSIGNOP_FN (dbl_assign, float_complex_matrix, matrix,
227  float_complex_array, assign)
228 
229 DEFNULLASSIGNOP_FN (null_assign, float_complex_matrix, delete_elements)
230 
231 DEFNDASSIGNOP_OP (assign_add, float_complex_matrix,
232  float_complex_matrix, float_complex_array, +=)
233 DEFNDASSIGNOP_OP (assign_sub, float_complex_matrix,
234  float_complex_matrix, float_complex_array, -=)
235 DEFNDASSIGNOP_FNOP (assign_el_mul, float_complex_matrix, float_complex_matrix,
236  float_complex_array, product_eq)
237 DEFNDASSIGNOP_FNOP (assign_el_div, float_complex_matrix, float_complex_matrix,
238  float_complex_array, quotient_eq)
239 
240 CONVDECL (float_complex_matrix_to_complex_matrix)
241 {
243 
244  return
245  new octave_complex_matrix (ComplexNDArray (v.float_complex_array_value ()));
246 }
247 
248 void
250 {
256 
260 
282  octave_float_complex_matrix, trans_ldiv);
284  octave_float_complex_matrix, herm_ldiv);
285 
305  octave_float_complex_matrix, el_ldiv);
310 
312  octave_float_complex_matrix, fcm_fcm);
316  octave_complex_matrix, fcm_cm);
317 
321  octave_complex_matrix, dbl_clx_assign);
323  octave_matrix, dbl_assign);
324 
326  octave_null_matrix, null_assign);
328  octave_null_str, null_assign);
330  octave_null_sq_str, null_assign);
331 
333  octave_float_complex_matrix, assign_add);
335  octave_float_complex_matrix, assign_sub);
337  octave_float_complex_matrix, assign_el_mul);
339  octave_float_complex_matrix, assign_el_div);
340 
342  float_complex_matrix_to_complex_matrix);
343 }
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
#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
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-ch-mat.h:127
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1328
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-ch-mat.h:133
const octave_base_value const Array< octave_idx_type > &ra_idx octave_int16_scalar & v1
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:330
#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
virtual FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-base.cc:602
#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
void install_fcm_fcm_ops(void)
Definition: op-fcm-fcm.cc:249
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
virtual FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-base.cc:620
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
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
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