| 285 | | if (!(Mr==Nt)||!(Mr==2)) { |
| 286 | | std::cout<<"Temporarily only 2x2 VBLAST is supported"<<std::endl; |
| | 304 | cx_mat r(Mr,OutData_length/Nt); |
| | 305 | cx_mat z(1,OutData_length/Nt); |
| | 306 | cx_mat s(1,OutData_length/Nt); |
| | 307 | |
| | 308 | |
| | 309 | cx_mat T(Nt,Mr); |
| | 310 | cx_mat w(1,Mr); |
| | 311 | T.zeros(); |
| | 312 | |
| | 313 | |
| | 314 | |
| | 315 | |
| | 316 | //Computer pseudo-inverse (Moore-Penrose method) |
| | 317 | |
| | 318 | T=inv(htrans(H)*H)*htrans(H); |
| | 319 | // std::cout<<"H:"<<H<<std::endl; |
| | 320 | // std::cout<<"T:"<<T<<std::endl; |
| | 321 | //std::cout<<"HTH"<<H*T*H<<std::endl; |
| | 322 | |
| | 323 | double n,nmax; |
| | 324 | short I,Q,sno; |
| | 325 | short int k,k2,st; |
| | 326 | |
| | 327 | st=0; |
| | 328 | for (short int i=NH; i<Data_length;i+=Mr) { |
| | 329 | for (short int l=0;l<Mr;l++) r(l,st)=cx_double((*I_in)[i+l],(*Q_in)[i+l]); |
| | 330 | st++; |
| | 331 | }; |
| | 332 | |
| | 333 | nmax=-1; |
| | 334 | for (k2=0;k2<Nt;k2++) { |
| | 335 | //if (k2>0) { |
| | 336 | T=pinv(H); |
| | 337 | //std::cout<<"T:"<<T<<std::endl; |
| | 338 | // std::cout<<"HTH"<<H*T*H<<std::endl; |
| | 339 | //} |
| | 340 | k=k2; |
| | 341 | nmax=-1; |
| | 342 | for (short int i=0;i<Nt;i++) { |
| | 343 | w=T.row(i); |
| | 344 | n= norm(abs(w),2); |
| | 345 | if (n>nmax) { |
| | 346 | nmax=n; |
| | 347 | k=i; |
| | 348 | //std::cout<<"k:"<<k<<" nmax:"<<nmax<<std::endl; |
| | 349 | } |
| | 350 | } |
| | 351 | |
| | 352 | w=T.row(k); |
| | 353 | //std::cout<<"w:"<<w<<std::endl; |
| | 354 | z=w*r; |
| | 355 | //std::cout<<"z:"<<z<<std::endl; |
| | 356 | // std::cout<<" z=w*r;"<<std::endl; |
| | 357 | |
| | 358 | for (short int i=0;i<(OutData_length/Nt);i++) { |
| | 359 | SigProc::DemodulateQPSK((short)(real(z(0,i))),(short)(imag(z(0,i))),sno); |
| | 360 | SigProc::ModulateQPSK(sno,I,Q); |
| | 361 | //std::cout<<"sno:"<<sno<<" I,Q:"<<I<<","<<Q<<std::endl; |
| | 362 | s(0,i)=cx_double(I,Q)*0.989/sqrt(Nt); |
| | 363 | } |
| | 364 | // std::cout<<" s size:"<<s.n_elem<<"s:"<<s<<std::endl; |
| | 365 | r=r-H.col(k)*s; |
| | 366 | //std::cout<<" r="<<H.col(k)*s<<std::endl; |
| | 367 | //std::cout<<"r"<<r<<std::endl; |
| | 368 | //std::cout<<"H.col:"<<H.col(k)<<std::endl; |
| | 369 | //std::cout<<"zeros"<<zeros<cx_colvec>(Mr)<<std::endl; |
| | 370 | H.col(k)=zeros<cx_colvec>(Mr); |
| | 371 | |
| | 372 | // std::cout<<"H"<<H<<std::endl; |
| | 373 | |
| | 374 | //std::cout<<"rx_index:"<<(i-NH)/Mr+k<<" , i="<<i<<" ,k="<<k<<" ,st="<<st<<std::endl; |
| | 375 | st=0; |
| | 376 | for (short int i=k;i<OutData_length;i+=Nt) { |
| | 377 | rx_symbols(i,0)=z(0,st); |
| | 378 | st++; |
| | 379 | // std::cout<<"i:"<<i<<std::endl; |
| | 380 | } |
| | 381 | |
| | 382 | |
| | 383 | } |
| | 384 | |
| | 385 | |
| | 386 | |
| | 387 | /** |
| | 388 | |
| | 389 | if (!(Mr==Nt)||!(Mr==2)){ |
| | 390 | std::cout<<"Temporarily only 2x2 VBLAST is supported"<<std::endl; |
| 288 | | } |
| 289 | | |
| 290 | | |
| 291 | | cx_mat r(Mr,1); |
| 292 | | |
| 293 | | cx_mat T0(Nt,Mr); |
| 294 | | cx_mat T(Nt,Mr); |
| 295 | | cx_rowvec w; |
| 296 | | T.zeros(); |
| 297 | | |
| 298 | | //Computer pseudo-inverse (Moore-Penrose method) |
| 299 | | T=conj(H)*inv(H*conj(H)); |
| 300 | | //std::cout<<"H:"<<H<<std::endl; |
| 301 | | //std::cout<<"T:"<<T<<std::endl; |
| 302 | | |
| 303 | | double n,nmin; |
| 304 | | cx_mat z(1,1),s(1,1); |
| 305 | | short I,Q,sno; |
| 306 | | |
| 307 | | n=0; |
| 308 | | nmin=0; |
| 309 | | short int k; |
| 310 | | |
| 311 | | //n=norm(abs(w),2); |
| 312 | | //std::cout<<"k:"<<k<<" n:"<<n<<std::endl; |
| 313 | | mat sicorder(Mr,2); |
| 314 | | sicorder.zeros(); |
| 315 | | |
| 316 | | for (k=0;k<Mr;k++) { |
| 317 | | w=T.row(k); |
| 318 | | sicorder(k,0)=norm(abs(w),2); |
| 319 | | sicorder(k,1)=k; |
| 320 | | } |
| 321 | | |
| 322 | | short int l,l2,l2p,k2; |
| 323 | | for (k=0;k<Mr-1;k++) { |
| 324 | | for (l=0;l<(Mr-k-1);l++) { |
| 325 | | l2=sicorder(l,1); |
| 326 | | l2p=sicorder(l+1,1); |
| 327 | | if (sicorder(l2,0)<sicorder(l2p,0)) { |
| 328 | | sicorder(l,1)=l2p; |
| 329 | | sicorder(l+1,1)=l2; |
| 331 | | } |
| 332 | | } |
| 333 | | |
| 334 | | // std::cout<<"sicorder:"<<sicorder<<std::endl; |
| 335 | | |
| 336 | | |
| 337 | | |
| 338 | | |
| 339 | | for (short int i=NH; i<Data_length;i+=Mr) { |
| 340 | | for (short int l=0;l<Mr;l++) r(l,0)=cx_double((*I_in)[i+l],(*Q_in)[i+l]); |
| 341 | | for (k2=0;k2<Mr;k2++) { |
| 342 | | k=sicorder(k2,1); |
| 343 | | //T=pinv(H); |
| 344 | | |
| 345 | | w=T.row(k); |
| 346 | | //std::cout<<"w:"<<w<<std::endl; |
| 347 | | z=w*r; |
| 348 | | //std::cout<<"z:"<<z<<std::endl; |
| 349 | | SigProc::DemodulateQPSK((short)(real(z(0,0))),(short)(imag(z(0,0))),sno); |
| 350 | | SigProc::ModulateQPSK(sno,I,Q); |
| 351 | | //std::cout<<"sno:"<<sno<<std::endl; |
| 352 | | s=cx_double(I,Q)/sqrt(Nt)*0.7;; |
| 353 | | r=r-H.col(k)*s; |
| 354 | | //std::cout<<"r"<<r<<std::endl; |
| 355 | | //H.col(k)=zeros<cx_colvec>(1,Nt); |
| 356 | | rx_symbols(i+k-NH,0)=z(0,0); |
| 357 | | |
| 358 | | } |
| 359 | | |
| 360 | | |
| 361 | | } |
| 362 | | |
| | 393 | cx_mat r(Mr,1); |
| | 394 | |
| | 395 | cx_mat T0(Nt,Mr); |
| | 396 | cx_mat T(Nt,Mr); |
| | 397 | cx_rowvec w; |
| | 398 | T.zeros(); |
| | 399 | |
| | 400 | //Computer pseudo-inverse (Moore-Penrose method) |
| | 401 | T=conj(H)*inv(H*conj(H)); |
| | 402 | //std::cout<<"H:"<<H<<std::endl; |
| | 403 | //std::cout<<"T:"<<T<<std::endl; |
| | 404 | |
| | 405 | double n,nmin; |
| | 406 | cx_mat z(1,1),s(1,1); |
| | 407 | short I,Q,sno; |
| | 408 | |
| | 409 | n=0; |
| | 410 | nmin=0; |
| | 411 | short int k; |
| | 412 | |
| | 413 | //n=norm(abs(w),2); |
| | 414 | //std::cout<<"k:"<<k<<" n:"<<n<<std::endl; |
| | 415 | mat sicorder(Mr,2); |
| | 416 | sicorder.zeros(); |
| | 417 | |
| | 418 | for (k=0;k<Mr;k++) { |
| | 419 | w=T.row(k); |
| | 420 | sicorder(k,0)=norm(abs(w),2); |
| | 421 | sicorder(k,1)=k; |
| | 422 | } |
| | 423 | |
| | 424 | short int l,l2,l2p,k2; |
| | 425 | for (k=0;k<Mr-1;k++) { |
| | 426 | for (l=0;l<(Mr-k-1);l++) { |
| | 427 | l2=sicorder(l,1); |
| | 428 | l2p=sicorder(l+1,1); |
| | 429 | if (sicorder(l2,0)<sicorder(l2p,0)){ |
| | 430 | sicorder(l,1)=l2p; |
| | 431 | sicorder(l+1,1)=l2; |
| | 432 | } |
| | 433 | } |
| | 434 | } |
| | 435 | |
| | 436 | // std::cout<<"sicorder:"<<sicorder<<std::endl; |
| | 437 | |
| | 438 | |
| | 439 | |
| | 440 | |
| | 441 | for (short int i=NH; i<Data_length;i+=Mr) { |
| | 442 | for (short int l=0;l<Mr;l++) r(l,0)=cx_double((*I_in)[i+l],(*Q_in)[i+l]); |
| | 443 | for (k2=0;k2<Mr;k2++) { |
| | 444 | k=sicorder(k2,1); |
| | 445 | //T=pinv(H); |
| | 446 | |
| | 447 | w=T.row(k); |
| | 448 | //std::cout<<"w:"<<w<<std::endl; |
| | 449 | z=w*r; |
| | 450 | //std::cout<<"z:"<<z<<std::endl; |
| | 451 | SigProc::DemodulateQPSK((short)(real(z(0,0))),(short)(imag(z(0,0))),sno); |
| | 452 | SigProc::ModulateQPSK(sno,I,Q); |
| | 453 | //std::cout<<"sno:"<<sno<<std::endl; |
| | 454 | s=cx_double(I,Q)/sqrt(Nt)*0.7;; |
| | 455 | r=r-H.col(k)*s; |
| | 456 | //std::cout<<"r"<<r<<std::endl; |
| | 457 | //H.col(k)=zeros<cx_colvec>(1,Nt); |
| | 458 | rx_symbols(i+k-NH,0)=z(0,0); |
| | 459 | |
| | 460 | } |
| | 461 | |
| | 462 | |
| | 463 | } |
| | 464 | **/ |