testcomplexica.cpp

Go to the documentation of this file.
00001 #include "ComplexICA.h"
00002 #include "UniformRNG.h"
00003 #include "miscfunc.h"
00004 #include <fstream>
00005 int main()
00006 {
00007         const int nchannels = 2;
00008         const int nsamples = 2000;
00009         const float minrand = -0.5;
00010         const float maxrand = 0.5;
00011         UniformRNG Random;
00012         
00013         //Convolve(Master,Corr,Output);
00014         
00015         cmat orig_source(nchannels,nsamples);
00016         cmat input(nchannels,nsamples);
00017         for (int j = 0; j < nsamples; ++j)
00018         {
00019                         orig_source(0,j) = std::complex<double>(sin(j/125.23),0.0);
00020                         orig_source(1,j) = std::complex<double>(Random.GetNumber(minrand,maxrand),Random.GetNumber(minrand,maxrand)); 
00021         }
00022         cmat orig_mix(nchannels,nchannels);
00023         for (int i = 0; i < nchannels; ++i)
00024                 for (int j = 0; j < nchannels; ++j)
00025                         orig_mix(i,j) = std::complex<double>(Random.GetNumber(minrand,maxrand),Random.GetNumber(minrand,maxrand)); 
00026         for (int i = 0; i < nsamples; ++i)
00027                 ublas::column(input,i) = ublas::prod(orig_mix,ublas::column(orig_source,i));
00028         cmat source(nchannels,nsamples);
00029         cmat mix(nchannels,nchannels);
00030         std::cout << "input: " << input << std::endl << std::endl;
00031         ComplexICA(input,source,mix);
00032         std::cout << std::endl << std::endl;
00033         //std::cout << "orig_source: " << orig_source << std::endl << std::endl;
00034         std::cout << "orig_mix: " << orig_mix << std::endl<< std::endl;
00035         //std::cout << "est_source: " << source << std::endl<< std::endl;
00036         std::cout << "est_mix: " << mix << std::endl<< std::endl; 
00037         std::ofstream outfile("compica.out");
00038         for (int i = 0; i < nsamples; ++i)
00039                 outfile << i << " " <<  source(0,i).real() << " " << source(1,i).real()<< " " <<  source(0,i).imag() << " " << source(1,i).imag() << std::endl;
00040 }

Generated on Mon Sep 15 12:54:34 2008 for GPLIB++ by  doxygen 1.5.5