代码说明
我正在尝试创建一个具有浮点类型的双指针函数,并且有 3 个浮点参数。该函数应该通过使用“malloc”和“calloc”函数为二维数组分配内存来存储微分方程的数值解来求解一阶常微分方程。
求解器的原型函数是float **RK2(float t0, float x0, float h);
其中t0
和x0
是方程的初始条件,h
是所使用的步长。
执行所有计算并将所有数据存储在分配的名为 的数组中后,我返回一个双指针,该指针指向包含所有解决方案的x
数组。x
在我的过程中main()
,我调用该函数RK2
并将返回值设置为一个双指针,表示p
我想要指向该数组x
。call 命令是p = RK2(t0, x0, h)
p 声明的地方float **p = NULL
相关代码
在代码中,func
下面的函数只是包含微分方程信息的函数。
#include <stdio.h>
#include <stdlib.h>
#define ROWS 1000
#define COLUMNS 2
float func(float x, float t);
float **RK2(float tt0, float x0, float h);
int main(){
float t0 = 0.0;
float x0 = …
Run Code Online (Sandbox Code Playgroud)