code: public static INDArray pca_factor(INDArray A, int nDims, boolean normalize) {
  
          if (normalize) {
              // Normalize to mean 0 for each feature ( each column has 0 mean )
              INDArray mean = A.mean(0);
              A.subiRowVector(mean);
          }
  
          long m = A.rows();
          long n = A.columns();
  
          // The prepare SVD results, we'll decomp A to UxSxV'
          INDArray s = Nd4j.create(A.dataType(), m < n ? m : n);
          INDArray VT = Nd4j.create(A.dataType(), new long[]{n, n}, 'f');
  
          // Note - we don't care about U 
          Nd4j.getBlasWrapper().lapack().gesvd(A, s, null, VT);
  
          // for comparison k & nDims are the equivalent values in both methods implementing PCA
  
          // So now let's rip out the appropriate number of left singular vectors from
          // the V output (note we pulls rows since VT is a transpose of V)
          INDArray V = VT.transpose();
          INDArray factor = Nd4j.create(A.dataType(),new long[]{n, nDims}, 'f');
          for (int i = 0; i < nDims; i++) {
              factor.putColumn(i, V.getColumn(i));
          }
  
          return factor;
      }
docs: Calculates pca factors of a matrix, for a flags number of reduced features
  returns the factors to scale observations
  
  The return is a factor matrix to reduce (normalized) feature sets
  
  @see pca(INDArray, int, boolean)
  
  @param A the array of features, rows are results, columns are features - will be changed
  @param nDims the number of components on which to project the features
  @param normalize whether to normalize (adjust each feature to have zero mean)
  @return the reduced feature set