示例#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_