Mercurial > octave
annotate libinterp/operators/op-cm-m.cc @ 33634:4a70f390c85e default tip @
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 28 May 2024 15:25:54 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31867
diff
changeset
|
3 // Copyright (C) 1996-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2928 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
2928 | 28 #endif |
29 | |
30 #include "mx-cm-m.h" | |
31 #include "mx-m-cm.h" | |
4544 | 32 #include "mx-cnda-nda.h" |
33 #include "mx-nda-cnda.h" | |
2928 | 34 |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
35 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
36 #include "ovl.h" |
2928 | 37 #include "ov.h" |
38 #include "ov-cx-mat.h" | |
39 #include "ov-re-mat.h" | |
40 #include "ov-typeinfo.h" | |
41 #include "ops.h" | |
42 #include "xdiv.h" | |
43 #include "xpow.h" | |
44 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
45 OCTAVE_BEGIN_NAMESPACE(octave) |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
46 |
2928 | 47 // complex matrix by matrix ops. |
48 | |
4550 | 49 DEFNDBINOP_OP (add, complex_matrix, matrix, complex_array, array, +) |
50 DEFNDBINOP_OP (sub, complex_matrix, matrix, complex_array, array, -) | |
4543 | 51 |
2928 | 52 DEFBINOP_OP (mul, complex_matrix, matrix, *) |
5785 | 53 |
9663
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
54 DEFBINOP (mul_trans, complex_matrix, matrix) |
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
55 { |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
56 OCTAVE_CAST_BASE_VALUE (const octave_complex_matrix&, v1, a1); |
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
57 OCTAVE_CAST_BASE_VALUE (const octave_matrix&, v2, a2); |
9663
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
58 |
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
59 ComplexMatrix m1 = v1.complex_matrix_value (); |
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
60 Matrix m2 = v2.matrix_value (); |
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
61 |
9665
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9663
diff
changeset
|
62 return ComplexMatrix (xgemm (real (m1), m2, blas_no_trans, blas_trans), |
1dba57e9d08d
use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents:
9663
diff
changeset
|
63 xgemm (imag (m1), m2, blas_no_trans, blas_trans)); |
9663
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
64 } |
7e5b4de5fbfe
improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
65 |
5785 | 66 DEFBINOP (div, complex_matrix, matrix) |
67 { | |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
68 OCTAVE_CAST_BASE_VALUE (const octave_complex_matrix&, v1, a1); |
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
69 OCTAVE_CAST_BASE_VALUE (const octave_matrix&, v2, a2); |
5785 | 70 MatrixType typ = v2.matrix_type (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
71 |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
72 ComplexMatrix ret = xdiv (v1.complex_matrix_value (), |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9665
diff
changeset
|
73 v2.matrix_value (), typ); |
5785 | 74 |
75 v2.matrix_type (typ); | |
76 return ret; | |
77 } | |
78 | |
2928 | 79 DEFBINOPX (pow, complex_matrix, matrix) |
80 { | |
81 error ("can't do A ^ B for A and B both matrices"); | |
82 } | |
83 | |
5785 | 84 DEFBINOP (ldiv, complex_matrix, matrix) |
85 { | |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
86 OCTAVE_CAST_BASE_VALUE (const octave_complex_matrix&, v1, a1); |
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
87 OCTAVE_CAST_BASE_VALUE (const octave_matrix&, v2, a2); |
5785 | 88 MatrixType typ = v1.matrix_type (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
89 |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (), |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9665
diff
changeset
|
91 v2.matrix_value (), typ); |
5785 | 92 |
93 v1.matrix_type (typ); | |
94 return ret; | |
95 } | |
2928 | 96 |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
97 DEFNDCMPLXCMPOP_FN (lt, complex_matrix, matrix, complex_array, array, mx_el_lt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
98 DEFNDCMPLXCMPOP_FN (le, complex_matrix, matrix, complex_array, array, mx_el_le) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
99 DEFNDCMPLXCMPOP_FN (eq, complex_matrix, matrix, complex_array, array, mx_el_eq) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
100 DEFNDCMPLXCMPOP_FN (ge, complex_matrix, matrix, complex_array, array, mx_el_ge) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
101 DEFNDCMPLXCMPOP_FN (gt, complex_matrix, matrix, complex_array, array, mx_el_gt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
102 DEFNDCMPLXCMPOP_FN (ne, complex_matrix, matrix, complex_array, array, mx_el_ne) |
2928 | 103 |
4550 | 104 DEFNDBINOP_FN (el_mul, complex_matrix, matrix, complex_array, array, product) |
105 DEFNDBINOP_FN (el_div, complex_matrix, matrix, complex_array, array, quotient) | |
106 DEFNDBINOP_FN (el_pow, complex_matrix, matrix, complex_array, array, elem_xpow) | |
2928 | 107 |
108 DEFBINOP (el_ldiv, complex_matrix, matrix) | |
109 { | |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
110 OCTAVE_CAST_BASE_VALUE (const octave_complex_matrix&, v1, a1); |
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
111 OCTAVE_CAST_BASE_VALUE (const octave_matrix&, v2, a2); |
2928 | 112 |
4550 | 113 return quotient (v2.array_value (), v1.complex_array_value ()); |
2928 | 114 } |
115 | |
4550 | 116 DEFNDBINOP_FN (el_and, complex_matrix, matrix, complex_array, array, mx_el_and) |
117 DEFNDBINOP_FN (el_or, complex_matrix, matrix, complex_array, array, mx_el_or) | |
2928 | 118 |
4915 | 119 DEFNDCATOP_FN (cm_m, complex_matrix, matrix, complex_array, array, concat) |
120 | |
4686 | 121 DEFNDASSIGNOP_FN (assign, complex_matrix, matrix, complex_array, assign) |
2928 | 122 |
123 void | |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
124 install_cm_m_ops (octave::type_info& ti) |
2928 | 125 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 INSTALL_BINOP_TI (ti, op_add, octave_complex_matrix, octave_matrix, add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
127 INSTALL_BINOP_TI (ti, op_sub, octave_complex_matrix, octave_matrix, sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
128 INSTALL_BINOP_TI (ti, op_mul, octave_complex_matrix, octave_matrix, mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
129 INSTALL_BINOP_TI (ti, op_div, octave_complex_matrix, octave_matrix, div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
130 INSTALL_BINOP_TI (ti, op_pow, octave_complex_matrix, octave_matrix, pow); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
131 INSTALL_BINOP_TI (ti, op_ldiv, octave_complex_matrix, octave_matrix, ldiv); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
132 INSTALL_BINOP_TI (ti, op_lt, octave_complex_matrix, octave_matrix, lt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 INSTALL_BINOP_TI (ti, op_le, octave_complex_matrix, octave_matrix, le); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
134 INSTALL_BINOP_TI (ti, op_eq, octave_complex_matrix, octave_matrix, eq); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
135 INSTALL_BINOP_TI (ti, op_ge, octave_complex_matrix, octave_matrix, ge); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
136 INSTALL_BINOP_TI (ti, op_gt, octave_complex_matrix, octave_matrix, gt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
137 INSTALL_BINOP_TI (ti, op_ne, octave_complex_matrix, octave_matrix, ne); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
138 INSTALL_BINOP_TI (ti, op_el_mul, octave_complex_matrix, octave_matrix, el_mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
139 INSTALL_BINOP_TI (ti, op_el_div, octave_complex_matrix, octave_matrix, el_div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 INSTALL_BINOP_TI (ti, op_el_pow, octave_complex_matrix, octave_matrix, el_pow); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
141 INSTALL_BINOP_TI (ti, op_el_ldiv, octave_complex_matrix, octave_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
142 el_ldiv); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 INSTALL_BINOP_TI (ti, op_el_and, octave_complex_matrix, octave_matrix, el_and); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
144 INSTALL_BINOP_TI (ti, op_el_or, octave_complex_matrix, octave_matrix, el_or); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
145 INSTALL_BINOP_TI (ti, op_mul_trans, octave_complex_matrix, octave_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
146 mul_trans); |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
147 INSTALL_BINOP_TI (ti, op_mul_herm, octave_complex_matrix, octave_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
148 mul_trans); |
2928 | 149 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
150 INSTALL_CATOP_TI (ti, octave_complex_matrix, octave_matrix, cm_m); |
4915 | 151 |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
152 INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_complex_matrix, octave_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
153 assign); |
2928 | 154 } |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
155 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
156 OCTAVE_END_NAMESPACE(octave) |