Decompiled source of DSPCalculator v0.1.13

DSPCalculator.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI;
using CommonAPI.Systems.ModLocalization;
using DSPCalculator.Compatibility;
using DSPCalculator.Logic;
using DSPCalculator.UI;
using HarmonyLib;
using MathNet.Numerics.LinearAlgebra;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DSPCalculator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("微软中国")]
[assembly: AssemblyProduct("DSPCalculator")]
[assembly: AssemblyCopyright("Copyright © 微软中国 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("162c0831-05e9-411f-a9a7-3476e5199a57")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DSPCalculator
{
	[BepInPlugin("com.GniMaerd.DSPCalculator", "DSPCalculator", "0.1.13")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry" })]
	[CommonAPISubmoduleDependency(new string[] { "TabSystem" })]
	[CommonAPISubmoduleDependency(new string[] { "LocalizationModule" })]
	public class DSPCalculatorPlugin : BaseUnityPlugin
	{
		public const string NAME = "DSPCalculator";

		public const string GUID = "com.GniMaerd.DSPCalculator";

		public const string VERSION = "0.1.13";

		public static bool developerMode;

		public static ConfigEntry<KeyCode> OpenWindowHotKey;

		public static ConfigEntry<KeyCode> SwitchWindowSizeHotKey;

		public static ConfigEntry<int> OpenWindowModifier;

		public static ConfigEntry<int> SwitchWindowModifier;

		public static ConfigEntry<bool> EditableTitle;

		public static ConfigEntry<bool> RoundUpAssemblerNum;

		public static bool showMixBeltCheckbox;

		public void Awake()
		{
			OpenWindowHotKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("config", "OpenWindowHotKey", (KeyCode)113, "打开计算器窗口的快捷键。HotKey to open calculator window.");
			SwitchWindowSizeHotKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("config", "SwitchWindowSizeHotKey", (KeyCode)9, "将计算器窗口展开或缩小的快捷键。HotKey to fold or unfold calculator window.");
			OpenWindowModifier = ((BaseUnityPlugin)this).Config.Bind<int>("config", "OpenWindowHKModifier", 0, "byte shift = 1, ctrl = 2, alt = 4");
			SwitchWindowModifier = ((BaseUnityPlugin)this).Config.Bind<int>("config", "SwitchWindowHKModifier", 0, "byte shift = 1, ctrl = 2, alt = 4");
			EditableTitle = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "EditTitle", false, "将此项置为true可以使计算器的窗口标题可以被编辑。Set the to true will allow you to edit the calculator window's title in game.");
			RoundUpAssemblerNum = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "RoundUpAssemblerNum", true, "生产设施数量显示是否自动向上取整。Is the display of the number of production facilities automatically rounded up.");
			Harmony.CreateAndPatchAll(typeof(DSPCalculatorPlugin), (string)null);
			Harmony.CreateAndPatchAll(typeof(RecipePickerPatcher), (string)null);
			Harmony.CreateAndPatchAll(typeof(UIHotkeySettingPatcher), (string)null);
			Localizations.AddLocalizations();
		}

		public void Start()
		{
			UIHotkeySettingPatcher.Init();
			WindowsManager.OnStart();
		}

		public void Update()
		{
			UIHotkeySettingPatcher.OnUpdate();
			WindowsManager.OnUpdate();
			UIPauseBarPatcher.OnUpdate();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameData), "NewGame")]
		[HarmonyPatch(typeof(GameData), "Import")]
		public static void OnLoadGame()
		{
			CalcDB.TryInit();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameMain), "LateUpdate")]
		public static bool EscLogicBlocker()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (WindowsManager.hasOpenedWindow)
			{
				bool flag = !VFInput._godModeMechaMove;
				bool flag2 = VFInput.escKey.onDown || VFInput.escape || VFInput.delayedEscape;
				if (flag && flag2)
				{
					VFInput.UseEscape();
					WindowsManager.CloseTopWindow();
					return true;
				}
			}
			return true;
		}
	}
	public class Localizations
	{
		public static void AddLocalizations()
		{
			LocalizationModule.RegisterTranslation("量化计算器", "Calculator", "量化计算器", "Calculator");
			LocalizationModule.RegisterTranslation("设置目标产物", "Target Product", "设置目标产物", "Target Product");
			LocalizationModule.RegisterTranslation("来自calc", "> From ", "> 来自", "- From ");
			LocalizationModule.RegisterTranslation("实际需求calc", "- Actual demand  ", "- 实际需求  ", "- Actual demand  ");
			LocalizationModule.RegisterTranslation("溢出calc", "- Excessive output  ", "- 产出过量  ", "- Excessive output  ");
			LocalizationModule.RegisterTranslation("当前配方", "current recipe", "当前配方", "current recipe");
			LocalizationModule.RegisterTranslation("产出过量标签", "Excessive", "产出过量", "Excessive");
			LocalizationModule.RegisterTranslation("溢出或副产物", "Overflow / By-product", "溢出/副产物", "Overflow / By-product");
			LocalizationModule.RegisterTranslation("产出calc", "Total Output", "总产出", "Total Output");
			LocalizationModule.RegisterTranslation("存在环路警告", "There is a no solution loop in the recipe solving process! \nThe changes will not take effect, please try reset all configurations.", "配方求解过程出现环路!\n更改将不会生效,请尝试还原默认配置。", "There is a no solution loop in the recipe solving process! \nThe changes will not take effect, please try reset all configurations.");
			LocalizationModule.RegisterTranslation("更改配方标题", "Change Recipe", "更改配方", "Change Recipe");
			LocalizationModule.RegisterTranslation("更改配方说明", "Click to specify the recipe for producing this item. This setting will remain in effect for this item until the rule is cleared.", "点击以指定生产此物品的配方。在清除规则前,该设定将一直对此物品生效。", "Click to specify the recipe for producing this item. This setting will remain in effect for this item until the rule is cleared.");
			LocalizationModule.RegisterTranslation("清除配方设定标题", "Clear Recipe Specification", "清除强制指定的配方", "Clear Recipe Specification");
			LocalizationModule.RegisterTranslation("清除配方设定说明", "No longer specifying that this item must use a certain recipe, it can be selected by the calculator itself.", "不再指定此物品必须使用某个配方,可由计算器自由选取。", "No longer specifying that this item must use a certain recipe, it can be selected by the calculator itself.");
			LocalizationModule.RegisterTranslation("视为原矿标题", "Treat as Raw Ore", "视为原矿", "Treat as Raw Ore");
			LocalizationModule.RegisterTranslation("视为原矿说明", "Treating this item as raw ore will no longer count towards the production line that produces it. This item will serve as the basic input as a directly obtainable original item.", "将该物品视为原矿,将不再计算生产该物品的产线。该物品将作为直接可获取的原始物品作为基本输入。", "Treating this item as raw ore will no longer count towards the production line that produces it. This item will serve as the basic input as a directly obtainable original item.");
			LocalizationModule.RegisterTranslation("不再视为原矿标题", "Remove From Raw Ore", "不再视为原矿", "Remove From Raw Ore");
			LocalizationModule.RegisterTranslation("不再视为原矿说明", "No longer treat this item as directly obtainable raw material.", "不再将该物品视为可直接获得的原矿。", "No longer treat this item as directly obtainable raw material.");
			LocalizationModule.RegisterTranslation("还原默认配置标题", "Reset All Configuration", "还原默认配置", "Reset All Configuration");
			LocalizationModule.RegisterTranslation("还原默认配置说明", "All preferred production buildings, proliferator settings, raw ore settings, etc. will be restored to default configurations.", "所有首选生产建筑、增产、原矿等设置将被还原为默认配置。", "All preferred production buildings, proliferator settings, raw ore settings, etc. will be restored to default configurations.");
			LocalizationModule.RegisterTranslation("预估电量", "Power Consumption Est.", "预估电量需求", "Power Consumption Est.");
			LocalizationModule.RegisterTranslation("工厂需求", "Production Facilities", "生产设施", "Production Facilities");
			LocalizationModule.RegisterTranslation("原矿需求", "Raw Resources Demands", "原材料需求", "Raw Resources Demands");
			LocalizationModule.RegisterTranslation("副产物和溢出产物", "By-product / Excessive product", "副产物 / 过量产物", "By-product / Excessive product");
			LocalizationModule.RegisterTranslation("强制增产效能", "Proliferator Extra              %", "强制增产效能              %", "Proliferator Extra              %");
			LocalizationModule.RegisterTranslation("强制加速效能", "Proliferator Spd+              %", "强制加速效能              %", "Proliferator Spd+              %");
			LocalizationModule.RegisterTranslation("强制增产效能标题", "Specifying the Proliferator Extra Product Efficiency", "强制指定增产剂增产效能", "Specifying the Proliferator Extra Product Efficiency");
			LocalizationModule.RegisterTranslation("强制增产效能说明", "If checked, each item in the calculator will be calculated using the player's input extra product efficiency, ignoring the game's original proliferator properties, regardless of which proliferator is selected. (Unless you've chosen NOT USE PROLIFERATOR button)", "勾选此项后,计算器的每一项都将使用玩家输入的增产/加速效能来进行计算,而无视游戏原本的增产/加速比例设定,无论选择了何种增产剂。(除非你选择了“不使用增产剂”按钮)", "If checked, each item in the calculator will be calculated using the player's input extra product efficiency, ignoring the game's original proliferator properties, regardless of which proliferator is selected. (Unless you've chosen NOT USE PROLIFERATOR button)");
			LocalizationModule.RegisterTranslation("强制加速效能标题", "Specifying the Proliferator Production Speedup Efficiency", "强制指定增产剂加速效能", "Specifying the Proliferator Production Speedup Efficiency");
			LocalizationModule.RegisterTranslation("强制加速效能说明", "If checked, each item in the calculator will be calculated using the player's input production speedup efficiency, ignoring the game's original proliferator properties, regardless of which proliferator is selected. (Unless you've chosen NOT USE PROLIFERATOR button)", "勾选此项后,计算器的每一项都将使用玩家输入的增产/加速效能来进行计算,而无视游戏原本的增产/加速比例设定,无论选择了何种增产剂。(除非你选择了“不使用增产剂”按钮)", "If checked, each item in the calculator will be calculated using the player's input production speedup efficiency, ignoring the game's original proliferator properties, regardless of which proliferator is selected. (Unless you've chosen NOT USE PROLIFERATOR button)");
			LocalizationModule.RegisterTranslation("收起/展开", "Fold / Unfold", "收起/展开窗口", "Fold / Unfold");
			LocalizationModule.RegisterTranslation("生产加速calc", "Production Speedup", "生产加速", "Production Speedup");
			LocalizationModule.RegisterTranslation("额外产出calc", "Extra products", "额外产出", "Extra products");
			LocalizationModule.RegisterTranslation("打开量化计算器窗口", "Open the Quantitative Calculator Window", "打开量化计算器窗口", "Open the Quantitative Calculator Window");
			LocalizationModule.RegisterTranslation("切换计算器窗口大小", "Fold/Unfold Calculator Window", "切换计算器窗口大小", "Fold/Unfold Calculator Window");
			LocalizationModule.RegisterTranslation("显示混带信息", "Show Mix-belt Scheme", "显示混带信息", "Show Mix-belt Scheme");
			LocalizationModule.RegisterTranslation("混带显示标题", "Show Mix-belt Scheme", "显示混带信息", "Show Mix-belt Scheme");
			LocalizationModule.RegisterTranslation("混带显示说明", "Calculated with 4 default stacks, the step size of product for calculation is 60/min. \nThis feature is still in the testing stage and cannot guarantee the operation of mixed belts.\nAnd this mode is not suitable for computing large-scale production lines", "以4默认堆叠计算,产量计算的步长为60/min。\n该功能尚在测试阶段,并不能确保混带的运行,\n且该模式不适用于计算大规模生产线。", "Calculated with 4 default stacks, the step size of product for calculation is 60/min. \nThis feature is still in the testing stage and cannot guarantee the operation of mixed belts.\nAnd this mode is not suitable for computing large-scale production lines");
			LocalizationModule.RegisterTranslation("份calc", "units", "份", "units");
			LocalizationModule.RegisterTranslation("份数标题", "Unit", "份", "Unit");
			LocalizationModule.RegisterTranslation("份数说明", "Each unit represents 60/min, which is equivalent to the capacity of the sorter at a distance of 3 grids.\nSorter value: represents the required quantity of sorters at 1/2/3 grid distances.", "每1份为60/min,相当于分拣器在3格距离的运力。\n分拣器数值:代表1/2/3格距离的分拣器的所需数量。", "Each unit represents 60/min, which is equivalent to the capacity of the sorter at a distance of 3 grids.\nSorter value: represents the required quantity of sorters at 1/2/3 grid distances.");
			LocalizationModule.RegisterTranslation("生产设施数量显示向上取整", "Round up facilitiy number", "生产设施数向上取整", "Round up facilitiy number");
			LocalizationModule.RegisterTranslation("增产剂并入产线", "Add proliferator product line", "将增产剂并入产线", "Add proliferator product line");
			LocalizationModule.RegisterTranslation("增产剂并入产线描述", "Proliferators will no longer be considered as directly input raw materials from external sources, but will be incorporated into the current production line to calculate the overall production line demand. When calculating the demand for proliferators, any one of them is considered to have been self sprayed before being used for spraying on the production line.\nThe calculation of additional proliferator types (e.g. Mk.IV) added by mod is currently not supported.", "增产剂将不再视为外部直接输入的原料,而是并入当前产线中计算整体产线的需求。计算增产剂需求量时,任何增产剂都视作经过自喷涂后再用于产线的喷涂。\n此选项目前不支持mod添加的额外增产剂类型(例如Mk.IV型)的计算。", "Proliferators will no longer be considered as directly input raw materials from external sources, but will be incorporated into the current production line to calculate the overall production line demand. When calculating the demand for proliferators, any one of them is considered to have been self sprayed before being used for spraying on the production line.\nThe calculation of additional proliferator types (e.g. MK.IV) added by mod is currently not supported.");
			LocalizationModule.RegisterTranslation("增产剂生产消耗比产出多警告", "The production process of proliferator consumes more of itself than it produces, which cannot be calculated. Please reset the configurations.", "增产剂生产过程对自身的消耗比产出多,无法计算。请重置用户设置。", "The production process of proliferator consumes more of itself than it produces, which cannot be calculated. Please reset the configurations.");
			LocalizationModule.RegisterTranslation("求解出错警告", "There is no correct solution in solving process! \nPlease try reset all configurations.", "配方求解过程出现无解情况!\n请尝试还原默认配置。", "There is no correct solution in solving process! \nPlease try reset all configurations.");
			LocalizationModule.RegisterTranslation("混带需求", "Mix-Belt Demands", "混带需求", "Mix-Belt Demands");
			LocalizationModule.RegisterTranslation("条calc", "lines", "条", "lines");
			LocalizationModule.RegisterTranslation("标记为已完成", "Mark as completed", "标记为已完成", "Mark as completed");
		}
	}
	public static class Utils
	{
		public static string KMG(double num)
		{
			string text = "";
			if (num < 100.0)
			{
				return num.ToString("0.##");
			}
			if (num < 1000.0)
			{
				return num.ToString("0.#");
			}
			if (num < 10000.0)
			{
				return num.ToString("N0");
			}
			if (num < 1000000.0)
			{
				text = "k";
				num /= 1000.0;
			}
			else if (num < 1000000000.0)
			{
				text = "M";
				num /= 1000000.0;
			}
			else if (num < 1000000000000.0)
			{
				text = "G";
				num /= 1000000000.0;
			}
			else if (num < 1000000000000000.0)
			{
				text = "T";
				num /= 1000000000000.0;
			}
			else if (num < 1E+18)
			{
				text = "P";
				num /= 1000000000000000.0;
			}
			else
			{
				text = "E";
				num /= 1E+18;
			}
			if (num < 9.995)
			{
				return $"{num:0.000} {text}";
			}
			if (num < 99.95)
			{
				return $"{num:0.00} {text}";
			}
			if (num < 999.5)
			{
				return $"{num:0.0} {text}";
			}
			return $"{num:N0} {text}";
		}

		public static string KMG(long num)
		{
			if (num <= 9999)
			{
				return num.ToString("N0");
			}
			return KMG((double)num);
		}

		public static string KMGForceDigi(double num)
		{
			if (num < 10000.0)
			{
				return num.ToString("N2");
			}
			return KMG(num);
		}

		public static double GetIncMilli(int index, UserPreference preference)
		{
			if (preference.customizeIncMilli && index > 0)
			{
				return preference.incMilliOverride;
			}
			return Cargo.incTableMilli[index];
		}

		public static double GetAccMilli(int index, UserPreference preference)
		{
			if (preference.customizeAccMilli && index > 0)
			{
				return preference.accMilliOverride;
			}
			return Cargo.accTableMilli[index];
		}

		public static double GetPowerRatio(int index, UserPreference preference)
		{
			return Cargo.powerTableRatio[index];
		}

		public static bool SolveEquationsLimited(double[,] augMatrix, out double[] result)
		{
			int length = augMatrix.GetLength(1);
			result = new double[length];
			int length2 = augMatrix.GetLength(0);
			for (int i = 0; i < length2; i++)
			{
			}
			return true;
		}
	}
}
namespace DSPCalculator.UI
{
	public class UICalcWindow
	{
		public const float cellWidth = 890f;

		public const float cellHeight = 80f;

		public const float cellDistance = 6f;

		public const float sideCellWidth = 138.66f;

		public const float sideCellHeight = 45f;

		public const int sideCellCountPerRow = 3;

		public const float sidePanelWidth = 400f;

		public static float targetIconAnchoredPosX = 52f;

		public static float targetIconAnchoredPosYLargeWindow = -80f;

		public static float targetIconAnchoredPosYSmallWindow = -60f;

		public const int assemblerDemandCountPerRow = 4;

		public const int TYPE_FILTER = 100000;

		public static Color itemIconNormalColor = new Color(0.6f, 0.6f, 0.6f, 1f);

		public static Color itemIconHighlightColor = new Color(0.7f, 0.7f, 0.7f, 1f);

		public static Color itemIconPressedColor = new Color(0.6f, 0.6f, 0.6f, 1f);

		public static Color itemIconDisabledColor = new Color(0.5f, 0.5f, 0.5f, 1f);

		public static Color TextWhiteColor = new Color(0.588f, 0.588f, 0.588f, 1f);

		public static Color TextWarningColor = new Color(0.852f, 0.487f, 0.022f, 1f);

		public static Color TextBlueColor = new Color(0.282f, 0.845f, 1f, 0.705f);

		public static Color incModeImageColor = new Color(0.287f, 0.824f, 1f, 0.266f);

		public static Color accModeImageColor = new Color(0.9906f, 0.5897f, 0.3691f, 0.384f);

		public static Color incModeTextColor = new Color(0.282f, 0.845f, 1f, 0.705f);

		public static Color accModeTextColor = new Color(0.9906f, 0.5897f, 0.3691f, 0.705f);

		public static float largeWindowWidth = 1340f;

		public static float smallWindowWidth = 315f;

		public static float largeWindowViewGroupWidth = 890f;

		public static float smallWindowViewGroupWidth = 290f;

		public static float largeWindowViewGroupHeight = 570f;

		public static float smallWindowViewGroupHeight = 610f;

		public static float animationSpeed = 150f;

		public bool isTopAndActive;

		public bool nextFrameRecalc;

		public static GameObject recipeObj;

		public static GameObject arrowObj;

		public static GameObject iconObj_NoTip;

		public static GameObject iconObj_ButtonTip;

		public static GameObject TextObj;

		public static GameObject TextWithUITip;

		public static GameObject textButtonObj;

		public static GameObject imageButtonObj;

		public static GameObject incTogglePrefabObj;

		public static GameObject checkBoxObj;

		public static Sprite leftTriangleSprite;

		public static Sprite rightTriangleSprite;

		public static Sprite backgroundSprite = null;

		public static Sprite buttonBackgroundSprite = null;

		public static Sprite gearSprite = null;

		public static Sprite filterSprite = null;

		public static Sprite biaxialArrowSprite = null;

		public static Sprite oreSprite = null;

		public static Sprite crossSprite = null;

		public static Sprite bannedSprite = null;

		public static Sprite todoListSprite = null;

		public static Sprite resetSprite = null;

		public static Sprite checkboxOnSprite = null;

		public static Sprite checkboxOffSprite = null;

		public GameObject windowObj;

		public GameObject viewGroupObj;

		public GameObject mainCanvasObj;

		public GameObject switchSizeButtonObj;

		public GameObject customTitleInputObj;

		public Image titleInputBG;

		public InputField titleInput;

		public UIButton titleInputUIBtn;

		public Text titleText;

		public GameObject targetProductTextObj;

		public Image targetProductIcon;

		public UIButton targetProductIconUIBtn;

		public List<UIItemNode> uiItemNodes;

		public List<UIItemNodeSimple> uiSideItemNodes;

		public ScrollRect contentScrollRect;

		public Transform contentTrans;

		public GameObject targetProductIconObj;

		public GameObject speedInputObj;

		public GameObject perMinTextObj;

		public Transform sideContentTrans;

		public GameObject incToggleObj;

		public Text incText;

		public GameObject proliferatorSelectionObj;

		public GameObject assemblerSelectionObj;

		public Dictionary<int, UIButton> proliferatorUsedButtons;

		public Dictionary<int, Dictionary<int, UIButton>> assemblerUsedButtons;

		public Text finalInfoText;

		public Text assemblerDemandsTitleText;

		public GameObject assemblersDemandsGroupObj;

		public List<GameObject> assemblersDemandObjs;

		public Image cbBluebuff;

		public Image cbEnergyBurst;

		public Image cbDirac;

		public Image cbInferior;

		public Image cbIncMilli;

		public Image cbAccMilli;

		public Image cbRoundUp;

		public Image cbMixbelt;

		public Image cbSolveProlifer;

		public Text txtBluebuff;

		public Text txtEnergyBurst;

		public Text txtDirac;

		public Text txtInferior;

		public Text txtIncMilli;

		public Text txtAccMilli;

		public Text txtRoundUp;

		public Text txtMixbelt;

		public Text txtSolveProlifer;

		public InputField incInput;

		public InputField accInput;

		public Dictionary<int, int> uiItemNodeOrders;

		public Dictionary<int, UIItemNodeSimple> uiItemSimplesByItemId;

		public SolutionTree solution;

		public bool isLargeWindow;

		public float targetVerticalPosition;

