inkfish/classgroup.py
def multiply(self, other):
        """
        An implementation of form composition as documented by "Explaining composition".
        """
        a1, b1, c1 = self.reduced()
        a2, b2, c2 = other.reduced()

        g = (b2 + b1) // 2
        h = (b2 - b1) // 2

        w = mod.gcd(a1, a2, g)

        j = w
        r = 0
        s = a1 // w
        t = a2 // w
        u = g // w

        # solve these equations for k, l, m
        """
        k * t - l * s = h
        k * u - m * s = c2
        l * u - m * t = c1
        """

        """
        solve
        (tu)k - (hu + sc) = 0 mod st
        k = (- hu - sc) * (tu)^-1
        """

        k_temp, constant_factor = mod.solve_mod(t * u, h * u + s * c1, s * t)
        n, constant_factor_2 = mod.solve_mod(t * constant_factor, h - t * k_temp, s)
        k = k_temp + constant_factor * n
        l = (t * k - h) // s
        m = (t * u * k - h * u - s * c1) // (s * t)
        #assert m * s * t == t * u * k - h * u - s * c1
        #assert u * l == t * m + c1
        #assert (t * u * k - h * u - s * c1) % (s * t) == 0

        a3 = s * t - r * u
        b3 = (j * u + m * r) - (k * t + l * s)
        c3 = k * l - j * m
        return self.__class__(a3, b3, c3).reduced()

        An implementation of form composition as documented by "Explaining composition".
        
An implementation of form composition as documented by "Explaining composition".
An implementation of form composition as documented by " Explaining composition " .
def multiply(self, other):
        a1, b1, c1 = self.reduced()
        a2, b2, c2 = other.reduced()
        g = (b2 + b1) // 2
        h = (b2 - b1) // 2
        w = mod.gcd(a1, a2, g)
        j = w
        r = 0
        s = a1 // w
        t = a2 // w
        u = g // w
        k_temp, constant_factor = mod.solve_mod(t * u, h * u + s * c1, s * t)
        n, constant_factor_2 = mod.solve_mod(t * constant_factor, h - t * k_temp, s)
        k = k_temp + constant_factor * n
        l = (t * k - h) // s
        m = (t * u * k - h * u - s * c1) // (s * t)
        a3 = s * t - r * u
        b3 = (j * u + m * r) - (k * t + l * s)
        c3 = k * l - j * m
        return self.__class__(a3, b3, c3).reduced()
def multiply ( self , other ) : a1 , b1 , c1 = self . reduced ( ) a2 , b2 , c2 = other . reduced ( ) g = ( b2 + b1 ) // 2 h = ( b2 - b1 ) // 2 w = mod . gcd ( a1 , a2 , g ) j = w r = 0 s = a1 // w t = a2 // w u = g // w """
        k * t - l * s = h
        k * u - m * s = c2
        l * u - m * t = c1
        """ """
        solve
        (tu)k - (hu + sc) = 0 mod st
        k = (- hu - sc) * (tu)^-1
        """ k_temp , constant_factor = mod . solve_mod ( t * u , h * u + s * c1 , s * t ) n , constant_factor_2 = mod . solve_mod ( t * constant_factor , h - t * k_temp , s ) k = k_temp + constant_factor * n l = ( t * k - h ) // s m = ( t * u * k - h * u - s * c1 ) // ( s * t ) a3 = s * t - r * u b3 = ( j * u + m * r ) - ( k * t + l * s ) c3 = k * l - j * m return self . __class__ ( a3 , b3 , c3 ) . reduced ( )
An implementation of form composition as documented by "Explaining composition".
An implementation of form composition as documented by " Explaining composition " .
"""
        An implementation of form composition as documented by "Explaining composition".
        """ # solve these equations for k, l, m """
        k * t - l * s = h
        k * u - m * s = c2
        l * u - m * t = c1
        """ """
        solve
        (tu)k - (hu + sc) = 0 mod st
        k = (- hu - sc) * (tu)^-1
        """ #assert m * s * t == t * u * k - h * u - s * c1 #assert u * l == t * m + c1 #assert (t * u * k - h * u - s * c1) % (s * t) == 0
self
other