-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break test program into multiple separate programs.
- Loading branch information
1 parent
12c3832
commit 826a19b
Showing
8 changed files
with
116 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,8 @@ lib/* | |
|
||
# Ada Library Information | ||
*.ali | ||
|
||
# Test binaries | ||
test_ode | ||
test_integ | ||
test_stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
with Ada.Numerics.Generic_Elementary_Functions; | ||
with Ada.Text_IO; | ||
with BBS.Numerical; | ||
with BBS.Numerical.integration_real; | ||
|
||
procedure test_integ is | ||
subtype real is Float; | ||
package integ is new BBS.Numerical.integration_real(real); | ||
package float_io is new Ada.Text_IO.Float_IO(real); | ||
package elem is new Ada.Numerics.Generic_Elementary_Functions(real); | ||
|
||
function f1(x : real) return real is | ||
begin | ||
return (100.0/(x*x))*elem.sin(10.0/x); | ||
end; | ||
|
||
function f2(t, y : real) return real is | ||
begin | ||
return -y + t + 1.0; | ||
end; | ||
|
||
y : real; | ||
tol : real; | ||
begin | ||
Ada.Text_IO.Put_Line("Testing some of the numerical routines."); | ||
-- | ||
Ada.Text_IO.Put_Line("Testing integration:"); | ||
y := integ.trapezoid(f1'Access, 1.0, 3.0, 10); | ||
Ada.Text_IO.Put(" Trapazoid rule gives "); | ||
float_io.Put(y, 2, 3, 0); | ||
Ada.Text_IO.New_Line; | ||
y := integ.simpson(f1'Access, 1.0, 3.0, 10); | ||
Ada.Text_IO.Put(" Simpson rule gives "); | ||
float_io.Put(y, 2, 6, 0); | ||
Ada.Text_IO.New_Line; | ||
tol := 1.0e-6; | ||
y := integ.adapt_simpson(f1'Access, 1.0, 3.0, tol, 8); | ||
Ada.Text_IO.Put(" Adaptive Simpson gives "); | ||
float_io.Put(y, 2, 6, 0); | ||
Ada.Text_IO.Put(" with estimated tolerance "); | ||
float_io.Put(tol, 2, 6, 0); | ||
Ada.Text_IO.New_Line; | ||
end test_integ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
with "../BBS_Numerical.gpr"; | ||
|
||
project test_integ is | ||
for languages use ("Ada"); | ||
for Source_Dirs use ("."); | ||
for Object_Dir use "../obj"; | ||
for Main use ("test_integ.adb"); | ||
for Exec_Dir use "."; | ||
package builder is | ||
for switches ("Ada") use ("-s"); | ||
end builder; | ||
package compiler is | ||
for switches ("Ada") use ("-g", "-gnateE", "-gnata"); | ||
end compiler; | ||
end test_integ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
with "../BBS_Numerical.gpr"; | ||
|
||
project test is | ||
project test_ode is | ||
for languages use ("Ada"); | ||
for Source_Dirs use ("."); | ||
for Object_Dir use "../obj"; | ||
for Main use ("test.adb"); | ||
for Main use ("test_ode.adb"); | ||
for Exec_Dir use "."; | ||
package builder is | ||
for switches ("Ada") use ("-s"); | ||
end builder; | ||
package compiler is | ||
for switches ("Ada") use ("-g", "-gnateE", "-gnata"); | ||
end compiler; | ||
end test; | ||
end test_ode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
with Ada.Numerics.Generic_Elementary_Functions; | ||
with Ada.Text_IO; | ||
with BBS.Numerical; | ||
with BBS.Numerical.regression; | ||
with BBS.Numerical.Statistics; | ||
|
||
procedure test_stats is | ||
subtype real is Float; | ||
package linreg is new BBS.Numerical.regression(real); | ||
package float_io is new Ada.Text_IO.Float_IO(real); | ||
package elem is new Ada.Numerics.Generic_Elementary_Functions(real); | ||
|
||
data : linreg.data_array := | ||
((x => 1.0, y => 1.0), | ||
(x => 2.0, y => 1.0), | ||
(x => 3.0, y => 2.0), | ||
(x => 4.0, y => 2.0), | ||
(x => 5.0, y => 4.0)); | ||
res : linreg.simple_linreg_result; | ||
begin | ||
Ada.Text_IO.Put_Line("Testing some of the numerical routines."); | ||
res := linreg.simple_linear(data); | ||
Ada.Text_IO.Put_Line("Linear regression result:"); | ||
Ada.Text_IO.Put(" a = "); | ||
float_io.Put(res.a, 2, 3, 0); | ||
Ada.Text_IO.Put(", b = "); | ||
float_io.Put(res.b, 2, 3, 0); | ||
Ada.Text_IO.Put(", SSe = "); | ||
float_io.Put(res.SSe, 2, 3, 0); | ||
Ada.Text_IO.Put(", variance = "); | ||
float_io.Put(res.variance, 2, 3, 0); | ||
Ada.Text_IO.New_Line; | ||
end test_stats; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
with "../BBS_Numerical.gpr"; | ||
|
||
project test_stats is | ||
for languages use ("Ada"); | ||
for Source_Dirs use ("."); | ||
for Object_Dir use "../obj"; | ||
for Main use ("test_stats.adb"); | ||
for Exec_Dir use "."; | ||
package builder is | ||
for switches ("Ada") use ("-s"); | ||
end builder; | ||
package compiler is | ||
for switches ("Ada") use ("-g", "-gnateE", "-gnata"); | ||
end compiler; | ||
end test_stats; |