athena_signal/kernels/dios_ssp_gsc/dios_ssp_gsc_rmNPsdOsMs.c
int dios_ssp_gsc_rmnpsdosms_findminimum(objCNPsdOsMs *npsdosms1)
{
	int u, k;

	for (k = 0; k < npsdosms1->m_L; k++)
	{
		npsdosms1->m_k_mod[k] = 0;
		if (npsdosms1->m_P[k]*npsdosms1->m_Bmin[k]*npsdosms1->m_Bc < npsdosms1->m_actmin[k])
		{
			npsdosms1->m_actmin[k] = npsdosms1->m_P[k] * npsdosms1->m_Bmin[k] * npsdosms1->m_Bc;
			npsdosms1->m_actmin_sub[k] = npsdosms1->m_P[k] * npsdosms1->m_Bmin_sub[k] * npsdosms1->m_Bc;
			npsdosms1->m_k_mod[k] = 1;
		}
	}
	if (npsdosms1->m_subwc == npsdosms1->m_V)
	{
		npsdosms1->m_subwc = 1;
		for (k = 0; k < npsdosms1->m_L; k++)
		{
			if (npsdosms1->m_k_mod[k])
			{
				npsdosms1->m_lmin_flag[k] = 0;
			}
			/* store actmin */
			npsdosms1->m_store[k][npsdosms1->m_Ucount - 1] = npsdosms1->m_actmin[k];
			/* find minimum of last U stored actmin(k) */
			npsdosms1->m_Pmin_u[k] = npsdosms1->m_store[k][0];
			for (u = 1; u < npsdosms1->m_U; u++)
            {
				npsdosms1->m_Pmin_u[k] = npsdosms1->m_store[k][u] < npsdosms1->m_Pmin_u[k]?npsdosms1->m_store[k][u] : npsdosms1->m_Pmin_u[k];
            }
			
			if ((npsdosms1->m_lmin_flag[k]) && (npsdosms1->m_actmin_sub[k] < npsdosms1->m_noise_slope_max * npsdosms1->m_Pmin_u[k]) 
                    && (npsdosms1->m_actmin_sub[k] > npsdosms1->m_Pmin_u[k]))
			{
				npsdosms1->m_Pmin_u[k] = npsdosms1->m_actmin_sub[k];
				/* replace all previous stored values of actmin(k) by actmin_sub(k) */
				for (u = 0; u < npsdosms1->m_U; u++)
                {
					npsdosms1->m_store[k][u] = npsdosms1->m_actmin_sub[k];
                }
			}	
			npsdosms1->m_lmin_flag[k] = 0;
		}

		/* set actmin(k) and actmin_sub(k) to their maximum values */
		for (k = 0; k < npsdosms1->m_L; k++)
		{
			npsdosms1->m_actmin[k] = actmin_max;
			npsdosms1->m_actmin_sub[k] = actmin_max;
		}
		
		if (npsdosms1->m_Ucount == npsdosms1->m_U)
        {
			npsdosms1->m_Ucount = 1;
        }
		else
        {
			npsdosms1->m_Ucount = npsdosms1->m_Ucount + 1;
        }
	}
	else 
	{
		for (k = 0; k < npsdosms1->m_L; k++)
		{
			if(npsdosms1->m_k_mod[k])
			{
				npsdosms1->m_lmin_flag[k] = 1;
			}
			npsdosms1->m_Pmin_u[k] = npsdosms1->m_actmin_sub[k] < npsdosms1->m_Pmin_u[k]?npsdosms1->m_actmin_sub[k] : npsdosms1->m_Pmin_u[k];
			npsdosms1->m_N[k] = npsdosms1->m_Pmin_u[k];
		}
		npsdosms1->m_subwc++;
	}

	return 0;
}
/* search of the minimum of the smoothed PSD P and 
 * update of the estimation of the noise N */
