ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
vector_uchar.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_UCHAR_HPP
20#define CCGSL_VECTOR_UCHAR_HPP
21
22#include<gsl/gsl_vector_uchar.h>
23#include<new>
24#include<iterator>
25
26#include"exception.hpp"
27#include"block_uchar.hpp"
28
29// This file is autogenerated
30
31namespace gsl {
32 // declare matrix_uchar class
33 class matrix_uchar;
46 public:
51 ccgsl_pointer = 0;
52 count = 0; // initially nullptr will do
53 }
54 // Refines random access container
55 // Refines assignable
60 explicit vector_uchar( size_t const n ) : owns_data(true){
61 if( n > 0 ) ccgsl_pointer = gsl_vector_uchar_alloc( n );
62 else { ccgsl_pointer = new gsl_vector_uchar; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
63 // just plausibly we could allocate vector_uchar but not count
64 try { count = new size_t; } catch( std::bad_alloc& e ){
65 // try to tidy up before rethrowing
66 if( n > 0 ) gsl_vector_uchar_free( ccgsl_pointer );
67 else delete ccgsl_pointer;
68 throw e;
69 }
70 *count = 1; // initially there is just one reference to ccgsl_pointer
71 }
72#ifndef DOXYGEN_SKIP
77 explicit vector_uchar( int const n ) : owns_data(true){
78 if( n > 0 ) ccgsl_pointer = gsl_vector_uchar_alloc( static_cast<size_t>( n ) );
79 else if(n<0)
80 gsl_error("failed tring to make a vector of negative length",
81 __FILE__, __LINE__, exception::GSL_EDOM );
82 else { ccgsl_pointer = new gsl_vector_uchar; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
83 // just plausibly we could allocate vector_uchar but not count
84 try { count = new size_t; } catch( std::bad_alloc& e ){
85 // try to tidy up before rethrowing
86 if( n > 0 ) gsl_vector_uchar_free( ccgsl_pointer );
87 else delete ccgsl_pointer;
88 throw e;
89 }
90 *count = 1; // initially there is just one reference to ccgsl_pointer
91 }
92#endif // DOXYGEN_SKIP
98 explicit vector_uchar( gsl_vector_uchar* v ) : owns_data(true){
99 ccgsl_pointer = v;
100 // just plausibly we could fail to allocate count: no further action needed.
101 count = new size_t;
102 *count = 1; // initially there is just one reference to ccgsl_pointer
103 }
104#ifdef __GXX_EXPERIMENTAL_CXX0X__
109 vector_uchar( std::initializer_list<unsigned char> initializer_list ) : owns_data(true){
110 size_t const n = initializer_list.size();
111 ccgsl_pointer = gsl_vector_uchar_alloc( n );
112 // just plausibly we could allocate vector_uchar but not count
113 try { count = new size_t; } catch( std::bad_alloc& e ){
114 // try to tidy up before rethrowing
115 if( n > 0 ) gsl_vector_uchar_free( ccgsl_pointer );
116 else delete ccgsl_pointer;
117 throw e;
118 }
119 *count = 1; // initially there is just one reference to ccgsl_pointer
120 // now copy
121 auto p = begin();
122 for( auto x : initializer_list ){ *p = x; ++p; }
123 }
124#endif
125 // copy constructor
130 vector_uchar( vector_uchar const& v ) : owns_data( v.owns_data ), ccgsl_pointer( v.ccgsl_pointer ), count( v.count ){
131 if( count != 0 ) ++*count; // vector_uchar is now shared.
132 }
137 vector_uchar( vector_uchar& v ) : owns_data( v.owns_data ),
138 ccgsl_pointer( v.ccgsl_pointer ), count( v.count ){
139 if( count != 0 ) ++*count; // vector_uchar is now shared.
140 }
141 // assignment operator
147 // first, possibly delete anything pointed to by @c this
148 if( count == 0 or --*count == 0 ){
149 if( ccgsl_pointer != 0 ){
150 if( ccgsl_pointer->size > 0 ) gsl_vector_uchar_free( ccgsl_pointer );
151 else delete ccgsl_pointer; }
152 delete count;
153 }
154 // Then copy
155 owns_data = v.owns_data;
156 ccgsl_pointer = v.ccgsl_pointer;
157 count = v.count;
158 if( count != 0 ) ++*count; // block_uchar is now shared.
159 return *this;
160 }
173 template<typename V> vector_uchar( V& v, size_t const stride = 1 ) : owns_data(true){
174 size_t const n = v.size() / stride;
175 ccgsl_pointer = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
176 ccgsl_pointer->size = n;
177 ccgsl_pointer->stride = stride;
178 ccgsl_pointer->data = v.data();
179 ccgsl_pointer->block = 0;
180 ccgsl_pointer->owner = 0;
181 // just plausibly we could allocate vector_uchar but not count
182 try { count = new size_t; } catch( std::bad_alloc& e ){
183 // try to tidy up before rethrowing
184 if( n > 0 ) gsl_vector_uchar_free( ccgsl_pointer );
185 else delete ccgsl_pointer;
186 throw e;
187 }
188 *count = 1; // initially there is just one reference to ccgsl_pointer
189 }
190 // clone()
197 vector_uchar copy( get()->size );
198 // Now copy
199 gsl_vector_uchar_memcpy( copy.get(), get() );
200 // return new object
201 return copy;
202 }
203 // destructor
208 if( count != 0 and --*count == 0 ){
209 // could have allocated null pointer
210 if( ccgsl_pointer != 0 and owns_data ){
211 if( ccgsl_pointer->size > 0 ) gsl_vector_uchar_free( ccgsl_pointer );
212 else delete ccgsl_pointer; }
213 delete count;
214 }
215 }
216
217 // Allow possibility of assigning from gsl_vector_uchar without sharing
226 void wrap_gsl_vector_uchar_without_ownership( gsl_vector_uchar* v ){
227 if( count != 0 and --*count == 0 ){
228 // could have allocated null pointer
229 if( ccgsl_pointer != 0 ){
230 if( ccgsl_pointer->size != 0 ) gsl_vector_uchar_free( ccgsl_pointer );
231 else delete ccgsl_pointer; }
232 }
233 ccgsl_pointer = v;
234 if(0 == count) count = new size_t;
235 *count = 1;
236 owns_data = false; // should never be able to delete ccgsl_pointer
237 }
238 // Refines equality comparable
239 // == operator
246 bool operator==( vector_uchar const& v ) const {
247 // trivially equal if gsl_vector_uchar*s are identical
248 if( ccgsl_pointer == v.ccgsl_pointer ) return true;
249 // trivially not equal if one is zero: != should be same as xor here
250 if( (ccgsl_pointer == 0) != (v.ccgsl_pointer == 0 ) ) return false;
251 // trivially not equal if sizes are different
252 if( ccgsl_pointer->size != v.ccgsl_pointer->size ) return false;
253 // check elementwise for equality
254 for( size_t i = 0; i < ccgsl_pointer->size; ++i )
255 if( gsl_vector_uchar_get( ccgsl_pointer, i ) != gsl_vector_uchar_get( v.ccgsl_pointer, i ) ) return false;
256 return true;
257 }
261 void reset(){ vector_uchar().swap( *this ); }
262#ifdef __GXX_EXPERIMENTAL_CXX0X__
267 vector_uchar( vector_uchar&& v ) : owns_data( v.owns_data ), ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
268 std::swap( count, v.count );
269 v.ccgsl_pointer = nullptr;
270 }
277 vector_uchar( std::move( v ) ).swap( *this );
278 return *this;
279 }
280#endif
281 // != operator
288 bool operator!=( vector_uchar const& v ) const { return not operator==( v ); }
289 // Refines forward container
290 // Refines less than comparable
291 // operator<
300 bool operator<( vector_uchar const& v ) const {
301 // null vector_uchar comes first
302 if( ccgsl_pointer == 0 ) return v.ccgsl_pointer != 0;
303 // if v is null then this > v
304 if( v.ccgsl_pointer == 0 ) return false;
305 // Now compare elementwise
306 size_t const size = ccgsl_pointer->size;
307 size_t const v_size = v.ccgsl_pointer->size;
308 size_t const min = size > v_size ? size : v_size;
309 for( size_t i = 0; i < min; ++i ){
310 unsigned char const t = gsl_vector_uchar_get( ccgsl_pointer, i );
311 unsigned char const u =gsl_vector_uchar_get( v.ccgsl_pointer, i );
312 if( t < u ) return true;
313 if( u < t ) return false;
314 }
315 // elements match.
316 return size < v_size;
317 }
318 // operator>
327 bool operator>( vector_uchar const& v ) const {
328 // null vector_uchar comes first
329 if( ccgsl_pointer == 0 ) return false;
330 // if v is null then this > v
331 if( v.ccgsl_pointer == 0 ) return true;
332 // Now compare elementwise
333 size_t const size = ccgsl_pointer->size;
334 size_t const v_size = v.ccgsl_pointer->size;
335 size_t const min = size > v_size ? size : v_size;
336 for( size_t i = 0; i < min; ++i ){
337 unsigned char const t = gsl_vector_uchar_get( ccgsl_pointer, i );
338 unsigned char const u =gsl_vector_uchar_get( v.ccgsl_pointer, i );
339 if( t > u ) return true;
340 if( u > t ) return false;
341 }
342 // elements match.
343 return size > v_size;
344 }
345 // operator<=
354 bool operator<=( vector_uchar const& v ) const {
355 return operator<( v ) or operator==( v );
356 }
357 // operator>=
366 bool operator>=( vector_uchar const& v ) const {
367 return operator>( v ) or operator==( v );
368 }
369 // Refines container
370 // type value_type
374 typedef unsigned char value_type;
375 // type reference
380 // type const_reference
385 // type pointer
390 // type const_pointer
394 typedef value_type const* const_pointer;
395 // type iterator
396 private:
401 template<typename container, typename content,bool reverse_t> class iterator_base {
402 friend class vector_uchar;
403 public:
407 typedef std::random_access_iterator_tag iterator_category;
411 typedef unsigned char value_type;
420 // // type iterator_traits<vector_uchar>::difference_type
424 typedef ptrdiff_t difference_type;
425 public:
426 // // operator*
432 // Always try to return something
433 static content something = 0;
434 // First check that iterator is initialised.
435 if( v == 0 ){
436 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
437 return something;
438 } else if( v->ccgsl_pointer == 0 ){
439 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
440 return something;
441 }
442 // Check that position make sense
443 if( position >= static_cast<difference_type>( v->size() ) ){
444 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
445 return something;
446 }
447 if( position <= -1 ){
448 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
449 return something;
450 }
451 // position and v are valid: return data
452 return *(v->ccgsl_pointer->data + position * v->ccgsl_pointer->stride);
453 }
454 // // operator->
460 // First check that iterator is initialised.
461 if( v == 0 ){
462 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
463 return 0;
464 } else if( v->ccgsl_pointer == 0 ){
465 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
466 return 0;
467 }
468 // Check that position make sense
469 if( position >= static_cast<difference_type>( v->size() ) ){
470 gsl_error( "trying to dereference end()", __FILE__, __LINE__, exception::GSL_EFAILED );
471 return 0;
472 }
473 if( position <= -1 ){
474 gsl_error( "trying to dereference rend()", __FILE__, __LINE__, exception::GSL_EFAILED );
475 return 0;
476 }
477 // position and v are valid: return data
478 return v->ccgsl_pointer->data + position * v->ccgsl_pointer->stride;
479 }
480 // // operator[]
487 // Always try to return something
488 static content something = 0;
489 // First check that iterator is initialised.
490 if( v == 0 ){
491 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
492 return something;
493 } else if( v->ccgsl_pointer == 0 ){
494 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
495 return something;
496 }
497 // Check that position make sense
498 difference_type const p = reverse_t ? position - n : position + n;
499 if( p >= static_cast<difference_type>( v->size() ) ){
500 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
501 return something;
502 }
503 if( p <= -1 ){
504 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
505 return something;
506 }
507 // p is a valid position
508 return *(v->ccgsl_pointer->data + p * v->ccgsl_pointer->stride);
509 }
510 // // operator-: find distance between two iterators
517 // Warn if either iterator undefined
518 if( v == 0 or i.v == 0 ){
519 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
520 return 0;
521 } else if( v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
522 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
523 return 0;
524 }
525 // Warn if iterators do not point to same vector_uchar
526 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
527 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
529 return 0;
530 }
531 return reverse_t ? i.position - position : position - i.position;
532 }
533 // // operator!=
534 // // operator<
541 return this->v == i.v and this->position == i.position;
542 }
549 return not this->operator==( i );
550 }
559 // Warn if either iterator undefined
560 if( v == 0 or i.v == 0 ){
561 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
562 return false;
563 }
564 // Warn if iterators do not point to same vector_uchar
565 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
566 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
568 return false;
569 }
570 return reverse_t ? i.position < position : position < i.position;
571 }
572 protected:
577 void increment(){
578 // Only makes sense if v points to a vector_uchar
579 if( v == 0 ){
580 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
581 return;
582 } else if( v->ccgsl_pointer == 0 ){
583 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
584 return;
585 }
586 // increment position and check against size
587 if( reverse_t ){ if( position >= 0 ) --position; }
588 else { if( position < static_cast<difference_type>( v->size() ) ) ++position; }
589 }
594 void decrement(){
595 // Only makes sense if v points to a vector_uchar
596 if( v == 0 ){
597 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
598 return;
599 } else if( v->ccgsl_pointer == 0 ){
600 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
601 return;
602 }
603 // decrement position and check against size
604 if( reverse_t ){ if( position < static_cast<difference_type>( v->size() ) ) ++position; }
605 else { if( position >= 0 ) --position; }
606 }
611 void shift( difference_type const n ){
612 // Warn if iterator undefined
613 if( v == 0 ){
614 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
615 return;
616 } else if( v->ccgsl_pointer == 0 ){
617 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
618 return;
619 }
620 position += reverse_t ? -n : n;
621 }
625 iterator_base(){ v = 0; }
632 : v( v ), position( position ){}
636 container* v;
641 };
642 // Need to know about const_iterator_t
643 template<bool reverse_t> class const_iterator_t;
647 template<bool reverse_t> class iterator_t : public iterator_base<vector_uchar,unsigned char,reverse_t>{
648 public:
649 // // Refines output iterator
650 // // operator=
658 return *this;
659 }
660 // // Refines forward iterator
661 // // operator++ (both)
668 return *this;
669 }
675 // return value
678 return result;
679 }
680 // // Refines bidirectional iterator
681 // // operator-- (both)
688 return *this;
689 }
695 // return value
698 return result;
699 }
705 // // operator+=
712 this->shift( n );
713 return *this;
714 }
715 // // operator-=
722 this->shift( -n );
723 return *this;
724 }
725 // // operator+ (n+i)(i+n)
734 result.shift( n );
735 return result;
736 }
737 // // operator- (n-i)(i-n)(i-j)
746 result.shift( -n );
747 return result;
748 }
756 }
763 // Warn if either iterator undefined
764 if( this->v == 0 or i.v == 0 ){
765 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
766 return 0;
767 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
768 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
769 return 0;
770 }
771 // Warn if iterators do not point to same vector_uchar
772 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
773 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
775 return 0;
776 }
777 return reverse_t ? i.position - this->position : this->position - i.position;
778 }
785 return this->v == i.v and this->position == i.position;
786 }
793 return not this->operator==( i );
794 }
800 bool operator<( const_iterator_t<reverse_t> const& i ) const {
801 // Warn if either iterator undefined
802 if( this->v == 0 or i.v == 0 ){
803 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
804 return false;
805 }
806 // Warn if iterators do not point to same vector_uchar
807 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
808 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
810 return false;
811 }
812 return reverse_t ? i.position < this->position : this->position < i.position;
813 }
817 iterator_t() : iterator_base<vector_uchar,unsigned char,reverse_t>(){}
818 protected:
819 friend class vector_uchar;
820 // We need a constructor for vector_uchar
827 : iterator_base<vector_uchar,unsigned char,reverse_t>( v, position ){}
828 };
832 template<bool reverse_t> class const_iterator_t
833 : public iterator_base<vector_uchar const,unsigned char,reverse_t>{
834 public:
835 // // Refines output iterator
836 // // operator=
844 return *this;
845 }
846 // // Refines forward iterator
847 // // operator++ (both)
854 return *this;
855 }
861 // return value
864 return result;
865 }
866 // // Refines bidirectional iterator
867 // // operator-- (both)
874 return *this;
875 }
881 // return value
884 return result;
885 }
891 // // operator+=
898 this->shift( n );
899 return *this;
900 }
901 // // operator-=
908 this->shift( -n );
909 return *this;
910 }
911 // // operator+ (n+i)(i+n)
920 result += n;
921 return result;
922 }
923 // // operator- (n-i)(i-n)(i-j)
932 result -= n;
933 return result;
934 }
942 }
949 // Warn if either iterator undefined
950 if( this->v == 0 or i.v == 0 ){
951 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
952 return 0;
953 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
954 gsl_error( "vector_uchar not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
955 return 0;
956 }
957 // Warn if iterators do not point to same vector_uchar
958 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
959 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
961 return 0;
962 }
963 return reverse_t ? i.position - this->position : this->position - i.position;
964 }
968 const_iterator_t() : iterator_base<vector_uchar,unsigned char,reverse_t>(){}
976 }
982 bool operator==( iterator_t<reverse_t> const& i ) const {
983 return this->v == i.v and this->position == i.position;
984 }
990 bool operator!=( iterator_t<reverse_t> const& i ) const {
991 return not this->operator==( i );
992 }
998 bool operator<( iterator_t<reverse_t> const& i ) const {
999 // Warn if either iterator undefined
1000 if( this->v == 0 or i.v == 0 ){
1001 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1002 return false;
1003 }
1004 // Warn if iterators do not point to same vector_uchar
1005 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1006 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
1008 return false;
1009 }
1010 return reverse_t ? i.position < this->position : this->position < i.position;
1011 }
1018 return this->v == i.v and this->position == i.position;
1019 }
1026 return not this->operator==( i );
1027 }
1034 // Warn if either iterator undefined
1035 if( this->v == 0 or i.v == 0 ){
1036 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1037 return false;
1038 }
1039 // Warn if iterators do not point to same vector_uchar
1040 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1041 gsl_error( "trying to take difference of iterators for different vector_uchar objects", __FILE__, __LINE__,
1043 return false;
1044 }
1045 return reverse_t ? i.position < this->position : this->position < i.position;
1046 }
1047 protected:
1048 // We need a constructor for vector_uchar
1049 friend class vector_uchar;
1056 : iterator_base<vector_uchar const,unsigned char,reverse_t>( v, position ){}
1057 };
1058 public:
1075 // type difference_type
1080 // type size_type
1084 typedef size_t size_type;
1085 // begin()
1091 return iterator( this, 0 );
1092 }
1098 return const_iterator( this, 0 );
1099 }
1100 // end()
1106 if( ccgsl_pointer == 0 ) return iterator( this, 0 );
1107 return iterator( this, size() );
1108 }
1114 if( ccgsl_pointer == 0 ) return const_iterator( this, 0 );
1115 return const_iterator( this, size() );
1116 }
1117 // size()
1122 size_type size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1130 unsigned char* data() {
1131 if( ccgsl_pointer == 0 ) gsl_error( "null vector_uchar", __FILE__, __LINE__, GSL_EFAULT );
1132#ifndef GSL_RANGE_CHECK_OFF
1133 if( ccgsl_pointer->stride != 1 )
1134 gsl_error( "vector_uchar does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1135#endif
1136 return ccgsl_pointer->data; }
1144 unsigned char const* data() const {
1145 if( ccgsl_pointer == 0 ) gsl_error( "null vector_uchar", __FILE__, __LINE__, GSL_EFAULT );
1146#ifndef GSL_RANGE_CHECK_OFF
1147 if( ccgsl_pointer->stride != 1 )
1148 gsl_error( "vector_uchar does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1149#endif
1150 return ccgsl_pointer->data; }
1151 // max_size()
1157 size_type max_size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1158 // empty()
1163 bool empty() const { return ccgsl_pointer == 0 or ccgsl_pointer->size == 0; }
1164 // swap() --- should work even if sizes don't match
1170 void swap( vector_uchar& v ){
1171 std::swap( ccgsl_pointer, v.ccgsl_pointer );
1172 std::swap( count, v.count );
1173 }
1174 // Refines reversible container
1175 // rbegin()
1181 if( ccgsl_pointer ==0 ) return reverse_iterator( this, 0 );
1182 return reverse_iterator( this, size() - 1 );
1183 }
1189 if( ccgsl_pointer ==0 ) return const_reverse_iterator( this, 0 );
1190 return const_reverse_iterator( this, size() - 1 );
1191 }
1192 // rend()
1198 return reverse_iterator( this, -1 );
1199 }
1205 return const_reverse_iterator( this, -1 );
1206 }
1207 // operator[]
1213 unsigned char& operator[]( size_t const n ){
1214 // Always try to return something
1215 static unsigned char something = 0;
1216 // First check that iterator is initialised.
1217 if( ccgsl_pointer == 0 ){
1218 gsl_error( "vector_uchar is null", __FILE__, __LINE__, exception::GSL_EFAULT );
1219 return something;
1220 }
1221#ifndef GSL_RANGE_CHECK_OFF
1222 // Check that position make sense
1223 if( n >= size() ){
1224 gsl_error( "trying to read beyond end of vector_uchar", __FILE__, __LINE__, exception::GSL_EINVAL );
1225 return something;
1226 }
1227 // n is a valid position
1228#endif
1229 return *(ccgsl_pointer->data + n * ccgsl_pointer->stride);
1230 }
1236 unsigned char const& operator[]( size_t const n ) const {
1237 // Always try to return something
1238 static unsigned char something = 0;
1239 // First check that iterator is initialised.
1240 if( ccgsl_pointer == 0 ){
1241 gsl_error( "vector_uchar is null", __FILE__, __LINE__, exception::GSL_EFAULT );
1242 return something;
1243 }
1244#ifndef GSL_RANGE_CHECK_OFF
1245 // Check that position make sense
1246 if( n >= size() ){
1247 gsl_error( "trying to read beyond end of vector_uchar", __FILE__, __LINE__, exception::GSL_EINVAL );
1248 return something;
1249 }
1250 // n is a valid position
1251#endif
1252 return *(ccgsl_pointer->data + n * ccgsl_pointer->stride);
1253 }
1254 private:
1262 gsl_vector_uchar* ccgsl_pointer;
1266 size_t* count;
1267 public:
1268 // shared reference functions
1273 gsl_vector_uchar* get() { return ccgsl_pointer; }
1278 gsl_vector_uchar const* get() const { return ccgsl_pointer; }
1284 bool unique() const { return count != 0 and *count == 1; }
1289 size_t use_count() const { return count == 0 ? 0 : *count; }
1295#ifdef __GXX_EXPERIMENTAL_CXX0X__
1296 explicit
1297#endif
1298 operator bool() const { return ccgsl_pointer != 0; }
1299
1300 // GSL functions
1307 static vector_uchar calloc( size_t const n ){ return vector_uchar( gsl_vector_uchar_calloc( n ) ); }
1311 void set_zero(){ gsl_vector_uchar_set_zero( get() ); }
1316 void set_all( unsigned char x ){ gsl_vector_uchar_set_all( get(), x ); }
1322 int set_basis( size_t i ){ return gsl_vector_uchar_set_basis( get(), i ); }
1328 int memcpy( vector_uchar const& src ){ return gsl_vector_uchar_memcpy( get(), src.get() ); }
1333 int reverse(){ return gsl_vector_uchar_reverse( get() ); }
1340 int swap_elements( size_t const i, size_t const j ){
1341 return gsl_vector_uchar_swap_elements( get(), i, j ); }
1346 unsigned char max() const { return gsl_vector_uchar_max( get() ); }
1351 unsigned char min() const { return gsl_vector_uchar_min( get() ); }
1357 void minmax( unsigned char* min_out, unsigned char* max_out ) const {
1358 gsl_vector_uchar_minmax( get(), min_out, max_out ); }
1364 void minmax( unsigned char& min_out, unsigned char& max_out ) const {
1365 gsl_vector_uchar_minmax( get(), &min_out, &max_out ); }
1370 size_t max_index() const { return gsl_vector_uchar_max_index( get() ); }
1375 size_t min_index() const { return gsl_vector_uchar_min_index( get() ); }
1381 void minmax_index( size_t* imin, size_t* imax ) const {
1382 gsl_vector_uchar_minmax_index( get(), imin, imax ); }
1388 int add( vector_uchar const& b ){ return gsl_vector_uchar_add( get(), b.get() ); }
1394 int sub( vector_uchar const& b ){ return gsl_vector_uchar_sub( get(), b.get() ); }
1400 int mul( vector_uchar const& b ){ return gsl_vector_uchar_mul( get(), b.get() ); }
1406 int div( vector_uchar const& b ){ return gsl_vector_uchar_div( get(), b.get() ); }
1412 int scale( unsigned char const x ){ return gsl_vector_uchar_scale( get(), x ); }
1418 int add_constant( unsigned char const x ){ return gsl_vector_uchar_add_constant( get(), x ); }
1426 int axpby( unsigned char const alpha, vector_uchar const& x,
1427 unsigned char const beta ){
1428 return gsl_vector_uchar_axpby( alpha, x.get(), beta, get() );
1429 }
1435 unsigned char sum( vector_uchar const& a ) const { return gsl_vector_uchar_sum( a.get() ); }
1440 int isnull() const { return gsl_vector_uchar_isnull( get() ); }
1445 int ispos() const { return gsl_vector_uchar_ispos( get() ); }
1450 int isneg() const { return gsl_vector_uchar_isneg( get() ); }
1455 int isnonneg() const { return gsl_vector_uchar_isnonneg( get() ); }
1461 unsigned char get( size_t const i ) const { return gsl_vector_uchar_get( get(), i ); }
1467 void set( size_t const i, unsigned char x ){ gsl_vector_uchar_set( get(), i, x ); }
1473 unsigned char* ptr( size_t const i ){ return gsl_vector_uchar_ptr( get(), i ); }
1479 unsigned char const* const_ptr( size_t const i ) const { return gsl_vector_uchar_const_ptr( get(), i ); }
1485 int fread( FILE* stream ){ return gsl_vector_uchar_fread( stream, get() ); }
1491 int fwrite( FILE* stream ) const { return gsl_vector_uchar_fwrite( stream, get() ); }
1497 int fscanf( FILE* stream ){ return gsl_vector_uchar_fscanf( stream, get() ); }
1504 int fprintf( FILE* stream, char const* format ) const {
1505 return gsl_vector_uchar_fprintf( stream, get(), format ); }
1513 vector_uchar( block_uchar& b, size_t const offset, size_t const n, size_t const stride = 1 ){
1514 ccgsl_pointer = gsl_vector_uchar_alloc_from_block( b.get(), offset, n, stride );
1515 // just plausibly we could allocate vector_uchar but not count
1516 try { count = new size_t; } catch( std::bad_alloc& e ){
1517 // try to tidy up before rethrowing
1518 gsl_vector_uchar_free( ccgsl_pointer );
1519 throw e;
1520 }
1521 *count = 1; // initially there is just one reference to ccgsl_pointer
1522 }
1530 vector_uchar( vector_uchar& v, size_t const offset, size_t const n, size_t const stride = 1 ){
1531 ccgsl_pointer = gsl_vector_uchar_alloc_from_vector( v.get(), offset, n, stride );
1532 // just plausibly we could allocate vector_uchar but not count
1533 try { count = new size_t; } catch( std::bad_alloc& e ){
1534 // try to tidy up before rethrowing
1535 gsl_vector_uchar_free( ccgsl_pointer );
1536 throw e;
1537 }
1538 *count = 1; // initially there is just one reference to ccgsl_pointer
1539 }
1546 static vector_uchar view_array( unsigned char* v, size_t n ){
1547 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1548 *w = gsl_vector_uchar_view_array( v, n ).vector;
1549 return vector_uchar( w );
1550 }
1551
1552
1560 static vector_uchar view_array_with_stride( unsigned char* base, size_t stride, size_t n ){
1561 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1562 *w = gsl_vector_uchar_view_array_with_stride( base, stride, n ).vector;
1563 return vector_uchar( w );
1564 }
1565
1566
1573 static vector_uchar const const_view_array( unsigned char const* v, size_t n ){
1574 gsl_vector_uchar* w = static_cast<gsl_vector_uchar *>( malloc( sizeof( gsl_vector_uchar ) ) );
1575 *w = gsl_vector_uchar_const_view_array( v, n ).vector;
1576 return vector_uchar( w );
1577 }
1578
1579
1587 static vector_uchar const const_view_array_with_stride( unsigned char const* base, size_t stride, size_t n ){
1588 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1589 *w = gsl_vector_uchar_const_view_array_with_stride( base, stride, n ).vector;
1590 return vector_uchar( w );
1591 }
1592
1593
1594#ifndef DOXYGEN_SKIP
1601 static vector_uchar const view_array( unsigned char const* v, size_t n ){
1602 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1603 *w = gsl_vector_uchar_const_view_array( v, n ).vector;
1604 return vector_uchar( w );
1605 }
1606#endif //DOXYGEN_SKIP
1607
1608
1609#ifndef DOXYGEN_SKIP
1617 static vector_uchar const view_array_with_stride( unsigned char const* base, size_t stride, size_t n ){
1618 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1619 *w = gsl_vector_uchar_const_view_array_with_stride( base, stride, n ).vector;
1620 return vector_uchar( w );
1621 }
1622#endif //DOXYGEN_SKIP
1623
1624
1631 vector_uchar subvector( size_t i, size_t n ){
1632 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1633 *w = gsl_vector_uchar_subvector( get(), i, n ).vector;
1634 return vector_uchar( w );
1635 }
1636
1637
1645 vector_uchar subvector_with_stride( size_t i, size_t stride, size_t n ){
1646 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1647 *w = gsl_vector_uchar_subvector_with_stride( get(), i, stride, n ).vector;
1648 return vector_uchar( w );
1649 }
1650
1651
1658 vector_uchar const const_subvector( size_t i, size_t n ) const {
1659 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1660 *w = gsl_vector_uchar_const_subvector( get(), i, n ).vector;
1661 return vector_uchar( w );
1662 }
1663
1664
1672 vector_uchar const const_subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1673 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1674 *w = gsl_vector_uchar_const_subvector_with_stride( get(), i, stride, n ).vector;
1675 return vector_uchar( w );
1676 }
1677
1678
1679#ifndef DOXYGEN_SKIP
1686 vector_uchar const subvector( size_t i, size_t n ) const {
1687 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1688 *w = gsl_vector_uchar_const_subvector( get(), i, n ).vector;
1689 return vector_uchar( w );
1690 }
1691#endif //DOXYGEN_SKIP
1692
1693
1694#ifndef DOXYGEN_SKIP
1702 vector_uchar const subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1703 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1704 *w = gsl_vector_uchar_const_subvector_with_stride( get(), i, stride, n ).vector;
1705 return vector_uchar( w );
1706 }
1707#endif //DOXYGEN_SKIP
1708
1709
1716 template<typename ARRAY>
1717 static vector_uchar view_array( ARRAY& v, size_t n = 0 ){
1718 if(n > v.size())
1719 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1720 if(0 == n)
1721 n = v.size();
1722 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1723 *w = gsl_vector_uchar_view_array( v.data(), n ).vector;
1724 return vector_uchar( w );
1725 }
1726
1727
1735 template<typename ARRAY>
1736 static vector_uchar view_array_with_stride( ARRAY& base, size_t stride, size_t n=0 ){
1737 if(0 == n)
1738 n = base.size()/stride;
1739 if((n-1)*stride > base.size())
1740 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1741 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1742 *w = gsl_vector_uchar_view_array_with_stride( base.data(), stride, n ).vector;
1743 return vector_uchar( w );
1744 }
1745
1746
1753 template<typename ARRAY>
1754 static vector_uchar const const_view_array( ARRAY const& v, size_t n=0 ){
1755 if(n > v.size())
1756 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1757 if(0 == n)
1758 n = v.size();
1759 gsl_vector_uchar* w = static_cast<gsl_vector_uchar *>( malloc( sizeof( gsl_vector_uchar ) ) );
1760 *w = gsl_vector_uchar_const_view_array( v.data(), n ).vector;
1761 return vector_uchar( w );
1762 }
1763
1764
1772 template<typename ARRAY>
1773 static vector_uchar const const_view_array_with_stride( ARRAY const& base, size_t stride, size_t n=0 ){
1774 if(0 == n)
1775 n = base.size()/stride;
1776 if((n-1)*stride > base.size())
1777 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1778 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1779 *w = gsl_vector_uchar_const_view_array_with_stride( base.data(), stride, n ).vector;
1780 return vector_uchar( w );
1781 }
1782
1783
1784#ifndef DOXYGEN_SKIP
1791 template<typename ARRAY>
1792 static vector_uchar const view_array( ARRAY const& v, size_t n=0 ){
1793 if(n > v.size())
1794 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1795 if(0 == n)
1796 n = v.size();
1797 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1798 *w = gsl_vector_uchar_const_view_array( v.data(), n ).vector;
1799 return vector_uchar( w );
1800 }
1801#endif //DOXYGEN_SKIP
1802
1803
1804#ifndef DOXYGEN_SKIP
1812 template<typename ARRAY>
1813 static vector_uchar const view_array_with_stride( ARRAY const& base, size_t stride, size_t n ){
1814 if(0 == n)
1815 n = base.size()/stride;
1816 if((n-1)*stride > base.size())
1817 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1818 gsl_vector_uchar* w = static_cast<gsl_vector_uchar*>( malloc( sizeof( gsl_vector_uchar ) ) );
1819 *w = gsl_vector_uchar_const_view_array_with_stride( base.data(), stride, n ).vector;
1820 return vector_uchar( w );
1821 }
1822#endif //DOXYGEN_SKIP
1823
1824 // Extra allocators from matrix_uchar objects. The definition must come after matrix_uchar.
1839 };
1840
1847 inline vector_uchar::iterator operator+
1848 ( vector_uchar::iterator::difference_type const n, vector_uchar::iterator const& i ){ return i + n; }
1849
1858
1867 return i + n; }
1868
1877 return i + n; }
1878
1879}
1880#endif
This class handles vector_uchars as shared handles.
Definition: block_uchar.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_uchar objects as shared handles.
A class template for the const iterators.
const_iterator_t< reverse_t > & operator=(const_iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
const_iterator_t< reverse_t > & operator--()
The prefix – operator.
const_iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
const_iterator_t< reverse_t > operator--(int)
The postfix – operator.
const_iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
bool operator==(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
const_iterator_t()
The default constructor.
const_iterator_t< reverse_t > & operator++()
The prefix ++ operator.
bool operator==(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
bool operator<(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
const_iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
bool operator!=(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
const_iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
const_iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
const_iterator_t(vector_uchar const *v, difference_type position)
This constructor allows vector_uchar to create non-default iterators.
iterator_base< vector_ucharconst, unsignedchar, reverse_t >::difference_type difference_type
Difference type.
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
const_iterator_t(iterator_t< reverse_t > const &i)
A copy constructor.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
The container must have iterator types.
iterator_base(container *v, difference_type position)
This constructor allows vector_uchar to create non-default iterators.
value_type & reference
An iterator must have a reference type.
reference operator[](difference_type const n) const
Get element at i + n by reference ([] operator).
reference operator*() const
Dereference the pointer.
unsigned char value_type
An iterator must have a value type.
value_type * pointer
An iterator must have a pointer typea.
bool operator<(iterator_base< container, content, reverse_t > const &i) const
The < operator is used to compare iterators.
iterator_base()
The iterator is default constructible.
pointer operator->() const
Dereference the pointer.
difference_type position
Mark position of iterator within vector_uchar.
container * v
Store a pointer to a vector_uchar we can iterate over: 0 if no vector_uchar.
void shift(difference_type const n)
Shift iterator n places.
std::random_access_iterator_tag iterator_category
An iterator must have an iterator category.
void decrement()
Decrement the iterator.
void increment()
Increment the iterator.
ptrdiff_t difference_type
An iterator must have a difference_type.
bool operator==(iterator_base< container, content, reverse_t > const &i) const
The == operator.
difference_type operator-(iterator_base< container, content, reverse_t > const &i) const
The - operator: find distance between two iterators.
bool operator!=(iterator_base< container, content, reverse_t > const &i) const
The != operator.
A class template for the two non-const iterators.
iterator_t< reverse_t > & operator=(iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
iterator_t< reverse_t > operator--(int)
The postfix – operator.
iterator_t()
The default constructor.
iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
iterator_t(vector_uchar *v, difference_type position)
This constructor allows vector_uchar to create non-default iterators.
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_t< reverse_t > & operator++()
The prefix ++ operator.
iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_base< vector_uchar, unsignedchar, reverse_t >::difference_type difference_type
Difference type.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
bool operator==(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
iterator_t< reverse_t > & operator--()
The prefix – operator.
This class handles vector_uchar objects as shared handles.
const_reverse_iterator rbegin() const
Get iterator pointing to first vector_uchar element.
static vector_uchar alloc_col_from_matrix(matrix_uchar &m, size_t const j)
C++ version of gsl_vector_uchar_alloc_col_from_matrix().
const_iterator end() const
Get iterator pointing beyond last vector_uchar element.
unsigned char const * data() const
Give access to the data block_uchar.
size_t size_type
A container must have a size_type.
void set(size_t const i, unsigned char x)
C++ version of gsl_vector_uchar_set().
unsigned char get(size_t const i) const
C++ version of gsl_vector_uchar_get().
void set_all(unsigned char x)
C++ version of gsl_vector_uchar_set_all().
bool operator>=(vector_uchar const &v) const
A container needs to define an ordering for sorting.
iterator_t< true > reverse_iterator
The reverse_iterator type.
vector_uchar()
The default constructor is only really useful for assigning to.
~vector_uchar()
The destructor only deletes the pointers if count reaches zero.
int fread(FILE *stream)
C++ version of gsl_vector_uchar_fread().
vector_uchar(V &v, size_t const stride=1)
Construct from an object that implements data() and size().
vector_uchar subvector_with_stride(size_t i, size_t stride, size_t n)
C++ version of gsl_vector_uchar_subvector_with_stride().
const_iterator_t< true > const_reverse_iterator
The const_reverse_t type.
int isnull() const
C++ version of gsl_vector_uchar_isnull().
int sub(vector_uchar const &b)
C++ version of gsl_vector_uchar_sub().
vector_uchar(vector_uchar const &v)
The copy constructor.
unsigned char value_type
A container must have a value_type.
void minmax(unsigned char *min_out, unsigned char *max_out) const
C++ version of gsl_vector_uchar_minmax().
size_t * count
The shared reference count.
vector_uchar & operator=(vector_uchar &&v)
Move operator.
void wrap_gsl_vector_uchar_without_ownership(gsl_vector_uchar *v)
This function is intended mainly for internal use.
size_type size() const
The size (number of elements) of the vector_uchar.
int isnonneg() const
C++ version of gsl_vector_uchar_isnonneg().
int scale(unsigned char const x)
C++ version of gsl_vector_uchar_scale().
static vector_uchar const const_view_array_with_stride(unsigned char const *base, size_t stride, size_t n)
C++ version of gsl_vector_uchar_const_view_array_with_stride().
iterator begin()
Get iterator pointing to first vector_uchar element.
size_t min_index() const
C++ version of gsl_vector_uchar_min_index().
static vector_uchar view_array(unsigned char *v, size_t n)
C++ version of gsl_vector_uchar_view_array().
bool operator!=(vector_uchar const &v) const
Two vector_uchar objects are different equal if their elements are not identical.
const_iterator_t< false > const_iterator
The const_iterator type.
reverse_iterator rend()
Get iterator pointing beyond last vector_uchar element.
void reset()
Stop sharing ownership of the shared pointer.
static vector_uchar const const_view_array(unsigned char const *v, size_t n)
C++ version of gsl_vector_uchar _const_view_array().
vector_uchar const const_subvector_with_stride(size_t i, size_t stride, size_t n) const
C++ version of gsl_vector_uchar_const_subvector_with_stride().
static vector_uchar alloc_row_from_matrix(matrix_uchar &m, size_t const i)
C++ version of gsl_vector_uchar_alloc_row_from_matrix().
vector_uchar clone() const
The clone function.
void minmax(unsigned char &min_out, unsigned char &max_out) const
C++ version of gsl_vector_uchar_minmax().
bool operator<(vector_uchar const &v) const
A container needs to define an ordering for sorting.
int mul(vector_uchar const &b)
C++ version of gsl_vector_uchar_mul().
int add(vector_uchar const &b)
C++ version of gsl_vector_uchar_add().
vector_uchar & operator=(vector_uchar const &v)
The assignment operator.
unsigned char const & operator[](size_t const n) const
Get element at position n by reference ([] operator).
static vector_uchar view_array(ARRAY &v, size_t n=0)
C++ version of gsl_vector_uchar_view_array().
void set_zero()
C++ version of gsl_vector_uchar_set_zero().
iterator end()
Get iterator pointing beyond last vector_uchar element.
void swap(vector_uchar &v)
Swap two vector_uchar objects.
bool owns_data
Used to allow a vector that does not own its data.
int swap_elements(size_t const i, size_t const j)
C++ version of gsl_vector_uchar_swap_elements().
bool operator<=(vector_uchar const &v) const
A container needs to define an ordering for sorting.
static vector_uchar const const_view_array_with_stride(ARRAY const &base, size_t stride, size_t n=0)
C++ version of gsl_vector_uchar_const_view_array_with_stride().
const_reverse_iterator rend() const
Get iterator pointing beyond last vector_uchar element.
reverse_iterator rbegin()
Get iterator pointing to first vector_uchar element.
unsigned char max() const
C++ version of gsl_vector_uchar_max().
int axpby(unsigned char const alpha, vector_uchar const &x, unsigned char const beta)
C++ version of gsl_vector_uchar_axpby().
const_iterator::difference_type difference_type
A container must have a difference_type.
vector_uchar const const_subvector(size_t i, size_t n) const
C++ version of gsl_vector_uchar_const_subvector().
bool unique() const
Find if this is the only object sharing the gsl_vector_uchar.
value_type * pointer
A container must have a pointer type.
vector_uchar(size_t const n)
The default constructor creates a new vector_uchar with n elements.
bool operator==(vector_uchar const &v) const
Two vector_uchar objects are identically equal if their elements are identical.
size_t max_index() const
C++ version of gsl_vector_uchar_max_index().
int ispos() const
C++ version of gsl_vector_uchar_ispos().
static vector_uchar const const_view_array(ARRAY const &v, size_t n=0)
C++ version of gsl_vector_uchar _const_view_array().
vector_uchar subvector(size_t i, size_t n)
C++ version of gsl_vector_uchar_subvector().
size_t use_count() const
Find how many vector_uchar objects share this pointer.
unsigned char * data()
Give access to the data block_uchar.
vector_uchar(vector_uchar &v, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_uchar_alloc_from_vector().
bool empty() const
Find if the vector_uchar is empty.
int set_basis(size_t i)
C++ version of gsl_vector_uchar_set_basis().
int fscanf(FILE *stream)
C++ version of gsl_vector_uchar_fscanf().
int fwrite(FILE *stream) const
C++ version of gsl_vector_uchar_fwrite().
int memcpy(vector_uchar const &src)
C++ version of gsl_vector_uchar_memcpy().
vector_uchar(block_uchar &b, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_uchar_alloc_from_block().
vector_uchar(std::initializer_list< unsigned char > initializer_list)
Could construct from a std::initializer_list in C++11.
int div(vector_uchar const &b)
C++ version of gsl_vector_uchar_div().
size_type max_size() const
The max size (number of elements) of the vector_uchar.
gsl_vector_uchar * get()
Get the gsl_vector_uchar.
static vector_uchar view_array_with_stride(unsigned char *base, size_t stride, size_t n)
C++ version of gsl_vector_uchar_view_array_with_stride().
gsl_vector_uchar * ccgsl_pointer
The shared pointer.
vector_uchar(vector_uchar &v)
The copy constructor.
const_iterator begin() const
Get iterator pointing to first vector_uchar element.
iterator_t< false > iterator
The iterator type.
int isneg() const
C++ version of gsl_vector_uchar_isneg().
static vector_uchar calloc(size_t const n)
C++ version of gsl_vector_uchar_calloc().
unsigned char * ptr(size_t const i)
C++ version of gsl_vector_uchar_ptr().
static vector_uchar view_array_with_stride(ARRAY &base, size_t stride, size_t n=0)
C++ version of gsl_vector_uchar_view_array_with_stride().
bool operator>(vector_uchar const &v) const
A container needs to define an ordering for sorting.
unsigned char const * const_ptr(size_t const i) const
C++ version of gsl_vector_uchar_const_ptr().
unsigned char sum(vector_uchar const &a) const
C++ version of gsl_vector_uchar_sum().
value_type & reference
A container must have a reference type.
int add_constant(unsigned char const x)
C++ version of gsl_vector_uchar_add_constant().
gsl_vector_uchar const * get() const
Get the gsl_vector_uchar.
int fprintf(FILE *stream, char const *format) const
C++ version of gsl_vector_uchar_fprintf().
void minmax_index(size_t *imin, size_t *imax) const
C++ version of gsl_vector_uchar_minmax_index().
vector_uchar(vector_uchar &&v)
Move constructor.
unsigned char min() const
C++ version of gsl_vector_uchar_min().
int reverse()
C++ version of gsl_vector_uchar_reverse().
value_type const & const_reference
A container must have a constant reference type.
unsigned char & operator[](size_t const n)
Get element at position n by reference ([] operator).
value_type const * const_pointer
A container must have a constant pointer 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