function [R,RT]=sumLoop(N,rep)
    x=0; T=0; avgT=0;
    R=zeros(rep); RT=zeros(4); 
    // 29.03.2019 - ne radi u scilabu ugnjezdivanje tic toc pa moram sam ukupno 
    tic();
    for j=1:rep
        for i=1:N
            x=x+i*i;
        end        
        R(j)=x;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;
endfunction

function [R,RT]=sumVectLoop(N,rep)
    x=0; T=0; avgT=0;
    R=zeros(rep); RT=zeros(4);
    tic();
    for j=1:rep
        orgVect=1:N;
        orgKv=orgVect.*orgVect;
        x=sum(orgKv);
        R(j)=x;
    end
    T=toc();   
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;
endfunction

function [R,RT]=sumVectFLoop(N,delta,rep)
    x=0; T=0; avgT=0;
    R=zeros(rep); RT=zeros(4);
    tic();
    for j=1:rep
        orgVect=1:delta:N;
        orgKv=orgVect.*orgVect;
        x=sum(orgKv);
        R(j)=x;
    end
    T=toc();   
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;
endfunction

function [R,RT]=sumFLoop(N,delta,rep)
    x=0; T=0; avgT=0;
    R=zeros(rep); RT=zeros(4);
    tic();
    for j=1:rep
        i=1;
        while (i<N)
            x=x+i*i;
            i=i+delta;
        end
        R(j)=x;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;
endfunction

function [R,RT]=sumFLoopFor(N,delta,rep)
    x=0; T=0; avgT=0;
    R=zeros(rep); RT=zeros(4);
    tic();
    for j=1:rep
        for i=1:delta:N
            x=x+i*i;
        end
        R(j)=x;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;
endfunction

function [R,RT]=fiboNR(N,rep)
    // nerekurzivni fibonacci
    T=0; avgT=0;
    R=zeros(rep); RT=zeros(4);
    tic();
    for j=1:rep
        fib=zeros(N+1);
        for n=1:N
            if (n==1) || (n==2) then fib(n)=1;
            else fib(n)=fib(n-1)+fib(n-2);
            end
        end
        R(j)=fib(N);
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;     
endfunction

function x=fibRtmp(N)
    if (N<=2) then x=1 else x=fibRtmp(N-1)+fibRtmp(N-2);
    end
endfunction

function [R,RT]=fiboR(N,rep)
    avgT=0; T=0;
    R=zeros(rep); RT=zeros(4);
    tic();
    for j=1:rep
        Rlast=fibRtmp(N);
        R(j)=Rlast;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;      
endfunction

function [R,RT]=mtxGenMNOld(M,N,F,rep)
    avgT=0; T=0;
    mtxR=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        clear mtxR;
        for row=1:M
            for col=1:N
                mtxR(row,col)=(row*col)/F; 
            end
        end
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;    
    R=mtxR;  
endfunction

function [R,RT]=mtxGenMN(M,N,F,rep)
    avgT=0; T=0;
    mtxR=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        mtxR=zeros(M,N);
        for row=1:M
            for col=1:N
                mtxR(row,col)=(row*col)/F; 
            end
        end
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;    
    R=mtxR;  
endfunction

function [R,RT]=mtxVectGenMN(M,N,F,rep)
    avgT=0; T=0;
    mtxR=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        r=1:M; c=1:N;
        mtxR=r'*c;
        mtxR=mtxR/F;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;    
    R=mtxR;  
endfunction

function [R,RT]=mtxGenNNPow(N,X,F,rep)
    avgT=0; T=0;
    mtxR=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        mtxR=zeros(N,N);
        for row=1:N
            for col=1:N
                mtxR(row,col)=(row*col)/F; 
            end
        end
        mtxRpow=mtxR^X;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;    
    R=mtxRpow;  
endfunction

function [R,RT]=mtxVectGenNNPow(N,X,F,rep)
    avgT=0; T=0;
    mtxR=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        r=1:N;
        mtxR=r'*r;
        mtxR=mtxR/F;
        mtxRpow=mtxR^X;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;    
    R=mtxRpow;  
endfunction

function [R,RT]=rndMtxMulti(M,N,rep)
    // random generator matrica MxN i NxM plus mnozenje
    avgT=0; T=0;
    R=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        A=rand(M,N);
        B=rand(N,M);
        C=A*B;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;       
