- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我对使用隐式方案使用 odeint 库求解 ODE 系统很感兴趣,但我很难实现一个简单的 implicit_euler
示例。
查看文档,我设法使工作显式步进器、自适应步进器以及 rosenbrock4
步进器。前者似乎是半隐式的。因此,我有兴趣实现一个完全隐式的方案(同时在每个时间步检索雅可比矩阵)。但是我没能找到这个步进器的文档和工作示例。我有的是
typedef boost::numeric::ublas::vector< double > vector_type;
typedef boost::numeric::ublas::matrix< double > matrix_type;`
struct stiff_system
{
void operator()( const vector_type &x , vector_type &dxdt , double /* t */ )
{
dxdt[ 0 ] = -101.0 * x[ 0 ] - 100.0 * x[ 1 ];
dxdt[ 1 ] = x[ 0 ];
}
};
struct stiff_system_jacobi
{
void operator()( const vector_type & /* x */ , matrix_type &J , const double & /* t */ , vector_type &dfdt )
{
J( 0 , 0 ) = -101.0;
J( 0 , 1 ) = -100.0;
J( 1 , 0 ) = 1.0;
J( 1 , 1 ) = 0.0;
dfdt[0] = 0.0;
dfdt[1] = 0.0;
}
};
typedef implicit_euler< double > stepper_IE;
vector_type inout( 2 , 1.0 );
size_t steps = integrate_const( stepper_IE() ,
std::make_pair( stiff_system() , stiff_system_jacobi() ) ,
inout , 0.0 , 5.0 , 0.01, streaming_observer( std::cout, x_vec , times ));
错误如下:
C:\boost_1_55_0\boost\numeric\odeint\stepper\implicit_euler.hpp:94
: error: C2064: term does not evaluate to a function taking 3 arguments class does not define an 'operator()
' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments
我现在的问题是:有人知道如何让它工作吗,或者有人可以指点我看比这个更详细的文档:
或者这个:
谢谢
最佳答案
不幸的是,隐式欧拉法和 Rosenbrock 求解器(另一个隐式求解器)没有相同的接口(interface)。详细而言,隐式欧拉期望具有此签名的雅可比行列式函数
void jacobian( const state_type &x , matrix_type &jacobi , const value_type t );
因此,您需要将 stiff_system_jacobi
的定义更改为
struct stiff_system_jacobi
{
void operator()( const vector_type & , matrix_type &J , const double & ) const
{
J( 0 , 0 ) = -101.0;
J( 0 , 1 ) = -100.0;
J( 1 , 0 ) = 1.0;
J( 1 , 1 ) = 0.0;
}
};
如果您的系统确实是非自治的,您需要通过一个额外的坐标来增强状态类型,该坐标代表时间并且具有平凡的动力学 dt/dt = 1。
关于c++ - odeint 隐式欧拉简单示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24207938/
在编程中,我只使用整数。不过这次要进行一些计算。我需要计算Euler-Mascheroni Constant γ .最多 n 位小数。{虽然 n ∈ [30, 150]对我来说已经足够了。 [x] =
有人可以帮忙处理这段代码吗?它应该得到第 10,001 个素数。我知道 is_prime 函数可以测试一个数字是否为素数,因为我成功地利用此代码解决了上一个问题。现在我只是尝试在 for 循环中调用它
我发现了几个与这个问题相关的主题,我只是想知道为什么我的代码返回不正确的数据。所以我们必须找到第一个除数超过 500 的三角形数。详情可在此处找到:http://projecteuler.net/pr
#include int main(void) { char *num = "73167176531330624919225119674426574742355349194934"
我正在尝试投影欧拉问题 8,但是我遇到了问题。1000位数字中相邻四位的乘积最大为9×9×8×9=5832。 731671765313306249192251196744265747423553491
这是针对 Project Euler 19 的。我几乎想出了代码,但由于某种原因我的输出是 +1。 #include #define SIZE 12 int main(void) {
int main(void) { int n, div, a, b; double phi; printf("Enter n:\n"); if (scanf("%d", &n) < 1
欧拉问题: 如果我们列出所有 10 以下的自然数,它们是 3 或 5 的倍数,我们得到 3、5、6 和 9。这些倍数的和是 23。 求 1000 以下的所有 3 或 5 的倍数之和。 我试图从 pro
我知道这可能会被否决,但我真的很沮丧 24 小时,查看其他 Euler 3 线程并没有帮助我解决这个问题。有人可以帮助我的代码吗?我认为我非常接近。 function is_prime(num) {
我卡在了Question 7欧拉计划。我有这段代码。 #include int main (void) { int contador = 0, i, n, variavel = 0;
我正在尝试使用 sympy 的 idiff 函数对某些表达式执行隐式微分。 在本例中,rdot 为 dr/ds,其中 s 是仿射参数。我想对相同的仿射参数对 Ltdot、Lphidot 和 Lrdot
我正在尝试解决我的第一个项目 Euler 问题,只是为了玩 Rust,但被困在似乎需要极长计算时间的问题上 问题: https://projecteuler.net/problem=757 我想出了这
我正在学习C编程,并制定了以下算法来解决这个问题: 代码实际上有效,但最初循环只有 10 次重复(rep int main() { float p; //the power for e
我之前曾尝试暴力破解它,但没有成功。这是我的递归尝试#2(第一次使用递归方法)。请帮忙! 发生的情况是这样的:代码运行良好,数字较小,但是当我们达到一百万时,代码就会运行,并且什么也不会发生。在 Ec
Given a number find the 5 digits before the trailing 0. 9! = 362880 so f(9)=36288 10! = 3628800 so f
我是一名优秀的程序员,十分优秀!