uwhpsc-2016 / homework1

Homework #1
1 stars 1 forks source link

Exercise #3, Output format for D,L,U #31

Open jhyearsley opened 8 years ago

jhyearsley commented 8 years ago

I am wondering if there is a preferred way to output the three matrices D,L,U -- as a dictionary, a tuble, etc.? Seems like a dictionary might be the most useful way...

alyfarahat commented 8 years ago

I had the same question, but figured out the answer only after looking at / running the unit tests.

cswiercz commented 8 years ago

D, L, and U are supposed to be the appropriate matrices of type numpy.ndarray.

Python functions can have multiple output and the multiple outputs can be parsed in the parent function. For example,


def func(x):
    a = x+1
    b = x-1
    return a,b

bubba, gump = func(4)
print bubba  # prints 5
print gump  # prints 3

What's actually happening is that func is returning a Python tuple. tuple entries can be obtained via the comma delimited approach used above. So really, what's going on is the following:

items = (3, 6, 8)
a, b, c = items
print a  # prints 3

That should help.