本文整理匯總了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
}