ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
vector_int.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010, 2011, 2012, 2019, 2020, 2021, 2024 John D Lamb
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef CCGSL_VECTOR_INT_HPP
20#define CCGSL_VECTOR_INT_HPP
21
22#include<gsl/gsl_vector_int.h>
23#include<new>
24#include<iterator>
25
26#include"exception.hpp"
27#include"block_int.hpp"
28
29// This file is autogenerated
30
31namespace gsl {
32 // declare matrix_int class
33 class matrix_int;
45 class vector_int {
46 public:
51 owns_data = false;
52 ccgsl_pointer = 0;
53 count = 0; // initially nullptr will do
54 }
55 // Refines random access container
56 // Refines assignable
61 explicit vector_int( size_t const n ) : owns_data(true){
62 if( n > 0 ) ccgsl_pointer = gsl_vector_int_alloc( n );
63 else { ccgsl_pointer = new gsl_vector_int; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
64 // just plausibly we could allocate vector_int but not count
65 try { count = new size_t; } catch( std::bad_alloc& e ){
66 // try to tidy up before rethrowing
67 if( n > 0 ) gsl_vector_int_free( ccgsl_pointer );
68 else delete ccgsl_pointer;
69 throw e;
70 }
71 *count = 1; // initially there is just one reference to ccgsl_pointer
72 }
73#ifndef DOXYGEN_SKIP
78 explicit vector_int( int const n ) : owns_data(true){
79 if( n > 0 ) ccgsl_pointer = gsl_vector_int_alloc( static_cast<size_t>( n ) );
80 else if(n<0)
81 gsl_error("failed tring to make a vector of negative length",
82 __FILE__, __LINE__, exception::GSL_EDOM );
83 else { ccgsl_pointer = new gsl_vector_int; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
84 // just plausibly we could allocate vector_int but not count
85 try { count = new size_t; } catch( std::bad_alloc& e ){
86 // try to tidy up before rethrowing
87 if( n > 0 ) gsl_vector_int_free( ccgsl_pointer );
88 else delete ccgsl_pointer;
89 throw e;
90 }
91 *count = 1; // initially there is just one reference to ccgsl_pointer
92 }
93#endif // DOXYGEN_SKIP
99 explicit vector_int( gsl_vector_int* v ) : owns_data(true){
100 ccgsl_pointer = v;
101 // just plausibly we could fail to allocate count: no further action needed.
102 count = new size_t;
103 *count = 1; // initially there is just one reference to ccgsl_pointer
104 }
105#ifdef __GXX_EXPERIMENTAL_CXX0X__
110 vector_int( std::initializer_list<int> initializer_list ) : owns_data(true){
111 size_t const n = initializer_list.size();
112 ccgsl_pointer = gsl_vector_int_alloc( n );
113 // just plausibly we could allocate vector_int but not count
114 try { count = new size_t; } catch( std::bad_alloc& e ){
115 // try to tidy up before rethrowing
116 if( n > 0 ) gsl_vector_int_free( ccgsl_pointer );
117 else delete ccgsl_pointer;
118 throw e;
119 }
120 *count = 1; // initially there is just one reference to ccgsl_pointer
121 // now copy
122 auto p = begin();
123 for( auto x : initializer_list ){ *p = x; ++p; }
124 }
125#endif
126 // copy constructor
131 vector_int( vector_int const& v ) : owns_data( v.owns_data ),
132 ccgsl_pointer( v.ccgsl_pointer ), count( v.count ){
133 if( count != 0 ) ++*count; // vector_int is now shared.
134 }
139 vector_int( vector_int& v ) : owns_data( v.owns_data ),
140 ccgsl_pointer( v.ccgsl_pointer ), count( v.count ){
141 if( count != 0 ) ++*count; // vector_int is now shared.
142 }
143 // assignment operator
149 // first, possibly delete anything pointed to by @c this
150 if( count == 0 or --*count == 0 ){
151 if( ccgsl_pointer != 0 ){
152 if( ccgsl_pointer->size > 0 ) gsl_vector_int_free( ccgsl_pointer );
153 else delete ccgsl_pointer; }
154 delete count;
155 }
156 // Then copy
157 owns_data = v.owns_data;
158 ccgsl_pointer = v.ccgsl_pointer;
159 count = v.count;
160 if( count != 0 ) ++*count; // block_int is now shared.
161 return *this;
162 }
175 template<typename V> vector_int( V& v, size_t const stride = 1 ) : owns_data(true){
176 size_t const n = v.size() / stride;
177 ccgsl_pointer = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
178 ccgsl_pointer->size = n;
179 ccgsl_pointer->stride = stride;
180 ccgsl_pointer->data = v.data();
181 ccgsl_pointer->block = 0;
182 ccgsl_pointer->owner = 0;
183 // just plausibly we could allocate vector_int but not count
184 try { count = new size_t; } catch( std::bad_alloc& e ){
185 // try to tidy up before rethrowing
186 if( n > 0 ) gsl_vector_int_free( ccgsl_pointer );
187 else delete ccgsl_pointer;
188 throw e;
189 }
190 *count = 1; // initially there is just one reference to ccgsl_pointer
191 }
192 // clone()
199 vector_int copy( get()->size );
200 // Now copy
201 gsl_vector_int_memcpy( copy.get(), get() );
202 // return new object
203 return copy;
204 }
205 // destructor
210 if( count != 0 and --*count == 0 ){
211 // could have allocated null pointer
212 if( ccgsl_pointer != 0 and owns_data){
213 if( ccgsl_pointer->size > 0 ) gsl_vector_int_free( ccgsl_pointer );
214 else delete ccgsl_pointer; }
215 delete count;
216 }
217 }
218
219 // Allow possibility of assigning from gsl_vector_int without sharing
228 void wrap_gsl_vector_int_without_ownership( gsl_vector_int* v ){
229 if( count != 0 and --*count == 0 ){
230 // could have allocated null pointer
231 if( ccgsl_pointer != 0 ){
232 if( ccgsl_pointer->size != 0 ) gsl_vector_int_free( ccgsl_pointer );
233 else delete ccgsl_pointer; }
234 }
235 ccgsl_pointer = v;
236 if(0 == count) count = new size_t;
237 *count = 1;
238 owns_data = false; // should never be able to delete ccgsl_pointer
239 }
240 // Refines equality comparable
241 // == operator
248 bool operator==( vector_int const& v ) const {
249 // trivially equal if gsl_vector_int*s are identical
250 if( ccgsl_pointer == v.ccgsl_pointer ) return true;
251 // trivially not equal if one is zero: != should be same as xor here
252 if( (ccgsl_pointer == 0) != (v.ccgsl_pointer == 0 ) ) return false;
253 // trivially not equal if sizes are different
254 if( ccgsl_pointer->size != v.ccgsl_pointer->size ) return false;
255 // check elementwise for equality
256 for( size_t i = 0; i < ccgsl_pointer->size; ++i )
257 if( gsl_vector_int_get( ccgsl_pointer, i ) != gsl_vector_int_get( v.ccgsl_pointer, i ) ) return false;
258 return true;
259 }
263 void reset(){ vector_int().swap( *this ); }
264#ifdef __GXX_EXPERIMENTAL_CXX0X__
269 vector_int( vector_int&& v ) : owns_data {v.owns_data},
270 ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
271 std::swap( count, v.count );
272 v.ccgsl_pointer = nullptr;
273 }
280 vector_int( std::move( v ) ).swap( *this );
281 return *this;
282 }
283#endif
284 // != operator
291 bool operator!=( vector_int const& v ) const { return not operator==( v ); }
292 // Refines forward container
293 // Refines less than comparable
294 // operator<
303 bool operator<( vector_int const& v ) const {
304 // null vector_int comes first
305 if( ccgsl_pointer == 0 ) return v.ccgsl_pointer != 0;
306 // if v is null then this > v
307 if( v.ccgsl_pointer == 0 ) return false;
308 // Now compare elementwise
309 size_t const size = ccgsl_pointer->size;
310 size_t const v_size = v.ccgsl_pointer->size;
311 size_t const min = size > v_size ? size : v_size;
312 for( size_t i = 0; i < min; ++i ){
313 int const t = gsl_vector_int_get( ccgsl_pointer, i );
314 int const u =gsl_vector_int_get( v.ccgsl_pointer, i );
315 if( t < u ) return true;
316 if( u < t ) return false;
317 }
318 // elements match.
319 return size < v_size;
320 }
321 // operator>
330 bool operator>( vector_int const& v ) const {
331 // null vector_int comes first
332 if( ccgsl_pointer == 0 ) return false;
333 // if v is null then this > v
334 if( v.ccgsl_pointer == 0 ) return true;
335 // Now compare elementwise
336 size_t const size = ccgsl_pointer->size;
337 size_t const v_size = v.ccgsl_pointer->size;
338 size_t const min = size > v_size ? size : v_size;
339 for( size_t i = 0; i < min; ++i ){
340 int const t = gsl_vector_int_get( ccgsl_pointer, i );
341 int const u =gsl_vector_int_get( v.ccgsl_pointer, i );
342 if( t > u ) return true;
343 if( u > t ) return false;
344 }
345 // elements match.
346 return size > v_size;
347 }
348 // operator<=
357 bool operator<=( vector_int const& v ) const {
358 return operator<( v ) or operator==( v );
359 }
360 // operator>=
369 bool operator>=( vector_int const& v ) const {
370 return operator>( v ) or operator==( v );
371 }
372 // Refines container
373 // type value_type
377 typedef int value_type;
378 // type reference
383 // type const_reference
388 // type pointer
393 // type const_pointer
397 typedef value_type const* const_pointer;
398 // type iterator
399 private:
404 template<typename container, typename content,bool reverse_t> class iterator_base {
405 friend class vector_int;
406 public:
410 typedef std::random_access_iterator_tag iterator_category;
414 typedef int value_type;
423 // // type iterator_traits<vector_int>::difference_type
427 typedef ptrdiff_t difference_type;
428 public:
429 // // operator*
435 // Always try to return something
436 static content something = 0;
437 // First check that iterator is initialised.
438 if( v == 0 ){
439 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
440 return something;
441 } else if( v->ccgsl_pointer == 0 ){
442 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
443 return something;
444 }
445 // Check that position make sense
446 if( position >= static_cast<difference_type>( v->size() ) ){
447 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
448 return something;
449 }
450 if( position <= -1 ){
451 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
452 return something;
453 }
454 // position and v are valid: return data
455 return *(v->ccgsl_pointer->data + position * v->ccgsl_pointer->stride);
456 }
457 // // operator->
463 // First check that iterator is initialised.
464 if( v == 0 ){
465 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
466 return 0;
467 } else if( v->ccgsl_pointer == 0 ){
468 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
469 return 0;
470 }
471 // Check that position make sense
472 if( position >= static_cast<difference_type>( v->size() ) ){
473 gsl_error( "trying to dereference end()", __FILE__, __LINE__, exception::GSL_EFAILED );
474 return 0;
475 }
476 if( position <= -1 ){
477 gsl_error( "trying to dereference rend()", __FILE__, __LINE__, exception::GSL_EFAILED );
478 return 0;
479 }
480 // position and v are valid: return data
481 return v->ccgsl_pointer->data + position * v->ccgsl_pointer->stride;
482 }
483 // // operator[]
490 // Always try to return something
491 static content something = 0;
492 // First check that iterator is initialised.
493 if( v == 0 ){
494 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
495 return something;
496 } else if( v->ccgsl_pointer == 0 ){
497 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
498 return something;
499 }
500 // Check that position make sense
501 difference_type const p = reverse_t ? position - n : position + n;
502 if( p >= static_cast<difference_type>( v->size() ) ){
503 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
504 return something;
505 }
506 if( p <= -1 ){
507 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
508 return something;
509 }
510 // p is a valid position
511 return *(v->ccgsl_pointer->data + p * v->ccgsl_pointer->stride);
512 }
513 // // operator-: find distance between two iterators
520 // Warn if either iterator undefined
521 if( v == 0 or i.v == 0 ){
522 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
523 return 0;
524 } else if( v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
525 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
526 return 0;
527 }
528 // Warn if iterators do not point to same vector_int
529 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
530 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
532 return 0;
533 }
534 return reverse_t ? i.position - position : position - i.position;
535 }
536 // // operator!=
537 // // operator<
544 return this->v == i.v and this->position == i.position;
545 }
552 return not this->operator==( i );
553 }
562 // Warn if either iterator undefined
563 if( v == 0 or i.v == 0 ){
564 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
565 return false;
566 }
567 // Warn if iterators do not point to same vector_int
568 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
569 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
571 return false;
572 }
573 return reverse_t ? i.position < position : position < i.position;
574 }
575 protected:
580 void increment(){
581 // Only makes sense if v points to a vector_int
582 if( v == 0 ){
583 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
584 return;
585 } else if( v->ccgsl_pointer == 0 ){
586 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
587 return;
588 }
589 // increment position and check against size
590 if( reverse_t ){ if( position >= 0 ) --position; }
591 else { if( position < static_cast<difference_type>( v->size() ) ) ++position; }
592 }
597 void decrement(){
598 // Only makes sense if v points to a vector_int
599 if( v == 0 ){
600 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
601 return;
602 } else if( v->ccgsl_pointer == 0 ){
603 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
604 return;
605 }
606 // decrement position and check against size
607 if( reverse_t ){ if( position < static_cast<difference_type>( v->size() ) ) ++position; }
608 else { if( position >= 0 ) --position; }
609 }
614 void shift( difference_type const n ){
615 // Warn if iterator undefined
616 if( v == 0 ){
617 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
618 return;
619 } else if( v->ccgsl_pointer == 0 ){
620 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
621 return;
622 }
623 position += reverse_t ? -n : n;
624 }
628 iterator_base(){ v = 0; }
635 : v( v ), position( position ){}
639 container* v;
644 };
645 // Need to know about const_iterator_t
646 template<bool reverse_t> class const_iterator_t;
650 template<bool reverse_t> class iterator_t : public iterator_base<vector_int,int,reverse_t>{
651 public:
652 // // Refines output iterator
653 // // operator=
661 return *this;
662 }
663 // // Refines forward iterator
664 // // operator++ (both)
671 return *this;
672 }
678 // return value
681 return result;
682 }
683 // // Refines bidirectional iterator
684 // // operator-- (both)
691 return *this;
692 }
698 // return value
701 return result;
702 }
708 // // operator+=
715 this->shift( n );
716 return *this;
717 }
718 // // operator-=
725 this->shift( -n );
726 return *this;
727 }
728 // // operator+ (n+i)(i+n)
737 result.shift( n );
738 return result;
739 }
740 // // operator- (n-i)(i-n)(i-j)
749 result.shift( -n );
750 return result;
751 }
759 }
766 // Warn if either iterator undefined
767 if( this->v == 0 or i.v == 0 ){
768 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
769 return 0;
770 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
771 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
772 return 0;
773 }
774 // Warn if iterators do not point to same vector_int
775 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
776 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
778 return 0;
779 }
780 return reverse_t ? i.position - this->position : this->position - i.position;
781 }
788 return this->v == i.v and this->position == i.position;
789 }
796 return not this->operator==( i );
797 }
803 bool operator<( const_iterator_t<reverse_t> const& i ) const {
804 // Warn if either iterator undefined
805 if( this->v == 0 or i.v == 0 ){
806 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
807 return false;
808 }
809 // Warn if iterators do not point to same vector_int
810 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
811 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
813 return false;
814 }
815 return reverse_t ? i.position < this->position : this->position < i.position;
816 }
820 iterator_t() : iterator_base<vector_int,int,reverse_t>(){}
821 protected:
822 friend class vector_int;
823 // We need a constructor for vector_int
830 : iterator_base<vector_int,int,reverse_t>( v, position ){}
831 };
835 template<bool reverse_t> class const_iterator_t
836 : public iterator_base<vector_int const,int,reverse_t>{
837 public:
838 // // Refines output iterator
839 // // operator=
847 return *this;
848 }
849 // // Refines forward iterator
850 // // operator++ (both)
857 return *this;
858 }
864 // return value
867 return result;
868 }
869 // // Refines bidirectional iterator
870 // // operator-- (both)
877 return *this;
878 }
884 // return value
887 return result;
888 }
894 // // operator+=
901 this->shift( n );
902 return *this;
903 }
904 // // operator-=
911 this->shift( -n );
912 return *this;
913 }
914 // // operator+ (n+i)(i+n)
923 result += n;
924 return result;
925 }
926 // // operator- (n-i)(i-n)(i-j)
935 result -= n;
936 return result;
937 }
945 }
952 // Warn if either iterator undefined
953 if( this->v == 0 or i.v == 0 ){
954 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
955 return 0;
956 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
957 gsl_error( "vector_int not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
958 return 0;
959 }
960 // Warn if iterators do not point to same vector_int
961 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
962 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
964 return 0;
965 }
966 return reverse_t ? i.position - this->position : this->position - i.position;
967 }
979 }
985 bool operator==( iterator_t<reverse_t> const& i ) const {
986 return this->v == i.v and this->position == i.position;
987 }
993 bool operator!=( iterator_t<reverse_t> const& i ) const {
994 return not this->operator==( i );
995 }
1001 bool operator<( iterator_t<reverse_t> const& i ) const {
1002 // Warn if either iterator undefined
1003 if( this->v == 0 or i.v == 0 ){
1004 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1005 return false;
1006 }
1007 // Warn if iterators do not point to same vector_int
1008 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1009 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
1011 return false;
1012 }
1013 return reverse_t ? i.position < this->position : this->position < i.position;
1014 }
1021 return this->v == i.v and this->position == i.position;
1022 }
1029 return not this->operator==( i );
1030 }
1037 // Warn if either iterator undefined
1038 if( this->v == 0 or i.v == 0 ){
1039 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1040 return false;
1041 }
1042 // Warn if iterators do not point to same vector_int
1043 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1044 gsl_error( "trying to take difference of iterators for different vector_int objects", __FILE__, __LINE__,
1046 return false;
1047 }
1048 return reverse_t ? i.position < this->position : this->position < i.position;
1049 }
1050 protected:
1051 // We need a constructor for vector_int
1052 friend class vector_int;
1059 : iterator_base<vector_int const,int,reverse_t>( v, position ){}
1060 };
1061 public:
1078 // type difference_type
1083 // type size_type
1087 typedef size_t size_type;
1088 // begin()
1094 return iterator( this, 0 );
1095 }
1101 return const_iterator( this, 0 );
1102 }
1103 // end()
1109 if( ccgsl_pointer == 0 ) return iterator( this, 0 );
1110 return iterator( this, size() );
1111 }
1117 if( ccgsl_pointer == 0 ) return const_iterator( this, 0 );
1118 return const_iterator( this, size() );
1119 }
1120 // size()
1125 size_type size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1133 int* data() {
1134 if( ccgsl_pointer == 0 ) gsl_error( "null vector_int", __FILE__, __LINE__, GSL_EFAULT );
1135#ifndef GSL_RANGE_CHECK_OFF
1136 if( ccgsl_pointer->stride != 1 )
1137 gsl_error( "vector_int does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1138#endif
1139 return ccgsl_pointer->data; }
1147 int const* data() const {
1148 if( ccgsl_pointer == 0 ) gsl_error( "null vector_int", __FILE__, __LINE__, GSL_EFAULT );
1149#ifndef GSL_RANGE_CHECK_OFF
1150 if( ccgsl_pointer->stride != 1 )
1151 gsl_error( "vector_int does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1152#endif
1153 return ccgsl_pointer->data; }
1154 // max_size()
1160 size_type max_size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1161 // empty()
1166 bool empty() const { return ccgsl_pointer == 0 or ccgsl_pointer->size == 0; }
1167 // swap() --- should work even if sizes don't match
1173 void swap( vector_int& v ){
1174 std::swap( ccgsl_pointer, v.ccgsl_pointer );
1175 std::swap( count, v.count );
1176 }
1177 // Refines reversible container
1178 // rbegin()
1184 if( ccgsl_pointer ==0 ) return reverse_iterator( this, 0 );
1185 return reverse_iterator( this, size() - 1 );
1186 }
1192 if( ccgsl_pointer ==0 ) return const_reverse_iterator( this, 0 );
1193 return const_reverse_iterator( this, size() - 1 );
1194 }
1195 // rend()
1201 return reverse_iterator( this, -1 );
1202 }
1208 return const_reverse_iterator( this, -1 );
1209 }
1210 // operator[]
1216 int& operator[]( size_t const n ){
1217 // Always try to return something
1218 static int something = 0;
1219 // First check that iterator is initialised.
1220 if( ccgsl_pointer == 0 ){
1221 gsl_error( "vector_int is null", __FILE__, __LINE__, exception::GSL_EFAULT );
1222 return something;
1223 }
1224#ifndef GSL_RANGE_CHECK_OFF
1225 // Check that position make sense
1226 if( n >= size() ){
1227 gsl_error( "trying to read beyond end of vector_int", __FILE__, __LINE__, exception::GSL_EINVAL );
1228 return something;
1229 }
1230 // n is a valid position
1231#endif
1232 return *(ccgsl_pointer->data + n * ccgsl_pointer->stride);
1233 }
1239 int const& operator[]( size_t const n ) const {
1240 // Always try to return something
1241 static int something = 0;
1242 // First check that iterator is initialised.
1243 if( ccgsl_pointer == 0 ){
1244 gsl_error( "vector_int is null", __FILE__, __LINE__, exception::GSL_EFAULT );
1245 return something;
1246 }
1247#ifndef GSL_RANGE_CHECK_OFF
1248 // Check that position make sense
1249 if( n >= size() ){
1250 gsl_error( "trying to read beyond end of vector_int", __FILE__, __LINE__, exception::GSL_EINVAL );
1251 return something;
1252 }
1253 // n is a valid position
1254#endif
1255 return *(ccgsl_pointer->data + n * ccgsl_pointer->stride);
1256 }
1257 private:
1265 gsl_vector_int* ccgsl_pointer;
1269 size_t* count;
1270 public:
1271 // shared reference functions
1276 gsl_vector_int* get() { return ccgsl_pointer; }
1281 gsl_vector_int const* get() const { return ccgsl_pointer; }
1287 bool unique() const { return count != 0 and *count == 1; }
1292 size_t use_count() const { return count == 0 ? 0 : *count; }
1298#ifdef __GXX_EXPERIMENTAL_CXX0X__
1299 explicit
1300#endif
1301 operator bool() const { return ccgsl_pointer != 0; }
1302
1303 // GSL functions
1310 static vector_int calloc( size_t const n ){ return vector_int( gsl_vector_int_calloc( n ) ); }
1314 void set_zero(){ gsl_vector_int_set_zero( get() ); }
1319 void set_all( int x ){ gsl_vector_int_set_all( get(), x ); }
1325 int set_basis( size_t i ){ return gsl_vector_int_set_basis( get(), i ); }
1331 int memcpy( vector_int const& src ){ return gsl_vector_int_memcpy( get(), src.get() ); }
1336 int reverse(){ return gsl_vector_int_reverse( get() ); }
1343 int swap_elements( size_t const i, size_t const j ){
1344 return gsl_vector_int_swap_elements( get(), i, j ); }
1349 int max() const { return gsl_vector_int_max( get() ); }
1354 int min() const { return gsl_vector_int_min( get() ); }
1360 void minmax( int* min_out, int* max_out ) const {
1361 gsl_vector_int_minmax( get(), min_out, max_out ); }
1367 void minmax( int& min_out, int& max_out ) const {
1368 gsl_vector_int_minmax( get(), &min_out, &max_out ); }
1373 size_t max_index() const { return gsl_vector_int_max_index( get() ); }
1378 size_t min_index() const { return gsl_vector_int_min_index( get() ); }
1384 void minmax_index( size_t* imin, size_t* imax ) const {
1385 gsl_vector_int_minmax_index( get(), imin, imax ); }
1391 int add( vector_int const& b ){ return gsl_vector_int_add( get(), b.get() ); }
1397 int sub( vector_int const& b ){ return gsl_vector_int_sub( get(), b.get() ); }
1403 int mul( vector_int const& b ){ return gsl_vector_int_mul( get(), b.get() ); }
1409 int div( vector_int const& b ){ return gsl_vector_int_div( get(), b.get() ); }
1415 int scale( int const x ){ return gsl_vector_int_scale( get(), x ); }
1421 int add_constant( int const x ){ return gsl_vector_int_add_constant( get(), x ); }
1429 int axpby( int const alpha, vector_int const& x,
1430 int const beta ){
1431 return gsl_vector_int_axpby( alpha, x.get(), beta, get() ); }
1437 int sum( vector_int const& a ) const { return gsl_vector_int_sum( a.get() ); }
1442 int isnull() const { return gsl_vector_int_isnull( get() ); }
1447 int ispos() const { return gsl_vector_int_ispos( get() ); }
1452 int isneg() const { return gsl_vector_int_isneg( get() ); }
1457 int isnonneg() const { return gsl_vector_int_isnonneg( get() ); }
1463 int get( size_t const i ) const { return gsl_vector_int_get( get(), i ); }
1469 void set( size_t const i, int x ){ gsl_vector_int_set( get(), i, x ); }
1475 int* ptr( size_t const i ){ return gsl_vector_int_ptr( get(), i ); }
1481 int const* const_ptr( size_t const i ) const { return gsl_vector_int_const_ptr( get(), i ); }
1487 int fread( FILE* stream ){ return gsl_vector_int_fread( stream, get() ); }
1493 int fwrite( FILE* stream ) const { return gsl_vector_int_fwrite( stream, get() ); }
1499 int fscanf( FILE* stream ){ return gsl_vector_int_fscanf( stream, get() ); }
1506 int fprintf( FILE* stream, char const* format ) const {
1507 return gsl_vector_int_fprintf( stream, get(), format ); }
1515 vector_int( block_int& b, size_t const offset, size_t const n, size_t const stride = 1 ){
1516 ccgsl_pointer = gsl_vector_int_alloc_from_block( b.get(), offset, n, stride );
1517 // just plausibly we could allocate vector_int but not count
1518 try { count = new size_t; } catch( std::bad_alloc& e ){
1519 // try to tidy up before rethrowing
1520 gsl_vector_int_free( ccgsl_pointer );
1521 throw e;
1522 }
1523 *count = 1; // initially there is just one reference to ccgsl_pointer
1524 }
1532 vector_int( vector_int& v, size_t const offset, size_t const n, size_t const stride = 1 ){
1533 ccgsl_pointer = gsl_vector_int_alloc_from_vector( v.get(), offset, n, stride );
1534 // just plausibly we could allocate vector_int but not count
1535 try { count = new size_t; } catch( std::bad_alloc& e ){
1536 // try to tidy up before rethrowing
1537 gsl_vector_int_free( ccgsl_pointer );
1538 throw e;
1539 }
1540 *count = 1; // initially there is just one reference to ccgsl_pointer
1541 }
1548 static vector_int view_array( int* v, size_t n ){
1549 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1550 *w = gsl_vector_int_view_array( v, n ).vector;
1551 return vector_int( w );
1552 }
1553
1554
1562 static vector_int view_array_with_stride( int* base, size_t stride, size_t n ){
1563 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1564 *w = gsl_vector_int_view_array_with_stride( base, stride, n ).vector;
1565 return vector_int( w );
1566 }
1567
1568
1575 static vector_int const const_view_array( int const* v, size_t n ){
1576 gsl_vector_int* w = static_cast<gsl_vector_int *>( malloc( sizeof( gsl_vector_int ) ) );
1577 *w = gsl_vector_int_const_view_array( v, n ).vector;
1578 return vector_int( w );
1579 }
1580
1581
1589 static vector_int const const_view_array_with_stride( int const* base, size_t stride, size_t n ){
1590 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1591 *w = gsl_vector_int_const_view_array_with_stride( base, stride, n ).vector;
1592 return vector_int( w );
1593 }
1594
1595
1596#ifndef DOXYGEN_SKIP
1603 static vector_int const view_array( int const* v, size_t n ){
1604 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1605 *w = gsl_vector_int_const_view_array( v, n ).vector;
1606 return vector_int( w );
1607 }
1608#endif //DOXYGEN_SKIP
1609
1610
1611#ifndef DOXYGEN_SKIP
1619 static vector_int const view_array_with_stride( int const* base, size_t stride, size_t n ){
1620 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1621 *w = gsl_vector_int_const_view_array_with_stride( base, stride, n ).vector;
1622 return vector_int( w );
1623 }
1624#endif //DOXYGEN_SKIP
1625
1626
1633 vector_int subvector( size_t i, size_t n ){
1634 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1635 *w = gsl_vector_int_subvector( get(), i, n ).vector;
1636 return vector_int( w );
1637 }
1638
1639
1647 vector_int subvector_with_stride( size_t i, size_t stride, size_t n ){
1648 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1649 *w = gsl_vector_int_subvector_with_stride( get(), i, stride, n ).vector;
1650 return vector_int( w );
1651 }
1652
1653
1660 vector_int const const_subvector( size_t i, size_t n ) const {
1661 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1662 *w = gsl_vector_int_const_subvector( get(), i, n ).vector;
1663 return vector_int( w );
1664 }
1665
1666
1674 vector_int const const_subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1675 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1676 *w = gsl_vector_int_const_subvector_with_stride( get(), i, stride, n ).vector;
1677 return vector_int( w );
1678 }
1679
1680
1681#ifndef DOXYGEN_SKIP
1688 vector_int const subvector( size_t i, size_t n ) const {
1689 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1690 *w = gsl_vector_int_const_subvector( get(), i, n ).vector;
1691 return vector_int( w );
1692 }
1693#endif //DOXYGEN_SKIP
1694
1695
1696#ifndef DOXYGEN_SKIP
1704 vector_int const subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1705 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1706 *w = gsl_vector_int_const_subvector_with_stride( get(), i, stride, n ).vector;
1707 return vector_int( w );
1708 }
1709#endif //DOXYGEN_SKIP
1710
1711
1718 template<typename ARRAY>
1719 static vector_int view_array( ARRAY& v, size_t n = 0 ){
1720 if(n > v.size())
1721 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1722 if(0 == n)
1723 n = v.size();
1724 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1725 *w = gsl_vector_int_view_array( v.data(), n ).vector;
1726 return vector_int( w );
1727 }
1728
1729
1737 template<typename ARRAY>
1738 static vector_int view_array_with_stride( ARRAY& base, size_t stride, size_t n=0 ){
1739 if(0 == n)
1740 n = base.size()/stride;
1741 if((n-1)*stride > base.size())
1742 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1743 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1744 *w = gsl_vector_int_view_array_with_stride( base.data(), stride, n ).vector;
1745 return vector_int( w );
1746 }
1747
1748
1755 template<typename ARRAY>
1756 static vector_int const const_view_array( ARRAY const& v, size_t n=0 ){
1757 if(n > v.size())
1758 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1759 if(0 == n)
1760 n = v.size();
1761 gsl_vector_int* w = static_cast<gsl_vector_int *>( malloc( sizeof( gsl_vector_int ) ) );
1762 *w = gsl_vector_int_const_view_array( v.data(), n ).vector;
1763 return vector_int( w );
1764 }
1765
1766
1774 template<typename ARRAY>
1775 static vector_int const const_view_array_with_stride( ARRAY const& base, size_t stride, size_t n=0 ){
1776 if(0 == n)
1777 n = base.size()/stride;
1778 if((n-1)*stride > base.size())
1779 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1780 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1781 *w = gsl_vector_int_const_view_array_with_stride( base.data(), stride, n ).vector;
1782 return vector_int( w );
1783 }
1784
1785
1786#ifndef DOXYGEN_SKIP
1793 template<typename ARRAY>
1794 static vector_int const view_array( ARRAY const& v, size_t n=0 ){
1795 if(n > v.size())
1796 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1797 if(0 == n)
1798 n = v.size();
1799 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1800 *w = gsl_vector_int_const_view_array( v.data(), n ).vector;
1801 return vector_int( w );
1802 }
1803#endif //DOXYGEN_SKIP
1804
1805#ifndef DOXYGEN_SKIP
1813 template<typename ARRAY>
1814 static vector_int const view_array_with_stride( ARRAY const& base, size_t stride, size_t n ){
1815 if(0 == n)
1816 n = base.size()/stride;
1817 if((n-1)*stride > base.size())
1818 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1819 gsl_vector_int* w = static_cast<gsl_vector_int*>( malloc( sizeof( gsl_vector_int ) ) );
1820 *w = gsl_vector_int_const_view_array_with_stride( base.data(), stride, n ).vector;
1821 return vector_int( w );
1822 }
1823#endif //DOXYGEN_SKIP
1824
1825 // Extra allocators from matrix_int objects. The definition must come after matrix_int.
1832 static vector_int alloc_row_from_matrix( matrix_int& m, size_t const i );
1839 static vector_int alloc_col_from_matrix( matrix_int& m, size_t const j );
1840 };
1841
1848 inline vector_int::iterator operator+
1849 ( vector_int::iterator::difference_type const n, vector_int::iterator const& i ){ return i + n; }
1850
1859
1868 return i + n; }
1869
1878 return i + n; }
1879
1880}
1881#endif
This class handles vector_ints as shared handles.
Definition: block_int.hpp:41
@ GSL_EDOM
input domain error, e.g sqrt(-1)
Definition: exception.hpp:472
@ GSL_EFAILED
generic failure
Definition: exception.hpp:476
@ GSL_EINVAL
invalid argument supplied by user
Definition: exception.hpp:475
@ GSL_EBADLEN
matrix, vector lengths are not conformant
Definition: exception.hpp:490
@ GSL_EFAULT
invalid pointer
Definition: exception.hpp:474
This class handles matrix_int objects as shared handles.
Definition: matrix_int.hpp:57
A class template for the const iterators.
Definition: vector_int.hpp:836
const_iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
Definition: vector_int.hpp:863
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
const_iterator_t< reverse_t > & operator=(const_iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
Definition: vector_int.hpp:844
bool operator!=(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
Definition: vector_int.hpp:993
bool operator<(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
bool operator==(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
Definition: vector_int.hpp:985
const_iterator_t()
The default constructor.
Definition: vector_int.hpp:971
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
Definition: vector_int.hpp:943
const_iterator_t< reverse_t > operator--(int)
The postfix – operator.
Definition: vector_int.hpp:883
const_iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
Definition: vector_int.hpp:900
const_iterator_t< reverse_t > & operator++()
The prefix ++ operator.
Definition: vector_int.hpp:855
const_iterator_t(iterator_t< reverse_t > const &i)
A copy constructor.
Definition: vector_int.hpp:976
const_iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
Definition: vector_int.hpp:933
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
Definition: vector_int.hpp:951
const_iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
Definition: vector_int.hpp:910
const_iterator_t(vector_int const *v, difference_type position)
This constructor allows vector_int to create non-default iterators.
bool operator==(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
const_iterator_t< reverse_t > & operator--()
The prefix – operator.
Definition: vector_int.hpp:875
const_iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
Definition: vector_int.hpp:921
iterator_base< vector_intconst, int, reverse_t >::difference_type difference_type
Difference type.
Definition: vector_int.hpp:893
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
The container must have iterator types.
Definition: vector_int.hpp:404
bool operator!=(iterator_base< container, content, reverse_t > const &i) const
The != operator.
Definition: vector_int.hpp:551
iterator_base(container *v, difference_type position)
This constructor allows vector_int to create non-default iterators.
Definition: vector_int.hpp:634
std::random_access_iterator_tag iterator_category
An iterator must have an iterator category.
Definition: vector_int.hpp:410
reference operator*() const
Dereference the pointer.
Definition: vector_int.hpp:434
ptrdiff_t difference_type
An iterator must have a difference_type.
Definition: vector_int.hpp:427
pointer operator->() const
Dereference the pointer.
Definition: vector_int.hpp:462
container * v
Store a pointer to a vector_int we can iterate over: 0 if no vector_int.
Definition: vector_int.hpp:639
bool operator==(iterator_base< container, content, reverse_t > const &i) const
The == operator.
Definition: vector_int.hpp:543
void shift(difference_type const n)
Shift iterator n places.
Definition: vector_int.hpp:614
void decrement()
Decrement the iterator.
Definition: vector_int.hpp:597
value_type & reference
An iterator must have a reference type.
Definition: vector_int.hpp:422
value_type * pointer
An iterator must have a pointer typea.
Definition: vector_int.hpp:418
reference operator[](difference_type const n) const
Get element at i + n by reference ([] operator).
Definition: vector_int.hpp:489
int value_type
An iterator must have a value type.
Definition: vector_int.hpp:414
void increment()
Increment the iterator.
Definition: vector_int.hpp:580
bool operator<(iterator_base< container, content, reverse_t > const &i) const
The < operator is used to compare iterators.
Definition: vector_int.hpp:561
difference_type operator-(iterator_base< container, content, reverse_t > const &i) const
The - operator: find distance between two iterators.
Definition: vector_int.hpp:519
difference_type position
Mark position of iterator within vector_int.
Definition: vector_int.hpp:643
iterator_base()
The iterator is default constructible.
Definition: vector_int.hpp:628
A class template for the two non-const iterators.
Definition: vector_int.hpp:650
iterator_t(vector_int *v, difference_type position)
This constructor allows vector_int to create non-default iterators.
Definition: vector_int.hpp:829
bool operator==(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
Definition: vector_int.hpp:787
iterator_t()
The default constructor.
Definition: vector_int.hpp:820
iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
Definition: vector_int.hpp:714
iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
Definition: vector_int.hpp:747
iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
Definition: vector_int.hpp:735
iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
Definition: vector_int.hpp:677
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
Definition: vector_int.hpp:803
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
Definition: vector_int.hpp:757
iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
Definition: vector_int.hpp:724
iterator_t< reverse_t > & operator--()
The prefix – operator.
Definition: vector_int.hpp:689
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
Definition: vector_int.hpp:765
iterator_base< vector_int, int, reverse_t >::difference_type difference_type
Difference type.
Definition: vector_int.hpp:707
iterator_t< reverse_t > operator--(int)
The postfix – operator.
Definition: vector_int.hpp:697
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
Definition: vector_int.hpp:795
iterator_t< reverse_t > & operator=(iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
Definition: vector_int.hpp:658
iterator_t< reverse_t > & operator++()
The prefix ++ operator.
Definition: vector_int.hpp:669
This class handles vector_int objects as shared handles.
Definition: vector_int.hpp:45
int div(vector_int const &b)
C++ version of gsl_vector_int_div().
size_t use_count() const
Find how many vector_int objects share this pointer.
vector_int(vector_int const &v)
The copy constructor.
Definition: vector_int.hpp:131
void wrap_gsl_vector_int_without_ownership(gsl_vector_int *v)
This function is intended mainly for internal use.
Definition: vector_int.hpp:228
int add(vector_int const &b)
C++ version of gsl_vector_int_add().
void reset()
Stop sharing ownership of the shared pointer.
Definition: vector_int.hpp:263
static vector_int alloc_row_from_matrix(matrix_int &m, size_t const i)
C++ version of gsl_vector_int_alloc_row_from_matrix().
const_iterator_t< false > const_iterator
The const_iterator type.
static vector_int calloc(size_t const n)
C++ version of gsl_vector_int_calloc().
static vector_int const const_view_array_with_stride(ARRAY const &base, size_t stride, size_t n=0)
C++ version of gsl_vector_int_const_view_array_with_stride().
~vector_int()
The destructor only deletes the pointers if count reaches zero.
Definition: vector_int.hpp:209
vector_int(size_t const n)
The default constructor creates a new vector_int with n elements.
Definition: vector_int.hpp:61
int memcpy(vector_int const &src)
C++ version of gsl_vector_int_memcpy().
const_iterator end() const
Get iterator pointing beyond last vector_int element.
const_reverse_iterator rbegin() const
Get iterator pointing to first vector_int element.
vector_int()
The default constructor is only really useful for assigning to.
Definition: vector_int.hpp:50
vector_int clone() const
The clone function.
Definition: vector_int.hpp:198
void minmax(int &min_out, int &max_out) const
C++ version of gsl_vector_int_minmax().
int fscanf(FILE *stream)
C++ version of gsl_vector_int_fscanf().
int & operator[](size_t const n)
Get element at position n by reference ([] operator).
reverse_iterator rbegin()
Get iterator pointing to first vector_int element.
iterator begin()
Get iterator pointing to first vector_int element.
static vector_int const const_view_array(ARRAY const &v, size_t n=0)
C++ version of gsl_vector_int _const_view_array().
vector_int(vector_int &v)
The copy constructor.
Definition: vector_int.hpp:139
int sum(vector_int const &a) const
C++ version of gsl_vector_int_sum().
void set(size_t const i, int x)
C++ version of gsl_vector_int_set().
int fprintf(FILE *stream, char const *format) const
C++ version of gsl_vector_int_fprintf().
void set_zero()
C++ version of gsl_vector_int_set_zero().
void swap(vector_int &v)
Swap two vector_int objects.
vector_int & operator=(vector_int &&v)
Move operator.
Definition: vector_int.hpp:279
int add_constant(int const x)
C++ version of gsl_vector_int_add_constant().
bool operator==(vector_int const &v) const
Two vector_int objects are identically equal if their elements are identical.
Definition: vector_int.hpp:248
bool operator>=(vector_int const &v) const
A container needs to define an ordering for sorting.
Definition: vector_int.hpp:369
int * data()
Give access to the data block_int.
vector_int const const_subvector(size_t i, size_t n) const
C++ version of gsl_vector_int_const_subvector().
vector_int & operator=(vector_int const &v)
The assignment operator.
Definition: vector_int.hpp:148
int fread(FILE *stream)
C++ version of gsl_vector_int_fread().
int isneg() const
C++ version of gsl_vector_int_isneg().
value_type & reference
A container must have a reference type.
Definition: vector_int.hpp:382
vector_int(V &v, size_t const stride=1)
Construct from an object that implements data() and size().
Definition: vector_int.hpp:175
iterator_t< false > iterator
The iterator type.
gsl_vector_int * ccgsl_pointer
The shared pointer.
bool operator!=(vector_int const &v) const
Two vector_int objects are different equal if their elements are not identical.
Definition: vector_int.hpp:291
int scale(int const x)
C++ version of gsl_vector_int_scale().
int get(size_t const i) const
C++ version of gsl_vector_int_get().
bool unique() const
Find if this is the only object sharing the gsl_vector_int.
const_iterator::difference_type difference_type
A container must have a difference_type.
bool empty() const
Find if the vector_int is empty.
static vector_int view_array_with_stride(ARRAY &base, size_t stride, size_t n=0)
C++ version of gsl_vector_int_view_array_with_stride().
iterator end()
Get iterator pointing beyond last vector_int element.
vector_int(vector_int &v, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_int_alloc_from_vector().
vector_int(vector_int &&v)
Move constructor.
Definition: vector_int.hpp:269
static vector_int view_array(int *v, size_t n)
C++ version of gsl_vector_int_view_array().
value_type * pointer
A container must have a pointer type.
Definition: vector_int.hpp:392
const_reverse_iterator rend() const
Get iterator pointing beyond last vector_int element.
int sub(vector_int const &b)
C++ version of gsl_vector_int_sub().
int isnonneg() const
C++ version of gsl_vector_int_isnonneg().
size_t max_index() const
C++ version of gsl_vector_int_max_index().
const_iterator begin() const
Get iterator pointing to first vector_int element.
static vector_int const const_view_array(int const *v, size_t n)
C++ version of gsl_vector_int _const_view_array().
int ispos() const
C++ version of gsl_vector_int_ispos().
int const & operator[](size_t const n) const
Get element at position n by reference ([] operator).
const_iterator_t< true > const_reverse_iterator
The const_reverse_t type.
vector_int(block_int &b, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_int_alloc_from_block().
vector_int subvector(size_t i, size_t n)
C++ version of gsl_vector_int_subvector().
int max() const
C++ version of gsl_vector_int_max().
int min() const
C++ version of gsl_vector_int_min().
int value_type
A container must have a value_type.
Definition: vector_int.hpp:377
static vector_int view_array_with_stride(int *base, size_t stride, size_t n)
C++ version of gsl_vector_int_view_array_with_stride().
bool operator<(vector_int const &v) const
A container needs to define an ordering for sorting.
Definition: vector_int.hpp:303
size_type size() const
The size (number of elements) of the vector_int.
int set_basis(size_t i)
C++ version of gsl_vector_int_set_basis().
void minmax_index(size_t *imin, size_t *imax) const
C++ version of gsl_vector_int_minmax_index().
bool operator>(vector_int const &v) const
A container needs to define an ordering for sorting.
Definition: vector_int.hpp:330
int mul(vector_int const &b)
C++ version of gsl_vector_int_mul().
bool owns_data
Used to allow a vector that does not own its data.
int axpby(int const alpha, vector_int const &x, int const beta)
C++ version of gsl_vector_int_axpby().
size_t min_index() const
C++ version of gsl_vector_int_min_index().
iterator_t< true > reverse_iterator
The reverse_iterator type.
void minmax(int *min_out, int *max_out) const
C++ version of gsl_vector_int_minmax().
vector_int const const_subvector_with_stride(size_t i, size_t stride, size_t n) const
C++ version of gsl_vector_int_const_subvector_with_stride().
int swap_elements(size_t const i, size_t const j)
C++ version of gsl_vector_int_swap_elements().
static vector_int alloc_col_from_matrix(matrix_int &m, size_t const j)
C++ version of gsl_vector_int_alloc_col_from_matrix().
gsl_vector_int const * get() const
Get the gsl_vector_int.
static vector_int view_array(ARRAY &v, size_t n=0)
C++ version of gsl_vector_int_view_array().
vector_int subvector_with_stride(size_t i, size_t stride, size_t n)
C++ version of gsl_vector_int_subvector_with_stride().
int * ptr(size_t const i)
C++ version of gsl_vector_int_ptr().
int reverse()
C++ version of gsl_vector_int_reverse().
vector_int(std::initializer_list< int > initializer_list)
Could construct from a std::initializer_list in C++11.
Definition: vector_int.hpp:110
reverse_iterator rend()
Get iterator pointing beyond last vector_int element.
int const * const_ptr(size_t const i) const
C++ version of gsl_vector_int_const_ptr().
int isnull() const
C++ version of gsl_vector_int_isnull().
void set_all(int x)
C++ version of gsl_vector_int_set_all().
static vector_int const const_view_array_with_stride(int const *base, size_t stride, size_t n)
C++ version of gsl_vector_int_const_view_array_with_stride().
int fwrite(FILE *stream) const
C++ version of gsl_vector_int_fwrite().
int const * data() const
Give access to the data block_int.
value_type const & const_reference
A container must have a constant reference type.
Definition: vector_int.hpp:387
bool operator<=(vector_int const &v) const
A container needs to define an ordering for sorting.
Definition: vector_int.hpp:357
value_type const * const_pointer
A container must have a constant pointer type.
Definition: vector_int.hpp:397
size_t * count
The shared reference count.
gsl_vector_int * get()
Get the gsl_vector_int.
size_type max_size() const
The max size (number of elements) of the vector_int.
size_t size_type
A container must have a size_type.
gsl_vector * ccgsl_pointer
The shared pointer.
Definition: vector.hpp:1309
size_t size(series const &cs)
C++ version of gsl_cheb_size().
Definition: chebyshev.hpp:287
int min(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_min().
Definition: movstat.hpp:581
vector position(workspace const &w)
C++ version of gsl_multifit_nlinear_position().
double beta(rng const &r, double const a, double const b)
C++ version of gsl_ran_beta().
Definition: randist.hpp:262
double get(quantile_workspace &w)
C++ version of gsl_rstat_quantile_get().
Definition: rstat.hpp:626
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
Definition: rstat.hpp:299
double b(int order, double qq)
C++ version of gsl_sf_mathieu_b().
Definition: sf_mathieu.hpp:298
double a(int order, double qq)
C++ version of gsl_sf_mathieu_a().
Definition: sf_mathieu.hpp:272
gsl_sf_result result
Typedef for gsl_sf_result.
Definition: sf_result.hpp:30
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34