00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef BOOST_NUMERIC_BINDINGS_LAPACK_GEQRF_HPP
00015 #define BOOST_NUMERIC_BINDINGS_LAPACK_GEQRF_HPP
00016
00017 #include <complex>
00018 #include <boost/numeric/bindings/traits/traits.hpp>
00019 #include <boost/numeric/bindings/lapack/lapack.h>
00020 #include <boost/numeric/bindings/lapack/workspace.hpp>
00021 #include <boost/numeric/bindings/traits/detail/array.hpp>
00022
00023
00024 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00025 # include <boost/static_assert.hpp>
00026 # include <boost/type_traits.hpp>
00027 #endif
00028 #include <cassert>
00029
00030
00031 namespace boost { namespace numeric { namespace bindings {
00032
00033 namespace lapack {
00034
00036
00037
00038
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 namespace detail {
00055
00056 inline
00057 void geqrf (int const m, int const n,
00058 float* a, int const lda,
00059 float* tau, float* work, int const lwork, int& info)
00060 {
00061 LAPACK_SGEQRF (&m, &n, a, &lda, tau, work, &lwork, &info);
00062 }
00063
00064 inline
00065 void geqrf (int const m, int const n,
00066 double* a, int const lda,
00067 double* tau, double* work, int const lwork, int& info)
00068 {
00069 LAPACK_DGEQRF (&m, &n, a, &lda, tau, work, &lwork, &info);
00070 }
00071
00072 inline
00073 void geqrf (int const m, int const n,
00074 traits::complex_f* a, int const lda,
00075 traits::complex_f* tau, traits::complex_f* work,
00076 int const lwork, int& info)
00077 {
00078 LAPACK_CGEQRF (&m, &n,
00079 traits::complex_ptr (a), &lda,
00080 traits::complex_ptr (tau),
00081 traits::complex_ptr (work), &lwork, &info );
00082 }
00083
00084
00085 inline
00086 void geqrf (int const m, int const n,
00087 traits::complex_d* a, int const lda,
00088 traits::complex_d* tau, traits::complex_d* work,
00089 int const lwork, int& info)
00090 {
00091 LAPACK_ZGEQRF (&m, &n,
00092 traits::complex_ptr (a), &lda,
00093 traits::complex_ptr (tau),
00094 traits::complex_ptr (work), &lwork, &info );
00095 }
00096
00097 }
00098
00099 template <typename A, typename Tau, typename Work>
00100 inline
00101 int geqrf (A& a, Tau& tau, Work& work) {
00102
00103 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00104 BOOST_STATIC_ASSERT((boost::is_same<
00105 typename traits::matrix_traits<A>::matrix_structure,
00106 traits::general_t
00107 >::value));
00108 #endif
00109
00110 int const m = traits::matrix_size1 (a);
00111 int const n = traits::matrix_size2 (a);
00112 assert (std::min(m,n) <= traits::vector_size (tau));
00113 assert (n <= traits::vector_size (work));
00114
00115 int info;
00116 detail::geqrf (m, n,
00117 traits::matrix_storage (a),
00118 traits::leading_dimension (a),
00119 traits::vector_storage (tau),
00120 traits::vector_storage (work),
00121 traits::vector_size (work),
00122 info);
00123 return info;
00124 }
00125
00126
00127
00128
00129 template <typename A, typename Tau>
00130 inline
00131 int geqrf (A& a, Tau& tau, optimal_workspace ) {
00132 typedef typename A::value_type value_type ;
00133 const int n = traits::matrix_size2 (a);
00134 traits::detail::array<value_type> work(std::max(1, n*32));
00135 return geqrf( a, tau, work );
00136 }
00137
00138
00139
00140
00141 template <typename A, typename Tau>
00142 inline
00143 int geqrf (A& a, Tau& tau, minimal_workspace ) {
00144 typedef typename A::value_type value_type ;
00145 const int n = traits::matrix_size2 (a);
00146 traits::detail::array<value_type> work(std::max(1, n));
00147 return geqrf( a, tau, work );
00148 }
00149
00150
00151
00152
00153
00154
00155 template <typename A, typename Tau, typename Work>
00156 inline
00157 int geqrf (A& a, Tau& tau, detail::workspace1<Work> workspace ) {
00158 typedef typename A::value_type value_type ;
00159 const int n = traits::matrix_size2 (a);
00160 traits::detail::array<value_type> work(std::max(1, n));
00161 return geqrf( a, tau, workspace.w_ );
00162 }
00163
00164
00165 template <typename A, typename Tau>
00166 inline
00167 int geqrf (A& a, Tau& tau) {
00168 return geqrf( a, tau, optimal_workspace() );
00169 }
00170
00171 }
00172
00173 }}}
00174
00175 #endif