?? ode_rungekuttacontentstep.c
字號:
//ODE_RungeKuttaContentStep.cpp
//全區間定步長積分龍格-庫塔法
#include <iostream> //輸入輸出流頭文件
#include "OrdinaryDifferentialEguation.h" //求解常微分方程(組)頭文件
using namespace std; //名字空間
void main(void)
{
double y[3] = {-1.0, 0.0, 1.0}, t(0.0), h(0.01);
valarray<double> vy(y, 3);
matrix<double> vz(3,11);
ODE_RungeKuttaContentStep(t,vy,h,11,vz);
cout.setf(ios::fixed); //輸出數據為定點法
cout.precision(6); //精度6位
for(int i=0; i<11; i++)
{
double x = h * i;
cout << "t = " << x << endl;
for(int j=0; j<3; j++)
cout << " y(" << j << ") = " << vz(j, i) << "\t";
cout << endl;
}
}
//計算微分方程組中各方程右端函數值
template <class _Ty>
void FunctionValueRKCS(_Ty t, valarray<_Ty>& y, valarray<_Ty>& d)
{
int n = y.size(); //微分方程組中方程的個數,也是未知函數的個數
d[0] = y[1];
d[1] = -y[0];
d[2] = -y[2];
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -