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

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

?? matrix.c

?? 基于神經網絡的辨識工具箱 (527KB)
?? C
?? 第 1 頁 / 共 3 頁
字號:
/**********************************************************************
 *                                                                    *
 * This C language library provides some simple matrix operations and *
 * the functions MLOAD and MSAVE enables the use of MAT files         *
 * generated by MATLAB.                                               *
 *                                                                    *
 * Coded by     : Steffen Torp & Magnus Norgaard                      *
 *                                                                    *
 * References   : Brugervejledning til C/Matlab matrix bibliotek,     *
 *                Appendix F i Noergaard og Torp (1993).              *
 *                                                                    *
 * Dependencies : matrix.h                                            *
 *                                                                    *
 * Comments     : All matrices are represented by a structure with    *
 *                the dimensions of the matrix and a pointer to       *
 *                an array of pointers to each row in the matrix.     *
 *                The functions using stdio can be excluded by        *
 *                defining the symbol NO_IO to the compiler.          *
 *                If the library is compiled on the OS/9 system       *
 *                the symbol OS9 must be defined.                     *
 *                                                                    *
 * Last edit    : sept. 22, 1994 Magnus Norgaard                      *
 *                                                                    *
 **********************************************************************/

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

#include "matrix2.h"     

#define TRUE 1
#define FALSE 0

#ifndef NO_IO  /* I/O functions are not available in the DSP C compiler */
#include <stdio.h>
int  loadmat(FILE*, int*, char*, int*, int*, int*, double**, double**);
void savemat(FILE*,  int, char*,  int,  int,  int,  double*,  double*);
long longconv(long);           /* Internal functions, only used by  */
void matconv(int, double*);    /* The functions in this library.    */
typedef struct {               /* Matrix structure for MATLAB files */
	long type;
	long mrows;
	long ncols;
	long imagf;
	long namlen;
} Fmatrix;
#endif


#define READ "rb"
#define APND "ab"
#define SYSTEM 0               /* 0 = PC, 1000 = Apollo and OS/9 */
#ifdef OS9
  #undef READ
  #undef APND
  #undef SYSTEM
  #define SYSTEM 1000
  #define READ "r"
  #define APND "a"
#endif


/*
 * MMAKE :
 * -------
 * This function allocates memory for a matrix of the specified size
 * and assigns the specified dimensions to the allocated matrix.
 * Inputs  : rows - number of rows.
 *           cols - number of columns.
 * Outputs : *ptm - pointer to the new matrix structure.
 */
matrix *mmake( int rows, int cols )
{
	matrix *ptm;
	double **row_pointers;
	register int i;

#if RUNCHK

	/* Check that no dimension is zero. */
	if ((rows==0)||(cols==0)) merror("Invalid dimension error in mmake!");
#endif

	/* Memory allocation for matrix structure. */
	ptm = (matrix*)malloc(sizeof(matrix));

	/* Memory for array of pointers to rows. */;
	row_pointers = (double**)malloc(rows*sizeof(double*));

	/* Memory for all rows, initialize row pointers. */
	row_pointers[0] = (double*)malloc(rows*cols*sizeof(double));
	for (i=1;i<rows;i++) {
		row_pointers[i] = row_pointers[i-1] + cols;
	}

#if RUNCHK

	/* Check if last allocation was ok ! */
	if (!row_pointers[0]) {
		merror("Memory allocation error in mmmake!");
	}
#endif

	ptm->row = rows;             /* Initialize matrix structure */
	ptm->col = cols;
	ptm->mat = row_pointers;     /* Pointer to row pointers     */

	return ptm;           /* Return pointer to matrix structure */
}


/*
 * MFREE :
 * -------
 * This function deallocates the memory that was used for a matrix.
 * Input : Pointer to the matrix to be deallocated.
 */
void mfree( matrix *ptm )
{
	/* Deallocate rows */
	free(ptm->mat[0]);

	/* Deallocate row pointer array */
	free(ptm->mat);

	/* Deallocate matrix structure */
	free(ptm);
}



/*
 * MSAVE :
 * -------
 * This function is used to save a matrix in a MAT-file, that can be read
 * by MATLAB. The function uses the SAVEMAT.C function provided by MATLAB.
 * The function only handles numrical matrices.
 * Inputs : ptm       - pointer to the matrix that will be saved.
 *          file_name - string with name of file to save in.
 *          mat_name  - string with name of matrix in MATLAB.
 */
