trevc.hpp

Go to the documentation of this file.
00001 /*
00002  * 
00003  * Copyright (c) Toon Knapen & Kresimir Fresl 2003
00004  *
00005  * Distributed under the Boost Software License, Version 1.0.
00006  * (See accompanying file LICENSE_1_0.txt or copy at
00007  * http://www.boost.org/LICENSE_1_0.txt)
00008  *
00009  * KF acknowledges the support of the Faculty of Civil Engineering, 
00010  * University of Zagreb, Croatia.
00011  *
00012  */
00013 
00014 #ifndef BOOST_NUMERIC_BINDINGS_LAPACK_TREVC_HPP
00015 #define BOOST_NUMERIC_BINDINGS_LAPACK_TREVC_HPP
00016 
00017 #include <complex>
00018 #include <boost/numeric/bindings/traits/traits.hpp>
00019 #include <boost/numeric/bindings/traits/type_traits.hpp>
00020 #include <boost/numeric/bindings/lapack/lapack.h>
00021 #include <boost/numeric/bindings/traits/detail/array.hpp>
00022 // #include <boost/numeric/bindings/traits/std_vector.hpp>
00023 
00024 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK 
00025 #  include <boost/static_assert.hpp>
00026 #  include <boost/type_traits.hpp>
00027 #endif 
00028 
00029 
00030 namespace boost { namespace numeric { namespace bindings { 
00031 
00032   namespace lapack {
00033 
00035     //
00036     // Compute eigenvectors of Schur matrix (computed by gees).
00037     // 
00039 
00040     /* 
00041      * trevc() computes the eigenvectors using the Schur factorization
00042      *
00043      * Let  A = U * S * herm(U), then trecv computes the eigenvectors of
00044      * S, and may optionally apply them to U.
00045      *
00046      * To compute the Schur factorization, see gees.
00047      */ 
00048 
00049     namespace detail {
00050       inline 
00051       void trevc (char const side, char const howmny, const logical_t* select, int const n,
00052                  float* t, int const ldt, float* vl, int const ldvl, float* vr, int const ldvr,
00053                  int const mm, int& m, float* work, int& info) 
00054       {
00055         LAPACK_STREVC (&side, &howmny, select, &n, t, &ldt, vl, &ldvl, vr, &ldvr, &mm, &m, work, &info);
00056       }
00057 
00058       inline 
00059       void trevc (char const side, char const howmny, const logical_t* select, int const n,
00060                  double* t, int const ldt, double* vl, int const ldvl, double* vr, int const ldvr,
00061                  int const mm, int& m, double* work, int& info) 
00062       {
00063         LAPACK_DTREVC (&side, &howmny, select, &n, t, &ldt, vl, &ldvl, vr, &ldvr, &mm, &m, work, &info);
00064       }
00065 
00066       inline 
00067       void trevc (char const side, char const howmny, const logical_t* select, int const n,
00068                  traits::complex_f* t, int const ldt, traits::complex_f* vl, int const ldvl, traits::complex_f* vr, int const ldvr,
00069                  int const mm, int& m, traits::complex_f* work, int& info) 
00070       {
00071         LAPACK_CTREVC (&side, &howmny, select, &n, traits::complex_ptr(t), &ldt, traits::complex_ptr(vl), &ldvl,
00072                         traits::complex_ptr(vr), &ldvr, &mm, &m, traits::complex_ptr(work+n), traits::complex_ptr(work), &info);
00073       }
00074 
00075       inline 
00076       void trevc (char const side, char const howmny, const logical_t* select, int const n,
00077                   traits::complex_d* t, int const ldt, traits::complex_d* vl, int const ldvl, traits::complex_d* vr, int const ldvr,
00078                   int const mm, int& m, traits::complex_d* work, int& info) 
00079       {
00080         LAPACK_ZTREVC (&side, &howmny, select, &n, traits::complex_ptr(t), &ldt,
00081                        traits::complex_ptr(vl), &ldvl, traits::complex_ptr(vr), &ldvr,
00082                        &mm, &m, traits::complex_ptr(work+n), traits::complex_ptr(work), &info);
00083       }
00084 
00085     } 
00086 
00087     // Compute Schur factorization with Schur vectors
00088     template <typename MatrT, typename VL, typename VR, typename Work>
00089     inline
00090     int trevc (char const side, char const howmny, MatrT& t, VL& vl, VR& vr, Work& work) {
00091 
00092 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK 
00093       BOOST_STATIC_ASSERT((boost::is_same<
00094         typename traits::matrix_traits<MatrT>::matrix_structure, 
00095         traits::general_t
00096       >::value)); 
00097       BOOST_STATIC_ASSERT((boost::is_same<
00098         typename traits::matrix_traits<VL>::matrix_structure, 
00099         traits::general_t
00100       >::value)); 
00101       BOOST_STATIC_ASSERT((boost::is_same<
00102         typename traits::matrix_traits<VR>::matrix_structure, 
00103         traits::general_t
00104       >::value)); 
00105 #endif 
00106 
00107       int const n = traits::matrix_size1 (t);
00108       assert (n == traits::matrix_size2 (t)); 
00109       assert (n == traits::matrix_size1 (vl)); 
00110       assert (n == traits::matrix_size2 (vl)); 
00111       assert (n == traits::matrix_size1 (vr)); 
00112       assert (n == traits::matrix_size2 (vr)); 
00113       assert (3*n <= traits::vector_size (work)); 
00114 
00115       logical_t* select=0;
00116 
00117       int mm=n;
00118       int m;
00119       int info; 
00120       detail::trevc (side, howmny, select, n,
00121                     traits::matrix_storage (t), 
00122                     traits::leading_dimension (t),
00123                     traits::matrix_storage (vl),
00124                     traits::leading_dimension (vl),
00125                     traits::matrix_storage (vr),
00126                     traits::leading_dimension (vr),
00127                     mm,
00128                     m,
00129                     traits::vector_storage (work),
00130                     info);
00131       return info; 
00132     }
00133 
00134   }
00135 
00136 }}}
00137 
00138 #endif 

Generated on Wed Nov 23 19:00:51 2011 for FreeCAD by  doxygen 1.6.1