gpt4 book ai didi

java - Java Colt Matrix 包需要帮助

转载 作者:行者123 更新时间:2023-12-01 16:12:24 26 4
gpt4 key购买 nike

谁能告诉我如何使用 Colt 从矩阵中删除列图书馆?

最佳答案

没有明确的方法来删除列,但您可以创建原始矩阵的 View ,其中包含除您想要删除的列之外的所有列。

/**
* Returns a view of the original matrix that contains all rows and all columns
* except for the specified column.
*
* The view is backed by the original matrix, that is, all changes to the
* returned matrix will be reflected by the original matrix.
*
* @param src The matrix to have a column "removed".
* @param colIdx The index of the column to be hidden
* ({@code 0 <= colIdx < src.columns()} .
* @return A view of the original matrix with column {@code colIdx} removed.
*/
public DoubleMatrix2D hideColumn(final DoubleMatrix2D src, final int colIdx) {
// create array of column indices to be preserved
final int[] keepColumns = new int[src.columns() - 1];
for (int i = 0; i < keepColumns.length; i++) {
keepColumns[i] = ((i < colIdx) ? i : i + 1);
}

return src.viewSelection(null /* keep ALL rows */, keepColumns);
}

关于java - Java Colt Matrix 包需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/579832/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com