title: Numpy: Linear system with specific conditions. No negative solutions
body: <p>I'm writing a Python code using numpy. In my code I use "linalg.solve" to solve a linear system of n equations in n variables. Of course the solutions could be either positive or negative. What I need to do is to have always positive solutions or at least equal to 0. To do so I first want the software to solve my linear system of equations in this form</p>
  
  <pre><code>x=np.linalg.solve(A,b)
  </code></pre>
  
  <p>in which x is an array with n variables in a specific order (x1, x2, x3.....xn),
  A is a n dimensional square matrix and b is a n-dimensional array.
  Now I thought to do this:</p>
  
  <p>-solve the system of equations</p>
  
  <p>-check if every x is positive</p>
  
  <p>-if not, every negative x I'll want them to be =0 (for example x2=-2 ---->x2=0)</p>
  
  <p>-with a generic xn=0 want to eliminate the n-row and the n-coloumn in the n dimensional square matrix A (I'll obtain another square matrix A1) and eliminate the n element in b obtaining b1.</p>
  
  <p>-solve the system again with the matrix A1 and b1</p>
  
  <p>-re-iterate untill every x is positive or zero</p>
  
  <p>-at last build a final  array of n elements in which I'll put the last iteration solutions and every variable which was equal to zero ( I NEED THEM IN ORDER AS IT WOULD HAVE BEEN NO ITERATIONS so if during the iterations it was x2=0 -----> xfinal=[x1, 0 , x3,.....,xn]</p>
  
  <p>Think it 'll work but don't know how to do it in python.</p>
  
  <p>Hope I was clear. Can't really figure it out! </p>