本文整理匯總了Golang中github.com/hrautila/go/opt/matrix.FloatMatrix.FloatArray方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrix.FloatArray方法的具體用法?Golang FloatMatrix.FloatArray怎麽用?Golang FloatMatrix.FloatArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hrautila/go/opt/matrix.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.FloatArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GbtrsFloat
func GbtrsFloat(A, B *matrix.FloatMatrix, ipiv []int32, KL int, opts ...linalg.Option) error {
pars, err := linalg.GetParameters(opts...)
if err != nil {
return err
}
ind := linalg.GetIndexOpts(opts...)
ind.Kl = KL
err = checkGbtrs(ind, A, B, ipiv)
if err != nil {
return err
}
if ind.N == 0 || ind.Nrhs == 0 {
return nil
}
Aa := A.FloatArray()
Ba := B.FloatArray()
trans := linalg.ParamString(pars.Trans)
info := dgbtrs(trans, ind.N, ind.Kl, ind.Ku, ind.Nrhs,
Aa[ind.OffsetA:], ind.LDa, ipiv, Ba[ind.OffsetB:], ind.LDb)
if info != 0 {
return errors.New(fmt.Sprintf("Gbtrs: call error: %d", info))
}
return nil
}
示例2: TrsmFloat
// See function Trsm.
func TrsmFloat(A, B *matrix.FloatMatrix, alpha float64, opts ...linalg.Option) (err error) {
params, e := linalg.GetParameters(opts...)
if e != nil {
err = e
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level3_func(ind, ftrsm, A, B, nil, params)
if err != nil {
return
}
if ind.N == 0 || ind.M == 0 {
return
}
Aa := A.FloatArray()
Ba := B.FloatArray()
uplo := linalg.ParamString(params.Uplo)
transA := linalg.ParamString(params.TransA)
side := linalg.ParamString(params.Side)
diag := linalg.ParamString(params.Diag)
dtrsm(side, uplo, transA, diag, ind.M, ind.N, alpha,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb)
return
}
示例3: SyrkFloat
// See function Syrk.
func SyrkFloat(A, C *matrix.FloatMatrix, alpha, beta float64, opts ...linalg.Option) (err error) {
params, e := linalg.GetParameters(opts...)
if e != nil {
err = e
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level3_func(ind, fsyrk, A, nil, C, params)
if e != nil || err != nil {
return
}
if ind.N == 0 {
return
}
Aa := A.FloatArray()
Ca := C.FloatArray()
uplo := linalg.ParamString(params.Uplo)
trans := linalg.ParamString(params.Trans)
//diag := linalg.ParamString(params.Diag)
dsyrk(uplo, trans, ind.N, ind.K, alpha, Aa[ind.OffsetA:], ind.LDa, beta,
Ca[ind.OffsetC:], ind.LDc)
return
}
示例4: F2
func (p *FloorPlan) F2(x, z *matrix.FloatMatrix) (f, Df, H *matrix.FloatMatrix, err error) {
f, Df, err = p.F1(x)
x17 := matrix.FloatVector(x.FloatArray()[17:])
tmp := p.Amin.Div(x17.Pow(3.0))
tmp = z.Mul(tmp).Scale(2.0)
diag := matrix.FloatDiagonal(5, tmp.FloatArray()...)
H = matrix.FloatZeros(22, 22)
H.SetSubMatrix(17, 17, diag)
return
}
示例5: sinv
func sinv(x, y *matrix.FloatMatrix, dims *DimensionSet, mnl int) (err error) {
/*DEBUGGED*/
err = nil
// For the nonlinear and 'l' blocks:
//
// yk o\ xk = yk .\ xk.
ind := mnl + dims.At("l")[0]
blas.Tbsv(y, x, &la_.IOpt{"n", ind}, &la_.IOpt{"k", 0}, &la_.IOpt{"ldA", 1})
// For the 'q' blocks:
//
// [ l0 -l1' ]
// yk o\ xk = 1/a^2 * [ ] * xk
// [ -l1 (a*I + l1*l1')/l0 ]
//
// where yk = (l0, l1) and a = l0^2 - l1'*l1.
for _, m := range dims.At("q") {
aa := blas.Nrm2Float(y, &la_.IOpt{"n", m - 1}, &la_.IOpt{"offset", ind + 1})
ee := y.GetIndex(ind)
aa = (ee + aa) * (ee - aa)
cc := x.GetIndex(ind)
dd := blas.DotFloat(x, y, &la_.IOpt{"n", m - 1}, &la_.IOpt{"offsetx", ind + 1},
&la_.IOpt{"offsety", ind + 1})
x.SetIndex(ind, cc*ee-dd)
blas.ScalFloat(x, aa/ee, &la_.IOpt{"n", m - 1}, &la_.IOpt{"offset", ind + 1})
blas.AxpyFloat(y, x, dd/ee-cc, &la_.IOpt{"n", m - 1},
&la_.IOpt{"offsetx", ind + 1}, &la_.IOpt{"offsety", ind + 1})
blas.ScalFloat(x, 1.0/aa, &la_.IOpt{"n", m}, &la_.IOpt{"offset", ind})
ind += m
}
// For the 's' blocks:
//
// yk o\ xk = xk ./ gamma
//
// where gammaij = .5 * (yk_i + yk_j).
ind2 := ind
for _, m := range dims.At("s") {
for j := 0; j < m; j++ {
u := matrix.FloatVector(y.FloatArray()[ind2+j : ind2+m])
u.Add(y.GetIndex(ind2 + j))
u.Scale(0.5)
blas.Tbsv(u, x, &la_.IOpt{"n", m - j}, &la_.IOpt{"k", 0}, &la_.IOpt{"lda", 1},
&la_.IOpt{"offsetx", ind + j*(m+1)})
}
ind += m * m
ind2 += m
}
return
}
示例6: ScalFloat
// See function Scal.
func ScalFloat(X *matrix.FloatMatrix, alpha float64, opts ...linalg.Option) (err error) {
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fscal, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.FloatArray()
dscal(ind.Nx, alpha, Xa[ind.OffsetX:], ind.IncX)
return
}
示例7: maxStep
// Returns min {t | x + t*e >= 0}, where e is defined as follows
//
// - For the nonlinear and 'l' blocks: e is the vector of ones.
// - For the 'q' blocks: e is the first unit vector.
// - For the 's' blocks: e is the identity matrix.
//
// When called with the argument sigma, also returns the eigenvalues
// (in sigma) and the eigenvectors (in x) of the 's' components of x.
func maxStep(x *matrix.FloatMatrix, dims *DimensionSet, mnl int, sigma *matrix.FloatMatrix) (rval float64, err error) {
/*DEBUGGED*/
rval = 0.0
err = nil
t := make([]float64, 0, 10)
ind := mnl + dims.Sum("l")
if ind > 0 {
t = append(t, -minvec(x.FloatArray()[:ind]))
}
for _, m := range dims.At("q") {
if m > 0 {
v := blas.Nrm2Float(x, &la_.IOpt{"offset", ind + 1}, &la_.IOpt{"n", m - 1})
v -= x.GetIndex(ind)
t = append(t, v)
}
ind += m
}
var Q *matrix.FloatMatrix
var w *matrix.FloatMatrix
ind2 := 0
if sigma == nil && len(dims.At("s")) > 0 {
mx := dims.Max("s")
Q = matrix.FloatZeros(mx, mx)
w = matrix.FloatZeros(mx, 1)
}
for _, m := range dims.At("s") {
if sigma == nil {
blas.Copy(x, Q, &la_.IOpt{"offsetx", ind}, &la_.IOpt{"n", m * m})
err = lapack.SyevrFloat(Q, w, nil, 0.0, nil, []int{1, 1}, la_.OptRangeInt,
&la_.IOpt{"n", m}, &la_.IOpt{"lda", m})
if m > 0 {
t = append(t, -w.GetIndex(0))
}
} else {
err = lapack.SyevdFloat(x, sigma, la_.OptJobZValue, &la_.IOpt{"n", m},
&la_.IOpt{"lda", m}, &la_.IOpt{"offseta", ind}, &la_.IOpt{"offsetw", ind2})
if m > 0 {
t = append(t, -sigma.GetIndex(ind2))
}
}
ind += m * m
ind2 += m
}
if len(t) > 0 {
rval = maxvec(t)
}
return
}
示例8: GesvdFloat
func GesvdFloat(A, S, U, Vt *matrix.FloatMatrix, opts ...linalg.Option) error {
pars, err := linalg.GetParameters(opts...)
if err != nil {
return err
}
ind := linalg.GetIndexOpts(opts...)
err = checkGesvd(ind, pars, A, S, U, Vt)
if err != nil {
return err
}
if ind.M == 0 || ind.N == 0 {
return nil
}
Aa := A.FloatArray()
Sa := S.FloatArray()
var Ua, Va []float64
Ua = nil
Va = nil
if U != nil {
Ua = U.FloatArray()[ind.OffsetU:]
}
if Vt != nil {
Va = Vt.FloatArray()[ind.OffsetVt:]
}
info := dgesvd(linalg.ParamString(pars.Jobu), linalg.ParamString(pars.Jobvt),
ind.M, ind.N, Aa[ind.OffsetA:], ind.LDa, Sa[ind.OffsetS:], Ua, ind.LDu, Va, ind.LDvt)
if info != 0 {
return errors.New("GesvdFloat not implemented yet")
}
return nil
}
示例9: CopyFloat
// See function Copy.
func CopyFloat(X, Y *matrix.FloatMatrix, opts ...linalg.Option) (err error) {
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fcopy, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.FloatArray()
Ya := Y.FloatArray()
dcopy(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
return
}
示例10: AsumFloat
// See function Asum.
func AsumFloat(X *matrix.FloatMatrix, opts ...linalg.Option) (v float64) {
v = math.NaN()
ind := linalg.GetIndexOpts(opts...)
err := check_level1_func(ind, fasum, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
v = 0.0
return
}
Xa := X.FloatArray()
v = dasum(ind.Nx, Xa[ind.OffsetX:], ind.IncX)
return
}
示例11: DotFloat
// See functin Dot.
func DotFloat(X, Y *matrix.FloatMatrix, opts ...linalg.Option) (v float64) {
v = math.NaN()
ind := linalg.GetIndexOpts(opts...)
err := check_level1_func(ind, fdot, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
v = 0.0
return
}
Xa := X.FloatArray()
Ya := Y.FloatArray()
v = ddot(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
return
}
示例12: GbtrfFloat
func GbtrfFloat(A *matrix.FloatMatrix, ipiv []int32, M, KL int, opts ...linalg.Option) error {
ind := linalg.GetIndexOpts(opts...)
ind.M = M
ind.Kl = KL
err := checkGbtrf(ind, A, ipiv)
if err != nil {
return err
}
if ind.M == 0 || ind.N == 0 {
return nil
}
Aa := A.FloatArray()
info := dgbtrf(ind.M, ind.N, ind.Kl, ind.Ku, Aa[ind.OffsetA:], ind.LDa, ipiv)
if info != 0 {
return errors.New(fmt.Sprintf("Gbtrf call error: %d", info))
}
return nil
}
示例13: PotrfFloat
func PotrfFloat(A *matrix.FloatMatrix, opts ...linalg.Option) error {
pars, err := linalg.GetParameters(opts...)
if err != nil {
return err
}
ind := linalg.GetIndexOpts(opts...)
err = checkPotrf(ind, A)
if ind.N == 0 {
return nil
}
Aa := A.FloatArray()
uplo := linalg.ParamString(pars.Uplo)
info := dpotrf(uplo, ind.N, Aa[ind.OffsetA:], ind.LDa)
if info != 0 {
return errors.New(fmt.Sprintf("Potrf: call error %d", info))
}
return nil
}
示例14: GbsvFloat
func GbsvFloat(A, B *matrix.FloatMatrix, ipiv []int32, kl int, opts ...linalg.Option) error {
ind := linalg.GetIndexOpts(opts...)
ind.Kl = kl
err := checkGbsv(ind, A, B, ipiv)
if err != nil {
return err
}
if ind.N == 0 || ind.Nrhs == 0 {
return nil
}
Aa := A.FloatArray()
Ba := B.FloatArray()
info := dgbsv(ind.N, ind.Kl, ind.Ku, ind.Nrhs, Aa[ind.OffsetA:], ind.LDa,
ipiv, Ba[ind.OffsetB:], ind.LDb)
if info != 0 {
return errors.New(fmt.Sprintf("Gbsv call error: %d", info))
}
return nil
}
示例15: SyrFloat
// See function Syr.
func SyrFloat(X, A *matrix.FloatMatrix, alpha float64, opts ...linalg.Option) (err error) {
var params *linalg.Parameters
params, err = linalg.GetParameters(opts...)
if err != nil {
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level2_func(ind, fsyr, X, nil, A, params)
if err != nil {
return
}
if ind.N == 0 {
return
}
Xa := X.FloatArray()
Aa := A.FloatArray()
uplo := linalg.ParamString(params.Uplo)
dsyr(uplo, ind.N, alpha, Xa[ind.OffsetX:], ind.IncX, Aa[ind.OffsetA:], ind.LDa)
return
}