defining a function acting on a matrix in python -
I want to define a simple task to swap two entries in the matrix, I currently have The following code is:
I am struggling to find a way to make it so that when I have any variable, current
(Where current = matrix [3] [2]
) if
section > works with a = 3, b = 2
on target metrics
I'm not sure what it is you want but at least it works with Python code Importing: Import
as np def swap (M, A, B, Direction): If Direction == 1: Entry = M [A, B] M [A, B ] = M [A-B] M [A-1, B] = Entry # One Test Matrix NP Randem. Print n = swap (n, 2,1,1) print n
This output:
[[1925] [74 38] [99 3 9]] [[25] [74 3 9] [99 38]]
Then swaps 38 and 39
Comments
Post a Comment