本文整理汇总了Golang中github.com/cpmech/gosl/io.Pf函数的典型用法代码示例。如果您正苦于以下问题:Golang Pf函数的具体用法?Golang Pf怎么用?Golang Pf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: debug_print_up_results
func debug_print_up_results(d *Domain) {
io.Pf("\ntime = %23.10f\n", d.Sol.T)
for _, v := range d.Msh.Verts {
n := d.Vid2node[v.Id]
eqpl := n.GetEq("pl")
equx := n.GetEq("ux")
equy := n.GetEq("uy")
var pl, ux, uy float64
if eqpl >= 0 {
pl = d.Sol.Y[eqpl]
}
if equx >= 0 {
ux = d.Sol.Y[equx]
}
if equy >= 0 {
uy = d.Sol.Y[equy]
}
if math.Abs(pl) < 1e-13 {
pl = 0
}
if math.Abs(ux) < 1e-13 {
ux = 0
}
if math.Abs(uy) < 1e-13 {
uy = 0
}
io.Pf("%3d : pl=%23.10v ux=%23.10f uy=%23.10f\n", v.Id, pl, ux, uy)
}
}
示例2: PrintDeep3
// PrintDeep3 prints an array of array of array
func PrintDeep3(name string, A [][][]float64) {
io.Pf("%s = [\n", name)
for _, a := range A {
io.Pf(" %v\n", a)
}
io.Pf("]\n")
}
示例3: Test_mmMul01
func Test_mmMul01(tst *testing.T) {
//verbose()
chk.PrintTitle("mmMul01. MatrixMatrix multiplication")
a := [][]float64{
{1.0, 2.0, 3.0},
{0.5, 0.75, 1.5},
}
b := [][]float64{
{0.1, 0.5, 0.5, 0.75},
{0.2, 2.0, 2.0, 2.0},
{0.3, 0.5, 0.5, 0.5},
}
c := MatAlloc(2, 4)
MatMul(c, 1, a, b) // c := 1*a*b
io.Pf("a = %v\n", a)
io.Pf("b = %v\n", b)
io.Pf("c = %v\n", c)
ccor := [][]float64{
{1.4, 6.0, 6.0, 6.25},
{0.65, 2.5, 2.5, 2.625},
}
chk.Matrix(tst, "c", 1.0e-15, c, ccor)
}
示例4: 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))
}
}
示例5: 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))
}
}
示例6: check_constants
func check_constants(tst *testing.T, E, ν, Kcor, Gcor, lcor float64) {
K, G := Calc_K_from_Enu(E, ν), Calc_G_from_Enu(E, ν)
l := Calc_l_from_Enu(E, ν)
io.Pf("E = %v\n", E)
io.Pf("ν = %v\n", ν)
io.Pf("K = %v\n", K)
io.Pf("G = %v\n", G)
io.Pf("l = %v\n", l)
chk.Scalar(tst, "KfromEν", 1e-17, K, Kcor)
chk.Scalar(tst, "GfromEν", 1e-17, G, Gcor)
chk.Scalar(tst, "lfromEν", 1e-17, l, lcor)
EfromKG, νfromKG := Calc_E_from_KG(K, G), Calc_nu_from_KG(K, G)
chk.Scalar(tst, "EfromKG", 1e-17, EfromKG, E)
chk.Scalar(tst, "νfromKG", 1e-17, νfromKG, ν)
EfromlG, νfromlG := Calc_E_from_lG(l, G), Calc_nu_from_lG(l, G)
chk.Scalar(tst, "EfromlG", 1e-17, EfromlG, E)
chk.Scalar(tst, "νfromlG", 1e-17, νfromlG, ν)
EfromKν, GfromKν := Calc_E_from_Knu(K, ν), Calc_G_from_Knu(K, ν)
chk.Scalar(tst, "EfromKν", 1e-17, EfromKν, E)
chk.Scalar(tst, "GfromKν", 1e-17, GfromKν, G)
}
示例7: Print
func (e *Equations) Print() {
io.Pf("N1 = %v, N2 = %v, N = %v\n", e.N1, e.N2, e.N)
io.Pf("RF1 (unknown) =\n %v\n", e.RF1)
io.Pf("FR1 = \n%v\n", e.FR1)
io.Pf("RF2 (prescribed) =\n %v\n", e.RF2)
io.Pf("FR2 = \n%v\n", e.FR2)
}
示例8: 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")
}
}
示例9: main
func main() {
// input filename
_, fnkey := io.ArgToFilename(0, "frame2d", ".sim", true)
// simple problems
var opts []*goga.Optimiser
if fnkey == "simple" {
io.Pf("\n\n\n")
//P := []int{1}
P := utl.IntRange2(1, 19)
opts = make([]*goga.Optimiser, len(P))
for i, problem := range P {
opts[i] = solve_problem(fnkey, problem)
}
} else {
opts = []*goga.Optimiser{solve_problem(fnkey, 0)}
}
if opts[0].PlotSet1 {
return
}
if opts[0].Nsamples > 1 {
io.Pf("\n")
rpt := goga.NewTexReport(opts)
rpt.ShowDEC = false
rpt.Type = 4
rpt.TextSize = ""
rpt.Title = "FORM Reliability: " + fnkey
rpt.Fnkey = "rel-" + fnkey
rpt.Generate()
}
}
示例10: Test_invs04
func Test_invs04(tst *testing.T) {
//verbose()
chk.PrintTitle("invs04")
a := []float64{-10.0, -20.0, -30.0, 4.0 * SQ2, 5.0 * SQ2, 6.0 * SQ2}
at := Alloc2()
Man2Ten(at, a)
io.Pf("a = %v\n", a)
chk.Matrix(tst, "Man2Ten", 1e-17, at, [][]float64{
{-10, 4, 6},
{4, -20, 5},
{6, 5, -30},
})
b := []float64{-88, -77, -55, -3 * SQ2}
bt := Alloc2()
Man2Ten(bt, b)
io.Pf("b = %v\n", b)
chk.Matrix(tst, "Man2Ten", 1e-17, bt, [][]float64{
{-88, -3, 0},
{-3, -77, 0},
{0, 0, -55},
})
ver := chk.Verbose
run_invs_tests(tst, a, ver)
run_invs_tests(tst, b, ver)
}
示例11: Test_deep01
func Test_deep01(tst *testing.T) {
//verbose()
chk.PrintTitle("deep01")
a := Deep3alloc(3, 2, 4)
for i := 0; i < 3; i++ {
for j := 0; j < 2; j++ {
for k := 0; k < 4; k++ {
if math.Abs(a[i][j][k]) > 1e-17 {
tst.Errorf("[1;31ma[i][j][k] failed[0m")
}
}
}
}
io.Pf("a = %v\n", a)
b := Deep4alloc(3, 2, 1, 2)
for i := 0; i < 3; i++ {
for j := 0; j < 2; j++ {
for k := 0; k < 1; k++ {
for l := 0; l < 2; l++ {
if math.Abs(b[i][j][k][l]) > 1e-17 {
tst.Errorf("[1;31mb[i][j][k][l] failed[0m")
}
}
}
}
}
io.Pf("b = %v\n", b)
}
示例12: TestAbs
func TestAbs(result, expected, absolute_error float64, test_description string) (status int) {
switch {
case math.IsNaN(result) || math.IsNaN(expected):
status = NaN
case math.IsInf(result, 0) || math.IsInf(expected, 0):
status = Inf
case (expected > 0 && expected < DBL_MIN) || (expected < 0 && expected > -DBL_MIN):
status = NotEqual
default:
if math.Abs(result-expected) > absolute_error {
status = NotEqual
} else {
status = Equal
}
}
if test_description != "" {
io.Pf(test_description)
switch status {
case NaN:
io.Pf(" [1;31mNaN[0m\n %v observed\n %v expected. diff = %v\n", result, expected, result-expected)
case Inf:
io.Pf(" [1;31mInf[0m\n %v observed\n %v expected. diff = %v\n", result, expected, result-expected)
case Equal:
io.Pf(" [1;32mOk[0m\n %v observed\n %v expected. diff = %v\n", result, expected, result-expected)
case NotEqual:
io.Pf(" [1;31mError[0m\n %v observed\n %v expected. diff = %v\n", result, expected, result-expected)
}
}
return
}
示例13: Deep3Deserialize
// Deep3Deserialize deserializes an array of array of array in column-compressed format
// Example:
func Deep3Deserialize(I, P []int, S []float64, debug bool) (A [][][]float64) {
_, nrows, _, ncols := Deep3GetInfo(I, P, S, false)
A = make([][][]float64, nrows)
for i := 0; i < nrows; i++ {
A[i] = make([][]float64, ncols[i])
}
iprev := 0 // previous i
j := 0 // column index
for l, i := range I {
nitems := P[l+1] - P[l]
if i != iprev { // jumped to new column
j = 0
}
if debug {
io.Pf("l=%v i=%v nitems=%v j=%v\n", l, i, nitems, j)
}
for k, p := 0, P[l]; p < P[l+1]; k, p = k+1, p+1 {
if debug {
io.Pf(" k=%v p=%v s=%v\n", k, p, S[p])
}
if k == 0 {
A[i][j] = make([]float64, nitems)
}
A[i][j][k] = S[p]
}
iprev = i
j += 1
}
return
}
示例14: StatF
// StatF computes statistical information corresponding to objective function idxF
func StatF(o *Optimiser, idxF int, verbose bool) (fmin, fave, fmax, fdev float64, F []float64) {
nsamples := len(o.BestOvas[idxF])
if nsamples == 0 {
if verbose {
io.Pfred("there are no samples for statistical analysis\n")
}
return
}
F = make([]float64, nsamples)
if nsamples == 1 {
F[0] = o.BestOvas[idxF][0]
fmin, fave, fmax = F[0], F[0], F[0]
return
}
for i, f := range o.BestOvas[idxF] {
F[i] = f
}
fmin, fave, fmax, fdev = rnd.StatBasic(F, true)
if verbose {
str := "\n"
if len(o.RptFref) == o.Nova {
str = io.Sf(" (%g)\n", o.RptFref[idxF])
}
io.Pf("fmin = %g\n", fmin)
io.Pf("fave = %g"+str, fave)
io.Pf("fmax = %g\n", fmax)
io.Pf("fdev = %g\n", fdev)
o.fix_formatting_data()
io.Pf(rnd.BuildTextHist(nice(fmin, o.HistNdig)-o.HistDelFmin, nice(fmax, o.HistNdig)+o.HistDelFmax,
o.HistNsta, F, o.HistFmt, o.HistLen))
}
return
}
示例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])
}
}