예제 #1
0
파일: field.py 프로젝트: timleslie/pygeom
    def reduce(self, others):
        """
        Reduce this number, along with a list of others so that all common
        factors are removed.
        """
        if self == 0:
            if others:
                return [self] + others[0].reduce(others[1:])
            else:
                return [self]

        common_denom = self.den
        for x in others:
            common_denom *= x.den

        self = self * common_denom
        others = [x * common_denom for x in others]

        gcd_ = self.num
        for x in others:
            gcd_ = gcd(gcd_, x.num)

        self = self.__div__(gcd_)
        others = [x / gcd_ for x in others]
        return [self] + others
예제 #2
0
파일: field.py 프로젝트: marchon/pygeom
    def reduce(self, others):
        """
        Reduce this number, along with a list of others so that all common
        factors are removed.
        """
        if self == 0:
            if others:
                return [self] + others[0].reduce(others[1:])
            else:
                return [self]

        common_denom = self.den
        for x in others:
            common_denom *= x.den


        self = self*common_denom
        others = [x*common_denom for x in others]

        gcd_ = self.num
        for x in others:
            gcd_ = gcd(gcd_, x.num)

        self = self.__div__(gcd_)
        others = [x/gcd_ for x in others]
        return [self] + others
예제 #3
0
파일: field.py 프로젝트: timleslie/pygeom
 def _reduce(self):
     """
     Reduce the values to remove any common factors.
     """
     gcd_ = gcd(self.num, self.den)
     self.num /= gcd_
     self.den /= gcd_
예제 #4
0
파일: field.py 프로젝트: marchon/pygeom
 def _reduce(self):
     """
     Reduce the values to remove any common factors.
     """
     gcd_ = gcd(self.num, self.den)
     self.num /= gcd_
     self.den /= gcd_