home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!wupost!monsanto.com!skws02!bcschu
- From: bcschu@skws02.monsanto.com (Brett Schultz)
- Subject: reading in a matrix from a file
- Message-ID: <1992Jul22.213617.18402@tin.monsanto.com>
- Sender: news@tin.monsanto.com (USENET News System)
- Organization: Monsanto Company
- Date: Wed, 22 Jul 1992 21:36:17 GMT
- Lines: 35
-
- What is the fastest way to allocate space for and read in a matrix from a file?
-
- e.g.
-
- For a 2X3 matrix the file looks like:
- 1
- 2
- 3 - end of first row
- 4
- 5
- 6 - end of second row
-
- The way i was doing it was to first allocate space for the int ** (in this case
- 2 of them)
-
- then allocate space for the 3 int * as I read through the file.
- I'm sure there is a faster way to do this.
-
- Note: I have total control of how the file is set up.
-
-
- I was wondering if anyone has any ideas on how to allocate space for the matrix
- using the least possible number of malloc calls (normally the matrix I am
- reading in is a 20,000X30 matrix so I want to save the number of malloc calls)
- and could you use fread or something like that to read in the matrix at one
- time and store it in memory. Remember I can make the file look anyway I want
- to make the storage of the matrix the fastest as possible.
-
- Thanks,
-
- Brett Schultz
- email: bcschu@tin.monsanto.com
-
-
-
-