本文整理汇总了Golang中github.com/rmera/gochem/v3.Matrix.Dot方法的典型用法代码示例。如果您正苦于以下问题:Golang Matrix.Dot方法的具体用法?Golang Matrix.Dot怎么用?Golang Matrix.Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rmera/gochem/v3.Matrix
的用法示例。
在下文中一共展示了Matrix.Dot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Projection
//Projection returns the projection of test in ref.
func Projection(test, ref *v3.Matrix) *v3.Matrix {
rr, _ := ref.Dims()
Uref := v3.Zeros(rr)
Uref.Unit(ref)
scalar := test.Dot(Uref) //math.Abs(la)*math.Cos(angle)
Uref.Scale(scalar, Uref)
return Uref
}
示例2: AntiProjection
//AntiProjection returns a vector in the direction of ref with the magnitude of
//a vector A would have if |test| was the magnitude of its projection
//in the direction of test.
func AntiProjection(test, ref *v3.Matrix) *v3.Matrix {
rr, _ := ref.Dims()
testnorm := test.Norm(0)
Uref := v3.Zeros(rr)
Uref.Unit(ref)
scalar := test.Dot(Uref)
scalar = (testnorm * testnorm) / scalar
Uref.Scale(scalar, Uref)
return Uref
}
示例3: Angle
//Angle takes 2 vectors and calculate the angle in radians between them
//It does not check for correctness or return errors!
func Angle(v1, v2 *v3.Matrix) float64 {
normproduct := v1.Norm(0) * v2.Norm(0)
dotprod := v1.Dot(v2)
argument := dotprod / normproduct
//Take care of floating point math errors
if math.Abs(argument-1) <= appzero {
argument = 1
} else if math.Abs(argument+1) <= appzero {
argument = -1
}
//fmt.Println(dotprod/normproduct,argument) //dotprod/normproduct, dotprod, normproduct,v1.TwoNorm(),v2.TwoNorm())
angle := math.Acos(argument)
if math.Abs(angle) <= appzero {
return 0.00
}
return angle
}