IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

probleme cannot allocate an array of constant size 0


Sujet :

C++

  1. #1
    Membre averti
    Inscrit en
    Juin 2009
    Messages
    15
    Détails du profil
    Informations forums :
    Inscription : Juin 2009
    Messages : 15
    Par défaut probleme cannot allocate an array of constant size 0
    Bonjour a tous,

    Je rencontre quelques difficultés avec mon code. Je débute donc j' ai du mal a comprendre les erreurs signalées lors de la compilation.

    la compilation me renvoie l erreur suivante cannot allocate an array of constant size 0 pour la ligne
    tabW1x[i][j]=tab_Cs_x1[i][j]-tab_Cs_x2[i][j];
    tabW1y[i][j]=tab_Cs_y1[i][j]-tab_Cs_y2[i][j];

    tabW2x[i][j]=(tab_Cs_x1[i][j]-tab_Cs_x2[i][j])^2;
    tabW2y[i][j]=(tab_Cs_y1[i][j]-tab_Cs_y2[i][j])^2;


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    // spline.cpp : Defines the entry point for the console application.
    //
     
    #include "stdafx.h"
    #include <math.h>
    #include <stdio.h>
    //#include <matrix.h>
     
    int _tmain(int argc, _TCHAR* argv[])
    {
     
     
     
     
    //#include <mex.h>   
     
     
    	//void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     
    		float beta_n_x (float , int );
    		float beta_n_s_x( float ,float , int );
    		// declaration of variables
     
    		//mxArray *xData;
    		//float *xValues;
     
    		//mxArray *yData;
    		//float *yValues;
     
    		//*outArray;
     
    		int i,j,k;
    		float tabx[X];
    		float taby[X];
    		int X=8; 
    		int tabs[S];
    		int S=2; 
    		int n=1;
     
     
    		float tabx1[X];
    		float taby1[X];
    		float tabx2[X];
    		float taby2[X];
     
     
    		float tab_beta0_x[X][2]; 
    		float tab_beta0_y[X][2];
     
    		float tab_beta_n_x[X][2];
    		float tab_beta_n_y[X][2];
     
    		float ntabx1[X][S];
    		float ntaby1[X][S];
    		float ntabx2[X][S];
    		float ntaby2[X][S];
    		float tab_beta_n_s_x1[X][S];
    		float tab_beta_n_s_y1[X][S];
    		float tab_beta_n_s_x1[X][S];
    		float tab_beta_n_s_y1[X][S];
     
     
    		int constanteX1=0;
    		int constanteY1=0;
    		int constanteX2=0;
    		int constanteY2=0;
     
    		float tab_C0_x1[X][2];
    		float tab_C0_y1[X][2];
    		float tab_C0_x2[X][2];
    		float tab_C0_y2[X][2];
     
     
    		float tab_Cs_x1[X][2];
    		float tab_Cs_y1[X][2];
    		float tab_Cs_x2[X][2];
    		float tab_Cs_y2[X][2];
     
     
    		float tabW1x[X][S];
    		float tabW1y[X][S];		
     
    		float tabW2x[X][S];
    		float tabW2y[X][S];
     
     
    		float CurveEst[X][S];
     
     
    		float MaximaResults[X][S];
     
    		//intialiser leurs cases a zero
    		int Lambda;
    		float tabresultsX[X];
    		float tabresultsY[X];
     
    		int R=0;
     
     
    //beginning of the Game.
     
    		//xData= prhs[0];
    		//xValues=mxGetPr(xData);
    		//X= mxGetN(xData);
     
    		//yData= prhs[1];
    		//yValues=mxGetPr(yData);
     
     
    		tabx[X]={10,20,30,40,50,60,70,80};
    		tabx[Y]={10,20,30,40,50,60,70,80};
     
    //filling X and Y coordinates tables.
     
    		//for (i=0,i=X-1,i++)
     
    			//{
    				//tabx[i]=xValues[i];
    				//taby[i]=yValues[i];
    			//}
     
     
    		//filling new X and Y coordinates X1=X+0.5 & X2=X-0.5
     
    		for (i=0,i=X-1,i++)
     
    			{
     
    				tabx1[i]=tabx[i]+0.5;
    				tabx2[i]=tabx[i]-0.5;
    				taby1[i]=tabx[i]+0.5;
    				taby2[i]=tabx[i]-0.5;
     
    			}
     
     
     
    		//filling new X and Y coordinates at 1/scale
     
    		for (i=0,i=X-1,i++)
     
    		{
    			for (j=0,j=S-1,j++)
     
    			{
     
    			ntabx1[i][j]=tabx1[i]/tabs[j];
    			ntaby1[i][j]=taby1[i]/tabs[j];
    			ntabx2[i][j]=tabx2[i]/tabs[j];
    			ntaby2[i][j]=taby2[i]/tabs[j];
     
    			}
    		}
     
     
     
    		//filling beta nth order at SCALE S table for X and Y coordinates
     
    		for (i=0,i=X-1,i++)
     
    		{
    			for (j=0,j=S-1,j++)
     
    			{
     
    			tab_beta_n_s_x1[i][j]= 1/tabs[j]*beta_n_x(ntabx1[i][j],n);
    			tab_beta_n_s_y1[i][j]= 1/tabs[j]*beta_n_x(ntaby1[i][j],n);
    			tab_beta_n_s_x2[i][j]= 1/tabs[j]*beta_n_x(ntabx2[i][j],n);
    			tab_beta_n_s_y2[i][j]= 1/tabs[j]*beta_n_x(ntaby2[i][j],n);
     
    			}
     
    		}
     
     
     
    		//filling curve parametization table for X and Y coordinates
     
    		for (i=0,i=X-1,i++)
    		{
     
    			for (j=0,j=X-1,j++)
    			{
     
    			tab_C0_x1[i][1]=tabx[i];
    			tab_C0_x1[i][2]=(tabx1[j]*beta_n_x(tabx1[i]-tabx1[j],n))+constanteX1;
    			constanteX1=tab_C0_x1[i][2];
     
    			tab_C0_y1[i][1]=taby[i];
    			tab_C0_y1[i][2]=(taby1[j]*beta_n_y(taby1[i]-taby1[j],n))+constanteY1;
    			constanteY1=tab_C0_x1[i][2];
     
    			tab_C0_x2[i][1]=tabx[i];
    			tab_C0_x2[i][2]=(tabx2[j]*beta_n_x(tabx1[i]-tabx1[j],n))+constanteX2;
    			constanteX1=tab_C0_x1[i][2];
     
    			tab_C0_y2[i][1]=taby[i];
    			tab_C0_y2[i][2]=(taby2[j]*beta_n_y(taby2[i]-taby2[j],n))+constanteY2;
    			constanteY2=tab_C0_x2[i][2];
    			}
     
     
    		}
     
     
     
    		//filling curve evolution table for X and Y coordinates
     
     
    		for (i=0,i=X-1,i++)
     
    		{
    			for (j=0,j=S-1,j++)
     
    			{
     
    			tab_Cs_x1[i][j]=conv(tab_C0_x1[i][2],tab_beta_n_s_x1[i][j]);
    			tab_Cs_y1[i][j]=conv(tab_C0_y1[i][2],tab_beta_n_s_y1[i][j]);
    			tab_Cs_x2[i][j]=conv(tab_C0_x2[i][2],tab_beta_n_s_x2[i][j]);
    			tab_Cs_y2[i][j]=conv(tab_C0_y2[i][2],tab_beta_n_s_y2[i][j]);
     
    			}
    		}
     
    	//filling Wavelets tables W1 et W2 for X and Y
     
    		for (i=0,i=X-1,i++)
     
    		{
    			for (j=0,j=S-1,j++)
     
    			{
     
    				tabW1x[i][j]=tab_Cs_x1[i][j]-tab_Cs_x2[i][j];
    				tabW1y[i][j]=tab_Cs_y1[i][j]-tab_Cs_y2[i][j];		
     
    				tabW2x[i][j]=(tab_Cs_x1[i][j]-tab_Cs_x2[i][j])^2;
    				tabW2y[i][j]=(tab_Cs_y1[i][j]-tab_Cs_y2[i][j])^2;
     
    			}
     
    		}
     
    	//filling curvature function Estimation tables 
     
     
    		for (i=0,i=X-1,i++)
     
    		{
    			for (j=0,j=S-1,j++)
     
    			{
     
    				tabCurveEst[i][j]= (tabW1x[i][j]*tabW2y[i][j]-tabW1y[i][j]*tabW2x[i][j])  /  ( ((tabW1x[i][j])^2 + (tabW1y[i][j])^2)^(1.5) );
    			}
     
    		}
     
     
    		//filling MaximaResults tables
     
     
    		for (i=0,i=X-1,i++)
     
    		{
    			for (j=0,j=S-1,j++)
     
    			{
    				if ((tabCurveEst[i][j]>epsilon1)||(tabCurveEst[i][j]<-epsilon1))
     
    					{
     
    					MaximaResults[i][j]= tabCurveEst[i][j];
     
    					}
     
    				else 
     
    					{
    					MaximaResults[i][j]=0;
     
     
    					}
     
    			}
    		}
     
     
     
    		//filling Cornercandidates tables
     
     
    			for (i=0,i=X-1,i++)
     
    			{
    					for (j=S-2,j=0,j--) //Scale decreasing
     
    					{
     
    						for (k=-S,j=S,k++) //While scale decreasing neighborhood
     
    						{
    							if (((i+k>0)&&(i+k<X)&&(MaximaResults[i+k][j+1]!=0)&&( (  (     (   (tabx[i+k]-tabx[i])^2   )     +     (    (taby[i+k]-taby[i])^2  )    ^(1/2)     ) < epsilon2 ))
     
    							{
    									MaximaResults[i+k][j+1]=0;							
     
    							}
     
     
    						}
     
    					}
     
    			}
     
    			//filling Postprocessing of corner candidates tables
     
     
     
    			for (j=0,j=S-1,j++)
     
    			{
    				for (i=1,j=X-2,i++)
     
    				{
    					A=MaximaResults[i-1][j];
    					B=MaximaResults[i][j];
    					C=MaximaResults[i+1][j];
     
    					if ((A!=0)&&(B!=0)&&(C!=0))
     
    						{
    							Ax=tabx[i-1];
    							Ay=tabx[i-1];
    							Bx=tabx[i];
    							By=tabx[i];
    							Cx=tabx[i+1];
    							Cy=tabx[i+1];
     
    							if (   (((Bx-Ax)^2) +((By-Ay)^2)^(0.5)) + (((Bx-Cx)^2) +((By-Cy)^2)^(0.5))  >= Lambda (( ((Ax-Cx)^2) +((Ay-Cy)^2)^(0.5)))     )
     
     
    							{
     
    								for (v=0,v=R-1,v++)
     
    								{
    									if (tabx[i]!=tabresultsX[v];) // regarder si la valeur n est pas deja dans le tableau
     
    									{
    										tabresultsX[R]=tabx[i];
    										tabresultsY[R]=taby[i];
     
    									}
     
     
    									R++; //R is incremented in order to copy interesting coordinates on the next empty place the fine size of the results table will be R.
    								}
     
    							}
    						}
    					}
     
    			}	}
     
    		//	plhs[0] = mxcreateDoubleMatrix(X,2,float);
     
    		//	for (i=0,i=X-1,i++)
     
    		//	{
     
    			//	outArray=[(i*S)+1]=tabresultsX[i];
    			//	outArray=[(i*S)+2]=tabresultsX[i];
     
    			//}
     
    			//return;
     
    		}
     
     
    		float beta_n_x (float x, int n)
    		{
     
    			float bn_x;
    			float S=x;
    			int i;
    			for (i=1,i<=n,i++)
    			{	
    			bn_x=conv(x,S);
    			S=bn_x;
    			}
    			return bn_x;
    		}
     
    		float beta_n_s_x( float x; float s; int n )
     
    		{
    			float b_n_s_x;
    			b_n_s_x = (1/s)* beta_n_x (x/s, n)
    			return b_n_s_x;
     
    		}
    	return 0;
    }

  2. #2
    Membre éprouvé
    Étudiant
    Inscrit en
    Octobre 2007
    Messages
    189
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2007
    Messages : 189
    Par défaut
    L'erreur dis clairement que tu as tenté de créer un tableau de taille nulle, ce qui n'est ( logiquement ) pas autorisé.

    Au cas où "^2" ne met pas au carré.

    PS : utilise les balises de code.

  3. #3
    Membre éclairé Avatar de cynique
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    60
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 60
    Par défaut
    Citation Envoyé par sebintokyo Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    // ... 1
     
    		float tabx[X];
    		float taby[X];
    		int X=8; 
    		int tabs[S];
    		int S=2; 
     
    // ... 2
    		for (i=0,i=X-1,i++)
     
    // ... 3
     
    				tabW2x[i][j]=(tab_Cs_x1[i][j]-tab_Cs_x2[i][j])^2;
    				tabW2y[i][j]=(tab_Cs_y1[i][j]-tab_Cs_y2[i][j])^2;
    1ere partie: X n'est pas un "const int", et tu ne peut pas l'utiliser dans les declarations des tableaux. Et aussi, tu dois le declarer avant de l'utiliser.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    		const int X=8; 
    		float tabx[X];
    		float taby[X];
    		const int S=2; 
    		int tabs[S];
    2eme partie: Cette syntaxe n'est pas valide. Il faut:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    		for (i=0; i < X; i++)
    Note bien les point-virgules au lieu des virgules, et le < au lieu du = et -1.

    3eme partie: Le ^ n'est pas l'operateur d'exposants. C++ et C tous-les-deux manquent un operateur d'exposants. ^ est l'operateur "OU exclusif".

Discussions similaires

  1. Probleme d'allocation avec un malloc
    Par theshark85 dans le forum C
    Réponses: 11
    Dernier message: 25/04/2006, 17h30
  2. Probleme de type avec Array
    Par BECHE dans le forum Langage
    Réponses: 5
    Dernier message: 30/03/2006, 23h05
  3. [VBA][Excel]Array en constante
    Par Pollux dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 03/02/2006, 12h46
  4. probleme d allocation avec un tableau de BYTE
    Par e1lauren dans le forum C++
    Réponses: 5
    Dernier message: 06/05/2005, 13h42
  5. probleme d'allocation dynamique
    Par vince3320 dans le forum C
    Réponses: 10
    Dernier message: 22/04/2004, 16h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo