a gmp matrix as a function's argument

Bogdan Damski bodzio at lanl.gov
Wed Jun 22 21:22:53 CEST 2005


Hello!

I have a problem with sending a mpq_t matrix from one C function to
another. I read the manual and wrote different smaple programs that 
run correctly, but  I can not handle this problem. 

The simplest program that illustrates my problems is the following:
------------------------------------------------------------------
#include<stdio.h>
#include<gmp.h>                                                                                             void fill_vector(mpq_t w[][]);
                                                                                                  int main(){
    int i, j;
    mpq_t w[10][2];
                                                                                                           for(i= 0; i< 10; i++)
        for(j= 0; j< 2; j++)   mpq_init( w[i][j] );
                                                                                              
    fill_vector(w);
    mpq_out_str(stdout, 10, w[0][0]);
    printf("\n");
                                                                                               
    return 0;
}
void fill_vector(mpq_t w[][]){
    int i;
    for(i= 0; i< 10; i++)   mpq_set_str(w[i][0], "1/4", 10);
}
-------------------------------------------------------------------

When I compile this program I get:
gmp.c: In function `fill_vector':
gmp.c:21: invalid use of array with unspecified bounds
the line 21 is the line with for loop in fill_vector function.


Can you please tell me how shall I modify the declaration of fill_vector
function to make that simple program running  successsfully ?????

Interestingly, when I try to do the same with "w" being a vector, e. g. 
mpq_t w[10], and change w[][] into w[] everyting works!

I would appreciate greatly any advice!
Bogdan 



More information about the gmp-discuss mailing list