endfunction

function [R,RT]=rndMtxDivBack(N,rep)
    avgT=0; T=0;
    R=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        A=rand(N,N);
        b=rand(N,1);
        X=A\b;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;      
endfunction


function [R,RT]=rndMtxDivInv(N,rep)
    avgT=0; T=0;
    R=0;
    RT=zeros(4);
    tic();
    for j=1:rep
        A=rand(N,N);
        b=rand(N,1);
        X=inv(A)*b;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;       
endfunction

function [R,RT]=rndDet(N,rep)
    avgT=0; T=0;
    R=zeros(rep); 
    RT=zeros(4);
    tic();
    for j=1:rep
        A=rand(N,N);
        dA=det(A);
        R(j)=dA;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T; 
endfunction

function [R,RT]=rndDet0(N,rep)
    avgT=0; T=0;
    R=zeros(rep); 
    RT=zeros(4);
    tic();
    for j=1:rep
        A=rand(N,N);        
        c1=round(N*rand());
       // c2=round(N*rand());
        //mprintf('%d. Mijenjam %d sa %d\n',j,c1,c2);
        if (c1==0) then c1=1; end
       // if (c2==0) then c2=1; end
       // A(:,c2)=A(:,c1);    // izjednacim stupce, determinanta bi trebala postati 0!
        A(:,c1)=0;
        dA=det(A);
        R(j)=dA;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;       
endfunction

function [R,RT]=rndDet0X(N,rep)
    avgT=0; T=0;
    R=zeros(rep); 
    RT=zeros(4);
    tic();    
    for j=1:rep
        zrow=zeros(1,N);
        zcol=zeros(N,1);
        A=rand(N,N);        
        c1=round(N*rand());
        if (c1==0) then c1=1; end
        A(:,c1)=0;
        is0=0;
        for r=1:N
            if (A(:,r)==zcol) then is0=1; end
            if (A(r,:)==zrow) then is0=1; end
            if (is0==1) then break; end
        end
        if (is0==1) then dA=0 else dA=det(A); end
        R(j)=dA;
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;       
endfunction

function [R,RT,O]=rndSort(N,rep)
    avgT=0; T=0;
    R=zeros(rep); 
    O=zeros(rep); 
    RT=zeros(4);
    tic();
    for j=1:rep
        A=rand(N,1);
        O(j)=A(1);
        B=gsort(A);
        R(j)=B(1);
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;       
endfunction

function [R,RT,O]=rndSortRound(N,rep)
    avgT=0; T=0;
    O=zeros(rep); 
    R=zeros(rep); 
    RT=zeros(4);
    tic();   
    for j=1:rep
        A=rand(N,1);
        A=1000*A; A=round(A);
        O(j)=A(1);
        B=gsort(A);
        R(j)=B(1);
    end
    T=toc();
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T;       
endfunction

function [TSave,TLoad,Fsize]=rndMtxSaveLoad(N,rep)
    // 29.03. umjesto rand stavim pocetni rand, a onda sve ide +1 u petlji (da imam ralniji save time)
    totSave=0; totLoad=0;
    avgTSave=0; avgTLoad=0;
    TSave=zeros(4); TLoad=zeros(4);
    Fsize=zeros(rep);
    A=rand(N,N);
    tic();
    for j=1:rep// trazim N-ti broj
        A=A+j;
        tmpFn='C:\tmpSCI\dat'+string(j)+'.dat';
        save(tmpFn,"A");
        fs=fileinfo(tmpFn); Fsize(j)=fs(1);
    end
    totSave=toc();
    tic();
    for j=1:rep 
        tmpFn='C:\tmpSCI\dat'+string(j)+'.dat';
        load(tmpFn,"A");
    end
    totLoad=toc();
    avgTSave=totSave/rep;
    avgTLoad=totLoad/rep;
    TSave(1)=avgTSave;
    TSave(4)=totSave;
    TLoad(1)=avgTLoad;
    TLoad(4)=totLoad;
endfunction

