00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string.h>
00023 #include <flgrCoreDispatch.h>
00024 #include <flgrCoreData.h>
00025 #include <flgrCoreDataIO.h>
00026 #include <flgrCoreShift.h>
00027 #include <flgrCoreShiftFast.h>
00028
00029
00037
00038
00040 #define FLGR_MACRO_SHIFT1D_RIGHT(dtype) \
00041 dtype *psrc = (dtype *) datsrc->array; \
00042 dtype *pdest = (dtype *) datdest->array; \
00043 dtype *pinsert = (dtype*) vec_insert->array; \
00044 int l = datsrc->length; \
00045 int m = l-nbshift; \
00046 int i,spp = datsrc->spp; \
00047 dtype val; \
00048 \
00049 \
00050 \
00051 if(nbshift >= datsrc->length) return; \
00052 \
00053 for(i=0 ; i<nbshift*spp ; i++) { \
00054 val = flgr_get_array_##dtype(pinsert,i%spp); \
00055 flgr1d_set_data_array_##dtype(pdest,i,val); \
00056 } \
00057 \
00058 memcpy(pdest+nbshift*spp,psrc,m*spp*sizeof(dtype)); \
00059 return
00060
00061 void flgr1d_shift_right_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00062 fgBIT *psrc = (fgBIT *) datsrc->array;
00063 fgBIT *pdest = (fgBIT *) datdest->array;
00064 fgBIT *pinsert = vec_insert->array;
00065 fgBIT val;
00066 int l = sizeof(fgBIT)<<3;
00067 int k,m;
00068 int j,spp = datsrc->spp;
00069
00070
00071
00072 if(nbshift >= datsrc->length) return;
00073
00074 if((nbshift==1) && (datsrc->spp == 1))
00075 return flgr1d_shift_1_right_spp1_fgBIT(datdest, datsrc, *((fgBIT *) (vec_insert->array)));
00076
00077 l = datsrc->length;
00078 m = l-nbshift;
00079
00080 for(j=0 ; j<nbshift*spp ; j++) {
00081 val = flgr_get_array_fgBIT(pinsert,j%spp);
00082 flgr1d_set_data_array_fgBIT(pdest,j,val);
00083 }
00084
00085 for(j=0,k=nbshift*spp ; j<m*spp ; k++,j++) {
00086 val = flgr1d_get_data_array_fgBIT(psrc,j);
00087 flgr1d_set_data_array_fgBIT(pdest,k,val);
00088 }
00089
00090 }
00091 void flgr1d_shift_right_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00092 FLGR_MACRO_SHIFT1D_RIGHT(fgUINT8);
00093 }
00094 void flgr1d_shift_right_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00095 FLGR_MACRO_SHIFT1D_RIGHT(fgUINT16);
00096 }
00097 void flgr1d_shift_right_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00098 FLGR_MACRO_SHIFT1D_RIGHT(fgUINT32);
00099 }
00100 void flgr1d_shift_right_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00101 FLGR_MACRO_SHIFT1D_RIGHT(fgINT8);
00102 }
00103 void flgr1d_shift_right_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00104 FLGR_MACRO_SHIFT1D_RIGHT(fgINT16);
00105 }
00106 void flgr1d_shift_right_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00107 FLGR_MACRO_SHIFT1D_RIGHT(fgINT32);
00108 }
00109 void flgr1d_shift_right_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00110 FLGR_MACRO_SHIFT1D_RIGHT(fgFLOAT32);
00111 }
00112 void flgr1d_shift_right_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00113 FLGR_MACRO_SHIFT1D_RIGHT(fgFLOAT64);
00114 }
00115
00116
00118
00125
00126 FLGR_Ret flgr1d_shift_right(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00127 FLGR_Ret ret;
00128
00129
00130
00131 if((datdest==NULL) || (datsrc==NULL)) {
00132 POST_ERROR("Null objects!\n");
00133 return FLGR_RET_NULL_OBJECT;
00134 }
00135
00136 if((ret = flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__)) != FLGR_RET_OK) return ret;
00137
00138 if(nbshift >= datsrc->length) return FLGR_RET_PARAM_ERROR;
00139
00140 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_shift_right,datdest,datsrc,nbshift,vec_insert);
00141 }
00142
00143
00144
00145
00147
00149 #define FLGR_MACRO_SHIFT1D_LEFT(dtype) \
00150 dtype *psrc = (dtype *) datsrc->array; \
00151 dtype *pdest = (dtype *) datdest->array; \
00152 dtype *pinsert = vec_insert->array; \
00153 int l = datsrc->length; \
00154 int m = l-nbshift; \
00155 int i,spp = datsrc->spp; \
00156 dtype val; \
00157 \
00158 \
00159 \
00160 \
00161 if(nbshift >= datsrc->length) return; \
00162 \
00163 for(i=(l-nbshift)*spp ; i<l*spp ; i++) { \
00164 val = flgr_get_array_##dtype(pinsert,i%spp); \
00165 flgr1d_set_data_array_##dtype(pdest,i,val); \
00166 } \
00167 \
00168 memcpy(pdest,psrc+nbshift*spp,m*spp*sizeof(dtype)); \
00169 return
00170
00171
00172 void flgr1d_shift_left_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00173 fgBIT *psrc = (fgBIT *) datsrc->array;
00174 fgBIT *pdest = (fgBIT *) datdest->array;
00175 fgBIT *pinsert = (fgBIT*) vec_insert->array;
00176 fgBIT val;
00177 int l = datsrc->length;
00178 int m = l-nbshift;
00179 int j,k,spp = datsrc->spp;
00180
00181 if((nbshift==1) && (datsrc->spp == 1))
00182 return flgr1d_shift_1_left_spp1_fgBIT(datdest, datsrc, *((fgBIT *) (vec_insert->array)));
00183
00184 if(nbshift >= datsrc->length) return;
00185
00186 for(j=m*spp ; j<l*spp ; j++){
00187 val = flgr_get_array_fgBIT(pinsert,j%spp);
00188 flgr1d_set_data_array_fgBIT(pdest,j,val);
00189 }
00190
00191 for(j=0,k=nbshift*spp ; j<m*spp ; k++,j++) {
00192 val = flgr1d_get_data_array_fgBIT(psrc,k);
00193 flgr1d_set_data_array_fgBIT(pdest,j,val);
00194 }
00195 }
00196 void flgr1d_shift_left_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00197 FLGR_MACRO_SHIFT1D_LEFT(fgUINT8);
00198 }
00199 void flgr1d_shift_left_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00200 FLGR_MACRO_SHIFT1D_LEFT(fgUINT16);
00201 }
00202 void flgr1d_shift_left_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00203 FLGR_MACRO_SHIFT1D_LEFT(fgUINT32);
00204 }
00205 void flgr1d_shift_left_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00206 FLGR_MACRO_SHIFT1D_LEFT(fgINT8);
00207 }
00208 void flgr1d_shift_left_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00209 FLGR_MACRO_SHIFT1D_LEFT(fgINT16);
00210 }
00211 void flgr1d_shift_left_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00212 FLGR_MACRO_SHIFT1D_LEFT(fgINT32);
00213 }
00214 void flgr1d_shift_left_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00215 FLGR_MACRO_SHIFT1D_LEFT(fgFLOAT32);
00216 }
00217 void flgr1d_shift_left_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00218 FLGR_MACRO_SHIFT1D_LEFT(fgFLOAT64);
00219 }
00220
00221
00223
00230
00231 FLGR_Ret flgr1d_shift_left(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift, FLGR_Vector *vec_insert) {
00232 FLGR_Ret ret;
00233
00234
00235
00236 if((datdest==NULL) || (datsrc==NULL)) {
00237 POST_ERROR("Null objects!\n");
00238 return FLGR_RET_NULL_OBJECT;
00239 }
00240
00241 if((ret = flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__)) != FLGR_RET_OK) return ret;
00242
00243 if(nbshift >= datsrc->length) return FLGR_RET_PARAM_ERROR;
00244
00245 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_shift_left,datdest,datsrc,nbshift,vec_insert);
00246 }
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00264
00266 #define FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(dtype) \
00267 dtype *psrc = (dtype *) datsrc->array; \
00268 dtype *pdest = (dtype *) datdest->array; \
00269 int l = datsrc->length; \
00270 int m = l-nbshift; \
00271 int spp = datsrc->spp; \
00272 \
00273 \
00274 \
00275 if(nbshift >= datsrc->length) return; \
00276 \
00277 \
00278 memcpy(pdest,psrc+m*spp,nbshift*spp*sizeof(dtype)); \
00279 memcpy(pdest+nbshift*spp,psrc,m*spp*sizeof(dtype))
00280
00281
00282 void flgr1d_shift_circular_right_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00283 fgBIT *psrc = (fgBIT *) datsrc->array;
00284 fgBIT *pdest = (fgBIT *) datdest->array;
00285 fgBIT val;
00286 int l = sizeof(fgBIT)<<3;
00287 int k,m;
00288 int j,spp = datsrc->spp;
00289
00290
00291 if(nbshift >= datsrc->length) return;
00292
00293 l = datsrc->length;
00294 m = l-nbshift;
00295
00296 for(j=0,k=m*spp ; j<nbshift*spp ; j++,k++) {
00297 val = flgr1d_get_data_array_fgBIT(psrc,k);
00298 flgr1d_set_data_array_fgBIT(pdest,j,val);
00299 }
00300
00301 for(j=0,k=nbshift*spp ; j<m*spp ; k++,j++) {
00302 val = flgr1d_get_data_array_fgBIT(psrc,j);
00303 flgr1d_set_data_array_fgBIT(pdest,k,val);
00304 }
00305
00306 }
00307 void flgr1d_shift_circular_right_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00308 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgUINT8);
00309 }
00310 void flgr1d_shift_circular_right_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00311 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgUINT16);
00312 }
00313 void flgr1d_shift_circular_right_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00314 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgUINT32);
00315 }
00316 void flgr1d_shift_circular_right_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00317 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgINT8);
00318 }
00319 void flgr1d_shift_circular_right_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00320 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgINT16);
00321 }
00322 void flgr1d_shift_circular_right_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00323 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgINT32);
00324 }
00325 void flgr1d_shift_circular_right_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00326 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgFLOAT32);
00327 }
00328 void flgr1d_shift_circular_right_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00329 FLGR_MACRO_SHIFT1D_CIRCULAR_RIGHT(fgFLOAT64);
00330 }
00332
00338
00339 FLGR_Ret flgr1d_shift_circular_right(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00340 FLGR_Ret ret;
00341
00342
00343
00344 if((datdest==NULL) || (datsrc==NULL)) {
00345 POST_ERROR("Null objects!\n");
00346 return FLGR_RET_NULL_OBJECT;
00347 }
00348
00349 if((ret = flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__)) != FLGR_RET_OK) return ret;
00350
00351 if(nbshift >= datsrc->length) return FLGR_RET_PARAM_ERROR;
00352
00353 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_shift_circular_right,datdest,datsrc,nbshift);
00354 }
00355
00356
00357
00358
00359
00360
00362
00364 #define FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(dtype) \
00365 dtype *psrc = (dtype *) datsrc->array; \
00366 dtype *pdest = (dtype *) datdest->array; \
00367 int l = datsrc->length; \
00368 int m = l-nbshift; \
00369 int spp = datsrc->spp; \
00370 \
00371 \
00372 \
00373 if(nbshift >= datsrc->length) return; \
00374 \
00375 memcpy(pdest+m*spp,psrc,nbshift*spp*sizeof(dtype)); \
00376 memcpy(pdest,psrc+nbshift*spp,m*spp*sizeof(dtype))
00377
00378
00379 void flgr1d_shift_circular_left_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00380 fgBIT *psrc = (fgBIT *) datsrc->array;
00381 fgBIT *pdest = (fgBIT *) datdest->array;
00382 fgBIT val;
00383 int l = sizeof(fgBIT)<<3;
00384 int k,m;
00385 int j,spp = datsrc->spp;
00386
00387
00388 if(nbshift >= datsrc->length) return;
00389
00390 l = datsrc->length;
00391 m = l-nbshift;
00392
00393 for(j=0,k=m*spp ; j<nbshift*spp ; j++,k++) {
00394 val = flgr1d_get_data_array_fgBIT(psrc,j);
00395 flgr1d_set_data_array_fgBIT(pdest,k,val);
00396 }
00397
00398 for(j=0,k=nbshift*spp ; j<m*spp ; k++,j++) {
00399 val = flgr1d_get_data_array_fgBIT(psrc,k);
00400 flgr1d_set_data_array_fgBIT(pdest,j,val);
00401 }
00402
00403 }
00404 void flgr1d_shift_circular_left_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00405 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgUINT8);
00406 }
00407 void flgr1d_shift_circular_left_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00408 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgUINT16);
00409 }
00410 void flgr1d_shift_circular_left_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00411 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgUINT32);
00412 }
00413 void flgr1d_shift_circular_left_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00414 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgINT8);
00415 }
00416 void flgr1d_shift_circular_left_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00417 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgINT16);
00418 }
00419 void flgr1d_shift_circular_left_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00420 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgINT32);
00421 }
00422 void flgr1d_shift_circular_left_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00423 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgFLOAT32);
00424 }
00425 void flgr1d_shift_circular_left_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00426 FLGR_MACRO_SHIFT1D_CIRCULAR_LEFT(fgFLOAT64);
00427 }
00429
00435
00436 FLGR_Ret flgr1d_shift_circular_left(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int nbshift) {
00437 FLGR_Ret ret;
00438
00439
00440
00441 if((datdest==NULL) || (datsrc==NULL)) {
00442 POST_ERROR("Null objects!\n");
00443 return FLGR_RET_NULL_OBJECT;
00444 }
00445
00446 if((ret = flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__)) != FLGR_RET_OK) return ret;
00447
00448 if(nbshift >= datsrc->length) return FLGR_RET_PARAM_ERROR;
00449
00450 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_shift_circular_left,datdest,datsrc,nbshift);
00451 }
00452
00453
00454