[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Resizing vectors and matrices

From: John Lamb
Subject: Re: [Help-gsl] Resizing vectors and matrices
Date: Tue, 14 Sep 2004 17:52:40 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040114

address@hidden wrote:
I am using the GNU Scientific Library to write software that simulates the evolutionary process. Specifically, I have an ODE-system and need to add equations at run-time corresponding to new mutants entering the system. Since I do not know from the outset how large the system will be at its peak, it would be convenient to resize the matrices and vectors containing the parameters when needed. However, I have not been able to find any clean way of doing this.

You could look at how the C++ standard template library allows you to increase the size of a vector. This uses two numbers: the size is what you use and the capacity is what you have available. You can resize (change the size) whenever you want. If the new size exceeds the capacity, you create new vectors with capacity the first power of two bigger than the new size, copy and reassign.

All of this is a lot easier in C++ than in C because you can just extend gsl vectors to do what you want. But it should still be reasonably easy in C.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]