我在Octave中有以下代码试图使用Simpson的方法实现自适应求积:
function integral = adaptive2(f, a, b, TOL, count)
max_count = 20;
disp("hello world");
disp(count);
h = (b-a)/2;
x_1 = a;
x_2 = (b-a)/2;
x_3 = b;
w_0 = a;
w_1 = (b-a)/4;
w_2 = (b-a)/2;
w_3 = 3*(b-a)/4;
w_4 = b;
initial_1 = (f(x_1) + 4*f(x_2) + f(x_3));
i1 = (h/3) * initial_1;
initial_2 = (f(w_0) + 4*f(w_1) + 2*f(w_2) + 4*f(w_3) + f(w_4));
i2 = (h/6) * initial_2;
disp(i1);
disp(i2);
if count == max_count
integral = i2;
return;
endif
if abs(i1 - i2) < (10 * TOL)
integral = i2;
return;
endif
count = count + 1;
disp(count);
disp(TOL);
integral = (adaptive2(f, a, (b+a)/2, TOL/2, count) + adaptive2(f, (b+a)/2, b, TOL/2, count));
return;和那些附庸:
f = @(x) 1/sqrt(x)
a = 10^-4
b = 1
TOL = 10^-6
count = 0我得到了以下错误:
panic segmentation violation - stopping myself 我需要修复的代码中发生了什么?它是一个无限的循环吗?在结尾处的递归调用是否不正确?
发布于 2016-03-30 00:11:36
I能够再现这个不应该发生的分段错误:
关于我的设置:
复制错误的代码:
octave:1> plot(1)
Insufficient GL support
Insufficient GL support
panic: Segmentation fault -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Segmentation fault重现错误的步骤:
意见:
在我在gentoo框上启用2元素身份验证之前,X11窗口运行良好。当我关闭2元素身份验证时,它再次正常工作。
结论:
双因素身份验证破坏了octave在图上进行X11转发的能力。可能是某种保护功能。
https://stackoverflow.com/questions/30312157
复制相似问题