App.axaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Avalonia;
  2. using Avalonia.Controls.ApplicationLifetimes;
  3. using Avalonia.Data.Core.Plugins;
  4. using Avalonia.Markup.Xaml;
  5. using FxpConvert.Common;
  6. #if DEBUG
  7. using HotAvalonia;
  8. using OxyPlot;
  9. #endif
  10. using ShakerApp.ViewModels;
  11. using ShakerApp.Views;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Globalization;
  15. using System.Linq;
  16. using System.Runtime.CompilerServices;
  17. using System.Runtime.InteropServices;
  18. using System.Runtime.Intrinsics;
  19. namespace ShakerApp;
  20. public partial class App : Application
  21. {
  22. public unsafe override void Initialize()
  23. {
  24. #if DEBUG
  25. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  26. {
  27. this.EnableHotReload();
  28. }
  29. #endif
  30. AvaloniaXamlLoader.Load(this);
  31. }
  32. public override void OnFrameworkInitializationCompleted()
  33. {
  34. Vector512<double> nv = Vector512<double>.One * double.NegativeInfinity;
  35. Vector512<double> pv = Vector512<double>.One * double.PositiveInfinity;
  36. DataPoint[] maxtempresult = Enumerable.Repeat(new DataPoint(double.MinValue, double.MaxValue), (int)(8 >> 1)).ToArray();
  37. ref var maxresunlt = ref Unsafe.As<DataPoint, Vector512<double>>(ref maxtempresult[0]);
  38. DataPoint[] mintempresult = Enumerable.Repeat(new DataPoint(double.MaxValue, double.MaxValue), (int)(8 >> 1)).ToArray();
  39. ref var minresunlt = ref Unsafe.As<DataPoint, Vector512<double>>(ref maxtempresult[0]);
  40. var first = Vector512.Create<double>(new double[] { 1, 2, 3, 6, double.NaN, double.NegativeInfinity, double.PositiveInfinity, 2 });
  41. ref var tempv = ref Unsafe.Add(ref first, 0);
  42. var errv = Vector512.Equals(tempv, tempv).AsInt64();
  43. //errv = Vector512.AndNot(errv, Vector512<double>.One);
  44. errv *= (Vector512.Equals(tempv,nv).AsInt64()+Vector512<long>.One);
  45. errv *= (Vector512.Equals(tempv, pv).AsInt64() + Vector512<long>.One);
  46. var tempmax = Vector512<double>.One * double.MaxValue;
  47. var v = Vector512.ConditionalSelect<double>(errv.AsDouble(), tempv, tempmax);
  48. var tempmin = Vector512<double>.One * double.MinValue;
  49. maxresunlt = Vector512.Max(tempv, maxresunlt);
  50. minresunlt = Vector512.Min(tempv, minresunlt);
  51. BindingPlugins.DataValidators.RemoveAt(0);
  52. ShakerSettingViewModel.Instance.Init();
  53. if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
  54. {
  55. if (desktop.Args!.Contains("-debug"))
  56. {
  57. ViewModels.MainViewModel.Default.CanDebug = true;
  58. }
  59. desktop.MainWindow = new MainWindow();
  60. }
  61. base.OnFrameworkInitializationCompleted();
  62. //Window1 window = new Window1();
  63. //window.Show();
  64. }
  65. }