本文整理汇总了Python中pycast.common.matrix.Matrix.gauss_jordan方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.gauss_jordan方法的具体用法?Python Matrix.gauss_jordan怎么用?Python Matrix.gauss_jordan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycast.common.matrix.Matrix
的用法示例。
在下文中一共展示了Matrix.gauss_jordan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gauss_jordan_switch_column_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import gauss_jordan [as 别名]
def gauss_jordan_switch_column_test(self):
"""Test the gauss jordan algorithm if the first values is zero.
This test checks, if the lines are switched correctly.
"""
rows = 3
cols = 6
data = [
[0, 2, 0, 1, 0, 0],
[2, 3, 0, 0, 1, 0],
[3, 4, 1, 0, 0, 1]
]
mtrx = Matrix(cols, rows)
mtrx.initialize(data, rowBased=True)
exRes = [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[-0.75, 0.5, 0.25],
[0.5, 0.0, -1.5],
[0.0, 0.0, 1.0]
]
res = mtrx.gauss_jordan()
self.assertEqual(res.matrix, exRes)
示例2: gauss_jordan_linear_equation_system_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import gauss_jordan [as 别名]
def gauss_jordan_linear_equation_system_test(self):
"""Test gauss_jordan algorithm to solve a linear equation system."""
rows = 3
cols = 4
data = [
[1, 1, 1, 0],
[4, 2, 1, 1],
[9, 3, 1, 3]
]
mtrx = Matrix(cols, rows)
mtrx.initialize(data, rowBased=True)
# 2-dimensional list exRes[column][rows]
exRes = [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.5, -0.5, 0]
]
res = mtrx.gauss_jordan()
self.assertEqual(res.matrix, exRes)
示例3: gauss_jordan_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import gauss_jordan [as 别名]
def gauss_jordan_test(self):
"""Test gauss_jordan algorithm for the calculation of the inverse."""
rows = 3
cols = 6
data = [
[1, 2, 0, 1, 0, 0],
[2, 3, 0, 0, 1, 0],
[3, 4, 1, 0, 0, 1]
]
mtrx = Matrix(cols, rows)
mtrx.initialize(data, rowBased=True)
exRes = [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[-3, 2, 1],
[2, -1, -2],
[0, 0, 1]
]
res = mtrx.gauss_jordan()
self.assertEqual(res.matrix, exRes)