{
this.Q = _Q;
this.A = _A;
this.B = _B;
IIntGraph g = graphNew.intMatrixGraph(_F);
this.inA = new boolean[_F.rows()];
for (int i = 0; i < A.length; i++)
inA[A[i]] = true;
inB = new boolean[_F.rows()];
for (int i = 0; i < B.length; i++)
inB[B[i]] = true;
// convert double matrix into Big Decimals
this.F = new SparseObjectMatrix2D(_F.rows(), _F.rows());
for (int i=0; i<_F.rows(); i++)
for (int j=0; j<_F.rows(); j++)
if (_F.get(i,j) != 0)
F.set(i,j, new BigDecimal(_F.get(i,j)));
// collect in- and outflux of every node
this.influxes = new BigDecimal[_F.rows()];
this.outfluxes = new BigDecimal[_F.rows()];
for (int i=0; i<influxes.length; i++)
{
influxes[i] = BigDecimal.ZERO;
outfluxes[i] = BigDecimal.ZERO;
}
for (int i=0; i<F.rows(); i++)
for (int j=0; j<F.rows(); j++)
{
if (F.get(i,j) != null)
{
influxes[j] = influxes[j].add((BigDecimal)F.get(i,j));
outfluxes[i] = outfluxes[i].add((BigDecimal)F.get(i,j));
}
}
// correct for rounding errors by iterating nodes with increasing committor.
int[] IQ = doubleArrays.sortedIndexes(Q);
for (int i=0; i<IQ.length; i++)
{
int s = IQ[i]; // this is the current node
if (influxes[s].equals(BigDecimal.ZERO) ||
outfluxes[s].equals(BigDecimal.ZERO))
continue;
BigDecimal err = outfluxes[s].subtract(influxes[s]); // difference between in and out
// correct outflux.
int[] neighbors = g.getNeighbors(s).getArray();
int ilargest = 0;
double flargest = _F.get(s,neighbors[0]);
for (int j=1; j<neighbors.length; j++)
if (_F.get(s, neighbors[j]) > flargest)