search of the minimum of the smoothed PSD P and
update of the estimation of the noise N
search of the minimum of the smoothed PSD P and update of the estimation of the noise N
int dios_ssp_gsc_rmnpsdosms_findminimum(objCNPsdOsMs *npsdosms1)
{
	int u, k;
	for (k = 0; k < npsdosms1->m_L; k++)
	{
		npsdosms1->m_k_mod[k] = 0;
		if (npsdosms1->m_P[k]*npsdosms1->m_Bmin[k]*npsdosms1->m_Bc < npsdosms1->m_actmin[k])
		{
			npsdosms1->m_actmin[k] = npsdosms1->m_P[k] * npsdosms1->m_Bmin[k] * npsdosms1->m_Bc;
			npsdosms1->m_actmin_sub[k] = npsdosms1->m_P[k] * npsdosms1->m_Bmin_sub[k] * npsdosms1->m_Bc;
			npsdosms1->m_k_mod[k] = 1;
		}
	}
	if (npsdosms1->m_subwc == npsdosms1->m_V)
	{
		npsdosms1->m_subwc = 1;
		for (k = 0; k < npsdosms1->m_L; k++)
		{
			if (npsdosms1->m_k_mod[k])
			{
				npsdosms1->m_lmin_flag[k] = 0;
			}
			npsdosms1->m_store[k][npsdosms1->m_Ucount - 1] = npsdosms1->m_actmin[k];
			npsdosms1->m_Pmin_u[k] = npsdosms1->m_store[k][0];
			for (u = 1; u < npsdosms1->m_U; u++)
            {
				npsdosms1->m_Pmin_u[k] = npsdosms1->m_store[k][u] < npsdosms1->m_Pmin_u[k]?npsdosms1->m_store[k][u] : npsdosms1->m_Pmin_u[k];
            }
			if ((npsdosms1->m_lmin_flag[k]) && (npsdosms1->m_actmin_sub[k] < npsdosms1->m_noise_slope_max * npsdosms1->m_Pmin_u[k]) 
                    && (npsdosms1->m_actmin_sub[k] > npsdosms1->m_Pmin_u[k]))
			{
				npsdosms1->m_Pmin_u[k] = npsdosms1->m_actmin_sub[k];
				for (u = 0; u < npsdosms1->m_U; u++)
                {
					npsdosms1->m_store[k][u] = npsdosms1->m_actmin_sub[k];
                }
			}	
			npsdosms1->m_lmin_flag[k] = 0;
		}
		for (k = 0; k < npsdosms1->m_L; k++)
		{
			npsdosms1->m_actmin[k] = actmin_max;
			npsdosms1->m_actmin_sub[k] = actmin_max;
		}
		if (npsdosms1->m_Ucount == npsdosms1->m_U)
        {
			npsdosms1->m_Ucount = 1;
        }
		else
        {
			npsdosms1->m_Ucount = npsdosms1->m_Ucount + 1;
        }
	}
	else 
	{
		for (k = 0; k < npsdosms1->m_L; k++)
		{
			if(npsdosms1->m_k_mod[k])
			{
				npsdosms1->m_lmin_flag[k] = 1;
			}
			npsdosms1->m_Pmin_u[k] = npsdosms1->m_actmin_sub[k] < npsdosms1->m_Pmin_u[k]?npsdosms1->m_actmin_sub[k] : npsdosms1->m_Pmin_u[k];
			npsdosms1->m_N[k] = npsdosms1->m_Pmin_u[k];
		}
		npsdosms1->m_subwc++;
	}
	return 0;
}
int dios_ssp_gsc_rmnpsdosms_findminimum ( objCNPsdOsMs * npsdosms1 ) { int u , k ; for ( k = 0 ; k < npsdosms1 -> m_L ; k ++ ) { npsdosms1 -> m_k_mod [ k ] = 0 ; if ( npsdosms1 -> m_P [ k ] * npsdosms1 -> m_Bmin [ k ] * npsdosms1 -> m_Bc < npsdosms1 -> m_actmin [ k ] ) { npsdosms1 -> m_actmin [ k ] = npsdosms1 -> m_P [ k ] * npsdosms1 -> m_Bmin [ k ] * npsdosms1 -> m_Bc ; npsdosms1 -> m_actmin_sub [ k ] = npsdosms1 -> m_P [ k ] * npsdosms1 -> m_Bmin_sub [ k ] * npsdosms1 -> m_Bc ; npsdosms1 -> m_k_mod [ k ] = 1 ; } } if ( npsdosms1 -> m_subwc == npsdosms1 -> m_V ) { npsdosms1 -> m_subwc = 1 ; for ( k = 0 ; k < npsdosms1 -> m_L ; k ++ ) { if ( npsdosms1 -> m_k_mod [ k ] ) { npsdosms1 -> m_lmin_flag [ k ] = 0 ; } npsdosms1 -> m_store [ k ] [ npsdosms1 -> m_Ucount - 1 ] = npsdosms1 -> m_actmin [ k ] ; npsdosms1 -> m_Pmin_u [ k ] = npsdosms1 -> m_store [ k ] [ 0 ] ; for ( u = 1 ; u < npsdosms1 -> m_U ; u ++ ) { npsdosms1 -> m_Pmin_u [ k ] = npsdosms1 -> m_store [ k ] [ u ] < npsdosms1 -> m_Pmin_u [ k ] ? npsdosms1 -> m_store [ k ] [ u ] : npsdosms1 -> m_Pmin_u [ k ] ; } if ( ( npsdosms1 -> m_lmin_flag [ k ] ) && ( npsdosms1 -> m_actmin_sub [ k ] < npsdosms1 -> m_noise_slope_max * npsdosms1 -> m_Pmin_u [ k ] ) && ( npsdosms1 -> m_actmin_sub [ k ] > npsdosms1 -> m_Pmin_u [ k ] ) ) { npsdosms1 -> m_Pmin_u [ k ] = npsdosms1 -> m_actmin_sub [ k ] ; for ( u = 0 ; u < npsdosms1 -> m_U ; u ++ ) { npsdosms1 -> m_store [ k ] [ u ] = npsdosms1 -> m_actmin_sub [ k ] ; } } npsdosms1 -> m_lmin_flag [ k ] = 0 ; } for ( k = 0 ; k < npsdosms1 -> m_L ; k ++ ) { npsdosms1 -> m_actmin [ k ] = actmin_max ; npsdosms1 -> m_actmin_sub [ k ] = actmin_max ; } if ( npsdosms1 -> m_Ucount == npsdosms1 -> m_U ) { npsdosms1 -> m_Ucount = 1 ; } else { npsdosms1 -> m_Ucount = npsdosms1 -> m_Ucount + 1 ; } } else { for ( k = 0 ; k < npsdosms1 -> m_L ; k ++ ) { if ( npsdosms1 -> m_k_mod [ k ] ) { npsdosms1 -> m_lmin_flag [ k ] = 1 ; } npsdosms1 -> m_Pmin_u [ k ] = npsdosms1 -> m_actmin_sub [ k ] < npsdosms1 -> m_Pmin_u [ k ] ? npsdosms1 -> m_actmin_sub [ k ] : npsdosms1 -> m_Pmin_u [ k ] ; npsdosms1 -> m_N [ k ] = npsdosms1 -> m_Pmin_u [ k ] ; } npsdosms1 -> m_subwc ++ ; } return 0 ; }
search of the minimum of the smoothed PSD P and
 update of the estimation of the noise N
search of the minimum of the smoothed PSD P and update of the estimation of the noise N
/* store actmin */ /* find minimum of last U stored actmin(k) */ /* replace all previous stored values of actmin(k) by actmin_sub(k) */ /* set actmin(k) and actmin_sub(k) to their maximum values */