protected override void InternalCompute() { double[,] d, w; GetDistancesAndWeights(out d, out w); var x = new DenseMatrix(VisitedGraph.VertexCount, 2); x[0, 0] = 0; x[0, 1] = 0; var rand = new Random(); for (int i = 1; i < VisitedGraph.VertexCount; i++) { x[i, 0] = Math.Max(double.Epsilon, rand.NextDouble() * Parameters.Width); x[i, 1] = Math.Max(double.Epsilon, rand.NextDouble() * Parameters.Height); } DenseMatrix l = ComputeL(w); double s0 = CalcStress(x, d, w); var cholesky = new DenseCholesky((DenseMatrix)l.SubMatrix(1, l.RowCount - 1, 1, l.ColumnCount - 1)); for (int i = 0; i < Parameters.MaxIterations; i++) { DenseMatrix lx = ComputeLZ(d, w, x); Matrix <double> b = lx.Multiply(x); Matrix <double> rx = cholesky.Solve(b.SubMatrix(1, b.RowCount - 1, 0, b.ColumnCount)); x.SetSubMatrix(1, x.RowCount - 1, 0, x.ColumnCount, rx); double s1 = CalcStress(x, d, w); if (Math.Abs(s0 - s1) < 1e-4 * s0) { break; } s0 = s1; } SetPositions(x); }
public override Cholesky <double> Cholesky() { return(DenseCholesky.Create(this)); }
public override Cholesky <float> Cholesky() { return(DenseCholesky.Create(this)); }
public override Cholesky <Complex32> Cholesky() { return(DenseCholesky.Create(this)); }