void msave( matrix *ptm, char file_name[], char mat_name[] )
{
#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	FILE *fp;
	double *preal,*pimag;
	double *data;
	int type,imagf,mn,i,j,k;

	mn = ptm->row*ptm->col;                       /* Number of data.  */
	data = (double*)malloc(mn*sizeof(double));    /* Allocate buffer. */
	k = 0;

	/* Prepare for SAVEMAT call using MATLAB format. */

	for ( j=0; j < ptm->col; j++ )
	{
		for ( i=0; i < ptm->row; i++ )
		{
			*(data+k) = get_val(ptm,i,j); /* Write to buffer. */
			k++;
		}
	}
	imagf = 0;                  /* No complex data.                   */
	type  = SYSTEM;             /* Only numeric data.                 */
	preal = data;               /* Real data is in buffer "data".     */
	pimag = (double *)0;        /* No complex data.                   */
	fp = fopen(file_name,APND); /* Append to existing file or create. */
				    /* new one, using binary file-format. */ 
	if (!(fp)) merror("Can't open file error in msave!");
	savemat(fp,type,mat_name,ptm->row,ptm->col,imagf,preal,pimag);
				    /* Save the matrix in MAT-file.       */
	fclose(fp);                 /* Close MAT-file.                    */
	free(data);                 /* Deallocate buffer memory.          */
#else
	ptm=ptm;
	file_name=file_name;
	mat_name=mat_name;
	exit(0); /* printf is not available in DSP compiler. */
#endif
}


/*
 * MLOAD :
 * -------
 * This function is used to load a matrix from a MAT-file, that was written
 * by MATLAB. The function uses the LOADMAT.C function provided by MATLAB,
 * but it only handles numerical and real matrices.
 * Inputs : file_name - string with the name of the MAT-file to read.
 *          mat_name  - string with the name of the matrix to load.
 * Output : ptm       - Pointer to the loaded matrix.
 */
matrix *mload( char file_name[], char mat_name[] )
{
#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	FILE *fp;
	matrix *ptm;
	char name[20];
	int found,i,j,k;
	int type,mrows,ncols,imagf;
	double *xr,*xi;

	fp = fopen(file_name,READ);        /* Open MAT-file for reading   */
					   /* from the beginning of file. */
	if (!(fp)) merror("File not found error in mload!");

	do  /* Search for the matrix with name in mat_name */
	{
		/* Read the file until matrix is found or EOF is reached. */
		if (loadmat(fp,&type,name,&mrows,&ncols,&imagf,&xr,&xi)) {
			printf("The searched matrix is : %s \n",mat_name);
			merror("matrix not in file error in mload!");
		}

		found = strncmp(mat_name,name,20);
	}
	while ( found!=0 );      /* Keep searching until matrix is found. */

	if (imagf) {
		printf("%s\n","Warning from mload :");
		printf("%s\n","The matrix was complex, but the");
		printf("%s\n","imaginary part has been ignored !");
	}

	if ((mrows==0)||(ncols==0)) merror("Matrix was empty error in mload!");

	ptm = mmake( mrows, ncols ); /* Allocate memory for loaded matrix */

	/* Copy data from buffer to matrix using C matrix structure. */
	k = 0;
	for ( j=0; j<ncols; j++ )
	{
		for ( i=0; i<mrows; i++ )
		{                               
			put_val(ptm,i,j,*(xr+k));
			k++;
		}
	}

	free(xr);   /* Deallocate data buffers and pointers.*/
	if (imagf) free(xi);
	fclose(fp); /* Close MAT-file.                      */
	return ptm; /* Return pointer to the loaded matrix. */
#else
	file_name=file_name;
	mat_name=mat_name;
	exit(0); /* printf is not available in DSP compiler. */
#endif
}


/*
 * SLOAD :
 * -------
 * This function loads a scalar (one by one matrix) from a MAT-file.
 * Inputs : file_name - Name of MAT-file to search for scalar.
 *          scal_name - Name of Matlab variable in MAT-file.
 * Output : scalar    - The scalar, which was loaded.
 */
double sload( char file_name[], char scal_name[] )
{
#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	matrix *ptm;
	double scalar;

	ptm    = mload( file_name, scal_name );
	scalar = ptm->mat[0][0];
	mfree(ptm);

	return scalar;
#else
	file_name=file_name;
	scal_name=scal_name;
	exit(0); /* printf is not available in DSP compiler. */
#endif
}


/*
 * MERROR :
 * --------
 * This function displays the specified error message and exits to server
 * operating system.
 * Input : Text string with the error message.
 */
