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


Python Matrix.col方法代码示例

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


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

示例1: test_col_row

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import col [as 别名]
def test_col_row():
    x, y = symbols("xy")
    M = Matrix([[x,0,0],
                [0,y,0]])
    M.row(1,lambda x,i: x+i+1)
    assert M == Matrix([[x,0,0],
                        [1,y+2,3]])
    M.col(0,lambda x,i: x+y**i)
    assert M == Matrix([[x+1,0,0],
                        [1+y,y+2,3]])
开发者ID:Lucaweihs,项目名称:sympy,代码行数:12,代码来源:test_matrices.py

示例2: test_col_row

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import col [as 别名]
def test_col_row():
    x, y = symbols("x y")
    M = Matrix([[x,0,0],
                [0,y,0]])
    M.row(1,lambda r, j: r+j+1)
    assert M == Matrix([[x,0,0],
                        [1,y+2,3]])
    M.col(0,lambda c, j: c+y**j)
    assert M == Matrix([[x+1,0,0],
                        [1+y,y+2,3]])
开发者ID:robotment,项目名称:sympy,代码行数:12,代码来源:test_matrices.py

示例3: __init__

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import col [as 别名]
    def __init__(
            self,
            a_choice: int,
            b_choice: int,
            payoff_matrix: Matrix,
            previous_step: Optional):
        self.step_number = 1
        if previous_step:
            self.step_number = previous_step.step_number + 1

        self.a_choice = a_choice
        self.b_choice = b_choice

        self.a_gain = payoff_matrix.col(self.b_choice).T.tolist()[0]
        self.b_gain = payoff_matrix.row(self.a_choice).tolist()[0]
        self.min_upper_game_cost = self.upper_game_cost
        self.max_lower_game_cost = self.lower_game_cost

        if previous_step:
            self.a_gain = [sum(x) for x in
                           zip(self.a_gain, previous_step.a_gain)]
            self.b_gain = [sum(x) for x in
                           zip(self.b_gain, previous_step.b_gain)]
            self.min_upper_game_cost = min(
                (self.upper_game_cost, previous_step.min_upper_game_cost))
            self.max_lower_game_cost = max(
                (self.lower_game_cost, previous_step.max_lower_game_cost))
开发者ID:1v1expert,项目名称:UniversityTasks,代码行数:29,代码来源:algorithm_step.py

示例4: _find_extremums_by_axis

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import col [as 别名]
	def _find_extremums_by_axis(self, payoff_matrix: Matrix, axis: str, fn: Callable) -> List[Tuple]:
		if axis == 'columns':
			lines = [payoff_matrix.col(j).T.tolist()[0] for j in range(payoff_matrix.cols)]
		elif axis == 'rows':
			lines = [payoff_matrix.row(i).tolist()[0] for i in range(payoff_matrix.rows)]
		else:
			raise Exception("Axis should be 'rows' or 'columns'")
		
		return [(fn(line), line.index(fn(line))) for line in lines]
开发者ID:1v1expert,项目名称:UniversityTasks,代码行数:11,代码来源:numerical_solver.py


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