Mercurial > octave
annotate libinterp/operators/op-scm-m.cc @ 25054:6652d3823428 stable
maint: Update copyright dates in all source files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 30 Mar 2018 09:19:05 -0400 |
parents | 46440078d73b |
children | 078b795c5219 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
3 Copyright (C) 2004-2018 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5164 | 7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
11 (at your option) any later version. |
5164 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 GNU General Public License for more details. |
5164 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
5164 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
25 # include "config.h" |
5164 | 26 #endif |
27 | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
28 #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
|
29 #include "ovl.h" |
5164 | 30 #include "ov.h" |
31 #include "ov-typeinfo.h" | |
32 #include "ov-re-mat.h" | |
33 #include "ov-cx-mat.h" | |
34 #include "ops.h" | |
35 #include "xdiv.h" | |
36 | |
37 #include "sparse-xpow.h" | |
38 #include "sparse-xdiv.h" | |
39 #include "smx-scm-m.h" | |
40 #include "smx-m-scm.h" | |
41 #include "ov-cx-sparse.h" | |
42 | |
43 // sparse complex matrix by matrix ops. | |
44 | |
45 DEFBINOP_OP (add, sparse_complex_matrix, matrix, +) | |
46 DEFBINOP_OP (sub, sparse_complex_matrix, matrix, -) | |
47 | |
5429 | 48 DEFBINOP_OP (mul, sparse_complex_matrix, matrix, *) |
5164 | 49 |
50 DEFBINOP (div, sparse_complex_matrix, matrix) | |
51 { | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
52 const octave_sparse_complex_matrix& v1 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
53 = dynamic_cast<const octave_sparse_complex_matrix&> (a1); |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
54 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
5785 | 55 MatrixType typ = v2.matrix_type (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 ComplexMatrix ret = xdiv (v1.complex_matrix_value (), |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
58 v2.matrix_value (), typ); |
5785 | 59 |
60 v2.matrix_type (typ); | |
61 return ret; | |
5164 | 62 } |
63 | |
64 DEFBINOPX (pow, sparse_complex_matrix, matrix) | |
65 { | |
66 error ("can't do A ^ B for A and B both matrices"); | |
67 } | |
68 | |
69 DEFBINOP (ldiv, sparse_complex_matrix, matrix) | |
70 { | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
71 const octave_sparse_complex_matrix& v1 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
72 = dynamic_cast<const octave_sparse_complex_matrix&> (a1); |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
73 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
74 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
75 if (v1.rows () == 1 && v1.columns () == 1) |
6221 | 76 { |
77 Complex d = v1.complex_value (); | |
78 | |
79 if (d == 0.0) | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
80 warn_divide_by_zero (); |
5322 | 81 |
6221 | 82 return octave_value (v2.array_value () / d); |
83 } | |
84 else | |
85 { | |
86 MatrixType typ = v1.matrix_type (); | |
5322 | 87 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
88 ComplexMatrix ret = xleftdiv (v1.sparse_complex_matrix_value (), |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
89 v2.matrix_value (), typ); |
6221 | 90 |
91 v1.matrix_type (typ); | |
92 return ret; | |
93 } | |
5164 | 94 } |
95 | |
96 DEFBINOP_FN (lt, sparse_complex_matrix, matrix, mx_el_lt) | |
97 DEFBINOP_FN (le, sparse_complex_matrix, matrix, mx_el_le) | |
98 DEFBINOP_FN (eq, sparse_complex_matrix, matrix, mx_el_eq) | |
99 DEFBINOP_FN (ge, sparse_complex_matrix, matrix, mx_el_ge) | |
100 DEFBINOP_FN (gt, sparse_complex_matrix, matrix, mx_el_gt) | |
101 DEFBINOP_FN (ne, sparse_complex_matrix, matrix, mx_el_ne) | |
102 | |
103 DEFBINOP_FN (el_mul, sparse_complex_matrix, matrix, product) | |
104 DEFBINOP_FN (el_div, sparse_complex_matrix, matrix, quotient) | |
105 | |
106 DEFBINOP (el_pow, sparse_complex_matrix, matrix) | |
107 { | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
108 const octave_sparse_complex_matrix& v1 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
109 = dynamic_cast<const octave_sparse_complex_matrix&> (a1); |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
110 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
111 |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
112 return octave_value |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 (elem_xpow (v1.sparse_complex_matrix_value (), SparseMatrix |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 (v2.matrix_value ()))); |
5164 | 115 } |
116 | |
117 DEFBINOP (el_ldiv, sparse_complex_matrix, matrix) | |
118 { | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
119 const octave_sparse_complex_matrix& v1 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
120 = dynamic_cast<const octave_sparse_complex_matrix&> (a1); |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
121 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
5164 | 122 |
123 return octave_value | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 (quotient (v2.matrix_value (), v1.sparse_complex_matrix_value ())); |
5164 | 125 } |
126 | |
127 DEFBINOP_FN (el_and, sparse_complex_matrix, matrix, mx_el_and) | |
128 DEFBINOP_FN (el_or, sparse_complex_matrix, matrix, mx_el_or) | |
129 | |
130 DEFCATOP (scm_m, sparse_complex_matrix, matrix) | |
131 { | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
132 octave_sparse_complex_matrix& v1 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
133 = dynamic_cast<octave_sparse_complex_matrix&> (a1); |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
134 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
5164 | 135 SparseMatrix tmp (v2.matrix_value ()); |
136 return octave_value | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
137 (v1.sparse_complex_matrix_value ().concat (tmp, ra_idx)); |
5164 | 138 } |
139 | |
140 DEFASSIGNOP (assign, sparse_complex_matrix, matrix) | |
141 { | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
142 octave_sparse_complex_matrix& v1 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
143 = dynamic_cast<octave_sparse_complex_matrix&> (a1); |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
144 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
5164 | 145 |
146 SparseComplexMatrix tmp (v2.complex_matrix_value ()); | |
147 v1.assign (idx, tmp); | |
148 return octave_value (); | |
149 } | |
150 | |
151 void | |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 install_scm_m_ops (octave::type_info& ti) |
5164 | 153 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 INSTALL_BINOP_TI (ti, op_add, octave_sparse_complex_matrix, octave_matrix, add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
155 INSTALL_BINOP_TI (ti, op_sub, octave_sparse_complex_matrix, octave_matrix, sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 INSTALL_BINOP_TI (ti, op_mul, octave_sparse_complex_matrix, octave_matrix, mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
157 INSTALL_BINOP_TI (ti, op_div, octave_sparse_complex_matrix, octave_matrix, div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 INSTALL_BINOP_TI (ti, op_pow, octave_sparse_complex_matrix, octave_matrix, pow); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
159 INSTALL_BINOP_TI (ti, op_ldiv, octave_sparse_complex_matrix, octave_matrix, ldiv); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
160 INSTALL_BINOP_TI (ti, op_lt, octave_sparse_complex_matrix, octave_matrix, lt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 INSTALL_BINOP_TI (ti, op_le, octave_sparse_complex_matrix, octave_matrix, le); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
162 INSTALL_BINOP_TI (ti, op_eq, octave_sparse_complex_matrix, octave_matrix, eq); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
163 INSTALL_BINOP_TI (ti, op_ge, octave_sparse_complex_matrix, octave_matrix, ge); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
164 INSTALL_BINOP_TI (ti, op_gt, octave_sparse_complex_matrix, octave_matrix, gt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
165 INSTALL_BINOP_TI (ti, op_ne, octave_sparse_complex_matrix, octave_matrix, ne); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 INSTALL_BINOP_TI (ti, op_el_mul, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
167 el_mul); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
168 INSTALL_BINOP_TI (ti, op_el_div, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
169 el_div); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 INSTALL_BINOP_TI (ti, op_el_pow, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
171 el_pow); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
172 INSTALL_BINOP_TI (ti, op_el_ldiv, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
173 el_ldiv); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
174 INSTALL_BINOP_TI (ti, op_el_and, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
175 el_and); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
176 INSTALL_BINOP_TI (ti, op_el_or, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
177 el_or); |
5164 | 178 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
179 INSTALL_CATOP_TI (ti, octave_sparse_complex_matrix, octave_matrix, scm_m); |
5164 | 180 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
181 INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_sparse_complex_matrix, octave_matrix, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
182 assign); |
5164 | 183 } |