0
$\begingroup$

The below function is representing an algorithm, so how can I get its complexity? I don't mean the time of running by using the tic .. toc, I mean how many operation (Additions and multiplications) are performed in this loop.

for times=1:m;                                    
    for col=1:N;                                  
        product(col)=abs(T(:,col)'*r_n);          
    end
    [val,pos]=max(product);                      
    Aug_t=[Aug_t,T(:,pos)];                      
    T(:,pos)=zeros(M,1);                         
    aug_y=(Aug_t'*Aug_t)^(-1)*Aug_t'*Yy;          
    r_n=Yy-Aug_t*aug_y;                            
    pos_array(times)=pos;                        
end

Size of parameters, m = 256 , N = 256, T= [256,256] and M = [256,1]

$\endgroup$
0
$\begingroup$

You should know what each operator (i.e., *) and each called function (i.e. product) does. Then add up those operations. For instance, I'm pretty sure that in Matlab, the way you're building up Aug_t means that Aug_t' * Aug_t generates a vector dot-product, so for each element in Aug_t there's a multiply-accumulate.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.