GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-fcm-fcm.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include "errwarn.h"
31#include "ovl.h"
32#include "ov.h"
33#include "ov-cx-mat.h"
34#include "ov-flt-cx-mat.h"
35#include "ov-typeinfo.h"
36#include "ov-null-mat.h"
37#include "ops.h"
38#include "xdiv.h"
39#include "xpow.h"
40
41OCTAVE_NAMESPACE_BEGIN
42
43// unary complex matrix ops.
44
45DEFNDUNOP_OP (not, float_complex_matrix, float_complex_array, !)
46DEFNDUNOP_OP (uplus, float_complex_matrix, float_complex_array, /* no-op */)
47DEFNDUNOP_OP (uminus, float_complex_matrix, float_complex_array, -)
48
49DEFUNOP (transpose, float_complex_matrix)
50{
52 = dynamic_cast<const octave_float_complex_matrix&> (a);
53
54 if (v.ndims () > 2)
55 error ("transpose not defined for N-D objects");
56
58}
59
60DEFUNOP (hermitian, float_complex_matrix)
61{
63 = dynamic_cast<const octave_float_complex_matrix&> (a);
64
65 if (v.ndims () > 2)
66 error ("complex-conjugate transpose not defined for N-D objects");
67
69}
70
71DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
72DEFNCUNOP_METHOD (decr, float_complex_matrix, decrement)
73DEFNCUNOP_METHOD (changesign, float_complex_matrix, changesign)
74
75// complex matrix by complex matrix ops.
76
77DEFNDBINOP_OP (add, float_complex_matrix, float_complex_matrix,
78 float_complex_array, float_complex_array, +)
79DEFNDBINOP_OP (sub, float_complex_matrix, float_complex_matrix,
80 float_complex_array, float_complex_array, -)
81
82DEFBINOP_OP (mul, float_complex_matrix, float_complex_matrix, *)
83
84DEFBINOP (div, float_complex_matrix, float_complex_matrix)
85{
87 = dynamic_cast<const octave_float_complex_matrix&> (a1);
89 = dynamic_cast<const octave_float_complex_matrix&> (a2);
90 MatrixType typ = v2.matrix_type ();
91
94
95 v2.matrix_type (typ);
96 return ret;
97}
98
99DEFBINOPX (pow, float_complex_matrix, float_complex_matrix)
100{
101 error ("can't do A ^ B for A and B both matrices");
102}
103
104DEFBINOP (ldiv, float_complex_matrix, float_complex_matrix)
105{
107 = dynamic_cast<const octave_float_complex_matrix&> (a1);
109 = dynamic_cast<const octave_float_complex_matrix&> (a2);
110 MatrixType typ = v1.matrix_type ();
111
114
115 v1.matrix_type (typ);
116 return ret;
117}
118
119DEFBINOP (trans_mul, float_complex_matrix, float_complex_matrix)
120{
122 = dynamic_cast<const octave_float_complex_matrix&> (a1);
124 = dynamic_cast<const octave_float_complex_matrix&> (a2);
128}
129
130DEFBINOP (mul_trans, float_complex_matrix, float_complex_matrix)
131{
133 = dynamic_cast<const octave_float_complex_matrix&> (a1);
135 = dynamic_cast<const octave_float_complex_matrix&> (a2);
139}
140
141DEFBINOP (herm_mul, float_complex_matrix, float_complex_matrix)
142{
144 = dynamic_cast<const octave_float_complex_matrix&> (a1);
146 = dynamic_cast<const octave_float_complex_matrix&> (a2);
150}
151
152DEFBINOP (mul_herm, float_complex_matrix, float_complex_matrix)
153{
155 = dynamic_cast<const octave_float_complex_matrix&> (a1);
157 = dynamic_cast<const octave_float_complex_matrix&> (a2);
161}
162
163DEFBINOP (trans_ldiv, float_complex_matrix, float_complex_matrix)
164{
166 = dynamic_cast<const octave_float_complex_matrix&> (a1);
168 = dynamic_cast<const octave_float_complex_matrix&> (a2);
169 MatrixType typ = v1.matrix_type ();
170
173 typ, blas_trans);
174
175 v1.matrix_type (typ);
176 return ret;
177}
178
179DEFBINOP (herm_ldiv, float_complex_matrix, float_complex_matrix)
180{
182 = dynamic_cast<const octave_float_complex_matrix&> (a1);
184 = dynamic_cast<const octave_float_complex_matrix&> (a2);
185 MatrixType typ = v1.matrix_type ();
186
189 typ, blas_conj_trans);
190
191 v1.matrix_type (typ);
192 return ret;
193}
194
195DEFNDCMPLXCMPOP_FN (lt, float_complex_matrix, float_complex_matrix,
196 float_complex_array, float_complex_array, mx_el_lt)
197DEFNDCMPLXCMPOP_FN (le, float_complex_matrix, float_complex_matrix,
198 float_complex_array, float_complex_array, mx_el_le)
199DEFNDCMPLXCMPOP_FN (eq, float_complex_matrix, float_complex_matrix,
200 float_complex_array, float_complex_array, mx_el_eq)
201DEFNDCMPLXCMPOP_FN (ge, float_complex_matrix, float_complex_matrix,
202 float_complex_array, float_complex_array, mx_el_ge)
203DEFNDCMPLXCMPOP_FN (gt, float_complex_matrix, float_complex_matrix,
204 float_complex_array, float_complex_array, mx_el_gt)
205DEFNDCMPLXCMPOP_FN (ne, float_complex_matrix, float_complex_matrix,
206 float_complex_array, float_complex_array, mx_el_ne)
207
208DEFNDBINOP_FN (el_mul, float_complex_matrix, float_complex_matrix,
209 float_complex_array, float_complex_array, product)
210DEFNDBINOP_FN (el_div, float_complex_matrix, float_complex_matrix,
211 float_complex_array, float_complex_array, quotient)
212DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex_matrix,
213 float_complex_array, float_complex_array, elem_xpow)
214
215DEFBINOP (el_ldiv, float_complex_matrix, float_complex_matrix)
216{
218 = dynamic_cast<const octave_float_complex_matrix&> (a1);
220 = dynamic_cast<const octave_float_complex_matrix&> (a2);
221
224}
225
226DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex_matrix,
227 float_complex_array, float_complex_array, mx_el_and)
228DEFNDBINOP_FN (el_or, float_complex_matrix, float_complex_matrix,
229 float_complex_array, float_complex_array, mx_el_or)
230
231DEFNDCATOP_FN (fcm_fcm, float_complex_matrix, float_complex_matrix,
232 float_complex_array, float_complex_array, concat)
233
234DEFNDCATOP_FN (cm_fcm, complex_matrix, float_complex_matrix,
235 float_complex_array, float_complex_array, concat)
236
237DEFNDCATOP_FN (fcm_cm, float_complex_matrix, complex_matrix,
238 float_complex_array, float_complex_array, concat)
239
240DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex_matrix,
241 float_complex_array, assign)
242DEFNDASSIGNOP_FN (sgl_clx_assign, float_complex_matrix, complex_matrix,
243 float_complex_array, assign)
244DEFNDASSIGNOP_FN (sgl_assign, float_complex_matrix, matrix,
245 float_complex_array, assign)
246DEFNDASSIGNOP_FN (dbl_assign, complex_matrix, float_complex_matrix,
247 complex_array, assign)
248
249DEFNULLASSIGNOP_FN (null_assign, float_complex_matrix, delete_elements)
250
251DEFNDASSIGNOP_OP (assign_add, float_complex_matrix,
252 float_complex_matrix, float_complex_array, +=)
253DEFNDASSIGNOP_OP (assign_sub, float_complex_matrix,
254 float_complex_matrix, float_complex_array, -=)
255DEFNDASSIGNOP_FNOP (assign_el_mul, float_complex_matrix, float_complex_matrix,
256 float_complex_array, product_eq)
257DEFNDASSIGNOP_FNOP (assign_el_div, float_complex_matrix, float_complex_matrix,
258 float_complex_array, quotient_eq)
259
260void
262{
268
272
294 octave_float_complex_matrix, trans_ldiv);
296 octave_float_complex_matrix, herm_ldiv);
297
322
328 octave_complex_matrix, fcm_cm);
329
333 octave_complex_matrix, sgl_clx_assign);
335 octave_matrix, sgl_assign);
337 octave_float_complex_matrix, dbl_assign);
338
340 octave_null_matrix, null_assign);
342 octave_null_str, null_assign);
344 octave_null_sq_str, null_assign);
345
347 octave_float_complex_matrix, assign_add);
349 octave_float_complex_matrix, assign_sub);
351 octave_float_complex_matrix, assign_el_mul);
353 octave_float_complex_matrix, assign_el_div);
354}
355
356OCTAVE_NAMESPACE_END
ComplexColumnVector quotient(const ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:156
ComplexColumnVector product_eq(ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:156
ComplexColumnVector product(const ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:156
ComplexColumnVector quotient_eq(ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:156
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
Definition: CMatrix.cc:3341
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
ComplexMatrix mul_trans(const ComplexMatrix &m, const SparseComplexMatrix &a)
Definition: CSparse.cc:7511
ComplexMatrix mul_herm(const ComplexMatrix &m, const SparseComplexMatrix &a)
Definition: CSparse.cc:7517
ComplexMatrix trans_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition: CSparse.cc:7541
ComplexMatrix herm_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition: CSparse.cc:7547
boolMatrix mx_el_le(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolMatrix mx_el_or(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:88
boolMatrix mx_el_and(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:88
boolMatrix mx_el_gt(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolMatrix mx_el_eq(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolMatrix mx_el_lt(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolMatrix mx_el_ge(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
FloatComplexMatrix hermitian(void) const
Definition: fCMatrix.h:178
FloatComplexMatrix transpose(void) const
Definition: fCMatrix.h:180
MatrixType matrix_type(void) const
Definition: ov-base-mat.h:135
int ndims(void) const
Definition: ov-base-mat.h:120
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-ch-mat.h:139
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-ch-mat.h:133
FloatComplexNDArray float_complex_array_value(bool=false) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
void error(const char *fmt,...)
Definition: error.cc:980
@ blas_no_trans
Definition: mx-defs.h:81
@ blas_conj_trans
Definition: mx-defs.h:83
@ blas_trans
Definition: mx-defs.h:82
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
void install_fcm_fcm_ops(octave::type_info &ti)
Definition: op-fcm-fcm.cc:261
const octave_base_value & a2
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
const octave_char_matrix & v2
#define DEFNDASSIGNOP_FN(name, t1, t2, e, f)
Definition: ops.h:110
#define DEFNDBINOP_OP(name, t1, t2, e1, e2, op)
Definition: ops.h:274
#define INSTALL_NCUNOP_TI(ti, op, t, f)
Definition: ops.h:49
#define DEFNULLASSIGNOP_FN(name, t, f)
Definition: ops.h:98
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:299
#define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:310
#define DEFBINOPX(name, t1, t2)
Definition: ops.h:223
#define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop)
Definition: ops.h:139
#define DEFBINOP(name, t1, t2)
Definition: ops.h:228
#define DEFNDUNOP_OP(name, t, e, op)
Definition: ops.h:189
#define DEFBINOP_OP(name, t1, t2, op)
Definition: ops.h:233
#define DEFNCUNOP_METHOD(name, t, method)
Definition: ops.h:215
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:53
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:347
#define DEFUNOP(name, t)
Definition: ops.h:177
#define INSTALL_CATOP_TI(ti, t1, t2, f)
Definition: ops.h:58
#define INSTALL_UNOP_TI(ti, op, t, f)
Definition: ops.h:45
#define DEFNDASSIGNOP_OP(name, t1, t2, f, op)
Definition: ops.h:124
#define INSTALL_ASSIGNOP_TI(ti, op, t1, t2, f)
Definition: ops.h:62
octave_value op_ne(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1878
octave_value op_el_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1883
octave_value op_uplus(const octave_value &a)
Definition: ov.h:1836
octave_value op_add(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1865
octave_value op_gt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1877
octave_value op_uminus(const octave_value &a)
Definition: ov.h:1837
octave_value op_el_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1881
octave_value op_mul_herm(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1899
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1839
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1885
octave_value op_sub(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1866
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1867
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1840
octave_value op_le(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1874
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1884
octave_value op_herm_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1898
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1875
octave_value op_el_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1882
octave_value op_not(const octave_value &a)
Definition: ov.h:1835
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1871
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1870
octave_value op_ge(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1876
octave_value op_el_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1880
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1868
octave_value op_trans_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1896
octave_value op_mul_trans(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1897
octave_value op_lt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1873
Matrix xdiv(const Matrix &a, const SparseMatrix &b, MatrixType &typ)
Definition: sparse-xdiv.cc:137
Matrix xleftdiv(const SparseMatrix &a, const Matrix &b, MatrixType &typ)
Definition: sparse-xdiv.cc:468
octave_value elem_xpow(double a, const SparseMatrix &b)
Definition: sparse-xpow.cc:251
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:391