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


Python LinearAlgebra.generalized_inverse方法代码示例

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


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

示例1: __init__

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import generalized_inverse [as 别名]
    def __init__(self, atoms, constraints):
	self.atoms = atoms
	natoms = len(self.atoms)
	nconst = reduce(operator.add, map(len, constraints))
	b = Numeric.zeros((nconst, natoms), Numeric.Float)
	c = Numeric.zeros((nconst,), Numeric.Float)
	i = 0
	for cons in constraints:
	    cons.setCoefficients(self.atoms, b, c, i)
	    i = i + len(cons)
	u, s, vt = LinearAlgebra.singular_value_decomposition(b)
	self.rank = 0
	for i in range(min(natoms, nconst)):
	    if s[i] > 0.:
		self.rank = self.rank + 1
	self.b = b
	self.bi = LinearAlgebra.generalized_inverse(b)
	self.p = Numeric.identity(natoms)-Numeric.dot(self.bi, self.b)
	self.c = c
	self.bi_c = Numeric.dot(self.bi, c)
	c_test = Numeric.dot(self.b, self.bi_c)
	if Numeric.add.reduce((c_test-c)**2)/nconst > 1.e-12:
	    Utility.warning("The charge constraints are inconsistent."
			    " They will be applied as a least-squares"
			    " condition.")
开发者ID:fxia22,项目名称:ASM_xf,代码行数:27,代码来源:ChargeFit.py

示例2: testgeneralizedInverse

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import generalized_inverse [as 别名]
 def testgeneralizedInverse (self):
     "Test LinearAlgebra.generalized_inverse"
     import LinearAlgebra
     ca = Numeric.array([[1,1-1j],[0,1]])
     cai = LinearAlgebra.inverse(ca)
     cai2 = LinearAlgebra.generalized_inverse(ca)
     self.failUnless(eq(cai, cai2))
开发者ID:mikeswamp,项目名称:numeric_copy,代码行数:9,代码来源:test.py

示例3: screwMotion

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import generalized_inverse [as 别名]
    def screwMotion(self):
	import LinearAlgebra
	axis, angle = self.rotation().axisAndAngle()
	d = self.vector*axis
	x = d*axis-self.vector
	r0 = Numeric.dot(LinearAlgebra.generalized_inverse(
	                    self.tensor.array-Numeric.identity(3)), x.array)
	return VectorModule.Vector(r0), axis, angle, d
开发者ID:fxia22,项目名称:ASM_xf,代码行数:10,代码来源:Transformation.py

示例4: fitPolynomial

# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import generalized_inverse [as 别名]
def fitPolynomial(order, points, values):
    if len(points) != len(values):
	raise ValueError, 'Inconsistent arguments'
    if type(order) != type(()):
	order = (order,)
    order = tuple(map(lambda n: n+1, order))
    if not _isSequence(points[0]):
	points = map(lambda p: (p,), points)
    if len(order) != len(points[0]):
	raise ValueError, 'Inconsistent arguments'
    if Numeric.multiply.reduce(order) > len(points):
	raise ValueError, 'Not enough points'
    matrix = []
    for p in points:
	matrix.append(Numeric.ravel(_powers(p, order)))
    matrix = Numeric.array(matrix)
    values = Numeric.array(values)
    inv = LinearAlgebra.generalized_inverse(matrix)
    coeff = Numeric.dot(inv, values)
    #coeff = LinearAlgebra.linear_least_squares(matrix, values)[0]
    coeff = Numeric.reshape(coeff, order)
    return Polynomial(coeff)
开发者ID:OS2World,项目名称:DEV-PYTHON-UTIL-ScientificPython,代码行数:24,代码来源:Polynomial.py


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