Module: Algebra::PolynomialFactorization
- Includes:
- Q, Z, Zp
- Included in:
- Polynomial
- Defined in:
- lib/algebra/polynomial-factor.rb,
lib/algebra/polynomial-factor-zp.rb,
lib/algebra/polynomial-factor-int.rb
Defined Under Namespace
Modules: Q, Z, Zp
Instance Method Summary
collapse
Methods included from Q
#contQ, #factorize_rational, #ppQ
Methods included from Z
#_factorize, #centorize, #divmod_ED, #factorize_int, #hensel_lift, #lifting, #reduce_over_prime_field, #resolve_c, #resultant_by_elimination, #sqfree_over_integral, #try_e
Methods included from Zp
#factorize_modp, #factors_of_sqfree, #verschiebung, #weak_factors_and_r
Instance Method Details
#factorize ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/algebra/polynomial-factor.rb', line 55
def factorize
return Algebra::Factors.new([[zero, 1]]) if zero?
fact0 = if ground <= Integer
factorize_int
elsif defined?(Rational) && ground <= Rational ||
defined?(Algebra::LocalizedRing) && ground <= Algebra::LocalizedRing
factorize_rational
elsif defined?(Algebra::ResidueClassRing) && ground <= Algebra::ResidueClassRing
if ground.ground <= Integer
factorize_modp
else
factorize_alg
end
elsif ground <= Algebra::Polynomial
require 'algebra/m-polynomial-factor'
require 'algebra/polynomial-converter'
mp = self.class.convert_to(Algebra::MPolynomial)
f = value_on(mp)
fact = f.factorize
fact.map { |g| g.value_on(self.class) }
else
raise "(factor) unknown data type : #{self.class}"
end
fact0.normalize!
end
|
#irreducible? ⇒ Boolean
81
82
83
|
# File 'lib/algebra/polynomial-factor.rb', line 81
def irreducible?
factorize.size == 1
end
|
#monic_int(a = lc) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/algebra/polynomial-factor.rb', line 28
def monic_int(a = lc)
d = deg
project(self.class) do |c, n|
if n == d
ground.unity
elsif n < d
c * a**(d - 1 - n)
else
raise
end
end
end
|
#monic_int_rev(a) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/algebra/polynomial-factor.rb', line 42
def monic_int_rev(a)
d = deg
project(self.class) do |c, n|
if n == d
a
elsif n < d
c / a**(d - 1 - n)
else
raise
end
end
end
|
#psqfree? ⇒ Boolean
24
25
26
|
# File 'lib/algebra/polynomial-factor.rb', line 24
def psqfree?
pgcd(derivate).deg <= 0
end
|
14
15
16
17
18
|
# File 'lib/algebra/polynomial-factor.rb', line 14
def sqfree
f = self
g = gcd(derivate)
f / g * g.lc
end
|
#sqfree? ⇒ Boolean
20
21
22
|
# File 'lib/algebra/polynomial-factor.rb', line 20
def sqfree?
gcd(derivate).deg <= 0
end
|