		public UICalcWindow(int idx)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Expected O, but got Unknown
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0751: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0791: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0864: Unknown result type (might be due to invalid IL or missing references)
			//IL_0889: Unknown result type (might be due to invalid IL or missing references)
			//IL_0961: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Expected O, but got Unknown
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a25: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca1: Expected O, but got Unknown
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fdd: Expected O, but got Unknown
			//IL_10b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1046: Unknown result type (might be due to invalid IL or missing references)
			//IL_106d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1092: Unknown result type (might be due to invalid IL or missing references)
			//IL_1118: Unknown result type (might be due to invalid IL or missing references)
			//IL_1122: Expected O, but got Unknown
			//IL_1161: Unknown result type (might be due to invalid IL or missing references)
			//IL_11c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_11e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1200: Unknown result type (might be due to invalid IL or missing references)
			//IL_120a: Expected O, but got Unknown
			//IL_12e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1307: Unknown result type (might be due to invalid IL or missing references)
			//IL_1311: Expected O, but got Unknown
			//IL_1369: Unknown result type (might be due to invalid IL or missing references)
			//IL_1373: Expected O, but got Unknown
			//IL_13e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1675: Unknown result type (might be due to invalid IL or missing references)
			//IL_16cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1716: Unknown result type (might be due to invalid IL or missing references)
			//IL_1720: Expected O, but got Unknown
			//IL_174f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1774: Unknown result type (might be due to invalid IL or missing references)
			//IL_17af: Unknown result type (might be due to invalid IL or missing references)
			//IL_17cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_17e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1803: Unknown result type (might be due to invalid IL or missing references)
			//IL_1824: Unknown result type (might be due to invalid IL or missing references)
			//IL_1840: Unknown result type (might be due to invalid IL or missing references)
			//IL_1870: Unknown result type (might be due to invalid IL or missing references)
			//IL_187a: Expected O, but got Unknown
			//IL_18fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1900: Unknown result type (might be due to invalid IL or missing references)
			//IL_1927: Unknown result type (might be due to invalid IL or missing references)
			//IL_192c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1953: Unknown result type (might be due to invalid IL or missing references)
			//IL_1958: Unknown result type (might be due to invalid IL or missing references)
			//IL_195d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1964: Expected O, but got Unknown
			//IL_1987: Unknown result type (might be due to invalid IL or missing references)
			//IL_19a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c42: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c60: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c6a: Expected O, but got Unknown
			//IL_1d0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d29: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1de9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ed0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1eee: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ef8: Expected O, but got Unknown
			//IL_1f9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1fd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_2077: Unknown result type (might be due to invalid IL or missing references)
			//IL_2098: Unknown result type (might be due to invalid IL or missing references)
			//IL_215e: Unknown result type (might be due to invalid IL or missing references)
			//IL_217c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2186: Expected O, but got Unknown
			//IL_21e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_2204: Unknown result type (might be due to invalid IL or missing references)
			//IL_220e: Expected O, but got Unknown
			//IL_2340: Unknown result type (might be due to invalid IL or missing references)
			//IL_235e: Unknown result type (might be due to invalid IL or missing references)
			//IL_2368: Expected O, but got Unknown
			//IL_1a21: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a49: Expected O, but got Unknown
			//IL_1aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ac7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad1: Expected O, but got Unknown
			//IL_1b31: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b59: Expected O, but got Unknown
			//IL_1bb9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1be1: Expected O, but got Unknown
			//IL_155c: Unknown result type (might be due to invalid IL or missing references)
			//IL_157b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1585: Expected O, but got Unknown
			TryInitStaticPrefabs();
			solution = new SolutionTree();
			uiItemNodes = new List<UIItemNode>();
			uiSideItemNodes = new List<UIItemNodeSimple>();
			proliferatorUsedButtons = new Dictionary<int, UIButton>();
			assemblerUsedButtons = new Dictionary<int, Dictionary<int, UIButton>>();
			assemblersDemandObjs = new List<GameObject>();
			uiItemNodeOrders = new Dictionary<int, int>();
			uiItemSimplesByItemId = new Dictionary<int, UIItemNodeSimple>();
			isTopAndActive = true;
			isLargeWindow = true;
			nextFrameRecalc = false;
			targetVerticalPosition = -1f;
			GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Blueprint Browser");
			GameObject val2 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows");
			windowObj = Object.Instantiate<GameObject>(val);
			((Object)windowObj).name = "calc-window " + idx;
			windowObj.transform.SetParent(val2.transform);
			windowObj.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
			windowObj.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(-670f, 357f, 0f);
			windowObj.transform.localScale = Vector3.one;
			windowObj.AddComponent<RectMask2D>();
			Vector3 localPosition = windowObj.transform.localPosition;
			int num = 40;
			float num2 = Random.Range(localPosition.x - (float)num, localPosition.x + (float)num);
			float num3 = Random.Range(localPosition.y - (float)num, localPosition.y + (float)num);
			windowObj.transform.localPosition = new Vector3(num2, num3, localPosition.z);
			Object.Destroy((Object)(object)((Component)windowObj.transform.Find("inspector-group")).gameObject);
			Object.Destroy((Object)(object)((Component)windowObj.transform.Find("folder-info-group")).gameObject);
			Object.Destroy((Object)(object)((Component)windowObj.transform.Find("title-group")).gameObject);
			GameObject gameObject = ((Component)windowObj.transform.Find("view-group/Scroll View/Viewport/Content")).gameObject;
			while (gameObject.transform.childCount > 0)
			{
				Object.DestroyImmediate((Object)(object)((Component)gameObject.transform.GetChild(gameObject.transform.childCount - 1)).gameObject);
			}
			GameObject gameObject2 = ((Component)windowObj.transform.Find("panel-bg/title-text")).gameObject;
			titleText = ((Component)windowObj.transform.Find("panel-bg/title-text")).GetComponent<Text>();
			GameObject gameObject3 = ((Component)windowObj.transform.Find("panel-bg/x")).gameObject;
			Button component = gameObject3.GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				CloseWindow();
			});
			switchSizeButtonObj = Object.Instantiate<GameObject>(gameObject3, windowObj.transform.Find("panel-bg"));
			((Object)switchSizeButtonObj).name = "-";
			switchSizeButtonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(-43f, -13f);
			switchSizeButtonObj.GetComponent<Image>().sprite = leftTriangleSprite;
			switchSizeButtonObj.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("收起/展开") + UIHotkeySettingPatcher.GetFoldHotkeyString();
			switchSizeButtonObj.GetComponent<UIButton>().tips.corner = 3;
			switchSizeButtonObj.GetComponent<UIButton>().tips.delay = 0.3f;
			Button component2 = switchSizeButtonObj.GetComponent<Button>();
			((UnityEventBase)component2.onClick).RemoveAllListeners();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				SwitchWindowSize();
			});
			viewGroupObj = ((Component)windowObj.transform.Find("view-group")).gameObject;
			viewGroupObj.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 0f);
			viewGroupObj.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f);
			viewGroupObj.GetComponent<RectTransform>().pivot = new Vector2(0f, 0f);
			viewGroupObj.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(12f, 12f, 0f);
			viewGroupObj.GetComponent<RectTransform>().sizeDelta = new Vector2(largeWindowViewGroupWidth, largeWindowViewGroupHeight);
			mainCanvasObj = ((Component)windowObj.transform.Find("view-group/Scroll View/Viewport/Content")).gameObject;
			contentTrans = mainCanvasObj.transform;
			GridLayoutGroup val3 = mainCanvasObj.AddComponent<GridLayoutGroup>();
			ContentSizeFitter val4 = mainCanvasObj.AddComponent<ContentSizeFitter>();
			val3.cellSize = new Vector2(890f, 80f);
			val4.horizontalFit = (FitMode)0;
			val4.verticalFit = (FitMode)2;
			contentScrollRect = ((Component)windowObj.transform.Find("view-group/Scroll View")).GetComponent<ScrollRect>();
			((Component)windowObj.transform.Find("view-group/Scroll View/Viewport")).GetComponent<RectTransform>().sizeDelta = new Vector2(0f, -3f);
			Vector3 localPosition2 = ((Component)windowObj.transform.Find("view-group/Scroll View/Viewport")).transform.localPosition;
			((Component)windowObj.transform.Find("view-group/Scroll View/Viewport")).transform.localPosition = new Vector3(localPosition2.x, localPosition2.y - 3f, localPosition2.z);
			Transform val5 = windowObj.transform.Find("inspector-group-bg");
			((Component)val5).GetComponent<RectTransform>().sizeDelta = new Vector2(416f, 245f);
			GameObject val6 = Object.Instantiate<GameObject>(viewGroupObj, val5);
			val6.GetComponent<RectTransform>().sizeDelta = new Vector2(416f, 407f);
			val6.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, -412f, 0f);
			GameObject gameObject4 = ((Component)val6.transform.Find("Scroll View/Viewport/Content")).gameObject;
			sideContentTrans = gameObject4.transform;
			gameObject4.GetComponent<GridLayoutGroup>().cellSize = new Vector2(138.66f, 45f);
			windowObj.SetActive(true);
			titleText.text = Localization.Translate("量化计算器");
			Transform val7 = windowObj.transform.Find("panel-bg");
			GameObject val8 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Blueprint Browser/inspector-group/Scroll View/Viewport/Content/group-1/input-short-text");
			if ((Object)(object)val8 == (Object)null)
			{
				val8 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Blueprint Browser/inspector-group/BP-panel-scroll(Clone)/Viewport/pane/group-1/input-short-text");
			}
			if ((Object)(object)val8 == (Object)null)
			{
				Debug.LogError((object)"Error when init oriInputField because some other mods has changed the Blueprint Browser UI. Please check if you've install the BluePrintTweaks and then contant jinxOAO.");
			}
			customTitleInputObj = Object.Instantiate<GameObject>(val8, windowObj.transform);
			((Object)customTitleInputObj).name = "inputfield-title";
			customTitleInputObj.GetComponent<RectTransform>().sizeDelta = new Vector2(200f, 30f);
			customTitleInputObj.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f, 1f);
			customTitleInputObj.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f, 1f);
			customTitleInputObj.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 1f);
			customTitleInputObj.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, -10f, 0f);
			titleInputBG = customTitleInputObj.GetComponent<Image>();
			titleInput = customTitleInputObj.GetComponent<InputField>();
			titleInput.text = Localization.Translate("量化计算器");
			titleInput.characterLimit = 30;
			((Selectable)titleInput).transition = (Transition)0;
			((UnityEventBase)titleInput.onEndEdit).RemoveAllListeners();
			((Graphic)customTitleInputObj.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			((Graphic)((Component)customTitleInputObj.transform.Find("value-text")).GetComponent<Text>()).color = Color.white;
			((Component)customTitleInputObj.transform.Find("value-text")).GetComponent<Text>().fontSize = 18;
			((Component)customTitleInputObj.transform.Find("value-text")).GetComponent<Text>().font = titleText.font;
			((Component)customTitleInputObj.transform.Find("value-text")).GetComponent<Text>().alignment = (TextAnchor)4;
			customTitleInputObj.GetComponent<UIButton>().tips.tipTitle = "";
			customTitleInputObj.GetComponent<UIButton>().tips.tipText = "";
			customTitleInputObj.SetActive(false);
			customTitleInputObj.SetActive(true);
			titleInputUIBtn = customTitleInputObj.GetComponent<UIButton>();
			Transition val9 = new Transition();
			val9.target = (Graphic)(object)customTitleInputObj.GetComponent<Image>();
			val9.normalColor = new Color(0f, 0f, 0f, 0.01f);
			val9.mouseoverColor = new Color(0f, 0f, 0f, 0.3f);
			val9.highlightColorOverride = new Color(0f, 0f, 0f, 0.5f);
			val9.damp = 0.3f;
			val9.highlightColorMultiplier = 1f;
			val9.highlightSizeMultiplier = 1f;
			val9.mouseoverSize = 1f;
			val9.pressedColor = new Color(0f, 0f, 0f, 0.5f);
			val9.pressedSize = 1f;
			titleInputUIBtn.transitions = (Transition[])(object)new Transition[1] { val9 };
			titleInputUIBtn.highlighted = false;
			if (DSPCalculatorPlugin.EditableTitle.Value)
			{
				gameObject2.SetActive(false);
			}
			else
			{
				customTitleInputObj.SetActive(false);
			}
			targetProductTextObj = Object.Instantiate<GameObject>(TextObj, val7);
			((Object)targetProductTextObj).name = "target-title";
			targetProductTextObj.transform.localScale = Vector3.one;
			targetProductTextObj.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(25f, 318f, 0f);
			targetProductTextObj.GetComponent<Text>().text = Localization.Translate("设置目标产物");
			targetProductTextObj.GetComponent<Text>().fontSize = 16;
			GameObject val10 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Station Window/storage-box-0/storage-icon-empty");
			if ((Object)(object)val10 != (Object)null)
			{
				targetProductIconObj = Object.Instantiate<GameObject>(val10);
				((Object)targetProductIconObj).name = "target-product";
				targetProductIconObj.transform.SetParent(val7);
				targetProductIconObj.transform.localScale = Vector3.one;
				RectTransform component3 = targetProductIconObj.GetComponent<RectTransform>();
				component3.anchorMax = new Vector2(0f, 1f);
				component3.anchorMin = new Vector2(0f, 1f);
				component3.anchoredPosition3D = new Vector3(targetIconAnchoredPosX, targetIconAnchoredPosYLargeWindow, 0f);
				component3.sizeDelta = new Vector2(54f, 54f);
				((Component)targetProductIconObj.transform.Find("white")).GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 40f);
				targetProductIconObj.GetComponent<UIButton>().transitions[0].normalColor = itemIconNormalColor;
				targetProductIconObj.GetComponent<UIButton>().transitions[0].mouseoverColor = itemIconHighlightColor;
				targetProductIcon = ((Component)targetProductIconObj.transform.Find("white")).GetComponent<Image>();
				((UnityEventBase)targetProductIconObj.GetComponent<Button>().onClick).RemoveAllListeners();
				((UnityEvent)targetProductIconObj.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					OnTargetProductIconClick();
				});
				targetProductIcon.sprite = Resources.Load<Sprite>("ui/textures/sprites/icons/controlpanel-icon-40");
				targetProductIconUIBtn = targetProductIconObj.GetComponent<UIButton>();
			}
			else
			{
				Debug.LogError((object)"Error when init UICalcWindow.");
			}
			speedInputObj = Object.Instantiate<GameObject>(val8, val7);
			((Object)speedInputObj).name = "speed-input";
			speedInputObj.transform.localPosition = new Vector3(120f, 0f, 0f);
			speedInputObj.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 30f);
			speedInputObj.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f);
			speedInputObj.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(100f, targetIconAnchoredPosYLargeWindow, 0f);
			speedInputObj.GetComponent<InputField>().text = "3600";
			speedInputObj.GetComponent<InputField>().contentType = (ContentType)3;
			speedInputObj.GetComponent<InputField>().characterLimit = 12;
			((Selectable)speedInputObj.GetComponent<InputField>()).transition = (Transition)0;
			((UnityEventBase)speedInputObj.GetComponent<InputField>().onEndEdit).RemoveAllListeners();
			((UnityEvent<string>)(object)speedInputObj.GetComponent<InputField>().onEndEdit).AddListener((UnityAction<string>)delegate(string x)
			{
				OnTargetSpeedChange(x);
			});
			((Graphic)speedInputObj.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			((Graphic)((Component)speedInputObj.transform.Find("value-text")).GetComponent<Text>()).color = Color.white;
			((Component)speedInputObj.transform.Find("value-text")).GetComponent<Text>().fontSize = 16;
			speedInputObj.GetComponent<UIButton>().tips.tipTitle = "";
			speedInputObj.GetComponent<UIButton>().tips.tipText = "";
			speedInputObj.SetActive(false);
			speedInputObj.SetActive(true);
			perMinTextObj = Object.Instantiate<GameObject>(TextObj, val7);
			((Object)perMinTextObj).name = "per-minute";
			perMinTextObj.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
			perMinTextObj.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
			perMinTextObj.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(210f, targetIconAnchoredPosYLargeWindow, 0f);
			perMinTextObj.GetComponent<Text>().text = "/min";
			incToggleObj = Object.Instantiate<GameObject>(incTogglePrefabObj, val7);
			((Object)incToggleObj).name = "inc-setting";
			incToggleObj.transform.localPosition = new Vector3(-38f, 287f, 0f);
			((UnityEvent)((Component)incToggleObj.transform.Find("inc-switch")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				OnGlobalIncToggleClick();
			});
			incText = ((Component)incToggleObj.transform.Find("inc-effect-type-text")).GetComponent<Text>();
			GameObject gameObject5 = ((Component)incToggleObj.transform.Find("inc-switch/switch-thumb")).gameObject;
			if (solution.userPreference.globalIsInc)
			{
				gameObject5.GetComponent<RectTransform>().anchoredPosition = new Vector2(-10f, 0f);
				incText.text = Localization.Translate("额外产出calc");
				((Graphic)incText).color = incModeTextColor;
				((Graphic)((Component)incToggleObj.transform.Find("inc-switch")).GetComponent<Image>()).color = incModeImageColor;
			}
			else
			{
				gameObject5.GetComponent<RectTransform>().anchoredPosition = new Vector2(10f, 0f);
				incText.text = Localization.Translate("生产加速calc");
				((Graphic)incText).color = accModeTextColor;
				((Graphic)((Component)incToggleObj.transform.Find("inc-switch")).GetComponent<Image>()).color = accModeImageColor;
			}
			incToggleObj.SetActive(true);
			proliferatorSelectionObj = new GameObject();
			((Object)proliferatorSelectionObj).name = "proliferator-select";
			proliferatorSelectionObj.transform.SetParent(val7, false);
			proliferatorSelectionObj.transform.localPosition = new Vector3(82f, 270f, 0f);
			int itemId = 0;
			int incLevel2 = 0;
			GameObject val11 = Object.Instantiate<GameObject>(imageButtonObj, proliferatorSelectionObj.transform);
			val11.GetComponent<Image>().sprite = buttonBackgroundSprite;
			Image component4 = ((Component)val11.transform.Find("icon")).GetComponent<Image>();
			component4.sprite = bannedSprite;
			((Graphic)component4).color = Color.red;
			val11.transform.localPosition = new Vector3(0f, 0f);
			((UnityEvent)val11.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				SetGlobalIncLevel(incLevel2);
			});
			proliferatorUsedButtons[incLevel2] = val11.GetComponent<UIButton>();
			proliferatorUsedButtons[incLevel2].tips.itemId = itemId;
			for (int i = 0; i < CalcDB.proliferatorItemIds.Count; i++)
			{
				int num4 = CalcDB.proliferatorItemIds[i];
				int incLevel = CalcDB.proliferatorAbilitiesMap[num4];
				GameObject val12 = Object.Instantiate<GameObject>(imageButtonObj, proliferatorSelectionObj.transform);
				val12.GetComponent<Image>().sprite = buttonBackgroundSprite;
				Image component5 = ((Component)val12.transform.Find("icon")).GetComponent<Image>();
				component5.sprite = ((ProtoSet<ItemProto>)(object)LDB.items).Select(num4).iconSprite;
				val12.transform.localPosition = new Vector3((float)((i + 1) * 35), 0f);
				((UnityEvent)val12.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					SetGlobalIncLevel(incLevel);
				});
				proliferatorUsedButtons[incLevel] = val12.GetComponent<UIButton>();
				proliferatorUsedButtons[incLevel].tips.itemId = num4;
			}
			assemblerSelectionObj = new GameObject();
			((Object)assemblerSelectionObj).name = "assembler-select";
			assemblerSelectionObj.transform.SetParent(val7, false);
			float num5 = 0f;
			float num6 = 0f;
			if (CompatManager.GB)
			{
				num5 = -45f;
				num6 = -10f;
			}
			assemblerSelectionObj.transform.localPosition = new Vector3(-358f + num5, 270f + num6, 0f);
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			foreach (KeyValuePair<int, List<AssemblerData>> item in CalcDB.assemblerListByType)
			{
				if ((float)(num7 * 35 + num8 * 10) + num5 > 315f)
				{
					num9++;
					num7 = 0;
					num8 = 0;
				}
				int typeInt = item.Key;
				if (!assemblerUsedButtons.ContainsKey(typeInt))
				{
					assemblerUsedButtons[typeInt] = new Dictionary<int, UIButton>();
				}
				List<AssemblerData> value = item.Value;
				if (value.Count <= 1)
				{
					continue;
				}
				for (int j = 0; j < value.Count; j++)
				{
					AssemblerData assemblerData = value[j];
					int assemblerItemId = assemblerData.ID;
					dictionary[assemblerItemId] = 1;
					GameObject val13 = Object.Instantiate<GameObject>(imageButtonObj, assemblerSelectionObj.transform);
					val13.GetComponent<Image>().sprite = buttonBackgroundSprite;
					Image component6 = ((Component)val13.transform.Find("icon")).GetComponent<Image>();
					component6.sprite = assemblerData.iconSprite;
					val13.transform.localPosition = new Vector3((float)(num7 * 35 + num8 * 10), (float)(num9 * 35));
					((UnityEvent)val13.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
					{
						SetGlobalAssemblerPreference(typeInt * 100000 + assemblerItemId);
					});
					val13.GetComponent<UIButton>().highlighted = false;
					val13.GetComponent<UIButton>().tips.itemId = assemblerItemId;
					val13.GetComponent<UIButton>().tips.corner = 3;
					val13.GetComponent<UIButton>().tips.delay = 0.1f;
					assemblerUsedButtons[typeInt][assemblerItemId] = val13.GetComponent<UIButton>();
					num7++;
				}
				num8++;
			}
			GameObject val14 = Object.Instantiate<GameObject>(TextObj, val5);
			((Object)val14).name = "final-info";
			val14.transform.localPosition = new Vector3(15f, -20f, 0f);
			finalInfoText = val14.GetComponent<Text>();
			finalInfoText.fontSize = 16;
			finalInfoText.alignment = (TextAnchor)0;
			GameObject val15 = Object.Instantiate<GameObject>(TextObj, val5);
			val15.transform.localPosition = new Vector3(15f, -82f, 0f);
			assemblerDemandsTitleText = val15.GetComponent<Text>();
			assemblerDemandsTitleText.fontSize = 16;
			assemblerDemandsTitleText.alignment = (TextAnchor)0;
			assemblerDemandsTitleText.text = Localization.Translate("工厂需求");
			assemblersDemandsGroupObj = new GameObject();
			((Object)assemblersDemandsGroupObj).name = "assember-demands";
			assemblersDemandsGroupObj.transform.SetParent(val5);
			assemblersDemandsGroupObj.transform.localScale = Vector3.one;
			assemblersDemandsGroupObj.transform.localPosition = new Vector3(13f, -110f, 0f);
			GameObject val16 = Object.Instantiate<GameObject>(iconObj_ButtonTip);
			((Object)val16).name = "reset-all";
			val16.transform.SetParent(val7, false);
			val16.transform.localScale = Vector3.one;
			val16.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
			val16.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
			val16.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
			val16.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(-75f, -15f, 0f);
			val16.GetComponent<RectTransform>().sizeDelta = new Vector2(18f, 18f);
			val16.GetComponent<Image>().sprite = resetSprite;
			((UnityEvent)val16.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				ClearAllUserPreference();
			});
			val16.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("还原默认配置标题");
			val16.GetComponent<UIButton>().tips.tipText = Localization.Translate("还原默认配置说明");
			val16.GetComponent<UIButton>().tips.corner = 3;
			val16.GetComponent<UIButton>().tips.width = 200;
			val16.GetComponent<UIButton>().transitions[0].normalColor = new Color(0.6f, 0f, 0f, 1f);
			val16.GetComponent<UIButton>().transitions[0].pressedColor = new Color(0.6f, 0f, 0f, 1f);
			val16.GetComponent<UIButton>().transitions[0].mouseoverColor = new Color(0.9f, 0.2f, 0.2f, 1f);
			GameObject val17 = new GameObject();
			((Object)val17).name = "checkbox-group";
			val17.transform.SetParent(val5);
			val17.transform.localScale = Vector3.one;
			val17.transform.localPosition = new Vector3(155f, -20f, 0f);
			if (CompatManager.TCFV)
			{
				GameObject val18 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
				((Object)val18).name = "checkbox-bluebuff";
				cbBluebuff = val18.GetComponent<Image>();
				txtBluebuff = ((Component)val18.transform.Find("text")).GetComponent<Text>();
				val18.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((UnityEvent)val18.GetComponent<Button>().onClick).AddListener(new UnityAction(OnBluebuffClick));
				GameObject val19 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
				((Object)val19).name = "checkbox-energyburst";
				cbEnergyBurst = val19.GetComponent<Image>();
				txtEnergyBurst = ((Component)val19.transform.Find("text")).GetComponent<Text>();
				val19.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, -20f, 0f);
				((UnityEvent)val19.GetComponent<Button>().onClick).AddListener(new UnityAction(OnEnergyBurstClick));
				GameObject val20 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
				((Object)val20).name = "checkbox-dirac";
				cbDirac = val20.GetComponent<Image>();
				txtDirac = ((Component)val20.transform.Find("text")).GetComponent<Text>();
				val20.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, -40f, 0f);
				((UnityEvent)val20.GetComponent<Button>().onClick).AddListener(new UnityAction(OnDiracClick));
				GameObject val21 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
				((Object)val21).name = "checkbox-inferior";
				cbInferior = val21.GetComponent<Image>();
				txtInferior = ((Component)val21.transform.Find("text")).GetComponent<Text>();
				val21.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, -60f, 0f);
				((UnityEvent)val21.GetComponent<Button>().onClick).AddListener(new UnityAction(OnInferiorClick));
			}
			GameObject val22 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
			((Object)val22).name = "checkbox-custom-inc";
			cbIncMilli = val22.GetComponent<Image>();
			txtIncMilli = ((Component)val22.transform.Find("text")).GetComponent<Text>();
			val22.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(110f, 0f, 0f);
			((UnityEvent)val22.GetComponent<Button>().onClick).AddListener(new UnityAction(OnCustomIncMilliClick));
			val22.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("强制增产效能标题");
			val22.GetComponent<UIButton>().tips.tipText = Localization.Translate("强制增产效能说明");
			val22.GetComponent<UIButton>().tips.corner = 1;
			val22.GetComponent<UIButton>().tips.delay = 0.1f;
			val22.GetComponent<UIButton>().tips.width = 400;
			GameObject val23 = Object.Instantiate<GameObject>(val8, val17.transform);
			((Object)val23).name = "inputfield-inc";
			val23.GetComponent<RectTransform>().sizeDelta = new Vector2(30f, 20f);
			val23.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f);
			val23.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(212f, 0f, 0f);
			incInput = val23.GetComponent<InputField>();
			val23.GetComponent<InputField>().text = "25";
			val23.GetComponent<InputField>().contentType = (ContentType)2;
			val23.GetComponent<InputField>().characterLimit = 3;
			((Selectable)val23.GetComponent<InputField>()).transition = (Transition)0;
			((UnityEventBase)val23.GetComponent<InputField>().onEndEdit).RemoveAllListeners();
			((UnityEvent<string>)(object)val23.GetComponent<InputField>().onEndEdit).AddListener((UnityAction<string>)delegate(string x)
			{
				OnEndEditIncMilli(x);
			});
			((Graphic)val23.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			((Graphic)((Component)val23.transform.Find("value-text")).GetComponent<Text>()).color = Color.white;
			((Component)val23.transform.Find("value-text")).GetComponent<Text>().fontSize = 12;
			val23.GetComponent<UIButton>().tips.tipTitle = "";
			val23.GetComponent<UIButton>().tips.tipText = "";
			val23.SetActive(false);
			val23.SetActive(true);
			GameObject val24 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
			((Object)val24).name = "checkbox-custom-acc";
			cbAccMilli = val24.GetComponent<Image>();
			txtAccMilli = ((Component)val24.transform.Find("text")).GetComponent<Text>();
			val24.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(110f, -20f, 0f);
			((UnityEvent)val24.GetComponent<Button>().onClick).AddListener(new UnityAction(OnCustomAccMilliClick));
			val24.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("强制加速效能标题");
			val24.GetComponent<UIButton>().tips.tipText = Localization.Translate("强制加速效能说明");
			val24.GetComponent<UIButton>().tips.corner = 1;
			val24.GetComponent<UIButton>().tips.delay = 0.1f;
			val24.GetComponent<UIButton>().tips.width = 400;
			GameObject val25 = Object.Instantiate<GameObject>(val8, val17.transform);
			((Object)val25).name = "inputfield-acc";
			val25.GetComponent<RectTransform>().sizeDelta = new Vector2(30f, 20f);
			val25.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f);
			val25.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(212f, -20f, 0f);
			accInput = val25.GetComponent<InputField>();
			val25.GetComponent<InputField>().text = "100";
			val25.GetComponent<InputField>().contentType = (ContentType)2;
			val25.GetComponent<InputField>().characterLimit = 3;
			((Selectable)val25.GetComponent<InputField>()).transition = (Transition)0;
			((UnityEventBase)val25.GetComponent<InputField>().onEndEdit).RemoveAllListeners();
			((UnityEvent<string>)(object)val25.GetComponent<InputField>().onEndEdit).AddListener((UnityAction<string>)delegate(string x)
			{
				OnEndEditAccMilli(x);
			});
			((Graphic)val25.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			((Graphic)((Component)val25.transform.Find("value-text")).GetComponent<Text>()).color = Color.white;
			((Component)val25.transform.Find("value-text")).GetComponent<Text>().fontSize = 12;
			val25.GetComponent<UIButton>().tips.tipTitle = "";
			val25.GetComponent<UIButton>().tips.tipText = "";
			val25.SetActive(false);
			val25.SetActive(true);
			GameObject val26 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
			((Object)val26).name = "checkbox-roundup";
			cbRoundUp = val26.GetComponent<Image>();
			txtRoundUp = ((Component)val26.transform.Find("text")).GetComponent<Text>();
			val26.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(110f, -40f, 0f);
			((UnityEvent)val26.GetComponent<Button>().onClick).AddListener(new UnityAction(OnAssemblerRoundUpSettingChange));
			GameObject val27 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
			((Object)val27).name = "checkbox-roundup";
			cbSolveProlifer = val27.GetComponent<Image>();
			txtSolveProlifer = ((Component)val27.transform.Find("text")).GetComponent<Text>();
			val27.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(110f, -60f, 0f);
			((UnityEvent)val27.GetComponent<Button>().onClick).AddListener(new UnityAction(OnSolveProliferatorSettingChange));
			val27.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("增产剂并入产线");
			val27.GetComponent<UIButton>().tips.tipText = Localization.Translate("增产剂并入产线描述");
			val27.GetComponent<UIButton>().tips.corner = 1;
			val27.GetComponent<UIButton>().tips.delay = 0.1f;
			val27.GetComponent<UIButton>().tips.width = 300;
			GameObject val28 = Object.Instantiate<GameObject>(checkBoxObj, val17.transform);
			((Object)val28).name = "checkbox-mixbelt";
			cbMixbelt = val28.GetComponent<Image>();
			txtMixbelt = ((Component)val28.transform.Find("text")).GetComponent<Text>();
			val28.GetComponent<UIButton>().tips.tipTitle = Localization.Translate("混带显示标题");
			val28.GetComponent<UIButton>().tips.tipText = Localization.Translate("混带显示说明");
			val28.GetComponent<UIButton>().tips.corner = 1;
			val28.GetComponent<UIButton>().tips.delay = 0.1f;
			val28.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(110f, -60f, 0f);
			((UnityEvent)val28.GetComponent<Button>().onClick).AddListener(new UnityAction(OnMixbeltInfoCbClick));
			val28.SetActive(DSPCalculatorPlugin.showMixBeltCheckbox);
			RefreshFinalInfoText();
			RefreshCheckBoxes();
			RefreshAssemblerButtonDisplay();
			RefreshProliferatorButtonDisplay();
		}

		public static void TryInitStaticPrefabs()
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Expected O, but got Unknown
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)recipeObj == (Object)null)
			{
				UIItemTip val = Object.Instantiate<UIItemTip>(Configs.builtin.uiItemTipPrefab);
				recipeObj = ((Component)((Component)val).gameObject.transform.Find("recipe")).gameObject;
				arrowObj = ((Component)recipeObj.transform.Find("arrow")).gameObject;
				iconObj_NoTip = ((Component)recipeObj.transform.Find("icon")).gameObject;
				iconObj_ButtonTip = Object.Instantiate<GameObject>(iconObj_NoTip);
				((Graphic)iconObj_ButtonTip.GetComponent<Image>()).raycastTarget = true;
				((Component)iconObj_ButtonTip.transform.Find("count")).gameObject.SetActive(false);
				UIButton val2 = iconObj_ButtonTip.AddComponent<UIButton>();
				Button button = iconObj_ButtonTip.AddComponent<Button>();
				val2.button = button;
				val2.audios = default(AudioSettings);
				val2.audios.enterName = "ui-hover-0";
				val2.audios.downName = "ui-click-0";
				val2.audios.upName = "";
				val2.transitions = (Transition[])(object)new Transition[1];
				Transition val3 = new Transition();
				val2.transitions[0] = val3;
				val3.target = (Graphic)(object)iconObj_ButtonTip.GetComponent<Image>();
				val3.damp = 0.3f;
				val3.mouseoverSize = 1f;
				val3.pressedSize = 1f;
				val3.normalColor = itemIconNormalColor;
				val3.mouseoverColor = itemIconHighlightColor;
				val3.pressedColor = itemIconPressedColor;
				val3.disabledColor = itemIconDisabledColor;
				RectTransform component = iconObj_ButtonTip.GetComponent<RectTransform>();
				component.anchorMax = new Vector2(0f, 0.5f);
				component.anchorMin = new Vector2(0f, 0.5f);
				component.pivot = new Vector2(0f, 0.5f);
				TextObj = Object.Instantiate<GameObject>(GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Assembler Window/state/state-text"));
				TextObj.GetComponent<Text>().text = "";
				TextObj.GetComponent<Text>().alignment = (TextAnchor)3;
				((Graphic)TextObj.GetComponent<Text>()).color = TextWhiteColor;
				TextObj.GetComponent<Text>().lineSpacing = 0.7f;
				TextWithUITip = Object.Instantiate<GameObject>(TextObj);
				UIButton val4 = TextWithUITip.AddComponent<UIButton>();
				Button val5 = TextWithUITip.AddComponent<Button>();
				((Selectable)val5).transition = (Transition)0;
				val4.button = val5;
				val4.transitions = (Transition[])(object)new Transition[0];
				GameObject val6 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Dyson Sphere Editor/Dyson Editor Control Panel/hierarchy/layers/buttons-group/buttons/add-button");
				textButtonObj = Object.Instantiate<GameObject>(val6);
				((Object)textButtonObj).name = "button";
				textButtonObj.transform.localScale = Vector3.one;
				((UnityEventBase)textButtonObj.GetComponent<Button>().onClick).RemoveAllListeners();
				textButtonObj.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
				textButtonObj.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
				GameObject val7 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/ray-receiver/switch-button-1");
				imageButtonObj = Object.Instantiate<GameObject>(val7);
				((Object)imageButtonObj).name = "button-img";
				((UnityEventBase)imageButtonObj.GetComponent<Button>().onClick).RemoveAllListeners();
				imageButtonObj.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
				imageButtonObj.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
				Object.DestroyImmediate((Object)(object)imageButtonObj.GetComponent<Button>());
				imageButtonObj.AddComponent<Button>();
				Object.DestroyImmediate((Object)(object)((Component)imageButtonObj.transform.Find("button-text")).gameObject);
				imageButtonObj.GetComponent<RectTransform>().sizeDelta = new Vector2(32f, 32f);
				imageButtonObj.GetComponent<UIButton>().tips.tipTitle = "";
				imageButtonObj.GetComponent<UIButton>().tips.tipText = "";
				GameObject val8 = new GameObject();
				((Object)val8).name = "icon";
				val8.transform.SetParent(imageButtonObj.transform, false);
				Image val9 = val8.AddComponent<Image>();
				val9.sprite = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1101)._iconSprite;
				val8.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
				val8.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f, 0.5f);
				val8.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f, 0.5f);
				val8.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, 0f, 0f);
				val8.GetComponent<RectTransform>().sizeDelta = new Vector2(30f, 30f);
				val8.transform.localScale = Vector3.one;
				incTogglePrefabObj = Object.Instantiate<GameObject>(GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Assembler Window/produce/inc-info"));
				((UnityEventBase)((Component)incTogglePrefabObj.transform.Find("inc-switch")).GetComponent<Button>().onClick).RemoveAllListeners();
				Object.DestroyImmediate((Object)(object)((Component)incTogglePrefabObj.transform.Find("inc-label")).gameObject);
				Object.DestroyImmediate((Object)(object)((Component)incTogglePrefabObj.transform.Find("inc-effect-value-text")).gameObject);
				Object.DestroyImmediate((Object)(object)((Component)incTogglePrefabObj.transform.Find("inc-effect-value-text-2")).gameObject);
				Object.DestroyImmediate((Object)(object)((Component)incTogglePrefabObj.transform.Find("inc-effect-type-text-2")).gameObject);
				((Component)incTogglePrefabObj.transform.Find("inc-effect-type-text")).GetComponent<RectTransform>().anchoredPosition3D = new Vector3(138f, 0f, 0f);
				((Component)incTogglePrefabObj.transform.Find("inc-effect-type-text")).GetComponent<Text>().alignment = (TextAnchor)5;
				checkBoxObj = Object.Instantiate<GameObject>(GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Dyson Sphere Editor/Dyson Editor Control Panel/hierarchy/layers/display-group/display-toggle-3/checkbox-back-structures"));
				((Object)checkBoxObj).name = "check-box";
				((UnityEventBase)checkBoxObj.GetComponent<Button>().onClick).RemoveAllListeners();
				((Graphic)((Component)checkBoxObj.transform.Find("text")).GetComponent<Text>()).color = Color.white;
				leftTriangleSprite = Resources.Load<Sprite>("ui/textures/sprites/test/last-icon");
				rightTriangleSprite = Resources.Load<Sprite>("ui/textures/sprites/test/next-icon");
				backgroundSprite = Resources.Load<Sprite>("ui/textures/sprites/sci-fi/window-content-3");
				buttonBackgroundSprite = Resources.Load<Sprite>("ui/textures/sprites/sci-fi/window-content-3");
				gearSprite = Resources.Load<Sprite>("icons/signal/signal-405");
				filterSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/filter-icon");
				biaxialArrowSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/biaxial-arrow");
				oreSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/vein-icon-56");
				crossSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/delete-icon");
				bannedSprite = Resources.Load<Sprite>("icons/signal/signal-509");
				todoListSprite = Resources.Load<Sprite>("ui/textures/sprites/test/test-list-alt");
				resetSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/refresh-32-icon");
				checkboxOnSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/checkbox-on");
				checkboxOffSprite = Resources.Load<Sprite>("ui/textures/sprites/icons/checkbox-off");
			}
		}

		public void OnUpdate()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)windowObj.transform.parent.GetChild(windowObj.transform.parent.childCount - 1) == (Object)(object)windowObj.transform && windowObj.activeSelf)
			{
				isTopAndActive = true;
			}
			else
			{
				isTopAndActive = false;
			}
			float num = largeWindowWidth;
			if (!isLargeWindow)
			{
				num = smallWindowWidth;
			}
			float x = windowObj.GetComponent<RectTransform>().sizeDelta.x;
			float num2 = x;
			if (num2 < num && num - num2 > 0.01f)
			{
				float y = windowObj.GetComponent<RectTransform>().sizeDelta.y;
				float y2 = viewGroupObj.GetComponent<RectTransform>().sizeDelta.y;
				num2 += animationSpeed;
				if (num2 > num)
				{
					num2 = num;
				}
				float num3 = num2 - (smallWindowWidth - smallWindowViewGroupWidth);
				if (num3 > largeWindowViewGroupWidth)
				{
					num3 = largeWindowViewGroupWidth;
				}
				windowObj.GetComponent<RectTransform>().sizeDelta = new Vector2(num2, y);
				float num4 = (num2 - smallWindowWidth) / (largeWindowWidth - smallWindowWidth) * (largeWindowViewGroupHeight - smallWindowViewGroupHeight) + smallWindowViewGroupHeight;
				viewGroupObj.GetComponent<RectTransform>().sizeDelta = new Vector2(num3, num4);
				float num5 = (num2 - smallWindowWidth) / (largeWindowWidth - smallWindowWidth) * (targetIconAnchoredPosYLargeWindow - targetIconAnchoredPosYSmallWindow) + targetIconAnchoredPosYSmallWindow;
				float x2 = targetProductIconObj.GetComponent<RectTransform>().anchoredPosition.x;
				targetProductIconObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(x2, num5);
				x2 = speedInputObj.GetComponent<RectTransform>().anchoredPosition.x;
				speedInputObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(x2, num5);
				x2 = perMinTextObj.GetComponent<RectTransform>().anchoredPosition.x;
				perMinTextObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(x2, num5);
			}
			else if (num2 > num && num2 - num > 0.01f)
			{
				float y3 = windowObj.GetComponent<RectTransform>().sizeDelta.y;
				float y4 = viewGroupObj.GetComponent<RectTransform>().sizeDelta.y;
				num2 -= animationSpeed;
				if (num2 < num)
				{
					num2 = num;
				}
				float num6 = num2 - (smallWindowWidth - smallWindowViewGroupWidth);
				if (num6 > largeWindowViewGroupWidth)
				{
					num6 = largeWindowViewGroupWidth;
				}
				windowObj.GetComponent<RectTransform>().sizeDelta = new Vector2(num2, y3);
				float num7 = (num2 - smallWindowWidth) / (largeWindowWidth - smallWindowWidth) * (largeWindowViewGroupHeight - smallWindowViewGroupHeight) + smallWindowViewGroupHeight;
				viewGroupObj.GetComponent<RectTransform>().sizeDelta = new Vector2(num6, num7);
				float num8 = (num2 - smallWindowWidth) / (largeWindowWidth - smallWindowWidth) * (targetIconAnchoredPosYLargeWindow - targetIconAnchoredPosYSmallWindow) + targetIconAnchoredPosYSmallWindow;
				float x3 = targetProductIconObj.GetComponent<RectTransform>().anchoredPosition.x;
				targetProductIconObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(x3, num8);
				x3 = speedInputObj.GetComponent<RectTransform>().anchoredPosition.x;
				speedInputObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(x3, num8);
				x3 = perMinTextObj.GetComponent<RectTransform>().anchoredPosition.x;
				perMinTextObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(x3, num8);
			}
			ShowHideChildrenWhenWindowSizeChanged(x, num2);
			if (nextFrameRecalc)
			{
				nextFrameRecalc = false;
				solution.ReSolve();
				RefreshAll();
			}
			if (titleInput.isFocused)
			{
				titleInputUIBtn.highlighted = true;
			}
			else
			{
				titleInputUIBtn.highlighted = false;
			}
			if (windowObj.activeSelf)
			{
				if (targetVerticalPosition >= 0f)
				{
					float num9 = targetVerticalPosition - contentScrollRect.verticalNormalizedPosition;
					float num10 = 0.01f;
					float num11 = 0.1f;
					if (uiItemNodeOrders.Count > 12)
					{
						float num12 = (float)uiItemNodeOrders.Count * 1f / 12f;
						num10 *= 0.2f + 0.8f / num12;
						num11 *= 0.8f + 0.2f / num12;
					}
					if (num9 <= num10 && num9 >= 0f - num10)
					{
						contentScrollRect.verticalNormalizedPosition = targetVerticalPosition;
						targetVerticalPosition = -1f;
					}
					else
					{
						float num13 = num9 * num11;
						if (num13 > 0f && num13 < num10)
						{
							num13 = num10;
						}
						else if (num13 < 0f && num13 > 0f - num10)
						{
							num13 = 0f - num10;
						}
						ScrollRect obj = contentScrollRect;
						obj.verticalNormalizedPosition += num13;
					}
				}
				bool isMoving = targetVerticalPosition >= 0f;
				for (int i = 0; i < uiItemNodes.Count; i++)
				{
					uiItemNodes[i].OnUpdate(isMoving);
				}
				for (int j = 0; j < uiSideItemNodes.Count; j++)
				{
					uiSideItemNodes[j].OnUpdate(isMoving);
				}
			}
			if (isTopAndActive)
			{
				bool shift = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
				bool ctrl = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
				bool alt = Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307);
				if (Input.GetKeyDown(DSPCalculatorPlugin.SwitchWindowSizeHotKey.Value) && UIHotkeySettingPatcher.CheckModifier(2, shift, ctrl, alt))
				{
					SwitchWindowSize();
				}
			}
		}

		public void AddCellTest()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject();
			Image val2 = val.AddComponent<Image>();
			val2.sprite = Resources.Load<Sprite>("Assets/DSPBattle/r3-5");
			val.GetComponent<RectTransform>().sizeDelta = new Vector2(890f, 80f);
			val.transform.SetParent(mainCanvasObj.transform, false);
			val.SetActive(false);
			val.SetActive(true);
		}

		public void CloseWindow()
		{
			if (WindowsManager.lastClosedWindow != null)
			{
				if (WindowsManager.windows != null)
				{
					WindowsManager.windows.Remove(WindowsManager.lastClosedWindow);
				}
				Object.Destroy((Object)(object)WindowsManager.lastClosedWindow.windowObj);
			}
			isTopAndActive = false;
			windowObj.transform.SetAsFirstSibling();
			windowObj.SetActive(false);
			WindowsManager.lastClosedWindow = this;
			if (!((Object)(object)UIPauseBarPatcher.pauseBarObj != (Object)null))
			{
				return;
			}
			bool flag = false;
			if (WindowsManager.windows != null)
			{
				for (int i = 0; i < WindowsManager.windows.Count; i++)
				{
					if (WindowsManager.windows[i].windowObj.activeSelf)
					{
						flag = true;
						break;
					}
				}
			}
			if (!flag)
			{
				UIPauseBarPatcher.pauseBarObj.SetActive(false);
				if ((Object)(object)GameMain.instance != (Object)null)
				{
					GameMain.instance._fullscreenPaused = false;
				}
			}
		}

		public void SwitchWindowSize()
		{
			isLargeWindow = !isLargeWindow;
		}

		public void OpenWindow()
		{
			if (WindowsManager.lastClosedWindow == this)
			{
				WindowsManager.lastClosedWindow = null;
			}
			windowObj.transform.SetAsLastSibling();
			windowObj.SetActive(true);
			titleText.text = Localization.Translate("量化计算器");
			RefreshCheckBoxes();
		}

		public void OnTargetProductIconClick()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			UIItemPicker.showAll = true;
			UIItemPicker.Popup(windowObj.GetComponent<RectTransform>().anchoredPosition + new Vector2(300f, -200f), (Action<ItemProto>)OnTargetProductChange);
		}

		public void OnTargetProductChange(ItemProto item)
		{
			UIItemPicker.showAll = false;
			if (item != null)
			{
				targetProductIcon.sprite = item.iconSprite;
				targetProductIconUIBtn.tips.corner = 3;
				targetProductIconUIBtn.tips.itemId = ((Proto)item).ID;
				targetProductIconUIBtn.tips.delay = 0.1f;
				solution.SetTargetItemAndBeginSolve(((Proto)item).ID);
				RefreshAll();
			}
		}

		public void OnTargetSpeedChange(string num)
		{
			try
			{
				double targetSpeed = Convert.ToDouble(num);
				solution.ChangeTargetSpeedAndSolve(targetSpeed);
				RefreshAll();
			}
			catch (Exception)
			{
			}
		}

		public void ShowHideChildrenWhenWindowSizeChanged(float oriWidth, float curWidth)
		{
			if (oriWidth >= 0.5f * largeWindowWidth && curWidth < 0.5f * largeWindowWidth)
			{
				incToggleObj.SetActive(false);
				proliferatorSelectionObj.SetActive(false);
				targetProductTextObj.SetActive(false);
				switchSizeButtonObj.GetComponent<Image>().sprite = rightTriangleSprite;
			}
			else if (oriWidth <= 0.5f * largeWindowWidth && curWidth > 0.5f * largeWindowWidth)
			{
				incToggleObj.SetActive(true);
				proliferatorSelectionObj.SetActive(true);
				targetProductTextObj.SetActive(true);
				switchSizeButtonObj.GetComponent<Image>().sprite = leftTriangleSprite;
			}
			if (oriWidth >= 0.9f * largeWindowWidth && curWidth < 0.9f * largeWindowWidth)
			{
				assemblerSelectionObj.SetActive(false);
			}
			else if (oriWidth <= 0.9f * largeWindowWidth && curWidth > 0.9f * largeWindowWidth)
			{
				assemblerSelectionObj.SetActive(true);
			}
		}

		public void RefreshAll()
		{
			RefreshProductContent();
			RefreshResourceNeedAndByProductContent();
			RefreshFinalInfoText();
			RefreshAssemblerDemandsDisplay();
			RefreshAssemblerButtonDisplay();
			RefreshIncToggle();
			RefreshProliferatorButtonDisplay();
			RefreshCheckBoxes();
		}

		public void RefreshProductContent()
		{
			for (int i = 0; i < uiItemNodes.Count; i++)
			{
				Object.DestroyImmediate((Object)(object)uiItemNodes[i].obj);
			}
			ClearNodes();
			int num = 0;
			if (solution.targetItem > 0 && solution.root != null && !solution.userPreference.solveProliferators)
			{
				List<ItemNode> list = new List<ItemNode>();
				list.Add(solution.root);
				Dictionary<int, ItemNode> dictionary = new Dictionary<int, ItemNode>();
				while (list.Count > 0)
				{
					ItemNode itemNode = list[list.Count - 1];
					ItemNode itemNode2 = solution.itemNodes[itemNode.itemId];
					if (!dictionary.ContainsKey(itemNode2.itemId) && itemNode2.needSpeed > 0.0010000000474974513)
					{
						dictionary.Add(itemNode2.itemId, itemNode2);
						if (!itemNode2.IsOre(solution.userPreference))
						{
							UIItemNode item = new UIItemNode(itemNode2, this);
							uiItemNodes.Add(item);
							uiItemNodeOrders[itemNode2.itemId] = num;
							num++;
						}
						else if (solution.userPreference.showMixBeltInfo)
						{
							UIItemNode item2 = new UIItemNode(itemNode2, this);
							uiItemNodes.Add(item2);
							uiItemNodeOrders[itemNode2.itemId] = num;
							num++;
						}
					}
					list.RemoveAt(list.Count - 1);
					for (int num2 = itemNode2.children.Count - 1; num2 >= 0; num2--)
					{
						list.Add(itemNode2.children[num2]);
					}
				}
			}
			if (solution.targetItem <= 0 || solution.root == null || !solution.userPreference.solveProliferators)
			{
				return;
			}
			Dictionary<int, ItemNode> dictionary2 = new Dictionary<int, ItemNode>();
			for (int num3 = CalcDB.proliferatorItemIds.Count; num3 >= 0; num3--)
			{
				List<ItemNode> list2 = new List<ItemNode>();
				if (num3 == CalcDB.proliferatorItemIds.Count)
				{
					list2.Add(solution.root);
				}
				else
				{
					int index = num3;
					int key = CalcDB.proliferatorItemIds[index];
					if (solution.itemNodes.ContainsKey(key) && solution.itemNodes[key].needSpeed > 0.0)
					{
						list2.Add(solution.itemNodes[key]);
					}
				}
				while (list2.Count > 0)
				{
					ItemNode itemNode3 = list2[list2.Count - 1];
					ItemNode itemNode4 = solution.itemNodes[itemNode3.itemId];
					if (!dictionary2.ContainsKey(itemNode4.itemId) && itemNode4.needSpeed > 0.0010000000474974513)
					{
						dictionary2.Add(itemNode4.itemId, itemNode4);
						if (!itemNode4.IsOre(solution.userPreference))
						{
							UIItemNode item3 = new UIItemNode(itemNode4, this);
							uiItemNodes.Add(item3);
							uiItemNodeOrders[itemNode4.itemId] = num;
							num++;
						}
						else if (solution.userPreference.showMixBeltInfo)
						{
							UIItemNode item4 = new UIItemNode(itemNode4, this);
							uiItemNodes.Add(item4);
							uiItemNodeOrders[itemNode4.itemId] = num;
							num++;
						}
					}
					list2.RemoveAt(list2.Count - 1);
					for (int num4 = itemNode4.children.Count - 1; num4 >= 0; num4--)
					{
						list2.Add(itemNode4.children[num4]);
					}
				}
			}
		}

		public void RefreshResourceNeedAndByProductContent()
		{
			for (int i = 0; i < uiSideItemNodes.Count; i++)
			{
				Object.DestroyImmediate((Object)(object)uiSideItemNodes[i].obj);
			}
			ClearSideNodes();
			if (solution.itemNodes.Count == 0)
			{
				return;
			}
			UIItemNodeSimple item = new UIItemNodeSimple(Localization.Translate("原矿需求"), this);
			uiSideItemNodes.Add(item);
			for (int j = 1; j < 3; j++)
			{
				UIItemNodeSimple item2 = new UIItemNodeSimple("", this);
				uiSideItemNodes.Add(item2);
			}
			int num = 0;
			foreach (KeyValuePair<int, ItemNode> itemNode3 in solution.itemNodes)
			{
				if (itemNode3.Value.IsOre(solution.userPreference) && itemNode3.Value.needSpeed > 0.0010000000474974513)
				{
					UIItemNodeSimple uIItemNodeSimple = new UIItemNodeSimple(itemNode3.Value, isResources: true, this);
					uiSideItemNodes.Add(uIItemNodeSimple);
					uiItemSimplesByItemId[itemNode3.Value.itemId] = uIItemNodeSimple;
					num++;
				}
			}
			if (!solution.userPreference.solveProliferators)
			{
				foreach (KeyValuePair<int, double> item13 in solution.proliferatorCount)
				{
					if (item13.Key > 0 && item13.Value > 0.0)
					{
						ItemNode itemNode = new ItemNode(item13.Key, 0.0, solution);
						itemNode.satisfiedSpeed = item13.Value;
						UIItemNodeSimple item3 = new UIItemNodeSimple(itemNode, isResources: false, this, isProliferatorDemand: true);
						uiSideItemNodes.Add(item3);
						num++;
					}
				}
			}
			if (num % 3 != 0)
			{
				int num2 = 3 - num % 3;
				for (int k = 0; k < num2; k++)
				{
					UIItemNodeSimple item4 = new UIItemNodeSimple("", this);
					uiSideItemNodes.Add(item4);
				}
			}
			UIItemNodeSimple item5 = new UIItemNodeSimple(Localization.Translate("副产物和溢出产物"), this);
			uiSideItemNodes.Add(item5);
			for (int l = 1; l < 3; l++)
			{
				UIItemNodeSimple item6 = new UIItemNodeSimple("", this);
				uiSideItemNodes.Add(item6);
			}
			num = 0;
			foreach (KeyValuePair<int, ItemNode> itemNode4 in solution.itemNodes)
			{
				if (itemNode4.Value.satisfiedSpeed - itemNode4.Value.needSpeed > 0.0010000000474974513)
				{
					UIItemNodeSimple item7 = new UIItemNodeSimple(itemNode4.Value, isResources: false, this);
					uiSideItemNodes.Add(item7);
					num++;
				}
			}
			if (num == 0)
			{
				int num3 = uiSideItemNodes.Count - 1;
				for (int m = 0; m < 3; m++)
				{
					Object.DestroyImmediate((Object)(object)uiSideItemNodes[num3 - m].obj);
					uiSideItemNodes.RemoveAt(num3 - m);
				}
			}
			else if (num % 3 != 0)
			{
				int num4 = 3 - num % 3;
				for (int n = 0; n < num4; n++)
				{
					UIItemNodeSimple item8 = new UIItemNodeSimple("", this);
					uiSideItemNodes.Add(item8);
				}
			}
			if (!solution.userPreference.showMixBeltInfo)
			{
				return;
			}
			num = 0;
			int num5 = 0;
			foreach (KeyValuePair<int, ItemNode> itemNode5 in solution.itemNodes)
			{
				num5 += itemNode5.Value.GetInserterRatio();
			}
			UIItemNodeSimple item9 = new UIItemNodeSimple(string.Format("{0} : {1} {2}", Localization.Translate("混带需求"), num5, Localization.Translate("份calc")), this);
			uiSideItemNodes.Add(item9);
			for (int num6 = 1; num6 < 3; num6++)
			{
				UIItemNodeSimple item10 = new UIItemNodeSimple("", this);
				uiSideItemNodes.Add(item10);
			}
			int[] array = new int[CalcDB.beltsDescending.Count];
			for (int num7 = 1; num7 < CalcDB.beltsDescending.Count; num7++)
			{
				if (num5 <= 0)
				{
					break;
				}
				if ((double)num5 > CalcDB.beltsDescending[num7].speed)
				{
					int num8 = (int)((double)num5 / CalcDB.beltsDescending[num7 - 1].speed);
					num5 -= (int)((double)num8 * CalcDB.beltsDescending[num7 - 1].speed);
					array[num7 - 1] = num8;
				}
			}
			if (num5 > 0)
			{
				array[^1]++;
			}
			for (int num9 = 0; num9 < array.Length; num9++)
			{
				if (array[num9] > 0)
				{
					ItemNode itemNode2 = new ItemNode(CalcDB.beltsDescending[num9].ID, 0.0, solution);
					itemNode2.satisfiedSpeed = array[num9];
					UIItemNodeSimple item11 = new UIItemNodeSimple(itemNode2, isResources: false, this, isProliferatorDemand: false, isMixBeltInfo: true);
					uiSideItemNodes.Add(item11);
					num++;
				}
			}
			if (num % 3 != 0)
			{
				int num10 = 3 - num % 3;
				for (int num11 = 0; num11 < num10; num11++)
				{
					UIItemNodeSimple item12 = new UIItemNodeSimple("", this);
					uiSideItemNodes.Add(item12);
				}
			}
		}

		public void ClearNodes()
		{
			uiItemNodes.Clear();
			uiItemNodeOrders.Clear();
		}

		public void ClearSideNodes()
		{
			uiSideItemNodes.Clear();
			uiItemSimplesByItemId.Clear();
		}

		public void RefreshFinalInfoText()
		{
			double num = 0.0;
			foreach (KeyValuePair<int, RecipeInfo> recipeInfo in solution.recipeInfos)
			{
				num += recipeInfo.Value.GetTotalEnergyConsumption();
			}
			finalInfoText.text = Localization.Translate("预估电量") + "\n" + Utils.KMG(num) + "W";
		}

		public void RefreshAssemblerDemandsDisplay()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject assemblersDemandObj in assemblersDemandObjs)
			{
				Object.DestroyImmediate((Object)(object)assemblersDemandObj);
			}
			assemblersDemandObjs.Clear();
			Dictionary<int, long> dictionary = new Dictionary<int, long>();
			foreach (KeyValuePair<int, RecipeInfo> recipeInfo in solution.recipeInfos)
			{
				RecipeInfo value = recipeInfo.Value;
				int assemblerItemId = value.assemblerItemId;
				long num = (long)Math.Ceiling(value.assemblerCount);
				if (!dictionary.ContainsKey(assemblerItemId))
				{
					dictionary[assemblerItemId] = num;
				}
				else
				{
					dictionary[assemblerItemId] += num;
				}
			}
			int num2 = 0;
			float num3 = 100f;
			foreach (KeyValuePair<int, long> item in dictionary)
			{
				if (item.Value > 0)
				{
					int key = item.Key;
					long value2 = item.Value;
					GameObject val = Object.Instantiate<GameObject>(iconObj_ButtonTip, assemblersDemandsGroupObj.transform);
					val.GetComponent<RectTransform>().anchoredPosition3D = new Vector3((float)(num2 % 4) * num3, (float)(-(num2 / 4 * 35)), 0f);
					val.GetComponent<RectTransform>().sizeDelta = new Vector2(30f, 30f);
					val.GetComponent<Image>().sprite = ((ProtoSet<ItemProto>)(object)LDB.items).Select(key).iconSprite;
					val.GetComponent<UIButton>().tips.itemId = key;
					val.GetComponent<UIButton>().tips.corner = 3;
					val.GetComponent<UIButton>().tips.delay = 0.2f;
					GameObject val2 = Object.Instantiate<GameObject>(TextWithUITip, assemblersDemandsGroupObj.transform);
					((Object)val2).name = "assembler-count";
					val2.transform.localScale = Vector3.one;
					val2.GetComponent<RectTransform>().anchoredPosition3D = new Vector3((float)(num2 % 4) * num3 + 35f, (float)(-(num2 / 4 * 35)), 0f);
					val2.GetComponent<UIButton>().tips.delay = 0.4f;
					val2.GetComponent<UIButton>().tips.corner = 2;
					Text component = val2.GetComponent<Text>();
					component.text = "× " + Utils.KMG(value2);
					component.fontSize = 16;
					((Graphic)component).raycastTarget = true;
					if (value2 > 9999)
					{
						val2.GetComponent<UIButton>().tips.tipTitle = value2.ToString("N0");
					}
					assemblersDemandObjs.Add(val);
					assemblersDemandObjs.Add(val2);
					num2++;
				}
			}
		}

		public void OnGlobalIncToggleClick()
		{
			bool flag = !solution.userPreference.globalIsInc;
			solution.userPreference.globalIsInc = flag;
			foreach (KeyValuePair<int, RecipeConfig> recipeConfig in solution.userPreference.recipeConfigs)
			{
				if (recipeConfig.Value.forceIncMode >= 0)
				{
					recipeConfig.Value.forceIncMode = (flag ? 1 : 0);
				}
			}
			RefreshIncToggle();
			nextFrameRecalc = true;
		}

		public void RefreshIncToggle()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)incToggleObj.transform.Find("inc-switch/switch-thumb")).gameObject;
			if (solution.userPreference.globalIsInc)
			{
				gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(-10f, 0f);
				incText.text = Localization.Translate("额外产出calc");
				((Graphic)incText).color = incModeTextColor;
				((Graphic)((Component)incToggleObj.transform.Find("inc-switch")).GetComponent<Image>()).color = incModeImageColor;
			}
			else
			{
				gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(10f, 0f);
				incText.text = Localization.Translate("生产加速calc");
				((Graphic)incText).color = accModeTextColor;
				((Graphic)((Component)incToggleObj.transform.Find("inc-switch")).GetComponent<Image>()).color = accModeImageColor;
			}
		}

		public void SetGlobalIncLevel(int level)
		{
			solution.userPreference.globalIncLevel = level;
			foreach (KeyValuePair<int, RecipeConfig> recipeConfig in solution.userPreference.recipeConfigs)
			{
				recipeConfig.Value.incLevel = level;
			}
			RefreshProliferatorButtonDisplay();
			nextFrameRecalc = true;
		}

		public void RefreshProliferatorButtonDisplay()
		{
			foreach (KeyValuePair<int, UIButton> proliferatorUsedButton in proliferatorUsedButtons)
			{
				if (proliferatorUsedButton.Key == solution.userPreference.globalIncLevel)
				{
					proliferatorUsedButton.Value.highlighted = true;
				}
				else
				{
					proliferatorUsedButton.Value.highlighted = false;
				}
			}
		}

		public void SetGlobalAssemblerPreference(int assemblerFullCode)
		{
			int num = assemblerFullCode / 100000;
			int num2 = assemblerFullCode % 100000;
			solution.userPreference.globalAssemblerIdByType[num] = num2;
			foreach (KeyValuePair<int, RecipeConfig> recipeConfig in solution.userPreference.recipeConfigs)
			{
				int type = CalcDB.recipeDict[recipeConfig.Value.ID].type;
				if (type == num)
				{
					solution.userPreference.recipeConfigs[recipeConfig.Key].assemblerItemId = num2;
				}
			}
			foreach (UIItemNode uiItemNode in uiItemNodes)
			{
				uiItemNode.RefreshAssemblerDisplay(refreshGlobal: false);
			}
			if (CompatManager.GB)
			{
				nextFrameRecalc = true;
				return;
			}
			RefreshAssemblerButtonDisplay();
			RefreshAssemblerDemandsDisplay();
			RefreshFinalInfoText();
		}

		public void RefreshAssemblerButtonDisplay()
		{
			foreach (KeyValuePair<int, Dictionary<int, UIButton>> assemblerUsedButton in assemblerUsedButtons)
			{
				int key = assemblerUsedButton.Key;
				int num = -1;
				if (CalcDB.assemblerListByType.ContainsKey(key) && CalcDB.assemblerListByType[key].Count > 0)
				{
					num = CalcDB.assemblerListByType[key][0].ID;
				}
				if (solution.userPreference.globalAssemblerIdByType.ContainsKey(key))
				{
					num = solution.userPreference.globalAssemblerIdByType[key];
				}
				foreach (KeyValuePair<int, UIButton> item in assemblerUsedButton.Value)
				{
					if (item.Key == num)
					{
						item.Value.highlighted = true;
					}
					else
					{
						item.Value.highlighted = false;
					}
				}
			}
		}

		

