示例#1
0
// Divide
func (a Scalar) Div_S(b S) S {
	var x, y big.Float
	x = big.Float(a)
	y = big.Float(b.(Scalar))
	z := x.Quo(&x, &y)
	return (Scalar)(*z)
}
示例#2
0
// Subtract
func (a Scalar) Sub_S(b S) S {
	var x, y big.Float
	x = big.Float(a)
	y = big.Float(b.(Scalar))
	z := x.Sub(&x, &y)
	return (Scalar)(*z)
}
示例#3
0
// Add
func (a Scalar) Add_S(b S) S {
	var x, y big.Float
	x = big.Float(a)
	y = big.Float(b.(Scalar))
	z := x.Add(&x, &y)
	return (Scalar)(*z)
}
示例#4
0
// Multiply
func (a Scalar) Mul_S(b S) S {
	var x, y big.Float
	x = big.Float(a)
	y = big.Float(b.(Scalar))
	z := x.Mul(&x, &y)
	return (Scalar)(*z)

}
示例#5
0
// Divide Scalar
func (a *Vector) DivSc_V(pos int, b S) {
	x := big.Float(a.Elem[pos])
	y := big.Float(b.(Scalar))
	x.Quo(&x, &y)
	a.Elem[pos] = Scalar(x)
}
示例#6
0
// Divide
func (a *Vector) Div_V(pos int, b V) {
	x := big.Float(a.Elem[pos])
	y := big.Float(b.(*Vector).Elem[pos])
	x.Quo(&x, &y)
	a.Elem[pos] = Scalar(x)
}
示例#7
0
// Convert Scalar to a float
func (a Scalar) ToFloat() float64 {
	x := big.Float(a)
	ret, _ := x.Float64()
	return ret
}
示例#8
0
// Negate a vector element
func (a *Vector) Neg_V(pos int) {
	x := big.Float(a.Elem[pos])
	x.Neg(&x)
	a.Elem[pos] = Scalar(x)
}
示例#9
0
// Dot product of two vectors
func (a *Vector) Dot(b *Vector) big.Float {
	return big.Float(Dot_V(a, b).(Scalar))
}