public static final Ptg calculateFunction( Ptg[] ptgs ) throws FunctionNotSupportedException, CalculationException
	{
		// the function identifier
		Ptg funk = ptgs[0];
		int funkId = 0;   //what function are we calling?

		// if ptgs are missing parent_recs, populate from funk
		XLSRecord bpar = funk.getParentRec();
		if( bpar != null )
		{
			for( Ptg ptg : ptgs )
			{
				if( ptg.getParentRec() == null )
				{
					ptg.setParentRec( bpar );
				}
			}
		}

		int oplen = ptgs.length - 1;
		// the ptgs acted upon by the function
		Ptg[] operands = new Ptg[oplen];
		System.arraycopy( ptgs, 1, operands, 0, oplen );
		if( (funk.getOpcode() == 0x21) || (funk.getOpcode() == 0x41) || (funk.getOpcode() == 0x61) )
		{  // ptgfunc
			return calculatePtgFunc( funk, funkId, operands );
		}
		if( (funk.getOpcode() == 0x22) || (funk.getOpcode() == 0x42) || (funk.getOpcode() == 0x62) )
		{ // ptgfuncvar
			return calculatePtgFuncVar( funk, funkId, operands );
		}
		return null;
	}