annotate liboctave/array/idx-vector.h @ 29568:a7cbd0e54e7a

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