• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang chk.Vector函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Test_conv06

func Test_conv06(tst *testing.T) {

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

	a := [][]float64{
		{1, 2, 3},
		{4, 5, 6},
		{7, 8, 9},
		{10, 11, 12},
	}
	a_ := MatAlloc(4, 3)
	am := MatToColMaj(a)
	aa := ColMajToMatNew(am, 4, 3)
	ColMajToMat(a_, am)
	io.Pforan("a  = %v\n", a)
	io.Pforan("am = %v\n", am)
	io.Pforan("aa = %v\n", aa)
	chk.Vector(tst, "a => am", 1e-17, am, []float64{1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12})
	chk.Matrix(tst, "am => a", 1e-17, aa, a)
	chk.Matrix(tst, "am => a", 1e-17, a_, a)

	b := [][]float64{
		{1, 2, 3, 4},
		{5, 6, 7, 8},
		{9, 0, -1, -2},
	}
	bm := MatToColMaj(b)
	bb := ColMajToMatNew(bm, 3, 4)
	io.Pforan("b  = %v\n", b)
	io.Pforan("bm = %v\n", bm)
	io.Pforan("bb = %v\n", bb)
	chk.Vector(tst, "b => bm", 1e-15, bm, []float64{1, 5, 9, 2, 6, 0, 3, 7, -1, 4, 8, -2})
	chk.Matrix(tst, "bm => b", 1e-15, bb, b)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:35,代码来源:t_conversions_test.go


示例2: 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


示例3: 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


示例4: TestSPDsolve02

func TestSPDsolve02(tst *testing.T) {

	//verbose()
	chk.PrintTitle("TestSPDsolve 02")

	a := [][]float64{
		{2, 1, 1, 3, 2},
		{1, 2, 2, 1, 1},
		{1, 2, 9, 1, 5},
		{3, 1, 1, 7, 1},
		{2, 1, 5, 1, 8},
	}
	b := []float64{-2, 4, 3, -5, 1}
	B := []float64{24, 29, 110, 12, 102}
	x := make([]float64, 5)
	X := make([]float64, 5)
	SPDsolve2(x, X, a, b, B)
	CheckResidR(tst, 1e-14, a, x, b)
	CheckResidR(tst, 1e-14, a, X, B)
	chk.Vector(tst, "x = inv(a) * b", 1e-13, x, []float64{
		-629.0 / 98.0,
		237.0 / 49.0,
		-53.0 / 49.0,
		62.0 / 49.0,
		23.0 / 14.0,
	})
	chk.Vector(tst, "X = inv(a) * B", 1e-13, X, []float64{0, 4, 7, -1, 8})
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:28,代码来源:t_densesol_test.go


示例5: Test_basicgeom05

func Test_basicgeom05(tst *testing.T) {

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

	zero := 1e-1
	told := 1e-9
	tolin := 1e-3

	o := &Point{0, 0, 0}
	a := &Point{0.5, 0.5, 0.5}
	b := &Point{0.1, 0.5, 0.8}
	c := &Point{1, 1, 1}
	cmin, cmax := PointsLims([]*Point{o, a, b, c})
	chk.Vector(tst, "cmin", 1e-17, cmin, []float64{0, 0, 0})
	chk.Vector(tst, "cmax", 1e-17, cmax, []float64{1, 1, 1})
	if !IsPointIn(a, cmin, cmax, zero) {
		chk.Panic("a=%v must be in box")
	}
	if !IsPointIn(b, cmin, cmax, zero) {
		chk.Panic("b=%v must be in box")
	}
	if !IsPointIn(c, cmin, cmax, zero) {
		chk.Panic("c=%v must be in box")
	}

	p := &Point{0.5, 0.5, 0.5}
	q := &Point{1.5, 1.5, 1.5}
	if !IsPointInLine(p, o, c, zero, told, tolin) {
		chk.Panic("p=%v must be in line")
	}
	if IsPointInLine(q, o, c, zero, told, tolin) {
		chk.Panic("q=%v must not be in line")
	}
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:35,代码来源:t_basicgeom_test.go


示例6: Test_mvMul01

func Test_mvMul01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("mvMul01. MatrixVector multiplication")

	a := [][]float64{
		{10.0, 20.0, 30.0, 40.0, 50.0},
		{1.0, 20.0, 3.0, 40.0, 5.0},
		{10.0, 2.0, 30.0, 4.0, 50.0},
	}
	u := []float64{0.5, 0.4, 0.3, 0.2, 0.1}
	r := []float64{0.5, 0.4, 0.3}
	z := []float64{1000, 1000, 1000}
	w := []float64{1000, 2000, 3000, 4000, 5000}
	au := make([]float64, 3)
	atr := make([]float64, 5)
	au_cor := []float64{35, 17.9, 20.6}
	atr_cor := []float64{8.4, 18.6, 25.2, 37.2, 42}
	zpau_cor := []float64{1035, 1017.9, 1020.6}
	wpar_cor := []float64{1008.4, 2018.6, 3025.2, 4037.2, 5042}
	MatVecMul(au, 1, a, u)     // au  = 1*a*u
	MatTrVecMul(atr, 1, a, r)  // atr = 1*transp(a)*r
	MatVecMulAdd(z, 1, a, u)   // z  += 1*a*u
	MatTrVecMulAdd(w, 1, a, r) // w  += 1*transp(a)*r
	chk.Vector(tst, "au", 1.0e-17, au, au_cor)
	chk.Vector(tst, "atr", 1.0e-17, atr, atr_cor)
	chk.Vector(tst, "zpau", 1.0e-12, z, zpau_cor)
	chk.Vector(tst, "wpar", 1.0e-12, w, wpar_cor)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:29,代码来源:t_matvecmul_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_fileio01

func Test_fileio01(tst *testing.T) {

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

	// start
	analysis := NewFEM("data/bh16.sim", "", true, false, false, false, chk.Verbose, 0)

	// domain A
	domsA := NewDomains(analysis.Sim, analysis.DynCfs, analysis.HydSta, 0, 1, false)
	if len(domsA) == 0 {
		tst.Errorf("NewDomains failed\n")
		return
	}
	domA := domsA[0]
	err := domA.SetStage(0)
	if err != nil {
		tst.Errorf("SetStage failed\n%v", err)
		return
	}
	for i, _ := range domA.Sol.Y {
		domA.Sol.Y[i] = float64(i)
	}
	io.Pforan("domA.Sol.Y = %v\n", domA.Sol.Y)

	// write file
	tidx := 123
	err = domA.SaveSol(tidx, true)
	if err != nil {
		tst.Errorf("SaveSol failed:\n%v", err)
		return
	}

	// domain B
	domsB := NewDomains(analysis.Sim, analysis.DynCfs, analysis.HydSta, 0, 1, false)
	if len(domsB) == 0 {
		tst.Errorf("NewDomains failed\n")
		return
	}
	domB := domsB[0]
	err = domB.SetStage(0)
	if err != nil {
		tst.Errorf("SetStage failed\n%v", err)
		return
	}
	io.Pfpink("domB.Sol.Y (before) = %v\n", domB.Sol.Y)

	// read file
	err = domB.ReadSol(analysis.Sim.DirOut, analysis.Sim.Key, analysis.Sim.EncType, tidx)
	if err != nil {
		tst.Errorf("ReadSol failed:\n%v", err)
		return
	}
	io.Pfgreen("domB.Sol.Y (after) = %v\n", domB.Sol.Y)

	// check
	chk.Vector(tst, "Y", 1e-17, domA.Sol.Y, domB.Sol.Y)
	chk.Vector(tst, "dy/dt", 1e-17, domA.Sol.Dydt, domB.Sol.Dydt)
	chk.Vector(tst, "d²y/dt²", 1e-17, domA.Sol.D2ydt2, domB.Sol.D2ydt2)
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:60,代码来源:t_fileio_test.go


示例9: Test_mylab01

func Test_mylab01(tst *testing.T) {

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

	I := make([]int, 5)
	IntFill(I, 666)
	J := IntVals(5, 666)
	Js := StrVals(5, "666")
	M := IntsAlloc(3, 4)
	N := DblsAlloc(3, 4)
	S := StrsAlloc(2, 3)
	A := IntRange(-1)
	a := IntRange2(0, 0)
	b := IntRange2(0, 1)
	c := IntRange2(0, 5)
	C := IntRange3(0, -5, -1)
	d := IntRange2(2, 5)
	D := IntRange2(-2, 5)
	e := IntAddScalar(D, 2)
	f := DblOnes(5)
	ff := DblVals(5, 666)
	g := []int{1, 2, 3, 4, 3, 4, 2, 1, 1, 2, 3, 4, 4, 2, 3, 7, 8, 3, 8, 3, 9, 0, 11, 23, 1, 2, 32, 12, 4, 32, 4, 11, 37}
	h := IntUnique(g)
	G := []int{1, 2, 3, 38, 3, 5, 3, 1, 2, 15, 38, 1, 11}
	H := IntUnique(D, C, G, []int{16, 39})
	X, Y := MeshGrid2D(3, 6, 10, 20, 4, 3)
	P := [][]int{
		{1, 2, 3, 4, 5},
		{-1, -2, -3, -4, -5},
		{6, 7, 8, 9, 10},
	}
	Pc := IntsClone(P)
	chk.Ints(tst, "I", I, []int{666, 666, 666, 666, 666})
	chk.Ints(tst, "J", J, []int{666, 666, 666, 666, 666})
	chk.Strings(tst, "Js", Js, []string{"666", "666", "666", "666", "666"})
	chk.Ints(tst, "A", A, []int{})
	chk.Ints(tst, "a", a, []int{})
	chk.Ints(tst, "b", b, []int{0})
	chk.Ints(tst, "c", c, []int{0, 1, 2, 3, 4})
	chk.Ints(tst, "C", C, []int{0, -1, -2, -3, -4})
	chk.Ints(tst, "d", d, []int{2, 3, 4})
	chk.Ints(tst, "D", D, []int{-2, -1, 0, 1, 2, 3, 4})
	chk.Ints(tst, "e", e, []int{0, 1, 2, 3, 4, 5, 6})
	chk.Vector(tst, "f", 1e-16, f, []float64{1, 1, 1, 1, 1})
	chk.Vector(tst, "ff", 1e-16, ff, []float64{666, 666, 666, 666, 666})
	chk.Ints(tst, "h", h, []int{0, 1, 2, 3, 4, 7, 8, 9, 11, 12, 23, 32, 37})
	chk.Ints(tst, "H", H, []int{-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 11, 15, 16, 38, 39})
	chk.IntMat(tst, "M", M, [][]int{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}})
	chk.Matrix(tst, "N", 1e-17, N, [][]float64{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}})
	chk.Matrix(tst, "X", 1e-17, X, [][]float64{{3, 4, 5, 6}, {3, 4, 5, 6}, {3, 4, 5, 6}})
	chk.Matrix(tst, "Y", 1e-17, Y, [][]float64{{10, 10, 10, 10}, {15, 15, 15, 15}, {20, 20, 20, 20}})
	chk.StrMat(tst, "S", S, [][]string{{"", "", ""}, {"", "", ""}})
	chk.IntMat(tst, "Pc", Pc, P)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:55,代码来源:t_mylab_test.go


示例10: Test_fileio01

func Test_fileio01(tst *testing.T) {

	chk.PrintTitle("fileio01")

	// start
	if !Start("data/bh16.sim", true, chk.Verbose) {
		tst.Errorf("test failed\n")
	}
	defer End()

	// domain A
	distr := false
	domA := NewDomain(Global.Sim.Regions[0], distr)
	if domA == nil {
		tst.Errorf("test failed\n")
	}
	if !domA.SetStage(0, Global.Sim.Stages[0], distr) {
		tst.Errorf("test failed\n")
	}
	for i, _ := range domA.Sol.Y {
		domA.Sol.Y[i] = float64(i)
	}
	io.Pforan("domA.Sol.Y = %v\n", domA.Sol.Y)

	// write file
	tidx := 123
	if !domA.SaveSol(tidx) {
		tst.Errorf("test failed")
		return
	}
	dir, fnk := Global.Dirout, Global.Fnkey
	io.Pfblue2("file %v written\n", out_nod_path(dir, fnk, tidx, Global.Rank))

	// domain B
	domB := NewDomain(Global.Sim.Regions[0], distr)
	if domB == nil {
		tst.Errorf("test failed\n")
	}
	if !domB.SetStage(0, Global.Sim.Stages[0], distr) {
		tst.Errorf("test failed")
	}
	io.Pfpink("domB.Sol.Y (before) = %v\n", domB.Sol.Y)

	// read file
	if !domB.ReadSol(dir, fnk, tidx) {
		tst.Errorf("test failed")
		return
	}
	io.Pfgreen("domB.Sol.Y (after) = %v\n", domB.Sol.Y)

	// check
	chk.Vector(tst, "Y", 1e-17, domA.Sol.Y, domB.Sol.Y)
	chk.Vector(tst, "dy/dt", 1e-17, domA.Sol.Dydt, domB.Sol.Dydt)
	chk.Vector(tst, "d²y/dt²", 1e-17, domA.Sol.D2ydt2, domB.Sol.D2ydt2)
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:55,代码来源:t_fileio_test.go


示例11: Test_eigenp00

func Test_eigenp00(tst *testing.T) {

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

	ncp := 6
	P := M_AllocEigenprojs(ncp)
	chk.Vector(tst, "P0", 1e-17, P[0], []float64{0, 0, 0, 0, 0, 0})
	chk.Vector(tst, "P1", 1e-17, P[1], []float64{0, 0, 0, 0, 0, 0})
	chk.Vector(tst, "P2", 1e-17, P[2], []float64{0, 0, 0, 0, 0, 0})
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:11,代码来源:t_eigenprojs_test.go


示例12: TestReadTable01

func TestReadTable01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("ReadTable 01")

	keys, res := ReadTableOrPanic("data/table01.dat")

	chk.Strings(tst, "keys", keys, []string{"a", "b", "c", "d"})
	chk.Vector(tst, "a", 1.0e-17, res["a"], []float64{1, 4, 7})
	chk.Vector(tst, "b", 1.0e-17, res["b"], []float64{2, 5, 8})
	chk.Vector(tst, "c", 1.0e-17, res["c"], []float64{3, 6, 9})
	chk.Vector(tst, "d", 1.0e-17, res["d"], []float64{666, 777, 641})
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:13,代码来源:t_readtable_test.go


示例13: Test_sigini01

func Test_sigini01(tst *testing.T) {

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

	// start simulation
	if !Start("data/sigini01.sim", true, chk.Verbose) {
		tst.Errorf("test failed\n")
		return
	}
	defer End()

	// run simulation
	if !Run() {
		tst.Errorf("test failed\n")
		return
	}

	// allocate domain
	distr := false
	d := NewDomain(Global.Sim.Regions[0], distr)
	if !d.SetStage(0, Global.Sim.Stages[0], distr) {
		tst.Errorf("SetStage failed\n")
		return
	}

	// check displacements
	tolu := 1e-16
	for _, n := range d.Nodes {
		eqx := n.GetEq("ux")
		eqy := n.GetEq("uy")
		u := []float64{d.Sol.Y[eqx], d.Sol.Y[eqy]}
		chk.Vector(tst, "u", tolu, u, nil)
	}

	// analytical solution
	qnV, qnH := -100.0, -50.0
	ν := 0.25
	σx, σy := qnH, qnV
	σz := ν * (σx + σy)
	σref := []float64{σx, σy, σz, 0}

	// check stresses
	e := d.Elems[0].(*ElemU)
	tols := 1e-13
	for idx, _ := range e.IpsElem {
		σ := e.States[idx].Sig
		io.Pforan("σ = %v\n", σ)
		chk.Vector(tst, "σ", tols, σ, σref)
	}
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:51,代码来源:t_u_test.go


示例14: Test_conv07

func Test_conv07(tst *testing.T) {

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

	r := []float64{1, 2, 3, 4, 5, 6}
	c := []float64{0.1, 0.2, 0.3, 0.4, 0.5, 0.6}
	rc := RCtoComplex(r, c)
	chk.VectorC(tst, "rc", 1e-17, rc, []complex128{1 + 0.1i, 2 + 0.2i, 3 + 0.3i, 4 + 0.4i, 5 + 0.5i, 6 + 0.6i})

	R, C := ComplexToRC(rc)
	chk.Vector(tst, "r", 1e-17, R, r)
	chk.Vector(tst, "c", 1e-17, C, c)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:14,代码来源:t_conversions_test.go


示例15: Test_sigini01

func Test_sigini01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("sigini01. zero displacements. initial stresses")

	// fem
	analysis := NewFEM("data/sigini01.sim", "", true, false, false, false, chk.Verbose, 0)

	// set stage
	err := analysis.SetStage(0)
	if err != nil {
		tst.Errorf("SetStage failed:\n%v", err)
		return
	}

	// initialise solution vectors
	err = analysis.ZeroStage(0, true)
	if err != nil {
		tst.Errorf("ZeroStage failed:\n%v", err)
		return
	}

	// domain
	dom := analysis.Domains[0]

	// check displacements
	tolu := 1e-16
	for _, n := range dom.Nodes {
		eqx := n.GetEq("ux")
		eqy := n.GetEq("uy")
		u := []float64{dom.Sol.Y[eqx], dom.Sol.Y[eqy]}
		chk.Vector(tst, "u", tolu, u, nil)
	}

	// analytical solution
	qnV, qnH := -100.0, -50.0
	ν := 0.25
	σx, σy := qnH, qnV
	σz := ν * (σx + σy)
	σref := []float64{σx, σy, σz, 0}

	// check stresses
	e := dom.Elems[0].(*ElemU)
	tols := 1e-13
	for idx, _ := range e.IpsElem {
		σ := e.States[idx].Sig
		io.Pforan("σ = %v\n", σ)
		chk.Vector(tst, "σ", tols, σ, σref)
	}
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:50,代码来源:t_u_test.go


示例16: 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


示例17: Test_smpinvs01

func Test_smpinvs01(tst *testing.T) {

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

	a, b, β, ϵ := -1.0, 0.5, 1e-3, 1e-3

	L := []float64{-8.0, -8.0, -8.0}
	N := make([]float64, 3)
	n := make([]float64, 3)
	m := SmpDirector(N, L, a, b, β, ϵ)
	SmpUnitDirector(n, m, N)
	io.Pforan("L = %v\n", L)
	io.Pforan("N = %v\n", N)
	io.Pforan("m = %v\n", m)
	io.Pforan("n = %v\n", n)
	chk.Vector(tst, "n", 1e-15, n, []float64{a / SQ3, a / SQ3, a / SQ3})

	p, q, err := GenInvs(L, n, a)
	if err != nil {
		chk.Panic("GenInvs failed:\n%v", err.Error())
	}
	io.Pforan("p = %v\n", p)
	io.Pforan("q = %v\n", q)
	if q < 0.0 || q > GENINVSQEPS {
		chk.Panic("q=%g is incorrect", q)
	}
	if math.Abs(p-a*L[0]) > 1e-14 {
		chk.Panic("p=%g is incorrect. err = %g", p, math.Abs(p-a*L[0]))
	}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:31,代码来源:t_smpinvs_test.go


示例18: Test_serial02

func Test_serial02(tst *testing.T) {

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

	A := [][][]float64{
		{{1, 3, 4}, {6}, {232, 23, 292, 2023}, {2, 3}},
		{{0}, {1}, {0}},
		{{0, 5, 6, 8, 3, 0}},
	}

	// serialize
	PrintDeep3("A", A)
	I, P, S := Deep3Serialize(A)
	Deep3GetInfo(I, P, S, true)

	// check serialization
	chk.Ints(tst, "I", I, []int{0, 0, 0, 0, 1, 1, 1, 2})
	chk.Ints(tst, "P", P, []int{0, 3, 4, 8, 10, 11, 12, 13, 19})
	chk.Vector(tst, "S", 1e-16, S, []float64{1, 3, 4, 6, 232, 23, 292, 2023, 2, 3, 0, 1, 0, 0, 5, 6, 8, 3, 0})

	// deserialize
	B := Deep3Deserialize(I, P, S, false)
	PrintDeep3("B", B)

	// check deserialization
	chk.Deep3(tst, "A", 1e-16, A, B)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:28,代码来源:t_serialize_test.go


示例19: TestSparseLA10

func TestSparseLA10(tst *testing.T) {

	//verbose()
	chk.PrintTitle("TestSparse LA10: SpTriMatTrVecMul")

	var a Triplet
	a.Init(3, 5, 15)
	a.Put(0, 0, 10.0)
	a.Put(0, 1, 20.0)
	a.Put(0, 2, 30.0)
	a.Put(0, 3, 40.0)
	a.Put(0, 4, 50.0)
	a.Put(1, 0, 1.0)
	a.Put(1, 1, 20.0)
	a.Put(1, 2, 3.0)
	a.Put(1, 3, 40.0)
	a.Put(1, 4, 5.0)
	a.Put(2, 0, 10.0)
	a.Put(2, 1, 2.0)
	a.Put(2, 2, 30.0)
	a.Put(2, 3, 4.0)
	a.Put(2, 4, 50.0)

	x := []float64{0.5, 0.4, 0.3}
	y := make([]float64, 5)
	SpTriMatTrVecMul(y, &a, x) // y := transpose(a) * x

	chk.Vector(tst, "y=Tr(a)*x", 1e-17, y, []float64{8.4, 18.6, 25.2, 37.2, 42})
}
开发者ID:PatrickSchm,项目名称:gosl,代码行数:29,代码来源:t_sparsela_test.go


示例20: Test_serial01

func Test_serial01(tst *testing.T) {

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

	A := [][][]float64{
		{{100, 101, 102}, {103}, {104, 105}},
		{{106}, {107}},
		{{108}, {109, 110}},
		{{111}},
		{{112, 113, 114, 115}, {116}, {117, 118}, {119, 120, 121}},
	}

	// serialize
	PrintDeep3("A", A)
	I, P, S := Deep3Serialize(A)
	Deep3GetInfo(I, P, S, true)

	// check serialization
	chk.Ints(tst, "I", I, []int{0, 0, 0, 1, 1, 2, 2, 3, 4, 4, 4, 4})
	chk.Ints(tst, "P", P, []int{0, 3, 4, 6, 7, 8, 9, 11, 12, 16, 17, 19, 22})
	Scor := LinSpace(100, 121, 22)
	io.Pf("Scor = %v\n", Scor)
	chk.Vector(tst, "S", 1e-16, S, Scor)

	// deserialize
	B := Deep3Deserialize(I, P, S, false)
	PrintDeep3("B", B)

	// check deserialization
	chk.Deep3(tst, "A", 1e-16, A, B)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:32,代码来源:t_serialize_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang io.Ff函数代码示例发布时间:2022-05-23
下一篇:
Golang chk.String函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap