I\'m having some strange behavior in my python code related to - and -=. I\'m writing a QR decomposition using numpy, and have the following line o
You could get different results from x - y and x -= y if the data types of x and y differ.
For example:
import numpy as np
x = np.array(range(0,6))
y = np.array(np.arange(0,3,0.5))
print x - y
x -= y
print x
This prints out:
[ 0. 0.5 1. 1.5 2. 2.5]
[0 0 1 1 2 2]
It may be worth making sure your arrays' dtypes are exactly as you expect (e.g. you're not inadvertently using integer or float32 arrays instead of float64), paying particular attention to arrays used on the left-hand side of -=.