MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / backSub

Method backSub

JSAT/src/jsat/linear/LUPDecomposition.java:254–275  ·  view source on GitHub ↗

Solves for the vector x such that U x = y @param U an upper triangular matrix @param y a vector whos length is equal to the rows in U @return x such that U x = y

(Matrix U, Vec y)

Source from the content-addressed store, hash-verified

252 * @return x such that U x = y
253 */
254 public static Vec backSub(Matrix U, Vec y)
255 {
256 if (y.length() != U.rows())
257 throw new ArithmeticException("Vector and matrix sizes do not agree");
258
259 Vec x = y instanceof SparseVector ? new SparseVector(U.cols()) : new DenseVector(U.cols());
260
261 final int start = Math.min(U.rows(), U.cols())-1;
262
263 for (int i = start; i >= 0; i--)
264 {
265 double x_i = y.get(i);
266 for (int j = i + 1; j <= start; j++)
267 x_i -= U.get(i, j) * x.get(j);
268 x_i /= U.get(i, i);
269 if(Double.isInfinite(x_i))//Occurs when U_(i,i) = 0
270 x_i = 0;
271 x.set(i, x_i);
272 }
273
274 return x;
275 }
276
277 /**
278 * Solves for the matrix x such that U x = y

Callers 6

testBackSub_3argsMethod · 0.95
solveMethod · 0.95
solveMethod · 0.95
solveMethod · 0.80

Calls 11

getMethod · 0.95
setMethod · 0.95
setMethod · 0.95
submitMethod · 0.80
logMethod · 0.80
getNameMethod · 0.65
lengthMethod · 0.45
rowsMethod · 0.45
colsMethod · 0.45
minMethod · 0.45
awaitMethod · 0.45

Tested by 3

testBackSub_3argsMethod · 0.76