### Question:
DoubleDiagonalMatrix extends AbstractMatrix { public void multAdd(double alpha, Vector x, Vector y) { throw new MatricksException("Not implemented"); } DoubleDiagonalMatrix(int size);  DoubleDiagonalMatrix(Vector data); int numRows(); int numCols(); double get(int row, int col); void set(int row, int col, double val); void scale(double a); void setAll(double a); MatrixCursor cursor(); void add(Matrix B); void add(double a, Matrix B); double elementSum(); double elementMultiplySum(Matrix m); void CG(Vector x, Vector y); void QR(Vector x, Vector y); Vector rowSums(); Vector columnSums(); void rowSums(double[] result); void columnSums(double[] result); void setToMaxTranspose(); void multAdd(double alpha, Vector x, Vector y); void mult(Vector x, Vector y); Matrix subMatrix(int[] rows, int[] cols); void add(int i, int j, double alpha); void mult(double [] x, double [] y); void multAdd(double[] x, double[] y); void transMult(double[] x, double[] y); void compact();  }### Answer:
@Test public void testMultAdd() { int size = 10; double [] x = new double[size]; double [] y = new double[size]; DenseDoubleVector vector = new DenseDoubleVector(size); for (int i=0; i<size; i++) { vector.set(i, i); x[i] = i; y[i] = 2*i; } DoubleDiagonalMatrix matrix = new DoubleDiagonalMatrix(vector); matrix.multAdd(x, y); for (int i=0; i<size; i++) { double expected = 2*i + i*i; assertEquals(expected, y[i], 1e-7d); } }