please I am trying to understand matrix computation.
and my question may seem simple but please need an answer
can some briefly explain to me what is an RHS vector.
I often see it used in the Apache commons math library
for example i got this from a stackoverflow page:
public class LinearAlgebraDemo
{
public static void main(String[] args)
{
double [][] values = {{1, 1, 2}, {2, 4, -3}, {3, 6, -5}};
double [] rhs = { 9, 1, 0 }; /* RHS Vector */
RealMatrix a = new Array2DRowRealMatrix(values);
DecompositionSolver solver = new LUDecompositionImpl(a).getSolver();
RealVector b = new ArrayRealVector(rhs);
RealVector x = solver.solve(b);
RealVector residual = a.operate(x).subtract(b);
double rnorm = residual.getLInfNorm();
}
}
can someone explain this code to me and especially the RHS vector and its purpose.
thank you very much.
You matrix equation looks like this:
where
Ais a matrix with m rows and n columns,xis a column vector ofmunknowns, andbis another column vector (aka The Right-Hand Side) ofmknown values. It’s on the right hand side of the equals sign – hence the name.If I gave you a simple equation with two numbers and an unknown value x, you’d know exactly how to solve it:
Think of this as solving for x by multiplying both sides of the equation by the inverse of A.
In this case it’s more complicated, because dividing by a matrix means inverting it.
You’re not going to invert the matrix; you’re going to create something called an LU decomposition of the matrix A. You should read about what that is and why it’s better than calculating a full inverse if you’re interested.