DoubleMatrixToken a = (DoubleMatrixToken) A.getToken();
int n = a.getRowCount();
DoubleMatrixToken b = (DoubleMatrixToken) B.getToken();
if (b.getRowCount() != n) {
throw new IllegalActionException(this,
"The number of rows of the B matrix (" + b.getRowCount()
+ ") should be equal to "
+ "the number of rows of the A matrix (" + n + ").");
}
int m = b.getColumnCount();
if (input.getWidth() != m) {
throw new IllegalActionException(this,
"The number of columns of the B matrix ("
+ b.getColumnCount() + ") should be equal to "
+ "the width of the input port ("
+ input.getWidth() + ").");
}
DoubleMatrixToken c = (DoubleMatrixToken) C.getToken();
if (c.getColumnCount() != n) {
throw new IllegalActionException(this,
"The number of columns of the C matrix ("
+ c.getColumnCount() + ") should be equal to "
+ "the number of rows of the A matrix (" + n + ").");
}
// The output width is not checked, since we may only want
// to use some of the outputs
DoubleMatrixToken d = (DoubleMatrixToken) D.getToken();
if (c.getRowCount() != d.getRowCount()) {
throw new IllegalActionException(this,
"The number of rows of the D matrix (" + d.getRowCount()
+ ") should be equal to "
+ "the number of rows of the C matrix ("
+ c.getRowCount() + ").");
}
if (d.getColumnCount() != input.getWidth()) {
throw new IllegalActionException(this,
"The number of columns of the D matrix ("
+ d.getColumnCount() + ") should be equal to "
+ "the width of the input port ("
+ input.getWidth() + ").");
}
DoubleMatrixToken x0 = (DoubleMatrixToken) initialStates.getToken();
if (x0.getColumnCount() != n) {
throw new IllegalActionException(this,
"The number of initial states (" + x0.getColumnCount()
+ ") should equal to "
+ "the number of columns of the A matrix (" + n
+ ").");
}