Package cern.colt.matrix.impl

Examples of cern.colt.matrix.impl.SparseDoubleMatrix2D


*
* @param values The values to be filled into the new matrix.
* @throws IllegalArgumentException if <tt>for any 1 &lt;= row &lt; values.length: values[row].length != values[row-1].length</tt>.
*/
public DoubleMatrix2D make(double[][] values) {
  if (this==sparse) return new SparseDoubleMatrix2D(values);
  else return new DenseDoubleMatrix2D(values);
}
View Full Code Here


}
/**
* Constructs a matrix with the given shape, each cell initialized with zero.
*/
public DoubleMatrix2D make(int rows, int columns) {
  if (this==sparse) return new SparseDoubleMatrix2D(rows,columns);
  if (this==rowCompressed) return new RCDoubleMatrix2D(rows,columns);
  //if (this==rowCompressedModified) return new RCMDoubleMatrix2D(rows,columns);
  else return new DenseDoubleMatrix2D(rows,columns);
}
View Full Code Here

*
* @param values The values to be filled into the new matrix.
* @throws IllegalArgumentException if <tt>for any 1 &lt;= row &lt; values.length: values[row].length != values[row-1].length</tt>.
*/
public DoubleMatrix2D make(double[][] values) {
  if (this==sparse) return new SparseDoubleMatrix2D(values);
  else return new DenseDoubleMatrix2D(values);
}
View Full Code Here

}
/**
* Constructs a matrix with the given shape, each cell initialized with zero.
*/
public DoubleMatrix2D make(int rows, int columns) {
  if (this==sparse) return new SparseDoubleMatrix2D(rows,columns);
  if (this==rowCompressed) return new RCDoubleMatrix2D(rows,columns);
  //if (this==rowCompressedModified) return new RCMDoubleMatrix2D(rows,columns);
  else return new DenseDoubleMatrix2D(rows,columns);
}
View Full Code Here

    System.out.println("Check 3: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));

    nodearray = nodes.toArray(new Node[]{});
   
    // SET THE EDGES
    SparseDoubleMatrix2D Weight = new SparseDoubleMatrix2D(nodearray.length,nodearray.length);
    for(Resource res : bscrdf.listSubjects().toSet()){
      for(Statement st : res.listProperties().toSet()){
        if(relationsandweights.keySet().contains(st.getPredicate().getURI())){
          Weight.set(urisandnodes.get(res.getURI()).name, urisandnodes.get(st.getObject().toString()).name, relationsandweights.get(st.getPredicate().getURI()));
        }
      }
      //  Weight.set(urisandnodes.get(res.getURI()).name, urisandnodes.get(st.getObject().toString()).name, baseweight);
      //}
//      for(Statement st : res.listProperties(lowweight).toSet()){
//        Weight.set(urisandnodes.get(res.getURI()).name, urisandnodes.get(st.getObject().toString()).name, lowweightnum);
//        Weight.set(urisandnodes.get(st.getObject().toString()).name, urisandnodes.get(res.getURI()).name, lowweightnum);
//      }
//      for(Statement st : res.listProperties(fiveweight).toSet()){
//        Weight.set(urisandnodes.get(res.getURI()).name, urisandnodes.get(st.getObject().toString()).name, 5);
//        Weight.set(urisandnodes.get(st.getObject().toString()).name, urisandnodes.get(res.getURI()).name, 5);
//      }
    }
   
    Weight.getNonZeros(rowlist, columnlist, valuelist);
   
    System.out.println(nodearray.length);
    System.out.println(rowlist.size());
    setComboBoxData(autocompletelist);
   
View Full Code Here

        currentRow.add(Double.parseDouble(token));
      }
      rows.add(currentRow);
    }
    int size = rows.size();
    DoubleMatrix2D matrix = new SparseDoubleMatrix2D(size, size);
    for (int i = 0; i < size; i++) {
      List<Double> currentRow = rows.get(i);
      if (currentRow.size() != size) {
        throw new IllegalArgumentException(
          "Matrix must have the same number of rows as columns");
      }
      for (int j = 0; j < size; j++) {
        double currentVal = currentRow.get(j);
        if (currentVal != 0) {
          matrix.setQuick(i, j, currentVal);
        }
      }
    }
    return matrix;
  }
