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

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

?? matrix.c

?? 基于神經網絡的辨識工具箱 (527KB)
?? C
?? 第 1 頁 / 共 3 頁
字號:
	      {
		if(ptm->mat[i][j] != elem)
		  {
		    tmp->mat[k][0]=i;
		    tmp->mat[k][1]=j;
                    k++;
		  }
	      }
	  }
	if(k==0)   /* No entries different from the element */
	{
	  retmat = mmake(1,1);
	  retmat->row=0;
	  retmat->col=0;
	}          /* Copy coordinates to a [ 2 | # of instances] matrix */
	else
	  {
	  retmat = mmake(k,2);
	  for(i=0; i < k; i++)
	  {
	    retmat->mat[i][0] = tmp->mat[i][0];
	    retmat->mat[i][1] = tmp->mat[i][1];
	  }
	}
	mfree(tmp);
	return retmat;
}



/* 
 * MDIAG :
 * -------
 * This function initializes a matrix to all zeros except for the
 * main diagonal elements, which will be assigned the specified value.
 * Inputs : ptm - Pointer to matrix that will be initialized.
 *          diag - Diagonal element value.
 */
void mdiag( matrix *ptm, double diag )
{
	register int i;

#if RUNCHK

	if (ptm->row != ptm->col) \
	merror("matrix not quadratic error in mdiag!");

#endif

	minit(ptm);
	for ( i=0; i < ptm->row; i++ ) ptm->mat[i][i] = diag;
}


/*
 * MUNIT :
 * -------
 * This function initializes a matrix to the unit or identity matrix.
 * Input : ptm - Pointer to the matrix.
 */
void munit( matrix *ptm )
{
	register int i;

#if RUNCHK

	if (ptm->row != ptm->col)
		merror("matrix not quadratic error in mdiag!");

#endif

	minit(ptm);
	for ( i=0; i < ptm->row; i++ ) ptm->mat[i][i] = 1.0;
}


/*
 * MSET :
 * ------
 * This function copies the content of a matrix to another matrix.
 * ( A := B ) == mset(a,b); Assignment of matrix.
 * Inputs : ptm1, ptm2 - Pointers to matrices.
 */
void mset( matrix *ptm1, matrix *ptm2 )
{
	register int bytes;

#if RUNCHK

	if ( !( (ptm1->row == ptm2->row) && (ptm1->col == ptm2->col) ) ) \
	merror("Dimension mismatch error in mset!");

#endif

	bytes = 8*(ptm1->row)*(ptm1->col);
	memcpy( ptm1->mat[0], ptm2->mat[0], bytes );
}


/*
 * MADD
 * ----
 *
 * Matrix addition
 *
 * Input:  *ptm1 - Pointer to result matrix
 *                 (can be equal to *ptm1 and/or *ptm2)
 *         *ptm2 - Pointer to first argument matrix
 *         *ptm3 - Pointer to second argument matrix
 */
void madd( matrix *ptm1, matrix *ptm2, matrix *ptm3 )
{
	register int i,j;

#if RUNCHK

	if (!((ptm1->row == ptm2->row) && (ptm2->row == ptm3->row))) \
	merror("Dimension mismatch error in madd!");
	if (!((ptm1->col == ptm2->col) && (ptm2->col == ptm3->col))) \
	merror("Dimension mismatch error in madd!");

#endif

	/* Add the two matrices element by element */
	for ( i=0; i < ptm2->row; i++ )
	{
		for ( j=0; j < ptm2->col; j++ )
		{
			ptm1->mat[i][j] = ptm2->mat[i][j] + ptm3->mat[i][j];
		}
	}
}


/*
 * MSUB
 * ----
 *
 * Matrix subtraction
 *
 * Input:  *ptm1 - Pointer to result matrix
 *                 (can be equal to *ptm1 and/or *ptm2)
 *         *ptm2 - Pointer to first argument matrix
 *         *ptm3 - Pointer to second argument matrix
 */
void msub( matrix *ptm1, matrix *ptm2, matrix *ptm3 )
{
	register int i,j;

#if RUNCHK

	if (!((ptm1->row == ptm2->row) && (ptm2->row == ptm3->row))) \
	merror("Dimension mismatch error in msub!");
	if (!((ptm1->col == ptm2->col) && (ptm2->col == ptm3->col))) \
	merror("Dimension mismatch error in msub!");

#endif

	/* Subtract the two matrices element by element */
	for ( i=0; i < ptm2->row; i++ )
	{
		for ( j=0; j < ptm2->col; j++ )
		{
			ptm1->mat[i][j] = ptm2->mat[i][j] - ptm3->mat[i][j];
		}
	}
}


