On Wed, Mar 03, 2004 at 03:47:19PM +0100, Mikael Johansson wrote:
> So, once I've allocated my matrix, say
>
> GEN dell=cgetg(first_size+1,t_MAT);
> for(long j=1; j<=first_size; j++) {
> dell[j]=lgetg(second_size+1,t_COL);
>
> how do I actually fiddle with the elements? Upon trying to
>
> dell[first_index+1][second_index+1]=stoi(value);
>
> all I receive is a compile error:
> homology.c:220: invalid types `long int[int]' for array subscript
[Are you using a C++ compiler ? This warning seems odd.]
You have to cast data correctly. The customary way is to do
mael(dell,first_index+1,second_index+1)=(long) stoi(value)
or
coeff(dell,second_index+1,first_index+1)=(long) stoi(value)
where mael and coeff are macros.
Though it you data are small integers, you are likely to be better off
using
GEN dell=cgetg(first_size+1,t_VEC);
for(long j=1; j<=first_size; j++) {
dell[j]=lgetg(second_size+1,t_VECSALL);
and use the Flv_/Flm_ interface.
Cheers,
Bill.