GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
op-fcm-fcm.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 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
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
53 if (v.ndims () > 2)
54 error ("transpose not defined for N-D objects");
55
56 return octave_value (v.float_complex_matrix_value ().transpose ());
57}
58
59DEFUNOP (hermitian, float_complex_matrix)
60{
62
63 if (v.ndims () > 2)
64 error ("complex-conjugate transpose not defined for N-D objects");
65
66 return octave_value (v.float_complex_matrix_value ().hermitian ());
67}
68
69DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
70DEFNCUNOP_METHOD (decr, float_complex_matrix, decrement)
71DEFNCUNOP_METHOD (changesign, float_complex_matrix, changesign)
72
73// complex matrix by complex matrix ops.
74
75DEFNDBINOP_OP (add, float_complex_matrix, float_complex_matrix,
76 float_complex_array, float_complex_array, +)
77DEFNDBINOP_OP (sub, float_complex_matrix, float_complex_matrix,
78 float_complex_array, float_complex_array, -)
79
80DEFBINOP_OP (mul, float_complex_matrix, float_complex_matrix, *)
81
82DEFBINOP (div, float_complex_matrix, float_complex_matrix)
83{
86 MatrixType typ = v2.matrix_type ();
87
88 FloatComplexMatrix ret = xdiv (v1.float_complex_matrix_value (),
90
91 v2.matrix_type (typ);
92 return ret;
93}
94
95DEFBINOPX (pow, float_complex_matrix, float_complex_matrix)
96{
97 error ("can't do A ^ B for A and B both matrices");
98}
99
100DEFBINOP (ldiv, float_complex_matrix, float_complex_matrix)
101{
104 MatrixType typ = v1.matrix_type ();
105
106 FloatComplexMatrix ret = xleftdiv (v1.float_complex_matrix_value (),
108
109 v1.matrix_type (typ);
110 return ret;
111}
112
113DEFBINOP (trans_mul, float_complex_matrix, float_complex_matrix)
114{
117 return octave_value(xgemm (v1.float_complex_matrix_value (),
120}
121
122DEFBINOP (mul_trans, float_complex_matrix, float_complex_matrix)
123{
126 return octave_value(xgemm (v1.float_complex_matrix_value (),
129}
130
131DEFBINOP (herm_mul, float_complex_matrix, float_complex_matrix)
132{
135 return octave_value(xgemm (v1.float_complex_matrix_value (),
138}
139
140DEFBINOP (mul_herm, float_complex_matrix, float_complex_matrix)
141{
144 return octave_value(xgemm (v1.float_complex_matrix_value (),
147}
148
149DEFBINOP (trans_ldiv, float_complex_matrix, float_complex_matrix)
150{
153 MatrixType typ = v1.matrix_type ();
154
155 FloatComplexMatrix ret = xleftdiv (v1.float_complex_matrix_value (),
157 typ, blas_trans);
158
159 v1.matrix_type (typ);
160 return ret;
161}
162
163DEFBINOP (herm_ldiv, float_complex_matrix, float_complex_matrix)
164{
167 MatrixType typ = v1.matrix_type ();
168
169 FloatComplexMatrix ret = xleftdiv (v1.float_complex_matrix_value (),
171 typ, blas_conj_trans);
172
173 v1.matrix_type (typ);
174 return ret;
175}
176
177DEFNDCMPLXCMPOP_FN (lt, float_complex_matrix, float_complex_matrix,
178 float_complex_array, float_complex_array, mx_el_lt)
179DEFNDCMPLXCMPOP_FN (le, float_complex_matrix, float_complex_matrix,
180 float_complex_array, float_complex_array, mx_el_le)
181DEFNDCMPLXCMPOP_FN (eq, float_complex_matrix, float_complex_matrix,
182 float_complex_array, float_complex_array, mx_el_eq)
183DEFNDCMPLXCMPOP_FN (ge, float_complex_matrix, float_complex_matrix,
184 float_complex_array, float_complex_array, mx_el_ge)
185DEFNDCMPLXCMPOP_FN (gt, float_complex_matrix, float_complex_matrix,
186 float_complex_array, float_complex_array, mx_el_gt)
187DEFNDCMPLXCMPOP_FN (ne, float_complex_matrix, float_complex_matrix,
188 float_complex_array, float_complex_array, mx_el_ne)
189
190DEFNDBINOP_FN (el_mul, float_complex_matrix, float_complex_matrix,
191 float_complex_array, float_complex_array, product)
192DEFNDBINOP_FN (el_div, float_complex_matrix, float_complex_matrix,
193 float_complex_array, float_complex_array, quotient)
194DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex_matrix,
195 float_complex_array, float_complex_array, elem_xpow)
196
197DEFBINOP (el_ldiv, float_complex_matrix, float_complex_matrix)
198{
201
203 v1.float_complex_array_value ()));
204}
205
206DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex_matrix,
207 float_complex_array, float_complex_array, mx_el_and)
208DEFNDBINOP_FN (el_or, float_complex_matrix, float_complex_matrix,
209 float_complex_array, float_complex_array, mx_el_or)
210
211DEFNDCATOP_FN (fcm_fcm, float_complex_matrix, float_complex_matrix,
212 float_complex_array, float_complex_array, concat)
213
214DEFNDCATOP_FN (cm_fcm, complex_matrix, float_complex_matrix,
215 float_complex_array, float_complex_array, concat)
216
217DEFNDCATOP_FN (fcm_cm, float_complex_matrix, complex_matrix,
218 float_complex_array, float_complex_array, concat)
219
220DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex_matrix,
221 float_complex_array, assign)
222DEFNDASSIGNOP_FN (sgl_clx_assign, float_complex_matrix, complex_matrix,
223 float_complex_array, assign)
224DEFNDASSIGNOP_FN (sgl_assign, float_complex_matrix, matrix,
225 float_complex_array, assign)
226DEFNDASSIGNOP_FN (dbl_assign, complex_matrix, float_complex_matrix,
227 complex_array, assign)
228
229DEFNULLASSIGNOP_FN (null_assign, float_complex_matrix, delete_elements)
230
231DEFNDASSIGNOP_OP (assign_add, float_complex_matrix,
232 float_complex_matrix, float_complex_array, +=)
233DEFNDASSIGNOP_OP (assign_sub, float_complex_matrix,
234 float_complex_matrix, float_complex_array, -=)
235DEFNDASSIGNOP_FNOP (assign_el_mul, float_complex_matrix, float_complex_matrix,
236 float_complex_array, product_eq)
237DEFNDASSIGNOP_FNOP (assign_el_div, float_complex_matrix, float_complex_matrix,
238 float_complex_array, quotient_eq)
239
240void
242{
248
252
274 octave_float_complex_matrix, trans_ldiv);
276 octave_float_complex_matrix, herm_ldiv);
277
302
308 octave_complex_matrix, fcm_cm);
309
313 octave_complex_matrix, sgl_clx_assign);
315 octave_matrix, sgl_assign);
317 octave_float_complex_matrix, dbl_assign);
318
320 octave_null_matrix, null_assign);
322 octave_null_str, null_assign);
324 octave_null_sq_str, null_assign);
325
327 octave_float_complex_matrix, assign_add);
329 octave_float_complex_matrix, assign_sub);
331 octave_float_complex_matrix, assign_el_mul);
333 octave_float_complex_matrix, assign_el_div);
334}
335
336OCTAVE_END_NAMESPACE(octave)
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:3347
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:7463
ComplexMatrix mul_herm(const ComplexMatrix &m, const SparseComplexMatrix &a)
Definition CSparse.cc:7469
ComplexMatrix trans_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition CSparse.cc:7493
ComplexMatrix herm_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition CSparse.cc:7499
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
MatrixType matrix_type() const
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition ov-ch-mat.h:140
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition ov-ch-mat.h:134
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
Definition error.cc:1003
@ 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)
const octave_base_value & a2
const octave_char_matrix & v2
#define DEFNDASSIGNOP_FN(name, t1, t2, e, f)
Definition ops.h:127
#define DEFNDBINOP_OP(name, t1, t2, e1, e2, op)
Definition ops.h:294
#define INSTALL_NCUNOP_TI(ti, op, t, f)
Definition ops.h:66
#define DEFNULLASSIGNOP_FN(name, t, f)
Definition ops.h:115
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition ops.h:319
#define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f)
Definition ops.h:330
#define DEFBINOPX(name, t1, t2)
Definition ops.h:243
#define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop)
Definition ops.h:158
#define DEFBINOP(name, t1, t2)
Definition ops.h:248
#define DEFNDUNOP_OP(name, t, e, op)
Definition ops.h:209
#define DEFBINOP_OP(name, t1, t2, op)
Definition ops.h:253
#define OCTAVE_CAST_BASE_VALUE(T, T_VAL, BASE_VAL)
Definition ops.h:52
#define DEFNCUNOP_METHOD(name, t, method)
Definition ops.h:235
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition ops.h:70
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition ops.h:367
#define DEFUNOP(name, t)
Definition ops.h:197
#define INSTALL_CATOP_TI(ti, t1, t2, f)
Definition ops.h:75
#define INSTALL_UNOP_TI(ti, op, t, f)
Definition ops.h:62
#define DEFNDASSIGNOP_OP(name, t1, t2, f, op)
Definition ops.h:142
#define INSTALL_ASSIGNOP_TI(ti, op, t1, t2, f)
Definition ops.h:79
octave_value op_ne(const octave_value &a1, const octave_value &a2)
Definition ov.h:1691
octave_value op_el_ldiv(const octave_value &a1, const octave_value &a2)
Definition ov.h:1696
octave_value op_uplus(const octave_value &a)
Definition ov.h:1649
octave_value op_add(const octave_value &a1, const octave_value &a2)
Definition ov.h:1678
octave_value op_gt(const octave_value &a1, const octave_value &a2)
Definition ov.h:1690
octave_value op_uminus(const octave_value &a)
Definition ov.h:1650
octave_value op_el_div(const octave_value &a1, const octave_value &a2)
Definition ov.h:1694
octave_value op_mul_herm(const octave_value &a1, const octave_value &a2)
Definition ov.h:1712
octave_value op_transpose(const octave_value &a)
Definition ov.h:1652
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition ov.h:1698
octave_value op_sub(const octave_value &a1, const octave_value &a2)
Definition ov.h:1679
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition ov.h:1680
octave_value op_hermitian(const octave_value &a)
Definition ov.h:1653
octave_value op_le(const octave_value &a1, const octave_value &a2)
Definition ov.h:1687
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition ov.h:1697
octave_value op_herm_mul(const octave_value &a1, const octave_value &a2)
Definition ov.h:1711
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition ov.h:1688
octave_value op_el_pow(const octave_value &a1, const octave_value &a2)
Definition ov.h:1695
octave_value op_not(const octave_value &a)
Definition ov.h:1648
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition ov.h:1684
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition ov.h:1683
octave_value op_ge(const octave_value &a1, const octave_value &a2)
Definition ov.h:1689
octave_value op_el_mul(const octave_value &a1, const octave_value &a2)
Definition ov.h:1693
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition ov.h:1681
octave_value op_trans_mul(const octave_value &a1, const octave_value &a2)
Definition ov.h:1709
octave_value op_mul_trans(const octave_value &a1, const octave_value &a2)
Definition ov.h:1710
octave_value op_lt(const octave_value &a1, const octave_value &a2)
Definition ov.h:1686
Matrix xdiv(const Matrix &a, const SparseMatrix &b, MatrixType &typ)
Matrix xleftdiv(const SparseMatrix &a, const Matrix &b, MatrixType &typ)
octave_value elem_xpow(double a, const SparseMatrix &b)