ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
vector_short.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_SHORT_HPP
20#define CCGSL_VECTOR_SHORT_HPP
21
22#include<gsl/gsl_vector_short.h>
23#include<new>
24#include<iterator>
25
26#include"exception.hpp"
27#include"block_short.hpp"
28
29// This file is autogenerated
30
31namespace gsl {
32 // declare matrix_short class
33 class matrix_short;
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_short( size_t const n ) : owns_data(true){
62 if( n > 0 ) ccgsl_pointer = gsl_vector_short_alloc( n );
63 else { ccgsl_pointer = new gsl_vector_short; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
64 // just plausibly we could allocate vector_short 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_short_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_short( int const n ) : owns_data(true){
79 if( n > 0 ) ccgsl_pointer = gsl_vector_short_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_short; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
84 // just plausibly we could allocate vector_short 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_short_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_short( gsl_vector_short* 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_short( std::initializer_list<short> initializer_list ) : owns_data(true){
111 size_t const n = initializer_list.size();
112 ccgsl_pointer = gsl_vector_short_alloc( n );
113 // just plausibly we could allocate vector_short 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_short_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_short( vector_short const& v ) : owns_data( v.owns_data ),
132 ccgsl_pointer( v.ccgsl_pointer ), count( v.count ){
133 if( count != 0 ) ++*count; // vector_short is now shared.
134 }
139 vector_short( vector_short& v ) : owns_data( v.owns_data ),
140 ccgsl_pointer( v.ccgsl_pointer ), count( v.count ){
141 if( count != 0 ) ++*count; // vector_short 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_short_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_short is now shared.
161 return *this;
162 }
175 template<typename V> vector_short( 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_short*>( malloc( sizeof( gsl_vector_short ) ) );
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_short 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_short_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_short copy( get()->size );
200 // Now copy
201 gsl_vector_short_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_short_free( ccgsl_pointer );
214 else delete ccgsl_pointer; }
215 delete count;
216 }
217 }
218
219 // Allow possibility of assigning from gsl_vector_short without sharing
228 void wrap_gsl_vector_short_without_ownership( gsl_vector_short* 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_short_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_short const& v ) const {
249 // trivially equal if gsl_vector_short*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_short_get( ccgsl_pointer, i ) != gsl_vector_short_get( v.ccgsl_pointer, i ) ) return false;
258 return true;
259 }
263 void reset(){ vector_short().swap( *this ); }
264#ifdef __GXX_EXPERIMENTAL_CXX0X__
269 vector_short( vector_short&& 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_short( std::move( v ) ).swap( *this );
281 return *this;
282 }
283#endif
284 // != operator
291 bool operator!=( vector_short const& v ) const { return not operator==( v ); }
292 // Refines forward container
293 // Refines less than comparable
294 // operator<
303 bool operator<( vector_short const& v ) const {
304 // null vector_short 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 short const t = gsl_vector_short_get( ccgsl_pointer, i );
314 short const u =gsl_vector_short_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_short const& v ) const {
331 // null vector_short 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 short const t = gsl_vector_short_get( ccgsl_pointer, i );
341 short const u =gsl_vector_short_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_short const& v ) const {
358 return operator<( v ) or operator==( v );
359 }
360 // operator>=
369 bool operator>=( vector_short const& v ) const {
370 return operator>( v ) or operator==( v );
371 }
372 // Refines container
373 // type value_type
377 typedef short 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_short;
406 public:
410 typedef std::random_access_iterator_tag iterator_category;
414 typedef short value_type;
423 // // type iterator_traits<vector_short>::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_short 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_short 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_short 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_short not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
526 return 0;
527 }
528 // Warn if iterators do not point to same vector_short
529 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
530 gsl_error( "trying to take difference of iterators for different vector_short 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_short
568 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
569 gsl_error( "trying to take difference of iterators for different vector_short 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_short
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_short 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_short
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_short 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_short 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_short,short,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_short not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
772 return 0;
773 }
774 // Warn if iterators do not point to same vector_short
775 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
776 gsl_error( "trying to take difference of iterators for different vector_short 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_short
810 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
811 gsl_error( "trying to take difference of iterators for different vector_short 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_short,short,reverse_t>(){}
821 protected:
822 friend class vector_short;
823 // We need a constructor for vector_short
830 : iterator_base<vector_short,short,reverse_t>( v, position ){}
831 };
835 template<bool reverse_t> class const_iterator_t
836 : public iterator_base<vector_short const,short,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_short not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
958 return 0;
959 }
960 // Warn if iterators do not point to same vector_short
961 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
962 gsl_error( "trying to take difference of iterators for different vector_short 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_short
1008 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1009 gsl_error( "trying to take difference of iterators for different vector_short 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_short
1043 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1044 gsl_error( "trying to take difference of iterators for different vector_short 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_short
1052 friend class vector_short;
1059 : iterator_base<vector_short const,short,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 short* data() {
1134 if( ccgsl_pointer == 0 ) gsl_error( "null vector_short", __FILE__, __LINE__, GSL_EFAULT );
1135#ifndef GSL_RANGE_CHECK_OFF
1136 if( ccgsl_pointer->stride != 1 )
1137 gsl_error( "vector_short does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1138#endif
1139 return ccgsl_pointer->data; }
1147 short const* data() const {
1148 if( ccgsl_pointer == 0 ) gsl_error( "null vector_short", __FILE__, __LINE__, GSL_EFAULT );
1149#ifndef GSL_RANGE_CHECK_OFF
1150 if( ccgsl_pointer->stride != 1 )
1151 gsl_error( "vector_short 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_short& 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 short& operator[]( size_t const n ){
1217 // Always try to return something
1218 static short something = 0;
1219 // First check that iterator is initialised.
1220 if( ccgsl_pointer == 0 ){
1221 gsl_error( "vector_short 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_short", __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 short const& operator[]( size_t const n ) const {
1240 // Always try to return something
1241 static short something = 0;
1242 // First check that iterator is initialised.
1243 if( ccgsl_pointer == 0 ){
1244 gsl_error( "vector_short 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_short", __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_short* ccgsl_pointer;
1269 size_t* count;
1270 public:
1271 // shared reference functions
1276 gsl_vector_short* get() { return ccgsl_pointer; }
1281 gsl_vector_short 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_short calloc( size_t const n ){ return vector_short( gsl_vector_short_calloc( n ) ); }
1314 void set_zero(){ gsl_vector_short_set_zero( get() ); }
1319 void set_all( short x ){ gsl_vector_short_set_all( get(), x ); }
1325 int set_basis( size_t i ){ return gsl_vector_short_set_basis( get(), i ); }
1331 int memcpy( vector_short const& src ){ return gsl_vector_short_memcpy( get(), src.get() ); }
1336 int reverse(){ return gsl_vector_short_reverse( get() ); }
1343 int swap_elements( size_t const i, size_t const j ){
1344 return gsl_vector_short_swap_elements( get(), i, j ); }
1349 short max() const { return gsl_vector_short_max( get() ); }
1354 short min() const { return gsl_vector_short_min( get() ); }
1360 void minmax( short& min_out, short& max_out ) const {
1361 gsl_vector_short_minmax( get(), &min_out, &max_out ); }
1366 size_t max_index() const { return gsl_vector_short_max_index( get() ); }
1371 size_t min_index() const { return gsl_vector_short_min_index( get() ); }
1377 void minmax_index( size_t* imin, size_t* imax ) const {
1378 gsl_vector_short_minmax_index( get(), imin, imax ); }
1384 int add( vector_short const& b ){ return gsl_vector_short_add( get(), b.get() ); }
1390 int sub( vector_short const& b ){ return gsl_vector_short_sub( get(), b.get() ); }
1396 int mul( vector_short const& b ){ return gsl_vector_short_mul( get(), b.get() ); }
1402 int div( vector_short const& b ){ return gsl_vector_short_div( get(), b.get() ); }
1408 int scale( short const x ){ return gsl_vector_short_scale( get(), x ); }
1414 int add_constant( short const x ){ return gsl_vector_short_add_constant( get(), x ); }
1422 int axpby( short const alpha, vector_short const& x,
1423 short const beta ){
1424 return gsl_vector_short_axpby( alpha, x.get(), beta, get() ); }
1430 short sum( vector_short const& a ) const { return gsl_vector_short_sum( a.get() ); }
1435 int isnull() const { return gsl_vector_short_isnull( get() ); }
1440 int ispos() const { return gsl_vector_short_ispos( get() ); }
1445 int isneg() const { return gsl_vector_short_isneg( get() ); }
1450 int isnonneg() const { return gsl_vector_short_isnonneg( get() ); }
1456 short get( size_t const i ) const { return gsl_vector_short_get( get(), i ); }
1462 void set( size_t const i, short x ){ gsl_vector_short_set( get(), i, x ); }
1468 short* ptr( size_t const i ){ return gsl_vector_short_ptr( get(), i ); }
1474 short const* const_ptr( size_t const i ) const { return gsl_vector_short_const_ptr( get(), i ); }
1480 int fread( FILE* stream ){ return gsl_vector_short_fread( stream, get() ); }
1486 int fwrite( FILE* stream ) const { return gsl_vector_short_fwrite( stream, get() ); }
1492 int fscanf( FILE* stream ){ return gsl_vector_short_fscanf( stream, get() ); }
1499 int fprintf( FILE* stream, char const* format ) const {
1500 return gsl_vector_short_fprintf( stream, get(), format ); }
1508 vector_short( block_short& b, size_t const offset, size_t const n, size_t const stride = 1 ){
1509 ccgsl_pointer = gsl_vector_short_alloc_from_block( b.get(), offset, n, stride );
1510 // just plausibly we could allocate vector_short but not count
1511 try { count = new size_t; } catch( std::bad_alloc& e ){
1512 // try to tidy up before rethrowing
1513 gsl_vector_short_free( ccgsl_pointer );
1514 throw e;
1515 }
1516 *count = 1; // initially there is just one reference to ccgsl_pointer
1517 }
1525 vector_short( vector_short& v, size_t const offset, size_t const n, size_t const stride = 1 ){
1526 ccgsl_pointer = gsl_vector_short_alloc_from_vector( v.get(), offset, n, stride );
1527 // just plausibly we could allocate vector_short but not count
1528 try { count = new size_t; } catch( std::bad_alloc& e ){
1529 // try to tidy up before rethrowing
1530 gsl_vector_short_free( ccgsl_pointer );
1531 throw e;
1532 }
1533 *count = 1; // initially there is just one reference to ccgsl_pointer
1534 }
1535
1542 static vector_short view_array( short* v, size_t n ){
1543 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1544 *w = gsl_vector_short_view_array( v, n ).vector;
1545 return vector_short( w );
1546 }
1547
1548
1556 static vector_short view_array_with_stride( short* base, size_t stride, size_t n ){
1557 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1558 *w = gsl_vector_short_view_array_with_stride( base, stride, n ).vector;
1559 return vector_short( w );
1560 }
1561
1562
1569 static vector_short const const_view_array( short const* v, size_t n ){
1570 gsl_vector_short* w = static_cast<gsl_vector_short *>( malloc( sizeof( gsl_vector_short ) ) );
1571 *w = gsl_vector_short_const_view_array( v, n ).vector;
1572 return vector_short( w );
1573 }
1574
1575
1583 static vector_short const const_view_array_with_stride( short const* base, size_t stride, size_t n ){
1584 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1585 *w = gsl_vector_short_const_view_array_with_stride( base, stride, n ).vector;
1586 return vector_short( w );
1587 }
1588
1589
1590#ifndef DOXYGEN_SKIP
1597 static vector_short const view_array( short const* v, size_t n ){
1598 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1599 *w = gsl_vector_short_const_view_array( v, n ).vector;
1600 return vector_short( w );
1601 }
1602#endif //DOXYGEN_SKIP
1603
1604
1605#ifndef DOXYGEN_SKIP
1613 static vector_short const view_array_with_stride( short const* base, size_t stride, size_t n ){
1614 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1615 *w = gsl_vector_short_const_view_array_with_stride( base, stride, n ).vector;
1616 return vector_short( w );
1617 }
1618#endif //DOXYGEN_SKIP
1619
1620
1627 vector_short subvector( size_t i, size_t n ){
1628 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1629 *w = gsl_vector_short_subvector( get(), i, n ).vector;
1630 return vector_short( w );
1631 }
1632
1633
1641 vector_short subvector_with_stride( size_t i, size_t stride, size_t n ){
1642 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1643 *w = gsl_vector_short_subvector_with_stride( get(), i, stride, n ).vector;
1644 return vector_short( w );
1645 }
1646
1647
1654 vector_short const const_subvector( size_t i, size_t n ) const {
1655 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1656 *w = gsl_vector_short_const_subvector( get(), i, n ).vector;
1657 return vector_short( w );
1658 }
1659
1660
1668 vector_short const const_subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1669 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1670 *w = gsl_vector_short_const_subvector_with_stride( get(), i, stride, n ).vector;
1671 return vector_short( w );
1672 }
1673
1674
1675#ifndef DOXYGEN_SKIP
1682 vector_short const subvector( size_t i, size_t n ) const {
1683 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1684 *w = gsl_vector_short_const_subvector( get(), i, n ).vector;
1685 return vector_short( w );
1686 }
1687#endif //DOXYGEN_SKIP
1688
1689
1690#ifndef DOXYGEN_SKIP
1698 vector_short const subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1699 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1700 *w = gsl_vector_short_const_subvector_with_stride( get(), i, stride, n ).vector;
1701 return vector_short( w );
1702 }
1703#endif //DOXYGEN_SKIP
1704
1705
1712 template<typename ARRAY>
1713 static vector_short view_array( ARRAY& v, size_t n = 0 ){
1714 if(n > v.size())
1715 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1716 if(0 == n)
1717 n = v.size();
1718 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1719 *w = gsl_vector_short_view_array( v.data(), n ).vector;
1720 return vector_short( w );
1721 }
1722
1723
1731 template<typename ARRAY>
1732 static vector_short view_array_with_stride( ARRAY& base, size_t stride, size_t n=0 ){
1733 if(0 == n)
1734 n = base.size()/stride;
1735 if((n-1)*stride > base.size())
1736 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1737 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1738 *w = gsl_vector_short_view_array_with_stride( base.data(), stride, n ).vector;
1739 return vector_short( w );
1740 }
1741
1742
1749 template<typename ARRAY>
1750 static vector_short const const_view_array( ARRAY const& v, size_t n=0 ){
1751 if(n > v.size())
1752 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1753 if(0 == n)
1754 n = v.size();
1755 gsl_vector_short* w = static_cast<gsl_vector_short *>( malloc( sizeof( gsl_vector_short ) ) );
1756 *w = gsl_vector_short_const_view_array( v.data(), n ).vector;
1757 return vector_short( w );
1758 }
1759
1760
1768 template<typename ARRAY>
1769 static vector_short const const_view_array_with_stride( ARRAY const& base, size_t stride, size_t n=0 ){
1770 if(0 == n)
1771 n = base.size()/stride;
1772 if((n-1)*stride > base.size())
1773 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1774 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1775 *w = gsl_vector_short_const_view_array_with_stride( base.data(), stride, n ).vector;
1776 return vector_short( w );
1777 }
1778
1779
1780#ifndef DOXYGEN_SKIP
1787 template<typename ARRAY>
1788 static vector_short const view_array( ARRAY const& v, size_t n=0 ){
1789 if(n > v.size())
1790 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1791 if(0 == n)
1792 n = v.size();
1793 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1794 *w = gsl_vector_short_const_view_array( v.data(), n ).vector;
1795 return vector_short( w );
1796 }
1797#endif //DOXYGEN_SKIP
1798
1799
1800#ifndef DOXYGEN_SKIP
1808 template<typename ARRAY>
1809 static vector_short const view_array_with_stride( ARRAY const& base, size_t stride, size_t n ){
1810 if(0 == n)
1811 n = base.size()/stride;
1812 if((n-1)*stride > base.size())
1813 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1814 gsl_vector_short* w = static_cast<gsl_vector_short*>( malloc( sizeof( gsl_vector_short ) ) );
1815 *w = gsl_vector_short_const_view_array_with_stride( base.data(), stride, n ).vector;
1816 return vector_short( w );
1817 }
1818#endif //DOXYGEN_SKIP
1819
1820 // Extra allocators from matrix_short objects. The definition must come after matrix_short.
1835 };
1836
1843 inline vector_short::iterator operator+
1844 ( vector_short::iterator::difference_type const n, vector_short::iterator const& i ){ return i + n; }
1845
1854
1863 return i + n; }
1864
1873 return i + n; }
1874
1875}
1876#endif
This class handles vector_shorts as shared handles.
Definition: block_short.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_short objects as shared handles.
A class template for the const iterators.
bool operator<(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
const_iterator_t< reverse_t > & operator=(const_iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
difference_type operator-(const_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.
const_iterator_t(vector_short const *v, difference_type position)
This constructor allows vector_short to create non-default iterators.
const_iterator_t()
The default constructor.
const_iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
const_iterator_t< reverse_t > & operator--()
The prefix – operator.
iterator_base< vector_shortconst, short, reverse_t >::difference_type difference_type
Difference type.
const_iterator_t< reverse_t > & operator-=(difference_type const n)
The -= 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.
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.
const_iterator_t< reverse_t > operator--(int)
The postfix – operator.
const_iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
const_iterator_t< reverse_t > & operator++()
The prefix ++ operator.
bool operator==(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
const_iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
The container must have iterator types.
std::random_access_iterator_tag iterator_category
An iterator must have an iterator category.
value_type * pointer
An iterator must have a pointer typea.
void shift(difference_type const n)
Shift iterator n places.
bool operator<(iterator_base< container, content, reverse_t > const &i) const
The < operator is used to compare iterators.
void increment()
Increment the iterator.
iterator_base()
The iterator is default constructible.
reference operator*() const
Dereference the pointer.
bool operator!=(iterator_base< container, content, reverse_t > const &i) const
The != operator.
short value_type
An iterator must have a value type.
ptrdiff_t difference_type
An iterator must have a difference_type.
value_type & reference
An iterator must have a reference type.
pointer operator->() const
Dereference the pointer.
container * v
Store a pointer to a vector_short we can iterate over: 0 if no vector_short.
difference_type position
Mark position of iterator within vector_short.
iterator_base(container *v, difference_type position)
This constructor allows vector_short to create non-default iterators.
reference operator[](difference_type const n) const
Get element at i + n by reference ([] operator).
bool operator==(iterator_base< container, content, reverse_t > const &i) const
The == operator.
void decrement()
Decrement the iterator.
difference_type operator-(iterator_base< container, content, reverse_t > const &i) const
The - operator: find distance between two iterators.
A class template for the two non-const iterators.
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_t()
The default constructor.
iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
iterator_t< reverse_t > & operator=(iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
iterator_t(vector_short *v, difference_type position)
This constructor allows vector_short to create non-default iterators.
iterator_t< reverse_t > operator--(int)
The postfix – operator.
iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
iterator_base< vector_short, short, reverse_t >::difference_type difference_type
Difference type.
bool operator==(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
iterator_t< reverse_t > & operator++()
The prefix ++ operator.
iterator_t< reverse_t > & operator--()
The prefix – operator.
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.
This class handles vector_short objects as shared handles.
reverse_iterator rbegin()
Get iterator pointing to first vector_short element.
int div(vector_short const &b)
C++ version of gsl_vector_short_div().
int swap_elements(size_t const i, size_t const j)
C++ version of gsl_vector_short_swap_elements().
bool operator<=(vector_short const &v) const
A container needs to define an ordering for sorting.
short & operator[](size_t const n)
Get element at position n by reference ([] operator).
const_iterator begin() const
Get iterator pointing to first vector_short element.
size_t max_index() const
C++ version of gsl_vector_short_max_index().
void set_zero()
C++ version of gsl_vector_short_set_zero().
vector_short(vector_short const &v)
The copy constructor.
int scale(short const x)
C++ version of gsl_vector_short_scale().
size_t use_count() const
Find how many vector_short objects share this pointer.
static vector_short alloc_row_from_matrix(matrix_short &m, size_t const i)
C++ version of gsl_vector_short_alloc_row_from_matrix().
int isnull() const
C++ version of gsl_vector_short_isnull().
static vector_short calloc(size_t const n)
C++ version of gsl_vector_short_calloc().
void minmax_index(size_t *imin, size_t *imax) const
C++ version of gsl_vector_short_minmax_index().
void wrap_gsl_vector_short_without_ownership(gsl_vector_short *v)
This function is intended mainly for internal use.
short const * const_ptr(size_t const i) const
C++ version of gsl_vector_short_const_ptr().
size_t size_type
A container must have a size_type.
vector_short(block_short &b, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_short_alloc_from_block().
vector_short & operator=(vector_short &&v)
Move operator.
bool operator<(vector_short const &v) const
A container needs to define an ordering for sorting.
vector_short(vector_short &v, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_short_alloc_from_vector().
static vector_short const const_view_array_with_stride(short const *base, size_t stride, size_t n)
C++ version of gsl_vector_short_const_view_array_with_stride().
int memcpy(vector_short const &src)
C++ version of gsl_vector_short_memcpy().
iterator begin()
Get iterator pointing to first vector_short element.
static vector_short const const_view_array_with_stride(ARRAY const &base, size_t stride, size_t n=0)
C++ version of gsl_vector_short_const_view_array_with_stride().
iterator end()
Get iterator pointing beyond last vector_short element.
short * data()
Give access to the data block_short.
bool operator==(vector_short const &v) const
Two vector_short objects are identically equal if their elements are identical.
gsl_vector_short * ccgsl_pointer
The shared pointer.
vector_short const const_subvector_with_stride(size_t i, size_t stride, size_t n) const
C++ version of gsl_vector_short_const_subvector_with_stride().
gsl_vector_short const * get() const
Get the gsl_vector_short.
bool owns_data
Used to allow a vector that does not own its data.
vector_short(V &v, size_t const stride=1)
Construct from an object that implements data() and size().
void reset()
Stop sharing ownership of the shared pointer.
const_iterator_t< false > const_iterator
The const_iterator type.
int isneg() const
C++ version of gsl_vector_short_isneg().
void minmax(short &min_out, short &max_out) const
C++ version of gsl_vector_short_minmax().
const_reverse_iterator rbegin() const
Get iterator pointing to first vector_short element.
void set(size_t const i, short x)
C++ version of gsl_vector_short_set().
bool empty() const
Find if the vector_short is empty.
static vector_short view_array(ARRAY &v, size_t n=0)
C++ version of gsl_vector_short_view_array().
value_type const & const_reference
A container must have a constant reference type.
short get(size_t const i) const
C++ version of gsl_vector_short_get().
const_iterator_t< true > const_reverse_iterator
The const_reverse_t type.
bool operator>=(vector_short const &v) const
A container needs to define an ordering for sorting.
vector_short(std::initializer_list< short > initializer_list)
Could construct from a std::initializer_list in C++11.
vector_short(size_t const n)
The default constructor creates a new vector_short with n elements.
vector_short & operator=(vector_short const &v)
The assignment operator.
short min() const
C++ version of gsl_vector_short_min().
int sub(vector_short const &b)
C++ version of gsl_vector_short_sub().
bool unique() const
Find if this is the only object sharing the gsl_vector_short.
vector_short subvector(size_t i, size_t n)
C++ version of gsl_vector_short_subvector().
short const * data() const
Give access to the data block_short.
short value_type
A container must have a value_type.
static vector_short view_array_with_stride(ARRAY &base, size_t stride, size_t n=0)
C++ version of gsl_vector_short_view_array_with_stride().
iterator_t< false > iterator
The iterator type.
int add(vector_short const &b)
C++ version of gsl_vector_short_add().
vector_short clone() const
The clone function.
size_type size() const
The size (number of elements) of the vector_short.
int axpby(short const alpha, vector_short const &x, short const beta)
C++ version of gsl_vector_short_axpby().
vector_short const const_subvector(size_t i, size_t n) const
C++ version of gsl_vector_short_const_subvector().
size_type max_size() const
The max size (number of elements) of the vector_short.
int add_constant(short const x)
C++ version of gsl_vector_short_add_constant().
int fprintf(FILE *stream, char const *format) const
C++ version of gsl_vector_short_fprintf().
int fwrite(FILE *stream) const
C++ version of gsl_vector_short_fwrite().
vector_short()
The default constructor is only really useful for assigning to.
int isnonneg() const
C++ version of gsl_vector_short_isnonneg().
size_t min_index() const
C++ version of gsl_vector_short_min_index().
const_iterator::difference_type difference_type
A container must have a difference_type.
gsl_vector_short * get()
Get the gsl_vector_short.
iterator_t< true > reverse_iterator
The reverse_iterator type.
value_type const * const_pointer
A container must have a constant pointer type.
size_t * count
The shared reference count.
int reverse()
C++ version of gsl_vector_short_reverse().
static vector_short const const_view_array(short const *v, size_t n)
C++ version of gsl_vector_short _const_view_array().
int fscanf(FILE *stream)
C++ version of gsl_vector_short_fscanf().
vector_short(vector_short &v)
The copy constructor.
int mul(vector_short const &b)
C++ version of gsl_vector_short_mul().
short * ptr(size_t const i)
C++ version of gsl_vector_short_ptr().
static vector_short const const_view_array(ARRAY const &v, size_t n=0)
C++ version of gsl_vector_short _const_view_array().
short sum(vector_short const &a) const
C++ version of gsl_vector_short_sum().
void swap(vector_short &v)
Swap two vector_short objects.
reverse_iterator rend()
Get iterator pointing beyond last vector_short element.
bool operator!=(vector_short const &v) const
Two vector_short objects are different equal if their elements are not identical.
short const & operator[](size_t const n) const
Get element at position n by reference ([] operator).
value_type & reference
A container must have a reference type.
void set_all(short x)
C++ version of gsl_vector_short_set_all().
~vector_short()
The destructor only deletes the pointers if count reaches zero.
const_iterator end() const
Get iterator pointing beyond last vector_short element.
int ispos() const
C++ version of gsl_vector_short_ispos().
vector_short(vector_short &&v)
Move constructor.
int fread(FILE *stream)
C++ version of gsl_vector_short_fread().
const_reverse_iterator rend() const
Get iterator pointing beyond last vector_short element.
static vector_short view_array_with_stride(short *base, size_t stride, size_t n)
C++ version of gsl_vector_short_view_array_with_stride().
int set_basis(size_t i)
C++ version of gsl_vector_short_set_basis().
static vector_short view_array(short *v, size_t n)
C++ version of gsl_vector_short_view_array().
value_type * pointer
A container must have a pointer type.
static vector_short alloc_col_from_matrix(matrix_short &m, size_t const j)
C++ version of gsl_vector_short_alloc_col_from_matrix().
bool operator>(vector_short const &v) const
A container needs to define an ordering for sorting.
vector_short subvector_with_stride(size_t i, size_t stride, size_t n)
C++ version of gsl_vector_short_subvector_with_stride().
short max() const
C++ version of gsl_vector_short_max().
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