當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Environment.Set方法代碼示例

本文整理匯總了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)
}
開發者ID:tflovorn,項目名稱:scExplorer,代碼行數:35,代碼來源:systemX.go

示例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)
}
開發者ID:tflovorn,項目名稱:scExplorer,代碼行數:31,代碼來源:systemBeta.go

示例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)
}
開發者ID:tflovorn,項目名稱:scExplorer,代碼行數:11,代碼來源:systemMu_h.go

示例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)
}
開發者ID:tflovorn,項目名稱:scExplorer,代碼行數:21,代碼來源:systemMu_b.go


注:本文中的github.com/tflovorn/scExplorer/tempAll.Environment.Set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。