本文整理匯總了Golang中github.com/henrylee2cn/algorithm/cvx/sets.FloatMatrixSet.Append方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrixSet.Append方法的具體用法?Golang FloatMatrixSet.Append怎麽用?Golang FloatMatrixSet.Append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/henrylee2cn/algorithm/cvx/sets.FloatMatrixSet
的用法示例。
在下文中一共展示了FloatMatrixSet.Append方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: coneqp_solver
//.........這裏部分代碼省略.........
sol.PrimalInfeasibility = pres
sol.DualInfeasibility = dres
sol.PrimalSlack = 0.0
sol.DualSlack = 0.0
return
}
x = q.Copy()
y = b.Copy()
s = matrix.FloatZeros(cdim, 1)
z = matrix.FloatZeros(cdim, 1)
checkpnt.AddVerifiable("x", x)
checkpnt.AddVerifiable("y", y)
checkpnt.AddMatrixVar("s", s)
checkpnt.AddMatrixVar("z", z)
var ts, tz, nrms, nrmz float64
if initvals == nil {
// Factor
//
// [ 0 A' G' ]
// [ A 0 0 ].
// [ G 0 -I ]
//
W = sets.NewFloatSet("d", "di", "v", "beta", "r", "rti")
W.Set("d", matrix.FloatOnes(dims.At("l")[0], 1))
W.Set("di", matrix.FloatOnes(dims.At("l")[0], 1))
W.Set("beta", matrix.FloatOnes(len(dims.At("q")), 1))
for _, n := range dims.At("q") {
vm := matrix.FloatZeros(n, 1)
vm.SetIndex(0, 1.0)
W.Append("v", vm)
}
for _, n := range dims.At("s") {
W.Append("r", matrix.FloatIdentity(n))
W.Append("rti", matrix.FloatIdentity(n))
}
checkpnt.AddScaleVar(W)
f, err = kktsolver(W)
if err != nil {
s := fmt.Sprintf("kkt error: %s", err)
err = errors.New("3: Rank(A) < p or Rank([P; G; A]) < n : " + s)
return
}
// Solve
//
// [ P A' G' ] [ x ] [ -q ]
// [ A 0 0 ] * [ y ] = [ b ].
// [ G 0 -I ] [ z ] [ h ]
mCopy(q, x)
x.Scal(-1.0)
mCopy(b, y)
blas.Copy(h, z)
checkpnt.Check("00init", 1)
err = f(x, y, z)
if err != nil {
s := fmt.Sprintf("kkt error: %s", err)
err = errors.New("4: Rank(A) < p or Rank([P; G; A]) < n : " + s)
return
}
blas.Copy(z, s)
blas.ScalFloat(s, -1.0)
checkpnt.Check("05init", 1)
示例2: conelp_solver
//.........這裏部分代碼省略.........
// these are singleton matrix
dkappa := matrix.FloatValue(0.0)
dtau := matrix.FloatValue(0.0)
checkpnt.AddVerifiable("x", x)
checkpnt.AddMatrixVar("s", s)
checkpnt.AddMatrixVar("z", z)
checkpnt.AddVerifiable("dx", dx)
checkpnt.AddMatrixVar("ds", ds)
checkpnt.AddMatrixVar("dz", dz)
checkpnt.Check("00init", 1)
var W *sets.FloatMatrixSet
var f KKTFuncVar
if primalstart == nil || dualstart == nil {
// Factor
//
// [ 0 A' G' ]
// [ A 0 0 ].
// [ G 0 -I ]
//
W = sets.NewFloatSet("d", "di", "v", "beta", "r", "rti")
dd := dims.At("l")[0]
mat := matrix.FloatOnes(dd, 1)
W.Set("d", mat)
mat = matrix.FloatOnes(dd, 1)
W.Set("di", mat)
dq := len(dims.At("q"))
W.Set("beta", matrix.FloatOnes(dq, 1))
for _, n := range dims.At("q") {
vm := matrix.FloatZeros(n, 1)
vm.SetIndex(0, 1.0)
W.Append("v", vm)
}
for _, n := range dims.At("s") {
W.Append("r", matrix.FloatIdentity(n))
W.Append("rti", matrix.FloatIdentity(n))
}
f, err = kktsolver(W)
if err != nil {
fmt.Printf("kktsolver error: %s\n", err)
return
}
checkpnt.AddScaleVar(W)
}
checkpnt.Check("05init", 5)
if primalstart == nil {
// minimize || G * x - h ||^2
// subject to A * x = b
//
// by solving
//
// [ 0 A' G' ] [ x ] [ 0 ]
// [ A 0 0 ] * [ dy ] = [ b ].
// [ G 0 -I ] [ -s ] [ h ]
//blas.ScalFloat(x, 0.0)
//blas.CopyFloat(b, dy)
checkpnt.MinorPush(5)
x.Scal(0.0)
mCopy(b, dy)
blas.CopyFloat(h, s)
err = f(x, dy, s)
if err != nil {