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

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

?? fis.c

?? 模糊控制工具箱,很好用的,有相應的說明文件,希望對大家有用!
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
 * Stand-alone C codes for fuzzy inference systems.
 * (This file is included in fismain.c)
 * J.-S. Roger Jang, 1994.
 * Copyright 1994-2001 The MathWorks, Inc. 
 */

/*
  * Copyright 1994-2005 The MathWorks, Inc.
 */
#ifndef __FIS__
# define __FIS__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

/***********************************************************************
 Macros and definitions
 **********************************************************************/
/* Define portable printf and double */
#if defined(MATLAB_MEX_FILE)
# define PRINTF mexPrintf
# define DOUBLE real_T
#elif defined(__SIMSTRUC__)
# define PRINTF ssPrintf
# define DOUBLE real_T
#else
# define PRINTF printf
# define DOUBLE double
#endif

#ifndef ABS
# define ABS(x)   ( (x) > (0) ? (x): (-(x)) )
#endif
#ifndef MAX
# define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#endif
#ifndef MIN
# define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#endif
#define MF_PARA_N 4
#define STR_LEN 500
#define MF_POINT_N 101

/* debugging macros */
/*
#define PRINT(expr) printf(#expr " = %g\n", (double)expr)
#define PRINTMAT(mat,m,n) printf(#mat " = \n"); fisPrintMatrix(mat,m,n)
#define FREEMAT(mat,m) printf("Free " #mat " ...\n"); fisFreeMatrix(mat,m)
#define FREEARRAY(array) printf("Free " #array " ...\n"); free(array)
*/

#if (defined(MATLAB_MEX_FILE) && !defined(__SIMSTRUC__))
# define FREE mxFree
#else
# define FREE free
#endif

#define FREEMAT(mat,m) fisFreeMatrix(mat,m)
#define FREEARRAY(array) FREE(array)

/***********************************************************************
 Data types
 **********************************************************************/

typedef struct fis_node {
	int handle;
	int load_param;
	char name[STR_LEN];
	char type[STR_LEN];
	char andMethod[STR_LEN];
	char orMethod[STR_LEN];
	char impMethod[STR_LEN];
	char aggMethod[STR_LEN];
	char defuzzMethod[STR_LEN];
	int userDefinedAnd;
	int userDefinedOr;
	int userDefinedImp;
	int userDefinedAgg;
	int userDefinedDefuzz;
	int in_n;
	int out_n;
	int rule_n;
	int **rule_list;
	DOUBLE *rule_weight;
	int *and_or;	/* AND-OR indicator */
	DOUBLE *firing_strength;
	DOUBLE *rule_output;
	/* Sugeno: output for each rules */
	/* Mamdani: constrained output MF values of rules */
	struct io_node **input;
	struct io_node **output;
	DOUBLE (*andFcn)(DOUBLE, DOUBLE);
	DOUBLE (*orFcn)(DOUBLE, DOUBLE);
	DOUBLE (*impFcn)(DOUBLE, DOUBLE);
	DOUBLE (*aggFcn)(DOUBLE, DOUBLE);
	DOUBLE (*defuzzFcn)();
	DOUBLE *BigOutMfMatrix;	/* used for Mamdani system only */
    DOUBLE *BigWeightMatrix;/* used for Mamdani system only */
	DOUBLE *mfs_of_rule;	/* MF values in a rule */

	DOUBLE *bias; /*bias, to be tuned when no rules are fired*/
	int isbias;

	struct fis_node *next;
} FIS;



typedef struct io_node {
	char name[STR_LEN];
	int mf_n;
	DOUBLE bound[2];
	DOUBLE value;
	struct mf_node **mf;
} IO;



typedef struct mf_node {
	char label[STR_LEN];	/* MF name */
	char type[STR_LEN];		/* MF type */
	int nparams;			/* length of params field */
	DOUBLE *params;			/* MF parameters */
	int userDefined;		/* 1 if the MF is user-defined */
	DOUBLE (*mfFcn)(DOUBLE, DOUBLE *); /* pointer to a mem. fcn */ 
	DOUBLE value;		    /* for Sugeno only */
	DOUBLE *value_array;	/* for Mamdani only, array of MF values */
} MF;

#endif /* __FIS__ */
/***********************************************************************
 File, arrays, matrices operations 
 **********************************************************************/
