check if all elements in the vector are finite. If not, set the element to 0 */
| 26 | |
| 27 | /* check if all elements in the vector are finite. If not, set the element to 0 */ |
| 28 | int checkVectorFinite(FLOAT_DMEM *x, long N) |
| 29 | { |
| 30 | int i; int f = 1; |
| 31 | int ret = 1; |
| 32 | for (i=0; i<N; i++) { |
| 33 | if ((std::isnan)(x[i])) { |
| 34 | //printf("ERRR!\n X:%f istart: %f iend %f gend %f gstart %f \n iVI %i II %i end %f start %f step %f startV %f\n",X,istart,iend,gend,gstart,ivI,curRange[i].isInit,curRange[i].end,curRange[i].start,curRange[i].step,startV); |
| 35 | //SMILE_ERR(2,"#NAN# value encountered in output (This value is now automatically set to 0, but somewhere there is a bug)! (index %i)",i); |
| 36 | x[i] = 0.0; f=0; |
| 37 | ret = 0; |
| 38 | } |
| 39 | if ((std::isinf)(x[i])) { |
| 40 | //printf("ERRR!\n X:%f istart: %f iend %f gend %f gstart %f \n iVI %i II %i end %f start %f step %f startV %f\n",X,istart,iend,gend,gstart,ivI,curRange[i].isInit,curRange[i].end,curRange[i].start,curRange[i].step,startV); |
| 41 | //SMILE_ERR(2,"#INF# value encountered in output (This value is now automatically set to 0, but somewhere there is a bug)! (index %i)",i); |
| 42 | x[i] = 0.0; f=0; |
| 43 | ret = 0; |
| 44 | } |
| 45 | } |
| 46 | return ret; |
| 47 | } |
| 48 | |
| 49 | // realloc and initialize additional memory with zero, like calloc |
| 50 | void * crealloc(void *a, size_t size, size_t old_size) |