help-octave
[Top][All Lists]
Advanced

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

least squares solution


From: Finnigan&Klaembt
Subject: least squares solution
Date: Wed, 1 Oct 2003 15:22:07 -0500

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



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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