annotate liboctave/array/idx-vector.h @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children 98192ec1621f 02f0649f43d7
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 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1993-2020 The Octave Project Developers
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_idx_vector_h)
383
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 240
diff changeset
27 #define octave_idx_vector_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21229
diff changeset
30
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8934
diff changeset
31 #include <cassert>
19381
af41e41ad28e replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 18084
diff changeset
32 #include <cstring>
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8934
diff changeset
33
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
34 #include <algorithm>
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8934
diff changeset
35 #include <iosfwd>
13735
2cd903770748 Fix broken gcc compilation due to changeset d13b6086aea9.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13729
diff changeset
36 #include <memory>
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3145
diff changeset
37
4653
14ab7b05a572 [project @ 2003-11-24 05:02:46 by jwe]
jwe
parents: 4650
diff changeset
38 #include "dim-vector.h"
21785
c9f8a7f7915e use forward declarations instead of including oct-inttypes.h where possible
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
39 #include "oct-inttypes-fwd.h"
12125
a21a3875ca83 implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents: 11586
diff changeset
40 #include "oct-refcount.h"
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
41
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
42 template <typename T> class Array;
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
43 template <typename T> class Sparse;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
44 class Range;
4504
f6a61399bc5c [project @ 2003-09-09 17:48:00 by jwe]
jwe
parents: 4461
diff changeset
45
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
46 // Design rationale:
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
47 // idx_vector is a reference-counting, polymorphic pointer, that can contain
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
48 // 4 types of index objects: a magic colon, a range, a scalar, or an index vector.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
49 // Polymorphic methods for single element access are provided, as well as
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
50 // templates implementing "early dispatch", i.e., hoisting the checks for index
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
51 // type out of loops.
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 1
diff changeset
52
453
393e95f46b51 [project @ 1994-06-06 00:05:20 by jwe]
jwe
parents: 434
diff changeset
53 class
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5781
diff changeset
54 OCTAVE_API
453
393e95f46b51 [project @ 1994-06-06 00:05:20 by jwe]
jwe
parents: 434
diff changeset
55 idx_vector
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 {
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
57 public:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
58
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
59 enum idx_class_type
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
60 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
61 class_invalid = -1,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
62 class_colon = 0,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
63 class_range,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
64 class_scalar,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
65 class_vector,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
66 class_mask
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
67 };
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
68
21326
9a49c83cb360 Fix declaration of template friend class std::unique_ptr
Mike Miller <mtmiller@octave.org>
parents: 21307
diff changeset
69 template <typename T, typename D> friend class std::unique_ptr;
13729
d13b6086aea9 Make std::auto_ptr friend of idx_vector to allow access to private class idx_vector_rep.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12125
diff changeset
70
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
71 private:
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
72
8319
c374691576f6 Fix for MSVC compilation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8298
diff changeset
73 class OCTAVE_API idx_base_rep
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
74 {
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
75 public:
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
76
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
77 idx_base_rep (void) : count (1), err (false) { }
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
78
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
79 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
80
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
81 idx_base_rep (const idx_base_rep&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
82
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
83 idx_base_rep& operator = (const idx_base_rep&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
84
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
85 virtual ~idx_base_rep (void) = default;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
86
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
87 // Non-range-checking element query.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
88 virtual octave_idx_type xelem (octave_idx_type i) const = 0;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
89
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
90 // Range-checking element query.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
91 virtual octave_idx_type checkelem (octave_idx_type i) const = 0;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
92
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
93 // Length of the index vector.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
94 virtual octave_idx_type length (octave_idx_type n) const = 0;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
95
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
96 // The maximum index + 1. The actual dimension is passed in.
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
97 virtual octave_idx_type extent (octave_idx_type n) const = 0;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
98
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
99 // Index class.
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
100 virtual idx_class_type idx_class (void) const { return class_invalid; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
101
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
102 // Sorts, maybe uniqifies, and returns a clone object pointer.
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
103 virtual idx_base_rep * sort_uniq_clone (bool uniq = false) = 0;
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
104 // Sorts, and returns a sorting permutation (aka Array::sort).
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
105 virtual idx_base_rep * sort_idx (Array<octave_idx_type>&) = 0;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
106
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
107 // Checks whether the index is colon or a range equivalent to colon.
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
108 virtual bool is_colon_equiv (octave_idx_type) const { return false; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
109
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
110 // The original dimensions of object (used when subscribing by matrices).
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
111 virtual dim_vector orig_dimensions (void) const { return dim_vector (); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
112
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
113 // i/o
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
114 virtual std::ostream& print (std::ostream& os) const = 0;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
115
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
116 virtual Array<octave_idx_type> as_array (void);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
117
27446
c23aee2104de consistently use octave_idx_type for reference counts
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
118 octave::refcount<octave_idx_type> count;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
119
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
120 bool err;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
121 };
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
122
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
123 // The magic colon index.
8319
c374691576f6 Fix for MSVC compilation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8298
diff changeset
124 class OCTAVE_API idx_colon_rep : public idx_base_rep
1879
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1560
diff changeset
125 {
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1560
diff changeset
126 public:
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
127
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
128 idx_colon_rep (void) = default;
1879
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1560
diff changeset
129
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
130 idx_colon_rep (char c);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
131
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
132 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
133
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
134 idx_colon_rep (const idx_colon_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
135
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
136 idx_colon_rep& operator = (const idx_colon_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
137
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
138 octave_idx_type xelem (octave_idx_type i) const { return i; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
139
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
140 octave_idx_type checkelem (octave_idx_type i) const;
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
141
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
142 octave_idx_type length (octave_idx_type n) const { return n; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
143
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
144 octave_idx_type extent (octave_idx_type n) const { return n; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
145
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
146 idx_class_type idx_class (void) const { return class_colon; }
1879
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1560
diff changeset
147
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
148 idx_base_rep * sort_uniq_clone (bool = false)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 { count++; return this; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
150
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
151 OCTAVE_NORETURN idx_base_rep * sort_idx (Array<octave_idx_type>&);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
152
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
153 bool is_colon_equiv (octave_idx_type) const { return true; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
154
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
155 std::ostream& print (std::ostream& os) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
156 };
2386
4fc9fd1424a9 [project @ 1996-10-12 18:31:34 by jwe]
jwe
parents: 2356
diff changeset
157
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
158 // To distinguish the "direct" constructors that blindly trust the data.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
159 enum direct { DIRECT };
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents: 2802
diff changeset
160
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
161 // The integer range index.
8319
c374691576f6 Fix for MSVC compilation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8298
diff changeset
162 class OCTAVE_API idx_range_rep : public idx_base_rep
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
163 {
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
164 public:
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
165
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
166 idx_range_rep (void) = delete;
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
167
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
168 idx_range_rep (octave_idx_type _start, octave_idx_type _len,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
169 octave_idx_type _step, direct)
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
170 : idx_base_rep (), start(_start), len(_len), step(_step) { }
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4653
diff changeset
171
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
172 // Zero-based constructor.
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
173 idx_range_rep (octave_idx_type _start, octave_idx_type _limit,
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
174 octave_idx_type _step);
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
175
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
176 idx_range_rep (const Range&);
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
177
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
178 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
179
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
180 idx_range_rep (const idx_range_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
181
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
182 idx_range_rep& operator = (const idx_range_rep& idx) = delete;
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
183
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
184 octave_idx_type xelem (octave_idx_type i) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
185 { return start + i * step; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
186
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
187 octave_idx_type checkelem (octave_idx_type i) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
188
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
189 octave_idx_type length (octave_idx_type) const { return len; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
190
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
191 octave_idx_type extent (octave_idx_type n) const
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
192 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
193 return len ? std::max (n, start + 1 + (step < 0 ? 0 : step * (len - 1)))
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
194 : n;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
195 }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
196
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
197 idx_class_type idx_class (void) const { return class_range; }
1879
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1560
diff changeset
198
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
199 idx_base_rep * sort_uniq_clone (bool uniq = false);
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
200
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
201 idx_base_rep * sort_idx (Array<octave_idx_type>&);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
202
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
203 bool is_colon_equiv (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
204 { return start == 0 && step == 1 && len == n; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
205
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
206 dim_vector orig_dimensions (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
207 { return dim_vector (1, len); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
208
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
209 octave_idx_type get_start (void) const { return start; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
210
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
211 octave_idx_type get_step (void) const { return step; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
212
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3503
diff changeset
213 std::ostream& print (std::ostream& os) const;
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
214
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
215 Range unconvert (void) const;
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
216
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
217 Array<octave_idx_type> as_array (void);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
218
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
219 private:
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
220
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
221 octave_idx_type start, len, step;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
222 };
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
223
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
224 // The integer scalar index.
8319
c374691576f6 Fix for MSVC compilation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8298
diff changeset
225 class OCTAVE_API idx_scalar_rep : public idx_base_rep
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
226 {
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
227 public:
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
228
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
229 idx_scalar_rep (void) = delete;
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
230
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
231 idx_scalar_rep (octave_idx_type i, direct)
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
232 : idx_base_rep (), data (i) { }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
233
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
234 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
235
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
236 idx_scalar_rep (const idx_scalar_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
237
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
238 idx_scalar_rep& operator = (const idx_scalar_rep& idx) = delete;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
239
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
240 // Zero-based constructor.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
241 idx_scalar_rep (octave_idx_type i);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
242
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
243 template <typename T>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
244 idx_scalar_rep (T x);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
245
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
246 octave_idx_type xelem (octave_idx_type) const { return data; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
247
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
248 octave_idx_type checkelem (octave_idx_type i) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
249
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
250 octave_idx_type length (octave_idx_type) const { return 1; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
251
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
252 octave_idx_type extent (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
253 { return std::max (n, data + 1); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
254
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
255 idx_class_type idx_class (void) const { return class_scalar; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
256
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
257 idx_base_rep * sort_uniq_clone (bool = false)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
258 { count++; return this; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
259
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
260 idx_base_rep * sort_idx (Array<octave_idx_type>&);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
261
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
262 bool is_colon_equiv (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
263 { return n == 1 && data == 0; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
264
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
265 dim_vector orig_dimensions (void) const { return dim_vector (1, 1); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
266
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
267 octave_idx_type get_data (void) const { return data; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
268
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
269 std::ostream& print (std::ostream& os) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
270
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
271 double unconvert (void) const;
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
272
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
273 Array<octave_idx_type> as_array (void);
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
274
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
275 private:
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
276
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
277 octave_idx_type data;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
278 };
4504
f6a61399bc5c [project @ 2003-09-09 17:48:00 by jwe]
jwe
parents: 4461
diff changeset
279
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
280 // The integer vector index.
8319
c374691576f6 Fix for MSVC compilation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 8298
diff changeset
281 class OCTAVE_API idx_vector_rep : public idx_base_rep
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
282 {
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
283 public:
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
284
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
285 idx_vector_rep (void)
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23795
diff changeset
286 : data (nullptr), len (0), ext (0), aowner (nullptr), orig_dims ()
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
287 { }
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
288
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
289 // Direct constructor.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
290 idx_vector_rep (octave_idx_type *_data, octave_idx_type _len,
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
291 octave_idx_type _ext, const dim_vector& od, direct)
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
292 : idx_base_rep (), data (_data), len (_len), ext (_ext),
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23615
diff changeset
293 aowner (nullptr), orig_dims (od)
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
294 { }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
295
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
296 // Zero-based constructor.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
297 idx_vector_rep (const Array<octave_idx_type>& inda);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
298
10285
22a7913bbeb5 optimize return values of find and sort
Jaroslav Hajek <highegg@gmail.com>
parents: 10273
diff changeset
299 idx_vector_rep (const Array<octave_idx_type>& inda,
22a7913bbeb5 optimize return values of find and sort
Jaroslav Hajek <highegg@gmail.com>
parents: 10273
diff changeset
300 octave_idx_type _ext, direct);
22a7913bbeb5 optimize return values of find and sort
Jaroslav Hajek <highegg@gmail.com>
parents: 10273
diff changeset
301
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
302 template <typename T>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
303 idx_vector_rep (const Array<T>&);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
304
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
305 idx_vector_rep (bool);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
306
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
307 idx_vector_rep (const Array<bool>&, octave_idx_type = -1);
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
308
8384
a99b9113c58c optimize sparse bool indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
309 idx_vector_rep (const Sparse<bool>&);
a99b9113c58c optimize sparse bool indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
310
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
311 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
312
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
313 idx_vector_rep (const idx_vector_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
314
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
315 idx_vector_rep& operator = (const idx_vector_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
316
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
317 ~idx_vector_rep (void);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
318
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
319 octave_idx_type xelem (octave_idx_type i) const { return data[i]; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
320
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
321 octave_idx_type checkelem (octave_idx_type i) const;
4653
14ab7b05a572 [project @ 2003-11-24 05:02:46 by jwe]
jwe
parents: 4650
diff changeset
322
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
323 octave_idx_type length (octave_idx_type) const { return len; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
324
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
325 octave_idx_type extent (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
326 { return std::max (n, ext); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
327
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
328 idx_class_type idx_class (void) const { return class_vector; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
329
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
330 idx_base_rep * sort_uniq_clone (bool uniq = false);
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
331
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
332 idx_base_rep * sort_idx (Array<octave_idx_type>&);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
333
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
334 dim_vector orig_dimensions (void) const { return orig_dims; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
335
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
336 const octave_idx_type * get_data (void) const { return data; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
337
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
338 std::ostream& print (std::ostream& os) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
339
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
340 Array<double> unconvert (void) const;
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
341
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
342 Array<octave_idx_type> as_array (void);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
343
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
344 private:
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
345
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
346 const octave_idx_type *data;
11503
b3f511c48b14 idx-vector.h, idx-vector.cc: data member initialization and constructor fixes
John W. Eaton <jwe@octave.org>
parents: 10516
diff changeset
347 octave_idx_type len;
b3f511c48b14 idx-vector.h, idx-vector.cc: data member initialization and constructor fixes
John W. Eaton <jwe@octave.org>
parents: 10516
diff changeset
348 octave_idx_type ext;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
349
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
350 // This is a trick to allow user-given zero-based arrays to be used
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
351 // as indices without copying. If the following pointer is nonzero,
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
352 // we do not own the data, but rather have an Array<octave_idx_type>
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
353 // object that provides us the data. Note that we need a pointer
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
354 // because we deferred the Array<T> declaration and we do not want
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
355 // it yet to be defined.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
356
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
357 Array<octave_idx_type> *aowner;
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
358
4653
14ab7b05a572 [project @ 2003-11-24 05:02:46 by jwe]
jwe
parents: 4650
diff changeset
359 dim_vector orig_dims;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
360 };
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
361
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
362 // The logical mask index.
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
363 class OCTAVE_API idx_mask_rep : public idx_base_rep
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
364 {
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
365 public:
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
366
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
367 idx_mask_rep (void) = delete;
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
368
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
369 // Direct constructor.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
370 idx_mask_rep (bool *_data, octave_idx_type _len,
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
371 octave_idx_type _ext, const dim_vector& od, direct)
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
372 : idx_base_rep (), data (_data), len (_len), ext (_ext),
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23615
diff changeset
373 lsti (-1), lste (-1), aowner (nullptr), orig_dims (od)
23401
e0c20a22da7e eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
374 { }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
375
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
376 idx_mask_rep (bool);
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
377
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
378 idx_mask_rep (const Array<bool>&, octave_idx_type = -1);
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
379
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
380 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
381
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
382 idx_mask_rep (const idx_mask_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
383
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
384 idx_mask_rep& operator = (const idx_mask_rep& idx) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
385
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
386 ~idx_mask_rep (void);
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
387
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
388 octave_idx_type xelem (octave_idx_type i) const;
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
389
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
390 octave_idx_type checkelem (octave_idx_type i) const;
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
391
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
392 octave_idx_type length (octave_idx_type) const { return len; }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
393
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
394 octave_idx_type extent (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
395 { return std::max (n, ext); }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
396
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
397 idx_class_type idx_class (void) const { return class_mask; }
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
398
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
399 idx_base_rep * sort_uniq_clone (bool = false)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
400 { count++; return this; }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
401
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
402 idx_base_rep * sort_idx (Array<octave_idx_type>&);
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
403
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
404 dim_vector orig_dimensions (void) const { return orig_dims; }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
405
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
406 bool is_colon_equiv (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
407 { return len == n && ext == n; }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
408
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
409 const bool * get_data (void) const { return data; }
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
410
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
411 std::ostream& print (std::ostream& os) const;
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
412
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
413 Array<bool> unconvert (void) const;
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
414
10425
0677c5d80b77 rewrite 1D sparse indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 10339
diff changeset
415 Array<octave_idx_type> as_array (void);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
416
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
417 private:
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
418
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
419 const bool *data;
11503
b3f511c48b14 idx-vector.h, idx-vector.cc: data member initialization and constructor fixes
John W. Eaton <jwe@octave.org>
parents: 10516
diff changeset
420 octave_idx_type len;
b3f511c48b14 idx-vector.h, idx-vector.cc: data member initialization and constructor fixes
John W. Eaton <jwe@octave.org>
parents: 10516
diff changeset
421 octave_idx_type ext;
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
422
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
423 // FIXME: I'm not sure if this is a good design. Maybe it would be
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
424 // better to employ some sort of generalized iteration scheme.
11503
b3f511c48b14 idx-vector.h, idx-vector.cc: data member initialization and constructor fixes
John W. Eaton <jwe@octave.org>
parents: 10516
diff changeset
425 mutable octave_idx_type lsti;
b3f511c48b14 idx-vector.h, idx-vector.cc: data member initialization and constructor fixes
John W. Eaton <jwe@octave.org>
parents: 10516
diff changeset
426 mutable octave_idx_type lste;
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
427
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
428 // This is a trick to allow user-given mask arrays to be used as
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
429 // indices without copying. If the following pointer is nonzero, we
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
430 // do not own the data, but rather have an Array<bool> object that
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
431 // provides us the data. Note that we need a pointer because we
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
432 // deferred the Array<T> declaration and we do not want it yet to be
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
433 // defined.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
434
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
435 Array<bool> *aowner;
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
436
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
437 dim_vector orig_dims;
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
438 };
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
439
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
440 idx_vector (idx_base_rep *r) : rep (r) { }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
441
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
442 // The shared empty vector representation (for fast default
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
443 // constructor).
21573
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
444 static idx_vector_rep *nil_rep (void);
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4653
diff changeset
445
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
446 // The shared empty vector representation with the error flag set.
21573
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
447 static idx_vector_rep *err_rep (void);
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4653
diff changeset
448
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
449 // If there was an error in constructing the rep, replace it with
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
450 // empty vector for safety.
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
451 void chkerr (void)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
452 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
453 if (rep->err)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
454 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
455 if (--rep->count == 0)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
456 delete rep;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
457 rep = err_rep ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
458 rep->count++;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
459 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
460 }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
461
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
462 public:
1551
8f63ee44726c [project @ 1995-10-08 23:19:55 by jwe]
jwe
parents: 1315
diff changeset
463
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
464 // Fast empty constructor.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
465 idx_vector (void) : rep (nil_rep ()) { rep->count++; }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
466
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
467 // Zero-based constructors (for use from C++).
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
468 idx_vector (octave_idx_type i) : rep (new idx_scalar_rep (i))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
469 { chkerr (); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
470
23015
198fbbf6934a new idx_vector (F77_INT) constructor
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
471 #if OCTAVE_SIZEOF_F77_INT_TYPE != OCTAVE_SIZEOF_IDX_TYPE
198fbbf6934a new idx_vector (F77_INT) constructor
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
472 idx_vector (octave_f77_int_type i)
198fbbf6934a new idx_vector (F77_INT) constructor
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
473 : rep (new idx_scalar_rep (static_cast<octave_idx_type> (i)))
198fbbf6934a new idx_vector (F77_INT) constructor
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
474 { chkerr (); }
198fbbf6934a new idx_vector (F77_INT) constructor
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
475 #endif
198fbbf6934a new idx_vector (F77_INT) constructor
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
476
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
477 idx_vector (octave_idx_type start, octave_idx_type limit,
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
478 octave_idx_type step = 1)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
479 : rep (new idx_range_rep (start, limit, step))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
480 { chkerr (); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
481
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
482 static idx_vector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
483 make_range (octave_idx_type start, octave_idx_type step,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
484 octave_idx_type len)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
485 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
486 return idx_vector (new idx_range_rep (start, len, step, DIRECT));
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
487 }
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8972
diff changeset
488
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
489 idx_vector (const Array<octave_idx_type>& inda)
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
490 : rep (new idx_vector_rep (inda))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
491 { chkerr (); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
492
10285
22a7913bbeb5 optimize return values of find and sort
Jaroslav Hajek <highegg@gmail.com>
parents: 10273
diff changeset
493 // Directly pass extent, no checking.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
494 idx_vector (const Array<octave_idx_type>& inda, octave_idx_type ext)
10285
22a7913bbeb5 optimize return values of find and sort
Jaroslav Hajek <highegg@gmail.com>
parents: 10273
diff changeset
495 : rep (new idx_vector_rep (inda, ext, DIRECT))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
496 { }
10285
22a7913bbeb5 optimize return values of find and sort
Jaroslav Hajek <highegg@gmail.com>
parents: 10273
diff changeset
497
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
498 // Colon is best constructed by simply copying (or referencing) this member.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
499 static const idx_vector colon;
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4653
diff changeset
500
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
501 // or passing ':' here
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
502 idx_vector (char c) : rep (new idx_colon_rep (c)) { chkerr (); }
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
503
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
504 // Conversion constructors (used by interpreter).
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
505
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
506 template <typename T>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
507 idx_vector (octave_int<T> x) : rep (new idx_scalar_rep (x)) { chkerr (); }
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
508
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
509 idx_vector (double x) : rep (new idx_scalar_rep (x)) { chkerr (); }
2386
4fc9fd1424a9 [project @ 1996-10-12 18:31:34 by jwe]
jwe
parents: 2356
diff changeset
510
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
511 idx_vector (float x) : rep (new idx_scalar_rep (x)) { chkerr (); }
3928
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3504
diff changeset
512
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
513 // A scalar bool does not necessarily map to scalar index.
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
514 idx_vector (bool x) : rep (new idx_mask_rep (x)) { chkerr (); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
515
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
516 template <typename T>
23534
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23496
diff changeset
517 idx_vector (const Array<octave_int<T>>& nda) : rep (new idx_vector_rep (nda))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
518 { chkerr (); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
519
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
520 idx_vector (const Array<double>& nda) : rep (new idx_vector_rep (nda))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
521 { chkerr (); }
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents: 2802
diff changeset
522
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
523 idx_vector (const Array<float>& nda) : rep (new idx_vector_rep (nda))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
524 { chkerr (); }
4938
703d97b89507 [project @ 2004-08-09 20:21:59 by jwe]
jwe
parents: 4653
diff changeset
525
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
526 idx_vector (const Array<bool>& nda);
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
527
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
528 idx_vector (const Range& r)
10489
d47802f0e557 Back out changeset 4e64fbbd5c58
Jaroslav Hajek <highegg@gmail.com>
parents: 10487
diff changeset
529 : rep (new idx_range_rep (r))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
530 { chkerr (); }
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents: 2802
diff changeset
531
8384
a99b9113c58c optimize sparse bool indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
532 idx_vector (const Sparse<bool>& nda) : rep (new idx_vector_rep (nda))
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
533 { chkerr (); }
8384
a99b9113c58c optimize sparse bool indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8367
diff changeset
534
4979
ce4e3d39d05b [project @ 2004-09-08 23:25:05 by jwe]
jwe
parents: 4938
diff changeset
535 idx_vector (const idx_vector& a) : rep (a.rep) { rep->count++; }
1551
8f63ee44726c [project @ 1995-10-08 23:19:55 by jwe]
jwe
parents: 1315
diff changeset
536
2802
bca5fbab2e52 [project @ 1997-03-09 11:02:27 by jwe]
jwe
parents: 2800
diff changeset
537 ~idx_vector (void)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
538 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
539 if (--rep->count == 0)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
540 delete rep;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
541 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
542
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
543 idx_vector& operator = (const idx_vector& a)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
544 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
545 if (this != &a)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
546 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
547 if (--rep->count == 0)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
548 delete rep;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
549
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
550 rep = a.rep;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
551 rep->count++;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
552 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
553 return *this;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
554 }
1551
8f63ee44726c [project @ 1995-10-08 23:19:55 by jwe]
jwe
parents: 1315
diff changeset
555
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
556 idx_class_type idx_class (void) const { return rep->idx_class (); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
557
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
558 octave_idx_type length (octave_idx_type n = 0) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
559 { return rep->length (n); }
191
b6b4d8c513fe [project @ 1993-10-29 23:41:39 by jwe]
jwe
parents: 164
diff changeset
560
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
561 octave_idx_type extent (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
562 { return rep->extent (n); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
563
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
564 octave_idx_type xelem (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
565 { return rep->xelem (n); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
566
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
567 octave_idx_type checkelem (octave_idx_type n) const
23487
af2f1f3dbe06 eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
568 { return rep->xelem (n); }
1551
8f63ee44726c [project @ 1995-10-08 23:19:55 by jwe]
jwe
parents: 1315
diff changeset
569
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
570 octave_idx_type operator () (octave_idx_type n) const
23487
af2f1f3dbe06 eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
571 { return rep->xelem (n); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
572
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
573 operator bool (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
574 { return ! rep->err; }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
575
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
576 bool is_colon (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
577 { return rep->idx_class () == class_colon; }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
578
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
579 bool is_scalar (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
580 { return rep->idx_class () == class_scalar; }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
581
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8972
diff changeset
582 bool is_range (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
583 { return rep->idx_class () == class_range; }
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8972
diff changeset
584
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
585 bool is_colon_equiv (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
586 { return rep->is_colon_equiv (n); }
3079
eb827eb9b8ff [project @ 1997-08-03 20:44:07 by jwe]
jwe
parents: 2847
diff changeset
587
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
588 idx_vector sorted (bool uniq = false) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
589 { return idx_vector (rep->sort_uniq_clone (uniq)); }
208
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
590
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
591 idx_vector sorted (Array<octave_idx_type>& sidx) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
592 { return idx_vector (rep->sort_idx (sidx)); }
10273
3a8c13b71612 implement special-case optimization for sort of index vectors
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
593
4653
14ab7b05a572 [project @ 2003-11-24 05:02:46 by jwe]
jwe
parents: 4650
diff changeset
594 dim_vector orig_dimensions (void) const { return rep->orig_dimensions (); }
4504
f6a61399bc5c [project @ 2003-09-09 17:48:00 by jwe]
jwe
parents: 4461
diff changeset
595
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
596 octave_idx_type orig_rows (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
597 { return orig_dimensions () (0); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
598
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
599 octave_idx_type orig_columns (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
600 { return orig_dimensions () (1); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
601
2663
00b2eff19bf5 [project @ 1997-02-08 21:58:49 by jwe]
jwe
parents: 2386
diff changeset
602 int orig_empty (void) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
603 { return (! is_colon () && orig_dimensions ().any_zero ()); }
2663
00b2eff19bf5 [project @ 1997-02-08 21:58:49 by jwe]
jwe
parents: 2386
diff changeset
604
4653
14ab7b05a572 [project @ 2003-11-24 05:02:46 by jwe]
jwe
parents: 4650
diff changeset
605 // i/o
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
606
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3503
diff changeset
607 std::ostream& print (std::ostream& os) const { return rep->print (os); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
608
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3503
diff changeset
609 friend std::ostream& operator << (std::ostream& os, const idx_vector& a)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
610 { return a.print (os); }
1560
27a03373de41 [project @ 1995-10-12 07:22:26 by jwe]
jwe
parents: 1553
diff changeset
611
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
612 // Slice with specializations. No checking of bounds!
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
613 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
614 // This is equivalent to the following loop (but much faster):
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
615 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
616 // for (octave_idx_type i = 0; i < idx->length (n); i++)
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
617 // dest[i] = src[idx(i)];
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
618 // return i;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
619 //
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
620 template <typename T>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
621 octave_idx_type
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
622 index (const T *src, octave_idx_type n, T *dest) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
623 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
624 octave_idx_type len = rep->length (n);
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
625
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
626 switch (rep->idx_class ())
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
627 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
628 case class_colon:
23420
1fee389bd04b Use std::copy_n rather than std::copy for clarity in liboctave/array.
Rik <rik@octave.org>
parents: 23401
diff changeset
629 std::copy_n (src, len, dest);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
630 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
631
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
632 case class_range:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
633 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
634 idx_range_rep *r = dynamic_cast<idx_range_rep *> (rep);
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
635 octave_idx_type start = r->get_start ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
636 octave_idx_type step = r->get_step ();
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
637 const T *ssrc = src + start;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
638 if (step == 1)
23420
1fee389bd04b Use std::copy_n rather than std::copy for clarity in liboctave/array.
Rik <rik@octave.org>
parents: 23401
diff changeset
639 std::copy_n (ssrc, len, dest);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
640 else if (step == -1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
641 std::reverse_copy (ssrc - len + 1, ssrc + 1, dest);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
642 else if (step == 0)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
643 std::fill_n (dest, len, *ssrc);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
644 else
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
645 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
646 for (octave_idx_type i = 0, j = 0; i < len; i++, j += step)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
647 dest[i] = ssrc[j];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
648 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
649 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
650 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
651
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
652 case class_scalar:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
653 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
654 idx_scalar_rep *r = dynamic_cast<idx_scalar_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
655 dest[0] = src[r->get_data ()];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
656 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
657 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
658
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
659 case class_vector:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
660 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
661 idx_vector_rep *r = dynamic_cast<idx_vector_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
662 const octave_idx_type *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
663 for (octave_idx_type i = 0; i < len; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
664 dest[i] = src[data[i]];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
665 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
666 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
667
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
668 case class_mask:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
669 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
670 idx_mask_rep *r = dynamic_cast<idx_mask_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
671 const bool *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
672 octave_idx_type ext = r->extent (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
673 for (octave_idx_type i = 0; i < ext; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
674 if (data[i]) *dest++ = src[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
675 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
676 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
677
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
678 default:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
679 assert (false);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
680 break;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
681 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
682
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
683 return len;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
684 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
685
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
686 // Slice assignment with specializations. No checking of bounds!
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
687 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
688 // This is equivalent to the following loop (but much faster):
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
689 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
690 // for (octave_idx_type i = 0; i < idx->length (n); i++)
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
691 // dest[idx(i)] = src[i];
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
692 // return i;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
693 //
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
694 template <typename T>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
695 octave_idx_type
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
696 assign (const T *src, octave_idx_type n, T *dest) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
697 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
698 octave_idx_type len = rep->length (n);
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
699
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
700 switch (rep->idx_class ())
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
701 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
702 case class_colon:
23420
1fee389bd04b Use std::copy_n rather than std::copy for clarity in liboctave/array.
Rik <rik@octave.org>
parents: 23401
diff changeset
703 std::copy_n (src, len, dest);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
704 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
705
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
706 case class_range:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
707 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
708 idx_range_rep *r = dynamic_cast<idx_range_rep *> (rep);
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
709 octave_idx_type start = r->get_start ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
710 octave_idx_type step = r->get_step ();
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
711 T *sdest = dest + start;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
712 if (step == 1)
23420
1fee389bd04b Use std::copy_n rather than std::copy for clarity in liboctave/array.
Rik <rik@octave.org>
parents: 23401
diff changeset
713 std::copy_n (src, len, sdest);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
714 else if (step == -1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
715 std::reverse_copy (src, src + len, sdest - len + 1);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
716 else
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
717 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
718 for (octave_idx_type i = 0, j = 0; i < len; i++, j += step)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
719 sdest[j] = src[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
720 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
721 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
722 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
723
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
724 case class_scalar:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
725 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
726 idx_scalar_rep *r = dynamic_cast<idx_scalar_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
727 dest[r->get_data ()] = src[0];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
728 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
729 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
730
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
731 case class_vector:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
732 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
733 idx_vector_rep *r = dynamic_cast<idx_vector_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
734 const octave_idx_type *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
735 for (octave_idx_type i = 0; i < len; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
736 dest[data[i]] = src[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
737 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
738 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
739
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
740 case class_mask:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
741 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
742 idx_mask_rep *r = dynamic_cast<idx_mask_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
743 const bool *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
744 octave_idx_type ext = r->extent (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
745 for (octave_idx_type i = 0; i < ext; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
746 if (data[i]) dest[i] = *src++;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
747 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
748 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
749
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
750 default:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
751 assert (false);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
752 break;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
753 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
754
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
755 return len;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
756 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
757
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
758 // Slice fill with specializations. No checking of bounds!
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
759 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
760 // This is equivalent to the following loop (but much faster):
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
761 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
762 // for (octave_idx_type i = 0; i < idx->length (n); i++)
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
763 // dest[idx(i)] = val;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
764 // return i;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
765 //
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
766 template <typename T>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
767 octave_idx_type
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
768 fill (const T& val, octave_idx_type n, T *dest) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
769 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
770 octave_idx_type len = rep->length (n);
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
771
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
772 switch (rep->idx_class ())
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
773 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
774 case class_colon:
23420
1fee389bd04b Use std::copy_n rather than std::copy for clarity in liboctave/array.
Rik <rik@octave.org>
parents: 23401
diff changeset
775 std::fill_n (dest, len, val);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
776 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
777
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
778 case class_range:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
779 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
780 idx_range_rep *r = dynamic_cast<idx_range_rep *> (rep);
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
781 octave_idx_type start = r->get_start ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
782 octave_idx_type step = r->get_step ();
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
783 T *sdest = dest + start;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
784 if (step == 1)
23420
1fee389bd04b Use std::copy_n rather than std::copy for clarity in liboctave/array.
Rik <rik@octave.org>
parents: 23401
diff changeset
785 std::fill_n (sdest, len, val);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
786 else if (step == -1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
787 std::fill (sdest - len + 1, sdest + 1, val);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
788 else
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
789 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
790 for (octave_idx_type i = 0, j = 0; i < len; i++, j += step)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
791 sdest[j] = val;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
792 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
793 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
794 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
795
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
796 case class_scalar:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
797 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
798 idx_scalar_rep *r = dynamic_cast<idx_scalar_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
799 dest[r->get_data ()] = val;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
800 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
801 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
802
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
803 case class_vector:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
804 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
805 idx_vector_rep *r = dynamic_cast<idx_vector_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
806 const octave_idx_type *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
807 for (octave_idx_type i = 0; i < len; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
808 dest[data[i]] = val;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
809 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
810 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
811
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
812 case class_mask:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
813 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
814 idx_mask_rep *r = dynamic_cast<idx_mask_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
815 const bool *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
816 octave_idx_type ext = r->extent (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
817 for (octave_idx_type i = 0; i < ext; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
818 if (data[i]) dest[i] = val;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
819 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
820 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
821
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
822 default:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
823 assert (false);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
824 break;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
825 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
826
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
827 return len;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
828 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
829
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
830 // Generic non-breakable indexed loop. The loop body should be
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
831 // encapsulated in a single functor body. This is equivalent to the
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
832 // following loop (but faster, at least for simple inlined bodies):
8934
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
833 //
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
834 // for (octave_idx_type i = 0; i < idx->length (n); i++) body (idx(i));
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
835
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
836 template <typename Functor>
8934
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
837 void
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
838 loop (octave_idx_type n, Functor body) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
839 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
840 octave_idx_type len = rep->length (n);
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
841
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
842 switch (rep->idx_class ())
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
843 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
844 case class_colon:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
845 for (octave_idx_type i = 0; i < len; i++) body (i);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
846 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
847
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
848 case class_range:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
849 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
850 idx_range_rep *r = dynamic_cast<idx_range_rep *> (rep);
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
851 octave_idx_type start = r->get_start ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
852 octave_idx_type step = r->get_step ();
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
853 octave_idx_type i, j;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
854 if (step == 1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
855 for (i = start, j = start + len; i < j; i++) body (i);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
856 else if (step == -1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
857 for (i = start, j = start - len; i > j; i--) body (i);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
858 else
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
859 for (i = 0, j = start; i < len; i++, j += step) body (j);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
860 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
861 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
862
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
863 case class_scalar:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
864 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
865 idx_scalar_rep *r = dynamic_cast<idx_scalar_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
866 body (r->get_data ());
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
867 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
868 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
869
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
870 case class_vector:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
871 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
872 idx_vector_rep *r = dynamic_cast<idx_vector_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
873 const octave_idx_type *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
874 for (octave_idx_type i = 0; i < len; i++) body (data[i]);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
875 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
876 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
877
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
878 case class_mask:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
879 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
880 idx_mask_rep *r = dynamic_cast<idx_mask_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
881 const bool *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
882 octave_idx_type ext = r->extent (0);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
883 for (octave_idx_type i = 0; i < ext; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
884 if (data[i]) body (i);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
885 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
886 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
887
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
888 default:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
889 assert (false);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
890 break;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
891 }
8934
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
892
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
893 }
8934
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
894
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
895 // Generic breakable indexed loop. The loop body should be
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
896 // encapsulated in a single functor body. This is equivalent to the
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
897 // following loop (but faster, at least for simple inlined bodies):
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
898 //
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
899 // for (octave_idx_type i = 0; i < idx->length (n); i++)
8934
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
900 // if (body (idx(i))) break;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
901 // return i;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
902 //
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
903
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21137
diff changeset
904 template <typename Functor>
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
905 octave_idx_type
8934
c2099a4d12ea partially optimize accumarray
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
906 bloop (octave_idx_type n, Functor body) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
907 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
908 octave_idx_type len = rep->length (n), ret;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
909
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
910 switch (rep->idx_class ())
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
911 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
912 case class_colon:
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
913 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
914 octave_idx_type i;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
915 for (i = 0; i < len && body (i); i++) ;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
916 ret = i;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
917 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
918 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
919
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
920 case class_range:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
921 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
922 idx_range_rep *r = dynamic_cast<idx_range_rep *> (rep);
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
923 octave_idx_type start = r->get_start ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
924 octave_idx_type step = r->get_step ();
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
925 octave_idx_type i, j;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
926 if (step == 1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
927 for (i = start, j = start + len; i < j && body (i); i++) ;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
928 else if (step == -1)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
929 for (i = start, j = start - len; i > j && body (i); i--) ;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
930 else
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
931 for (i = 0, j = start; i < len && body (j); i++, j += step) ;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
932 ret = i;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
933 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
934 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
935
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
936 case class_scalar:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
937 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
938 idx_scalar_rep *r = dynamic_cast<idx_scalar_rep *> (rep);
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23446
diff changeset
939 ret = (body (r->get_data ()) ? 1 : 0);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
940 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
941 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
942
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
943 case class_vector:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
944 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
945 idx_vector_rep *r = dynamic_cast<idx_vector_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
946 const octave_idx_type *data = r->get_data ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
947 octave_idx_type i;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
948 for (i = 0; i < len && body (data[i]); i++) ;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
949 ret = i;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
950 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
951 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
952
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
953 case class_mask:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
954 {
23432
e35a5c1233d0 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23420
diff changeset
955 idx_mask_rep *r = dynamic_cast<idx_mask_rep *> (rep);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
956 const bool *data = r->get_data ();
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
957 octave_idx_type ext = r->extent (0);
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
958 octave_idx_type j = 0;
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
959 for (octave_idx_type i = 0; i < ext; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
960 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
961 if (data[i])
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
962 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
963 if (body (i))
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
964 break;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
965 else
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
966 j++;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
967 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
968 }
9985
43a29eeda994 fix idx_vector::loop for masks
Jaroslav Hajek <highegg@gmail.com>
parents: 9894
diff changeset
969
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
970 ret = j;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
971 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
972 break;
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
973
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
974 default:
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
975 assert (false);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
976 break;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
977 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
978
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
979 return ret;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
980 }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
981
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
982 // Rationale:
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
983 // This method is the key to "smart indexing". When indexing cartesian
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
984 // arrays, sometimes consecutive index vectors can be reduced into a
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
985 // single index. If rows (A) = k and i.maybe_reduce (j) gives k, then
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
986 // A(i,j)(:) is equal to A(k)(:).
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
987
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
988 // If the next index can be reduced, returns true and updates this.
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
989 bool maybe_reduce (octave_idx_type n, const idx_vector& j,
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
990 octave_idx_type nj);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
991
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
992 bool is_cont_range (octave_idx_type n,
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
993 octave_idx_type& l, octave_idx_type& u) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
994
9725
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
995 // Returns the increment for ranges and colon, 0 for scalars and empty
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
996 // vectors, 1st difference otherwise.
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
997 octave_idx_type increment (void) const;
aea3a3a950e1 implement nth_element
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
998
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
999 idx_vector
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1000 complement (octave_idx_type n) const;
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1001
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8333
diff changeset
1002 bool is_permutation (octave_idx_type n) const;
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8333
diff changeset
1003
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
1004 // Returns the inverse permutation. If this is not a permutation on 1:n, the
10512
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
1005 // result is undefined (but no error unless extent () != n).
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
1006 idx_vector inverse_permutation (octave_idx_type n) const;
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
1007
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
1008 // Copies all the indices to a given array. Not allowed for colons.
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8972
diff changeset
1009 void copy_data (octave_idx_type *data) const;
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8972
diff changeset
1010
9879
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
1011 // If the index is a mask, convert it to index vector.
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
1012 idx_vector unmask (void) const;
034677ab6865 smarter treatment of mask indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9780
diff changeset
1013
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
1014 // Unconverts the index to a scalar, Range, double array or a mask.
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8972
diff changeset
1015 void unconvert (idx_class_type& iclass,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1016 double& scalar, Range& range,
9894
83bd7f34f9da improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9886
diff changeset
1017 Array<double>& array, Array<bool>& mask) const;
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
1018
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
1019 Array<octave_idx_type> as_array (void) const;
10475
739109ef88ee helper idx_vector methods
Jaroslav Hajek <highegg@gmail.com>
parents: 10425
diff changeset
1020
10487
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
1021 // Raw pointer to index array. This is non-const because it may be
942386d6d1a5 style fixes
John W. Eaton <jwe@octave.org>
parents: 10486
diff changeset
1022 // necessary to mutate the index.
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23432
diff changeset
1023 const octave_idx_type * raw (void);
10516
f0266ee4aabe optimize some special indexing & assignment cases
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
1024
23592
80e3bfb7bd5a maint: Deprecate is_vector and replace with isvector.
Rik <rik@octave.org>
parents: 23534
diff changeset
1025 bool isvector (void) const;
80e3bfb7bd5a maint: Deprecate is_vector and replace with isvector.
Rik <rik@octave.org>
parents: 23534
diff changeset
1026
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1027 // FIXME: these are here for compatibility. They should be removed
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
1028 // when no longer in use.
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1029
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1030 octave_idx_type elem (octave_idx_type n) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1031 { return (*this) (n); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1032
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1033 bool is_colon_equiv (octave_idx_type n, int) const
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1034 { return is_colon_equiv (n); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1035
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
1036 octave_idx_type
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
1037 freeze (octave_idx_type z_len, const char *tag, bool resize_ok = false);
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1038
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1039 void sort (bool uniq = false)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1040 { *this = sorted (uniq); }
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1041
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
1042 octave_idx_type ones_count (void) const;
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1043
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8319
diff changeset
1044 octave_idx_type max (void) const { return extent (1) - 1; }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1045
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1046 private:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1047
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7573
diff changeset
1048 idx_base_rep *rep;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1049
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1050 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1051
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1052 #endif