package calculations; /** * This program shows how a repetitive vector-matrix-multiplication can converge to a fixed point. * Such a calculation is mentioned in the lecture during the topic of the random web-surfer. * @author Felix & Lars */ public class VectorMatrixMultiplication { /** * Multiplies a vector times a matrix. * @param v Input vector to be multiplied (from the left hand side) with the matrix. * @param m Input matrix to be multiplied (from the right hand side) with the vector. * Since matrix multiplications aren't commutative, it's important to specify that the * this method multiplies the vector times the matrix and not vice-versa. * Otherwise the result would again be a matrix and not a vector! */ public static double[] multiply(double[] v, double[][] m) { assert (v.length == m.length); // vector length must be equal so matrix height double[] res = new double[m.length]; // result vector // TODO: Add code here // Perform the multiplication of the vector times the matrix. // http://de.wikipedia.org/wiki/Falksches_Schema // for ... return res; } /** * Prints the given vector. * @param v Some arbitrary vector to print. */ public static void show(double[] v) { for (int i=0; i