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


Golang FloatMatrix.GetAtUnsafe方法代码示例

本文整理汇总了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
}
开发者ID:hrautila,项目名称:gomas,代码行数:13,代码来源:trdsec.go

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

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

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


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