code: public synchronized int addColumn(Vector col) {
          DoubleVector column = Vectors.asDouble(col);
          if (isFinished)
              throw new IllegalStateException(
                  "Cannot add columns to a MatrixBuilder that is finished");
          if (column instanceof SparseVector) {
              SparseVector s = (SparseVector)column;
              for (int r : s.getNonZeroIndices()) {
                  // NB: Matlab sparse format is in [row col val] format
                  //
                  // NOTE: Matlab indices start at 1, not 0, so update all the
                  // column and column values to be Matlab formatted.
                  addEntry(r + 1, curColumn + 1, column.get(r));
              }
          }
          else {
              for (int r = 0; r < column.length(); ++r) {
                  double d = column.get(r);
                  if (d != 0d) {
                      // NOTE: Matlab indices start at 1, not 0, so update all
                      // the row and column values to be Matlab formatted.
                      addEntry(r + 1, curColumn + 1, d);
                  }
              }
          }
          return ++curColumn;
      }
docs: {@inheritDoc}