ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
vector_complex.hpp
Go to the documentation of this file.
1/*
2 * $Id: vector_complex.hpp 314 2014-02-22 14:31:16Z jdl3 $
3 * Copyright (C) 2010, 2011, 2012, 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_HPP
21#define CCGSL_VECTOR_COMPLEX_HPP
22
23#include<gsl/gsl_vector_complex_double.h>
24#include<new>
25#include<iterator>
26#ifdef __GXX_EXPERIMENTAL_CXX0X__
27#include<complex>
28#endif
29
30#include"exception.hpp"
31#include"block_complex.hpp"
32#include"vector.hpp"
33
34// This file is a template
35#define CCGSL_MTY 2
36
37namespace gsl {
38 // declare matrix_complex class
39 class matrix_complex;
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( size_t const n )
63 : owns_data(true) {
64 if( n > 0 ) ccgsl_pointer = gsl_vector_complex_alloc( n );
65 else { ccgsl_pointer = new gsl_vector_complex; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
66 // just plausibly we could allocate vector_complex 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_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( int const n )
81 : owns_data(true) {
82 if( n > 0 ) ccgsl_pointer = gsl_vector_complex_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; ccgsl_pointer->size = 0; ccgsl_pointer->data = 0; }
87 // just plausibly we could allocate vector_complex 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_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( gsl_vector_complex* 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( std::initializer_list<std::complex<double> > initializer_list )
115 : owns_data{true}{
116 size_t const n = initializer_list.size();
117 ccgsl_pointer = gsl_vector_complex_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_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( std::move( x ) ); ++p;
130 }
131 }
132#endif
133 // copy constructor
139 : owns_data(v.owns_data),
141 if( count != 0 ) ++*count; // vector_complex 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_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 is now shared.
161 return *this;
162 }
163 // clone()
170 vector_complex copy( get()->size );
171 // Now copy
172 gsl_vector_complex_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_free( ccgsl_pointer );
185 else delete ccgsl_pointer; }
186 delete count;
187 }
188 }
189 // Allow possibility of assigning from gsl_vector_complex without sharing
198 void wrap_gsl_vector_complex_without_ownership( gsl_vector_complex* v ){
199 if( count != 0 and --*count == 0 ){
200 // could have allocated null pointer
201 if( ccgsl_pointer != 0 ){
202 if( ccgsl_pointer->size != 0 ) gsl_vector_complex_free( ccgsl_pointer );
203 else delete ccgsl_pointer; }
204 }
205 ccgsl_pointer = v;
206 if(0 == count) count = new size_t;
207 *count = 1;
208 owns_data = false; // should never be able to delete ccgsl_pointer
209 }
210 // Refines equality comparable
211 // == operator
218 bool operator==( vector_complex const& v ) const {
219 // trivially equal if gsl_vector_complex*s are identical
220 if( ccgsl_pointer == v.ccgsl_pointer ) return true;
221 // trivially not equal if one is zero: != should be same as xor here
222 if( (ccgsl_pointer == 0) != (v.ccgsl_pointer == 0 ) ) return false;
223 // trivially not equal if sizes are different
224 if( ccgsl_pointer->size != v.ccgsl_pointer->size ) return false;
225 // check elementwise for equality
226 for( size_t i = 0; i < CCGSL_MTY * ccgsl_pointer->size; ++i )
227 if( *(ccgsl_pointer->data + i) != *(v.ccgsl_pointer->data + i) )
228 return false;
229 return true;
230 }
234 void reset(){ vector_complex().swap( *this ); }
235#ifdef __GXX_EXPERIMENTAL_CXX0X__
241 : owns_data (v.owns_data),
242 ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
243 std::swap( count, v.count );
244 v.ccgsl_pointer = nullptr;
245 }
252 vector_complex( std::move( v ) ).swap( *this );
253 return *this;
254 }
255#endif
256 // != operator
263 bool operator!=( vector_complex const& v ) const { return not operator==( v ); }
264 // Refines forward container
265 // Refines less than comparable
266 // operator<
275 bool operator<( vector_complex const& v ) const {
276 // null vector_complex comes first
277 if( ccgsl_pointer == 0 ) return v.ccgsl_pointer != 0;
278 // if v is null then this > v
279 if( v.ccgsl_pointer == 0 ) return false;
280 // Now compare elementwise
281 size_t const size = ccgsl_pointer->size;
282 size_t const v_size = v.ccgsl_pointer->size;
283 size_t const min = size > v_size ? size : v_size;
284 for( size_t i = 0; i < min; ++i ){
285 complex const t = gsl_vector_complex_get( ccgsl_pointer, i );
286 complex const u =gsl_vector_complex_get( v.ccgsl_pointer, i );
287 if( t < u ) return true;
288 if( u < t ) return false;
289 }
290 // elements match.
291 return size < v_size;
292 }
293 // operator>
302 bool operator>( vector_complex const& v ) const {
303 // null vector_complex comes first
304 if( ccgsl_pointer == 0 ) return false;
305 // if v is null then this > v
306 if( v.ccgsl_pointer == 0 ) return true;
307 // Now compare elementwise
308 size_t const size = ccgsl_pointer->size;
309 size_t const v_size = v.ccgsl_pointer->size;
310 size_t const min = size > v_size ? size : v_size;
311 for( size_t i = 0; i < min; ++i ){
312 complex const t = gsl_vector_complex_get( ccgsl_pointer, i );
313 complex const u =gsl_vector_complex_get( v.ccgsl_pointer, i );
314 if( t > u ) return true;
315 if( u > t ) return false;
316 }
317 // elements match.
318 return size > v_size;
319 }
320 // operator<=
329 bool operator<=( vector_complex const& v ) const {
330 return operator<( v ) or operator==( v );
331 }
332 // operator>=
341 bool operator>=( vector_complex const& v ) const {
342 return operator>( v ) or operator==( v );
343 }
344 // Refines container
345 // type value_type
350 // type reference
355 // type const_reference
360 // type pointer
365 // type const_pointer
370 // type iterator
371 private:
376 template<typename container, typename content,bool reverse_t>
378 friend class vector_complex;
379 public:
395 typedef std::random_access_iterator_tag iterator_category;
396 // // type iterator_traits<vector_complex>::difference_type
400 typedef ptrdiff_t difference_type;
401 public:
402 // // operator*
408 // First check that iterator is initialised.
409 if( v == 0 ){
410 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
411 return complex_ref( 0 );
412 } else if( v->ccgsl_pointer == 0 ){
413 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
414 return complex_ref( 0 );
415 }
416 // Check that position make sense
417 if( position >= static_cast<difference_type>( v->size() ) ){
418 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
419 return complex_ref( 0 );
420 }
421 if( position <= -1 ){
422 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
423 return complex_ref( 0 );
424 }
425 // position and v are valid: return data
426 return complex_ref( v->ccgsl_pointer->data + CCGSL_MTY * position * v->ccgsl_pointer->stride );
427 }
428 // // operator->
434 // First check that iterator is initialised.
435 if( v == 0 ){
436 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
437 return pointer( 0 );
438 } else if( v->ccgsl_pointer == 0 ){
439 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
440 return pointer( 0 );
441 }
442 // Check that position make sense
443 if( position >= static_cast<difference_type>( v->size() ) ){
444 gsl_error( "trying to dereference end()", __FILE__, __LINE__, exception::GSL_EFAILED );
445 return pointer( 0 );
446 }
447 if( position <= -1 ){
448 gsl_error( "trying to dereference rend()", __FILE__, __LINE__, exception::GSL_EFAILED );
449 return pointer( 0 );
450 }
451 // position and v are valid: return data
452 return pointer( v->ccgsl_pointer->data + CCGSL_MTY * position * v->ccgsl_pointer->stride );
453 }
454 // // operator[]
461 // First check that iterator is initialised.
462 if( v == 0 ){
463 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
464 return reference( 0 );
465 } else if( v->ccgsl_pointer == 0 ){
466 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
467 return reference( 0 );
468 }
469 // Check that position make sense
470 difference_type const p = reverse_t ? position - n : position + n;
471 if( p >= static_cast<difference_type>( v->size() ) ){
472 gsl_error( "trying to dereference beyond rbegin()", __FILE__, __LINE__, exception::GSL_EFAILED );
473 return reference( 0 );
474 }
475 if( p <= -1 ){
476 gsl_error( "trying to dereference beyond begin()", __FILE__, __LINE__, exception::GSL_EFAILED );
477 return reference( 0 );
478 }
479 // p is a valid position
480 return reference( v->ccgsl_pointer->data + CCGSL_MTY * p * v->ccgsl_pointer->stride );
481 }
482 // // operator-: find distance between two iterators
489 // Warn if either iterator undefined
490 if( v == 0 or i.v == 0 ){
491 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
492 return 0;
493 } else if( v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
494 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
495 return 0;
496 }
497 // Warn if iterators do not point to same vector_complex
498 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
499 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
501 return 0;
502 }
503 return reverse_t ? i.position - position : position - i.position;
504 }
505 // // operator!=
506 // // operator<
513 return this->v == i.v and this->position == i.position;
514 }
521 return not this->operator==( i );
522 }
531 // Warn if either iterator undefined
532 if( v == 0 or i.v == 0 ){
533 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
534 return false;
535 }
536 // Warn if iterators do not point to same vector_complex
537 if( v->ccgsl_pointer != i.v->ccgsl_pointer ){
538 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
540 return false;
541 }
542 return reverse_t ? i.position < position : position < i.position;
543 }
544 protected:
549 void increment(){
550 // Only makes sense if v points to a vector_complex
551 if( v == 0 ){
552 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
553 return;
554 } else if( v->ccgsl_pointer == 0 ){
555 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
556 return;
557 }
558 // increment position and check against size
559 if( reverse_t ){ if( position >= 0 ) --position; }
560 else { if( position < static_cast<difference_type>( v->size() ) ) ++position; }
561 }
566 void decrement(){
567 // Only makes sense if v points to a vector_complex
568 if( v == 0 ){
569 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
570 return;
571 } else if( v->ccgsl_pointer == 0 ){
572 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
573 return;
574 }
575 // decrement position and check against size
576 if( reverse_t ){ if( position < static_cast<difference_type>( v->size() ) ) ++position; }
577 else { if( position >= 0 ) --position; }
578 }
583 void shift( difference_type const n ){
584 // Warn if iterator undefined
585 if( v == 0 ){
586 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
587 return;
588 } else if( v->ccgsl_pointer == 0 ){
589 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
590 return;
591 }
592 position += reverse_t ? -n : n;
593 }
597 iterator_base(){ v = 0; }
604 : v( v ), position( position ){}
608 container* v;
613 };
614 // Need to know about const_iterator_t
615 template<bool reverse_t> class const_iterator_t;
619 template<bool reverse_t> class iterator_t : public iterator_base<vector_complex,double,reverse_t>{
620 public:
621 // // Refines output iterator
622 // // operator=
630 return *this;
631 }
632 // // Refines forward iterator
633 // // operator++ (both)
640 return *this;
641 }
647 // return value
650 return result;
651 }
652 // // Refines bidirectional iterator
653 // // operator-- (both)
660 return *this;
661 }
667 // return value
670 return result;
671 }
677 // // operator+=
684 this->shift( n );
685 return *this;
686 }
687 // // operator-=
694 this->shift( -n );
695 return *this;
696 }
697 // // operator+ (n+i)(i+n)
706 result.shift( n );
707 return result;
708 }
709 // // operator- (n-i)(i-n)(i-j)
718 result.shift( -n );
719 return result;
720 }
728 }
735 // Warn if either iterator undefined
736 if( this->v == 0 or i.v == 0 ){
737 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
738 return 0;
739 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
740 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
741 return 0;
742 }
743 // Warn if iterators do not point to same vector_complex
744 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
745 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
747 return 0;
748 }
749 return reverse_t ? i.position - this->position : this->position - i.position;
750 }
757 return this->v == i.v and this->position == i.position;
758 }
765 return not this->operator==( i );
766 }
772 bool operator<( const_iterator_t<reverse_t> const& i ) const {
773 // Warn if either iterator undefined
774 if( this->v == 0 or i.v == 0 ){
775 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
776 return false;
777 }
778 // Warn if iterators do not point to same vector_complex
779 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
780 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
782 return false;
783 }
784 return reverse_t ? i.position < this->position : this->position < i.position;
785 }
789 iterator_t() : iterator_base<vector_complex,double,reverse_t>(){}
790 protected:
791 friend class vector_complex;
792 // We need a constructor for vector_complex
799 : iterator_base<vector_complex,double,reverse_t>( v, position ){}
800 };
804 template<bool reverse_t> class const_iterator_t
805 : public iterator_base<vector_complex const,double,reverse_t>{
806 public:
807 // // Refines output iterator
808 // // operator=
816 return *this;
817 }
818 // // Refines forward iterator
819 // // operator++ (both)
826 return *this;
827 }
833 // return value
836 return result;
837 }
838 // // Refines bidirectional iterator
839 // // operator-- (both)
846 return *this;
847 }
853 // return value
856 return result;
857 }
863 // // operator+=
870 this->shift( n );
871 return *this;
872 }
873 // // operator-=
880 this->shift( -n );
881 return *this;
882 }
883 // // operator+ (n+i)(i+n)
892 result += n;
893 return result;
894 }
895 // // operator- (n-i)(i-n)(i-j)
904 result -= n;
905 return result;
906 }
914 }
921 // Warn if either iterator undefined
922 if( this->v == 0 or i.v == 0 ){
923 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
924 return 0;
925 } else if( this->v->ccgsl_pointer == 0 or i.v->ccgsl_pointer == 0 ){
926 gsl_error( "vector_complex not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
927 return 0;
928 }
929 // Warn if iterators do not point to same vector_complex
930 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
931 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
933 return 0;
934 }
935 return reverse_t ? i.position - this->position : this->position - i.position;
936 }
948 }
954 bool operator==( iterator_t<reverse_t> const& i ) const {
955 return this->v == i.v and this->position == i.position;
956 }
962 bool operator!=( iterator_t<reverse_t> const& i ) const {
963 return not this->operator==( i );
964 }
970 bool operator<( iterator_t<reverse_t> const& i ) const {
971 // Warn if either iterator undefined
972 if( this->v == 0 or i.v == 0 ){
973 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
974 return false;
975 }
976 // Warn if iterators do not point to same vector_complex
977 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
978 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
980 return false;
981 }
982 return reverse_t ? i.position < this->position : this->position < i.position;
983 }
990 return this->v == i.v and this->position == i.position;
991 }
998 return not this->operator==( i );
999 }
1006 // Warn if either iterator undefined
1007 if( this->v == 0 or i.v == 0 ){
1008 gsl_error( "iterator not initialised", __FILE__, __LINE__, exception::GSL_EFAILED );
1009 return false;
1010 }
1011 // Warn if iterators do not point to same vector_complex
1012 if( this->v->ccgsl_pointer != i.v->ccgsl_pointer ){
1013 gsl_error( "trying to take difference of iterators for different vector_complex objects", __FILE__, __LINE__,
1015 return false;
1016 }
1017 return reverse_t ? i.position < this->position : this->position < i.position;
1018 }
1019 protected:
1020 // We need a constructor for vector_complex
1021 friend class vector_complex;
1028 : iterator_base<vector_complex const,double,reverse_t>( v, position ){}
1029 };
1030 public:
1047 // type difference_type
1052 // type size_type
1056 typedef size_t size_type;
1057 // begin()
1063 return iterator( this, 0 );
1064 }
1070 return const_iterator( this, 0 );
1071 }
1072 // end()
1078 if( ccgsl_pointer == 0 ) return iterator( this, 0 );
1079 return iterator( this, size() );
1080 }
1086 if( ccgsl_pointer == 0 ) return const_iterator( this, 0 );
1087 return const_iterator( this, size() );
1088 }
1089 // size()
1094 size_type size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1102 double* data() {
1103 if( ccgsl_pointer == 0 ) gsl_error( "null vector", __FILE__, __LINE__, GSL_EFAULT );
1104#ifndef GSL_RANGE_CHECK_OFF
1105 if( ccgsl_pointer->stride != 1 )
1106 gsl_error( "vector does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1107#endif
1108 return ccgsl_pointer->data; }
1116 double const* data() const {
1117 if( ccgsl_pointer == 0 ) gsl_error( "null vector", __FILE__, __LINE__, GSL_EFAULT );
1118#ifndef GSL_RANGE_CHECK_OFF
1119 if( ccgsl_pointer->stride != 1 )
1120 gsl_error( "vector does not have stride of size 1", __FILE__, __LINE__, GSL_EBADLEN );
1121#endif
1122 return ccgsl_pointer->data; }
1123 // max_size()
1129 size_type max_size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
1130 // empty()
1135 bool empty() const { return ccgsl_pointer == 0 or ccgsl_pointer->size == 0; }
1136 // swap() --- should work even if sizes don't match
1143 gsl_vector_complex* tmp = ccgsl_pointer; ccgsl_pointer = v.ccgsl_pointer; v.ccgsl_pointer = tmp;
1144 size_t* tmp2 = count; count = v.count; v.count = tmp2;
1145 }
1146 // Refines reversible container
1147 // rbegin()
1153 if( ccgsl_pointer ==0 ) return reverse_iterator( this, 0 );
1154 return reverse_iterator( this, size() - 1 );
1155 }
1161 if( ccgsl_pointer ==0 ) return const_reverse_iterator( this, 0 );
1162 return const_reverse_iterator( this, size() - 1 );
1163 }
1164 // rend()
1170 return reverse_iterator( this, -1 );
1171 }
1177 return const_reverse_iterator( this, -1 );
1178 }
1179 // operator[]
1185 complex_ref operator[]( size_t const n ){
1186 // First check that iterator is initialised.
1187 if( ccgsl_pointer == 0 ){
1188 gsl_error( "vector_complex is null", __FILE__, __LINE__, exception::GSL_EFAILED );
1189 return complex_ref( 0 );
1190 }
1191#ifndef GSL_RANGE_CHECK_OFF
1192 // Check that position make sense
1193 if( n >= size() ){
1194 gsl_error( "trying to read beyond end of vector_complex", __FILE__, __LINE__, exception::GSL_EFAILED );
1195 return complex_ref( 0 );
1196 }
1197 // n is a valid position
1198#endif
1199 return complex_ref( ccgsl_pointer->data + CCGSL_MTY * n * ccgsl_pointer->stride );
1200 }
1206 complex_ref const operator[]( size_t const n ) const {
1207 // First check that iterator is initialised.
1208 if( ccgsl_pointer == 0 ){
1209 gsl_error( "vector_complex is null", __FILE__, __LINE__, exception::GSL_EFAILED );
1210 return complex_ref( 0 );
1211 }
1212#ifndef GSL_RANGE_CHECK_OFF
1213 // Check that position make sense
1214 if( n >= size() ){
1215 gsl_error( "trying to read beyond end of vector_complex", __FILE__, __LINE__, exception::GSL_EFAILED );
1216 return complex_ref( 0 );
1217 }
1218 // n is a valid position
1219#endif
1220 return complex_ref( ccgsl_pointer->data + n * ccgsl_pointer->stride );
1221 }
1222 private:
1230 gsl_vector_complex* ccgsl_pointer;
1234 size_t* count;
1235 public:
1236 // shared reference functions
1241 gsl_vector_complex* get() { return ccgsl_pointer; }
1246 gsl_vector_complex const* get() const { return ccgsl_pointer; }
1252 bool unique() const { return count != 0 and *count == 1; }
1257 size_t use_count() const { return count == 0 ? 0 : *count; }
1263#ifdef __GXX_EXPERIMENTAL_CXX0X__
1264 explicit
1265#endif
1266 operator bool() const { return ccgsl_pointer != 0; }
1267
1268 // GSL functions
1275 static vector_complex calloc( size_t const n ){ return vector_complex( gsl_vector_complex_calloc( n ) ); }
1279 void set_zero(){ gsl_vector_complex_set_zero( get() ); }
1284 void set_all( complex x ){ gsl_vector_complex_set_all( get(), x ); }
1290 int set_basis( size_t i ){ return gsl_vector_complex_set_basis( get(), i ); }
1296 int memcpy( vector_complex const& src ){ return gsl_vector_complex_memcpy( get(), src.get() ); }
1301 int reverse(){ return gsl_vector_complex_reverse( get() ); }
1308 int swap_elements( size_t const i, size_t const j ){
1309 return gsl_vector_complex_swap_elements( get(), i, j ); }
1315 int add( vector_complex const& b ){ return gsl_vector_complex_add( get(), b.get() ); }
1321 int sub( vector_complex const& b ){ return gsl_vector_complex_sub( get(), b.get() ); }
1327 int mul( vector_complex const& b ){ return gsl_vector_complex_mul( get(), b.get() ); }
1333 int div( vector_complex const& b ){ return gsl_vector_complex_div( get(), b.get() ); }
1339 int scale( complex const x ){ return gsl_vector_complex_scale( get(), x ); }
1345 int add_constant( complex const x ){ return gsl_vector_complex_add_constant( get(), x ); }
1353 int axpby( complex const alpha, vector_complex const& x,
1354 complex const beta ){
1355 return gsl_vector_complex_axpby( alpha, x.get(), beta, get() );
1356 }
1361 int isnull() const { return gsl_vector_complex_isnull( get() ); }
1366 int ispos() const { return gsl_vector_complex_ispos( get() ); }
1371 int isneg() const { return gsl_vector_complex_isneg( get() ); }
1376 int isnonneg() const { return gsl_vector_complex_isnonneg( get() ); }
1382 complex get( size_t const i ) const { return gsl_vector_complex_get( get(), i ); }
1388 void set( size_t const i, complex x ){ gsl_vector_complex_set( get(), i, x ); }
1394 complex_ptr ptr( size_t const i ){
1395 if( i >= ccgsl_pointer->size )
1396 gsl_error( "Index out of range", __FILE__, __LINE__, exception::GSL_EINVAL );
1397 return complex_ptr( ccgsl_pointer->data + CCGSL_MTY * i ); }
1403 complex_ptr const const_ptr( size_t const i ){
1404 if( i >= ccgsl_pointer->size )
1405 gsl_error( "Index out of range", __FILE__, __LINE__, exception::GSL_EINVAL );
1406 return complex_ptr( ccgsl_pointer->data + CCGSL_MTY * i ); }
1412 int fread( FILE* stream ){ return gsl_vector_complex_fread( stream, get() ); }
1418 int fwrite( FILE* stream ) const { return gsl_vector_complex_fwrite( stream, get() ); }
1424 int fscanf( FILE* stream ){ return gsl_vector_complex_fscanf( stream, get() ); }
1431 int fprintf( FILE* stream, char const* format ) const {
1432 return gsl_vector_complex_fprintf( stream, get(), format ); }
1440 vector_complex( block_complex& b, size_t const offset, size_t const n, size_t const stride = 1 ){
1441 ccgsl_pointer = gsl_vector_complex_alloc_from_block( b.get(), offset, n, stride );
1442 // just plausibly we could allocate vector_complex but not count
1443 try { count = new size_t; } catch( std::bad_alloc& e ){
1444 // try to tidy up before rethrowing
1445 gsl_vector_complex_free( ccgsl_pointer );
1446 throw e;
1447 }
1448 *count = 1; // initially there is just one reference to ccgsl_pointer
1449 }
1457 vector_complex( vector_complex& v, size_t const offset, size_t const n, size_t const stride = 1 ){
1458 ccgsl_pointer = gsl_vector_complex_alloc_from_vector( v.get(), offset, n, stride );
1459 // just plausibly we could allocate vector_complex but not count
1460 try { count = new size_t; } catch( std::bad_alloc& e ){
1461 // try to tidy up before rethrowing
1462 gsl_vector_complex_free( ccgsl_pointer );
1463 throw e;
1464 }
1465 *count = 1; // initially there is just one reference to ccgsl_pointer
1466 }
1481 gsl::vector const const_real() const {
1489 gsl::vector const real() const {
1505 gsl::vector const const_imag() const {
1513 gsl::vector const imag() const {
1521 static vector_complex view_array( double* v, size_t n ){
1522 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1523 *w = gsl_vector_complex_view_array( v, n ).vector;
1524 return vector_complex( w );
1525 }
1526
1527
1535 static vector_complex view_array_with_stride( double* base, size_t stride, size_t n ){
1536 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1537 *w = gsl_vector_complex_view_array_with_stride( base, stride, n ).vector;
1538 return vector_complex( w );
1539 }
1540
1541
1548 static vector_complex const const_view_array( double const* v, size_t n ){
1549 gsl_vector_complex* w = static_cast<gsl_vector_complex *>( malloc( sizeof( gsl_vector_complex ) ) );
1550 *w = gsl_vector_complex_const_view_array( v, n ).vector;
1551 return vector_complex( w );
1552 }
1553
1554
1562 static vector_complex const const_view_array_with_stride( double const* base, size_t stride, size_t n ){
1563 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1564 *w = gsl_vector_complex_const_view_array_with_stride( base, stride, n ).vector;
1565 return vector_complex( w );
1566 }
1567
1568
1569#ifndef DOXYGEN_SKIP
1576 static vector_complex const view_array( double const* v, size_t n ){
1577 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1578 *w = gsl_vector_complex_const_view_array( v, n ).vector;
1579 return vector_complex( w );
1580 }
1581#endif //DOXYGEN_SKIP
1582
1583
1584#ifndef DOXYGEN_SKIP
1592 static vector_complex const view_array_with_stride( double const* base, size_t stride, size_t n ){
1593 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1594 *w = gsl_vector_complex_const_view_array_with_stride( base, stride, n ).vector;
1595 return vector_complex( w );
1596 }
1597#endif //DOXYGEN_SKIP
1598
1599
1606 vector_complex subvector( size_t i, size_t n ){
1607 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1608 *w = gsl_vector_complex_subvector( get(), i, n ).vector;
1609 return vector_complex( w );
1610 }
1611
1612
1620 vector_complex subvector_with_stride( size_t i, size_t stride, size_t n ){
1621 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1622 *w = gsl_vector_complex_subvector_with_stride( get(), i, stride, n ).vector;
1623 return vector_complex( w );
1624 }
1625
1626
1633 vector_complex const const_subvector( size_t i, size_t n ) const {
1634 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1635 *w = gsl_vector_complex_const_subvector( get(), i, n ).vector;
1636 return vector_complex( w );
1637 }
1638
1639
1647 vector_complex const const_subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1648 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1649 *w = gsl_vector_complex_const_subvector_with_stride( get(), i, stride, n ).vector;
1650 return vector_complex( w );
1651 }
1652
1653
1654#ifndef DOXYGEN_SKIP
1661 vector_complex const subvector( size_t i, size_t n ) const {
1662 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1663 *w = gsl_vector_complex_const_subvector( get(), i, n ).vector;
1664 return vector_complex( w );
1665 }
1666#endif //DOXYGEN_SKIP
1667
1668
1669#ifndef DOXYGEN_SKIP
1677 vector_complex const subvector_with_stride( size_t i, size_t stride, size_t n ) const {
1678 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1679 *w = gsl_vector_complex_const_subvector_with_stride( get(), i, stride, n ).vector;
1680 return vector_complex( w );
1681 }
1682#endif //DOXYGEN_SKIP
1683
1684
1691 template<typename ARRAY>
1692 static vector_complex view_array( ARRAY& v, size_t n = 0 ){
1693 if(n > v.size())
1694 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1695 if(0 == n)
1696 n = v.size();
1697 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1698 *w = gsl_vector_complex_view_array( v.data(), n ).vector;
1699 return vector_complex( w );
1700 }
1701
1702
1710 template<typename ARRAY>
1711 static vector_complex view_array_with_stride( ARRAY& base, size_t stride, size_t n=0 ){
1712 if(0 == n)
1713 n = base.size()/stride;
1714 if((n-1)*stride > base.size())
1715 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1716 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1717 *w = gsl_vector_complex_view_array_with_stride( base.data(), stride, n ).vector;
1718 return vector_complex( w );
1719 }
1720
1721
1728 template<typename ARRAY>
1729 static vector_complex const const_view_array( ARRAY const& v, size_t n=0 ){
1730 if(n > v.size())
1731 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1732 if(0 == n)
1733 n = v.size();
1734 gsl_vector_complex* w = static_cast<gsl_vector_complex *>( malloc( sizeof( gsl_vector_complex ) ) );
1735 *w = gsl_vector_complex_const_view_array( v.data(), n ).vector;
1736 return vector_complex( w );
1737 }
1738
1739
1747 template<typename ARRAY>
1748 static vector_complex const const_view_array_with_stride( ARRAY const& base, size_t stride, size_t n=0 ){
1749 if(0 == n)
1750 n = base.size()/stride;
1751 if((n-1)*stride > base.size())
1752 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1753 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1754 *w = gsl_vector_complex_const_view_array_with_stride( base.data(), stride, n ).vector;
1755 return vector_complex( w );
1756 }
1757
1758
1759#ifndef DOXYGEN_SKIP
1766 template<typename ARRAY>
1767 static vector_complex const view_array( ARRAY const& v, size_t n=0 ){
1768 if(n > v.size())
1769 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1770 if(0 == n)
1771 n = v.size();
1772 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1773 *w = gsl_vector_complex_const_view_array( v.data(), n ).vector;
1774 return vector_complex( w );
1775 }
1776#endif //DOXYGEN_SKIP
1777
1778
1779#ifndef DOXYGEN_SKIP
1787 template<typename ARRAY>
1788 static vector_complex const view_array_with_stride( ARRAY const& base, size_t stride, size_t n ){
1789 if(0 == n)
1790 n = base.size()/stride;
1791 if((n-1)*stride > base.size())
1792 gsl_error( "n is too big", __FILE__, __LINE__, exception::GSL_EBADLEN );
1793 gsl_vector_complex* w = static_cast<gsl_vector_complex*>( malloc( sizeof( gsl_vector_complex ) ) );
1794 *w = gsl_vector_complex_const_view_array_with_stride( base.data(), stride, n ).vector;
1795 return vector_complex( w );
1796 }
1797#endif //DOXYGEN_SKIP
1798
1799 // Extra allocators from matrix_complex objects. The definition must come after matrix_complex.
1814 };
1815
1824
1833
1842 return i + n; }
1843
1852 return i + n; }
1853
1854}
1855#undef CCGSL_MTY
1856#endif
This class handles vector_complexs as shared handles.
This class can be used like a pointer for complex objects so that we can iterate over a vector (for e...
Definition: complex.hpp:691
This class can be used like a reference for complex objects so that we can iterate over a vector (for...
Definition: complex.hpp:613
This class handles complex numbers.
Definition: complex.hpp:42
@ 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 objects as shared handles.
A class template for the const iterators.
const_iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
bool operator<(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
const_iterator_t< reverse_t > & operator--()
The prefix – operator.
const_iterator_t< reverse_t > & operator++()
The prefix ++ operator.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
const_iterator_t(iterator_t< reverse_t > const &i)
A copy constructor.
bool operator!=(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
iterator_base< vector_complexconst, double, reverse_t >::difference_type difference_type
Difference type.
const_iterator_t< reverse_t > & operator=(const_iterator_t< reverse_t > const &i)
We can assign one output iterator from another.
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
const_iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
const_iterator_t(vector_complex const *v, difference_type position)
This constructor allows vector_complex to create non-default iterators.
const_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.
const_iterator_t< reverse_t > operator--(int)
The postfix – operator.
bool operator<(const_iterator_t< reverse_t > const &i) const
Comparison with const iterator.
bool operator==(iterator_t< reverse_t > const &i) const
Comparison with non-const iterator.
const_iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
const_iterator_t()
The default constructor.
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.
The container must have iterator types.
std::random_access_iterator_tag iterator_category
An iterator must have a pointer type.
difference_type operator-(iterator_base< container, content, reverse_t > const &i) const
The - operator: find distance between two iterators.
void shift(difference_type const n)
Shift iterator n places.
pointer operator->() const
Dereference the pointer.
bool operator!=(iterator_base< container, content, reverse_t > const &i) const
The != operator.
difference_type position
Mark position of iterator within vector_complex.
reference operator*() const
Dereference the pointer.
void decrement()
Decrement the iterator.
iterator_base()
The iterator is default constructible.
ptrdiff_t difference_type
An iterator must have a difference_type.
complex_ptr pointer
An iterator must have a pointer type.
complex value_type
An iterator must have a value_type.
bool operator==(iterator_base< container, content, reverse_t > const &i) const
The == operator.
bool operator<(iterator_base< container, content, reverse_t > const &i) const
The < operator is used to compare iterators.
iterator_base(container *v, difference_type position)
This constructor allows vector_complex to create non-default iterators.
void increment()
Increment the iterator.
container * v
Store a pointer to a vector_complex we can iterate over: 0 if no vector_complex.
complex_ref reference
An iterator must have a reference type.
reference operator[](difference_type const n) const
Get element at i + n by reference ([] operator).
A class template for the two non-const iterators.
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.
iterator_t(vector_complex *v, difference_type position)
This constructor allows vector_complex to create non-default iterators.
iterator_t< reverse_t > operator--(int)
The postfix – operator.
iterator_t< reverse_t > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
difference_type operator-(iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_t< reverse_t > & operator-=(difference_type const n)
The -= operator.
iterator_t< reverse_t > operator+(difference_type const n) const
The + operator.
iterator_base< vector_complex, double, reverse_t >::difference_type difference_type
Difference type.
iterator_t< reverse_t > & operator++()
The prefix ++ operator.
iterator_t()
The default constructor.
iterator_t< reverse_t > & operator=(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.
iterator_t< reverse_t > operator++(int)
The postfix ++ operator.
iterator_t< reverse_t > & operator--()
The prefix – operator.
difference_type operator-(const_iterator_t< reverse_t > const &i) const
The - operator: find distance between two iterators.
iterator_t< reverse_t > & operator+=(difference_type const n)
The += operator.
This class handles vector_complex objects as shared handles.
const_iterator end() const
Get iterator pointing beyond last vector_complex element.
bool operator>=(vector_complex const &v) const
A container needs to define an ordering for sorting.
void set_zero()
C++ version of gsl_vector_complex_set_zero().
vector_complex(block_complex &b, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_complex_alloc_from_block().
int fwrite(FILE *stream) const
C++ version of gsl_vector_complex_fwrite().
size_type size() const
The size (number of elements) of the vector_complex.
static vector_complex alloc_row_from_matrix(matrix_complex &m, size_t const i)
C++ version of gsl_vector_complex_alloc_row_from_matrix().
size_type max_size() const
The max size (number of elements) of the vector_complex.
int ispos() const
C++ version of gsl_vector_complex_ispos().
vector_complex(vector_complex &&v)
Move constructor.
double * data()
Give access to the data block.
bool operator==(vector_complex const &v) const
Two vector_complex objects are identically equal if their elements are identical.
vector_complex(vector_complex &v, size_t const offset, size_t const n, size_t const stride=1)
C++ version of gsl_vector_complex_alloc_from_vector().
const_iterator_t< false > const_iterator
The const_iterator type.
static vector_complex const const_view_array_with_stride(ARRAY const &base, size_t stride, size_t n=0)
C++ version of gsl_vector_complex_const_view_array_with_stride().
complex_ref operator[](size_t const n)
Get element at position n by reference ([] operator).
bool operator!=(vector_complex const &v) const
Two vector_complex objects are different equal if their elements are not identical.
static vector_complex calloc(size_t const n)
C++ version of gsl_vector_complex_calloc().
int reverse()
C++ version of gsl_vector_complex_reverse().
const_reverse_iterator rbegin() const
Get iterator pointing to first vector_complex element.
const_iterator::difference_type difference_type
A container must have a difference_type.
int div(vector_complex const &b)
C++ version of gsl_vector_complex_div().
static vector_complex alloc_col_from_matrix(matrix_complex &m, size_t const j)
C++ version of gsl_vector_complex_alloc_col_from_matrix().
vector_complex(size_t const n)
The default constructor creates a new vector_complex with n elements.
vector_complex clone() const
The clone function.
complex_ptr const const_ptr(size_t const i)
C++ version of gsl_vector_complex_const_ptr().
vector_complex & operator=(vector_complex const &v)
The assignment operator.
vector_complex subvector(size_t i, size_t n)
C++ version of gsl_vector_complex_subvector().
iterator end()
Get iterator pointing beyond last vector_complex element.
gsl::vector imag()
C++ version of gsl_vector_complex_imag().
void swap(vector_complex &v)
Swap two vector_complex objects.
int add(vector_complex const &b)
C++ version of gsl_vector_complex_add().
vector_complex & operator=(vector_complex &&v)
Move operator.
iterator begin()
Get iterator pointing to first vector_complex element.
const_iterator_t< true > const_reverse_iterator
The const_reverse_t type.
int add_constant(complex const x)
C++ version of gsl_vector_complex_add_constant().
complex_ref const operator[](size_t const n) const
Get element at position n by reference ([] operator).
gsl_vector_complex * get()
Get the gsl_vector_complex.
bool empty() const
Find if the vector_complex is empty.
static vector_complex view_array(ARRAY &v, size_t n=0)
C++ version of gsl_vector_complex_view_array().
int fprintf(FILE *stream, char const *format) const
C++ version of gsl_vector_complex_fprintf().
bool owns_data
Used to allow a vector that does not own its data.
complex_ref reference
A container must have a reference type.
int axpby(complex const alpha, vector_complex const &x, complex const beta)
C++ version of gsl_vector_complex_axpby().
size_t use_count() const
Find how many vector_complex objects share this pointer.
complex value_type
A container must have a value_type.
void set_all(complex x)
C++ version of gsl_vector_complex_set_all().
vector_complex const const_subvector(size_t i, size_t n) const
C++ version of gsl_vector_complex_const_subvector().
void wrap_gsl_vector_complex_without_ownership(gsl_vector_complex *v)
This function is intended mainly for internal use.
int sub(vector_complex const &b)
C++ version of gsl_vector_complex_sub().
static vector_complex const const_view_array(ARRAY const &v, size_t n=0)
C++ version of gsl_vector_complex _const_view_array().
iterator_t< false > iterator
The iterator type.
static vector_complex view_array_with_stride(ARRAY &base, size_t stride, size_t n=0)
C++ version of gsl_vector_complex_view_array_with_stride().
gsl_vector_complex const * get() const
Get the gsl_vector_complex.
reference const const_reference
A container must have a constant reference type.
~vector_complex()
The destructor only deletes the pointers if count reaches zero.
int fread(FILE *stream)
C++ version of gsl_vector_complex_fread().
int memcpy(vector_complex const &src)
C++ version of gsl_vector_complex_memcpy().
complex_ptr ptr(size_t const i)
C++ version of gsl_vector_complex_ptr().
iterator_t< true > reverse_iterator
The reverse_iterator type.
complex get(size_t const i) const
C++ version of gsl_vector_complex_get().
gsl::vector const real() const
Another C++ version of gsl_vector_complex_const_real().
void set(size_t const i, complex x)
C++ version of gsl_vector_complex_set().
bool operator<=(vector_complex const &v) const
A container needs to define an ordering for sorting.
double const * data() const
Give access to the data block.
complex_ptr pointer
A container must have a pointer type.
static vector_complex const const_view_array(double const *v, size_t n)
C++ version of gsl_vector_complex _const_view_array().
reverse_iterator rbegin()
Get iterator pointing to first vector_complex element.
void reset()
Stop sharing ownership of the shared pointer.
static vector_complex view_array(double *v, size_t n)
C++ version of gsl_vector_complex_view_array().
static vector_complex const const_view_array_with_stride(double const *base, size_t stride, size_t n)
C++ version of gsl_vector_complex_const_view_array_with_stride().
bool operator<(vector_complex const &v) const
A container needs to define an ordering for sorting.
size_t * count
The shared reference count.
gsl::vector real()
C++ version of gsl_vector_complex_real().
gsl_vector_complex * ccgsl_pointer
The shared pointer.
gsl::vector const const_imag() const
C++ version of gsl_vector_complex_const_imag().
vector_complex()
The default constructor is only really useful for assigning to.
vector_complex const const_subvector_with_stride(size_t i, size_t stride, size_t n) const
C++ version of gsl_vector_complex_const_subvector_with_stride().
int mul(vector_complex const &b)
C++ version of gsl_vector_complex_mul().
gsl::vector const const_real() const
C++ version of gsl_vector_complex_const_real().
gsl::vector const imag() const
Another C++ version of gsl_vector_complex_const_imag().
bool unique() const
Find if this is the only object sharing the gsl_vector_complex.
int isnonneg() const
C++ version of gsl_vector_complex_isnonneg().
int set_basis(size_t i)
C++ version of gsl_vector_complex_set_basis().
int fscanf(FILE *stream)
C++ version of gsl_vector_complex_fscanf().
const_iterator begin() const
Get iterator pointing to first vector_complex element.
int swap_elements(size_t const i, size_t const j)
C++ version of gsl_vector_complex_swap_elements().
int isneg() const
C++ version of gsl_vector_complex_isneg().
vector_complex(vector_complex const &v)
The copy constructor.
size_t size_type
A container must have a size_type.
int isnull() const
C++ version of gsl_vector_complex_isnull().
vector_complex(std::initializer_list< std::complex< double > > initializer_list)
Could construct from a std::initializer_list in C++11.
bool operator>(vector_complex const &v) const
A container needs to define an ordering for sorting.
int scale(complex const x)
C++ version of gsl_vector_complex_scale().
complex_ptr const const_pointer
A container must have a constant pointer type.
const_reverse_iterator rend() const
Get iterator pointing beyond last vector_complex element.
reverse_iterator rend()
Get iterator pointing beyond last vector_complex element.
static vector_complex view_array_with_stride(double *base, size_t stride, size_t n)
C++ version of gsl_vector_complex_view_array_with_stride().
vector_complex subvector_with_stride(size_t i, size_t stride, size_t n)
C++ version of gsl_vector_complex_subvector_with_stride().
This class handles vector objects as shared handles.
Definition: vector.hpp:74
static vector view_array_with_stride(double *base, size_t stride, size_t n)
C++ version of gsl_vector_view_array_with_stride().
Definition: vector.hpp:1606
static vector const const_view_array_with_stride(double const *base, size_t stride, size_t n)
C++ version of gsl_vector_const_view_array_with_stride().
Definition: vector.hpp:1632
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