本文整理汇总了Python中LinearAlgebra.determinant方法的典型用法代码示例。如果您正苦于以下问题:Python LinearAlgebra.determinant方法的具体用法?Python LinearAlgebra.determinant怎么用?Python LinearAlgebra.determinant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearAlgebra
的用法示例。
在下文中一共展示了LinearAlgebra.determinant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: linePlaneIntersectionNumeric
# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import determinant [as 别名]
def linePlaneIntersectionNumeric(p1, p2, p3, p4, p5):
if not useNumeric:
return linePlaneIntersection(p1, p2, p3, p4, p5)
if useNumpy:
top = [
[1., 1., 1., 1.],
[p1[0], p2[0], p3[0], p4[0]], [p1[1], p2[1], p3[1], p4[1]],
[p1[2], p2[2], p3[2], p4[2]]]
topDet = numpy.linalg.det(top)
bottom = [
[1., 1., 1., 0.], [p1[0], p2[0], p3[0], p5[0]-p4[0]],
[p1[1], p2[1], p3[1], p5[1]-p4[1]], [p1[2], p2[2], p3[2], p5[2]-p4[2]]]
botDet = numpy.linalg.det(bottom)
else: # actually use numeric
top = Matrix.Matrix(
[[1., 1., 1., 1.], [p1[0], p2[0], p3[0], p4[0]], [p1[1], p2[1],
p3[1], p4[1]], [p1[2], p2[2], p3[2], p4[2]]])
topDet = LinearAlgebra.determinant(top)
bottom = Matrix.Matrix(
[[1., 1., 1., 0.], [p1[0], p2[0], p3[0], p5[0]-p4[0]], [p1[1],
p2[1], p3[1], p5[1]-p4[1]], [p1[2], p2[2], p3[2], p5[2]-p4[2]]])
botDet = LinearAlgebra.determinant(bottom)
if topDet == 0.0 or botDet == 0.0:
return False
t = -topDet/botDet
x = p4[0] + (p5[0]-p4[0]) * t
y = p4[1] + (p5[1]-p4[1]) * t
z = p4[2] + (p5[2]-p4[2]) * t
return [x, y, z]
示例2: EnergyFromBoxShape
# 需要导入模块: import LinearAlgebra [as 别名]
# 或者: from LinearAlgebra import determinant [as 别名]
def EnergyFromBoxShape(self, strain):
if self.atoms == None:
return
if self.debug:
unstrainedEnergy = self.atoms.GetPotentialEnergy()
unstrainedSCVs = ApplyStrain(self.atoms, strain)
if self.debug >= 2:
print "volume:",LA.determinant(self.atoms.GetUnitCell())
energy = self.atoms.GetPotentialEnergy()
# restore original state
self.atoms.GetUnitCell().SetBasis(unstrainedSCVs)
if self.debug:
if abs(unstrainedEnergy - self.atoms.GetPotentialEnergy()) > 1.e-10:
print unstrainedEnergy,self.atoms.GetPotentialEnergy()
raise StandardError
return energy