1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Description: add test on has_gsl? before using GSL integration method
This one was missing from the spec for complex intergration with GSL methods
Author: Cédric Boutillier <boutil@debian.org>
Bug: https://github.com/clbustos/integration/pull/1
Last-Update: 2012-10-17
--- a/spec/integration_spec.rb
+++ b/spec/integration_spec.rb
@@ -17,9 +17,13 @@
Integration.integrate(0,1,{:tolerance=>1e-12,:method=>:adaptive_quadrature},&normal_pdf).should be_within(1e-11).of(0.341344746068)
end
it "should return a correct value for a complex integration with gsl methods" do
- normal_pdf=lambda {|x| (1/Math.sqrt(2*Math::PI))*Math.exp(-(x**2/2))}
- Integration.integrate(0,1,{:tolerance=>1e-12,:method=>:qng},&normal_pdf).should be_within(1e-11).of(0.341344746068)
- Integration.integrate(0,1,{:tolerance=>1e-12,:method=>:qag},&normal_pdf).should be_within(1e-11).of(0.341344746068)
+ if Integration.has_gsl?
+ normal_pdf=lambda {|x| (1/Math.sqrt(2*Math::PI))*Math.exp(-(x**2/2))}
+ Integration.integrate(0,1,{:tolerance=>1e-12,:method=>:qng},&normal_pdf).should be_within(1e-11).of(0.341344746068)
+ Integration.integrate(0,1,{:tolerance=>1e-12,:method=>:qag},&normal_pdf).should be_within(1e-11).of(0.341344746068)
+ else
+ pending("GSL not available")
+ end
end
|