Mercurial > octave
annotate libinterp/operators/op-s-m.cc @ 33657:6f2baadfdb3d bytecode-interpreter tip
maint: Merge default to bytecode-interpreter.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Tue, 04 Jun 2024 20:06:05 -0400 |
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 | |
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-scalar.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
33 #include "ov-float.h" |
2928 | 34 #include "ov-re-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
35 #include "ov-flt-re-mat.h" |
2928 | 36 #include "ov-typeinfo.h" |
37 #include "ops.h" | |
38 #include "xdiv.h" | |
39 #include "xpow.h" | |
40 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31318
diff
changeset
|
41 OCTAVE_BEGIN_NAMESPACE(octave) |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
42 |
2928 | 43 // scalar by matrix ops. |
44 | |
4543 | 45 DEFNDBINOP_OP (add, scalar, matrix, scalar, array, +) |
46 DEFNDBINOP_OP (sub, scalar, matrix, scalar, array, -) | |
47 DEFNDBINOP_OP (mul, scalar, matrix, scalar, array, *) | |
2928 | 48 |
49 DEFBINOP (div, scalar, matrix) | |
50 { | |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
51 OCTAVE_CAST_BASE_VALUE (const octave_scalar&, v1, a1); |
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
52 OCTAVE_CAST_BASE_VALUE (const octave_matrix&, v2, a2); |
3766 | 53 |
54 Matrix m1 = v1.matrix_value (); | |
55 Matrix m2 = v2.matrix_value (); | |
5785 | 56 MatrixType typ = v2.matrix_type (); |
3766 | 57 |
5785 | 58 Matrix ret = xdiv (m1, m2, typ); |
59 | |
60 v2.matrix_type (typ); | |
61 return ret; | |
2928 | 62 } |
63 | |
64 DEFBINOP_FN (pow, scalar, matrix, xpow) | |
65 | |
66 DEFBINOP (ldiv, scalar, 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_scalar&, 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); |
2928 | 70 |
31318
eba9d6d4cc41
Backed out changeset 83e47ccf34ac
Arun Giridhar <arungiridhar@gmail.com>
parents:
31317
diff
changeset
|
71 return octave_value (v2.array_value () / v1.double_value ()); |
2928 | 72 } |
73 | |
4543 | 74 DEFNDBINOP_FN (lt, scalar, matrix, scalar, array, mx_el_lt) |
75 DEFNDBINOP_FN (le, scalar, matrix, scalar, array, mx_el_le) | |
76 DEFNDBINOP_FN (eq, scalar, matrix, scalar, array, mx_el_eq) | |
77 DEFNDBINOP_FN (ge, scalar, matrix, scalar, array, mx_el_ge) | |
78 DEFNDBINOP_FN (gt, scalar, matrix, scalar, array, mx_el_gt) | |
79 DEFNDBINOP_FN (ne, scalar, matrix, scalar, array, mx_el_ne) | |
2928 | 80 |
4543 | 81 DEFNDBINOP_OP (el_mul, scalar, matrix, scalar, array, *) |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
82 DEFNDBINOP_FN (el_div, scalar, matrix, scalar, array, elem_xdiv) |
4543 | 83 DEFNDBINOP_FN (el_pow, scalar, matrix, scalar, array, elem_xpow) |
2928 | 84 |
85 DEFBINOP (el_ldiv, scalar, matrix) | |
86 { | |
31867
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_scalar&, v1, a1); |
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
88 OCTAVE_CAST_BASE_VALUE (const octave_matrix&, v2, a2); |
2928 | 89 |
31318
eba9d6d4cc41
Backed out changeset 83e47ccf34ac
Arun Giridhar <arungiridhar@gmail.com>
parents:
31317
diff
changeset
|
90 return octave_value (v2.array_value () / v1.double_value ()); |
2928 | 91 } |
92 | |
4543 | 93 DEFNDBINOP_FN (el_and, scalar, matrix, scalar, array, mx_el_and) |
94 DEFNDBINOP_FN (el_or, scalar, matrix, scalar, array, mx_el_or) | |
2928 | 95 |
4915 | 96 DEFNDCATOP_FN (s_m, scalar, matrix, array, array, concat) |
97 | |
2928 | 98 DEFCONV (matrix_conv, scalar, matrix) |
99 { | |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
100 OCTAVE_CAST_BASE_VALUE (const octave_scalar&, v, a); |
2928 | 101 |
102 return new octave_matrix (v.matrix_value ()); | |
103 } | |
104 | |
105 void | |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 install_s_m_ops (octave::type_info& ti) |
2928 | 107 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
108 INSTALL_BINOP_TI (ti, op_add, octave_scalar, octave_matrix, add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
109 INSTALL_BINOP_TI (ti, op_sub, octave_scalar, octave_matrix, sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
110 INSTALL_BINOP_TI (ti, op_mul, octave_scalar, octave_matrix, mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
111 INSTALL_BINOP_TI (ti, op_div, octave_scalar, octave_matrix, div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
112 INSTALL_BINOP_TI (ti, op_pow, octave_scalar, octave_matrix, pow); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
113 INSTALL_BINOP_TI (ti, op_ldiv, octave_scalar, octave_matrix, ldiv); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
114 INSTALL_BINOP_TI (ti, op_lt, octave_scalar, octave_matrix, lt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
115 INSTALL_BINOP_TI (ti, op_le, octave_scalar, octave_matrix, le); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
116 INSTALL_BINOP_TI (ti, op_eq, octave_scalar, octave_matrix, eq); |
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_ge, octave_scalar, octave_matrix, ge); |
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_gt, octave_scalar, octave_matrix, gt); |
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_ne, octave_scalar, octave_matrix, ne); |
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_el_mul, octave_scalar, octave_matrix, el_mul); |
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_el_div, octave_scalar, octave_matrix, el_div); |
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_el_pow, octave_scalar, octave_matrix, el_pow); |
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_el_ldiv, octave_scalar, octave_matrix, el_ldiv); |
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_el_and, octave_scalar, octave_matrix, el_and); |
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_el_or, octave_scalar, octave_matrix, el_or); |
2928 | 126 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
127 INSTALL_CATOP_TI (ti, octave_scalar, octave_matrix, s_m); |
4915 | 128 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
129 INSTALL_ASSIGNCONV_TI (ti, octave_scalar, octave_matrix, octave_matrix); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
130 INSTALL_ASSIGNCONV_TI (ti, octave_float_scalar, octave_matrix, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
131 octave_float_matrix); |
2928 | 132 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 INSTALL_WIDENOP_TI (ti, octave_scalar, octave_matrix, matrix_conv); |
2928 | 134 } |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
135 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31318
diff
changeset
|
136 OCTAVE_END_NAMESPACE(octave) |