Sha256: 7e91060f180253aadf425fcf44f61942224eccfe5330e8aebc11a90dff9e7c6d

Contents?: true

Size: 821 Bytes

Versions: 22

Compression:

Stored size: 821 Bytes

Contents

#!/usr/bin/env ruby
require("gsl")
include GSL
include GSL::Siman

N_TRIES = 200
ITERS_FIXED_T = 10
STEP_SIZE = 10
K = 1.0
T_INITIAL = 0.002
MU_T = 1.005
T_MIN = 2.0e-6

params = Siman::Params.alloc(N_TRIES, ITERS_FIXED_T, STEP_SIZE, K, T_INITIAL,
                           MU_T, T_MIN)

efunc = Efunc.alloc { |vx|
  x = vx[0]
  s = (x - 1.0)
  Math::exp(-s*s)*Math::sin(8*x)
}

metric = Metric.alloc { |vx, vy|
  (x[0] - y[0]).abs
}

step = Step.alloc { |rng, vx, step_size|
  r = rng.uniform
  old_x = vx[0]
  a =  r * 2 * step_size - step_size + old_x
  vx[0] = a
}

simanprint = Print.alloc { |vx|
  printf("%12g", vx[0])
}

x = GSL::Vector.alloc([15.5])
GSL::Rng.env_setup()
r = GSL::Rng.alloc()

Siman::solve(r, x, efunc, step, metric, simanprint, params)
#Siman::solve(r, x, efunc, step, metric, nil, params)
p x

Version data entries

22 entries across 22 versions & 4 rubygems

Version Path
gsl-2.1.0.3 examples/siman.rb
gsl-2.1.0.2 examples/siman.rb
gsl-2.1.0.1 examples/siman.rb
gsl-2.1.0 examples/siman.rb
gsl-1.16.0.6 examples/siman.rb
rb-gsl-1.16.0.5 examples/siman.rb
rb-gsl-1.16.0.4 examples/siman.rb
rb-gsl-1.16.0.3 examples/siman.rb
rb-gsl-1.16.0.3.rc1 examples/siman.rb
gsl-nmatrix-1.15.3.2 examples/siman.rb
gsl-nmatrix-1.15.3.1 examples/siman.rb
rb-gsl-1.16.0.2 examples/siman.rb
rb-gsl-1.16.0.1 examples/siman.rb
rb-gsl-1.16.0 examples/siman.rb
rb-gsl-1.15.3.2 examples/siman.rb
rb-gsl-1.15.3.1 examples/siman.rb
blackwinter-gsl-1.15.3.2 examples/siman.rb
gsl-nmatrix-1.15.3.0 examples/siman.rb
gsl-1.15.3 examples/siman.rb
gsl-1.14.7 examples/siman.rb