- stringstream output;
-
- output.precision(i);
- output << fixed << x;
-
- return output.str();
-}
-
-
-/***********************************************************************/
-
-inline void gobble(istream& f){
-
- char d;
- while(isspace(d=f.get())) {;}
- f.putback(d);
-
-}
-
-/***********************************************************************/
-
-inline float roundDist(float dist, int precision){
-
- return int(dist * precision + 0.5)/float(precision);
-
-}
-
-/***********************************************************************/
-
-inline int getNumNames(string names){
-
- int count = 0;
-
- if(names != ""){
- count = 1;
- for(int i=0;i<names.size();i++){
- if(names[i] == ','){
- count++;
- }
- }
- }
-
- return count;
-
-}
-
-/**************************************************************************************************/
-
-inline vector<vector<double> > binomial(int maxOrder){
-
- vector<vector<double> > binomial(maxOrder+1);
-
- for(int i=0;i<=maxOrder;i++){
- binomial[i].resize(maxOrder+1);
- binomial[i][0]=1;
- binomial[0][i]=0;
- }
- binomial[0][0]=1;
-
- binomial[1][0]=1;
- binomial[1][1]=1;
-
- for(int i=2;i<=maxOrder;i++){
- binomial[1][i]=0;
- }
-
- for(int i=2;i<=maxOrder;i++){
- for(int j=1;j<=maxOrder;j++){
- if(i==j){ binomial[i][j]=1; }
- if(j>i) { binomial[i][j]=0; }
- else { binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j]; }
- }
- }
-
- return binomial;
-}
-
-/***********************************************************************/
-
-inline string getRootName(string longName){
-
- string rootName = longName;
-
- if(longName.find_last_of(".") != longName.npos){
- int pos = longName.find_last_of('.')+1;
- rootName = longName.substr(0, pos);
- }
-
- return rootName;
-}
-/***********************************************************************/
-
-inline string getSimpleName(string longName){
-
- string simpleName = longName;
-
- if(longName.find_last_of("/") != longName.npos){
- int pos = longName.find_last_of('/')+1;
- simpleName = longName.substr(pos, longName.length());
- }
-
- return simpleName;
-}
-/***********************************************************************/
-
-inline int factorial(int num){
- int total = 1;
-
- for (int i = 1; i <= num; i++) {
- total *= i;
- }
-
- return total;
-}
-/**************************************************************************************************
-
-double min(double x, double y)
-{
- if(x<y){ return x; }
- else { return y; }
-}
-
-/***********************************************************************/
-
-inline string getPathName(string longName){
-
- string rootPathName = longName;
-
- if(longName.find_last_of('/') != longName.npos){
- int pos = longName.find_last_of('/')+1;
- rootPathName = longName.substr(0, pos);
- }
-
- return rootPathName;
-}
-
-/***********************************************************************/
-
-inline string getExtension(string longName){