ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
vector_complex_float.hpp
Go to the documentation of this file.
1/*
2 * $Id: vector_complex_float.hpp 314 2014-02-22 14:31:16Z jdl3 $
3 * Copyright (C) 2010, 2011, 2019, 2020, 2024 John D Lamb
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef CCGSL_VECTOR_COMPLEX_FLOAT_HPP
21#define CCGSL_VECTOR_COMPLEX_FLOAT_HPP
22
23#include<gsl/gsl_vector_complex_float.h>
24#include<new>
25#include<iterator>
26
27#include"exception.hpp"
29#include"vector_float.hpp"
30#ifdef __GXX_EXPERIMENTAL_CXX0X__
31#include<complex>
32#endif
33
34// This file is a template
35#define CCGSL_MTY 2
36
37namespace gsl {
38 // declare matrix_complex_float class
39 class matrix_complex_float;
47 public:
52 owns_data = false;
53 ccgsl_pointer = 0;
54 count = 0; // initially nullptr will do
55 }
56 // Refines random access container
57 // Refines assignable
62 explicit vector_complex_float( size_t const n )
63 : owns_data(true) {
64 if( n > 0 ) ccgsl_pointer = gsl_vector_complex_float_alloc( n );
65 else { ccgsl_pointer = new gsl_vector_complex_float; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
66 // just plausibly we could allocate vector_complex_float but not count
67 try { count = new size_t; } catch( std::bad_alloc& e ){
68 // try to tidy up before rethrowing
69 if( n > 0 ) gsl_vector_complex_float_free( ccgsl_pointer );
70 else delete ccgsl_pointer;
71 throw e;
72 }
73 *count = 1; // initially there is just one reference to ccgsl_pointer
74 }
75#ifndef DOXYGEN_SKIP
80 explicit vector_complex_float( int const n )
81 : owns_data(true) {
82 if( n > 0 ) ccgsl_pointer = gsl_vector_complex_float_alloc( static_cast<size_t>( n ) );
83 else if(n<0)
84 gsl_error("failed tring to make a vector of negative length",
85 __FILE__, __LINE__, exception::GSL_EDOM );
86 else { ccgsl_pointer = new gsl_vector_complex_float; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
87 // just plausibly we could allocate vector_complex_float but not count
88 try { count = new size_t; } catch( std::bad_alloc& e ){
89 // try to tidy up before rethrowing
90 if( n > 0 ) gsl_vector_complex_float_free( ccgsl_pointer );
91 else delete ccgsl_pointer;
92 throw e;
93 }
94 *count = 1; // initially there is just one reference to ccgsl_pointer
95 }
96#endif // DOXYGEN_SKIP
102 explicit vector_complex_float( gsl_vector_complex_float* v )
103 : owns_data(true){
104 ccgsl_pointer = v;
105 // just plausibly we could fail to allocate count: no further action needed.
106 count = new size_t;
107 *count = 1; // initially there is just one reference to ccgsl_pointer
108 }
109#ifdef __GXX_EXPERIMENTAL_CXX0X__
114 vector_complex_float( std::initializer_list<std::complex<float> > initializer_list )
115 : owns_data{true}{
116 size_t const n = initializer_list.size();
117 ccgsl_pointer = gsl_vector_complex_float_alloc( n );
118 // just plausibly we could allocate vector but not count
119 try { count = new size_t; } catch( std::bad_alloc& e ){
120 // try to tidy up before rethrowing
121 if( n > 0 ) gsl_vector_complex_float_free( ccgsl_pointer );
122 else delete ccgsl_pointer;
123 throw e;
124 }
125 *count = 1; // initially there is just one reference to ccgsl_pointer
126 // now copy
127 auto p = begin();
128 for( auto x : initializer_list ){
129 *p = complex_float( std::move( x ) ); ++p;
130 }
131 }
132#endif
133 // copy constructor
139 : owns_data(v.owns_data),
141 if( count != 0 ) ++*count; // vector_complex_float 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_complex_float_free( ccgsl_pointer );
153 else delete ccgsl_pointer; }
154 delete count;
155 }
156 // Then copy
159 count = v.count;
160 if( count != 0 ) ++*count; // vector_complex_float is now shared.
161 return *this;
162 }
163 // clone()
170 vector_complex_float copy( get()->size );
171 // Now copy
172 gsl_vector_complex_float_memcpy( copy.get(), get() );
173 // return new object
174 return copy;
175 }
176 // destructor
181 if( count != 0 and --*count == 0 ){
182 // could have allocated null pointer
183 if( ccgsl_pointer != 0 and owns_data ){
184 if( ccgsl_pointer->size > 0 ) gsl_vector_complex_float_free( ccgsl_pointer );
185 else delete ccgsl_pointer; }
186 delete count;
187 }
188 }
197 void wrap_gsl_vector_complex_float_without_ownership( gsl_vector_complex_float* v ){
198 if( count != 0 and --*count == 0 ){
199 // could have allocated null pointer
200 if( ccgsl_pointer != 0 ){
201 if( ccgsl_pointer->size != 0 ) gsl_vector_complex_float_free( ccgsl_pointer );
202 else delete ccgsl_pointer; }
203 }
204 ccgsl_pointer = v;
205 if(0 == count) count = new size_t;
206 *count = 1;
207 owns_data = false; // should never be able to delete ccgsl_pointer
208 }
209 // Refines equality comparable
210 // == operator
217 bool operator==( vector_complex_float const& v ) const {
218 // trivially equal if gsl_vector_complex_float*s are identical
219 if( ccgsl_pointer == v.ccgsl_pointer ) return true;
220 // trivially not equal if one is zero: != should be same as xor here
221 if( (ccgsl_pointer == 0) != (v.ccgsl_pointer == 0 ) ) return false;
222 // trivially not equal if sizes are different
223 if( ccgsl_pointer->size != v.ccgsl_pointer->size ) return false;
224 // check elementwise for equality
225 for( size_t i = 0; i < CCGSL_MTY * ccgsl_pointer->size; ++i )
226 if( *(ccgsl_pointer->data + i) != *(v.ccgsl_pointer->data + i) )
227 return false;
228 return true;
229 }
233 void reset(){ vector_complex_float().swap( *this ); }
234#ifdef __GXX_EXPERIMENTAL_CXX0X__
240 : owns_data (v.owns_data),
241 ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
242 std::swap( count, v.count );
243 v.ccgsl_pointer = nullptr;
244 }
251 vector_complex_float( std::move( v ) ).swap( *this );
252 return *this;
253 }
254#endif
255 // != operator
262 bool operator!=( vector_complex_float const& v ) const { return not operator==( v ); }
263 // Refines forward container
264 // Refines less than comparable
265 // operator<
274 bool operator<( vector_complex_float const& v ) const {
275 // null vector_complex_float comes first
276 if( ccgsl_pointer == 0 ) return v.ccgsl_pointer != 0;
277 // if v is null then this > v
278 if( v.ccgsl_pointer == 0 ) return false;
279 // Now compare elementwise
280 size_t const size = ccgsl_pointer->size;
281 size_t const v_size = v.ccgsl_pointer->size;
282 size_t const min = size > v_size ? size : v_size;
283 for( size_t i = 0; i < min; ++i ){
284 complex_float const t = gsl_vector_complex_float_get( ccgsl_pointer, i );
285 complex_float const u =gsl_vector_complex_float_get( v.ccgsl_pointer, i );
286 if( t < u ) return true;
287 if( u < t ) return false;
288 }
289 // elements match.
290 return size < v_size;
291 }
292 // operator>
301 bool operator>( vector_complex_float const& v ) const {
302 // null vector_complex_float comes first
303 if( ccgsl_pointer == 0 ) return false;
304 // if v is null then this > v
305 if( v.ccgsl_pointer == 0 ) return true;
306 // Now compare elementwise
307 size_t const size = ccgsl_pointer->size;
308 size_t const v_size = v.ccgsl_pointer->size;
309 size_t const min = size > v_size ? size : v_size;
310 for( size_t i = 0; i < min; ++i ){
311 complex_float const t = gsl_vector_complex_float_get( ccgsl_pointer, i );
312 complex_float const u =gsl_vector_complex_float_get( v.ccgsl_pointer, i );
313 if( t > u ) return true;
314 if( u > t ) return false;
315 }
316 // elements match.
317 return size > v_size;
318 }
319 // operator<=
328 bool operator<=( vector_complex_float const& v ) const {
329 return operator<( v ) or operator==( v );
330 }
331 // operator>=
340 bool operator>=( vector_complex_float const& v ) const {
341 return operator>( v ) or operator==( v );
342 }
343 // Refines container
344 // type value_type
349 // type reference
354 // type const_reference
359 // type pointer
364 // type const_pointer
369 // type iterator
370 private:
375 template<typename container, typename content,bool reverse_t>
378 public:
394 typedef std::random_access_iterator_tag iterator_category;
395 // // type iterator_traits<block_complex_float>::difference_type
399 typedef ptrdiff_t difference_type;
400 public:
401 // // operator*
407 // First check that iterator is initialised.
408 if( v == 0 ){
409 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
410 return complex_float_ref( 0 );
411 } else if( v->ccgsl_pointer == 0 ){
412 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
413 return complex_float_ref( 0 );
414 }
415 // Check that position make sense
416 if( position >= static_cast<difference_type>( v->size() ) ){
417 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
418 return complex_float_ref( 0 );
419 }
420 if( position <= -1 ){
421 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
422 return complex_float_ref( 0 );
423 }
424 // position and v are valid: return data
425 return complex_float_ref( v->ccgsl_pointer->data + CCGSL_MTY * position * v->ccgsl_pointer->stride );
426 }
427 // // operator->
433 // First check that iterator is initialised.
434 if( v == 0 ){
435 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
436 return pointer( 0 );
437 } else if( v->ccgsl_pointer == 0 ){
438 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
439 return pointer( 0 );
440 }
441 // Check that position make sense
442 if( position >= static_cast<difference_type>( v->size() ) ){
443 gsl_error( "trying to dereference end()", __FILE__, __LINE__, exception::GSL_EFAILED );
444 return pointer( 0 );
445 }
446 if( position <= -1 ){
447 gsl_error( "trying to dereference rend()", __FILE__, __LINE__, exception::GSL_EFAILED );
448 return pointer( 0 );
449 }
450 // position and v are valid: return data
451 return pointer( v->ccgsl_pointer->data + CCGSL_MTY * position * v->ccgsl_pointer->stride );
452 }
453 // // operator[]
460 // First check that iterator is initialised.
461 if( v == 0 ){
462 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
463 return reference( 0 );
464 } else if( v->ccgsl_pointer == 0 ){
465 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
466 return reference( 0 );
467 }
468 // Check that position make sense
469 difference_type const p = reverse_t ? position - n : position + n;
470 if( p >= static_cast<difference_type>( v->size() ) ){
471 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
472 return reference( 0 );
473 }
474 if( p <= -1 ){
475 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
476 return reference( 0 );
477 }
478 // p is a valid position
479 return reference( v->ccgsl_pointer->data + CCGSL_MTY * p * v->ccgsl_pointer->stride );
480 }
481 // // operator-: find distance between two iterators
488 // Warn if either iterator undefined
489 if( v == 0 or i.v == 0 ){
490 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
491 return 0;
492 } else if( v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
493 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
494 return 0;
495 }
496 // Warn if iterators do not point to same vector_complex_float
497 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
498 gsl_error( "trying to take difference of iterators for different vector_complex_float objects", __FILE__, __LINE__,
500 return 0;
501 }
502 return reverse_t ? i.position - position : position - i.position;
503 }
504 // // operator!=
505 // // operator<
512 return this->v == i.v and this->position == i.position;
513 }
520 return not this->operator==( i );
521 }
530 // Warn if either iterator undefined
531 if( v == 0 or i.v == 0 ){
532 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
533 return false;
534 }
535 // Warn if iterators do not point to same vector_complex_float
536 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
537 gsl_error( "trying to take difference of iterators for different vector_complex_float objects", __FILE__, __LINE__,
539 return false;
540 }
541 return reverse_t ? i.position < position : position < i.position;
542 }
543 protected:
548 void increment(){
549 // Only makes sense if v points to a vector_complex_float
550 if( v == 0 ){
551 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
552 return;
553 } else if( v->ccgsl_pointer == 0 ){
554 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
555 return;
556 }
557 // increment position and check against size
558 if( reverse_t ){ if( position >= 0 ) --position; }
559 else { if( position < static_cast<difference_type>( v->size() ) ) ++position; }
560 }
565 void decrement(){
566 // Only makes sense if v points to a vector_complex_float
567 if( v == 0 ){
568 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
569 return;
570 } else if( v->ccgsl_pointer == 0 ){
571 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
572 return;
573 }
574 // decrement position and check against size
575 if( reverse_t ){ if( position < static_cast<difference_type>( v->size() ) ) ++position; }
576 else { if( position >= 0 ) --position; }
577 }
582 void shift( difference_type const n ){
583 // Warn if iterator undefined
584 if( v == 0 ){
585 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
586 return;
587 } else if( v->ccgsl_pointer == 0 ){
588 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
589 return;
590 }
591 position += reverse_t ? -n : n;
592 }
596 iterator_base(){ v = 0; }
603 : v( v ), position( position ){}
607 container* v;
612 };
613 // Need to know about const_iterator_t
614 template<bool reverse_t> class const_iterator_t;
618 template<bool reverse_t> class iterator_t : public iterator_base<vector_complex_float,float,reverse_t>{
619 public:
620 // // Refines output iterator
621 // // operator=
629 return *this;
630 }
631 // // Refines forward iterator
632 // // operator++ (both)
639 return *this;
640 }
646 // return value
649 return result;
650 }
651 // // Refines bidirectional iterator
652 // // operator-- (both)
659 return *this;
660 }
666 // return value
669 return result;
670 }
676 // // operator+=
683 this->shift( n );
684 return *this;
685 }
686 // // operator-=
693 this->shift( -n );
694 return *this;
695 }
696 // // operator+ (n+i)(i+n)
705 result.shift( n );
706 return result;
707 }
708 // // operator- (n-i)(i-n)(i-j)
717 result.shift( -n );
718 return result;
719 }
727 }
734 // Warn if either iterator undefined
735 if( this->v == 0 or i.v == 0 ){
736 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
737 return 0;
738 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
739 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
740 return 0;
741 }
742 // Warn if iterators do not point to same vector_complex_float
743 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
744 gsl_error( "trying to take difference of iterators for different vector_complex_float objects", __FILE__, __LINE__,
746 return 0;
747 }
748 return reverse_t ? i.position - this->position : this->position - i.position;
749 }
756 return this->v == i.v and this->position == i.position;
757 }
764 return not this->operator==( i );
765 }
771 bool operator<( const_iterator_t<reverse_t> const& i ) const {
772 // Warn if either iterator undefined
773 if( this->v == 0 or i.v == 0 ){
774 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
775 return false;
776 }
777 // Warn if iterators do not point to same vector_complex_float
778 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
779 gsl_error( "trying to take difference of iterators for different vector_complex_float objects", __FILE__, __LINE__,
781 return false;
782 }
783 return reverse_t ? i.position < this->position : this->position < i.position;
784 }
789 protected:
791 // We need a constructor for vector_complex_float
798 : iterator_base<vector_complex_float,float,reverse_t>( v, position ){}
799 };
803 template<bool reverse_t> class const_iterator_t
804 : public iterator_base<vector_complex_float const,float,reverse_t>{
805 public:
806 // // Refines output iterator
807 // // operator=
815 return *this;
816 }
817 // // Refines forward iterator
818 // // operator++ (both)
825 return *this;
826 }
832 // return value
835 return result;
836 }
837 // // Refines bidirectional iterator
838 // // operator-- (both)
845 return *this;
846 }
852 // return value
855 return result;
856 }
862 // // operator+=
869 this->shift( n );
870 return *this;
871 }
872 // // operator-=
879 this->shift( -n );
880 return *this;
881 }
882 // // operator+ (n+i)(i+n)
891 result += n;
892 return result;
893 }
894 // // operator- (n-i)(i-n)(i-j)
903 result -= n;
904 return result;
905 }
913 }
920 // Warn if either iterator undefined
921 if( this->v == 0 or i.v == 0 ){
922 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
923 return 0;
924 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
925 gsl_error( "vector_complex_float not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
926 return 0;
927 }
928 // Warn if iterators do not point to same vector_complex_float
929 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
930 gsl_error( "trying to take difference of iterators for different vector_complex_float objects", __FILE__, __LINE__,
932 return 0;
933 }
934 return reverse_t ? i.position - this->position : this->position - i.position;
935 }
947 }
953 bool operator==( iterator_t<reverse_t> const& i ) const {
954 return this->v == i.v and this->position == i.position;
955 }
961 bool operator!=( iterator_t<reverse_t> const& i ) const {
962 return not this->operator==( i );
963 }
969 bool operator<( iterator_t<reverse_t> const& i ) const {
970 // Warn if either iterator undefined
971 if( this->v == 0 or i.v == 0 ){
972 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
973 return false;
974 }
975 // Warn if iterators do not point to same vector_complex_float
976 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
977 gsl_error( "trying to take difference of iterators for different vector_complex_float objects", __FILE__, __LINE__,
979 return false;
980 }
981 return reverse_t ? i.position < this->position : this->position < i.position;
982 }
989 return this->v == i.v and this->position == i.position;
990 }
997 return not this->operator==( i );
998 }
1005 // Warn if either iterator undefined
1006 if( this->v == 0 or i.v == 0 ){
1007 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1008 return false;
1009 }
1010 // Warn if iterators do not point to same vector_complex
1011 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1012 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
1014 return false;
1015 }
1016 return reverse_t ? i.position < this->position : this->position < i.position;
1017 }
1018 protected:
1019 // We need a constructor for vector_complex_float
1027 : iterator_base<vector_complex_float const,float,reverse_t>( v, position ){}
1028 };
1029 public:
1046 // type difference_type
1051 // type size_type
1055 typedef size_t size_type;
1056 // begin()
1062 return iterator( this, 0 );
1063 }
1069 return const_iterator( this, 0 );
1070 }
1071 // end()
1077 if( ccgsl_pointer == 0 ) return iterator( this, 0 );
1078 return iterator( this, size() );
1079 }
1085 if( ccgsl_pointer == 0 ) return const_iterator( this, 0 );
1086 return const_iterator( this, size() );
1087 }
1088 // size()
1093 size_type size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1101 float* data() {
1102 if( ccgsl_pointer == 0 ) gsl_error( "null vector", __FILE__, __LINE__, GSL_EFAULT );
1103#ifndef GSL_RANGE_CHECK_OFF
1104 if( ccgsl_pointer->stride != 1 )
1105 gsl_error( "vector does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1106#endif
1107 return ccgsl_pointer->data; }
1115 float const* data() const {
1116 if( ccgsl_pointer == 0 ) gsl_error( "null vector", __FILE__, __LINE__, GSL_EFAULT );
1117#ifndef GSL_RANGE_CHECK_OFF
1118 if( ccgsl_pointer->stride != 1 )
1119 gsl_error( "vector does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1120#endif
1121 return ccgsl_pointer->data; }
1122 // max_size()
1128 size_type max_size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1129 // empty()
1134 bool empty() const { return ccgsl_pointer == 0 or ccgsl_pointer->size == 0; }
1135 // swap() --- should work even if sizes don't match
1142 gsl_vector_complex_float* tmp = ccgsl_pointer; ccgsl_pointer = v.ccgsl_pointer; v.ccgsl_pointer = tmp;
1143 size_t* tmp2 = count; count = v.count; v.count = tmp2;
1144 }
1145 // Refines reversible container
1146 // rbegin()
1152 if( ccgsl_pointer ==0 ) return reverse_iterator( this, 0 );
1153 return reverse_iterator( this, size() - 1 );
1154 }
1160 if( ccgsl_pointer ==0 ) return const_reverse_iterator( this, 0 );
1161 return const_reverse_iterator( this, size() - 1 );
1162 }
1163 // rend()
1169 return reverse_iterator( this, -1 );
1170 }
1176 return const_reverse_iterator( this, -1 );
1177 }
1178 // operator[]
1185 // First check that iterator is initialised.
1186 if( ccgsl_pointer == 0 ){
1187 gsl_error( "vector_complex_float is null", __FILE__, __LINE__, exception::GSL_EFAILED );
1188 return complex_float_ref( 0 );
1189 }
1190#ifndef GSL_RANGE_CHECK_OFF
1191 // Check that position make sense
1192 if( n >= size() ){
1193 gsl_error( "trying to read beyond end of vector_complex_float", __FILE__, __LINE__, exception::GSL_EFAILED );
1194 return complex_float_ref( 0 );
1195 }
1196 // n is a valid position
1197#endif
1198 return complex_float_ref( ccgsl_pointer->data + CCGSL_MTY * n * ccgsl_pointer->stride );
1199 }
1205 complex_float_ref const operator[]( size_t const n ) const {
1206 // First check that iterator is initialised.
1207 if( ccgsl_pointer == 0 ){
1208 gsl_error( "vector_complex_float is null", __FILE__, __LINE__, exception::GSL_EFAILED );
1209 return complex_float_ref( 0 );
1210 }
1211#ifndef GSL_RANGE_CHECK_OFF
1212 // Check that position make sense
1213 if( n >= size() ){
1214 gsl_error( "trying to read beyond end of vector_complex_float", __FILE__, __LINE__, exception::GSL_EFAILED );
1215 return complex_float_ref( 0 );
1216 }
1217 // n is a valid position
1218#endif
1219 return complex_float_ref( ccgsl_pointer->data + n * ccgsl_pointer->stride );
1220 }
1221 private:
1229 gsl_vector_complex_float* ccgsl_pointer;
1233 size_t* count;
1234 public:
1235 // shared reference functions
1240 gsl_vector_complex_float* get() { return ccgsl_pointer; }
1245 gsl_vector_complex_float const* get() const { return ccgsl_pointer; }
1251 bool unique() const { return count != 0 and *count == 1; }
1256 size_t use_count() const { return count == 0 ? 0 : *count; }
1262#ifdef __GXX_EXPERIMENTAL_CXX0X__
1263 explicit
1264#endif
1265 operator bool() const { return ccgsl_pointer != 0; }
1266
1267 // GSL functions
1274 static vector_complex_float calloc( size_t const n ){ return vector_complex_float( gsl_vector_complex_float_calloc( n ) ); }
1278 void set_zero(){ gsl_vector_complex_float_set_zero( get() ); }
1283 void set_all( complex_float x ){ gsl_vector_complex_float_set_all( get(), x ); }
1289 int set_basis( size_t i ){ return gsl_vector_complex_float_set_basis( get(), i ); }
1295 int memcpy( vector_complex_float const& src ){ return gsl_vector_complex_float_memcpy( get(), src.get() ); }
1300 int reverse(){ return gsl_vector_complex_float_reverse( get() ); }
1307 int swap_elements( size_t const i, size_t const j ){
1308 return gsl_vector_complex_float_swap_elements( get(), i, j ); }
1314 int add( vector_complex_float const& b ){ return gsl_vector_complex_float_add( get(), b.get() ); }
1320 int sub( vector_complex_float const& b ){ return gsl_vector_complex_float_sub( get(), b.get() ); }
1326 int mul( vector_complex_float const& b ){ return gsl_vector_complex_float_mul( get(), b.get() ); }
1332 int div( vector_complex_float const& b ){ return gsl_vector_complex_float_div( get(), b.get() ); }
1338 int scale( complex_float const x ){ return gsl_vector_complex_float_scale( get(), x ); }
1344 int add_constant( complex_float const x ){ return gsl_vector_complex_float_add_constant( get(), x ); }
1352 int axpby( complex_float const alpha, vector_complex_float const& x,
1353 complex_float const beta ){
1354 return gsl_vector_complex_float_axpby( alpha, x.get(), beta, get() );
1355 }
1360 int isnull() const { return gsl_vector_complex_float_isnull( get() ); }
1365 int ispos() const { return gsl_vector_complex_float_ispos( get() ); }
1370 int isneg() const { return gsl_vector_complex_float_isneg( get() ); }
1375 int isnonneg() const { return gsl_vector_complex_float_isnonneg( get() ); }
1381 complex_float get( size_t const i ) const { return gsl_vector_complex_float_get( get(), i ); }
1387 void set( size_t const i, complex_float x ){ gsl_vector_complex_float_set( get(), i, x ); }
1393 complex_float_ptr ptr( size_t const i ){
1394 if( i >= ccgsl_pointer->size )
1395 gsl_error( "Index out of range", __FILE__, __LINE__, exception::GSL_EINVAL );
1396 return complex_float_ptr( ccgsl_pointer->data + CCGSL_MTY * i ); }
1402 complex_float_ptr const const_ptr( size_t const i ){
1403 if( i >= ccgsl_pointer->size )
1404 gsl_error( "Index out of range", __FILE__, __LINE__, exception::GSL_EINVAL );
1405 return complex_float_ptr( ccgsl_pointer->data + CCGSL_MTY * i ); }
1411 int fread( FILE* stream ){ return gsl_vector_complex_float_fread( stream, get() ); }
1417 int fwrite( FILE* stream ) const { return gsl_vector_complex_float_fwrite( stream, get() ); }
1423 int fscanf( FILE* stream ){ return gsl_vector_complex_float_fscanf( stream, get() ); }
1430 int fprintf( FILE* stream, char const* format ) const {
1431 return gsl_vector_complex_float_fprintf( stream, get(), format ); }
1439 vector_complex_float( block_complex_float& b, size_t const offset, size_t const n, size_t const stride = 1 ){
1440 ccgsl_pointer = gsl_vector_complex_float_alloc_from_block( b.get(), offset, n, stride );
1441 // just plausibly we could allocate vector_complex_float but not count
1442 try { count = new size_t; } catch( std::bad_alloc& e ){
1443 // try to tidy up before rethrowing
1444 gsl_vector_complex_float_free( ccgsl_pointer );
1445 throw e;
1446 }
1447 *count = 1; // initially there is just one reference to ccgsl_pointer
1448 }
1456 vector_complex_float( vector_complex_float& v, size_t const offset, size_t const n, size_t const stride = 1 ){
1457 ccgsl_pointer = gsl_vector_complex_float_alloc_from_vector( v.get(), offset, n, stride );
1458 // just plausibly we could allocate vector_complex_float but not count
1459 try { count = new size_t; } catch( std::bad_alloc& e ){
1460 // try to tidy up before rethrowing
1461 gsl_vector_complex_float_free( ccgsl_pointer );
1462 throw e;
1463 }
1464 *count = 1; // initially there is just one reference to ccgsl_pointer
1465 }
1488 gsl::vector_float const real() const {
1512 gsl::vector_float const imag() const {
1520 static vector_complex_float view_array( float* v, size_t n ){
1521 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1522 *w = gsl_vector_complex_float_view_array( v, n ).vector;
1523 return vector_complex_float( w );
1524 }
1525
1526
1534 static vector_complex_float view_array_with_stride( float* base, size_t stride, size_t n ){
1535 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1536 *w = gsl_vector_complex_float_view_array_with_stride( base, stride, n ).vector;
1537 return vector_complex_float( w );
1538 }
1539
1540
1547 static vector_complex_float const const_view_array( float const* v, size_t n ){
1548 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float *>( malloc( sizeof( gsl_vector_complex_float ) ) );
1549 *w = gsl_vector_complex_float_const_view_array( v, n ).vector;
1550 return vector_complex_float( w );
1551 }
1552
1553
1561 static vector_complex_float const const_view_array_with_stride( float const* base, size_t stride, size_t n ){
1562 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1563 *w = gsl_vector_complex_float_const_view_array_with_stride( base, stride, n ).vector;
1564 return vector_complex_float( w );
1565 }
1566
1567
1568#ifndef DOXYGEN_SKIP
1575 static vector_complex_float const view_array( float const* v, size_t n ){
1576 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1577 *w = gsl_vector_complex_float_const_view_array( v, n ).vector;
1578 return vector_complex_float( w );
1579 }
1580#endif //DOXYGEN_SKIP
1581
1582
1583#ifndef DOXYGEN_SKIP
1591 static vector_complex_float const view_array_with_stride( float const* base, size_t stride, size_t n ){
1592 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1593 *w = gsl_vector_complex_float_const_view_array_with_stride( base, stride, n ).vector;
1594 return vector_complex_float( w );
1595 }
1596#endif //DOXYGEN_SKIP
1597
1598
1605 vector_complex_float subvector( size_t i, size_t n ){
1606 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1607 *w = gsl_vector_complex_float_subvector( get(), i, n ).vector;
1608 return vector_complex_float( w );
1609 }
1610
1611
1619 vector_complex_float subvector_with_stride( size_t i, size_t stride, size_t n ){
1620 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1621 *w = gsl_vector_complex_float_subvector_with_stride( get(), i, stride, n ).vector;
1622 return vector_complex_float( w );
1623 }
1624
1625
1632 vector_complex_float const const_subvector( size_t i, size_t n ) const {
1633 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1634 *w = gsl_vector_complex_float_const_subvector( get(), i, n ).vector;
1635 return vector_complex_float( w );
1636 }
1637
1638
1646 vector_complex_float const const_subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1647 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1648 *w = gsl_vector_complex_float_const_subvector_with_stride( get(), i, stride, n ).vector;
1649 return vector_complex_float( w );
1650 }
1651
1652
1653#ifndef DOXYGEN_SKIP
1660 vector_complex_float const subvector( size_t i, size_t n ) const {
1661 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1662 *w = gsl_vector_complex_float_const_subvector( get(), i, n ).vector;
1663 return vector_complex_float( w );
1664 }
1665#endif //DOXYGEN_SKIP
1666
1667
1668#ifndef DOXYGEN_SKIP
1676 vector_complex_float const subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1677 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1678 *w = gsl_vector_complex_float_const_subvector_with_stride( get(), i, stride, n ).vector;
1679 return vector_complex_float( w );
1680 }
1681#endif //DOXYGEN_SKIP
1682
1683
1690 template<typename ARRAY>
1691 static vector_complex_float view_array( ARRAY& v, size_t n = 0 ){
1692 if(n > v.size())
1693 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1694 if(0 == n)
1695 n = v.size();
1696 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1697 *w = gsl_vector_complex_float_view_array( v.data(), n ).vector;
1698 return vector_complex_float( w );
1699 }
1700
1701
1709 template<typename ARRAY>
1710 static vector_complex_float view_array_with_stride( ARRAY& base, size_t stride, size_t n=0 ){
1711 if(0 == n)
1712 n = base.size()/stride;
1713 if((n-1)*stride > base.size())
1714 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1715 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1716 *w = gsl_vector_complex_float_view_array_with_stride( base.data(), stride, n ).vector;
1717 return vector_complex_float( w );
1718 }
1719
1720
1727 template<typename ARRAY>
1728 static vector_complex_float const const_view_array( ARRAY const& v, size_t n=0 ){
1729 if(n > v.size())
1730 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1731 if(0 == n)
1732 n = v.size();
1733 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float *>( malloc( sizeof( gsl_vector_complex_float ) ) );
1734 *w = gsl_vector_complex_float_const_view_array( v.data(), n ).vector;
1735 return vector_complex_float( w );
1736 }
1737
1738
1746 template<typename ARRAY>
1747 static vector_complex_float const const_view_array_with_stride( ARRAY const& base, size_t stride, size_t n=0 ){
1748 if(0 == n)
1749 n = base.size()/stride;
1750 if((n-1)*stride > base.size())
1751 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1752 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1753 *w = gsl_vector_complex_float_const_view_array_with_stride( base.data(), stride, n ).vector;
1754 return vector_complex_float( w );
1755 }
1756
1757
1758#ifndef DOXYGEN_SKIP
1765 template<typename ARRAY>
1766 static vector_complex_float const view_array( ARRAY const& v, size_t n=0 ){
1767 if(n > v.size())
1768 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1769 if(0 == n)
1770 n = v.size();
1771 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1772 *w = gsl_vector_complex_float_const_view_array( v.data(), n ).vector;
1773 return vector_complex_float( w );
1774 }
1775#endif //DOXYGEN_SKIP
1776
1777
1778#ifndef DOXYGEN_SKIP
1786 template<typename ARRAY>
1787 static vector_complex_float const view_array_with_stride( ARRAY const& base, size_t stride, size_t n ){
1788 if(0 == n)
1789 n = base.size()/stride;
1790 if((n-1)*stride > base.size())
1791 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1792 gsl_vector_complex_float* w = static_cast<gsl_vector_complex_float*>( malloc( sizeof( gsl_vector_complex_float ) ) );
1793 *w = gsl_vector_complex_float_const_view_array_with_stride( base.data(), stride, n ).vector;
1794 return vector_complex_float( w );
1795 }
1796#endif //DOXYGEN_SKIP
1797
1798 // Extra allocators from matrix_complex_float objects. The definition must come after matrix_complex_float.
1813 };
1814
1823
1832
1841 return i + n; }
1842
1851 return i + n; }
1852
1853}
1854#undef CCGSL_MTY
1855#endif
This class handles vector_complex_floats as shared handles.
This class can be used like a pointer for complex_float objects so that we can iterate over a vector ...
This class can be used like a reference for complex_float objects so that we can iterate over a vecto...
This class handles complex_float numbers.
@ 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
This class handles matrix_complex_float objects as shared handles.
A class template for the const iterators.
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.
const_iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
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(vector_complex_float const *v, difference_type position)
This constructor allows vector_complex_float to create non-default iterators.
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.
iterator_base< vector_complex_floatconst, float, reverse_t >::difference_type difference_type
Difference type.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
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.
const_iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
bool operator!=(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
const_iterator_t< reverse_t > & operator=(const_iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
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(iterator_t< reverse_t > const &i)
A copy constructor.
const_iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
const_iterator_t< reverse_t > & operator--()
The prefix – operator.
The container must have iterator types.
difference_type position
Mark position of iterator within vector_complex_float.
pointer operator->() const
Dereference the pointer.
bool operator!=(iterator_base< container, content, reverse_t > const &i) const
The != operator.
iterator_base()
The iterator is default constructible.
ptrdiff_t difference_type
An iterator must have a difference_type.
container * v
Store a pointer to a vector_complex_float we can iterate over: 0 if no vector_complex_float.
bool operator==(iterator_base< container, content, reverse_t > const &i) const
The == operator.
complex_float value_type
An iterator must have a value_type.
void shift(difference_type const n)
Shift iterator n places.
difference_type operator-(iterator_base< container, content, reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_base(container *v, difference_type position)
This constructor allows vector_complex_float to create non-default iterators.
complex_float_ptr pointer
An iterator must have a pointer type.
reference operator[](difference_type const n) const
Get element at i + n by reference ([] operator).
reference operator*() const
Dereference the pointer.
complex_float_ref reference
An iterator must have a reference type.
bool operator<(iterator_base< container, content, reverse_t > const &i) const
The < operator is used to compare iterators.
std::random_access_iterator_tag iterator_category
An iterator must have a pointer type.
A class template for the two non-const iterators.
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.
difference_type operator-(const_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=(iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
iterator_t< reverse_t > operator--(int)
The postfix – operator.
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-=(difference_type const n)
The -= operator.
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
iterator_t(vector_complex_float *v, difference_type position)
This constructor allows vector_complex_float to create non-default 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_base< vector_complex_float, float, reverse_t >::difference_type difference_type
Difference type.
This class handles vector_complex_float objects as shared handles.
gsl::vector_float const real() const
Another C++ version of gsl_vector_complex_const_real().
bool operator>=(vector_complex_float const &v) const
A container needs to define an ordering for sorting.
int div(vector_complex_float const &b)
C++ version of gsl_vector_complex_float_div().
int fread(FILE *stream)
C++ version of gsl_vector_complex_float_fread().
int ispos() const
C++ version of gsl_vector_complex_float_ispos().
iterator_t< false > iterator
The iterator type.
vector_complex_float()
The default constructor is only really useful for assigning to.
void set_zero()
C++ version of gsl_vector_complex_float_set_zero().
static vector_complex_float const const_view_array(float const *v, size_t n)
C++ version of gsl_vector_complex_float _const_view_array().
complex_float_ptr ptr(size_t const i)
C++ version of gsl_vector_complex_float_ptr().
vector_complex_float(vector_complex_float &v, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_complex_float_alloc_from_vector().
reference const const_reference
A container must have a constant reference type.
int isnull() const
C++ version of gsl_vector_complex_float_isnull().
vector_complex_float const const_subvector(size_t i, size_t n) const
C++ version of gsl_vector_complex_float_const_subvector().
const_iterator begin() const
Get iterator pointing to first vector_complex_float element.
gsl_vector_complex_float * get()
Get the gsl_vector_complex_float.
const_iterator_t< false > const_iterator
The const_iterator type.
vector_complex_float(vector_complex_float &&v)
Move constructor.
complex_float_ptr const const_pointer
A container must have a constant pointer type.
vector_complex_float subvector(size_t i, size_t n)
C++ version of gsl_vector_complex_float_subvector().
int axpby(complex_float const alpha, vector_complex_float const &x, complex_float const beta)
C++ version of gsl_vector_complex_float_axpby().
static vector_complex_float calloc(size_t const n)
C++ version of gsl_vector_complex_float_calloc().
static vector_complex_float view_array_with_stride(float *base, size_t stride, size_t n)
C++ version of gsl_vector_complex_float_view_array_with_stride().
const_reverse_iterator rbegin() const
Get iterator pointing to first vector_complex_float element.
void set(size_t const i, complex_float x)
C++ version of gsl_vector_complex_float_set().
complex_float_ptr const const_ptr(size_t const i)
C++ version of gsl_vector_complex_float_const_ptr().
gsl::vector_float imag()
C++ version of gsl_vector_complex_imag().
size_type size() const
The size (number of elements) of the vector_complex_float.
static vector_complex_float view_array(float *v, size_t n)
C++ version of gsl_vector_complex_float_view_array().
int add_constant(complex_float const x)
C++ version of gsl_vector_complex_float_add_constant().
vector_complex_float(std::initializer_list< std::complex< float > > initializer_list)
Could construct from a std::initializer_list in C++11.
gsl_vector_complex_float const * get() const
Get the gsl_vector_complex_float.
bool operator!=(vector_complex_float const &v) const
Two vector_complex_float objects are different equal if their elements are not identical.
complex_float value_type
A container must have a value_type.
iterator end()
Get iterator pointing beyond last vector_complex_float element.
int reverse()
C++ version of gsl_vector_complex_float_reverse().
int set_basis(size_t i)
C++ version of gsl_vector_complex_float_set_basis().
bool operator==(vector_complex_float const &v) const
Two vector_complex_float objects are identically equal if their elements are identical.
iterator_t< true > reverse_iterator
The reverse_iterator type.
complex_float get(size_t const i) const
C++ version of gsl_vector_complex_float_get().
int swap_elements(size_t const i, size_t const j)
C++ version of gsl_vector_complex_float_swap_elements().
bool owns_data
Used to allow a vector that does not own its data.
iterator begin()
Get iterator pointing to first vector_complex_float element.
gsl::vector_float const const_real() const
C++ version of gsl_vector_complex_const_real().
reverse_iterator rbegin()
Get iterator pointing to first vector_complex_float element.
float const * data() const
Give access to the data block.
gsl::vector_float const imag() const
Another C++ version of gsl_vector_complex_const_imag().
complex_float_ref const operator[](size_t const n) const
Get element at position n by reference ([] operator).
int fprintf(FILE *stream, char const *format) const
C++ version of gsl_vector_complex_float_fprintf().
complex_float_ptr pointer
A container must have a pointer type.
complex_float_ref operator[](size_t const n)
Get element at position n by reference ([] operator).
size_t * count
The shared reference count.
bool unique() const
Find if this is the only object sharing the gsl_vector_complex_float.
vector_complex_float & operator=(vector_complex_float &&v)
Move operator.
size_t size_type
A container must have a size_type.
gsl::vector_float const const_imag() const
C++ version of gsl_vector_complex_const_imag().
vector_complex_float subvector_with_stride(size_t i, size_t stride, size_t n)
C++ version of gsl_vector_complex_float_subvector_with_stride().
vector_complex_float clone() const
The clone function.
bool operator<(vector_complex_float const &v) const
A container needs to define an ordering for sorting.
gsl_vector_complex_float * ccgsl_pointer
The shared pointer.
int fwrite(FILE *stream) const
C++ version of gsl_vector_complex_float_fwrite().
bool operator<=(vector_complex_float const &v) const
A container needs to define an ordering for sorting.
bool operator>(vector_complex_float const &v) const
A container needs to define an ordering for sorting.
static vector_complex_float const const_view_array_with_stride(float const *base, size_t stride, size_t n)
C++ version of gsl_vector_complex_float_const_view_array_with_stride().
void wrap_gsl_vector_complex_float_without_ownership(gsl_vector_complex_float *v)
This function is intended mainly for internal use.
int mul(vector_complex_float const &b)
C++ version of gsl_vector_complex_float_mul().
vector_complex_float(size_t const n)
The default constructor creates a new vector_complex_float with n elements.
vector_complex_float(vector_complex_float const &v)
The copy constructor.
size_type max_size() const
The max size (number of elements) of the vector_complex_float.
void reset()
Stop sharing ownership of the shared pointer.
float * data()
Give access to the data block.
complex_float_ref reference
A container must have a reference type.
int add(vector_complex_float const &b)
C++ version of gsl_vector_complex_float_add().
static vector_complex_float view_array_with_stride(ARRAY &base, size_t stride, size_t n=0)
C++ version of gsl_vector_complex_float_view_array_with_stride().
int scale(complex_float const x)
C++ version of gsl_vector_complex_float_scale().
int sub(vector_complex_float const &b)
C++ version of gsl_vector_complex_float_sub().
~vector_complex_float()
The destructor only deletes the pointers if count reaches zero.
bool empty() const
Find if the vector_complex_float is empty.
static vector_complex_float alloc_row_from_matrix(matrix_complex_float &m, size_t const i)
C++ version of gsl_vector_complex_float_alloc_row_from_matrix().
gsl::vector_float real()
C++ version of gsl_vector_complex_real().
int memcpy(vector_complex_float const &src)
C++ version of gsl_vector_complex_float_memcpy().
vector_complex_float const const_subvector_with_stride(size_t i, size_t stride, size_t n) const
C++ version of gsl_vector_complex_float_const_subvector_with_stride().
static vector_complex_float alloc_col_from_matrix(matrix_complex_float &m, size_t const j)
C++ version of gsl_vector_complex_float_alloc_col_from_matrix().
const_iterator_t< true > const_reverse_iterator
The const_reverse_t type.
static vector_complex_float view_array(ARRAY &v, size_t n=0)
C++ version of gsl_vector_complex_float_view_array().
const_iterator::difference_type difference_type
A container must have a difference_type.
vector_complex_float & operator=(vector_complex_float const &v)
The assignment operator.
int isnonneg() const
C++ version of gsl_vector_complex_float_isnonneg().
vector_complex_float(block_complex_float &b, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_complex_float_alloc_from_block().
reverse_iterator rend()
Get iterator pointing beyond last vector_complex_float element.
int fscanf(FILE *stream)
C++ version of gsl_vector_complex_float_fscanf().
size_t use_count() const
Find how many vector_complex_float objects share this pointer.
static vector_complex_float const const_view_array(ARRAY const &v, size_t n=0)
C++ version of gsl_vector_complex_float _const_view_array().
static vector_complex_float const const_view_array_with_stride(ARRAY const &base, size_t stride, size_t n=0)
C++ version of gsl_vector_complex_float_const_view_array_with_stride().
int isneg() const
C++ version of gsl_vector_complex_float_isneg().
void swap(vector_complex_float &v)
Swap two vector_complex_float objects.
const_reverse_iterator rend() const
Get iterator pointing beyond last vector_complex_float element.
void set_all(complex_float x)
C++ version of gsl_vector_complex_float_set_all().
const_iterator end() const
Get iterator pointing beyond last vector_complex_float element.
This class handles vector_float objects as shared handles.
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().
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 min(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_min().
Definition: movstat.hpp:581
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
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
#define CCGSL_MTY