function [R,RT]=sigAMSinFFT(f0,fc,N,rep,draw)
    x=0; avgT=0; T=0; R=0;
    minT=0; maxT=0;
    RT=zeros(4);    
    // f0 frekvencija originalnog signala
    // fc frekvencija nositelja
    // amplituda izmedu -1 - 1
    // N koliko T zelim uzeti kao generator
    fu=10*fc;
    T0=1/f0;

    Tall=N*T0;
    Tdelt=1/fu;    
    t=0:Tdelt:Tall;  
    tmp=size(t);  
    Nuzoraka=tmp(2);
    fftOd=0;    
    fftDelt=fu/Nuzoraka;
    fftDo=fu-fftDelt;
    fftX=fftOd:fftDelt:fftDo;
    Nfft=(size(fftX))(2);
    tic(); 
    for j=1:rep
        sig0=sin(2*%pi*f0*t);
        sigC=sin(2*%pi*fc*t);
        
        sigAM=sigC.*(1+sig0);
        fftAM=abs(fft(sigAM));    
       
        if (draw==1) then
            clf;
            subplot(2,1,1);
            plot(t,sigAM,'c',t,sig0,'k');
            subplot(2,1,2);
            plot(fftX(1:Nfft/2),fftAM(1:Nfft/2));
        end                 
    end
    T=toc();    
    avgT=T/rep;
    RT(1)=avgT;
    RT(4)=T; 
endfunction

// SETTINGS
Folder='C:\tmpSCI';
Nexecution=5;
Nponavljanja=100;
Nrekurzije=3;
NponavljanjaDatoteke=10;


