当前位置: 首页>>代码示例>>Golang>>正文


Golang io.Sf函数代码示例

本文整理汇总了Golang中github.com/cpmech/gosl/io.Sf函数的典型用法代码示例。如果您正苦于以下问题:Golang Sf函数的具体用法?Golang Sf怎么用?Golang Sf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Sf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: PlotFltOva

// PlotFltOva plots flt-ova points
func (o *Optimiser) PlotFltOva(sols0 []*Solution, iFlt, iOva int, ovaMult float64, pp *PlotParams) {
	if pp.YfuncX != nil {
		X := utl.LinSpace(o.FltMin[iFlt], o.FltMax[iFlt], pp.NptsYfX)
		Y := make([]float64, pp.NptsYfX)
		for i := 0; i < pp.NptsYfX; i++ {
			Y[i] = pp.YfuncX(X[i])
		}
		plt.Plot(X, Y, pp.FmtYfX.GetArgs(""))
	}
	if sols0 != nil {
		o.PlotAddFltOva(iFlt, iOva, sols0, ovaMult, &pp.FmtSols0)
	}
	o.PlotAddFltOva(iFlt, iOva, o.Solutions, ovaMult, &pp.FmtSols)
	best, _ := GetBestFeasible(o, iOva)
	if best != nil {
		plt.PlotOne(best.Flt[iFlt], best.Ova[iOva]*ovaMult, pp.FmtBest.GetArgs(""))
	}
	if pp.Extra != nil {
		pp.Extra()
	}
	if pp.AxEqual {
		plt.Equal()
	}
	plt.Gll(io.Sf("$x_{%d}$", iFlt), io.Sf("$f_{%d}$", iOva), "leg_out=1, leg_ncol=4, leg_hlen=1.5")
	plt.SaveD(pp.DirOut, pp.FnKey+pp.FnExt)
}
开发者ID:cpmech,项目名称:goga,代码行数:27,代码来源:plotting.go

示例2: Plot_Dgam_f

func (o *Plotter) Plot_Dgam_f(x, y []float64, res []*State, sts [][]float64, last bool) {
	if o.m == nil {
		o.set_empty()
		return
	}
	nr := len(res)
	k := nr - 1
	ys := o.m.YieldFuncs(res[0])
	fc0 := ys[0]
	xmi, xma, ymi, yma := res[0].Dgam, res[0].Dgam, fc0, fc0
	for i := 0; i < nr; i++ {
		x[i] = res[i].Dgam
		ys = o.m.YieldFuncs(res[i])
		y[i] = ys[0]
		xmi = min(xmi, x[i])
		xma = max(xma, x[i])
		ymi = min(ymi, y[i])
		yma = max(yma, y[i])
	}
	//o.DrawRamp(xmi, xma, ymi, yma)
	plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl))
	plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs))
	plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs))
	if last {
		plt.Gll("$\\Delta\\gamma$", "$f$", "")
		if lims, ok := o.Lims["Dgam,f"]; ok {
			plt.AxisLims(lims)
		}
	}
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:30,代码来源:plotter.go

示例3: Camera

