⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gaussmar.c

📁 This program reads iid zero-mean unit-variance Gaussian variates
💻 C
字号:
#include <math.h>
#include <stdio.h>
#define PMODE 0644
float x[1048576] ;
/* This program reads iid zero-mean unit-variance Gaussian variates,
   and converts them into first-order Gauss-Markov with correlation 
   coefficient of rho, and variance of 1. To run the program use:
   markov <input file name> <N> <rho> <output file name>
   Nader Moayeri  ;   2/13/85                                        */
main(argc,argv)
int argc ;
char *argv[] ;
{  int i, n, fd ; 
   double a, rho ;
   n = atoi(argv[2]) ;
   rho = atof(argv[3]) ;
   a = sqrt(1.-rho*rho) ;
   if ( ( fd = open(argv[1],0) )  ==  -1 )
      {  printf("Error in opening the input file.\n") ;
	 exit(1) ;
      }
   if ( ( i = read(fd,x,4*n) )  !=  (4*n) )
      {  printf("Error in reading the training sequence.\n") ;
	 exit(1) ;
      }
   if (( fd = creat(argv[4],PMODE )) == -1)
      {  printf("Error in creating the output file.\n") ;
         exit(1) ;
      }
   for ( i = 1; i < n; ++i )
      x[i] = rho*x[i-1] + a*x[i] ;
   if (( i = write(fd,x,4*n) ) != (4*n) )
      {  printf("Error in writing onto the output file.\n") ;
         exit(1) ;
      }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -