2016-09-08 35 views
1

我不明白digamma function of boost如何在程序中使用。任何例子,赞赏。我包括提高如何在boost中使用digamma函数

#include <boost/math/special_functions/digamma.hpp> 

但函数调用digamma(x),其中x是一个double提供了以下错误:

error: there are no arguments to ‘digamma’ that depend on a template parameter, so a declaration of ‘digamma’ must be available [-fpermissive]

+1

你有什么不明白的?您只需插入一个值并获取记录的结果,并不容易。 –

+0

更具体地说,如果该功能不知何故不适合你,请出示你的[mcve],这样我们就可以看到你在做什么错误/你没有正确理解。 –

+0

刚刚编辑了这个问题。 – user3639557

回答

1

下面是一个例子: http://cpp.sh/7bdu

#include <boost/math/special_functions/digamma.hpp> 
#include <iostream> 
int main() { 
    std::cout << boost::math::digamma(3.14) << "\n"; 
} 

编辑:这个问题是用一个错误信息编辑的。错误消息意味着编译器没有找到digamma的定义,因为您没有包含命名空间位boost::math::

+0

啊,你说得对。有没有办法为'boost :: math :: digamma()'定义一个更短的别名? – user3639557

+0

是的,您可以使用[using directives](http://en.cppreference.com/w/cpp/language/namespace#Using-directives)或[using declarations](http://en.cppreference.com/W/CPP /语言/命名空间#使用申述)。 –

相关问题