func Camera(elev, azim float64, args string) {
	cmd := io.Sf("gca().view_init(elev=%g, azim=%g", elev, azim)
	if len(args) > 0 {
		cmd += io.Sf(",%s", args)
	}
	io.Ff(&bb, "%s)\n", cmd)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:7,代码来源:mplotlib.go

示例4: Arrow

func Arrow(xi, yi, xf, yf float64, args string) {
	cmd := io.Sf("Arrow(%g,%g, %g,%g", xi, yi, xf, yf)
	if len(args) > 0 {
		cmd += io.Sf(",%s", args)
	}
	io.Ff(&bb, "%s)\n", cmd)
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:7,代码来源:mplotlib.go

示例5: String

// String prints a json formatted string with GeoLayers' content
func (o GeoLayers) String() string {
	if len(o) == 0 {
		return "[]"
	}
	l := "[\n"
	for i, lay := range o {
		if i > 0 {
			l += ",\n"
		}
		l += io.Sf("  { \"Tags\":%v, \"Zmin\":%g, \"Zmax\":%g, \"nf0\":%g, \"RhoS0\":%g, \"Cl\":%g\n", lay.Tags, lay.Zmin, lay.Zmax, lay.nf0, lay.RhoS0, lay.Cl)
		l += "    \"Nodes\":["
		for j, nod := range lay.Nodes {
			if j > 0 {
				l += ","
			}
			l += io.Sf("%d", nod.Vert.Id)
		}
		l += "],\n    \"Elems\":["
		for j, ele := range lay.Elems {
			if j > 0 {
				l += ","
			}
			l += io.Sf("%d", ele.Id())
		}
		l += "] }"
	}
	l += "\n]"
	return l
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:30,代码来源:geost.go

示例6: Circle

func Circle(xc, yc, r float64, args string) {
	cmd := io.Sf("Circle(%g,%g,%g", xc, yc, r)
	if len(args) > 0 {
		cmd += io.Sf(",%s", args)
	}
	io.Ff(&bb, "%s)\n", cmd)
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:7,代码来源:mplotlib.go

示例7: Plot

// Plot plots retention model
//  args1 -- arguments for model computed by solving differential equation; e.g. "'b*-'"
//           if args1 == "", plot is skiped
//  args2 -- arguments for model computed by directly calling sl(pc), if available
//           if args2 == "", plot is skiped
func Plot(mdl Model, pc0, sl0, pcf float64, npts int, args1, args2, label string) (err error) {

	// plot using Update
	Pc := utl.LinSpace(pc0, pcf, npts)
	Sl := make([]float64, npts)
	if args1 != "" {
		Sl[0] = sl0
		for i := 1; i < npts; i++ {
			Sl[i], err = Update(mdl, Pc[i-1], Sl[i-1], Pc[i]-Pc[i-1])
			if err != nil {
				return
			}
		}
		plt.Plot(Pc, Sl, io.Sf("%s, label='%s', clip_on=0", args1, label))
	}

	// plot using Sl function
	if args2 != "" {
		if m, ok := mdl.(Nonrate); ok {
			Pc = utl.LinSpace(pc0, pcf, 101)
			Sl = make([]float64, 101)
			for i, pc := range Pc {
				Sl[i] = m.Sl(pc)
			}
			plt.Plot(Pc, Sl, io.Sf("%s, label='%s_direct', clip_on=0", args2, label))
		}
	}
	return
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:34,代码来源:plot.go

示例8: StrDistMatrix

// StrDistMatrix returns a string representation of Dist matrix
func (o *Graph) StrDistMatrix() (l string) {
	nv := len(o.Dist)
	maxlen := 0
	for i := 0; i < nv; i++ {
		for j := 0; j < nv; j++ {
			if o.Dist[i][j] < GRAPH_INF {
				maxlen = utl.Imax(maxlen, len(io.Sf("%g", o.Dist[i][j])))
			}
		}
	}
	maxlen = utl.Imax(3, maxlen)
	fmts := io.Sf("%%%ds", maxlen+1)
	fmtn := io.Sf("%%%dg", maxlen+1)
	for i := 0; i < nv; i++ {
		for j := 0; j < nv; j++ {
			if o.Dist[i][j] < GRAPH_INF {
				l += io.Sf(fmtn, o.Dist[i][j])
			} else {
				l += io.Sf(fmts, "∞")
			}
		}
		l += "\n"
	}
	return
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:26,代码来源:graph.go

示例9: Annotate

func Annotate(x, y float64, txt string, args string) {
	cmd := io.Sf("annotate(%s, xy=(%g,%g)", txt, x, y)
	if len(args) > 0 {
		cmd += io.Sf(",%s", args)
	}
	io.Ff(&bb, "%s)\n", cmd)
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:7,代码来源:mplotlib.go

示例10: CheckDerivT

// CheckDerivT checks derivatives w.r.t to t for fixed coordinates x
func CheckDerivT(tst *testing.T, o Func, t0, tf float64, xcte []float64, np int, tskip []float64, sktol, dtol, dtol2 float64, ver bool) {
	t := utl.LinSpace(t0, tf, np)
	for i := 0; i < np; i++ {
		g := o.G(t[i], xcte)
		h := o.H(t[i], xcte)
		skip := false
		for _, val := range tskip {
			if math.Abs(val-t[i]) < sktol {
				skip = true
				break
			}
		}
		if skip {
			continue
		}
		dnum := num.DerivCen(func(t float64, args ...interface{}) (res float64) {
			return o.F(t, xcte)
		}, t[i])
		chk.AnaNum(tst, io.Sf("G(%10f)", t[i]), dtol, g, dnum, ver)
		dnum2 := num.DerivCen(func(t float64, args ...interface{}) (res float64) {
			return o.G(t, xcte)
		}, t[i])
		chk.AnaNum(tst, io.Sf("H(%10f)", t[i]), dtol2, h, dnum2, ver)
	}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:26,代码来源:testing.go

示例11: Info

func (o FemData) Info() (l string) {
	l += io.Sf("VtagU  = %v\n", o.VtagU)
	l += io.Sf("AwdU   = %v\n", o.AwdU)
	l += io.Sf("AwdM22 = %v\n", o.AwdM22)
	l += io.Sf("AwdM11 = %v\n", o.AwdM11)
	return
}
开发者ID:cpmech,项目名称:goga,代码行数:7,代码来源:fesim.go

示例12: Plot_ed_q

func (o *Plotter) Plot_ed_q(x, y []float64, res []*State, sts [][]float64, last bool) {
	nr := len(res)
	if len(sts) != nr {
		return
	}
	k := nr - 1
	for i := 0; i < nr; i++ {
		x[i] = o.Ed[i] * 100.0
		if o.QdivP {
			y[i] = o.Q[i] / o.P[i]
		} else {
			y[i] = o.Q[i]
		}
		if o.Multq {
			y[i] *= fun.Sign(o.W[i])
		}
	}
	plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl))
	plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs))
	plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs))
	if last {
		ylbl := "$q$"
		if o.QdivP {
			ylbl = "$q/p$"
		}
		plt.Gll("$\\varepsilon_d\\;[\\%]$", ylbl, "leg_out=1, leg_ncol=4, leg_hlen=1.5")
		if lims, ok := o.Lims["ed,q"]; ok {
			plt.AxisLims(lims)
		}
	}
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:31,代码来源:plotter.go

示例13: Plot_i_f

func (o *Plotter) Plot_i_f(x, y []float64, res []*State, sts [][]float64, last bool) {
	if o.m == nil {
		o.set_empty()
		return
	}
	nr := len(res)
	var y2 []float64
	if o.nsurf > 1 {
		y2 = make([]float64, nr)
	}
	for i := 0; i < nr; i++ {
		ys := o.m.YieldFuncs(res[i])
		y[i] = ys[0]
		if o.nsurf > 1 {
			y2[i] = ys[1]
		}
		x[i] = float64(i)
	}
	lbl := "f " + o.Lbl
	plt.Plot(x, y, io.Sf("'r.', ls='-', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Clr, o.Mrk, lbl))
	if o.nsurf > 1 {
		lbl = "F " + o.Lbl
		plt.Plot(x, y2, io.Sf("'b+', ls=':', lw=2, clip_on=0, color='%s', marker='%s', label=r'%s'", o.Clr, o.Mrk, lbl))
	}
	if last {
		plt.Gll("$i$", "$f,\\;F$", "leg_out=1, leg_ncol=4, leg_hlen=2")
		if lims, ok := o.Lims["i,f"]; ok {
			plt.AxisLims(lims)
		}
	}
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:31,代码来源:plotter.go

示例14: PlotAll

// PlotAll plot all functions
func (o FuncsData) PlotAll(pd *PlotFdata, dirout, fnkey string) {
	ext := "png"
	if pd.Eps {
		ext = "eps"
	}
	fn := io.Sf("functions-%s.%s", fnkey, ext)
	plt.Reset()
	for k, f := range o {
		if utl.StrIndexSmall(pd.Skip, f.Name) >= 0 {
			continue
		}
		save := (k == len(o)-1)
		args := io.Sf("label='%s', clip_on=0", f.Name)
		ff := o.Get(f.Name)
		if ff != nil {
			if pd.WithTxt {
				x := pd.Ti
				y := ff.F(x, nil)
				plt.Text(x, y, io.Sf("%g", y), "fontsize=8")
				x = pd.Tf
				y = ff.F(x, nil)
				plt.Text(x, y, io.Sf("%g", y), "fontsize=8, ha='right'")
			}
			fun.PlotT(ff, dirout, fn, pd.Ti, pd.Tf, nil, pd.Np, args, pd.WithG, pd.WithH, save, false, nil)
		}
	}
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:28,代码来源:func.go

示例15: checkinput

func checkinput(tst *testing.T, m *Mesh, nverts, ncells int, X [][]float64, vtags, ctags, parts []int, types []string, V [][]int, etags, ftags [][]int) {
	if len(m.Verts) != nverts {
		tst.Errorf("nverts is incorrect: %d != %d", len(m.Verts), nverts)
		return
	}
	if len(m.Cells) != ncells {
		tst.Errorf("ncells is incorrect: %d != %d", len(m.Cells), ncells)
		return
	}
	io.Pfyel("\nvertices:\n")
	for i, v := range m.Verts {
		io.Pf("%+v\n", v)
		chk.Vector(tst, io.Sf("vertex %2d: X", v.Id), 1e-15, v.X, X[v.Id])
		if v.Tag != vtags[i] {
			tst.Errorf("vtag is incorrect: %d != %d", v.Tag, vtags[i])
			return
		}
	}
	io.Pfyel("\ncells:\n")
	for i, c := range m.Cells {
		io.Pf("%+v\n", c)
		if c.Tag != ctags[i] {
			tst.Errorf("ctag is incorrect: %d != %d", c.Tag, ctags[i])
			return
		}
		if c.Part != parts[i] {
			tst.Errorf("part is incorrect: %d != %d", c.Part, parts[i])
			return
		}
		chk.String(tst, types[i], c.Type)
		chk.Ints(tst, io.Sf("cell %2d : V", c.Id), c.V, V[c.Id])
		chk.Ints(tst, io.Sf("cell %2d : edgetags", c.Id), c.EdgeTags, etags[c.Id])
	}
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:34,代码来源:t_mesh_test.go


注:本文中的github.com/cpmech/gosl/io.Sf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。