@swift-4.2.4
import SwiftyMath typealias AlgebraicExtension<F, p: IrrPolynomialTP> = PolynomialQuotientRing<p> where p.CoeffRing == F typealias Q = RationalNumber typealias Qx = xPolynomial<Q> let x = Qx.indeterminate struct p1: IrrPolynomialTP { static let value = Qx(coeffs: -2, 0, 1) } typealias A = AlgebraicExtension<Q, p1> // A = Q[x]/p1 let α = A(x) print(α) print(α * α) print(α * α == 2) struct p2: IrrPolynomialTP { static let value = xPolynomial<Q>(coeffs: 1, 0, 1) } typealias B = AlgebraicExtension<Q, p2> // B = Q[x]/p2 let i = B(x) print(i) print(i * i) print(i * i == -1)
(edited)