Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Blind Source Separation (BSS) unit test
- ported from sep_demo.m by Andreas Ziehe
- */
- void bss_unittest()
- {
- // ica data
- int FS = 4000;
- EVector t(FS+1, true);
- t.setLinSpaced(FS+1,0,1);
- // source signals
- EMatrix s(2,FS+1);
- for(int i = 0; i < FS+1; i++)
- {
- s(0,i) = sin(2*3.14*55*t[i]);
- s(1,i) = cos(2*3.14*100*t[i]);
- }
- // mixing matrix
- EMatrix A(2,2);
- A(0,0) = 1; A(0,1) = 0.85;
- A(1,0) = 0.55; A(1,1) = 1;
- SGMatrix<float64_t> X(2,FS+1);
- Eigen::Map<EMatrix> EX(X.matrix,2,FS+1);
- EX = A * s;
- // begin
- SGVector<float64_t> sep(3); sep[0]=0; sep[1]=1; sep[2]=2; sep[3]=3;
- SGMatrix<float64_t> C = tdsep(X,sep);
- // Unmix
- //Eigen::Map<EMatrix> EC(C.matrix,2,2);
- //EMatrix unmix = EC.inverse() * EX;
- // Normalize estimated mixing matrix
- //for(int t = 0; t < EC.cols(); t++)
- // EC.col(t) /= EC.col(t).maxCoeff();
- return;
- }
- SGMatrix<float64_t> tdsep(SGMatrix<float64_t> &x, SGVector<float64_t> &sel)
- {
- int n = x.num_rows;
- int m = x.num_cols;
- SGMatrix<float64_t>::display_matrix(x.matrix,n,m);
- Eigen::Map<EMatrix> Ex(x.matrix,n,m);
- std::cout << Ex << std::endl; // crashes
- // ...
Advertisement
Add Comment
Please, Sign In to add comment