[fpc-pascal] Initializing dynamic arrays

Paulo Costa paco.mail.telepac.pt at gmail.com
Mon Jun 4 16:14:25 CEST 2012

On 04/06/2012 13:51, ingemar at ragnemalm.se wrote:
> I am writing a unit for dealing with matrix algebra with arbitrary sized
> matrices (as opposed to the FPC unit that deals with a few fixed size
> ones).

If you are writing that for your fun and to learn, go ahead, if what you 
really want is to have a unit to deal with arbitrary sized matrices, 
just go to:
and install the SdpoDynmatrix package.
There you have automatically ref counted arbitrary sized matrices with 
overloaded operators to add, subtract, multiply and invert them.

As for the initialization of a matrix you can do the, somewhat ugly but 
effective, trick of creating a function like:

// Converts a String representation to a TDMatrix
// a11 a12 a13; a12 a22 a23;
function StringToDMatrix(str: string): TDMatrix;

and then write:

A := StringToDMatrix('1 2 3; 4 5 6;');

Paulo Costa

More information about the fpc-pascal mailing list