algorithm for computing the first few components in a principal component or partial least squares analysis