Ask Your Question
1

passing an array of values or a matrix to a user defined function, also expected the array or the matrix as output...How can we do this?

asked 2016-03-19 15:00:56 +0100

noufalasharaf gravatar image

passing an array of values or a matrix to a user defined function, also expected the array or the matrix as output...How can we do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-19 17:54:10 +0100

calc314 gravatar image

Sage is built on Python, which is not strongly typed. So, you can easily pass a variety of objects in and out of functions. For example:

def example(a,b):
    c = a*b
    return(c)

If you pass matrices into this function, it will pass a matrix out.

a=matrix(2,2,[1,2,3,4])
b=matrix(2,2,[5,6,7,8])
example(a,b)

gives the result

[19 22]
[43 50]
edit flag offensive delete link more

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: 2016-03-19 15:00:56 +0100

Seen: 422 times

Last updated: Mar 19 '16