Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Python multi-dimensional arrays,matrix?

beginner07

New Coder
The problem is that,to write a function which generate a random matrix (bigger than 2x2). And calculate all the 2x2 part determinant of the original matrix.Then generate a new matrix with that values.
For example:
generated matrix
[4, 4, 8, 1
2, 6, 4, 7
1, 6, 6, 10]

calculated matrix
[16, -32, 52
6, 12, -2]
Thanks for your answer:)

That's my code but it works only on 3x4 matrix. How can i edit this to function on a random shape matrix?
Python:
arr = np.random.randint(1,10,(3,4))
matrix = np.zeros((2,3))

matrix[0,0] = int(np.linalg.det(np.array([arr[i][0:2] for i in range(0,2)])))
matrix[0,1] = int(np.linalg.det(np.array([arr[i][1:3] for i in range(0,2)])))
matrix[0,2] = int(np.linalg.det(np.array([arr[i][2:] for i in range(0,2)])))

matrix[1,0] = int(np.linalg.det(np.array([arr[i][0:2] for i in range(1,3)])))
matrix[1,1] = int(np.linalg.det(np.array([arr[i][1:3] for i in range(1,3)])))
matrix[1,2] = int(np.linalg.det(np.array([arr[i][2:] for i in range(1,3)])))
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom