Mercurial > octave
annotate libinterp/operators/op-cs-sm.cc @ 26596:cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
* libinterp/corefcn/errwarn.h (warn_divide_by_zero),
libinterp/corefcn/errwarn.cc (warn_divide_by_zero): Deprecate function
"warn_divide_by_zero", and leave implementation empty for a few releases.
* libinterp/corefcn/error.cc: Use different id for test.
* examples/code/make_int.cc: No longer advertise "warn_divide_by_zero" in the
examples.
* libinterp/operators/op-*-*.cc: Remove unused header "errwarn.h". Remove check
for scalar zero divisor including the warning.
* libinterp/operators/op-dms-template.cc (gripe_if_zero): Remove function.
* scripts/general/quadgk.m, scripts/general/quadv.m,
scripts/statistics/kurtosis.m, scripts/statistics/mean.m,
scripts/statistics/skewness.m: No longer need to turn off unused warning.
* scripts/help/warning_ids.m: Remove documentation of "Octave:divide-by-zero".
* test/jit.tst, test/mk-sparse-tst.sh, test/prefer.tst: Remove warning
"Octave:divide-by-zero".
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Tue, 22 Jan 2019 14:34:08 +0100 |
parents | 00f796120a6d |
children | b442ec6dda5c |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
3 Copyright (C) 2004-2019 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 | |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
28 #include "ovl.h" |
5164 | 29 #include "ov.h" |
30 #include "ov-typeinfo.h" | |
31 #include "ov-complex.h" | |
32 #include "ops.h" | |
33 #include "xpow.h" | |
34 | |
35 #include "sparse-xpow.h" | |
36 #include "sparse-xdiv.h" | |
37 #include "ov-re-sparse.h" | |
38 #include "ov-cx-sparse.h" | |
39 #include "smx-cs-sm.h" | |
40 #include "smx-sm-cs.h" | |
41 | |
42 // complex by sparse matrix ops. | |
43 | |
44 DEFBINOP_OP (add, complex, sparse_matrix, +) | |
45 DEFBINOP_OP (sub, complex, sparse_matrix, -) | |
46 DEFBINOP_OP (mul, complex, sparse_matrix, *) | |
47 | |
48 DEFBINOP (div, complex, sparse_matrix) | |
49 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
50 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
51 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2); |
5164 | 52 |
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
|
53 if (v2.rows () == 1 && v2.columns () == 1) |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
54 return octave_value (SparseComplexMatrix (1, 1, v1.complex_value () / v2.scalar_value ())); |
6221 | 55 else |
56 { | |
57 MatrixType typ = v2.matrix_type (); | |
58 ComplexMatrix m1 = ComplexMatrix (1, 1, v1.complex_value ()); | |
59 SparseMatrix m2 = v2.sparse_matrix_value (); | |
60 ComplexMatrix ret = xdiv (m1, m2, typ); | |
61 v2.matrix_type (typ); | |
62 return ret; | |
63 } | |
5164 | 64 } |
65 | |
66 DEFBINOP (pow, complex, sparse_matrix) | |
67 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
68 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
69 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2); |
5164 | 70 return xpow (v1.complex_value (), v2.matrix_value ()); |
71 } | |
72 | |
73 DEFBINOP (ldiv, complex, sparse_matrix) | |
74 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
75 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
76 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2); |
5164 | 77 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
78 return octave_value (v2.sparse_matrix_value () / v1.complex_value ()); |
5164 | 79 } |
80 | |
81 DEFBINOP_FN (lt, complex, sparse_matrix, mx_el_lt) | |
82 DEFBINOP_FN (le, complex, sparse_matrix, mx_el_le) | |
83 DEFBINOP_FN (eq, complex, sparse_matrix, mx_el_eq) | |
84 DEFBINOP_FN (ge, complex, sparse_matrix, mx_el_ge) | |
85 DEFBINOP_FN (gt, complex, sparse_matrix, mx_el_gt) | |
86 DEFBINOP_FN (ne, complex, sparse_matrix, mx_el_ne) | |
87 | |
88 DEFBINOP_OP (el_mul, complex, sparse_matrix, *) | |
89 DEFBINOP_FN (el_div, complex, sparse_matrix, x_el_div) | |
90 DEFBINOP_FN (el_pow, complex, sparse_matrix, elem_xpow) | |
91 | |
92 DEFBINOP (el_ldiv, complex, sparse_matrix) | |
93 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
94 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
95 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2); |
5164 | 96 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
97 return octave_value (v2.sparse_matrix_value () / v1.complex_value ()); |
5164 | 98 } |
99 | |
100 DEFBINOP_FN (el_and, complex, sparse_matrix, mx_el_and) | |
101 DEFBINOP_FN (el_or, complex, sparse_matrix, mx_el_or) | |
102 | |
103 DEFCATOP (cs_sm, sparse_matrix, complex) | |
104 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
105 octave_complex& v1 = dynamic_cast<octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
106 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2); |
5164 | 107 SparseComplexMatrix tmp (1, 1, v1.complex_value ()); |
108 return octave_value (tmp. concat (v2.sparse_matrix_value (), ra_idx)); | |
109 } | |
110 | |
111 DEFCONV (sparse_matrix_conv, complex, sparse_matrix) | |
112 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
113 const octave_complex& v = dynamic_cast<const octave_complex&> (a); |
5164 | 114 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
115 return new octave_sparse_matrix (SparseMatrix (v.matrix_value ())); |
5164 | 116 } |
117 | |
118 void | |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
119 install_cs_sm_ops (octave::type_info& ti) |
5164 | 120 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
121 INSTALL_BINOP_TI (ti, op_add, octave_complex, octave_sparse_matrix, add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 INSTALL_BINOP_TI (ti, op_sub, octave_complex, octave_sparse_matrix, sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
123 INSTALL_BINOP_TI (ti, op_mul, octave_complex, octave_sparse_matrix, mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
124 INSTALL_BINOP_TI (ti, op_div, octave_complex, octave_sparse_matrix, div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
125 INSTALL_BINOP_TI (ti, op_pow, octave_complex, octave_sparse_matrix, pow); |
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_ldiv, octave_complex, octave_sparse_matrix, ldiv); |
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_lt, octave_complex, octave_sparse_matrix, lt); |
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_le, octave_complex, octave_sparse_matrix, le); |
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_eq, octave_complex, octave_sparse_matrix, eq); |
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_ge, octave_complex, octave_sparse_matrix, ge); |
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_gt, octave_complex, octave_sparse_matrix, gt); |
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_ne, octave_complex, octave_sparse_matrix, ne); |
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_el_mul, octave_complex, octave_sparse_matrix, el_mul); |
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_el_div, octave_complex, octave_sparse_matrix, el_div); |
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_el_pow, octave_complex, octave_sparse_matrix, el_pow); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
136 INSTALL_BINOP_TI (ti, op_el_ldiv, octave_complex, octave_sparse_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
137 el_ldiv); |
24540
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_and, octave_complex, octave_sparse_matrix, el_and); |
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_or, octave_complex, octave_sparse_matrix, el_or); |
5164 | 140 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 INSTALL_CATOP_TI (ti, octave_complex, octave_sparse_matrix, cs_sm); |
5164 | 142 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 INSTALL_ASSIGNCONV_TI (ti, octave_complex, octave_sparse_matrix, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
144 octave_complex_matrix); |
5164 | 145 |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
146 INSTALL_WIDENOP_TI (ti, octave_complex, octave_sparse_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
147 sparse_matrix_conv); |
5164 | 148 } |