/*!\file ControlConstrainx
 * \brief constrain optimization parameters during inverse method
 */

#include "./ControlConstrainx.h"

#undef __FUNCT__ 
#define __FUNCT__ "ControlConstrainx"

#include "../shared/shared.h"
#include "../include/macros.h"
#include "../toolkits/toolkits.h"
#include "../EnumDefinitions/EnumDefinitions.h"

void ControlConstrainx( double* p_g, int gsize, double mincontrolconstraint, double maxcontrolconstraint,char* control_type){

	int i;
	
	if(isnan(mincontrolconstraint) & isnan(maxcontrolconstraint)){
		/*do nothing*/
	}
	else{
		for(i=0;i<gsize;i=i+2){

			if(!isnan(mincontrolconstraint)){
				if (p_g[i]<mincontrolconstraint)p_g[i]=mincontrolconstraint;
			}

			if(!isnan(maxcontrolconstraint)){
				if (p_g[i]>maxcontrolconstraint)p_g[i]=maxcontrolconstraint;
			}
		}
	}
		
}
