2016-04-16 21 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版本則不使用。