/*
 * MMUL
 * ----
 *
 * Matrix multiplication
 *
 * Input:  *ptm1 - Pointer to result matrix (Not equal to *ptm1 or *ptm2) 
 *         *ptm2 - Pointer to first argument matrix
 *         *ptm3 - Pointer to second argument matrix
 *
 */
void mmul( matrix *ptm1, matrix *ptm2, matrix *ptm3 )
{
	register int i,j,k;

#if RUNCHK

	if ((ptm1==ptm2) || (ptm1==ptm3)) \
	merror("Memory conflict error in mmul!");

	if ( !( (ptm2->col == ptm3->row) && \
	(ptm2->row == ptm1->row) && (ptm3->col == ptm1->col) ) ) \
	merror("Dimension mismatch error in mmul!");

#endif

	for ( i=0; i < ptm2->row; i++ )
	{
		for ( j=0; j < ptm3->col; j++ )
		{
			ptm1->mat[i][j] = 0.0;
			for ( k=0; k < ptm2->col; k++ )
			{
				ptm1->mat[i][j] += ptm2->mat[i][k] * ptm3->mat[k][j];
			}
		}
	}
}


/*
 * SMUL
 * ----
 *
 * Multiply matrix with scalar
 *
 * Input:  *ptm1  - Pointer to result matrix
 *         *ptm2  - Pointer to argument matrix
 *         factor - Scalar factor to be multiplied with argument matrix  
 */
void smul( matrix *ptm1, matrix *ptm2, double factor)
{
	register int i,j;

#if RUNCHK

	if (!((ptm1->row==ptm2->row) && (ptm1->col==ptm2->col))) \
	merror("Dimension mismatch error in smul!");

#endif

	for( i=0; i < ptm2->row; i++ )
	{
		for( j=0; j < ptm2->col; j++ )
		{
			ptm1->mat[i][j] = factor*ptm2->mat[i][j];
		}
	}
}


/*
 * TRACE :
 * -------
 * Calculates the trace (the sum of the main diagonal elements) of a matrix.
 * Input  : ptm   - Pointer to the matrix.
 * Output : trace - Trace of the matrix.
 */
double trace( matrix* ptm )
{
	register double trace = 0.0;
	register int i;

#if RUNCHK

	/* Check whether matrix is square */
	if (ptm->row != ptm->col) \
	merror("Matrix not square error in trace!");

#endif

	/* Calculate sum of diagonal elements */
	for ( i=0; i < ptm->row; i++)
	{
		trace += ptm->mat[i][i];
	}

	/* Return with trace */
	return trace;
}


/* SPROD :
 * -------
 * This function calculates the scalar-product of two vectors of equal
 * length. The vectors may be either row- or column- vectors or any 
 * combination of those. (The usual mmul routine can be used to calculate
 * scalar-products, but it requires a row- and a column-vector.)
 * Inputs : ptv1 - Pointer to first factor vector.
 *          ptv2 - Pointer to second factor vector.
 * Output : prod - Scalar product of the two vectors.
 */
double sprod( matrix* ptv1, matrix* ptv2 )
{
	register double prod = 0.0;
	register int i, elements;

#if RUNCHK

	/* Check whether the arguments are vectors.   */
	if (!(((ptv1->row==1)||(ptv1->col==1))&&((ptv2->row==1)||(ptv2->col==1)))) \
	merror("One of the inputs is not a vector error in sprod!");

	/* Check whether vectors has the same length. */
	if ((ptv1->row + ptv1->col) != (ptv2->row + ptv2->col)) \
	merror("Dimension mismatch error in sprod!");

#endif
	/* Calculate scalar product of the vectors.   */

	elements = ptv1->row + ptv1->col - 1;

	for ( i=0; i<elements; i++ ) {
		prod += (vget(ptv1,i))*(vget(ptv2,i));
	}

	return prod;
}


/* SPROD2 :
 * --------
 * This function calculates the scalar-product of two vectors of equal
 * length. The vectors may be either row- or column- vectors or any 
 * combination of those. (The usual mmul routine can be used to calculate
 * scalar-products, but it requires a row- and a column-vector.) In this
 * function, a starting and ending index can be specified for each vector.
 * In which case, only the specified part of the vectors will be used for
 * calculating the scalar-product.
 *
 * Inputs : ptv1 - Pointer to first factor vector.
 *          ptv2 - Pointer to second factor vector.
 *          begX - Beginning index of vectors 1 and 2.
 *          endX - Ending index of vectors 1 and 2.
 * Output : prod - Scalar product of the two vectors.
 */
