/** * Returns the eigenvector matrix, <tt>V</tt> * * @return <tt>V</tt> */ public DoubleMatrix2D getV() { return DoubleFactory2D.dense.make(V); }
/** * Returns the eigenvector matrix, <tt>V</tt> * * @return <tt>V</tt> */ public DoubleMatrix2D getV() { return DoubleFactory2D.dense.make(V); }
@Override public void actionPerformed(ActionEvent e) { int N = DEFAULT_NUMBER_OF_NODES; DoubleMatrix2D trafficMatrix = DoubleFactory2D.dense.make(N, N); setTrafficMatrix(trafficMatrix); } });
/** * Constructs a 1d matrix of the right dynamic type. */ protected DoubleMatrix1D make1D(int size) { return make(0, 0).like1D(size); } }
/** * Constructs a 1d matrix of the right dynamic type. */ protected DoubleMatrix1D make1D(int size) { return make(0, 0).like1D(size); } }
/** * Constructs an identity matrix (having ones on the diagonal and zeros * elsewhere). */ public DoubleMatrix2D identity(int rowsAndColumns) { DoubleMatrix2D matrix = make(rowsAndColumns, rowsAndColumns); for (int i = rowsAndColumns; --i >= 0;) { matrix.setQuick(i, i, 1); } return matrix; }
/** * Constructs an identity matrix (having ones on the diagonal and zeros * elsewhere). */ public DoubleMatrix2D identity(int rowsAndColumns) { DoubleMatrix2D matrix = make(rowsAndColumns, rowsAndColumns); for (int i = rowsAndColumns; --i >= 0;) { matrix.setQuick(i, i, 1); } return matrix; }
private DoubleMatrix2D getTrafficMatrix(int trafficMatrixId) { TableModel aux = trafficMatrices.get(trafficMatrixId).getModel(); int N = aux.getRowCount() - 1; DoubleMatrix2D trafficMatrix = DoubleFactory2D.dense.make(N, N); for (int ingressNodeId = 0; ingressNodeId < N; ingressNodeId++) { for (int egressNodeId = 0; egressNodeId < N; egressNodeId++) { Number value = (Number) aux.getValueAt(ingressNodeId, egressNodeId + 1); trafficMatrix.setQuick(ingressNodeId, egressNodeId, value.doubleValue()); } } return trafficMatrix; }
/** * <p>Returns a matrix with as many rows resources, and columns as nodes. Coordinate (res,n) is 1 if resource res is hosted in node n</p> * * @return The matrix */ public DoubleMatrix2D getMatrixResource2NodeAssignment() { DoubleMatrix2D delta_en = DoubleFactory2D.sparse.make(resources.size(), nodes.size()); for (Resource res : resources) if (res.iAttachedToANode()) delta_en.set(res.index, res.hostNode.get().index, 1.0); return delta_en; }
/** * <p>Returns a matrix with as many rows resources, and columns as SRGs. Coordinate (res,srg) is 1 if resource res fails when srg fails</p> * * @return The matrix */ public DoubleMatrix2D getMatrixResource2SRGAssignment() { DoubleMatrix2D delta_es = DoubleFactory2D.sparse.make(resources.size(), srgs.size()); for (SharedRiskGroup srg : srgs) for (Node n : srg.getNodes()) for (Resource res : n.cache_nodeResources) delta_es.set(res.index, srg.index, 1.0); return delta_es; }
/** * Constructs a matrix with uniformly distributed values in <tt>(0,1)</tt> * (exclusive). */ public DoubleMatrix2D random(int rows, int columns) { return make(rows, columns).assign(cern.jet.math.tdouble.DoubleFunctions.random()); }
/** * Constructs a matrix with uniformly distributed values in <tt>(0,1)</tt> * (exclusive). */ public DoubleMatrix2D random(int rows, int columns) { return make(rows, columns).assign(cern.jet.math.tdouble.DoubleFunctions.random()); }
/** * Demonstrates usage of this class. */ public static void demo3(VectorVectorFunction norm) { double[][] values = { { -0.9611052f, -0.25421095f }, { 0.4308269f, -0.69932648f }, { -1.2071029f, 0.62030596f }, { 1.5345166f, 0.02135884f }, { -1.1341542f, 0.20388430f } }; System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.make(values).viewDice(); System.out.println("\nA=" + A.viewDice()); System.out.println("\ndist=" + distance(A, norm).viewDice()); }
/** * Demonstrates usage of this class. */ public static void demo3(VectorVectorFunction norm) { double[][] values = { { -0.9611052f, -0.25421095f }, { 0.4308269f, -0.69932648f }, { -1.2071029f, 0.62030596f }, { 1.5345166f, 0.02135884f }, { -1.1341542f, 0.20388430f } }; System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.make(values).viewDice(); System.out.println("\nA=" + A.viewDice()); System.out.println("\ndist=" + distance(A, norm).viewDice()); }
/** * Generates a constant traffic matrix. * * @param N Number of nodes * @param value Traffic value * @return Traffic matrix */ public static DoubleMatrix2D constantTrafficMatrix(int N, double value) { if (value < 0) throw new Net2PlanException("Traffic value must be greater or equal than zero"); DoubleMatrix2D trafficMatrix = DoubleFactory2D.dense.make(N, N, value); for (int n = 0; n < N; n++) trafficMatrix.setQuick(n, n, 0); return trafficMatrix; }
private static DoubleMatrix2D resizeTrafficMatrix(DoubleMatrix2D trafficMatrix, int N) { int oldN = trafficMatrix.rows(); int minN = Math.min(oldN, N); DoubleMatrix2D newTrafficMatrix = DoubleFactory2D.dense.make(N, N); for (int ingressNodeId = 0; ingressNodeId < minN; ingressNodeId++) for (int egressNodeId = ingressNodeId + 1; egressNodeId < minN; egressNodeId++) newTrafficMatrix.setQuick(ingressNodeId, egressNodeId, trafficMatrix.getQuick(ingressNodeId, egressNodeId)); return newTrafficMatrix; }
/** * Demonstrates advanced sorting. Sorts by sum of row. */ public static void zdemo6() { double[][] values = { { 3, 7, 0 }, { 2, 1, 0 }, { 2, 2, 0 }, { 1, 8, 0 }, { 2, 5, 0 }, { 7, 0, 0 }, { 2, 3, 0 }, { 1, 0, 0 }, { 4, 0, 0 }, { 2, 0, 0 } }; DoubleMatrix2D A = DoubleFactory2D.dense.make(values); DoubleMatrix2D B, C; System.out.println("\n\nunsorted:" + A); B = quickSort.sort(A, 1); C = quickSort.sort(B, 0); System.out.println("quick sorted :" + C); B = mergeSort.sort(A, 1); C = mergeSort.sort(B, 0); System.out.println("merge sorted :" + C); }
/** Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), it generates the resulting demand-link routing in the form f_de (fractions of traffic in a node from demand d, transmitted through link e). * * @param numDemandsInLayer Number of demands in the layer. * @param demandsToConvert List of demands in the layer to apply conversion, the rest are untouched * @param f_te For each destination node <i>t</i> (<i>t = 0</i> refers to the first node index, <i>t = 1</i> refers to the second one, and so on), and each link <i>e</i> (<i>e = 0</i> refers to the first link index, <i>e = 1</i> refers to the second one, and so on), {@code f_te[t][e]} sets the fraction of the traffic targeted to node <i>t</i> that arrives (or is generated in) node <i>a(e)</i> (the origin node of link <i>e</i>), that is forwarded through link <i>e</i>. It must hold that for every node <i>n</i> different of <i>t</i>, the sum of the fractions <i>f<sub>te</sub></i> along its outgoing links must be lower or equal than 1 (unchecked) * @return Demand-link routing in the form f_de (fractions of traffic in a node from demand d, transmitted through link e) */ public static DoubleMatrix2D convert_fte2fde(int numDemandsInLayer , SortedSet<Demand> demandsToConvert, DoubleMatrix2D f_te) { int E = f_te.columns(); int D = numDemandsInLayer; DoubleMatrix2D f_de = DoubleFactory2D.sparse.make(D, E); for (Demand d : demandsToConvert) f_de.viewRow(d.getIndex()).assign(f_te.viewRow(d.getEgressNode().getIndex())); return f_de; }