private void calculate() throws Exception {
		//Get B
		Matrix diagonalizedMatrix = matrix.transpose().copy().times(matrix.copy()).copy();
		//Diagonalize B
		EigenvalueDecomposition ed = new EigenvalueDecomposition(diagonalizedMatrix);
		//Get eigenvalues and sort them into ArrayLists
		double[] eigenValues = ed.getRealEigenvalues();
		ArrayList<Double> unsortedEigenValues = new ArrayList<Double>();
		for (int i = 0 ; i < eigenValues.length ; i++)
			unsortedEigenValues.add(eigenValues[i]);
		//Get eigenvectors
		ArrayList<Matrix> unsortedEigenVectors = getColumns(ed.getV().copy());
		//Romove the non-strictly-positive eigenvalues and their corresponding eigenvectors
		for (int i = 0 ; i < unsortedEigenValues.size() ; i++) {
			if (unsortedEigenValues.get(i) <= 0) {
				unsortedEigenValues.remove(i);
				unsortedEigenVectors.remove(i);
			}
		}
		//Put the ArrayLists into a TreeMap
		Comparator<Double> c = Collections.reverseOrder();
		TreeMap<Double , Matrix> sortedMap = new TreeMap<Double , Matrix>(c);
		for (int i = 0 ; i < unsortedEigenValues.size() ; i++)
			sortedMap.put(Double.valueOf(unsortedEigenValues.get(i)) , unsortedEigenVectors.get(i).copy());
		//Retrieve sorted eigenvalues and add them square-rooted to d
		Iterator<Double> evalues = sortedMap.keySet().iterator();
		while (evalues.hasNext()) {
			double evalue = evalues.next().doubleValue();
			d.add(Double.valueOf(Math.sqrt(evalue)));
		}
		//Retrieve sorted eigenvectors and add them unit-vectored to u
		Iterator<Matrix> evectors = sortedMap.values().iterator();
		while (evectors.hasNext()) {
			Matrix evector = evectors.next().copy();
			u.add(getUnitMatrix(evector).copy());
		}
		//Set v, d and u
		Matrix uCombined = combineColumns(u).copy();
		Matrix dCombined = getDiagonalizedMatrix(d).copy();
		Matrix vCombined = matrix.copy().times(uCombined).copy().times(dCombined.inverse().copy()).copy();
		v = getColumns(vCombined);
		//Check if rank exceeds d's dimension
		if (rank > d.size())
			throw new Exception("Rank " + rank + " is higher than the maximum number of eigenvalues "
				+ d.size() + "!");
		//Get ranked matrix
		for (int i = 0 ; i < (rank - 1) ; i++) {
			Matrix currentRanked = v.get(i).copy().times(u.get(i).transpose().copy().times(d.get(i).doubleValue()));
			rankedMatrix = rankedMatrix.plus(currentRanked).copy();
		}
	}