import java.io.Serializable;





public class ABMatrix implements Serializable {

	/**

	 * for Serializable interface

	 */

	private static final long serialVersionUID = 5334532903567570727L;





	/**

	 * M is the number of rows and columns since we always have a square matrix

	 */

	public int M;

	

		

	/**

	 * This is the actual matrix that you must use

	 */

	public double[][] matrix;
	
	public String[] names;


	

	public ABMatrix()

	{

		matrix = null;

		M = 0;
		
		names = null;

	}

	

	/**

	 * This loads a previously saved matrix

	 * @param filename

	 */

	public ABMatrix(double[][] input, int m, String[] names) throws Exception

	{

		M = m;

		matrix = input;

		if (m!=names.length)

		{

			throw new Exception("The number of variables must match the size of the programs.");

		}

	}

	public int findname(char n, int neg)
	{
		
		String name;
		if(neg==1)
			name="n"+String.valueOf(n);
		else
			name=String.valueOf(n);

		int j=0;
		if(names[j]==null)
		{
			names[j]=name;
		}
		else
		{
		while(names[j]!=null)
		{
			if(names[j].equals(name))
				break;
			else
			{
				j++;
				if(names[j]==null)
				{
					names[j]=name;
					break;
				}
				
			}
		}
		}
		return j;
		
	}


	//TODO this is just a datastructure right now, you may wish to add methods

	//     to it such as merge and shortcut in the future. You could even determine

	//     satisifiablility here since this really represents the constraints.

	

}

