Defines | Typedefs | Enumerations | Functions

ocsTools.hh File Reference

#include <unistd.h>
#include "cfftw.hh"
#include "ocsConst.hh"
#include <iostream.h>
#include <string.h>
#include <math.h>
#include <fstream.h>
#include <complex.h>
#include <stdlib.h>
#include <stdio.h>
#include <strstream>
#include <string>

Go to the source code of this file.

Defines

#define _OCS_SYSTEM_HDRS_
#define NEAR_ZERO   2.2e-13

Typedefs

typedef complex< double > cplx

Enumerations

enum  { MOSIX_UNLOCK, MOSIX_LOCK }

Functions

template<class T >
sq (T)
template<class T >
cube (T)
int sgn (double x)
double min (double a, double b)
void MinAndArgMin (double *Vec, int Length, double &MinValue, int &ArgMin)
void MaxAndArgMax (double *Vec, int Length, double &MaxValue, int &ArgMax)
double GetRadiusCircle (double *PointA, double *PointB, double *PointC)
double GetDistance2Points (double *PointA, double *PointB, int FirstCoord)
int Periodicity (int ii, int Periodicity)
void TransRzRyV3toXhat (double *Vector, double *thetaZthetaY)
void TransRzRxV3toXhat (double *Vector, double *thetaZthetaY)
void TransRzRyV3to_Xhat (double *Vector, double *thetaZthetaY)
void TransRyV3to_YZ (double *Vector, double *thetaY)
void TransRzRxV3to_Xhat (double *Vector, double *thetaZthetaX)
void TransRzRxV3to_Xhat (double *Vector, double *thetaZ, double *thetaX)
void Multiply (cplx Left[][2], cplx Right[][2])
void URotatesAboutZ (double angle, cplx UMatrix[][2])
void URotatesAboutY (double angle, cplx UMatrix[][2])
void URotatesAboutX (double angle, cplx UMatrix[][2])
void MRotatesAboutZ (double angle, double MMatrix[][3])
void MRotatesAboutY (double angle, double MMatrix[][3])
void MRotatesAboutX (double angle, double MMatrix[][3])
void MGeneralRotation (double angle, double *r_vec, double MMatrix[][3])
void RotatesAboutZ (double angle, double *Vector)
void RotatesAboutX (double angle, double *Vector)
void RotatesAboutY (double angle, double *Vector)
void RotatesAboutX (double angle, cplx *JonesVector)
void RotatesAboutY (double angle, cplx *JonesVector)
void RotatesAboutZ (double angle, cplx *JonesVector)
void Multiply (double Left[][3], double Right[][3])
void Multiply (double Left[][3], double Right[3])
double ScalarProduct (double *VectorA, double *VectorB)
void CrossProduct (double Left[4], double Right[4], int FirstCoord)
void CrossProduct (double *Left, double *Right, double *Product)
double GetVectorLength (double *Vector, int Dimension)
double dB2Linear (double dBvalue)
double dBm2Linear (double dBmPower)
double Linear2dB (double LinearValue)
double Linear2dBm (double LinearPower)
double Linear2dB_Limited (double LinearValue, double MaxValue_dB)
double GetDegreeOfPolarization (double *StokesVector)
double GetPhase (const cplx Phasor)
void Stokes2Jones (const double *Stokes, cplx *Jones)
void Jones2Stokes (const cplx *Jones, double *Stokes)
void Stokes2JonesKeepPower (const double *Stokes, cplx *Jones)
void Jones2StokesKeepPower (const cplx *Jones, double *Stokes)
void JonesPair2MixedStokes (const cplx *Jones1, const cplx *Jones2, cplx *MixedStokes)
double Frequency2Wavelength (double Frequency)
double Wavelength2Frequency (double Wavelength)
double MaxOfArray (double *Array, int Length)
 Returns the maximum element of the array Array.
double MinOfArray (double *Array, int Length)
 Returns the minimum element of the array Array.
