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
沒有鏈接到圖書館(PLplot),它很難幫助你。 –