Performance problem in C#

Hans-Peter Bittner 116 Reputation points
2021-12-23T22:10:37.173+00:00

I have a code-module in C#, which contains a loop with math. operations. At the end of each execution of the loop I get the UTC-time in milliseconds and store this by writeline() in a protocol-file (for example 200 lines at all). When the code-module is part of a small project, the loop runs quickly and with nearly constant speed. But when the identical code-module with the same input data is part of a bigger project, the loop runs at the beginning approx. 1.5 - 3 times slower and then the speed goes lower and lower. How is this possible? I have found no error in my code.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,266 questions
{count} votes

8 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,036 Reputation points
    2021-12-24T11:52:05.337+00:00

    Since there is a good deal of code there is no way I can point to specific code to consider refactoring. With that if data used in both projects are equal then use Visual Studio's profiler and if in the larger project there is more data than the smaller project that can mean the code is not optimal.

    the loop runs at the beginning approx. 1.5 - 3 times slower and then the speed goes lower and lower.

    Sounds like one or more objects are not being disposed and that leads back to working with Visual Studio's profiler and while doing this, under Debugger setting, Exception Settings check Common Language Runtime Exceptions, figure out why, fix and continue. I did notice you are ignoring exceptions in several places and that may possibly a place to start.

    1 person found this answer helpful.
    0 comments No comments

  2. Hans-Peter Bittner 116 Reputation points
    2021-12-23T23:17:49.557+00:00

    //My code-module:

            private int FunktionMath_FourierTransform(string argument)
            {
                int fehler = 0;
    
                //argument: (Typ1 Feld1, out Typ2 Feld2, Typ3 Vorwärts); //Diskrete Fourier-Transformation. 
                //Feld1 und Feld2 können zwei gleichgroße n-dimensionale Vektoren oder m x n Matrizen sein, wobei m, n ganzzahlig > 0 mit äquidistanten Stützpunkten sind.
                //Bei der Hin-Transformation mit  Vorwärts == "true" kann Typ1 "decimal" oder "complex" sein, 
                //bei der Rück-Transformation mit  Vorwärts == "false" wird Typ1 "complex" erwartet, 
                //Typ2 ist immer "complex", Typ3 ist \"var\" mit Subtyp "bool"
    
                string SystemLokal = ""; string meldung = "";
    
                bool diagnoselok = diagnosealt; 
    
                string[] trennmuster = { "," };
                int maxanzahl = 4;
                StringSplitOptions SSO = StringSplitOptions.RemoveEmptyEntries;//None
                string[] argumenteliste = argument.Split(trennmuster, maxanzahl, SSO);
    
                int anzahl = argumenteliste.Length;
    
                string ArgumentName = "";
                string ErgebnisName = "";
                string SteuerungName = "";
    
                //meldung = "Fourier Punkt 10: fehler = " + Convert.ToString(fehler);
                //ProtokollSchreiben.WriteLine(meldung);//Test
    
                if (anzahl == 3)
                {
                    ArgumentName = argumenteliste[0].Trim();
                    ErgebnisName = argumenteliste[1].Trim();
                    SteuerungName = argumenteliste[2].Trim();
    
                    ErgebnisName = VorwortOutAbschneiden(ErgebnisName);
    
                    bool rechenerfolgvor = OBR.GetRechenErfolg();
                    OBR.ResetRechenErfolg();
    
                    string EingabeTyp = ""; 
                    string AusgabeTyp = ""; string FeldElementTyp = "";
    
                    bool finde = VariablenNamePruefenDatentyp(ErgebnisName, out AusgabeTyp, out FeldElementTyp);
                    if (finde != true) { fehler = 1; }
    
                    ArrayList FeldWert = new ArrayList();
                    if (fehler == 0)
                    {
                        fehler = VariablenWertPruefen(ArgumentName, out FeldWert);
                    }
    
                    ArrayList SteuerungWert = new ArrayList();
                    if (fehler == 0)
                    {
                        fehler = VariablenWertPruefen(SteuerungName, out SteuerungWert);
                    }
    
                    bool Vorwärts = true;
                    if (fehler == 0)
                    {
                        string Vorwärtswort = (string)SteuerungWert[0];
                        Vorwärtswort = Vorwärtswort.ToLower();
                        if (Vorwärtswort == "false") { Vorwärts = false; }
                    }
    
                    //meldung = "Fourier Punkt 12: fehler = " + Convert.ToString(fehler);
                    //ProtokollSchreiben.WriteLine(meldung);//Test
    
                    ProgrammMethoden PM = new ProgrammMethoden();
                    string indexvektor; 
                    int index;
    
                    VariablenFeldDaten VarFeldDaten1 = new VariablenFeldDaten();
                    int DimAnzahl1 = 0;
    
                    int Achsenzahl11 = 0;
                    int Achsenzahl12 = 0;
                    int MatrixDezimalDim0 = 1;
                    int MatrixDezimalDim1 = 1;
                    int MatrixKomplexDim0 = 1;
                    int MatrixKomplexDim1 = 1;
    
                    int Achsenzahl1 = 0;
                    int VektorDezimalDim = 1;
                    int VektorKomplexDim = 1;
    
                    //meldung = "Fourier Punkt 13: fehler = " + Convert.ToString(fehler);
                    //ProtokollSchreiben.WriteLine(meldung);//Test
    
                    int laufanz = 0;
    
                    if (fehler == 0)
                    {
                        switch (FeldWert[0].GetType().Name)
                        {
                            case "VariablenFeldDaten":
                                VarFeldDaten1 = (VariablenFeldDaten)FeldWert[0];
                                DimAnzahl1 = VarFeldDaten1.DimensionenVektor.Count;
                                if (DimAnzahl1 == 2)
                                {
                                    Achsenzahl11 = (int)VarFeldDaten1.DimensionenVektor[0];
                                    Achsenzahl12 = (int)VarFeldDaten1.DimensionenVektor[1];
                                    EingabeTyp = VarFeldDaten1.Typ;
    
                                    if (0 < (Achsenzahl11 * Achsenzahl12))
                                    {
                                        /*
                                        //Nur für Fast-Fourier-Transform erforderlich:
                                        if ((Achsenzahl11 % 2 != 0) || (Achsenzahl12 % 2 != 0))
                                        {
                                            fehler = 1;
    
                                            SystemNavigation(out SystemLokal);
                                            meldung = "Fehler: Nur geradzahlige Anzahl von Elementen bei Matrix1 in jeder Dimension zulässig, " + SystemLokal + "; ";
                                            ProtokollSchreiben.WriteLine(meldung);
                                            if (ProgrammDebug == true)
                                            {
                                                if (DebugAnzeigeFrei == true)
                                                {
                                                    int Debugfehler = FunktionSystem_DebugInfo("");
                                                    DebugAnzeigeFrei = false;
                                                }
                                            }
                                        }
                                        */
    
                                        laufanz = Achsenzahl11 + Achsenzahl12; 
    
                                        if (EingabeTyp == "Dezimal")
                                        {
                                            MatrixDezimalDim0 = Achsenzahl11; MatrixDezimalDim1 = Achsenzahl12;
                                        }
                                        else
                                        {
                                            MatrixKomplexDim0 = Achsenzahl11; MatrixKomplexDim1 = Achsenzahl12;
                                        }                                    
                                    }
                                    else
                                    {
                                        fehler = 1;
    
                                        SystemNavigation(out SystemLokal);
                                        meldung = "Fehler: Anzahl der Elemente bei Matrix1 ist Null; " + SystemLokal + "; ";
                                        ProtokollSchreiben.WriteLine(meldung);
                                        if (ProgrammDebug == true)
                                        {
                                            if (DebugAnzeigeFrei == true)
                                            {
                                                int Debugfehler = FunktionSystem_DebugInfo("");
                                                DebugAnzeigeFrei = false;
                                            }
                                        }
                                    }
                                }
                                else if (DimAnzahl1 == 1)
                                {
                                    Achsenzahl1 = (int)VarFeldDaten1.DimensionenVektor[0];
                                    EingabeTyp = VarFeldDaten1.Typ;
    
                                    if (0 < Achsenzahl1)
                                    {
                                        /*
                                        //Nur für Fast-Fourier-Transform erforderlich:
                                        if (Achsenzahl1 % 2 != 0)
                                        {
                                            fehler = 1;
    
                                            SystemNavigation(out SystemLokal);
                                            meldung = "Fehler: Nur geradzahlige Anzahl von Elementen bei Vektor1 zulässig, " + SystemLokal + "; ";
                                            ProtokollSchreiben.WriteLine(meldung);
                                            if (ProgrammDebug == true)
                                            {
                                                if (DebugAnzeigeFrei == true)
                                                {
                                                    int Debugfehler = FunktionSystem_DebugInfo("");
                                                    DebugAnzeigeFrei = false;
                                                }
                                            }
                                        }
                                        */
    
                                        laufanz = 1;
    
                                        if (EingabeTyp == "Dezimal")
                                        {
                                            VektorDezimalDim = Achsenzahl1;
                                        }
                                        else
                                        {
                                            VektorKomplexDim = Achsenzahl1;
                                        }                                                                      
                                    }
                                    else
                                    {
                                        fehler = 1;
    
                                        SystemNavigation(out SystemLokal);
                                        meldung = "Fehler: Anzahl der Elemente bei Vektor1 ist Null; " + SystemLokal + "; ";
                                        ProtokollSchreiben.WriteLine(meldung);
                                        if (ProgrammDebug == true)
                                        {
                                            if (DebugAnzeigeFrei == true)
                                            {
                                                int Debugfehler = FunktionSystem_DebugInfo("");
                                                DebugAnzeigeFrei = false;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    fehler = 1;
    
                                    SystemNavigation(out SystemLokal);
                                    meldung = "Fehler: Nur max. 2 Dimensionen bei Feld1 zulässig; " + SystemLokal + "; ";
                                    ProtokollSchreiben.WriteLine(meldung);
                                    if (ProgrammDebug == true)
                                    {
                                        if (DebugAnzeigeFrei == true)
                                        {
                                            int Debugfehler = FunktionSystem_DebugInfo("");
                                            DebugAnzeigeFrei = false;
                                        }
                                    }
                                }                           
                                break;
                            default:
                                fehler = 1;
                                break;
                        }
                        if (fehler != 0)
                        {
                            SystemNavigation(out SystemLokal);
                            meldung = "Fehler: Datentyp von Parameter 1 ist unzulässig; " + SystemLokal + "; ";
                            ProtokollSchreiben.WriteLine(meldung);
                            if (ProgrammDebug == true)
                            {
                                if (DebugAnzeigeFrei == true)
                                {
                                    int Debugfehler = FunktionSystem_DebugInfo("");
                                    DebugAnzeigeFrei = false;
                                }
                            }
                        }
                    }
    
                    //meldung = "Fourier Punkt 2: fehler = " + Convert.ToString(fehler) + ", DimAnzahl1 = " + Convert.ToString(DimAnzahl1) + ", Achsenzahl1 = " + Convert.ToString(Achsenzahl1) + ", Achsenzahl11 = " + Convert.ToString(Achsenzahl11) + ", Achsenzahl12 = " + Convert.ToString(Achsenzahl12);
                    //ProtokollSchreiben.WriteLine(meldung);//Test
    
                    if (fehler == 0)
                    {
                        FunktionC();//Löschen der x- und y-Zeile
                        FunktionDegree("false");//Winkeleinheit zu rad umschalten
    
                        int moduli = 1; string modulmax = laufanz.ToString();
    
                        DiagnoseAnzeige DA;
                        DA = new DiagnoseAnzeige();
    
                        if (diagnoselok == true)
                        {
                            DA.Opacity = 100;
                            DA.Show();
                        }
    
                        Dezimal DeziWert = new Dezimal();
                        DeziWert.Mantisse = 0; DeziWert.Exponent = 0;
    
                        if (DimAnzahl1 == 2)
                        {
                            Dezimal[,] Matrix1Dezimalelem = new Dezimal[MatrixDezimalDim0, MatrixDezimalDim1];
                            Komplex[,] Matrix1Komplexelem = new Komplex[MatrixKomplexDim0, MatrixKomplexDim1];
    
                            /*
                            if (EingabeTyp == "Dezimal")//Test
                            {
                                TestDatenSetzenDezimal(Achsenzahl11, Achsenzahl12, out Matrix1Dezimalelem);
                            }
                            else
                            {
                                TestDatenSetzenKomplex(Achsenzahl11, Achsenzahl12, out Matrix1Komplexelem);                        
                            }
                            */
    
                            //Orig 
                            for (int i = 0; (i < Achsenzahl11) && (fehler == 0); i++)
                            {
                                for (int j = 0; (j < Achsenzahl12) && (fehler == 0); j++)
                                {
                                    indexvektor = "[" + Convert.ToString(i) + "][" + Convert.ToString(j) + "]";
                                    fehler = PM.VariablenFeldElementBehandeln(VarFeldDaten1.DimensionenVektor, indexvektor, out index);
                                    if (fehler == 0)
                                    {
                                        if (EingabeTyp == "Dezimal")
                                        {
                                            Matrix1Dezimalelem[i, j] = (Dezimal)VarFeldDaten1.Wert[index];
                                        }
                                        else
                                        {
                                            Matrix1Komplexelem[i, j] = (Komplex)VarFeldDaten1.Wert[index];
                                        }
                                    }
                                }
                            }
    
                            Komplex[,] ErgebnisMatrixKomplexWert = new Komplex[Achsenzahl11, Achsenzahl12];
                            for (int i = 0; i < Achsenzahl11; i++)//nzb
                            {
                                for (int j = 0; j < Achsenzahl12; j++)
                                {
                                    ErgebnisMatrixKomplexWert[i, j].Re = DeziWert;
                                    ErgebnisMatrixKomplexWert[i, j].Im = DeziWert;
                                }
                            }
    
                            fehler = FunkFourierTransform2Dim(Matrix1Dezimalelem, Matrix1Komplexelem, EingabeTyp, out ErgebnisMatrixKomplexWert, Vorwärts, moduli, modulmax, diagnoselok, DA);
    
                            //meldung = "Fourier Punkt 3: fehler = " + Convert.ToString(fehler);
                            //ProtokollSchreiben.WriteLine(meldung);//Test                                        
    
                            for (int i = 0; (i < Achsenzahl11) && (fehler == 0); i++)
                            {
                                for (int j = 0; (j < Achsenzahl12) && (fehler == 0); j++)
                                {
                                    FeldWert.Clear();
                                    FeldWert.Add(ErgebnisMatrixKomplexWert[i, j]);
    
                                    string ErgebnisNameElem = ErgebnisName + "[" + Convert.ToString(i) + "][" + Convert.ToString(j) + "]";
                                    fehler = VariablenWertSetzen(ErgebnisNameElem, FeldWert);
                                }
                            }
                        }
                        else if (DimAnzahl1 == 1)
                        {
                            Dezimal[] Vektor1Dezimalelem = new Dezimal[VektorDezimalDim];
                            Komplex[] Vektor1Komplexelem = new Komplex[VektorKomplexDim];                   
    
                            for (int i = 0; (i < Achsenzahl1) && (fehler == 0); i++)
                            {
                                if (EingabeTyp == "Dezimal")
                                {
                                    Vektor1Dezimalelem[i] = (Dezimal)VarFeldDaten1.Wert[i];
                                }
                                else
                                {
                                    Vektor1Komplexelem[i] = (Komplex)VarFeldDaten1.Wert[i];
                                }
                            } 
    
                            Komplex[] ErgebnisVektorKomplexWert = new Komplex[Achsenzahl1];
                            for (int i = 0; i < Achsenzahl1; i++)//nzb
                            {
                                ErgebnisVektorKomplexWert[i].Re = DeziWert;
                                ErgebnisVektorKomplexWert[i].Im = DeziWert;                            
                            }
    
                            fehler = FunkFourierTransform1Dim(Vektor1Dezimalelem, Vektor1Komplexelem, EingabeTyp, out ErgebnisVektorKomplexWert, Vorwärts, moduli, modulmax, diagnoselok, DA);
    
                            //meldung = "Fourier Punkt 4: fehler = " + Convert.ToString(fehler);
                            //ProtokollSchreiben.WriteLine(meldung);//Test
    
                            for (int i = 0; (i < Achsenzahl1) && (fehler == 0); i++)
                            {
                                FeldWert.Clear();
                                FeldWert.Add(ErgebnisVektorKomplexWert[i]);
    
                                string ErgebnisNameElem = ErgebnisName + "[" + Convert.ToString(i) + "]";
                                fehler = VariablenWertSetzen(ErgebnisNameElem, FeldWert);                            
                            }
                        }
                        else { fehler = 1; }
    
                        DA.Close();            
                    }
    
                    OBR.SetRechenErfolg(rechenerfolgvor);                
                }
                else
                {
                    fehler = 1;
    
                    SystemNavigation(out SystemLokal);
                    meldung = "Fehler in " + SystemLokal + ": Nur 3 Parameter bei Aufruf der Funktion zulässig; ";
                    ProtokollSchreiben.WriteLine(meldung);
                    if (ProgrammDebug == true)
                    {
                        if (DebugAnzeigeFrei == true)
                        {
                            int Debugfehler = FunktionSystem_DebugInfo("");
                            DebugAnzeigeFrei = false;
                        }
                    }
                }                 
    
                return fehler;
            }
    
            private void TestDatenSetzenDezimal(int Vekdim0, int Vekdim1, out Dezimal[,] Matrix1Dezimalelem)//Test
            {
                bool diagnoselok = false; string status = ""; string statuslok = "";
    
                Dezimal DeziNull = new Dezimal();
                DeziNull.Mantisse = 0; DeziNull.Exponent = 0;
    
                BigInteger PImant; int PIexpo;
                OBR.Pi(out PImant, out PIexpo, diagnoselok, out statuslok);//Pi lang
    
                BigInteger PiViertelmant; int PiViertelexpo;
                BigInteger ymant = 4; int yexpo = 0;
                OBR.DivideDez(PImant, PIexpo, ymant, yexpo, out PiViertelmant, out PiViertelexpo, diagnoselok, out statuslok);
                status += statuslok;
    
                BigInteger SinPiViertelmant; int SinPiViertelexpo;
                int modulilok = 0; int moduljlok = 0; string modulmaxlok = "1";
                OBR.Sin(PiViertelmant, PiViertelexpo, out SinPiViertelmant, out SinPiViertelexpo, diagnoselok, modulilok, out moduljlok, modulmaxlok, out statuslok);
                status += statuslok;
    
                Dezimal SinPiViertel = new Dezimal();
                SinPiViertel.Mantisse = SinPiViertelmant; SinPiViertel.Exponent = SinPiViertelexpo;
    
                BigInteger Amplitudemant = 1; int Amplitudeexpo = 0;
                Dezimal Amplitude = new Dezimal();
                Amplitude.Mantisse = Amplitudemant; Amplitude.Exponent = Amplitudeexpo;
    
                int Elodim = 8;
                Dezimal[] Elongation = new Dezimal[Elodim];
                int k = 0;
                while (k < Elodim - 3)
                {
                    Elongation[k + 0] = DeziNull;
                    Elongation[k + 1] = SinPiViertel;
                    Elongation[k + 2] = Amplitude;
                    Elongation[k + 3] = SinPiViertel;
    
                    SinPiViertel.Mantisse = (-1) * SinPiViertel.Mantisse;
                    Amplitude.Mantisse = (-1) * Amplitude.Mantisse;
    
                    k = k + 4;
                }
    
                Matrix1Dezimalelem = new Dezimal[Vekdim0, Vekdim1];
    
                k = 0;
                int m; int n;
                for (int i = 0; i < Vekdim0; i++)
                {
                    m = k + i;
                    for (int j = 0; j < Vekdim1; j++)
                    {
                        n = m + j;
                        Matrix1Dezimalelem[i, j] = Elongation[n % Elodim];
                    }
                }
            }
    
            private void TestDatenSetzenKomplex(int Vekdim0, int Vekdim1, out Komplex[,] Matrix1Komplexelem)//Test
            {
                bool diagnoselok = false; string status = ""; string statuslok = "";
    
                Dezimal DeziNull = new Dezimal();
                DeziNull.Mantisse = 0; DeziNull.Exponent = 0;
    
                BigInteger PImant; int PIexpo;
                OBR.Pi(out PImant, out PIexpo, diagnoselok, out statuslok);//Pi lang
    
                BigInteger PiViertelmant; int PiViertelexpo;
                BigInteger ymant = 4; int yexpo = 0;
                OBR.DivideDez(PImant, PIexpo, ymant, yexpo, out PiViertelmant, out PiViertelexpo, diagnoselok, out statuslok);
                status += statuslok;
    
                BigInteger SinPiViertelmant; int SinPiViertelexpo;
                int modulilok = 0; int moduljlok = 0; string modulmaxlok = "1";
                OBR.Sin(PiViertelmant, PiViertelexpo, out SinPiViertelmant, out SinPiViertelexpo, diagnoselok, modulilok, out moduljlok, modulmaxlok, out statuslok);
                status += statuslok;
    
                Dezimal SinPiViertel = new Dezimal();
                SinPiViertel.Mantisse = SinPiViertelmant; SinPiViertel.Exponent = SinPiViertelexpo;
    
                BigInteger Amplitudemant = 1; int Amplitudeexpo = 0;
                Dezimal Amplitude = new Dezimal();
                Amplitude.Mantisse = Amplitudemant; Amplitude.Exponent = Amplitudeexpo;
    
                int Elodim = 8;
                Dezimal[] Elongation = new Dezimal[Elodim];
                int k = 0;
                while (k < Elodim - 3)
                {
                    Elongation[k + 0] = DeziNull;
                    Elongation[k + 1] = SinPiViertel;
                    Elongation[k + 2] = Amplitude;
                    Elongation[k + 3] = SinPiViertel;
    
                    SinPiViertel.Mantisse = (-1) * SinPiViertel.Mantisse;
                    Amplitude.Mantisse = (-1) * Amplitude.Mantisse;
    
                    k = k + 4;
                }
    
                Matrix1Komplexelem = new Komplex[Vekdim0, Vekdim1];
    
                k = 0;
                int m; int n;
                for (int i = 0; i < Vekdim0; i++)
                {
                    m = k + i;
                    for (int j = 0; j < Vekdim1; j++)
                    {
                        n = m + j;
                        Matrix1Komplexelem[i, j].Re = Elongation[n % Elodim];
                        Matrix1Komplexelem[i, j].Im = Elongation[n % Elodim];
                    }
                }
            }
    
            private int FunkFourierTransform1Dim(Dezimal[] Vektor1Dezimalelem, Komplex[] Vektor1Komplexelem, string EingabeTyp, out Komplex[] ErgebnisVektorKomplexWert, bool Vorwärts, int moduli, string modulmax, bool diagnosevor, DiagnoseAnzeige DA)
            {
                int fehler = 0;
    
                //Diskrete Fourier-Transformation. 
                //Feld1, Feld2 und out Feld3 können drei gleichgroße n-dimensionale Vektoren sein, wobei n ganzzahlig > 0 ist.
    
                string SystemLokal; string meldung;
    
                bool diagnoselok = false;
                //Versuch: diagnoselok = diagnosevor; //Führt zu Flackern der Anzeige wegen OBR.Cos und OBR.Sin, bei OBR.AddDez, OBR.SubtractDez, OBR.MultiplyDez und OBR.DivideDez wird diagnose nicht benutzt
    
                if (diagnosevor == true)
                {
                    DA.Refresh();
                    DA.SetDiagnoseAnzeige(1, "Teil " + moduli.ToString() + " / " + modulmax + "; Modul: Math_FourierTransform()");
                    DA.SetDiagnoseAnzeige(2, "Berechnung wird ausgeführt ...");
                    DA.SetDiagnoseAnzeige(3, "Fortschritt: 0 %");
                }
    
                int Ergebnisdim = 0;
                if (EingabeTyp == "Dezimal")
                {
                    Ergebnisdim = Vektor1Dezimalelem.Length;
                }
                else
                {
                    Ergebnisdim = Vektor1Komplexelem.Length;
                }
                //meldung = "Fourier1Dim Punkt 1: fehler = " + Convert.ToString(fehler) + ", EingabeTyp = " + EingabeTyp + ", Ergebnisdim = " + Convert.ToString(Ergebnisdim);
                //ProtokollSchreiben.WriteLine(meldung);//Test                            
    
                Dezimal ErgebnisDezimalWert = new Dezimal();
                ErgebnisDezimalWert.Mantisse = 0; ErgebnisDezimalWert.Exponent = 0;
                ErgebnisVektorKomplexWert = new Komplex[Ergebnisdim];
    
                //Initialisierung bringt (keinen) Geschwindigkeitsvorteil: 
                //for (int i = 0; i < Ergebnisdim; i++)
                //{
                //    ErgebnisVektorKomplexWert[i].Re = ErgebnisDezimalWert;
                //    ErgebnisVektorKomplexWert[i].Im = ErgebnisDezimalWert;
                //}
    
                BigInteger Remant = 0; int Reexpo = 0;
                BigInteger Immant = 0; int Imexpo = 0;
                BigInteger xmant = 0; int xexpo = 0;
                BigInteger ymant = 0; int yexpo = 0;
                BigInteger zmant = 0; int zexpo = 0;
                BigInteger umant = 0; int uexpo = 0;
                BigInteger vmant = 0; int vexpo = 0;
                BigInteger wmant = 0; int wexpo = 0;
                BigInteger SignPhiKonstmant = 0; int SignPhiKonstexpo = 0;
    
                Komplex WertKompx;
    
                string status = ""; string statuslok = "";
    
                bool rechenerfolg = OBR.GetRechenErfolg();
                if (rechenerfolg != true)
                {
                    fehler = 1;
                }           
    
                OBR.Pi(out ymant, out yexpo, diagnoselok, out statuslok);//Pi lang
                status += statuslok;
                xmant = 2; xexpo = 0;
                OBR.MultiplyDez(xmant, xexpo, ymant, yexpo, out SignPhiKonstmant, out SignPhiKonstexpo, diagnoselok, out statuslok);
                status += statuslok;
    
                ymant = Ergebnisdim; yexpo = 0;
                OBR.DivideDez(SignPhiKonstmant, SignPhiKonstexpo, ymant, yexpo, out SignPhiKonstmant, out SignPhiKonstexpo, diagnoselok, out statuslok);
                status += statuslok;
    
                if (Vorwärts == true)
                {
                    SignPhiKonstmant = BigInteger.Negate(SignPhiKonstmant);//Signum für Phi im Exponent
                }
    
                int modulilok = 0; int moduljlok = 0; string modulmaxlok = "1";
                BigInteger SignPhiKonstimant; int SignPhiKonstiexpo;
                BigInteger SignPhiKonstijmant; int SignPhiKonstijexpo;
    
                for (int i = 0; (i < Ergebnisdim) && (fehler == 0); i++)
                {
                    ymant = i; yexpo = 0;
                    OBR.MultiplyDez(SignPhiKonstmant, SignPhiKonstexpo, ymant, yexpo, out SignPhiKonstimant, out SignPhiKonstiexpo, diagnoselok, out statuslok);
                    status += statuslok;
    
                    for (int j = 0; (j < Ergebnisdim) && (fehler == 0); j++) 
                    {
                        ymant = j; yexpo = 0;
                        OBR.MultiplyDez(SignPhiKonstimant, SignPhiKonstiexpo, ymant, yexpo, out SignPhiKonstijmant, out SignPhiKonstijexpo, diagnoselok, out statuslok);
                        status += statuslok;
    
                        OBR.Cos(SignPhiKonstijmant, SignPhiKonstijexpo, out ymant, out yexpo, diagnoselok, modulilok, out moduljlok, modulmaxlok, out statuslok);
                        status += statuslok;
    
                        OBR.Sin(SignPhiKonstijmant, SignPhiKonstijexpo, out vmant, out vexpo, diagnoselok, modulilok, out moduljlok, modulmaxlok, out statuslok);
                        status += statuslok;
    
                        if (EingabeTyp == "Dezimal")
                        {
                            xmant = Vektor1Dezimalelem[j].Mantisse; xexpo = Vektor1Dezimalelem[j].Exponent;
    
                            OBR.MultiplyDez(xmant, xexpo, ymant, yexpo, out zmant, out zexpo, diagnoselok, out statuslok);
                            status += statuslok;                        
                            OBR.MultiplyDez(xmant, xexpo, vmant, vexpo, out wmant, out wexpo, diagnoselok, out statuslok);
                            status += statuslok;
                        }
                        else
                        {
                            WertKompx = Vektor1Komplexelem[j];
    
                            ErgebnisDezimalWert = WertKompx.Re;
                            xmant = ErgebnisDezimalWert.Mantisse; xexpo = ErgebnisDezimalWert.Exponent;
                            ErgebnisDezimalWert = WertKompx.Im;
                            umant = ErgebnisDezimalWert.Mantisse; uexpo = ErgebnisDezimalWert.Exponent; 
    
                            fehler = OBR.MultiplyKomplex(xmant, xexpo, umant, uexpo, ymant, yexpo, vmant, vexpo, out zmant, out zexpo, out wmant, out wexpo, diagnoselok, out statuslok);
                            status += statuslok;                        
                        }
                        OBR.AddDez(Remant, Reexpo, zmant, zexpo, out Remant, out Reexpo, diagnoselok, out statuslok);
                        status += statuslok;
                        OBR.Ad
    
    0 comments No comments

  3. Hans-Peter Bittner 116 Reputation points
    2021-12-24T05:41:32.743+00:00

    Next step: You asked me for the context in the bigger project. That is an interpreter, which can interpret various script-files. Each time, when the following statement in a script is interpreted,

    Math_FourierTransform(Matrix1, out Matrix2, Vorwärts);

    the interpreter calls my code-module: FunktionMath_FourierTransform(string argument)

    An example for a working script-file is as follows (see lines #105 and #132):

    /****************************************************************************************
    *                                           *
    *   Beispiel 2760 Math_FourierTransform.BIT             *
    *                                           *
    *   Autor Hans-Peter Bittner (2021)                     *
    *                                           *
    ****************************************************************************************/
    
    main()
    {
        var Punkt1;
        GetUTC (out Punkt1);
    
        DeleteAll();
        C();
    
        SetX("//Sinusfunktion / Phase ====================================");
        M();
    
        var Modus;
        GetModus(out Modus);
        var ModusSatz = "Modus: " + Modus;
        SetX(ModusSatz);
        M();
    
        decimal Vekdim1 = 25;
        decimal Vekdim2 = 25;
        decimal Matrix1 = new decimal [Vekdim1][Vekdim2];
    
        var Vekdim1Wort;
        Convert_ToString(Vekdim1, out Vekdim1Wort);
        var Vekdim2Wort;
        Convert_ToString(Vekdim2, out Vekdim2Wort);
        var Vekdim1Satz = "Dim: [" + Vekdim1Wort + "][" + Vekdim2Wort + "]";
        SetX(Vekdim1Satz);
        M();
    
        SetX("//Fourier-Transform 2 Dim Teil 1: Eingabedaten =============");
        M();
    
        C();
        Degree(false);
    
        decimal PI;
        Math_Pi(out PI);
        decimal PiViertel = PI / 4;
        decimal SinPiViertel;
        Math_Sin(PiViertel, out SinPiViertel);
        decimal Amplitude = 1; 
    
        decimal Elodim = 8;
        decimal Elongation = new decimal [Elodim];
        decimal k = 0;
        while (k < Elodim - 3)
        {
            Elongation [k + 0] = 0;
            Elongation [k + 1] = SinPiViertel;
            Elongation [k + 2] = Amplitude;
            Elongation [k + 3] = SinPiViertel;
    
            SinPiViertel = (-1) * SinPiViertel;
            Amplitude = (-1) * Amplitude;
    
            k = k + 4;
        }   
    
        decimal i; 
        decimal j; 
        k = 0;
        decimal m;
        decimal n;
        for (i = 0; i < Vekdim1; i = i + 1)
        {
            m = k + i;
            for (j = 0; j < Vekdim2; j = j + 1)
            {
                n = m + j;
                Matrix1[i][j] = Elongation [n % Elodim];
            }
        }
    
        for (i = 0; i < Vekdim1; i = i + 1)
        {
            for (j = 0; j < Vekdim2; j = j + 1)
            {
                SetX(Matrix1[i][j]);
                M();
            }
        }
    
        var Punkt2;
        GetUTC (out Punkt2);
    
        var Langform = false;
        var Dauer;
    
        SetX("//Fourier-Transform 2 Dim Teil 2: Vorwärts =================");
        M();
    
        var Punkt3;
        GetUTC (out Punkt3);
    
        complex Matrix2 = new complex [Vekdim1][Vekdim2];
        var Vorwärts = true;
        Math_FourierTransform(Matrix1, out Matrix2, Vorwärts);
    
        var Punkt4;
        GetUTC (out Punkt4);
    
        for (i = 0; i < Vekdim1; i = i + 1)
        {
            for (j = 0; j < Vekdim2; j = j + 1)
            {
                SetX(Matrix2[i][j]);
                M();
            }
        }
    
        var Punkt5;
        GetUTC (out Punkt5);
    
        //Hier kann eine Zwischenverarbeitung stattfinden ================
    
        SetX("//Fourier-Transform 2 Dim Teil 3: Rückwärts ================");
        M();
    
        var Punkt6;
        GetUTC (out Punkt6);
    
        complex Matrix3 = new complex [Vekdim1][Vekdim2];
        Vorwärts = false;
        Math_FourierTransform(Matrix2, out Matrix3, Vorwärts);
    
        var Punkt7;
        GetUTC (out Punkt7);
    
        for (i = 0; i < Vekdim1; i = i + 1)
        {
            for (j = 0; j < Vekdim2; j = j + 1)
            {
                SetX(Matrix3[i][j]);
                M(); // Richtig
            }
        }
    
        var Punkt8;
        GetUTC (out Punkt8);
    
        SetX("//Fourier-Transform 2 Dim Bericht ==========================");
        M();
    
        GetTimeSpanString(Punkt1, Punkt2, Langform, out Dauer);
        SetX("Teil 1 gesamt: ");
        M();
        SetX(Dauer);
        M();
    
        GetTimeSpanString(Punkt3, Punkt4, Langform, out Dauer);
        SetX("Teil 2 Reine Transformation: ");
        M();
        SetX(Dauer);
        M();
    
        GetTimeSpanString(Punkt3, Punkt5, Langform, out Dauer);
        SetX("Teil 2 gesamt: ");
        M();
        SetX(Dauer);
        M();
    
        GetTimeSpanString(Punkt6, Punkt7, Langform, out Dauer);
        SetX("Teil 3 Reine Transformation: ");
        M();
        SetX(Dauer);
        M();
    
        GetTimeSpanString(Punkt6, Punkt8, Langform, out Dauer);
        SetX("Teil 3 gesamt: ");
        M();
        SetX(Dauer);
        M();
    
        var Punkt9;
        GetUTC (out Punkt9);
    
        GetTimeSpanString(Punkt1, Punkt9, Langform, out Dauer);
        SetX("Reine Rechenzeit mit Anzeige gesamt: ");
        M();
        SetX(Dauer);
        M();
    }
    
    0 comments No comments

  4. Hans-Peter Bittner 116 Reputation points
    2021-12-24T06:16:16.33+00:00

    Next step: The main parts of my small project are as follows (see lines #405 and #412):

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;//Dateizugriff
    using System.Linq;
    using System.Numerics;//BigInteger
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    using BIT_Programm;
    using MeinRechnerDiagnose;
    using MeinRechnerERLib;
    using MeinRechnerPRLib;
    using BIT_BigRational;
    
    namespace Try_catch_Zeit
    {
        public partial class Form1 : Form
        {
            private OIKOS_BigRational OBR;
    
            //private BigInteger maxRechenoperationen = 1000000;//Für Operation 1 und 2
            private BigInteger maxRechenoperationen = 10000;//Für Operation 3
            private BigInteger Rechenoperationen;
            private BigInteger maxTeile = 1000;
            private BigInteger Teile;
            private int Durchlauf;
            private BigInteger Fortschritt;
            private string Protokollpfad;
            private string maxExp = "99999999";
            //private string maxDezi = "64";//Für Operation 1 und 2
            private string maxDezi = "20";//Für Operation 3 und 4
            private bool rechenerfolg;
    
            public Form1()
            {
                InitializeComponent();
    
                bool MantisseEndNullen = false;
                int moduli = 0; string modulmax = "17";
                OIKOS_PotenzReiheZwei ER = new OIKOS_PotenzReiheZwei(moduli, out moduli, modulmax);//Anzahl Module: 1
                OIKOS_ProduktReihenLib PR = new OIKOS_ProduktReihenLib(moduli, out moduli, modulmax);//Anzahl Module: 16
    
                OBR = new OIKOS_BigRational(maxExp, maxDezi, MantisseEndNullen, Protokollpfad, ER, PR);
    
                this.lblRechenoperationen.Text = "Anzahl der Rechenoperationen [1 <= x <= " + Convert.ToString(maxRechenoperationen) + "] pro Teil:";
                //this.txtRechenoperationen.Text = "50000";//Für Operation 1 und 2
                //this.txtRechenoperationen.Text = "1";//Für Operation 3
                this.txtRechenoperationen.Text = "10";//Für Operation 4
    
                this.lblTeile.Text = "Anzahl der Teile [1 <= x <= " + Convert.ToString(maxTeile) + "] pro Durchlauf:";
                //this.txtTeile.Text = "200";//Für Operation 1 und 2
                //this.txtTeile.Text = "50";//Für Operation 3
                this.txtTeile.Text = "1";//Für Operation 4
    
                Durchlauf = 0;
                //this.lblDurchlaufWert.Text = Convert.ToString(Durchlauf) + " / 2";//Für Operation 1 - 3
                this.lblDurchlaufWert.Text = "";//Für Operation 4
    
                Fortschritt = 0;
                //this.lblFortschrittWert.Text = Convert.ToString(Fortschritt) + " %";//Für Operation 1 - 3
                this.lblFortschrittWert.Text = "";//Für Operation 4
    
                this.rechenerfolg = true;
    
                this.txtStatus.Text = "Bereit; ";
            }
    
            private void btnStart_Click(object sender, EventArgs e)
            {
                int fehler = 0;
    
                if (fehler == 0)
                {
                    try
                    {
                        Rechenoperationen = BigInteger.Parse(this.txtRechenoperationen.Text);
                        if ((Rechenoperationen < 1) || (maxRechenoperationen < Rechenoperationen)) { fehler = 1; }
                    }
                    catch
                    {
                        fehler = 1;
                    }
                    if (fehler != 0) { this.txtStatus.Text = "Fehler bei Anzahl der Rechenoperationen; Bereit; "; }
                }
                if (fehler == 0)
                {
                    try
                    {
                        Teile = BigInteger.Parse(this.txtTeile.Text);
                        if ((Teile < 1) || (maxTeile < Teile)) { fehler = 1; }
                    }
                    catch
                    {
                        fehler = 1;
                    }
                    if (fehler != 0) { this.txtStatus.Text = "Fehler bei Anzahl der Teile; Bereit; "; }
                }
                if (fehler == 0)
                {
                    bool erfolg = true;
    
                    string doku = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    //Hier Unterverzeichnis anlegen für Progdatenexport
                    string Dokuordner = "";
                    string DokuordnerVersion = "";
    
                    try
                    {
                        if (System.IO.Directory.Exists(doku))
                        {
                            Dokuordner = doku + @"\UniOIKOSBIT";
                            if (System.IO.Directory.Exists(Dokuordner))
                            {
                                ;
                            }
                            else
                            {
                                System.IO.Directory.CreateDirectory(Dokuordner);
                            }
    
                            DokuordnerVersion = Dokuordner + @"\MR_51";
                            if (System.IO.Directory.Exists(DokuordnerVersion))
                            {
                                ;
                            }
                            else
                            {
                                System.IO.Directory.CreateDirectory(DokuordnerVersion);
                            }
    
                            Protokollpfad = DokuordnerVersion + @"\Protokoll_MR_51";                                                
                        }
                        else
                        {
                            erfolg = false;
                            this.txtStatus.Text = "Protokoll-Ordner nicht gefunden.";
                        }
                    }
                    catch
                    {
                        erfolg = false;
                        this.txtStatus.Text = "Fehler bei Protokoll-Verzeichnis";
                    }
                    if (erfolg != true) { fehler = 1; }
                }
    
                bool Try_catch;
                Durchlauf = 0;
                this.txtStatus.Text = "Programm wird ausgeführt ...; ";
                this.txtStatus.Refresh();
                if (fehler == 0)
                {
                    /*
                    //Nur für Operation 1 - 3 (zur Vereinfachung)
                    Try_catch = false;
                    Durchlauf++;
                    fehler = Rechenlauf(Try_catch, Durchlauf, Teile, Rechenoperationen);//Außerhalb von try/catch
    
                    if (fehler != 0) { this.txtStatus.Text = "Durchlauf = " + Convert.ToString(Durchlauf) + "; Fehler = " + Convert.ToString(fehler) + "; Bereit; "; }
                    */
                }
    
                if (fehler == 0)
                {
                    Try_catch = true;
                    Durchlauf++;
                    try
                    {
                        fehler = Rechenlauf(Try_catch, Durchlauf, Teile, Rechenoperationen);//Innerhalb von try/catch
                    }
                    catch
                    {
                        fehler = 1;
                    }
    
                    if (fehler != 0) { this.txtStatus.Text = "Durchlauf = " + Convert.ToString(Durchlauf) + "; Fehler = " + Convert.ToString(fehler) + "; Bereit; "; }
                }
    
                if (fehler == 0)
                {
                    this.txtStatus.Text = "Programm richtig ausgeführt; Bereit; ";
                }
                else
                {
                    this.txtStatus.Text = "Abnormales Programm-Ende; " + this.txtStatus.Text;  
                }
            }
    
            private int Rechenlauf(bool Try_catch, int Durchlauf, BigInteger Teile, BigInteger Rechenoperationen)
            {
                int fehler = 0;
    
                //this.lblDurchlaufWert.Text = Convert.ToString(Durchlauf) + " / 2";//Für Operation 1 - 3
                this.lblDurchlaufWert.Text = "";//Für Operation 4
                this.lblDurchlaufWert.Refresh();
                /*
                //Nur für Operation 1 - 3 Anfang
                string jetzt = OBR.GetUTCZeit();
    
                this.lblFortschrittWert.Text = "0 %";
                this.lblFortschrittWert.Refresh();
    
                if (System.IO.Directory.Exists(Protokollpfad))
                {
                }
                else
                {
                    System.IO.Directory.CreateDirectory(Protokollpfad);
                }
                string dateiaus = Protokollpfad + @"\Try_catch_Zeit_" + jetzt + ".TXT";
    
                int Dateifehler = 0;
                StreamWriter sw = null;
    
                try
                {
                    bool append = true;
                    sw = new StreamWriter(dateiaus, append);
    
                    sw.WriteLine("Try_catch_Zeit: Tc = " + Convert.ToString(Try_catch) + ", Durchlauf = " + Convert.ToString(Durchlauf) + ", Teile = " + Convert.ToString(Teile) + ", Rechenoperationen pro Teil = " + Convert.ToString(Rechenoperationen) + "\n");
                }
                catch
                {
                    fehler = 1; Dateifehler = 1;
                }
                //Nur für Operation 1 - 3 Ende
                */
    
                if (fehler == 0)
                {
                    /*
                    //Nur für Operation 1 - 3 Anfang
                    DateTime Punkt1; DateTime Punkt2;
                    Punkt1 = OBR.GetUTC();
    
                    BigInteger RechenErgebnis;
                    Komplex RechenErgebnisKomplex;
                    Komplex[] RechenErgebnisVektorKomplex;
                    //Nur für Operation 1 - 3 Ende
                    */
                    Komplex[,] RechenErgebnisMatrixKomplex;
                    /*
                    //Nur für Operation 1 - 3 Anfang
                    BigInteger Millisekmant; int Millisekexpo;
                    bool diagnoselok = false; string status;
                    string Protokollsatz;
                    //Nur für Operation 1 - 3 Ende
                    */
    
                    for (BigInteger iTeil = 0; (iTeil < Teile) && (fehler == 0); iTeil++)
                    {
                        //Es sollte nur eine der folgenden Operationen aktiviert sein:
    
                        //Operation1(Rechenoperationen, out RechenErgebnis);//Geschwindigkeitsverlauf mit Stufe bei Rechenoperationen = 50000, unabh. von Try/catch; Geschwindigkeitsverlauf etwa Konstant bei Rechenoperationen = 100000
    
                        //Operation2(Rechenoperationen, out RechenErgebnisKomplex);//Geschwindigkeitsverlauf etwa Konstant bei Rechenoperationen = 50000, unabh. von Try/catch
    
                        //fehler = Operation3(Rechenoperationen, out RechenErgebnisVektorKomplex);//Geschwindigkeitsverlauf etwa konstant bei Rechenoperationen = 1, Teile = 50, unabh. von Try/catch, Eingabevektor Dim = 25
    
                        fehler = Operation4(Rechenoperationen, out RechenErgebnisMatrixKomplex);//Geschwindigkeitsverlauf etwa konstant bei Rechenoperationen = 1, Teile = 1, unabh. von Try/catch, Geschwindigkeitsniveau bei Eingabematrix 25 x 25 um ca. 5% erniedrigt durch Diagnose-Anzeige
    
                        /*
                        //Nur für Operation 1 - 3
                        Fortschritt = 100 * (iTeil + 1) / Teile;
                        this.lblFortschrittWert.Text = Convert.ToString(Fortschritt) + " %";
                        this.lblFortschrittWert.Refresh();
    
                        Punkt2 = OBR.GetUTC();
                        OBR.ZeitspanneMillisekunden(Punkt1, Punkt2, out Millisekmant, out Millisekexpo, diagnoselok, out status);
                        Protokollsatz = Convert.ToString(Millisekmant) + "E" + Convert.ToString(Millisekexpo);
    
                        try
                        {
                            sw.WriteLine(Protokollsatz);
                        }
                        catch
                        {
                            fehler = 1; Dateifehler = 1;
                        }
                        */
                    }
                }
    
                //try//Nur für Operation 1 - 3
                //{
                //    if (sw != null)
                //    {
                //        sw.Close();
                //    }
                //    else { fehler = 1; Dateifehler = 1; }
                //}
                //catch
                //{
                //    fehler = 1; Dateifehler = 1;    
                //}
                //if (Dateifehler != 0)
                //{
                //    MessageBox.Show("Fehler beim Schreiben der Protokolldatei-Zeit-Test. ", "Hinweis",
                //                                        MessageBoxButtons.OK, MessageBoxIcon.None);
                //}
    
                return fehler;
            }
    
            private int Operation4(BigInteger Rechenoperationen, out Komplex[,] RechenErgebnisMatrixKomplex)
            {
                int fehler = 0;
    
                Dezimal DeziWert = new Dezimal();
                DeziWert.Mantisse = 0; DeziWert.Exponent = 0;
    
                int Vekdim0 = 1; int Vekdim1 = 1;            
                if (1 < Rechenoperationen)
                {
                    Vekdim0 = 25; Vekdim1 = 25;
                    //Einfache, direkte Dimensionierung der Arrays: Zeit für Vorwärts + Rückwärts = 120 s + 123 s = 243 s 
                    //Redimensionierung der Arrays: Zeit für  Vorwärts + Rückwärts = 148,286 s + 148,517 s = 296,803 s
    
                    //Vekdim0 = 100; Vekdim1 = 100;//Zeit für Vorwärts + Rückwärts = ca. 163 min + ca. 168 min = ca. 331 min = ca. 19860 s //Zeit-Verhältnis = 1 : 81,7283950617284 oder 1 : 1,277 * 4^3
                }
    
                Dezimal[,] Matrix1Dezimalelem = new Dezimal[Vekdim0, Vekdim1];
                Komplex[,] Matrix1Komplexelem = new Komplex[Vekdim0, Vekdim1];
                Komplex[,] ErgebnisMatrixKomplexWert = new Komplex[Vekdim0, Vekdim1];
    
                RechenErgebnisMatrixKomplex = new Komplex[Vekdim0, Vekdim1];
                for (int i = 0; i < Vekdim0; i++)
                {
                    for (int j = 0; j < Vekdim1; j++)
                    {
                        RechenErgebnisMatrixKomplex[i, j].Re = DeziWert; RechenErgebnisMatrixKomplex[i, j].Im = DeziWert;
                    }
                }
    
                string EingabeTyp = "Dezimal";
    
                bool diagnoselok = false; string status = ""; string statuslok = "";
    
                Dezimal DeziNull = new Dezimal();
                DeziNull.Mantisse = 0; DeziNull.Exponent = 0;
    
                BigInteger PImant; int PIexpo;
                OBR.Pi(out PImant, out PIexpo, diagnoselok, out statuslok);//Pi lang
    
                BigInteger PiViertelmant; int PiViertelexpo;
                BigInteger ymant = 4; int yexpo = 0;
                OBR.DivideDez(PImant, PIexpo, ymant, yexpo, out PiViertelmant, out PiViertelexpo, diagnoselok, out statuslok);
                status += statuslok;
    
                BigInteger SinPiViertelmant; int SinPiViertelexpo;
                int modulilok = 0; int moduljlok = 0; string modulmaxlok = "1";
                OBR.Sin(PiViertelmant, PiViertelexpo, out SinPiViertelmant, out SinPiViertelexpo, diagnoselok, modulilok, out moduljlok, modulmaxlok, out statuslok);
                status += statuslok;
    
                Dezimal SinPiViertel = new Dezimal();
                SinPiViertel.Mantisse = SinPiViertelmant; SinPiViertel.Exponent = SinPiViertelexpo;
    
                BigInteger Amplitudemant = 1; int Amplitudeexpo = 0;
                Dezimal Amplitude = new Dezimal();
                Amplitude.Mantisse = Amplitudemant; Amplitude.Exponent = Amplitudeexpo;
    
                int Elodim = 8;
                Dezimal[] Elongation = new Dezimal[Elodim];
                int k = 0;
                while (k < Elodim - 3)
                {
                    Elongation[k + 0] = DeziNull;
                    Elongation[k + 1] = SinPiViertel;
                    Elongation[k + 2] = Amplitude;
                    Elongation[k + 3] = SinPiViertel;
    
                    SinPiViertel.Mantisse = (-1) * SinPiViertel.Mantisse;
                    Amplitude.Mantisse = (-1) * Amplitude.Mantisse;
    
                    k = k + 4;
                }
    
                k = 0;
                int m; int n;
                for (int i = 0; i < Vekdim0; i++)
                {
                    m = k + i;
                    for (int j = 0; j < Vekdim1; j++)
                    {
                        n = m + j;
                        Matrix1Dezimalelem[i, j] = Elongation[n % Elodim];
                    }
                }
    
                bool Vorwärts = true;
                int moduli = 1; string modulmax = Convert.ToString(Vekdim0 + Vekdim1);
                bool diagnosevor = true;
                DiagnoseAnzeige DA = new DiagnoseAnzeige();
    
                if (diagnosevor == true)
                {
                    DA.Opacity = 100;
                    DA.Show();
                }                    
    
                fehler = FunkFourierTransform2Dim(Matrix1Dezimalelem, Matrix1Komplexelem, EingabeTyp, out ErgebnisMatrixKomplexWert, Vorwärts, moduli, modulmax, diagnosevor, DA);
    
                Vorwärts = false;
                EingabeTyp = "Komplex";
    
                if (fehler == 0)
                {
                    fehler = FunkFourierTransform2Dim(Matrix1Dezimalelem, ErgebnisMatrixKomplexWert, EingabeTyp, out ErgebnisMatrixKomplexWert, Vorwärts, moduli, modulmax, diagnosevor, DA);
                }
    
                if (diagnosevor == true)
                {
                    DA.Close();
                }
    
                for (int i = 0; i < Vekdim0; i++)
                {
                    for (int j = 0; j < Vekdim1; j++)
                    {
                        RechenErgebnisMatrixKomplex[i, j] = ErgebnisMatrixKomplexWert[i, j];
                    }
                }
    
                return fehler;
            }
        }
    }
    
    0 comments No comments

  5. Hans-Peter Bittner 116 Reputation points
    2021-12-24T18:53:41.233+00:00

    Hello @Karen Payne MVP , I have now used the debugger-analyse-profiler-tool and code-analyse-tool. Two warnings occured in relation to dispose objects. I have made some little changes in my code, but the warnings and the problem of speed slowing still remained. Please can you describe me in more detail how to work with the profiler tool and how to handle Common Language Runtime Exceptions.

    0 comments No comments