Recursion 分段冲突-在八度音阶中停止我自己

Recursion 分段冲突-在八度音阶中停止我自己,recursion,octave,numerical-integration,Recursion,Octave,Numerical Integration,我有以下倍频程代码,尝试使用辛普森方法实现自适应正交: 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

我有以下倍频程代码,尝试使用辛普森方法实现自适应正交:

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;
我得到以下错误:

panic segmentation violation - stopping myself 

这段代码中发生了什么我需要修复的问题?它是一个无限循环吗?最后的递归调用是否不正确?

我能够重现这个segfault,它不应该发生:

关于我的设置:

  • Linux 4.1.15-gentoo-r1
  • GNU倍频程,版本3.8.2
  • 油灰释放63
  • X11转发工具:xming 6.9.0.31
  • 复制错误的代码:

    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
    
    重现错误的步骤:

    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框上启用双因素身份验证
  • 为x11转发启用xming,将其映射到本地主机:0
  • 使用putty登录GentooLinux实例
  • 运行倍频程命令行和运行绘图(1)
  • 获取上述错误
  • 意见:

  • 当我从公式中删除xming和putty时,绘图在本地主机上正确显示,没有任何错误
  • 如果我在没有xming的情况下运行,则会收到错误,正如预期的那样:

    gnuplot: unable to open display 'localhost:10.0'
    gnuplot: X11 aborted.
    
  • 当我在linux中关闭双因素身份验证时,错误不再发生

  • 在我启用gentoo box上的2因素身份验证之前,X11 windows运行良好。当我关闭双因素身份验证时,它再次正常工作

    结论:


    双因素身份验证淘汰了octave在绘图上执行X11转发的能力。这可能是某种保护功能。

    GNU Octave不应该出现故障,所以这是一个bug。您使用的是哪个版本、操作系统和版本?它在这里没有崩溃(linux上的octave 3.8.2),但似乎陷入了一个循环。您可以尝试减少
    max_count
    ,以使用较少的递归调用对其进行调试。