notSupportedMessage("modulo", this, rightArgument));
*/
// Get the corresponding element type for this matrix type,
// and try a scalar operation.
Type elementType = getElementType();
/*
// If this is a complex array, throw an error message as modulo
// can't be performed on it
if (elementType == BaseType.COMPLEX)
throw new IllegalActionException(
notSupportedMessage("modulo", this, rightArgument));
*/
int typeInfo = TypeLattice.compare(elementType, rightArgument);
if (typeInfo == CPO.SAME) {
Token result = _moduloElement(rightArgument);
return result;
} else if (typeInfo == CPO.HIGHER) {
Token convertedArgument = elementType.convert(rightArgument);
try {
Token result = _moduloElement(convertedArgument);
return result;
} catch (IllegalActionException ex) {
// If the type-specific operation fails, then create a better
// error message that has the types of the arguments that were
// passed in.
throw new IllegalActionException(null, ex, notSupportedMessage(
"modulo", this, rightArgument));
}
}
// If we get here, then either our element type is lower than
// the rightArgument or incomparable to it.
typeInfo = TypeLattice.compare(getType(), rightArgument);
if (typeInfo == CPO.SAME) {
// Dividing a matrix by a matrix. If the divisor has
// only one element, then this is OK.
return _moduloElement(rightArgument);
} else if (typeInfo == CPO.HIGHER) {
// Dividing a matrix by something that can be converted
// to a matrix, which if it has one element is OK.
Token convertedArgument = getType().convert(rightArgument);
try {
return _moduloElement(convertedArgument);
} catch (IllegalActionException ex) {
// If the type-specific operation fails, then create a better
// error message that has the types of the arguments that were
// passed in.
throw new IllegalActionException(null, ex, notSupportedMessage(
"modulo", this, rightArgument));
}
} else if (typeInfo == CPO.INCOMPARABLE) {
// Items being added are incomparable.
// However, division may still be possible because
// the LUB of the types might support it. E.g., [double]/complex,
// where the LUB is [complex].
Type lubType = (Type) TypeLattice.lattice().leastUpperBound(
getType(), rightArgument.getType());
// If the LUB is a new type, try it.
if (!lubType.equals(getType())) {
Token lub = lubType.convert(this);
// Caution: convert() might return this again, e.g.
// if lubType is general. Only proceed if the conversion
// returned a new type.
if (!(lub.getType().equals(getType()))) {