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

📄 system.h

📁 这个程序主要是基于空时编码的编解码实现过程。
💻 H
字号:
//**************************************************************//
//                                                              //
//                     August 2002                              //
//                         by                                   //
//                Leung, Raymond Wai-Kong                       // 
//                                                              //
//**************************************************************//


//Interleaver
void	Scramble( int *rule, int length, int scrnum );
void	CyclicShift( int *x, int length, int shift );

//float	LClip0( float x );
double	LClip1( double x );
//float	LClip2( float x );
//float	LClip3( float x );
//float	RClip1( double x );
//float	RClip2( double x );
//float	RClip3( double x );

//float	RClipT( double x );


union NumericType
{
	int		i;
	float	f;
};


class Complex
{
public:
	float Re;
	float Im;

	Complex& operator = ( const Complex& adder );
	Complex& operator += ( const Complex& adder );
    Complex& operator -= ( const Complex& subber );
	Complex& operator *= ( const Complex& multiplier );
	friend Complex operator + ( const Complex& a, const Complex& b );
	friend Complex operator - ( const Complex& a, const Complex& b );
	friend Complex operator * ( const Complex& a, const Complex& b );
};

inline Complex& Complex::operator = ( const Complex& equal )
{
    Re = equal.Re;
    Im = equal.Im;
    return *this;
}

inline Complex& Complex::operator += ( const Complex& adder )
{
    Re += adder.Re;
    Im += adder.Im;
    return *this;
}

inline Complex& Complex::operator -= ( const Complex& subber )
{
    Re -= subber.Re;
    Im -= subber.Im;
    return *this;
}

inline Complex& Complex::operator *= ( const Complex& multiplier )
{
	float re = Re, im = Im;

	Re = re * multiplier.Re - im * multiplier.Im;
	Im = re * multiplier.Im + im * multiplier.Re;
    return *this;
}


//Input/Output function
class IO
{
	private:
		char FileN[256];
		char FileT[256];
		int ptrN, ptrT;

	public:
		void FnInit( );
		void FnJoin( int num );
		void FnJoin( float num );
		void FnJoin( char *prefix );
		void FnEnd( );
		void FileHeader( );
		void ScreenOut( double snr, int blockNum, int *bitError, int *frameError );
		void FileOut( float snr, int blockNum, int *bitError, int *frameError );
		void ImportantEorrorMessage( char *message );
		void ErrorMessage( char *message );
		
		void SimStateWrite( float snr, int simpt, int blockNum, int w, int x, int y, int z, int *bitError, int *frameError );
		void SimStateRead( float *snr, int *simpt, int *blockNum, int *w, int *x, int *y, int *z, int *bitError, int *frameError );
};

//Random number generator
class Random
{
private:
//Modular Arithmetic Generator
	int StateS;
	static const int A;
	static const int M;
	static const int Q;
	static const int R;
//Wichmann/Hill Generator
	int	StateX;
	int	StateY;
	int StateZ;
	static const int A1;
	static const int A2;
	static const int A3;
	static const int M1;
	static const int M2;
	static const int M3;
//Box-Muller Method
	static const double pi2;


public:
//Modular Arithmetic Generator
	void	SetState( int s );
	void	ReadState( int *s );
	void	IntNextSate( int *s );
	int		RandomInt( );
//Wichmann/Hill Generator
	void	SetState( int x, int y, int z );
	void	ReadState( int *x, int *y, int *z );
	void	DoubleNextState( int *x, int *y, int *z );
	double	RandomDouble( );
//Both Wichmann/Hill and Modular Arithmetic Generator
	void	SetState( int s, int x, int y, int z );
	void	ReadState( int *s, int *x, int *y, int *z );
//Box-Muller Method
	float	RealNoise( double sigma );
	Complex	ComplexNoise( double sigma );
	Complex	RayleighGenerator( float p );
};


⌨️ 快捷键说明

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