2016-04-16 35 views
0

Ada中的Plplot需要使用ada.numerics.real_arrays的文件,并防止在其他地方使用它。与此同时,向量操作因此被隐藏起来,结果显然ada的每个plplot示例都使用基于元素的操作,这首先破坏了专用线性代数类型的用途。在使用plplot时使用Ada real_arrays操作符

我只是在做错事,或者这是一个真正的限制plplot?

作为一个例子:

with ada.text_io; use ada.text_io; -- 'use' allows using library functions without fuilly qualified names 
with ada.float_text_io; use ada.float_text_io; 
--with ada.numerics.real_arrays; use ada.numerics.real_arrays; 

with 
PLplot_Auxiliary, 
PLplot; 
use 
PLplot_Auxiliary, 
PLplot; 

procedure Simple is 
    procedure Put (X : Real_Vector) is -- vector version of above, 1D instead of 2D 
    type Fixed is delta 0.01 range -100.0..100.0; 
    begin 
    for I in X'Range (1) loop 
     Put (Fixed'Image (Fixed (X (I)))); 
     New_Line; 
    end loop; 
    end Put; 

    x, y : Real_Vector(-10 .. 10); 


begin 
    for i in x'range loop 
     x(i) := float(i); 
     y(i) := x(i)**2; 
     y := x+y; --This line cause compilation to fail because plplot_auxiliary does not provide "+" for Real_Vector 
    end loop; 

    put(x); 

    Initialize_PLplot; -- Call this only once. 
    Simple_Plot(x, y); -- Make the plot. 
    End_PLplot;  -- Call this only once. 
end Simple; 

构建具有:

gnatmake -aI/usr/share/ada/adainclude/plplotadad -aL/usr/lib64/ada/adalib/plplotadad simple.adb \ 
-cargs `PKG_CONFIG_PATH="/usr/lib64/pkgconfig:%{_PKG_CONFIG_PATH}:/usr/lib64/pkgconfig:/usr/share/pkgconfig" pkg-config --cflags plplotd-ada` -largs `PKG_CONFIG_PATH="/usr/lib64/pkgconfig:%{_PKG_CONFIG_PATH}:/usr/lib64/pkgconfig:/usr/share/pkgconfig" pkg-config --libs plplotd-ada` 
gcc -c -I/usr/share/ada/adainclude/plplotadad -I/usr/include/plplot simple.adb 
gnatbind -aI/usr/share/ada/adainclude/plplotadad -aO/usr/lib64/ada/adalib/plplotadad -x simple.ali 
gnatlink simple.ali -lplplotadad -lplplotd 
+0

没有链接到图书馆(PLplot),它很难帮助你。 –

回答

1

在由libplplot-ada1-dev包中的Debian /杰西提供的源文件寻找,它看起来像包PLPlot_Auxilary可以在被提供Ada 95版本或Ada 2005版本。 Ada 2005版本使用Ada数字包,而Ada 95版本则不使用。