MathNet.Numerics.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Resources;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MathNet.Numerics.Differentiation;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.IntegralTransforms;
using MathNet.Numerics.Integration;
using MathNet.Numerics.Integration.GaussRule;
using MathNet.Numerics.Interpolation;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex;
using MathNet.Numerics.LinearAlgebra.Complex.Factorization;
using MathNet.Numerics.LinearAlgebra.Complex32;
using MathNet.Numerics.LinearAlgebra.Complex32.Factorization;
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.LinearAlgebra.Double.Factorization;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.LinearAlgebra.Single;
using MathNet.Numerics.LinearAlgebra.Single.Factorization;
using MathNet.Numerics.LinearAlgebra.Solvers;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.LinearRegression;
using MathNet.Numerics.Optimization;
using MathNet.Numerics.Optimization.LineSearch;
using MathNet.Numerics.Optimization.ObjectiveFunctions;
using MathNet.Numerics.Optimization.TrustRegion.Subproblems;
using MathNet.Numerics.Providers.FourierTransform;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Providers.SparseSolver;
using MathNet.Numerics.Random;
using MathNet.Numerics.RootFinding;
using MathNet.Numerics.Statistics;
using MathNet.Numerics.Threading;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]
[assembly: Guid("7b66646f-f0ee-425d-9065-910d1937a2df")]
[assembly: InternalsVisibleTo("MathNet.Numerics.Tests")]
[assembly: InternalsVisibleTo("MathNet.Numerics.Tests.MKL")]
[assembly: InternalsVisibleTo("MathNet.Numerics.Tests.CUDA")]
[assembly: InternalsVisibleTo("MathNet.Numerics.Tests.OpenBLAS")]
[assembly: InternalsVisibleTo("Benchmark")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyCompany("Math.NET Project")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright Math.NET Project")]
[assembly: AssemblyDescription("Math.NET Numerics is the numerical foundation of the Math.NET project, aiming to provide methods and algorithms for numerical computations in science, engineering and every day use. Supports .NET 5.0 or higher, .NET Standard 2.0 and .NET Framework 4.6.1 or higher, on Windows, Linux and Mac.")]
[assembly: AssemblyFileVersion("5.0.0.0")]
[assembly: AssemblyInformationalVersion("5.0.0")]
[assembly: AssemblyProduct("Math.NET Numerics")]
[assembly: AssemblyTitle("MathNet.Numerics")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/mathnet/mathnet-numerics")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: AssemblyVersion("5.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
}
namespace MathNet.Numerics
{
	public static class AppSwitches
	{
		private const string AppSwitchDisableNativeProviderProbing = "Switch.MathNet.Numerics.Providers.DisableNativeProviderProbing";

		private const string AppSwitchDisableNativeProviders = "Switch.MathNet.Numerics.Providers.DisableNativeProviders";

		private const string AppSwitchDisableMklNativeProvider = "Switch.MathNet.Numerics.Providers.DisableMklNativeProvider";

		private const string AppSwitchDisableCudaNativeProvider = "Switch.MathNet.Numerics.Providers.DisableCudaNativeProvider";

		private const string AppSwitchDisableOpenBlasNativeProvider = "Switch.MathNet.Numerics.Providers.DisableOpenBlasNativeProvider";

		public static bool DisableNativeProviderProbing
		{
			get
			{
				return IsEnabled("Switch.MathNet.Numerics.Providers.DisableNativeProviderProbing");
			}
			set
			{
				SetSwitch("Switch.MathNet.Numerics.Providers.DisableNativeProviderProbing", value);
			}
		}

		public static bool DisableNativeProviders
		{
			get
			{
				return IsEnabled("Switch.MathNet.Numerics.Providers.DisableNativeProviders");
			}
			set
			{
				SetSwitch("Switch.MathNet.Numerics.Providers.DisableNativeProviders", value);
			}
		}

		public static bool DisableMklNativeProvider
		{
			get
			{
				return IsEnabled("Switch.MathNet.Numerics.Providers.DisableMklNativeProvider");
			}
			set
			{
				SetSwitch("Switch.MathNet.Numerics.Providers.DisableMklNativeProvider", value);
			}
		}

		public static bool DisableCudaNativeProvider
		{
			get
			{
				return IsEnabled("Switch.MathNet.Numerics.Providers.DisableCudaNativeProvider");
			}
			set
			{
				SetSwitch("Switch.MathNet.Numerics.Providers.DisableCudaNativeProvider", value);
			}
		}

		public static bool DisableOpenBlasNativeProvider
		{
			get
			{
				return IsEnabled("Switch.MathNet.Numerics.Providers.DisableOpenBlasNativeProvider");
			}
			set
			{
				SetSwitch("Switch.MathNet.Numerics.Providers.DisableOpenBlasNativeProvider", value);
			}
		}

		private static void SetSwitch(string switchName, bool isEnabled)
		{
			AppContext.SetSwitch(switchName, isEnabled);
		}

		private static bool IsEnabled(string switchName)
		{
			bool isEnabled;
			return AppContext.TryGetSwitch(switchName, out isEnabled) && isEnabled;
		}
	}
	internal static class ArrayExtensions
	{
		public static void Copy(this double[] source, double[] dest)
		{
			Buffer.BlockCopy(source, 0, dest, 0, source.Length * 8);
		}

		public static void Copy(this float[] source, float[] dest)
		{
			Buffer.BlockCopy(source, 0, dest, 0, source.Length * 4);
		}

		public static void Copy(this Complex[] source, Complex[] dest)
		{
			Array.Copy(source, 0, dest, 0, source.Length);
		}

		public static void Copy(this Complex32[] source, Complex32[] dest)
		{
			Array.Copy(source, 0, dest, 0, source.Length);
		}
	}
	public static class Combinatorics
	{
		public static double Variations(int n, int k)
		{
			if (k < 0 || n < 0 || k > n)
			{
				return 0.0;
			}
			return Math.Floor(0.5 + Math.Exp(SpecialFunctions.FactorialLn(n) - SpecialFunctions.FactorialLn(n - k)));
		}

		public static double VariationsWithRepetition(int n, int k)
		{
			if (k < 0 || n < 0)
			{
				return 0.0;
			}
			return Math.Pow(n, k);
		}

		public static double Combinations(int n, int k)
		{
			return SpecialFunctions.Binomial(n, k);
		}

		public static double CombinationsWithRepetition(int n, int k)
		{
			if (k < 0 || n < 0 || (n == 0 && k > 0))
			{
				return 0.0;
			}
			if (n == 0 && k == 0)
			{
				return 1.0;
			}
			return Math.Floor(0.5 + Math.Exp(SpecialFunctions.FactorialLn(n + k - 1) - SpecialFunctions.FactorialLn(k) - SpecialFunctions.FactorialLn(n - 1)));
		}

		public static double Permutations(int n)
		{
			return SpecialFunctions.Factorial(n);
		}

		public static int[] GeneratePermutation(int n, System.Random randomSource = null)
		{
			if (n < 0)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			int[] array = new int[n];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = i;
			}
			SelectPermutationInplace(array, randomSource);
			return array;
		}

		public static void SelectPermutationInplace<T>(T[] data, System.Random randomSource = null)
		{
			System.Random random = randomSource ?? SystemRandomSource.Default;
			for (int num = data.Length - 1; num > 0; num--)
			{
				int num2 = random.Next(num + 1);
				int num3 = num;
				int num4 = num2;
				T val = data[num2];
				T val2 = data[num];
				data[num3] = val;
				data[num4] = val2;
			}
		}

		public static IEnumerable<T> SelectPermutation<T>(this IEnumerable<T> data, System.Random randomSource = null)
		{
			System.Random random = randomSource ?? SystemRandomSource.Default;
			T[] array = data.ToArray();
			for (int i = array.Length - 1; i >= 0; i--)
			{
				int j = random.Next(i + 1);
				yield return array[j];
				array[j] = array[i];
			}
		}

		public static bool[] GenerateCombination(int n, System.Random randomSource = null)
		{
			if (n < 0)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			System.Random rnd = randomSource ?? SystemRandomSource.Default;
			bool[] array = new bool[n];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = rnd.NextBoolean();
			}
			return array;
		}

		public static bool[] GenerateCombination(int n, int k, System.Random randomSource = null)
		{
			if (n < 0)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			if (k < 0)
			{
				throw new ArgumentOutOfRangeException("k", "Value must not be negative (zero is ok).");
			}
			if (k > n)
			{
				throw new ArgumentOutOfRangeException("k", "k must be smaller than or equal to n.");
			}
			System.Random random = randomSource ?? SystemRandomSource.Default;
			bool[] array = new bool[n];
			if (k * 3 < n)
			{
				int num = 0;
				while (num < k)
				{
					int num2 = random.Next(n);
					if (!array[num2])
					{
						array[num2] = true;
						num++;
					}
				}
				return array;
			}
			int[] array2 = GeneratePermutation(n, random);
			for (int i = 0; i < k; i++)
			{
				array[array2[i]] = true;
			}
			return array;
		}

		public static IEnumerable<T> SelectCombination<T>(this IEnumerable<T> data, int elementsToChoose, System.Random randomSource = null)
		{
			T[] array = (data as T[]) ?? data.ToArray();
			if (elementsToChoose < 0)
			{
				throw new ArgumentOutOfRangeException("elementsToChoose", "Value must not be negative (zero is ok).");
			}
			if (elementsToChoose > array.Length)
			{
				throw new ArgumentOutOfRangeException("elementsToChoose", "elementsToChoose must be smaller than or equal to data.Count.");
			}
			bool[] mask = GenerateCombination(array.Length, elementsToChoose, randomSource);
			for (int i = 0; i < mask.Length; i++)
			{
				if (mask[i])
				{
					yield return array[i];
				}
			}
		}

		public static int[] GenerateCombinationWithRepetition(int n, int k, System.Random randomSource = null)
		{
			if (n < 0)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			if (k < 0)
			{
				throw new ArgumentOutOfRangeException("k", "Value must not be negative (zero is ok).");
			}
			System.Random random = randomSource ?? SystemRandomSource.Default;
			int[] array = new int[n];
			for (int i = 0; i < k; i++)
			{
				array[random.Next(n)]++;
			}
			return array;
		}

		public static IEnumerable<T> SelectCombinationWithRepetition<T>(this IEnumerable<T> data, int elementsToChoose, System.Random randomSource = null)
		{
			if (elementsToChoose < 0)
			{
				throw new ArgumentOutOfRangeException("elementsToChoose", "Value must not be negative (zero is ok).");
			}
			T[] array = (data as T[]) ?? data.ToArray();
			int[] mask = GenerateCombinationWithRepetition(array.Length, elementsToChoose, randomSource);
			for (int i = 0; i < mask.Length; i++)
			{
				for (int j = 0; j < mask[i]; j++)
				{
					yield return array[i];
				}
			}
		}

		public static int[] GenerateVariation(int n, int k, System.Random randomSource = null)
		{
			if (n < 0)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			if (k < 0)
			{
				throw new ArgumentOutOfRangeException("k", "Value must not be negative (zero is ok).");
			}
			if (k > n)
			{
				throw new ArgumentOutOfRangeException("k", "k must be smaller than or equal to n.");
			}
			System.Random random = randomSource ?? SystemRandomSource.Default;
			int[] array = new int[n];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = i;
			}
			int[] array2 = new int[k];
			int num = 0;
			int num2 = array.Length - 1;
			while (num < array2.Length)
			{
				int num3 = random.Next(num2 + 1);
				array2[num] = array[num3];
				array[num3] = array[num2];
				num++;
				num2--;
			}
			return array2;
		}

		public static BigInteger[] GenerateVariation(BigInteger n, int k, System.Random randomSource = null)
		{
			if (n < 0L)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			if (k < 0)
			{
				throw new ArgumentOutOfRangeException("k", "Value must not be negative (zero is ok).");
			}
			if (k > n)
			{
				throw new ArgumentOutOfRangeException("k", "k must be smaller than or equal to n.");
			}
			System.Random rnd = randomSource ?? SystemRandomSource.Default;
			BigInteger[] array = new BigInteger[k];
			if (n == 0L || k == 0)
			{
				return array;
			}
			array[0] = rnd.NextBigIntegerSequence(BigInteger.Zero, n).First();
			for (int i = 1; i < k; i++)
			{
				BigInteger bigInteger = rnd.NextBigIntegerSequence(BigInteger.Zero, n - i).First();
				bool[] array2 = Generate.Repeat(i, value: true);
				bool flag;
				do
				{
					flag = false;
					for (int j = 0; j < i; j++)
					{
						if (array2[j] && bigInteger >= array[j])
						{
							array2[j] = false;
							flag = true;
							++bigInteger;
						}
					}
				}
				while (flag);
				array[i] = bigInteger;
			}
			return array;
		}

		public static IEnumerable<T> SelectVariation<T>(this IEnumerable<T> data, int elementsToChoose, System.Random randomSource = null)
		{
			System.Random random = randomSource ?? SystemRandomSource.Default;
			T[] array = data.ToArray();
			if (elementsToChoose < 0)
			{
				throw new ArgumentOutOfRangeException("elementsToChoose", "Value must not be negative (zero is ok).");
			}
			if (elementsToChoose > array.Length)
			{
				throw new ArgumentOutOfRangeException("elementsToChoose", "elementsToChoose must be smaller than or equal to data.Count.");
			}
			for (int i = array.Length - 1; i >= array.Length - elementsToChoose; i--)
			{
				int swapIndex = random.Next(i + 1);
				yield return array[swapIndex];
				array[swapIndex] = array[i];
			}
		}

		public static int[] GenerateVariationWithRepetition(int n, int k, System.Random randomSource = null)
		{
			if (n < 0)
			{
				throw new ArgumentOutOfRangeException("n", "Value must not be negative (zero is ok).");
			}
			if (k < 0)
			{
				throw new ArgumentOutOfRangeException("k", "Value must not be negative (zero is ok).");
			}
			System.Random rnd = randomSource ?? SystemRandomSource.Default;
			int[] array = new int[k];
			rnd.NextInt32s(array, 0, n);
			return array;
		}

		public static IEnumerable<T> SelectVariationWithRepetition<T>(this IEnumerable<T> data, int elementsToChoose, System.Random randomSource = null)
		{
			if (elementsToChoose < 0)
			{
				throw new ArgumentOutOfRangeException("elementsToChoose", "Value must not be negative (zero is ok).");
			}
			T[] array = (data as T[]) ?? data.ToArray();
			int[] indices = GenerateVariationWithRepetition(array.Length, elementsToChoose, randomSource);
			for (int i = 0; i < indices.Length; i++)
			{
				yield return array[indices[i]];
			}
		}
	}
	[Serializable]
	[DataContract(Namespace = "urn:MathNet/Numerics")]
	public readonly struct Complex32 : IFormattable, IEquatable<Complex32>
	{
		[DataMember(Order = 1)]
		private readonly float _real;

		[DataMember(Order = 2)]
		private readonly float _imag;

		public static readonly Complex32 Zero = new Complex32(0f, 0f);

		public static readonly Complex32 One = new Complex32(1f, 0f);

		public static readonly Complex32 ImaginaryOne = new Complex32(0f, 1f);

		public static readonly Complex32 PositiveInfinity = new Complex32(float.PositiveInfinity, float.PositiveInfinity);

		public static readonly Complex32 NaN = new Complex32(float.NaN, float.NaN);

		public float Real
		{
			[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
			get
			{
				return _real;
			}
		}

		public float Imaginary
		{
			[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
			get
			{
				return _imag;
			}
		}

		public float Phase
		{
			[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
			get
			{
				if (_imag != 0f || !(_real < 0f))
				{
					return (float)Math.Atan2(_imag, _real);
				}
				return (float)Math.PI;
			}
		}

		public float Magnitude
		{
			[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
			get
			{
				if (float.IsNaN(_real) || float.IsNaN(_imag))
				{
					return float.NaN;
				}
				if (float.IsInfinity(_real) || float.IsInfinity(_imag))
				{
					return float.PositiveInfinity;
				}
				float num = Math.Abs(_real);
				float num2 = Math.Abs(_imag);
				if (num > num2)
				{
					double num3 = num2 / num;
					return num * (float)Math.Sqrt(1.0 + num3 * num3);
				}
				if (num == 0f)
				{
					return num2;
				}
				double num4 = num / num2;
				return num2 * (float)Math.Sqrt(1.0 + num4 * num4);
			}
		}

		public float MagnitudeSquared => _real * _real + _imag * _imag;

		public Complex32 Sign
		{
			get
			{
				if (float.IsPositiveInfinity(_real) && float.IsPositiveInfinity(_imag))
				{
					return new Complex32(0.70710677f, 0.70710677f);
				}
				if (float.IsPositiveInfinity(_real) && float.IsNegativeInfinity(_imag))
				{
					return new Complex32(0.70710677f, -0.70710677f);
				}
				if (float.IsNegativeInfinity(_real) && float.IsPositiveInfinity(_imag))
				{
					return new Complex32(-0.70710677f, -0.70710677f);
				}
				if (float.IsNegativeInfinity(_real) && float.IsNegativeInfinity(_imag))
				{
					return new Complex32(-0.70710677f, 0.70710677f);
				}
				float num = SpecialFunctions.Hypotenuse(_real, _imag);
				if (num == 0f)
				{
					return Zero;
				}
				return new Complex32(_real / num, _imag / num);
			}
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public Complex32(float real, float imaginary)
		{
			_real = real;
			_imag = imaginary;
		}

		public static Complex32 FromPolarCoordinates(float magnitude, float phase)
		{
			return new Complex32(magnitude * (float)Math.Cos(phase), magnitude * (float)Math.Sin(phase));
		}

		public bool IsZero()
		{
			if (_real == 0f)
			{
				return _imag == 0f;
			}
			return false;
		}

		public bool IsOne()
		{
			if (_real == 1f)
			{
				return _imag == 0f;
			}
			return false;
		}

		public bool IsImaginaryOne()
		{
			if (_real == 0f)
			{
				return _imag == 1f;
			}
			return false;
		}

		public bool IsNaN()
		{
			if (!float.IsNaN(_real))
			{
				return float.IsNaN(_imag);
			}
			return true;
		}

		public bool IsInfinity()
		{
			if (!float.IsInfinity(_real))
			{
				return float.IsInfinity(_imag);
			}
			return true;
		}

		public bool IsReal()
		{
			return _imag == 0f;
		}

		public bool IsRealNonNegative()
		{
			if (_imag == 0f)
			{
				return _real >= 0f;
			}
			return false;
		}

		public Complex32 Exponential()
		{
			float num = (float)Math.Exp(_real);
			if (IsReal())
			{
				return new Complex32(num, 0f);
			}
			return new Complex32(num * (float)Math.Cos(_imag), num * (float)Math.Sin(_imag));
		}

		public Complex32 NaturalLogarithm()
		{
			if (IsRealNonNegative())
			{
				return new Complex32((float)Math.Log(_real), 0f);
			}
			return new Complex32(0.5f * (float)Math.Log(MagnitudeSquared), Phase);
		}

		public Complex32 CommonLogarithm()
		{
			return NaturalLogarithm() / 2.3025851f;
		}

		public Complex32 Logarithm(float baseValue)
		{
			return NaturalLogarithm() / (float)Math.Log(baseValue);
		}

		public Complex32 Power(Complex32 exponent)
		{
			if (IsZero())
			{
				if (exponent.IsZero())
				{
					return One;
				}
				if (exponent.Real > 0f)
				{
					return Zero;
				}
				if (exponent.Real < 0f)
				{
					if (exponent.Imaginary != 0f)
					{
						return new Complex32(float.PositiveInfinity, float.PositiveInfinity);
					}
					return new Complex32(float.PositiveInfinity, 0f);
				}
				return NaN;
			}
			return (exponent * NaturalLogarithm()).Exponential();
		}

		public Complex32 Root(Complex32 rootExponent)
		{
			return Power(1f / rootExponent);
		}

		public Complex32 Square()
		{
			if (IsReal())
			{
				return new Complex32(_real * _real, 0f);
			}
			return new Complex32(_real * _real - _imag * _imag, 2f * _real * _imag);
		}

		public Complex32 SquareRoot()
		{
			if (IsRealNonNegative())
			{
				return new Complex32((float)Math.Sqrt(_real), 0f);
			}
			float num = Math.Abs(Real);
			float num2 = Math.Abs(Imaginary);
			double num4;
			if (num >= num2)
			{
				float num3 = Imaginary / Real;
				num4 = Math.Sqrt(num) * Math.Sqrt(0.5 * (1.0 + Math.Sqrt(1f + num3 * num3)));
			}
			else
			{
				float num5 = Real / Imaginary;
				num4 = Math.Sqrt(num2) * Math.Sqrt(0.5 * ((double)Math.Abs(num5) + Math.Sqrt(1f + num5 * num5)));
			}
			return (Real >= 0f) ? new Complex32((float)num4, (float)((double)Imaginary / (2.0 * num4))) : ((!(Imaginary >= 0f)) ? new Complex32((float)((double)num2 / (2.0 * num4)), (float)(0.0 - num4)) : new Complex32((float)((double)num2 / (2.0 * num4)), (float)num4));
		}

		public (Complex32, Complex32) SquareRoots()
		{
			Complex32 complex = SquareRoot();
			return (complex, -complex);
		}

		public (Complex32, Complex32, Complex32) CubicRoots()
		{
			float magnitude = (float)Math.Pow(Magnitude, 1.0 / 3.0);
			float num = Phase / 3f;
			return (FromPolarCoordinates(magnitude, num), FromPolarCoordinates(magnitude, num + (float)Math.PI * 2f / 3f), FromPolarCoordinates(magnitude, num - (float)Math.PI * 2f / 3f));
		}

		public static bool operator ==(Complex32 complex1, Complex32 complex2)
		{
			return complex1.Equals(complex2);
		}

		public static bool operator !=(Complex32 complex1, Complex32 complex2)
		{
			return !complex1.Equals(complex2);
		}

		public static Complex32 operator +(Complex32 summand)
		{
			return summand;
		}

		public static Complex32 operator -(Complex32 subtrahend)
		{
			return new Complex32(0f - subtrahend._real, 0f - subtrahend._imag);
		}

		public static Complex32 operator +(Complex32 summand1, Complex32 summand2)
		{
			return new Complex32(summand1._real + summand2._real, summand1._imag + summand2._imag);
		}

		public static Complex32 operator -(Complex32 minuend, Complex32 subtrahend)
		{
			return new Complex32(minuend._real - subtrahend._real, minuend._imag - subtrahend._imag);
		}

		public static Complex32 operator +(Complex32 summand1, float summand2)
		{
			return new Complex32(summand1._real + summand2, summand1._imag);
		}

		public static Complex32 operator -(Complex32 minuend, float subtrahend)
		{
			return new Complex32(minuend._real - subtrahend, minuend._imag);
		}

		public static Complex32 operator +(float summand1, Complex32 summand2)
		{
			return new Complex32(summand2._real + summand1, summand2._imag);
		}

		public static Complex32 operator -(float minuend, Complex32 subtrahend)
		{
			return new Complex32(minuend - subtrahend._real, 0f - subtrahend._imag);
		}

		public static Complex32 operator *(Complex32 multiplicand, Complex32 multiplier)
		{
			return new Complex32(multiplicand._real * multiplier._real - multiplicand._imag * multiplier._imag, multiplicand._real * multiplier._imag + multiplicand._imag * multiplier._real);
		}

		public static Complex32 operator *(float multiplicand, Complex32 multiplier)
		{
			return new Complex32(multiplier._real * multiplicand, multiplier._imag * multiplicand);
		}

		public static Complex32 operator *(Complex32 multiplicand, float multiplier)
		{
			return new Complex32(multiplicand._real * multiplier, multiplicand._imag * multiplier);
		}

		public static Complex32 operator /(Complex32 dividend, Complex32 divisor)
		{
			if (dividend.IsZero() && divisor.IsZero())
			{
				return NaN;
			}
			if (divisor.IsZero())
			{
				return PositiveInfinity;
			}
			float real = dividend.Real;
			float imaginary = dividend.Imaginary;
			float real2 = divisor.Real;
			float imaginary2 = divisor.Imaginary;
			if (Math.Abs(imaginary2) <= Math.Abs(real2))
			{
				return InternalDiv(real, imaginary, real2, imaginary2, swapped: false);
			}
			return InternalDiv(imaginary, real, imaginary2, real2, swapped: true);
		}

		private static Complex32 InternalDiv(float a, float b, float c, float d, bool swapped)
		{
			float num = d / c;
			float num2 = 1f / (c + d * num);
			float real;
			float num3;
			if (num != 0f)
			{
				real = (a + b * num) * num2;
				num3 = (b - a * num) * num2;
			}
			else
			{
				real = (a + d * (b / c)) * num2;
				num3 = (b - d * (a / c)) * num2;
			}
			if (swapped)
			{
				num3 = 0f - num3;
			}
			return new Complex32(real, num3);
		}

		public static Complex32 operator /(float dividend, Complex32 divisor)
		{
			if (dividend == 0f && divisor.IsZero())
			{
				return NaN;
			}
			if (divisor.IsZero())
			{
				return PositiveInfinity;
			}
			float real = divisor.Real;
			float imaginary = divisor.Imaginary;
			if (Math.Abs(imaginary) <= Math.Abs(real))
			{
				return InternalDiv(dividend, 0f, real, imaginary, swapped: false);
			}
			return InternalDiv(0f, dividend, imaginary, real, swapped: true);
		}

		public static Complex32 operator /(Complex32 dividend, float divisor)
		{
			if (dividend.IsZero() && divisor == 0f)
			{
				return NaN;
			}
			if (divisor == 0f)
			{
				return PositiveInfinity;
			}
			return new Complex32(dividend._real / divisor, dividend._imag / divisor);
		}

		public Complex32 Conjugate()
		{
			return new Complex32(_real, 0f - _imag);
		}

		public Complex32 Reciprocal()
		{
			if (IsZero())
			{
				return Zero;
			}
			return 1f / this;
		}

		public override string ToString()
		{
			return string.Format(CultureInfo.CurrentCulture, "({0}, {1})", _real, _imag);
		}

		public string ToString(string format)
		{
			CultureInfo currentCulture = CultureInfo.CurrentCulture;
			float real = _real;
			string arg = real.ToString(format, CultureInfo.CurrentCulture);
			real = _imag;
			return string.Format(currentCulture, "({0}, {1})", arg, real.ToString(format, CultureInfo.CurrentCulture));
		}

		public string ToString(IFormatProvider provider)
		{
			return string.Format(provider, "({0}, {1})", _real, _imag);
		}

		public string ToString(string format, IFormatProvider provider)
		{
			float real = _real;
			string arg = real.ToString(format, provider);
			real = _imag;
			return string.Format(provider, "({0}, {1})", arg, real.ToString(format, provider));
		}

		public bool Equals(Complex32 other)
		{
			if (IsNaN() || other.IsNaN())
			{
				return false;
			}
			if (IsInfinity() && other.IsInfinity())
			{
				return true;
			}
			if (_real.AlmostEqual(other._real))
			{
				return _imag.AlmostEqual(other._imag);
			}
			return false;
		}

		public override int GetHashCode()
		{
			int num = 27;
			int num2 = 13 * num;
			float real = _real;
			num = num2 + real.GetHashCode();
			int num3 = 13 * num;
			real = _imag;
			return num3 + real.GetHashCode();
		}

		public override bool Equals(object obj)
		{
			if (obj is Complex32 other)
			{
				return Equals(other);
			}
			return false;
		}

		public static Complex32 Parse(string value, IFormatProvider formatProvider = null)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			value = value.Trim();
			if (value.Length == 0)
			{
				throw new FormatException();
			}
			if (value.StartsWith("(", StringComparison.Ordinal))
			{
				if (!value.EndsWith(")", StringComparison.Ordinal))
				{
					throw new FormatException();
				}
				value = value.Substring(1, value.Length - 2).Trim();
			}
			NumberFormatInfo numberFormatInfo = formatProvider.GetNumberFormatInfo();
			TextInfo textInfo = formatProvider.GetTextInfo();
			string[] keywords = new string[8] { textInfo.ListSeparator, numberFormatInfo.NaNSymbol, numberFormatInfo.NegativeInfinitySymbol, numberFormatInfo.PositiveInfinitySymbol, "+", "-", "i", "j" };
			LinkedList<string> linkedList = new LinkedList<string>();
			GlobalizationHelper.Tokenize(linkedList.AddFirst(value), keywords, 0);
			LinkedListNode<string> token = linkedList.First;
			bool imaginary;
			float num = ParsePart(ref token, out imaginary, formatProvider);
			if (token == null)
			{
				if (!imaginary)
				{
					return new Complex32(num, 0f);
				}
				return new Complex32(0f, num);
			}
			if (token.Value == textInfo.ListSeparator)
			{
				token = token.Next;
				if (imaginary)
				{
					throw new FormatException();
				}
				bool imaginary2;
				float imaginary3 = ParsePart(ref token, out imaginary2, formatProvider);
				return new Complex32(num, imaginary3);
			}
			bool imaginary4;
			float num2 = ParsePart(ref token, out imaginary4, formatProvider);
			if (!(imaginary ^ imaginary4))
			{
				throw new FormatException();
			}
			if (!imaginary)
			{
				return new Complex32(num, num2);
			}
			return new Complex32(num2, num);
		}

		private static float ParsePart(ref LinkedListNode<string> token, out bool imaginary, IFormatProvider format)
		{
			imaginary = false;
			if (token == null)
			{
				throw new FormatException();
			}
			if (token.Value == "+")
			{
				token = token.Next;
				if (token == null)
				{
					throw new FormatException();
				}
			}
			bool flag = false;
			if (token.Value == "-")
			{
				flag = true;
				token = token.Next;
				if (token == null)
				{
					throw new FormatException();
				}
			}
			if (string.Compare(token.Value, "i", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(token.Value, "j", StringComparison.OrdinalIgnoreCase) == 0)
			{
				imaginary = true;
				token = token.Next;
				if (token == null)
				{
					return (!flag) ? 1 : (-1);
				}
			}
			float num = GlobalizationHelper.ParseSingle(ref token, format.GetCultureInfo());
			if (token != null && (string.Compare(token.Value, "i", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(token.Value, "j", StringComparison.OrdinalIgnoreCase) == 0))
			{
				if (imaginary)
				{
					throw new FormatException();
				}
				imaginary = true;
				token = token.Next;
			}
			if (!flag)
			{
				return num;
			}
			return 0f - num;
		}

		public static bool TryParse(string value, out Complex32 result)
		{
			return TryParse(value, null, out result);
		}

		public static bool TryParse(string value, IFormatProvider formatProvider, out Complex32 result)
		{
			try
			{
				result = Parse(value, formatProvider);
				return true;
			}
			catch (ArgumentNullException)
			{
				result = Zero;
				return false;
			}
			catch (FormatException)
			{
				result = Zero;
				return false;
			}
		}

		public static explicit operator Complex32(decimal value)
		{
			return new Complex32((float)value, 0f);
		}

		public static explicit operator Complex32(Complex value)
		{
			return new Complex32((float)value.Real, (float)value.Imaginary);
		}

		public static implicit operator Complex32(byte value)
		{
			return new Complex32((int)value, 0f);
		}

		public static implicit operator Complex32(short value)
		{
			return new Complex32(value, 0f);
		}

		[CLSCompliant(false)]
		public static implicit operator Complex32(sbyte value)
		{
			return new Complex32(value, 0f);
		}

		[CLSCompliant(false)]
		public static implicit operator Complex32(ushort value)
		{
			return new Complex32((int)value, 0f);
		}

		public static implicit operator Complex32(int value)
		{
			return new Complex32(value, 0f);
		}

		public static implicit operator Complex32(BigInteger value)
		{
			return new Complex32((long)value, 0f);
		}

		public static implicit operator Complex32(long value)
		{
			return new Complex32(value, 0f);
		}

		[CLSCompliant(false)]
		public static implicit operator Complex32(uint value)
		{
			return new Complex32(value, 0f);
		}

		[CLSCompliant(false)]
		public static implicit operator Complex32(ulong value)
		{
			return new Complex32(value, 0f);
		}

		public static implicit operator Complex32(float value)
		{
			return new Complex32(value, 0f);
		}

		public static explicit operator Complex32(double value)
		{
			return new Complex32((float)value, 0f);
		}

		public Complex ToComplex()
		{
			return new Complex(_real, _imag);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Negate(Complex32 value)
		{
			return -value;
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Conjugate(Complex32 value)
		{
			return value.Conjugate();
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Add(Complex32 left, Complex32 right)
		{
			return left + right;
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Subtract(Complex32 left, Complex32 right)
		{
			return left - right;
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Multiply(Complex32 left, Complex32 right)
		{
			return left * right;
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Divide(Complex32 dividend, Complex32 divisor)
		{
			return dividend / divisor;
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Reciprocal(Complex32 value)
		{
			return value.Reciprocal();
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Sqrt(Complex32 value)
		{
			return value.SquareRoot();
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double Abs(Complex32 value)
		{
			return value.Magnitude;
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Exp(Complex32 value)
		{
			return value.Exponential();
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Pow(Complex32 value, Complex32 power)
		{
			return value.Power(power);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Pow(Complex32 value, float power)
		{
			return value.Power(power);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Log(Complex32 value)
		{
			return value.NaturalLogarithm();
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Log(Complex32 value, float baseValue)
		{
			return value.Logarithm(baseValue);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex32 Log10(Complex32 value)
		{
			return value.CommonLogarithm();
		}

		public static Complex32 Sin(Complex32 value)
		{
			return (Complex32)value.ToComplex().Sin();
		}

		public static Complex32 Cos(Complex32 value)
		{
			return (Complex32)value.ToComplex().Cos();
		}

		public static Complex32 Tan(Complex32 value)
		{
			return (Complex32)value.ToComplex().Tan();
		}

		public static Complex32 Asin(Complex32 value)
		{
			return (Complex32)value.ToComplex().Asin();
		}

		public static Complex32 Acos(Complex32 value)
		{
			return (Complex32)value.ToComplex().Acos();
		}

		public static Complex32 Atan(Complex32 value)
		{
			return (Complex32)value.ToComplex().Atan();
		}

		public static Complex32 Sinh(Complex32 value)
		{
			return (Complex32)value.ToComplex().Sinh();
		}

		public static Complex32 Cosh(Complex32 value)
		{
			return (Complex32)value.ToComplex().Cosh();
		}

		public static Complex32 Tanh(Complex32 value)
		{
			return (Complex32)value.ToComplex().Tanh();
		}
	}
	public static class ComplexExtensions
	{
		public static double MagnitudeSquared(this Complex32 complex)
		{
			return complex.Real * complex.Real + complex.Imaginary * complex.Imaginary;
		}

		public static double MagnitudeSquared(this Complex complex)
		{
			return complex.Real * complex.Real + complex.Imaginary * complex.Imaginary;
		}

		public static Complex Sign(this Complex complex)
		{
			if (double.IsPositiveInfinity(complex.Real) && double.IsPositiveInfinity(complex.Imaginary))
			{
				return new Complex(0.7071067811865476, 0.7071067811865476);
			}
			if (double.IsPositiveInfinity(complex.Real) && double.IsNegativeInfinity(complex.Imaginary))
			{
				return new Complex(0.7071067811865476, -0.7071067811865476);
			}
			if (double.IsNegativeInfinity(complex.Real) && double.IsPositiveInfinity(complex.Imaginary))
			{
				return new Complex(-0.7071067811865476, -0.7071067811865476);
			}
			if (double.IsNegativeInfinity(complex.Real) && double.IsNegativeInfinity(complex.Imaginary))
			{
				return new Complex(-0.7071067811865476, 0.7071067811865476);
			}
			double num = SpecialFunctions.Hypotenuse(complex.Real, complex.Imaginary);
			if (num == 0.0)
			{
				return Complex.Zero;
			}
			return new Complex(complex.Real / num, complex.Imaginary / num);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex Conjugate(this Complex complex)
		{
			return Complex.Conjugate(complex);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex Reciprocal(this Complex complex)
		{
			return Complex.Reciprocal(complex);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex Exp(this Complex complex)
		{
			return Complex.Exp(complex);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex Ln(this Complex complex)
		{
			return Complex.Log(complex);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex Log10(this Complex complex)
		{
			return Complex.Log10(complex);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static Complex Log(this Complex complex, double baseValue)
		{
			return Complex.Log(complex, baseValue);
		}

		public static Complex Power(this Complex complex, Complex exponent)
		{
			if (complex.IsZero())
			{
				if (exponent.IsZero())
				{
					return Complex.One;
				}
				if (exponent.Real > 0.0)
				{
					return Complex.Zero;
				}
				if (exponent.Real < 0.0)
				{
					if (exponent.Imaginary != 0.0)
					{
						return new Complex(double.PositiveInfinity, double.PositiveInfinity);
					}
					return new Complex(double.PositiveInfinity, 0.0);
				}
				return new Complex(double.NaN, double.NaN);
			}
			return Complex.Pow(complex, exponent);
		}

		public static Complex Root(this Complex complex, Complex rootExponent)
		{
			return Complex.Pow(complex, (Complex)1 / rootExponent);
		}

		public static Complex Square(this Complex complex)
		{
			if (complex.IsReal())
			{
				return new Complex(complex.Real * complex.Real, 0.0);
			}
			return new Complex(complex.Real * complex.Real - complex.Imaginary * complex.Imaginary, 2.0 * complex.Real * complex.Imaginary);
		}

		public static Complex SquareRoot(this Complex complex)
		{
			if (complex.IsRealNonNegative())
			{
				return new Complex(Math.Sqrt(complex.Real), 0.0);
			}
			double num = Math.Abs(complex.Real);
			double num2 = Math.Abs(complex.Imaginary);
			double num4;
			if (num >= num2)
			{
				double num3 = complex.Imaginary / complex.Real;
				num4 = Math.Sqrt(num) * Math.Sqrt(0.5 * (1.0 + Math.Sqrt(1.0 + num3 * num3)));
			}
			else
			{
				double num5 = complex.Real / complex.Imaginary;
				num4 = Math.Sqrt(num2) * Math.Sqrt(0.5 * (Math.Abs(num5) + Math.Sqrt(1.0 + num5 * num5)));
			}
			return (complex.Real >= 0.0) ? new Complex(num4, complex.Imaginary / (2.0 * num4)) : ((!(complex.Imaginary >= 0.0)) ? new Complex(num2 / (2.0 * num4), 0.0 - num4) : new Complex(num2 / (2.0 * num4), num4));
		}

		public static (Complex, Complex) SquareRoots(this Complex complex)
		{
			Complex complex2 = complex.SquareRoot();
			return (complex2, -complex2);
		}

		public static (Complex, Complex, Complex) CubicRoots(this Complex complex)
		{
			double magnitude = Math.Pow(complex.Magnitude, 1.0 / 3.0);
			double num = complex.Phase / 3.0;
			return (Complex.FromPolarCoordinates(magnitude, num), Complex.FromPolarCoordinates(magnitude, num + Math.PI * 2.0 / 3.0), Complex.FromPolarCoordinates(magnitude, num - Math.PI * 2.0 / 3.0));
		}

		public static bool IsZero(this Complex complex)
		{
			if (complex.Real == 0.0)
			{
				return complex.Imaginary == 0.0;
			}
			return false;
		}

		public static bool IsOne(this Complex complex)
		{
			if (complex.Real == 1.0)
			{
				return complex.Imaginary == 0.0;
			}
			return false;
		}

		public static bool IsImaginaryOne(this Complex complex)
		{
			if (complex.Real == 0.0)
			{
				return complex.Imaginary == 1.0;
			}
			return false;
		}

		public static bool IsNaN(this Complex complex)
		{
			if (!double.IsNaN(complex.Real))
			{
				return double.IsNaN(complex.Imaginary);
			}
			return true;
		}

		public static bool IsInfinity(this Complex complex)
		{
			if (!double.IsInfinity(complex.Real))
			{
				return double.IsInfinity(complex.Imaginary);
			}
			return true;
		}

		public static bool IsReal(this Complex complex)
		{
			return complex.Imaginary == 0.0;
		}

		public static bool IsRealNonNegative(this Complex complex)
		{
			if (complex.Imaginary == 0.0)
			{
				return complex.Real >= 0.0;
			}
			return false;
		}

		public static double Norm(this Complex complex)
		{
			return complex.MagnitudeSquared();
		}

		public static double Norm(this Complex32 complex)
		{
			return complex.MagnitudeSquared;
		}

		public static double NormOfDifference(this Complex complex, Complex otherValue)
		{
			return (complex - otherValue).MagnitudeSquared();
		}

		public static double NormOfDifference(this Complex32 complex, Complex32 otherValue)
		{
			return (complex - otherValue).MagnitudeSquared;
		}

		public static Complex ToComplex(this string value)
		{
			return value.ToComplex(null);
		}

		public static Complex ToComplex(this string value, IFormatProvider formatProvider)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			value = value.Trim();
			if (value.Length == 0)
			{
				throw new FormatException();
			}
			if (value.StartsWith("(", StringComparison.Ordinal))
			{
				if (!value.EndsWith(")", StringComparison.Ordinal))
				{
					throw new FormatException();
				}
				value = value.Substring(1, value.Length - 2).Trim();
			}
			NumberFormatInfo numberFormatInfo = formatProvider.GetNumberFormatInfo();
			TextInfo textInfo = formatProvider.GetTextInfo();
			string[] keywords = new string[8] { textInfo.ListSeparator, numberFormatInfo.NaNSymbol, numberFormatInfo.NegativeInfinitySymbol, numberFormatInfo.PositiveInfinitySymbol, "+", "-", "i", "j" };
			LinkedList<string> linkedList = new LinkedList<string>();
			GlobalizationHelper.Tokenize(linkedList.AddFirst(value), keywords, 0);
			LinkedListNode<string> token = linkedList.First;
			bool imaginary;
			double num = ParsePart(ref token, out imaginary, formatProvider);
			if (token == null)
			{
				if (!imaginary)
				{
					return new Complex(num, 0.0);
				}
				return new Complex(0.0, num);
			}
			if (token.Value == textInfo.ListSeparator)
			{
				token = token.Next;
				if (imaginary)
				{
					throw new FormatException();
				}
				bool imaginary2;
				double imaginary3 = ParsePart(ref token, out imaginary2, formatProvider);
				return new Complex(num, imaginary3);
			}
			bool imaginary4;
			double num2 = ParsePart(ref token, out imaginary4, formatProvider);
			if (!(imaginary ^ imaginary4))
			{
				throw new FormatException();
			}
			if (!imaginary)
			{
				return new Complex(num, num2);
			}
			return new Complex(num2, num);
		}

		private static double ParsePart(ref LinkedListNode<string> token, out bool imaginary, IFormatProvider format)
		{
			imaginary = false;
			if (token == null)
			{
				throw new FormatException();
			}
			if (token.Value == "+")
			{
				token = token.Next;
				if (token == null)
				{
					throw new FormatException();
				}
			}
			bool flag = false;
			if (token.Value == "-")
			{
				flag = true;
				token = token.Next;
				if (token == null)
				{
					throw new FormatException();
				}
			}
			if (string.Compare(token.Value, "i", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(token.Value, "j", StringComparison.OrdinalIgnoreCase) == 0)
			{
				imaginary = true;
				token = token.Next;
				if (token == null)
				{
					return (!flag) ? 1 : (-1);
				}
			}
			double num = GlobalizationHelper.ParseDouble(ref token, format.GetCultureInfo());
			if (token != null && (string.Compare(token.Value, "i", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(token.Value, "j", StringComparison.OrdinalIgnoreCase) == 0))
			{
				if (imaginary)
				{
					throw new FormatException();
				}
				imaginary = true;
				token = token.Next;
			}
			if (!flag)
			{
				return num;
			}
			return 0.0 - num;
		}

		public static bool TryToComplex(this string value, out Complex result)
		{
			return value.TryToComplex(null, out result);
		}

		public static bool TryToComplex(this string value, IFormatProvider formatProvider, out Complex result)
		{
			try
			{
				result = value.ToComplex(formatProvider);
				return true;
			}
			catch (ArgumentNullException)
			{
				result = Complex.Zero;
				return false;
			}
			catch (FormatException)
			{
				result = Complex.Zero;
				return false;
			}
		}

		public static Complex32 ToComplex32(this string value)
		{
			return Complex32.Parse(value);
		}

		public static Complex32 ToComplex32(this string value, IFormatProvider formatProvider)
		{
			return Complex32.Parse(value, formatProvider);
		}

		public static bool TryToComplex32(this string value, out Complex32 result)
		{
			return Complex32.TryParse(value, out result);
		}

		public static bool TryToComplex32(this string value, IFormatProvider formatProvider, out Complex32 result)
		{
			return Complex32.TryParse(value, formatProvider, out result);
		}
	}
	public static class Constants
	{
		public const double E = Math.E;

		public const double Log2E = 1.4426950408889634;

		public const double Log10E = 0.4342944819032518;

		public const double Ln2 = 0.6931471805599453;

		public const double Ln10 = 2.302585092994046;

		public const double LnPi = 1.1447298858494002;

		public const double Ln2PiOver2 = 0.9189385332046728;

		public const double InvE = 1.0 / Math.E;

		public const double SqrtE = 1.6487212707001282;

		public const double Sqrt2 = 1.4142135623730951;

		public const double Sqrt3 = 1.7320508075688772;

		public const double Sqrt1Over2 = 0.7071067811865476;

		public const double HalfSqrt3 = 0.8660254037844386;

		public const double Pi = Math.PI;

		public const double Pi2 = Math.PI * 2.0;

		public const double PiOver2 = Math.PI / 2.0;

		public const double Pi3Over2 = 4.71238898038469;

		public const double PiOver4 = Math.PI / 4.0;

		public const double SqrtPi = 1.772453850905516;

		public const double Sqrt2Pi = 2.5066282746310007;

		public const double SqrtPiOver2 = 1.2533141373155003;

		public const double Sqrt2PiE = 4.132731354122493;

		public const double LogSqrt2Pi = 0.9189385332046728;

		public const double LogSqrt2PiE = 1.4189385332046727;

		public const double LogTwoSqrtEOverPi = 0.6207822376352452;

		public const double InvPi = 1.0 / Math.PI;

		public const double TwoInvPi = 2.0 / Math.PI;

		public const double InvSqrtPi = 0.5641895835477563;

		public const double InvSqrt2Pi = 0.3989422804014327;

		public const double TwoInvSqrtPi = 1.1283791670955126;

		public const double TwoSqrtEOverPi = 1.8603827342052657;

		public const double Degree = Math.PI / 180.0;

		public const double Grad = Math.PI / 200.0;

		public const double PowerDecibel = 0.11512925464970228;

		public const double NeutralDecibel = 0.23025850929940456;

		public const double Catalan = 0.915965594177219;

		public const double EulerMascheroni = 0.5772156649015329;

		public const double GoldenRatio = 1.618033988749895;

		public const double Glaisher = 1.2824271291006226;

		public const double Khinchin = 2.6854520010653062;

		public const int SizeOfDouble = 8;

		public const int SizeOfInt = 4;

		public const int SizeOfFloat = 4;

		public const int SizeOfComplex = 16;

		public const int SizeOfComplex32 = 8;

		public const double SpeedOfLight = 299792458.0;

		public const double MagneticPermeability = 1.2566370614359173E-06;

		public const double ElectricPermittivity = 8.854187817193708E-12;

		public const double CharacteristicImpedanceVacuum = 376.73031346177066;

		public const double GravitationalConstant = 6.67429E-11;

		public const double PlancksConstant = 6.62606896E-34;

		public const double DiracsConstant = 1.054571629E-34;

		public const double PlancksMass = 2.17644E-08;

		public const double PlancksTemperature = 1.416786E+32;

		public const double PlancksLength = 1.616253E-35;

		public const double PlancksTime = 5.39124E-44;

		public const double ElementaryCharge = 1.602176487E-19;

		public const double MagneticFluxQuantum = 2.067833668E-15;

		public const double ConductanceQuantum = 7.7480917005E-05;

		public const double JosephsonConstant = 483597891000000.0;

		public const double VonKlitzingConstant = 25812.807557;

		public const double BohrMagneton = 9.27400915E-24;

		public const double NuclearMagneton = 5.05078324E-27;

		public const double FineStructureConstant = 0.0072973525376;

		public const double RydbergConstant = 10973731.568528;

		public const double BohrRadius = 5.2917720859E-11;

		public const double HartreeEnergy = 4.35974394E-18;

		public const double QuantumOfCirculation = 0.00036369475199;

		public const double FermiCouplingConstant = 1.16637E-05;

		public const double WeakMixingAngle = 0.22256;

		public const double ElectronMass = 9.10938215E-31;

		public const double ElectronMassEnergyEquivalent = 8.18710438E-14;

		public const double ElectronMolarMass = 5.4857990943E-07;

		public const double ComptonWavelength = 2.4263102175E-12;

		public const double ClassicalElectronRadius = 2.8179402894E-15;

		public const double ThomsonCrossSection = 6.652458558E-29;

		public const double ElectronMagneticMoment = -9.28476377E-24;

		public const double ElectronGFactor = -2.0023193043622;

		public const double MuonMass = 1.8835313E-28;

		public const double MuonMassEnegryEquivalent = 1.692833511E-11;

		public const double MuonMolarMass = 0.0001134289256;

		public const double MuonComptonWavelength = 1.173444104E-14;

		public const double MuonMagneticMoment = -4.49044786E-26;

		public const double MuonGFactor = -2.0023318414;

		public const double TauMass = 3.16777E-27;

		public const double TauMassEnergyEquivalent = 2.84705E-10;

		public const double TauMolarMass = 0.00190768;

		public const double TauComptonWavelength = 6.9772E-16;

		public const double ProtonMass = 1.672621637E-27;

		public const double ProtonMassEnergyEquivalent = 1.503277359E-10;

		public const double ProtonMolarMass = 0.00100727646677;

		public const double ProtonComptonWavelength = 1.3214098446E-15;

		public const double ProtonMagneticMoment = 1.410606662E-26;

		public const double ProtonGFactor = 5.585694713;

		public const double ShieldedProtonMagneticMoment = 1.410570419E-26;

		public const double ProtonGyromagneticRatio = 267522209.9;

		public const double ShieldedProtonGyromagneticRatio = 267515336.2;

		public const double NeutronMass = 1.674927212E-27;

		public const double NeutronMassEnegryEquivalent = 1.505349506E-10;

		public const double NeutronMolarMass = 0.00100866491597;

		public const double NeutronComptonWavelength = 0.13195908951;

		public const double NeutronMagneticMoment = -9.6623641E-27;

		public const double NeutronGFactor = -3.82608545;

		public const double NeutronGyromagneticRatio = 183247185.0;

		public const double DeuteronMass = 3.3435832E-27;

		public const double DeuteronMassEnegryEquivalent = 3.00506272E-10;

		public const double DeuteronMolarMass = 0.002013553212725;

		public const double DeuteronMagneticMoment = 4.33073465E-27;

		public const double HelionMass = 5.00641192E-27;

		public const double HelionMassEnegryEquivalent = 4.49953864E-10;

		public const double HelionMolarMass = 0.0030149322473;

		public const double Avogadro = 6.0221412927E+23;

		public const double Yotta = 1E+24;

		public const double Zetta = 1E+21;

		public const double Exa = 1E+18;

		public const double Peta = 1000000000000000.0;

		public const double Tera = 1000000000000.0;

		public const double Giga = 1000000000.0;

		public const double Mega = 1000000.0;

		public const double Kilo = 1000.0;

		public const double Hecto = 100.0;

		public const double Deca = 10.0;

		public const double Deci = 0.1;

		public const double Centi = 0.01;

		public const double Milli = 0.001;

		public const double Micro = 1E-06;

		public const double Nano = 1E-09;

		public const double Pico = 1E-12;

		public const double Femto = 1E-15;

		public const double Atto = 1E-18;

		public const double Zepto = 1E-21;

		public const double Yocto = 1E-24;
	}
	public static class Control
	{
		private static int _maxDegreeOfParallelism;

		private static int _parallelizeOrder;

		private static int _parallelizeElements;

		private static string _nativeProviderHintPath;

		public static bool CheckDistributionParameters { get; set; }

		public static bool ThreadSafeRandomNumberGenerators { get; set; }

		public static string NativeProviderPath
		{
			get
			{
				return _nativeProviderHintPath;
			}
			set
			{
				_nativeProviderHintPath = value;
				LinearAlgebraControl.HintPath = value;
				FourierTransformControl.HintPath = value;
				SparseSolverControl.HintPath = value;
			}
		}

		public static int MaxDegreeOfParallelism
		{
			get
			{
				return _maxDegreeOfParallelism;
			}
			set
			{
				_maxDegreeOfParallelism = Math.Max(1, Math.Min(1024, value));
				LinearAlgebraControl.Provider.InitializeVerify();
				FourierTransformControl.Provider.InitializeVerify();
				SparseSolverControl.Provider.InitializeVerify();
			}
		}

		public static TaskScheduler TaskScheduler { get; set; }

		internal static int ParallelizeOrder
		{
			get
			{
				return _parallelizeOrder;
			}
			set
			{
				_parallelizeOrder = Math.Max(3, value);
			}
		}

		internal static int ParallelizeElements
		{
			get
			{
				return _parallelizeElements;
			}
			set
			{
				_parallelizeElements = Math.Max(3, value);
			}
		}

		static Control()
		{
			ConfigureAuto();
		}

		public static void ConfigureAuto()
		{
			CheckDistributionParameters = true;
			ThreadSafeRandomNumberGenerators = true;
			_maxDegreeOfParallelism = Environment.ProcessorCount;
			_parallelizeOrder = 64;
			_parallelizeElements = 300;
			TaskScheduler = TaskScheduler.Default;
		}

		public static void UseManaged()
		{
			LinearAlgebraControl.UseManaged();
			FourierTransformControl.UseManaged();
			SparseSolverControl.UseManaged();
		}

		public static void UseDefaultProviders()
		{
			if (AppSwitches.DisableNativeProviders)
			{
				UseManaged();
				return;
			}
			LinearAlgebraControl.UseDefault();
			FourierTransformControl.UseDefault();
			SparseSolverControl.UseDefault();
		}

		public static void UseBestProviders()
		{
			if (AppSwitches.DisableNativeProviders || AppSwitches.DisableNativeProviderProbing)
			{
				UseManaged();
				return;
			}
			LinearAlgebraControl.UseBest();
			FourierTransformControl.UseBest();
			SparseSolverControl.UseBest();
		}

		public static void UseNativeMKL()
		{
			LinearAlgebraControl.UseNativeMKL();
			FourierTransformControl.UseNativeMKL();
			SparseSolverControl.UseNativeMKL();
		}

		public static bool TryUseNativeMKL()
		{
			bool num = LinearAlgebraControl.TryUseNativeMKL();
			bool flag = FourierTransformControl.TryUseNativeMKL();
			bool flag2 = SparseSolverControl.TryUseNativeMKL();
			return num || flag || flag2;
		}

		public static void UseNativeCUDA()
		{
			LinearAlgebraControl.UseNativeCUDA();
		}

		public static bool TryUseNativeCUDA()
		{
			return LinearAlgebraControl.TryUseNativeCUDA();
		}

		public static void UseNativeOpenBLAS()
		{
			LinearAlgebraControl.UseNativeOpenBLAS();
		}

		public static bool TryUseNativeOpenBLAS()
		{
			return LinearAlgebraControl.TryUseNativeOpenBLAS();
		}

		public static bool TryUseNative()
		{
			if (AppSwitches.DisableNativeProviders || AppSwitches.DisableNativeProviderProbing)
			{
				return false;
			}
			bool num = LinearAlgebraControl.TryUseNative();
			bool flag = FourierTransformControl.TryUseNative();
			bool flag2 = SparseSolverControl.TryUseNative();
			return num || flag || flag2;
		}

		public static void FreeResources()
		{
			LinearAlgebraControl.FreeResources();
			FourierTransformControl.FreeResources();
			SparseSolverControl.FreeResources();
		}

		public static void UseSingleThread()
		{
			_maxDegreeOfParallelism = 1;
			ThreadSafeRandomNumberGenerators = false;
			LinearAlgebraControl.Provider.InitializeVerify();
			FourierTransformControl.Provider.InitializeVerify();
			SparseSolverControl.Provider.InitializeVerify();
		}

		public static void UseMultiThreading()
		{
			_maxDegreeOfParallelism = Environment.ProcessorCount;
			ThreadSafeRandomNumberGenerators = true;
			LinearAlgebraControl.Provider.InitializeVerify();
			FourierTransformControl.Provider.InitializeVerify();
			SparseSolverControl.Provider.InitializeVerify();
		}

		public static string Describe()
		{
			AssemblyInformationalVersionAttribute assemblyInformationalVersionAttribute = typeof(Control).GetTypeInfo().Assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Math.NET Numerics Configuration:");
			stringBuilder.AppendLine("Version " + assemblyInformationalVersionAttribute?.InformationalVersion);
			stringBuilder.AppendLine("Built for .NET Framework 4.6.1");
			stringBuilder.AppendLine($"Linear Algebra Provider: {LinearAlgebraControl.Provider}");
			stringBuilder.AppendLine($"Fourier Transform Provider: {FourierTransformControl.Provider}");
			stringBuilder.AppendLine($"Sparse Solver Provider: {SparseSolverControl.Provider}");
			stringBuilder.AppendLine($"Max Degree of Parallelism: {MaxDegreeOfParallelism}");
			stringBuilder.AppendLine($"Parallelize Elements: {ParallelizeElements}");
			stringBuilder.AppendLine($"Parallelize Order: {ParallelizeOrder}");
			stringBuilder.AppendLine($"Check Distribution Parameters: {CheckDistributionParameters}");
			stringBuilder.AppendLine($"Thread-Safe RNGs: {ThreadSafeRandomNumberGenerators}");
			stringBuilder.AppendLine($"Operating System: {Environment.OSVersion}");
			stringBuilder.AppendLine($"Framework: {Environment.Version}");
			string environmentVariable = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
			if (!string.IsNullOrEmpty(environmentVariable))
			{
				stringBuilder.AppendLine("Processor Architecture: " + environmentVariable);
			}
			string environmentVariable2 = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");
			if (!string.IsNullOrEmpty(environmentVariable2))
			{
				stringBuilder.AppendLine("Processor Identifier: " + environmentVariable2);
			}
			return stringBuilder.ToString();
		}
	}
	public static class Differentiate
	{
		public static NumericalDerivative Points(int points, int center)
		{
			return new NumericalDerivative(points, center);
		}

		public static NumericalDerivative Order(int order)
		{
			int num = order + (order.IsEven() ? 1 : 2);
			return new NumericalDerivative(num, num / 2);
		}

		public static double Derivative(Func<double, double> f, double x, int order)
		{
			return Order(order).EvaluateDerivative(f, x, order);
		}

		public static Func<double, double> DerivativeFunc(Func<double, double> f, int order)
		{
			return Order(order).CreateDerivativeFunctionHandle(f, order);
		}

		public static double FirstDerivative(Func<double, double> f, double x)
		{
			return Order(1).EvaluateDerivative(f, x, 1);
		}

		public static Func<double, double> FirstDerivativeFunc(Func<double, double> f)
		{
			return Order(1).CreateDerivativeFunctionHandle(f, 1);
		}

		public static double SecondDerivative(Func<double, double> f, double x)
		{
			return Order(2).EvaluateDerivative(f, x, 2);
		}

		public static Func<double, double> SecondDerivativeFunc(Func<double, double> f)
		{
			return Order(2).CreateDerivativeFunctionHandle(f, 2);
		}

		public static double PartialDerivative(Func<double[], double> f, double[] x, int parameterIndex, int order)
		{
			return Order(order).EvaluatePartialDerivative(f, x, parameterIndex, order);
		}

		public static Func<double[], double> PartialDerivativeFunc(Func<double[], double> f, int parameterIndex, int order)
		{
			return Order(order).CreatePartialDerivativeFunctionHandle(f, parameterIndex, order);
		}

		public static double FirstPartialDerivative(Func<double[], double> f, double[] x, int parameterIndex)
		{
			return PartialDerivative(f, x, parameterIndex, 1);
		}

		public static Func<double[], double> FirstPartialDerivativeFunc(Func<double[], double> f, int parameterIndex)
		{
			return PartialDerivativeFunc(f, parameterIndex, 1);
		}

		public static double PartialDerivative2(Func<double, double, double> f, double x, double y, int parameterIndex, int order)
		{
			return Order(order).EvaluatePartialDerivative((double[] array) => f(array[0], array[1]), new double[2] { x, y }, parameterIndex, order);
		}

		public static Func<double, double, double> PartialDerivative2Func(Func<double, double, double> f, int parameterIndex, int order)
		{
			Func<double[], double> handle = Order(order).CreatePartialDerivativeFunctionHandle((double[] array) => f(array[0], array[1]), parameterIndex, order);
			return (double x, double y) => handle(new double[2] { x, y });
		}

		public static double FirstPartialDerivative2(Func<double, double, double> f, double x, double y, int parameterIndex)
		{
			return PartialDerivative2(f, x, y, parameterIndex, 1);
		}

		public static Func<double, double, double> FirstPartialDerivative2Func(Func<double, double, double> f, int parameterIndex)
		{
			return PartialDerivative2Func(f, parameterIndex, 1);
		}
	}
	public static class DifferIntegrate
	{
		public static double DoubleExponential(Func<double, double> f, double x, double order, double x0 = 0.0, double targetAbsoluteError = 1E-10)
		{
			if (Math.Abs(order) < double.Epsilon)
			{
				return f(x);
			}
			if (order > 0.0 && Math.Abs(order - (double)(int)order) < double.Epsilon)
			{
				return Differentiate.Derivative(f, x, (int)order);
			}
			int num = (int)Math.Ceiling(order) + 1;
			if (num < 1)
			{
				num = 1;
			}
			double r = (double)num - order - 1.0;
			double num2 = Differentiate.Derivative((double v) => Integrate.DoubleExponential((double t) => Math.Pow(v - t, r) * f(t), x0, v, targetAbsoluteError), x, num);
			double num3 = SpecialFunctions.Gamma((double)num - order);
			return num2 / num3;
		}

		public static double GaussLegendre(Func<double, double> f, double x, double order, double x0 = 0.0, int gaussLegendrePoints = 128)
		{
			if (Math.Abs(order) < double.Epsilon)
			{
				return f(x);
			}
			if (order > 0.0 && Math.Abs(order - (double)(int)order) < double.Epsilon)
			{
				return Differentiate.Derivative(f, x, (int)order);
			}
			int num = (int)Math.Ceiling(order) + 1;
			if (num < 1)
			{
				num = 1;
			}
			double r = (double)num - order - 1.0;
			double num2 = Differentiate.Derivative((double v) => Integrate.GaussLegendre((double t) => Math.Pow(v - t, r) * f(t), x0, v, gaussLegendrePoints), x, num);
			double num3 = SpecialFunctions.Gamma((double)num - order);
			return num2 / num3;
		}

		public static double GaussKronrod(Func<double, double> f, double x, double order, double x0 = 0.0, double targetRelativeError = 1E-10, int gaussKronrodPoints = 15)
		{
			if (Math.Abs(order) < double.Epsilon)
			{
				return f(x);
			}
			if (order > 0.0 && Math.Abs(order - (double)(int)order) < double.Epsilon)
			{
				return Differentiate.Derivative(f, x, (int)order);
			}
			int num = (int)Math.Ceiling(order) + 1;
			if (num < 1)
			{
				num = 1;
			}
			double r = (double)num - order - 1.0;
			double num2 = Differentiate.Derivative((double v) => Integrate.GaussKronrod((double t) => Math.Pow(v - t, r) * f(t), x0, v, targetRelativeError, 15, gaussKronrodPoints), x, num);
			double num3 = SpecialFunctions.Gamma((double)num - order);
			return num2 / num3;
		}
	}
	public static class Distance
	{
		public static double SAD<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			return (a - b).L1Norm();
		}

		public static double SAD(double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			double num = 0.0;
			for (int i = 0; i < a.Length; i++)
			{
				num += Math.Abs(a[i] - b[i]);
			}
			return num;
		}

		public static float SAD(float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			float num = 0f;
			for (int i = 0; i < a.Length; i++)
			{
				num += Math.Abs(a[i] - b[i]);
			}
			return num;
		}

		public static double MAE<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			return (a - b).L1Norm() / (double)a.Count;
		}

		public static double MAE(double[] a, double[] b)
		{
			return SAD(a, b) / (double)a.Length;
		}

		public static float MAE(float[] a, float[] b)
		{
			return SAD(a, b) / (float)a.Length;
		}

		public static double SSD<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			double num = (a - b).L2Norm();
			return num * num;
		}

		public static double SSD(double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			double[] array = new double[a.Length];
			LinearAlgebraControl.Provider.SubtractArrays(a, b, array);
			return LinearAlgebraControl.Provider.DotProduct(array, array);
		}

		public static float SSD(float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			float[] array = new float[a.Length];
			LinearAlgebraControl.Provider.SubtractArrays(a, b, array);
			return LinearAlgebraControl.Provider.DotProduct(array, array);
		}

		public static double MSE<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			double num = (a - b).L2Norm();
			return num * num / (double)a.Count;
		}

		public static double MSE(double[] a, double[] b)
		{
			return SSD(a, b) / (double)a.Length;
		}

		public static float MSE(float[] a, float[] b)
		{
			return SSD(a, b) / (float)a.Length;
		}

		public static double Euclidean<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			return (a - b).L2Norm();
		}

		public static double Euclidean(double[] a, double[] b)
		{
			return Math.Sqrt(SSD(a, b));
		}

		public static float Euclidean(float[] a, float[] b)
		{
			return (float)Math.Sqrt(SSD(a, b));
		}

		public static double Manhattan<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			return (a - b).L1Norm();
		}

		public static double Manhattan(double[] a, double[] b)
		{
			return SAD(a, b);
		}

		public static float Manhattan(float[] a, float[] b)
		{
			return SAD(a, b);
		}

		public static double Chebyshev<T>(MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			return (a - b).InfinityNorm();
		}

		public static double Chebyshev(double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			double num = Math.Abs(a[0] - b[0]);
			for (int i = 1; i < a.Length; i++)
			{
				double num2 = Math.Abs(a[i] - b[i]);
				if (num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}

		public static float Chebyshev(float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			float num = Math.Abs(a[0] - b[0]);
			for (int i = 1; i < a.Length; i++)
			{
				float num2 = Math.Abs(a[i] - b[i]);
				if (num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}

		public static double Minkowski<T>(double p, MathNet.Numerics.LinearAlgebra.Vector<T> a, MathNet.Numerics.LinearAlgebra.Vector<T> b) where T : struct, IEquatable<T>, IFormattable
		{
			return (a - b).Norm(p);
		}

		public static double Minkowski(double p, double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			if (p < 0.0)
			{
				throw new ArgumentOutOfRangeException("p");
			}
			if (p == 1.0)
			{
				return Manhattan(a, b);
			}
			if (p == 2.0)
			{
				return Euclidean(a, b);
			}
			if (double.IsPositiveInfinity(p))
			{
				return Chebyshev(a, b);
			}
			double num = 0.0;
			for (int i = 0; i < a.Length; i++)
			{
				num += Math.Pow(Math.Abs(a[i] - b[i]), p);
			}
			return Math.Pow(num, 1.0 / p);
		}

		public static float Minkowski(double p, float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			if (p < 0.0)
			{
				throw new ArgumentOutOfRangeException("p");
			}
			if (p == 1.0)
			{
				return Manhattan(a, b);
			}
			if (p == 2.0)
			{
				return Euclidean(a, b);
			}
			if (double.IsPositiveInfinity(p))
			{
				return Chebyshev(a, b);
			}
			double num = 0.0;
			for (int i = 0; i < a.Length; i++)
			{
				num += Math.Pow(Math.Abs(a[i] - b[i]), p);
			}
			return (float)Math.Pow(num, 1.0 / p);
		}

		public static double Canberra(double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			double num = 0.0;
			for (int i = 0; i < a.Length; i++)
			{
				num += Math.Abs(a[i] - b[i]) / (Math.Abs(a[i]) + Math.Abs(b[i]));
			}
			return num;
		}

		public static float Canberra(float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			float num = 0f;
			for (int i = 0; i < a.Length; i++)
			{
				num += Math.Abs(a[i] - b[i]) / (Math.Abs(a[i]) + Math.Abs(b[i]));
			}
			return num;
		}

		public static double Cosine(double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			double num = LinearAlgebraControl.Provider.DotProduct(a, b);
			double num2 = LinearAlgebraControl.Provider.DotProduct(a, a);
			double num3 = LinearAlgebraControl.Provider.DotProduct(b, b);
			return 1.0 - num / Math.Sqrt(num2 * num3);
		}

		public static float Cosine(float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			float num = LinearAlgebraControl.Provider.DotProduct(a, b);
			float num2 = LinearAlgebraControl.Provider.DotProduct(a, a);
			float num3 = LinearAlgebraControl.Provider.DotProduct(b, b);
			return (float)(1.0 - (double)num / Math.Sqrt(num2 * num3));
		}

		public static double Hamming(double[] a, double[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			int num = 0;
			for (int i = 0; i < a.Length; i++)
			{
				if (a[i] != b[i])
				{
					num++;
				}
			}
			return num;
		}

		public static float Hamming(float[] a, float[] b)
		{
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			int num = 0;
			for (int i = 0; i < a.Length; i++)
			{
				if (a[i] != b[i])
				{
					num++;
				}
			}
			return num;
		}

		public static double Pearson(IEnumerable<double> a, IEnumerable<double> b)
		{
			return 1.0 - Correlation.Pearson(a, b);
		}

		public static double Jaccard(double[] a, double[] b)
		{
			int num = 0;
			int num2 = 0;
			if (a == null)
			{
				throw new ArgumentNullException("a");
			}
			if (b == null)
			{
				throw new ArgumentNullException("b");
			}
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			if (a.Length == 0 && b.Length == 0)
			{
				return 0.0;
			}
			int i = 0;
			for (int num3 = a.Length; i < num3; i++)
			{
				if (a[i] != 0.0 && b[i] != 0.0)
				{
					if (a[i] == b[i])
					{
						num++;
					}
					num2++;
				}
			}
			return 1.0 - (double)num / (double)num2;
		}

		public static double Jaccard(float[] a, float[] b)
		{
			int num = 0;
			int num2 = 0;
			if (a == null)
			{
				throw new ArgumentNullException("a");
			}
			if (b == null)
			{
				throw new ArgumentNullException("b");
			}
			if (a.Length != b.Length)
			{
				throw new ArgumentException("All vectors must have the same dimensionality.");
			}
			if (a.Length == 0 && b.Length == 0)
			{
				return 0.0;
			}
			int i = 0;
			for (int num3 = a.Length; i < num3; i++)
			{
				if (a[i] != 0f && b[i] != 0f)
				{
					if (a[i] == b[i])
					{
						num++;
					}
					num2++;
				}
			}
			return 1.0 - (double)((float)num / (float)num2);
		}
	}
	public static class Euclid
	{
		private static readonly int[] MultiplyDeBruijnBitPosition = new int[32]
		{
			0, 9, 1, 10, 13, 21, 2, 29, 11, 14,
			16, 18, 22, 25, 3, 30, 8, 12, 20, 28,
			15, 17, 24, 7, 19, 27, 23, 6, 26, 5,
			4, 31
		};

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static double Modulus(double dividend, double divisor)
		{
			return (dividend % divisor + divisor) % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Modulus(float dividend, float divisor)
		{
			return (dividend % divisor + divisor) % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int Modulus(int dividend, int divisor)
		{
			return (dividend % divisor + divisor) % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static long Modulus(long dividend, long divisor)
		{
			return (dividend % divisor + divisor) % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static BigInteger Modulus(BigInteger dividend, BigInteger divisor)
		{
			return (dividend % divisor + divisor) % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static double Remainder(double dividend, double divisor)
		{
			return dividend % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Remainder(float dividend, float divisor)
		{
			return dividend % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int Remainder(int dividend, int divisor)
		{
			return dividend % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static long Remainder(long dividend, long divisor)
		{
			return dividend % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static BigInteger Remainder(BigInteger dividend, BigInteger divisor)
		{
			return dividend % divisor;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsEven(this int number)
		{
			return (number & 1) == 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsEven(this long number)
		{
			return (number & 1) == 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOdd(this int number)
		{
			return (number & 1) == 1;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOdd(this long number)
		{
			return (number & 1) == 1;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsPowerOfTwo(this int number)
		{
			if (number > 0)
			{
				return (number & (number - 1)) == 0;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsPowerOfTwo(this long number)
		{
			if (number > 0)
			{
				return (number & (number - 1)) == 0;
			}
			return false;
		}

		public static bool IsPerfectSquare(this int number)
		{
			if (number < 0)
			{
				return false;
			}
			int num = number & 0xF;
			if (num > 9)
			{
				return false;
			}
			if (num == 0 || num == 1 || num == 4 || num == 9)
			{
				int num2 = (int)Math.Floor(Math.Sqrt(number) + 0.5);
				return num2 * num2 == number;
			}
			return false;
		}

		public static bool IsPerfectSquare(this long number)
		{
			if (number < 0)
			{
				return false;
			}
			int num = (int)(number & 0xF);
			if (num > 9)
			{
				return false;
			}
			if (num == 0 || num == 1 || num == 4 || num == 9)
			{
				long num2 = (long)Math.Floor(Math.Sqrt(number) + 0.5);
				return num2 * num2 == number;
			}
			return false;
		}

		public static int PowerOfTwo(this int exponent)
		{
			if (exponent < 0 || exponent >= 31)
			{
				throw new ArgumentOutOfRangeException("exponent");
			}
			return 1 << exponent;
		}

		public static long PowerOfTwo(this long exponent)
		{
			if (exponent < 0 || exponent >= 63)
			{
				throw new ArgumentOutOfRangeException("exponent");
			}
			return 1L << (int)exponent;
		}

		public static int Log2(this int number)
		{
			number |= number >> 1;
			number |= number >> 2;
			number |= number >> 4;
			number |= number >> 8;
			number |= number >> 16;
			return MultiplyDeBruijnBitPosition[(uint)((long)number * 130329821L) >> 27];
		}

		public static int CeilingToPowerOfTwo(this int number)
		{
			if (number == int.MinValue)
			{
				return 0;
			}
			if (number > 1073741824)
			{
				throw new ArgumentOutOfRangeException("number");
			}
			number--;
			number |= number >> 1;
			number |= number >> 2;
			number |= number >> 4;
			number |= number >> 8;
			number |= number >> 16;
			return number + 1;
		}

		public static long CeilingToPowerOfTwo(this long number)
		{
			if (number == long.MinValue)
			{
				return 0L;
			}
			if (number > 4611686018427387904L)
			{
				throw new ArgumentOutOfRangeException("number");
			}
			number--;
			number |= number >> 1;
			number |= number >> 2;
			number |= number >> 4;
			number |= number >> 8;
			number |= number >> 16;
			number |= number >> 32;
			return number + 1;
		}

		public static long GreatestCommonDivisor(long a, long b)
		{
			while (b != 0L)
			{
				long num = a % b;
				a = b;
				b = num;
			}
			return Math.Abs(a);
		}

		public static long GreatestCommonDivisor(IList<long> integers)
		{
			if (integers == null)
			{
				throw new ArgumentNullException("integers");
			}
			if (integers.Count == 0)
			{
				return 0L;
			}
			long num = Math.Abs(integers[0]);
			for (int i = 1; i < integers.Count; i++)
			{
				if (num <= 1)
				{
					break;
				}
				num = GreatestCommonDivisor(num, integers[i]);
			}
			return num;
		}

		public static long GreatestCommonDivisor(params long[] integers)
		{
			return GreatestCommonDivisor((IList<long>)integers);
		}

		public static long ExtendedGreatestCommonDivisor(long a, long b, out long x, out long y)
		{
			long num = 1L;
			long num2 = 0L;
			long num3 = 0L;
			long num4 = 1L;
			while (b != 0L)
			{
				long result;
				long num5 = Math.DivRem(a, b, out result);
				a = b;
				b = result;
				long num6 = num3;
				num3 = num - num5 * num3;
				num = num6;
				long num7 = num4;
				num4 = num2 - num5 * num4;
				num2 = num7;
			}
			if (a >= 0)
			{
				x = num;
				y = num2;
				return a;
			}
			x = -num;
			y = -num2;
			return -a;
		}

		public static long LeastCommonMultiple(long a, long b)
		{
			if (a == 0L || b == 0L)
			{
				return 0L;
			}
			return Math.Abs(a / GreatestCommonDivisor(a, b) * b);
		}

		public static long LeastCommonMultiple(IList<long> integers)
		{
			if (integers == null)
			{
				throw new ArgumentNullException("integers");
			}
			if (integers.Count == 0)
			{
				return 1L;
			}
			long num = Math.Abs(integers[0]);
			for (int i = 1; i < integers.Count; i++)
			{
				num = LeastCommonMultiple(num, integers[i]);
			}
			return num;
		}

		public static long LeastCommonMultiple(params long[] integers)
		{
			return LeastCommonMultiple((IList<long>)integers);
		}

		public static BigInteger GreatestCommonDivisor(BigInteger a, BigInteger b)
		{
			return BigInteger.GreatestCommonDivisor(a, b);
		}

		public static BigInteger GreatestCommonDivisor(IList<BigInteger> integers)
		{
			if (integers == null)
			{
				throw new ArgumentNullException("integers");
			}
			if (integers.Count == 0)
			{
				return 0;
			}
			BigInteger bigInteger = BigInteger.Abs(integers[0]);
			for (int i = 1; i < integers.Count; i++)
			{
				if (!(bigInteger > BigInteger.One))
				{
					break;
				}
				bigInteger = GreatestCommonDivisor(bigInteger, integers[i]);
			}
			return bigInteger;
		}

		public static BigInteger GreatestCommonDivisor(params BigInteger[] integers)
		{
			return GreatestCommonDivisor((IList<BigInteger>)integers);
		}

		public static BigInteger ExtendedGreatestCommonDivisor(BigInteger a, BigInteger b, out BigInteger x, out BigInteger y)
		{
			BigInteger bigInteger = BigInteger.One;
			BigInteger bigInteger2 = BigInteger.Zero;
			BigInteger bigInteger3 = BigInteger.Zero;
			BigInteger bigInteger4 = BigInteger.One;
			while (!b.IsZero)
			{
				BigInteger remainder;
				BigInteger bigInteger5 = BigInteger.DivRem(a, b, out remainder);
				a = b;
				b = remainder;
				BigInteger bigInteger6 = bigInteger3;
				bigInteger3 = bigInteger - bigInteger5 * bigInteger3;
				bigInteger = bigInteger6;
				BigInteger bigInteger7 = bigInteger4;
				bigInteger4 = bigInteger2 - bigInteger5 * bigInteger4;
				bigInteger2 = bigInteger7;
			}
			if (a >= BigInteger.Zero)
			{
				x = bigInteger;
				y = bigInteger2;
				return a;
			}
			x = -bigInteger;
			y = -bigInteger2;
			return -a;
		}

		public static BigInteger LeastCommonMultiple(BigInteger a, BigInteger b)
		{
			if (a.IsZero || b.IsZero)
			{
				return BigInteger.Zero;
			}
			return BigInteger.Abs(a / BigInteger.GreatestCommonDivisor(a, b) * b);
		}

		public static BigInteger LeastCommonMultiple(IList<BigInteger> integers)
		{
			if (integers == null)
			{
				throw new ArgumentNullException("integers");
			}
			if (integers.Count == 0)
			{
				return 1;
			}
			BigInteger bigInteger = BigInteger.Abs(integers[0]);
			for (int i = 1; i < integers.Count; i++)
			{
				bigInteger = LeastCommonMultiple(bigInteger, integers[i]);
			}
			return bigInteger;
		}

		public static BigInteger LeastCommonMultiple(params BigInteger[] integers)
		{
			return LeastCommonMultiple((IList<BigInteger>)integers);
		}
	}
	public static class ExcelFunctions
	{
		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double NormSDist(double z)
		{
			return Normal.CDF(0.0, 1.0, z);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double NormSInv(double probability)
		{
			return Normal.InvCDF(0.0, 1.0, probability);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double NormDist(double x, double mean, double standardDev, bool cumulative)
		{
			if (!cumulative)
			{
				return Normal.PDF(mean, standardDev, x);
			}
			return Normal.CDF(mean, standardDev, x);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double NormInv(double probability, double mean, double standardDev)
		{
			return Normal.InvCDF(mean, standardDev, probability);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double TDist(double x, int degreesFreedom, int tails)
		{
			return tails switch
			{
				1 => 1.0 - StudentT.CDF(0.0, 1.0, degreesFreedom, x), 
				2 => 1.0 - StudentT.CDF(0.0, 1.0, degreesFreedom, x) + StudentT.CDF(0.0, 1.0, degreesFreedom, 0.0 - x), 
				_ => throw new ArgumentOutOfRangeException("tails"), 
			};
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double TInv(double probability, int degreesFreedom)
		{
			return 0.0 - StudentT.InvCDF(0.0, 1.0, degreesFreedom, probability / 2.0);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double FDist(double x, int degreesFreedom1, int degreesFreedom2)
		{
			return 1.0 - FisherSnedecor.CDF(degreesFreedom1, degreesFreedom2, x);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double FInv(double probability, int degreesFreedom1, int degreesFreedom2)
		{
			return FisherSnedecor.InvCDF(degreesFreedom1, degreesFreedom2, 1.0 - probability);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double BetaDist(double x, double alpha, double beta)
		{
			return Beta.CDF(alpha, beta, x);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double BetaInv(double probability, double alpha, double beta)
		{
			return Beta.InvCDF(alpha, beta, probability);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double GammaDist(double x, double alpha, double beta, bool cumulative)
		{
			if (!cumulative)
			{
				return Gamma.PDF(alpha, 1.0 / beta, x);
			}
			return Gamma.CDF(alpha, 1.0 / beta, x);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double GammaInv(double probability, double alpha, double beta)
		{
			return Gamma.InvCDF(alpha, 1.0 / beta, probability);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double Quartile(double[] array, int quant)
		{
			return quant switch
			{
				0 => ArrayStatistics.Minimum(array), 
				1 => array.QuantileCustom(0.25, QuantileDefinition.R7), 
				2 => array.QuantileCustom(0.5, QuantileDefinition.R7), 
				3 => array.QuantileCustom(0.75, QuantileDefinition.R7), 
				4 => ArrayStatistics.Maximum(array), 
				_ => throw new ArgumentOutOfRangeException("quant"), 
			};
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double Percentile(double[] array, double k)
		{
			return array.QuantileCustom(k, QuantileDefinition.R7);
		}

		[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
		public static double PercentRank(double[] array, double x)
		{
			return array.QuantileRank(x, RankDefinition.Min);
		}
	}
	[Serializable]
	public class NonConvergenceException : Exception
	{
		public NonConvergenceException()
			: base("An algorithm failed to converge.")
		{
		}

		public NonConvergenceException(string message)
			: base(message)
		{
		}

		public NonConvergenceException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected NonConvergenceException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	public class NumericalBreakdownException : NonConvergenceException
	{
		public NumericalBreakdownException()
			: base("Algorithm experience a numerical break down.")
		{
		}

		public NumericalBreakdownException(string message)
			: base(message)
		{
		}

		public NumericalBreakdownException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected NumericalBreakdownException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	public abstract class NativeInterfaceException : Exception
	{
		protected NativeInterfaceException()
		{
		}

		protected NativeInterfaceException(string message)
			: base(message)
		{
		}

		protected NativeInterfaceException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected NativeInterfaceException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	public class InvalidParameterException : NativeInterfaceException
	{
		public InvalidParameterException()
			: base("An invalid parameter was passed to a native method.")
		{
		}

		public InvalidParameterException(int parameter)
			: base($"An invalid parameter was passed to a native method, parameter number : {parameter}")
		{
		}

		public InvalidParameterException(int parameter, Exception innerException)
			: base($"An invalid parameter was passed to a native method, parameter number : {parameter}", innerException)
		{
		}

		protected InvalidParameterException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	public class MemoryAllocationException : NativeInterfaceException
	{
		public MemoryAllocationException()
			: base("Unable to allocate native memory.")
		{
		}

		public MemoryAllocationException(Exception innerException)
			: base("Unable to allocate native memory.", innerException)
		{
		}

		protected MemoryAllocationException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	public class SingularUMatrixException : NativeInterfaceException
	{
		public SingularUMatrixException()
			: base("U is singular, and the inversion could not be completed.")
		{
		}

		public SingularUMatrixException(int element)
			: base($"U is singular, and the inversion could not be completed. The {element}-th diagonal element of the factor U is zero.")
		{
		}

		public SingularUMatrixException(int element, Exception innerException)
			: base($"U is singular, and the inversion could not be completed. The {element}-th diagonal element of the factor U is zero.", innerException)
		{
		}

		protected SingularUMatrixException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	public static class FindMinimum
	{
		public static double OfScalarFunctionConstrained(Func<double, double> function, double lowerBound, double upperBound, double tolerance = 1E-05, int maxIterations = 1000)
		{
			return GoldenSectionMinimizer.Minimum(ObjectiveFunction.ScalarValue(function), lowerBound, upperBound, tolerance, maxIterations).MinimizingPoint;
		}

		public static double OfScalarFunction(Func<double, double> function, double initialGuess, double tolerance = 1E-08, int maxIterations = 1000)
		{
			return NelderMeadSimplex.Minimum(ObjectiveFunction.Value((MathNet.Numerics.LinearAlgebra.Vector<double> v) => function(v[0])), CreateVector.Dense(new double[1] { initialGuess }), tolerance, maxIterations).MinimizingPoint[0];
		}

		public static (double P0, double P1) OfFunction(Func<double, double, double> function, double initialGuess0, double initialGuess1, double tolerance = 1E-08, int maxIterations = 1000)
		{
			MinimizationResult minimizationResult = NelderMeadSimplex.Minimum(ObjectiveFunction.Value((MathNet.Numerics.LinearAlgebra.Vector<double> v) => function(v[0], v[1])), CreateVector.Dense(new double[2] { initialGuess0, initialGuess1 }), tolerance, maxIterations);
			return (minimizationResult.MinimizingPoint[0], minimizationResult.MinimizingPoint[1]);
		}

		public static (double P0, double P1, double P2) OfFunction(Func<double, double, double, double> function, double initialGuess0, double initialGuess1, double initialGuess2, double tolerance = 1E-08, int maxIterations = 1000)
		{
			MinimizationResult minimizationResult = NelderMeadSimplex.Minimum(ObjectiveFunction.Value((MathNet.Numerics.LinearAlgebra.Vector<double> v) => function(v[0], v[1], v[2])), CreateVector.Dense(new double[3] { initialGuess0, initialGuess1, initialGuess2 }), tolerance, maxIterations);
			return (minimizationResult.MinimizingPoint[0], minimizationResult.MinimizingPoint[1], minimizationResult.MinimizingPoint[2]);
		}

		public static (double P0, double P1, double P2, double P3) OfFunction(Func<double, double, double, double, double> function, double initialGuess0, double initialGuess1, double initialGuess2, double initialGuess3, double tolerance = 1E-08, int maxIterations = 1000)
		{
			MinimizationResult minimizationResult = NelderMeadSimplex.Minimum(ObjectiveFunction.Value((MathNet.Numerics.LinearAlgebra.Vector<double> v) => function(v[0], v[1], v[2], v[3])), CreateVector.Dense(new double[4] { initialGuess0, initialGuess1, initialGuess2, initialGuess3 }), tolerance, maxIterations);
			return (minimizationResult.MinimizingPoint[0], minimizationResult.MinimizingPoint[1], minimizationResult.MinimizingPoint[2], minimizationResult.MinimizingPoint[3]);
		}

		public static (double P0, double P1, double P2, double P3, double P4) OfFunction(Func<double, double, double, double, double, double> function, double initialGuess0, double initialGuess1, double initialGuess2, double initialGuess3, double initialGuess4, double tolerance = 1E-08, int maxIterations = 1000)
		{
			MinimizationResult minimizationResult = NelderMeadSimplex.Minimum(ObjectiveFunction.Value((MathNet.Numerics.LinearAlgebra.Vector<double> v) => function(v[0], v[1], v[2], v[3], v[4])), CreateVector.Dense(new double[5] { initialGuess0, initialGuess1, initialGuess2, initialGuess3, initialGuess4 }), tolerance, maxIterations);
			return (minimizationResult.MinimizingPoint[0], minimizationResult.MinimizingPoint[1], minimizationResult.MinimizingPoint[2], minimizationResult.MinimizingPoint[3], minimizationResult.MinimizingPoint[4]);
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunction(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, double> function, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double tolerance = 1E-08, int maxIterations = 1000)
		{
			return NelderMeadSimplex.Minimum(ObjectiveFunction.Value(function), initialGuess, tolerance, maxIterations).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionConstrained(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, double> function, MathNet.Numerics.LinearAlgebra.Vector<double> lowerBound, MathNet.Numerics.LinearAlgebra.Vector<double> upperBound, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-05, double parameterTolerance = 1E-05, double functionProgressTolerance = 1E-05, int maxIterations = 1000)
		{
			ForwardDifferenceGradientObjectiveFunction objective = new ForwardDifferenceGradientObjectiveFunction(ObjectiveFunction.Value(function), lowerBound, upperBound);
			return new BfgsBMinimizer(gradientTolerance, parameterTolerance, functionProgressTolerance, maxIterations).FindMinimum(objective, lowerBound, upperBound, initialGuess).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionGradient(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, double> function, Func<MathNet.Numerics.LinearAlgebra.Vector<double>, MathNet.Numerics.LinearAlgebra.Vector<double>> gradient, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-05, double parameterTolerance = 1E-05, double functionProgressTolerance = 1E-05, int maxIterations = 1000)
		{
			IObjectiveFunction objective = ObjectiveFunction.Gradient(function, gradient);
			return new BfgsMinimizer(gradientTolerance, parameterTolerance, functionProgressTolerance, maxIterations).FindMinimum(objective, initialGuess).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionGradient(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, (double, MathNet.Numerics.LinearAlgebra.Vector<double>)> functionGradient, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-05, double parameterTolerance = 1E-05, double functionProgressTolerance = 1E-05, int maxIterations = 1000)
		{
			IObjectiveFunction objective = ObjectiveFunction.Gradient(functionGradient);
			return new BfgsMinimizer(gradientTolerance, parameterTolerance, functionProgressTolerance, maxIterations).FindMinimum(objective, initialGuess).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionGradientConstrained(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, double> function, Func<MathNet.Numerics.LinearAlgebra.Vector<double>, MathNet.Numerics.LinearAlgebra.Vector<double>> gradient, MathNet.Numerics.LinearAlgebra.Vector<double> lowerBound, MathNet.Numerics.LinearAlgebra.Vector<double> upperBound, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-05, double parameterTolerance = 1E-05, double functionProgressTolerance = 1E-05, int maxIterations = 1000)
		{
			IObjectiveFunction objective = ObjectiveFunction.Gradient(function, gradient);
			return new BfgsBMinimizer(gradientTolerance, parameterTolerance, functionProgressTolerance, maxIterations).FindMinimum(objective, lowerBound, upperBound, initialGuess).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionGradientConstrained(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, (double, MathNet.Numerics.LinearAlgebra.Vector<double>)> functionGradient, MathNet.Numerics.LinearAlgebra.Vector<double> lowerBound, MathNet.Numerics.LinearAlgebra.Vector<double> upperBound, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-05, double parameterTolerance = 1E-05, double functionProgressTolerance = 1E-05, int maxIterations = 1000)
		{
			IObjectiveFunction objective = ObjectiveFunction.Gradient(functionGradient);
			return new BfgsBMinimizer(gradientTolerance, parameterTolerance, functionProgressTolerance, maxIterations).FindMinimum(objective, lowerBound, upperBound, initialGuess).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionGradientHessian(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, double> function, Func<MathNet.Numerics.LinearAlgebra.Vector<double>, MathNet.Numerics.LinearAlgebra.Vector<double>> gradient, Func<MathNet.Numerics.LinearAlgebra.Vector<double>, Matrix<double>> hessian, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-08, int maxIterations = 1000)
		{
			return NewtonMinimizer.Minimum(ObjectiveFunction.GradientHessian(function, gradient, hessian), initialGuess, gradientTolerance, maxIterations).MinimizingPoint;
		}

		public static MathNet.Numerics.LinearAlgebra.Vector<double> OfFunctionGradientHessian(Func<MathNet.Numerics.LinearAlgebra.Vector<double>, (double, MathNet.Numerics.LinearAlgebra.Vector<double>, Matrix<double>)> functionGradientHessian, MathNet.Numerics.LinearAlgebra.Vector<double> initialGuess, double gradientTolerance = 1E-08, int maxIterations = 1000)
		{
			return NewtonMinimizer.Minimum(ObjectiveFunction.GradientHessian(functionGradientHessian), initialGuess, gradientTolerance, maxIterations).MinimizingPoint;
		}
	}
	public static class FindRoots
	{
		public static double OfFunction(Func<double, double> f, double lowerBound, double upperBound, double accuracy = 1E-08, int maxIterations = 100)
		{
			if (!ZeroCrossingBracketing.ExpandReduce(f, ref lowerBound, ref upperBound, 1.6, maxIterations, maxIterations * 10))
			{
				throw new NonConvergenceException("The algorithm has failed, exceeded the number of iterations allowed or there is no root within the provided bounds.");
			}
			if (Brent.TryFindRoot(f, lowerBound, upperBound, accuracy, maxIterations, out var root))
			{
				return root;
			}
			if (Bisection.TryFindRoot(f, lowerBound, upperBound, accuracy, maxIterations, out root))
			{
				return root;
			}
			throw new NonConvergenceException("The algorithm has failed, exceeded the number of iterations allowed or there is no root within the provided bounds.");
		}

		public static double OfFunctionDerivative(Func<double, double> f, Func<double, double> df, double lowerBound, double upperBound, double accuracy = 1E-08, int maxIterations = 100)
		{
			if