Mercurial > octave
annotate libinterp/operators/op-m-s.cc @ 27923:bd51beb6205e
update formatting of copyright notices
* Use <https://octave.org/copyright/> instead of
<https://octave.org/COPYRIGHT.html/>.
* For consistency with other comments in the Octave sources, use
C++-style comments for copyright blocks in C and C++ files.
* Use delimiters above and below copyright blocks that are appropriate
for the language used in the file.
* Eliminate extra spacing inside copyright blocks.
* lex.ll (looks_like_copyright): Also allow newlines and carriage
returns before the word "Copyright".
* scripts/mk-doc.pl (gethelp): Also skip empty comment lines.
* bp-table.cc, type.m: Adjust tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jan 2020 11:59:41 -0500 |
parents | 1891570abac8 |
children | 0a5b15007766 |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1996-2020 The Octave Project Developers |
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 | |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
30 #include "ovl.h" |
2928 | 31 #include "ov.h" |
32 #include "ov-re-mat.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
33 #include "ov-flt-re-mat.h" |
13160
6abc581bf2c9
Define missing real double -> float complex assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
34 #include "ov-flt-cx-mat.h" |
2928 | 35 #include "ov-scalar.h" |
36 #include "ov-typeinfo.h" | |
37 #include "ops.h" | |
38 #include "xdiv.h" | |
39 #include "xpow.h" | |
40 | |
41 // matrix by scalar ops. | |
42 | |
4543 | 43 DEFNDBINOP_OP (add, matrix, scalar, array, scalar, +) |
44 DEFNDBINOP_OP (sub, matrix, scalar, array, scalar, -) | |
45 DEFNDBINOP_OP (mul, matrix, scalar, array, scalar, *) | |
2928 | 46 |
47 DEFBINOP (div, matrix, scalar) | |
48 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
49 const octave_matrix& v1 = dynamic_cast<const octave_matrix&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
50 const octave_scalar& v2 = dynamic_cast<const octave_scalar&> (a2); |
2928 | 51 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
52 return octave_value (v1.array_value () / v2.double_value ()); |
2928 | 53 } |
54 | |
55 DEFBINOP_FN (pow, matrix, scalar, xpow) | |
56 | |
57 DEFBINOP (ldiv, matrix, scalar) | |
58 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
59 const octave_matrix& v1 = dynamic_cast<const octave_matrix&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
60 const octave_scalar& v2 = dynamic_cast<const octave_scalar&> (a2); |
3766 | 61 |
62 Matrix m1 = v1.matrix_value (); | |
63 Matrix m2 = v2.matrix_value (); | |
5785 | 64 MatrixType typ = v1.matrix_type (); |
3766 | 65 |
5785 | 66 Matrix ret = xleftdiv (m1, m2, typ); |
67 | |
68 v1.matrix_type (typ); | |
69 return ret; | |
2928 | 70 } |
71 | |
4543 | 72 DEFNDBINOP_FN (lt, matrix, scalar, array, scalar, mx_el_lt) |
73 DEFNDBINOP_FN (le, matrix, scalar, array, scalar, mx_el_le) | |
74 DEFNDBINOP_FN (eq, matrix, scalar, array, scalar, mx_el_eq) | |
75 DEFNDBINOP_FN (ge, matrix, scalar, array, scalar, mx_el_ge) | |
76 DEFNDBINOP_FN (gt, matrix, scalar, array, scalar, mx_el_gt) | |
77 DEFNDBINOP_FN (ne, matrix, scalar, array, scalar, mx_el_ne) | |
2928 | 78 |
4543 | 79 DEFNDBINOP_OP (el_mul, matrix, scalar, array, scalar, *) |
2928 | 80 |
81 DEFBINOP (el_div, matrix, scalar) | |
82 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
83 const octave_matrix& v1 = dynamic_cast<const octave_matrix&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
84 const octave_scalar& v2 = dynamic_cast<const octave_scalar&> (a2); |
2928 | 85 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
86 return octave_value (v1.array_value () / v2.double_value ()); |
2928 | 87 } |
88 | |
4543 | 89 DEFNDBINOP_FN (el_pow, matrix, scalar, array, scalar, elem_xpow) |
2928 | 90 |
91 DEFBINOP (el_ldiv, matrix, scalar) | |
92 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
93 const octave_matrix& v1 = dynamic_cast<const octave_matrix&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
94 const octave_scalar& v2 = dynamic_cast<const octave_scalar&> (a2); |
2928 | 95 |
4543 | 96 return x_el_div (v2.double_value (), v1.array_value ()); |
2928 | 97 } |
98 | |
4543 | 99 DEFNDBINOP_FN (el_and, matrix, scalar, array, scalar, mx_el_and) |
100 DEFNDBINOP_FN (el_or, matrix, scalar, array, scalar, mx_el_or) | |
2928 | 101 |
4915 | 102 DEFNDCATOP_FN (m_s, matrix, scalar, array, array, concat) |
103 | |
8679
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
104 DEFNDASSIGNOP_FN (assign, matrix, scalar, scalar, assign) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
105 DEFNDASSIGNOP_FN (sgl_assign, float_matrix, scalar, float_scalar, assign) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
106 DEFNDASSIGNOP_FN (clx_sgl_assign, float_complex_matrix, scalar, float_complex, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 assign) |
2928 | 108 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
109 DEFNDASSIGNOP_OP (assign_add, matrix, scalar, scalar, +=) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
110 DEFNDASSIGNOP_OP (assign_sub, matrix, scalar, scalar, -=) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
111 DEFNDASSIGNOP_OP (assign_mul, matrix, scalar, scalar, *=) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
112 DEFNDASSIGNOP_OP (assign_div, matrix, scalar, scalar, /=) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
113 |
2928 | 114 void |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
115 install_m_s_ops (octave::type_info& ti) |
2928 | 116 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
117 INSTALL_BINOP_TI (ti, op_add, octave_matrix, octave_scalar, add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
118 INSTALL_BINOP_TI (ti, op_sub, octave_matrix, octave_scalar, sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
119 INSTALL_BINOP_TI (ti, op_mul, octave_matrix, octave_scalar, mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
120 INSTALL_BINOP_TI (ti, op_div, octave_matrix, octave_scalar, div); |
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_pow, octave_matrix, octave_scalar, pow); |
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_ldiv, octave_matrix, octave_scalar, ldiv); |
4543 | 123 |
24540
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_lt, octave_matrix, octave_scalar, lt); |
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_le, octave_matrix, octave_scalar, le); |
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_eq, octave_matrix, octave_scalar, eq); |
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_ge, octave_matrix, octave_scalar, ge); |
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_gt, octave_matrix, octave_scalar, gt); |
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_ne, octave_matrix, octave_scalar, ne); |
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_el_mul, octave_matrix, octave_scalar, el_mul); |
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_el_div, octave_matrix, octave_scalar, el_div); |
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_el_pow, octave_matrix, octave_scalar, el_pow); |
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_ldiv, octave_matrix, octave_scalar, el_ldiv); |
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_and, octave_matrix, octave_scalar, el_and); |
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_or, octave_matrix, octave_scalar, el_or); |
2928 | 136 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
137 INSTALL_CATOP_TI (ti, octave_matrix, octave_scalar, m_s); |
4915 | 138 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
139 INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_matrix, octave_scalar, assign); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
140 INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_float_matrix, octave_scalar, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
141 sgl_assign); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
142 INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_float_complex_matrix, octave_scalar, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
143 clx_sgl_assign); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
144 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 INSTALL_ASSIGNOP_TI (ti, op_add_eq, octave_matrix, octave_scalar, assign_add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
146 INSTALL_ASSIGNOP_TI (ti, op_sub_eq, octave_matrix, octave_scalar, assign_sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 INSTALL_ASSIGNOP_TI (ti, op_mul_eq, octave_matrix, octave_scalar, assign_mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 INSTALL_ASSIGNOP_TI (ti, op_div_eq, octave_matrix, octave_scalar, assign_div); |
2928 | 149 } |