double sprod2( matrix* ptv1, matrix* ptv2, int beg1, int end1, int beg2, int end2 )
{
	register double prod = 0.0;
	register int i, elements;

#if RUNCHK

	/* Check whether the arguments are vectors.   */
	if (!(((ptv1->row==1)||(ptv1->col==1))&&((ptv2->row==1)||(ptv2->col==1)))) \
	merror("One of the inputs is not a vector error in sprod!");

	/* Check whether vectors has the same length. */
	if ((end1 - beg1) != (end2 - beg2)) \
	merror("Dimension mismatch error in sprod!");

#else
	end2 = end2;  /* Avoid a warning. */
	
#endif
	/* Calculate scalar product of the vectors.   */

	elements = end1 - beg1 + 1;

	for ( i=0; i<elements; i++ ) {
		prod += (vget(ptv1,i+beg1))*(vget(ptv2,i+beg2));
	}

	return prod;
}

	
/*
 * MPUT :
 * ------
 * This function assigns a specified value to a specified element in
 * a matrix.
 * Inputs : ptm     - Pointer to the matrix.
 *          value   - Value to assign in matrix.
 *          row_pos - The row in which the element is to be assigned.
 *          col_pos - The column in which the element is to be assigned.
 */
void mput( matrix *ptm, int row_pos, int col_pos, double value )
{

#if RUNCHK

	/* Check if indices are inside matrix bounds. */
	if ( !((row_pos >= 0) && (row_pos < ptm->row)) ) \
	merror("Index out of range error in mput!");
	if ( !((col_pos >= 0) && (col_pos < ptm->col)) ) \
	merror("Index out of range error in mput!");

#endif

	/* Assign the value to the element */
	ptm->mat[row_pos][col_pos] = value;
}

	
/*
 * VPUT :
 * ------
 * This function assigns a specified value to a specified element in
 * a vector.
 * Inputs : ptv   - Pointer to the vector.
 *          value - Value to assign in matrix.
 *          pos   - The position in which the element is to be assigned.
 */
void vput( matrix *ptv, int pos, double value )
{

#if RUNCHK

	/* Check if index is inside vector bounds. */
	if ( !((pos>=0) && (pos <= ptv->row + ptv->col - 2)) ) \
	merror("Index out of range error in vput!");

#endif

	/* Assign the value to the element */
	if (ptv->row == 1)
	{
		ptv->mat[0][pos] = value; /* Row vector */
	}
	else if (ptv->col == 1)
	{
		ptv->mat[pos][0] = value; /* Column vector */
	}
	else merror("Input is not a vector error in vput!");

}



/*
 * MGET :
 * ------
 * This function returns a pointer to a specified element in a matrix.
 * Inputs : ptm     - Pointer to the matrix.
 *          row_pos - row of element.
 *          col_pos - column of element.
 */
double mget( matrix *ptm, int row_pos, int col_pos )
{

#if RUNCHK

	/* Check whether indices is inside matrix bounds. */
	if ( !((row_pos >= 0) && (row_pos < ptm->row)) ) \
	merror("Index out of range error in mget!");
	if ( !((col_pos >= 0) && (col_pos < ptm->col)) ) \
	merror("Index out of range error in mget!");

#endif

	/* Get address of specified element */
	return (ptm->mat[row_pos][col_pos]);
}


/*
 * VGET :
 * ------
 * Gets an element of either a column- or row-vector.
 * Inputs : ptv - Pointer to the vector.
 *          pos - Position of element.
 * Output : pte - Pointer to the specified element.
 */
double vget( matrix* ptv, int pos )
{
	register double *pte;

#if RUNCHK

	/* Check if index is inside matrix bounds. */
	if ( pos > ptv->row + ptv->col - 2 ) \
	merror("Index out of range error in vget!");

#endif

	if ( ptv->row == 1 )
	{
		pte = &(ptv->mat[0][pos]);
	}
	else if ( ptv->col == 1 )
	{
		pte = &(ptv->mat[pos][0]);
	}
	else merror("Input is not a vector in vget!");

	return *pte;
}


/*
 * ADDCOLS :
 * ---------
 * Create a new matrix, by putting two matrices next to one another
 *
 *                            [    :    ]
 *                       M1 = [ M2 : M3 ]
 *                            [    :    ]
 *
 * OBS: The number of rows in M1, M2 and M3 must be the same, and the number 
 *      of columns in M1 must be equal to the sum of rows in M2 and M3.
 *
 * Inputs:   *ptm1       : Pointer to result matrix (can be equal to *ptm2)
 *           *ptm2       : Pointer to the matrix to be placed left
 *           *ptm3       : Pointer to the matrix to be placed right
 */
