public void ObterPesosEAbascissasCheb()
        {
            const int numeroDePontos = 4;

            double[] momentosAnaliticos = CalcularMomentosAnaliticos(2 * numeroDePontos);

            var chebyChev = new ChebyshevModificado(numeroDePontos, momentosAnaliticos, ChebyshevModificado.TipoDeDominio.SemiInfinito);

            double[] pesos, abscissas;

            chebyChev.CalcularPesosEAbscissas(out pesos, out abscissas);

            AlgoritmoPD algoritmoPd = new AlgoritmoPD(numeroDePontos, momentosAnaliticos);

            double[] pesosEsperados;
            double[] abscissasEsperadas;

            algoritmoPd.CalcularPesosEAbscissas(out pesosEsperados, out abscissasEsperadas);

            Wheeler wheeler = new Wheeler(numeroDePontos,momentosAnaliticos);

            double[] pesosWheeler;
            double[] abscissasWheeler;

            wheeler.CalcularPesosEAbscissas(out pesosWheeler, out abscissasWheeler);
        }
Пример #2
0
        public void CalcularPesosEAbscissasWheelerTeste()
        {
            int numeroDePontos = 4;
            double[] momentos = new double[] { 1, 5, 26, 140, 778, 4450, 26140, 157400 };

            double[] pesosEsperados = new[] { 0.045875854768069, 0.454124145231932,
                0.454124145231932, 0.045875854768068 };
            double[] abscissasEsperadas = new[] { 2.665585781661023, 4.258036215697274,
                5.741963784302726, 7.334414218338978 };

            Wheeler algoritmo = new Wheeler(numeroDePontos, momentos);

            double[] pesos;
            double[] abscissas;

            algoritmo.CalcularPesosEAbscissas(out pesos,out abscissas);

            for (int i = 0; i < numeroDePontos; i++)
            {
                Assert.AreEqual(pesosEsperados[i], pesos[i], 0.0001);
                Assert.AreEqual(abscissasEsperadas[i], abscissas[i], 0.0001);
            }
        }
Пример #3
0
 private static void Run(string queryToLoad, bool runQuery, string activationCode, bool deactivate, bool noForward, bool noUpdate, string caller)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (Environment.OSVersion.Version.Major >= 6)
     {
         try
         {
             SetProcessDPIAware();
         }
         catch
         {
         }
     }
     AutoSaver.Start();
     Wheeler.Register();
     if (Environment.OSVersion.Version.Major < 6)
     {
         ToolStripManager.RenderMode = ToolStripManagerRenderMode.System;
     }
     if (!((activationCode != null) || deactivate))
     {
         Splash = new LINQPad.UI.Splash();
         Splash.Show();
         Splash.Update();
     }
     Log.add_StringWriter(new Action <string>(Log.Write));
     Log.add_ExceptionWriter(new Action <Exception>(Log.Write));
     TypeResolver.ManyToOne  = Resources.ManyToOne;
     TypeResolver.OneToMany  = Resources.OneToMany;
     TypeResolver.OneToOne   = Resources.OneToOne;
     TypeResolver.ManyToMany = Resources.ManyToMany;
     TypeResolver.Results    = Resources.Results;
     TypeResolver.Column     = Resources.Column;
     TypeResolver.Key        = Resources.Key;
     TypeResolver.Database   = Resources.Database;
     TypeResolver.GetSameFolderReferences        = new Func <string, string[]>(AssemblyProber.GetSameFolderReferences);
     WSAgent.WebClientFactory                    = new Func <WebClient>(WebHelper.GetWebClient);
     WSAgent.FastWebClientFactory                = new Func <WebClient>(WebHelper.GetFastWebClient);
     WSAgent.BackupWebClientFactory              = new Func <WebClient>(WebHelper.GetBackupWebClient);
     WSAgent.CurrentVersionString                = VersionString;
     AutocompletionManager.PassiveAutocompletion = UserOptions.Instance.PassiveAutocompletion;
     AutocompletionManager.DisableLambdaSnippets = UserOptions.Instance.DisableLambdaSnippets;
     SnippetManager.set_LINQPadSnippetsFolder(UserOptions.Instance.GetCustomSnippetsFolder(false));
     WSAgent.DiagnosticMode = DiagnosticMode;
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.CurrentDomain_UnhandledException);
     if (deactivate)
     {
         WSAgent.Remove(true);
     }
     else
     {
         if (activationCode != null)
         {
             using (RegisterForm form = new RegisterForm(activationCode))
             {
                 form.ShowDialog();
                 return;
             }
         }
         if (!noUpdate)
         {
             Thread thread = new Thread(new ParameterizedThreadStart(UpdateAgent.RunServerComms))
             {
                 Name         = "Update Agent",
                 IsBackground = true
             };
             _updateThread = thread;
             _updateThread.Start(caller);
         }
         if (!string.IsNullOrEmpty(caller))
         {
             new Thread(delegate {
                 try
                 {
                     Thread.Sleep(0xbb8);
                     if (File.Exists(caller))
                     {
                         FileInfo info = new FileInfo(caller);
                         if (((info.Directory == null) || (info.Directory.Parent == null)) || (info.Directory.Parent.Name.ToLowerInvariant() != "updates"))
                         {
                             if (info.IsReadOnly)
                             {
                                 info.IsReadOnly = false;
                             }
                             if (!File.Exists(caller + ".config"))
                             {
                                 try
                                 {
                                     File.WriteAllText(caller + ".config", "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<configuration>\r\n  <startup useLegacyV2RuntimeActivationPolicy=\"true\">\r\n    <supportedRuntime version=\"v4.0\"/>\r\n  </startup>\r\n  <runtime>\r\n    <legacyUnhandledExceptionPolicy enabled=\"1\" />\r\n  </runtime>\r\n</configuration>");
                                 }
                                 catch
                                 {
                                 }
                             }
                             string path = Assembly.GetExecutingAssembly().Location + ".config";
                             if (!File.Exists(path))
                             {
                                 try
                                 {
                                     File.WriteAllText(path, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<configuration>\r\n  <startup useLegacyV2RuntimeActivationPolicy=\"true\">\r\n    <supportedRuntime version=\"v4.0\"/>\r\n  </startup>\r\n  <runtime>\r\n    <legacyUnhandledExceptionPolicy enabled=\"1\" />\r\n  </runtime>\r\n</configuration>");
                                 }
                                 catch
                                 {
                                 }
                             }
                             try
                             {
                                 File.Copy(Assembly.GetExecutingAssembly().Location, caller, true);
                             }
                             catch
                             {
                                 Thread.Sleep(0x1388);
                                 File.Copy(Assembly.GetExecutingAssembly().Location, caller, true);
                             }
                         }
                     }
                 }
                 catch
                 {
                 }
             })
             {
                 Name = "Update patcher"
             }.Start();
         }
         UnpackDb();
         QueryOneToOne();
         QueryStudioKeys(noForward);
         StartSemanticParsingService();
         new Thread(delegate {
             try
             {
                 Thread.Sleep(0x3e8);
                 if (GacResolver.IsLINQPadGaced())
                 {
                     MessageBox.Show("Warning: A different revision of LINQPad has been installed to the Global Assembly Cache. This will prevent correct operation.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
             catch
             {
             }
         })
         {
             IsBackground = true
         }.Start();
         Application.Run(new MainForm(queryToLoad, runQuery));
         TempFileRef.DeleteAll();
     }
 }