Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_BIG_BIG_GENERATE_PD_H
00002 #define OPENTISSUE_CORE_MATH_BIG_BIG_GENERATE_PD_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_random.h>
00013 #include <OpenTissue/core/math/math_value_traits.h>
00014 #include <OpenTissue/core/math/big/big_types.h>
00015 #include <OpenTissue/core/math/big/big_generate_PSD.h>
00016
00017 namespace OpenTissue
00018 {
00019 namespace math
00020 {
00021 namespace big
00022 {
00023
00032 template<typename matrix_type>
00033 inline void generate_PD( size_t const & n, matrix_type & A )
00034 {
00035 typedef typename matrix_type::value_type value_type;
00036 typedef OpenTissue::math::ValueTraits<value_type> value_traits;
00037
00038 generate_PSD(n, A, value_traits::zero() );
00039 }
00040
00049 template<typename matrix_type>
00050 inline void fast_generate_PD( size_t const & n, matrix_type & A )
00051 {
00052 typedef typename matrix_type::value_type value_type;
00053 typedef OpenTissue::math::ValueTraits<value_type> value_traits;
00054
00055 Random<value_type> value(value_traits::zero(),value_traits::one());
00056
00057 matrix_type R;
00058 R.resize(n,n,false);
00059
00060 for(size_t i=0;i<n;++i)
00061 {
00062 for(size_t j=0;j<n;++j)
00063 R(i,j) = value();
00064 }
00065
00066 ublas::noalias(A) = ublas::sparse_prod< matrix_type >( ublas::trans(R), R );
00067
00068 for(size_t i=0;i<n;++i)
00069 A(i,i) += value();
00070 }
00071
00072 }
00073 }
00074 }
00075
00076
00077 #endif