void addcols(matrix *ptm1, matrix *ptm2, matrix *ptm3)
{
	register int i, j;

#if RUNCHK

	/* Check whether M1, M2 and M3 have the same number of rows        */
	if ( !( (ptm2->row == ptm3->row) && (ptm2->row == ptm1->row) ) ) \
	merror("Dimension mismatch in addcols!");
	
	/* Check that there aren't too many columns in M1                  */
	if ( ptm1->col != (ptm2->col + ptm3->col) ) \
	merror("Number of columns out of range in addcols!");

#endif

	/* Copy M2 to the left side of M1 */
	for( j = 0; j < ptm2->col; j++ )
	{
		for( i = 0; i < ptm1->row; i++ ) 
		{
			ptm1->mat[i][j] = ptm2->mat[i][j];
		}
	}

	/* Copy M3 to the right side of M1 */
	for( j = 0; j < ptm3->col; j++)
	{
		for( i = 0; i < ptm1->row; i++ )
		{
			ptm1->mat[i][(j+ptm2->col)] = ptm3->mat[i][j];
		}
	}

}

/*
 * ADDROWS :
 * ---------
 * Create a new matrix, by putting two matrices on top of one another
 *
 *                            [ M2 ]
 *                       M1 = [----]
 *                            [ M3 ]
 *
 * OBS: The number of columns in M2 and M3 must be the same, and the size of 
 *      M1 must fit M2 and M3.
 *
 * Inputs:   *ptm1       : Pointer to result matrix 
 *           *ptm2       : Pointer to matrix to be placed in the top
 *           *ptm3       : Pointer to matrix to be placed in the bottom
 */
