public void covariance() { covMatrix = new double[2][]; for (int i = 0; i < 2; i++) covMatrix[i] = new double[2]; V = new double[2][]; for (int i = 0; i < 2; i++) V[i] = new double[2]; d = new double[2]; // //covMatrix[0][0] = 0; // //covMatrix[0][1] = 0; // //covMatrix[1][0] = 0; // //covMatrix[1][1] = 0; for (int i = 0; i < totalCount; i++) { covMatrix[0][0] += (intermediatePoints[i].X - meanX) * (intermediatePoints[i].X - meanX); covMatrix[0][1] += (intermediatePoints[i].X - meanX) * (intermediatePoints[i].Y - meanY); covMatrix[1][0] = covMatrix[0][1]; covMatrix[1][1] += (intermediatePoints[i].Y - meanY) * (intermediatePoints[i].Y - meanY); } covMatrix[0][0] = covMatrix[0][0] / (totalCount - 1); covMatrix[0][1] = covMatrix[0][1] / (totalCount - 1); covMatrix[1][0] = covMatrix[1][0] / (totalCount - 1); covMatrix[1][1] = covMatrix[1][1] / (totalCount - 1); // Console.WriteLine(" testing covariance matrix: {0} {1} {2} {3}", covMatrix[0][0], covMatrix[0][1], covMatrix[1][0], covMatrix[1][1]); // Console.WriteLine(" matrix testing : {0}", covMatrix); //yeta baata eigenvalue ra eigenvector niskincha GeneralMatrix generalMatrix = new GeneralMatrix(covMatrix); EigenvalueDecomposition eigenvalueDecomposition = new EigenvalueDecomposition(generalMatrix); d = eigenvalueDecomposition.getD(); // get eigen values V = eigenvalueDecomposition.getV(); // get eigen vectors //for (int i = 0; i < 2; i++) //Console.WriteLine("eigenvalue: " + d[i]); //for (int i = 0; i < 2; i++) //{ // for (int j = 0; j < 2; j++) // Console.WriteLine("eigenvector " + V[i][j]); //} }