// check transition matrix structure and determine components
calculateComponents();
for (int c=0; c<components.size(); c++)
{
IDoubleArray Tsub = T.view(components.get(c).getArray(),components.get(c).getArray()).copy();
for (int i=0; i<Tsub.rows(); i++)
{
IDoubleArray row = Tsub.viewRow(i);
Algebra.util.scale(1.0/Doubles.util.sum(row), row);
}
//System.out.println(c+" "+componentIsClosed(components[c]));
if (!componentIsClosed(components.get(c)))
continue; // no probability in this set.
IDoubleArray pisub = calculateSub(Tsub);
/*if (c == 0)
{
System.out.println("Submatrix: "+Tsub.length);
for (int j=0; j<Tsub.length; j++)
System.out.println(j+" "+DoubleArrays.sum(Tsub[j]));
Graph g = Graph.fromWeightMatrix(Tsub);
int[][] C = g.strongComponents();
System.out.println("Number of components: "+C.length);
System.out.println("PI: ");
DoubleArrays.print(pisub,"\n");
System.out.println("T sub:");
AlgebraPrimitive.writeMatrixSparse(Tsub,System.out);
System.exit(0);
}
*
*/
this.componentsPi.set(c, pisub);
for (int i=0; i<pisub.size(); i++)
{
int s = components.get(c).get(i);
pi.set(s, pisub.get(i));
//this.componentsPi.set(c).set(s, pisub.get(i));
//this.componentsPi.get(c).set(s, pisub.get(i));
//System.out.println("trying to get from component "+c+" with size "+components.get(c));
//System.out.println("trying to get from pi comp with size "+componentsPi.get(c));