ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
eigen_nonsymm.hpp
Go to the documentation of this file.
1/*
2 * $Id: eigen_nonsymm.hpp 125 2012-02-19 18:18:25Z jdl3 $
3 * Copyright (C) 2010, 2011, 2012 John D Lamb
4 * Enum copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef CCGSL_EIGEN_NONSYMM_HPP
22#define CCGSL_EIGEN_NONSYMM_HPP
23
24#include<gsl/gsl_eigen.h>
25#include<new>
26#include<iterator>
27
28#include"vector.hpp"
29#include"vector_complex.hpp"
30#include"matrix.hpp"
31
32namespace gsl {
36 namespace eigen {
41 public:
46 ccgsl_pointer = 0;
47 count = 0; // initially nullptr will do
48 }
49 // Refines random access container
50 // Refines assignable
55 explicit nonsymm_workspace( size_t const n ){
56 ccgsl_pointer = gsl_eigen_nonsymm_alloc( n );
57 // just plausibly we could allocate nonsymm_workspace but not count
58 try { count = new size_t; } catch( std::bad_alloc& e ){
59 // try to tidy up before rethrowing
60 gsl_eigen_nonsymm_free( ccgsl_pointer );
61 throw e;
62 }
63 *count = 1; // initially there is just one reference to ccgsl_pointer
64 }
70 explicit nonsymm_workspace( gsl_eigen_nonsymm_workspace* v ){
71 ccgsl_pointer = v;
72 // just plausibly we could fail to allocate count: no further action needed.
73 count = new size_t;
74 *count = 1; // initially there is just one reference to ccgsl_pointer
75 }
76 // copy constructor
82 count = v.count; if( count != 0 ) ++*count; }
83 // assignment operator
89 // first, possibly delete anything pointed to by this
90 if( count == 0 or --*count == 0 ){
91 if( ccgsl_pointer != 0 ) gsl_eigen_nonsymm_free( ccgsl_pointer );
92 delete count;
93 } // Then copy
94 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
95 }
96 // destructor
101 if( count == 0 or --*count == 0 ){
102 // could have allocated null pointer
103 if( ccgsl_pointer != 0 ) gsl_eigen_nonsymm_free( ccgsl_pointer );
104 delete count;
105 }
106 }
107#ifdef __GXX_EXPERIMENTAL_CXX0X__
113 std::swap( count, v.count );
114 v.ccgsl_pointer = nullptr;
115 }
122 nonsymm_workspace( std::move( v ) ).swap( *this );
123 return *this;
124 }
125#endif
126 // Refines equality comparable
127 // == operator
134 bool operator==( nonsymm_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
135 // != operator
142 bool operator!=( nonsymm_workspace const& v ) const { return not operator==( v ); }
143 // Refines forward container
144 // Refines less than comparable
145 // operator<
154 bool operator<( nonsymm_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
155 // operator>
164 bool operator>( nonsymm_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
165 // operator<=
174 bool operator<=( nonsymm_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
175 // operator>=
184 bool operator>=( nonsymm_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
189 bool empty() const { return ccgsl_pointer == 0; }
190 // swap() --- should work even if sizes don't match
197 std::swap( ccgsl_pointer, v.ccgsl_pointer );
198 std::swap( count, v.count );
199 }
204 size_t size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
205 private:
209 gsl_eigen_nonsymm_workspace* ccgsl_pointer;
213 size_t* count;
214 public:
215 // shared reference functions
220 gsl_eigen_nonsymm_workspace* get() const { return ccgsl_pointer; }
226 bool unique() const { return count != 0 and *count == 1; }
231 size_t use_count() const { return count == 0 ? 0 : *count; }
237#ifdef __GXX_EXPERIMENTAL_CXX0X__
238 explicit
239#endif
240 operator bool() const { return ccgsl_pointer != 0; }
241 };
253 return gsl_eigen_nonsymm( A.get(), eval.get(), w.get() ); }
258 public:
263 ccgsl_pointer = 0;
264 count = 0; // initially nullptr will do
265 }
266 // Refines random access container
267 // Refines assignable
272 explicit nonsymmv_workspace( size_t const n ){
273 ccgsl_pointer = gsl_eigen_nonsymmv_alloc( n );
274 // just plausibly we could allocate nonsymmv_workspace but not count
275 try { count = new size_t; } catch( std::bad_alloc& e ){
276 // try to tidy up before rethrowing
277 gsl_eigen_nonsymmv_free( ccgsl_pointer );
278 throw e;
279 }
280 *count = 1; // initially there is just one reference to ccgsl_pointer
281 }
287 explicit nonsymmv_workspace( gsl_eigen_nonsymmv_workspace* v ){
288 ccgsl_pointer = v;
289 // just plausibly we could fail to allocate count: no further action needed.
290 count = new size_t;
291 *count = 1; // initially there is just one reference to ccgsl_pointer
292 }
293 // copy constructor
299 count = v.count; if( count != 0 ) ++*count; }
300 // assignment operator
306 // first, possibly delete anything pointed to by this
307 if( count == 0 or --*count == 0 ){
308 if( ccgsl_pointer != 0 ) gsl_eigen_nonsymmv_free( ccgsl_pointer );
309 delete count;
310 } // Then copy
311 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
312 }
313 // destructor
318 if( count == 0 or --*count == 0 ){
319 // could have allocated null pointer
320 if( ccgsl_pointer != 0 ) gsl_eigen_nonsymmv_free( ccgsl_pointer );
321 delete count;
322 }
323 }
324#ifdef __GXX_EXPERIMENTAL_CXX0X__
330 std::swap( count, v.count );
331 v.ccgsl_pointer = nullptr;
332 }
339 nonsymmv_workspace( std::move( v ) ).swap( *this );
340 return *this;
341 }
342#endif
343 // Refines equality comparable
344 // == operator
351 bool operator==( nonsymmv_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
352 // != operator
359 bool operator!=( nonsymmv_workspace const& v ) const { return not operator==( v ); }
360 // Refines forward container
361 // Refines less than comparable
362 // operator<
371 bool operator<( nonsymmv_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
372 // operator>
381 bool operator>( nonsymmv_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
382 // operator<=
391 bool operator<=( nonsymmv_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
392 // operator>=
401 bool operator>=( nonsymmv_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
406 bool empty() const { return ccgsl_pointer == 0; }
407 // swap() --- should work even if sizes don't match
414 std::swap( ccgsl_pointer, v.ccgsl_pointer );
415 std::swap( count, v.count );
416 }
421 size_t size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
422 private:
426 gsl_eigen_nonsymmv_workspace* ccgsl_pointer;
430 size_t* count;
431 public:
432 // shared reference functions
437 gsl_eigen_nonsymmv_workspace* get() const { return ccgsl_pointer; }
443 bool unique() const { return count != 0 and *count == 1; }
448 size_t use_count() const { return count == 0 ? 0 : *count; }
454#ifdef __GXX_EXPERIMENTAL_CXX0X__
455 explicit
456#endif
457 operator bool() const { return ccgsl_pointer != 0; }
458 };
472 return gsl_eigen_nonsymmv( A.get(), eval.get(), evec.get(), w.get() ); }
479 inline void nonsymm_params( int const compute_t, int const balance, nonsymm_workspace& w ){
480 gsl_eigen_nonsymm_params( compute_t, balance, w.get() ); }
494 return gsl_eigen_nonsymm_Z( A.get(), eval.get(), Z.get(), w.get() ); }
509 return gsl_eigen_nonsymmv_Z( A.get(), eval.get(), evec.get(), Z.get(), w.get() ); }
510 }
511}
512
513#endif
Workspace for nonsymmetric matrices.
nonsymm_workspace(gsl_eigen_nonsymm_workspace *v)
Could construct from a gsl_eigen_nonsymm_workspace.
nonsymm_workspace(nonsymm_workspace const &v)
The copy constructor.
size_t size() const
The size of the workspace.
nonsymm_workspace & operator=(nonsymm_workspace const &v)
The assignment operator.
bool operator<=(nonsymm_workspace const &v) const
A container needs to define an ordering for sorting.
gsl_eigen_nonsymm_workspace * get() const
Get the gsl_eigen_nonsymm_workspace.
bool operator<(nonsymm_workspace const &v) const
A container needs to define an ordering for sorting.
nonsymm_workspace()
The default constructor is only really useful for assigning to.
bool operator==(nonsymm_workspace const &v) const
Two nonsymm_workspace are identically equal if their elements are identical.
bool operator>=(nonsymm_workspace const &v) const
A container needs to define an ordering for sorting.
bool empty() const
Find if the nonsymm_workspace is empty.
nonsymm_workspace & operator=(nonsymm_workspace &&v)
Move operator.
nonsymm_workspace(nonsymm_workspace &&v)
Move constructor.
size_t * count
The shared reference count.
~nonsymm_workspace()
The destructor only deletes the pointers if count reaches zero.
nonsymm_workspace(size_t const n)
The default constructor creates a new nonsymm_workspace with n elements.
bool operator>(nonsymm_workspace const &v) const
A container needs to define an ordering for sorting.
gsl_eigen_nonsymm_workspace * ccgsl_pointer
The shared pointer.
bool operator!=(nonsymm_workspace const &v) const
Two nonsymm_workspace are different equal if their elements are not identical.
size_t use_count() const
Find how many nonsymm_workspace objects share this pointer.
void swap(nonsymm_workspace &v)
Swap two nonsymm_workspace.
bool unique() const
Find if this is the only object sharing the gsl_eigen_nonsymm_workspace.
Workspace for real nonsymmetric matrices (eigenvectors and eigenvalues)
bool operator<(nonsymmv_workspace const &v) const
A container needs to define an ordering for sorting.
gsl_eigen_nonsymmv_workspace * ccgsl_pointer
The shared pointer.
bool operator>(nonsymmv_workspace const &v) const
A container needs to define an ordering for sorting.
nonsymmv_workspace(nonsymmv_workspace &&v)
Move constructor.
gsl_eigen_nonsymmv_workspace * get() const
Get the gsl_eigen_nonsymmv_workspace.
size_t use_count() const
Find how many nonsymmv_workspace objects share this pointer.
nonsymmv_workspace(gsl_eigen_nonsymmv_workspace *v)
Could construct from a gsl_eigen_nonsymmv_workspace.
bool operator==(nonsymmv_workspace const &v) const
Two nonsymmv_workspace are identically equal if their elements are identical.
size_t * count
The shared reference count.
bool operator>=(nonsymmv_workspace const &v) const
A container needs to define an ordering for sorting.
bool unique() const
Find if this is the only object sharing the gsl_eigen_nonsymmv_workspace.
nonsymmv_workspace & operator=(nonsymmv_workspace &&v)
Move operator.
~nonsymmv_workspace()
The destructor only deletes the pointers if count reaches zero.
size_t size() const
The size of the workspace.
nonsymmv_workspace(nonsymmv_workspace const &v)
The copy constructor.
bool operator!=(nonsymmv_workspace const &v) const
Two nonsymmv_workspace are different equal if their elements are not identical.
void swap(nonsymmv_workspace &v)
Swap two nonsymmv_workspace.
nonsymmv_workspace(size_t const n)
The default constructor creates a new nonsymmv_workspace with n elements.
nonsymmv_workspace & operator=(nonsymmv_workspace const &v)
The assignment operator.
bool empty() const
Find if the nonsymmv_workspace is empty.
bool operator<=(nonsymmv_workspace const &v) const
A container needs to define an ordering for sorting.
nonsymmv_workspace()
The default constructor is only really useful for assigning to.
This class handles matrix_complex objects as shared handles.
gsl_matrix_complex * get()
Get the gsl_matrix_complex.
This class handles matrix objects as shared handles.
Definition: matrix.hpp:72
gsl_matrix * get()
Get the gsl_matrix.
Definition: matrix.hpp:1207
This class handles vector_complex objects as shared handles.
int eval(double const x, vector &B, workspace &w)
C++ version of gsl_bspline_eval().
Definition: bspline.hpp:309
int nonsymm_Z(gsl::matrix &A, gsl::vector_complex &eval, gsl::matrix &Z, nonsymm_workspace &w)
C++ version of gsl_eigen_nonsymm_Z().
int nonsymmv(gsl::matrix &A, gsl::vector_complex &eval, gsl::matrix_complex &evec, nonsymmv_workspace &w)
C++ version of gsl_eigen_nonsymmv().
void nonsymm_params(int const compute_t, int const balance, nonsymm_workspace &w)
C++ version of gsl_eigen_nonsymm_params().
int nonsymmv_Z(gsl::matrix &A, gsl::vector_complex &eval, gsl::matrix_complex &evec, gsl::matrix &Z, nonsymmv_workspace &w)
C++ version of gsl_eigen_nonsymmv_Z().
int nonsymm(gsl::matrix &A, gsl::vector_complex &eval, nonsymm_workspace &w)
C++ version of gsl_eigen_nonsymm().
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
Definition: rstat.hpp:299
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34