2012-03-14 6 views
0

私は次のコードを持っている:私は、コンパイル時に、私は次のエラーを取得する、しかしブーストSTUDENT_T分布

#include <boost/smart_ptr/shared_ptr.hpp> 
#include <boost/numeric/interval.hpp> 
#include <boost/math/distributions/students_t.hpp> 

using namespace boost::numeric; 
using namespace interval_lib; 

unsigned int len=10; 
unsigned int v = len - 1; 
    double sqrtlen = sqrt(double(len)); 
    students_t dist(v); 
    double stdev = 0.2; 
    double mean = 3; 
    double t_stat = mean * sqrtlen/stdev; 
    double q = cdf(complement(dist, std::fabs(t_stat))); 

を:

Tests.cpp:39:3: error: ‘students_t’ was not declared in this scope 
Tests.cpp:39:14: error: expected ‘;’ before ‘dist’ 
Tests.cpp:45:31: error: ‘dist’ was not declared in this scope 
Tests.cpp:45:54: error: ‘complement’ was not declared in this scope 
Tests.cpp:45:55: error: ‘cdf’ was not declared in this scope 

私が持っているとき、それは文句を言っている理由を私は理解していません適切なヘッダーが含まれています。誰でもそれを修正する方法を教えてもらえますか?ありがとう!

答えて

2

いい名前空間が含まれていないためです。

So, for example, the Students-t distribution template in namespace boost::math is

Link here

+0

ありがとうございました。私は名前空間のboost :: mathを見逃していました。それを修正しました – user1155299

+0

@ user1155299:この場合、この回答を受け入れる必要があります。 – Mankarse

1

I think your namespace might be off.別の一般的指針:DOCから、あなたが名前の衝突を持っている場合は、可能な場合のディレクティブ「を使用して」避け、彼らはいくつかの本当に困難なデバッグエラーが発生する可能性があります。

+0

ありがとう、私はboost :: mathで修正した – user1155299