Click here to Skip to main content
15,890,282 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: sending click message to child button of a window. Pin
_T("No name")11-Jan-10 21:52
_T("No name")11-Jan-10 21:52 
AnswerRe: sending click message to child button of a window. Pin
Roger Allen13-Jan-10 5:12
Roger Allen13-Jan-10 5:12 
GeneralRe: sending click message to child button of a window. Pin
_T("No name")13-Jan-10 5:55
_T("No name")13-Jan-10 5:55 
GeneralRe: sending click message to child button of a window. Pin
Roger Allen13-Jan-10 6:09
Roger Allen13-Jan-10 6:09 
GeneralRe: sending click message to child button of a window. Pin
_T("No name")13-Jan-10 6:20
_T("No name")13-Jan-10 6:20 
QuestionWhy does it print junk characters ? Pin
krish_kumar7-Jan-10 17:50
krish_kumar7-Jan-10 17:50 
AnswerRe: Why does it print junk characters ? Pin
oggenok647-Jan-10 18:34
oggenok647-Jan-10 18:34 
QuestionDifferent (Wrong) answers when not debugging Pin
Brien Smith-Martinez7-Jan-10 17:50
Brien Smith-Martinez7-Jan-10 17:50 
I am having a strange problem. When debugging using Code::Blocks, the following function returns the correct answers. However, when I am not debugging, it gives a correct answer the first time. Subsequent calls to the SAME function using the SAME parameter results in different answers, but not without a pattern:

The first three calls result in return values that are close to each other, after that, the return values are completely different from the first three, but identical to each other.
like so:
0.29012
0.29013
0.29102
0.42030
0.42030
...

double CalculateMSE( std::vector< complex<double> > inputv)
{
    int N = inputv.size();
    int M = 2*N+int(0.1*double(N) + 0.5);

    //%K is the time bandwidth product.

    int K = 100;

    int T = M;


    std::vector<double> m = mylinspace(0, M-1, M);
    std::vector<double> k = mylinspace( -1 * ceil(K/2), K/2, K+1);
    std::vector<double> freq_samples;

    for( int i=0; i < k.size(); i++)
        freq_samples.push_back( k[i] / T );
  
    std::vector<double> sinc_pulse( freq_samples.size() );
    sinc_pulse = mysinc(freq_samples);

    std::vector< std::vector< double > > sinc_pulse2;

    for(int i=0; i < m.size(); i++)
    {
        sinc_pulse2.push_back( sinc_pulse );
    }

    std::vector< matrix< std::complex<double> > > B;
    matrix< std::complex<double> > exp_freq_samples;

    std::complex<double> cplx_j(0,1);

    matrix< double > mx_freq_samples( 1, freq_samples.size() );

    for( int i=0; i < freq_samples.size(); i++)
    {
        mx_freq_samples(0,i) = freq_samples[i];
    }

    matrix< double > mx_m(1, m.size());

    for( int i=0; i < m.size(); i++)
    {
        mx_m(0,i) = m[i];
    }

    matrix< double > mx_sinc_pulse( sinc_pulse2.size(), sinc_pulse2[0].size() );

    for( int i=0; i<mx_sinc_pulse.size1(); i++)
    {
        for( int j=0; j<mx_sinc_pulse.size2(); j++)
        {
            mx_sinc_pulse(i, j) = sinc_pulse2[i][j];
        }
    }

    mx_sinc_pulse = trans(mx_sinc_pulse);

    matrix< double > mx_pp(1, m.size());
    matrix< double > trans_freq_samples( trans(mx_freq_samples) );
    complex< double > cplx_tmp  = -1.0 * cplx_j * 2.0 * PI;

    for( int i=0; i<N; i++)
    {
        matrix< std::complex<double> > Bmat;


        for (unsigned j = 0; j <mx_pp.size1 (); j++)
            for (unsigned jj = 0; jj <mx_pp.size2 (); jj++)
                mx_pp (j, jj) = i + m[jj];



        Bmat = prod(trans_freq_samples, mx_pp);
        Bmat *= cplx_tmp;


        for( int j=0; j < Bmat.size1(); j++)
        {
            for( int jj=0; jj < Bmat.size2(); jj++)
            {
                Bmat(j, jj) = mx_sinc_pulse(j, jj) * exp(Bmat(j, jj));

            }
        }

        B.push_back( Bmat );
    }


    matrix< complex<double> > P(K+1,M);


    for (int i=0; i < inputv.size(); i++)
    {
        P = inputv[i] * B[i] + P;
    }


    matrix< double > Kg(M, 1);

    for( int i=0; i<Kg.size1(); i++)
        Kg(i, 0) = 1;

    matrix< complex<double> > transP;

    matrix< complex<double> > tmpP = prod(herm(P) , P);

    matrix<double> mag_pi_sqrd(tmpP.size2(), 1);

    for( int i=0; i<mag_pi_sqrd.size1(); i++)
    {
        mag_pi_sqrd(i, 0) = real(tmpP(i,i));
    }

    matrix< double > MSE_tmp(M, 1);

    double sumtotal = 0;

    for( int i = 0; i < M; i++)
    {
        matrix< complex<double> > p_i(P.size1(), 1);
        matrix< complex<double> > p_j(P.size1(), M-1);
        for(int j=0; j < P.size1(); j++)
        {
            p_i(j, 0) = P(j, i);
        }

        for(int j=0; j < M-1; j++)
        {
            int ix = j;
            if( j >= i )
                ix++;
            for(int jj=0; jj < P.size1(); jj++)
                p_j(jj, j) = P(jj, ix);
        }
        matrix< complex<double> > hp_i = herm(p_i);
        matrix< complex<double> > prodhpi_pj = prod( hp_i, p_j );

        matrix< complex<double> > hermprodhpi_pj = herm(prodhpi_pj);



        matrix< double > mag_rhoij = real( prod( prodhpi_pj , hermprodhpi_pj ) );
        MSE_tmp(i, 0) = (Kg(i,0) * mag_rhoij(0,0)) / (mag_pi_sqrd(i,0)*mag_pi_sqrd(i,0));

        sumtotal += MSE_tmp(i, 0);
    }

    sumtotal = sumtotal/double(M);

    return sumtotal;
}


