def to_stik(mu_1,mu_2,t,sigma_tilde,n_1,n_2):
	"""
	t : se efter qt(0.975, df=n-2)
	sigma_tilde : findes som residual error 
	"""
	lille = mu_1 - mu_2 - t * sigma_tilde^2*sq(1/n_1 + 1/n_2)
	stor = mu_1 + mu_2 - t * sigma_tilde^2*sq(1/n_1 + 1/n_2)
	return lille,stor
Exemple #2
0
def solution(n1, n2):
    ans = 0
    for i in range(n1, n2 + 1):
        if sq(i) == int(sq(i)):
            ans -= i
        else:
            ans += i
    return ans
Exemple #3
0
 def diag(self):
     self._diag.clear()
     self._diag.append(
         sq((self.points[0][0] - self.points[2][0])**2 +
            (self.points[0][1] - self.points[2][1])**2))
     self._diag.append(
         sq((self.points[1][0] - self.points[3][0])**2 +
            (self.points[1][1] - self.points[3][1])**2))
def et_stik(mu,t,sigma_tilde,n):
	"""
	det hoejst ssh den med UKENDT varians
	n : antal i stikproeven
	t : se efter qt(0.975, df=n-1)
	sigma_tilde : findes som residual error 
	"""
	lille = mu - t * sigma_tilde^2/sq(n)
	stor = mu + t * sigma_tilde^2/sq(n)
	return lille, stor 
Exemple #5
0
def sqrt(num):
    try:
        a = num.re
        b = num.im

        alpha = sq((sq(a**2 + b**2) + a) / 2)
        beta = sq((sq(a**2 + b**2) - a) / 2)
        return Complex(alpha, beta)
    except:
        return sq(num)
Exemple #6
0
def roots(a, b, c):
    delta = (b**2) - (4 * a * c)
    if delta < 0:
        return ()
    elif delta == 0:
        return (-b / (2 * a))
    else:
        x = (-b + sq(delta)) / (2 * a)
        y = (-b - sq(delta)) / (2 * a)
        return (y, x)
def linreg_beta(beta_hat,n,t,sigma_tilde,var_x):
	"""
	alpha_hat = er intercepten 
	n : antal i alt 
	t : se efter qt(0.975, df=n -2)
	sigma_tilde : brug betas sd
	"""
	ssd_x = (n-1)*var_x
	lille = beta_hat - t * sigma_tilde^2/sq(ssd_x)
	stor = beta_hat + t * sigma_tilde^2/sq(ssd_x)
	return lille, stor
Exemple #8
0
def test_solution():
    import solution
    from math import sqrt as sq

    vector_a = solution.Vector3D(1, 5, 3)
    vector_b = solution.Vector3D(4, 4, 1)
    vector_c = solution.Vector3D(1, 5, 2)

    assert vector_a.magnitude() == sq(35)
    assert vector_b.magnitude() == sq(33)
    assert vector_c.magnitude() == sq(30)
def linreg_alpha(alpha_hat,n,t,sigma_tilde,var_x,mean_x):
	"""
	alpha_hat = er intercepten 
	n : antal i stikproeven
	t : se efter qt(0.975, df=n-2)
	sigma_tilde : brug alphas sd
	"""
	ssd_x = (n-1)*var_x
	lille = alpha_hat -t * sq(1/n + mean_x**2/ssd_x)
	stor = alpha_hat -t * sq(1/n + mean_x**2/ssd_x)
	return lille, stor
Exemple #10
0
def selesaikanABC(a, b, c):
    a = float(a)
    b = float(b)
    c = float(c)
    D = b**2 - 4 * a * c
    if D < 0:
        hasil = "Determinannya negatif. Persamaan tidak mempunyai akar real."
    else:
        x1 = (-b + sq(D)) / (2 * a)
        x2 = (-b - sq(D)) / (2 * a)
        hasil = (x1, x2)
    return str(hasil)
