class GSL::MultiFit::MultidLMNumDiff

Public Class Methods

alloc(*params) click to toggle source
# File lib/gsl_extras.rb, line 930
def self.alloc(*params)
        new(*params)
end
new(yproc, ndata, ndims, nparams) click to toggle source
Calls superclass method GSL::MultiFit::MultidLM::new
# File lib/gsl_extras.rb, line 934
                def initialize(yproc, ndata, ndims, nparams)
                        fproc = Proc.new do |x, *gridpoints, y, sigma, f|
#                               gridpoints = (0...@ndims).to_a.map do |i|
#                                       @gridpoints.col(i)
#                               end
                                for i in 0...ndata.size do
                                        f[i] = (@yproc.call(x, *gridpoints.map{|vec| vec[i]}) - y[i])/sigma[i]
                                end
                        end
                        dfproc = Proc.new do |x, *gridpoints, y, sigma, jac|
                                        for j in 0...nparams do
                                                xj = x[j]
                                                xplus = x.dup
                                                xplus[j] = xj + @delt[j]
                                                xminus = x.dup
                                                xminus[j] = xj - @delt[j]

                                                for i in 0...ndata do
                                                        gp = gridpoints.map{|vec| vec[i]}
                                                        yplus = @yproc.call(xplus, *gp)
                                                        yminus = @yproc.call(xminus, *gp)
                                                        #p "delt", @delt, "sigma", @sigma, "jac", jac, "jac.shape", jac.shape, "result", (yplus - yminus)/2*@delt[j]/sigma[i]
                                                        jac.set(i, j, (yplus - yminus)/2*@delt[j]/sigma[i])
                                                end
                                        end
                        end  
                        super(yproc, fproc, dfproc, ndata, ndims, nparams)


                end

Public Instance Methods

set_data(xstart, delt, *gridpoints, y, sigma) click to toggle source
Calls superclass method GSL::MultiFit::MultidLM#set_data
# File lib/gsl_extras.rb, line 964
def set_data(xstart, delt, *gridpoints, y, sigma)
        @delt = (delt || GSL::Vector.alloc([1e-5]*xstart.size))
        super(xstart, *gridpoints, y, sigma)
end