value += 1;
if (value != 0)
temp.set(i, j, value);
}
}
Algebra algebra = new Algebra();
DoubleMatrix2D fundamentalMatrix = algebra.inverse(temp);
temp = new SparseDoubleMatrix2D(temp.rows(), temp.columns());
for (int i = 0; i < temp.rows(); i++)
{
for (int j = 0; j < temp.columns(); j++)
{
double value = -1.0 * fundamentalMatrix.get(i, j);
value += fundamentalMatrix.get(j, j);
if (i == j)
value += 1;
if (value != 0)
temp.set(i, j, value);
}
}
DoubleMatrix2D stationaryMatrixDiagonal = new SparseDoubleMatrix2D(temp
.rows(), temp.columns());
int numVertices = stationaryDistribution.size();
for (int i = 0; i < numVertices; i++)
stationaryMatrixDiagonal.set(i, i, 1.0 / stationaryDistribution
.get(i));
DoubleMatrix2D meanFirstPassageMatrix = algebra.mult(temp,
stationaryMatrixDiagonal);
return meanFirstPassageMatrix;
}