implementation of least squares method and power method for finding dominant eigenvalue and eigenvector