View Full Code Here

    public static <V,E> SparseDoubleMatrix2D graphToSparseMatrix(Graph<V,E> g, Map<E,Number> nev)
    {
        if (nev == null)
            nev = new ConstantMap<E,Number>(1);
        int numVertices = g.getVertexCount();
        SparseDoubleMatrix2D matrix = new SparseDoubleMatrix2D(numVertices,
                numVertices);

        BidiMap<V,Integer> indexer = Indexer.<V>create(g.getVertices());
        int i=0;
       
        for(V v : g.getVertices())
        {
            for (E e : g.getOutEdges(v))
            {
                V w = g.getOpposite(v,e);
                int j = indexer.get(w);
                matrix.set(i, j, matrix.getQuick(i,j) + nev.get(e).doubleValue());
            }
            i++;
        }
        return matrix;
    }
View Full Code Here

     * @return SparseDoubleMatrix2D
     */
    public static <V,E> SparseDoubleMatrix2D createVertexDegreeDiagonalMatrix(Graph<V,E> graph)
    {
        int numVertices = graph.getVertexCount();
        SparseDoubleMatrix2D matrix = new SparseDoubleMatrix2D(numVertices,
                numVertices);
        int i = 0;
        for (V v : graph.getVertices())
        {
            matrix.set(i, i, graph.degree(v));
            i++;
        }
        return matrix;
    }
View Full Code Here

        DoubleMatrix2D A = GraphMatrixOperations.graphToSparseMatrix(graph,
                null);
        //create diagonal matrix of vertex degrees
        DoubleMatrix2D D = GraphMatrixOperations
                .createVertexDegreeDiagonalMatrix(graph);
        DoubleMatrix2D temp = new SparseDoubleMatrix2D(numVertices - 1,
                numVertices - 1);
        //compute D - A except for last row and column
        for (int i = 0; i < numVertices - 1; i++)
        {
            for (int j = 0; j < numVertices - 1; j++)
            {
                temp.set(i, j, D.get(i, j) - A.get(i, j));
            }
        }
        Algebra algebra = new Algebra();
        DoubleMatrix2D tempInverse = algebra.inverse(temp);
        DoubleMatrix2D T = new SparseDoubleMatrix2D(numVertices, numVertices);
        //compute "voltage" matrix
        for (int i = 0; i < numVertices - 1; i++)
        {
            for (int j = 0; j < numVertices - 1; j++)
            {
                T.set(i, j, tempInverse.get(i, j));
            }
        }
        return T;
    }
View Full Code Here

                    temp.set(i, j, value);
            }
        }
        Algebra algebra = new Algebra();
        DoubleMatrix2D fundamentalMatrix = algebra.inverse(temp);
        temp = new SparseDoubleMatrix2D(temp.rows(), temp.columns());
        for (int i = 0; i < temp.rows(); i++)
        {
            for (int j = 0; j < temp.columns(); j++)
            {
                double value = -1.0 * fundamentalMatrix.get(i, j);
                value += fundamentalMatrix.get(j, j);
                if (i == j)
                    value += 1;
                if (value != 0)
                    temp.set(i, j, value);
            }
        }
        DoubleMatrix2D stationaryMatrixDiagonal = new SparseDoubleMatrix2D(temp
                .rows(), temp.columns());
        int numVertices = stationaryDistribution.size();
        for (int i = 0; i < numVertices; i++)
            stationaryMatrixDiagonal.set(i, i, 1.0 / stationaryDistribution
                    .get(i));
        DoubleMatrix2D meanFirstPassageMatrix = algebra.mult(temp,
                stationaryMatrixDiagonal);
        return meanFirstPassageMatrix;
    }
View Full Code Here

TOP

Related Classes of cern.colt.matrix.impl.SparseDoubleMatrix2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.