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

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

?? grid.c

?? 螞蟻聚類算法源代碼(ant based clustering algorithm)
?? C
字號:
/*  Ant-based Clustering    Copyright (C) 2004 Julia Handl    Email: Julia.Handl@gmx.de    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//***************************************************date: 7.4.2003author: Julia Handl (julia.handl@gmx.de)description: implementation of a the two-dimensional gridused for ant-based clusteringThe grid is a simple two-dimensional array thatcan store integers (these index into the data collection). It contains an additionalindex structure that keeps track of the dataitems on the grid and their respective positions(such that ants can directly access them and do not have to search). The grid is toroidaland the update of grid positions thereforerequires to "wrap around" corrdinates at the borders. ***************************************************/#include "grid.h"#include <iostream>#include "random.h"extern long idum;/* Constructor:    memory allocation and initialisation*/grid::grid(conf * c, databin<USED_DATA_TYPE> * b) {       /* storage of the pointer to data and current parameter settings */    par = c;    bin = b;    /* preparation of the grid-cells */    cells = new int* [par->imax];    for (int i=0; i<par->imax; i++) {	cells[i] = new int [par->jmax];	for (int j=0; j<par->jmax; j++) {	    cells[i][j] = FREE;	}    }    /* preparation of the index of free data items */    index = new position<int>[par->binsize];    last = 0;    items = 0;}/* Access to index */position<int> & grid::getposition(int i) {    return index[i];}/* Destructor: delete all allocated memory */grid::~grid() {    /* delete grid cells */    for (int i=0; i<par->imax; i++) {	delete [] cells[i];    }    delete [] cells;    /* delete index */    delete [] index;}/* Print the current spatial distribution to a file;   required by the visualisation routine */void grid::print() {    ofstream to("grid.dat");    for (int i=0; i<par->imax; i++) {	for (int j=0; j<par->jmax; j++) {	    if (cells[i][j] != FREE) {		to << cells[i][j]+1 << " ";	    }	    else {		to << 0 << " ";		    }	}	to << endl;    }}void grid::init() {    // generation of the initial random data distribution    // update of both grid cells and index      last = 0;    for (int i=0; i<par->binsize; ) {	int ipos = int(ran0(&idum)*par->imax);	int jpos = int(ran0(&idum)*par->jmax);       	if (cells[ipos][jpos] == FREE) {	    cells[ipos][jpos] = i;	    index[i].set(ipos, jpos);	    i++;	}     }    items = par->binsize;    }/* write-read access to grid cells  */int &grid::operator()(int i, int j) {    return cells[i][j];}/* return the position of a random element    from the index of free data items */const position<int> & grid::next() {    last = int(ran0(&idum) * items);        return index[last];}/* advise data item <data> to the grid at position <pos> */void grid::add(position<int> & pos, const int data) {    /* copy data identifier to grid */    cells[int(pos[0])][int(pos[1])] = data;    /* update index */    index[items++] = pos;}/* same as add, without index update */const void grid::replace(position<int> & pos, int data, int replaced) {    cells[int(pos[0])][int(pos[1])] = data;}const void grid::remove(position<int> & pos) {        // update index (last points to the last element that    // was returned by next(). This is the one to be replaced.    // This isn't very elegant, I know :-(        index[last] = index[--items];    // mark cell as free    cells[int(pos[0])][int(pos[1])] = FREE;    return;}const int grid::remove_init(position<int> * pos) {     // notice that the index must be treated different    // from a simple remove    (*pos) = index[--items];        int temp = cells[int((*pos)[0])][int((*pos)[1])];    // mark cell as free    cells[int((*pos)[0])][int((*pos)[1])] = FREE;    return temp;}// neighborhood function f providing environment informationconst double grid::fold(const int data, position<int> & pos, const int radius, const int nsize, double scalefactor) {    double sum = 0.0;    for (int i=int(pos[0]-radius); i<=pos[0]+radius; i++) {	for (int j=int(pos[1]-radius); j<=pos[1]+radius; j++) {	    int ii = checkborder(i, par->imax);	    int jj = checkborder(j, par->jmax);	 	    if ((cells[ii][jj] != FREE) && (cells[ii][jj] != data)) {		double d = dissimilarity(data, cells[ii][jj]) / scalefactor;		sum += 1.0 - d;	    }	}    }        if (sum > 0) return sum/nsize;    else return 0.0;} /* neighborhood function f providing environment information */const double grid::f(const int data, position<int> & pos, const int radius, const int nsize, double scalefactor, int clusterphase) {    double sum = 0.0;     double ctr = 0.0;    double weight = 0.0;    int dx, dy;    int incx, incy;    incy = -1;    dy = radius;    for (int i=int(pos[0]-radius); i<=pos[0]+radius; i++) {	dx = radius;	incx = -1;	for (int j=int(pos[1]-radius); j<=pos[1]+radius; j++) {	    int ii = checkborder(i, par->imax);	    int jj = checkborder(j, par->jmax);	 	    if ((cells[ii][jj] != FREE) && (cells[ii][jj] != data)) {		double d;		if (par->weighting == FALSE) {		    d = (1.0 - dissimilarity(data, cells[ii][jj]) / scalefactor);		    if (d <= 0 ) return 0.0;		    ctr += 1.0; 			}		else {		    weight = exp(-double(max(dx, dy))/double(radius));		    d = (1.0-dissimilarity(data, cells[ii][jj]) / scalefactor) / weight; 		    ctr += weight;		}		sum += d;	    }	    if (dx == 0) incx = 1;	    dx += incx;	}	if (dy == 0) incy = 1;	dy += incy;    }   if (clusterphase == TRUE) {       if (sum > 0) return sum/double(nsize);	 else return 0.0;    }    else {	if (sum > 0) return sum/double(ctr);	else return 0.0;	}}/* access to precomputed distance matrix */const double grid::dissimilarity(const int data1, const int data2) {    return bin->precomputed_d(data1, data2);}/* generate random position within a specified radius of the current position */void grid::generate(position<int> & pos, const int radius, position<int> & temp) {    int dx, dy;    double xt = (ran0(&idum)*2.0-1.0)*radius;    double yt = (ran0(&idum)*2.0-1.0)*radius;    dx = int((xt < 0) ? floor(xt) : ceil(xt));    dy = int((yt < 0) ? floor(yt) : ceil(yt));    temp = pos;    temp.add(dx,dy,par->imax,par->jmax);}void grid::generate(position<double> & pos, const int radius, position<double> & temp) {    int dx, dy;    double xt = (ran0(&idum)*2.0-1.0)*radius;    double yt = (ran0(&idum)*2.0-1.0)*radius;    dx = int((xt < 0) ? ceil(xt) : floor(xt));    dy = int((yt < 0) ? ceil(yt) : floor(yt));    temp = pos;    temp.add((int)dx,(int)dy,par->imax,par->jmax);}/* search for dropping position near <pos> */const position<int> grid::searchdroppingsite(position<int> & pos, const int data) {    double radius = 1.0;    position<int> temp = pos;    int ctr = 0;        /* try each radius five times */    while (cells[int(temp[0])][int(temp[1])] != FREE) {	generate(pos, (int)radius, temp);	radius += 0.2;	ctr++;    }    return temp;}/* Search for a free dropping site near the grid position <pos> */const position<double> grid::searchdroppingsite(position<double> & pos, const int data) {      double radius = 1.0;    position<double> temp = pos;    int ctr = 0;        /* try each radius five times */    while (cells[int(temp[0])][int(temp[1])] != FREE) {	generate(pos, (int)radius, temp);	radius += 0.2;	ctr++;    }        return temp;}/* border checks to stay on toroidal grid */const int grid::checkborder(const int p, const int lim) {    if (p >= lim) {	return p % lim;    }    if (p < 0) {	int temp = p%lim;	if (temp != 0) return lim + (p%lim);	else return 0;    }    return p;}double grid::square(double x) {    return x*x;}/* Euclidean distance for integer positions */double grid::spatialdistance(position<int> * p1, position<int> * p2, int torus) {    int dx = abs((*p1)[0]-(*p2)[0]);    if (torus == TRUE) dx = min(dx, par->imax - dx);    int dy = abs((*p1)[1]-(*p2)[1]);    if (torus == TRUE) dy = min(dy, par->jmax - dy);    return sqrt(double(square(dx)+square(dy)));}/* Euclidean distance for double positions */double grid::spatialdistance(position<double> * p1, position<double> * p2, int torus) {    double dx = abs((*p1)[0]-(*p2)[0]);    if (torus == TRUE) dx = min(dx, par->imax - dx);    double dy = abs((*p1)[1]-(*p2)[1]);    if (torus == TRUE) dy = min(dy, par->jmax - dy);    return sqrt(double(square(dx)+square(dy)));}double max(double i, double j) {    if (i > j) return i;    else return j;}double min(double i, double j) {    if (i < j) return i;    else return j;}int max(int i, int j) {    if (i > j) return i;    else return j;}int min(int i, int j) {    if (i < j) return i;    else return j;}double abs(double x) {    if (x < 0) return -x;    else return x;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲av色图| 韩国一区二区视频| 国产做a爰片久久毛片| 99久久精品情趣| 欧美一区午夜视频在线观看| 国产网站一区二区| 午夜av电影一区| 97se亚洲国产综合自在线观| 欧美大片顶级少妇| 视频一区视频二区中文字幕| 91女厕偷拍女厕偷拍高清| 欧美mv日韩mv国产网站app| 一区二区三区在线观看国产| 国产美女一区二区| 欧美α欧美αv大片| 婷婷中文字幕一区三区| 91老师片黄在线观看| 中文字幕精品一区| 国产精品亚洲成人| 日韩一级欧美一级| 午夜精品福利一区二区蜜股av | 91久久免费观看| 久久综合狠狠综合久久激情| 日本亚洲欧美天堂免费| 欧美系列在线观看| 亚洲国产精品自拍| 欧美自拍偷拍午夜视频| 亚洲精品美腿丝袜| 91香蕉视频污| 亚洲免费在线视频| 91免费版pro下载短视频| 国产精品成人网| 99久久国产综合精品色伊| 中文字幕一区二区三区四区不卡| 国产精品18久久久久久久久久久久| 欧美va日韩va| 国产露脸91国语对白| 久久久精品国产99久久精品芒果| 成人一区二区三区视频 | 久久九九久久九九| 精品一二三四区| 久久综合成人精品亚洲另类欧美 | 亚洲成人av在线电影| 91福利在线观看| 亚洲第一激情av| 在线播放/欧美激情| 日韩国产欧美视频| 日韩欧美www| 国产精品99久久久久久宅男| 国产嫩草影院久久久久| 成人免费高清在线观看| 亚洲精品乱码久久久久久久久 | 午夜精品福利在线| 欧美变态凌虐bdsm| aaa亚洲精品一二三区| 亚洲国产精品一区二区尤物区| 欧美一区二区视频免费观看| 久久91精品国产91久久小草| 亚洲国产成人在线| 欧洲一区在线观看| 老司机精品视频导航| 中文幕一区二区三区久久蜜桃| 在线免费观看日韩欧美| 精品亚洲免费视频| 亚洲欧洲一区二区在线播放| 欧美精品欧美精品系列| 成人黄色小视频| 婷婷夜色潮精品综合在线| 欧美激情一区二区在线| 欧美日韩午夜影院| 国产夫妻精品视频| 亚洲国产精品久久不卡毛片| 久久综合久久综合九色| 欧美视频三区在线播放| 丁香一区二区三区| 午夜视频久久久久久| 国产精品视频在线看| 欧美精品自拍偷拍| 成人精品在线视频观看| 久久成人免费日本黄色| 秋霞国产午夜精品免费视频 | 欧美日韩一区二区在线观看| 精品一区二区三区香蕉蜜桃| 亚洲男人天堂一区| 欧美激情艳妇裸体舞| 欧美疯狂性受xxxxx喷水图片| 波多野结衣精品在线| 久久99日本精品| 石原莉奈在线亚洲二区| 亚洲欧美日本韩国| 国产精品伦一区| 精品对白一区国产伦| 欧美二区三区91| 欧美在线观看视频一区二区三区| 丰满亚洲少妇av| 韩国一区二区视频| 蜜臀av一区二区| 亚洲777理论| 亚洲午夜电影在线观看| 亚洲欧洲日本在线| 国产精品视频免费| 日本一区二区综合亚洲| 26uuu精品一区二区| 欧美一卡二卡在线| 4438x亚洲最大成人网| 欧美视频精品在线| 欧美偷拍一区二区| 欧洲激情一区二区| 色狠狠av一区二区三区| av资源网一区| 成人av网站在线| 99久久精品国产一区| 成人免费视频国产在线观看| 国产精品12区| 成人18视频日本| 暴力调教一区二区三区| 99久久99久久免费精品蜜臀| av电影在线观看一区| www.在线成人| 色婷婷久久久亚洲一区二区三区| 成人一区在线观看| 99免费精品视频| 91在线观看下载| 91久久国产最好的精华液| 欧日韩精品视频| 欧美日韩电影一区| 欧美一区二区不卡视频| 精品精品国产高清a毛片牛牛| 久久青草欧美一区二区三区| 国产婷婷色一区二区三区四区| 久久久不卡影院| 亚洲欧美偷拍另类a∨色屁股| 曰韩精品一区二区| 五月天久久比比资源色| 免费在线观看一区二区三区| 久久99精品视频| 成人午夜视频网站| 欧美在线色视频| 日韩精品在线一区| 国产精品三级视频| 亚洲国产精品一区二区尤物区| 老司机免费视频一区二区三区| 一本到三区不卡视频| 91国产精品成人| 日韩美女视频在线| 欧美高清在线一区二区| 亚洲码国产岛国毛片在线| 婷婷久久综合九色国产成人| 国产精品综合二区| 欧美三级午夜理伦三级中视频| 日韩一区二区三区电影在线观看| 国产亚洲一区二区在线观看| 亚洲欧美国产77777| 蜜臀av一区二区在线观看| av中文字幕在线不卡| 欧美一区二区在线视频| 国产三级欧美三级日产三级99| 一区二区在线看| 国产精品自拍在线| 欧美三级电影精品| 欧美激情一区二区| 免费欧美日韩国产三级电影| 福利一区二区在线观看| 91精品国产色综合久久| 亚洲欧美成aⅴ人在线观看| 麻豆91免费看| 91精品1区2区| 日本一区二区三区四区在线视频| 亚洲国产精品影院| 99久久99久久精品免费看蜜桃| 日韩欧美在线观看一区二区三区| 亚洲三级在线免费| 蜜芽一区二区三区| 色偷偷成人一区二区三区91| 国产精品色眯眯| 国产一区二区在线视频| 日韩一区二区三区视频在线观看| 亚洲精品视频在线看| 国产91精品欧美| ww亚洲ww在线观看国产| 奇米四色…亚洲| 91精品国产综合久久福利| 一区二区三区精密机械公司| 不卡av在线免费观看| 欧美精品一区二区三区在线播放| 偷拍亚洲欧洲综合| 欧美亚洲一区三区| 伊人开心综合网| 91毛片在线观看| 亚洲欧美激情视频在线观看一区二区三区| 激情av综合网| 精品少妇一区二区三区在线播放| 日日欢夜夜爽一区| 91精品国产免费| 婷婷六月综合网| 欧美一级黄色大片| 另类小说视频一区二区| 日韩天堂在线观看| 久久99国产精品久久99| 26uuu精品一区二区在线观看|