00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef BOOST_NUMERIC_BINDINGS_LAPACK_POSV_HPP
00015 #define BOOST_NUMERIC_BINDINGS_LAPACK_POSV_HPP
00016
00017 #include <boost/numeric/bindings/traits/type_traits.hpp>
00018 #include <boost/numeric/bindings/traits/traits.hpp>
00019 #include <boost/numeric/bindings/lapack/lapack.h>
00020
00021 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00022 # include <boost/numeric/bindings/traits/detail/symm_herm_traits.hpp>
00023 # include <boost/static_assert.hpp>
00024 # include <boost/type_traits/is_same.hpp>
00025 #endif
00026
00027 #include <cassert>
00028
00029 namespace boost { namespace numeric { namespace bindings {
00030
00031 namespace lapack {
00032
00034
00035
00036
00037
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 namespace detail {
00061
00062 inline
00063 void posv (char const uplo, int const n, int const nrhs,
00064 float* a, int const lda,
00065 float* b, int const ldb, int* info)
00066 {
00067 LAPACK_SPOSV (&uplo, &n, &nrhs, a, &lda, b, &ldb, info);
00068 }
00069
00070 inline
00071 void posv (char const uplo, int const n, int const nrhs,
00072 double* a, int const lda,
00073 double* b, int const ldb, int* info)
00074 {
00075 LAPACK_DPOSV (&uplo, &n, &nrhs, a, &lda, b, &ldb, info);
00076 }
00077
00078 inline
00079 void posv (char const uplo, int const n, int const nrhs,
00080 traits::complex_f* a, int const lda,
00081 traits::complex_f* b, int const ldb, int* info)
00082 {
00083 LAPACK_CPOSV (&uplo, &n, &nrhs,
00084 traits::complex_ptr (a), &lda,
00085 traits::complex_ptr (b), &ldb, info);
00086 }
00087
00088 inline
00089 void posv (char const uplo, int const n, int const nrhs,
00090 traits::complex_d* a, int const lda,
00091 traits::complex_d* b, int const ldb, int* info)
00092 {
00093 LAPACK_ZPOSV (&uplo, &n, &nrhs,
00094 traits::complex_ptr (a), &lda,
00095 traits::complex_ptr (b), &ldb, info);
00096 }
00097
00098 template <typename SymmMatrA, typename MatrB>
00099 inline
00100 int posv (char const uplo, SymmMatrA& a, MatrB& b) {
00101 int const n = traits::matrix_size1 (a);
00102 assert (n == traits::matrix_size2 (a));
00103 assert (n == traits::matrix_size1 (b));
00104 int info;
00105 posv (uplo, n, traits::matrix_size2 (b),
00106 traits::matrix_storage (a),
00107 traits::leading_dimension (a),
00108 traits::matrix_storage (b),
00109 traits::leading_dimension (b),
00110 &info);
00111 return info;
00112 }
00113
00114 }
00115
00116 template <typename SymmMatrA, typename MatrB>
00117 inline
00118 int posv (char const uplo, SymmMatrA& a, MatrB& b) {
00119
00120 assert (uplo == 'U' || uplo == 'L');
00121
00122 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00123 BOOST_STATIC_ASSERT((boost::is_same<
00124 typename traits::matrix_traits<SymmMatrA>::matrix_structure,
00125 traits::general_t
00126 >::value));
00127 BOOST_STATIC_ASSERT((boost::is_same<
00128 typename traits::matrix_traits<MatrB>::matrix_structure,
00129 traits::general_t
00130 >::value));
00131 #endif
00132
00133 return detail::posv (uplo, a, b);
00134 }
00135
00136 template <typename SymmMatrA, typename MatrB>
00137 inline
00138 int posv (SymmMatrA& a, MatrB& b) {
00139
00140 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00141 typedef traits::matrix_traits<SymmMatrA> matraits;
00142 typedef typename matraits::value_type val_t;
00143 BOOST_STATIC_ASSERT( (traits::detail::symm_herm_compatible< val_t, typename matraits::matrix_structure >::value ) ) ;
00144 BOOST_STATIC_ASSERT((boost::is_same<
00145 typename traits::matrix_traits<MatrB>::matrix_structure,
00146 traits::general_t
00147 >::value));
00148 #endif
00149
00150 char uplo = traits::matrix_uplo_tag (a);
00151 return detail::posv (uplo, a, b);
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 namespace detail {
00165
00166 inline
00167 void potrf (char const uplo, int const n,
00168 float* a, int const lda, int* info)
00169 {
00170 LAPACK_SPOTRF (&uplo, &n, a, &lda, info);
00171 }
00172
00173 inline
00174 void potrf (char const uplo, int const n,
00175 double* a, int const lda, int* info)
00176 {
00177 LAPACK_DPOTRF (&uplo, &n, a, &lda, info);
00178 }
00179
00180 inline
00181 void potrf (char const uplo, int const n,
00182 traits::complex_f* a, int const lda, int* info)
00183 {
00184 LAPACK_CPOTRF (&uplo, &n, traits::complex_ptr (a), &lda, info);
00185 }
00186
00187 inline
00188 void potrf (char const uplo, int const n,
00189 traits::complex_d* a, int const lda, int* info)
00190 {
00191 LAPACK_ZPOTRF (&uplo, &n, traits::complex_ptr (a), &lda, info);
00192 }
00193
00194 template <typename SymmMatrA>
00195 inline
00196 int potrf (char const uplo, SymmMatrA& a) {
00197 int const n = traits::matrix_size1 (a);
00198 assert (n == traits::matrix_size2 (a));
00199 int info;
00200 potrf (uplo, n, traits::matrix_storage (a),
00201 traits::leading_dimension (a), &info);
00202 return info;
00203 }
00204
00205 }
00206
00207 template <typename SymmMatrA>
00208 inline
00209 int potrf (char const uplo, SymmMatrA& a) {
00210
00211 assert (uplo == 'U' || uplo == 'L');
00212
00213 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00214 BOOST_STATIC_ASSERT((boost::is_same<
00215 typename traits::matrix_traits<SymmMatrA>::matrix_structure,
00216 traits::general_t
00217 >::value));
00218 #endif
00219
00220 return detail::potrf (uplo, a);
00221 }
00222
00223 template <typename SymmMatrA>
00224 inline
00225 int potrf (SymmMatrA& a) {
00226
00227 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00228 typedef traits::matrix_traits<SymmMatrA> matraits;
00229 typedef typename matraits::value_type val_t;
00230 BOOST_STATIC_ASSERT((boost::is_same<
00231 typename matraits::matrix_structure,
00232 typename traits::detail::symm_herm_t<val_t>::type
00233 >::value));
00234 #endif
00235
00236 char uplo = traits::matrix_uplo_tag (a);
00237 return detail::potrf (uplo, a);
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247 namespace detail {
00248
00249 inline
00250 void potrs (char const uplo, int const n, int const nrhs,
00251 float const* a, int const lda,
00252 float* b, int const ldb, int* info)
00253 {
00254 LAPACK_SPOTRS (&uplo, &n, &nrhs, a, &lda, b, &ldb, info);
00255 }
00256
00257 inline
00258 void potrs (char const uplo, int const n, int const nrhs,
00259 double const* a, int const lda,
00260 double* b, int const ldb, int* info)
00261 {
00262 LAPACK_DPOTRS (&uplo, &n, &nrhs, a, &lda, b, &ldb, info);
00263 }
00264
00265 inline
00266 void potrs (char const uplo, int const n, int const nrhs,
00267 traits::complex_f const* a, int const lda,
00268 traits::complex_f* b, int const ldb, int* info)
00269 {
00270 LAPACK_CPOTRS (&uplo, &n, &nrhs,
00271 traits::complex_ptr (a), &lda,
00272 traits::complex_ptr (b), &ldb, info);
00273 }
00274
00275 inline
00276 void potrs (char const uplo, int const n, int const nrhs,
00277 traits::complex_d const* a, int const lda,
00278 traits::complex_d* b, int const ldb, int* info)
00279 {
00280 LAPACK_ZPOTRS (&uplo, &n, &nrhs,
00281 traits::complex_ptr (a), &lda,
00282 traits::complex_ptr (b), &ldb, info);
00283 }
00284
00285 template <typename SymmMatrA, typename MatrB>
00286 inline
00287 int potrs (char const uplo, SymmMatrA const& a, MatrB& b) {
00288 int const n = traits::matrix_size1 (a);
00289 assert (n == traits::matrix_size2 (a));
00290 assert (n == traits::matrix_size1 (b));
00291 int info;
00292 potrs (uplo, n, traits::matrix_size2 (b),
00293 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
00294 traits::matrix_storage (a),
00295 #else
00296 traits::matrix_storage_const (a),
00297 #endif
00298 traits::leading_dimension (a),
00299 traits::matrix_storage (b),
00300 traits::leading_dimension (b),
00301 &info);
00302 return info;
00303 }
00304
00305 }
00306
00307 template <typename SymmMatrA, typename MatrB>
00308 inline
00309 int potrs (char const uplo, SymmMatrA const& a, MatrB& b) {
00310
00311 assert (uplo == 'U' || uplo == 'L');
00312
00313 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00314 BOOST_STATIC_ASSERT((boost::is_same<
00315 typename traits::matrix_traits<SymmMatrA>::matrix_structure,
00316 traits::general_t
00317 >::value));
00318 BOOST_STATIC_ASSERT((boost::is_same<
00319 typename traits::matrix_traits<MatrB>::matrix_structure,
00320 traits::general_t
00321 >::value));
00322 #endif
00323
00324 return detail::potrs (uplo, a, b);
00325 }
00326
00327 template <typename SymmMatrA, typename MatrB>
00328 inline
00329 int potrs (SymmMatrA const& a, MatrB& b) {
00330
00331 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00332 typedef traits::matrix_traits<SymmMatrA> matraits;
00333 typedef traits::matrix_traits<MatrB> mbtraits;
00334 typedef typename matraits::value_type val_t;
00335 BOOST_STATIC_ASSERT((boost::is_same<
00336 typename matraits::matrix_structure,
00337 typename traits::detail::symm_herm_t<val_t>::type
00338 >::value));
00339 BOOST_STATIC_ASSERT((boost::is_same<
00340 typename mbtraits::matrix_structure, traits::general_t
00341 >::value));
00342 #endif
00343
00344 char uplo = traits::matrix_uplo_tag (a);
00345 return detail::potrs (uplo, a, b);
00346 }
00347
00348
00349
00350 }
00351
00352 }}}
00353
00354 #endif