void memclr( void ) { char *me = "memclr"; char msg[256], **names = NULL; int iblk,i,j,k,len2,num_tp_curs,icur, num_edits, num_tpc, num_tp; TimePlotCurve_t *tpc_ptr = NULL; TimePlot_t *tp_ptr = NULL; RGST_AttributeElem_t *func; if (domains != NULL) { for ( iblk = 0 ; iblk < nblk ; iblk++ ) { domain_free(&domains[iblk]); } } spline_free(); decomp_free(); NodeList_free(); conditionals_free(); species_free(); TimeStepControl_free(NULL); FunctionTimer_free(gv_hash_tbl); FunctionTimer_ht_remove(gv_hash_tbl, "global"); FunctionTimer_ht_setup (gv_hash_tbl, "global"); UserList_free(); if (ifcom) freecom(); FREEMEM(lnbuf); line = NULL; GlobalArrays_free(NULL); func = rgst_list_attr(A_OBJECT, "Function_Free"); while (func != NULL) { Command_t *cp = (Command_t *) func->rgst_obj->obj; (*(cp->proc))(NULL); func = func->next; } if (rgst_check_for_obj("sourceData") == TRUE) { rgst_del("sourceData"); for ( i = 0 ; i < nsrc ; i++ ) { if (src[i].nzsrc > 0) { FREEMEM(src[i].ndxsrc) ; } if (src[i].nidat1 > 0) { FREEMEM(src[i].idat1) ; } if (src[i].nfdat1 > 0) { FREEMEM(src[i].fdat1) ; } if (src[i].ndat2 > 0) { FREEMEM(src[i].dat2) ; } } FREEMEM(src) ; } nsrc = 0; if (rgst_check_for_obj("freqMesgData") == TRUE) { rgst_del("freqMesgData"); for ( i = 0 ; i < nfq ; i++ ) { rgst_del (fq[i].name); FREEMEM(fq[i].msg) ; FREEMEM(fq[i].name) ; } FREEMEM(fq) ; FREEMEM(fqtp) ; } nfq = 0; if (rgst_check_for_obj("cycleMesgData") == TRUE) { rgst_del("cycleMesgData"); for ( i = 0 ; i < ncyc ; i++ ) { rgst_del (cyc[i].name); FREEMEM(cyc[i].msg) ; FREEMEM(cyc[i].name) ; } FREEMEM(cyc) ; FREEMEM(cyctp) ; } ncyc = 0; if (rgst_check_for_obj("gparmData") == TRUE) { rgst_del("gparmData"); FREEMEM(gparm); } if (rgst_check_for_obj("timePlotData") == TRUE) { rgst_del("timePlotData"); for (i=0 ; i<ntp ; i++) { for (icur=0; icur<tpdata[i]->num_tp_curs; icur++) { rgst_del(tpdata[i]->tp_curs[icur]->name); TimePlotCurve_destruct(tpdata[i]->tp_curs[icur]); } rgst_del(tpdata[i]->name); TimePlot_destruct(tpdata[i]); } FREEMEM(tpdata); } ntp = 0; Region_free(); if (ptab != NULL) rgst_del("ptabData"); if (etab != NULL) rgst_del("etabData"); if (ktab != NULL) rgst_del("ktabData"); if (stab != NULL) rgst_del("stabData"); FREEMEM(ptab); FREEMEM(etab); FREEMEM(ktab); FREEMEM(stab); nbq = 0; if (rgst_check_for_obj("domains") == TRUE) { rgst_del("domains"); } FREEMEM(domains); names = rgst_list_objs_by_type( &num_tp, "TimePlot_t"); for (i = 0; i<num_tp; i++) { ctlwarning(me,"shawn, why are there time plots left, they should have" "been removed by now"); tp_ptr = rgst_get_t(names[i],"TimePlot_t"); if (tp_ptr == NULL) ctlerror(me,logic_err); rgst_del(names[i]); tp_ptr = TimePlot_destruct(tp_ptr); FREEMEM(names[i]); } FREEMEM(names); hash_del_objs_of_type(gv_hash_tbl,"double",NULL); #ifdef DEBUG hash_print_by_type(rgst_objs_hash_tbl); hash_print_by_type(gv_hash_tbl); #endif }
int main() { int row = 4, col = 6; int nbuckets = 40; int hist_ratio = 5; int period = 2; int i, j; float data1[4 * 6] = {1.1, 2.5, 3.6, 1.5, 2.9, 3.5, 0.7, 2.1, 2.7, 3.9, 2.2, 1.4, 3.5, 1.5, 0.2, 1.3, 2.6, 3.1, 0.3, 1.7, 0.9, 3.2, 2.8, 2.6}; float data2[4 * 6] = {1.0, 2.5, 3.7, 1.4, 2.6, 3.7, 0.4, 2.3, 2.8, 3.9, 2.0, 1.5, 3.1, 1.0, 0.3, 1.3, 2.8, 3.4, 0.6, 1.9, 0.8, 3.1, 2.4, 0.2}; float low = 0, high = 1.0; int row_nchunks = 2; int col_nchunks = 6; int result[row * col]; int count; float chunk[period*col*row]; DECOMP *dp; RETRIEVER *rp; YANDEX *yp; // Init dp = decomp_new(row, col, row_nchunks, col_nchunks); rp = retriever_new(dp, period); yp = yandex_new(rp, nbuckets, hist_ratio, NULL); // Start a period yandex_start(yp); // Feed data retriever_feed(rp, data1); yandex_update(yp); retriever_feed(rp, data2); yandex_update(yp); // Stop a period yandex_stop(yp); // Query int chunksize; int nexact, nfuzzy; int okflag; yandex_query(yp, low, high, result, &count, YANDEX_IN); buckets_print(yp->bp); printf("=======================================================\n"); printf("Query range: %.2f -- %.2f\n", low, high); printf("Result(%d)\n", count); for (i = 0; i < count; i++) { printf("%2d ", result[i]); } printf("\n"); for (i = 0; i < count; i++) { chunksize = retriever_get_chunk(rp, result[i], chunk); printf("Pos %2d[%d]: ", result[i], chunksize); for (j = 0; j < chunksize; j++) { if (j%(col/col_nchunks) == 0) printf("\n"); printf("%.2f ", chunk[j]); } printf("\n\n"); } okflag = yandex_verify(yp, low, high, result, count, &nexact, &nfuzzy, 1, YANDEX_IN); low = -1; high = 3; yandex_query(yp, low, high, result, &count, YANDEX_NOT_IN); printf("=======================================================\n"); printf("Query not in range: %.2f -- %.2f\n", low, high); printf("Result(%d)\n", count); for (i = 0; i < count; i++) { printf("%2d ", result[i]); } printf("\n"); for (i = 0; i < count; i++) { chunksize = retriever_get_chunk(rp, result[i], chunk); printf("Pos %2d[%d]: ", result[i], chunksize); for (j = 0; j < chunksize; j++) { if (j%(col/col_nchunks) == 0) printf("\n"); printf("%.2f ", chunk[j]); } printf("\n\n"); } okflag = yandex_verify(yp, low, high, result, count, &nexact, &nfuzzy, 1, YANDEX_NOT_IN); decomp_free(dp); retriever_free(rp); yandex_free(yp); return 0; }