本文整理匯總了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)
}