当前位置: 首页>>代码示例>>Python>>正文


Python LinearAlgebra.eigenvalues方法代码示例

本文整理汇总了Python中LinearAlgebra.eigenvalues方法的典型用法代码示例。如果您正苦于以下问题:Python LinearAlgebra.eigenvalues方法的具体用法?Python LinearAlgebra.eigenvalues怎么用?Python LinearAlgebra.eigenvalues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinearAlgebra的用法示例。


在下文中一共展示了LinearAlgebra.eigenvalues方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testEigenvalues

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import eigenvalues [as 别名]
 def testEigenvalues(self):
     """
     From bug #545259 -- illegal value to DGEEV routine
     """
     import LinearAlgebra
     a = Numeric.array([[2,3], [4,5]])
     v = LinearAlgebra.eigenvalues(a)
     assert_eq(v, Numeric.array([3.5-math.sqrt(57)/2.,
                                 3.5+math.sqrt(57)/2.]))
开发者ID:mikeswamp,项目名称:numeric_copy,代码行数:11,代码来源:test.py

示例2: testHeigenvalues

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import eigenvalues [as 别名]
 def testHeigenvalues(self):
     """
     From bug #464980.
     """
     import LinearAlgebra
     a = Numeric.array([[1.0, 0.01j], [-0.01j, 1.0]])
     v = LinearAlgebra.eigenvalues(a)
     assert_eq(v, [1.01+0.j, 0.99+0.j])
     Hv = LinearAlgebra.Heigenvalues(a)
     assert_eq(v, [1.01+0.j, 0.99+0.j])
开发者ID:mikeswamp,项目名称:numeric_copy,代码行数:12,代码来源:test.py

示例3: Vector

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import eigenvalues [as 别名]
me.faces.extend(me.verts[0],me.verts[1],me.verts[2]) # Add the faces, they reference the verts in polyline 1 and 2

scn = Blender.Scene.GetCurrent()
ob = scn.objects.new(me)

print ob.getLocation()

po = []
      
po.extend([1,2,3])
po.extend([2,3])

b = []

c =  la.eigenvectors(a)
d = la.eigenvalues(a)

opa = Vector(c[1][0])

print c[0], 'Mas por que'
print c[1][0], 'Mas por que v1' , opa.magnitude
print c[1][1], 'Mas por que v2'
print c[1][2], 'Mas por que v3'



b =  [Vector(c[1][0]),Vector(c[1][1]),Vector(c[1][2])]

print b,'Felipe b '

开发者ID:duststorm,项目名称:lodpbr,代码行数:31,代码来源:polyFill.py

示例4: showcircle

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import eigenvalues [as 别名]

