|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.aerith.misao.util.SimultaneousEquation
The SimultaneousEquation
represents a simultaneous
equation. It has a function to solve the equation.
For example, in the case of the simultaneous equations:
a x + b y + c = 0 d x + e y + f = 0the coefficient matrix will be set as:
SimultaneousEquation se = new SimultaneousEquation(2); se.coef[0][0] = a; se.coef[0][1] = b; se.coef[0][2] = c; se.coef[1][0] = d; se.coef[1][1] = e; se.coef[1][2] = f;and the answer will be obtained as:
se.solve(); x = se.getAnswer(0); y = se.getAnswer(1);
Note that this class does not support the case that a coefficient is 0.
Field Summary | |
double[][] |
coef
The coefficient matrix. |
protected int |
dimension
The dimension of the equations, which is the number of variables, or the number of equations. |
Constructor Summary | |
SimultaneousEquation(int dimension)
Constructs a default SimultaneousEquation , with
the number of equations. |
Method Summary | |
double |
getAnswer(int i)
Gets the answer of i-th variable. |
void |
solve()
Solves this simultaneous equation. |
private void |
solve(int k)
Solves the specified equation in this simultaneous equation. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public double[][] coef
dimension
and the number of columns is dimension
+ 1.
The right edge term of each equation i,
coef[i][dimension
], is a constant term.protected int dimension
Constructor Detail |
public SimultaneousEquation(int dimension)
SimultaneousEquation
, with
the number of equations. All the values in the coefficient
matrix are set as 0.dimension
- the number of equations.Method Detail |
public double getAnswer(int i)
i
- the index of variable to get the answer.public void solve()
Note that this method does not support the case that a coefficient is 0.
private void solve(int k)
k
- the index of equation to solve.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |