GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
op-cm-cm.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, complex_matrix, complex_array, !)
46DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */)
47DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -)
48
49DEFUNOP (transpose, complex_matrix)
50{
52
53 if (v.ndims () > 2)
54 error ("transpose not defined for N-D objects");
55
56 return octave_value (v.complex_matrix_value ().transpose ());
57}
58
59DEFUNOP (hermitian, 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.complex_matrix_value ().hermitian ());
67}
68
69DEFNCUNOP_METHOD (incr, complex_matrix, increment)
70DEFNCUNOP_METHOD (decr, complex_matrix, decrement)
71DEFNCUNOP_METHOD (changesign, complex_matrix, changesign)
72
73// complex matrix by complex matrix ops.
74
75DEFNDBINOP_OP (add, complex_matrix, complex_matrix, complex_array,
76 complex_array, +)
77DEFNDBINOP_OP (sub, complex_matrix, complex_matrix, complex_array,
78 complex_array, -)
79
80DEFBINOP_OP (mul, complex_matrix, complex_matrix, *)
81
82DEFBINOP (div, complex_matrix, complex_matrix)
83{
86 MatrixType typ = v2.matrix_type ();
87
88 ComplexMatrix ret = xdiv (v1.complex_matrix_value (),
89 v2.complex_matrix_value (), typ);
90
91 v2.matrix_type (typ);
92 return ret;
93}
94
95DEFBINOPX (pow, complex_matrix, complex_matrix)
96{
97 error ("can't do A ^ B for A and B both matrices");
98}
99
100DEFBINOP (ldiv, complex_matrix, complex_matrix)
101{
104 MatrixType typ = v1.matrix_type ();
105
106 ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
107 v2.complex_matrix_value (), typ);
108
109 v1.matrix_type (typ);
110 return ret;
111}
112
113DEFBINOP (trans_mul, complex_matrix, complex_matrix)
114{
117 return octave_value(xgemm (v1.complex_matrix_value (),
120}
121
122DEFBINOP (mul_trans, complex_matrix, complex_matrix)
123{
126 return octave_value(xgemm (v1.complex_matrix_value (),
129}
130
131DEFBINOP (herm_mul, complex_matrix, complex_matrix)
132{
135 return octave_value(xgemm (v1.complex_matrix_value (),
138}
139
140DEFBINOP (mul_herm, complex_matrix, complex_matrix)
141{
144 return octave_value(xgemm (v1.complex_matrix_value (),
147}
148
149DEFBINOP (trans_ldiv, complex_matrix, complex_matrix)
150{
153 MatrixType typ = v1.matrix_type ();
154
155 ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
157
158 v1.matrix_type (typ);
159 return ret;
160}
161
162DEFBINOP (herm_ldiv, complex_matrix, complex_matrix)
163{
166 MatrixType typ = v1.matrix_type ();
167
168 ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
169 v2.complex_matrix_value (), typ,
171
172 v1.matrix_type (typ);
173 return ret;
174}
175
176DEFNDCMPLXCMPOP_FN (lt, complex_matrix, complex_matrix, complex_array,
177 complex_array, mx_el_lt)
178DEFNDCMPLXCMPOP_FN (le, complex_matrix, complex_matrix, complex_array,
179 complex_array, mx_el_le)
180DEFNDCMPLXCMPOP_FN (eq, complex_matrix, complex_matrix, complex_array,
181 complex_array, mx_el_eq)
182DEFNDCMPLXCMPOP_FN (ge, complex_matrix, complex_matrix, complex_array,
183 complex_array, mx_el_ge)
184DEFNDCMPLXCMPOP_FN (gt, complex_matrix, complex_matrix, complex_array,
185 complex_array, mx_el_gt)
186DEFNDCMPLXCMPOP_FN (ne, complex_matrix, complex_matrix, complex_array,
187 complex_array, mx_el_ne)
188
189DEFNDBINOP_FN (el_mul, complex_matrix, complex_matrix, complex_array,
190 complex_array, product)
191DEFNDBINOP_FN (el_div, complex_matrix, complex_matrix, complex_array,
192 complex_array, quotient)
193DEFNDBINOP_FN (el_pow, complex_matrix, complex_matrix, complex_array,
194 complex_array, elem_xpow)
195
196DEFBINOP (el_ldiv, complex_matrix, complex_matrix)
197{
200
202 v1.complex_array_value ()));
203}
204
205DEFNDBINOP_FN (el_and, complex_matrix, complex_matrix, complex_array,
206 complex_array, mx_el_and)
207DEFNDBINOP_FN (el_or, complex_matrix, complex_matrix, complex_array,
208 complex_array, mx_el_or)
209
210DEFNDCATOP_FN (cm_cm, complex_matrix, complex_matrix, complex_array,
211 complex_array, concat)
212
213DEFNDASSIGNOP_FN (assign, complex_matrix, complex_matrix, complex_array, assign)
214
215DEFNULLASSIGNOP_FN (null_assign, complex_matrix, delete_elements)
216
217DEFNDASSIGNOP_OP (assign_add, complex_matrix, complex_matrix, complex_array, +=)
218DEFNDASSIGNOP_OP (assign_sub, complex_matrix, complex_matrix, complex_array, -=)
219DEFNDASSIGNOP_FNOP (assign_el_mul, complex_matrix, complex_matrix,
220 complex_array, product_eq)
221DEFNDASSIGNOP_FNOP (assign_el_div, complex_matrix, complex_matrix,
222 complex_array, quotient_eq)
223
224void
226{
232
233 INSTALL_NCUNOP_TI (ti, op_incr, octave_complex_matrix, incr);
234 INSTALL_NCUNOP_TI (ti, op_decr, octave_complex_matrix, decr);
236
238 add);
240 sub);
242 mul);
244 div);
246 pow);
248 ldiv);
251 trans_mul);
254 mul_trans);
256 herm_mul);
258 mul_herm);
259 INSTALL_BINOP_TI (ti, op_trans_ldiv, octave_complex_matrix,
261 trans_ldiv);
262 INSTALL_BINOP_TI (ti, op_herm_ldiv, octave_complex_matrix,
264 herm_ldiv);
265
273 el_mul);
275 el_div);
277 el_pow);
279 el_ldiv);
281 el_and);
283 el_or);
284
286
289 assign);
290
292 null_assign);
294 null_assign);
296 null_assign);
297
300 assign_add);
303 assign_sub);
306 assign_el_mul);
309 assign_el_div);
310}
311
312OCTAVE_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
ComplexMatrix complex_matrix_value(bool=false) const
Definition ov-ch-mat.h:131
ComplexNDArray complex_array_value(bool=false) const
Definition ov-ch-mat.h:137
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_cm_cm_ops(octave::type_info &ti)
Definition op-cm-cm.cc:225
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)