本文整理汇总了Golang中github.com/cpmech/gosl/plt.Reset函数的典型用法代码示例。如果您正苦于以下问题:Golang Reset函数的具体用法?Golang Reset怎么用?Golang Reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Reset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Test_fun12
func Test_fun12(tst *testing.T) {
//verbose()
chk.PrintTitle("fun12. mul")
cos, err := New("cos", []*Prm{
&Prm{N: "a", V: 1},
&Prm{N: "b/pi", V: 2},
&Prm{N: "c", V: 1},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
lin, err := New("lin", []*Prm{
&Prm{N: "m", V: 0.5},
&Prm{N: "ts", V: 0},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
mul, err := New("mul", []*Prm{
&Prm{N: "fa", Fcn: cos},
&Prm{N: "fb", Fcn: lin},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 1.0
xcte := []float64{0, 0, 0}
//if true {
if false {
withG, withH, save, show := true, true, false, true
plt.Reset()
PlotT(cos, "/tmp/gosl", "fun-cos-12.png", tmin, tmax, xcte, 41, "", withG, withH, save, show, nil)
plt.Reset()
PlotT(lin, "/tmp/gosl", "fun-lin-12.png", tmin, tmax, xcte, 41, "", withG, withH, save, show, nil)
plt.Reset()
PlotT(mul, "/tmp/gosl", "fun-mul-12.png", tmin, tmax, xcte, 41, "", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-9
dtol2 := 1e-8
ver := chk.Verbose
tskip := []float64{tmin, tmax}
CheckDerivT(tst, cos, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
io.Pf("\n")
CheckDerivT(tst, lin, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
io.Pf("\n")
CheckDerivT(tst, mul, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
}
示例2: Test_fun03
func Test_fun03(tst *testing.T) {
//verbose()
chk.PrintTitle("fun03. add, cte, srmps")
cte, err := New("cte", []*Prm{&Prm{N: "C", V: 30}})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
srmps, err := New("srmps", []*Prm{
&Prm{N: "ca", V: 0},
&Prm{N: "cb", V: 1},
&Prm{N: "ta", V: 0},
&Prm{N: "tb", V: 1},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
add, err := New("add", []*Prm{
&Prm{N: "a", V: 1},
&Prm{N: "b", V: 1},
&Prm{N: "fa", Fcn: cte},
&Prm{N: "fb", Fcn: srmps},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 1.0
xcte := []float64{0, 0, 0}
if false {
withG, withH, save, show := true, true, false, true
plt.Reset()
PlotT(cte, "/tmp/gosl", "fun-cte-01.png", tmin, tmax, xcte, 41, "", withG, withH, save, show, nil)
plt.Reset()
PlotT(srmps, "/tmp/gosl", "fun-srmps-01.png", tmin, tmax, xcte, 41, "", withG, withH, save, show, nil)
plt.Reset()
PlotT(add, "/tmp/gosl", "fun-add-01.png", tmin, tmax, xcte, 41, "", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-10
dtol2 := 1e-9
ver := chk.Verbose
tskip := []float64{tmin, tmax}
CheckDerivT(tst, cte, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
io.Pf("\n")
CheckDerivT(tst, srmps, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
io.Pf("\n")
CheckDerivT(tst, add, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
}
示例3: PlotTwoNurbs
// PlotTwoNurbs plots two NURBS for comparison
func PlotTwoNurbs(dirout, fn string, b, c *Nurbs, npts int, ids bool, extra func()) {
plt.Reset()
if io.FnExt(fn) == ".eps" {
plt.SetForEps(1.5, 500)
} else {
plt.SetForPng(1.5, 500, 150)
}
plt.Subplot(3, 1, 1)
b.DrawCtrl2d(ids, "", "")
b.DrawElems2d(npts, ids, "", "")
if extra != nil {
extra()
}
plt.Equal()
plt.Subplot(3, 1, 2)
c.DrawCtrl2d(ids, "", "")
c.DrawElems2d(npts, ids, "", "")
plt.Equal()
plt.Subplot(3, 1, 3)
b.DrawElems2d(npts, ids, ", lw=3", "")
c.DrawElems2d(npts, ids, ", color='red', marker='+', markevery=10", "color='green', size=7, va='bottom'")
plt.Equal()
plt.SaveD(dirout, fn)
}
示例4: 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)
}
}
}
示例5: Test_fun11
func Test_fun11(tst *testing.T) {
//verbose()
chk.PrintTitle("fun11. ref-inc-rl1")
fun, err := New("ref-inc-rl1", []*Prm{
&Prm{N: "lam0", V: 0.001},
&Prm{N: "lam1", V: 1.2},
&Prm{N: "alp", V: 0.01},
&Prm{N: "bet", V: 10},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 1.0
xcte := []float64{0, 0, 0}
if false {
plt.Reset()
withG, withH, save, show := true, true, false, true
PlotT(fun, "/tmp/gosl", "fun-ref-inc-rl1-01.png", tmin, tmax, xcte, 41, "'.-'", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-10
dtol2 := 1e-10
ver := chk.Verbose
CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
示例6: Test_fun10
func Test_fun10(tst *testing.T) {
//verbose()
chk.PrintTitle("fun10. rmp")
fun, err := New("rmp", []*Prm{
&Prm{N: "ta", V: 1},
&Prm{N: "tb", V: 2},
&Prm{N: "ca", V: 0.5},
&Prm{N: "cb", V: -1.5},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 3.0
xcte := []float64{0, 0, 0}
if false {
plt.Reset()
withG, withH, save, show := true, true, false, true
PlotT(fun, "/tmp/gosl", "fun-rmp-01.png", tmin, tmax, xcte, 4, "'.-'", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-12
dtol2 := 1e-17
ver := chk.Verbose
CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
示例7: Test_fun09
func Test_fun09(tst *testing.T) {
//verbose()
chk.PrintTitle("fun09. cos")
fun, err := New("cos", []*Prm{
&Prm{N: "a", V: 10},
&Prm{N: "b", V: math.Pi},
&Prm{N: "c", V: 1.0},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 2.0
xcte := []float64{0, 0, 0}
if false {
plt.Reset()
withG, withH, save, show := true, true, false, true
PlotT(fun, "/tmp/gosl", "fun-cos-01.png", tmin, tmax, xcte, 41, "'.-'", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-8
dtol2 := 1e-7
ver := chk.Verbose
CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
示例8: Test_fun13
func Test_fun13(tst *testing.T) {
//verbose()
chk.PrintTitle("fun13. mul")
pulse, err := New("pulse", []*Prm{
&Prm{N: "ca", V: 0.2},
&Prm{N: "cb", V: 2.0},
&Prm{N: "ta", V: 1.0},
&Prm{N: "tb", V: 2.5},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 5.0
xcte := []float64{0, 0, 0}
//if true {
if false {
withG, withH, save, show := true, true, false, true
plt.Reset()
PlotT(pulse, "/tmp/gosl", "fun-pulse-13.png", tmin, tmax, xcte, 61, "", withG, withH, save, show, nil)
}
sktol := 1e-17
dtol := 1e-10
dtol2 := 1e-10
ver := chk.Verbose
tskip := []float64{1, 4}
CheckDerivT(tst, pulse, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
}
示例9: Test_fun06c
func Test_fun06c(tst *testing.T) {
//verbose()
chk.PrintTitle("fun06c. pts")
fun, err := New("pts", []*Prm{
// T = 0 0.05 0.1 0.2 0.3 0.5 0.75 1
&Prm{N: "y=dt", Extra: "0.05 0.05 0.1 0.1 0.2 0.25 0.25 0"},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 1.0
xcte := []float64{0, 0, 0}
//if true {
if false {
plt.Reset()
withG, withH, save, show := true, true, true, false
PlotT(fun, "/tmp/gosl", "fun-ptsC-01.png", tmin, tmax, xcte, 8, "'o-', clip_on=0", withG, withH, save, show, nil)
}
tmin = 0.01
tmax = 0.99
sktol := 1e-10
dtol := 1e-10
dtol2 := 1e-10
ver := chk.Verbose
CheckDerivT(tst, fun, tmin, tmax, xcte, 10, nil, sktol, dtol, dtol2, ver)
}
示例10: Test_fun08
func Test_fun08(tst *testing.T) {
//verbose()
chk.PrintTitle("fun08. exc2")
fun, err := New("exc2", []*Prm{
&Prm{N: "ta", V: 5},
&Prm{N: "A", V: 3},
&Prm{N: "b", V: 0.2},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 7.0
xcte := []float64{0, 0, 0}
if false {
plt.Reset()
withG, withH, save, show := true, true, false, true
PlotT(fun, "/tmp/gosl", "fun-exc2-01.png", tmin, tmax, xcte, 41, "'o-'", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-10
dtol2 := 1e-10
ver := chk.Verbose
CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
示例11: Test_fun04
func Test_fun04(tst *testing.T) {
//verbose()
chk.PrintTitle("fun04. lin")
lin, err := New("lin", []*Prm{
&Prm{N: "m", V: 0.5},
&Prm{N: "ts", V: 0},
})
if err != nil {
tst.Errorf("test failed: %v\n", err)
return
}
tmin := 0.0
tmax := 1.0
xcte := []float64{0, 0, 0}
if false {
plt.Reset()
withG, withH, save, show := true, true, false, true
PlotT(lin, "/tmp/gosl", "fun-lin-01.png", tmin, tmax, xcte, 11, "", withG, withH, save, show, nil)
}
sktol := 1e-10
dtol := 1e-10
dtol2 := 1e-10
ver := chk.Verbose
CheckDerivT(tst, lin, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
示例12: Test_bc01
func Test_bc01(tst *testing.T) {
doplot := false
//doplot := true
chk.PrintTitle("bc01")
mdl := GetModel("testsim", "mat1", "bc", false)
mdl.Init(mdl.GetPrms(true))
pc0 := -1.0
sl0 := 1.0
pcf := 3.0
nptsA := 11
nptsB := 11
if doplot {
plt.Reset()
Plot(mdl, pc0, sl0, pcf, nptsA, "'b.-'", "'r+-'", "bc")
}
tolCc := 1e-11
tolD1a, tolD1b := 1e-10, 1e-17
tolD2a, tolD2b := 1e-10, 1e-17
Check(tst, mdl, pc0, sl0, pcf, nptsB, tolCc, tolD1a, tolD1b, tolD2a, tolD2b, chk.Verbose, []float64{0.2}, 1e-7, doplot)
if doplot {
PlotEnd(true)
}
}
示例13: PlotTwoVarsContour
// PlotTwoVarsContour plots contour for two variables problem. len(x) == 2
// Input
// dirout -- directory to save files
// fnkey -- file name key for eps figure
// x -- solution. can be <nil>
// np -- number of points for contour
// extra -- called just before saving figure
// axequal -- axis.equal
// vmin -- min 0 values
// vmax -- max 1 values
// f -- function to plot filled contour. can be <nil>
// gs -- functions to plot contour @ level 0. can be <nil>
func PlotTwoVarsContour(dirout, fnkey string, x []float64, np int, extra func(), axequal bool,
vmin, vmax []float64, f TwoVarsFunc_t, gs ...TwoVarsFunc_t) {
if fnkey == "" {
return
}
chk.IntAssert(len(vmin), 2)
chk.IntAssert(len(vmax), 2)
V0, V1 := utl.MeshGrid2D(vmin[0], vmax[0], vmin[1], vmax[1], np, np)
var Zf [][]float64
var Zg [][][]float64
if f != nil {
Zf = la.MatAlloc(np, np)
}
if len(gs) > 0 {
Zg = utl.Deep3alloc(len(gs), np, np)
}
xtmp := make([]float64, 2)
for i := 0; i < np; i++ {
for j := 0; j < np; j++ {
xtmp[0], xtmp[1] = V0[i][j], V1[i][j]
if f != nil {
Zf[i][j] = f(xtmp)
}
for k, g := range gs {
Zg[k][i][j] = g(xtmp)
}
}
}
plt.Reset()
plt.SetForEps(0.8, 350)
if f != nil {
cmapidx := 0
plt.Contour(V0, V1, Zf, io.Sf("fsz=7, cmapidx=%d", cmapidx))
}
for k, _ := range gs {
plt.ContourSimple(V0, V1, Zg[k], false, 8, "zorder=5, levels=[0], colors=['yellow'], linewidths=[2], clip_on=0")
}
if x != nil {
plt.PlotOne(x[0], x[1], "'r*', label='optimum', zorder=10")
}
if extra != nil {
extra()
}
if dirout == "" {
dirout = "."
}
plt.Cross("clr='grey'")
plt.SetXnticks(11)
plt.SetYnticks(11)
if axequal {
plt.Equal()
}
plt.AxisRange(vmin[0], vmax[0], vmin[1], vmax[1])
args := "leg_out='1', leg_ncol=4, leg_hlen=1.5"
plt.Gll("$x_0$", "$x_1$", args)
plt.SaveD(dirout, fnkey+".eps")
}
示例14: Test_invs05
func Test_invs05(tst *testing.T) {
//verbose()
chk.PrintTitle("invs05")
if SAVEPLOT {
plt.Reset()
plt.SetForPng(1, 500, 125)
PlotRosette(1.1, true, true, true, 7)
}
addtoplot := func(σa, σb float64, σ []float64) {
plt.PlotOne(σa, σb, "'ro', ms=5")
plt.Text(σa, σb, io.Sf("$\\sigma_{123}=(%g,%g,%g)$", σ[0], σ[1], σ[2]), "size=8")
}
dotest := func(σ []float64, σacor, σbcor, σccor, θcor, tolσ float64) {
w := M_w(σ)
θ2 := math.Asin(w) * 180.0 / (3.0 * math.Pi)
θ3 := M_θ(σ)
σa, σb, σc := L2O(σ[0], σ[1], σ[2])
σ0, σ1, σ2 := O2L(σa, σb, σc)
σI, σA := make([]float64, 3), []float64{σa, σb, σc}
la.MatVecMul(σI, 1, O2Lmat(), σA) // σI := L * σA
io.Pf("σa σb σc = %v %v %v\n", σa, σb, σc)
io.Pf("w = %v\n", w)
io.Pf("θ2, θ3 = %v, %v\n", θ2, θ3)
chk.Scalar(tst, "σa", 1e-17, σa, σacor)
chk.Scalar(tst, "σb", 1e-17, σb, σbcor)
chk.Scalar(tst, "σc", 1e-17, σc, σccor)
chk.Scalar(tst, "σ0", tolσ, σ0, σ[0])
chk.Scalar(tst, "σ1", tolσ, σ1, σ[1])
chk.Scalar(tst, "σ2", tolσ, σ2, σ[2])
chk.Scalar(tst, "σI0", tolσ, σI[0], σ[0])
chk.Scalar(tst, "σI1", tolσ, σI[1], σ[1])
chk.Scalar(tst, "σI2", tolσ, σI[2], σ[2])
chk.Scalar(tst, "θ2", 1e-6, θ2, θcor)
chk.Scalar(tst, "θ3", 1e-17, θ3, θ2)
addtoplot(σa, σb, σ)
}
dotest([]float64{-1, 0, 0, 0}, 0, 2.0/SQ6, 1.0/SQ3, 30, 1e-15)
dotest([]float64{0, -1, 0, 0}, 1.0/SQ2, -1.0/SQ6, 1.0/SQ3, 30, 1e-15)
dotest([]float64{0, 0, -1, 0}, -1.0/SQ2, -1.0/SQ6, 1.0/SQ3, 30, 1e-15)
if SAVEPLOT {
plt.Gll("$\\sigma_a$", "$\\sigma_b$", "")
plt.Equal()
plt.SaveD("/tmp/gosl", "fig_invs05.png")
}
}
示例15: PlotNurbsBasis
// PlotNurbsBasis plots basis functions la and lb
func PlotNurbsBasis(dirout, fn string, b *Nurbs, la, lb int) {
npts := 41
plt.Reset()
if io.FnExt(fn) == ".eps" {
plt.SetForEps(1.5, 500)
} else {
plt.SetForPng(1.5, 600, 150)
}
plt.Subplot(3, 2, 1)
b.DrawCtrl2d(false, "", "")
b.DrawElems2d(npts, false, "", "")
t0 := time.Now()
b.PlotBasis(la, "", 11, 0) // 0 => CalcBasis
io.Pfcyan("time elapsed (calcbasis) = %v\n", time.Now().Sub(t0))
plt.Equal()
plt.Subplot(3, 2, 2)
b.DrawCtrl2d(false, "", "")
b.DrawElems2d(npts, false, "", "")
b.PlotBasis(lb, "", 11, 0) // 0 => CalcBasis
plt.Equal()
plt.Subplot(3, 2, 3)
b.DrawCtrl2d(false, "", "")
b.DrawElems2d(npts, false, "", "")
b.PlotBasis(la, "", 11, 1) // 1 => CalcBasisAndDerivs
plt.Equal()
plt.Subplot(3, 2, 4)
b.DrawCtrl2d(false, "", "")
b.DrawElems2d(npts, false, "", "")
b.PlotBasis(lb, "", 11, 1) // 1 => CalcBasisAndDerivs
plt.Equal()
plt.Subplot(3, 2, 5)
b.DrawCtrl2d(false, "", "")
b.DrawElems2d(npts, false, "", "")
t0 = time.Now()
b.PlotBasis(la, "", 11, 2) // 2 => RecursiveBasis
io.Pfcyan("time elapsed (recursive) = %v\n", time.Now().Sub(t0))
plt.Equal()
plt.Subplot(3, 2, 6)
b.DrawCtrl2d(false, "", "")
b.DrawElems2d(npts, false, "", "")
b.PlotBasis(lb, "", 11, 2) // 2 => RecursiveBasis
plt.Equal()
plt.SaveD(dirout, fn)
}