ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
vector_float.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_FLOAT_HPP
20#define CCGSL_VECTOR_FLOAT_HPP
21
22#include<gsl/gsl_vector_float.h>
23#include<new>
24#include<iterator>
25
26#include"exception.hpp"
27#include"block_float.hpp"
28
29// This file is autogenerated
30
31namespace gsl {
32 // declare matrix_float class
33 class matrix_float;
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_float( size_t const n ) : owns_data(true){
62 if( n > 0 ) ccgsl_pointer = gsl_vector_float_alloc( n );
63 else { ccgsl_pointer = new gsl_vector_float; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
64 // just plausibly we could allocate vector_float 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_float_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_float( int const n ) : owns_data(true){
79 if( n > 0 ) ccgsl_pointer = gsl_vector_float_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_float; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
84 // just plausibly we could allocate vector_float 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_float_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_float( gsl_vector_float* v )
100 : owns_data(false) {
101 ccgsl_pointer = v;
102 // just plausibly we could fail to allocate count: no further action needed.
103 count = new size_t;
104 *count = 1; // initially there is just one reference to ccgsl_pointer
105 }
106#ifdef __GXX_EXPERIMENTAL_CXX0X__
111 vector_float( std::initializer_list<float> initializer_list ) : owns_data(true){
112 size_t const n = initializer_list.size();
113 ccgsl_pointer = gsl_vector_float_alloc( n );
114 // just plausibly we could allocate vector_float but not count
115 try { count = new size_t; } catch( std::bad_alloc& e ){
116 // try to tidy up before rethrowing
117 if( n > 0 ) gsl_vector_float_free( ccgsl_pointer );
118 else delete ccgsl_pointer;
119 throw e;
120 }
121 *count = 1; // initially there is just one reference to ccgsl_pointer
122 // now copy
123 auto p = begin();
124 for( auto x : initializer_list ){ *p = x; ++p; }
125 }
126#endif
127 // copy constructor
134 if( count != 0 ) ++*count; // vector_float is now shared.
135 }
142 if( count != 0 ) ++*count; // vector_float is now shared.
143 }
144 // assignment operator
150 // first, possibly delete anything pointed to by @c this
151 if( count == 0 or --*count == 0 ){
152 if( ccgsl_pointer != 0 ){
153 if( ccgsl_pointer->size > 0 ) gsl_vector_float_free( ccgsl_pointer );
154 else delete ccgsl_pointer; }
155 delete count;
156 }
157 // Then copy
160 count = v.count;
161 if( count != 0 ) ++*count; // block_float is now shared.
162 return *this;
163 }
176 template<typename V> vector_float( V& v, size_t const stride = 1 ) : owns_data(true){
177 size_t const n = v.size() / stride;
178 ccgsl_pointer = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
179 ccgsl_pointer->size = n;
180 ccgsl_pointer->stride = stride;
181 ccgsl_pointer->data = v.data();
182 ccgsl_pointer->block = 0;
183 ccgsl_pointer->owner = 0;
184 // just plausibly we could allocate vector_float but not count
185 try { count = new size_t; } catch( std::bad_alloc& e ){
186 // try to tidy up before rethrowing
187 if( n > 0 ) gsl_vector_float_free( ccgsl_pointer );
188 else delete ccgsl_pointer;
189 throw e;
190 }
191 *count = 1; // initially there is just one reference to ccgsl_pointer
192 }
193 // clone()
200 vector_float copy( get()->size );
201 // Now copy
202 gsl_vector_float_memcpy( copy.get(), get() );
203 // return new object
204 return copy;
205 }
206 // destructor
211 if( count != 0 and --*count == 0 ){
212 // could have allocated null pointer
213 if( ccgsl_pointer != 0 and owns_data){
214 if( ccgsl_pointer->size > 0 ) gsl_vector_float_free( ccgsl_pointer );
215 else delete ccgsl_pointer; }
216 delete count;
217 }
218 }
219
220 // Allow possibility of assigning from gsl_vector_float without sharing
229 void wrap_gsl_vector_float_without_ownership( gsl_vector_float* v ){
230 if( count != 0 and --*count == 0 ){
231 // could have allocated null pointer
232 if( ccgsl_pointer != 0 ){
233 if( ccgsl_pointer->size != 0 ) gsl_vector_float_free( ccgsl_pointer );
234 else delete ccgsl_pointer; }
235 }
236 ccgsl_pointer = v;
237 if(0 == count) count = new size_t;
238 *count = 1;
239 owns_data = false; // should never be able to delete ccgsl_pointer
240 }
241 // Refines equality comparable
242 // == operator
249 bool operator==( vector_float const& v ) const {
250 // trivially equal if gsl_vector_float*s are identical
251 if( ccgsl_pointer == v.ccgsl_pointer ) return true;
252 // trivially not equal if one is zero: != should be same as xor here
253 if( (ccgsl_pointer == 0) != (v.ccgsl_pointer == 0 ) ) return false;
254 // trivially not equal if sizes are different
255 if( ccgsl_pointer->size != v.ccgsl_pointer->size ) return false;
256 // check elementwise for equality
257 for( size_t i = 0; i < ccgsl_pointer->size; ++i )
258 if( gsl_vector_float_get( ccgsl_pointer, i ) != gsl_vector_float_get( v.ccgsl_pointer, i ) ) return false;
259 return true;
260 }
264 void reset(){ vector_float().swap( *this ); }
265#ifdef __GXX_EXPERIMENTAL_CXX0X__
271 ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
272 std::swap( count, v.count );
273 v.ccgsl_pointer = nullptr;
274 }
281 vector_float( std::move( v ) ).swap( *this );
282 return *this;
283 }
284#endif
285 // != operator
292 bool operator!=( vector_float const& v ) const { return not operator==( v ); }
293 // Refines forward container
294 // Refines less than comparable
295 // operator<
304 bool operator<( vector_float const& v ) const {
305 // null vector_float comes first
306 if( ccgsl_pointer == 0 ) return v.ccgsl_pointer != 0;
307 // if v is null then this > v
308 if( v.ccgsl_pointer == 0 ) return false;
309 // Now compare elementwise
310 size_t const size = ccgsl_pointer->size;
311 size_t const v_size = v.ccgsl_pointer->size;
312 size_t const min = size > v_size ? size : v_size;
313 for( size_t i = 0; i < min; ++i ){
314 float const t = gsl_vector_float_get( ccgsl_pointer, i );
315 float const u =gsl_vector_float_get( v.ccgsl_pointer, i );
316 if( t < u ) return true;
317 if( u < t ) return false;
318 }
319 // elements match.
320 return size < v_size;
321 }
322 // operator>
331 bool operator>( vector_float const& v ) const {
332 // null vector_float comes first
333 if( ccgsl_pointer == 0 ) return false;
334 // if v is null then this > v
335 if( v.ccgsl_pointer == 0 ) return true;
336 // Now compare elementwise
337 size_t const size = ccgsl_pointer->size;
338 size_t const v_size = v.ccgsl_pointer->size;
339 size_t const min = size > v_size ? size : v_size;
340 for( size_t i = 0; i < min; ++i ){
341 float const t = gsl_vector_float_get( ccgsl_pointer, i );
342 float const u =gsl_vector_float_get( v.ccgsl_pointer, i );
343 if( t > u ) return true;
344 if( u > t ) return false;
345 }
346 // elements match.
347 return size > v_size;
348 }
349 // operator<=
358 bool operator<=( vector_float const& v ) const {
359 return operator<( v ) or operator==( v );
360 }
361 // operator>=
370 bool operator>=( vector_float const& v ) const {
371 return operator>( v ) or operator==( v );
372 }
373 // Refines container
374 // type value_type
378 typedef float value_type;
379 // type reference
384 // type const_reference
389 // type pointer
394 // type const_pointer
398 typedef value_type const* const_pointer;
399 // type iterator
400 private:
405 template<typename container, typename content,bool reverse_t> class iterator_base {
406 friend class vector_float;
407 public:
411 typedef std::random_access_iterator_tag iterator_category;
415 typedef float value_type;
424 // // type iterator_traits<vector_float>::difference_type
428 typedef ptrdiff_t difference_type;
429 public:
430 // // operator*
436 // Always try to return something
437 static content something = 0;
438 // First check that iterator is initialised.
439 if( v == 0 ){
440 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
441 return something;
442 } else if( v->ccgsl_pointer == 0 ){
443 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
444 return something;
445 }
446 // Check that position make sense
447 if( position >= static_cast<difference_type>( v->size() ) ){
448 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
449 return something;
450 }
451 if( position <= -1 ){
452 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
453 return something;
454 }
455 // position and v are valid: return data
456 return *(v->ccgsl_pointer->data + position * v->ccgsl_pointer->stride);
457 }
458 // // operator->
464 // First check that iterator is initialised.
465 if( v == 0 ){
466 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
467 return 0;
468 } else if( v->ccgsl_pointer == 0 ){
469 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
470 return 0;
471 }
472 // Check that position make sense
473 if( position >= static_cast<difference_type>( v->size() ) ){
474 gsl_error( "trying to dereference end()", __FILE__, __LINE__, exception::GSL_EFAILED );
475 return 0;
476 }
477 if( position <= -1 ){
478 gsl_error( "trying to dereference rend()", __FILE__, __LINE__, exception::GSL_EFAILED );
479 return 0;
480 }
481 // position and v are valid: return data
482 return v->ccgsl_pointer->data + position * v->ccgsl_pointer->stride;
483 }
484 // // operator[]
491 // Always try to return something
492 static content something = 0;
493 // First check that iterator is initialised.
494 if( v == 0 ){
495 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
496 return something;
497 } else if( v->ccgsl_pointer == 0 ){
498 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
499 return something;
500 }
501 // Check that position make sense
502 difference_type const p = reverse_t ? position - n : position + n;
503 if( p >= static_cast<difference_type>( v->size() ) ){
504 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
505 return something;
506 }
507 if( p <= -1 ){
508 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
509 return something;
510 }
511 // p is a valid position
512 return *(v->ccgsl_pointer->data + p * v->ccgsl_pointer->stride);
513 }
514 // // operator-: find distance between two iterators
521 // Warn if either iterator undefined
522 if( v == 0 or i.v == 0 ){
523 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
524 return 0;
525 } else if( v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
526 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
527 return 0;
528 }
529 // Warn if iterators do not point to same vector_float
530 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
531 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
533 return 0;
534 }
535 return reverse_t ? i.position - position : position - i.position;
536 }
537 // // operator!=
538 // // operator<
545 return this->v == i.v and this->position == i.position;
546 }
553 return not this->operator==( i );
554 }
563 // Warn if either iterator undefined
564 if( v == 0 or i.v == 0 ){
565 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
566 return false;
567 }
568 // Warn if iterators do not point to same vector_float
569 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
570 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
572 return false;
573 }
574 return reverse_t ? i.position < position : position < i.position;
575 }
576 protected:
581 void increment(){
582 // Only makes sense if v points to a vector_float
583 if( v == 0 ){
584 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
585 return;
586 } else if( v->ccgsl_pointer == 0 ){
587 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
588 return;
589 }
590 // increment position and check against size
591 if( reverse_t ){ if( position >= 0 ) --position; }
592 else { if( position < static_cast<difference_type>( v->size() ) ) ++position; }
593 }
598 void decrement(){
599 // Only makes sense if v points to a vector_float
600 if( v == 0 ){
601 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
602 return;
603 } else if( v->ccgsl_pointer == 0 ){
604 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
605 return;
606 }
607 // decrement position and check against size
608 if( reverse_t ){ if( position < static_cast<difference_type>( v->size() ) ) ++position; }
609 else { if( position >= 0 ) --position; }
610 }
615 void shift( difference_type const n ){
616 // Warn if iterator undefined
617 if( v == 0 ){
618 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
619 return;
620 } else if( v->ccgsl_pointer == 0 ){
621 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
622 return;
623 }
624 position += reverse_t ? -n : n;
625 }
629 iterator_base(){ v = 0; }
636 : v( v ), position( position ){}
640 container* v;
645 };
646 // Need to know about const_iterator_t
647 template<bool reverse_t> class const_iterator_t;
651 template<bool reverse_t> class iterator_t : public iterator_base<vector_float,float,reverse_t>{
652 public:
653 // // Refines output iterator
654 // // operator=
662 return *this;
663 }
664 // // Refines forward iterator
665 // // operator++ (both)
672 return *this;
673 }
679 // return value
682 return result;
683 }
684 // // Refines bidirectional iterator
685 // // operator-- (both)
692 return *this;
693 }
699 // return value
702 return result;
703 }
709 // // operator+=
716 this->shift( n );
717 return *this;
718 }
719 // // operator-=
726 this->shift( -n );
727 return *this;
728 }
729 // // operator+ (n+i)(i+n)
738 result.shift( n );
739 return result;
740 }
741 // // operator- (n-i)(i-n)(i-j)
750 result.shift( -n );
751 return result;
752 }
760 }
767 // Warn if either iterator undefined
768 if( this->v == 0 or i.v == 0 ){
769 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
770 return 0;
771 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
772 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
773 return 0;
774 }
775 // Warn if iterators do not point to same vector_float
776 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
777 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
779 return 0;
780 }
781 return reverse_t ? i.position - this->position : this->position - i.position;
782 }
789 return this->v == i.v and this->position == i.position;
790 }
797 return not this->operator==( i );
798 }
804 bool operator<( const_iterator_t<reverse_t> const& i ) const {
805 // Warn if either iterator undefined
806 if( this->v == 0 or i.v == 0 ){
807 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
808 return false;
809 }
810 // Warn if iterators do not point to same vector_float
811 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
812 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
814 return false;
815 }
816 return reverse_t ? i.position < this->position : this->position < i.position;
817 }
821 iterator_t() : iterator_base<vector_float,float,reverse_t>(){}
822 protected:
823 friend class vector_float;
824 // We need a constructor for vector_float
831 : iterator_base<vector_float,float,reverse_t>( v, position ){}
832 };
836 template<bool reverse_t> class const_iterator_t
837 : public iterator_base<vector_float const,float,reverse_t>{
838 public:
839 // // Refines output iterator
840 // // operator=
848 return *this;
849 }
850 // // Refines forward iterator
851 // // operator++ (both)
858 return *this;
859 }
865 // return value
868 return result;
869 }
870 // // Refines bidirectional iterator
871 // // operator-- (both)
878 return *this;
879 }
885 // return value
888 return result;
889 }
895 // // operator+=
902 this->shift( n );
903 return *this;
904 }
905 // // operator-=
912 this->shift( -n );
913 return *this;
914 }
915 // // operator+ (n+i)(i+n)
924 result += n;
925 return result;
926 }
927 // // operator- (n-i)(i-n)(i-j)
936 result -= n;
937 return result;
938 }
946 }
953 // Warn if either iterator undefined
954 if( this->v == 0 or i.v == 0 ){
955 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
956 return 0;
957 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
958 gsl_error( "vector_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
959 return 0;
960 }
961 // Warn if iterators do not point to same vector_float
962 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
963 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
965 return 0;
966 }
967 return reverse_t ? i.position - this->position : this->position - i.position;
968 }
980 }
986 bool operator==( iterator_t<reverse_t> const& i ) const {
987 return this->v == i.v and this->position == i.position;
988 }
994 bool operator!=( iterator_t<reverse_t> const& i ) const {
995 return not this->operator==( i );
996 }
1002 bool operator<( iterator_t<reverse_t> const& i ) const {
1003 // Warn if either iterator undefined
1004 if( this->v == 0 or i.v == 0 ){
1005 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1006 return false;
1007 }
1008 // Warn if iterators do not point to same vector_float
1009 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1010 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
1012 return false;
1013 }
1014 return reverse_t ? i.position < this->position : this->position < i.position;
1015 }
1022 return this->v == i.v and this->position == i.position;
1023 }
1030 return not this->operator==( i );
1031 }
1038 // Warn if either iterator undefined
1039 if( this->v == 0 or i.v == 0 ){
1040 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1041 return false;
1042 }
1043 // Warn if iterators do not point to same vector_float
1044 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1045 gsl_error( "trying to take difference of iterators for different vector_float objects", __FILE__, __LINE__,
1047 return false;
1048 }
1049 return reverse_t ? i.position < this->position : this->position < i.position;
1050 }
1051 protected:
1052 // We need a constructor for vector_float
1053 friend class vector_float;
1060 : iterator_base<vector_float const,float,reverse_t>( v, position ){}
1061 };
1062 public:
1079 // type difference_type
1084 // type size_type
1088 typedef size_t size_type;
1089 // begin()
1095 return iterator( this, 0 );
1096 }
1102 return const_iterator( this, 0 );
1103 }
1104 // end()
1110 if( ccgsl_pointer == 0 ) return iterator( this, 0 );
1111 return iterator( this, size() );
1112 }
1118 if( ccgsl_pointer == 0 ) return const_iterator( this, 0 );
1119 return const_iterator( this, size() );
1120 }
1121 // size()
1126 size_type size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1134 float* data() {
1135 if( ccgsl_pointer == 0 ) gsl_error( "null vector_float", __FILE__, __LINE__, GSL_EFAULT );
1136#ifndef GSL_RANGE_CHECK_OFF
1137 if( ccgsl_pointer->stride != 1 )
1138 gsl_error( "vector_float does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1139#endif
1140 return ccgsl_pointer->data; }
1148 float const* data() const {
1149 if( ccgsl_pointer == 0 ) gsl_error( "null vector_float", __FILE__, __LINE__, GSL_EFAULT );
1150#ifndef GSL_RANGE_CHECK_OFF
1151 if( ccgsl_pointer->stride != 1 )
1152 gsl_error( "vector_float does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1153#endif
1154 return ccgsl_pointer->data; }
1155 // max_size()
1161 size_type max_size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1162 // empty()
1167 bool empty() const { return ccgsl_pointer == 0 or ccgsl_pointer->size == 0; }
1168 // swap() --- should work even if sizes don't match
1174 void swap( vector_float& v ){
1175 std::swap( ccgsl_pointer, v.ccgsl_pointer );
1176 std::swap( count, v.count );
1177 }
1178 // Refines reversible container
1179 // rbegin()
1185 if( ccgsl_pointer ==0 ) return reverse_iterator( this, 0 );
1186 return reverse_iterator( this, size() - 1 );
1187 }
1193 if( ccgsl_pointer ==0 ) return const_reverse_iterator( this, 0 );
1194 return const_reverse_iterator( this, size() - 1 );
1195 }
1196 // rend()
1202 return reverse_iterator( this, -1 );
1203 }
1209 return const_reverse_iterator( this, -1 );
1210 }
1211 // operator[]
1217 float& operator[]( size_t const n ){
1218 // Always try to return something
1219 static float something = 0;
1220 // First check that iterator is initialised.
1221 if( ccgsl_pointer == 0 ){
1222 gsl_error( "vector_float is null", __FILE__, __LINE__, exception::GSL_EFAULT );
1223 return something;
1224 }
1225#ifndef GSL_RANGE_CHECK_OFF
1226 // Check that position make sense
1227 if( n >= size() ){
1228 gsl_error( "trying to read beyond end of vector_float", __FILE__, __LINE__, exception::GSL_EINVAL );
1229 return something;
1230 }
1231 // n is a valid position
1232#endif
1233 return *(ccgsl_pointer->data + n * ccgsl_pointer->stride);
1234 }
1240 float const& operator[]( size_t const n ) const {
1241 // Always try to return something
1242 static float something = 0;
1243 // First check that iterator is initialised.
1244 if( ccgsl_pointer == 0 ){
1245 gsl_error( "vector_float is null", __FILE__, __LINE__, exception::GSL_EFAULT );
1246 return something;
1247 }
1248#ifndef GSL_RANGE_CHECK_OFF
1249 // Check that position make sense
1250 if( n >= size() ){
1251 gsl_error( "trying to read beyond end of vector_float", __FILE__, __LINE__, exception::GSL_EINVAL );
1252 return something;
1253 }
1254 // n is a valid position
1255#endif
1256 return *(ccgsl_pointer->data + n * ccgsl_pointer->stride);
1257 }
1258 private:
1266 gsl_vector_float* ccgsl_pointer;
1270 size_t* count;
1271 public:
1272 // shared reference functions
1277 gsl_vector_float* get() { return ccgsl_pointer; }
1282 gsl_vector_float const* get() const { return ccgsl_pointer; }
1288 bool unique() const { return count != 0 and *count == 1; }
1293 size_t use_count() const { return count == 0 ? 0 : *count; }
1299#ifdef __GXX_EXPERIMENTAL_CXX0X__
1300 explicit
1301#endif
1302 operator bool() const { return ccgsl_pointer != 0; }
1303
1304 // GSL functions
1311 static vector_float calloc( size_t const n ){ return vector_float( gsl_vector_float_calloc( n ) ); }
1315 void set_zero(){ gsl_vector_float_set_zero( get() ); }
1320 void set_all( float x ){ gsl_vector_float_set_all( get(), x ); }
1326 int set_basis( size_t i ){ return gsl_vector_float_set_basis( get(), i ); }
1332 int memcpy( vector_float const& src ){ return gsl_vector_float_memcpy( get(), src.get() ); }
1337 int reverse(){ return gsl_vector_float_reverse( get() ); }
1344 int swap_elements( size_t const i, size_t const j ){
1345 return gsl_vector_float_swap_elements( get(), i, j ); }
1350 float max() const { return gsl_vector_float_max( get() ); }
1355 float min() const { return gsl_vector_float_min( get() ); }
1361 void minmax( float* min_out, float* max_out ) const {
1362 gsl_vector_float_minmax( get(), min_out, max_out ); }
1368 void minmax( float& min_out, float& max_out ) const {
1369 gsl_vector_float_minmax( get(), &min_out, &max_out ); }
1374 size_t max_index() const { return gsl_vector_float_max_index( get() ); }
1379 size_t min_index() const { return gsl_vector_float_min_index( get() ); }
1385 void minmax_index( size_t* imin, size_t* imax ) const {
1386 gsl_vector_float_minmax_index( get(), imin, imax ); }
1392 int add( vector_float const& b ){ return gsl_vector_float_add( get(), b.get() ); }
1398 int sub( vector_float const& b ){ return gsl_vector_float_sub( get(), b.get() ); }
1404 int mul( vector_float const& b ){ return gsl_vector_float_mul( get(), b.get() ); }
1410 int div( vector_float const& b ){ return gsl_vector_float_div( get(), b.get() ); }
1416 int scale( float const x ){ return gsl_vector_float_scale( get(), x ); }
1422 int add_constant( float const x ){ return gsl_vector_float_add_constant( get(), x ); }
1430 int axpby( float const alpha, vector_float const& x,
1431 float const beta ){
1432 return gsl_vector_float_axpby( alpha, x.get(), beta, get() );
1433 }
1439 float sum( vector_float const& a ) const { return gsl_vector_float_sum( a.get() ); }
1444 int isnull() const { return gsl_vector_float_isnull( get() ); }
1449 int ispos() const { return gsl_vector_float_ispos( get() ); }
1454 int isneg() const { return gsl_vector_float_isneg( get() ); }
1459 int isnonneg() const { return gsl_vector_float_isnonneg( get() ); }
1465 float get( size_t const i ) const { return gsl_vector_float_get( get(), i ); }
1471 void set( size_t const i, float x ){ gsl_vector_float_set( get(), i, x ); }
1477 float* ptr( size_t const i ){ return gsl_vector_float_ptr( get(), i ); }
1483 float const* const_ptr( size_t const i ) const { return gsl_vector_float_const_ptr( get(), i ); }
1489 int fread( FILE* stream ){ return gsl_vector_float_fread( stream, get() ); }
1495 int fwrite( FILE* stream ) const { return gsl_vector_float_fwrite( stream, get() ); }
1501 int fscanf( FILE* stream ){ return gsl_vector_float_fscanf( stream, get() ); }
1508 int fprintf( FILE* stream, char const* format ) const {
1509 return gsl_vector_float_fprintf( stream, get(), format ); }
1517 vector_float( block_float& b, size_t const offset, size_t const n, size_t const stride = 1 ){
1518 ccgsl_pointer = gsl_vector_float_alloc_from_block( b.get(), offset, n, stride );
1519 // just plausibly we could allocate vector_float but not count
1520 try { count = new size_t; } catch( std::bad_alloc& e ){
1521 // try to tidy up before rethrowing
1522 gsl_vector_float_free( ccgsl_pointer );
1523 throw e;
1524 }
1525 *count = 1; // initially there is just one reference to ccgsl_pointer
1526 }
1534 vector_float( vector_float& v, size_t const offset, size_t const n, size_t const stride = 1 ){
1535 ccgsl_pointer = gsl_vector_float_alloc_from_vector( v.get(), offset, n, stride );
1536 // just plausibly we could allocate vector_float but not count
1537 try { count = new size_t; } catch( std::bad_alloc& e ){
1538 // try to tidy up before rethrowing
1539 gsl_vector_float_free( ccgsl_pointer );
1540 throw e;
1541 }
1542 *count = 1; // initially there is just one reference to ccgsl_pointer
1543 }
1550 static vector_float view_array( float* v, size_t n ){
1551 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1552 *w = gsl_vector_float_view_array( v, n ).vector;
1553 return vector_float( w );
1554 }
1555
1556
1564 static vector_float view_array_with_stride( float* base, size_t stride, size_t n ){
1565 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1566 *w = gsl_vector_float_view_array_with_stride( base, stride, n ).vector;
1567 return vector_float( w );
1568 }
1569
1570
1577 static vector_float const const_view_array( float const* v, size_t n ){
1578 gsl_vector_float* w = static_cast<gsl_vector_float *>( malloc( sizeof( gsl_vector_float ) ) );
1579 *w = gsl_vector_float_const_view_array( v, n ).vector;
1580 return vector_float( w );
1581 }
1582
1583
1591 static vector_float const const_view_array_with_stride( float const* base, size_t stride, size_t n ){
1592 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1593 *w = gsl_vector_float_const_view_array_with_stride( base, stride, n ).vector;
1594 return vector_float( w );
1595 }
1596
1597
1598#ifndef DOXYGEN_SKIP
1605 static vector_float const view_array( float const* v, size_t n ){
1606 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1607 *w = gsl_vector_float_const_view_array( v, n ).vector;
1608 return vector_float( w );
1609 }
1610#endif //DOXYGEN_SKIP
1611
1612
1613#ifndef DOXYGEN_SKIP
1621 static vector_float const view_array_with_stride( float const* base, size_t stride, size_t n ){
1622 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1623 *w = gsl_vector_float_const_view_array_with_stride( base, stride, n ).vector;
1624 return vector_float( w );
1625 }
1626#endif //DOXYGEN_SKIP
1627
1628
1635 vector_float subvector( size_t i, size_t n ){
1636 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1637 *w = gsl_vector_float_subvector( get(), i, n ).vector;
1638 return vector_float( w );
1639 }
1640
1641
1649 vector_float subvector_with_stride( size_t i, size_t stride, size_t n ){
1650 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1651 *w = gsl_vector_float_subvector_with_stride( get(), i, stride, n ).vector;
1652 return vector_float( w );
1653 }
1654
1655
1662 vector_float const const_subvector( size_t i, size_t n ) const {
1663 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1664 *w = gsl_vector_float_const_subvector( get(), i, n ).vector;
1665 return vector_float( w );
1666 }
1667
1668
1676 vector_float const const_subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1677 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1678 *w = gsl_vector_float_const_subvector_with_stride( get(), i, stride, n ).vector;
1679 return vector_float( w );
1680 }
1681
1682
1683#ifndef DOXYGEN_SKIP
1690 vector_float const subvector( size_t i, size_t n ) const {
1691 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1692 *w = gsl_vector_float_const_subvector( get(), i, n ).vector;
1693 return vector_float( w );
1694 }
1695#endif //DOXYGEN_SKIP
1696
1697
1698#ifndef DOXYGEN_SKIP
1706 vector_float const subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1707 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1708 *w = gsl_vector_float_const_subvector_with_stride( get(), i, stride, n ).vector;
1709 return vector_float( w );
1710 }
1711#endif //DOXYGEN_SKIP
1712
1713
1720 template<typename ARRAY>
1721 static vector_float view_array( ARRAY& v, size_t n = 0 ){
1722 if(n > v.size())
1723 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1724 if(0 == n)
1725 n = v.size();
1726 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1727 *w = gsl_vector_float_view_array( v.data(), n ).vector;
1728 return vector_float( w );
1729 }
1730
1731
1739 template<typename ARRAY>
1740 static vector_float view_array_with_stride( ARRAY& base, size_t stride, size_t n=0 ){
1741 if(0 == n)
1742 n = base.size()/stride;
1743 if((n-1)*stride > base.size())
1744 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1745 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1746 *w = gsl_vector_float_view_array_with_stride( base.data(), stride, n ).vector;
1747 return vector_float( w );
1748 }
1749
1750
1757 template<typename ARRAY>
1758 static vector_float const const_view_array( ARRAY const& v, size_t n=0 ){
1759 if(n > v.size())
1760 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1761 if(0 == n)
1762 n = v.size();
1763 gsl_vector_float* w = static_cast<gsl_vector_float *>( malloc( sizeof( gsl_vector_float ) ) );
1764 *w = gsl_vector_float_const_view_array( v.data(), n ).vector;
1765 return vector_float( w );
1766 }
1767
1768
1776 template<typename ARRAY>
1777 static vector_float const const_view_array_with_stride( ARRAY const& base, size_t stride, size_t n=0 ){
1778 if(0 == n)
1779 n = base.size()/stride;
1780 if((n-1)*stride > base.size())
1781 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1782 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1783 *w = gsl_vector_float_const_view_array_with_stride( base.data(), stride, n ).vector;
1784 return vector_float( w );
1785 }
1786
1787
1788#ifndef DOXYGEN_SKIP
1795 template<typename ARRAY>
1796 static vector_float const view_array( ARRAY const& v, size_t n=0 ){
1797 if(n > v.size())
1798 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1799 if(0 == n)
1800 n = v.size();
1801 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1802 *w = gsl_vector_float_const_view_array( v.data(), n ).vector;
1803 return vector_float( w );
1804 }
1805#endif //DOXYGEN_SKIP
1806
1807#ifndef DOXYGEN_SKIP
1815 template<typename ARRAY>
1816 static vector_float const view_array_with_stride( ARRAY const& base, size_t stride, size_t n ){
1817 if(0 == n)
1818 n = base.size()/stride;
1819 if((n-1)*stride > base.size())
1820 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1821 gsl_vector_float* w = static_cast<gsl_vector_float*>( malloc( sizeof( gsl_vector_float ) ) );
1822 *w = gsl_vector_float_const_view_array_with_stride( base.data(), stride, n ).vector;
1823 return vector_float( w );
1824 }
1825#endif //DOXYGEN_SKIP
1826
1827 // Extra allocators from matrix_float objects. The definition must come after matrix_float.
1842 };
1843
1850 inline vector_float::iterator operator+
1851 ( vector_float::iterator::difference_type const n, vector_float::iterator const& i ){ return i + n; }
1852
1861
1870 return i + n; }
1871
1880 return i + n; }
1881
1882}
1883#endif
This class handles vector_floats as shared handles.
Definition: block_float.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_float objects as shared handles.
A class template for the const iterators.
const_iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
const_iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
const_iterator_t< reverse_t > & operator--()
The prefix – operator.
const_iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_base< vector_floatconst, float, reverse_t >::difference_type difference_type
Difference type.
const_iterator_t< reverse_t > operator--(int)
The postfix – operator.
const_iterator_t(vector_float const *v, difference_type position)
This constructor allows vector_float to create non-default iterators.
const_iterator_t< reverse_t > & operator=(const_iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
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.
const_iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
bool operator==(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
difference_type operator-(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.
const_iterator_t< reverse_t > & operator++()
The prefix ++ operator.
const_iterator_t()
The default constructor.
const_iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
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(iterator_t< reverse_t > const &i)
A copy constructor.
The container must have iterator types.
difference_type position
Mark position of iterator within vector_float.
iterator_base()
The iterator is default constructible.
pointer operator->() const
Dereference the pointer.
bool operator<(iterator_base< container, content, reverse_t > const &i) const
The < operator is used to compare iterators.
value_type & reference
An iterator must have a reference type.
void increment()
Increment the iterator.
float value_type
An iterator must have a value type.
bool operator==(iterator_base< container, content, reverse_t > const &i) const
The == operator.
value_type * pointer
An iterator must have a pointer typea.
iterator_base(container *v, difference_type position)
This constructor allows vector_float to create non-default iterators.
container * v
Store a pointer to a vector_float we can iterate over: 0 if no vector_float.
ptrdiff_t difference_type
An iterator must have a difference_type.
std::random_access_iterator_tag iterator_category
An iterator must have an iterator category.
void shift(difference_type const n)
Shift iterator n places.
void decrement()
Decrement the iterator.
difference_type operator-(iterator_base< container, content, reverse_t > const &i) const
The - operator: find distance between two 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.
reference operator*() const
Dereference the pointer.
A class template for the two non-const iterators.
iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
iterator_t< reverse_t > & operator=(iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
iterator_t()
The default constructor.
iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
iterator_t(vector_float *v, difference_type position)
This constructor allows vector_float to create non-default 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-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_t< reverse_t > & operator++()
The prefix ++ operator.
iterator_t< reverse_t > operator--(int)
The postfix – operator.
iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
iterator_t< reverse_t > & operator--()
The prefix – operator.
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_base< vector_float, float, reverse_t >::difference_type difference_type
Difference type.
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.
This class handles vector_float objects as shared handles.
size_t size_type
A container must have a size_type.
int add_constant(float const x)
C++ version of gsl_vector_float_add_constant().
size_type max_size() const
The max size (number of elements) of the vector_float.
int reverse()
C++ version of gsl_vector_float_reverse().
int fprintf(FILE *stream, char const *format) const
C++ version of gsl_vector_float_fprintf().
vector_float const const_subvector(size_t i, size_t n) const
C++ version of gsl_vector_float_const_subvector().
vector_float subvector(size_t i, size_t n)
C++ version of gsl_vector_float_subvector().
reverse_iterator rend()
Get iterator pointing beyond last vector_float element.
const_iterator end() const
Get iterator pointing beyond last vector_float element.
iterator_t< true > reverse_iterator
The reverse_iterator type.
const_reverse_iterator rend() const
Get iterator pointing beyond last vector_float element.
bool operator!=(vector_float const &v) const
Two vector_float objects are different equal if their elements are not identical.
gsl_vector_float const * get() const
Get the gsl_vector_float.
bool operator<=(vector_float const &v) const
A container needs to define an ordering for sorting.
iterator end()
Get iterator pointing beyond last vector_float element.
float get(size_t const i) const
C++ version of gsl_vector_float_get().
const_iterator::difference_type difference_type
A container must have a difference_type.
const_reverse_iterator rbegin() const
Get iterator pointing to first vector_float element.
iterator_t< false > iterator
The iterator type.
static vector_float alloc_row_from_matrix(matrix_float &m, size_t const i)
C++ version of gsl_vector_float_alloc_row_from_matrix().
void set_zero()
C++ version of gsl_vector_float_set_zero().
vector_float(size_t const n)
The default constructor creates a new vector_float with n elements.
int isnull() const
C++ version of gsl_vector_float_isnull().
iterator begin()
Get iterator pointing to first vector_float element.
static vector_float view_array(ARRAY &v, size_t n=0)
C++ version of gsl_vector_float_view_array().
static vector_float const const_view_array(float const *v, size_t n)
C++ version of gsl_vector_float _const_view_array().
bool operator>(vector_float const &v) const
A container needs to define an ordering for sorting.
vector_float const const_subvector_with_stride(size_t i, size_t stride, size_t n) const
C++ version of gsl_vector_float_const_subvector_with_stride().
void set(size_t const i, float x)
C++ version of gsl_vector_float_set().
size_t min_index() const
C++ version of gsl_vector_float_min_index().
float const & operator[](size_t const n) const
Get element at position n by reference ([] operator).
int fscanf(FILE *stream)
C++ version of gsl_vector_float_fscanf().
int add(vector_float const &b)
C++ version of gsl_vector_float_add().
int isneg() const
C++ version of gsl_vector_float_isneg().
static vector_float const const_view_array_with_stride(ARRAY const &base, size_t stride, size_t n=0)
C++ version of gsl_vector_float_const_view_array_with_stride().
void reset()
Stop sharing ownership of the shared pointer.
int isnonneg() const
C++ version of gsl_vector_float_isnonneg().
size_t max_index() const
C++ version of gsl_vector_float_max_index().
void set_all(float x)
C++ version of gsl_vector_float_set_all().
float & operator[](size_t const n)
Get element at position n by reference ([] operator).
const_iterator_t< true > const_reverse_iterator
The const_reverse_t type.
int ispos() const
C++ version of gsl_vector_float_ispos().
bool operator<(vector_float const &v) const
A container needs to define an ordering for sorting.
float value_type
A container must have a value_type.
void swap(vector_float &v)
Swap two vector_float objects.
value_type & reference
A container must have a reference type.
reverse_iterator rbegin()
Get iterator pointing to first vector_float element.
size_type size() const
The size (number of elements) of the vector_float.
gsl_vector_float * get()
Get the gsl_vector_float.
static vector_float view_array(float *v, size_t n)
C++ version of gsl_vector_float_view_array().
bool owns_data
Used to allow a vector that does not own its data.
size_t * count
The shared reference count.
vector_float(vector_float &&v)
Move constructor.
int memcpy(vector_float const &src)
C++ version of gsl_vector_float_memcpy().
float max() const
C++ version of gsl_vector_float_max().
int div(vector_float const &b)
C++ version of gsl_vector_float_div().
value_type * pointer
A container must have a pointer type.
vector_float & operator=(vector_float const &v)
The assignment operator.
static vector_float calloc(size_t const n)
C++ version of gsl_vector_float_calloc().
int scale(float const x)
C++ version of gsl_vector_float_scale().
bool operator>=(vector_float const &v) const
A container needs to define an ordering for sorting.
vector_float()
The default constructor is only really useful for assigning to.
int swap_elements(size_t const i, size_t const j)
C++ version of gsl_vector_float_swap_elements().
static vector_float view_array_with_stride(float *base, size_t stride, size_t n)
C++ version of gsl_vector_float_view_array_with_stride().
int set_basis(size_t i)
C++ version of gsl_vector_float_set_basis().
float min() const
C++ version of gsl_vector_float_min().
void minmax(float &min_out, float &max_out) const
C++ version of gsl_vector_float_minmax().
float * ptr(size_t const i)
C++ version of gsl_vector_float_ptr().
float const * const_ptr(size_t const i) const
C++ version of gsl_vector_float_const_ptr().
int axpby(float const alpha, vector_float const &x, float const beta)
C++ version of gsl_vector_float_axpby().
float * data()
Give access to the data block_float.
static vector_float view_array_with_stride(ARRAY &base, size_t stride, size_t n=0)
C++ version of gsl_vector_float_view_array_with_stride().
size_t use_count() const
Find how many vector_float objects share this pointer.
vector_float(block_float &b, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_float_alloc_from_block().
bool unique() const
Find if this is the only object sharing the gsl_vector_float.
int fread(FILE *stream)
C++ version of gsl_vector_float_fread().
vector_float & operator=(vector_float &&v)
Move operator.
value_type const * const_pointer
A container must have a constant pointer type.
vector_float(V &v, size_t const stride=1)
Construct from an object that implements data() and size().
bool operator==(vector_float const &v) const
Two vector_float objects are identically equal if their elements are identical.
vector_float(vector_float const &v)
The copy constructor.
vector_float subvector_with_stride(size_t i, size_t stride, size_t n)
C++ version of gsl_vector_float_subvector_with_stride().
void minmax_index(size_t *imin, size_t *imax) const
C++ version of gsl_vector_float_minmax_index().
vector_float(vector_float &v, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_float_alloc_from_vector().
value_type const & const_reference
A container must have a constant reference type.
int mul(vector_float const &b)
C++ version of gsl_vector_float_mul().
static vector_float const const_view_array(ARRAY const &v, size_t n=0)
C++ version of gsl_vector_float _const_view_array().
float const * data() const
Give access to the data block_float.
gsl_vector_float * ccgsl_pointer
The shared pointer.
static vector_float alloc_col_from_matrix(matrix_float &m, size_t const j)
C++ version of gsl_vector_float_alloc_col_from_matrix().
static vector_float const const_view_array_with_stride(float const *base, size_t stride, size_t n)
C++ version of gsl_vector_float_const_view_array_with_stride().
int fwrite(FILE *stream) const
C++ version of gsl_vector_float_fwrite().
vector_float(vector_float &v)
The copy constructor.
vector_float(std::initializer_list< float > initializer_list)
Could construct from a std::initializer_list in C++11.
const_iterator begin() const
Get iterator pointing to first vector_float element.
float sum(vector_float const &a) const
C++ version of gsl_vector_float_sum().
vector_float clone() const
The clone function.
void wrap_gsl_vector_float_without_ownership(gsl_vector_float *v)
This function is intended mainly for internal use.
bool empty() const
Find if the vector_float is empty.
~vector_float()
The destructor only deletes the pointers if count reaches zero.
int sub(vector_float const &b)
C++ version of gsl_vector_float_sub().
const_iterator_t< false > const_iterator
The const_iterator type.
void minmax(float *min_out, float *max_out) const
C++ version of gsl_vector_float_minmax().
double beta(rng const &r, double const a, double const b)
C++ version of gsl_ran_beta().
Definition: randist.hpp:262
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