Class: HenselCode::FinitePadicExpansion

Inherits:
PAdicBase
  • Object
show all
Defined in:
lib/hensel_code/finite_padic_expansion.rb

Overview

finite p-adic expansion hensel code class

Instance Attribute Summary collapse

Attributes inherited from PAdicBase

#exponent, #hensel_code, #n, #prime, #rational

Instance Method Summary collapse

Methods inherited from PAdicBase

#*, #+, #-, #/, #denominator, #initialize, #numerator, #replace_exponent, #replace_hensel_code, #replace_prime, #replace_rational, #to_r

Methods included from PAdicVerifier

#different_prime_and_different_exponent?, #different_prime_and_same_exponent?, #incompatible_operand_type?, #same_prime_and_different_exponent?, #valid?

Methods included from Tools

#crt, #eea_core, #extended_gcd, #mod_inverse, #random_distinct_numbers, #random_integer, #random_prime, #random_rational

Constructor Details

This class inherits a constructor from HenselCode::PAdicBase

Instance Attribute Details

#polynomialObject

Returns the value of attribute polynomial.



6
7
8
# File 'lib/hensel_code/finite_padic_expansion.rb', line 6

def polynomial
  @polynomial
end

Instance Method Details

#inspectObject



26
27
28
# File 'lib/hensel_code/finite_padic_expansion.rb', line 26

def inspect
  "<HenselCode: #{polynomial_form}>"
end

#inverseObject



30
31
32
33
# File 'lib/hensel_code/finite_padic_expansion.rb', line 30

def inverse
  new_hensel_code = polynomial.inverse.coefficients
  self.class.new prime, exponent, new_hensel_code
end

#modulusObject



8
9
10
# File 'lib/hensel_code/finite_padic_expansion.rb', line 8

def modulus
  prime
end

#to_aObject



12
13
14
# File 'lib/hensel_code/finite_padic_expansion.rb', line 12

def to_a
  hensel_code
end

#to_sObject



20
21
22
23
24
# File 'lib/hensel_code/finite_padic_expansion.rb', line 20

def to_s
  hensel_code.map.with_index do |h, i|
    "#{h}#{polynomial_variable(i)}"
  end.join(" + ")
end

#to_truncatedObject



16
17
18
# File 'lib/hensel_code/finite_padic_expansion.rb', line 16

def to_truncated
  TruncatedFinitePadicExpansion.new(prime, exponent, rational)
end