Board index » delphi » Large data structures

Large data structures

In a previous article, ghs...@merle.acns.nwu.edu (George Hsieh) wrote:

Quote

>            I'm using an older version of Turbo Pascal compiler (V. 5.5)
>and I'm running into some problems because I want to implement a very large
>matrix of double precision floating reals.  And I need enough other stack
>space to do all the other computations.  The first problem is that I cannot
>create a large enough matrix (~100X100).  

This is one of the oldest and most frequently asked types of questions.

The easiest way to get space for what you want to do is something like this
type
   PMatrixCol = ^TMatrixCol;
   TMatrixCol = array[1..100] of double;

   TMatrixRow = array[1..100] of PMatrixCol;

var Matrix: TMatrixRow;

{Picture Matrix as a vertical array of pointers with TMatrixCols extending
 to the right of the pointers...}

   {Allocate mem for the columns...}
   For i := 1 do 100 do Matrix[i] := new(PMatrixCol);

   {do something with element(Row,Col)..}
   Matrix[Row]^[Col] := SomeValue;

This will take up (10,000 * SizeOf(Double) ) bytes for the TMatrixCols,
plus (100 * SizeOf(Pointer) ) for the pointers in a TMatrixRow.

 

Re:Large data structures


                I'm using an older version of Turbo Pascal compiler (V. 5.5)
and I'm running into some problems because I want to implement a very large
matrix of double precision floating reals.  And I need enough other stack
space to do all the other computations.  The first problem is that I cannot
create a large enough matrix (~100X100).  Anyone sucessfully solved this
problem?  Second, even if I could make this big a matrix, I'd probably run out
of space to do all the other things.  Would it be possible to put the routines
associated with this big matrix into a subprogram (i.e. separately compiled
unit) and call it from the main program?  Would this allow me to have the
storage I need in the main program while keeping a large matrix on the side?
Thanks in advance for your help.

George Hsieh
2225 North Campus Drive
Northwestern University, Evanston, IL 60201
Telephone : (708) 491-5286

Other Threads