当前位置: 首页>>代码示例>>Golang>>正文


Golang FloatMatrix.Minus方法代码示例

本文整理汇总了Golang中github.com/hrautila/matrix.FloatMatrix.Minus方法的典型用法代码示例。如果您正苦于以下问题:Golang FloatMatrix.Minus方法的具体用法?Golang FloatMatrix.Minus怎么用?Golang FloatMatrix.Minus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/hrautila/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)
	}
}
开发者ID:hrautila,项目名称:matops,代码行数:48,代码来源:house.go

示例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)
}
开发者ID:hrautila,项目名称:matops,代码行数:43,代码来源:house.go

示例3: error

func error(ref, val *matrix.FloatMatrix) (nrm float64, diff *matrix.FloatMatrix) {
	diff = ref.Minus(val)
	nrm = blas.Nrm2(diff).Float()
	return
}
开发者ID:hrautila,项目名称:go.opt,代码行数:5,代码来源:testgp.go


注:本文中的github.com/hrautila/matrix.FloatMatrix.Minus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。