def selesaikanABC(a, b, c):
    a = float(a)
    b = float(b)
    c = float(c)
    D = (b**2) - (4 * a * c)
    if (D < 0):
        print("Determinannya negatif. Persamaan tidak mempunyai akar real")
    else:
        x1 = (-b + sq(D)) / (2 * a)
        x2 = (-b - sq(D)) / (2 * a)
        hasil = [x1, x2]
        print(hasil)
Exemple #12
0
def selesaikanABC(r, s, t):
    r = float(r)
    s = float(s)
    t = float(t)
    D = (s**2) - (4 * r * t)
    if (D < 0):
        print("Determinannya negatif. Persamaan tidak mempunyai akar real")
    else:
        j1 = (-s + sq(D)) / (2 * r)
        j2 = (-s - sq(D)) / (2 * r)
        hasil = [j1, j2]
        print(hasil)
Exemple #13
0
def selesaikanABC(a, b, c):
    a = float(a)
    b = float(b)
    c = float(c)
    D = (b**2) - (4 * a * c)
    if D < 0:
        return "Determinannya negatif. Persamaan tidak mempunyai akar real"
    else:
        x1 = (-b + sq(D)) / 2 * a
        x2 = (-b - sq(D)) / 2 * a
        hasil = (x1, x2)
        return hasil
Exemple #14
0
def circumCircle(p1, p2, p3):
    """circumCircle(p1, p2, p3) -> (Vector2, float)

    Returns the center and radius of the circumcircle of the given
    three points."""

    p1sm = squaredNorm(p1)
    x1 = p1[0]
    y1 = p1[1]
    p2sm = squaredNorm(p2)
    x2 = p2[0]
    y2 = p2[1]
    p3sm = squaredNorm(p3)
    x3 = p3[0]
    y3 = p3[1]
    a = numpy.linalg.det(
        numpy.array([[x1, y1, 1],
                     [x2, y2, 1],
                     [x3, y3, 1]]))
    d = numpy.linalg.det(
        -numpy.array([[p1sm, y1, 1],
                      [p2sm, y2, 1],
                      [p3sm, y3, 1]]))
    e = numpy.linalg.det(
        numpy.array([[p1sm, x1, 1],
                     [p2sm, x2, 1],
                     [p3sm, x3, 1]]))
    f = numpy.linalg.det(
        -numpy.array([[p1sm, x1, y1],
                      [p2sm, x2, y2],
                      [p3sm, x3, y3]]))
    circumCenter = Vector2(-d/(2*a), -e/(2*a))

    denom = 4*math.sq(a) - f/a

    circumRadius2 = (math.sq(d) + math.sq(e)) / (4*math.sq(a)) - f/a

    if circumRadius2 > 0:
        circumRadius = math.sqrt(circumRadius2)
    else:
        lengths = [(p2-p1).magnitude(),
                   (p3-p2).magnitude(),
                   (p1-p3).magnitude()]
        lengths.sort()
        circumRadius = (lengths[1] + lengths[2]) / 4.0
        sys.stderr.write("circumcircle: side lengths^2 are %s -> improvised radius = %s\n"
                         % (lengths, circumRadius))

    return circumCenter, circumRadius
Exemple #15
0
def circumCircle(p1, p2, p3):
    """circumCircle(p1, p2, p3) -> (Vector2, float)

    Returns the center and radius of the circumcircle of the given
    three points."""
    
    p1sm = squaredNorm(p1)
    x1 = p1[0]
    y1 = p1[1]
    p2sm = squaredNorm(p2)
    x2 = p2[0]
    y2 = p2[1]
    p3sm = squaredNorm(p3)
    x3 = p3[0]
    y3 = p3[1]
    a = numpy.linalg.det(
        numpy.array([[x1, y1, 1],
                     [x2, y2, 1],
                     [x3, y3, 1]]))
    d = numpy.linalg.det(
        -numpy.array([[p1sm, y1, 1],
                      [p2sm, y2, 1],
                      [p3sm, y3, 1]]))
    e = numpy.linalg.det(
        numpy.array([[p1sm, x1, 1],
                     [p2sm, x2, 1],
                     [p3sm, x3, 1]]))
    f = numpy.linalg.det(
        -numpy.array([[p1sm, x1, y1],
                      [p2sm, x2, y2],
                      [p3sm, x3, y3]]))
    circumCenter = Vector2(-d/(2*a), -e/(2*a))

    denom = 4*math.sq(a) - f/a

    circumRadius2 = (math.sq(d) + math.sq(e)) / (4*math.sq(a)) - f/a

    if circumRadius2 > 0:
        circumRadius = math.sqrt(circumRadius2)
    else:
        lengths = [(p2-p1).magnitude(),
                   (p3-p2).magnitude(),
                   (p1-p3).magnitude()]
        lengths.sort()
        circumRadius = (lengths[1] + lengths[2]) / 4.0
        sys.stderr.write("circumcircle: side lengths^2 are %s -> improvised radius = %s\n"
                         % (lengths, circumRadius))

    return circumCenter, circumRadius
