/* List of functions available:
   getDescription(MG)
   getOrder(MG)
   getProperties(MG)
   getCentralQuotient(MG)
   getCQ(MG)
   getBaseRing(MG)

******************************************************************************

  getDescription(GrpMat or List)
  Inputs:
  matGrp: Matrix Group or List of Matrix Groups particular to our listing

  Output:
  The Description of the Matrix Group";

******************************************************************************

  getBaseRing(GrpMat)
  Inputs:
  matGrp: Matrix Group given from previous function";
  
  Output:
  The Base Ring over which the Matrix Group is defined        

******************************************************************************/

// declare attributes
AddAttribute(GrpMat, "Description");
AddAttribute(GrpMat, "Field");
AddAttribute(GrpMat, "Family");
AddAttribute(GrpMat, "Properties");
AddAttribute(GrpMat, "CentralQuotient");
AddAttribute(GrpMat, "CQ");

forward getDescriptionQ;

getDescription:= procedure(MG)
	getDescriptionQ(MG, 0);
end procedure;

getOrder:= function(MG)
	// not implemented
end function;

getProperties:= function(MG)
	if (assigned MG`Properties) then
		return MG`Properties;
	else
		return "**No properties found**";
	end if;
end function;

getCentralQuotient:= function(MG)
	if (assigned MG`CentralQuotient) then
		return MG`CentralQuotient;
	else
		return "**Central Quotient not found**";
	end if;
end function;

getCQ:= function(MG)
	return getCentralQuotient(MG);
end function;

getRomanNumeral:= function(n)
	str:= '';
	lstSingle:= ["","i","ii","iii","iv","v","vi","vii","viii","ix"];
	lstTens:= ["","x","xx","xxx","xl","l","lx","lxx","lxxx","xc"];
	lstHundreds:= ["","c","cc","ccc","cd","d","dc","dcc","dccc","cm"];
	lstThousands:= ["","m","mm","mmm","mmmm","^v","^vm","^vmm","^vmmm","^mx"];

	str:=lstSingle[(n mod 10) + 1];

	if (n ge 10) then
		str:=lstTens[(Floor(n/10)+1) mod 10] cat str;
	end if;

	if (n ge 100) then
		str:=lstHundreds[(Floor(n/100)+1) mod 10] cat str;
	end if;
	
	if (n ge 1000) then
		str:= lstThousands[(Floor(n/1000)+1) mod 10] cat str;
	end if;

	return str;
end function;

getDescriptionQ:= function(MG, d)
	if (Category(MG) eq 'GrpMat') then
		if (assigned MG`Description) then
			return MG`Description;
		else
			return "**No Description Found**";
		end if;
	else
		if (Category(MG) eq 'SeqEnum') then
			if (IsEmpty(MG)) then
				return "<Empty>";
			else
				for i:=1 to #MG do
					if (d eq 0) then
						"(" cat IntegerToString(i) cat ")";	
						getDescriptionQ(MG[i] , 1);					
					else
						getRomanNumeral(i) cat ". " cat getDescriptionQ(MG[i] , 1);
					end if;					
					
				end for;
			end if;
		end if;
	end if;	

	return "--------------------";
end function;

getBaseRing:= function(MG)
	return MG`Field;
end function;