如何获取矩阵中的数据切片

时间:2019-07-18 09:45:25

标签: java arrays matrix data-structures slice

我想从带有“ MatrixIndirectNode”的“ MatrixEgoNetwork”矩阵中获取数据切片,但是在这里我遇到了困难,您能帮我吗?

我尝试使用keepAll(),但仍然不能

   public double countSimilarity(double[][] matrixEgoNetwork, double[][] matrixIndirectNode, int index) {

    if (matrixIndirectNode == null) {
        return this.countDirectSimilarity(matrixEgoNetwork, index);
    }

    double sim = 0;

    for (int i = 0; i < matrixEgoNetwork.length; i++) {
        for (int j = 0; j < matrixEgoNetwork[0].length ; j++) {
            matrixEgoNetwork[i][j].retainAll(matrixIndirectNode[i][index]) //"I tried to Use retainAll() but an error appeared Cannot resolve method"
            if (matrixEgoNetwork[i][0] ==  matrixEgoNetwork[i][index] && matrixEgoNetwork[i][j]!=0) {
                sim++;

        }
        }
  }
return sim;

    }

private double countDirectSimilarity(double[][] matrixEgoNetwork, int index) {
    double sim = 0;

    for (int i = 0; i < matrixEgoNetwork.length; i++) {
        for (int j = 0; j < matrixEgoNetwork[0].length ; j++) {
            if (matrixEgoNetwork[i][0]== matrixEgoNetwork[i][index] && matrixEgoNetwork[i][j]!=0) {
                sim++;

            }
        }

    }

    return sim;

}

我要生成的输出是从矩阵之间的切片中获取的数据量,错误是当我使用retainAll获取矩阵之间的数据切片时无法解析方法,您能帮我解决这个问题吗?

0 个答案:

没有答案