title: NumPy Error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
body: <p>I am working on an Image Convolution code using numpy:</p>
  
  <pre><code>def CG(A, b, x, imax=10, epsilon = 0.01):
      steps=np.asarray(x)
      i = 0
      r = b - A * x
      d = r.copy()
      delta_new = r.T * r
      delta_0 = delta_new
      while i &lt; imax and delta_new &gt; epsilon**2 * delta_0:
          q = A * d
          alpha = float(delta_new / (d.T * q))
          x = x + alpha * d
          if i%50 == 0:
              r = b - A * x
          else:
              r = r - alpha * q
          delta_old = delta_new
          delta_new = r.T * r
          beta = float(delta_new / delta_old)
          d = r + beta * d
          i = i + 1
          steps = np.append(steps, np.asarray(x), axis=1)
      return steps
  </code></pre>
  
  <p>I get the below error:</p>
  
  <pre><code>ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  </code></pre>
  
  <p>on line <code>while i &lt; imax and delta_new &gt; epsilon**2 * delta_0:</code></p>
  
  <p>Could anyone please tell me what am I doing wrong ? </p>