GNU Octave  9.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-2024 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 
45 DEFNDUNOP_OP (not, float_complex_matrix, float_complex_array, !)
46 DEFNDUNOP_OP (uplus, float_complex_matrix, float_complex_array, /* no-op */)
47 DEFNDUNOP_OP (uminus, float_complex_matrix, float_complex_array, -)
48 
49 DEFUNOP (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 
59 DEFUNOP (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 
69 DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
70 DEFNCUNOP_METHOD (decr, float_complex_matrix, decrement)
71 DEFNCUNOP_METHOD (changesign, float_complex_matrix, changesign)
72 
73 // complex matrix by complex matrix ops.
74 
75 DEFNDBINOP_OP (add, float_complex_matrix, float_complex_matrix,
76  float_complex_array, float_complex_array, +)
77 DEFNDBINOP_OP (sub, float_complex_matrix, float_complex_matrix,
78  float_complex_array, float_complex_array, -)
79 
80 DEFBINOP_OP (mul, float_complex_matrix, float_complex_matrix, *)
81 
82 DEFBINOP (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 
95 DEFBINOPX (pow, float_complex_matrix, float_complex_matrix)
96 {
97  error ("can't do A ^ B for A and B both matrices");
98 }
99 
100 DEFBINOP (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 
113 DEFBINOP (trans_mul, float_complex_matrix, float_complex_matrix)
114 {
117  return octave_value(xgemm (v1.float_complex_matrix_value (),
120 }
121 
122 DEFBINOP (mul_trans, float_complex_matrix, float_complex_matrix)
123 {
126  return octave_value(xgemm (v1.float_complex_matrix_value (),
129 }
130 
131 DEFBINOP (herm_mul, float_complex_matrix, float_complex_matrix)
132 {
135  return octave_value(xgemm (v1.float_complex_matrix_value (),
138 }
139 
140 DEFBINOP (mul_herm, float_complex_matrix, float_complex_matrix)
141 {
144  return octave_value(xgemm (v1.float_complex_matrix_value (),
147 }
148 
149 DEFBINOP (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 
163 DEFBINOP (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 
177 DEFNDCMPLXCMPOP_FN (lt, float_complex_matrix, float_complex_matrix,
178  float_complex_array, float_complex_array, mx_el_lt)
179 DEFNDCMPLXCMPOP_FN (le, float_complex_matrix, float_complex_matrix,
180  float_complex_array, float_complex_array, mx_el_le)
181 DEFNDCMPLXCMPOP_FN (eq, float_complex_matrix, float_complex_matrix,
182  float_complex_array, float_complex_array, mx_el_eq)
183 DEFNDCMPLXCMPOP_FN (ge, float_complex_matrix, float_complex_matrix,
184  float_complex_array, float_complex_array, mx_el_ge)
185 DEFNDCMPLXCMPOP_FN (gt, float_complex_matrix, float_complex_matrix,
186  float_complex_array, float_complex_array, mx_el_gt)
187 DEFNDCMPLXCMPOP_FN (ne, float_complex_matrix, float_complex_matrix,
188  float_complex_array, float_complex_array, mx_el_ne)
189 
190 DEFNDBINOP_FN (el_mul, float_complex_matrix, float_complex_matrix,
191  float_complex_array, float_complex_array, product)
192 DEFNDBINOP_FN (el_div, float_complex_matrix, float_complex_matrix,
193  float_complex_array, float_complex_array, quotient)
194 DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex_matrix,
195  float_complex_array, float_complex_array, elem_xpow)
196 
197 DEFBINOP (el_ldiv, float_complex_matrix, float_complex_matrix)
198 {
201 
203  v1.float_complex_array_value ()));
204 }
205 
206 DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex_matrix,
207  float_complex_array, float_complex_array, mx_el_and)
208 DEFNDBINOP_FN (el_or, float_complex_matrix, float_complex_matrix,
209  float_complex_array, float_complex_array, mx_el_or)
210 
211 DEFNDCATOP_FN (fcm_fcm, float_complex_matrix, float_complex_matrix,
212  float_complex_array, float_complex_array, concat)
213 
214 DEFNDCATOP_FN (cm_fcm, complex_matrix, float_complex_matrix,
215  float_complex_array, float_complex_array, concat)
216 
217 DEFNDCATOP_FN (fcm_cm, float_complex_matrix, complex_matrix,
218  float_complex_array, float_complex_array, concat)
219 
220 DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex_matrix,
221  float_complex_array, assign)
222 DEFNDASSIGNOP_FN (sgl_clx_assign, float_complex_matrix, complex_matrix,
223  float_complex_array, assign)
224 DEFNDASSIGNOP_FN (sgl_assign, float_complex_matrix, matrix,
225  float_complex_array, assign)
226 DEFNDASSIGNOP_FN (dbl_assign, complex_matrix, float_complex_matrix,
227  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 void
242 {
248 
249  INSTALL_NCUNOP_TI (ti, op_incr, octave_float_complex_matrix, incr);
250  INSTALL_NCUNOP_TI (ti, op_decr, octave_float_complex_matrix, decr);
252 
273  INSTALL_BINOP_TI (ti, op_trans_ldiv, octave_float_complex_matrix,
274  octave_float_complex_matrix, trans_ldiv);
276  octave_float_complex_matrix, herm_ldiv);
277 
297  octave_float_complex_matrix, el_ldiv);
302 
304  octave_float_complex_matrix, fcm_fcm);
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 
336 OCTAVE_END_NAMESPACE(octave)
ComplexColumnVector quotient(const ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:158
ComplexColumnVector product_eq(ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:158
ComplexColumnVector product(const ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:158
ComplexColumnVector quotient_eq(ComplexColumnVector &x, const ComplexColumnVector &y)
Definition: CColVector.h:158
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
Definition: CMatrix.cc:3346
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:7516
ComplexMatrix mul_herm(const ComplexMatrix &m, const SparseComplexMatrix &a)
Definition: CSparse.cc:7522
ComplexMatrix trans_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition: CSparse.cc:7546
ComplexMatrix herm_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
Definition: CSparse.cc:7552
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
Definition: ov-base-mat.h:139
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
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
Definition: error.cc:988
@ 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:241
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:127
#define DEFNDBINOP_OP(name, t1, t2, e1, e2, op)
Definition: ops.h:291
#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:316
#define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:327
#define DEFBINOPX(name, t1, t2)
Definition: ops.h:240
#define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop)
Definition: ops.h:156
#define DEFBINOP(name, t1, t2)
Definition: ops.h:245
#define DEFNDUNOP_OP(name, t, e, op)
Definition: ops.h:206
#define DEFBINOP_OP(name, t1, t2, op)
Definition: ops.h:250
#define OCTAVE_CAST_BASE_VALUE(T, T_VAL, BASE_VAL)
Definition: ops.h:52
#define DEFNCUNOP_METHOD(name, t, method)
Definition: ops.h:232
#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:364
#define DEFUNOP(name, t)
Definition: ops.h:194
#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:141
#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:1676
octave_value op_el_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1681
octave_value op_uplus(const octave_value &a)
Definition: ov.h:1634
octave_value op_add(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1663
octave_value op_gt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1675
octave_value op_uminus(const octave_value &a)
Definition: ov.h:1635
octave_value op_el_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1679
octave_value op_mul_herm(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1697
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1637
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1683
octave_value op_sub(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1664
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1665
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1638
octave_value op_le(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1672
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1682
octave_value op_herm_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1696
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1673
octave_value op_el_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1680
octave_value op_not(const octave_value &a)
Definition: ov.h:1633
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1669
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1668
octave_value op_ge(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1674
octave_value op_el_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1678
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1666
octave_value op_trans_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1694
octave_value op_mul_trans(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1695
octave_value op_lt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1671
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:469
octave_value elem_xpow(double a, const SparseMatrix &b)
Definition: sparse-xpow.cc:347