double Quadrature (double *Data, int NumPts, double LeftEndPt, double RightEndPt)
cplx exp_jc_real (double __x)
double lin_map (double x, double a1, double diff_a, double b1, double diff_b)
int lin_map (double x, double a1, double diff_a, int b1, int num_b)
double lin_map (int x, int a1, int num_a, double b1, double diff_b)
double lin_map (int x, int a1, int num_a, int b1, int num_b)
double lin_interpolate (double x, double a1, double diff_a, int b1, int num_b, double *data)
cplx lin_interpolate (double x, double a1, double diff_a, int b1, int num_b, cplx *data)
int lock_or_unlock_mosix (int what)
int cpujob_mosix (void)
int slow_mosix (void)
double dB_to_factor (double G_dB)
double factor_to_dB (double factor)
double gaussian (double t, double t0, double FWHM_norm)
void gaussian_pdf (int N, double stan_dev, double *vec)
double soliton (double t, double t0, double eta)
cplx bessel5 (double omega, double omega_0, double FWHM)
void electrical_filter (cplx *my_power_time, cfftw *fft, double fwhm)
void optical_filter (cplx *my_field_time, cplx *my_field_freq, cfftw *fft, double fwhm)
void my_error (char *spruch)
double peak_power (cplx *in, int N)
double pulse_energy (cplx *in, int N, double width)
void fftshift (cplx *v, int datlen_l)
void ifftshift (cplx *v, int datlen_l)
float ranG (long *)
float Gaussian_pdf (long *idum)
void frprmn (float p[], int n, float ftol, int *iter, float *fret, float(*func)(float[]), void(*dfunc)(float[], float[]))
void frprmnd (double p[], int n, double ftol, int *iter, double *fret, double(*func)(double[]), void(*dfunc)(double[], double[]))
void powell (float p[], float xi[][4], int n, float ftol, int *iter, float *fret, float(*func)(float[]))
double ** dmatrix (long nrl, long nrh, long ncl, long nch)
cplx ** cmatrix (long nrl, long nrh, long ncl, long nch)
void free_dmatrix (double **m, long nrl, long nrh, long ncl, long nch)
void free_cmatrix (cplx **m, long nrl, long nrh, long ncl, long nch)
void gaussj (double **a, int n, double **b, int m)
void gaussj_complex (cplx **a, int n, cplx **b, int m)
float erffc (float x)
float gammp (float a, float x)
void gcf (float *gammcf, float a, float x, float *gln)
void gser (float *gamser, float a, float x, float *gln)
float gammln (float xx)
float gammq (float a, float x)
double erfccExtendedRange (double x)
float erfcc (float x)
float zbrent (float(*func)(float), float x1, float x2, float tol)
float brent (float ax, float bx, float cx, float(*f)(float), float tol, float *xmin)
double brentd (double ax, double bx, double cx, double(*f)(double), double tol, double *xmin)
double splint (double *xa, double *ya, double *y2a, int n, double x)
void spline (double *x, double *y, int n, double yp1, double ypn, double *y2)

Define Documentation

#define _OCS_SYSTEM_HDRS_
#define NEAR_ZERO   2.2e-13

Typedef Documentation

typedef complex<double> cplx

Enumeration Type Documentation

anonymous enum
Enumerator:
MOSIX_UNLOCK 
MOSIX_LOCK 

Function Documentation

cplx bessel5 ( double  omega,
double  omega_0,
double  FWHM 
)

Referenced by electrical_filter().

float brent ( float  ax,
float  bx,
float  cx,
float(*)(float)  f,
float  tol,
float *  xmin 
)

References CGOLD, nrerror(), SHFT, and SIGN.

Referenced by linmin().

double brentd ( double  ax,
double  bx,
double  cx,
double(*)(double)  f,
double  tol,
double *  xmin 
)

References CGOLD, nrerror(), SHFT, and SIGN.

Referenced by linmind().

cplx** cmatrix ( long  nrl,
long  nrh,
long  ncl,
long  nch 
)

References nrerror().

Referenced by ElecEqualizer::AllocateMemory().

int cpujob_mosix ( void   ) 
void CrossProduct ( double *  Left,
double *  Right,
double *  Product 
)
void CrossProduct ( double  Left[4],
double  Right[4],
int  FirstCoord 
)
template<class T >
T cube ( in  )  [inline]
double dB2Linear ( double  dBvalue  ) 
double dB_to_factor ( double  G_dB  )  [inline]
double dBm2Linear ( double  dBmPower  ) 
double** dmatrix ( long  nrl,
long  nrh,
long  ncl,
long  nch 
)
void electrical_filter ( cplx my_power_time,
cfftw fft,
double  fwhm 
)
float erfcc ( float  x  ) 

