Module: HenselCode::GAdicVerifier

Included in:
GAdicBase
Defined in:
lib/hensel_code/gadic_verifier.rb

Overview

verifications pre-evaluation of hensel codes

Instance Method Summary collapse

Instance Method Details

#different_primes_and_different_exponent?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



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

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

#different_primes_and_same_exponent?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



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

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

#incompatible_operand_type?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



13
14
15
16
# File 'lib/hensel_code/gadic_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_primes_and_different_exponent?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



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

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

#valid?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

def valid?(other)
  incompatible_operand_type?(other)
  different_primes_and_same_exponent?(other)
  different_primes_and_different_exponent?(other)
  same_primes_and_different_exponent?(other)
end