params.cpp 2.7 KB
Newer Older
1 2
#include "params.h"

3 4 5 6 7 8 9 10 11 12
struct param_info
{
	param_info(std::string n, int d, std::string i) : 
		name(n), dimension(d), info(i) { };

	std::string name;
	int dimension;
	std::string info;
};

13
// Assing the input params map
14 15 16 17 18 19 20
static const std::map<params::input, const param_info> input_map = {
	{params::COS_TH,                {"COS_TH",                1, "Cosine of the Half angle"}},
	{params::RUSIN_TH_TD,           {"RUSIN_TH_TD",           2, "Radialy symmetric Half angle parametrization"}},
	{params::RUSIN_TH_TD_PD,        {"RUSIN_TH_TD_PD",        3, "Isotropic Half angle parametrization"}},
	{params::RUSIN_TH_PH_TD_PD,     {"RUSIN_TH_PH_TD_PD",     4, "Complete Half angle parametrization"}},
	{params::SPHERICAL_TL_PL_TV_PV, {"SPHERICAL_TL_PL_TV_PV", 4, "Complete classical parametrization"}},
	{params::CARTESIAN,             {"CARTESIAN",             6, "Complete vector parametrization"}}
21
};
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125

params::input params::parse_input(const std::string& txt)
{
	for(std::map<params::input, const param_info>::const_iterator it=input_map.begin(); it != input_map.end(); ++it)
	{
		if(txt.compare(it->second.name) == 0)
		{
			return it->first;
		}
	}

	return params::UNKNOWN_INPUT;

	/*
		if(txt == std::string("COS_TH"))
		{
		return params::COS_TH;
		}
		else if(txt == std::string("RUSIN_TH_TD"))
		{
		return params::RUSIN_TH_TD;
		}
		else if(txt == std::string("RUSIN_TH_PH_TD_PD"))
		{
		return params::RUSIN_TH_PH_TD_PD;
		}
		else
		{
		return params::UNKNOWN_INPUT;
		}
		*/
}
		  
std::string params::get_name(const params::input param)
{
	std::map<params::input, const param_info>::const_iterator it = input_map.find(param);
	if(it != input_map.end())
	{
		return it->second.name;
	}

	return std::string();
}

int  params::dimension(params::input t)
{
	std::map<params::input, const param_info>::const_iterator it = input_map.find(t);
	if(it != input_map.end())
	{
		return it->second.dimension;
	}
	else
	{
		return -1;
	}
	/*
		switch(t)
		{
	// 1D Parametrizations
	case params::COS_TH:
	return 1;
	break;

	// 2D Parametrizations
	case params::ISOTROPIC_TD_PD:
	case params::RUSIN_TH_TD:
	case params::ROMEIRO_TH_TD:
	case params::COS_TH_TD:
	return 2;
	break;

	// 3D Parametrization
	case params::RUSIN_TH_PH_TD:
	case params::RUSIN_TH_TD_PD:
	case params::ISOTROPIC_TV_TL_DPHI:
	return 3;
	break;

	// 4D Parametrization
	case params::RUSIN_TH_PH_TD_PD:
	case params::SPHERICAL_TL_PL_TV_PV:
	return 4;
	break;

	// 6D Parametrization
	case params::CARTESIAN:
	return 6;
	break;

	default:
	assert(false);
	return -1;
	break;
	}
	*/
}

void params::print_input_params()
{
	for(std::map<params::input, const param_info>::const_iterator it=input_map.begin(); it != input_map.end(); ++it)
	{
		std::cout << it->second.name << std::endl;
	}
}