Referenced by erfccExtendedRange().

double erfccExtendedRange ( double  x  ) 
float erffc ( float  x  ) 

References gammp(), and gammq().

Referenced by ReduOptSignal::GetOutageProbGaussian().

cplx exp_jc_real ( double  __x  )  [inline]
double factor_to_dB ( double  factor  )  [inline]
void fftshift ( cplx v,
int  datlen_l 
)
void free_cmatrix ( cplx **  m,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

References FREE_ARG, and NR_END.

Referenced by ElecEqualizer::~ElecEqualizer().

void free_dmatrix ( double **  m,
long  nrl,
long  nrh,
long  ncl,
long  nch 
)

References FREE_ARG, and NR_END.

Referenced by ElecEqualizer::~ElecEqualizer().

double Frequency2Wavelength ( double  Frequency  ) 
void frprmn ( float  p[],
int  n,
float  ftol,
int *  iter,
float *  fret,
float(*)(float[])  func,
void(*)(float[], float[])  dfunc 
)

References EPS, FREEALL, linmin(), nrerror(), and nrvector().

void frprmnd ( double  p[],
int  n,
double  ftol,
int *  iter,
double *  fret,
double(*)(double[])  func,
void(*)(double[], double[])  dfunc 
)

References dvector(), EPS, FREEALLD, linmind(), and nrerror().

float gammln ( float  xx  ) 

References log().

Referenced by gcf(), and gser().

float gammp ( float  a,
float  x 
)

References gcf(), gser(), and nrerror().

Referenced by erffc().

float gammq ( float  a,
float  x 
)

References gcf(), gser(), and nrerror().

Referenced by erffc().

double gaussian ( double  t,
double  t0,
double  FWHM_norm 
)
void gaussian_pdf ( int  N,
double  stan_dev,
double *  vec 
)

References log(), sq(), and sqrt().

float Gaussian_pdf ( long *  idum  ) 

References log(), ranG(), and sqrt().

void gaussj ( double **  a,
int  n,
double **  b,
int  m 
)
void gaussj_complex ( cplx **  a,
int  n,
cplx **  b,
int  m 
)
void gcf ( float *  gammcf,
float  a,
float  x,
float *  gln 
)

References FPMIN, gammln(), ITMAX, log(), and nrerror().

Referenced by gammp(), and gammq().

double GetDegreeOfPolarization ( double *  StokesVector  ) 
double GetDistance2Points ( double *  PointA,
double *  PointB,
int  FirstCoord 
)

References sq(), and sqrt().

Referenced by GetRadiusCircle().

double GetPhase ( const cplx  Phasor  ) 
double GetRadiusCircle ( double *  PointA,
double *  PointB,
double *  PointC 
)
double GetVectorLength ( double *  Vector,
int  Dimension 
)

References sq(), and sqrt().

void gser ( float *  gamser,
float  a,
float  x,
float *  gln 
)

References EPS, gammln(), log(), and nrerror().

Referenced by gammp(), and gammq().

void ifftshift ( cplx v,
int  datlen_l 
)
void Jones2Stokes ( const cplx Jones,
double *  Stokes 
)
void Jones2StokesKeepPower ( const cplx Jones,
double *  Stokes 
)

References Jones2Stokes(), and sq().

void JonesPair2MixedStokes ( const cplx Jones1,
const cplx Jones2,
cplx MixedStokes 
)

Converts a pair of Jones vectors v_1, v_2 into the mixed Stokes vector S_12 = ConjugateTranspose(v_1)*Sigma*v_2 where Sigma is the Pauli Spin 4-vector

Converts a pair of Jones vectors v_1, v_2 into the mixed Stokes vector S_12 = ConjugateTranspose(v_1)*Sigma*v_2 where Sigma is the Pauli Spin 4-vector

Converts a pair of Jones vectors v_1, v_2 into the mixed Stokes vector S_12 = ConjugateTranspose(v_1)*Sigma*v_2 where Sigma is the Pauli Spin 4-vector.

Here the Jones vectors are complex 2x1 column vectors and S_12 is a complex 4-vector.

If v_1 = v_2, then the Mixed Stokes vector is just the standard Stokes vector of v_1, and is in particular real.

In general, the complex conjugate of S_12 is S_21.

If v_1 and v_2 form an orthonormal basis, then the zero-th entry of S_12 is zero

We do not normalize by the zero-th entry of S_12, as it may be 0!

Written by JZ, Dec 2005

References jc.

Referenced by GaussianReceiver::ComputeFirstOrderPMDParameters(), and GaussianReceiver::ReceiveSignalDGD_NoisePartiallyPolarized().

cplx lin_interpolate ( double  x,
double  a1,
double  diff_a,
int  b1,
int  num_b,
cplx data 
) [inline]
double lin_interpolate ( double  x,
double  a1,
double  diff_a,
int  b1,
int  num_b,
double *  data 
) [inline]
double lin_map ( double  x,
double  a1,
double  diff_a,
double  b1,
double  diff_b 
) [inline]
int lin_map ( double  x,
double  a1,
double  diff_a,
int  b1,
int  num_b 
) [inline]
double lin_map ( int  x,
int  a1,
int  num_a,
double  b1,
double  diff_b 
) [inline]
double lin_map ( int  x,
int  a1,
int  num_a,
int  b1,
int  num_b 
) [inline]
double Linear2dB ( double  LinearValue  ) 
double Linear2dB_Limited ( double  LinearValue,
double  MaxValue_dB 
)
double Linear2dBm ( double  LinearPower  ) 
int lock_or_unlock_mosix ( int  what  ) 
void MaxAndArgMax ( double *  Vec,
int  Length,
double &  MaxValue,
int &  ArgMax 
)
double MaxOfArray ( double *  Array,
int  Length 
)

Returns the maximum element of the array Array.

Referenced by ChiSquareReceiver::ComputePDFAtTimeValue().

void MGeneralRotation ( double  angle,
double *  r_vec,
double  MMatrix[][3] 
)

References Multiply(), sq(), and sqrt().

double min ( double  a,
double  b 
) [inline]
void MinAndArgMin ( double *  Vec,
int  Length,
double &  MinValue,
int &  ArgMin 
)
double MinOfArray ( double *  Array,
int  Length 
)

Returns the minimum element of the array Array.

Referenced by ChiSquareReceiver::ComputePDFAtTimeValue().

void MRotatesAboutX ( double  angle,
double  MMatrix[][3] 
)
void MRotatesAboutY ( double  angle,
double  MMatrix[][3] 
)
void MRotatesAboutZ ( double  angle,
double  MMatrix[][3] 
)
void Multiply ( cplx  Left[][2],
cplx  Right[][2] 
)
void Multiply ( double  Left[][3],
double  Right[][3] 
)

Referenced by MGeneralRotation().

void Multiply ( double  Left[][3],
double  Right[3] 
)
void my_error ( char *  spruch  ) 
void optical_filter ( cplx my_field_time,
cplx my_field_freq,
cfftw fft,
double  fwhm 
)
double peak_power ( cplx in,
int  N 
)
int Periodicity ( int  ii,
int  Periodicity 
)
void powell ( float  p[],
float  xi[][4],
int  n,
float  ftol,
int *  iter,
float *  fret,
float(*)(float[])  func 
)
double pulse_energy ( cplx in,
int  N,
double  width 
)
double Quadrature ( double *  Data,
int  NumPts,
double  LeftEndPt,
double  RightEndPt 
)

Computes $^RightEndPt f(x) dx, where function is given by Data[k] = f(LeftEndPt + k*Delta) with Delta = (RightEndPt - LeftEndPt)/(NumPts-1)

So Data[0] = f(LeftEndPt) and Data[NumPts-1] = RightEndPt The method uses Simpson's rule, which estimates the integral as

Integral = Delta/3( f(x_0) + 4[f(x_1) + f(x_3) +... f(x_{n-3}) + f(x_{n-1})] + 2[f(x_2) + f(x_4) +... f(x_{n-2})] + f(x_n) )

where n is even.

For us if NumPts is odd then n=NumPts-1, and if NumPts is even then n=NumPts-2, and we use Simpson on the subarray of the first NumPts-1 points, with the final part of the integral being done using trapezoid rule with 2 points.

If NumPts < 5 then Simpson's rule doesn't really apply and so we just use Trapezoid rule.

Integral=0.0;

for(int ii=0;ii < NumPts;ii++) Integral+=Data[ii];

Integral *= Delta;

Referenced by ElecSignalStat::ComputeAveragePDFs(), GaussianReceiver::ComputeAveragePDFs(), ChiSquareReceiver::ComputeGaussianPDFsAndBER(), Histogram2D::ComputeIntegralPDF(), OptSignal::ComputeMeanFreqSignal(), OptSignal::ComputeMeanPhasePulse(), OptSignal::ComputeMeanTimePulse(), Histogram2D::ComputeMeanX_PDF(), Histogram2D::ComputeMeanY_PDF(), ElecSignalStat::ComputeMinimumBERAndDecisionThreshold(), GaussianReceiver::ComputeMinimumBERAndDecisionThreshold(), ChiSquareReceiver::ComputeMinimumBERAndDecisionThreshold(), ChiSquareReceiver::ComputeMomentsInEachBit(), ChiSquareReceiver::ComputePDFAtTimeValue(), OptSignal::ComputeRMSPulseWidth(), Histogram2D::ComputeXMarginalPDF(), Histogram2D::ComputeYMarginalPDF(), and OptSignal::GetEnergyInTimeRange().

float ranG ( long *   ) 

References AM, IA1, IA2, IR1, IR2, NTAB, and RNMX.

Referenced by Gaussian_pdf().

void RotatesAboutX ( double  angle,
double *  Vector 
)
void RotatesAboutX ( double  angle,
cplx JonesVector 
)

References jc.

void RotatesAboutY ( double  angle,
double *  Vector 
)
void RotatesAboutY ( double  angle,
cplx JonesVector 
)

References jc.

void RotatesAboutZ ( double  angle,
double *  Vector 
)
void RotatesAboutZ ( double  angle,
cplx JonesVector 
)
double ScalarProduct ( double *  VectorA,
double *  VectorB 
)
int sgn ( double  x  )  [inline]
int slow_mosix ( void   ) 
double soliton ( double  t,
double  t0,
double  eta 
) [inline]
void spline ( double *  x,
double *  y,
int  n,
double  yp1,
double  ypn,
double *  y2 
)
double splint ( double *  xa,
double *  ya,
double *  y2a,
int  n,
double  x 
)
template<class T >
T sq ( in  )  [inline]
void Stokes2Jones ( const double *  Stokes,
cplx Jones 
)
void Stokes2JonesKeepPower ( const double *  Stokes,
cplx Jones 
)

References sq(), sqrt(), and Stokes2Jones().

void TransRyV3to_YZ ( double *  Vector,
double *  thetaY 
)
void TransRzRxV3to_Xhat ( double *  Vector,
double *  thetaZthetaX 
)
void TransRzRxV3to_Xhat ( double *  Vector,
double *  thetaZ,
double *  thetaX 
)

References pi, RotatesAboutX(), RotatesAboutZ(), and sq().

void TransRzRxV3toXhat ( double *  Vector,
double *  thetaZthetaY 
)

References pi, and TransRzRxV3to_Xhat().

void TransRzRyV3to_Xhat ( double *  Vector,
double *  thetaZthetaY 
)
void TransRzRyV3toXhat ( double *  Vector,
double *  thetaZthetaY 
)

References pi, and TransRzRyV3to_Xhat().

void URotatesAboutX ( double  angle,
cplx  UMatrix[][2] 
)

References jc.

void URotatesAboutY ( double  angle,
cplx  UMatrix[][2] 
)

References jc.

void URotatesAboutZ ( double  angle,
cplx  UMatrix[][2] 
)
double Wavelength2Frequency ( double  Wavelength  ) 
float zbrent ( float(*)(float)  func,
float  x1,
float  x2,
float  tol 
)

References EPS, nrerror(), and SIGN.