void addrows( matrix *ptm1, matrix *ptm2, matrix *ptm3 )
{
	register int i, j;

#if RUNCHK
       
	/* Check whether M1, M2 and M3 have the same number of columns     */
	if (!((ptm2->col == ptm3->col) && (ptm1->col == ptm2->col))) \
	merror("Dimension mismatch in addrows!");

	/* Check whether M1 has the right dimensions to fit M2 & M3        */
	if (ptm1->row != (ptm2->row + ptm3->row)) \
	merror("Dimension mismatch in addrows!");

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美日韩精品久久久久| 亚洲欧美区自拍先锋| av成人动漫在线观看| 美腿丝袜在线亚洲一区 | 色综合夜色一区| 久久er99精品| 亚洲www啪成人一区二区麻豆 | 亚洲高清三级视频| 中文字幕精品一区二区精品绿巨人| 欧美四级电影在线观看| 成人av网站在线观看免费| 精品一二线国产| 亚洲v精品v日韩v欧美v专区| 成人免费在线观看入口| 久久久久久久网| 日韩欧美一二三区| 制服丝袜亚洲精品中文字幕| 一本色道久久综合精品竹菊| 成人黄色片在线观看| 国产精品影视在线| 国内外成人在线| 麻豆91精品视频| 日韩精品电影在线| 亚洲成a人片综合在线| 亚洲色图另类专区| 亚洲欧洲精品天堂一级| 国产午夜亚洲精品理论片色戒| 日韩三级免费观看| 88在线观看91蜜桃国自产| 欧美三级中文字| 欧美视频在线不卡| 欧美日韩精品一区视频| 欧美特级限制片免费在线观看| 日本道色综合久久| 色婷婷av一区二区三区gif| 99这里都是精品| 99久久久久久| 91在线porny国产在线看| 不卡视频在线观看| 91亚洲国产成人精品一区二区三 | 懂色av一区二区夜夜嗨| 国产精品一二三区| 国产99久久久国产精品免费看| 国产原创一区二区| 国产91丝袜在线播放| 成人爽a毛片一区二区免费| www.欧美日韩国产在线| 91色视频在线| 欧美亚洲国产bt| 3d动漫精品啪啪| 欧美精品一区二区在线观看| 久久精品亚洲麻豆av一区二区| 中文字幕乱码日本亚洲一区二区| 国产精品久久久久影院| 亚洲精品视频在线观看网站| 亚洲18色成人| 老鸭窝一区二区久久精品| 国产精品影视天天线| 91视视频在线观看入口直接观看www| 色94色欧美sute亚洲13| 欧美日韩三级视频| 精品区一区二区| 国产精品久久久久毛片软件| 亚洲一区电影777| 蜜臀av性久久久久蜜臀aⅴ | 91在线视频网址| 欧美日韩一区精品| 欧美大片一区二区| 国产精品麻豆久久久| 婷婷六月综合亚洲| 国产.欧美.日韩| 欧美日韩一区二区在线观看 | 日韩一区二区免费在线观看| 久久精品欧美日韩精品| 亚洲欧洲在线观看av| 首页国产欧美日韩丝袜| 国产成人亚洲综合a∨婷婷| 在线一区二区三区四区五区 | 91久久精品一区二区三区| 欧美精品一二三| 国产精品麻豆久久久| 午夜精品久久一牛影视| 国产成人精品免费网站| 欧美日韩亚洲综合一区二区三区| 欧美xxxxxxxxx| 亚洲老妇xxxxxx| 国产一区二区三区久久久| 在线观看网站黄不卡| 久久综合精品国产一区二区三区| 亚洲精品成人悠悠色影视| 精品一区二区三区视频在线观看| 99国产一区二区三精品乱码| 欧美成人免费网站| 国产综合色精品一区二区三区| 91性感美女视频| 久久久美女毛片| 日韩中文字幕不卡| 色综合亚洲欧洲| 亚洲国产成人在线| 激情综合网最新| 精品视频资源站| 日韩毛片精品高清免费| 国产麻豆视频一区| 337p亚洲精品色噜噜噜| 一区二区三区四区精品在线视频| 高清不卡在线观看av| 日韩一级完整毛片| 性做久久久久久久久| 色婷婷av久久久久久久| 中文字幕中文乱码欧美一区二区| 久久99九九99精品| 欧美一区二区三区系列电影| 玉足女爽爽91| 91亚洲精品乱码久久久久久蜜桃| 日本一区二区在线不卡| 久久av老司机精品网站导航| 欧美精品日韩综合在线| 悠悠色在线精品| 日本韩国欧美一区| 亚洲另类在线视频| 91亚洲国产成人精品一区二三| 欧美激情在线看| 丁香六月久久综合狠狠色| 久久影院视频免费| 国产主播一区二区| 26uuuu精品一区二区| 韩国一区二区视频| 精品卡一卡二卡三卡四在线| 日本欧美加勒比视频| 9191国产精品| 日本一不卡视频| 日韩一区二区三区电影在线观看 | 亚洲欧美在线视频| 99这里都是精品| 亚洲欧洲中文日韩久久av乱码| 成人精品免费网站| 亚洲欧洲日韩av| 色就色 综合激情| 亚洲国产精品麻豆| 91精品久久久久久久久99蜜臂| 日精品一区二区三区| 日韩免费看的电影| 国产一区二区在线视频| 欧美激情中文不卡| 99精品国产一区二区三区不卡| 亚洲精品自拍动漫在线| 欧美三级资源在线| 蜜臀av一区二区三区| 久久久精品免费免费| 成人午夜视频网站| 一区二区三区不卡视频 | 中日韩免费视频中文字幕| 成人动漫在线一区| 一区二区激情视频| 337p亚洲精品色噜噜| 韩国理伦片一区二区三区在线播放| 久久久久9999亚洲精品| 99免费精品视频| 性欧美大战久久久久久久久| 精品理论电影在线| 99久久精品国产网站| 午夜精品福利一区二区三区av| 国产午夜亚洲精品理论片色戒| 国产精品456露脸| 久久综合久久久久88| 97精品视频在线观看自产线路二| 亚洲一卡二卡三卡四卡五卡| 3d成人h动漫网站入口| 狠狠色综合播放一区二区| 欧美成人精品二区三区99精品| 成人免费看视频| 亚洲电影一级黄| 精品国产一区二区三区久久影院| 成人免费高清视频在线观看| 亚洲国产精品精华液网站| 7777精品伊人久久久大香线蕉最新版| 美女任你摸久久| 麻豆精品一二三| 国产欧美综合色| 日本韩国一区二区三区| 久久aⅴ国产欧美74aaa| 亚洲丝袜美腿综合| 欧美一区二区啪啪| 成人国产精品免费观看视频| 五月婷婷激情综合网| 亚洲国产精品成人久久综合一区| 欧美日韩和欧美的一区二区| 国产91清纯白嫩初高中在线观看 | 精品国产免费一区二区三区香蕉| 97精品国产露脸对白| 日韩精品一级二级| 亚洲人妖av一区二区| 精品成a人在线观看| 在线观看日韩电影| 国产不卡免费视频| 蜜臀av一级做a爰片久久| 一区二区三区四区高清精品免费观看 | 青青草精品视频| 亚洲永久精品大片| 国产精品你懂的|