void merror( char error_text[] )
{

#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	printf("--- Runtime error in matrix library:\n");
	printf("--- ");
	printf("%s\n\n",error_text);
#else
	error_text=error_text; /* Dummy command to avoid warnings on DSP */ 
#endif
	/*exit(1);*/
	mexErrMsgTxt("AN ERROR OCCURED IN A CMEX-PROGRAM");
}


/*
 * MPRINT :
 * --------
 * This is a simple function to print a matrix on the screen.
 * Input : ptm - Pointer to the matrix that will be printed.
 */
void mprint( matrix *ptm )
{
#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	int i,j;
	for ( i=0; i < ptm->row; i++ )
	{
		for( j=0; j < ptm->col; j++ )
		{
			printf("%4f %s",ptm->mat[i][j]," ");
		}
		printf("\n");
	}
#else
	ptm=ptm;
	exit(0); /* printf is not available in DSP compiler. */
#endif
}


/*
 * MINPUT1 :
 * ---------
 * This function reads the dimensions and content of a matrix from 
 * the keyboard.
 * Output : Pointer to new matrix.
 */
matrix *minput1()
{
#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	matrix *ptm;
	int i,j,mrows,ncols;

	printf("%s","Number of rows    :");
	scanf("%d",&mrows);
	printf("%s","Number of columns :");
	scanf("%d",&ncols);

	ptm = mmake(mrows,ncols);

	for ( i=0; i<mrows; i++ )
	{
		for ( j=0; j<ncols; j++ )
		{
			printf("%s %d %s %d %s","Enter element (",i,",",j,")  :");
			scanf("%lf",&(ptm->mat[i][j]));
			/* PS. scanf does not work with floating formats in Turbo C. */
		}
	}
	return ptm;
#else
	exit(0); /* scanf is not available in DSP compiler. */
#endif
}


/*
 * MINPUT2 :
 * ---------
 * This function prompts for the content of a matrix of known size.
 * Input : Pointer to matrix to be read from keyboard.
 */
void minput2( matrix *ptm )
{
#ifndef NO_IO     /* For compilation by the DSP ANSI-C compiler. */

	int i,j;

	printf("%s %d %s %d %s\n","This matrix has",ptm->row,"rows and",
			ptm->col,"columns.");
	printf("%s %d %s\n","Please enter the following",
			ptm->row*ptm->col,"elements.");

	for ( i=0; i < ptm->row; i++ )
	{
		for ( j=0; j < ptm->col; j++ )
		{
			printf("%s %d %s %d %s","Enter element (",i,",",j,")  :");
			scanf("%lf",&(*ptm).mat[i][j]);
			/* PS. scanf does not work with floating formats in Turbo C. */
		}
	}
#else
	ptm=ptm;
	exit(0); /* scanf is not available in DSP compiler. */
#endif
}


/*
 * MTRANS :
 * --------
 * This function computes the transposed of a matrix.
 * Inputs : ptm2 - Pointer to argument matrix.
 *          ptm1 - Pointer to result matrix.
 * Notice : The two matrices may NOT be the same.
 */
