First time here? Check out the FAQ!

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 9 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

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]
Preview: (hide)
link

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: 9 years ago

Seen: 452 times

Last updated: Mar 19 '16