本文整理匯總了Golang中github.com/hrautila/cmat.FloatMatrix.GetAtUnsafe方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrix.GetAtUnsafe方法的具體用法?Golang FloatMatrix.GetAtUnsafe怎麽用?Golang FloatMatrix.GetAtUnsafe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hrautila/cmat.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.GetAtUnsafe方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: rationalBackward
// Compute rational approximation backward
func rationalBackward(z, delta *cmat.FloatMatrix, start, end int) (float64, float64) {
var val, dval float64
val, dval = 0.0, 0.0
for i := end - 1; i >= start; i-- {
dj := delta.GetAtUnsafe(i)
zj := z.GetAtUnsafe(i)
tval := zj / dj
val = val + zj*tval
dval = dval + tval*tval
}
return val, dval
}
示例2: bdQLzero
/*
* Bidiagonal bottom to top implicit zero shift QL sweep
*/
func bdQLzero(D, E, Cr, Sr, Cl, Sl *cmat.FloatMatrix, saves bool) int {
var d1, e1, d2, cosr, sinr, cosl, sinl, r float64
N := D.Len()
d1 = D.GetAtUnsafe(N - 1)
cosr = 1.0
cosl = 1.0
for k := N - 1; k > 0; k-- {
e1 = E.GetAtUnsafe(k - 1)
d2 = D.GetAtUnsafe(k - 1)
cosr, sinr, r = ComputeGivens(d1*cosr, e1)
if k < N-1 {
E.SetAtUnsafe(k, sinl*r)
}
cosl, sinl, r = ComputeGivens(cosl*r, sinr*d2)
D.SetAtUnsafe(k, r)
d1 = d2
if saves {
Cr.SetAtUnsafe(k-1, cosr)
Sr.SetAtUnsafe(k-1, -sinr)
Cl.SetAtUnsafe(k-1, cosl)
Sl.SetAtUnsafe(k-1, -sinl)
}
}
d2 = cosr * D.GetAtUnsafe(0)
D.SetAtUnsafe(0, d2*cosl)
E.SetAtUnsafe(0, d2*sinl)
return N - 1
}
示例3: bdQLsweep
/*
* Bidiagonal bottom to top implicit QL sweep
*/
func bdQLsweep(D, E, Cr, Sr, Cl, Sl *cmat.FloatMatrix, f0, g0 float64, saves bool) int {
var d1, e1, d2, e2, f, g, cosr, sinr, cosl, sinl, r float64
N := D.Len()
d1 = D.GetAtUnsafe(N - 1)
e1 = E.GetAtUnsafe(N - 2)
f = f0
g = g0
for k := N - 1; k > 0; k-- {
d2 = D.GetAtUnsafe(k - 1)
cosr, sinr, r = ComputeGivens(f, g)
if k < N-1 {
E.SetAt(k, r)
}
f, e1 = RotateGivens(d1, e1, cosr, sinr)
g, d2 = RotateGivens(0.0, d2, cosr, sinr)
cosl, sinl, r = ComputeGivens(f, g)
d1 = r
f, d2 = RotateGivens(e1, d2, cosl, sinl)
if k > 1 {
e2 = E.GetAtUnsafe(k - 2)
g, e2 = RotateGivens(0.0, e2, cosl, sinl)
E.SetAtUnsafe(k-2, e2)
}
D.SetAtUnsafe(k, d1)
//D.SetAtUnsafe(k-1, d2)
d1 = d2
e1 = e2
if saves {
Cr.SetAtUnsafe(k-1, cosr)
Sr.SetAtUnsafe(k-1, -sinr)
Cl.SetAtUnsafe(k-1, cosl)
Sl.SetAtUnsafe(k-1, -sinl)
}
}
D.SetAtUnsafe(0, d1)
E.SetAt(0, f)
return N - 1
}
示例4: trdQLsweep
/*
* Tridiagonal bottom to top implicit QL sweep
*/
func trdQLsweep(D, E, Cr, Sr *cmat.FloatMatrix, f0, g0 float64, saves bool) int {
var d0, e0, e1, d1, e0r, e0c, w0, f, g, cosr, sinr, r float64
N := D.Len()
d0 = D.GetAtUnsafe(N - 1)
e0 = E.GetAtUnsafe(N - 2)
f = f0
g = g0
for k := N - 1; k > 0; k-- {
d1 = D.GetAtUnsafe(k - 1)
cosr, sinr, r = ComputeGivens(f, g)
if k < N-1 {
E.SetAtUnsafe(k, r)
}
d0, e0c = RotateGivens(d0, e0, cosr, sinr)
e0r, d1 = RotateGivens(e0, d1, cosr, sinr)
d0, e0r = RotateGivens(d0, e0r, cosr, sinr)
e0c, d1 = RotateGivens(e0c, d1, cosr, sinr)
// here: e0c == e0r
if k > 1 {
e1 = E.GetAtUnsafe(k - 2)
w0, e1 = RotateGivens(0.0, e1, cosr, sinr)
}
D.SetAtUnsafe(k, d0)
d0 = d1
e0 = e1
f = e0r
g = w0
if saves {
Cr.SetAtUnsafe(k-1, cosr)
Sr.SetAtUnsafe(k-1, -sinr)
}
}
D.SetAtUnsafe(0, d0)
E.SetAtUnsafe(0, e0c)
return N - 1
}