本文整理汇总了Golang中github.com/tflovorn/scExplorer/tempAll.Environment.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Environment.Set方法的具体用法?Golang Environment.Set怎么用?Golang Environment.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tflovorn/scExplorer/tempAll.Environment
的用法示例。
在下文中一共展示了Environment.Set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AbsErrorX
// Calculate x - (x_1 + x_2) with Mu_h fixed.
func AbsErrorX(env *tempAll.Environment, variables []string) solve.Diffable {
F := func(v vec.Vector) (float64, error) {
if v.ContainsNaN() {
fmt.Printf("got NaN in AbsErrorX (v=%v)\n", v)
return 0.0, errors.New("NaN in input")
}
env.Set(v, variables)
// Before we evaluate error in X, Mu_b and D1 should have
// appropriate values.
system, start := D1Mu_bSystem(env)
eps := 1e-9
_, err := solve.MultiDim(system, start, eps, eps)
if err != nil {
return 0.0, err
}
if env.Mu_b > 0.0 {
fmt.Println("Warning: got Mu_b > 0 in AbsErrorX")
env.Mu_b = 0.0
}
// evaluate X error
x1 := tempPair.X1(env)
x2, err := tempCrit.X2(env)
if err != nil {
fmt.Printf("error from X2(): %v\n", err)
return 0.0, err
}
lhs := env.X
rhs := x1 + x2
return lhs - rhs, nil
}
h := 1e-5
epsabs := 1e-4
return solve.SimpleDiffable(F, len(variables), h, epsabs)
}
示例2: AbsErrorBeta
func AbsErrorBeta(env *tempAll.Environment, variables []string) solve.Diffable {
F := func(v vec.Vector) (float64, error) {
if v.ContainsNaN() {
fmt.Printf("got NaN in AbsErrorBeta (v=%v)\n", v)
return 0.0, errors.New("NaN in input")
}
env.Set(v, variables)
if !env.FixedPairCoeffs || !env.PairCoeffsReady {
// Before we evaluate error in Beta, Mu_h and D1 should have
// appropriate values.
eps := 1e-9
_, err := D1MuSolve(env, eps, eps)
if err != nil {
return 0.0, err
}
}
// Beta equation error = x - x1 - x2
x1 := X1(env)
x2, err := tempCrit.X2(env)
if err != nil {
fmt.Printf("error from X2(): %v\n", err)
return 0.0, err
}
lhs := env.X
rhs := x1 + x2
return lhs - rhs, nil
}
h := 1e-5
epsabs := 1e-4
return solve.SimpleDiffable(F, len(variables), h, epsabs)
}
示例3: AbsErrorMu_h
func AbsErrorMu_h(env *tempAll.Environment, variables []string) solve.Diffable {
F := func(v vec.Vector) (float64, error) {
env.Set(v, variables)
lhs := env.X
rhs := X1(env)
return lhs - rhs, nil
}
h := 1e-6
epsabs := 1e-4
return solve.SimpleDiffable(F, len(variables), h, epsabs)
}
示例4: AbsErrorMu_b
// Calculate Mu_b - (-Omega_+(0))
func AbsErrorMu_b(env *tempAll.Environment, variables []string) solve.Diffable {
F := func(v vec.Vector) (float64, error) {
if v.ContainsNaN() {
fmt.Printf("got NaN in AbsErrorMu_b (v=%v)\n", v)
return 0.0, errors.New("NaN in input")
}
env.Set(v, variables)
zv := vec.ZeroVector(3)
omega0, err := tempCrit.OmegaPlus(env, zv)
if err != nil {
return 0.0, err
}
lhs := env.Mu_b
rhs := -omega0
return lhs - rhs, nil
}
h := 1e-5
epsabs := 1e-4
return solve.SimpleDiffable(F, len(variables), h, epsabs)
}