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


Golang chk.PrintTitle函数代码示例

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


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

示例1: Test_prms02

func Test_prms02(tst *testing.T) {

	//verbose()
	chk.PrintTitle("prms02")

	var prms Prms
	prms = []*Prm{
		&Prm{N: "klx", V: 1.0},
		&Prm{N: "kly", V: 2.0},
		&Prm{N: "klz", V: 3.0},
	}
	io.Pforan("%v\n", prms)

	var klx, kly, klz float64
	err_msg := prms.ConnectSet([]*float64{&klx, &kly, &klz}, []string{"klx", "kly", "klz"}, "Test_prms02")
	if err_msg != "" {
		tst.Error("connect set failed: %v\n", err_msg)
		return
	}

	chk.Scalar(tst, "klx", 1e-15, klx, 1.0)
	chk.Scalar(tst, "kly", 1e-15, kly, 2.0)
	chk.Scalar(tst, "klz", 1e-15, klz, 3.0)

	prms[1].Set(2.2)
	chk.Scalar(tst, "kly", 1e-15, kly, 2.2)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:27,代码来源:t_prms_test.go

示例2: Test_linsol02

func Test_linsol02(tst *testing.T) {

	//verbose()
	chk.PrintTitle("linsol02. real")

	// input matrix data into Triplet
	var t Triplet
	t.Init(10, 10, 64)
	for i := 0; i < 10; i++ {
		j := i
		if i > 0 {
			j = i - 1
		}
		for ; j < 10; j++ {
			val := 10.0 - float64(j)
			if i > j {
				val -= 1.0
			}
			t.Put(i, j, val)
		}
	}

	// run test
	b := []float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}
	x_correct := []float64{-1, 8, -65, 454, -2725, 13624, -54497, 163490, -326981, 326991}
	tol := 1e-9 // TODO: check why tests fails with 1e-10 @ office but not @ home
	run_linsol_testR(tst, &t, 1e-4, tol, b, x_correct)
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:28,代码来源:t_linsol_test.go

示例3: Test_linsol04

func Test_linsol04(tst *testing.T) {

	//verbose()
	chk.PrintTitle("linsol04. complex (but real)")

	// input matrix data into Triplet
	var t TripletC
	t.Init(10, 10, 64, false)
	for i := 0; i < 10; i++ {
		j := i
		if i > 0 {
			j = i - 1
		}
		for ; j < 10; j++ {
			val := 10.0 - float64(j)
			if i > j {
				val -= 1.0
			}
			t.Put(i, j, val, 0)
		}
	}

	// run test
	b := []complex128{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}
	x_correct := []complex128{-1, 8, -65, 454, -2725, 13624, -54497, 163490, -326981, 326991}
	run_linsol_testC(tst, &t, 1e-4, 1e-9, b, x_correct)
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:27,代码来源:t_linsol_test.go

示例4: Test_groups01

func Test_groups01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("groups01")

	Init(0)

	ng := 3            // number of groups
	nints := 12        // number of integers
	size := nints / ng // groups size
	ints := utl.IntRange(nints)
	groups := utl.IntsAlloc(ng, size)
	hists := make([]*IntHistogram, ng)
	for i := 0; i < ng; i++ {
		hists[i] = &IntHistogram{Stations: utl.IntRange(nints + 1)}
	}
	IntGetGroups(groups, ints)
	io.Pfcyan("groups = %v\n", groups)
	for i := 0; i < NSAMPLES; i++ {
		IntGetGroups(groups, ints)
		for j := 0; j < ng; j++ {
			check_repeated(groups[j])
			hists[j].Count(groups[j], false)
		}
	}
	for i := 0; i < ng; i++ {
		io.Pf("\n")
		io.Pf(TextHist(hists[i].GenLabels("%d"), hists[i].Counts, 60))
	}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:30,代码来源:t_random_test.go

示例5: Test_GOflt01

func Test_GOflt01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("GOflt01. float64")

	Init(1234)

	xmin := 10.0
	xmax := 20.0
	vals := make([]float64, NSAMPLES)

	// using Float64
	t0 := time.Now()
	for i := 0; i < NSAMPLES; i++ {
		vals[i] = Float64(xmin, xmax)
	}
	io.Pforan("time elapsed = %v\n", time.Now().Sub(t0))

	hist := Histogram{Stations: []float64{10, 12.5, 15, 17.5, 20}}
	hist.Count(vals, true)
	io.Pfpink(TextHist(hist.GenLabels("%4g"), hist.Counts, 60))

	// using Float64s
	t0 = time.Now()
	Float64s(vals, xmin, xmax)
	io.Pforan("time elapsed = %v\n", time.Now().Sub(t0))

	hist.Count(vals, true)
	io.Pfblue2(TextHist(hist.GenLabels("%4g"), hist.Counts, 60))
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:30,代码来源:t_random_test.go

示例6: Test_mtdeb01

func Test_mtdeb01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("mtdeb01. Deb's mutation")

	var ops OpsData
	ops.SetDefault()
	ops.Pm = 1.0
	ops.Xrange = [][]float64{{-3, 3}, {-4, 4}}
	ops.EnfRange = true

	rnd.Init(0)

	A := []float64{-1, 1}
	io.Pforan("before: A = %v\n", A)
	FltMutationDeb(A, 10, &ops)
	io.Pforan("after:  A = %v\n", A)

	ha0 := rnd.Histogram{Stations: utl.LinSpace(-3, 3, 11)}

	nsamples := 1000
	aa := make([]float64, len(A))
	a0s := make([]float64, nsamples)
	for _, t := range []int{0, 50, 100} {
		for i := 0; i < nsamples; i++ {
			copy(aa, A)
			FltMutationDeb(aa, t, &ops)
			a0s[i] = aa[0]
		}
		ha0.Count(a0s, true)
		io.Pf("\ntime = %d\n", t)
		io.Pf("%s", rnd.TextHist(ha0.GenLabels("%.1f"), ha0.Counts, 60))
	}
}
开发者ID:postfix,项目名称:goga-1,代码行数:34,代码来源:t_opsfloats_test.go

示例7: TestMyLab04

func TestMyLab04(tst *testing.T) {

	//verbose()
	chk.PrintTitle("mylab04")

	n := 5
	a := LinSpace(2.0, 3.0, n)
	δ := (3.0 - 2.0) / float64(n-1)
	r := make([]float64, n)
	for i := 0; i < n; i++ {
		r[i] = 2.0 + float64(i)*δ
	}
	io.Pf("δ = %v\n", δ)
	io.Pf("a = %v\n", a)
	io.Pf("r = %v\n", r)
	chk.Vector(tst, "linspace(2,3,5)", 1e-17, a, []float64{2.0, 2.25, 2.5, 2.75, 3.0})

	b := LinSpaceOpen(2.0, 3.0, n)
	Δ := (3.0 - 2.0) / float64(n)
	R := make([]float64, n)
	for i := 0; i < n; i++ {
		R[i] = 2.0 + float64(i)*Δ
	}
	io.Pf("Δ = %v\n", Δ)
	io.Pf("b = %v\n", b)
	io.Pf("R = %v\n", R)
	chk.Vector(tst, "linspace(2,3,5,open)", 1e-17, b, []float64{2.0, 2.2, 2.4, 2.6, 2.8})

	c := LinSpace(2.0, 3.0, 1)
	io.Pf("c = %v\n", c)
	chk.Vector(tst, "linspace(2,3,1)", 1e-17, c, []float64{2.0})

}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:33,代码来源:t_mylab_test.go

示例8: Test_draw01

func Test_draw01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("draw01")

	P := [][]float64{
		{-2.5, 0.0},
		{-5.5, 4.0},
		{0.0, 10.0},
		{5.5, 4.0},
		{2.5, 0.0},
	}

	var sd Sty
	sd.Init()
	sd.Closed = true
	DrawPolyline(P, &sd, "")
	AutoScale(P)
	Equal()
	DrawLegend([]Fmt{
		Fmt{"red", "o", "-", 1, -1, "first", -1},
		Fmt{"green", "s", "-", 2, 0, "second", -1},
		Fmt{"blue", "+", "-", 3, 10, "third", -1},
	}, 10, "best", false, "")
	if chk.Verbose {
		SaveD("/tmp/gosl", "draw01.eps")
	}
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:28,代码来源:t_drawing_test.go

示例9: Test_up01b

func Test_up01b(tst *testing.T) {

	// capture errors and flush log
	defer End()

	//verbose()
	chk.PrintTitle("up01b")

	// start simulation
	if !Start("data/up01.sim", true, chk.Verbose) {
		chk.Panic("cannot start simulation")
	}

	// for debugging Kb
	if true {
		defer up_DebugKb(&testKb{
			tst: tst, eid: 3, tol: 1e-8, verb: chk.Verbose,
			ni: 1, nj: 1, itmin: 1, itmax: -1, tmin: 800, tmax: 1000,
		})()
	}

	// run simulation
	if !Run() {
		chk.Panic("cannot run simulation\n")
	}
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:26,代码来源:t_up_test.go

示例10: Test_mylab08

func Test_mylab08(tst *testing.T) {

	//verbose()
	chk.PrintTitle("mylab08. dot and cross products")

	u := []float64{3, -3, 1}
	v := []float64{4, 9, 2}
	w := make([]float64, 3)
	s := Dot3d(u, v)
	Cross3d(w, u, v) // w := u cross v
	chk.Scalar(tst, "s = u dot v", 1e-17, s, -13)
	chk.Vector(tst, "w = u cross v", 1e-17, w, []float64{-15, -2, 39})

	u = []float64{3, -3, 1}
	v = []float64{-12, 12, -4}
	s = Dot3d(u, v)
	Cross3d(w, u, v) // w := u cross v
	chk.Scalar(tst, "s = u dot v", 1e-17, s, -76)
	chk.Vector(tst, "w = u cross v", 1e-17, w, []float64{0, 0, 0})

	u = []float64{3, 2, -2}
	v = []float64{1, 0, -5}
	s = Dot3d(u, v)
	Cross3d(w, u, v) // w := u cross v
	chk.Scalar(tst, "s = u dot v", 1e-17, s, 13)
	chk.Vector(tst, "w = u cross v", 1e-17, w, []float64{-10, 13, -2})
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:27,代码来源:t_mylab_test.go

示例11: Test_mylab03a

func Test_mylab03a(tst *testing.T) {

	//verbose()
	chk.PrintTitle("mylab03a. ints: min and max. dbls: min and max")

	A := []int{1, 2, 3, -1, -2, 0, 8, -3}
	mi, ma := IntMinMax(A)
	io.Pf("A      = %v\n", A)
	io.Pf("min(A) = %v\n", mi)
	io.Pf("max(A) = %v\n", ma)
	if mi != -3 {
		chk.Panic("min(A) failed")
	}
	if ma != 8 {
		chk.Panic("max(A) failed")
	}

	if Imin(-1, 2) != -1 {
		chk.Panic("Imin(-1,2) failed")
	}
	if Imax(-1, 2) != 2 {
		chk.Panic("Imax(-1,2) failed")
	}
	if Min(-1, 2) != -1.0 {
		chk.Panic("Min(-1,2) failed")
	}
	if Max(-1, 2) != 2.0 {
		chk.Panic("Max(-1,2) failed")
	}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:30,代码来源:t_mylab_test.go

示例12: Test_mylab07

func Test_mylab07(tst *testing.T) {

	//verbose()
	chk.PrintTitle("mylab07. get column")

	v := [][]float64{
		{1, 2, 3, 4},
		{-1, 2, 3, 0},
		{-1, 2, 1, 4},
		{1, -2, 3, 8},
		{1, 1, -3, 4},
		{0, 2, 9, -4},
	}

	x := DblsGetColumn(0, v)
	chk.Vector(tst, "v[:,0]", 1e-17, x, []float64{1, -1, -1, 1, 1, 0})

	x = DblsGetColumn(1, v)
	chk.Vector(tst, "v[:,1]", 1e-17, x, []float64{2, 2, 2, -2, 1, 2})

	x = DblsGetColumn(2, v)
	chk.Vector(tst, "v[:,2]", 1e-17, x, []float64{3, 3, 1, 3, -3, 9})

	x = DblsGetColumn(3, v)
	chk.Vector(tst, "v[:,3]", 1e-17, x, []float64{4, 0, 4, 8, 4, -4})
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:26,代码来源:t_mylab_test.go

示例13: Test_state01

func Test_state01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("state01")

	nsig, nalp, large, nle := 4, 1, false, true
	state0 := NewState(nsig, nalp, large, nle)
	io.Pforan("state0 = %+v\n", state0)
	chk.Vector(tst, "sig", 1.0e-17, state0.Sig, []float64{0, 0, 0, 0})
	chk.Vector(tst, "alp", 1.0e-17, state0.Alp, []float64{0})
	chk.Vector(tst, "epsE", 1.0e-17, state0.EpsE, []float64{0, 0, 0, 0})

	state0.Sig[0] = 10.0
	state0.Sig[1] = 11.0
	state0.Sig[2] = 12.0
	state0.Sig[3] = 13.0
	state0.Alp[0] = 20.0

	state1 := NewState(nsig, nalp, large, nle)
	state1.Set(state0)
	io.Pforan("state1 = %+v\n", state1)
	chk.Vector(tst, "sig", 1.0e-17, state1.Sig, []float64{10, 11, 12, 13})
	chk.Vector(tst, "alp", 1.0e-17, state1.Alp, []float64{20})

	state2 := state1.GetCopy()
	io.Pforan("state2 = %+v\n", state2)
	chk.Vector(tst, "sig", 1.0e-17, state2.Sig, []float64{10, 11, 12, 13})
	chk.Vector(tst, "alp", 1.0e-17, state2.Alp, []float64{20})
	chk.Vector(tst, "epsE", 1.0e-17, state2.EpsE, []float64{0, 0, 0, 0})
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:30,代码来源:t_state_test.go

示例14: Test_munkres04

func Test_munkres04(tst *testing.T) {

	//verbose()
	chk.PrintTitle("munkres04. row and column matrices")

	C := [][]float64{
		{1.0},
		{2.0},
		{0.5},
		{3.0},
		{4.0},
	}

	var mnk Munkres
	mnk.Init(len(C), len(C[0]))
	mnk.SetCostMatrix(C)
	mnk.Run()
	io.Pforan("links = %v\n", mnk.Links)
	io.Pforan("cost = %v  (13938)\n", mnk.Cost)
	chk.Ints(tst, "links", mnk.Links, []int{-1, -1, 0, -1, -1})
	chk.Scalar(tst, "cost", 1e-17, mnk.Cost, 0.5)

	C = [][]float64{
		{1.0, 2.0, 0.5, 3.0, 4.0},
	}
	mnk.Init(len(C), len(C[0]))
	mnk.SetCostMatrix(C)
	mnk.Run()
	io.Pforan("links = %v\n", mnk.Links)
	io.Pforan("cost = %v  (13938)\n", mnk.Cost)
	chk.Ints(tst, "links", mnk.Links, []int{2})
	chk.Scalar(tst, "cost", 1e-17, mnk.Cost, 0.5)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:33,代码来源:t_munkres_test.go

示例15: Test_pipe01

func Test_pipe01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("runcmd01")

	Pforan("running pipe\n")

	// find $DIR -type f # Find all files
	dir := "."
	find := exec.Command("find", dir, "-type", "f")

	// | grep -v '/[._]' # Ignore hidden/temporary files
	egrep := exec.Command("egrep", "-v", `/[._]`)

	// | sort -t. -k2 # Sort by file extension
	sort := exec.Command("sort", "-t.", "-k2")

	output, stderr, err := Pipeline(find, egrep, sort)
	Pfblue2("\noutput:\n%v\n", string(output))
	Pfcyan("stderr:\n%v\n", string(stderr))
	if err != nil {
		tst.Errorf("error: %v\n", err)
		return
	}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:25,代码来源:t_external_test.go


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