/** * Returns the eigenvector matrix, <tt>V</tt> * * @return <tt>V</tt> */ public DoubleMatrix2D getV() { return DoubleFactory2D.dense.make(V); }
/** * Demonstrates usage of this class. */ public void demo1() { System.out.println("\n\n"); DoubleMatrix2D[][] parts1 = { { null, make(2, 2, 1), null }, { make(4, 4, 2), null, make(4, 3, 3) }, { null, make(2, 2, 4), null } }; System.out.println("\n" + compose(parts1)); // System.out.println("\n"+cern.colt.matrixpattern.Converting.toHTML(make(parts1).toString())); /* * // illegal 2 != 3 DoubleMatrix2D[][] parts2 = { { null, make(2,2,1), * null }, { make(4,4,2), null, make(4,3,3) }, { null, make(2,3,4), null } }; * System.out.println("\n"+make(parts2)); */ DoubleMatrix2D[][] parts3 = { { identity(3), null, }, { null, identity(3).viewColumnFlip() }, { identity(3).viewRowFlip(), null } }; System.out.println("\n" + compose(parts3)); // System.out.println("\n"+cern.colt.matrixpattern.Converting.toHTML(make(parts3).toString())); DoubleMatrix2D A = ascending(2, 2); DoubleMatrix2D B = descending(2, 2); DoubleMatrix2D _ = null; DoubleMatrix2D[][] parts4 = { { A, _, A, _ }, { _, A, _, B } }; System.out.println("\n" + compose(parts4)); // System.out.println("\n"+cern.colt.matrixpattern.Converting.toHTML(make(parts4).toString())); }
/** * Constructs a randomly sampled matrix with the given shape. Randomly picks * exactly <tt>Math.round(rows*columns*nonZeroFraction)</tt> cells and * initializes them to <tt>value</tt>, all the rest will be initialized to * zero. Note that this is not the same as setting each cell with * probability <tt>nonZeroFraction</tt> to <tt>value</tt>. Note: The random * seed is a constant. * * @throws IllegalArgumentException * if <tt>nonZeroFraction < 0 || nonZeroFraction > 1</tt>. * @see cern.jet.random.tdouble.sampling.DoubleRandomSampler */ public DoubleMatrix2D sample(int rows, int columns, double value, double nonZeroFraction) { DoubleMatrix2D matrix = make(rows, columns); sample(matrix, value, nonZeroFraction); return matrix; }
DoubleMatrix2D X = cern.colt.matrix.tdouble.DoubleFactory2D.dense.identity(n); this.solve(X); buf.append(String.valueOf(X));
final DoubleMatrix1D egressTraffic_t = netPlan.getVectorNodeEgressUnicastTraffic(); final DoubleMatrix2D trafficMatrixDiagonalNegative = netPlan.getMatrixNode2NodeOfferedTraffic(); trafficMatrixDiagonalNegative.assign (DoubleFactory2D.sparse.diagonal(egressTraffic_t) , DoubleFunctions.minus); op.setInputParameter("TM", trafficMatrixDiagonalNegative); DoubleMatrix2D maxNumOutLinksCarryingTraffic_nt = DoubleFactory2D.dense.make(N,N,1.0); for (int n = 0 ; n < N ; n ++) maxNumOutLinksCarryingTraffic_nt.set(n, n, 0); op.setInputParameter("U", netPlan.getVectorLinkCapacity().getMaxLocation() [0]);
alphaBeta.setQuick(1, 0, beta); u.assign(DoubleFunctions.div(beta)); U = factory.appendRow(U, u); if (V == null) { V = new DenseColumnDoubleMatrix2D((int) v.size(), 1); V.assign((double[]) v.elements()); } else { V = factory.appendColumn(V, v); C.assign(alphaBeta); } else { C = factory.composeBidiagonal(C, alphaBeta); V.assign((double[]) v.elements()); } else { V = factory.appendColumn(V, v); C.assign(alphaBeta); } else { C = factory.composeBidiagonal(C, alphaBeta);
NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); if (demandsToSetRouting == null) demandsToSetRouting = new TreeSet<> (layer.demands); final DoubleMatrix2D trafficBased_xde = xdeValueAsFractionsRespectToDemandOfferedTraffic ? DoubleFactory2D.sparse.diagonal(getVectorDemandOfferedTraffic(layer)).zMult(x_de, null) : x_de; checkMatrixDemandLinkCarriedTrafficFlowConservationConstraints(trafficBased_xde, false, layer); if (x_de.rows() == 0) return;
/** * Demonstrates usage of this class. */ public static void demo2(int rows, int columns, boolean print) { System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.ascending(rows, columns); // double value = 1; // DoubleMatrix2D A = factory.make(rows,columns); // A.assign(value); System.out.println("benchmarking correlation..."); cern.colt.Timer timer = new cern.colt.Timer().start(); DoubleMatrix2D corr = correlation(covariance(A)); timer.stop().display(); if (print) { System.out.println("printing result..."); System.out.println(corr); } System.out.println("done."); }
DoubleMatrix2D X = cern.colt.matrix.tdouble.DoubleFactory2D.dense.identity(n); this.solve(X); buf.append(String.valueOf(X));
/** * Constructs a randomly sampled matrix with the given shape. Randomly picks * exactly <tt>Math.round(rows*columns*nonZeroFraction)</tt> cells and * initializes them to <tt>value</tt>, all the rest will be initialized to * zero. Note that this is not the same as setting each cell with * probability <tt>nonZeroFraction</tt> to <tt>value</tt>. Note: The random * seed is a constant. * * @throws IllegalArgumentException * if <tt>nonZeroFraction < 0 || nonZeroFraction > 1</tt>. * @see cern.jet.random.tdouble.sampling.DoubleRandomSampler */ public DoubleMatrix2D sample(int rows, int columns, double value, double nonZeroFraction) { DoubleMatrix2D matrix = make(rows, columns); sample(matrix, value, nonZeroFraction); return matrix; }
alphaBeta.setQuick(1, 0, beta); u.assign(DoubleFunctions.div(beta)); U = factory.appendRow(U, u); if (V == null) { V = new DenseColumnDoubleMatrix2D((int) v.size(), 1); V.assign((double[]) v.elements()); } else { V = factory.appendColumn(V, v); C.assign(alphaBeta); } else { C = factory.composeBidiagonal(C, alphaBeta); V.assign((double[]) v.elements()); } else { V = factory.appendColumn(V, v); C.assign(alphaBeta); } else { C = factory.composeBidiagonal(C, alphaBeta);
if (x_de.size() > 0) if (x_de.getMinLocation()[0] < -PRECISION_FACTOR) throw new Net2PlanException("Carried traffics cannot be negative"); final DoubleMatrix2D trafficBased_xde = xdeValueAsFractionsRespectToDemandOfferedTraffic ? DoubleFactory2D.sparse.diagonal(getVectorDemandOfferedTraffic(layer)).zMult(x_de, null) : x_de; final DoubleMatrix2D A_ne = netPlan.getMatrixNodeLinkIncidence(layer); final DoubleMatrix2D Div_dn = trafficBased_xde.zMult(A_ne.viewDice(), null); // out traffic minus in traffic of demand d in node n
/** * Demonstrates usage of this class. */ public static void demo2(int rows, int columns, boolean print) { System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.ascending(rows, columns); // double value = 1; // DoubleMatrix2D A = factory.make(rows,columns); // A.assign(value); System.out.println("benchmarking correlation..."); cern.colt.Timer timer = new cern.colt.Timer().start(); DoubleMatrix2D corr = correlation(covariance(A)); timer.stop().display(); if (print) { System.out.println("printing result..."); System.out.println(corr); } System.out.println("done."); }
/** * Returns the eigenvector matrix, <tt>V</tt> * * @return <tt>V</tt> */ public DoubleMatrix2D getV() { return DoubleFactory2D.dense.make(V); }
/** * Demonstrates usage of this class. */ public void demo1() { System.out.println("\n\n"); DoubleMatrix2D[][] parts1 = { { null, make(2, 2, 1), null }, { make(4, 4, 2), null, make(4, 3, 3) }, { null, make(2, 2, 4), null } }; System.out.println("\n" + compose(parts1)); // System.out.println("\n"+cern.colt.matrixpattern.Converting.toHTML(make(parts1).toString())); /* * // illegal 2 != 3 DoubleMatrix2D[][] parts2 = { { null, make(2,2,1), * null }, { make(4,4,2), null, make(4,3,3) }, { null, make(2,3,4), null } }; * System.out.println("\n"+make(parts2)); */ DoubleMatrix2D[][] parts3 = { { identity(3), null, }, { null, identity(3).viewColumnFlip() }, { identity(3).viewRowFlip(), null } }; System.out.println("\n" + compose(parts3)); // System.out.println("\n"+cern.colt.matrixpattern.Converting.toHTML(make(parts3).toString())); DoubleMatrix2D A = ascending(2, 2); DoubleMatrix2D B = descending(2, 2); DoubleMatrix2D _ = null; DoubleMatrix2D[][] parts4 = { { A, _, A, _ }, { _, A, _, B } }; System.out.println("\n" + compose(parts4)); // System.out.println("\n"+cern.colt.matrixpattern.Converting.toHTML(make(parts4).toString())); }
DoubleMatrix2D X = cern.colt.matrix.tdouble.DoubleFactory2D.dense.identity(m); this.solve(X); buf.append(String.valueOf(X));
alphaBeta.setQuick(1, 0, beta); u.assign(DoubleFunctions.div(beta)); U = factory.appendRow(U, u); if (V == null) { V = new DenseColumnDoubleMatrix2D((int) v.size(), 1); V.assign((double[]) v.elements()); } else { V = factory.appendColumn(V, v); C.assign(alphaBeta); } else { C = factory.composeBidiagonal(C, alphaBeta); V.assign((double[]) v.elements()); } else { V = factory.appendColumn(V, v); C.assign(alphaBeta); } else { C = factory.composeBidiagonal(C, alphaBeta);
final DoubleMatrix1D egressTraffic_t = netPlan.getVectorNodeEgressUnicastTraffic(upperLayer); final DoubleMatrix2D trafficMatrixDiagonalNegative = netPlan.getMatrixNode2NodeOfferedTraffic(upperLayer); trafficMatrixDiagonalNegative.assign (DoubleFactory2D.sparse.diagonal(egressTraffic_t) , DoubleFunctions.minus); op.setInputParameter("TM", trafficMatrixDiagonalNegative); op.setInputParameter("U_hi", ciurcuitCapacityGbps.getDouble());
@Override public void actionPerformed(ActionEvent e) { int N = DEFAULT_NUMBER_OF_NODES; DoubleMatrix2D trafficMatrix = DoubleFactory2D.dense.make(N, N); setTrafficMatrix(trafficMatrix); } });
DoubleMatrix2D X = cern.colt.matrix.tdouble.DoubleFactory2D.dense.identity(m); this.solve(X); buf.append(String.valueOf(X));