C++ help

Discussion in 'OT Technology' started by mrburner, Dec 2, 2003.

  1. mrburner

    mrburner Ron Paul 2008

    Joined:
    May 9, 2001
    Messages:
    7,448
    Likes Received:
    0
    Location:
    Phoenix
    well as some of you may know from the last program that i needed help with...i am in an advanced class that i shouldn't be in

    background: i am in cs251(principles of computer organization) and cs152(programming) but cs152 is a prereq for cs251...but i declared my major late and this was the best way to fit both in...now, with that aside, i struggle with the programs in the cs251 class...so any help is appreciated

    http://www.wooster.edu/math/sgray/CS251/assignments/Prog4.pdf

    that is the link to the program that i am having trouble with...i am so close to being done with this class, i'm fine with tests and everything else, but i really don't understand a lot of the programs he gives us (that is until some nice people on ot explain them to me)

    anyways, on this program, i have read it over a number of times and have no idea how to even start...so first off, can anyone help me on getting started and maybe we can move from there? thanks
     
  2. TerryMathews

    TerryMathews Guest

    Basically, he wants you to write a program that populates those arrays with random numbers (I think), and time runs of each function for 500, 1000, and 2000 values of n.

    Easiest way to do that will be to make them seperate functions and call them from the main function, having the main function handle the timing.
     
  3. mrburner

    mrburner Ron Paul 2008

    Joined:
    May 9, 2001
    Messages:
    7,448
    Likes Received:
    0
    Location:
    Phoenix
    i don't follow you at all...like i said, i'm a beginner and this stuff is advanced for me...is there any way you can dumb it down more than that for me? thanks
     
  4. mrburner

    mrburner Ron Paul 2008

    Joined:
    May 9, 2001
    Messages:
    7,448
    Likes Received:
    0
    Location:
    Phoenix
    please, anyone?
     
  5. StevesVR4

    StevesVR4 Get Arrested

    Joined:
    Jul 1, 2003
    Messages:
    7,328
    Likes Received:
    0
    Your professor provided the pseudocode in the .pdf file so that is a good start for the program. He also provided the slow and fast multiply functions so that is also something you don't have to worry about. First you will need to create three arrays that are NxN in size. N will be 500, 1000, and 2000 in your program so you will certainly want to #define N near the beginning of the program. After the arrays are created, you will need to initialize the values. I don't see where the assignment says how to initialize the arrays so you can probably do it however you want. Using random numbers between 1-100 is probably what I would do. Of course, to make sure the timings you receive are easily repeatable with no variation due to the multiplying, you can initialize the array with a fixed set of numbers. Just start at 0 and sequentially number the values from 0 to N*N. For the timing part, the languages (C, C++, Java) all have functions that allow you to retrieve the current time in milliseconds. You will want to get the time, then call the function P times, then get the time again. Subtract the ending time and the starting time and divide by P to get the average time per run. You will want to repeat that process for each of the functions. Then print out the average times for the three functions (slow multiply, fast multiply ijk order, and fast multiply ikj order). The research part will just be going to the manfacturer websites and digging out the cache sizes they use. Run the program on each of the different platforms to get the required results. Hope that helps.
     

Share This Page