本文整理汇总了Golang中github.com/cpmech/gosl/chk.IntAssert函数的典型用法代码示例。如果您正苦于以下问题:Golang IntAssert函数的具体用法?Golang IntAssert怎么用?Golang IntAssert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IntAssert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Init
// Init initialises FORM structure
func (o *ReliabFORM) Init(μ, σ []float64, lrv []bool, gfcn ReliabGfcn_t, hfcn ReliabHfcn_t) {
// input
o.μ = μ
o.σ = σ
o.lrv = lrv
o.gfcn = gfcn
o.hfcn = hfcn
// default constants
o.NmaxItA = 10
o.NmaxItB = 10
o.TolA = 0.001
o.TolB = 0.001
o.NlsSilent = true
o.NlsCheckJ = false
o.NlsCheckJtol = 1e-9
// allocate slices
nx := len(μ)
chk.IntAssert(len(σ), nx)
chk.IntAssert(len(lrv), nx)
o.α = make([]float64, nx)
o.xtmp = make([]float64, nx)
o.dgdx = make([]float64, nx)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:27,代码来源:reliability.go
示例2: Test_nurbs02
func Test_nurbs02(tst *testing.T) {
//verbose()
chk.PrintTitle("nurbs02")
// NURBS
b := FactoryNurbs2dPlateHole()
elems := b.Elements()
nbasis := b.GetElemNumBasis()
io.Pforan("nbasis = %v\n", nbasis)
chk.IntAssert(nbasis, 9) // orders := (2,2) => nbasis = (2+1)*(2+1) = 9
// check basis and elements
chk.Ints(tst, "elem[0]", elems[0], []int{2, 3, 2, 3})
chk.Ints(tst, "elem[1]", elems[1], []int{3, 4, 2, 3})
chk.Ints(tst, "ibasis0", b.IndBasis(elems[0]), []int{0, 1, 2, 4, 5, 6, 8, 9, 10})
chk.Ints(tst, "ibasis1", b.IndBasis(elems[1]), []int{1, 2, 3, 5, 6, 7, 9, 10, 11})
chk.IntAssert(b.GetElemNumBasis(), len(b.IndBasis(elems[0])))
// check derivatives
b.CheckDerivs(tst, 11, 1e-5, false)
// refine NURBS
c := b.KrefineN(2, false)
elems = c.Elements()
chk.IntAssert(c.GetElemNumBasis(), len(c.IndBasis(elems[0])))
// check refined elements
io.Pf("\n------------ refined -------------\n")
chk.Ints(tst, "elem[0]", elems[0], []int{2, 3, 2, 3})
chk.Ints(tst, "elem[1]", elems[1], []int{3, 4, 2, 3})
chk.Ints(tst, "elem[2]", elems[2], []int{4, 5, 2, 3})
chk.Ints(tst, "elem[3]", elems[3], []int{5, 6, 2, 3})
chk.Ints(tst, "elem[4]", elems[4], []int{2, 3, 3, 4})
chk.Ints(tst, "elem[5]", elems[5], []int{3, 4, 3, 4})
chk.Ints(tst, "elem[6]", elems[6], []int{4, 5, 3, 4})
chk.Ints(tst, "elem[7]", elems[7], []int{5, 6, 3, 4})
// check refined basis
chk.Ints(tst, "ibasis0", c.IndBasis(elems[0]), []int{0, 1, 2, 6, 7, 8, 12, 13, 14})
chk.Ints(tst, "ibasis1", c.IndBasis(elems[1]), []int{1, 2, 3, 7, 8, 9, 13, 14, 15})
chk.Ints(tst, "ibasis2", c.IndBasis(elems[2]), []int{2, 3, 4, 8, 9, 10, 14, 15, 16})
chk.Ints(tst, "ibasis3", c.IndBasis(elems[3]), []int{3, 4, 5, 9, 10, 11, 15, 16, 17})
chk.Ints(tst, "ibasis4", c.IndBasis(elems[4]), []int{6, 7, 8, 12, 13, 14, 18, 19, 20})
chk.Ints(tst, "ibasis5", c.IndBasis(elems[5]), []int{7, 8, 9, 13, 14, 15, 19, 20, 21})
chk.Ints(tst, "ibasis6", c.IndBasis(elems[6]), []int{8, 9, 10, 14, 15, 16, 20, 21, 22})
chk.Ints(tst, "ibasis7", c.IndBasis(elems[7]), []int{9, 10, 11, 15, 16, 17, 21, 22, 23})
// plot
if chk.Verbose {
io.Pf("\n------------ plot -------------\n")
la := 0 + 0*b.n[0]
lb := 2 + 1*b.n[0]
PlotNurbs("/tmp/gosl/gm", "nurbs02a.png", b, 41, true, nil)
PlotNurbsBasis("/tmp/gosl/gm", "nurbs02b.png", b, la, lb)
PlotNurbsDerivs("/tmp/gosl/gm", "nurbs02c.png", b, la, lb)
PlotTwoNurbs("/tmp/gosl/gm", "nurbs02d.png", b, c, 41, true, nil)
}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:59,代码来源:t_nurbs_test.go
示例3: Test_frees01a
func Test_frees01a(tst *testing.T) {
// finalise analysis process and catch errors
defer End()
//verbose()
chk.PrintTitle("frees01a")
// start simulation
if !Start("data/frees01.sim", true, chk.Verbose) {
chk.Panic("cannot start FE simulation")
}
// domain
distr := false
dom := NewDomain(Global.Sim.Regions[0], distr)
if dom == nil {
chk.Panic("cannot run FE simulation")
}
// set stage
if !dom.SetStage(0, Global.Sim.Stages[0], distr) {
chk.Panic("cannot set stage\n")
}
// nodes and elements
chk.IntAssert(len(dom.Nodes), 62)
chk.IntAssert(len(dom.Elems), 15)
// vertices with "fl"
seepverts := map[int]bool{3: true, 45: true, 7: true, 49: true, 11: true, 53: true, 15: true, 57: true, 19: true, 61: true, 23: true}
// check dofs
var seepeqs []int
for _, nod := range dom.Nodes {
if seepverts[nod.Vert.Id] {
chk.IntAssert(len(nod.Dofs), 2)
seepeqs = append(seepeqs, nod.Dofs[1].Eq)
} else {
chk.IntAssert(len(nod.Dofs), 1)
}
}
sort.Ints(seepeqs)
io.Pforan("seepeqs = %v\n", seepeqs)
chk.Ints(tst, "seepeqs", seepeqs, []int{14, 16, 19, 30, 32, 43, 45, 56, 58, 69, 71})
// check Fmap
e2 := dom.Elems[2].(*ElemP)
chk.Ints(tst, "e2.Fmap", e2.Fmap, []int{14, 16, 19})
e5 := dom.Elems[5].(*ElemP)
chk.Ints(tst, "e5.Fmap", e5.Fmap, []int{16, 30, 32})
e8 := dom.Elems[8].(*ElemP)
chk.Ints(tst, "e8.Fmap", e8.Fmap, []int{30, 43, 45})
e11 := dom.Elems[11].(*ElemP)
chk.Ints(tst, "e11.Fmap", e11.Fmap, []int{43, 56, 58})
e14 := dom.Elems[14].(*ElemP)
chk.Ints(tst, "e14.Fmap", e14.Fmap, []int{56, 69, 71})
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:58,代码来源:t_frees_test.go
示例4: Test_frees01a
func Test_frees01a(tst *testing.T) {
//verbose()
chk.PrintTitle("frees01a")
// start simulation
analysis := NewFEM("data/frees01.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 vectros
err = analysis.ZeroStage(0, true)
if err != nil {
tst.Errorf("ZeroStage failed:\n%v", err)
return
}
// domain
dom := analysis.Domains[0]
// nodes and elements
chk.IntAssert(len(dom.Nodes), 62)
chk.IntAssert(len(dom.Elems), 15)
// vertices with "fl"
seepverts := map[int]bool{3: true, 45: true, 7: true, 49: true, 11: true, 53: true, 15: true, 57: true, 19: true, 61: true, 23: true}
// check dofs
var seepeqs []int
for _, nod := range dom.Nodes {
if seepverts[nod.Vert.Id] {
chk.IntAssert(len(nod.Dofs), 2)
seepeqs = append(seepeqs, nod.Dofs[1].Eq)
} else {
chk.IntAssert(len(nod.Dofs), 1)
}
}
sort.Ints(seepeqs)
io.Pforan("seepeqs = %v\n", seepeqs)
chk.Ints(tst, "seepeqs", seepeqs, []int{14, 16, 19, 30, 32, 43, 45, 56, 58, 69, 71})
// check Fmap
e2 := dom.Elems[2].(*ElemP)
chk.Ints(tst, "e2.Fmap", e2.Fmap, []int{14, 16, 19})
e5 := dom.Elems[5].(*ElemP)
chk.Ints(tst, "e5.Fmap", e5.Fmap, []int{16, 30, 32})
e8 := dom.Elems[8].(*ElemP)
chk.Ints(tst, "e8.Fmap", e8.Fmap, []int{30, 43, 45})
e11 := dom.Elems[11].(*ElemP)
chk.Ints(tst, "e11.Fmap", e11.Fmap, []int{43, 56, 58})
e14 := dom.Elems[14].(*ElemP)
chk.Ints(tst, "e14.Fmap", e14.Fmap, []int{56, 69, 71})
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:58,代码来源:t_frees_test.go
示例5: 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")
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:69,代码来源:plotting.go
示例6: Set
// Set copies states
// Note: 1) this and other states must have been pre-allocated with the same sizes
// 2) this method does not check for errors
func (o *OnedState) Set(other *OnedState) {
o.Sig = other.Sig
o.Dgam = other.Dgam
o.Loading = other.Loading
chk.IntAssert(len(o.Alp), len(other.Alp))
chk.IntAssert(len(o.Phi), len(other.Phi))
copy(o.Alp, other.Alp)
copy(o.Phi, other.Phi)
o.F = other.F
}
开发者ID:PatrickSchm,项目名称:gofem,代码行数:13,代码来源:onedstate.go
示例7: Test_mylab09
func Test_mylab09(tst *testing.T) {
//verbose()
chk.PrintTitle("mylab09. arg min and max")
u := []float64{1, 2, 3, -5, 60, -10, 8}
imin, imax := DblArgMinMax(u)
io.Pforan("imin = %v (5)\n", imin)
io.Pforan("imax = %v (4)\n", imax)
chk.IntAssert(imin, 5)
chk.IntAssert(imax, 4)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:12,代码来源:t_mylab_test.go
示例8: SetIniIvs
// SetIniIvs sets initial ivs for given values in sol and ivs map
func (o *ElemUP) SetIniIvs(sol *Solution, ivs map[string][]float64) (err error) {
// set p-element first
err = o.P.SetIniIvs(sol, nil)
if err != nil {
return
}
// initial stresses given
if _, okk := ivs["svT"]; okk {
// total vertical stresses and K0
nip := len(o.U.IpsElem)
svT := ivs["svT"]
K0s := ivs["K0"]
chk.IntAssert(len(svT), nip)
chk.IntAssert(len(K0s), 1)
K0 := K0s[0]
// for each integration point
sx := make([]float64, nip)
sy := make([]float64, nip)
sz := make([]float64, nip)
for i, ip := range o.U.IpsElem {
// compute pl @ ip
err = o.P.Cell.Shp.CalcAtIp(o.P.X, ip, false)
if err != nil {
return
}
pl := 0.0
for m := 0; m < o.P.Cell.Shp.Nverts; m++ {
pl += o.P.Cell.Shp.S[m] * sol.Y[o.P.Pmap[m]]
}
// compute effective stresses
p := pl * o.P.States[i].A_sl
svE := svT[i] + p
shE := K0 * svE
sx[i], sy[i], sz[i] = shE, svE, shE
if o.Ndim == 3 {
sx[i], sy[i], sz[i] = shE, shE, svE
}
}
ivs = map[string][]float64{"sx": sx, "sy": sy, "sz": sz}
}
// set u-element
return o.U.SetIniIvs(sol, ivs)
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:51,代码来源:e_up.go
示例9: Test_hist01
func Test_hist01(tst *testing.T) {
//verbose()
chk.PrintTitle("hist01")
lims := []float64{0, 1, 2, 3, 4, 5}
hist := Histogram{Stations: lims}
idx := hist.FindBin(-3.3)
chk.IntAssert(idx, -1)
idx = hist.FindBin(7.0)
chk.IntAssert(idx, -1)
for i, x := range lims {
idx = hist.FindBin(x)
io.Pforan("x=%g idx=%d\n", x, idx)
if i < len(lims)-1 {
chk.IntAssert(idx, i)
} else {
chk.IntAssert(idx, -1)
}
}
idx = hist.FindBin(0.5)
chk.IntAssert(idx, 0)
idx = hist.FindBin(1.5)
chk.IntAssert(idx, 1)
idx = hist.FindBin(2.5)
chk.IntAssert(idx, 2)
idx = hist.FindBin(3.99999999999999)
chk.IntAssert(idx, 3)
idx = hist.FindBin(4.999999)
chk.IntAssert(idx, 4)
hist.Count([]float64{
0, 0.1, 0.2, 0.3, 0.9, // 5
1, 1, 1, 1.2, 1.3, 1.4, 1.5, 1.99, // 8
2, 2.5, // 2
3, 3.5, // 2
4.1, 4.5, 4.9, // 3
-3, -2, -1,
5, 6, 7, 8,
}, true)
io.Pforan("counts = %v\n", hist.Counts)
chk.Ints(tst, "counts", hist.Counts, []int{5, 8, 2, 2, 3})
labels := hist.GenLabels("%g")
io.Pforan("labels = %v\n", labels)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:54,代码来源:t_hist_test.go
示例10: Test_nurbs03
func Test_nurbs03(tst *testing.T) {
//verbose()
chk.PrintTitle("nurbs03")
// NURBS
b := FactoryNurbs1dCurveA()
elems := b.Elements()
nbasis := b.GetElemNumBasis()
io.Pforan("nbasis = %v\n", nbasis)
chk.IntAssert(nbasis, 4) // orders := (3,) => nbasis = (3+1) = 4
// check basis and elements
chk.Ints(tst, "elem[0]", elems[0], []int{3, 4})
chk.Ints(tst, "elem[1]", elems[1], []int{4, 5})
chk.Ints(tst, "elem[2]", elems[2], []int{5, 6})
chk.Ints(tst, "ibasis0", b.IndBasis(elems[0]), []int{0, 1, 2, 3})
chk.Ints(tst, "ibasis1", b.IndBasis(elems[1]), []int{1, 2, 3, 4})
chk.Ints(tst, "ibasis2", b.IndBasis(elems[2]), []int{2, 3, 4, 5})
// refine NURBS
c := b.Krefine([][]float64{
{0.15, 0.5, 0.85},
})
// plot
if chk.Verbose {
PlotNurbs("/tmp/gosl/gm", "nurbs03a.png", b, 41, true, nil)
PlotTwoNurbs("/tmp/gosl/gm", "nurbs03b.png", b, c, 41, true, nil)
}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:31,代码来源:t_nurbs_test.go
示例11: RouletteSelect
// RouletteSelect selects n individuals
// Input:
// cumprob -- cumulated probabilities (from sorted population)
// sample -- a list of random numbers; can be nil
// Output:
// selinds -- selected individuals (indices). len(selinds) == nsel
func RouletteSelect(selinds []int, cumprob []float64, sample []float64) {
nsel := len(selinds)
chk.IntAssertLessThanOrEqualTo(nsel, len(cumprob))
if sample == nil {
var s float64
for i := 0; i < nsel; i++ {
s = rand.Float64()
for j, m := range cumprob {
if m > s {
selinds[i] = j
break
}
}
}
return
}
chk.IntAssert(len(sample), nsel)
for i, s := range sample {
for j, m := range cumprob {
if m > s {
selinds[i] = j
break
}
}
}
}
开发者ID:postfix,项目名称:goga-1,代码行数:32,代码来源:selection.go
示例12: Test_mylab09
func Test_mylab09(tst *testing.T) {
//verbose()
chk.PrintTitle("mylab09. arg min and max and L2norm")
u := []float64{1, 2, 3, -5, 60, -10, 8}
imin, imax := DblArgMinMax(u)
io.Pforan("imin = %v (5)\n", imin)
io.Pforan("imax = %v (4)\n", imax)
chk.IntAssert(imin, 5)
chk.IntAssert(imax, 4)
v := []float64{0, 1, 8, 0, -1, 3, 4}
d := L2norm(u, v)
io.Pforan("d = %v\n", d)
chk.Scalar(tst, "L2(u,v)", 1e-17, d, 62.912637840103322)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:17,代码来源:t_mylab_test.go
示例13: Test_nurbs01
func Test_nurbs01(tst *testing.T) {
//verbose()
chk.PrintTitle("nurbs01")
msh, err := ReadMsh("data", "nurbs01.msh", 0)
if err != nil {
tst.Errorf("test failed:\n%v", err)
return
}
for _, cell := range msh.Cells {
p0, p1 := cell.Shp.Nurbs.Ord(0), cell.Shp.Nurbs.Ord(1)
io.Pfcyan("cell # %d : NURBS orders = (%d,%d)\n", cell.Id, p0, p1)
chk.IntAssert(p0, 2)
chk.IntAssert(p1, 2)
}
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:18,代码来源:t_nurbs_test.go
示例14: CumSum
// CumSum returns the cumulative sum of the elements in p
// Input:
// p -- values
// Output:
// cs -- cumulated sum; pre-allocated with len(cs) == len(p)
func CumSum(cs, p []float64) {
if len(p) < 1 {
return
}
chk.IntAssert(len(cs), len(p))
cs[0] = p[0]
for i := 1; i < len(p); i++ {
cs[i] = cs[i-1] + p[i]
}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:15,代码来源:mylab.go
示例15: Point
// Point returns the x-y-z coordinates of a point on Bezier curve
func (o *BezierQuad) Point(C []float64, t float64) {
if len(o.Q) != 3 {
chk.Panic("Point: quadratic Bezier must be initialised first (with 3 control points)")
}
ndim := len(o.Q[0])
chk.IntAssert(len(C), ndim)
for i := 0; i < ndim; i++ {
C[i] = (1.0-t)*(1.0-t)*o.Q[0][i] + 2.0*t*(1.0-t)*o.Q[1][i] + t*t*o.Q[2][i]
}
return
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:12,代码来源:bezier.go
示例16: ConnectSet
// ConnectSet connects set of parameters
func (o *Prms) ConnectSet(V []*float64, names []string, caller string) (err string) {
chk.IntAssert(len(V), len(names))
for i, name := range names {
prm := o.Find(name)
if prm == nil {
return io.Sf("cannot find parameter named %q as requested by %q\n", name, caller)
}
prm.Connect(V[i])
}
return
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:12,代码来源:prms.go
示例17: Test_hist02
func Test_hist02(tst *testing.T) {
//verbose()
chk.PrintTitle("hist02")
lims := []int{0, 1, 2, 3, 4, 5}
hist := IntHistogram{Stations: lims}
idx := hist.FindBin(-3)
chk.IntAssert(idx, -1)
idx = hist.FindBin(7)
chk.IntAssert(idx, -1)
for i, x := range lims {
idx = hist.FindBin(x)
io.Pforan("x=%g idx=%d\n", x, idx)
if i < len(lims)-1 {
chk.IntAssert(idx, i)
} else {
chk.IntAssert(idx, -1)
}
}
hist.Count([]int{
0, 0, 0, 0, 0, // 5
1, 1, 1, 1, 1, 1, 1, 1, // 8
2, 2, // 2
3, 3, // 2
4, 4, 4, // 3
-3, -2, -1,
5, 6, 7, 8,
}, true)
io.Pforan("counts = %v\n", hist.Counts)
chk.Ints(tst, "counts", hist.Counts, []int{5, 8, 2, 2, 3})
labels := hist.GenLabels("%d")
io.Pforan("labels = %v\n", labels)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:39,代码来源:t_hist_test.go
示例18: DblsParetoMinProb
// DblsParetoMinProb compares two vectors using Pareto's optimal criterion
// φ ∃ [0,1] is a scaling factor that helps v win even if it's not smaller.
// If φ==0, deterministic analysis is carried out. If φ==1, probabilistic analysis is carried out.
// As φ → 1, v "gets more help".
// Note: (1) minimum dominates (is better)
// (2) v dominates if !u_dominates
func DblsParetoMinProb(u, v []float64, φ float64) (u_dominates bool) {
chk.IntAssert(len(u), len(v))
var pu, pv float64
for i := 0; i < len(u); i++ {
pu += ProbContestSmall(u[i], v[i], φ)
pv += ProbContestSmall(v[i], u[i], φ)
}
pu /= float64(len(u))
if FlipCoin(pu) {
u_dominates = true
}
return
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:19,代码来源:pareto.go
示例19: Test_cubiceq02
func Test_cubiceq02(tst *testing.T) {
//verbose()
chk.PrintTitle("cubiceq02. y(x) = x³ + x²")
a, b, c := 1.0, 0.0, 0.0
x1, x2, x3, nx := EqCubicSolveReal(a, b, c)
io.Pforan("\na=%v b=%v c=%v\n", a, b, c)
io.Pfcyan("nx=%v\n", nx)
io.Pfcyan("x1=%v x2=%v x3=%v\n", x1, x2, x3)
chk.IntAssert(nx, 2)
chk.Scalar(tst, "x1", 1e-17, x1, -1)
chk.Scalar(tst, "x2", 1e-17, x2, 0)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:14,代码来源:t_equations_test.go
示例20: SimpleOutput
// SimpleOutput implements a simple output function
func SimpleOutput(first bool, dx, x float64, y []float64, args ...interface{}) (err error) {
chk.IntAssert(len(args), 1)
res := args[0].(*Results)
res.Dx = append(res.Dx, dx)
res.X = append(res.X, x)
ndim := len(y)
if len(res.Y) == 0 {
res.Y = utl.DblsAlloc(ndim, 0)
}
for j := 0; j < ndim; j++ {
res.Y[j] = append(res.Y[j], y[j])
}
return
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:15,代码来源:plotting.go
注:本文中的github.com/cpmech/gosl/chk.IntAssert函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论