module BLS::FQP
Module for a field over polynomial. TT - ThisType, CT - ChildType, TTT - Tuple Type
Public Instance Methods
==(other)
click to toggle source
# File lib/bls/field.rb, line 115 def ==(other) coeffs == other.coeffs end
add(other)
click to toggle source
# File lib/bls/field.rb, line 123 def add(other) self.class.new(coeffs.map.with_index { |v, i| v + other.coeffs[i] }) end
Also aliased as: +
conjugate()
click to toggle source
# File lib/bls/field.rb, line 159 def conjugate self.class.new([coeffs[0], coeffs[1].negate]) end
div(other)
click to toggle source
# File lib/bls/field.rb, line 133 def div(other) inv = other.is_a?(Integer) ? Fq.new(other).invert.value : other.invert multiply(inv) end
Also aliased as: /
negate()
click to toggle source
# File lib/bls/field.rb, line 139 def negate self.class.new(coeffs.map(&:negate)) end
pow(n)
click to toggle source
# File lib/bls/field.rb, line 143 def pow(n) one = self.class.const_get(:ONE) return one if n.zero? return self if n == 1 p = one d = self while n.positive? p *= d unless (n & 1).zero? n >>= 1 d = d.square end p end
Also aliased as: **
subtract(other)
click to toggle source
# File lib/bls/field.rb, line 128 def subtract(other) self.class.new(coeffs.map.with_index { |v, i| v - other.coeffs[i] }) end
Also aliased as: -
zero?()
click to toggle source
# File lib/bls/field.rb, line 119 def zero? coeffs.find { |c| !c.zero? }.nil? end