From fabio.ufla at yahoo.com.br  Mon Aug 31 19:09:03 2009
From: fabio.ufla at yahoo.com.br (=?iso-8859-1?Q?Fabio_Mathias_Corr=EAa?=)
Date: Mon, 31 Aug 2009 10:09:03 -0700 (PDT)
Subject: [Rd]  Problem in matrix definition?
In-Reply-To: <4A9B880E.9000405@statistik.tu-dortmund.de>
Message-ID: <798421.77107.qm@web59715.mail.ac4.yahoo.com>

The problem is that arrays are the same size. The only difference is how they were built!

The way to build the matrix should not influence in the outcome!

Below is the commented code in MatLab!

Neural Information Processing - Letters and Reviews Vol.8, No.2, August 2005

function Y = geninv(G)
    % Returns the Moore-Penrose inverse of the argument
    % Transpose if m < n
   [m,n]=size(G); transpose=false;
   if m<n
      transpose=true;
      A=G*G';
      n=m;
   else
   A=G'*G;
   end
   % Full rank Cholesky factorization of A
   dA=diag(A); tol= min(dA(dA>0))*1e-9;
   L=zeros(size(A));
   r=0;
   for k=1:n
      r=r+1;
      L(k:n,r)=A(k:n,k)-L(k:n,1:(r-1))*L(k,1:(r-1))';
% Note: for r=1, the substracted vector is zero
      if L(k,r)>tol
         L(k,r)=sqrt(L(k,r));
         if k<n
            L((k+1):n,r)=L((k+1):n,r)/L(k,r);
         end
      else
         r=r-1;
      end
   end
   L=L(:,1:r);
% Computation of the generalized inverse of G
   M=inv(L'*L);
   if transpose
      Y=G'*L*M*M*L';
   else
      Y=L*M*M*L'*G';
   end


Thanks!

? ???????????? F?bio Mathias Corr?a
Estat?stica e Experimenta??o Agropecu?ria/UFLA
                     Brazil


      ____________________________________________________________________________________
Veja quais s?o os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com



[Rd] Problem in matrix definition?
=?iso-8859-1?Q?Fabio_Mathias_Corr=EAa?=