/** * Returns the number of cells having non-zero values. */ public int cardinality() { if (this.isNoView) return this.elements.size(); else return super.cardinality(); } /**
/** * Returns the number of cells having non-zero values. */ public int cardinality() { if (this.isNoView) return this.elements.size(); else return super.cardinality(); } /**
public static int[] initializeDepths(SparseDoubleMatrix2D adjMat, int[] depths) { for(int j=0; j<depths.length; ++j){ // this allows multiple entry points if(j == 0 || adjMat.viewColumn(j).cardinality() == 0){ depths[j] = 0; } else { depths[j] = -1; } } return depths; } }
public static SparseDoubleMatrix2D reduceCandidateList(IntArrayList signatureNonZeros, IntArrayList functionNonZeros, SparseDoubleMatrix2D candidateList) { // reduce for(int i=0; i<signatureNonZeros.size(); ++i) { // find nodes with only one possible candidate if(candidateList.viewRow(signatureNonZeros.get(i)).cardinality() == 1) { int nonZero = -1; for(int j=0; j<functionNonZeros.size(); ++j) { if(candidateList.get(signatureNonZeros.get(i), functionNonZeros.get(j)) != 0.0) { nonZero = functionNonZeros.get(j); break; } } if(nonZero == -1){ System.out.println("REDUCE LOOP IS BROKEN - J NOT FOUND"); System.out.println(signatureNonZeros); System.out.println(functionNonZeros); System.out.println(candidateList); System.out.println(); break; } // remove candidacy of other nodes since it /has/ to be that one node for(int x=0; x<signatureNonZeros.size(); ++x) { if(x != i) { candidateList.set(signatureNonZeros.get(x), nonZero, 0.0); } } } } return candidateList; }
boolean fillIndexList = indexList != null; boolean fillValueList = valueList != null; int card = cardinality(maxCardinality); if (fillIndexList) indexList.setSize(card); if (fillValueList) valueList.setSize(card);
boolean fillIndexList = indexList != null; boolean fillValueList = valueList != null; int card = cardinality(maxCardinality); if (fillIndexList) indexList.setSize(card); if (fillValueList) valueList.setSize(card);
public CFGSig(ControlFlowGraph cfg) { this.adjacencyMatrix = cfg.getAdjacencyMatrix(); this.vertexCount = cfg.getVertexCount(); this.edgeCount = cfg.getEdgeCount(); this.name = cfg.getIdentifier(false); this.stringSignature = ""; stringSignature += name + ";"; stringSignature += adjacencyMatrix.rows(); DoubleArrayList unused = new DoubleArrayList(); IntArrayList indices = null; for(int i=0; i<adjacencyMatrix.rows(); ++i) { DoubleMatrix1D row = adjacencyMatrix.viewRow(i); if(row.cardinality() > 0) { stringSignature += ";" + i + ":"; indices = new IntArrayList(); row.getNonZeros(indices, unused); for(int j=0; j<indices.size(); ++j) { if(j > 0) stringSignature += ","; stringSignature += indices.get(j); } } } // build sig from adjmat }
if(signatureAdjacencyMatrix.viewColumn(j).cardinality() == 0) signatureVector.set(0, j, 1.0); if(functionAdjacencyMatrix.viewColumn(j).cardinality() == 0) { functionVector.set(0, j, 1.0);