Friday, February 20, 2015

Markov Squaring java in pgm



MarkovSquaring.java

public class MarkovSquaring
{
             public static void main(String[] args)
{
                    int T = Integer.parseInt(args[0]);
                    double[][] p = StdArrayIO.readDouble2D();
                    int N = p.length;

        double[] rank = new double[N];
        rank[0] = 1.0;

        for (int t = 0; t < T; t++)
       {
            p = Matrix.multiply(p, p);
        }
                        StdArrayIO.println(p);
    }
}

No comments:

Post a Comment