simple question

This is a discussion on simple question within the C Programming forums, part of the General Programming Boards category; Dear All, I want to have a code with a formula N-1 N-1 aut[m]=summation x(n)x(n+m) n=0 n= 0 if I ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    38

    simple question

    Dear All,
    I want to have a code with a formula
    N-1 N-1
    aut[m]=summation x(n)x(n+m)
    n=0 n= 0
    if I have code like

    Code:
    for (m=0;m<N;m++)
    {
           for (n=0;n<N;n++)
               {
                  aut[m]+=x(n)*x(n+m);
               }
    }
    will this work?
    Last edited by lwong; 10-20-2003 at 03:03 AM.

  2. #2
    Black Mage Extraordinaire VegasSte's Avatar
    Join Date
    Oct 2002
    Posts
    167
    Have you tried it in a c compiler?
    It seems sound enough!

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    38
    Yes, I have complied it, no any error, but the results are out of my expectation. say x(n) is a sequence like:
    Code:
    x(n)={1.0,2.0,3.0,3.5}, and N=4.
    when the program runs at some points, take an example , x(5) (when n=3,m=2), the program dont know what value x(5) is? it will return me a radom number which is not i want. How can I solve this problem?
    Thank you.

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156
    Originally posted by lwong
    Yes, I have complied it, no any error, but the results are out of my expectation. say x(n) is a sequence like:
    Code:
    x(n)={1.0,2.0,3.0,3.5}, and N=4.
    when the program runs at some points, take an example , x(5) (when n=3,m=2), the program dont know what value x(5) is? it will return me a radom number which is not i want. How can I solve this problem?
    Thank you.
    Whithout code to look at, we can only guess. And my guess is that you've defined x to be an array of 5 values, which means x(0) thru x(4). x(5) does not exist so you are looking at random data outside your array.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 08:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 11:15 AM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 05:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21