private void extractMaxs() { int j = 0; double FRTCM_MAX = 0; double TCMD_MAX = 0; int INDEX_FRTCM_MAX = 0; int INDEX_TCMD_MAX = 0; Complex[] u_AUX_OS_FRTCM = new Complex[0]; Complex[] u_AUX_OS_TCMD = new Complex[0]; List <Double> AUX_OS_TCMD = new List <double>(); List <Double> AUX_OS_FRTCM = new List <double>(); for (int i = 0; i < OS_FREQUENCY_LIST.Count; i++) { if (OS_FREQUENCY_LIST[i] == FREQUENCIES_LIST[j]) { AUX_OS_TCMD.Add(OS_TCMD_LIST[i]); AUX_OS_FRTCM.Add(OS_FRTCM_LIST[i]); } else { int n = AUX_OS_FRTCM.Count; Complex[] uT_AUX_OS_FRTCM = new Complex[n]; Complex[] uT_AUX_OS_TCMD = new Complex[n]; for (int k = 0; k < n; k++) { uT_AUX_OS_FRTCM[k] = new Complex(AUX_OS_FRTCM[k], 0); uT_AUX_OS_TCMD[k] = new Complex(AUX_OS_TCMD[k], 0); } Fourier.Forward(uT_AUX_OS_FRTCM, FourierOptions.NoScaling); Fourier.Forward(uT_AUX_OS_TCMD, FourierOptions.NoScaling); u_AUX_OS_FRTCM = new Complex[n]; u_AUX_OS_TCMD = new Complex[n]; for (int k = 0; k < n / 2; k++) { u_AUX_OS_FRTCM[k] = 2.0 / n * uT_AUX_OS_FRTCM[k]; u_AUX_OS_TCMD[k] = 2.0 / n * uT_AUX_OS_TCMD[k]; } double[] MAG_u_AUX_OS_FRTCM = new double[n]; double[] MAG_u_AUX_OS_TCMD = new double[n]; for (int k = 0; k < n / 2; k++) { MAG_u_AUX_OS_FRTCM[k] = u_AUX_OS_FRTCM[k].Magnitude; MAG_u_AUX_OS_TCMD[k] = u_AUX_OS_TCMD[k].Magnitude; } FRTCM_MAX = MAG_u_AUX_OS_FRTCM.Max(); TCMD_MAX = MAG_u_AUX_OS_TCMD.Max(); INDEX_FRTCM_MAX = MAG_u_AUX_OS_FRTCM.ToList().IndexOf(FRTCM_MAX); INDEX_TCMD_MAX = MAG_u_AUX_OS_TCMD.ToList().IndexOf(TCMD_MAX); MAX_OS_FRTCM_LIST.Add(u_AUX_OS_FRTCM[INDEX_FRTCM_MAX]); MAX_OS_TCMD_LIST.Add(u_AUX_OS_TCMD[INDEX_TCMD_MAX]); AUX_OS_TCMD.Clear(); AUX_OS_FRTCM.Clear(); AUX_OS_TCMD.Add(OS_TCMD_LIST[i]); AUX_OS_FRTCM.Add(OS_FRTCM_LIST[i]); j++; } } }
private void extractMaxs() { int j = 0; double FRTCM_MAX = 0; double TCMD_MAX = 0; int INDEX_FRTCM_MAX = 0; int INDEX_TCMD_MAX = 0; List <Complex> u_AUX_OS_FRTCM = new List <Complex>(); List <Complex> u_AUX_OS_TCMD = new List <Complex>(); List <Double> AUX_OS_TCMD = new List <double>(); List <Double> AUX_OS_FRTCM = new List <double>(); for (int i = 0; i < OS_FREQUENCY_LIST.Count; i++) { if (OS_FREQUENCY_LIST[i] == FREQUENCIES_LIST[j]) { AUX_OS_TCMD.Add(OS_TCMD_LIST[i]); AUX_OS_FRTCM.Add(OS_FRTCM_LIST[i]); } else { int n = AUX_OS_FRTCM.Count; Double[] uT_AUX_OS_FRTCM_REAL = new Double[n]; Double[] uT_AUX_OS_FRTCM_IMAG = new Double[n]; Double[] uT_AUX_OS_TCMD_REAL = new Double[n]; Double[] uT_AUX_OS_TCMD_IMAG = new Double[n]; for (int k = 0; k < n; k++) { uT_AUX_OS_FRTCM_REAL[k] = AUX_OS_FRTCM[k]; uT_AUX_OS_FRTCM_IMAG[k] = 0; uT_AUX_OS_TCMD_REAL[k] = AUX_OS_TCMD[k]; uT_AUX_OS_TCMD_IMAG[k] = 0; } Fourier.Forward(uT_AUX_OS_FRTCM_REAL, uT_AUX_OS_FRTCM_IMAG, FourierOptions.NoScaling); Fourier.Forward(uT_AUX_OS_TCMD_REAL, uT_AUX_OS_TCMD_IMAG, FourierOptions.NoScaling); for (int k = 0; k < n / 2; k++) { Complex AUX = new Complex(2.0 / n * uT_AUX_OS_FRTCM_REAL[k], 2.0 / n * uT_AUX_OS_FRTCM_IMAG[k]); u_AUX_OS_FRTCM.Add(AUX); AUX = new Complex(2.0 / n * uT_AUX_OS_TCMD_REAL[k], 2.0 / n * uT_AUX_OS_TCMD_IMAG[k]); u_AUX_OS_TCMD.Add(AUX); } double[] MAG_u_AUX_OS_FRTCM = new double[n]; double[] MAG_u_AUX_OS_TCMD = new double[n]; for (int k = 0; k < n / 2; k++) { MAG_u_AUX_OS_FRTCM[k] = u_AUX_OS_FRTCM[k].Mag; MAG_u_AUX_OS_TCMD[k] = u_AUX_OS_TCMD[k].Mag; } FRTCM_MAX = MAG_u_AUX_OS_FRTCM.Max(); TCMD_MAX = MAG_u_AUX_OS_TCMD.Max(); INDEX_FRTCM_MAX = MAG_u_AUX_OS_FRTCM.ToList().IndexOf(FRTCM_MAX); INDEX_TCMD_MAX = MAG_u_AUX_OS_TCMD.ToList().IndexOf(TCMD_MAX); MAX_OS_FRTCM_LIST.Add(u_AUX_OS_FRTCM[INDEX_FRTCM_MAX]); MAX_OS_TCMD_LIST.Add(u_AUX_OS_TCMD[INDEX_TCMD_MAX]); AUX_OS_TCMD.Clear(); AUX_OS_FRTCM.Clear(); u_AUX_OS_FRTCM.Clear(); u_AUX_OS_TCMD.Clear(); AUX_OS_TCMD.Add(OS_TCMD_LIST[i]); AUX_OS_FRTCM.Add(OS_FRTCM_LIST[i]); j++; } } }