MCPcopy Create free account
hub / github.com/WinVector/Logistic / DirectSolver

Class DirectSolver

src/com/winvector/opt/impl/DirectSolver.java:13–33  ·  view source on GitHub ↗

@author johnmount

Source from the content-addressed store, hash-verified

11 *
12 */
13public final class DirectSolver implements LinearSolver {
14 private final Algebra algebra = Algebra.ZERO;
15
16 @Override
17 public double[] solve(final double[][] a, final double[] b) {
18 final int dim = b.length;
19 final DoubleMatrix2D mb = new DenseDoubleMatrix2D(dim,1);
20 for(int i=0;i<dim;++i) {
21 final double bi = b[i];
22 mb.set(i,0,bi);
23 }
24 final DoubleMatrix2D ab = new DenseDoubleMatrix2D(a);
25 final DoubleMatrix2D mx = algebra.solve(ab,mb);
26 final double[] x = new double[dim];
27 for(int i=0;i<dim;++i) {
28 x[i] = mx.get(i,0);
29 }
30 return x;
31 }
32
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected