help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

least squares solution


From: albert treblataf
Subject: least squares solution
Date: Wed, 1 Oct 2003 13:42:24 -0700 (PDT)

Hello, First of all Octave is great software.
I'm running a modal parameter curve fitting function in Octave and I'm having
problems running out of memory. Also the calculation is taking around 90 seconds
on my machine. The following is part of my function that seems to be the
problem. it builds the matrices for the least squares solution.
My questions are:
1) Has any one an idea how to further optimise this code?
2) if the same code were an application written in "c" would it run faster?
function SOL = lestsquarestest
nh=30;
m = 13;
n = 10;
L = 384;
% create artificial complex data for test
hr = (2*rand(384,30))-1;
hi = (2*rand(384,30))-1;
h = hr + i * hi;
Pdenr = (2*rand(384,11))-1;
Pdeni = (2*rand(384,11))-1;
Pden = Pdenr + i * Pdeni;
Pnumr = (2*rand(384,14))-1;
Pnumi = (2*rand(384,14))-1;
Pnum = Pnumr + i * Pnumi;
%form matrices for least squares solution
SOLROW = zeros(L*nh,(m+1)*nh + n);
WCUM = zeros(L*nh,1);
for hc = 1:nh,
    T = zeros(L,n);
    for i = 1:n,
        T(:,i) = Pden(:,i) .* h(:,hc);
    end  
    W = h(:,hc) .* Pden(:,n+1);
    SOLROW((hc-1)*L + 1 : hc*L , (hc-1)*(m+1) + 1 : hc*(m+1)) = Pnum;
    SOLROW((hc-1)*L + 1 : hc*L , (m+1)*nh + 1 : (m+1)*nh + n) = -T;
    WCUM((hc-1)*L + 1 : hc*L,1 ) = W;
end
 
SOL=zeros((m+1)*nh + n,1);
SOL = SOLROW \ WCUM;
return

Thanks in advance
albert


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
reply via email to

[Prev in Thread] Current Thread [Next in Thread]