Class: HenselCode::PAdicBase
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#different_prime_and_different_exponent?, #different_prime_and_same_exponent?, #incompatible_operand_type?, #same_prime_and_different_exponent?, #valid?
Methods included from Tools
#eea_core, #extended_gcd, #mod_inverse, #random_distinct_primes, #random_integer, #random_prime, #random_rational
Constructor Details
#initialize(prime, exponent, number) ⇒ PAdicBase
Returns a new instance of PAdicBase.
12
13
14
15
16
17
18
|
# File 'lib/hensel_code/padic_base.rb', line 12
def initialize(prime, exponent, number)
@prime = prime
@exponent = exponent
@n = Integer.sqrt(((prime**exponent) - 1) / 2)
valid_number?(number)
encode
end
|
Instance Attribute Details
#exponent ⇒ Object
Returns the value of attribute exponent.
9
10
11
|
# File 'lib/hensel_code/padic_base.rb', line 9
def exponent
@exponent
end
|
#hensel_code ⇒ Object
Returns the value of attribute hensel_code.
9
10
11
|
# File 'lib/hensel_code/padic_base.rb', line 9
def hensel_code
@hensel_code
end
|
#n ⇒ Object
Returns the value of attribute n.
9
10
11
|
# File 'lib/hensel_code/padic_base.rb', line 9
def n
@n
end
|
#prime ⇒ Object
Returns the value of attribute prime.
9
10
11
|
# File 'lib/hensel_code/padic_base.rb', line 9
def prime
@prime
end
|
#rational ⇒ Object
Returns the value of attribute rational.
9
10
11
|
# File 'lib/hensel_code/padic_base.rb', line 9
def rational
@rational
end
|
Instance Method Details
#*(other) ⇒ Object
43
44
45
46
|
# File 'lib/hensel_code/padic_base.rb', line 43
def *(other)
valid?(other)
evaluate("*", other)
end
|
#+(other) ⇒ Object
33
34
35
36
|
# File 'lib/hensel_code/padic_base.rb', line 33
def +(other)
valid?(other)
evaluate("+", other)
end
|
#-(other) ⇒ Object
38
39
40
41
|
# File 'lib/hensel_code/padic_base.rb', line 38
def -(other)
valid?(other)
evaluate("-", other)
end
|
#/(other) ⇒ Object
48
49
50
51
|
# File 'lib/hensel_code/padic_base.rb', line 48
def /(other)
valid?(other)
evaluate("/", other)
end
|
#denominator ⇒ Object
24
25
26
|
# File 'lib/hensel_code/padic_base.rb', line 24
def denominator
rational.denominator
end
|
#numerator ⇒ Object
20
21
22
|
# File 'lib/hensel_code/padic_base.rb', line 20
def numerator
rational.numerator
end
|
#replace_exponent(new_exponent) ⇒ Object
57
58
59
|
# File 'lib/hensel_code/padic_base.rb', line 57
def replace_exponent(new_exponent)
replace_attribute("exponent=", new_exponent, 0)
end
|
#replace_hensel_code(new_hensel_code) ⇒ Object
65
66
67
68
|
# File 'lib/hensel_code/padic_base.rb', line 65
def replace_hensel_code(new_hensel_code)
valid_hensel_code?(new_hensel_code)
replace_attribute("hensel_code=", new_hensel_code, 1)
end
|
#replace_prime(new_prime) ⇒ Object
53
54
55
|
# File 'lib/hensel_code/padic_base.rb', line 53
def replace_prime(new_prime)
replace_attribute("prime=", new_prime, 0)
end
|
#replace_rational(new_rational) ⇒ Object
61
62
63
|
# File 'lib/hensel_code/padic_base.rb', line 61
def replace_rational(new_rational)
replace_attribute("rational=", new_rational, 0)
end
|
#to_r ⇒ Object
28
29
30
31
|
# File 'lib/hensel_code/padic_base.rb', line 28
def to_r
decode
rational
end
|