提升 ODEINT 太多参数无法发挥作用
boost odeint too many arguments to function
我使用 boost/odeint 来解决一阶颂歌。
raman_system.h
中系统的定义如下所示:
class raman_signal_system {
double alpha_s;
double dB_to_neper;
double g_pump_b;
double P_p;
public:
raman_signal_system()
: alpha_s(0.00021181),
dB_to_neper(0.23025850929940458),
g_pump_b(0.00044446),
P_p(0.494) {}
void operator() (const double P_s, double& dPsdz, const double z)
{
dPsdz = -alpha_s * dB_to_neper * P_s + P_s * P_p * g_pump_b;
}
};
我在拉曼main
方法.cpp如下:
/**
* @author Harun Kara
* @date 23.01.2017
* @brief Implementaion of the Raman amplification for fiber communications systems
*/
#include "raman_system.h"
#include <fstream>
#include <iostream>
#include <vector>
#include<boost/numeric/odeint.hpp>
int main(int argc, char *argv[]) {
namespace odeint = boost::numeric::odeint;
odeint::runge_kutta4< double > rk4;
raman_signal_system sys();
double P_s = 0.00079433;
double z = 0.0; // initial (forward/signal)
double l = 80e3; // Fiberlenght in m
size_t steps = 200;
const double dz = l/steps; // stepsize
std::vector<double> P_s_vec;
std::vector<double> places;
P_s_vec.push_back(P_s);
places.push_back(z);
for( size_t i=0; i<steps; ++i ) {
rk4.do_step( sys, P_s, z, dz );
z += dz;
P_s_vec.push_back(P_s);
places.push_back(z);
}
return 0;
}
如果我尝试构建,则会收到以下错误:
/home/kara/raman/src/raman.cpp:43: required from here
/home/kara/raman/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp:229: error: too many arguments to function
sys( x , m_dxdt.m_v ,t );
我找不到导致此错误的原因。请有人帮助我,找出我的代码有什么问题吗?
使用 Boost 1.60.0, Qt, CMake
此行
raman_signal_system sys();
被编译器识别为本地函数声明,因此错误消息是传递给该函数的参数过多。
要使用变量的默认构造函数初始化变量,只需编写
raman_signal_system sys; // <<<< No parenthesis
正确声明 sys
变量后,重载调用operator()
应该可以正常工作:
sys( x , m_dxdt.m_v ,t );
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 未在作用域中声明unordered_map
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 有没有一种方法可以在编译时获得作用域类名
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- C++quit()函数中可能存在作用域问题
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 带有指定长度字符* 参数的 std::regex_search 在 VS2017 中不起作用?
- "using namespace std;"在C++的作用是什么?
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- Eigen::VectorXd 和 Boost::Odeint,不起作用
- 提升 ODEINT 太多参数无法发挥作用
- get_unit_value在提升ODEINT中的作用