public static Double[][] readData(String fileName) {
		BufferedReader b;
		Double[][] data = null;
		try {
			b = new BufferedReader(new FileReader(fileName));
			String line;
			// count number of lines
			int N = 0;
			while ((line = b.readLine()) != null) {
				N++;
			}
			b.close();

			// data is of the form: (userID, movieID,rating)_i
			data = new Double[N][3];
			int count = 0;
			b = new BufferedReader(new FileReader(fileName));
			while ((line = b.readLine()) != null) {
				String[] s = line.split("\t");
				try {
					for (int i = 0; i < 3; i++)
						data[count][i] = new Double(s[i]);
				} catch (NumberFormatException nfe) {
					System.err.println("input data must be of type integer.");
					nfe.printStackTrace();
				}
				count++;
			}
			b.close();
		} catch (FileNotFoundException e) {
			System.err.println("Couldn't read the parameter file. Check the file name: " + fileName);
			e.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}

		return data;
	}