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

📄 system.h

📁 Turbo码性能仿真源程序信道编码方面的
💻 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	LClip1( float 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 );

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];
		int ptr;

	public:
		void FnInit( );
		void FnJoin( int num );
		void FnJoin( float num );
		void FnJoin( char *prefix );
		void FileHeader( );
		void ScreenOut( double Snr, int BlockNum, int *BitError, int *FrameError );
		void FileOut( float Snr, int BlockNum, int *BitError, int *FrameError );
		void ErrorMessage( char *message );
};

//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 );
	//struct	Complex	ComplexNoise( double sigma );
	Complex	ComplexNoise( double sigma );
	Complex	RayleighGenerator( );
};


⌨️ 快捷键说明

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