trexc.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_TREXC_HPP
00015 #define BOOST_NUMERIC_BINDINGS_LAPACK_TREXC_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     // Reorder the Schur factorization of a matrix.
00037     // 
00039 
00040     /* 
00041      * trexc()  reorders the Schur factorization of a matrix
00042      * A =  Q*T*Q**T, so that the diagonal block of T with row
00043      * index IFST is  moved to row ILST.
00044      */ 
00045 
00046     namespace detail {
00047       inline 
00048       int trexc_work_size( int const n, float ) {return n;}
00049 
00050       inline 
00051       int trexc_work_size( int const n, double ) {return n;}
00052 
00053       inline 
00054       int trexc_work_size( int const n, traits::complex_f ) {return 0;}
00055 
00056       inline 
00057       int trexc_work_size( int const n, traits::complex_d ) {return 0;}
00058     }
00059 
00060     // Get the minimum size of the work array.
00061     template <typename MatrT>
00062     int trexc_work_size(const MatrT& t) {
00063        return detail::trexc_work_size( traits::matrix_size1(t), typename MatrT::value_type() );
00064     }
00065 
00066     namespace detail {
00067       inline 
00068       void trexc (char const compq, int const n,
00069                  float* t, int const ldt, float* q, int const ldq, int& ifst, int& ilst,
00070                  float* work, int& info) 
00071       {
00072         LAPACK_STREXC (&compq, &n, t, &ldt, q, &ldq, &ifst, &ilst, work, &info);
00073       }
00074 
00075       inline 
00076       void trexc (char const compq, int const n,
00077                  double* t, int const ldt, double* q, int const ldq, int& ifst, int& ilst,
00078                  double* work, int& info) 
00079       {
00080         LAPACK_DTREXC (&compq, &n, t, &ldt, q, &ldq, &ifst, &ilst, work, &info);
00081       }
00082 
00083       inline 
00084       void trexc (char const compq, int const n,
00085                  traits::complex_f* t, int const ldt, traits::complex_f* q, int const ldq, int& ifst, int& ilst,
00086                  float* work, int& info) 
00087       {
00088         LAPACK_CTREXC (&compq, &n, traits::complex_ptr(t), &ldt, traits::complex_ptr(q), &ldq, &ifst, &ilst, &info);
00089       }
00090 
00091       inline 
00092       void trexc (char const compq, int const n,
00093                  traits::complex_d* t, int const ldt, traits::complex_d* q, int const ldq, int& ifst, int& ilst,
00094                  double* work, int& info) 
00095       {
00096         LAPACK_ZTREXC (&compq, &n, traits::complex_ptr(t), &ldt, traits::complex_ptr(q), &ldq, &ifst, &ilst, &info);
00097       }
00098 
00099     } 
00100 
00101     // Reorder Schur factorization with Schur vectors
00102     template <typename MatrT, typename Q, typename Work>
00103     inline
00104     int trexc (char const compq, MatrT& t, Q& q, int& ifst, int& ilst, Work& work) {
00105 
00106 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK 
00107       BOOST_STATIC_ASSERT((boost::is_same<
00108         typename traits::matrix_traits<MatrT>::matrix_structure, 
00109         traits::general_t
00110       >::value)); 
00111       BOOST_STATIC_ASSERT((boost::is_same<
00112         typename traits::matrix_traits<Q>::matrix_structure, 
00113         traits::general_t
00114       >::value)); 
00115 #endif 
00116 
00117       int const n = traits::matrix_size1 (t);
00118       assert (n == traits::matrix_size2 (t)); 
00119       assert (n == traits::matrix_size1 (q)); 
00120       assert (n == traits::matrix_size2 (q)); 
00121       assert (trexc_work_size(t) <= traits::vector_size (work)); 
00122 
00123       int info; 
00124       detail::trexc (compq, n,
00125                     traits::matrix_storage (t), 
00126                     traits::leading_dimension (t),
00127                     traits::matrix_storage (q),
00128                     traits::leading_dimension (q),
00129                     ifst, ilst,
00130                     traits::vector_storage (work),
00131                     info);
00132       return info; 
00133     }
00134 
00135   }
00136 
00137 }}}
00138 
00139 #endif 

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