public DoubleVector getRowVector(int row) {
   int cols = columns();
   DoubleVector vec = new DenseVector(cols);
   for (int c = 0; c < cols; ++c) {
     vec.set(c, get(row, c));
   }
   return vec;
 }
 /** Generates a simple random vector. */
 private static DoubleVector generateInitialVector(int length, double mean, double std) {
   DoubleVector vector = new DenseVector(length);
   for (int i = 0; i < length; ++i) {
     double v = RANDOM.nextGaussian();
     v = std * v + mean;
     vector.set(i, v);
   }
   return vector;
 }
  /**
   * @param length CAUTION: This value is ignored
   * @return A random vector that is orthogonal to all previously created vectors
   */
  public DoubleVector generate() {
    if (generatedVectors.size() == vectorLength)
      throw new IllegalArgumentException("Too many vectors have been generated");

    DoubleVector vector = generateInitialVector(vectorLength, mean, std);
    for (DoubleVector otherVector : generatedVectors) {
      double uDotV = dotProduct(otherVector, vector);
      double uDotU = dotProduct(otherVector, otherVector);
      for (int i = 0; i < vectorLength; ++i) {
        double projection = otherVector.get(i) * uDotV / uDotU;
        vector.set(i, vector.get(i) - projection);
      }
    }
    generatedVectors.add(vector);
    return vector;
  }