Any ideas?


AnswerRe: Different (Wrong) answers when not debugging Pin
Garth J Lancaster7-Jan-10 18:16
professionalGarth J Lancaster7-Jan-10 18:16 
GeneralRe: Different (Wrong) answers when not debugging Pin
Brien Smith-Martinez7-Jan-10 23:08
Brien Smith-Martinez7-Jan-10 23:08 
GeneralRe: Different (Wrong) answers when not debugging Pin
Garth J Lancaster9-Jan-10 14:01
professionalGarth J Lancaster9-Jan-10 14:01 
QuestionRe: Different (Wrong) answers when not debugging Pin
CPallini7-Jan-10 22:09
mveCPallini7-Jan-10 22:09 
AnswerRe: Different (Wrong) answers when not debugging Pin
Brien Smith-Martinez7-Jan-10 23:06
Brien Smith-Martinez7-Jan-10 23:06 
AnswerRe: Different (Wrong) answers when not debugging Pin
KarstenK7-Jan-10 23:20
mveKarstenK7-Jan-10 23:20 
QuestionHow to save content in IPicture to JPG format? Pin
Jingcheng7-Jan-10 9:04
Jingcheng7-Jan-10 9:04 
QuestionRe: How to save content in IPicture to JPG format? Pin
David Crow7-Jan-10 11:02
David Crow7-Jan-10 11:02 
AnswerRe: How to save content in IPicture to JPG format? Pin
Jingcheng7-Jan-10 13:29
Jingcheng7-Jan-10 13:29 
GeneralRe: How to save content in IPicture to JPG format? Pin
Hamid_RT7-Jan-10 20:40
Hamid_RT7-Jan-10 20:40 
Question[Solved]Network messages not being sent to the window procedure when using asynchrnous sockets [modified] Pin
zoopp7-Jan-10 7:53
zoopp7-Jan-10 7:53 
AnswerRe: Network messages not being sent to the window procedure when using asynchrnous sockets Pin
Richard MacCutchan7-Jan-10 9:05
mveRichard MacCutchan7-Jan-10 9:05 
AnswerRe: Network messages not being sent to the window procedure when using asynchrnous sockets Pin
Moak7-Jan-10 9:44
Moak7-Jan-10 9:44 
GeneralRe: Network messages not being sent to the window procedure when using asynchrnous sockets Pin
zoopp8-Jan-10 2:32
zoopp8-Jan-10 2:32 
QuestionScanline Polygon Fill Algorithm ??? Pin
a04.lqd7-Jan-10 7:48
a04.lqd7-Jan-10 7:48 
AnswerRe: Scanline Polygon Fill Algorithm ??? Pin
Nelek7-Jan-10 7:53
protectorNelek7-Jan-10 7:53 
GeneralRe: Scanline Polygon Fill Algorithm ??? Pin
a04.lqd7-Jan-10 7:55
a04.lqd7-Jan-10 7:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.