@@ -10,30 +10,30 @@ namespace vtr {
1010/* *
1111 * @brief A half-open range specification for a matrix dimension [begin_index, last_index)
1212 *
13- * It comes with valid indicies from [begin_index() ... end_index()-1], provided size() > 0.
13+ * It comes with valid indices from [begin_index() ... end_index()-1], provided size() > 0.
1414 */
1515class DimRange {
1616 public:
1717 // /@brief default constructor
1818 DimRange () = default ;
1919
2020 // /@brief a constructor with begin_index, end_index
21- DimRange (size_t begin, size_t end)
21+ DimRange (int begin, int end)
2222 : begin_index_(begin)
2323 , end_index_(end) {}
2424
2525 // /@brief Return the begin index
26- size_t begin_index () const { return begin_index_; }
26+ int begin_index () const { return begin_index_; }
2727
2828 // /@brief Return the end index
29- size_t end_index () const { return end_index_; }
29+ int end_index () const { return end_index_; }
3030
3131 // /@brief Return the size
3232 size_t size () const { return end_index_ - begin_index_; }
3333
3434 private:
35- size_t begin_index_ = 0 ;
36- size_t end_index_ = 0 ;
35+ int begin_index_ = 0 ;
36+ int end_index_ = 0 ;
3737};
3838
3939/* *
@@ -69,7 +69,7 @@ class NdOffsetMatrixProxy {
6969 , start_(start) {}
7070
7171 // /@brief const [] operator
72- const NdOffsetMatrixProxy<T, N - 1 > operator [](size_t index) const {
72+ const NdOffsetMatrixProxy<T, N - 1 > operator [](int index) const {
7373 VTR_ASSERT_SAFE_MSG (index >= dim_ranges_[idim_].begin_index (), " Index out of range (below dimension minimum)" );
7474 VTR_ASSERT_SAFE_MSG (index < dim_ranges_[idim_].end_index (), " Index out of range (above dimension maximum)" );
7575
@@ -79,10 +79,10 @@ class NdOffsetMatrixProxy {
7979 * The elements are stored in zero-indexed form, so we need to adjust
8080 * for any non-zero minimum index
8181 */
82- size_t effective_index = index - dim_ranges_[idim_].begin_index ();
82+ int effective_index = index - dim_ranges_[idim_].begin_index ();
8383
8484 // Determine the stride of the next dimension
85- size_t next_dim_stride = dim_stride_ / dim_ranges_[idim_ + 1 ].size ();
85+ int next_dim_stride = dim_stride_ / dim_ranges_[idim_ + 1 ].size ();
8686
8787 // Strip off one dimension
8888 return NdOffsetMatrixProxy<T, N - 1 >(dim_ranges_, // Pass the dimension information
@@ -92,7 +92,7 @@ class NdOffsetMatrixProxy {
9292 }
9393
9494 // /@brief [] operator
95- NdOffsetMatrixProxy<T, N - 1 > operator [](size_t index) {
95+ NdOffsetMatrixProxy<T, N - 1 > operator [](int index) {
9696 // Call the const version and cast-away constness
9797 return const_cast <const NdOffsetMatrixProxy<T, N>*>(this )->operator [](index);
9898 }
@@ -122,21 +122,21 @@ class NdOffsetMatrixProxy<T, 1> {
122122 , start_(start) {}
123123
124124 // /@brief const [] operator
125- const T& operator [](size_t index) const {
125+ const T& operator [](int index) const {
126126 VTR_ASSERT_SAFE_MSG (dim_stride_ == 1 , " Final dimension must have stride 1" );
127127 VTR_ASSERT_SAFE_MSG (index >= dim_ranges_[idim_].begin_index (), " Index out of range (below dimension minimum)" );
128128 VTR_ASSERT_SAFE_MSG (index < dim_ranges_[idim_].end_index (), " Index out of range (above dimension maximum)" );
129129
130130 // The elements are stored in zero-indexed form, so we need to adjust
131131 // for any non-zero minimum index
132- size_t effective_index = index - dim_ranges_[idim_].begin_index ();
132+ int effective_index = index - dim_ranges_[idim_].begin_index ();
133133
134134 // Base case
135135 return start_[effective_index];
136136 }
137137
138138 // /@brief [] operator
139- T& operator [](size_t index) {
139+ T& operator [](int index) {
140140 // Call the const version and cast-away constness
141141 return const_cast <T&>(const_cast <const NdOffsetMatrixProxy<T, 1 >*>(this )->operator [](index));
142142 }
@@ -163,7 +163,7 @@ class NdOffsetMatrixProxy<T, 1> {
163163 * This should improve memory usage (no extra pointers to store for each dimension),
164164 * and cache locality (less indirection via pointers, predictable strides).
165165 *
166- * The indicies are calculated based on the dimensions to access the appropriate elements.
166+ * The indices are calculated based on the dimensions to access the appropriate elements.
167167 * Since the indexing calculations are visible to the compiler at compile time they can be
168168 * optimized to be efficient.
169169 */
@@ -230,14 +230,14 @@ class NdOffsetMatrixBase {
230230 }
231231
232232 // /@brief Returns the starting index of ith dimension
233- size_t begin_index (size_t i) const {
233+ int begin_index (size_t i) const {
234234 VTR_ASSERT_SAFE (i < ndims ());
235235
236236 return dim_ranges_[i].begin_index ();
237237 }
238238
239239 // /@brief Returns the one-past-the-end index of the ith dimension
240- size_t end_index (size_t i) const {
240+ int end_index (size_t i) const {
241241 VTR_ASSERT_SAFE (i < ndims ());
242242
243243 return dim_ranges_[i].end_index ();
@@ -333,7 +333,7 @@ class NdOffsetMatrixBase {
333333 *
334334 * Examples:
335335 *
336- * //A 2-dimensional matrix with indicies [0..4][0..9]
336+ * //A 2-dimensional matrix with indices [0..4][0..9]
337337 * NdOffsetMatrix<int,2> m1({5,10});
338338 *
339339 * //Accessing an element
@@ -342,28 +342,28 @@ class NdOffsetMatrixBase {
342342 * //Setting an element
343343 * m4[6][20] = 0;
344344 *
345- * //A 2-dimensional matrix with indicies [2..6][5..9]
345+ * //A 2-dimensional matrix with indices [2..6][5..9]
346346 * // Note that C++ requires one more set of curly brace than you would expect
347347 * NdOffsetMatrix<int,2> m2({{{2,7},{5,10}}});
348348 *
349- * //A 3-dimensional matrix with indicies [0..4][0..9][0..19]
349+ * //A 3-dimensional matrix with indices [0..4][0..9][0..19]
350350 * NdOffsetMatrix<int,3> m3({5,10,20});
351351 *
352- * //A 3-dimensional matrix with indicies [2..6][1..19][50..89]
352+ * //A 3-dimensional matrix with indices [2..6][1..19][50..89]
353353 * NdOffsetMatrix<int,3> m4({{{2,7}, {1,20}, {50,90}}});
354354 *
355- * //A 2-dimensional matrix with indicies [2..6][1..20], with all entries
356- * //intialized to 42
355+ * //A 2-dimensional matrix with indices [2..6][1..20], with all entries
356+ * //initialized to 42
357357 * NdOffsetMatrix<int,2> m4({{{2,7}, {1,21}}}, 42);
358358 *
359- * //A 2-dimensional matrix with indicies [0..4][0..9], with all entries
359+ * //A 2-dimensional matrix with indices [0..4][0..9], with all entries
360360 * //initialized to 42
361361 * NdOffsetMatrix<int,2> m1({5,10}, 42);
362362 *
363363 * //Filling all entries with value 101
364364 * m1.fill(101);
365365 *
366- * //Resizing an existing matrix (all values reset to default constucted value)
366+ * //Resizing an existing matrix (all values reset to default constructed value)
367367 * m1.resize({5,5})
368368 *
369369 * //Resizing an existing matrix (all elements set to value 88)
@@ -385,25 +385,25 @@ class NdOffsetMatrix : public NdOffsetMatrixBase<T, N> {
385385 * Returns a proxy-object to allow chained array-style indexing (N >= 2 case)
386386 * template<typename = typename std::enable_if<N >= 2>::type, typename T1=T>
387387 */
388- const NdOffsetMatrixProxy<T, N - 1 > operator [](size_t index) const {
388+ const NdOffsetMatrixProxy<T, N - 1 > operator [](int index) const {
389389 VTR_ASSERT_SAFE_MSG (this ->dim_size (0 ) > 0 , " Can not index into size zero dimension" );
390390 VTR_ASSERT_SAFE_MSG (this ->dim_size (1 ) > 0 , " Can not index into size zero dimension" );
391391 VTR_ASSERT_SAFE_MSG (index >= this ->dim_ranges_ [0 ].begin_index (), " Index out of range (below dimension minimum)" );
392392 VTR_ASSERT_SAFE_MSG (index < this ->dim_ranges_ [0 ].end_index (), " Index out of range (above dimension maximum)" );
393393
394394 /*
395- * Clacluate the effective index
395+ * Calculate the effective index
396396 *
397397 * The elements are stored in zero-indexed form, so adjust for any
398398 * non-zero minimum index in this dimension
399399 */
400- size_t effective_index = index - this ->dim_ranges_ [0 ].begin_index ();
400+ int effective_index = index - this ->dim_ranges_ [0 ].begin_index ();
401401
402402 // Calculate the stride for the current dimension
403- size_t dim_stride = this ->size () / this ->dim_size (0 );
403+ int dim_stride = this ->size () / this ->dim_size (0 );
404404
405405 // Calculate the stride for the next dimension
406- size_t next_dim_stride = dim_stride / this ->dim_size (1 );
406+ int next_dim_stride = dim_stride / this ->dim_size (1 );
407407
408408 // Peel off the first dimension
409409 return NdOffsetMatrixProxy<T, N - 1 >(this ->dim_ranges_ .data (), // Pass the dimension information
@@ -417,7 +417,7 @@ class NdOffsetMatrix : public NdOffsetMatrixBase<T, N> {
417417 *
418418 * Returns a proxy-object to allow chained array-style indexing
419419 */
420- NdOffsetMatrixProxy<T, N - 1 > operator [](size_t index) {
420+ NdOffsetMatrixProxy<T, N - 1 > operator [](int index) {
421421 // Call the const version, since returned by value don't need to worry about const
422422 return const_cast <const NdOffsetMatrix<T, N>*>(this )->operator [](index);
423423 }
@@ -436,7 +436,7 @@ class NdOffsetMatrix<T, 1> : public NdOffsetMatrixBase<T, 1> {
436436
437437 public:
438438 // /@brief Access an element (immutable)
439- const T& operator [](size_t index) const {
439+ const T& operator [](int index) const {
440440 VTR_ASSERT_SAFE_MSG (this ->dim_size (0 ) > 0 , " Can not index into size zero dimension" );
441441 VTR_ASSERT_SAFE_MSG (index >= this ->dim_ranges_ [0 ].begin_index (), " Index out of range (below dimension minimum)" );
442442 VTR_ASSERT_SAFE_MSG (index < this ->dim_ranges_ [0 ].end_index (), " Index out of range (above dimension maximum)" );
@@ -445,7 +445,7 @@ class NdOffsetMatrix<T, 1> : public NdOffsetMatrixBase<T, 1> {
445445 }
446446
447447 // /@brief Access an element (mutable)
448- T& operator [](size_t index) {
448+ T& operator [](int index) {
449449 // Call the const version, and cast away const-ness
450450 return const_cast <T&>(const_cast <const NdOffsetMatrix<T, 1 >*>(this )->operator [](index));
451451 }
0 commit comments