steqr.hpp

Go to the documentation of this file.
00001 //
00002 // Copyright Karl Meerbergen 2007
00003 //
00004 // Distributed under the Boost Software License, Version 1.0. 
00005 // (See accompanying file LICENSE_1_0.txt or copy at 
00006 // http://www.boost.org/LICENSE_1_0.txt)
00007 //
00008 
00009 #ifndef BOOST_NUMERIC_BINDINGS_LAPACK_STEQR_HPP
00010 #define BOOST_NUMERIC_BINDINGS_LAPACK_STEQR_HPP
00011 
00012 #include <boost/numeric/bindings/lapack/workspace.hpp>
00013 #include <boost/numeric/bindings/traits/vector_traits.hpp>
00014 #include <boost/numeric/bindings/traits/matrix_traits.hpp>
00015 #include <boost/numeric/bindings/traits/type_traits.hpp>
00016 #include <boost/numeric/bindings/traits/detail/array.hpp>
00017 #include <boost/numeric/bindings/traits/traits.hpp>
00018 #include <boost/numeric/bindings/lapack/lapack.h>
00019 
00020 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK 
00021 #  include <boost/static_assert.hpp>
00022 #  include <boost/type_traits/is_same.hpp>
00023 #endif 
00024 
00025 
00026   /********************************************************************/
00027   /*                      eigenvalue problems                         */
00028   /********************************************************************/
00029 
00030   /* tridiagonal symmetric */
00031 
00032 
00033 namespace boost { namespace numeric { namespace bindings { namespace lapack {
00034 
00035     namespace detail {
00036 
00037       inline 
00038       void steqr ( char compz, int n, float* d, float* e, float* z, int ldz, float* work, int& info ) 
00039       {
00040         LAPACK_SSTEQR( &compz, &n, d, e, z, &ldz, work, &info ) ;
00041       }
00042 
00043       inline 
00044       void steqr ( char compz, int n, double* d, double* e, double* z, int ldz, double* work, int& info ) 
00045       {
00046         LAPACK_DSTEQR( &compz, &n, d, e, z, &ldz, work, &info ) ;
00047       }
00048 
00049     } // namespace detail
00050 
00051 
00052     template <typename D, typename E, typename Z, typename W>
00053     inline
00054     int steqr( char compz, D& d, E& e, Z& z, W& work ) {
00055 
00056       int const n = traits::vector_size (d);
00057       assert( traits::vector_size (e) == n-1 );
00058       assert( traits::matrix_size1 (z) == n );
00059       assert( traits::matrix_size2 (z) == n );
00060       assert( compz=='N' || compz=='V' || compz=='I' );
00061 
00062       int lwork = traits::vector_size( work ) ;
00063 
00064       int info; 
00065       detail::steqr( compz, n,
00066                      traits::vector_storage( d ), 
00067                      traits::vector_storage( e ), 
00068                      traits::matrix_storage( z ), 
00069                      traits::leading_dimension( z ), 
00070                      traits::vector_storage( work ),  
00071                      info ) ;
00072       return info; 
00073     } // steqr()
00074 
00075 
00076     template <typename D, typename E, typename Z>
00077     inline
00078     int steqr( char compz, D& d, E& e, Z& z, optimal_workspace ) {
00079       int lwork = 0 ;
00080       if (compz != 'N') lwork = 2 * traits::vector_size( d ) - 2 ;
00081 
00082       traits::detail::array<typename traits::vector_traits<D>::value_type> work( lwork );
00083 
00084       return steqr( compz, d, e, z, work ) ;
00085     }
00086 
00087 
00088     template <typename D, typename E, typename Z>
00089     inline
00090     int steqr( char compz, D& d, E& e, Z& z, minimal_workspace ) {
00091       int lwork = 1 ;
00092       if (compz != 'N') lwork = 2 * traits::vector_size( e ) ;
00093 
00094       traits::detail::array<typename traits::vector_traits<D>::value_type> work( lwork );
00095 
00096       return steqr( compz, d, e, z, work ) ;
00097     }
00098 
00099     template <typename D, typename E, typename Z>
00100     inline
00101     int steqr( char compz, D& d, E& e, Z& z ) {
00102       return steqr( compz, d, e, z, minimal_workspace() ) ;
00103     }
00104 
00105 
00106 }}}}
00107 
00108 #endif // BOOST_NUMERIC_BINDINGS_LAPACK_GBSV_HPP

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