Esempio n. 1
0
        public void WriteHistoryForNewLattice(string firstLine)
        {
            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + firstLine + " **\r\n"))));

            paragraph.Inlines.Add(new Bold(new Run(Languages.labelLatticeBasis + ":")));
            paragraph.Inlines.Add(" " + Lattice.LatticeToString() + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelLengthBasisVectors)));
            paragraph.Inlines.Add(" " + Lattice.VectorLengthToString() + "\r\n");

            if (Lattice.N == 2 && Lattice.M == 2)
            {
                paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelAngleBasisVectors)));
                paragraph.Inlines.Add(" " + Util.FormatDoubleLog(Lattice.AngleBasisVectors) + "\r\n");

                paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelEstimationR)));
                paragraph.Inlines.Add(" " + Util.FormatDoubleLog(Math.Sqrt(hermiteConstant * (double)Lattice.Determinant)) + "\r\n");
            }

            paragraph.Inlines.Add(new Bold(new Run(Languages.labelReducedLatticeBasis + ":")));
            paragraph.Inlines.Add(" " + Lattice.LatticeReducedToString() + "\r\n");

            List <string> reductionSteps = Lattice.LatticeReductionStepsToString();

            for (int i = 1; i <= reductionSteps.Count; i++)
            {
                paragraph.Inlines.Add("    " + string.Format(Languages.labelReductionStep, i, reductionSteps.Count) + " " + reductionSteps[i - 1] + "\r\n");
            }

            paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelSuccessiveMinima)));
            paragraph.Inlines.Add(" " + Lattice.VectorReducedLengthToString() + "\r\n");

            if (Lattice.N == 2 && Lattice.M == 2)
            {
                paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelAngleReducedVectors)));
                paragraph.Inlines.Add(" " + Util.FormatDoubleLog(Lattice.AngleReducedVectors) + "\r\n");
                paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelDensity)));
                paragraph.Inlines.Add(" " + Util.FormatDoubleToPercentageLog(Lattice.Density) + " / " + Util.FormatDoubleToPercentageLog(Lattice.DensityRelToOptimum) + "\r\n");
            }

            paragraph.Inlines.Add(new Bold(new Run("   " + Languages.labelMinimalVector)));
            paragraph.Inlines.Add(" " + Lattice.GetMinimalReducedVector() + "\r\n");

            paragraph.Inlines.Add(new Bold(new Run(Languages.labelUnimodularTransformationMatrix)));
            paragraph.Inlines.Add(" " + Lattice.LatticeTransformationToString() + "\r\n");

            if (Lattice.N == Lattice.M)
            {
                paragraph.Inlines.Add(new Bold(new Run(Languages.labelDeterminant)));
                paragraph.Inlines.Add(" " + Lattice.Determinant + "\r\n");
            }

            if (History.Document.Blocks.FirstBlock != null)
            {
                History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
            }
            else
            {
                History.Document.Blocks.Add(paragraph);
            }
        }