<commit_before>//
//  AlgebraicExtension.swift
//  SwiftyMath
//
//  Created by <NAME> on 2018/04/09.
//

import Foundation

public struct AlgebraicExtension<K: Field, p: IrrPolynomialTP>: QuotientRingType, Field where K == p.CoeffRing {
    public typealias Base = Polynomial<K>
    public typealias Sub = PolynomialIdeal<p>
    
    private let p: Base
    
    public init(from n: 𝐙) {
        self.init(Polynomial(from: n))
    }
    
    public init(_ x: K) {
        self.init(Polynomial(x))
    }
    
    public init(_ x: Polynomial<K>) {
        self.p = Sub.normalizedInQuotient(x)
    }
    
    public var representative: Polynomial<K> {
        return p
    }
}

extension AlgebraicExtension: ExpressibleByIntegerLiteral where K: ExpressibleByIntegerLiteral {
    public typealias IntegerLiteralType = K.IntegerLiteralType
    public init(integerLiteral value: IntegerLiteralType) {
        let a = K(integerLiteral: value)
        self.init(Polynomial(a))
    }
}<commit_msg>add AlgExt.init(from: 𝐐)<commit_after>//
//  AlgebraicExtension.swift
//  SwiftyMath
//
//  Created by <NAME> on 2018/04/09.
//

import Foundation

public struct AlgebraicExtension<K: Field, p: IrrPolynomialTP>: QuotientRingType, Field where K == p.CoeffRing {
    public typealias Base = Polynomial<K>
    public typealias Sub = PolynomialIdeal<p>
    
    private let p: Base
    
    public init(from n: 𝐙) {
        self.init(Polynomial(K(from: n)))
    }
    
    public init(from q: 𝐐) {
        self.init(Polynomial(K(from: q)))
    }
    
    public init(_ x: K) {
        self.init(Polynomial(x))
    }
    
    public init(_ x: Polynomial<K>) {
        self.p = Sub.normalizedInQuotient(x)
    }
    
    public var representative: Polynomial<K> {
        return p
    }
}

extension AlgebraicExtension: ExpressibleByIntegerLiteral where K: ExpressibleByIntegerLiteral {
    public typealias IntegerLiteralType = K.IntegerLiteralType
    public init(integerLiteral value: IntegerLiteralType) {
        let a = K(integerLiteral: value)
        self.init(Polynomial(a))
    }
}
{'fraction_non_alphanumeric': 0.10366441658630665, 'fraction_numerical': 0.007714561234329798, 'mean_word_length': 2.7864963503649633, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1784809', 'n_tokens_mistral': 721, 'n_tokens_neox': 694, 'n_words': 158}