本文整理匯總了Golang中github.com/henrylee2cn/algorithm/matrix.FloatMatrix.Minus方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrix.Minus方法的具體用法?Golang FloatMatrix.Minus怎麽用?Golang FloatMatrix.Minus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/henrylee2cn/algorithm/matrix.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.Minus方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: applyHHTo2x1
/*
* Applies a real elementary reflector H to a real m by n matrix A,
* from either the left or the right. H is represented in the form
*
* H = I - tau * ( 1 ) * ( 1 v.T )
* ( v )
*
* where tau is a real scalar and v is a real vector.
*
* If tau = 0, then H is taken to be the unit matrix.
*
* A is /a1\ a1 := a1 - w1
* \A2/ A2 := A2 - v*w1
* w1 := tau*(a1 + A2.T*v) if side == LEFT
* := tau*(a1 + A2*v) if side == RIGHT
*
* Intermediate work space w1 required as parameter, no allocation.
*/
func applyHHTo2x1(tau, v, a1, A2, w1 *matrix.FloatMatrix, flags Flags) {
tval := tau.GetAt(0, 0)
if tval == 0.0 {
return
}
// maybe with Scale(0.0), Axpy(w1, a1, 1.0)
a1.CopyTo(w1)
if flags&LEFT != 0 {
// w1 = a1 + A2.T*v
MVMult(w1, A2, v, 1.0, 1.0, TRANSA)
} else {
// w1 = a1 + A2*v
MVMult(w1, A2, v, 1.0, 1.0, NOTRANS)
}
// w1 = tau*w1
Scale(w1, tval)
// a1 = a1 - w1
a1.Minus(w1)
// A2 = A2 - v*w1
if flags&LEFT != 0 {
MVRankUpdate(A2, v, w1, -1.0)
} else {
MVRankUpdate(A2, w1, v, -1.0)
}
}
示例2: applyHouseholder
/* From LAPACK/dlarf.f
*
* Applies a real elementary reflector H to a real m by n matrix A,
* from either the left or the right. H is represented in the form
*
* H = I - tau * ( 1 ) * ( 1 v.T )
* ( v )
*
* where tau is a real scalar and v is a real vector.
*
* If tau = 0, then H is taken to be the unit matrix.
*
* A is /a1\ a1 := a1 - w1
* \A2/ A2 := A2 - v*w1
* w1 := tau*(a1 + A2.T*v) if side == LEFT
* := tau*(a1 + A2*v) if side == RIGHT
*
* Allocates/frees intermediate work space matrix w1.
*/
func applyHouseholder(tau, v, a1, A2 *matrix.FloatMatrix, flags Flags) {
tval := tau.GetAt(0, 0)
if tval == 0.0 {
return
}
w1 := a1.Copy()
if flags&LEFT != 0 {
// w1 = a1 + A2.T*v
MVMult(w1, A2, v, 1.0, 1.0, TRANSA)
} else {
// w1 = a1 + A2*v
MVMult(w1, A2, v, 1.0, 1.0, NOTRANS)
}
// w1 = tau*w1
Scale(w1, tval)
// a1 = a1 - w1
a1.Minus(w1)
// A2 = A2 - v*w1
MVRankUpdate(A2, v, w1, -1.0)
}
示例3: nrmError
func nrmError(ref, val *matrix.FloatMatrix) (nrm float64, diff *matrix.FloatMatrix) {
diff = ref.Minus(val)
nrm = blas.Nrm2(diff).Float()
return
}