No Slide Title

Download Report

Transcript No Slide Title

Department of Signal and Systems
IT++
A software package for NEWCOM
Thomas Eriksson September 2004
Department of Signal and Systems
What is IT++?
IT++ is a C++ library of mathematical, signal processing, speech processing, and
communications classes and functions. It has been developed by researchers in these
areas. The kernel of the package are templated vector and matrix classes and lots of
functions for vectors and matrices. As such the kernel is similar to the Matlab
functions. IT++ is based on LAPACK and CBLAS.
The IT++ library originates from the former department of Information Theory at
Chalmers University of Technology, Gothenburg, Sweden. Since the library is coded
in C++ the name of the library seemed like a good idea at the time. While
departments come and go, IT++ have developed a life of its' own and is now released
under the GNU GPL license for you to enjoy.
IT++ works on GNU/Linux, Sun Solaris, Cygwin, Windows 2000/NT/XP (with
Microsoft Visual C++, and Mac OS X.
Thomas Eriksson September 2004
Department of Signal and Systems
What is IT++ not?
IT++ does not contain full programs or simulators, but it does contain the building
blocks for most applications.
Thomas Eriksson September 2004
Department of Signal and Systems
The parts of IT++
itbase contains the basic stuff of it++, including vector and matrix manipulation,
mathematical functions and signal processing functions. We have random number
generation, FFT and other transforms, filtering, matrix algebra, a command-line
parser, equation solving and much more.
itcomm contains communication-related functions and classes. It is more spezialized
than itbase, containing building blocks for communication systems. For example, it
contain modulators and demodulators, channel encoders and decoders, spreading and
de-spreading functions, channel classes, interleavers, e.t.c.
itsrccode is the source coding part of it++, specialized on data compression and
speech signal processing. We have vector quantization, linear prediction, Gaussian
mixture modelling, etc.
Thomas Eriksson September 2004
Department of Signal and Systems
Modules of IT++
Here is a list of IT++ modules:
•Writing Matlab Mex-files using IT++
•Bessel Functions
•Matrix Decompositions
•Conversion Functions
•Determinant
•Logarithmic and Exponential Functions
•Error Functions
•Trigonometric Functions
•Hyperbolic Functions
•Miscellaneous Functions
•Filter Classes and Functions
•Inverse Matrix
•Error handling functions
•IT++ File Format
•Solving Linear Equation Systems
•Random Number Generation
•Signal Processing Functions
•Deterministic Sources
•Special Matricies
•Windows
•Timers
•Forward Error Correcting Codes
•Communication Channels
•Interleavers
•Digital Modulation
•Audio
•LPC-related Functions
Thomas Eriksson September 2004
Department of Signal and Systems
The basic types
Scalar types:
complex<double>
bin
Vector types:
Vec<type>
vec
cvec
ivec
bvec
svec
Matrix types:
Mat<type>
mat
cmat
imat
bmat
smat
real and imag part of type double
Used for binary (0,1) data
The templated vector class
A vector of double
A vector of complex<double>
An integer vector (int)
A binary vector
An integer vector (short)
The templated vector class
A matrix of double
A matrix of complex<double>
An integer matrix (int)
A binary matrix (bin)
An integer matrix (short)
Thomas Eriksson September 2004
Department of Signal and Systems
Vector manipulation
vec myvector;
vec myvector(10);
myvector.set_length(15);
vec a = "0 0.7 5 9.3";
ivec b = "0:5";
vec c = "3:2.5:13";
a(3)=3.14;
a[0]=1.2;
a=c.left(2);
a=c.right(2);
a=c.mid(2,2);
a=c(2,4);
c=concat(a,myvector);
c=to_vec(b);
// defines an empty vector
// A vector of length 10
// the vector gets length 15
// a = [0 0.7 5 9.3]
// b = [0 1 2 3 4 5]
// c = [3 5.5 8 10.5 13]
// Assignment to vector elements (MATLAB style)
// c-style assignment works also. First element has index 0.
//
//
// From index 2 of c, to index 4.
// Same as above
// Concatenation of two vectors
// Converts the integer vector to a Vec<double>
Thomas Eriksson September 2004
Department of Signal and Systems
Mathematics
Bessel Functions
vec a,b;
Matrix Decompositions
a=randn(54);
// Gaussian random numbers Conversion Functions
b=round(a);
//
Determinant
mat m=”1 2 3; 4 5 6; 7 8 9”;
Logarithmic and Exponential Functions
m=inv(m);
// the inverse
Error Functions
cout << a << b << m << endl ;
Trigonometric Functions
a=eig(m);
// eigenvalue decomposition Hyperbolic Functions
double d;
Miscellaneous Functions
d=erf(0.2);
// the error function
Inverse Matrix
a=3*a+sin(b);
// arithmetics and functions
Solving Linear Equation Systems
a=elem_mult(a,b); // elementwise multiplication Random Number Generation
Special Matricies
Thomas Eriksson September 2004
Department of Signal and Systems
Random numbers
Discrete-valued random
number generators
•Bernoulli_RNG
•I_Uniform_RNG
Continuous-valued random
number generators
•Uniform_RNG
•Exponential_RNG
•Normal_RNG
•Complex_Normal_RNG
•AR1_Normal_RNG
•Weibull_RNG
•Rayleigh_RNG
•Rice_RNG
Random vectors and matrices are easily obtained
by using these predefined functions:
•randb: random bit vector or matrix.
•randu: random uniform vector or matrix.
•randi: random index vector or matrix.
•randray: random Rayleigh vector or matrix.
•randrice: random Rice vector or matrix.
•randexp: random Exponential vector or matrix.
•randn: random Gaussian vector or matrix.
•randn_c: random complex Gaussian vector or
matrix.
Thomas Eriksson September 2004
Department of Signal and Systems
Filtering
Filtering classes
•AR_Filter
•MA_Filter
•ARMA_Filter
autoregressive filter class
moving average filter class
Filter functions
•filter
filtering function (AR, MA, ARMA)
Filter design
•fir1
FIR filter design using the window method.
Thomas Eriksson September 2004
Department of Signal and Systems
Signal processing
Signal processing
•a2k, k2a, a2lar, k2lar, lpc, levinsson, lerouxguegen
•fft, ifft
•spectrum
•cov, xcorr
•chirp
•dht, dht2, dwht, dhwt2, self_dht, self_dwht
•filter_spectrum
•filter_whiteness
Signal sources
•Sine_Source
•Square_Source
•Triangle_Source
•Sawtooth_Source
•Impulse_Source
•Pattern_Source
Thomas Eriksson September 2004
Department of Signal and Systems
Communication
The itcomm Library
The itcomm library contains many different communication functions such as
modulators and demodulators, channel encoders and decoders, spreading and despreading functions, channel classes, interleavers, e.t.c.
Modulator Classes
There is a base modulator class called Modulator and two derived classes
Modulator_1d and Modulator_2d. You can use Modulator_1d to define you own 1dimensional signal constellations (e.g. BPSK and PAM) and Modulator_2d to define
you own 2-dimensional signal constellations (e.g. QPSK, QAM e.t.c)
The predefined classes are BPSK, PAM, PSK, QAM, QPSK, and OFDM.
Channel Classes
The following channel classes are available in itcomm: AWGN_Channel,
Multipath_Rayleigh_Channel, Rayleigh_Channel, BSC, and Rice_Channel.
Thomas Eriksson September 2004
Department of Signal and Systems
Communication
Error Control Classes
The following error control classes are available in
itcomm: Turbo_Codec, BCH, Reed_Solomon,
Convolutional_Code, Punctured_Convolutional_Code,
Hamming_Code, Rec_Syst_Conv_Code.
Spreading Classes
The following spreading classes are available in
itcomm: Spread_1d, Spread_2d, Multicode_Spread_1d,
Multicode_Spread_2d. Also, the class Gold can be used
to generate Gold spreading sequences.
Interleaver Classes
The following interleaver classes are available in
itcomm: Block_Interleaver, Cross_Interleaver, and
Sequence_Interleaver.
Thomas Eriksson September 2004
Department of Signal and Systems
MATLAB interface
IT++ support several ways to communicate with MATLAB.
•MATLAB engine. With MATLAB engine, a matlab process can be started from inside
the C++ program. This is useful for plotting, or to use functionality of MATLAB not yet
implemented in IT++.
•By itfile. IT++ defines a file format that is understood both by IT++ and MATLAB. This
is useful to save data from a program for later analysis in MATLAB, or if MATLAB
provides som data that can be used by the IT++ program.
Interface functions and classes:
•By MEX files. IT++ provides some interface routines for mex file writing, to convert
between matlab and it++ vectors and matrices.
Matlab_Engine M;
vec v;
M.put(v,”v”);
M.command(”plot(v)”);
vec v("1 2 3");
it_file f("file.it");
f << Name("v") << v;
Thomas Eriksson September 2004
Department of Signal and Systems
#include "itcomm.h"
int main() {
int
i, Number_of_bits;
double Ec, Eb;
vec
EbN0dB, EbN0, N0, noise_variance, bit_error_rate;
bvec
transmitted_bits, received_bits;
cvec
transmitted_symbols, received_symbols;
QPSK qpsk; //The QPSK modulator class
AWGN_Channel awgn_channel; //The AWGN channel class
it_file
ff; //For saving the results to file
BERC berc; //Used to count the bit errors
tic(); // start a timer
Ec = 1.0; //The transmitted energy per QPSK symbol is 1.
Eb = Ec / 2.0; //The transmitted energy per bit is 0.5.
Thomas Eriksson September 2004
Department of Signal and Systems
EbN0dB = linspace(0.0,9.0,10); //Simulate for 10 Eb/N0 values from 0 to 9 dB.
EbN0 = inv_dB(EbN0dB); //Calculate Eb/N0 in a linear scale instead of dB.
N0 = Eb * pow(EbN0,-1.0); //N0 is the variance of the (complex valued) noise.
Number_of_bits = 100000; //100000 bits are transmitted for each Eb/N0 value
bit_error_rate.set_length(EbN0dB.length());
RNG_randomize();
for (i=0; i<EbN0dB.length(); i++) {
cout << "Eb/N0 value " << i+1 << " of " << EbN0dB.length() << endl;
transmitted_bits = randb(Number_of_bits);
transmitted_symbols = qpsk.modulate_bits(transmitted_bits);
awgn_channel.set_noise(N0(i));
received_symbols = awgn_channel(transmitted_symbols);
received_bits = qpsk.demodulate_bits(received_symbols);
Thomas Eriksson September 2004
Department of Signal and Systems
transmitted_symbols = qpsk.modulate_bits(transmitted_bits);
awgn_channel.set_noise(N0(i));
received_symbols = awgn_channel(transmitted_symbols);
received_bits = qpsk.demodulate_bits(received_symbols);
berc.clear();
berc.count(transmitted_bits,received_bits);
bit_error_rate(i) = berc.get_errorrate();
}
toc();
cout << "EbN0dB = " << EbN0dB << " [dB]" << endl;
cout << "BER = " << bit_error_rate << endl;
cout << "Saving results to ./qpsk_result_file.it" << endl << endl;
ff.open("qpsk_result_file.it");
ff << Name("EbN0dB") << EbN0dB;
ff << Name("ber") << bit_error_rate;
ff.close();
Thomas Eriksson September 2004
Department of Signal and Systems
Possible extension
•New functionality provided by NEWCOM partners
•???
Thomas Eriksson September 2004