#include "matrix.h"

IntegerMatrix rowsToIntegerMatrix(IntegerVectorList const &rows, int width)
{
  int height=rows.size();
  int a=-1;
  for(IntegerVectorList::const_iterator i=rows.begin();i!=rows.end();i++)
    {
      if(a==-1)
	a=i->size();
      else
	{
	  assert(a==i->size());
	}
    }
  if(a==-1)
    {
      assert(width!=-1);
    }
  else
    {
      if(width!=-1)
	{
	  assert(width==a);
	}
    }
  if(width==-1)width=a;
  IntegerMatrix ret(height,width);

  int j=0;
  for(IntegerVectorList::const_iterator i=rows.begin();i!=rows.end();i++)
    ret[j++]=*i;

  return ret;
}
