Ask Your Question
0

Functions of the elements of a matrix

asked 2024-03-03 16:38:08 +0100

Cyrille gravatar image

I have a matrix say

M=[[10,12],[25,2]]

And I would like to create a function of the type

$f_1(M,i)=2M[i][0]+3M[i][1]$

I perfectly understand that neither M[i][0]nor M[i][1]are declared variable. Is there a solution to my problem ? Or should I explore an other way ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2024-03-03 17:56:04 +0100

Max Alekseyev gravatar image

updated 2024-03-03 17:58:24 +0100

Is this what you want?

f_1 = lambda M,i: 2*M[i,0]+3*M[i,1]
print( f_1(Matrix([[10,12],[25,2]]), 1) )
edit flag offensive delete link more

Comments

Thanks Max

Cyrille gravatar imageCyrille ( 2024-03-03 18:25:45 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-03-03 16:38:08 +0100

Seen: 577 times

Last updated: Mar 05