title: lsqr result strongly depends on weights
body: <p>I need to solve:</p>
  
  <pre><code>argmin||W*FT^-1(Ax)-W*p||
  </code></pre>
  
  <p>using lsqr. p is image, x is k-space matrix, A is a matrix and W is a weighting matrix. In order to pass them to matlab lsqr, I vectorized p, x and W.</p>
  
  <p>This is my code:</p>
  
  <pre><code>b=W.*p;
  x=lsqr(@(x1,modo)FUNC(x1,W_vector,A,modo),b,tol,maxit);
  X_k_lsqr=reshape(x,dim(1),dim(2),dim(3));
  X_lsqr=real(ifftn(X_k_lsqr)).*MASK(:,:,:,1);
  </code></pre>
  
  <p>%% Auxiliary function</p>
  
  <pre><code>function [result modo]=FUNC(x1,W_vector,A,modo)
      %Computes y=A*x for modo='notransp'
      %Computes y=A'*x for modo='transp'
      switch modo
          case 'notransp'
              res=A*x1;
              R1=reshape(res,norient,dim(1)*dim(2)*dim(3));
              for co=1:norient
                  R2(:,:,:,co)=reshape(R1(co,:),dim(1),dim(2),dim(3));
                  FR(:,:,:,co)=ifftn(R2(:,:,:,co));
                  aux=FR(:,:,:,co);
                  R3(co,:)=aux(:).';
              end
              result=W.*R3(:); 
          case 'transp'
              RR1=reshape(x1./(W+eps),norient,dim(1)*dim(2)*dim(3));
              for co=1:norient
                  RR2(:,:,:,co)=reshape(RR1(co,:),dim(1),dim(2),dim(3));
                  FRR(:,:,:,co)=fftn(RR2(:,:,:,co));
                  aux=FRR(:,:,:,co);
                  RR3(co,:)=aux(:).'; 
              end
              result=A'*RR3(:); 
      end
  end
  </code></pre>
  
  <p>As W appears in both terms of the minimization problem, I would have expected the image I obtain as a result to be almost independent on W values.</p>
  
  <p>The image looks qualitatively the same if I change W, but its values strongly depend on W. I don't know if something is wrong with my code.</p>
  
  <p>Should I actually obtain almost the same values for different W?</p>