Example #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
}
Example #2
0
func Invoke(quantity Quantity, points []float64) []float64 {
	ni, no := quantity.Dimensions()
	return interpolation.Invoke(quantity.Compute, points, ni, no)
}