home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18832 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  2.6 KB

  1. Path: sparky!uunet!munnari.oz.au!comp.vuw.ac.nz!newshost.wcc.govt.nz!kosmos.wcc.govt.nz!THOMSON_N
  2. From: thomson_n@kosmos.wcc.govt.nz
  3. Newsgroups: comp.lang.c++
  4. Subject: Copying 4D array's
  5. Date: 8 Jan 1993 11:02:23 GMT
  6. Organization: Wellington City Council (Public Access), Wgtn, Nz
  7. Lines: 66
  8. Message-ID: <1ijmvvINNk05@golem.wcc.govt.nz>
  9. Reply-To: thomson_n@kosmos.wcc.govt.nz
  10. NNTP-Posting-Host: kosmos.wcc.govt.nz
  11.  
  12.  
  13. I've got a problem, which I hope someone on the net can solve for me.
  14.  
  15. I'm new to the C language, but are programming in highc over the summer.
  16. My main problem is the run time of certain parts of my program. 
  17.  
  18. I am  trying to copy a 4D array to another 4D array and to a 1D array.
  19.  
  20.  
  21. Currently I am simply using a nested for loop.
  22.  
  23. "
  24.  
  25. for(i=0;i<=MAX_BUS;i++)
  26.    for(j=year_req.start;j<=year_req.end;j++)
  27.       for(k=month_req.start;k<=month_req.end;k++)
  28.            for(l=min_isle;l<=max_isle;l++)
  29.  
  30.             graph_data[i][j][k][l] = column_A[i][j][k][l];
  31.  
  32.  
  33.  
  34. "
  35.  
  36. It is not possible, given the rest of the program, to get around copying the
  37. array over, but I really need a faster method of doing this. Currently It's 
  38. running on a digital 433dx workstation.
  39.  
  40.  
  41. The second problem I have, which is much the same as the first, is that I
  42. also need to copy this 4D array to a 1D array. This is done by calling a
  43. function with the arguments of year, month, day, and halfhour. This function
  44. date_to_hh_num returns an integer value, of the number of half hours since
  45. 1/1/1960
  46.  
  47. The question here, is again, is there any way to speed up this process?
  48.  
  49.  
  50. for(yr1=year_req.start;yr1<=year_req.end;yr1++)
  51.    yr = yr1-year_req.start;
  52.    for(mo=month_req.start;mo<=month_req.end;mo++)
  53.       for(da=day_req.start;da<=day_req.end;da++)
  54.          for (hh=time_req.start;hh<=time_req.end;hh++) {
  55.               current_hh_num = date_to_hh_num(yr,mo,da,hh);
  56.               graph_data[current_hh_num] = column_A[yr][mo][da][hh];
  57.              }
  58. "
  59.  
  60.  
  61. Thanks in advance :)
  62.  
  63. Replies by email please.
  64.  
  65.  
  66. --
  67.  
  68. +----------------------------------------------------------------------------+
  69. | cheesecake = Nigel Thomson            Email:  THOMSON_N@kosmos.wcc.govt.nz |
  70. |  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   |
  71. |          They don't call me cheesecake for nothing                    ::   |
  72. |    :::::)        Chocolate cheesecake with Baileys :)                 ::   |
  73. |    ::                                      *NOT* a Happy Smily Monster::   |
  74. |    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   |
  75. +----------------------------------------------------------------------------+
  76.  
  77.  
  78.