/* Copyright 1994-2002 The MathWorks, Inc.  */
/* $Revision: $  $Date: $  */

/* display error message and exit */
static void fisError(char *msg)
{
#ifdef MATLAB_MEX_FILE
	mexErrMsgTxt(msg);
#else
	PRINTF("%s\n",msg);
    exit(1);
#endif
}

#ifndef NO_PRINTF         /*in case for rtw and dSPACE use */

/* an friendly interface to fopen() */
static FILE *fisOpenFile(char *file, char *mode)
{
	FILE *fp, *fopen();

	if ((fp = fopen(file, mode)) == NULL){
		PRINTF("The file %s cannot be opened.", file);
		fisError("\n");
	}
	return(fp);
}

#endif


/* define a standard memory access function with error checking */
void *fisCalloc(int num_of_x, int size_of_x)
{
	void *ptr;

#if (defined(MATLAB_MEX_FILE) &&  !defined(__SIMSTRUC__))
	/* datstruc.c ln325 requires ptr = NULL when it supplies num_of_x = 0 */
	if (num_of_x == 0) 
            ptr = NULL; /* mxCalloc returns a NULL pointer if num_of_x or size_of_x = 0 */
	else {
            ptr = mxCalloc(num_of_x, size_of_x);
            /* however we still need to check that memory was allocated successfully,
               exclude the case when num_of_x = 0, and if unsuccessful issue an error */
            if (ptr == NULL)
                fisError("Could not allocate memory in mxCalloc function call.");}
#else /* a Simulink file (defined(__SIMSTRUC__)), or standalone is being created */
	if (num_of_x == 0) 
            ptr = NULL; /* calloc returns a NULL pointer if num_of_x or size_of_x = 0 */
	else {
            ptr = calloc(num_of_x, size_of_x);
            /* however we still need to check that memory was allocated successfully,
               exclude the case when num_of_x = 0, and if unsuccessful issue an error */
            if (ptr == NULL)
                fisError("Could not allocate memory in calloc function call.");}
#endif

        return(ptr);
}


char **fisCreateMatrix(int row_n, int col_n, int element_size)
{
	char **matrix;
	int i;

	if (row_n == 0 && col_n == 0)
		return(NULL);
	matrix = (char **)fisCalloc(row_n, sizeof(char *));
	if (matrix == NULL)
		fisError("Calloc error in fisCreateMatrix!");
	for (i = 0; i < row_n; i++) { 
		matrix[i] = (char *)fisCalloc(col_n, element_size);
		if (matrix[i] == NULL)
			fisError("Calloc error in fisCreateMatrix!");
	}
	return(matrix);
}


/* won't complain if given matrix is already freed */
static void fisFreeMatrix(void **matrix, int row_n)
{
	int i;
	if (matrix != NULL) {
		for (i = 0; i < row_n; i++) {
			FREE(matrix[i]);
		}
		FREE(matrix);
	}
}


static DOUBLE**fisCopyMatrix(DOUBLE **source, int row_n, int col_n)
{
	DOUBLE **target;
	int i, j;

	target = (DOUBLE **)fisCreateMatrix(row_n, col_n, sizeof(DOUBLE));
	for (i = 0; i < row_n; i++)
		for (j = 0; j < col_n; j++)
			target[i][j] = source[i][j];
	return(target);
}


#ifndef NO_PRINTF        /* not available for RTW and dSPACE */

static void fisPrintMatrix(DOUBLE **matrix, int row_n, int col_n)
{
	int i, j;
	for (i = 0; i < row_n; i++) {
		for (j = 0; j < col_n; j++)
			PRINTF("%.3f ", matrix[i][j]);
		PRINTF("\n");
	}
}

static void fisPrintArray(DOUBLE *array, int size)
{
	int i;
	for (i = 0; i < size; i++)
		PRINTF("%.3f ", array[i]);
	PRINTF("\n");
}

static void
fisPause()
{
	PRINTF("Hit RETURN to continue ...\n");
	getc(stdin);
}

#endif
/***********************************************************************
 Parameterized membership functions
 **********************************************************************/
/* Copyright 1994-2002 The MathWorks, Inc.  */
/* $Revision: $  $Date: $  */

