首页 > 解决方案 > 如何在 C++ 中调用 cmath 库中的特殊函数?

问题描述

我正在尝试定义一个函数,该函数需要我使用称为“关联拉盖尔多项式”的东西。它在图书馆下面列出。在 Visual Studio 代码中,intellisense 将“assoc_laguerre()”预测为一个函数,因此它显然存在!

然而,在构建代码时,它会突出显示带有消息的 assoc_laguerre() 函数:“未找到标识符”。

任何帮助将不胜感激!谢谢!

代码:

#include <iostream>
#include <vector>
#include <string>
#include<vector>
#include<fstream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<time.h>
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1
#include<math.h>
#include <stdio.h>
#include <cmath>
using namespace std;

//Function Definitons:
double a = 5.29177210903*pow(10,-11);
// Normalised Radial Component:
double Radial(double r,int n,int l,int Z){
    double rho, prefactor,R,L,M;
    rho = 2*r*Z/(n*a);
    R=pow(pow(rho/r,3)*tgamma(n-l)/(2*n*tgamma(n+l+1)),0.5)*exp(-rho/2)*pow(rho,l);
    L=R*assoc_laguerre(n-l-1,2*l+1,rho);

    M=L*R;
    return M;



}
int main()
{
    vector<string> msg {"End Process."};

    for (const string& word : msg)
    {
        cout << word << " ";
    }
  
}

标签: c++identifiercmath

解决方案


您没有使用启用的语言标准的 C++ 2017 版本进行编译。启用它,这应该可用。您的代码使用 GCC 10.1 和-std=c++17; 但如果我们使用-std=c++14而不是。

GodBolt


推荐阅读