Sha256: 2a2ecb9675e01c9e064d4c29c4ce263f46e019bef13acf2b90977059499dad03

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

#!/usr/bin/env ruby
# Ruby/GSL implementation of GSL "interpolation/test.c"
require("gsl")
require("./gsl_test2.rb")
include GSL::Test
include Math

def test_bsearch()
  status = 0
  x_array = GSL::Vector.alloc(0.0, 1.0, 2.0, 3.0, 4.0)
  index_result = Interp.bsearch(x_array, 1.5, 0, 4)
  s = (index_result != 1) ? 1 : 0
  status += 1
  test(s, "simple bsearch")

  index_result = x_array.bsearch(4.0, 0, 4)
  s = (index_result != 3) ? 1 : 0
  status += s;
  test(s, "upper endpoint bsearch");

  index_result = Interp.bsearch(x_array, 0.0, 0, 4);
  s = (index_result != 0) ? 1 : 0
  status += s;
  test(s, "lower endpoint bsearch");

  index_result = Interp.bsearch(x_array, 2.0, 0, 4);
  s = (index_result != 2) ? 1 : 0
  status += s;
  test(s, "degenerate bsearch");

  index_result = Interp.bsearch(x_array, 10.0, 0, 4);
  s = (index_result != 3) ? 1 : 0
  status += s;
  test(s, "out of bounds bsearch +");

  index_result = Interp.bsearch(x_array, -10.0, 0, 4);
  s = (index_result != 0) ? 1 : 0
  status += s;
  test(s, "out of bounds bsearch -");

end



test_bsearch()

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
gsl-nmatrix-1.15.3.2 tests/interp.rb
gsl-nmatrix-1.15.3.1 tests/interp.rb
rb-gsl-1.15.3.1 tests/interp.rb
blackwinter-gsl-1.15.3.2 tests/interp.rb
gsl-nmatrix-1.15.3.0 tests/interp.rb
gsl-1.15.3 tests/interp.rb
gsl-1.14.7 tests/interp.rb
gsl-1.14.6 tests/interp.rb
gsl-1.14.5 tests/interp.rb