How to pass an array 2-D

A

Aleramo

I have this function:

double calcolo_errore (gsl_vector_complex *w_k, int
elementi,gsl_vector_complex *steering_vector_c_t, int teta_l, int
teta_r, int fi_r, int fi_l, int counter, double f_k_piu_uno[][])
{
int fi_j, teta_i ;
double valore_errore ;

for (teta_i = 0 ; teta_i <= 90 ; teta_i++)
{
for (fi_j = 0 ; fi_j <= 360 ; fi_j++)
{
valore_errore += f_k_piu_uno [teta_i][fi_j] * pow (fabs
(calcolo_P_y_k (w_k, elementi, steering_vector_c_t) -
calcolo_P_riferimento (teta_i, fi_j, teta_l, teta_r, fi_r, fi_l)), 2) ;
}
}
printf ("\nCiclo: %d, Errore = %lf\n\n", counter, valore_errore) ;

return valore_errore ;
}

i receive the error message:

implementazione_algoritmov6.c:397: error: invalid use of array with
unspecified bounds

the row 397 is:

valore_errore += f_k_piu_uno [teta_i][fi_j] * pow (fabs
(calcolo_P_y_k (w_k, elementi, steering_vector_c_t) -
calcolo_P_riferimento (teta_i, fi_j, teta_l, teta_r, fi_r, fi_l)), 2) ;

Can't i use the writing with "[][]" in a function to have an element of
a vector?
what alternatives have i?
Thank u, Marco.
 
F

Flash Gordon

Aleramo said:
I have this function:

double calcolo_errore (gsl_vector_complex *w_k, int
elementi,gsl_vector_complex *steering_vector_c_t, int teta_l, int
teta_r, int fi_r, int fi_l, int counter, double f_k_piu_uno[][])

> Can't i use the writing with "[][]" in a function to have an element of
> a vector?
> what alternatives have i?

This is your problem. You can only leave out the sive on the left most
[], for the others you have to specify the size. After all, how else is
the compiler to know how long each row of your 2d matrix is? See the
comp.lang.c FAQ, specifically http://c-faq.com/aryptr/pass2dary.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top