annotate libinterp/corefcn/bsxfun.cc @ 31827:c8dd3da44e83

maint: Remove `#if 0` commented-out code from the codebase. The codebase had 1850+ lines of code that were commented out using the `#if 0` preprocessor directive. Running `hg annotate` indicated that most of them had been commented out several years ago and had not been edited in years, except maybe whitespace formatting, leading to a large amount of commented-out code that was not up-to-date with the rest of the codebase. This edit removes almost all instances of `#if 0` from .h and .cpp files, the only exception being a corner case where /* */ comments cannot be used as they will interfere with BIST formatting. If this removal proves to be too disruptive, please revert as required.
author Arun Giridhar <arungiridhar@gmail.com>
date Tue, 14 Feb 2023 22:04:06 -0500
parents 21f9b34eb893
children 05b4479c29d8
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 //
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31607
diff changeset
3 // Copyright (C) 2007-2023 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 ////////////////////////////////////////////////////////////////////////
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
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"
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
28 #endif
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
29
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
30 #include <list>
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
31 #include <string>
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
32 #include <vector>
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
33
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
34 #include "lo-mappers.h"
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
35
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14854
diff changeset
36 #include "defun.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
37 #include "interpreter.h"
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
38 #include "oct-map.h"
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
39 #include "ov-colon.h"
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
40 #include "ov-fcn-handle.h"
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
41 #include "unwind-prot.h"
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
42 #include "variables.h"
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
43
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
44 // Optimized bsxfun operations
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
45 enum bsxfun_builtin_op
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
46 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
47 bsxfun_builtin_plus = 0,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
48 bsxfun_builtin_minus,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
49 bsxfun_builtin_times,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
50 bsxfun_builtin_divide,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
51 bsxfun_builtin_max,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
52 bsxfun_builtin_min,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
53 bsxfun_builtin_eq,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
54 bsxfun_builtin_ne,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
55 bsxfun_builtin_lt,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
56 bsxfun_builtin_le,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
57 bsxfun_builtin_gt,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
58 bsxfun_builtin_ge,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
59 bsxfun_builtin_and,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
60 bsxfun_builtin_or,
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
61 bsxfun_builtin_power,
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
62 bsxfun_builtin_unknown,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
63 bsxfun_num_builtin_ops = bsxfun_builtin_unknown
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
64 };
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
65
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
66 const char *bsxfun_builtin_names[] =
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
67 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
68 "plus",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
69 "minus",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
70 "times",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
71 "rdivide",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
72 "max",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
73 "min",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
74 "eq",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
75 "ne",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
76 "lt",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
77 "le",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
78 "gt",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
79 "ge",
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
80 "and",
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
81 "or",
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
82 "power"
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
83 };
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
84
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
85 static bsxfun_builtin_op
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
86 bsxfun_builtin_lookup (const std::string& name)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
87 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
88 for (int i = 0; i < bsxfun_num_builtin_ops; i++)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
89 if (name == bsxfun_builtin_names[i])
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
90 return static_cast<bsxfun_builtin_op> (i);
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
91
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
92 return bsxfun_builtin_unknown;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
93 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
94
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
95 typedef octave_value (*bsxfun_handler) (const octave_value&,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
96 const octave_value&);
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
97
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
98 // Static table of handlers.
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
99 bsxfun_handler bsxfun_handler_table[bsxfun_num_builtin_ops][btyp_num_types];
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
100
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21080
diff changeset
101 template <typename NDA, NDA (bsxfun_op) (const NDA&, const NDA&)>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
102 static octave_value
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
103 bsxfun_forward_op (const octave_value& x, const octave_value& y)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
104 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
105 NDA xa = octave_value_extract<NDA> (x);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
106 NDA ya = octave_value_extract<NDA> (y);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
107 return octave_value (bsxfun_op (xa, ya));
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
108 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
109
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21080
diff changeset
110 template <typename NDA, boolNDArray (bsxfun_rel) (const NDA&, const NDA&)>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
111 static octave_value
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
112 bsxfun_forward_rel (const octave_value& x, const octave_value& y)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
113 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
114 NDA xa = octave_value_extract<NDA> (x);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
115 NDA ya = octave_value_extract<NDA> (y);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
116 return octave_value (bsxfun_rel (xa, ya));
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
117 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
118
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
119 // pow() needs a special handler for reals
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
120 // because of the potentially complex result.
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21080
diff changeset
121 template <typename NDA, typename CNDA>
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
122 static octave_value
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
123 do_bsxfun_real_pow (const octave_value& x, const octave_value& y)
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
124 {
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
125 NDA xa = octave_value_extract<NDA> (x);
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
126 NDA ya = octave_value_extract<NDA> (y);
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
127 if (! ya.all_integers () && xa.any_element_is_negative ())
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
128 return octave_value (bsxfun_pow (CNDA (xa), ya));
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
129 else
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
130 return octave_value (bsxfun_pow (xa, ya));
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
131 }
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
132
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31730
diff changeset
133 static void maybe_fill_table ()
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
134 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
135 static bool filled = false;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
136 if (filled)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
137 return;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
138
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
139 #define REGISTER_OP_HANDLER(OP, BTYP, NDA, FUNOP) \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
140 bsxfun_handler_table[OP][BTYP] = bsxfun_forward_op<NDA, FUNOP>
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
141
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
142 #define REGISTER_REL_HANDLER(REL, BTYP, NDA, FUNREL) \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
143 bsxfun_handler_table[REL][BTYP] = bsxfun_forward_rel<NDA, FUNREL>
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
144
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
145 #define REGISTER_STD_HANDLERS(BTYP, NDA) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
146 REGISTER_OP_HANDLER (bsxfun_builtin_plus, BTYP, NDA, bsxfun_add); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
147 REGISTER_OP_HANDLER (bsxfun_builtin_minus, BTYP, NDA, bsxfun_sub); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
148 REGISTER_OP_HANDLER (bsxfun_builtin_times, BTYP, NDA, bsxfun_mul); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
149 REGISTER_OP_HANDLER (bsxfun_builtin_divide, BTYP, NDA, bsxfun_div); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
150 REGISTER_OP_HANDLER (bsxfun_builtin_max, BTYP, NDA, bsxfun_max); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
151 REGISTER_OP_HANDLER (bsxfun_builtin_min, BTYP, NDA, bsxfun_min); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
152 REGISTER_REL_HANDLER (bsxfun_builtin_eq, BTYP, NDA, bsxfun_eq); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
153 REGISTER_REL_HANDLER (bsxfun_builtin_ne, BTYP, NDA, bsxfun_ne); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
154 REGISTER_REL_HANDLER (bsxfun_builtin_lt, BTYP, NDA, bsxfun_lt); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
155 REGISTER_REL_HANDLER (bsxfun_builtin_le, BTYP, NDA, bsxfun_le); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
156 REGISTER_REL_HANDLER (bsxfun_builtin_gt, BTYP, NDA, bsxfun_gt); \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
157 REGISTER_REL_HANDLER (bsxfun_builtin_ge, BTYP, NDA, bsxfun_ge)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
158
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
159 REGISTER_STD_HANDLERS (btyp_double, NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
160 REGISTER_STD_HANDLERS (btyp_float, FloatNDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
161 REGISTER_STD_HANDLERS (btyp_complex, ComplexNDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
162 REGISTER_STD_HANDLERS (btyp_float_complex, FloatComplexNDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
163 REGISTER_STD_HANDLERS (btyp_int8, int8NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
164 REGISTER_STD_HANDLERS (btyp_int16, int16NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
165 REGISTER_STD_HANDLERS (btyp_int32, int32NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
166 REGISTER_STD_HANDLERS (btyp_int64, int64NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
167 REGISTER_STD_HANDLERS (btyp_uint8, uint8NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
168 REGISTER_STD_HANDLERS (btyp_uint16, uint16NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
169 REGISTER_STD_HANDLERS (btyp_uint32, uint32NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
170 REGISTER_STD_HANDLERS (btyp_uint64, uint64NDArray);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
171
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
172 // For bools, we register and/or.
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
173 REGISTER_OP_HANDLER (bsxfun_builtin_and, btyp_bool, boolNDArray, bsxfun_and);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
174 REGISTER_OP_HANDLER (bsxfun_builtin_or, btyp_bool, boolNDArray, bsxfun_or);
9783
119d97db51f0 avoid repeated table init in bsxfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9743
diff changeset
175
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
176 // Register power handlers.
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
177 bsxfun_handler_table[bsxfun_builtin_power][btyp_double]
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
178 = do_bsxfun_real_pow<NDArray, ComplexNDArray>;
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
179 bsxfun_handler_table[bsxfun_builtin_power][btyp_float]
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
180 = do_bsxfun_real_pow<FloatNDArray, FloatComplexNDArray>;
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
181
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
182 REGISTER_OP_HANDLER (bsxfun_builtin_power, btyp_complex, ComplexNDArray,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
183 bsxfun_pow);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
184 REGISTER_OP_HANDLER (bsxfun_builtin_power, btyp_float_complex,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
185 FloatComplexNDArray, bsxfun_pow);
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9783
diff changeset
186
10107
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
187 // For chars, we want just relational handlers.
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
188 REGISTER_REL_HANDLER (bsxfun_builtin_eq, btyp_char, charNDArray, bsxfun_eq);
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
189 REGISTER_REL_HANDLER (bsxfun_builtin_ne, btyp_char, charNDArray, bsxfun_ne);
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
190 REGISTER_REL_HANDLER (bsxfun_builtin_lt, btyp_char, charNDArray, bsxfun_lt);
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
191 REGISTER_REL_HANDLER (bsxfun_builtin_le, btyp_char, charNDArray, bsxfun_le);
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
192 REGISTER_REL_HANDLER (bsxfun_builtin_gt, btyp_char, charNDArray, bsxfun_gt);
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
193 REGISTER_REL_HANDLER (bsxfun_builtin_ge, btyp_char, charNDArray, bsxfun_ge);
fd262afea1d1 optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
194
9783
119d97db51f0 avoid repeated table init in bsxfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9743
diff changeset
195 filled = true;
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
196 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
197
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
198 static octave_value
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
199 maybe_optimized_builtin (const std::string& name,
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
200 const octave_value& a, const octave_value& b)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
201 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
202 octave_value retval;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
203
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
204 maybe_fill_table ();
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
205
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
206 bsxfun_builtin_op op = bsxfun_builtin_lookup (name);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
207 if (op != bsxfun_builtin_unknown)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
208 {
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
209 builtin_type_t btyp_a = a.builtin_type ();
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
210 builtin_type_t btyp_b = b.builtin_type ();
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
211
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
212 // Simplify single/double combinations.
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
213 if (btyp_a == btyp_float && btyp_b == btyp_double)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
214 btyp_b = btyp_float;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
215 else if (btyp_a == btyp_double && btyp_b == btyp_float)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
216 btyp_a = btyp_float;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
217 else if (btyp_a == btyp_float_complex && btyp_b == btyp_complex)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
218 btyp_b = btyp_float_complex;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
219 else if (btyp_a == btyp_complex && btyp_b == btyp_float_complex)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
220 btyp_a = btyp_float_complex;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
221
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
222 if (btyp_a == btyp_b && btyp_a != btyp_unknown)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
223 {
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
224 bsxfun_handler handler = bsxfun_handler_table[op][btyp_a];
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
225 if (handler)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
226 retval = handler (a, b);
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
227 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
228 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
229
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
230 return retval;
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
231 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
232
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
233 static bool
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
234 maybe_update_column (octave_value& Ac, const octave_value& A,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
235 const dim_vector& dva, const dim_vector& dvc,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
236 octave_idx_type i, octave_value_list& idx)
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
237 {
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
238 octave_idx_type nd = dva.ndims ();
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
239
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
240 if (i == 0)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
241 {
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
242 idx(0) = octave_value (':');
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
243 for (octave_idx_type j = 1; j < nd; j++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
244 {
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 20172
diff changeset
245 if (dva(j) == 1)
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
246 idx(j) = octave_value (1);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
247 else
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
248 idx(j) = octave_value ((i % dvc(j)) + 1);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
249
20230
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20218
diff changeset
250 i /= dvc(j);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
251 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
252
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
253 Ac = A;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
254 Ac = Ac.single_subsref ("(", idx);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
255 return true;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
256 }
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
257 else
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
258 {
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
259 bool is_changed = false;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
260 octave_idx_type k = i;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
261 octave_idx_type k1 = i - 1;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
262 for (octave_idx_type j = 1; j < nd; j++)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
263 {
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 20172
diff changeset
264 if (dva(j) != 1 && k % dvc(j) != k1 % dvc(j))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
265 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
266 idx (j) = octave_value ((k % dvc(j)) + 1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
267 is_changed = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
268 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
269
20230
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20218
diff changeset
270 k /= dvc(j);
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20218
diff changeset
271 k1 /= dvc(j);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
272 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
273
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
274 if (is_changed)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
275 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
276 Ac = A;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
277 Ac = Ac.single_subsref ("(", idx);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
278 return true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
279 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
280 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
281 return false;
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
282 }
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
283 }
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
284
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
285 static void
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
286 update_index (Array<int>& idx, const dim_vector& dv, octave_idx_type i)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
287 {
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
288 octave_idx_type nd = dv.ndims ();
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
289
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
290 idx(0) = 0;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
291 for (octave_idx_type j = 1; j < nd; j++)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
292 {
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 20172
diff changeset
293 idx(j) = i % dv(j);
20230
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20218
diff changeset
294 i /= dv(j);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
295 }
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
296 }
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
297
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31273
diff changeset
298 OCTAVE_BEGIN_NAMESPACE(octave)
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
299
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30326
diff changeset
300 DEFMETHOD (bsxfun, interp, args, ,
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
301 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
302 @deftypefn {} {@var{C} =} bsxfun (@var{f}, @var{A}, @var{B})
25106
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
303 Apply a binary function @var{f} element-by-element to two array arguments
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
304 @var{A} and @var{B}, expanding singleton dimensions in either input argument as
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
305 necessary.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
306
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
307 @var{f} is a function handle, inline function, or string containing the name
25106
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
308 of the function to evaluate. The function @var{f} must be capable of accepting
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
309 two column-vector arguments of equal length, or one column vector argument and
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
310 a scalar.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
311
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
312 The dimensions of @var{A} and @var{B} must be equal or singleton. The
25106
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
313 singleton dimensions of the arrays will be expanded to the same dimensionality
d7ad543255c5 doc: Shorten very long first sentences of docstrings (bug #53388).
Rik <rik@octave.org>
parents: 25054
diff changeset
314 as the other array.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
315 @seealso{arrayfun, cellfun}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
316 @end deftypefn */)
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
317 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20802
diff changeset
318 if (args.length () != 3)
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
319 print_usage ();
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
320
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
321 octave_value fcn = args(0);
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
322 if (fcn.is_string ())
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
323 {
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
324 std::string name = fcn.string_value ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
325
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
326 symbol_table& symtab = interp.get_symbol_table ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
327
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
328 fcn = symtab.find_function (name);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
329
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
330 if (fcn.is_undefined ())
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
331 error ("bsxfun: invalid function name: %s", name.c_str ());
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
332 }
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
333 else if (! (args(0).is_function_handle () || args(0).is_inline_function ()))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
334 error ("bsxfun: F must be a string or function handle");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
335
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
336 octave_value_list retval;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
337
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
338 const octave_value A = args(1);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
339 const octave_value B = args(2);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
340
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
341 if (fcn.is_builtin_function ()
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
342 || (fcn.is_function_handle () && ! A.isobject () && ! B.isobject ()))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
343 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
344 // This may break if the default behavior is overridden. But if you
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
345 // override arithmetic operators for builtin classes, you should expect
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
346 // mayhem anyway (constant folding etc). Querying is_overloaded() may
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
347 // not be exactly what we need here.
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
348 octave_function *fcn_val = fcn.function_value ();
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
349 if (fcn_val)
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
350 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
351 octave_value tmp = maybe_optimized_builtin (fcn_val->name (), A, B);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
352 if (tmp.is_defined ())
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
353 retval(0) = tmp;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
354 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
355 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
356
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
357 if (retval.empty ())
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
358 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
359 dim_vector dva = A.dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
360 octave_idx_type nda = dva.ndims ();
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
361 dim_vector dvb = B.dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
362 octave_idx_type ndb = dvb.ndims ();
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
363 octave_idx_type nd = nda;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
364
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
365 if (nda > ndb)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
366 dvb.resize (nda, 1);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
367 else if (nda < ndb)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
368 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
369 dva.resize (ndb, 1);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
370 nd = ndb;
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
371 }
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
372
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
373 for (octave_idx_type i = 0; i < nd; i++)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
374 if (dva(i) != dvb(i) && dva(i) != 1 && dvb(i) != 1)
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
375 error ("bsxfun: dimensions of A and B must match");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
376
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
377 // Find the size of the output
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
378 dim_vector dvc;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
379 dvc.resize (nd);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
380
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
381 for (octave_idx_type i = 0; i < nd; i++)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
382 dvc(i) = (dva(i) < 1 ? dva(i)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
383 : (dvb(i) < 1 ? dvb(i)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
384 : (dva(i) > dvb(i) ? dva(i)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
385 : dvb(i))));
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
386
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
387 if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
388 {
21080
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
389 octave_value_list inputs (2);
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
390 inputs(0) = A;
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
391 inputs(1) = B;
31730
610a85b0ff62 use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
392 retval = interp.feval (fcn, inputs, 1);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
393 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
394 else if (dvc.numel () < 1)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
395 {
21080
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
396 octave_value_list inputs (2);
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
397 inputs(0) = A.resize (dvc);
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
398 inputs(1) = B.resize (dvc);
31730
610a85b0ff62 use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
399 retval = interp.feval (fcn, inputs, 1);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
400 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
401 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
402 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
403 octave_idx_type ncount = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
404 for (octave_idx_type i = 1; i < nd; i++)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
405 ncount *= dvc(i);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
406
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
407 #define BSXDEF(T) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
408 T result_ ## T; \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
409 bool have_ ## T = false;
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
410
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
411 BSXDEF(NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
412 BSXDEF(ComplexNDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
413 BSXDEF(FloatNDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
414 BSXDEF(FloatComplexNDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
415 BSXDEF(boolNDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
416 BSXDEF(int8NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
417 BSXDEF(int16NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
418 BSXDEF(int32NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
419 BSXDEF(int64NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
420 BSXDEF(uint8NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
421 BSXDEF(uint16NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
422 BSXDEF(uint32NDArray);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
423 BSXDEF(uint64NDArray);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
424
21602
47c76e56a1de maint: Remove extra space between end of statement and semicolon.
Rik <rik@octave.org>
parents: 21580
diff changeset
425 octave_value Ac;
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
426 octave_value_list idxA;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
427 octave_value Bc;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
428 octave_value_list idxB;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
429 octave_value C;
21080
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
430 octave_value_list inputs (2);
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21602
diff changeset
431 Array<int> ra_idx (dim_vector (dvc.ndims (), 1), 0);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
432
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
433 for (octave_idx_type i = 0; i < ncount; i++)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
434 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
435 if (maybe_update_column (Ac, A, dva, dvc, i, idxA))
21080
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
436 inputs(0) = Ac;
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
437
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
438 if (maybe_update_column (Bc, B, dvb, dvc, i, idxB))
21080
529593df22fa bsxfun.cc: Pre-declare size of octave_value_list.
Rik <rik@octave.org>
parents: 20918
diff changeset
439 inputs(1) = Bc;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
440
31730
610a85b0ff62 use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
441 octave_value_list tmp = interp.feval (fcn, inputs, 1);
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
442
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
443 #define BSXINIT(T, CLS, EXTRACTOR) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
444 (result_type == CLS) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
445 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
446 have_ ## T = true; \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
447 result_ ## T = tmp(0). EXTRACTOR ## _array_value (); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
448 result_ ## T .resize (dvc); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
449 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
450
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
451 if (i == 0)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
452 {
23583
b7747a2c88b2 maint: Deprecate is_sparse_type and replace with issparse.
Rik <rik@octave.org>
parents: 23582
diff changeset
453 if (! tmp(0).issparse ())
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
454 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
455 std::string result_type = tmp(0).class_name ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
456 if (result_type == "double")
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
457 {
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
458 if (tmp(0).isreal ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
459 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
460 have_NDArray = true;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
461 result_NDArray = tmp(0).array_value ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
462 result_NDArray.resize (dvc);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
463 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
464 else
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
465 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
466 have_ComplexNDArray = true;
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
467 result_ComplexNDArray
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
468 = tmp(0).complex_array_value ();
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
469 result_ComplexNDArray.resize (dvc);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
470 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
471 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
472 else if (result_type == "single")
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
473 {
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
474 if (tmp(0).isreal ())
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
475 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
476 have_FloatNDArray = true;
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
477 result_FloatNDArray
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
478 = tmp(0).float_array_value ();
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
479 result_FloatNDArray.resize (dvc);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
480 }
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
481 else
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
482 {
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
483 have_FloatComplexNDArray = true;
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
484 result_FloatComplexNDArray
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
485 = tmp(0).float_complex_array_value ();
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
486 result_FloatComplexNDArray.resize (dvc);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
487 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
488 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
489 else if BSXINIT(boolNDArray, "logical", bool)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
490 else if BSXINIT(int8NDArray, "int8", int8)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
491 else if BSXINIT(int16NDArray, "int16", int16)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
492 else if BSXINIT(int32NDArray, "int32", int32)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
493 else if BSXINIT(int64NDArray, "int64", int64)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
494 else if BSXINIT(uint8NDArray, "uint8", uint8)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
495 else if BSXINIT(uint16NDArray, "uint16", uint16)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
496 else if BSXINIT(uint32NDArray, "uint32", uint32)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
497 else if BSXINIT(uint64NDArray, "uint64", uint64)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
498 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
499 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
500 C = tmp(0);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
501 C = C.resize (dvc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
502 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
503 }
21372
a1aa52bff079 Allow bsxfun to work for sparse and type conversion (bug #45219, bug #40089).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21345
diff changeset
504 else // Skip semi-fast path for sparse matrices
a1aa52bff079 Allow bsxfun to work for sparse and type conversion (bug #45219, bug #40089).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21345
diff changeset
505 {
a1aa52bff079 Allow bsxfun to work for sparse and type conversion (bug #45219, bug #40089).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21345
diff changeset
506 C = tmp (0);
a1aa52bff079 Allow bsxfun to work for sparse and type conversion (bug #45219, bug #40089).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21345
diff changeset
507 C = C.resize (dvc);
a1aa52bff079 Allow bsxfun to work for sparse and type conversion (bug #45219, bug #40089).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21345
diff changeset
508 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
509 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
510 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
511 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
512 update_index (ra_idx, dvc, i);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
513
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
514 if (have_NDArray)
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
515 {
23585
570170b6eb09 maint: Deprecate is_float_type and replace with isfloat.
Rik <rik@octave.org>
parents: 23583
diff changeset
516 if (! tmp(0).isfloat ())
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
517 {
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
518 have_NDArray = false;
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
519 C = result_NDArray;
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
520 C = cat_op (C, tmp(0), ra_idx);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
521 }
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
522 else if (tmp(0).isreal ())
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
523 result_NDArray.insert (tmp(0).array_value (), ra_idx);
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
524 else
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
525 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
526 result_ComplexNDArray
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
527 = ComplexNDArray (result_NDArray);
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
528 result_ComplexNDArray.insert
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
529 (tmp(0).complex_array_value (), ra_idx);
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
530 have_NDArray = false;
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
531 have_ComplexNDArray = true;
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
532 }
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
533 }
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
534 else if (have_FloatNDArray)
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
535 {
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
536 if (! tmp(0).isfloat ())
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
537 {
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
538 have_FloatNDArray = false;
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
539 C = result_FloatNDArray;
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
540 C = cat_op (C, tmp(0), ra_idx);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
541 }
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
542 else if (tmp(0).isreal ())
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
543 result_FloatNDArray.insert
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
544 (tmp(0).float_array_value (), ra_idx);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
545 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
546 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
547 result_FloatComplexNDArray
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
548 = FloatComplexNDArray (result_FloatNDArray);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
549 result_FloatComplexNDArray.insert
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
550 (tmp(0).float_complex_array_value (), ra_idx);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
551 have_FloatNDArray = false;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
552 have_FloatComplexNDArray = true;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
553 }
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
554 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
555
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
556 #define BSXLOOP(T, CLS, EXTRACTOR) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
557 (have_ ## T) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
558 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
559 if (tmp(0).class_name () != CLS) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
560 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
561 have_ ## T = false; \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
562 C = result_ ## T; \
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
563 C = cat_op (C, tmp(0), ra_idx); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
564 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
565 else \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
566 result_ ## T .insert (tmp(0). EXTRACTOR ## _array_value (), ra_idx); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
567 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
568
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
569 else if BSXLOOP(ComplexNDArray, "double", complex)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
570 else if BSXLOOP(FloatComplexNDArray, "single", float_complex)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
571 else if BSXLOOP(boolNDArray, "logical", bool)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
572 else if BSXLOOP(int8NDArray, "int8", int8)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
573 else if BSXLOOP(int16NDArray, "int16", int16)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
574 else if BSXLOOP(int32NDArray, "int32", int32)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
575 else if BSXLOOP(int64NDArray, "int64", int64)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
576 else if BSXLOOP(uint8NDArray, "uint8", uint8)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
577 else if BSXLOOP(uint16NDArray, "uint16", uint16)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
578 else if BSXLOOP(uint32NDArray, "uint32", uint32)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
579 else if BSXLOOP(uint64NDArray, "uint64", uint64)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
580 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
581 C = cat_op (C, tmp(0), ra_idx);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20230
diff changeset
582 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
583 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
584
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
585 #define BSXEND(T) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
586 (have_ ## T) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
587 retval(0) = result_ ## T;
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
588
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20555
diff changeset
589 if BSXEND(NDArray)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
590 else if BSXEND(ComplexNDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
591 else if BSXEND(FloatNDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
592 else if BSXEND(FloatComplexNDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
593 else if BSXEND(boolNDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
594 else if BSXEND(int8NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
595 else if BSXEND(int16NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
596 else if BSXEND(int32NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
597 else if BSXEND(int64NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
598 else if BSXEND(uint8NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
599 else if BSXEND(uint16NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
600 else if BSXEND(uint32NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
601 else if BSXEND(uint64NDArray)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
602 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
603 retval(0) = C;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10141
diff changeset
604 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
605 }
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
606
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
607 return retval;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
608 }
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
609
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
610 /*
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
611
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
612 %!shared a, b, c, f
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
613 %! a = randn (4, 4);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
614 %! b = mean (a, 1);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
615 %! c = mean (a, 2);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
616 %! f = @minus;
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
617 %!error bsxfun (f)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
618 %!error bsxfun (f, a)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
619 %!error bsxfun (a, b)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
620 %!error bsxfun (a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
621 %!error bsxfun (f, a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
622 %!error bsxfun (f, ones (4, 0), ones (4, 4))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
623 %!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
624 %!assert (bsxfun (f, ones (1, 4), ones (4, 1)), zeros (4, 4))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
625 %!assert (bsxfun (f, a, b), a - repmat (b, 4, 1))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
626 %!assert (bsxfun (f, a, c), a - repmat (c, 1, 4))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
627 %!assert (bsxfun ("minus", ones (1, 4), ones (4, 1)), zeros (4, 4))
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
628
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
629 %!shared a, b, c, f
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
630 %! a = randn (4, 4);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
631 %! a(1) *= 1i;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
632 %! b = mean (a, 1);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
633 %! c = mean (a, 2);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
634 %! f = @minus;
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
635 %!error bsxfun (f)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
636 %!error bsxfun (f, a)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
637 %!error bsxfun (a, b)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
638 %!error bsxfun (a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
639 %!error bsxfun (f, a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
640 %!error bsxfun (f, ones (4, 0), ones (4, 4))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
641 %!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
642 %!assert (bsxfun (f, ones (1, 4), ones (4, 1)), zeros (4, 4))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
643 %!assert (bsxfun (f, a, b), a - repmat (b, 4, 1))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
644 %!assert (bsxfun (f, a, c), a - repmat (c, 1, 4))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
645 %!assert (bsxfun ("minus", ones (1, 4), ones (4, 1)), zeros (4, 4))
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
646
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
647 %!shared a, b, c, f
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
648 %! a = randn (4, 4);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
649 %! a(end) *= 1i;
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
650 %! b = mean (a, 1);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
651 %! c = mean (a, 2);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
652 %! f = @minus;
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
653 %!error bsxfun (f)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
654 %!error bsxfun (f, a)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
655 %!error bsxfun (a, b)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
656 %!error bsxfun (a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
657 %!error bsxfun (f, a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
658 %!error bsxfun (f, ones (4, 0), ones (4, 4))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
659 %!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
660 %!assert (bsxfun (f, ones (1, 4), ones (4, 1)), zeros (4, 4))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
661 %!assert (bsxfun (f, a, b), a - repmat (b, 4, 1))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
662 %!assert (bsxfun (f, a, c), a - repmat (c, 1, 4))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
663 %!assert (bsxfun ("minus", ones (1, 4), ones (4, 1)), zeros (4, 4))
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
664
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
665 %!shared a, b, c, f
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
666 %! a = randn (4, 4);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
667 %! b = a (1, :);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
668 %! c = a (:, 1);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
669 %! f = @(x, y) x == y;
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
670 %!error bsxfun (f)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
671 %!error bsxfun (f, a)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
672 %!error bsxfun (a, b)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
673 %!error bsxfun (a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
674 %!error bsxfun (f, a, b, c)
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
675 %!error bsxfun (f, ones (4, 0), ones (4, 4))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
676 %!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0, "logical"))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
677 %!assert (bsxfun (f, ones (1, 4), ones (4, 1)), ones (4, 4, "logical"))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
678 %!assert (bsxfun (f, a, b), a == repmat (b, 4, 1))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
679 %!assert (bsxfun (f, a, c), a == repmat (c, 1, 4))
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
680
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
681 %!shared a, b, c, d, f
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
682 %! a = randn (4, 4, 4);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
683 %! b = mean (a, 1);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
684 %! c = mean (a, 2);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
685 %! d = mean (a, 3);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
686 %! f = @minus;
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 28631
diff changeset
687 %!error bsxfun (f, ones ([4, 0, 4]), ones ([4, 4, 4]))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
688 %!assert (bsxfun (f, ones ([4, 0, 4]), ones ([4, 1, 4])), zeros ([4, 0, 4]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
689 %!assert (bsxfun (f, ones ([4, 4, 0]), ones ([4, 1, 1])), zeros ([4, 4, 0]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
690 %!assert (bsxfun (f, ones ([1, 4, 4]), ones ([4, 1, 4])), zeros ([4, 4, 4]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
691 %!assert (bsxfun (f, ones ([4, 4, 1]), ones ([4, 1, 4])), zeros ([4, 4, 4]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
692 %!assert (bsxfun (f, ones ([4, 1, 4]), ones ([1, 4, 4])), zeros ([4, 4, 4]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
693 %!assert (bsxfun (f, ones ([4, 1, 4]), ones ([1, 4, 1])), zeros ([4, 4, 4]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
694 %!assert (bsxfun (f, a, b), a - repmat (b, [4, 1, 1]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
695 %!assert (bsxfun (f, a, c), a - repmat (c, [1, 4, 1]))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
696 %!assert (bsxfun (f, a, d), a - repmat (d, [1, 1, 4]))
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30326
diff changeset
697 %!assert (bsxfun ("minus", ones ([4, 0, 4]), ones ([4, 1, 4])),
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30326
diff changeset
698 %! zeros ([4, 0, 4]))
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
699
22737
7abc25e6206a maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 22489
diff changeset
700 ## The test below is a very hard case to treat
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30326
diff changeset
701 %!assert (bsxfun (f, ones ([4, 1, 4, 1]), ones ([1, 4, 1, 4])),
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30326
diff changeset
702 %! zeros ([4, 4, 4, 4]))
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
703
10141
e409546ac0a8 add bsxfun tests
Jaroslav Hajek <highegg@gmail.com>
parents: 10107
diff changeset
704 %!shared a, b, aa, bb
25245
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
705 %! ## FIXME: Set a known "good" random seed. See bug #51779.
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
706 %! old_nstate = randn ("state");
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
707 %! restore_nstate = onCleanup (@() randn ("state", old_nstate));
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
708 %! randn ("state", 42); # initialize generator to make behavior reproducible
10141
e409546ac0a8 add bsxfun tests
Jaroslav Hajek <highegg@gmail.com>
parents: 10107
diff changeset
709 %! a = randn (3, 1, 3);
e409546ac0a8 add bsxfun tests
Jaroslav Hajek <highegg@gmail.com>
parents: 10107
diff changeset
710 %! aa = a(:, ones (1, 3), :, ones (1, 3));
e409546ac0a8 add bsxfun tests
Jaroslav Hajek <highegg@gmail.com>
parents: 10107
diff changeset
711 %! b = randn (1, 3, 3, 3);
e409546ac0a8 add bsxfun tests
Jaroslav Hajek <highegg@gmail.com>
parents: 10107
diff changeset
712 %! bb = b(ones (1, 3), :, :, :);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
713 %!assert (bsxfun (@plus, a, b), aa + bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
714 %!assert (bsxfun (@minus, a, b), aa - bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
715 %!assert (bsxfun (@times, a, b), aa .* bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
716 %!assert (bsxfun (@rdivide, a, b), aa ./ bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
717 %!assert (bsxfun (@ldivide, a, b), aa .\ bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
718 %!assert (bsxfun (@power, a, b), aa .^ bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
719 %!assert (bsxfun (@power, abs (a), b), abs (aa) .^ bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
720 %!assert (bsxfun (@eq, round (a), round (b)), round (aa) == round (bb))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
721 %!assert (bsxfun (@ne, round (a), round (b)), round (aa) != round (bb))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
722 %!assert (bsxfun (@lt, a, b), aa < bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
723 %!assert (bsxfun (@le, a, b), aa <= bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
724 %!assert (bsxfun (@gt, a, b), aa > bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
725 %!assert (bsxfun (@ge, a, b), aa >= bb)
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
726 %!assert (bsxfun (@min, a, b), min (aa, bb))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
727 %!assert (bsxfun (@max, a, b), max (aa, bb))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
728 %!assert (bsxfun (@and, a > 0, b > 0), (aa > 0) & (bb > 0))
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
729 %!assert (bsxfun (@or, a > 0, b > 0), (aa > 0) | (bb > 0))
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
730
22737
7abc25e6206a maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 22489
diff changeset
731 ## Test automatic bsxfun
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
732 %
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
733 %!test
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
734 %! fcns = {@plus, @minus, @times, @rdivide, @ldivide, @power, @max, @min, ...
17245
7babcdb9bc13 Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents: 15195
diff changeset
735 %! @rem, @mod, @atan2, @hypot, @eq, @ne, @lt, @le, @gt, @ge, ...
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
736 %! @and, @or, @xor };
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
737 %!
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
738 %! float_types = {@single, @double};
17245
7babcdb9bc13 Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents: 15195
diff changeset
739 %! int_types = {@int8, @int16, @int32, @int64, ...
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
740 %! @uint8, @uint16, @uint32, @uint64};
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
741 %!
25245
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
742 %! ## FIXME: Set a known "good" random seed. See bug #51779.
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
743 %! old_state = rand ("state");
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
744 %! restore_state = onCleanup (@() rand ("state", old_state));
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
745 %! rand ("state", 42); # initialize generator to make behavior reproducible
9b93b85459da Set a known random seed so bsxfun BIST tests pass (bug #53636).
Rik <rik@octave.org>
parents: 25106
diff changeset
746 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
747 %! x = rand (3) * 10-5;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
748 %! y = rand (3,1) * 10-5;
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
749 %!
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
750 %! for i=1:length (fcns)
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
751 %! for j = 1:length (float_types)
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
752 %! for k = 1:length (int_types)
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
753 %!
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
754 %! fcn = fcns{i};
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
755 %! f_type = float_types{j};
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
756 %! i_type = int_types{k};
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
757 %!
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
758 %! assert (bsxfun (fcn, f_type (x), i_type (y)), ...
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
759 %! fcn (f_type(x), i_type (y)));
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
760 %! assert (bsxfun (fcn, f_type (y), i_type (x)), ...
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
761 %! fcn (f_type(y), i_type (x)));
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
762 %!
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
763 %! assert (bsxfun (fcn, i_type (x), i_type (y)), ...
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
764 %! fcn (i_type (x), i_type (y)));
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
765 %! assert (bsxfun (fcn, i_type (y), i_type (x)), ...
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
766 %! fcn (i_type (y), i_type (x)));
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
767 %!
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
768 %! assert (bsxfun (fcn, f_type (x), f_type (y)), ...
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
769 %! fcn (f_type (x), f_type (y)));
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
770 %! assert (bsxfun (fcn, f_type(y), f_type(x)), ...
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30888
diff changeset
771 %! fcn (f_type (y), f_type (x)));
13013
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
772 %! endfor
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
773 %! endfor
5307bf69cd88 Add tests for automatic bsxfun
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12972
diff changeset
774 %! endfor
21345
12280fef2741 automatic broadcasting: correctly handle dimensions of length zero (bug #47085)
Carnë Draug <carandraug@octave.org>
parents: 21317
diff changeset
775
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
776 ## Automatic broadcasting with zero length dimensions
30326
cd7c824f3f22 eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
777 %!assert <*47085> ([1 2 3] + zeros (0, 3), zeros (0, 3))
cd7c824f3f22 eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
778 %!assert <*47085> (rand (3, 3, 1) + rand (3, 3, 0), zeros (3, 3, 0))
21345
12280fef2741 automatic broadcasting: correctly handle dimensions of length zero (bug #47085)
Carnë Draug <carandraug@octave.org>
parents: 21317
diff changeset
779
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
780 ## In-place broadcasting with zero length dimensions
23573
1b4f4ec53b4a use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents: 23572
diff changeset
781 %!test <*47085>
21345
12280fef2741 automatic broadcasting: correctly handle dimensions of length zero (bug #47085)
Carnë Draug <carandraug@octave.org>
parents: 21317
diff changeset
782 %! a = zeros (0, 3);
30326
cd7c824f3f22 eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
783 %! a += [1 2 3];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21372
diff changeset
784 %! assert (a, zeros (0, 3));
21345
12280fef2741 automatic broadcasting: correctly handle dimensions of length zero (bug #47085)
Carnë Draug <carandraug@octave.org>
parents: 21317
diff changeset
785
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
786 %!test <*53179>
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
787 %! im = ones (4,4,2) + single (i);
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
788 %! mask = true (4,4);
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
789 %! mask(:,1:2) = false;
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
790 %! r = bsxfun (@times, im, mask);
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
791 %! assert (r(:,:,1), repmat (single ([0, 0, 1+i, 1+i]), [4, 1]));
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
792
30913
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
793 ## automatic broadcasting with inplace times operator
31273
5f536c6a9bd6 Back out changeset b86b86ad4b23 (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30914
diff changeset
794 %!test <*38466>
30913
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
795 %! a = ones (2, 2, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
796 %! b = 2 * ones (2, 1);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
797 %! a .*= b;
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
798 %! assert (a, 2 * ones (2, 2, 2));
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
799
31273
5f536c6a9bd6 Back out changeset b86b86ad4b23 (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30914
diff changeset
800 %!test <*38466>
30913
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
801 %! a = ones (2, 2, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
802 %! b = 2 * ones (1, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
803 %! a .*= b;
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
804 %! assert (a, 2 * ones (2, 2, 2));
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
805
31273
5f536c6a9bd6 Back out changeset b86b86ad4b23 (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30914
diff changeset
806 %!test <*38466>
30913
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
807 %! a = ones (2, 2, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
808 %! b = 2 * ones (2, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
809 %! a .*= b;
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
810 %! assert (a, 2 * ones (2, 2, 2));
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
811
31273
5f536c6a9bd6 Back out changeset b86b86ad4b23 (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30914
diff changeset
812 %!test <*38466>
30913
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
813 %! a = ones (2, 2, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
814 %! b = 2 * ones (1, 1, 2);
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
815 %! a .*= b;
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
816 %! assert (a, 2 * ones (2, 2, 2));
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
817
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
818 %!assert (ones (2,2,2) .* ones (1,2), ones (2,2,2));
a4ed2fed7dfa Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30896
diff changeset
819
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
820 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
821
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31273
diff changeset
822 OCTAVE_END_NAMESPACE(octave)