// EXECUTION LOOP
for executor=1:Nexecution
    timer();
    fname = mopen(Folder+'\SCILAB-X2rez'+string(executor)+'.txt','wt');

    NS=[500000,1000000,2000000,4000000];
    NN=size(NS); Nc=NN(2);
    mfprintf(fname, 'Repetitions=%d\n',Nponavljanja);
    mfprintf(fname,'Function\tTotal\tAvg\tResult\n');
    for i=1:Nc 
        [r,t]=sumLoop(NS(i),Nponavljanja);
        mfprintf(fname,'sumLoop(%d)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
        [r,t]=sumVectLoop(NS(i),Nponavljanja);
        mfprintf(fname,'sumVectLoop(%d)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
        [r,t]=sumFLoop(NS(i),1,Nponavljanja);
        mfprintf(fname,'sumFLoop(%d,1)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    //    [r,t]=sumFLoopFor(NS(i),1,Nponavljanja);
    //    mfprintf(fname,'sumFLoopFor(%d,1)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    //    [r,t]=sumVectFLoop(NS(i),1,Nponavljanja);
    //    mfprintf(fname,'sumVectFLoop(%d,1)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    end
//    mfprintf(fname,'\n');
//
//    for i=1:Nc 
//        [r,t]=sumFLoop(NS(i)*0.05,0.05,Nponavljanja);
//        mfprintf(fname,'sumFLoop(%d,0.05)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
//        [r,t]=sumFLoopFor(NS(i)*0.05,0.05,Nponavljanja);
//        mfprintf(fname,'sumFLoopFor(%d,0.05)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
//        [r,t]=sumVectFLoop(NS(i)*0.05,0.05,Nponavljanja);
//        mfprintf(fname,'sumVectFLoop(%d,0.05)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
//    end
//    mfprintf(fname,'\n');
//
//    [r,t]=fiboNR(10,Nponavljanja);
//    mfprintf(fname,'fiboNR(10)\t%f\t%f\t%f\n',t(4),t(1),r(1));
//    [r,t]=fiboNR(100,Nponavljanja);
//    mfprintf(fname,'fiboNR(100)\t%f\t%f\t%f\n',t(4),t(1),r(1));
//    [r,t]=fiboNR(1000,Nponavljanja);
//    mfprintf(fname,'fiboNR(1000)\t%f\t%f\t%f\n',t(4),t(1),r(1));
//    [r,t]=fiboNR(1476,Nponavljanja);
//    mfprintf(fname,'fiboNR(1476)\t%f\t%f\t%f\n',t(4),t(1),r(1));
//
//    //for i=10:35
//    //    [r,t]=fiboR(i,Nrekurzije);
//    //    mfprintf(fname,'fiboR(%d,%dx)\t%f\t%f\t%f\n',i,Nrekurzije,t(4),t(1),r(1));    
//    //end
//    mfprintf(fname,'\n');
//
//    NS=[100,500,1000,2000];
//    NN=size(NS); Nc=NN(2);
//    for i=1:Nc
//        [r,t]=mtxGenMN(NS(i),NS(i),3,Nponavljanja);
//        mfprintf(fname,'mtxGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i),t(4),t(1)); 
//        [r,t]=mtxVectGenMN(NS(i),NS(i),3,Nponavljanja);
//        mfprintf(fname,'mtxVectGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i),t(4),t(1)); 
//        if i<Nc then
//            [r,t]=mtxGenMN(NS(i),NS(i)*2,3,Nponavljanja);
//            mfprintf(fname,'mtxGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i)*2,t(4),t(1)); 
//            [r,t]=mtxVectGenMN(NS(i),NS(i)*2,3,Nponavljanja);
//            mfprintf(fname,'mtxVectGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i)*2,t(4),t(1));  
//        end
//    end
//    mfprintf(fname,'\n');
//
//    for i=1:Nc
//        [r,t]=mtxGenNNPow(NS(i),3,NS(i)/2,Nponavljanja);
//        mfprintf(fname,'mtxGenNNPow(%d,3,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1)); 
//        [r,t]=mtxVectGenNNPow(NS(i),3,NS(i)/2,Nponavljanja);
//        mfprintf(fname,'mtxVectGenNNPow(%d,3,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1)); 
//        [r,t]=mtxGenNNPow(NS(i),11,NS(i)/2,Nponavljanja);
//        mfprintf(fname,'mtxGenNNPow(%d,11,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1)); 
//        [r,t]=mtxVectGenNNPow(NS(i),11,NS(i)/2,Nponavljanja);
//        mfprintf(fname,'mtxVectGenNNPow(%d,11,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1));   
//    end
//    mfprintf(fname,'\n');
//
//    NS=[100,1000,2000];
//    NN=size(NS); Nc=NN(2);
//    for i=1:Nc
//        [r,t]=rndMtxMulti(NS(i),NS(i)*2,Nponavljanja);
//        mfprintf(fname,'rndMtxMulti(%d,%d)\t%f\t%f\t\n',NS(i),NS(i)*2,t(4),t(1)); 
//        [r,t]=rndMtxMulti(NS(i)*2,NS(i),Nponavljanja);
//        mfprintf(fname,'rndMtxMulti(%d,%d)\t%f\t%f\t\n',NS(i)*2,NS(i),t(4),t(1)); 
//        [r,t]=rndMtxMulti(NS(i),NS(i),Nponavljanja);
//        mfprintf(fname,'rndMtxMulti(%d,%d)\t%f\t%f\t\n',NS(i),NS(i),t(4),t(1)); 
//    end
//    mfprintf(fname,'\n');
//
//    for i=1:Nc
//        [r,t]=rndMtxDivBack(NS(i),Nponavljanja);
//        mfprintf(fname,'rndMtxDivBack(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
//        [r,t]=rndMtxDivInv(NS(i),Nponavljanja);
//        mfprintf(fname,'rndMtxDivInv(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
//    end
//    mfprintf(fname,'\n');
//
//    for i=1:Nc
//        [r,t]=rndDet(NS(i),Nponavljanja);
//        mfprintf(fname,'rndDet(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
//        [r,t]=rndDet0(NS(i),Nponavljanja);
//        mfprintf(fname,'rndDet0(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
//        [r,t]=rndDet0X(NS(i),Nponavljanja);
//        mfprintf(fname,'rndDet0X(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
//    end
//    mfprintf(fname,'\n');

    NS=[500000,1000000,2000000,4000000];
	NN=size(NS); Nc=NN(2);
    for i=1:Nc
        [r,t]=rndSort(NS(i),Nponavljanja);
        mfprintf(fname,'rndSort(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
        [r,t]=rndSortRound(NS(i),Nponavljanja);
        mfprintf(fname,'rndSortRound(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
    end
    mfprintf(fname,'\n');

//    NS=[100,1000,3000];
//    NN=size(NS); Nc=NN(2);
//
//    for i=1:Nc
//        [tsave,tload,fs]=rndMtxSaveLoad(NS(i),NponavljanjaDatoteke);
//        mfprintf(fname,'rndMtxSaveLoad(%d)\n',NS(i));
//        mfprintf(fname,'Save\t%f\t%f\n',tsave(4),tsave(1));
//        mfprintf(fname,'Load\t%f\t%f\n',tload(4),tload(1));
//        mfprintf(fname,'FileSize\t%f\t%f\n\n',fs(1),fs(2));
//    end
//
//    [r,t]=sigAMSinFFT(100,1000,5,Nponavljanja,0);
//    mfprintf(fname,'sigAMSinFFT(100,1000,5,10,0)\nGen\t%f\t%f\n',t(4),t(1));
//    [r,t]=sigAMSinFFT(100,4000,5,Nponavljanja,0);
//    mfprintf(fname,'sigAMSinFFT(100,4000,5,10,0)\nGen\t%f\t%f\n',t(4),t(1));
//
//    [r,t]=sigAMSinFFT(100,1000,50,Nponavljanja,0);
//    mfprintf(fname,'sigAMSinFFT(100,1000,50,%d,0)\nGen\t%f\t%f\n',Nponavljanja,t(4),t(1));
//    [r,t]=sigAMSinFFT(100,4000,50,Nponavljanja,0);
//    mfprintf(fname,'sigAMSinFFT(100,4000,50,%d,0)\nGen\t%f\t%f\n',Nponavljanja,t(4),t(1));
//    
    exTimer=timer();
    mfprintf(fname,'CPU time\t%f',exTimer);
	mclose(fname);
end

/*
NS=[1000, 10000, 50000, 100000, 1000000];
NN=size(NS); Nc=NN(2);

mprintf('Repetitions=%d\n',Nponavljanja);
mprintf('Function\tTotal\tAvg\tResult\n');
for i=1:Nc 
    [r,t]=sumLoop(NS(i),Nponavljanja);
    mprintf('sumLoop(%d)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    [r,t]=sumVectLoop(NS(i),Nponavljanja);
    mprintf('sumVectLoop(%d)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    [r,t]=sumFLoop(NS(i),1,Nponavljanja);
    mprintf('sumFLoop(%d,1)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    [r,t]=sumFLoopFor(NS(i),1,Nponavljanja);
    mprintf('sumFLoopFor(%d,1)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    [r,t]=sumVectFLoop(NS(i),1,Nponavljanja);
    mprintf('sumVectFLoop(%d,1)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
end
mprintf('\n');

for i=1:Nc 
    [r,t]=sumFLoop(NS(i)*0.05,0.05,Nponavljanja);
    mprintf('sumFLoop(%d,0.05)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    [r,t]=sumFLoopFor(NS(i)*0.05,0.05,Nponavljanja);
    mprintf('sumFLoopFor(%d,0.05)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
    [r,t]=sumVectFLoop(NS(i)*0.05,0.05,Nponavljanja);
    mprintf('sumVectFLoop(%d,0.05)\t%f\t%f\t%f\n',NS(i),t(4),t(1),r(1));
end
mprintf('\n');

[r,t]=fiboNR(10,Nponavljanja);
mprintf('fiboNR(10)\t%f\t%f\t%f\n',t(4),t(1),r(1));
[r,t]=fiboNR(100,Nponavljanja);
mprintf('fiboNR(100)\t%f\t%f\t%f\n',t(4),t(1),r(1));
[r,t]=fiboNR(1000,Nponavljanja);
mprintf('fiboNR(1000)\t%f\t%f\t%f\n',t(4),t(1),r(1));
[r,t]=fiboNR(1476,Nponavljanja);
mprintf('fiboNR(1476)\t%f\t%f\t%f\n',t(4),t(1),r(1));

//for i=10:35
//    [r,t]=fiboR(i,Nrekurzije);
//    mprintf('fiboR(%d,%dx)\t%f\t%f\t%f\n',i,Nrekurzije,t(4),t(1),r(1));    
//end
mprintf('\n');

NS=[100,500,1000,2000];
NN=size(NS); Nc=NN(2);
for i=1:Nc
    [r,t]=mtxGenMN(NS(i),NS(i),3,Nponavljanja);
    mprintf('mtxGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i),t(4),t(1)); 
    [r,t]=mtxVectGenMN(NS(i),NS(i),3,Nponavljanja);
    mprintf('mtxVectGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i),t(4),t(1)); 
    if i<Nc then
        [r,t]=mtxGenMN(NS(i),NS(i)*2,3,Nponavljanja);
        mprintf('mtxGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i)*2,t(4),t(1)); 
        [r,t]=mtxVectGenMN(NS(i),NS(i)*2,3,Nponavljanja);
        mprintf('mtxVectGenMN(%d,%d,3)\t%f\t%f\t\n',NS(i),NS(i)*2,t(4),t(1));  
    end
end
mprintf('\n');

for i=1:Nc
    [r,t]=mtxGenNNPow(NS(i),3,NS(i)/2,Nponavljanja);
    mprintf('mtxGenNNPow(%d,3,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1)); 
    [r,t]=mtxVectGenNNPow(NS(i),3,NS(i)/2,Nponavljanja);
    mprintf('mtxVectGenNNPow(%d,3,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1)); 
    [r,t]=mtxGenNNPow(NS(i),11,NS(i)/2,Nponavljanja);
    mprintf('mtxGenNNPow(%d,11,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1)); 
    [r,t]=mtxVectGenNNPow(NS(i),11,NS(i)/2,Nponavljanja);
    mprintf('mtxVectGenNNPow(%d,11,%f)\t%f\t%f\t\n',NS(i),NS(i)/2,t(4),t(1));   
end
mprintf('\n');

NS=[100,1000,2000];
NN=size(NS); Nc=NN(2);
for i=1:Nc
    [r,t]=rndMtxMulti(NS(i),NS(i)*2,Nponavljanja);
    mprintf('rndMtxMulti(%d,%d)\t%f\t%f\t\n',NS(i),NS(i)*2,t(4),t(1)); 
    [r,t]=rndMtxMulti(NS(i)*2,NS(i),Nponavljanja);
    mprintf('rndMtxMulti(%d,%d)\t%f\t%f\t\n',NS(i)*2,NS(i),t(4),t(1)); 
    [r,t]=rndMtxMulti(NS(i),NS(i),Nponavljanja);
    mprintf('rndMtxMulti(%d,%d)\t%f\t%f\t\n',NS(i),NS(i),t(4),t(1)); 
end
mprintf('\n');

for i=1:Nc
    [r,t]=rndMtxDivBack(NS(i),Nponavljanja);
    mprintf('rndMtxDivBack(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
    [r,t]=rndMtxDivInv(NS(i),Nponavljanja);
    mprintf('rndMtxDivInv(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
end
mprintf('\n');

for i=1:Nc
    [r,t]=rndDet(NS(i),Nponavljanja);
    mprintf('rndDet(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
    [r,t]=rndDet0(NS(i),Nponavljanja);
    mprintf('rndDet0(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
    [r,t]=rndDet0X(NS(i),Nponavljanja);
    mprintf('rndDet0X(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
end
mprintf('\n');

for i=1:Nc
    [r,t]=rndSort(NS(i),Nponavljanja);
    mprintf('rndSort(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
    [r,t]=rndSortRound(NS(i),Nponavljanja);
    mprintf('rndSortRound(%d)\t%f\t%f\t\n',NS(i),t(4),t(1)); 
end
mprintf('\n');

NS=[100,1000,3000];
NN=size(NS); Nc=NN(2);

for i=1:Nc
    [tsave,tload,fs]=rndMtxSaveLoad(NS(i),NponavljanjaDatoteke);
    mprintf('rndMtxSaveLoad(%d)\n',NS(i));
    mprintf('Save\t%f\t%f\n',tsave(4),tsave(1));
    mprintf('Load\t%f\t%f\n',tload(4),tload(1));
    mprintf('FileSize\t%f\t%f\n\n',fs(1),fs(2));
end

[r,t]=sigAMSinFFT(100,1000,5,Nponavljanja,0);
mprintf('sigAMSinFFT(100,1000,5,10,0)\nGen\t%f\t%f\n',t(4),t(1));
[r,t]=sigAMSinFFT(100,4000,5,Nponavljanja,0);
mprintf('sigAMSinFFT(100,4000,5,10,0)\nGen\t%f\t%f\n',t(4),t(1));

[r,t]=sigAMSinFFT(100,1000,50,Nponavljanja,0);
mprintf('sigAMSinFFT(100,1000,50,%d,0)\nGen\t%f\t%f\n',Nponavljanja,t(4),t(1));
[r,t]=sigAMSinFFT(100,4000,50,Nponavljanja,0);
mprintf('sigAMSinFFT(100,4000,50,%d,0)\nGen\t%f\t%f\n',Nponavljanja,t(4),t(1));
*/