/* Triangular membership function */
static DOUBLE fisTriangleMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a = params[0], b = params[1], c = params[2];

	if (a>b)
		fisError("Illegal parameters in fisTriangleMf() --> a > b");
	if (b>c)
		fisError("Illegal parameters in fisTriangleMf() --> b > c");

	if (a == b && b == c)
		return(x == a);
	if (a == b)
		return((c-x)/(c-b)*(b<=x)*(x<=c));
	if (b == c)
		return((x-a)/(b-a)*(a<=x)*(x<=b));
	return(MAX(MIN((x-a)/(b-a), (c-x)/(c-b)), 0));
}

/* Trapezpoidal membership function */
static DOUBLE fisTrapezoidMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a = params[0], b = params[1], c = params[2], d = params[3];
	DOUBLE y1 = 0, y2 = 0;

	if (a>b) {
		PRINTF("a = %f, b = %f, c = %f, d = %f\n", a, b, c, d);
		fisError("Illegal parameters in fisTrapezoidMf() --> a > b");
	}
        if (b>c)
         {
                PRINTF("a = %f, b = %f, c = %f, d = %f\n", a, b, c, d);      
                fisError("Illegal parameters in fisTrapezoidMf() --> b > c");
         }
	if (c>d) {
		PRINTF("a = %f, b = %f, c = %f, d = %f\n", a, b, c, d);
		fisError("Illegal parameters in fisTrapezoidMf() --> c > d");
	}

	if (b <= x)
		y1 = 1;
	else if (x < a)
		y1 = 0;
	else if (a != b)
		y1 = (x-a)/(b-a);

	if (x <= c)
		y2 = 1;
	else if (d < x)
		y2 = 0;
	else if (c != d)
		y2 = (d-x)/(d-c);

	return(MIN(y1, y2));
	/*
	if (a == b && c == d)
		return((b<=x)*(x<=c));
	if (a == b)
		return(MIN(1, (d-x)/(d-c))*(b<=x)*(x<=d));
	if (c == d)
		return(MIN((x-a)/(b-a), 1)*(a<=x)*(x<=c));
	return(MAX(MIN(MIN((x-a)/(b-a), 1), (d-x)/(d-c)), 0));
	*/
}

/* Gaussian membership function */
static DOUBLE fisGaussianMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE sigma = params[0], c = params[1];
	DOUBLE tmp;

	if (sigma==0)
		fisError("Illegal parameters in fisGaussianMF() --> sigma = 0");
	tmp = (x-c)/sigma;
	return(exp(-tmp*tmp/2));
}

/* Extended Gaussian membership function */
static DOUBLE fisGaussian2Mf(DOUBLE x, DOUBLE *params)
{
	DOUBLE sigma1 = params[0], c1 = params[1];
	DOUBLE sigma2 = params[2], c2 = params[3];
	DOUBLE tmp1, tmp2;

	if ((sigma1 == 0) || (sigma2 == 0))
		fisError("Illegal parameters in fisGaussian2MF() --> sigma1 or sigma2 is zero");

	tmp1 = x >= c1? 1:exp(-pow((x-c1)/sigma1, 2.0)/2);
	tmp2 = x <= c2? 1:exp(-pow((x-c2)/sigma2, 2.0)/2);
	return(tmp1*tmp2);
}

/* Sigmoidal membership function */
static DOUBLE fisSigmoidMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a = params[0], c = params[1];
	return(1/(1+exp(-a*(x-c))));
}

/* Product of two sigmoidal functions */
static DOUBLE fisProductSigmoidMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a1 = params[0], c1 = params[1], a2 = params[2], c2 = params[3];
	DOUBLE tmp1 = 1/(1+exp(-a1*(x-c1)));
	DOUBLE tmp2 = 1/(1+exp(-a2*(x-c2)));
	return(tmp1*tmp2);
}

/* Absolute difference of two sigmoidal functions */
static DOUBLE fisDifferenceSigmoidMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a1 = params[0], c1 = params[1], a2 = params[2], c2 = params[3];
	DOUBLE tmp1 = 1/(1+exp(-a1*(x-c1)));
	DOUBLE tmp2 = 1/(1+exp(-a2*(x-c2)));
	return(fabs(tmp1-tmp2));
}