#.........这里部分代码省略.........
              hy**2*cx**4-12*hx**2*cy*ay*gy*dy-12*hy**2*cx*ax*gx*dx-8*hy*hx*r**2*bx*by-
              6*hy*hx*r**2*ax*cy-12*hy**2*cy*ay*gx*dx+8*hy*hx*cy*by*cx*gy-8*hy*hx*cy*by*cx*dy-
              12*hy*hx*cy*ay*gx*gy+12*hy*hx*cy*ay*gx*dy+12*hy*hx*cy*ay*dx*gy-
              12*hy*hx*cy*ay*dx*dy-8*hy*hx*by**2*gx*gy+8*hy*hx*by**2*gx*dy+8*hy*hx*by**2*dx*gy-
              8*hy*hx*by**2*dx*dy+2*hy*hx*cx**2*by*gx-2*hy*hx*cx**2*by*dx+8*hy*hx*cy*cx*bx*gx-
              8*hy*hx*cy*cx*bx*dx+10*hy*hx*cx**2*bx*gy-10*hy*hx*cx**2*bx*dy-12*hy*hx*cx*ax*gx*gy+
              12*hy*hx*cx*ax*gx*dy+12*hy*hx*cx*ax*dx*gy-12*hy*hx*cx*ax*dx*dy-8*hy*hx*bx**2*gx*gy+
              8*hy*hx*bx**2*gx*dy+8*hy*hx*bx**2*dx*gy-8*hy*hx*bx**2*dx*dy-8*hx**2*cx*bx*cy*gy+
              8*hx**2*cx*bx*cy*dy-12*hx**2*cx*ax*gy*dy,

              -2*hx**2*cy**3*gy-2*hy**2*cx**3*gx+2*hy**2*cx**3*dx-4*hy*hx*r**2*cx*by+
              2*hy*hx*cy*cx**2*gx+2*hx**2*cy**3*dy-4*r**2*cx*bx*hx**2-4*r**2*cy*by*hy**2-
              2*hy**2*cy**2*cx*gx+2*hy**2*cy**2*cx*dx+4*hy**2*cy*by*gx**2+4*hy**2*cy*by*dx**2+
              4*hx**2*cy*by*gy**2+4*hx**2*cy*by*dy**2+2*hy*hx*cx**3*gy-2*hy*hx*cx**3*dy+
              4*hy**2*cx*bx*gx**2+4*hy**2*cx*bx*dx**2-2*hx**2*cy*cx**2*gy+2*hx**2*cy*cx**2*dy+
              4*hx**2*cx*bx*gy**2+4*hx**2*cx*bx*dy**2+2*hy*hx*cy**3*gx-2*hy*hx*cy**3*dx-
              8*hy**2*cy*by*gx*dx-4*hy*hx*r**2*bx*cy-8*hx**2*cy*by*gy*dy-2*hy*hx*cy*cx**2*dx-
              8*hy*hx*cx*bx*gx*gy+8*hy*hx*cx*bx*gx*dy+8*hy*hx*cx*bx*dx*gy-
              8*hy*hx*cx*bx*dx*dy-8*hy**2*cx*bx*gx*dx-8*hx**2*cx*bx*gy*dy+2*hy*hx*cy**2*cx*gy-
              2*hy*hx*cy**2*cx*dy-8*hy*hx*cy*by*gx*gy+8*hy*hx*cy*by*gx*dy+
              8*hy*hx*cy*by*dx*gy-8*hy*hx*cy*by*dx*dy,

              cx**2*hy**2*gx**2-2*cx**2*hy**2*gx*dx+cx**2*hy**2*dx**2-2*r**2*hx*hy*cx*cy+
              cy**2*hx**2*gy**2-2*cy**2*hx**2*gy*dy+cy**2*hx**2*dy**2+cy**2*hy**2*gx**2-
              2*cy**2*hy**2*gx*dx+cy**2*hy**2*dx**2-2*cy**2*hx*hy*gy*gx+2*cy**2*hx*hy*dy*gx+
              2*cy**2*hx*hy*gy*dx-2*cy**2*hx*hy*dy*dx+cx**2*hx**2*gy**2-2*cx**2*hx**2*gy*dy+
              cx**2*hx**2*dy**2-r**2*hy**2*cy**2-2*cx**2*hx*hy*gy*gx+2*cx**2*hx*hy*dy*gx+
              2*cx**2*hx*hy*gy*dx-2*cx**2*hx*hy*dy*dx-r**2*hx**2*cx**2]

    # def z(t):
    #     res = 0
    #     for x in coeffs:
    #         res = res*t + x
    #     return res

    # def zdot(t):
    #     res = 0
    #     i = len(coeffs)
    #     for x in coeffs[:-1]:
    #         res = res*t + (i-1)*x
    #         i -= 1
    #     return res

    # def newton(t):
    #     # newton iteration to find the zero of z with t being the starting value for t
    #     if t < 0: t = 0
    #     if t > 1: t = 1
    #     slow = 1
    #     try:
    #         isz=z(t)
    #     except (ValueError, ArithmeticError):
    #         return
    #     loop = 0
    #     while abs(isz) > 1e-6:
    #         try:
    #             nt = t - slow * isz/zdot(t)
    #             newisz = z(nt)
    #         except (ValueError, ArithmeticError):
    #             slow *= 0.5 # we might have slow down the newton iteration
    #         else:
    #             t = nt
    #             isz = newisz
    #             if slow <= 0.5:
    #                 slow *= 2
    #         if loop > 100:
    #             break
    #         loop += 1
    #     else:
    #         return t

    # def ts():
    #     epsilon = 1e-5
    #     res = []
    #     count = 100
    #     for x in range(count+1):
    #        t = newton(x/float(count))
    #        if t is not None and 0-0.5*epsilon < t < 1+0.5*epsilon:
    #            res.append(t)
    #     res.sort()
    #     i = 1
    #     while len(res) > i:
    #         if res[i] > res[i-1] + epsilon:
    #             i += 1
    #         else:
    #             del res[i]
    #     return res

    # use Numeric to find the roots (via an equivalent eigenvalue problem)
    import Numeric, LinearAlgebra
    mat = Numeric.zeros((10, 10), Numeric.Float)
    for i in range(9):
        mat[i+1][i] = 1
    for i in range(10):
        mat[0][i] = -coeffs[i+1]/coeffs[0]
    ists = [zero.real for zero in LinearAlgebra.eigenvalues(mat) if -1e-10 < zero.imag < 1e-10 and 0 <= zero.real <= 1]

    for t in ists:
        isl = (xdot(t)*(x(t)-gx)+ydot(t)*(y(t)-gy))/(xdot(t)*cos+ydot(t)*sin)
        c.fill(path.circle_pt(x(t), y(t), 1), [color.rgb.green])
        c.stroke(path.circle_pt(gx+isl*cos, gy+isl*sin, r), [color.rgb.green])
