• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

ChiSquareReceiver.hh

Go to the documentation of this file.
00001 // $Id
00002 
00003 //###################################################################
00004 //
00005 //           Optical Communication Systems Simulator
00006 //
00007 //       Copyright (2004):
00008 //       Optical Fiber Communications Laboratory (OFCL)
00009 //       Computer Science & Electrical Engineering Department (CSEE)
00010 //       University of Maryland Baltimore County (UMBC)
00011 //
00012 //###################################################################
00013 
00014 // Written by John Zweck, May 2004
00015 
00016 #ifndef _CHI_SQUARE_RECEIVER_HH_
00017 #define _CHI_SQUARE_RECEIVER_HH_
00018 
00019 #include <gsl/gsl_errno.h>
00020 #include <gsl/gsl_math.h>
00021 #include <gsl/gsl_roots.h>
00022 
00023 #include "NoiseCovariance.hh"
00024 #include "ocsOptDemuxer.hh"
00025 #include "ocsPhotodetector.hh"
00026 #include "ocsElecFilter.hh"
00027 #include "ocsHistogram2D.hh"
00028 #include "ocsElecSignalStat.hh"
00029 
00031 
00032 struct ChiSquareReceiverParameters
00033 {
00034   double ActiveCurrentValue;
00035   int CovMatrixDim;
00036   double * LambdaVec;
00037   double * LambdaQSqVec;
00038 };
00039 
00040 
00041 cplx ChiSquareReceiverPsiCplx(cplx s, void * InParameters);
00042 double ChiSquareReceiverPsi(double s, void * InParameters);
00043 double ChiSquareReceiverDerivativePsi(double s, void * InParameters);
00044 double ChiSquareReceiverSecondDerivativePsi(double s, void * InParameters);
00045 
00046 
00049 
00058 enum typeOutput { PDFS = 1, EYE = 2};
00059 
00063 
00073 enum typeIntegrationMethod { FOURIER_TRANSFORM = 1, STEEPEST_DESCENT = 2};
00074 
00075 // For most compliers Fortran77 subroutines like myfun are recognized
00076 // as myfun_ Therefore:
00077 
00078 #define F77NAME(x) x##_
00079 
00080 extern "C" void F77NAME(dsyev)(char*,char*,int*,double*,int*,double*,double*,
00081                                int*,int*);
00082 // The last argument is an int which is the length of the
00083 // character array name.
00084 
00085 extern "C" int F77NAME(ilaenv)(int*,char*,char*,int*,int*,int*,int*,int);
00086 
00090 
00292 class ChiSquareReceiver
00293 {
00294 
00295  public:
00296 
00298 
00309   ChiSquareReceiver(string InFileName, NoiseCovariance * oNoiseCovariance2);
00310 
00311   ~ChiSquareReceiver(void);
00312 
00314 
00324   void ReceiveSignal(string OutFileNamePrefix2);
00325  
00326   void ComputeGaussianPDFsAndBER(void);
00327  
00328   double GetOSNR_dB(double B_OSA);
00329   double GetBitErrorRatio(void) {return BitErrorRatio;};
00330   double GetDecisionThresholdmV(void) 
00331          {return 1e3*DecisionThreshold/NormalizationFactor;};
00332 
00336 
00341   void SetOSNR(double Value);
00342 
00345 
00346   void SetElecFilterBandwidth(double ValueHz);
00347 
00350 
00351   void SetOptFilterBandwidth(double ValueHz);
00352 
00358 
00359   void ReceiveSignalCWNoLossNoDisp(string OutFileNamePrefix2,
00360                         double P_0, double z, double gamma, double N_ASE, double NF);
00361  
00362 
00364 
00365   double GetNormalizationFactor() {return NormalizationFactor;};
00366   void SetNormalizationFactor(double Value) {NormalizationFactor = Value;};
00367 
00368 private:
00369   void ReceiveNoiseFreeSignalAndRecoverClock(void);
00370   void PrepareToComputeKLModes(void);
00371 
00372   void GetReducedNoiseFreeSigAndDiagonalizeCovMatrix(void);
00373   void ComputeTimeIndependentPartOfFilterMatrix(void);
00374   
00375   void ComputeKLModes(int TimeIndex);
00376 
00377   void ComputePDFAtTimeValue(int TimeIndex);
00378   void ComputePDFAtTimeValueFourierTransform(int TimeIndex);  
00379   double ComputePDFValueSteepestDescent(int TimeIndex,int CurrentIndex);
00380   double EvaluateGaussianApproximation(double SaddlePoint);
00381 
00382   void WriteFilePDFs(void);
00383 
00387 
00388   void WriteFileEye(void);
00389 
00393 
00403   void ComputeAveragePDFs(void);
00404 
00408   
00409   void ComputeMinimumBERAndDecisionThreshold(void);
00410 
00413 
00414   void ComputeMomentsInEachBit(void);
00415 
00418 
00419   void ComputeEye(void);
00420 
00423 
00434   void SymmetricEig(double ** Matrix, double * EigValue,
00435                     double ** EigVector,int Dim);
00436 
00438 
00439   void PrepareSymmetricEig(void);
00440 
00447 
00448   bool TestEigDecomposition(double ** Matrix, double * EigValue,
00449                             double ** EigVector,int Dim);
00450 
00453 
00454   inline double ReducedFrequency(int k) 
00455                 {return (CovMatrixFirstIndex + k)*DeltaFreq;};
00456 
00457   void WriteFileSquareMatrix(double **A, int dim, string OutFileName, 
00458                              double NormalizationFactor);
00459 
00460   void WriteFileVector(double *V, int dim, string OutFileName, 
00461                    double NormalizationFactor);
00462 
00463   void WriteFilePairVectors(double * x, double *y, 
00464                             int dim,string OutFileName, 
00465                             double xNormalizationFactor, 
00466                             double yNormalizationFactor);
00467 
00468   void WriteFileComplexMatrix(cplx **A, int dim,
00469                               string RealOutFileName, 
00470                               string ImagOutFileName, 
00471                               double NormalizationFactor);
00472 
00475 
00476   void WriteFilePDFTimeSlices(string OutFileName);
00477 
00478   void WriteFileGSLFunction(double CurrentValue,double s_min,double s_max,
00479                             int NumPts,string OutFileName);
00480 
00481   void InitializeGSL_FunctionToDerivativePsi(void);
00482   double FindRootInterval(double &LowerBound,double &UpperBound);
00483 
00484 
00485  private:
00486 
00487   string Job;
00488   string OutFileNamePrefix;
00489 
00490   typeIntegrationMethod TypeIntegrationMethod;
00491 
00495 
00496   bool ReadInSignalAndCovMatrixFlag;
00497 
00498  
00501 
00502   string SignalAndCovMatrixDir;
00503 
00506 
00507   string SignalAndCovMatrixJob;
00508 
00513 
00514   double SetOSNRdB;
00515 
00518 
00519   double B_OSA;
00520 
00523 
00524   int DebugLevel;
00525 
00526   int DemuxChannArrayIndex;
00527   NoiseCovariance * oNoiseCovariance;  
00528   OptSignal * Signal;
00529   
00530   fftMatrices ReceiverReducedNoiseFreeSignal;
00531   double * ReducedNoiseFreeSignalRealVector;
00532 
00533   RanNumGen * RNG;
00534 
00535   OptSignal * DemuxedNoiseFreeSignal;
00536   OptFilter * TunableOptFilterForNoiseFreeSignal;
00537   OptDemuxer * OptDemuxerForNoiseFreeSignal;
00538   Photodetector * PhotodetectorForNoiseFreeSignal;
00539   ElecFilter * ElecFilterForNoiseFreeSignal;
00540   ElecSignalStat * ElecSignalStatForNoiseFreeSignal;
00541 
00542   OptSignal * OptFilterTransferFunction;
00543   Photodetector * ElecFilterTransferFunction;
00544 
00545   OptFilter * TunableOptFilterForTransferFunction;
00546   ElecFilter * ElecFilterForTransferFunction;
00547 
00548   double DeltaFreq; // equals ReducedDeltaFreq
00549   double TimeWindow; // equals ReducedTimeWindow
00550   double ReducedDeltaTime;
00551   double ReducedFreqWindow;
00552 
00555 
00559   double **CovarianceMatrix;
00560 
00561   typeOutput TypeOutput;
00562 
00566 
00567   int NumBitsToPlot;
00568   
00570 
00571   int NumBitsBetweenSlices;
00572 
00574 
00575   int NumSlicesPerBit;
00576 
00579 
00589   double TimeBetweenSlices;
00590 
00591 
00595 
00596   bool ReadInClockRecoveryTimeFlag;
00597 
00599 
00600   double ClockRecoveryTime;
00601 
00604 
00605   double ClockRecoveryCurrent;
00606 
00607   int NumTimeSlices;
00608 
00610 
00611   double * TimeSlices;
00612 
00614 
00615   double MinCurrent;
00616  
00618 
00619   double MaxCurrent;
00620 
00623 
00624   int NumPointsCurrent;
00625 
00626   double DeltaCurrent;
00627 
00630 
00631   double * CurrentVector;
00632 
00634 
00637   double * ActiveCurrentValuePtr;
00638 
00639   int CovMatrixDim;
00640   
00641   int CovMatrixFirstIndex;
00642   int CovMatrixLastIndex;
00643 
00644   double NormalizationFactor;
00645 
00646   double LowerPole;
00647   double UpperPole;
00648 
00649   double DecisionThreshold;
00650   double BitErrorRatio;
00651 
00652   int LengthSymmetricEigWork;
00653 
00654   double * SymmetricEigWork;
00655 
00657 
00658   double * CovarianceEvalues;
00659 
00662   
00663   double ** CovarianceEvectors;
00664 
00666 
00669   double * CovarianceEvectorsStorageVec;
00670   
00672 
00673   cplx ** FilterMatrixTimeIndependent;
00674 
00676 
00677   cplx * FilterMatrixTimeIndependentStorageVec;
00678 
00680 
00684   double ** FilterMatrix;
00685 
00687 
00688   double * FilterMatrixStorageVec;
00689 
00691 
00692   double ** HMatrix;
00693 
00695 
00696   double * HMatrixStorageVec;
00697 
00699 
00700   double ** VMatrix;
00701 
00703 
00704   double * VMatrixStorageVec;
00705 
00707 
00708   double ** WorkMatrix;
00709 
00711 
00712   double * WorkMatrixStorageVec;
00713 
00715 
00716   double ** TestEigMatrix;
00717 
00719 
00720   double * TestEigMatrixStorageVec;
00721 
00722 
00724 
00725   double * LambdaVec;
00726 
00728   
00729   double * LambdaQSqVec;
00730 
00732 
00733   double * WorkVec;
00734 
00735   gsl_function * GSL_Function;
00736   int RootFinderMaxIterations;
00737 
00738   double MinNegLambda;
00739 
00740   struct ChiSquareReceiverParameters * Parameters;
00741 
00742   // PDFTimeSlices[tt][vv], so tt-th row of PDFTimeSlices is the pdfs of
00743   // the tt-th TimeSlice. We write out its transpose though
00744 
00745   double ** PDFTimeSlices;
00746  
00748 
00749   double * PDFTimeSlicesStorageVec;
00750 
00752 
00753   double * AveragePDFZeros;
00754 
00756 
00757   double * AveragePDFOnes;
00758 
00760 
00761   double * PowerInSlice;
00762 
00764 
00765   int * BitString;
00766 
00769 
00775   double ** EyeMatrix;
00776 
00778 
00779   double * EyeMatrixStorageVec;
00780 
00782 
00783   double * BER;
00784 
00785   double * MomentsIntegrand;
00786 
00787   double * MeanCurrent;
00788 
00789   double * StandardDeviationCurrent;
00790 
00791 };
00792 
00793 #endif

Generated on Fri Jul 2 2010 12:57:46 for OCS by  doxygen 1.7.1