Module: HenselCode::PAdicVerifier

Included in:
PAdicBase
Defined in:
lib/hensel_code/padic_verifier.rb

Overview

verifications pre-evaluation of hensel codes

Instance Method Summary collapse

Instance Method Details

#different_prime_and_different_exponent?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



23
24
25
26
27
28
29
# File 'lib/hensel_code/padic_verifier.rb', line 23

def different_prime_and_different_exponent?(other)
  message = <<~MSG
    "#{self} has prime #{prime} and exponent #{exponent}
    while #{other} has prime #{other.prime} and exponent #{other.exponent}
  MSG
  raise HenselCodesWithDifferentPrimesAndExponents, message if prime != other.prime && exponent != other.exponent
end

#different_prime_and_same_exponent?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



18
19
20
21
# File 'lib/hensel_code/padic_verifier.rb', line 18

def different_prime_and_same_exponent?(other)
  message = "#{self} has prime #{prime} while #{other} has prime #{other.prime}"
  raise HenselCodesWithDifferentPrimes, message if prime != other.prime && exponent == other.exponent
end

#incompatible_operand_type?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



13
14
15
16
# File 'lib/hensel_code/padic_verifier.rb', line 13

def incompatible_operand_type?(other)
  message = "#{self} is a #{self.class} while #{other} is a #{other.class}"
  raise IncompatibleOperandTypes, message unless instance_of?(other.class)
end

#same_prime_and_different_exponent?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



31
32
33
34
# File 'lib/hensel_code/padic_verifier.rb', line 31

def same_prime_and_different_exponent?(other)
  message = "#{self} has exponent #{exponent} while #{other} has exponent #{other.exponent}"
  raise HenselCodesWithDifferentExponents, message if prime == other.prime && exponent != other.exponent
end

#valid?(other) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'lib/hensel_code/padic_verifier.rb', line 6

def valid?(other)
  incompatible_operand_type?(other)
  different_prime_and_same_exponent?(other)
  different_prime_and_different_exponent?(other)
  same_prime_and_different_exponent?(other)
end