void mtrans( matrix *ptm1, matrix *ptm2 )
{
	register int i,j;

#if RUNCHK

	if (ptm1==ptm2) merror("Memory conflict error in mtrans!");
#endif

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


/*
 * MINIT :
 * -------
 * This function initializes a matrix to all zeros.
 * Inputs : ptm - Pointer to the matrix that will be initialized.
 */
void minit( matrix *ptm )
{
	register unsigned char zero_byte = 0;
	register int bytes;
	
	/* Number of bytes in matrix data area. */
	bytes = 8*(ptm->row)*(ptm->col);

	/* Set data area to all zeroes. */
	memset( ptm->mat[0], zero_byte, bytes );
}



/*
 * MINITX :
 * --------
 * This function initializes a matrix to all x's. x being a scalar.
 * Inputs : ptm - Pointer to the matrix that will be initialized.
 *          x   - Element to be put into the matrix  
 */
void minitx( matrix *ptm, double x )
{
	register int i,j;
        for(i=0; i < ptm->row; i++)
	{
	  for(j=0; j < ptm->col; j++)
          {	
	    ptm->mat[i][j]=x;
	  }
	}
}


/*
 * MRAND :
 * -------
 * This function initializes a matrix with random numbers between -1 and 1.
 * Inputs : ptm - Pointer to the matrix that will be initialized.
 */
void mrand( matrix *ptm )
{
	register int i,j;
        for(i=0; i < ptm->row; i++){
	  for(j=0; j < ptm->col; j++)
	              ptm->mat[i][j]=rand()*2.0/RAND_MAX - 1.0;
	}
}



/*
 * MFIND :
 * -------
 * This function finds a given element in a matrix and returns
 * the row and coloumn coordinates to the locations. If no
 * instances of the element is found, a zero by zero matrix is
 * returned.
 * 
 * Inputs : ptm    - Pointer to matrix.
 *          elem   - Element to be searched for (double)
 * Output : retmat - 2 coloumn matrix. 1st coloumn contains row indices,
 *                   2nd coloumn contains the colomn indices.
 */
matrix *mfind( matrix *ptm, double elem )
{
        register int i,j,k;
	matrix *tmp, *retmat;
	k=0;
	tmp = mmake((ptm->row)*(ptm->col),2);

	/* Seach entire matrix */
	for(i=0; i < ptm->row; i++)
	  {
	    for(j=0; j < ptm->col; j++)
	      {
		if(ptm->mat[i][j] == elem)
		  {
		    tmp->mat[k][0]=i;
		    tmp->mat[k][1]=j;
                    k++;
		  }
	      }
	  }
	if(k==0)   /* The element is'nt recognized */
	{
	  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;
}



/*
 * MNOFIND :
 * ---------
 * This function finds all entries in a matrix not equal to a given element
 * and returns the row and coloumn coordinates to the locations. If all entries
 * equals the element, a zero by zero matrix is returned.
 * 
 * Inputs : ptm    - Pointer to matrix.
 *          elem   - Element to be searched for (double)
 * Output : retmat - 2 coloumn matrix. 1st coloumn contains row indices,
 *                   2nd coloumn contains the colomn indices.
 */
matrix *mnofind( matrix *ptm, double elem )
{
        register int i,j,k;
	matrix *tmp, *retmat;
	k=0;
	tmp = mmake((ptm->row)*(ptm->col),2);

	/* Seach entire matrix */
	for(i=0; i < ptm->row; i++)
	  {
	    for(j=0; j < ptm->col; j++)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品视频第一区| 欧美日本一区二区| 国产视频一区二区在线| 精品一区二区三区香蕉蜜桃 | 欧美一级视频精品观看| 亚洲成a人v欧美综合天堂| 欧美日本视频在线| 蜜桃视频一区二区三区| 精品对白一区国产伦| 国产成人av福利| 亚洲日本va午夜在线电影| 欧美在线综合视频| 久久69国产一区二区蜜臀| 中文字幕不卡在线| 色天天综合久久久久综合片| 午夜电影网一区| 精品国产亚洲在线| 91美女片黄在线观看91美女| 亚洲高清在线视频| 日韩视频一区二区| 粉嫩aⅴ一区二区三区四区 | 7777精品久久久大香线蕉| 激情综合色播激情啊| 国产精品久久久久久久久晋中| 色综合天天天天做夜夜夜夜做| 日韩精品一级中文字幕精品视频免费观看| 91精品国产欧美一区二区| 国产精品一二三区在线| 亚洲精品国产视频| 精品人伦一区二区色婷婷| 99久久99久久免费精品蜜臀| 日本特黄久久久高潮| 国产精品水嫩水嫩| 777午夜精品视频在线播放| 大陆成人av片| 日本不卡在线视频| 亚洲人成网站精品片在线观看| 日韩一级片在线观看| 91最新地址在线播放| 精品一区二区三区视频| 亚洲观看高清完整版在线观看 | 日韩一区二区三| 91原创在线视频| 国产一区美女在线| 亚洲成av人片一区二区| 国产精品免费久久| 精品伦理精品一区| 欧美麻豆精品久久久久久| 成人黄色在线看| 精品一区精品二区高清| 亚洲高清免费在线| 成人免费小视频| 中文字幕 久热精品 视频在线 | 91高清视频在线| 暴力调教一区二区三区| 国产一区二区三区日韩| 男女性色大片免费观看一区二区 | 天天操天天综合网| 一区二区三区在线播放| 欧美国产国产综合| 久久久久国产免费免费 | 国产麻豆91精品| 日韩av一级片| 亚洲不卡av一区二区三区| 综合久久国产九一剧情麻豆| 欧美极品美女视频| 久久奇米777| 欧美精品一区二区久久久| 欧美电影在哪看比较好| 欧美偷拍一区二区| 日本韩国视频一区二区| 99国产精品久| 成人精品免费网站| jizzjizzjizz欧美| 99久久精品国产麻豆演员表| 成人在线视频一区二区| 成人福利视频网站| 成人激情午夜影院| av亚洲精华国产精华| 91亚洲精品乱码久久久久久蜜桃| 成年人国产精品| 97se亚洲国产综合自在线观| 91丨九色丨国产丨porny| 91视视频在线直接观看在线看网页在线看| 成人免费看视频| 成人av电影免费在线播放| 99精品在线观看视频| 一本大道av伊人久久综合| 色婷婷久久一区二区三区麻豆| 一本色道久久综合亚洲精品按摩| 色94色欧美sute亚洲线路一ni | 97久久超碰精品国产| 一本一本久久a久久精品综合麻豆| 色拍拍在线精品视频8848| 欧美性大战xxxxx久久久| 欧美日韩成人一区二区| 欧美一区二区在线免费观看| 日韩免费视频线观看| 久久久www成人免费无遮挡大片| 欧美国产一区在线| 亚洲精品中文在线| 蜜桃av噜噜一区二区三区小说| 国产原创一区二区三区| aa级大片欧美| 欧美男男青年gay1069videost| 日韩欧美一区二区久久婷婷| 中文字幕免费不卡在线| 一区二区三区免费网站| 男女男精品网站| 99久久精品免费精品国产| 欧美高清视频不卡网| 久久久久久一二三区| 亚洲另类在线制服丝袜| 蜜桃视频在线观看一区二区| av在线免费不卡| 欧美一卡2卡三卡4卡5免费| 久久精品一区二区三区不卡| 一区二区成人在线| 国产在线精品一区二区三区不卡| 99国产精品久久久| 精品少妇一区二区三区| 一区二区三区精品久久久| 九九精品一区二区| 91行情网站电视在线观看高清版| 欧美tk丨vk视频| 亚洲一区二区视频在线观看| 激情图片小说一区| 欧美日韩免费电影| 国产精品毛片大码女人| 蜜桃精品视频在线观看| 在线这里只有精品| 中文字幕欧美国产| 黄网站免费久久| 欧美日韩一本到| 亚洲三级小视频| 国产精品1区2区3区在线观看| 欧美理论电影在线| 中文字幕亚洲区| 国产毛片一区二区| 日韩一区二区精品在线观看| 亚洲精品视频免费观看| 国产不卡一区视频| 精品欧美久久久| 午夜精品成人在线| 91猫先生在线| 中文字幕一区二区三区在线播放 | 亚洲成人久久影院| 97久久超碰国产精品| 国产欧美日韩精品一区| 久久国内精品自在自线400部| 91国偷自产一区二区开放时间 | 福利一区二区在线观看| 日韩亚洲欧美综合| 婷婷开心激情综合| 欧美色综合影院| 艳妇臀荡乳欲伦亚洲一区| 99re视频精品| 自拍偷拍欧美精品| 成av人片一区二区| 国产精品国产三级国产普通话蜜臀 | 亚洲欧洲av在线| 成人永久看片免费视频天堂| 久久久精品人体av艺术| 精品亚洲porn| 精品乱码亚洲一区二区不卡| 蜜桃视频一区二区| 日韩精品一区在线| 精品在线一区二区三区| 欧美本精品男人aⅴ天堂| 日本欧美韩国一区三区| 欧美成人精品1314www| 麻豆国产精品一区二区三区 | 久久精品亚洲精品国产欧美kt∨| 国内精品免费在线观看| 国产日韩精品一区二区三区在线| 国产美女精品一区二区三区| 欧美国产成人精品| 91免费观看国产| 亚洲观看高清完整版在线观看| 欧美日韩你懂的| 麻豆精品在线播放| 久久久久久久综合日本| 白白色 亚洲乱淫| 亚洲一区二区3| 欧美一区二区精品久久911| 精品在线你懂的| 国产精品狼人久久影院观看方式| 99久久99久久精品免费观看| 午夜久久久影院| 精品国产精品一区二区夜夜嗨 | 91亚洲精品乱码久久久久久蜜桃| 一区二区三区国产豹纹内裤在线| 欧美日韩国产bt| 国产一区二区伦理| 国产精品久久久久久久久动漫 | 中文字幕日韩欧美一区二区三区| 在线观看亚洲一区| 老司机免费视频一区二区三区| 国产欧美综合色| 欧美日韩三级视频|