annotate libinterp/operators/op-s-m.cc @ 31318:eba9d6d4cc41

Backed out changeset 83e47ccf34ac
author Arun Giridhar <arungiridhar@gmail.com>
date Wed, 19 Oct 2022 12:13:57 -0400
parents 83e47ccf34ac
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29989
diff changeset
3 // Copyright (C) 1996-2022 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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
31 #include "ov.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36 #include "ov-typeinfo.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
37 #include "ops.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38 #include "xdiv.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
39 #include "xpow.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
40
29989
b260322f6730 move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
41 OCTAVE_NAMESPACE_BEGIN
b260322f6730 move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
42
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
43 // scalar by matrix ops.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
44
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
45 DEFNDBINOP_OP (add, scalar, matrix, scalar, array, +)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
46 DEFNDBINOP_OP (sub, scalar, matrix, scalar, array, -)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
47 DEFNDBINOP_OP (mul, scalar, matrix, scalar, array, *)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
48
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
49 DEFBINOP (div, scalar, matrix)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
50 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
51 const octave_scalar& v1 = dynamic_cast<const octave_scalar&> (a1);
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
52 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2);
3766
df962bbf1788 [project @ 2001-01-29 14:33:07 by jwe]
jwe
parents: 3540
diff changeset
53
df962bbf1788 [project @ 2001-01-29 14:33:07 by jwe]
jwe
parents: 3540
diff changeset
54 Matrix m1 = v1.matrix_value ();
df962bbf1788 [project @ 2001-01-29 14:33:07 by jwe]
jwe
parents: 3540
diff changeset
55 Matrix m2 = v2.matrix_value ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
56 MatrixType typ = v2.matrix_type ();
3766
df962bbf1788 [project @ 2001-01-29 14:33:07 by jwe]
jwe
parents: 3540
diff changeset
57
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
58 Matrix ret = xdiv (m1, m2, typ);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
59
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
60 v2.matrix_type (typ);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
61 return ret;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
62 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
63
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
64 DEFBINOP_FN (pow, scalar, matrix, xpow)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
65
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
66 DEFBINOP (ldiv, scalar, matrix)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
67 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
68 const octave_scalar& v1 = dynamic_cast<const octave_scalar&> (a1);
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
69 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
72 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
73
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
74 DEFNDBINOP_FN (lt, scalar, matrix, scalar, array, mx_el_lt)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
75 DEFNDBINOP_FN (le, scalar, matrix, scalar, array, mx_el_le)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
76 DEFNDBINOP_FN (eq, scalar, matrix, scalar, array, mx_el_eq)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
77 DEFNDBINOP_FN (ge, scalar, matrix, scalar, array, mx_el_ge)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
78 DEFNDBINOP_FN (gt, scalar, matrix, scalar, array, mx_el_gt)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
79 DEFNDBINOP_FN (ne, scalar, matrix, scalar, array, mx_el_ne)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
80
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
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
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
83 DEFNDBINOP_FN (el_pow, scalar, matrix, scalar, array, elem_xpow)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
84
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
85 DEFBINOP (el_ldiv, scalar, matrix)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
86 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
87 const octave_scalar& v1 = dynamic_cast<const octave_scalar&> (a1);
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
88 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
91 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
92
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
93 DEFNDBINOP_FN (el_and, scalar, matrix, scalar, array, mx_el_and)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4192
diff changeset
94 DEFNDBINOP_FN (el_or, scalar, matrix, scalar, array, mx_el_or)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
95
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4543
diff changeset
96 DEFNDCATOP_FN (s_m, scalar, matrix, array, array, concat)
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4543
diff changeset
97
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
98 DEFCONV (matrix_conv, scalar, matrix)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
99 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
100 const octave_scalar& v = dynamic_cast<const octave_scalar&> (a);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
101
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
102 return new octave_matrix (v.matrix_value ());
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
103 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
104
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4543
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
134 }
29989
b260322f6730 move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
135
b260322f6730 move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
136 OCTAVE_NAMESPACE_END