def do():
    size = 20
    numgens = 50
    pertf = lambda x:0.5/sq(x)
    l = [Columns.rand() for i in range(size)]
    print()
    [print(n) for n in l]
    print()
    gen = 1
    gens = []
    t = []
    for n in l:
        t.append(n)
    gens.append(t)
    while gen<numgens:
        Columns.sort(l)
        [l.pop(-1) for i in range(int(size/2))]
        pert = pertf(gen)
        ll = []
        for i in range(len(l)-1):
            ll.append(Columns.merge(l[i],l[i+1],pert))
        ll.append(Columns.merge(l[len(l)-1],l[0],pert))
        l.extend(ll)
        print()
        print("Gen",gen,"done.")
        [print(n) for n in l]
        print()
        t = []
        for n in l:
            t.append(n)
        gens.append(t)
        gen+=1
Exemple #17
0
def button_equal():
    second_number = float(e.get())
    e.delete(0, END)
    if math == "addition":
        e.insert(0, f_num + second_number)

    elif math == "subtraction":
        e.insert(0, f_num - int(second_number))

    elif math == "division":
        e.insert(0, round(f_num / int(second_number), 4))

    elif math == "multiplication":
        e.insert(0, f_num * int(second_number))

    elif math == "exponent":
        e.insert(0, f_num**int(second_number))

    elif math == "modulus":
        e.insert(0, f_num % int(second_number))

    elif math == "square_root":
        e.insert(sq(0, f_num))

    elif math == "floor_division":
        e.insert(0, f_num // int(second_number))

    elif math == "inverse":
        e.insert(0, pow(f_num, -1))

    elif math == "dot":
        e.insert(0, float(f_num))

    else:
        e.insert(0, float(f_num))
def dc(s, e):
    r = float("3.141592653589793238462643383279502884197169399375105820974944"
              "592307816406286208998628034825342117067982148086513282306647"
              "093844609550582231725359408128481117450284102701938521105559"
              "644622948954930381964428810975665933446128475648233786783165"
              "271201909145648566923460348610454326648213393607260249141273"
              "724587006606315588174881520920962829254091715364367892590360"
              "011330530548820466521384146951941511609433057270365759591953"
              "092186117381932611793105118548074462379962749567351885752724"
              "891227938183011949129833673362440656643086021394946395224737"
              "190702179860943702770539217176293176752384674818467669405132"
              "000568127145263560827785771342757789609173637178721468440901"
              "224953430146549585371050792279689258923542019956112129021960"
              "864034418159813629774771309960518707211349999998372978049951"
              "059731732816096318595024459455346908302642522308253344685035"
              "261931188171010003137838752886587533208381420617177669147303"
              "598253490428755468731159562863882353787593751957781857780532"
              "1712268066130019278766111959092164201989") / 180.
    r_start = (s[0] * r, s[1] * r)
    r_end = (e[0] * r, e[1] * r)
    cl1 = co(r_start[0])
    cl2 = co(r_end[0])
    sl1 = si(r_start[0])
    sl2 = si(r_end[0])
    dt = r_end[1] - r_start[1]
    cdt = co(dt)
    sdt = si(dt)
    return int(
        at(sq(pw(cl2 * sdt, 2) + pw(cl1 * sl2 - sl1 * cl2 * cdt, 2)),
           sl1 * sl2 + cl1 * cl2 * cdt) * 6372795)
def dc(s, e):
    r = float("3.141592653589793238462643383279502884197169399375105820974944"
              "592307816406286208998628034825342117067982148086513282306647"
              "093844609550582231725359408128481117450284102701938521105559"
              "644622948954930381964428810975665933446128475648233786783165"
              "271201909145648566923460348610454326648213393607260249141273"
              "724587006606315588174881520920962829254091715364367892590360"
              "011330530548820466521384146951941511609433057270365759591953"
              "092186117381932611793105118548074462379962749567351885752724"
              "891227938183011949129833673362440656643086021394946395224737"
              "190702179860943702770539217176293176752384674818467669405132"
              "000568127145263560827785771342757789609173637178721468440901"
              "224953430146549585371050792279689258923542019956112129021960"
              "864034418159813629774771309960518707211349999998372978049951"
              "059731732816096318595024459455346908302642522308253344685035"
              "261931188171010003137838752886587533208381420617177669147303"
              "598253490428755468731159562863882353787593751957781857780532"
              "1712268066130019278766111959092164201989") / 180.
    r_start = (s[0] * r, s[1] * r)
    r_end = (e[0] * r, e[1] * r)
    cl1 = co(r_start[0])
    cl2 = co(r_end[0])
    sl1 = si(r_start[0])
    sl2 = si(r_end[0])
    dt = r_end[1] - r_start[1]
    cdt = co(dt)
    sdt = si(dt)
    return int(at(sq(pw(cl2 * sdt, 2) + pw(cl1 * sl2 - sl1 * cl2 * cdt, 2)),
                  sl1 * sl2 + cl1 * cl2 * cdt) * 6372795)
def isprime(n):
    prime = True
    ls = int(sq(n))
    for i in range(2, ls + 1):
        if n % i == 0:
            prime = False
            break
    return prime
Exemple #21
0
def d_cor(a, b):
    #a,b pairwise distance matrices of equal size
    dvar_a = paired_sample_covar(a, a)
    dvar_b = paired_sample_covar(b, b)
    if dvar_a * dvar_b == 0:
        return (0)
    dcor = (paired_sample_covar(a, b)) / sq(dvar_a * dvar_b)
    return (dcor)
Exemple #22
0
def apakahPrima(n):
    n = int(n)
    assert n >= 0
    primaKecil = [2, 3, 5, 7, 11]
    bukanPrKecil = [0, 1, 4, 6, 8, 9, 10]
    if n in primaKecil:
        return True
    elif n in bukanPrKecil:
        return False
    else:
        for i in range(2, int(sq(n)) + 1):
            if ((n % i) == 0):
                return False
            elif (i >= int(sq(n))):
                return True
            else:
                continue
Exemple #23
0
 def sides(self):
     self._sides.clear()
     ln = len(self.points)
     for i in range(ln):
         j = i + 1 if i != ln - 1 else 0
         self._sides.append(
             sq((self.points[i][0] - self.points[j][0])**2 +
                (self.points[i][1] - self.points[j][1])**2))
def prime(x):
    x = int(x)
    assert x >= 0
    sp = [2, 3, 5, 7, 11]
    nsp = [0, 1, 4, 6, 8, 9, 10]
    if x in sp:
        return True
    elif x in nsp:
        return False
    else:
        for i in range(2, int(sq(x)) + 1):
            if ((x % i) == 0):
                return False
            elif (i >= int(sq(x))):
                return True
            else:
                continue
Exemple #25
0
 def sqrt(self):
     calc_logger.info(f'Called sqrt func with attr {self.num}')
     try:
         result = sq(self.num)
     except ValueError:
         calc_logger.critical(f'Value {self.num} forbidden for this operation')
         result = f'Value {self.num} forbidden for this operation'
     return result
def main():
    fi = (1 + sq(5)) / 2
    k = 2
    while abs(fi - fibo(k) / fibo(k - 1)) > 0.00000000001:
        print k
        k += 1
    print "lo logre despues de %d vueltas" % k
    print "la aproximacion de %.7f es %.7f" % (fi, fibo(k) / fibo(k - 1))
Exemple #27
0
 def area(self):
     if self.is_trap():
         return round(
             ((self._sides[self._osn[0]] + self._sides[self._osn[1]]) / 2) *
             sq(self._sides[self._osn[0] + 1]**2 -
                ((self._sides[self._osn[0]] -
                  self._sides[self._osn[1]])**2) / 4), 2)
     else:
         return False
Exemple #28
0
def check(n):
    if n == 2 or n == 3 or n == 4:
        return True
    if n % 2 == 0:
        return False
    for i in range(2, int(sq(n) + 1), 2):
        if n % i == 0:
            return False

    return True
def compute(n):
    l = defaultdict(lambda: 0)
    a0 = int(sq(n))
    b0 = sq(n) - a0
    a1 = int(1 / b0)
    b1 = 1 / b0 - a1
    temp = b1
    l[n] = 1
    flag = True

    while flag:

        a2 = int(1 / b1)
        b2 = 1 / b1 - a2

        if round(Decimal(b2), 6) == round(Decimal(temp), 6):
            flag = False
            return l

        b1 = b2
        l[n] += 1
Exemple #30
0
def apakahPrima(x):
    n = int(x)
    assert n >= 0
    if n in [2, 3, 5, 7, 11]:
        return True
    elif n in [0, 1, 4, 6, 8, 9, 10]:
        return False
    else:
        for i in range(2, int(sq(n) + 1)):
            if n % i == 0:
                return False
        return True
Exemple #31
0
def func_count(start, step):
    m = start
    my_list = []
    i = 0
    for el in count(start):
        i += 1
        if i > sq(el):
            break
        else:
            my_list.append(el)
            print(el)
    return my_list
Exemple #32
0
def cholesky(A):
    n = len(A)
    L = np.zeros(shape = (n,n))
    
    for i in range(n):
        for k in range(i+1):
            ksuma = sum( L[i][j] * L[k][j] for j in range(k) )

            if (i == k):
                L[i][k] = sq(abs( A[i][i] - ksuma ))

            else:
                L[i][k] = (( 1.0 / L[k][k] ) * ( A[i][k] - ksuma ))
    return np.asarray(L)
Exemple #33
0
def apakahPrima(n):
    n = int(n)
    assert n >= 0  #hanya menerima bilangan non-negatif
    primaKecil = [2, 3, 5, 7, 11]
    bukanPrKecil = [0, 1, 4, 6, 8, 9, 10]
    if n in primaKecil:
        return True
    elif n in bukanPrKecil:
        return False
    else:
        for i in range(2, int(sq(n)) + 1):
            if n % i == 0:
                return False
        return True
Exemple #34
0
def apakahPrima(x):
    x = int(x)
    primaKecil = [2, 3, 5, 7, 11]
    bknPrimaKecil = [0, 1, 4, 6, 8, 9, 10]
    if x in primaKecil:
        return True
    elif x in bknPrimaKecil:
        return False
    else:
        for i in range(2, int(sq(x)) + 1):
            if x % i == 0:
                return False
            else:
                return True
Exemple #35
0
def cholesky(A):
    n = len(A)
    L = np.zeros(shape=(n, n))

    for i in range(n):
        for k in range(i + 1):
            ksuma = sum(L[i][j] * L[k][j] for j in range(k))

            if (i == k):
                L[i][k] = sq(abs(A[i][i] - ksuma))

            else:
                L[i][k] = ((1.0 / L[k][k]) * (A[i][k] - ksuma))
    return np.asarray(L)
Exemple #36
0
def apakahPrima(n):
    n = int(n)
    assert n >= 0
    primakecil = [2, 3, 5, 7, 11]
    bukanprima = [0, 1, 4, 6, 8, 9, 10]
    if n in primakecil:
        return True
    elif n in bukanprima:
        return False
    else:
        for i in range(2, int(sq(n)) + 1):
            if (n % i == 0):
                return False
    return True
Exemple #37
0
def compute(n, m):

    l = []
    a0 = int(sq(n))
    b0 = sq(n) - a0
    a1 = int(1 / b0)
    b1 = 1 / b0 - a1
    temp = b1
    flag = True
    count = 0

    while flag:

        a2 = int(1 / b1)
        b2 = 1 / b1 - a2
        print(a2, b2)
        count += 1

        if count == m:
            flag = False
            return l
        l.append(a2)
        b1 = b2
Exemple #38
0
def Npr(n,t):											#Privedenie mownosti dvigatelya
	return n*sq(288.15/(t+273.15))
Exemple #39
0
def cef(n,t):											#Rasprivedenie ydelnogo rasxoda topliva dvigatelya
	return n*sq((t+273.15)/288.15)		                
Exemple #40
0
def cef(n,t):											#Расприведение удельного расхода топлива двигателя
	return n*sq((t+273.15)/288.15)		
Exemple #41
0
def nf(n,t):											#Расприведение частоты вращения двигателя
	return n*sq((t+273.15)/288.15)
Exemple #42
0
def Nf(n,t):											#Расприведение мощности двигателя						
	return n*sq((t+273.15)/288.15)
Exemple #43
0
def Gvf(n,t,B):											#Расприведение расхода воздуха двигателя
	return n*(B/760)*sq(288.15/(t+273.15))	
Exemple #44
0
def Nf(n,t):											#Rasprivedenie mownosti dvigatelya
	return n*sq((t+273.15)/288.15)                      
Exemple #45
0
def cepr(n,t):											#Privedenie ydelnogo rasxoda topliva dvigatelya
	return n*sq(288.15/(t+273.15))	
Exemple #46
0
def Nctpr(n,t,B):										#Privedenie mownosti silovoi tyrbini dvigatelya
	return n*sq(288.15/(t+273.15))*(760.0/B)
Exemple #47
0
def npr(n,t):											#Privedenie chastoti vraweniya dvigatelya
	return n*sq(288.15/(t+273.15))
Exemple #48
0
def Gvpr(n,t,B):										#Privedenie rasxoda  vozdyxa dvigatelya
	return n*(760.0/B)*sq((t+273.15)/288.15)	
Exemple #49
0
def Gtpr(n,t,B):										#Privedenie rasxoda topliva dvigatelya
	return n*(760.0/B)*sq(288.15/(t+273.15))
Exemple #50
0
def markAlphaShapes(delaunayMap, alpha, beta = 0.0):
    if not hasattr(delaunayMap, "circumCircles"):
        print "- reconstructing triangle circumcircles..."
        delaunayMap.circumCircles = \
            delaunay.calculateTriangleCircumcircles(delaunayMap)

    # store parameters for convenience:
    delaunayMap.alpha = alpha
    delaunayMap.beta = beta

    print "- marking triangles with radii < alpha(%s)..." % (alpha, )
    for triangle in delaunayMap.faceIter(skipInfinite = True):
        triangle.setFlag(
            ALPHA_MARK, delaunayMap.circumCircles[triangle.label()][1] < alpha)

    print "- marking edges with empty circle radii < alpha(%s)..." % (alpha, )
    for edge in delaunayMap.edgeIter():
        assert len(edge) == 2, "markAlphaShapes() expects a delaunay map!"
        edge.setFlag(ALPHA_MARK,
                     edge.leftFace().flag(ALPHA_MARK) or
                     edge.rightFace().flag(ALPHA_MARK))
        if edge.flag(ALPHA_MARK):
            continue

        radius = edge.length()/2
        if radius < alpha:
            radius2 = math.sq(radius)

            p1 = edge[0]
            p2 = edge[1]
            midPoint = (p1 + p2)/2

            if (squaredNorm(edge.dart().nextSigma()[1]-midPoint) >= radius2 and
                squaredNorm(edge.dart().nextAlpha().nextSigma()[1]-midPoint) >= radius2):
                edge.setFlag(ALPHA_MARK)

    print "  %d/%d edges and %d/%d faces marked." % (
        sum([edge.flag(ALPHA_MARK) and 1 or 0 for edge in delaunayMap.edgeIter()]), delaunayMap.edgeCount,
        sum([face.flag(ALPHA_MARK) and 1 or 0 for face in delaunayMap.faceIter()]), delaunayMap.faceCount)

    print "- finding connected components of unlabelled cells..."
    edgeComponent = [None] * delaunayMap.maxEdgeLabel()
    faceComponent = [None] * delaunayMap.maxFaceLabel()

    componentCount = 0
    for edge in delaunayMap.edgeIter():
        if edge.flag(ALPHA_MARK) or edgeComponent[edge.label()]:
            continue
        componentCount += 1
        boundary = [edge]
        while boundary:
            cell = boundary.pop()
            if hasattr(cell, "leftFace"):
                edge = cell
                if edge.flag(ALPHA_MARK) or edgeComponent[edge.label()]:
                    continue
                edgeComponent[edge.label()] = componentCount
                boundary.append(edge.leftFace())
                boundary.append(edge.rightFace())
            else:
                face = cell
                if face.flag(ALPHA_MARK) or faceComponent[face.label()]:
                    continue
                faceComponent[face.label()] = componentCount
                for dart in face.contour().phiOrbit():
                    boundary.append(dart.edge())

    for face in delaunayMap.faceIter():
        if face.flag(ALPHA_MARK) or faceComponent[face.label()]:
            continue
        componentCount += 1
        faceComponent[face.label()] = componentCount

    print "  %s unlabelled components found." % (componentCount, )

    if not beta:
        return edgeComponent

    print "- looking for unmarked triangles with radii >= beta (%s)..." % (
        beta, )

    badComponent = [True] * (componentCount+1)
    for face in delaunayMap.faceIter(skipInfinite = True):
        if face.flag(ALPHA_MARK):
            continue
        if delaunayMap.circumCircles[face.label()][1] >= beta:
            badComponent[faceComponent[face.label()]] = False

    for label in range(1, componentCount+1):
        if badComponent[label]:
            print "  marking connected component %d." % (
                label, )
            componentCount -= 1
    for edge in delaunayMap.edgeIter():
        if not edge.flag(ALPHA_MARK):
            edge.setFlag(ALPHA_MARK, badComponent[edgeComponent[edge.label()]])
    for face in delaunayMap.faceIter(skipInfinite = True):
        if not face.flag(ALPHA_MARK):
            face.setFlag(ALPHA_MARK, badComponent[faceComponent[face.label()]])

    print "  %s unlabelled components left." % (componentCount, )
    return componentCount
Exemple #51
0
def magnitude(U):
    S = 0
    for e in U:
        S += e*e
    mU = sq(S)
    return mU
Exemple #52
0
def Gtf(n,t,B):											#Rasprivedenie rasxoda topliva dvigatelya
	return n*(B/760.0)*sq((t+273.15)/288.15)              
Exemple #53
0
def Gtf(n,t,B):											#Расприведение расхода топлива двигателя
	return n*(B/760)*sq((t+273.15)/288.15)
Exemple #54
0
def cepr(n,t):											#Приведение удельного расхода топлива двигателя
	return n*sq(288.15/(t+273.15))	
Exemple #55
0
def Gvf(n,t,B):											#Rasprivedenie rasxoda  vozdyxa dvigatelya
	return n*(B/760.0)*sq(288.15/(t+273.15))	            
Exemple #56
0
def Nctf(n,t,B):										#Расприведение мощности силовой турбины двигателя
	return n*sq((t+273.15)/288.15)*(B/760)
Exemple #57
0
def dpi(w,h,d):
	return sq(w**2+h**2)/(d*1.0)
Exemple #58
0
def nf(n,t):											#Rasprivedenie chastoti vraweniya dvigatelya
	return n*sq((t+273.15)/288.15)                      
Exemple #59
0
def Nctf(n,t,B):										#Rasprivedenie mownosti silovoi tyrbini dvigatelya
	return n*sq((t+273.15)/288.15)*(B/760.0)              
Exemple #60
0
def Npr(n,t):                                        	#Приведение мощности двигателя
	return n*sq(288.15/(t+273.15))