datatype_exception datatype_exception::build(std::string message, nd4j::DataType expected, nd4j::DataType actualX, nd4j::DataType actualY) {
     auto exp = DataTypeUtils::asString(expected);
     auto actX = DataTypeUtils::asString(actualX);
     auto actY = DataTypeUtils::asString(actualY);
     message += "; Expected: [" + exp + "]; Actual: [" + actX + ", " + actY + "]";
     return datatype_exception(message);
 }
void percival_unit_ADC_decode_check(
		const percival_frame<unsigned short int> & input,
		percival_frame<unsigned short int> & Coarse,
		percival_frame<unsigned short int> & Fine,
		percival_frame<unsigned short int> & Gain)
{
	if(input.width != Coarse.width || input.height != Coarse.height)
		throw dataspace_exception("In percival_unit_ADC_decode(_pf): coarse_frame and input frame dimensions mismatch.");
	if(input.width != Fine.width || input.height != Fine.height)
		throw dataspace_exception("In percival_unit_ADC_decode(_pf): fain_frame and input frame dimensions mismatch.");
	if(input.width != Gain.width || input.height != Gain.height)
		throw dataspace_exception("In percival_unit_ADC_decode(_pf): gain_frame and input frame dimensions mismatch.");

	if(Coarse.data == Fine.data)
		throw datatype_exception("In percival_unit_ADC_decode(_pf): Coarse and Fine frame pointers are identical.");
	if(Coarse.data == Gain.data)
		throw datatype_exception("In percival_unit_ADC_decode(_pf): Coarse and Gain frame pointers are identical.");
	if(Gain.data == Fine.data)
		throw datatype_exception("In percival_unit_ADC_decode(_pf): Gain and Fine frame pointers are identical.");
}
 datatype_exception datatype_exception::build(std::string message, nd4j::DataType actual) {
     auto act = DataTypeUtils::asString(actual);
     message += "; Actual: [" + act + "]";
     return datatype_exception(message);
 }