![]() |
|
#1
|
|||
|
|||
Do you have a time for a help meDo you have a time for a help me
I made programm which read and wrote .csv file in two – dim array on dinamic memori (big matrix 1000 x 500). The .csv have “0” and “1” and “,”. That I made two matrix (which both had “-1” on all position), first counter “1” in colums big matrix and wrote this position, second counter “1” in rows big matrix and wrote this position. This is small example : H matrix 1 0 1 0 1 0 0 0 0 1 1 1 Cmax=3 1 1 1 1 Rmax=4 First matrix for position for colums in big matrix Cmax 0 2 0 2 1 3 2 3 3 -1 3 -1 Counter “1” for colums 3 2 3 2 Second matrix for position for rows in big matrix Rmax 0 0 1 0 2 -1 2 1 -1 -1 3 2 -1 -1 -1 3 Counter “1” for rows 2 1 3 4 My final program isn’t good because include more memory at dinamical space and can’t compile it. I have idea but I can’t realise it because I need more knowledge. My idea is that only read big matrix and when to take one element from big matrix synchronous to fill first and secund matrix. Dimension first matrix is [Cmax] x [1000] (Cmax is Counter “1” for colums) and dimension second matrix is [Rmax] x [500] (Rmax is Counter “1” for rows). I think that need one function for counter Cmax and Rmax. So you have a time pleas send me your e – mail address or make at yahoo.com because your discretion and I send you my program and .csv file because can’t put .csv file at GID Forum Thank you. Send me replay message. Do you can help me. Tell me How do you send .csv file and my programm |
|||
|
#2
|
|||
|
|||
Re: Do you have a time for a help meQuote:
I'm not exactly sure what exactly your assignment is, so I will outline a program to perform my guess as to your task. If it doesn't help you, then I am sorry... If all you need to do is to count the number of ones in each column and count the number of ones in each row, then you don't need to store the entire huge array in memory. Just make arrays for the counters and update them as each row is read from the file. Code:
Regards, Dave Footnote: Since these are arrays of ints and you might want to make sure that they start with all zeros, maybe calloc() would be a better function than malloc(). If you use malloc, then I think you need a separate loop (or, maybe, you could call setmem()) to make sure that all of the onesInCol[] elements are set equal to zero before beginning the read operations. Last edited by davekw7x : 06-Nov-2007 at 15:30.
|
|
#3
|
|||
|
|||
Re: Do you have a time for a help meThank you for information and see my code which can't compile because need more memory
CPP / C++ / C Code:
Last edited by admin : 06-Nov-2007 at 19:32.
Reason: Please insert your C/C++ example codes between [CPP] and [/CPP] tags
|
|
#4
|
|||
|
|||
Re: Do you have a time for a help meQuote:
NOW we can see EXACTLY what you are trying to do. Thanks! CPP / C++ / C Code:
Last edited by Howard_L : 06-Nov-2007 at 18:35.
|
|
#5
|
|||
|
|||
Re: Do you have a time for a help meQuote:
In the other thread you said that you were using Visual Studio Version 6. Here's how: 1. Don't try to include <alloc.h>. It isn't there. 2. You must change every place where the word "far" appears. There is no more "far" stuff. 3. You should get rid of all of those ugly, unnecessary casts in the malloc() statements. It's not "wrong" to put them there, but they really clutter up the scene.) CPP / C++ / C Code:
This program compiles with Visual C++ version 6. There are numerous other style "tweaks" that I would do if it were mine, but maybe that's clean enough for now. Now, to test the allocation part without actually running the program with real data, I made a "worst case" test which would happen if all of the matrix values were 1: CPP / C++ / C Code:
Results after compiling with Visual C++ version 6.0 on my Windows XP workstation: Code:
I haven't tried to analyze the program design or implementation (and I won't), but at least you should be able to get it to compile with Visual C++ so that you can test/debug it. If you have any specific questions, ask. Regards, Dave Footnotes: 1. Programs compiled with the old compilers (with the "far" data types) for the old operating systems could only access about a megabyte of memory. Your program requires much more than that in data memory. Even with modern compilers and operating systems you must learn to be aware of your program's demands on memory and other resources. 2. I can't believe that you really need to hold all of the data in memory all at the same time. I respectfully suggest that you think about how you can perform the task with less memory. I outlined an approach to counting ones in rows and columns that takes far less memory. If you need to do more, then you may need more, but think about it anyhow. |
Recent GIDBlog
Compress Your Web Site by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Asynchronous transfer question | crystalattice | Miscellaneous Programming Forum | 2 | 24-Jan-2007 20:39 |
| constructors/classes | mapes479 | C++ Forum | 3 | 19-Nov-2006 17:34 |
| Fortran problem... | Justin Fox | Miscellaneous Programming Forum | 6 | 24-Oct-2006 15:30 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 15:13 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The