Functions
Phase Gradient Heap Integration

Functions

int pghi (const LTFAT_REAL s[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, LTFAT_COMPLEX c[])
 
int pghi_withmask (const LTFAT_COMPLEX cin[], const int mask[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, LTFAT_COMPLEX c[])
 
int pghi_init (double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, double tol1, double tol2, pghi_plan **p)
 
int pghi_execute (pghi_plan *p, const LTFAT_REAL s[], LTFAT_COMPLEX c[])
 
int pghi_execute_withmask (pghi_plan *p, const LTFAT_COMPLEX cin[], const int mask[], LTFAT_REAL buffer[], LTFAT_COMPLEX c[])
 
int pghi_done (pghi_plan **p)
 

Detailed Description

Algorithm Description

The implementation follows paper [7].

Please note that the gollowing relation holds between \(\lambda\) used in the paper and \(\gamma\) used in this implementation

\[ \gamma = \lambda L, \]

where \(L\) is the transform length.

Function Documentation

int pghi ( const LTFAT_REAL  s[],
double  gamma,
ltfat_int  L,
ltfat_int  W,
ltfat_int  a,
ltfat_int  M,
LTFAT_COMPLEX  c[] 
)

Reconstruct complex coefficients from the magnitude using PGHI algorithm

M2 = M/2 + 1, N = L/a

Parameters
[in]sTarget magnitude, size M2 x N x W
[in]gammaWindow specific constant
[in]LSignal length
[in]WNumber of channels
[in]aHop factor
[in]MNumber of frequency channels (FFT length)
[out]cReconstructed coefficients, size M2 x N x W

Versions

phaseret_pghi_d(const double s[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, ltfat_complex_d c[]);

phaseret_pghi_s(const double s[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, ltfat_complex_s c[]);

Returns
Status code Description
LTFATERR_SUCCESS Indicates no error
LTFATERR_NULLPOINTER Indicates that at least one of the following was NULL: c, s
LTFATERR_NOTPOSARG At least one of the followig was not positive: L, W, a
LTFATERR_BADARG gamma was not positive or it was NAN.
LTFATERR_NOMEM Indicates that heap allocation failed
See also
firwin2gamma
int pghi_done ( pghi_plan **  p)

Destroy PGHI plan

Parameters
[in]pPGHI plan

Versions

phaseret_pghi_done_d(phaseret_pghi_plan_d** p);

phaseret_pghi_done_s(phaseret_pghi_plan_s** p);

Returns
Status code Description
LTFATERR_SUCCESS Indicates no error
LTFATERR_NULLPOINTER p was NULL
int pghi_execute ( pghi_plan *  p,
const LTFAT_REAL  s[],
LTFAT_COMPLEX  c[] 
)

Execute PGHI plan

M2 = M/2 + 1, N = L/a

Parameters
[in]pPGHI plan
[in]sTarget magnitude of coefficients, size M2 x N X W
[out]cOutput coefficients with reconstructed phase, size M2 x N X W

Versions

phaseret_pghi_execute_d(phaseret_pghi_plan_d* p, const double s[], ltfat_complex_d c[]);

phaseret_pghi_execute_s(phaseret_pghi_plan_s* p, const float s[], ltfat_complex_s c[]);

Returns
Status code Description
LTFATERR_SUCCESS Indicates no error
LTFATERR_NULLPOINTER Indicates that at least one of the following was NULL: p, c, s
int pghi_execute_withmask ( pghi_plan *  p,
const LTFAT_COMPLEX  cin[],
const int  mask[],
LTFAT_REAL  buffer[],
LTFAT_COMPLEX  c[] 
)

Execute PGHI plan with respect to mask

M2 = M/2 + 1, N = L/a

Nonzero values in mask represent known coefficient in

Parameters
[in]pPGHI plan
[in]cinCoefficients with initial phase, size M2 x N X W
[in]maskMask used to select coefficients with known phase, size M2 x N X W
[in]bufferWork buffer, size M2 x N. Internal heap allocation occurs if it is NULL
[out]coutOutput coefficients with reconstructed phase, size M2 x N X W

Versions

phaseret_pghi_execute_withmask_d(phaseret_pghi_plan_d* p, const ltfat_complex_d cin[], const int mask[], double buffer[], ltfat_complex_d c[]);

phaseret_pghi_execute_withmask_s(phaseret_pghi_plan_s* p, const ltfat_complex_s cin[], const int mask[], double buffer[], ltfat_complex_s c[]);

Returns
Status code Description
LTFATERR_SUCCESS Indicates no error
LTFATERR_NULLPOINTER Indicates that at least one of the following was NULL: p, cin, mask, cout
LTFATERR_NOMEM Indicates that heap allocation failed
int pghi_init ( double  gamma,
ltfat_int  L,
ltfat_int  W,
ltfat_int  a,
ltfat_int  M,
double  tol1,
double  tol2,
pghi_plan **  p 
)

Initialize PGHI plan

M2 = M/2 + 1, N = L/a

Parameters
[in]gammaWindow specific constant
[in]LSignal length
[in]WNumber of channels
[in]aHop factor
[in]MNumber of frequency channels (FFT length)
[in]tol1Relative tolerance for the first pass, must be in range [0-1]
[in]tol2Relative tolernace for the second pass, must be in range [0-1] and lower or equal to tol1. If tol2 is NAN or it is equal to tol1, only the first pass will be done.
[out]pPGHI plan

Versions

phaseret_pghi_init_d(double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, double tol1, double tol2, phaseret_pghi_plan_d** p);

phaseret_pghi_init_s(double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, double tol1, double tol2, phaseret_pghi_plan_s** p);

Returns
Status code Description
LTFATERR_SUCCESS Indicates no error
LTFATERR_NULLPOINTER p was NULL.
LTFATERR_NOTPOSARG At least one of the followig was not positive: L, W, a
LTFATERR_BADARG gamma was not positive
LTFATERR_NOTINRANGE tol1 and tol2 were not in range [0-1] or tol1 < tol2
LTFATERR_NOMEM Indicates that heap allocation failed
See also
firwin2gamma
int pghi_withmask ( const LTFAT_COMPLEX  cin[],
const int  mask[],
double  gamma,
ltfat_int  L,
ltfat_int  W,
ltfat_int  a,
ltfat_int  M,
LTFAT_COMPLEX  c[] 
)

Reconstruct complex coefficients from the magnitude using PGHI algorithm ... using some known coefficients.

M2 = M/2 + 1, N = L/a

Parameters
[in]cinCoefficients with initial phase, size M2 x N X W
[in]maskMask used to select coefficients with known phase, size M2 x N X W
[in]gammaWindow specific constant
[in]LSignal length
[in]WNumber of signal channels
[in]aHop factor
[in]MNumber of frequency channels (FFT length)
[out]cReconstructed coefficients, size M2 x N x W

Versions

phaseret_pghi_withmask_d(const ltfat_complex_d s[], const int mask[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, ltfat_complex_d c[]);

phaseret_pghi_withmask_s(const ltfat_complex_s s[], const int mask[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, ltfat_complex_s c[]);

Returns
Status code Description
LTFATERR_SUCCESS Indicates no error
LTFATERR_NULLPOINTER Indicates that at least one of the following was NULL: cin, c, mask
LTFATERR_NOTPOSARG At least one of the followig was not positive: L, W, a
LTFATERR_BADARG gamma was not positive or it was NAN.
LTFATERR_NOMEM Indicates that heap allocation failed
See also
firwin2gamma