I really do not know how to solve it and need help to get through my work.
Can anyone with kindness help me?
 
 
---------- 转发邮件信息 ----------
发件人:"fmingu <fmingu@163.com>"
发送日期:2010-03-29 09:02:29
收件人:boost-users@lists.boost.org
主题: Re:Re: [Boost-users] A question on the preciseness of the double used in MTL. Can anyone with kindness help me?


在2010-03-29 08:28:13,"Steven Watanabe" <watanabesj@gmail.com> 写道:
>AMDG
>
>fmingu wrote:
>> I am using MTL(Matrix Template Library) for Matrix computing in Dev-C++ 4.9.8.0 and updated the gcc version from 3.2 to 4.4.1 by installing tdm-mingw-1.908.0-4.4.1-2 and the boost version is 1.37.0. The system is Windows xp The sample code is :
>>
>>  
>>
>> #include <boost/numeric/mtl/mtl.hpp>
>>
>>  
>>
>> #include "boost/random/normal_distribution.hpp"
>>
>> #include <boost/random.hpp>
>>
>> #include <boost/random/uniform_real.hpp>
>>
>>  
>>
>>  
>>
>> int main(int argc, char* argv[])
>>
>> {
>>
>>     using namespace mtl; using namespace mtl::matrix;
>>
>>     
>>
>>     const unsigned n= 5;
>>
>>     dense2D<double>                            A(n, n), B(n, n);
>>
>>     morton_dense<double, doppled_64_row_mask>  C(n, n), D(n, n);
>>
>>     
>>
>>     dense2D<double>                            F(n, n), E(n, n);
>>
>>     hessian_setup(A, 3.0); hessian_setup(B, 1.0); 
>>
>> hessian_setup(C, 2.0); hessian_setup(D, 11.0);
>>
>> B(1,1)=9.9999;
>>
>> ..........................
>>
>>     std::cout << "The matrices are: B=\n" << B <<"\n"; 
>>
>>     std::cout << "The result is  " <<1.0/3.0 <<"\n";
>>
>> …………………….
>>
>> But the result is shown that B(1,1) is 10, and 1.0/3.0 is 0.33.
>>
>> How can I get the highest precision of the type double and dense2D<double> for scientific computation?
>>
>> The same question occurred in random number generation in boost random library.
>>   
>
>Use std::setprecision to print more digits.
>
>In Christ,
>Steven Watanabe
>
I rewrote the program following your advice but      
std::cout << "The matrices are: B=\n" <<  std::setprecision(5)<<B<<"\n"; 
do not  show any changes  while the code:
    std::cout <<  "The result is  "   << std::setprecision(10)<<1.0/3.0 <<"\n";
worked well.
How can I do now?
Thanks a lot.