gonum.org/v1/gonum@v0.14.0/num/quat/conj.go (about) 1 // Copyright ©2018 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Copyright 2017 The Go Authors. All rights reserved. 6 // Use of this source code is governed by a BSD-style 7 // license that can be found in the LICENSE file. 8 9 package quat 10 11 // Conj returns the quaternion conjugate of q. 12 func Conj(q Number) Number { 13 return Number{Real: q.Real, Imag: -q.Imag, Jmag: -q.Jmag, Kmag: -q.Kmag} 14 } 15 16 // Inv returns the quaternion inverse of q. 17 func Inv(q Number) Number { 18 if IsInf(q) { 19 return zero 20 } 21 a := Abs(q) 22 return Scale(1/(a*a), Conj(q)) 23 }