示例#1
0
 def _CheckCosResult(self, f, l):
     # Take all data
     a = numx.absolute(f)
     assert (fcmp(f[l].real, self.n / 2, self._eps) == 0)
     stmp = ["%s" % a[l]]
     a[l] = 0
     stmp.append("should be zero %s" % (a[l], ))
     if (len(f) > self.n / 2 + 1):
         # Only for the complex transform
         assert (fcmp(f[self.n - l].real, self.n / 2, self._eps) == 0)
         a[self.n - l] = 0
     # Take the maximum
     test = 0
     try:
         assert (MLab.max(a) < self._eps)
         test = 1
     finally:
         if test == 0:
             print "Check Cos Result",
             printvec(a, 0, self._eps)
             print string.join(stmp)
示例#2
0
 def _CheckCosResult(self, f, l):
     # Take all data
     a = numx.absolute(f)
     assert(fcmp(f[l].real, self.n/2, self._eps) == 0)
     stmp = ["%s" % a[l]]
     a[l] = 0
     stmp.append("should be zero %s" % (a[l],))
     if(len(f) > self.n/2 + 1):
             # Only for the complex transform
             assert(fcmp(f[self.n-l].real, self.n/2, self._eps) == 0)
             a[self.n-l] = 0
     # Take the maximum
     test = 0
     try:
         assert(MLab.max(a) < self._eps)
         test = 1
     finally:
         if test == 0:
             print "Check Cos Result",
             printvec(a, 0, self._eps)
             print string.join(stmp)
示例#3
0
    def _CheckSinResult(self, f, l):
        a = numx.absolute(f)
        test = 0
        tmp1 = None
        tmp2 = None
        try:
            tmp1 = f[l].imag
            tmp2 = self.sin_n
            flag = fcmp(tmp1, tmp2, self._eps)
            assert (flag == 0)
            a[l] = 0
            if (len(f) > self.n / 2 + 1):
                # Only for the complex transform
                tmp1 = f[self.n - l].imag
                tmp2 = self.sin_n_l
                flag = fcmp(tmp1, tmp2, self._eps)
                assert (flag == 0)
                a[self.n - l] = 0
            test = 1
        finally:
            if test == 0:
                print
                print "Check Sin Result len(f) = %s, self.n/2 = %s", len(
                    f), self.n / 2
                print f[l]
                print "tmp1 = %s, tmp2 = %s, flag = %s" % (tmp1, tmp2, flag)
                #print f[self.n-l]

        # Take the maximum
        test = 0
        try:
            assert (MLab.max(a) < self._eps)
            test = 1
        finally:
            if test == 0:
                printvec(a, 0, self._eps)
                print MLab.max(a)
示例#4
0
 def _CheckSinResult(self, f, l):
     a = numx.absolute(f)
     test = 0
     tmp1 = None
     tmp2 = None
     try:
         tmp1 = f[l].imag
         tmp2 = self.sin_n
         flag = fcmp(tmp1, tmp2, self._eps)
         assert(flag == 0)
         a[l] = 0
         if(len(f) > self.n/2 + 1):
             # Only for the complex transform
             tmp1 = f[self.n-l].imag
             tmp2 = self.sin_n_l
             flag = fcmp(tmp1, tmp2, self._eps)
             assert(flag == 0)
             a[self.n-l] = 0
         test = 1
     finally:
         if test == 0:
             print 
             print "Check Sin Result len(f) = %s, self.n/2 = %s", len(f), self.n/2                
             print f[l]
             print "tmp1 = %s, tmp2 = %s, flag = %s" % (tmp1, tmp2, flag)
             #print f[self.n-l]
             
     # Take the maximum
     test = 0
     try:
         assert(MLab.max(a) < self._eps)
         test = 1
     finally:
         if test == 0:
             printvec(a, 0, self._eps)
             print MLab.max(a)
示例#5
0
def printvec(array, value, eps):
    for i in range(len(array)):
        if fcmp(array[i] + 1, value + 1, eps) != 0:
            print "v[%d]=%e   " % (i, array[i]),
    print
示例#6
0
def printvec(array, value, eps):
    for i in range(len(array)):
        if fcmp(array[i]+1, value+1, eps) != 0:
            print "v[%d]=%e   " % (i, array[i]),
    print