void datamul_eye_tests(float32_t eps) { float32_t errf; uint64_t frames=4096; uint32_t channels=16; float32_t*inputdata; float32_t*outputdata; float32_t freq=500; ambix_matrix_t eye = {0, 0, NULL}; STARTTEST(""); inputdata =data_sine(frames, channels, freq); outputdata=(float32_t*)malloc(sizeof(float32_t)*frames*channels); fail_if((NULL==outputdata), __LINE__, "couldn't mallocate outputdata"); ambix_matrix_init(channels, channels, &eye); ambix_matrix_fill(&eye, AMBIX_MATRIX_IDENTITY); fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(outputdata, &eye, inputdata, frames), __LINE__, "data multilplication failed"); errf=data_diff(__LINE__, inputdata, outputdata, frames*channels, eps); fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n"); matrix_print(&eye); printf("input :\n"); data_print(inputdata, frames*channels); printf("output:\n"); data_print(outputdata,frames*channels); #endif free(inputdata); free(outputdata); ambix_matrix_deinit(&eye); }
void fit_data_print(const fitinfo *fit) { if (fit->datatype == FIT_POLARIZED) { printf("== A ==\n"); data_print(&fit->dataA); printf("== B ==\n"); data_print(&fit->dataB); printf("== C ==\n"); data_print(&fit->dataC); printf("== D ==\n"); data_print(&fit->dataD); } else { data_print(&fit->dataA); } }
/* Deserialize: "pkg" to "data" */ slave_event_t slave_deserialize(data_t *data, int8_t *pkg, struct sockaddr_in *addr) { int i; #ifdef SLAVE_DEBUG_PRINT printf("Slave Deserialize: pkg \n"); #endif memcpy(&data->dev_addr.sin_addr, &addr->sin_addr, sizeof(struct in_addr)); for (i = 0; i < OPTIONS_NUM; i++) { uint32_t value; memcpy(&value, pkg, sizeof(value)); /* Translate from network to host byte-order */ data->opts[i].value = ntohl(value); pkg += sizeof(value); } #ifdef SLAVE_DEBUG_PRINT data_print("Slave Deserialize:", data); #endif return SLAVE_DATA; }
/* Serialize: "data" to "pkg" */ slave_event_t slave_serialize(data_t *data, int8_t *pkg, struct sockaddr_in *addr) { int i; #ifdef SLAVE_DEBUG_PRINT printf("Slave Serialize: data\n"); data_print(">>", data); #endif memcpy(&addr->sin_addr, &data->dev_addr.sin_addr, sizeof(struct in_addr)); for (i = 0; i < OPTIONS_NUM; i++) { /* Send values in network byte-order */ uint32_t value = htonl(data->opts[i].value); memcpy(pkg, &value, sizeof(value)); pkg += sizeof(value); } #ifdef SLAVE_DEBUG_PRINT printf("Slave Serialize: pkg\n"); #endif return SLAVE_DATA; }
void print_SkewNode(SkewNode* node,void (*data_print)(void*)) { if(node == NULL) { return; } data_print(node->data); printf(":%ld \n{",node->s); printf("L:\t"); print_SkewNode(getLeftBranch_SkewNode(node),data_print); printf("R:\t"); print_SkewNode(getRightBranch_SkewNode(node),data_print); printf("\n}"); }
/**@brief Funcion que libera todo los recursos alocados en memoria de una lista. @param linklist: Punteor a la lista que quiero liberar.*/ void list_free(LinkedList* linklist){ int size = linklist->nroCollection; int i; //TODO: change this for(i=0; i < (size-1); i++){ Data* aux = NULL; list_pop(linklist, aux); data_print(aux); data_free(aux); } free(linklist->front); linklist->front = 0; }
int evolve (void) { /* sys_print (0); */ update_sistema_then_cells (); data_extract (); data_print (0); cells_calculate (); t = T_INICIAL; /* t in globals.h */ int i; for (i = 1; i <= snapshots; i++) { update_ti (i); update_sistema_then_cells (); evolve_to_ti (); log_evolution (i); data_extract (); data_print (i); } return 0; }
void datamul_tests(float32_t eps) { float32_t errf; float32_t*resultdata = (float32_t*)calloc(2*4, sizeof(float32_t)); float32_t*resultdataT = (float32_t*)calloc(4*2, sizeof(float32_t)); float32_t*inputdata = (float32_t*)calloc(2*3, sizeof(float32_t)); fail_if((NULL==resultdata), __LINE__, "couldn't callocate resultdata"); fail_if((NULL==resultdataT), __LINE__, "couldn't callocate resultdataT"); fail_if((NULL==inputdata), __LINE__, "couldn't callocate inputdata"); ambix_matrix_t*mtx=NULL; STARTTEST("\n"); mtx=ambix_matrix_init(4, 3, NULL); ambix_matrix_fill_data(mtx, leftdata_4_3); data_transpose(inputdata, rightdata_3_2, 3, 2); fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(resultdata, mtx, inputdata, 2), __LINE__, "data multiplication failed"); data_transpose(resultdataT, resultdata, 2, 4); errf=data_diff(__LINE__, FLOAT32, resultdataT, resultdata_4_2, 4*2, eps); if(errf>eps) { printf("matrix:\n"); matrix_print(mtx); printf("input:\n"); data_print(FLOAT32, inputdata, 3*2); printf("expected:\n"); data_print(FLOAT32, resultdata_4_2, 4*2); printf("calculated:\n"); data_print(FLOAT32, resultdataT , 4*2); } fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n");matrix_print(mtx); printf("input :\n"); data_print(FLOAT32, rightdata_3_2, 3*2); printf("output:\n"); data_print(FLOAT32, resultdata, 4*2); printf("target:\n"); data_print(FLOAT32, resultdata_4_2, 4*2); #endif if(mtx)ambix_matrix_destroy(mtx); free(resultdata); free(resultdataT); free(inputdata); STOPTEST("\n"); }
/* handles incoming structured data by dumping it */ void data_acquired_handler(data_t *data) { if (conversion_mode == CONVERT_SI) { for (data_t *d = data; d; d = d->next) { if ((d->type == DATA_DOUBLE) && !strcmp(d->key, "temperature_F")) { *(double*)d->value = fahrenheit2celsius(*(double*)d->value); free(d->key); d->key = strdup("temperature_C"); char *pos; if (d->format && (pos = strrchr(d->format, 'F'))) { *pos = 'C'; } } } } if (conversion_mode == CONVERT_CUSTOMARY) { for (data_t *d = data; d; d = d->next) { if ((d->type == DATA_DOUBLE) && !strcmp(d->key, "temperature_C")) { *(double*)d->value = celsius2fahrenheit(*(double*)d->value); free(d->key); d->key = strdup("temperature_F"); char *pos; if (d->format && (pos = strrchr(d->format, 'C'))) { *pos = 'F'; } } } } for (output_handler_t *output = output_handler; output; output = output->next) { data_print(data, output->file, output->printer, output->aux); } data_free(data); }
main(){ data_init(); line1(1,1,17,13); data_print(); data_init(); line3(1,1,17,11); line3(1,4,7,18); data_print(); data_init(); line4(7,5,5,1); line4(5,5,1,3); line4(18,1,2,11); line4(18,4,6,18); data_print(); data_init(); line5(5,5,18,9, 3); line5(10,18,3,9, 4); data_print(); data_init(); circ2(12,12,3); circ2(10,10,9); data_print(); data_init(); circ3(11,10,3, 1,1); circ3(10,10,9, 3,0); data_print(); data_init(); circ3(10,10,8, 8,0); data_print(); return 0; }
void datamul_4_2_tests(uint32_t chunksize, float32_t eps) { uint32_t r, c, rows, cols; float32_t errf; uint64_t frames=8; uint32_t rawchannels=2; uint32_t cokchannels=4; float32_t*inputdata; float32_t*outputdata; float32_t*targetdata; float32_t freq=500; ambix_matrix_t eye = {0, 0, NULL}; STARTTEST(""); inputdata =data_sine(frames, rawchannels, freq); targetdata=data_sine(frames, cokchannels, freq); outputdata=(float32_t*)malloc(sizeof(float32_t)*frames*cokchannels); fail_if((NULL==outputdata), __LINE__, "couldn't allocate outputdata"); ambix_matrix_init(cokchannels, rawchannels, &eye); rows=eye.rows; cols=eye.cols; for(r=0; r<rows; r++) { for(c=0; c<cols; c++) { eye.data[r][c]=(1+r+c)%2; } } #if 0 matrix_print(&eye); printf("input\n"); data_print(inputdata, rawchannels*frames); #endif fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(outputdata, &eye, inputdata, frames), __LINE__, "data multilplication failed"); #if 0 printf("output\n"); data_print(outputdata, cokchannels*frames); printf("target\n"); data_print(targetdata, cokchannels*frames); #endif errf=data_diff(__LINE__, targetdata, outputdata, frames*cokchannels, eps); fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n"); matrix_print(&eye); printf("input :\n"); data_print(inputdata, frames*channels); printf("output:\n"); data_print(outputdata,frames*channels); #endif ambix_matrix_deinit(&eye); free(inputdata); free(outputdata); free(targetdata); }