Mikael Johansson on Tue, 02 Mar 2004 13:08:12 +0100


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

Matrix initialization in Library mode


For a homology calculation application I am building, I need to calculate 
matrix ranks over any characteristic. I decided that the Pari library 
seems to help me do just this, and so started my coding and construction.

Now I've reached the point where I need to start involving the Pari 
library, and promptly run into slight problems. I need to initialize a 
(probably rather sparse) matrix with entries in {-1, 0, 1} for use with 
either the keri or ker_mod_p library calls. The users guide gives in 
section 4.3 an example on how to create a matrix by using the cgetg 
command recursively - first for the root, and then for the columns of the 
matrix; but on the other hand, the entries in section 4.5 specifying the 
handling of t_MAT and t_COL state that these are introduced for specific 
GP use and recommend that one uses standard malloced C matrices when 
programming in library mode.

Is there a way to build the matrix in malloced memory and then introduce 
it to Pari for use of the rank calculation functions? Or should I ignore 
the comment in section 4.5? The code example with cgetg allocated 4 t_COLs 
of size 5 as the initialization for a 4x3 matrix - why 5?

I obviously miss certain parts of the programming philosophy, and await 
enlightenment hopefully.

-- 
Mikael Johansson         |  To see the world in a grain of sand
mik@math.su.se           |   And heaven in a wild flower
                         |  To hold infinity in the palm of your hand
                         |   And eternity for an hour