亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? srtree_search.c

?? srtree算法實現
?? C
字號:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <limits.h>#include <math.h>#include <sys/resource.h>#include <sys/times.h>#include <unistd.h>#include "srtree.h"//#define DEBUG//#define DEBUG_MM#define _EPSILON  1e-10int E_dist_comp_count = 0;int E_page_access_count = 0;int E_represent_accuracy = 0;int E_prune_ans_no = 0;int E_overlap_yes = 0;int E_no_answer = 0;void initialize(config_type *config, char *configFile){  FILE *fp;  int string_len;  //fp = fopen(CONFIG_FILE, "r");  fp = fopen(configFile, "r");  fscanf(fp, "m=%d\n", &m);  fscanf(fp, "M=%d\n", &M);  fscanf(fp, "dim=%d\n", &dim);  fscanf(fp, "reinsert_p=%d\n", &reinsert_p);   fscanf(fp, "no_histogram=%d\n",&no_histogram);  fgets(config->datafile, FILENAME_MAX, fp);  string_len = strlen(config->datafile);  config->datafile[string_len-1] = '\0';  fgets(config->queryfile, FILENAME_MAX, fp);  string_len = strlen(config->queryfile);  config->queryfile[string_len-1] = '\0';  sprintf(config->save_tree_file, "%s.srtree", config->datafile);}/* initialize */void tree_leaf_node_allocate(node_type **node){  (*node) = (node_type *)malloc(sizeof(node_type));  if (!*node) {        printf("Out of memory\n");        exit(EXIT_FAILURE);  }  (*node)->a = (double *)malloc(sizeof(double) * dim);  (*node)->b = (double *)malloc(sizeof(double) * dim);  if (!(*node)->a || !(*node)->b) {        printf("Out of memory\n");        exit(EXIT_FAILURE);  }} /* tree_leaf_node_allocate */void tree_node_allocate(node_type **node){  (*node) = (node_type *)malloc(sizeof(node_type));  if (!*node) {        printf("Out of memory\n");        exit(EXIT_FAILURE);  }  (*node)->a = (double *)malloc(sizeof(double) * dim);  (*node)->b = (double *)malloc(sizeof(double) * dim);  (*node)->ptr = (node_type **)malloc(sizeof(node_type *) * M);  if (!(*node)->a || !(*node)->b  || !(*node)->ptr) {        printf("Out of memory\n");        exit(EXIT_FAILURE);  }  (*node)->centroid = (double *)malloc(sizeof(double) * dim); if (!(*node)->centroid) {        printf("Out of memory\n");        exit(EXIT_FAILURE);  }}int read_query(char *queryfile, double ***query, int no_query){  FILE *fp_pos;    //int no_query;  int i,j;  //no_query=100;  fp_pos = fopen(queryfile, "r");  if (!fp_pos) {	printf("Can't open file, %s\n", queryfile);	exit(EXIT_FAILURE);  }  (*query) = (double **)malloc(no_query * sizeof(double *));  for (i=0; i<no_query; i++)  	(*query)[i] = (double *)malloc(dim * sizeof(double));  for (i=0; i<no_query; i++)	for (j=0; j<dim; j++)                fscanf(fp_pos, "%lf", &((*query)[i][j]));  fclose(fp_pos);  return(no_query);} /* read_query *//* Distance Computation */double MINDIST(double *P, double *a, double *b){        int i;        double sum = 0.0;                                                         for(i=0 ;i<dim ;i++)        {                if (P[i] > b[i])                        sum += pow(P[i] - b[i], 2.0);                else if (P[i] < a[i])                        sum += pow(a[i] - P[i], 2.0);        }                                return sum;     }double cal_Euclidean(node_type *node, double *query){        int i;        double distance;        distance = 0.0;                for(i=0; i< dim ;i++)                distance += pow((node->a[i] - query[i]),(double)2.0);                                return (sqrt(distance));}/***********************************//* rectangle_search():             *//* search query points on the tree *//*************************** *******/  int rectangle_search(node_type *curr_node, double *query, double error){  int find_flag;  int i, j, stop, flag;  int query_dim;                   query_dim = dim;    /* Search leaf node */  if(curr_node->attribute == LEAF) {      for(j=0; j<query_dim; j++)                 printf("%f ", curr_node->a[j]);              printf("  at %d\n", curr_node->id);        return(FOUND);    }  stop = M - curr_node->vacancy;  for(i=0; i < stop; i++) {          flag = TRUE;          /* search subtree */        for(j=0; j < query_dim; j++) {                if(curr_node->ptr[i]->a[j] > (query[j] + error) ||                   curr_node->ptr[i]->b[j] < (query[j] - error))                {                        flag = FALSE;                        break;                }        }          /* search the node which contains the query */        if(flag==TRUE) {                find_flag = rectangle_search(curr_node->ptr[i], query, error);        }  }          return(find_flag);        }/* rectangle_search *//**********************************//* rectangle_search_tree():       *//* prepare to search query points *//**********************************/                void rectangle_search_tree(node_type *root, int no_query, double **query, double error) {  int query_index;  int j, find_flag = NOT_FOUND;  int query_dim;  query_dim = dim;    /* start search data points by invoking rectangle_search() */  for(query_index=0; query_index < no_query; query_index++) {                printf("Query ");        for(j=0; j < query_dim; j++)               printf("%f ", query[query_index][j]);        printf("is found satisfied with\n");          find_flag = NOT_FOUND;        find_flag = rectangle_search(root, query[query_index], error);  }  } /* rectangle_search_tree */void read_inter_node(node_type *node, FILE *fp){  int i, count;     for (i = 0; i<dim; i++)        fscanf(fp, "%lf\n", &((node->a)[i]));    for (i = 0; i<dim; i++)        fscanf(fp, "%lf\n", &((node->b)[i]));  fscanf(fp, "%d\n", &(node->attribute));  if (node->attribute != LEAF)  	for (i = 0; i<dim; i++)        	fscanf(fp, "%lf\n", &((node->centroid)[i]));  else	memcpy(node->centroid, node->a, sizeof(double) * dim);  if (node->attribute == LEAF) {	fscanf(fp, "%d\n", &(node->id));  }  fscanf(fp, "%d\n", &(node->vacancy));  if (node->attribute != LEAF) {	fscanf(fp, "%lf\n", &(node->radius));	fscanf(fp, "%d\n", &(node->total_size));  } else {	node->radius = 0.0;	// Ling	node->total_size = 1;  }  /****************************************  printf("press 1\n");  scanf("%d", &dummy);  for (i = 0; i<dim; i++)        printf("%f ", node->a[i]);  printf("\n");     for (i = 0; i<dim; i++)        printf("%f ", node->b[i]);  printf("\n");    printf("attrib[%d]  ", node->attribute);  if (node->attribute == LEAF) {        printf("id[%d] ", node->id);  }  printf("vacancy[%d]\n", node->vacancy);  ****************************************/  if (node->attribute != LEAF) {  	count = M - node->vacancy;  	for (i=0; i<count; i++) {		tree_node_allocate(&(node->ptr[i]));                read_inter_node(node->ptr[i], fp);	}  }            return; } void read_srtree(node_type **root, char save_tree_file[]){   FILE *fp;   tree_node_allocate(root);  //fp = fopen(SAVE_SRTREE_FILE, "r");  fp = fopen(save_tree_file, "r");  //printf("save_tree: %s\n", save_tree_file);  if (!fp) {	printf("Can't open %s\n", save_tree_file);	exit(EXIT_FAILURE);  }  read_inter_node(*root, fp);    fclose(fp);   return;  }void free_tree(node_type *node){  int i;  if (!node) return;  free(node->a);  free(node->b);  free(node->centroid);  for (i=0; i < M-node->vacancy; i++)        free_tree(node->ptr[i]);  free(node);  return;}void NN_update(NN_type *NN, double dist, node_type *node, int k){  int i=0;  while (i<k-1 && NN->next->dist >= dist)  {	NN->dist=NN->next->dist;	NN->oid=NN->next->oid;	NN->pointer=NN->next->pointer;	NN=NN->next;	i++;  }  NN->dist=dist;  NN->oid=node->id;  NN->pointer=node;  return;}static int compare(ABL *i, ABL *j) {        if (i->min > j->min)                  return (1);        if (i->min < j->min)                  return (-1);        return (0);}/* Return the distance between the centroid */double dist_centroid(double *centroid1, double *centroid2){ int i=dim; double d,distance=0.0; while (i--) {	d = (*centroid1++) - (*centroid2++);	distance += d*d; }/* for (i=0; i < dim; i++) {        distance += (centroid1[i] - centroid2[i]) * (centroid1[i] - centroid2[i]); }*/ return sqrt(distance);}void gen_ABL(node_type *node, ABL branch[], double *query, int total){  int i;  double dist_rectangle;  double dist_sphere;  for (i=0;i<total;i++)  {	branch[i].node=node->ptr[i];	//branch[i].min=MINDIST(query, node->ptr[i]->a, node->ptr[i]->b);	dist_rectangle = MINDIST(query, node->ptr[i]->a, node->ptr[i]->b);	//dist_rectangle = sqrt(dist_rectangle);	dist_sphere = dist_centroid(query, node->ptr[i]->centroid) - node->ptr[i]->radius;	if (dist_sphere < 0.0)	    	dist_sphere = 0.0;	else		dist_sphere *= dist_sphere;       #ifdef DEBUG        printf("ABL %d: dist_sphere=%f, dist_rectangle=%f, radius=%f\n", 				i, dist_sphere, dist_rectangle, node->ptr[i]->radius);       #endif	if (dist_rectangle > dist_sphere)	    branch[i].min = dist_rectangle;	else	    branch[i].min = dist_sphere;  }  qsort(branch,total,sizeof(struct BranchArray),compare);  return;}void k_NN_NodeSearch(node_type *curr_node, double *query, NN_type *NN, int k){  int i, total;  double dist;  ABL       *branch;  E_page_access_count++;  /* Please refer NN Queries paper */  if (curr_node->ptr[0]->attribute == LEAF)   {	total = M - curr_node->vacancy;	for (i=0;i<total;i++)	{               #ifdef DEBUG                printf("compare with %d\n", curr_node->ptr[i]->id);               #endif		dist = cal_Euclidean(curr_node->ptr[i], query);		if (dist < NN->dist)			NN_update(NN, dist, curr_node->ptr[i], k);	}  }  else  {	/* Please refer SIGMOD record Sep. 1998 Vol. 27 No. 3 P.18 */	total=M-curr_node->vacancy; 	branch=(struct BranchArray *)malloc(total*sizeof(struct BranchArray));       #ifdef DEBUG_MM        if (!branch) {                printf("Out of memory\n");                exit(EXIT_FAILURE);        }       #endif 	gen_ABL(curr_node, branch, query, total);       #ifdef DEBUG        printf("[node=%p]\n", curr_node);        i = total;        while (i--)                printf("branch[%d].min = %f, NN->dist = %f\n", i, branch[i].min,  NN->dist);       #endif	for (i=0;i<total;i++)	{		if (branch[i].min - _EPSILON >= NN->dist)			break;		else	                k_NN_NodeSearch(branch[i].node,query,NN,k);	}	free(branch);  }  return;}void k_NN_search(node_type *root, double *query, int k){  int i;  NN_type *NN, *head;  if ((NN = (NN_type *)malloc(sizeof(NN_type))) == NULL)        fprintf(stderr, "malloc error at k-NN_search 1\n");  NN->oid = UNDEFINED;  NN->dist = INFINITY;  NN->pointer = NULL;  head=NN;  for (i=0; i<k-1; i++) {        if ((NN->next = (NN_type *)malloc(sizeof(NN_type))) == NULL)                fprintf(stderr, "malloc error at k-NN_search 1\n");         NN->next->oid = UNDEFINED;         NN->next->dist = INFINITY;        NN = NN->next;  }  NN->next = NULL;   k_NN_NodeSearch(root, query, head, k);   NN=head;  printf("\n");  while (NN != NULL) {          printf("ID: %d    Dist: %f\n", NN->oid, NN->dist);         NN = NN->next;  }  printf("\n");  return;   }int main(int argc, char *argv[]){  node_type *root;  config_type config;  int no_query;  double **query;  double error;    int i, nn;  //char E_result_filename[FILENAME_MAX];  // for experiment  float  userTime, sysTime;  struct rusage myTime1, myTime2;  FILE *E_result_fp;              double E_represent_accuracy_sum, E_prune_accuracy_sum;  int E_page_access_count_sum;  ////////////////////////////  if (argc != 4) {	//printf("Usage: %s <config> <k> <#query> <result file>\n", argv[0]);	printf("Usage: %s <config> <k> <#query>\n", argv[0]);	exit(EXIT_FAILURE);  }  //strcpy(E_result_filename, argv[4]);  ////////////////////////////  initialize(&config, argv[1]);  printf("read_srtree\n");  read_srtree(&root, config.save_tree_file);  printf("read_query\n");  no_query = read_query(config.queryfile, &query, atoi(argv[3]));  printf("start searching\n");  if (CHOICE==RANGE_SEARCH) {	while (TRUE) {	  	printf("Please input the error bound:"); 	 	scanf("%lf", &error);	  	rectangle_search_tree(root, no_query, query, error);		  } }  else if (CHOICE == kNN_SEARCH) {	nn = atoi(argv[2]);	E_page_access_count_sum = 0;	E_represent_accuracy_sum = 0.0;	E_prune_accuracy_sum = 0.0;	E_dist_comp_count = 0;                         	getrusage(RUSAGE_SELF,&myTime1);	for (i=0; i<no_query; i++) { 		printf("Query %d\n", i+1);		E_page_access_count = 0;		E_represent_accuracy = 0;		E_prune_ans_no = 0;		E_overlap_yes = 0;  		k_NN_search(root, query[i], nn);                		E_page_access_count_sum += E_page_access_count;		E_represent_accuracy_sum += ((double)E_represent_accuracy)/((double)E_page_access_count);		E_prune_accuracy_sum += ((double)E_overlap_yes)/((double)E_prune_ans_no);                                 		printf("---------------------------\n"); 	}                                	getrusage(RUSAGE_SELF,&myTime2);	// for experiment 	userTime =                ((float) (myTime2.ru_utime.tv_sec  - myTime1.ru_utime.tv_sec)) +                ((float) (myTime2.ru_utime.tv_usec - myTime1.ru_utime.tv_usec)) * 1e-6; 	sysTime =                ((float) (myTime2.ru_stime.tv_sec  - myTime1.ru_stime.tv_sec)) +                ((float) (myTime2.ru_stime.tv_usec - myTime1.ru_stime.tv_usec)) * 1e-6;	//E_result_fp = fopen(E_result_filename, "w");	E_result_fp = stdout;	fprintf(E_result_fp, "Number of query is %d\n", no_query);	fprintf(E_result_fp, "Average no. of page accesses = %f\n", (double)E_page_access_count_sum/(double)no_query); 	fprintf(E_result_fp, "User time : %f seconds\n",userTime); 	fprintf(E_result_fp, "System time : %f seconds\n",sysTime); 	fprintf(E_result_fp, "Total time : %f seconds\n",userTime+sysTime);	fprintf(E_result_fp, "\n");                	fclose(E_result_fp);                                  }  // end kNN search 	  printf("free_tree\n");  free_tree(root);  return(0);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品视频一区| 亚洲午夜日本在线观看| 7777精品伊人久久久大香线蕉的| 国产一区二区美女诱惑| 日韩电影免费一区| 免费看日韩a级影片| 精品国产精品网麻豆系列 | 国产69精品一区二区亚洲孕妇| 一级做a爱片久久| 亚洲高清免费一级二级三级| 亚洲一区二区三区不卡国产欧美| 中文字幕一区在线| 亚洲免费伊人电影| 日韩电影在线观看网站| 韩国av一区二区三区在线观看| 韩国三级电影一区二区| 激情五月婷婷综合| 欧洲一区二区三区在线| 欧美va在线播放| 自拍偷在线精品自拍偷无码专区| 91视频xxxx| 日韩欧美国产一区在线观看| 中文字幕精品综合| 五月天精品一区二区三区| 成人va在线观看| 精品国产乱码久久久久久牛牛 | 麻豆91精品视频| 日本韩国欧美在线| 国产精品毛片高清在线完整版| 天天综合天天做天天综合| 99久久婷婷国产| 日韩欧美国产午夜精品| 亚洲成av人**亚洲成av**| 成人黄色电影在线| 国产女主播视频一区二区| 日韩激情在线观看| 欧美日韩综合在线| 亚洲国产成人tv| 欧美一区二区视频观看视频| 亚洲综合色在线| 91美女蜜桃在线| 欧美国产日产图区| 99久精品国产| 尤物av一区二区| 欧美精品久久一区二区三区| 亚洲一区免费视频| 欧美日韩电影一区| 午夜精品久久久久久久久久| 欧美日韩情趣电影| 日本伊人午夜精品| 久久久国产一区二区三区四区小说 | 日韩黄色免费网站| 欧美成人精品高清在线播放| 激情文学综合网| 中文无字幕一区二区三区 | 欧美精品一区视频| 成人精品国产一区二区4080| 亚洲色图另类专区| 欧美成人高清电影在线| 成人黄色网址在线观看| 亚洲韩国一区二区三区| 日韩欧美一二三区| 成人网页在线观看| 日产国产高清一区二区三区| 久久久久久**毛片大全| 欧美视频一区二区三区四区 | 欧美一区二区三区四区五区 | 欧美一区二区二区| 色综合久久久久综合99| 久久综合综合久久综合| 精品国产一区二区三区不卡 | 2024国产精品视频| 欧美中文字幕久久| 9人人澡人人爽人人精品| 麻豆精品视频在线观看免费| 亚洲综合色婷婷| 17c精品麻豆一区二区免费| 日韩视频免费观看高清完整版在线观看 | 精品福利在线导航| 欧美色涩在线第一页| 91福利在线观看| 色88888久久久久久影院按摩| 国产乱一区二区| 国产毛片精品一区| 狠狠v欧美v日韩v亚洲ⅴ| 免费看欧美美女黄的网站| 亚洲成人tv网| 美国毛片一区二区三区| 蜜臀av一级做a爰片久久| 成人激情av网| 88在线观看91蜜桃国自产| 看国产成人h片视频| 91精品国产综合久久蜜臀| 舔着乳尖日韩一区| 日韩av一区二区在线影视| 首页国产欧美久久| 久久精品国产99国产精品| 国产成人午夜99999| 国产黄色精品视频| 色综合激情久久| 日韩一区二区视频| 国产精品视频一二| 亚洲一区二区在线视频| 久久国产精品色婷婷| 一级中文字幕一区二区| 美女在线视频一区| av一区二区三区在线| 欧美美女直播网站| 国产精品视频看| 亚洲成人激情av| jlzzjlzz亚洲女人18| 91精品在线观看入口| 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲色图制服丝袜| 国内精品伊人久久久久影院对白| 99精品国产一区二区三区不卡| 欧美日韩国产一级片| 中文字幕一区二区三区不卡| 日本不卡一二三| 欧美在线小视频| 中文字幕一区二区三区在线播放| 日本欧美肥老太交大片| 色视频成人在线观看免| 国产精品美女一区二区三区| 黄网站免费久久| 欧美日韩精品一区二区在线播放| 国产精品的网站| 国产成人午夜高潮毛片| 久久婷婷国产综合国色天香 | 激情综合五月天| 宅男在线国产精品| 另类小说一区二区三区| 91精品蜜臀在线一区尤物| 午夜天堂影视香蕉久久| 91免费观看视频在线| 国产精品乱码人人做人人爱| 国产美女在线精品| 日本一区二区成人| 色婷婷国产精品| 日韩福利视频网| 精品久久国产老人久久综合| 久久99精品久久久久婷婷| 久久精品人人做| 成人动漫中文字幕| 亚洲国产精品一区二区尤物区| 欧美一级在线免费| 国产精品99精品久久免费| √…a在线天堂一区| 欧美亚洲综合一区| 国产综合久久久久影院| 国产精品三级av| 欧美视频三区在线播放| 黄色小说综合网站| 尤物在线观看一区| 欧美mv日韩mv亚洲| 91蜜桃视频在线| 国产精品99久久久久久似苏梦涵| 亚洲精品视频在线| 中文在线一区二区| 日韩一级高清毛片| 一本大道久久a久久精二百| 奇米色777欧美一区二区| 亚洲免费观看高清完整版在线观看熊| 欧美三级三级三级| 一本色道久久综合精品竹菊| 精品一区二区三区免费观看| 一区二区三区免费观看| 日韩美女视频一区二区在线观看| www.综合网.com| 国产成人精品免费一区二区| 裸体歌舞表演一区二区| 五月婷婷欧美视频| 亚洲福利视频三区| 亚洲女同一区二区| 亚洲欧美日韩国产综合在线| 国产精品福利一区| 一级中文字幕一区二区| 一区二区三区四区不卡在线 | 91久久精品一区二区| av亚洲精华国产精华精| 91在线无精精品入口| 不卡一卡二卡三乱码免费网站 | 精品国产网站在线观看| 欧美精品免费视频| 日韩精品一区二区三区视频| 69精品人人人人| 欧美精品一区二区三区很污很色的| 欧美日韩国产免费一区二区| 91精品综合久久久久久| 精品粉嫩aⅴ一区二区三区四区| 欧美一级高清大全免费观看| 日韩亚洲欧美在线观看| 久久精品男人天堂av| 亚洲视频狠狠干| 久久超碰97中文字幕| 99精品一区二区三区| 欧美日韩高清一区二区三区| 欧美日本不卡视频| 亚洲国产成人一区二区三区| 亚洲一区在线播放|