#include "polymake/client.h"
#include "polymake/Matrix.h"
#include "polymake/Array.h"
#include "polymake/Rational.h"

namespace polymake { namespace common {

    //FIXME: add const Array<std::string>& row_labels 
   template <typename Scalar>
   void print_constraints_sub(const Matrix<Scalar>& M, const int are_eqs, const Array<std::string>& coord_labels){

    for(int i=0;i<M.rows();++i){
      cout <<  i << ":";
      bool first=true;
      for(int j=1;j<M.cols();++j){
	Scalar cur_coeff=M.row(i)[j];
	//Rational cur_coeff=M.row(i)[j];
	if(cur_coeff!=0){

	  if(cur_coeff>0 && (!first)){
	    cout << "+";
	  }
	  
	  if(cur_coeff==-1){
	    cout << "-";	  
	  } else {
	    if(cur_coeff!=1){
	      cout << std::setprecision(16) << cur_coeff;	    
	    }
	  }
	  cout << coord_labels[j-1];
	  first=false;
	}
      }
      if(are_eqs){
	cout << "=";
      } else {
	cout << ">=";
      }	
      Scalar neg_rhs=M.row(i)[0];
      cout << std::setprecision(16) << (neg_rhs!=0 ? -neg_rhs : neg_rhs) << '\n';      
    }
    cout << endl;
  }
  
}}
