uwhpsc-2016 / homework1

Homework #1
1 stars 1 forks source link

Increasing precision in Jupyter notebook #24

Closed gmikel closed 8 years ago

gmikel commented 8 years ago

HW #1 - Problem #3

I've finished programming most of Problem #3. As a check, I have the program print a few iterations so that I can verify against hand calculations. However, the vectors that are being output only show integer values.

How can I increase the precision so that I can more accurately verify against what I calculate by hand?

gmikel commented 8 years ago

I think I found my issue: Verified dtype. Ended up being an int64.

I'm going to leave this open in case I need any other help.

cswiercz commented 8 years ago

Numpy uses "partial" static typing. For example,

>>> import numpy
>>> a = numpy.array([1,2,3], dtype=numpy.int)
>>> b =  2.0*a  # 2.0 is a float. so does this output an int array or a double array?
array([ 2.,  4.,  6.])
>>> b.dtype  # turns out a double array
dtype('float64')
cswiercz commented 8 years ago

Also, if you end up having a completely separate question about HW 1 Problem 3 I would recommend opening a new issue just so it's easier for other students to find answers to their questions.

gmikel commented 8 years ago

Ahhh, I see now. I ended up tracking down the issue to one of the variables that I was iterating -- it ended up being of lower precision than I needed.

Thank you, Chris.