Plplot in Ada requires a file which using ada.numerics.real_arrays, and prevents using it anywhere else. At the same time, vector operations are thereby hidden, and as a consequence apparently every plplot example for ada uses element-wise operations, defeating the purpose of specialized linear algebra types in the first place.
Am I just doing things wrong, or is this a real limitation in plplot?
As an example:
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;
Builds with:
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
Looking in the source files provided by the libplplot-ada1-dev
package in Debian/Jessie, it looks like package PLPlot_Auxilary
can be provided either in an Ada 95 version or an Ada 2005 version. The Ada 2005 version uses the Ada numerics packages, while the Ada 95 version doesn't.