Applies the given {@code procedure} to each non-zero element of the specified column of this matrix.

@param j the column index.
@param procedure the {@link VectorProcedure}.
438410
public void eachNonZeroInColumn(int j, VectorProcedure procedure) {
        VectorIterator it = nonZeroIteratorOfColumn(j);

        while (it.hasNext()) {
            double x = it.next();
            int i = it.index();
            procedure.apply(i, x);
        }
    }
105122
public static void fillRow(Matrix A, int i, int from, int to, double val)
    {
        for(int j = from; j < to; j++)
            A.set(i, j, val);
    }
401832
public void eachInRow(int i, VectorProcedure procedure) {
        VectorIterator it = iteratorOfRow(i);

        while (it.hasNext()) {
            double x = it.next();
            int j = it.index();
            procedure.apply(j, x);
        }
    }
597249
public void set(int i, int j, double x) {
        if (i < 0 || j < 0) {
            throw new IllegalArgumentException("Invalid index: i = " + i + " j = " + j);
        }

        int nrows = size();
        if (i >= nrows) {
            for (int k = nrows; k <= i; k++) {
                data.add(new Datum<>(new SparseArray()));
            }
        }

        if (j >= ncols()) {
            numColumns = j + 1;
            if (numColumns > colSize.length) {
                int[] size = new int[3 * numColumns / 2];
                System.arraycopy(colSize, 0, size, 0, colSize.length);
                colSize = size;
            }
        }

        if (get(i).x.set(j, x)) {
            colSize[j]++;
            n++;            
        }
    }
619565
public static void swapCol(Matrix A, int j, int k)
    {
        swapCol(A, j, k, 0, A.rows());
    }
207077
public static void divCol(Matrix A, int j, double c)
    {
        divCol(A, j, 0, A.rows(), c);
    }
778694
public Matrix transformColumn(int j, VectorFunction function) {
        Matrix result = copy();
        VectorIterator it = result.iteratorOfColumn(j);

        while (it.hasNext()) {
            double x = it.next();
            int i = it.index();
            it.set(function.evaluate(i, x));
        }

        return result;
    }
819126
public static <T1, T2> Procedure<T1> bind(
            Procedure<? super T2> delegate,
            Function<? super T1, T2> function)
    {
        return new BindProcedure<T1, T2>(delegate, function);
    }
706130
public void updateRow(int i, double c, Vec b)
    {
        if(b.length() != this.cols())
            throw new ArithmeticException("vector is not of the same column length");
        if (b.isSparse())
            for (IndexValue iv : b)
                this.increment(i, iv.getIndex(), c * iv.getValue());
        else
            for (int j = 0; j < b.length(); j++)
                this.increment(i, j, c * b.get(j));
    }
1329253
public void getColumn(int j, double[] array, int offset)
    {
        int m = rows;
        for (int i=0;i<m;i++)
        {
            array[i+offset] = get(i, j);
        }
    }
415888
public static void projectRowReverse(Object[] row, int[] columnMap,
                                         Object[] newRow) {

        for (int i = 0; i < columnMap.length; i++) {
            row[columnMap[i]] = newRow[i];
        }
    }
675926
public VectorIterator iteratorOfColumn(int j) {
         final int jj = j;
         return new VectorIterator(rows) {
             private int i = -1;
             @Override
             public int index() {
                 return i;
             }

             @Override
             public double get() {
                 return Matrix.this.get(i, jj);
             }

             @Override
             public void set(double value) {
                 Matrix.this.set(i, jj, value);
             }

             @Override
             public boolean hasNext() {
                 return i + 1 < rows;
             }

             @Override
             public Double next() {
                 if(!hasNext()) {
                     throw new NoSuchElementException();
                 }
                 i++;
                 return get();
             }
         };
     }
1183723
public void setColumn(int col, double[] values) {
    int offset = translate(0, col, numRows);
    System.arraycopy(values, 0, matrix, offset, values.length);
  }
1335365
public void set(int row, int col, double val) {
        checkIndices(row, col);

        if (row != col) {
            throw new IllegalArgumentException(
                    "cannot set non-diagonal elements in a DiagonalMatrix");
        }
        values[row] = val;
    }
1200683
public void reshape(int newrows, int newcolumns) {
        if (((newrows == rows) && (newcolumns == columns)) || (newrows <= 0) || (newcolumns <= 0)) return;

        double[][] newrealmatrix = new double[newrows][newcolumns];
        double[][] newimagmatrix = new double[newrows][newcolumns];
        int minrows = Math.min(rows, newrows);
        int mincolumns = Math.min(columns, newcolumns);
        int i, j;
        for (i = 0; i < minrows; i++)
            for (j = 0; j < mincolumns; j++) {
                newrealmatrix[i][j] = realmatrix[i][j];
                newimagmatrix[i][j] = imagmatrix[i][j];
            }

        for (i = minrows; i < newrows; i++)
            for (j = 0; j < mincolumns; j++) {
                newrealmatrix[i][j] = 0d;
                newimagmatrix[i][j] = 0d;
            }

        for (i = 0; i < minrows; i++)
            for (j = mincolumns; j < newcolumns; j++) {
                newrealmatrix[i][j] = 0d;
                newimagmatrix[i][j] = 0d;
            }

        for (i = minrows; i < newrows; i++)
            for (j = mincolumns; j < newcolumns; j++) {
                newrealmatrix[i][j] = 0d;
                newimagmatrix[i][j] = 0d;
            }

        realmatrix = newrealmatrix;
        imagmatrix = newimagmatrix;
        rows = newrows;
        columns = newcolumns;
    }
298887
public void eachNonZero(MatrixProcedure procedure) {
        MatrixIterator it = nonZeroIterator();

        while (it.hasNext()) {
            double x = it.next();
            int i = it.rowIndex();
            int j = it.columnIndex();
            procedure.apply(i, j, x);
        }
    }
390550
public static <K, V> void forEachKey(Map<K, V> map, Procedure<? super K> procedure)
    {
        if (map == null)
        {
            throw new IllegalArgumentException("Cannot perform a forEachKey on null");
        }

        if (MapIterate.notEmpty(map))
        {
            if (map instanceof UnsortedMapIterable)
            {
                ((MapIterable<K, V>) map).forEachKey(procedure);
            }
            else
            {
                IterableIterate.forEach(map.keySet(), procedure);
            }
        }
    }