### Question:
TridiagonalSolver { public static double[] solvTriDag(TridiagonalMatrix aM, double[] b) { ArgChecker.notNull(aM, "null matrix"); ArgChecker.notNull(b, "null vector"); double[] d = aM.getDiagonal(); int n = d.length; ArgChecker.isTrue(n == b.length, "vector y wrong length for matrix"); double[] y = Arrays.copyOf(b, n); double[] l = aM.getLowerSubDiagonalData(); double[] u = aM.getUpperSubDiagonalData(); double[] x = new double[n]; for (int i = 1; i < n; i++) { double m = l[i - 1] / d[i - 1]; d[i] = d[i] - m * u[i - 1]; y[i] = y[i] - m * y[i - 1]; } x[n - 1] = y[n - 1] / d[n - 1]; for (int i = n - 2; i >= 0; i--) { x[i] = (y[i] - u[i] * x[i + 1]) / d[i]; } return x; } private  TridiagonalSolver(); static double[] solvTriDag(TridiagonalMatrix aM, double[] b); static DoubleArray solvTriDag(TridiagonalMatrix aM, DoubleArray b);  }### Answer:
@Test public void test() { final int n = 97; double[] a = new double[n - 1]; double[] b = new double[n]; double[] c = new double[n - 1]; double[] x = new double[n]; for (int ii = 0; ii < n; ii++) { b[ii] = RANDOM.nextRandom(); x[ii] = RANDOM.nextRandom(); if (ii < n - 1) { a[ii] = RANDOM.nextRandom(); c[ii] = RANDOM.nextRandom(); } } final TridiagonalMatrix m = new TridiagonalMatrix(b, a, c); final DoubleArray xVec = DoubleArray.copyOf(x); final DoubleArray yVec = (DoubleArray) MA.multiply(m, xVec); final double[] xSolv = solvTriDag(m, yVec).toArray(); for (int i = 0; i < n; i++) { assertThat(x[i]).isCloseTo(xSolv[i], offset(1e-9)); } DoubleArray resi = (DoubleArray) MA.subtract(MA.multiply(m, DoubleArray.copyOf(xSolv)), yVec); double err = MA.getNorm2(resi); assertThat(0.0).isCloseTo(err, offset(1e-14)); }