/* Generalized bell membership function */
static DOUBLE fisGeneralizedBellMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a = params[0], b = params[1], c = params[2];
	DOUBLE tmp;
	if (a==0)
		fisError("Illegal parameters in fisGeneralizedBellMf() --> a = 0");
	tmp = pow((x-c)/a, 2.0);
	if (tmp == 0 && b == 0)
		return(0.5);
	else if (tmp == 0 && b < 0)
		return(0.0);
	else
		return(1/(1+pow(tmp, b)));
}

/* S membership function */
static DOUBLE fisSMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a = params[0], b = params[1];
	DOUBLE out;

	if (a >= b)
		return(x >= (a+b)/2);

	if (x <= a)
		out = 0;
	else if (x <= (a + b)/2)
		out = 2*pow((x-a)/(b-a), 2.0);
	else if (x <= b)
		out = 1-2*pow((b-x)/(b-a), 2.0);
	else
		out = 1;
	return(out);
}

/* Z membership function */
static DOUBLE fisZMf(DOUBLE x, DOUBLE *params)
{
	DOUBLE a = params[0], b = params[1];
	DOUBLE out;

	if (a >= b)
		return(x <= (a+b)/2);

	if (x <= a)
		out = 1;
	else if (x <= (a + b)/2)
		out = 1 - 2*pow((x-a)/(b-a), 2.0);
	else if (x <= b)
		out = 2*pow((b-x)/(b-a), 2.0);
	else
		out = 0;
	return(out);
}

/* pi membership function */
static DOUBLE fisPiMf(DOUBLE x, DOUBLE *params)
{
	return(fisSMf(x, params)*fisZMf(x, params+2));
}

/* all membership function */
static DOUBLE fisAllMf(DOUBLE x, DOUBLE *params)
{
	return(1);
}

