import Foundation

struct Quaternion {
  var a, b, c, d: Double

  static let i = Quaternion(a: 0, b: 1, c: 0, d: 0)
  static let j = Quaternion(a: 0, b: 0, c: 1, d: 0)
  static let k = Quaternion(a: 0, b: 0, c: 0, d: 1)
}
extension Quaternion: Equatable {
  static func ==(lhs: Quaternion, rhs: Quaternion) -> Bool {
    return (lhs.a, lhs.b, lhs.c, lhs.d) == (rhs.a, rhs.b, rhs.c, rhs.d)
  }
}
extension Quaternion: ExpressibleByIntegerLiteral {
  init(integerLiteral: Double) {
    a = integerLiteral
    b = 0
    c = 0
    d = 0
  }
}
extension Quaternion: Numeric {
  var magnitude: Double {
    return norm
  }
  init?<T>(exactly: T) {