FixedMatrix implements Matrix<T> { @Override public final Vect<T> apply(final Vect<T> input) { if (input.coords().length != this.source) { throw new IllegalArgumentException( String.format( "Incompatible vector dimension %s with matrix dimension %s", input.coords().length, this.source ) ); } final List<Scalar<T>> result = new ArrayList<>(this.target); for (int idx = 0; idx < this.target; ++idx) { result.add(this.product(input, idx + 1)); } return new FixedVector<T>(result); } @SuppressWarnings("unchecked")  FixedMatrix(final int lines, final int columns,
        final Iterable<? extends Scalar<T>> coor); @Override final Scalar<T>[] coords(); @Override final Scalar<T>[] column(final int index); @Override final Scalar<T>[] line(final int index); @Override final Vect<T> apply(final Vect<T> input); @Override final int columns(); @Override final int lines();  }
@Test public void errorsWhenBadVectorSize() { this.thrown.expect(IllegalArgumentException.class); final int lines = 3; final int cols = 4; final FixedMatrix<Object> matrix = new FixedMatrix<>( lines, cols, new Scalars<>(lines * cols) ); final Vect<Object> input = new FixedVector<>(new Scalars<>(cols + 1)); matrix.apply(input); }