开发者ID:mjg,项目名称:PyX-svn,代码行数:104,代码来源:newbox.py

示例5: exercise_eigensystem

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import eigenvalues [as 别名]
def exercise_eigensystem():
  m = [0.13589302585705959, -0.041652833629281995, 0.0,
       -0.02777294381303139, 0.0, -0.028246956907939123,
       -0.037913518508910102, -0.028246956907939123, 0.028246956907939127,
       0.066160475416849232, 0.0, -1.998692119493731e-18, 0.0,
       1.9342749002960583e-17, 2.1341441122454314e-17, -0.041652833629281995,
       0.16651402880692701, -0.041652833629282252, -0.054064923492613354,
       -0.041657741914063608, -0.027943612435735281, 0.058527480224229975,
       -0.027943612435735132, -0.034820867346713427, -0.030583867788494697,
       0.062764479782448576, 1.2238306785281e-33, 0.0, 2.0081205093967302e-33,
       8.4334666705394195e-34, 0.0, -0.041652833629282252,
       0.13589302585705959, 0.0, -0.041574928784987308, -0.028246956907939064,
       0.0, -0.028246956907939064, 0.063090910812553094,
       0.028246956907939068, -0.034843953904614026, -1.9986921194937106e-18,
       -8.9229029691439759e-18, 1.0316952905846454e-17, 3.3927420561961863e-18,
       -0.02777294381303139, -0.05406492349261334, 0.0, 1.0754189352289423,
       0.0, 0.055233150062734049, -0.030424256077943676, 0.02480889398479039,
       -0.024808893984790394, -0.024808893984790425, 0.0,
       -6.8972719971392908e-18, -1.7405118013554239e-17,
       6.1312902919038241e-18, -4.3765557245111121e-18, 0.0,
       -0.041657741914063601, -0.041574928784987308, 0.0, 1.0754189352289425,
       0.02824584556921347, 0.0, 0.056206884746120872, -0.028245845569213546,
       -0.02824584556921347, -0.027961039176907447, 5.9506047506615062e-18,
       0.0, -1.4122576510436466e-18, -7.3628624017051534e-18,
       -0.028246956907939123, -0.027943612435735277, -0.028246956907939064,
       0.055233150062734056, 0.028245845569213474, 0.058637637326162888,
       -0.021712364921140592, 0.038218912676148069, -0.039777184406252442,
       -0.036925272405022302, 0.0015582717301043682, 4.0451470549537404e-18,
       0.0, -1.3724767734658202e-17, -1.7769914789611943e-17,
       -0.037913518508910102, 0.058527480224229982, 0.0, -0.030424256077943652,
       0.0, -0.021712364921140592, 0.28175206518101342, 0.0039066487534216467,
       -0.0039066487534216484, -0.26003970025987289, 0.0,
       7.5625035918149771e-18, 1.2380916665439571e-17, -1.0148697613996034e-16,
       -9.6668563066335756e-17, -0.028246956907939123, -0.027943612435735128,
       -0.028246956907939064, 0.02480889398479039, 0.056206884746120879,
       0.038218912676148069, 0.0039066487534216484, 0.058637637326162798,
       -0.031992570455625299, -0.042125561429569719, -0.026645066870537512,
       4.0451470549537242e-18, 9.6341055014789307e-18, -2.0511818948105707e-17,
       -1.4922860501580496e-17, 0.028246956907939127, -0.034820867346713427,
       0.063090910812553094, -0.024808893984790394, -0.028245845569213508,
       -0.039777184406252442, -0.0039066487534216501, -0.031992570455625306,
       0.2922682186182603, 0.043683833159674099, -0.26027564816263499,
       -5.2586006938540899e-18, 0.0, 9.7867664544895616e-18,
       1.5045367148343648e-17, 0.066160475416849232, -0.030583867788494701,
       0.028246956907939068, -0.024808893984790466, -0.028245845569213474,
       -0.036925272405022302, -0.26003970025987289, -0.042125561429569719,
       0.043683833159674092, 0.29696497266489519, -0.0015582717301043699,
       -7.5250966340669269e-19, 2.6213138712286628e-17,
       -1.5094268920622606e-17, 1.1871379455070714e-17, 0.0,
       0.062764479782448576, -0.034843953904614026, 0.0, -0.027961039176907457,
       0.0015582717301043665, 0.0, -0.026645066870537509, -0.26027564816263499,
       -0.0015582717301043699, 0.28692071503317257, -3.8759778199373453e-18,
       3.9691789817943108e-17, -8.14982209920807e-18, 3.5417945538672385e-17,
       -1.998692119493731e-18, 1.6308338425568088e-33, -1.9986921194937102e-18,
       -6.8972719971392892e-18, 5.950604750661507e-18, 4.0451470549537412e-18,
       7.5625035918149756e-18, 4.0451470549537242e-18, -5.2586006938540899e-18,
       -7.5250966340669346e-19, -3.8759778199373446e-18, 0.054471159454508082,
       0.0064409353489570716, 0.0035601061597435495, -0.044470117945807464,
       0.0, 0.0, -8.9229029691439759e-18, -1.7405118013554239e-17, 0.0, 0.0,
       1.2380916665439569e-17, 9.6341055014789307e-18, 0.0,
       2.6213138712286628e-17, 3.9691789817943114e-17, 0.0064409353489570777,
       0.47194161564298681, -0.17456675614101194, 0.29093392415301783,
       1.9342749002960583e-17, 1.4951347746978839e-33, 1.0316952905846454e-17,
       6.1312902919038033e-18, -1.4122576510436468e-18,
       -1.3724767734658202e-17, -1.0148697613996034e-16,
       -2.0511818948105704e-17, 9.7867664544895616e-18,
       -1.5094268920622603e-17, -8.1498220992080684e-18,
       0.0035601061597435478, -0.17456675614101194, 0.61470061296798617,
       0.4365737506672307, 2.1341441122454314e-17, 1.5911491532730484e-34,
       3.392742056196186e-18, -4.3765557245111453e-18, -7.3628624017051534e-18,
       -1.7769914789611943e-17, -9.6668563066335731e-17,
       -1.4922860501580496e-17, 1.5045367148343648e-17, 1.1871379455070717e-17,
       3.5417945538672392e-17, -0.044470117945807464, 0.29093392415301783,
       0.4365737506672307, 0.77197779276605605]
  #
  m = flex.double(m)
  m.resize(flex.grid(15,15))
  s = tntbx.eigensystem.real(m)
  e_values = s.values()
  #
  if (Numeric is not None):
    n = Numeric.asarray(m)
    n.shape = (15,15)
    n_values = LinearAlgebra.eigenvalues(n)
    assert len(e_values) == len(n_values)
    #
    print '               Eigenvalues'
    print '      %-16s %-16s' % ('TNT','Numpy')
    for i,e,n in zip(count(1), e_values, n_values):
      if (isinstance(e, complex)): e = e.real
      if (isinstance(n, complex)): n = n.real
      print "  %2d %16.12f %16.12f" % (i, e, n)
  #
  sorted_values = e_values.select(
    flex.sort_permutation(data=e_values, reverse=True))
  assert approx_equal(sorted_values, [
    1.1594490522786849, 1.0940938851317932, 1.0788186474215089,
    0.68233800454109983, 0.62042869735706307, 0.53297576878337871,
    0.18708677344352156, 0.16675360561093594, 0.12774949816038345,
    0.071304124011754358, 0.02865105770313877, 0.027761263516876356,
#.........这里部分代码省略.........
开发者ID:cctbx,项目名称:tntbx,代码行数:103,代码来源:tst_large_eigen.py


注:本文中的LinearAlgebra.eigenvalues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。