/* returns the number of parameters of MF */
static int fisGetMfParaN(char *mfType)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品三级av| 欧美v日韩v国产v| 国产成人av一区二区| 精品一区二区三区免费观看| 亚洲国产视频直播| 亚洲午夜精品一区二区三区他趣| 亚洲男人的天堂在线观看| 国产精品久久久久久久久久久免费看 | 久久久激情视频| 久久久欧美精品sm网站| 欧美激情在线观看视频免费| 久久久www免费人成精品| 欧美国产日韩在线观看| 国产日产亚洲精品系列| 国产天堂亚洲国产碰碰| 欧美激情一区二区三区四区| 中文字幕在线观看不卡| 亚洲制服丝袜av| 蜜臀av亚洲一区中文字幕| 另类小说图片综合网| 国产在线不卡一区| 成人动漫精品一区二区| 在线视频一区二区三| 欧美一区二区三区不卡| 久久久精品黄色| 亚洲三级在线看| 日韩极品在线观看| 国产福利一区二区三区在线视频| 99re成人精品视频| 69久久夜色精品国产69蝌蚪网| 欧美白人最猛性xxxxx69交| 欧美国产1区2区| 亚洲第一成年网| 国产精品一区一区| 一本一道波多野结衣一区二区| 欧美精品在线视频| 亚洲国产精品高清| 视频一区二区三区中文字幕| 国产91精品久久久久久久网曝门| 91福利国产成人精品照片| 精品国产一区二区三区忘忧草| 国产精品国产精品国产专区不蜜 | 中文字幕第一区综合| 亚洲精品国产精品乱码不99| 麻豆成人在线观看| 色综合天天狠狠| 99免费精品视频| 精品国内片67194| 国产福利不卡视频| 最新欧美精品一区二区三区| 在线观看日产精品| 免费久久99精品国产| 久久综合久久久久88| 成人app软件下载大全免费| 亚洲欧美一区二区不卡| 欧美日韩国产大片| 国产综合一区二区| 最新久久zyz资源站| 欧美日韩激情一区二区三区| 麻豆91在线播放免费| 国产精品视频一二三| 欧美性大战久久久久久久蜜臀| 日韩国产高清影视| 国产欧美日韩三区| 欧美日韩一区高清| 国产精品888| 激情综合五月天| 国产精品三级电影| 欧美精品一级二级三级| 国产高清在线精品| 亚洲一区二区三区四区不卡| 亚洲精品在线三区| 色哟哟国产精品免费观看| 日本大胆欧美人术艺术动态| 中文一区二区完整视频在线观看| 欧美在线观看视频一区二区三区| 精品在线观看免费| 一区二区不卡在线视频 午夜欧美不卡在| 884aa四虎影成人精品一区| 国产福利一区在线| 奇米影视一区二区三区小说| 国产精品激情偷乱一区二区∴| 欧美精选一区二区| 99久久国产综合精品女不卡| 九色综合狠狠综合久久| 亚洲一区二区三区美女| 欧美经典三级视频一区二区三区| 欧美人妖巨大在线| 91蝌蚪porny成人天涯| 久久99国产精品尤物| 亚洲福利一二三区| 自拍偷在线精品自拍偷无码专区| 精品日韩在线观看| 欧美午夜精品一区二区三区| 成人av在线资源网| 国产一区高清在线| 青青草原综合久久大伊人精品优势| 亚洲蜜臀av乱码久久精品蜜桃| 国产亚洲精品bt天堂精选| 欧美一区二区二区| 欧美精品九九99久久| 色婷婷综合五月| 91视频在线观看免费| 国产夫妻精品视频| 国产一区二区三区观看| 另类人妖一区二区av| 青娱乐精品在线视频| 午夜视频一区二区| 亚洲成人在线观看视频| 亚洲综合激情小说| 一区二区高清视频在线观看| 最新久久zyz资源站| 国产精品二区一区二区aⅴ污介绍| 亚洲欧美另类综合偷拍| 欧美在线观看视频在线| 风间由美中文字幕在线看视频国产欧美| 视频一区二区三区中文字幕| 亚洲动漫第一页| 欧美电视剧免费全集观看| 欧美日韩高清影院| 欧美日韩日本视频| 欧美三级在线看| 欧美日韩成人一区二区| 欧美日韩高清一区二区不卡| 欧美人妇做爰xxxⅹ性高电影| 欧美日韩成人综合在线一区二区| 欧美精品丝袜中出| 日韩欧美国产综合在线一区二区三区| 欧美精品粉嫩高潮一区二区| 欧美一区二区性放荡片| 日韩三级免费观看| 久久精品在线观看| 亚洲欧美在线观看| 亚洲一二三四在线观看| 日韩中文字幕91| 国产综合色在线视频区| 成年人午夜久久久| 欧美亚洲一区二区在线| 日韩午夜小视频| 久久久久久久综合| 国产精品传媒视频| 亚洲一区二区三区国产| 毛片av一区二区| 成人国产一区二区三区精品| 色综合中文字幕| 久久久午夜精品理论片中文字幕| 国产亚洲精品福利| 一区二区在线观看视频| 蜜桃一区二区三区在线观看| 成人中文字幕电影| 欧美怡红院视频| 欧美va在线播放| 亚洲人成网站影音先锋播放| 日本伊人精品一区二区三区观看方式| 国内久久婷婷综合| 在线观看亚洲a| 久久九九久久九九| 亚洲国产另类精品专区| 国产一区二区三区电影在线观看| 91麻豆免费视频| 精品久久五月天| 亚洲一区二区三区视频在线 | 91蝌蚪porny| 欧美第一区第二区| 亚洲精品国产视频| 国产99精品在线观看| 51精品视频一区二区三区| 国产精品九色蝌蚪自拍| 美女在线视频一区| 欧美午夜精品久久久久久孕妇 | 一本大道综合伊人精品热热| 日韩一区二区三| 亚洲一区二区三区视频在线 | 久久综合色综合88| 亚洲成人免费视频| www.亚洲国产| 久久久久99精品国产片| 日韩av中文在线观看| 91国偷自产一区二区开放时间 | 国产日韩av一区| 奇米影视一区二区三区小说| 色婷婷久久久亚洲一区二区三区 | 国产精品麻豆99久久久久久| 麻豆国产一区二区| 精品视频在线视频| 亚洲人成网站精品片在线观看| 国产成人在线观看| 精品不卡在线视频| 美女www一区二区| 欧美日本视频在线| 亚洲一区二区三区视频在线播放| 99久久久免费精品国产一区二区| 久久精品免视看| 国产精品白丝av| 欧美精品一区二区三区四区| 久久av老司机精品网站导航| 欧美一级欧美一级在线播放| 日韩电影在线观看电影| 欧美日韩国产bt| 日本中文字幕不卡|