Boost logo

Boost Users :

From: nisha kannookadan (nishak44_at_[hidden])
Date: 2007-11-29 04:34:04


Ok, I optimized my program (now its with pass by reference and the resize stuff is out):

void Wavelet::ttrans(matrix& At, int level)
{
        matrix cfe1, cfe2, cfo, cfe, c, d;
        int N,s2;
        
        N = (At.size1()+1)/2;
        s2 = At.size2();
        scalar_matrix zer(N,s2);
        
        for (int ii = 1; ii <= level; ii++)
        {
                
                cfo = subslice(At, 0,2,N, 0,1,s2);
                cfe = subslice(At, 1,2,N-1, 0,1,s2);
                
                c = (cfe + (subrange(cfo, 0,N-1, 0,s2)+subrange(cfo, 1,N, 0,s2))*0.5);
                
                zer.resize(N,s2,true);
                cfe1 = zer;
                cfe2 = zer;
                
                (subrange(cfe1, 0,N-1, 0,s2)).assign(cfe);
                (subrange(cfe2, 1,N, 0,s2)).assign(cfe);
                d = cfo-(cfe1+cfe2)*0.5;
                
            (subrange(At, 0,N-1, 0,At.size2())).assign(c);
            (subrange(At, N-1,2*N-1, 0,At.size2())).assign(d);
            
            N = N/2;
        }
        
        cfe1.clear();
        cfe2.clear();
        cfo.clear();
        cfe.clear();
        c.clear();
        d.clear();
        
}

But I guessed, its still not good enough, and wanted to work with pointer to mend copying..and the result was the next code piece, which compiles, but terminates when I run it..

void Wavelet::ttrans(matrix& At, int level)
{
        matrix cfe1, cfe2, *cfo, *cfe, *c, *d;
        int N,s2;
        
        N = (At.size1()+1)/2;
        s2 = At.size2();
        scalar_matrix zer(N,s2,0);
        
        for (int ii = 1; ii <= level; ii++)
        {
                
                *cfo = subslice(At, 0,2,N, 0,1,s2);
                *cfe = subslice(At, 1,2,N-1, 0,1,s2);
                
                *c = (*cfe + (subrange(*cfo, 0,N-1, 0,s2)+subrange(*cfo, 1,N, 0,s2))*0.5);
                
                zer.resize(N,s2,true);
                cfe1 = zer;
                cfe2 = zer;
                
                (subrange(cfe1, 0,N-1, 0,s2)).assign(*cfe);
                (subrange(cfe2, 1,N, 0,s2)).assign(*cfe);
                *d = *cfo-(cfe1+cfe2)*0.5;
                
            (subrange(At, 0,N-1, 0,At.size2())).assign(*c);
            (subrange(At, N-1,2*N-1, 0,At.size2())).assign(*d);
            
            N = N/2;
            cfe1.clear();
            cfe2.clear();
        }
        
}

Am I on the right track, or can I do much more for optimization. Do I still do a lot of copying?
And can anybody tell me, why this is not runnging?

I will check out the intel compiler.

Thanks.
}

_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net