Beispiel #1
0
/**	This function returns the Z error of the given FROG traces.
 *
 *	\param Esig the current signal field.
 *	\param Esigp the last signal field.
 *
 *	\returns The Z error between Esigp and Esig.
 */
TReal Zerr(const TmexArray &Esig, const TmexArray &Esigp)
{
	TReal Z = 0.0;
	
	for (size_t i = 0; i < Esig.size(); ++i)
		Z += norm(Esig[i] - Esigp[i]);
		
	return (Z/Esig.size());
} 
Beispiel #2
0
/**	Calculates the Y error.
 *
 *	\param	Esig	the FROG signal field.
 *	\param	Ew		the electric field.
 *	\returns	the Y error.
 */
TReal Zerr2_wW(const TmexArray &Esig, const TmexArray Ew)
{
	TReal Z = 0.0;
	for(size_t w = 0; w<Esig.size_M(); ++w)
		for(size_t W = 0; W<Esig.size_N(); ++W) {
			int wp = w - (W - Esig.size_N()/2);
			if (wp >= 0 && wp < static_cast<int>(Ew.size())) {
				Z += std::norm((Ew(W) * Ew(wp)) - Esig(w,W));
			}
		}
	return Z/Esig.size();
}
Beispiel #3
0
/**	\brief Calculates Esig.
 *
 *	Calculates Esig(t,tau) given the probe and gate pulses.
 *
 *	\param Esig	the array to store the calculation in.
 *	\param P	the probe pulse.
 *	\param G	the gate pulse.
 */
void CalcEsig(TmexArray &Esig, const TmexArray &P, const TmexArray &G)
{
	for(size_t t = 0; t<Esig.size_M(); ++t)
		for(size_t tau = 0; tau<Esig.size_N(); ++tau) {
			int tp = static_cast<int>(t - (tau - Esig.size_N()/2));
			if (tp >= 0 && tp < static_cast<int>(G.size())) {
				Esig(t,tau) = P(t) * G(tp);
			}
		}
}
Beispiel #4
0
/**	Calculates the gradient of the Z error for THG.
 *
 *	\param Esigp	the magnitude replaced Esig(t,tau).
 *	\param Et		the current best guess.
 *	\param dZ		the gradient. 
 */
void dZdE_thg(const TmexArray &Esigp, const TmexArray &Et, TmexArray &dZ)
{
	int M = Esigp.size_M();	// The number of time points.
	int N = Esigp.size_N();	// The number of delay points.
	TReal sz = Esigp.size();
	
	for(int t0 = 0; t0 < M; ++t0)
	{
		TCmplx T(0.0,0.0);
		for(int tau = 0; tau < N; ++tau) {
			int tp = t0 - (tau - N/2);
			if (tp >= 0 && tp < M) {
				T += (Et[t0] * Et[tp] * Et[tp] - Esigp(t0,tau)) * conj(Et[tp] * Et[tp]);
			}
			tp = t0 + (tau - N/2);
			if (tp >= 0 && tp < M) {
				T += 2.0 * conj(Et[tp] * Et[t0]) * (Et[tp] * Et[t0] * Et[t0] - Esigp(tp,tau));
			}
		}
		dZ[t0] = T/sz;
	}
}