简体   繁体   English

创建矩阵,其 position 值由 function 给出

[英]create matrix whose position value is given by a function

I have to create a 5X5 matrix from a function given below.我必须从下面给出的 function 创建一个 5X5 矩阵。

f(x,y) = x(1-y) + y(1-x); f(x,y) = x(1-y) + y(1-x); where 0 < x,y <=5其中 0 < x,y <=5

where x indicate row position and y indicates columns.其中 x 表示行 position 并且 y 表示列。 How do I create a matrix such that bottom left corner is f(0,0) and top left corner has value f(5,5)如何创建一个矩阵,使左下角为 f(0,0),左上角的值为 f(5,5)

M,N = 5,5
matrix = [[((x*(1-y))+(y*(1-x))) for y in range(M)] for x in range(N)]
for i in range(N):
    print(matrix[i])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建一个dict,其值是给定单词所有可能的字谜的集合 - Create a dict whose value is the set of all possible anagrams for a given word 创建具有随机位置的矩阵 - Create a Matrix with random position Python:创建 class,它的构造函数接受用户给定的 function,它成为一个方法 - Python: Create class whose constructor accepts a user-given function which becomes a method 创建值是列表的字典 - Create dictionary whose value is a list 根据给定的约束创建矩阵 - Create a matrix based on given constraints 给定一个向量场 (dx, dy),将位置 (Row, Col) 处的矩阵值移动到新位置 (Row + dx, Column + dy) - Given a vector field (dx, dy), move matrix value at position (Row, Col) to new position (Row + dx, Column + dy) Pandas 创建一个框架,其条目是应用于其他 DataFrame 的相应条目的 function 的值 - Pandas create a frame whose entries are the value of a function applied to the respective entries of other DataFrames 如何创建一个numpy矩阵,其值满足几个条件? - How to create a numpy matrix, whose values meet several conditions? 创建一个 3d numpy 数组,其条目在给定方向上增加 - Create a 3d numpy array whose entries increase in the given direction 从函数创建矩阵 - Create a matrix from a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM