示例#1
0
// Compute constructs an interpolant for a function.
func (self *Algorithm) Compute(target algorithm.Target,
	strategy algorithm.Strategy) *algorithm.Surrogate {

	ni, no := self.ni, self.no
	surrogate := algorithm.NewSurrogate(ni, no)
	for s := strategy.First(surrogate); s != nil; s = strategy.Next(s, surrogate) {
		s.Volumes = internal.Measure(self.basis, s.Indices, ni)
		s.Nodes = self.grid.Compute(s.Indices)
		s.Values = algorithm.Invoke(target, s.Nodes, ni, no)
		s.Estimates = internal.Estimate(self.basis, surrogate.Indices,
			surrogate.Surpluses, s.Nodes, ni, no)
		s.Surpluses = internal.Subtract(s.Values, s.Estimates)
		s.Scores = score(strategy, s, ni, no)
		surrogate.Push(s.Indices, s.Surpluses, s.Volumes)
	}
	return surrogate
}
示例#2
0
// Evaluate computes the values of an interpolant at a set of points.
func (self *Algorithm) Evaluate(surrogate *algorithm.Surrogate, points []float64) []float64 {
	return internal.Estimate(self.basis, surrogate.Indices, surrogate.Surpluses,
		points, surrogate.Inputs, surrogate.Outputs)
}