commit 9244de43f13b7db5202e4b6b5653abbf83bc9048 Author: lildosto Date: Sat May 23 14:08:36 2026 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7416fde --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# Unity default ignore files +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/[Ll]ogs/ +/[Mm]emoryCaptures/ +/[Aa]rchive/ + +# Asset meta files for folders ignored above +/[Ll]ibrary.meta +/[Tt]emp.meta +/[Oo]bj.meta +/[Bb]uild.meta +/[Bb]uilds.meta +/[Ss]ave.meta + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.opendb +*.tlog + +# Unity3D generated meta files +sysinfo.txt + +# Builds and big binaries (GitHub has a 100MB limit per file, so we must exclude these) +*.exe +*.zip +*.apk +*.unitypackage +*.app +.vs/ diff --git a/.vsconfig b/.vsconfig new file mode 100644 index 0000000..1586a48 --- /dev/null +++ b/.vsconfig @@ -0,0 +1,6 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Workload.ManagedGame" + ] +} diff --git a/Assets/Prefabs.meta b/Assets/Prefabs.meta new file mode 100644 index 0000000..477fc16 --- /dev/null +++ b/Assets/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f0e3526b7b08a245a694381f466ff41 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/INPTEquation.prefab b/Assets/Prefabs/INPTEquation.prefab new file mode 100644 index 0000000..0f2b010 --- /dev/null +++ b/Assets/Prefabs/INPTEquation.prefab @@ -0,0 +1,299 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &985874966542180765 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 985874966542180762} + - component: {fileID: 985874966542180760} + - component: {fileID: 985874966542180763} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &985874966542180762 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874966542180765} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 985874967725327421} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &985874966542180760 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874966542180765} + m_CullTransparentMesh: 0 +--- !u!114 &985874966542180763 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874966542180765} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!1 &985874967524545953 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 985874967524545966} + - component: {fileID: 985874967524545964} + - component: {fileID: 985874967524545967} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &985874967524545966 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967524545953} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 985874967725327421} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &985874967524545964 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967524545953} + m_CullTransparentMesh: 0 +--- !u!114 &985874967524545967 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967524545953} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter equation... +--- !u!1 &985874967725327420 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 985874967725327421} + - component: {fileID: 985874967725327416} + - component: {fileID: 985874967725327419} + - component: {fileID: 985874967725327418} + m_Layer: 5 + m_Name: INPTEquation + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &985874967725327421 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967725327420} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 985874967524545966} + - {fileID: 985874966542180762} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 600, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &985874967725327416 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967725327420} + m_CullTransparentMesh: 0 +--- !u!114 &985874967725327419 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967725327420} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &985874967725327418 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 985874967725327420} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 985874967725327419} + m_TextComponent: {fileID: 985874966542180763} + m_Placeholder: {fileID: 985874967524545967} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 diff --git a/Assets/Prefabs/INPTEquation.prefab.meta b/Assets/Prefabs/INPTEquation.prefab.meta new file mode 100644 index 0000000..f9ea192 --- /dev/null +++ b/Assets/Prefabs/INPTEquation.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fccb4ef9675556c439d94f41f15a8e1a +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/INPTInitialPoint.prefab b/Assets/Prefabs/INPTInitialPoint.prefab new file mode 100644 index 0000000..7b09db6 --- /dev/null +++ b/Assets/Prefabs/INPTInitialPoint.prefab @@ -0,0 +1,299 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2895230885503808811 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2895230885503808810} + - component: {fileID: 2895230885503808807} + - component: {fileID: 2895230885503808808} + - component: {fileID: 2895230885503808809} + m_Layer: 5 + m_Name: INPTInitialPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2895230885503808810 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230885503808811} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2895230886245064501} + - {fileID: 2895230886262753959} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 200, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2895230885503808807 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230885503808811} + m_CullTransparentMesh: 0 +--- !u!114 &2895230885503808808 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230885503808811} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &2895230885503808809 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230885503808811} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2895230885503808808} + m_TextComponent: {fileID: 2895230886262753958} + m_Placeholder: {fileID: 2895230886245064500} + m_ContentType: 3 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 2 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 2 + m_CharacterLimit: 15 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!1 &2895230886245064502 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2895230886245064501} + - component: {fileID: 2895230886245064499} + - component: {fileID: 2895230886245064500} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2895230886245064501 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230886245064502} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2895230885503808810} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2895230886245064499 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230886245064502} + m_CullTransparentMesh: 0 +--- !u!114 &2895230886245064500 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230886245064502} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Initial point... +--- !u!1 &2895230886262753960 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2895230886262753959} + - component: {fileID: 2895230886262753957} + - component: {fileID: 2895230886262753958} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2895230886262753959 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230886262753960} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2895230885503808810} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2895230886262753957 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230886262753960} + m_CullTransparentMesh: 0 +--- !u!114 &2895230886262753958 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2895230886262753960} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: diff --git a/Assets/Prefabs/INPTInitialPoint.prefab.meta b/Assets/Prefabs/INPTInitialPoint.prefab.meta new file mode 100644 index 0000000..249abc5 --- /dev/null +++ b/Assets/Prefabs/INPTInitialPoint.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dce03982ff0627e459979d3e508a5463 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/INPTVariable.prefab b/Assets/Prefabs/INPTVariable.prefab new file mode 100644 index 0000000..45fd6c8 --- /dev/null +++ b/Assets/Prefabs/INPTVariable.prefab @@ -0,0 +1,299 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2006212224380440147 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2006212224380440146} + - component: {fileID: 2006212224380440148} + - component: {fileID: 2006212224380440149} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2006212224380440146 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224380440147} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2006212224861606533} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2006212224380440148 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224380440147} + m_CullTransparentMesh: 0 +--- !u!114 &2006212224380440149 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224380440147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 22 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Variable +--- !u!1 &2006212224861606530 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2006212224861606533} + - component: {fileID: 2006212224861606534} + - component: {fileID: 2006212224861606535} + - component: {fileID: 2006212224861606532} + m_Layer: 5 + m_Name: INPTVariable + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2006212224861606533 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224861606530} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2006212224380440146} + - {fileID: 2006212225912600286} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2006212224861606534 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224861606530} + m_CullTransparentMesh: 0 +--- !u!114 &2006212224861606535 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224861606530} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &2006212224861606532 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212224861606530} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2006212224861606535} + m_TextComponent: {fileID: 2006212225912600097} + m_Placeholder: {fileID: 2006212224380440149} + m_ContentType: 4 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 1 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 3 + m_CharacterLimit: 1 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!1 &2006212225912600287 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2006212225912600286} + - component: {fileID: 2006212225912600096} + - component: {fileID: 2006212225912600097} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2006212225912600286 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212225912600287} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2006212224861606533} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2006212225912600096 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212225912600287} + m_CullTransparentMesh: 0 +--- !u!114 &2006212225912600097 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2006212225912600287} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 30 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: diff --git a/Assets/Prefabs/INPTVariable.prefab.meta b/Assets/Prefabs/INPTVariable.prefab.meta new file mode 100644 index 0000000..a69ded3 --- /dev/null +++ b/Assets/Prefabs/INPTVariable.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e7b5d763b32e0e44494864207f0d5275 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes.meta b/Assets/Scenes.meta new file mode 100644 index 0000000..4511815 --- /dev/null +++ b/Assets/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4eb5aeac669694c45af64b5730fe82ca +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity new file mode 100644 index 0000000..e3a952b --- /dev/null +++ b/Assets/Scenes/SampleScene.unity @@ -0,0 +1,6374 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 705507994} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &34561381 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 34561382} + - component: {fileID: 34561384} + - component: {fileID: 34561383} + - component: {fileID: 34561385} + m_Layer: 5 + m_Name: PNLMainMenu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &34561382 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 34561381} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 328073363} + - {fileID: 899715282} + - {fileID: 629087869} + m_Father: {fileID: 1141753987} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &34561383 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 34561381} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &34561384 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 34561381} + m_CullTransparentMesh: 0 +--- !u!114 &34561385 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 34561381} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 300 + m_Bottom: 0 + m_ChildAlignment: 1 + m_Spacing: 10 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 +--- !u!1 &37495281 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 37495282} + - component: {fileID: 37495284} + - component: {fileID: 37495283} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &37495282 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 37495281} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 567324289} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &37495283 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 37495281} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: X +--- !u!222 &37495284 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 37495281} + m_CullTransparentMesh: 0 +--- !u!1 &50727098 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 50727099} + - component: {fileID: 50727100} + m_Layer: 5 + m_Name: TGLBisectionMethod + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &50727099 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50727098} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 560263401} + - {fileID: 1419820221} + m_Father: {fileID: 1681187904} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: -0.000030517578, y: 0} + m_SizeDelta: {x: 350, y: 75} + m_Pivot: {x: 1, y: 0.5} +--- !u!114 &50727100 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50727098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 560263402} + toggleTransition: 1 + graphic: {fileID: 1826328024} + m_Group: {fileID: 1681187905} + onValueChanged: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: TGLNewtonRaphsonBisection + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_IsOn: 0 +--- !u!1 &245101418 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 245101419} + - component: {fileID: 245101420} + m_Layer: 5 + m_Name: EquationsMenu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &245101419 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 245101418} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1053954607} + - {fileID: 638408136} + - {fileID: 1317693096} + - {fileID: 1606950418} + - {fileID: 1141229488} + - {fileID: 1675034107} + m_Father: {fileID: 1029743022} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &245101420 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 245101418} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 75 + m_Bottom: 0 + m_ChildAlignment: 1 + m_Spacing: 50 + m_ChildForceExpandWidth: 0 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 +--- !u!1 &275540146 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 275540147} + - component: {fileID: 275540149} + - component: {fileID: 275540148} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &275540147 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 275540146} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1869820023} + m_Father: {fileID: 1624308493} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 50, y: 50} + m_Pivot: {x: 0, y: 0.5} +--- !u!114 &275540148 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 275540146} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &275540149 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 275540146} + m_CullTransparentMesh: 0 +--- !u!1 &291788984 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 291788985} + - component: {fileID: 291788987} + - component: {fileID: 291788986} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &291788985 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 291788984} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 806293295} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &291788986 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 291788984} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &291788987 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 291788984} + m_CullTransparentMesh: 0 +--- !u!1 &328073362 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 328073363} + - component: {fileID: 328073366} + - component: {fileID: 328073365} + - component: {fileID: 328073364} + m_Layer: 5 + m_Name: BTNEquationRootFinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &328073363 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 328073362} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 883764593} + m_Father: {fileID: 34561382} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &328073364 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 328073362} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 328073365} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: BTNEquationRootFinder + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &328073365 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 328073362} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &328073366 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 328073362} + m_CullTransparentMesh: 0 +--- !u!1 &411623340 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 411623341} + - component: {fileID: 411623344} + - component: {fileID: 411623343} + - component: {fileID: 411623342} + m_Layer: 5 + m_Name: INPTEquation + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &411623341 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 411623340} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2117349378} + - {fileID: 1753560745} + m_Father: {fileID: 1907570698} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -237.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &411623342 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 411623340} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 411623343} + m_TextComponent: {fileID: 1753560746} + m_Placeholder: {fileID: 2117349379} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &411623343 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 411623340} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &411623344 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 411623340} + m_CullTransparentMesh: 0 +--- !u!1 &468073318 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 468073319} + - component: {fileID: 468073322} + - component: {fileID: 468073321} + - component: {fileID: 468073320} + m_Layer: 5 + m_Name: BTNFindEquationRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &468073319 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 468073318} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1686026807} + m_Father: {fileID: 1907570698} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -577.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &468073320 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 468073318} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 468073321} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: BTNFindEquationRoot + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &468073321 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 468073318} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &468073322 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 468073318} + m_CullTransparentMesh: 0 +--- !u!1 &560263400 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 560263401} + - component: {fileID: 560263403} + - component: {fileID: 560263402} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &560263401 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 560263400} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1826328023} + m_Father: {fileID: 50727099} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 50, y: 50} + m_Pivot: {x: 0, y: 0.5} +--- !u!114 &560263402 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 560263400} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &560263403 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 560263400} + m_CullTransparentMesh: 0 +--- !u!1 &567324288 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 567324289} + - component: {fileID: 567324292} + - component: {fileID: 567324291} + - component: {fileID: 567324290} + m_Layer: 5 + m_Name: BTNMainMenuESS + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &567324289 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 567324288} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 37495282} + m_Father: {fileID: 1029743022} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 60, y: 60} + m_Pivot: {x: 1, y: 1} +--- !u!114 &567324290 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 567324288} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 567324291} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: BTNMainMenuESS + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &567324291 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 567324288} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &567324292 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 567324288} + m_CullTransparentMesh: 0 +--- !u!1 &569911634 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 569911635} + - component: {fileID: 569911637} + - component: {fileID: 569911636} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &569911635 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 569911634} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 888673477} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &569911636 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 569911634} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &569911637 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 569911634} + m_CullTransparentMesh: 0 +--- !u!1 &629087868 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 629087869} + - component: {fileID: 629087872} + - component: {fileID: 629087871} + - component: {fileID: 629087870} + m_Layer: 5 + m_Name: BTNExit + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &629087869 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 629087868} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 874769204} + m_Father: {fileID: 34561382} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &629087870 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 629087868} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 629087871} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: ExitTheProgram + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &629087871 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 629087868} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &629087872 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 629087868} + m_CullTransparentMesh: 0 +--- !u!1 &638408135 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 638408136} + - component: {fileID: 638408139} + - component: {fileID: 638408138} + - component: {fileID: 638408137} + m_Layer: 5 + m_Name: INPTESIterationCount + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &638408136 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638408135} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1825719252} + - {fileID: 846219422} + m_Father: {fileID: 245101419} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 354.93982, y: -112.5} + m_SizeDelta: {x: 261, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &638408137 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638408135} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 638408138} + m_TextComponent: {fileID: 846219423} + m_Placeholder: {fileID: 1825719253} + m_ContentType: 2 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 4 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 1 + m_CharacterLimit: 2 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &638408138 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638408135} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &638408139 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638408135} + m_CullTransparentMesh: 0 +--- !u!1 &705507993 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 705507995} + - component: {fileID: 705507994} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &705507994 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 1 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &705507995 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &708662513 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 708662514} + - component: {fileID: 708662516} + - component: {fileID: 708662515} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &708662514 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 708662513} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1581354701} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &708662515 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 708662513} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &708662516 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 708662513} + m_CullTransparentMesh: 0 +--- !u!1 &734743533 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 734743534} + - component: {fileID: 734743536} + - component: {fileID: 734743535} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &734743534 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 734743533} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1675034107} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &734743535 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 734743533} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 40 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Find Roots +--- !u!222 &734743536 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 734743533} + m_CullTransparentMesh: 0 +--- !u!1 &741253645 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 741253648} + - component: {fileID: 741253647} + - component: {fileID: 741253646} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &741253646 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 741253645} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &741253647 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 741253645} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &741253648 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 741253645} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &753423720 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 753423721} + - component: {fileID: 753423723} + - component: {fileID: 753423722} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &753423721 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 753423720} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1624308493} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -0.000015258789, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &753423722 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 753423720} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 30 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Newton-Raphson +--- !u!222 &753423723 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 753423720} + m_CullTransparentMesh: 0 +--- !u!1 &755611189 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 755611190} + - component: {fileID: 755611192} + - component: {fileID: 755611191} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &755611190 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 755611189} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 799977582} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &755611191 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 755611189} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &755611192 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 755611189} + m_CullTransparentMesh: 0 +--- !u!1 &795806524 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 795806525} + - component: {fileID: 795806527} + - component: {fileID: 795806526} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &795806525 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 795806524} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1540279552} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &795806526 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 795806524} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &795806527 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 795806524} + m_CullTransparentMesh: 0 +--- !u!1 &799977581 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 799977582} + - component: {fileID: 799977585} + - component: {fileID: 799977584} + - component: {fileID: 799977583} + m_Layer: 5 + m_Name: INPTMinX + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &799977582 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 799977581} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1960048561} + - {fileID: 755611190} + m_Father: {fileID: 1907570698} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -422.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &799977583 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 799977581} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 799977584} + m_TextComponent: {fileID: 755611191} + m_Placeholder: {fileID: 1960048562} + m_ContentType: 3 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 2 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 2 + m_CharacterLimit: 7 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &799977584 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 799977581} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &799977585 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 799977581} + m_CullTransparentMesh: 0 +--- !u!1 &806293294 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 806293295} + - component: {fileID: 806293298} + - component: {fileID: 806293297} + - component: {fileID: 806293296} + m_Layer: 5 + m_Name: INPTIterationCount + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &806293295 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 806293294} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1879957137} + - {fileID: 291788985} + m_Father: {fileID: 1907570698} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -407.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &806293296 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 806293294} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 806293297} + m_TextComponent: {fileID: 291788986} + m_Placeholder: {fileID: 1879957138} + m_ContentType: 2 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 4 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 1 + m_CharacterLimit: 3 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &806293297 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 806293294} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &806293298 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 806293294} + m_CullTransparentMesh: 0 +--- !u!1 &845457378 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 845457379} + - component: {fileID: 845457381} + - component: {fileID: 845457380} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &845457379 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 845457378} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1444703250} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &845457380 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 845457378} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter initial point... +--- !u!222 &845457381 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 845457378} + m_CullTransparentMesh: 0 +--- !u!1 &846219421 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 846219422} + - component: {fileID: 846219424} + - component: {fileID: 846219423} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &846219422 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 846219421} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 638408136} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &846219423 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 846219421} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &846219424 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 846219421} + m_CullTransparentMesh: 0 +--- !u!1 &874769203 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 874769204} + - component: {fileID: 874769206} + - component: {fileID: 874769205} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &874769204 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 874769203} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 629087869} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &874769205 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 874769203} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Exit The Program +--- !u!222 &874769206 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 874769203} + m_CullTransparentMesh: 0 +--- !u!1 &883764592 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 883764593} + - component: {fileID: 883764595} + - component: {fileID: 883764594} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &883764593 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 883764592} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 328073363} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &883764594 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 883764592} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Equation Root Finder +--- !u!222 &883764595 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 883764592} + m_CullTransparentMesh: 0 +--- !u!1 &888673476 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 888673477} + - component: {fileID: 888673480} + - component: {fileID: 888673479} + - component: {fileID: 888673478} + m_Layer: 5 + m_Name: INPTEqVariable + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &888673477 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 888673476} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2028830165} + - {fileID: 569911635} + m_Father: {fileID: 1907570698} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -322.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &888673478 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 888673476} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 888673479} + m_TextComponent: {fileID: 569911636} + m_Placeholder: {fileID: 2028830166} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &888673479 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 888673476} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &888673480 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 888673476} + m_CullTransparentMesh: 0 +--- !u!1 &899715281 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 899715282} + - component: {fileID: 899715285} + - component: {fileID: 899715284} + - component: {fileID: 899715283} + m_Layer: 5 + m_Name: BTNEquationSystemSolver + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &899715282 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 899715281} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1766547803} + m_Father: {fileID: 34561382} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &899715283 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 899715281} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 899715284} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: BTNEquationSystemSolver + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &899715284 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 899715281} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &899715285 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 899715281} + m_CullTransparentMesh: 0 +--- !u!1 &910077612 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 910077613} + - component: {fileID: 910077615} + - component: {fileID: 910077614} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &910077613 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 910077612} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1053954607} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &910077614 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 910077612} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Count +--- !u!222 &910077615 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 910077612} + m_CullTransparentMesh: 0 +--- !u!1 &963194225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 963194228} + - component: {fileID: 963194227} + - component: {fileID: 963194226} + - component: {fileID: 963194230} + - component: {fileID: 963194229} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &963194226 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 +--- !u!20 &963194227 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.09198114, g: 0.31610247, b: 0.5, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &963194228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &963194229 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a1b44d2e6ad183849baa8b9136dac8ab, type: 3} + m_Name: + m_EditorClassIdentifier: + PNLMainMenu: {fileID: 34561381} + PNLEquationRootFinder: {fileID: 1868945795} + PNLEquationSystemSolver: {fileID: 1029743021} + INPTEquation: {fileID: 411623340} + INPTMinX: {fileID: 799977581} + INPTMaxX: {fileID: 1540279551} + INPTRoot: {fileID: 1524345884} + INPTRoots: {fileID: 1581354700} + TGLNewtonRaphson: {fileID: 1624308492} + INPTNRInitialPoint: {fileID: 1444703249} + INPTEqVariable: {fileID: 888673476} + INPTIterationCount: {fileID: 806293294} + INPTEquationCount: {fileID: 1053954606} + INPTEquationPrefab: {fileID: 985874967725327420, guid: fccb4ef9675556c439d94f41f15a8e1a, + type: 3} + INPTVariablePrefab: {fileID: 2006212224861606530, guid: e7b5d763b32e0e44494864207f0d5275, + type: 3} + INPTInitialPointPrefab: {fileID: 2895230885503808811, guid: dce03982ff0627e459979d3e508a5463, + type: 3} + ESEquationParent: {fileID: 1317693095} + ESVariableParent: {fileID: 1606950417} + ESInitialPointParent: {fileID: 1141229487} + INPTESIterationCount: {fileID: 638408135} + INPTRootText: 0 + INPTRootsText: 0 + isNewtonRaphson: 1 +--- !u!114 &963194230 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d781ba518f05a794a879f2df79d6c6b8, type: 3} + m_Name: + m_EditorClassIdentifier: + Check: 0 + MainEquation1: cos(x) + MainEquation2: '7 * cos(323,18) + 18 * cos(x) - 16 - 11 * cos(y) ' + MainEquation3: 7 * sin(323,18) + 18 * sin(x) - 11 * sin(y) + MainEquation4: + MainEquation5: + Count: 6 + var1: 1 + var2: 0 + Equations: + - 3-x^2-y*z + - x-y+z+1 + - x^3-y*z-1 + VariableNames: + - x + - y + VariableInitialValues: + - 2 + - 1 +--- !u!1 &1029743021 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1029743022} + - component: {fileID: 1029743025} + - component: {fileID: 1029743024} + m_Layer: 5 + m_Name: PNLEquationSystemSolver + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1029743022 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1029743021} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 245101419} + - {fileID: 1581354701} + - {fileID: 567324289} + m_Father: {fileID: 1141753987} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1029743024 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1029743021} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1029743025 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1029743021} + m_CullTransparentMesh: 0 +--- !u!1 &1053954606 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1053954607} + - component: {fileID: 1053954610} + - component: {fileID: 1053954609} + - component: {fileID: 1053954608} + m_Layer: 5 + m_Name: INPTEquationCount + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1053954607 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1053954606} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 910077613} + - {fileID: 1112282458} + m_Father: {fileID: 245101419} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 104.43982, y: -112.5} + m_SizeDelta: {x: 140, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1053954608 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1053954606} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1053954609} + m_TextComponent: {fileID: 1112282459} + m_Placeholder: {fileID: 910077614} + m_ContentType: 2 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 4 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 1 + m_CharacterLimit: 1 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: INPTEquationCountChanged + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: 0 + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &1053954609 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1053954606} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1053954610 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1053954606} + m_CullTransparentMesh: 0 +--- !u!1 &1055913198 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1055913199} + - component: {fileID: 1055913201} + - component: {fileID: 1055913200} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1055913199 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1055913198} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1444703250} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1055913200 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1055913198} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &1055913201 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1055913198} + m_CullTransparentMesh: 0 +--- !u!1 &1112282457 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1112282458} + - component: {fileID: 1112282460} + - component: {fileID: 1112282459} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1112282458 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1112282457} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1053954607} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1112282459 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1112282457} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 0 +--- !u!222 &1112282460 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1112282457} + m_CullTransparentMesh: 0 +--- !u!1 &1141229487 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1141229488} + - component: {fileID: 1141229491} + - component: {fileID: 1141229490} + - component: {fileID: 1141229489} + m_Layer: 5 + m_Name: PNLInitialPoints + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1141229488 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141229487} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 245101419} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1385.4398, y: -75} + m_SizeDelta: {x: 300, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1141229489 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141229487} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 100 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 1 + m_Spacing: 10 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 +--- !u!114 &1141229490 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141229487} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1141229491 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141229487} + m_CullTransparentMesh: 0 +--- !u!1 &1141753983 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1141753987} + - component: {fileID: 1141753986} + - component: {fileID: 1141753985} + - component: {fileID: 1141753984} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1141753984 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141753983} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1141753985 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141753983} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1920, y: 1080} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0.5 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1141753986 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141753983} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1141753987 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1141753983} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 34561382} + - {fileID: 1868945796} + - {fileID: 1029743022} + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1252492428 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1252492429} + - component: {fileID: 1252492431} + - component: {fileID: 1252492430} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1252492429 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1252492428} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1524345885} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1252492430 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1252492428} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Root... +--- !u!222 &1252492431 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1252492428} + m_CullTransparentMesh: 0 +--- !u!1 &1297439217 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1297439218} + - component: {fileID: 1297439221} + - component: {fileID: 1297439220} + - component: {fileID: 1297439219} + m_Layer: 5 + m_Name: BTNMainMenuERF + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1297439218 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1297439217} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1367227987} + m_Father: {fileID: 1868945796} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 60, y: 60} + m_Pivot: {x: 1, y: 1} +--- !u!114 &1297439219 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1297439217} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1297439220} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: BTNMainMenuERF + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &1297439220 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1297439217} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1297439221 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1297439217} + m_CullTransparentMesh: 0 +--- !u!1 &1317693095 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1317693096} + - component: {fileID: 1317693099} + - component: {fileID: 1317693098} + - component: {fileID: 1317693097} + m_Layer: 5 + m_Name: PNLEquations + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1317693096 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1317693095} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 245101419} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 735.4398, y: -75} + m_SizeDelta: {x: 400, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1317693097 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1317693095} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 150 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 1 + m_Spacing: 10 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 +--- !u!114 &1317693098 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1317693095} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1317693099 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1317693095} + m_CullTransparentMesh: 0 +--- !u!1 &1367227986 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1367227987} + - component: {fileID: 1367227989} + - component: {fileID: 1367227988} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1367227987 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1367227986} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1297439218} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1367227988 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1367227986} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: X +--- !u!222 &1367227989 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1367227986} + m_CullTransparentMesh: 0 +--- !u!1 &1419820220 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1419820221} + - component: {fileID: 1419820223} + - component: {fileID: 1419820222} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1419820221 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1419820220} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 50727099} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -0.000015258789, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1419820222 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1419820220} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 30 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Bisection Method +--- !u!222 &1419820223 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1419820220} + m_CullTransparentMesh: 0 +--- !u!1 &1444703249 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1444703250} + - component: {fileID: 1444703253} + - component: {fileID: 1444703252} + - component: {fileID: 1444703251} + m_Layer: 5 + m_Name: INPTNRInitialPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1444703250 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1444703249} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 845457379} + - {fileID: 1055913199} + m_Father: {fileID: 1907570698} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -492.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1444703251 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1444703249} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1444703252} + m_TextComponent: {fileID: 1055913200} + m_Placeholder: {fileID: 845457380} + m_ContentType: 3 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 2 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 2 + m_CharacterLimit: 7 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &1444703252 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1444703249} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1444703253 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1444703249} + m_CullTransparentMesh: 0 +--- !u!1 &1524345884 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1524345885} + - component: {fileID: 1524345888} + - component: {fileID: 1524345887} + - component: {fileID: 1524345886} + m_Layer: 5 + m_Name: INPTRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1524345885 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1524345884} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1252492429} + - {fileID: 1833779187} + m_Father: {fileID: 1868945796} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: 0, y: 25} + m_SizeDelta: {x: -50, y: 75} + m_Pivot: {x: 0.5, y: 0} +--- !u!114 &1524345886 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1524345884} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1524345887} + m_TextComponent: {fileID: 1833779188} + m_Placeholder: {fileID: 1252492430} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 0} + m_MethodName: + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &1524345887 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1524345884} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1524345888 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1524345884} + m_CullTransparentMesh: 0 +--- !u!1 &1540279551 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1540279552} + - component: {fileID: 1540279555} + - component: {fileID: 1540279554} + - component: {fileID: 1540279553} + m_Layer: 5 + m_Name: INPTMaxX + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1540279552 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1540279551} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1840436160} + - {fileID: 795806525} + m_Father: {fileID: 1907570698} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1184.2655, y: -507.5} + m_SizeDelta: {x: 500, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1540279553 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1540279551} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1540279554} + m_TextComponent: {fileID: 795806526} + m_Placeholder: {fileID: 1840436161} + m_ContentType: 3 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 2 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 2 + m_CharacterLimit: 7 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &1540279554 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1540279551} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1540279555 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1540279551} + m_CullTransparentMesh: 0 +--- !u!1 &1581354700 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1581354701} + - component: {fileID: 1581354704} + - component: {fileID: 1581354703} + - component: {fileID: 1581354702} + m_Layer: 5 + m_Name: INPTRoots + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1581354701 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1581354700} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1913574580} + - {fileID: 708662514} + m_Father: {fileID: 1029743022} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: 0, y: 25} + m_SizeDelta: {x: -50, y: 75} + m_Pivot: {x: 0.5, y: 0} +--- !u!114 &1581354702 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1581354700} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1581354703} + m_TextComponent: {fileID: 708662515} + m_Placeholder: {fileID: 1913574581} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &1581354703 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1581354700} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1581354704 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1581354700} + m_CullTransparentMesh: 0 +--- !u!1 &1606950417 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1606950418} + - component: {fileID: 1606950421} + - component: {fileID: 1606950420} + - component: {fileID: 1606950419} + m_Layer: 5 + m_Name: PNLVariables + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1606950418 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606950417} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 245101419} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1085.4398, y: -75} + m_SizeDelta: {x: 200, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1606950419 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606950417} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 250 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 1 + m_Spacing: 10 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 +--- !u!114 &1606950420 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606950417} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1606950421 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606950417} + m_CullTransparentMesh: 0 +--- !u!1 &1624308492 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1624308493} + - component: {fileID: 1624308494} + m_Layer: 5 + m_Name: TGLNewton-Raphson + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1624308493 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1624308492} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 275540147} + - {fileID: 753423721} + m_Father: {fileID: 1681187904} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 350, y: 75} + m_Pivot: {x: 0, y: 0.5} +--- !u!114 &1624308494 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1624308492} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 275540148} + toggleTransition: 1 + graphic: {fileID: 1869820024} + m_Group: {fileID: 1681187905} + onValueChanged: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: TGLNewtonRaphsonBisection + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_IsOn: 1 +--- !u!1 &1675034106 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1675034107} + - component: {fileID: 1675034110} + - component: {fileID: 1675034109} + - component: {fileID: 1675034108} + m_Layer: 5 + m_Name: BTNFindEquationSystemRoots + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1675034107 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1675034106} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 734743534} + m_Father: {fileID: 245101419} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1735.4398, y: -112.5} + m_SizeDelta: {x: 300, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1675034108 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1675034106} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9811321, g: 0.5970096, b: 0.87562877, a: 1} + m_PressedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_SelectedColor: {r: 0.85882354, g: 0.27058825, b: 1, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1675034109} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 963194229} + m_MethodName: BTNFindEquationSystemRoots + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &1675034109 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1675034106} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1675034110 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1675034106} + m_CullTransparentMesh: 0 +--- !u!1 &1681187903 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1681187904} + - component: {fileID: 1681187905} + m_Layer: 5 + m_Name: ToggleGroup + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1681187904 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1681187903} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1624308493} + - {fileID: 50727099} + m_Father: {fileID: 1868945796} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 700, y: 75} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &1681187905 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1681187903} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2fafe2cfe61f6974895a912c3755e8f1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AllowSwitchOff: 0 +--- !u!1 &1686026806 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1686026807} + - component: {fileID: 1686026809} + - component: {fileID: 1686026808} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1686026807 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1686026806} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 468073319} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1686026808 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1686026806} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Find Root +--- !u!222 &1686026809 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1686026806} + m_CullTransparentMesh: 0 +--- !u!1 &1753560744 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1753560745} + - component: {fileID: 1753560747} + - component: {fileID: 1753560746} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1753560745 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1753560744} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 411623341} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1753560746 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1753560744} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &1753560747 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1753560744} + m_CullTransparentMesh: 0 +--- !u!1 &1766547802 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1766547803} + - component: {fileID: 1766547805} + - component: {fileID: 1766547804} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1766547803 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1766547802} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 899715282} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1766547804 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1766547802} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Equation System Solver +--- !u!222 &1766547805 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1766547802} + m_CullTransparentMesh: 0 +--- !u!1 &1825719251 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1825719252} + - component: {fileID: 1825719254} + - component: {fileID: 1825719253} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1825719252 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1825719251} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 638408136} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1825719253 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1825719251} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Iteration count... +--- !u!222 &1825719254 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1825719251} + m_CullTransparentMesh: 0 +--- !u!1 &1826328022 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1826328023} + - component: {fileID: 1826328025} + - component: {fileID: 1826328024} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1826328023 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1826328022} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 560263401} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0.000015258789, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1826328024 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1826328022} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1826328025 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1826328022} + m_CullTransparentMesh: 0 +--- !u!1 &1833779186 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1833779187} + - component: {fileID: 1833779189} + - component: {fileID: 1833779188} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1833779187 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1833779186} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1524345885} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1833779188 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1833779186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &1833779189 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1833779186} + m_CullTransparentMesh: 0 +--- !u!1 &1840436159 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1840436160} + - component: {fileID: 1840436162} + - component: {fileID: 1840436161} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1840436160 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1840436159} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1540279552} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1840436161 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1840436159} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter maximum x coordinate... +--- !u!222 &1840436162 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1840436159} + m_CullTransparentMesh: 0 +--- !u!1 &1868945795 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1868945796} + - component: {fileID: 1868945798} + - component: {fileID: 1868945797} + m_Layer: 5 + m_Name: PNLEquationRootFinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1868945796 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1868945795} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1681187904} + - {fileID: 1907570698} + - {fileID: 1524345885} + - {fileID: 1297439218} + m_Father: {fileID: 1141753987} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1868945797 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1868945795} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1868945798 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1868945795} + m_CullTransparentMesh: 0 +--- !u!1 &1869820022 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1869820023} + - component: {fileID: 1869820025} + - component: {fileID: 1869820024} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1869820023 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1869820022} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 275540147} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0.000015258789, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1869820024 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1869820022} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1869820025 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1869820022} + m_CullTransparentMesh: 0 +--- !u!1 &1879957136 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1879957137} + - component: {fileID: 1879957139} + - component: {fileID: 1879957138} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1879957137 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1879957136} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 806293295} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1879957138 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1879957136} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter iteration count... +--- !u!222 &1879957139 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1879957136} + m_CullTransparentMesh: 0 +--- !u!1 &1907570697 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1907570698} + - component: {fileID: 1907570699} + m_Layer: 5 + m_Name: RootMenu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1907570698 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1907570697} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 411623341} + - {fileID: 888673477} + - {fileID: 806293295} + - {fileID: 799977582} + - {fileID: 1540279552} + - {fileID: 1444703250} + - {fileID: 468073319} + m_Father: {fileID: 1868945796} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1907570699 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1907570697} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 200 + m_Bottom: 0 + m_ChildAlignment: 1 + m_Spacing: 10 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 +--- !u!1 &1913574579 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1913574580} + - component: {fileID: 1913574582} + - component: {fileID: 1913574581} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1913574580 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1913574579} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1581354701} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1913574581 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1913574579} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Roots... +--- !u!222 &1913574582 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1913574579} + m_CullTransparentMesh: 0 +--- !u!1 &1960048560 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1960048561} + - component: {fileID: 1960048563} + - component: {fileID: 1960048562} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1960048561 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960048560} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 799977582} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1960048562 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960048560} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter minimum x coordinate... +--- !u!222 &1960048563 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960048560} + m_CullTransparentMesh: 0 +--- !u!1 &2028830164 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2028830165} + - component: {fileID: 2028830167} + - component: {fileID: 2028830166} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2028830165 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028830164} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 888673477} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2028830166 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028830164} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter variable... +--- !u!222 &2028830167 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028830164} + m_CullTransparentMesh: 0 +--- !u!1 &2117349377 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2117349378} + - component: {fileID: 2117349380} + - component: {fileID: 2117349379} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2117349378 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2117349377} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 411623341} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2117349379 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2117349377} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter equation... +--- !u!222 &2117349380 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2117349377} + m_CullTransparentMesh: 0 diff --git a/Assets/Scenes/SampleScene.unity.meta b/Assets/Scenes/SampleScene.unity.meta new file mode 100644 index 0000000..952bd1e --- /dev/null +++ b/Assets/Scenes/SampleScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9fc0d4010bbf28b4594072e72b8655ab +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts.meta b/Assets/Scripts.meta new file mode 100644 index 0000000..f19519b --- /dev/null +++ b/Assets/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45eed84873cca754480c39540b8f1e50 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/DecimalMath.cs b/Assets/Scripts/DecimalMath.cs new file mode 100644 index 0000000..04b7b25 --- /dev/null +++ b/Assets/Scripts/DecimalMath.cs @@ -0,0 +1,539 @@ +ïğżusing System; + +/// +/// Analogy of Syatem.Math class for decimal types +/// +public static class DecimalMath +{ + /// + /// represents PI + /// + public const decimal PI = 3.14159265358979323846264338327950288419716939937510M; + + /// + /// represents PI + /// + public const decimal Epsilon = 0.0000000000000000001M; + + /// + /// represents 2*PI + /// + private const decimal PIx2 = 6.28318530717958647692528676655900576839433879875021M; + + /// + /// represents E + /// + public const decimal E = 2.7182818284590452353602874713526624977572470936999595749M; + + /// + /// represents PI/2 + /// + private const decimal PIdiv2 = 1.570796326794896619231321691639751442098584699687552910487M; + + /// + /// represents PI/4 + /// + private const decimal PIdiv4 = 0.785398163397448309615660845819875721049292349843776455243M; + + /// + /// represents 1.0/E + /// + private const decimal Einv = 0.3678794411714423215955237701614608674458111310317678M; + + /// + /// log(10,E) factor + /// + private const decimal Log10Inv = 0.434294481903251827651128918916605082294397005803666566114M; + + /// + /// Zero + /// + public const decimal Zero = 0.0M; + + /// + /// One + /// + public const decimal One = 1.0M; + + /// + /// Represents 0.5M + /// + private const decimal Half = 0.5M; + + /// + /// Max iterations count in Taylor series + /// + private const int MaxIteration = 100; + + /// + /// Analogy of Math.Exp method + /// + /// + /// + public static decimal Exp(decimal x) + { + var count = 0; + + if (x > One) + { + count = decimal.ToInt32(decimal.Truncate(x)); + x -= decimal.Truncate(x); + } + + if (x < Zero) + { + count = decimal.ToInt32(decimal.Truncate(x) - 1); + x = One + (x - decimal.Truncate(x)); + } + + var iteration = 1; + var result = One; + var factorial = One; + decimal cachedResult; + do + { + cachedResult = result; + factorial *= x / iteration++; + result += factorial; + } while (cachedResult != result); + + if (count == 0) + return result; + return result * PowerN(E, count); + } + + /// + /// Analogy of Math.Pow method + /// + /// + /// + /// + public static decimal Pow(decimal value, decimal pow) + { + if (pow == Zero) return One; + if (pow == One) return value; + if (value == One) return One; + + if (value == Zero) + { + if (pow > Zero) + { + return Zero; + } + + throw new Exception("Invalid Operation: zero base and negative power"); + } + + if (pow == -One) return One / value; + + var isPowerInteger = IsInteger(pow); + if (value < Zero && !isPowerInteger) + { + throw new Exception("Invalid Operation: negative base and non-integer power"); + } + + if (isPowerInteger && value > Zero) + { + int powerInt = (int)pow; + return PowerN(value, powerInt); + } + + if (isPowerInteger && value < Zero) + { + int powerInt = (int)pow; + if (powerInt % 2 == 0) + { + return Exp(pow * Log(-value)); + } + + return -Exp(pow * Log(-value)); + } + + return Exp(pow * Log(value)); + } + + private static bool IsInteger(decimal value) + { + var longValue = (long)value; + return Abs(value - longValue) <= Epsilon; + } + + /// + /// Power to the integer value + /// + /// + /// + /// + public static decimal PowerN(decimal value, int power) + { + while (true) + { + if (power == Zero) return One; + if (power < Zero) + { + value = One / value; + power = -power; + continue; + } + + var q = power; + var prod = One; + var current = value; + while (q > 0) + { + if (q % 2 == 1) + { + // detects the 1s in the binary expression of power + prod = current * prod; // picks up the relevant power + q--; + } + + current *= current; // value^i -> value^(2*i) + q >>= 1; + } + + return prod; + } + } + + /// + /// Analogy of Math.Log10 + /// + /// + /// + public static decimal Log10(decimal x) + { + return Log(x) * Log10Inv; + } + + /// + /// Analogy of Math.Log + /// + /// + /// + public static decimal Log(decimal x) + { + if (x <= Zero) + { + throw new ArgumentException("x must be greater than zero"); + } + var count = 0; + while (x >= One) + { + x *= Einv; + count++; + } + while (x <= Einv) + { + x *= E; + count--; + } + x--; + if (x == Zero) return count; + var result = Zero; + var iteration = 0; + var y = One; + var cacheResult = result - One; + while (cacheResult != result && iteration < MaxIteration) + { + iteration++; + cacheResult = result; + y *= -x; + result += y / iteration; + } + return count - result; + } + + /// + /// Analogy of Math.Cos + /// + /// + /// + public static decimal Cos(decimal x) + { + //truncating to [-2*PI;2*PI] + TruncateToPeriodicInterval(ref x); + + // now x in (-2pi,2pi) + if (x >= PI && x <= PIx2) + { + return -Cos(x - PI); + } + if (x >= -PIx2 && x <= -PI) + { + return -Cos(x + PI); + } + + x *= x; + //y=1-x/2!+x^2/4!-x^3/6!... + var xx = -x * Half; + var y = One + xx; + var cachedY = y - One;//init cache with different value + for (var i = 1; cachedY != y && i < MaxIteration; i++) + { + cachedY = y; + decimal factor = i * ((i << 1) + 3) + 1; //2i^2+2i+i+1=2i^2+3i+1 + factor = -Half / factor; + xx *= x * factor; + y += xx; + } + return y; + } + + /// + /// Analogy of Math.Tan + /// + /// + /// + public static decimal Tan(decimal x) + { + var cos = Cos(x); + if (cos == Zero) throw new ArgumentException(nameof(x)); + //calculate sin using cos + var sin = CalculateSinFromCos(x, cos); + return sin / cos; + } + /// + /// Helper function for calculating sin(x) from cos(x) + /// + /// + /// + /// + private static decimal CalculateSinFromCos(decimal x, decimal cos) + { + var moduleOfSin = Sqrt(One - (cos * cos)); + var sineIsPositive = IsSignOfSinePositive(x); + if (sineIsPositive) return moduleOfSin; + return -moduleOfSin; + } + /// + /// Analogy of Math.Sin + /// + /// + /// + public static decimal Sin(decimal x) + { + var cos = Cos(x); + return CalculateSinFromCos(x, cos); + } + + + /// + /// Truncates to [-2*PI;2*PI] + /// + /// + private static void TruncateToPeriodicInterval(ref decimal x) + { + while (x >= PIx2) + { + var divide = Math.Abs(decimal.ToInt32(x / PIx2)); + x -= divide * PIx2; + } + + while (x <= -PIx2) + { + var divide = Math.Abs(decimal.ToInt32(x / PIx2)); + x += divide * PIx2; + } + } + + + private static bool IsSignOfSinePositive(decimal x) + { + //truncating to [-2*PI;2*PI] + TruncateToPeriodicInterval(ref x); + + //now x in [-2*PI;2*PI] + if (x >= -PIx2 && x <= -PI) return true; + if (x >= -PI && x <= Zero) return false; + if (x >= Zero && x <= PI) return true; + if (x >= PI && x <= PIx2) return false; + + //will not be reached + throw new ArgumentException(nameof(x)); + } + + /// + /// Analogy of Math.Sqrt + /// + /// + /// lasts iteration while error less than this epsilon + /// + public static decimal Sqrt(decimal x, decimal epsilon = Zero) + { + if (x < Zero) throw new OverflowException("Cannot calculate square root from a negative number"); + //initial approximation + decimal current = (decimal)Math.Sqrt((double)x), previous; + do + { + previous = current; + if (previous == Zero) return Zero; + current = (previous + x / previous) * Half; + } while (Abs(previous - current) > epsilon); + return current; + } + /// + /// Analogy of Math.Sinh + /// + /// + /// + public static decimal Sinh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y - yy) * Half; + } + + /// + /// Analogy of Math.Cosh + /// + /// + /// + public static decimal Cosh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y + yy) * Half; + } + + /// + /// Analogy of Math.Sign + /// + /// + /// + public static int Sign(decimal x) + { + return x < Zero ? -1 : (x > Zero ? 1 : 0); + } + + /// + /// Analogy of Math.Tanh + /// + /// + /// + public static decimal Tanh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y - yy) / (y + yy); + } + + /// + /// Analogy of Math.Abs + /// + /// + /// + public static decimal Abs(decimal x) + { + if (x <= Zero) + { + return -x; + } + return x; + } + + /// + /// Analogy of Math.Asin + /// + /// + /// + public static decimal Asin(decimal x) + { + if (x > One || x < -One) + { + throw new ArgumentException("x must be in [-1,1]"); + } + //known values + if (x == Zero) return Zero; + if (x == One) return PIdiv2; + //asin function is odd function + if (x < Zero) return -Asin(-x); + + //my optimize trick here + + // used a math formula to speed up : + // asin(x)=0.5*(pi/2-asin(1-2*x*x)) + // if x>=0 is true + + var newX = One - 2 * x * x; + + //for calculating new value near to zero than current + //because we gain more speed with values near to zero + if (Abs(x) > Abs(newX)) + { + var t = Asin(newX); + return Half * (PIdiv2 - t); + } + var y = Zero; + var result = x; + decimal cachedResult; + var i = 1; + y += result; + var xx = x * x; + do + { + cachedResult = result; + result *= xx * (One - Half / (i)); + y += result / ((i << 1) + 1); + i++; + } while (cachedResult != result); + return y; + } + + /// + /// Analogy of Math.Atan + /// + /// + /// + public static decimal Atan(decimal x) + { + if (x == Zero) return Zero; + if (x == One) return PIdiv4; + return Asin(x / Sqrt(One + x * x)); + } + /// + /// Analogy of Math.Acos + /// + /// + /// + public static decimal Acos(decimal x) + { + if (x == Zero) return PIdiv2; + if (x == One) return Zero; + if (x < Zero) return PI - Acos(-x); + return PIdiv2 - Asin(x); + } + + /// + /// Analogy of Math.Atan2 + /// for more see this + /// + /// + /// + /// + /// + public static decimal Atan2(decimal y, decimal x) + { + if (x > Zero) + { + return Atan(y / x); + } + if (x < Zero && y >= Zero) + { + return Atan(y / x) + PI; + } + if (x < Zero && y < Zero) + { + return Atan(y / x) - PI; + } + if (x == Zero && y > Zero) + { + return PIdiv2; + } + if (x == Zero && y < Zero) + { + return -PIdiv2; + } + throw new ArgumentException("invalid atan2 arguments"); + } +} diff --git a/Assets/Scripts/DecimalMath.cs.meta b/Assets/Scripts/DecimalMath.cs.meta new file mode 100644 index 0000000..a6da59e --- /dev/null +++ b/Assets/Scripts/DecimalMath.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bcc23a5940935d5449776ed5bdf22e57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Function.cs b/Assets/Scripts/Function.cs new file mode 100644 index 0000000..4797899 --- /dev/null +++ b/Assets/Scripts/Function.cs @@ -0,0 +1,720 @@ +ïğżusing System; +using System.Collections; +using System.Collections.Generic; + + +/// +/// +/// +public enum Type { Variable, Value, UnaryOperator, Operator, Function, Result, Bracket, Comma, Error } +public struct Symbol +{ + public string m_name; + public decimal m_value; + public Type m_type; + public override string ToString() + { + return m_name; + } +} +public delegate Symbol EvaluateFunctionDelegate(string name, params Object[] args); +public class Function +{ + public decimal Result + { + get + { + return m_result; + } + } + + public ArrayList Equation + { + get + { + return (ArrayList)m_equation.Clone(); + } + } + public ArrayList Postfix + { + get + { + return (ArrayList)m_postfix.Clone(); + } + } + + public EvaluateFunctionDelegate DefaultFunctionEvaluation + { + set + { + m_defaultFunctionEvaluation = value; + } + } + + public bool Error + { + get + { + return m_bError; + } + } + + public string ErrorDescription + { + get + { + return m_sErrorDescription; + } + } + + public ArrayList Variables + { + get + { + ArrayList var = new ArrayList(); + foreach (Symbol sym in m_equation) + { + if ((sym.m_type == Type.Variable) && (!var.Contains(sym))) + var.Add(sym); + } + return var; + } + set + { + foreach (Symbol sym in value) + { + for (int i = 0; i < m_postfix.Count; i++) + { + if ((sym.m_name == ((Symbol)m_postfix[i]).m_name) && (((Symbol)m_postfix[i]).m_type == Type.Variable)) + { + Symbol sym1 = (Symbol)m_postfix[i]; + sym1.m_value = sym.m_value; + m_postfix[i] = sym1; + } + } + } + } + } + + public Function() + { } + + public void Parse(string equation) + { + int state = 1; + string temp = ""; + Symbol ctSymbol; + + m_bError = false; + m_sErrorDescription = "None"; + + m_equation.Clear(); + m_postfix.Clear(); + + int nPos = 0; + //-- Remove all white spaces from the equation string -- + equation = equation.Trim(); + while ((nPos = equation.IndexOf(' ')) != -1) + equation = equation.Remove(nPos, 1); + + for (int i = 0; i < equation.Length; i++) + { + switch (state) + { + case 1: + if (Char.IsNumber(equation[i])) + { + state = 2; + temp += equation[i]; + } + else if (Char.IsLetter(equation[i])) + { + state = 3; + temp += equation[i]; + } + else + { + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + case ".": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + } + break; + case 2: + if ((Char.IsNumber(equation[i])) || (equation[i] == '.') || (equation[i] == ',')) + temp += equation[i]; + else if (!Char.IsLetter(equation[i])) + { + state = 1; + ctSymbol.m_name = temp; + ctSymbol.m_value = Decimal.Parse(temp); + ctSymbol.m_type = Type.Value; + m_equation.Add(ctSymbol); + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + temp = ""; + } + break; + case 3: + if (Char.IsLetterOrDigit(equation[i])) + temp += equation[i]; + else + { + state = 1; + ctSymbol.m_name = temp; + ctSymbol.m_value = 0; + if (equation[i] == '(') + ctSymbol.m_type = Type.Function; + else + { + if (ctSymbol.m_name == "pi") + ctSymbol.m_value = DecimalMath.PI; + else if (ctSymbol.m_name == "e") + ctSymbol.m_value = DecimalMath.E; + ctSymbol.m_type = Type.Variable; + } + m_equation.Add(ctSymbol); + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + temp = ""; + } + break; + } + } + if (temp != "") + { + ctSymbol.m_name = temp; + if (state == 2) + { + ctSymbol.m_value = Decimal.Parse(temp); + ctSymbol.m_type = Type.Value; + } + else + { + if (ctSymbol.m_name == "pi") + ctSymbol.m_value = DecimalMath.PI; + else if (ctSymbol.m_name == "e") + ctSymbol.m_value = DecimalMath.E; + else + ctSymbol.m_value = 0; + ctSymbol.m_type = Type.Variable; + } + m_equation.Add(ctSymbol); + } + } + + public void Infix2Postfix() + { + Symbol tpSym; + Stack tpStack = new Stack(); + foreach (Symbol sym in m_equation) + { + if ((sym.m_type == Type.Value) || (sym.m_type == Type.Variable)) + m_postfix.Add(sym); + else if ((sym.m_name == "(") || (sym.m_name == "[") || (sym.m_name == "{")) + tpStack.Push(sym); + else if ((sym.m_name == ")") || (sym.m_name == "]") || (sym.m_name == "}")) + { + if (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + while ((tpSym.m_name != "(") && (tpSym.m_name != "[") && (tpSym.m_name != "{")) + { + m_postfix.Add(tpSym); + tpSym = (Symbol)tpStack.Pop(); + } + } + } + else if (sym.m_type == Type.UnaryOperator) + { + tpStack.Push(sym); + } + else + { + if (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + while ((tpStack.Count != 0) && ((tpSym.m_type == Type.UnaryOperator) || (tpSym.m_type == Type.Operator) || (tpSym.m_type == Type.Function) || (tpSym.m_type == Type.Comma)) && (Precedence(tpSym) >= Precedence(sym))) + { + m_postfix.Add(tpSym); + tpSym = (Symbol)tpStack.Pop(); + } + if (((tpSym.m_type == Type.UnaryOperator) || (tpSym.m_type == Type.Operator) || (tpSym.m_type == Type.Function) || (tpSym.m_type == Type.Comma)) && (Precedence(tpSym) >= Precedence(sym))) + m_postfix.Add(tpSym); + else + tpStack.Push(tpSym); + } + tpStack.Push(sym); + } + } + while (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + m_postfix.Add(tpSym); + } + } + + public void EvaluatePostfix() + { + Symbol tpSym1, tpSym2, tpResult; + Stack tpStack = new Stack(); + ArrayList fnParam = new ArrayList(); + m_bError = false; + foreach (Symbol sym in m_postfix) + { + if ((sym.m_type == Type.Value) || (sym.m_type == Type.Variable) || (sym.m_type == Type.Result)) + tpStack.Push(sym); + else if (sym.m_type == Type.UnaryOperator) + { + tpSym1 = (Symbol)tpStack.Pop(); + tpResult = Evaluate(sym, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (sym.m_type == Type.Operator) + { + tpSym1 = (Symbol)tpStack.Pop(); + tpSym2 = (Symbol)tpStack.Pop(); + tpResult = Evaluate(tpSym2, sym, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (sym.m_type == Type.Comma) + { + tpStack.Push(sym); + } + else if (sym.m_type == Type.Function) + { + fnParam.Clear(); + tpSym1 = (Symbol)tpStack.Pop(); + if ((tpSym1.m_type == Type.Value) || (tpSym1.m_type == Type.Variable) || (tpSym1.m_type == Type.Result)) + { + tpResult = EvaluateFunction(sym.m_name, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (tpSym1.m_type == Type.Comma) + { + while (tpSym1.m_type == Type.Comma) + { + tpSym1 = (Symbol)tpStack.Pop(); + fnParam.Add(tpSym1); + tpSym1 = (Symbol)tpStack.Pop(); + } + fnParam.Add(tpSym1); + tpResult = EvaluateFunction(sym.m_name, fnParam.ToArray()); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else + { + tpStack.Push(tpSym1); + tpResult = EvaluateFunction(sym.m_name); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + } + } + if (tpStack.Count == 1) + { + tpResult = (Symbol)tpStack.Pop(); + m_result = tpResult.m_value; + } + } + + protected int Precedence(Symbol sym) + { + switch (sym.m_type) + { + case Type.Bracket: + return 7; + case Type.Function: + return 5; + case Type.UnaryOperator: + return 4; + case Type.Comma: + return 0; + } + switch (sym.m_name) + { + case "^": + return 3; + case "/": + case "*": + case "%": + return 2; + case "+": + case "-": + return 1; + } + return -1; + } + + protected Symbol Evaluate(Symbol opr, Symbol sym1) + { + Symbol result; + result.m_name = opr.m_name + sym1.m_name; + result.m_type = Type.Result; + result.m_value = 0; + switch (opr.m_name) + { + case "+": + result.m_value = sym1.m_value; ; + break; + case "-": + result.m_value = -1 * sym1.m_value; + break; + default: + result.m_type = Type.Error; + result.m_name = "Undefine unary operator: " + opr.m_name + "."; + break; + } + return result; + } + + protected Symbol Evaluate(Symbol sym1, Symbol opr, Symbol sym2) + { + Symbol result; + result.m_name = sym1.m_name + opr.m_name + sym2.m_name; + result.m_type = Type.Result; + result.m_value = 0; + switch (opr.m_name) + { + case "^": + result.m_value = DecimalMath.Pow(sym1.m_value, sym2.m_value); + break; + case "/": + { + if (sym2.m_value != 0) + result.m_value = sym1.m_value / sym2.m_value; + else + { + result.m_name = "Divide by Zero."; + result.m_type = Type.Error; + } + break; + } + case "*": + result.m_value = sym1.m_value * sym2.m_value; + break; + case "%": + result.m_value = sym1.m_value % sym2.m_value; + break; + case "+": + result.m_value = sym1.m_value + sym2.m_value; + break; + case "-": + result.m_value = sym1.m_value - sym2.m_value; + break; + default: + result.m_type = Type.Error; + result.m_name = "Undefine operator: " + opr.m_name + "."; + break; + } + return result; + } + + protected Symbol EvaluateFunction(string name, params Object[] args) + { + Symbol result; + result.m_name = ""; + result.m_type = Type.Result; + result.m_value = 0; + switch (name) + { + case "cos": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Cos(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sin": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sin(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "tan": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Tan(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "cosh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Cosh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sinh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sinh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "tanh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Tanh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "log": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log10(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "ln": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "logn": + if (args.Length == 2) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + "'" + ((Symbol)args[1]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sqrt": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sqrt(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "abs": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Abs(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "acos": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Acos(((Symbol)args[0]).m_value) * 180 / DecimalMath.PI; + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "asin": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Asin(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "atan": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Atan(((Symbol)args[0]).m_value) * 180 / DecimalMath.PI; + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "exp": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Exp(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + default: + if (m_defaultFunctionEvaluation != null) + result = m_defaultFunctionEvaluation(name, args); + else + { + result.m_name = "Function: " + name + ", not found."; + result.m_type = Type.Error; + } + break; + } + return result; + } + + protected bool m_bError = false; + protected string m_sErrorDescription = "None"; + public decimal m_result = 0; + public ArrayList m_equation = new ArrayList(); + public ArrayList m_postfix = new ArrayList(); + protected EvaluateFunctionDelegate m_defaultFunctionEvaluation; +} diff --git a/Assets/Scripts/Function.cs.meta b/Assets/Scripts/Function.cs.meta new file mode 100644 index 0000000..64d909f --- /dev/null +++ b/Assets/Scripts/Function.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4624df48b44672048904abdf49a34331 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FunctionEvaluator.cs b/Assets/Scripts/FunctionEvaluator.cs new file mode 100644 index 0000000..d40fe02 --- /dev/null +++ b/Assets/Scripts/FunctionEvaluator.cs @@ -0,0 +1,171 @@ +ïğżusing System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[System.Serializable] +public class FunctionEvaluator : MonoBehaviour +{ + public bool Check = false; + public string MainEquation1, MainEquation2, MainEquation3, MainEquation4, MainEquation5; + public int Count; + public double var1; + public int var2; + + + public List Equations = new List(), VariableNames = new List(); + public List VariableInitialValues = new List(); + + Dictionary dict = new Dictionary(); + + + private void Update() + { + if (Check) + { + Check = false; + + //Debug.Log(NumericalMethods.Method_Derivative(MainEquation1, var1, "x", 0).ToString("0." + new string('#', 339))); + //Debug.Log(NumericalMethods.Method_TaylorSeries(MainEquation1, 6, "x", 0)); + + dict.Clear(); + for (int i = 0; i < VariableNames.Count; i++) + { + dict.Add(VariableNames[i], (decimal)VariableInitialValues[i]); + } + + Debug.Log(DecimalMath.Cos(90)); + string res = NumericalMethods.Method_TaylorSeries(MainEquation1, Count, "x", 1, 0.01m).Replace(',', '.'); + Debug.Log(res); + + + + //Debug.Log(NumericalMethods.Method_NumericalPartialDifferentiation("x^2+2*x*y", 2, "x", dict, 6, 0.01m)); + //Debug.Log(NumericalMethods.Method_NumericalDifferentiation("log(x)", 3, "x", 2, 2)); + + /*Dictionary results = NumericalMethods.MethodMultiVar_SolveEquationSystem(Equations, dict, Count); + + string sum = ""; + foreach (KeyValuePair p in results) + { + sum += p.Key + ": " + p.Value + ", "; + } + Debug.Log(sum);*/ + + + + + /*string res = NumericalMethods.Method_TaylorSeries(MainEquation1, Count, "x", 0).Replace(',', '.'); + Debug.Log(res);*/ + + //Debug.Log(NumericalMethods.Method_Derivative(MainEquation1, Count, "x", (decimal)var1)); + + + //Debug.Log(NumericalMethods.Method_BisectionMethod(MainEquation1, "x", -4, -2, 20)); + + + + + /*Dictionary root = NumericalMethods.MethodMultiVar_BisectionMethod(new List { MainEquation1, MainEquation2 }, new List { "x", "y" }, var1, var2, taylorCount); + foreach (KeyValuePair r in root) + { + Debug.Log(r.Key + ": " + r.Value); + }*/ + + + + + + /*string str = NumericalMethods.GenerateCombinations("-+", "s", 3); + Debug.Log(str); + string[] test = str.Split('s'); + + string str2 = ""; + for (int i = 0; i < test.Length; i++) + { + str2 += test[i]; + } + Debug.Log(str2);*/ + + + + + + /*string e1 = NumericalMethods.MethodMultiVar_TaylorSeries(MainEquation1, 1, dict); + string e2 = NumericalMethods.MethodMultiVar_TaylorSeries(MainEquation2, 1, dict); + string e3 = NumericalMethods.MethodMultiVar_TaylorSeries(MainEquation3, 1, dict); + Debug.Log(e1 + " | " + e2 + " | " + e3); + + float[][] tea = new float[][] { new float[] { 3, 7, -2 }, new float[] { -1, 1, 2 }, new float[] { 3, -2, -1 } }; + float[] leftv = new float[] { -5, 2, -1 }; + float[] res = Matrix.SolveEquation(tea, leftv); + string sum = ""; + for (int i = 0; i < res.Length; i++) sum += res[i] + ", "; + Debug.Log(sum);*/ + + + + + + /*Dictionary testt = new Dictionary(); + testt.Add("x", 1); + testt.Add("y", 2); + Debug.Log(NumericalMethods.Method_PartialDerivative("x^(3*y)*y^x", 1, "x", testt, 0.001f));*/ + + + + + /*List LES = new List(); + LES.Add(MainEquation1); + LES.Add(MainEquation2); + LES.Add(MainEquation3); + List VARS = new List(); + VARS.Add("x"); + VARS.Add("y"); + VARS.Add("z"); + float[][] test = Matrix.ConvertLinearEquationsToMatrix(LES, VARS); + + string deb = ""; + for (int i = 0; i < test.Length; i++) + { + for (int j = 0; j < test[i].Length; j++) + { + deb += test[i][j].ToString() + ", "; + } + deb += "\n"; + } + Debug.Log(deb);*/ + + + + + //Debug.Log(NumericalMethods.MethodMultiVar_TaylorSeries(MainEquation2, 1, dict)); + + + + + //Debug.Log(NumericalMethods.Method_PartialDerivative(MainEquation, 1, "x", dict, 0.01f)); + + + + + /*Function f = new Function(); + f.Parse(MainEquation1); + f.Infix2Postfix(); + f.EvaluatePostfix(); + Debug.Log(f.m_result); + + + + + for (int i = 0; i < f.m_equation.Count; i++) + { + Debug.Log("EEEEE: " + f.m_equation[i].ToString()); + } + for (int i = 0; i < f.m_postfix.Count; i++) + { + Debug.Log("PPPPP: " + f.m_postfix[i].ToString()); + }*/ + } + } +} diff --git a/Assets/Scripts/FunctionEvaluator.cs.meta b/Assets/Scripts/FunctionEvaluator.cs.meta new file mode 100644 index 0000000..9fbe38c --- /dev/null +++ b/Assets/Scripts/FunctionEvaluator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d781ba518f05a794a879f2df79d6c6b8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix.cs b/Assets/Scripts/Matrix.cs new file mode 100644 index 0000000..2c529e7 --- /dev/null +++ b/Assets/Scripts/Matrix.cs @@ -0,0 +1,279 @@ +ïğżusing System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Matrix +{ + public static decimal[][] GenerateRandomMatrix(int rows, int columns, decimal min, decimal max) + { + decimal[][] res = new decimal[rows][]; + for (int i = 0; i < rows; i++) + { + res[i] = new decimal[columns]; + for (int j = 0; j < columns; j++) + { + decimal value = (decimal)UnityEngine.Random.Range((float)min, (float)max); + value = (decimal)System.Math.Round(value, 2); + res[i][j] = value; + } + } + return res; + } + + public static decimal[][] Transpoze(decimal[][] _m) + { + decimal[][] res = new decimal[_m[0].Length][]; + for (int i = 0; i < _m[0].Length; i++) + { + res[i] = new decimal[_m.Length]; + } + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + res[j][i] = _m[i][j]; + } + } + return res; + } + + public static decimal MatrixDeterminant(decimal[][] _m) + { + if (_m.Length == _m[0].Length) + { + int c = _m.Length; + if (c == 2) + { + return (decimal)Math.Round(_m[0][0] * _m[1][1] - _m[0][1] * _m[1][0], 5); + } + else if (c == 1) + { + return (decimal)Math.Round(_m[0][0], 5); + } + else if (c == 0) + { + Debug.LogError("Matrix is empty!"); + return 0; + } + else + { + decimal resDet = 0; + for (int i = 0; i < c; i++) + { + for (int j = 0; j < c; j++) + { + decimal[][] newM = new decimal[c - 1][]; + for (int k = 0; k < c - 1; k++) + { + newM[k] = new decimal[c - 1]; + } + + bool isAddedK = false, isAddedL = false; + int offsetK = 0, offsetL = 0; + + for (int k = 0; k < c; k++) + { + isAddedL = false; + offsetL = 0; + for (int l = 0; l < c; l++) + { + if (!(k == i || l == j)) + { + newM[k + offsetK][l + offsetL] = _m[k][l]; + } + else + { + if (!isAddedK && k == i) + { + offsetK = -1; + isAddedK = true; + } + if (!isAddedL && l == j) + { + offsetL = -1; + isAddedL = true; + } + } + } + } + + decimal cofactor = (decimal)Math.Pow(-1, 0 + j + 2) * MatrixDeterminant(newM); + resDet += cofactor * _m[0][j]; + } + } + return (decimal)Math.Round(resDet, 5); + } + } + else + { + Debug.LogError("This matrix is not a square matrix!"); + return 0; + } + } + + public static decimal[] SolveEquation(decimal[][] _m, decimal[] _v) + { + int len = _m.Length; + + decimal[] res = new decimal[len]; + decimal d0 = MatrixDeterminant(_m); + + for (int i = 0; i < len; i++) + { + decimal[][] testMa = new decimal[len][]; + for (int j = 0; j < len; j++) + { + testMa[j] = new decimal[len]; + for (int k = 0; k < len; k++) + { + testMa[j][k] = _m[j][k]; + } + } + for (int j = 0; j < len; j++) + { + testMa[j][i] = _v[j]; + } + decimal di = MatrixDeterminant(testMa); + res[i] = (decimal)Math.Round(di / d0, 5); + } + + return res; + } + + public static decimal[][] ConvertLinearEquationsToMatrix(List equations, List variables) + { + if (equations.Count == variables.Count) + { + decimal[][] res = new decimal[equations.Count][]; + for (int i = 0; i < res.Length; i++) + { + res[i] = new decimal[equations.Count]; + } + for (int i = 0; i < equations.Count; i++) + { + for (int j = 0; j < equations[i].Length; j++) + { + for (int k = 0; k < variables.Count; k++) + { + if (equations[i][j] == variables[k][0]) + { + string coeff = ""; + for (int l = j - 1; l >= 0; l--) + { + if (equations[i][l] != '*' && equations[i][l] != '+' && equations[i][l] != '-') + { + coeff += equations[i][l]; + } + if (equations[i][l] == '-') + { + coeff += '-'; + break; + } + if (equations[i][l] == '+') + { + break; + } + } + char[] charArray = coeff.ToCharArray(); + Array.Reverse(charArray); + coeff = new string(charArray); + res[i][k] = decimal.Parse(coeff); + } + } + } + } + return res; + } + else return null; + } + + public static decimal[][] MatrixMultiplication(decimal[][] _m1, decimal[][] _m2) + { + if (_m1[0].Length == _m2.Length) + { + decimal[][] res = new decimal[_m1.Length][]; + for (int i = 0; i < _m1.Length; i++) + { + res[i] = new decimal[_m2[0].Length]; + } + + for (int i = 0; i < res.Length; i++) + { + for (int j = 0; j < res[0].Length; j++) + { + decimal sum = 0; + for (int k = 0; k < _m2.Length; k++) + { + sum += _m1[i][k] * _m2[k][j]; + } + res[i][j] = sum; + } + } + return res; + } + else + { + Debug.LogError("Matrices cannot be multiplied!"); + return null; + } + } + public static decimal[][] MatrixMultiplication(decimal[][] _m, decimal _c) + { + decimal[][] res = _m; + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + res[i][j] *= _c; + } + } + return res; + } + + public static decimal[] TurnListToVector(List _vec) + { + decimal[] res = new decimal[_vec.Count]; + for (int i = 0; i < _vec.Count; i++) + { + res[i] = _vec[i]; + } + return res; + } + public static decimal[][] TurnListToMatrix(List> _m) + { + decimal[][] res = new decimal[_m.Count][]; + for (int i = 0; i < _m.Count; i++) + { + res[i] = new decimal[_m[i].Count]; + for (int j = 0; j < _m[i].Count; j++) + { + res[i][j] = _m[i][j]; + } + } + return res; + } + + public static string DebugMatrix(decimal[][] _m, string _sep = " ") + { + string sum = ""; + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + sum += _m[i][j] + ((j == _m[0].Length - 1) ? "\n" : _sep); + } + } + return sum; + } + public static string DebugVector(decimal[] _v, string _sep = " ") + { + string sum = ""; + for (int i = 0; i < _v.Length; i++) + { + sum += _v[i] + "\n"; + } + return sum; + } + +} diff --git a/Assets/Scripts/Matrix.cs.meta b/Assets/Scripts/Matrix.cs.meta new file mode 100644 index 0000000..0fed70c --- /dev/null +++ b/Assets/Scripts/Matrix.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2462d4b55c2c2d3438a6fc61d3b6445a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix.meta b/Assets/Scripts/Matrix.meta new file mode 100644 index 0000000..cda9d86 --- /dev/null +++ b/Assets/Scripts/Matrix.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf225744eb8d4a743bc0a97d95a0d137 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix/CholeskyDecomposition.cs b/Assets/Scripts/Matrix/CholeskyDecomposition.cs new file mode 100644 index 0000000..382c612 --- /dev/null +++ b/Assets/Scripts/Matrix/CholeskyDecomposition.cs @@ -0,0 +1,174 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// Cholesky Decomposition. + /// For a symmetric, positive definite matrix A, the Cholesky decomposition + /// is an lower triangular matrix L so that A = L*L'. + /// If the matrix is not symmetric or positive definite, the constructor + /// returns a partial decomposition and sets an internal flag that may + /// be queried by the isSPD() method. + /// + + [Serializable] + public class CholeskyDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] L; + + /// Row and column dimension (square matrix). + /// @serial matrix dimension. + /// + private int n; + + /// Symmetric and positive definite flag. + /// @serial is symmetric and positive definite flag. + /// + private bool isspd; + + #endregion // Class variables + + #region Constructor + + /// Cholesky algorithm for symmetric and positive definite matrix. + /// Square, symmetric matrix. + /// + /// Structure to access L and isspd flag. + /// + + public CholeskyDecomposition(GeneralMatrix Arg) + { + // Initialize. + decimal[][] A = Arg.Array; + n = Arg.RowDimension; + L = new decimal[n][]; + for (int i = 0; i < n; i++) + { + L[i] = new decimal[n]; + } + isspd = (Arg.ColumnDimension == n); + // Main loop. + for (int j = 0; j < n; j++) + { + decimal[] Lrowj = L[j]; + decimal d = 0.0m; + for (int k = 0; k < j; k++) + { + decimal[] Lrowk = L[k]; + decimal s = 0.0m; + for (int i = 0; i < k; i++) + { + s += Lrowk[i] * Lrowj[i]; + } + Lrowj[k] = s = (A[j][k] - s) / L[k][k]; + d = d + s * s; + isspd = isspd & (A[k][j] == A[j][k]); + } + d = A[j][j] - d; + isspd = isspd & (d > 0.0m); + L[j][j] = (decimal)Math.Sqrt(Math.Max((double)d, 0)); + for (int k = j + 1; k < n; k++) + { + L[j][k] = 0.0m; + } + } + } + + #endregion // Constructor + + #region Public Properties + /// Is the matrix symmetric and positive definite? + /// true if A is symmetric and positive definite. + /// + virtual public bool SPD + { + get + { + return isspd; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Return triangular factor. + /// L + /// + + public virtual GeneralMatrix GetL() + { + return new GeneralMatrix(L, n, n); + } + + /// Solve A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X so that L*L'*X = B + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is not symmetric positive definite. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != n) + { + throw new System.ArgumentException("Matrix row dimensions must agree."); + } + if (!isspd) + { + throw new System.SystemException("Matrix is not symmetric positive definite."); + } + + // Copy right hand side. + decimal[][] X = B.ArrayCopy; + int nx = B.ColumnDimension; + + // Solve L*Y = B; + for (int k = 0; k < n; k++) + { + for (int i = k + 1; i < n; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * L[i][k]; + } + } + for (int j = 0; j < nx; j++) + { + X[k][j] /= L[k][k]; + } + } + + // Solve L'*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= L[k][k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * L[k][i]; + } + } + } + return new GeneralMatrix(X, n, nx); + } + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Matrix/CholeskyDecomposition.cs.meta b/Assets/Scripts/Matrix/CholeskyDecomposition.cs.meta new file mode 100644 index 0000000..9e5c339 --- /dev/null +++ b/Assets/Scripts/Matrix/CholeskyDecomposition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e3a2b7302aee27d49b7dae10fc2c43b2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix/EigenvalueDecomposition.cs b/Assets/Scripts/Matrix/EigenvalueDecomposition.cs new file mode 100644 index 0000000..e1263ab --- /dev/null +++ b/Assets/Scripts/Matrix/EigenvalueDecomposition.cs @@ -0,0 +1,1143 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// Eigenvalues and eigenvectors of a real matrix. + /// If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is + /// diagonal and the eigenvector matrix V is orthogonal. + /// I.e. A = V.Multiply(D.Multiply(V.Transpose())) and + /// V.Multiply(V.Transpose()) equals the identity matrix. + /// If A is not symmetric, then the eigenvalue matrix D is block diagonal + /// with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, + /// lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The + /// columns of V represent the eigenvectors in the sense that A*V = V*D, + /// i.e. A.Multiply(V) equals V.Multiply(D). The matrix V may be badly + /// conditioned, or even singular, so the validity of the equation + /// A = V*D*Inverse(V) depends upon V.cond(). + /// + /// + + [Serializable] + public class EigenvalueDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Row and column dimension (square matrix). + /// @serial matrix dimension. + /// + private int n; + + /// Symmetry flag. + /// @serial internal symmetry flag. + /// + private bool issymmetric; + + /// Arrays for internal storage of eigenvalues. + /// @serial internal storage of eigenvalues. + /// + private decimal[] d, e; + + /// Array for internal storage of eigenvectors. + /// @serial internal storage of eigenvectors. + /// + private decimal[][] V; + + /// Array for internal storage of nonsymmetric Hessenberg form. + /// @serial internal storage of nonsymmetric Hessenberg form. + /// + private decimal[][] H; + + /// Working storage for nonsymmetric algorithm. + /// @serial working storage for nonsymmetric algorithm. + /// + private decimal[] ort; + + #endregion // Class variables + + #region Private Methods + + // Symmetric Householder reduction to tridiagonal form. + + private void tred2() + { + // This is derived from the Algol procedures tred2 by + // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for + // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. + + for (int j = 0; j < n; j++) + { + d[j] = V[n - 1][j]; + } + + // Householder reduction to tridiagonal form. + + for (int i = n - 1; i > 0; i--) + { + // Scale to avoid under/overflow. + + decimal scale = 0.0m; + decimal h = 0.0m; + for (int k = 0; k < i; k++) + { + scale = scale + System.Math.Abs(d[k]); + } + if (scale == 0.0m) + { + e[i] = d[i - 1]; + for (int j = 0; j < i; j++) + { + d[j] = V[i - 1][j]; + V[i][j] = 0.0m; + V[j][i] = 0.0m; + } + } + else + { + // Generate Householder vector. + + for (int k = 0; k < i; k++) + { + d[k] /= scale; + h += d[k] * d[k]; + } + decimal f = d[i - 1]; + decimal g = (decimal)DecimalMath.Sqrt(h); + if (f > 0) + { + g = - g; + } + e[i] = scale * g; + h = h - f * g; + d[i - 1] = f - g; + for (int j = 0; j < i; j++) + { + e[j] = 0.0m; + } + + // Apply similarity transformation to remaining columns. + + for (int j = 0; j < i; j++) + { + f = d[j]; + V[j][i] = f; + g = e[j] + V[j][j] * f; + for (int k = j + 1; k <= i - 1; k++) + { + g += V[k][j] * d[k]; + e[k] += V[k][j] * f; + } + e[j] = g; + } + f = 0.0m; + for (int j = 0; j < i; j++) + { + e[j] /= h; + f += e[j] * d[j]; + } + decimal hh = f / (h + h); + for (int j = 0; j < i; j++) + { + e[j] -= hh * d[j]; + } + for (int j = 0; j < i; j++) + { + f = d[j]; + g = e[j]; + for (int k = j; k <= i - 1; k++) + { + V[k][j] -= (f * e[k] + g * d[k]); + } + d[j] = V[i - 1][j]; + V[i][j] = 0.0m; + } + } + d[i] = h; + } + + // Accumulate transformations. + + for (int i = 0; i < n - 1; i++) + { + V[n - 1][i] = V[i][i]; + V[i][i] = 1.0m; + decimal h = d[i + 1]; + if (h != 0.0m) + { + for (int k = 0; k <= i; k++) + { + d[k] = V[k][i + 1] / h; + } + for (int j = 0; j <= i; j++) + { + decimal g = 0.0m; + for (int k = 0; k <= i; k++) + { + g += V[k][i + 1] * V[k][j]; + } + for (int k = 0; k <= i; k++) + { + V[k][j] -= g * d[k]; + } + } + } + for (int k = 0; k <= i; k++) + { + V[k][i + 1] = 0.0m; + } + } + for (int j = 0; j < n; j++) + { + d[j] = V[n - 1][j]; + V[n - 1][j] = 0.0m; + } + V[n - 1][n - 1] = 1.0m; + e[0] = 0.0m; + } + + // Symmetric tridiagonal QL algorithm. + + private void tql2() + { + // This is derived from the Algol procedures tql2, by + // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for + // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. + + for (int i = 1; i < n; i++) + { + e[i - 1] = e[i]; + } + e[n - 1] = 0.0m; + + decimal f = 0.0m; + decimal tst1 = 0.0m; + decimal eps = (decimal)DecimalMath.Pow(2.0m, - 52.0m); + for (int l = 0; l < n; l++) + { + // Find small subdiagonal element + + tst1 = System.Math.Max(tst1, System.Math.Abs(d[l]) + System.Math.Abs(e[l])); + int m = l; + while (m < n) + { + if (System.Math.Abs(e[m]) <= eps * tst1) + { + break; + } + m++; + } + + // If m == l, d[l] is an eigenvalue, + // otherwise, iterate. + + if (m > l) + { + int iter = 0; + do + { + iter = iter + 1; // (Could check iteration count here.) + + // Compute implicit shift + + decimal g = d[l]; + decimal p = (d[l + 1] - g) / (2.0m * e[l]); + decimal r = Maths.Hypot(p, 1.0m); + if (p < 0) + { + r = - r; + } + d[l] = e[l] / (p + r); + d[l + 1] = e[l] * (p + r); + decimal dl1 = d[l + 1]; + decimal h = g - d[l]; + for (int i = l + 2; i < n; i++) + { + d[i] -= h; + } + f = f + h; + + // Implicit QL transformation. + + p = d[m]; + decimal c = 1.0m; + decimal c2 = c; + decimal c3 = c; + decimal el1 = e[l + 1]; + decimal s = 0.0m; + decimal s2 = 0.0m; + for (int i = m - 1; i >= l; i--) + { + c3 = c2; + c2 = c; + s2 = s; + g = c * e[i]; + h = c * p; + r = Maths.Hypot(p, e[i]); + e[i + 1] = s * r; + s = e[i] / r; + c = p / r; + p = c * d[i] - s * g; + d[i + 1] = h + s * (c * g + s * d[i]); + + // Accumulate transformation. + + for (int k = 0; k < n; k++) + { + h = V[k][i + 1]; + V[k][i + 1] = s * V[k][i] + c * h; + V[k][i] = c * V[k][i] - s * h; + } + } + p = (- s) * s2 * c3 * el1 * e[l] / dl1; + e[l] = s * p; + d[l] = c * p; + + // Check for convergence. + } + while (System.Math.Abs(e[l]) > eps * tst1); + } + d[l] = d[l] + f; + e[l] = 0.0m; + } + + // Sort eigenvalues and corresponding vectors. + + for (int i = 0; i < n - 1; i++) + { + int k = i; + decimal p = d[i]; + for (int j = i + 1; j < n; j++) + { + if (d[j] < p) + { + k = j; + p = d[j]; + } + } + if (k != i) + { + d[k] = d[i]; + d[i] = p; + for (int j = 0; j < n; j++) + { + p = V[j][i]; + V[j][i] = V[j][k]; + V[j][k] = p; + } + } + } + } + + // Nonsymmetric reduction to Hessenberg form. + + private void orthes() + { + // This is derived from the Algol procedures orthes and ortran, + // by Martin and Wilkinson, Handbook for Auto. Comp., + // Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutines in EISPACK. + + int low = 0; + int high = n - 1; + + for (int m = low + 1; m <= high - 1; m++) + { + + // Scale column. + + decimal scale = 0.0m; + for (int i = m; i <= high; i++) + { + scale = scale + System.Math.Abs(H[i][m - 1]); + } + if (scale != 0.0m) + { + + // Compute Householder transformation. + + decimal h = 0.0m; + for (int i = high; i >= m; i--) + { + ort[i] = H[i][m - 1] / scale; + h += ort[i] * ort[i]; + } + decimal g = (decimal)DecimalMath.Sqrt(h); + if (ort[m] > 0) + { + g = - g; + } + h = h - ort[m] * g; + ort[m] = ort[m] - g; + + // Apply Householder similarity transformation + // H = (I-u*u'/h)*H*(I-u*u')/h) + + for (int j = m; j < n; j++) + { + decimal f = 0.0m; + for (int i = high; i >= m; i--) + { + f += ort[i] * H[i][j]; + } + f = f / h; + for (int i = m; i <= high; i++) + { + H[i][j] -= f * ort[i]; + } + } + + for (int i = 0; i <= high; i++) + { + decimal f = 0.0m; + for (int j = high; j >= m; j--) + { + f += ort[j] * H[i][j]; + } + f = f / h; + for (int j = m; j <= high; j++) + { + H[i][j] -= f * ort[j]; + } + } + ort[m] = scale * ort[m]; + H[m][m - 1] = scale * g; + } + } + + // Accumulate transformations (Algol's ortran). + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + V[i][j] = (i == j?1.0m:0.0m); + } + } + + for (int m = high - 1; m >= low + 1; m--) + { + if (H[m][m - 1] != 0.0m) + { + for (int i = m + 1; i <= high; i++) + { + ort[i] = H[i][m - 1]; + } + for (int j = m; j <= high; j++) + { + decimal g = 0.0m; + for (int i = m; i <= high; i++) + { + g += ort[i] * V[i][j]; + } + // decimal division avoids possible underflow + g = (g / ort[m]) / H[m][m - 1]; + for (int i = m; i <= high; i++) + { + V[i][j] += g * ort[i]; + } + } + } + } + } + + + // Complex scalar division. + + [NonSerialized()] + private decimal cdivr, cdivi; + + private void cdiv(decimal xr, decimal xi, decimal yr, decimal yi) + { + decimal r, d; + if (System.Math.Abs(yr) > System.Math.Abs(yi)) + { + r = yi / yr; + d = yr + r * yi; + cdivr = (xr + r * xi) / d; + cdivi = (xi - r * xr) / d; + } + else + { + r = yr / yi; + d = yi + r * yr; + cdivr = (r * xr + xi) / d; + cdivi = (r * xi - xr) / d; + } + } + + + // Nonsymmetric reduction from Hessenberg to real Schur form. + + private void hqr2() + { + // This is derived from the Algol procedure hqr2, + // by Martin and Wilkinson, Handbook for Auto. Comp., + // Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. + + // Initialize + + int nn = this.n; + int n = nn - 1; + int low = 0; + int high = nn - 1; + decimal eps = (decimal)DecimalMath.Pow(2.0m, - 52.0m); + decimal exshift = 0.0m; + decimal p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y; + + // Store roots isolated by balanc and compute matrix norm + + decimal norm = 0.0m; + for (int i = 0; i < nn; i++) + { + if (i < low | i > high) + { + d[i] = H[i][i]; + e[i] = 0.0m; + } + for (int j = System.Math.Max(i - 1, 0); j < nn; j++) + { + norm = norm + System.Math.Abs(H[i][j]); + } + } + + // Outer loop over eigenvalue index + + int iter = 0; + while (n >= low) + { + + // Look for single small sub-diagonal element + + int l = n; + while (l > low) + { + s = System.Math.Abs(H[l - 1][l - 1]) + System.Math.Abs(H[l][l]); + if (s == 0.0m) + { + s = norm; + } + if (System.Math.Abs(H[l][l - 1]) < eps * s) + { + break; + } + l--; + } + + // Check for convergence + // One root found + + if (l == n) + { + H[n][n] = H[n][n] + exshift; + d[n] = H[n][n]; + e[n] = 0.0m; + n--; + iter = 0; + + // Two roots found + } + else if (l == n - 1) + { + w = H[n][n - 1] * H[n - 1][n]; + p = (H[n - 1][n - 1] - H[n][n]) / 2.0m; + q = p * p + w; + z = (decimal)DecimalMath.Sqrt(System.Math.Abs(q)); + H[n][n] = H[n][n] + exshift; + H[n - 1][n - 1] = H[n - 1][n - 1] + exshift; + x = H[n][n]; + + // Real pair + + if (q >= 0) + { + if (p >= 0) + { + z = p + z; + } + else + { + z = p - z; + } + d[n - 1] = x + z; + d[n] = d[n - 1]; + if (z != 0.0m) + { + d[n] = x - w / z; + } + e[n - 1] = 0.0m; + e[n] = 0.0m; + x = H[n][n - 1]; + s = System.Math.Abs(x) + System.Math.Abs(z); + p = x / s; + q = z / s; + r = (decimal)DecimalMath.Sqrt(p * p + q * q); + p = p / r; + q = q / r; + + // Row modification + + for (int j = n - 1; j < nn; j++) + { + z = H[n - 1][j]; + H[n - 1][j] = q * z + p * H[n][j]; + H[n][j] = q * H[n][j] - p * z; + } + + // Column modification + + for (int i = 0; i <= n; i++) + { + z = H[i][n - 1]; + H[i][n - 1] = q * z + p * H[i][n]; + H[i][n] = q * H[i][n] - p * z; + } + + // Accumulate transformations + + for (int i = low; i <= high; i++) + { + z = V[i][n - 1]; + V[i][n - 1] = q * z + p * V[i][n]; + V[i][n] = q * V[i][n] - p * z; + } + + // Complex pair + } + else + { + d[n - 1] = x + p; + d[n] = x + p; + e[n - 1] = z; + e[n] = - z; + } + n = n - 2; + iter = 0; + + // No convergence yet + } + else + { + + // Form shift + + x = H[n][n]; + y = 0.0m; + w = 0.0m; + if (l < n) + { + y = H[n - 1][n - 1]; + w = H[n][n - 1] * H[n - 1][n]; + } + + // Wilkinson's original ad hoc shift + + if (iter == 10) + { + exshift += x; + for (int i = low; i <= n; i++) + { + H[i][i] -= x; + } + s = System.Math.Abs(H[n][n - 1]) + System.Math.Abs(H[n - 1][n - 2]); + x = y = 0.75m * s; + w = (- 0.4375m) * s * s; + } + + // MATLAB's new ad hoc shift + + if (iter == 30) + { + s = (y - x) / 2.0m; + s = s * s + w; + if (s > 0) + { + s = (decimal)DecimalMath.Sqrt(s); + if (y < x) + { + s = - s; + } + s = x - w / ((y - x) / 2.0m + s); + for (int i = low; i <= n; i++) + { + H[i][i] -= s; + } + exshift += s; + x = y = w = 0.964m; + } + } + + iter = iter + 1; // (Could check iteration count here.) + + // Look for two consecutive small sub-diagonal elements + + int m = n - 2; + while (m >= l) + { + z = H[m][m]; + r = x - z; + s = y - z; + p = (r * s - w) / H[m + 1][m] + H[m][m + 1]; + q = H[m + 1][m + 1] - z - r - s; + r = H[m + 2][m + 1]; + s = System.Math.Abs(p) + System.Math.Abs(q) + System.Math.Abs(r); + p = p / s; + q = q / s; + r = r / s; + if (m == l) + { + break; + } + if (System.Math.Abs(H[m][m - 1]) * (System.Math.Abs(q) + System.Math.Abs(r)) < eps * (System.Math.Abs(p) * (System.Math.Abs(H[m - 1][m - 1]) + System.Math.Abs(z) + System.Math.Abs(H[m + 1][m + 1])))) + { + break; + } + m--; + } + + for (int i = m + 2; i <= n; i++) + { + H[i][i - 2] = 0.0m; + if (i > m + 2) + { + H[i][i - 3] = 0.0m; + } + } + + // decimal QR step involving rows l:n and columns m:n + + for (int k = m; k <= n - 1; k++) + { + bool notlast = (k != n - 1); + if (k != m) + { + p = H[k][k - 1]; + q = H[k + 1][k - 1]; + r = (notlast?H[k + 2][k - 1]:0.0m); + x = System.Math.Abs(p) + System.Math.Abs(q) + System.Math.Abs(r); + if (x != 0.0m) + { + p = p / x; + q = q / x; + r = r / x; + } + } + if (x == 0.0m) + { + break; + } + s = (decimal)DecimalMath.Sqrt(p * p + q * q + r * r); + if (p < 0) + { + s = - s; + } + if (s != 0) + { + if (k != m) + { + H[k][k - 1] = (- s) * x; + } + else if (l != m) + { + H[k][k - 1] = - H[k][k - 1]; + } + p = p + s; + x = p / s; + y = q / s; + z = r / s; + q = q / p; + r = r / p; + + // Row modification + + for (int j = k; j < nn; j++) + { + p = H[k][j] + q * H[k + 1][j]; + if (notlast) + { + p = p + r * H[k + 2][j]; + H[k + 2][j] = H[k + 2][j] - p * z; + } + H[k][j] = H[k][j] - p * x; + H[k + 1][j] = H[k + 1][j] - p * y; + } + + // Column modification + + for (int i = 0; i <= System.Math.Min(n, k + 3); i++) + { + p = x * H[i][k] + y * H[i][k + 1]; + if (notlast) + { + p = p + z * H[i][k + 2]; + H[i][k + 2] = H[i][k + 2] - p * r; + } + H[i][k] = H[i][k] - p; + H[i][k + 1] = H[i][k + 1] - p * q; + } + + // Accumulate transformations + + for (int i = low; i <= high; i++) + { + p = x * V[i][k] + y * V[i][k + 1]; + if (notlast) + { + p = p + z * V[i][k + 2]; + V[i][k + 2] = V[i][k + 2] - p * r; + } + V[i][k] = V[i][k] - p; + V[i][k + 1] = V[i][k + 1] - p * q; + } + } // (s != 0) + } // k loop + } // check convergence + } // while (n >= low) + + // Backsubstitute to find vectors of upper triangular form + + if (norm == 0.0m) + { + return ; + } + + for (n = nn - 1; n >= 0; n--) + { + p = d[n]; + q = e[n]; + + // Real vector + + if (q == 0) + { + int l = n; + H[n][n] = 1.0m; + for (int i = n - 1; i >= 0; i--) + { + w = H[i][i] - p; + r = 0.0m; + for (int j = l; j <= n; j++) + { + r = r + H[i][j] * H[j][n]; + } + if (e[i] < 0.0m) + { + z = w; + s = r; + } + else + { + l = i; + if (e[i] == 0.0m) + { + if (w != 0.0m) + { + H[i][n] = (- r) / w; + } + else + { + H[i][n] = (- r) / (eps * norm); + } + + // Solve real equations + } + else + { + x = H[i][i + 1]; + y = H[i + 1][i]; + q = (d[i] - p) * (d[i] - p) + e[i] * e[i]; + t = (x * s - z * r) / q; + H[i][n] = t; + if (System.Math.Abs(x) > System.Math.Abs(z)) + { + H[i + 1][n] = (- r - w * t) / x; + } + else + { + H[i + 1][n] = (- s - y * t) / z; + } + } + + // Overflow control + + t = System.Math.Abs(H[i][n]); + if ((eps * t) * t > 1) + { + for (int j = i; j <= n; j++) + { + H[j][n] = H[j][n] / t; + } + } + } + } + + // Complex vector + } + else if (q < 0) + { + int l = n - 1; + + // Last vector component imaginary so matrix is triangular + + if (System.Math.Abs(H[n][n - 1]) > System.Math.Abs(H[n - 1][n])) + { + H[n - 1][n - 1] = q / H[n][n - 1]; + H[n - 1][n] = (- (H[n][n] - p)) / H[n][n - 1]; + } + else + { + cdiv(0.0m, - H[n - 1][n], H[n - 1][n - 1] - p, q); + H[n - 1][n - 1] = cdivr; + H[n - 1][n] = cdivi; + } + H[n][n - 1] = 0.0m; + H[n][n] = 1.0m; + for (int i = n - 2; i >= 0; i--) + { + decimal ra, sa, vr, vi; + ra = 0.0m; + sa = 0.0m; + for (int j = l; j <= n; j++) + { + ra = ra + H[i][j] * H[j][n - 1]; + sa = sa + H[i][j] * H[j][n]; + } + w = H[i][i] - p; + + if (e[i] < 0.0m) + { + z = w; + r = ra; + s = sa; + } + else + { + l = i; + if (e[i] == 0) + { + cdiv(- ra, - sa, w, q); + H[i][n - 1] = cdivr; + H[i][n] = cdivi; + } + else + { + + // Solve complex equations + + x = H[i][i + 1]; + y = H[i + 1][i]; + vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q; + vi = (d[i] - p) * 2.0m * q; + if (vr == 0.0m & vi == 0.0m) + { + vr = eps * norm * (System.Math.Abs(w) + System.Math.Abs(q) + System.Math.Abs(x) + System.Math.Abs(y) + System.Math.Abs(z)); + } + cdiv(x * r - z * ra + q * sa, x * s - z * sa - q * ra, vr, vi); + H[i][n - 1] = cdivr; + H[i][n] = cdivi; + if (System.Math.Abs(x) > (System.Math.Abs(z) + System.Math.Abs(q))) + { + H[i + 1][n - 1] = (- ra - w * H[i][n - 1] + q * H[i][n]) / x; + H[i + 1][n] = (- sa - w * H[i][n] - q * H[i][n - 1]) / x; + } + else + { + cdiv(- r - y * H[i][n - 1], - s - y * H[i][n], z, q); + H[i + 1][n - 1] = cdivr; + H[i + 1][n] = cdivi; + } + } + + // Overflow control + + t = System.Math.Max(System.Math.Abs(H[i][n - 1]), System.Math.Abs(H[i][n])); + if ((eps * t) * t > 1) + { + for (int j = i; j <= n; j++) + { + H[j][n - 1] = H[j][n - 1] / t; + H[j][n] = H[j][n] / t; + } + } + } + } + } + } + + // Vectors of isolated roots + + for (int i = 0; i < nn; i++) + { + if (i < low | i > high) + { + for (int j = i; j < nn; j++) + { + V[i][j] = H[i][j]; + } + } + } + + // Back transformation to get eigenvectors of original matrix + + for (int j = nn - 1; j >= low; j--) + { + for (int i = low; i <= high; i++) + { + z = 0.0m; + for (int k = low; k <= System.Math.Min(j, high); k++) + { + z = z + V[i][k] * H[k][j]; + } + V[i][j] = z; + } + } + } + + #endregion // Private Methods + + + #region Constructor + + /// Check for symmetry, then construct the eigenvalue decomposition + /// Square matrix + /// + /// Structure to access D and V. + /// + + public EigenvalueDecomposition(GeneralMatrix Arg) + { + decimal[][] A = Arg.Array; + n = Arg.ColumnDimension; + V = new decimal[n][]; + for (int i = 0; i < n; i++) + { + V[i] = new decimal[n]; + } + d = new decimal[n]; + e = new decimal[n]; + + issymmetric = true; + for (int j = 0; (j < n) & issymmetric; j++) + { + for (int i = 0; (i < n) & issymmetric; i++) + { + issymmetric = (A[i][j] == A[j][i]); + } + } + + if (issymmetric) + { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + V[i][j] = A[i][j]; + } + } + + // Tridiagonalize. + tred2(); + + // Diagonalize. + tql2(); + } + else + { + H = new decimal[n][]; + for (int i2 = 0; i2 < n; i2++) + { + H[i2] = new decimal[n]; + } + ort = new decimal[n]; + + for (int j = 0; j < n; j++) + { + for (int i = 0; i < n; i++) + { + H[i][j] = A[i][j]; + } + } + + // Reduce to Hessenberg form. + orthes(); + + // Reduce Hessenberg to real Schur form. + hqr2(); + } + } + + #endregion // Constructor + + #region Public Properties + /// Return the real parts of the eigenvalues + /// real(diag(D)) + /// + virtual public decimal[] RealEigenvalues + { + get + { + return d; + } + } + /// Return the imaginary parts of the eigenvalues + /// imag(diag(D)) + /// + virtual public decimal[] ImagEigenvalues + { + get + { + return e; + } + } + /// Return the block diagonal eigenvalue matrix + /// D + /// + virtual public GeneralMatrix D + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] D = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + D[i][j] = 0.0m; + } + D[i][i] = d[i]; + if (e[i] > 0) + { + D[i][i + 1] = e[i]; + } + else if (e[i] < 0) + { + D[i][i - 1] = e[i]; + } + } + return X; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Return the eigenvector matrix + /// V + /// + + public virtual GeneralMatrix GetV() + { + return new GeneralMatrix(V, n, n); + } + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Matrix/EigenvalueDecomposition.cs.meta b/Assets/Scripts/Matrix/EigenvalueDecomposition.cs.meta new file mode 100644 index 0000000..eb39483 --- /dev/null +++ b/Assets/Scripts/Matrix/EigenvalueDecomposition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8fa5c66b38ce32f47b0959bb0315cd3b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix/GeneralMatrix.cs b/Assets/Scripts/Matrix/GeneralMatrix.cs new file mode 100644 index 0000000..ed4d811 --- /dev/null +++ b/Assets/Scripts/Matrix/GeneralMatrix.cs @@ -0,0 +1,1297 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + #region Internal Maths utility + internal class Maths + { + /// + /// sqrt(a^2 + b^2) without under/overflow. + /// + /// + /// + /// + + public static decimal Hypot(decimal a, decimal b) + { + decimal r; + if (Math.Abs(a) > Math.Abs(b)) + { + r = b/a; + r = Math.Abs(a) * (decimal)DecimalMath.Sqrt(1 + r * r); + } + else if (b != 0) + { + r = a/b; + r = Math.Abs(b) * (decimal)DecimalMath.Sqrt(1 + r * r); + } + else + { + r = 0.0m; + } + return r; + } + } + #endregion // Internal Maths utility + + /// .NET GeneralMatrix class. + /// + /// The .NET GeneralMatrix Class provides the fundamental operations of numerical + /// linear algebra. Various constructors create Matrices from two dimensional + /// arrays of decimal precision decimaling point numbers. Various "gets" and + /// "sets" provide access to submatrices and matrix elements. Several methods + /// implement basic matrix arithmetic, including matrix addition and + /// multiplication, matrix norms, and element-by-element array operations. + /// Methods for reading and printing matrices are also included. All the + /// operations in this version of the GeneralMatrix Class involve real matrices. + /// Complex matrices may be handled in a future version. + /// + /// Five fundamental matrix decompositions, which consist of pairs or triples + /// of matrices, permutation vectors, and the like, produce results in five + /// decomposition classes. These decompositions are accessed by the GeneralMatrix + /// class to compute solutions of simultaneous linear equations, determinants, + /// inverses and other matrix functions. The five decompositions are: + ///

    + ///
  • Cholesky Decomposition of symmetric, positive definite matrices. + ///
  • LU Decomposition of rectangular matrices. + ///
  • QR Decomposition of rectangular matrices. + ///
  • Singular Value Decomposition of rectangular matrices. + ///
  • Eigenvalue Decomposition of both symmetric and nonsymmetric square matrices. + ///
+ ///
+ ///
Example of use:
+ ///

+ ///

Solve a linear system A x = b and compute the residual norm, ||b - A x||. + ///

+	/// decimal[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
+	/// GeneralMatrix A = new GeneralMatrix(vals);
+	/// GeneralMatrix b = GeneralMatrix.Random(3,1);
+	/// GeneralMatrix x = A.Solve(b);
+	/// GeneralMatrix r = A.Multiply(x).Subtract(b);
+	/// decimal rnorm = r.NormInf();
+	/// 
+ ///
+ ///
+ /// + /// The MathWorks, Inc. and the National Institute of Standards and Technology. + /// + /// 5 August 1998 + /// + + [Serializable] + public class GeneralMatrix : System.ICloneable, System.Runtime.Serialization.ISerializable, System.IDisposable + { + #region Class variables + + /// Array for internal storage of elements. + /// @serial internal array storage. + /// + private decimal[][] A; + + /// Row and column dimensions. + /// @serial row dimension. + /// @serial column dimension. + /// + private int m, n; + + #endregion // Class variables + + #region Constructors + + /// Construct an m-by-n matrix of zeros. + /// Number of rows. + /// + /// Number of colums. + /// + + public GeneralMatrix(int m, int n) + { + this.m = m; + this.n = n; + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + } + } + + /// Construct an m-by-n constant matrix. + /// Number of rows. + /// + /// Number of colums. + /// + /// Fill the matrix with this scalar value. + /// + + public GeneralMatrix(int m, int n, decimal s) + { + this.m = m; + this.n = n; + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + } + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = s; + } + } + } + + /// Construct a matrix from a 2-D array. + /// Two-dimensional array of decimals. + /// + /// All rows must have the same length + /// + /// + /// + + public GeneralMatrix(decimal[][] A) + { + m = A.Length; + n = A[0].Length; + for (int i = 0; i < m; i++) + { + if (A[i].Length != n) + { + throw new System.ArgumentException("All rows must have the same length."); + } + } + this.A = A; + } + + /// Construct a matrix quickly without checking arguments. + /// Two-dimensional array of decimals. + /// + /// Number of rows. + /// + /// Number of colums. + /// + + public GeneralMatrix(decimal[][] A, int m, int n) + { + this.A = A; + this.m = m; + this.n = n; + } + + /// Construct a matrix from a one-dimensional packed array + /// One-dimensional array of decimals, packed by columns (ala Fortran). + /// + /// Number of rows. + /// + /// Array length must be a multiple of m. + /// + + public GeneralMatrix(decimal[] vals, int m) + { + this.m = m; + n = (m != 0?vals.Length / m:0); + if (m * n != vals.Length) + { + throw new System.ArgumentException("Array length must be a multiple of m."); + } + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + } + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = vals[i + j * m]; + } + } + } + #endregion // Constructors + + + #region Public Properties + /// Access the internal two-dimensional array. + /// Pointer to the two-dimensional array of matrix elements. + /// + virtual public decimal[][] Array + { + get + { + return A; + } + } + /// Copy the internal two-dimensional array. + /// Two-dimensional array copy of matrix elements. + /// + virtual public decimal[][] ArrayCopy + { + get + { + decimal[][] C = new decimal[m][]; + for (int i = 0; i < m; i++) + { + C[i] = new decimal[n]; + } + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return C; + } + + } + /// Make a one-dimensional column packed copy of the internal array. + /// Matrix elements packed in a one-dimensional array by columns. + /// + virtual public decimal[] ColumnPackedCopy + { + get + { + decimal[] vals = new decimal[m * n]; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + vals[i + j * m] = A[i][j]; + } + } + return vals; + } + + } + + /// Make a one-dimensional row packed copy of the internal array. + /// Matrix elements packed in a one-dimensional array by rows. + /// + virtual public decimal[] RowPackedCopy + { + get + { + decimal[] vals = new decimal[m * n]; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + vals[i * n + j] = A[i][j]; + } + } + return vals; + } + } + + /// Get row dimension. + /// m, the number of rows. + /// + virtual public int RowDimension + { + get + { + return m; + } + } + + /// Get column dimension. + /// n, the number of columns. + /// + virtual public int ColumnDimension + { + get + { + return n; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Construct a matrix from a copy of a 2-D array. + /// Two-dimensional array of decimals. + /// + /// All rows must have the same length + /// + + public static GeneralMatrix Create(decimal[][] A) + { + int m = A.Length; + int n = A[0].Length; + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + if (A[i].Length != n) + { + throw new System.ArgumentException("All rows must have the same length."); + } + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return X; + } + + /// Make a deep copy of a matrix + + public virtual GeneralMatrix Copy() + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return X; + } + + /// Get a single element. + /// Row index. + /// + /// Column index. + /// + /// A(i,j) + /// + /// + /// + + public virtual decimal GetElement(int i, int j) + { + return A[i][j]; + } + + /// Get a submatrix. + /// Initial row index + /// + /// Final row index + /// + /// Initial column index + /// + /// Final column index + /// + /// A(i0:i1,j0:j1) + /// + /// Submatrix indices + /// + + public virtual GeneralMatrix GetMatrix(int i0, int i1, int j0, int j1) + { + GeneralMatrix X = new GeneralMatrix(i1 - i0 + 1, j1 - j0 + 1); + decimal[][] B = X.Array; + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = j0; j <= j1; j++) + { + B[i - i0][j - j0] = A[i][j]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + /// Get a submatrix. + /// Array of row indices. + /// + /// Array of column indices. + /// + /// A(r(:),c(:)) + /// + /// Submatrix indices + /// + + public virtual GeneralMatrix GetMatrix(int[] r, int[] c) + { + GeneralMatrix X = new GeneralMatrix(r.Length, c.Length); + decimal[][] B = X.Array; + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = 0; j < c.Length; j++) + { + B[i][j] = A[r[i]][c[j]]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + /// Get a submatrix. + /// Initial row index + /// + /// Final row index + /// + /// Array of column indices. + /// + /// A(i0:i1,c(:)) + /// + /// Submatrix indices + /// + + public virtual GeneralMatrix GetMatrix(int i0, int i1, int[] c) + { + GeneralMatrix X = new GeneralMatrix(i1 - i0 + 1, c.Length); + decimal[][] B = X.Array; + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = 0; j < c.Length; j++) + { + B[i - i0][j] = A[i][c[j]]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + /// Get a submatrix. + /// Array of row indices. + /// + /// Initial column index + /// + /// Final column index + /// + /// A(r(:),j0:j1) + /// + /// Submatrix indices + /// + + public virtual GeneralMatrix GetMatrix(int[] r, int j0, int j1) + { + GeneralMatrix X = new GeneralMatrix(r.Length, j1 - j0 + 1); + decimal[][] B = X.Array; + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = j0; j <= j1; j++) + { + B[i][j - j0] = A[r[i]][j]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + /// Set a single element. + /// Row index. + /// + /// Column index. + /// + /// A(i,j). + /// + /// + /// + + public virtual void SetElement(int i, int j, decimal s) + { + A[i][j] = s; + } + + /// Set a submatrix. + /// Initial row index + /// + /// Final row index + /// + /// Initial column index + /// + /// Final column index + /// + /// A(i0:i1,j0:j1) + /// + /// Submatrix indices + /// + + public virtual void SetMatrix(int i0, int i1, int j0, int j1, GeneralMatrix X) + { + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = j0; j <= j1; j++) + { + A[i][j] = X.GetElement(i - i0, j - j0); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + /// Set a submatrix. + /// Array of row indices. + /// + /// Array of column indices. + /// + /// A(r(:),c(:)) + /// + /// Submatrix indices + /// + + public virtual void SetMatrix(int[] r, int[] c, GeneralMatrix X) + { + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = 0; j < c.Length; j++) + { + A[r[i]][c[j]] = X.GetElement(i, j); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + /// Set a submatrix. + /// Array of row indices. + /// + /// Initial column index + /// + /// Final column index + /// + /// A(r(:),j0:j1) + /// + /// Submatrix indices + /// + + public virtual void SetMatrix(int[] r, int j0, int j1, GeneralMatrix X) + { + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = j0; j <= j1; j++) + { + A[r[i]][j] = X.GetElement(i, j - j0); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + /// Set a submatrix. + /// Initial row index + /// + /// Final row index + /// + /// Array of column indices. + /// + /// A(i0:i1,c(:)) + /// + /// Submatrix indices + /// + + public virtual void SetMatrix(int i0, int i1, int[] c, GeneralMatrix X) + { + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = 0; j < c.Length; j++) + { + A[i][c[j]] = X.GetElement(i - i0, j); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + /// Matrix transpose. + /// A' + /// + + public virtual GeneralMatrix Transpose() + { + GeneralMatrix X = new GeneralMatrix(n, m); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[j][i] = A[i][j]; + } + } + return X; + } + + /// One norm + /// maximum column sum. + /// + + public virtual decimal Norm1() + { + decimal f = 0; + for (int j = 0; j < n; j++) + { + decimal s = 0; + for (int i = 0; i < m; i++) + { + s += System.Math.Abs(A[i][j]); + } + f = System.Math.Max(f, s); + } + return f; + } + + /// Two norm + /// maximum singular value. + /// + + public virtual decimal Norm2() + { + return (new SingularValueDecomposition(this).Norm2()); + } + + /// Infinity norm + /// maximum row sum. + /// + + public virtual decimal NormInf() + { + decimal f = 0; + for (int i = 0; i < m; i++) + { + decimal s = 0; + for (int j = 0; j < n; j++) + { + s += System.Math.Abs(A[i][j]); + } + f = System.Math.Max(f, s); + } + return f; + } + + /// Frobenius norm + /// sqrt of sum of squares of all elements. + /// + + public virtual decimal NormF() + { + decimal f = 0; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + f = Maths.Hypot(f, A[i][j]); + } + } + return f; + } + + /// Unary minus + /// -A + /// + + public virtual GeneralMatrix UnaryMinus() + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = -A[i][j]; + } + } + return X; + } + + /// C = A + B + /// another matrix + /// + /// A + B + /// + + public virtual GeneralMatrix Add(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] + B.A[i][j]; + } + } + return X; + } + + /// A = A + B + /// another matrix + /// + /// A + B + /// + + public virtual GeneralMatrix AddEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] + B.A[i][j]; + } + } + return this; + } + + /// C = A - B + /// another matrix + /// + /// A - B + /// + + public virtual GeneralMatrix Subtract(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] - B.A[i][j]; + } + } + return X; + } + + /// A = A - B + /// another matrix + /// + /// A - B + /// + + public virtual GeneralMatrix SubtractEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] - B.A[i][j]; + } + } + return this; + } + + /// Element-by-element multiplication, C = A.*B + /// another matrix + /// + /// A.*B + /// + + public virtual GeneralMatrix ArrayMultiply(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] * B.A[i][j]; + } + } + return X; + } + + /// Element-by-element multiplication in place, A = A.*B + /// another matrix + /// + /// A.*B + /// + + public virtual GeneralMatrix ArrayMultiplyEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] * B.A[i][j]; + } + } + return this; + } + + /// Element-by-element right division, C = A./B + /// another matrix + /// + /// A./B + /// + + public virtual GeneralMatrix ArrayRightDivide(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] / B.A[i][j]; + } + } + return X; + } + + /// Element-by-element right division in place, A = A./B + /// another matrix + /// + /// A./B + /// + + public virtual GeneralMatrix ArrayRightDivideEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] / B.A[i][j]; + } + } + return this; + } + + /// Element-by-element left division, C = A.\B + /// another matrix + /// + /// A.\B + /// + + public virtual GeneralMatrix ArrayLeftDivide(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = B.A[i][j] / A[i][j]; + } + } + return X; + } + + /// Element-by-element left division in place, A = A.\B + /// another matrix + /// + /// A.\B + /// + + public virtual GeneralMatrix ArrayLeftDivideEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = B.A[i][j] / A[i][j]; + } + } + return this; + } + + /// Multiply a matrix by a scalar, C = s*A + /// scalar + /// + /// s*A + /// + + public virtual GeneralMatrix Multiply(decimal s) + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = s * A[i][j]; + } + } + return X; + } + + /// Multiply a matrix by a scalar in place, A = s*A + /// scalar + /// + /// replace A by s*A + /// + + public virtual GeneralMatrix MultiplyEquals(decimal s) + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = s * A[i][j]; + } + } + return this; + } + + /// Linear algebraic matrix multiplication, A * B + /// another matrix + /// + /// Matrix product, A * B + /// + /// Matrix inner dimensions must agree. + /// + + public virtual GeneralMatrix Multiply(GeneralMatrix B) + { + if (B.m != n) + { + throw new System.ArgumentException("GeneralMatrix inner dimensions must agree."); + } + GeneralMatrix X = new GeneralMatrix(m, B.n); + decimal[][] C = X.Array; + decimal[] Bcolj = new decimal[n]; + for (int j = 0; j < B.n; j++) + { + for (int k = 0; k < n; k++) + { + Bcolj[k] = B.A[k][j]; + } + for (int i = 0; i < m; i++) + { + decimal[] Arowi = A[i]; + decimal s = 0; + for (int k = 0; k < n; k++) + { + s += Arowi[k] * Bcolj[k]; + } + C[i][j] = s; + } + } + return X; + } + + #region Operator Overloading + + /// + /// Addition of matrices + /// + /// + /// + /// + public static GeneralMatrix operator +(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Add(m2); + } + + /// + /// Subtraction of matrices + /// + /// + /// + /// + public static GeneralMatrix operator -(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Subtract(m2); + } + + /// + /// Multiplication of matrices + /// + /// + /// + /// + public static GeneralMatrix operator *(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Multiply(m2); + } + + #endregion //Operator Overloading + + /// LU Decomposition + /// LUDecomposition + /// + /// + /// + + public virtual LUDecomposition LUD() + { + return new LUDecomposition(this); + } + + /// QR Decomposition + /// QRDecomposition + /// + /// + /// + + public virtual QRDecomposition QRD() + { + return new QRDecomposition(this); + } + + /// Cholesky Decomposition + /// CholeskyDecomposition + /// + /// + /// + + public virtual CholeskyDecomposition chol() + { + return new CholeskyDecomposition(this); + } + + /// Singular Value Decomposition + /// SingularValueDecomposition + /// + /// + /// + + public virtual SingularValueDecomposition SVD() + { + return new SingularValueDecomposition(this); + } + + /// Eigenvalue Decomposition + /// EigenvalueDecomposition + /// + /// + /// + + public virtual EigenvalueDecomposition Eigen() + { + return new EigenvalueDecomposition(this); + } + + /// Solve A*X = B + /// right hand side + /// + /// solution if A is square, least squares solution otherwise + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + return (m == n ? (new LUDecomposition(this)).Solve(B):(new QRDecomposition(this)).Solve(B)); + } + + /// Solve X*A = B, which is also A'*X' = B' + /// right hand side + /// + /// solution if A is square, least squares solution otherwise. + /// + + public virtual GeneralMatrix SolveTranspose(GeneralMatrix B) + { + return Transpose().Solve(B.Transpose()); + } + + /// Matrix inverse or pseudoinverse + /// inverse(A) if A is square, pseudoinverse otherwise. + /// + + public virtual GeneralMatrix Inverse() + { + return Solve(Identity(m, m)); + } + + /// GeneralMatrix determinant + /// determinant + /// + + public virtual decimal Determinant() + { + return new LUDecomposition(this).Determinant(); + } + + /// GeneralMatrix rank + /// effective numerical rank, obtained from SVD. + /// + + public virtual int Rank() + { + return new SingularValueDecomposition(this).Rank(); + } + + /// Matrix condition (2 norm) + /// ratio of largest to smallest singular value. + /// + + public virtual decimal Condition() + { + return new SingularValueDecomposition(this).Condition(); + } + + /// Matrix trace. + /// sum of the diagonal elements. + /// + + public virtual decimal Trace() + { + decimal t = 0; + for (int i = 0; i < System.Math.Min(m, n); i++) + { + t += A[i][i]; + } + return t; + } + + /// Generate matrix with random elements + /// Number of rows. + /// + /// Number of colums. + /// + /// An m-by-n matrix with uniformly distributed random elements. + /// + + /*public static GeneralMatrix Random(int m, int n) + { + System.Random random = new System.Random(); + + GeneralMatrix A = new GeneralMatrix(m, n); + decimal[][] X = A.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + X[i][j] = random.Nextdecimal(); + } + } + return A; + }*/ + + /// Generate identity matrix + /// Number of rows. + /// + /// Number of colums. + /// + /// An m-by-n matrix with ones on the diagonal and zeros elsewhere. + /// + + public static GeneralMatrix Identity(int m, int n) + { + GeneralMatrix A = new GeneralMatrix(m, n); + decimal[][] X = A.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + X[i][j] = (i == j ? 1.0m : 0.0m); + } + } + return A; + } + + #endregion // Public Methods + + #region Private Methods + + /// Check if size(A) == size(B) * + + private void CheckMatrixDimensions(GeneralMatrix B) + { + if (B.m != m || B.n != n) + { + throw new System.ArgumentException("GeneralMatrix dimensions must agree."); + } + } + #endregion // Private Methods + + #region Implement IDisposable + /// + /// Do not make this method virtual. + /// A derived class should not be able to override this method. + /// + public void Dispose() + { + Dispose(true); + } + + /// + /// Dispose(bool disposing) executes in two distinct scenarios. + /// If disposing equals true, the method has been called directly + /// or indirectly by a user's code. Managed and unmanaged resources + /// can be disposed. + /// If disposing equals false, the method has been called by the + /// runtime from inside the finalizer and you should not reference + /// other objects. Only unmanaged resources can be disposed. + /// + /// + private void Dispose(bool disposing) + { + // This object will be cleaned up by the Dispose method. + // Therefore, you should call GC.SupressFinalize to + // take this object off the finalization queue + // and prevent finalization code for this object + // from executing a second time. + if (disposing) + GC.SuppressFinalize(this); + } + + /// + /// This destructor will run only if the Dispose method + /// does not get called. + /// It gives your base class the opportunity to finalize. + /// Do not provide destructors in types derived from this class. + /// + ~GeneralMatrix() + { + // Do not re-create Dispose clean-up code here. + // Calling Dispose(false) is optimal in terms of + // readability and maintainability. + Dispose(false); + } + #endregion // Implement IDisposable + + /// Clone the GeneralMatrix object. + public System.Object Clone() + { + return this.Copy(); + } + + /// + /// A method called when serializing this class + /// + /// + /// + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Matrix/GeneralMatrix.cs.meta b/Assets/Scripts/Matrix/GeneralMatrix.cs.meta new file mode 100644 index 0000000..966fe5b --- /dev/null +++ b/Assets/Scripts/Matrix/GeneralMatrix.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 724de4fb0b68d7641852aedf09ccc5c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix/LUDecomposition.cs b/Assets/Scripts/Matrix/LUDecomposition.cs new file mode 100644 index 0000000..5b97321 --- /dev/null +++ b/Assets/Scripts/Matrix/LUDecomposition.cs @@ -0,0 +1,322 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// LU Decomposition. + /// For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n + /// unit lower triangular matrix L, an n-by-n upper triangular matrix U, + /// and a permutation vector piv of length m so that A(piv,:) = L*U. + /// If m < n, then L is m-by-m and U is m-by-n. + /// The LU decompostion with pivoting always exists, even if the matrix is + /// singular, so the constructor will never fail. The primary use of the + /// LU decomposition is in the solution of square systems of simultaneous + /// linear equations. This will fail if IsNonSingular() returns false. + /// + + [Serializable] + public class LUDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] LU; + + /// Row and column dimensions, and pivot sign. + /// @serial column dimension. + /// @serial row dimension. + /// @serial pivot sign. + /// + private int m, n, pivsign; + + /// Internal storage of pivot vector. + /// @serial pivot vector. + /// + private int[] piv; + + #endregion // Class variables + + #region Constructor + + /// LU Decomposition + /// Rectangular matrix + /// + /// Structure to access L, U and piv. + /// + + public LUDecomposition(GeneralMatrix A) + { + // Use a "left-looking", dot-product, Crout/Doolittle algorithm. + + LU = A.ArrayCopy; + m = A.RowDimension; + n = A.ColumnDimension; + piv = new int[m]; + for (int i = 0; i < m; i++) + { + piv[i] = i; + } + pivsign = 1; + decimal[] LUrowi; + decimal[] LUcolj = new decimal[m]; + + // Outer loop. + + for (int j = 0; j < n; j++) + { + + // Make a copy of the j-th column to localize references. + + for (int i = 0; i < m; i++) + { + LUcolj[i] = LU[i][j]; + } + + // Apply previous transformations. + + for (int i = 0; i < m; i++) + { + LUrowi = LU[i]; + + // Most of the time is spent in the following dot product. + + int kmax = System.Math.Min(i, j); + decimal s = 0.0m; + for (int k = 0; k < kmax; k++) + { + s += LUrowi[k] * LUcolj[k]; + } + + LUrowi[j] = LUcolj[i] -= s; + } + + // Find pivot and exchange if necessary. + + int p = j; + for (int i = j + 1; i < m; i++) + { + if (System.Math.Abs(LUcolj[i]) > System.Math.Abs(LUcolj[p])) + { + p = i; + } + } + if (p != j) + { + for (int k = 0; k < n; k++) + { + decimal t = LU[p][k]; LU[p][k] = LU[j][k]; LU[j][k] = t; + } + int k2 = piv[p]; piv[p] = piv[j]; piv[j] = k2; + pivsign = - pivsign; + } + + // Compute multipliers. + + if (j < m & LU[j][j] != 0.0m) + { + for (int i = j + 1; i < m; i++) + { + LU[i][j] /= LU[j][j]; + } + } + } + } + #endregion // Constructor + + #region Public Properties + /// Is the matrix nonsingular? + /// true if U, and hence A, is nonsingular. + /// + virtual public bool IsNonSingular + { + get + { + for (int j = 0; j < n; j++) + { + if (LU[j][j] == 0) + return false; + } + return true; + } + } + + /// Return lower triangular factor + /// L + /// + virtual public GeneralMatrix L + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] L = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + if (i > j) + { + L[i][j] = LU[i][j]; + } + else if (i == j) + { + L[i][j] = 1.0m; + } + else + { + L[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Return upper triangular factor + /// U + /// + virtual public GeneralMatrix U + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] U = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i <= j) + { + U[i][j] = LU[i][j]; + } + else + { + U[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Return pivot permutation vector + /// piv + /// + virtual public int[] Pivot + { + get + { + int[] p = new int[m]; + for (int i = 0; i < m; i++) + { + p[i] = piv[i]; + } + return p; + } + } + + /// Return pivot permutation vector as a one-dimensional decimal array + /// (decimal) piv + /// + virtual public decimal[] decimalPivot + { + get + { + decimal[] vals = new decimal[m]; + for (int i = 0; i < m; i++) + { + vals[i] = (decimal) piv[i]; + } + return vals; + } + } + + #endregion // Public Properties + + #region Public Methods + + /// Determinant + /// det(A) + /// + /// Matrix must be square + /// + + public virtual decimal Determinant() + { + if (m != n) + { + throw new System.ArgumentException("Matrix must be square."); + } + decimal d = (decimal) pivsign; + for (int j = 0; j < n; j++) + { + d *= LU[j][j]; + } + return d; + } + + /// Solve A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X so that L*U*X = B(piv,:) + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is singular. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != m) + { + throw new System.ArgumentException("Matrix row dimensions must agree."); + } + if (!this.IsNonSingular) + { + throw new System.SystemException("Matrix is singular."); + } + + // Copy right hand side with pivoting + int nx = B.ColumnDimension; + GeneralMatrix Xmat = B.GetMatrix(piv, 0, nx - 1); + decimal[][] X = Xmat.Array; + + // Solve L*Y = B(piv,:) + for (int k = 0; k < n; k++) + { + for (int i = k + 1; i < n; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * LU[i][k]; + } + } + } + // Solve U*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= LU[k][k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * LU[i][k]; + } + } + } + return Xmat; + } + + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Matrix/LUDecomposition.cs.meta b/Assets/Scripts/Matrix/LUDecomposition.cs.meta new file mode 100644 index 0000000..8f5a6d5 --- /dev/null +++ b/Assets/Scripts/Matrix/LUDecomposition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 17b819c1b38065c4383c9c8112d2e300 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix/QRDecomposition.cs b/Assets/Scripts/Matrix/QRDecomposition.cs new file mode 100644 index 0000000..c6347c7 --- /dev/null +++ b/Assets/Scripts/Matrix/QRDecomposition.cs @@ -0,0 +1,287 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// QR Decomposition. + /// For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n + /// orthogonal matrix Q and an n-by-n upper triangular matrix R so that + /// A = Q*R. + /// + /// The QR decompostion always exists, even if the matrix does not have + /// full rank, so the constructor will never fail. The primary use of the + /// QR decomposition is in the least squares solution of nonsquare systems + /// of simultaneous linear equations. This will fail if IsFullRank() + /// returns false. + /// + + [Serializable] + public class QRDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] QR; + + /// Row and column dimensions. + /// @serial column dimension. + /// @serial row dimension. + /// + private int m, n; + + /// Array for internal storage of diagonal of R. + /// @serial diagonal of R. + /// + private decimal[] Rdiag; + + #endregion // Class variables + + #region Constructor + + /// QR Decomposition, computed by Householder reflections. + /// Rectangular matrix + /// + /// Structure to access R and the Householder vectors and compute Q. + /// + + public QRDecomposition(GeneralMatrix A) + { + // Initialize. + QR = A.ArrayCopy; + m = A.RowDimension; + n = A.ColumnDimension; + Rdiag = new decimal[n]; + + // Main loop. + for (int k = 0; k < n; k++) + { + // Compute 2-norm of k-th column without under/overflow. + decimal nrm = 0; + for (int i = k; i < m; i++) + { + nrm = Maths.Hypot(nrm, QR[i][k]); + } + + if (nrm != 0.0m) + { + // Form k-th Householder vector. + if (QR[k][k] < 0) + { + nrm = - nrm; + } + for (int i = k; i < m; i++) + { + QR[i][k] /= nrm; + } + QR[k][k] += 1.0m; + + // Apply transformation to remaining columns. + for (int j = k + 1; j < n; j++) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * QR[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + QR[i][j] += s * QR[i][k]; + } + } + } + Rdiag[k] = - nrm; + } + } + + #endregion // Constructor + + #region Public Properties + + /// Is the matrix full rank? + /// true if R, and hence A, has full rank. + /// + virtual public bool FullRank + { + get + { + for (int j = 0; j < n; j++) + { + if (Rdiag[j] == 0) + return false; + } + return true; + } + } + + /// Return the Householder vectors + /// Lower trapezoidal matrix whose columns define the reflections + /// + virtual public GeneralMatrix H + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] H = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + if (i >= j) + { + H[i][j] = QR[i][j]; + } + else + { + H[i][j] = 0.0m; + } + } + } + return X; + } + + } + + /// Return the upper triangular factor + /// R + /// + virtual public GeneralMatrix R + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] R = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i < j) + { + R[i][j] = QR[i][j]; + } + else if (i == j) + { + R[i][j] = Rdiag[i]; + } + else + { + R[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Generate and return the (economy-sized) orthogonal factor + /// Q + /// + virtual public GeneralMatrix Q + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] Q = X.Array; + for (int k = n - 1; k >= 0; k--) + { + for (int i = 0; i < m; i++) + { + Q[i][k] = 0.0m; + } + Q[k][k] = 1.0m; + for (int j = k; j < n; j++) + { + if (QR[k][k] != 0) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * Q[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + Q[i][j] += s * QR[i][k]; + } + } + } + } + return X; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Least squares solution of A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X that minimizes the two norm of Q*R*X-B. + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is rank deficient. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != m) + { + throw new System.ArgumentException("GeneralMatrix row dimensions must agree."); + } + if (!this.FullRank) + { + throw new System.SystemException("Matrix is rank deficient."); + } + + // Copy right hand side + int nx = B.ColumnDimension; + decimal[][] X = B.ArrayCopy; + + // Compute Y = transpose(Q)*B + for (int k = 0; k < n; k++) + { + for (int j = 0; j < nx; j++) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * X[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + X[i][j] += s * QR[i][k]; + } + } + } + // Solve R*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= Rdiag[k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * QR[i][k]; + } + } + } + + return (new GeneralMatrix(X, n, nx).GetMatrix(0, n - 1, 0, nx - 1)); + } + + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Matrix/QRDecomposition.cs.meta b/Assets/Scripts/Matrix/QRDecomposition.cs.meta new file mode 100644 index 0000000..516ddbf --- /dev/null +++ b/Assets/Scripts/Matrix/QRDecomposition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 80c5f324489884149b7fd041dd174bf8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Matrix/SingularValueDecomposition.cs b/Assets/Scripts/Matrix/SingularValueDecomposition.cs new file mode 100644 index 0000000..27e12d3 --- /dev/null +++ b/Assets/Scripts/Matrix/SingularValueDecomposition.cs @@ -0,0 +1,663 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// Singular Value Decomposition. + ///

+ /// For an m-by-n matrix A with m >= n, the singular value decomposition is + /// an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and + /// an n-by-n orthogonal matrix V so that A = U*S*V'. + ///

+ /// The singular values, sigma[k] = S[k][k], are ordered so that + /// sigma[0] >= sigma[1] >= ... >= sigma[n-1]. + ///

+ /// The singular value decompostion always exists, so the constructor will + /// never fail. The matrix condition number and the effective numerical + /// rank can be computed from this decomposition. + ///

+ + [Serializable] + public class SingularValueDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Arrays for internal storage of U and V. + /// @serial internal storage of U. + /// @serial internal storage of V. + /// + private decimal[][] U, V; + + /// Array for internal storage of singular values. + /// @serial internal storage of singular values. + /// + private decimal[] s; + + /// Row and column dimensions. + /// @serial row dimension. + /// @serial column dimension. + /// + private int m, n; + + #endregion //Class variables + + #region Constructor + + /// Construct the singular value decomposition + /// Rectangular matrix + /// + /// Structure to access U, S and V. + /// + + public SingularValueDecomposition(GeneralMatrix Arg) + { + // Derived from LINPACK code. + // Initialize. + decimal[][] A = Arg.ArrayCopy; + m = Arg.RowDimension; + n = Arg.ColumnDimension; + int nu = System.Math.Min(m, n); + s = new decimal[System.Math.Min(m + 1, n)]; + U = new decimal[m][]; + for (int i = 0; i < m; i++) + { + U[i] = new decimal[nu]; + } + V = new decimal[n][]; + for (int i2 = 0; i2 < n; i2++) + { + V[i2] = new decimal[n]; + } + decimal[] e = new decimal[n]; + decimal[] work = new decimal[m]; + bool wantu = true; + bool wantv = true; + + // Reduce A to bidiagonal form, storing the diagonal elements + // in s and the super-diagonal elements in e. + + int nct = System.Math.Min(m - 1, n); + int nrt = System.Math.Max(0, System.Math.Min(n - 2, m)); + for (int k = 0; k < System.Math.Max(nct, nrt); k++) + { + if (k < nct) + { + + // Compute the transformation for the k-th column and + // place the k-th diagonal in s[k]. + // Compute 2-norm of k-th column without under/overflow. + s[k] = 0; + for (int i = k; i < m; i++) + { + s[k] = Maths.Hypot(s[k], A[i][k]); + } + if (s[k] != 0.0m) + { + if (A[k][k] < 0.0m) + { + s[k] = - s[k]; + } + for (int i = k; i < m; i++) + { + A[i][k] /= s[k]; + } + A[k][k] += 1.0m; + } + s[k] = - s[k]; + } + for (int j = k + 1; j < n; j++) + { + if ((k < nct) & (s[k] != 0.0m)) + { + + // Apply the transformation. + + decimal t = 0; + for (int i = k; i < m; i++) + { + t += A[i][k] * A[i][j]; + } + t = (- t) / A[k][k]; + for (int i = k; i < m; i++) + { + A[i][j] += t * A[i][k]; + } + } + + // Place the k-th row of A into e for the + // subsequent calculation of the row transformation. + + e[j] = A[k][j]; + } + if (wantu & (k < nct)) + { + + // Place the transformation in U for subsequent back + // multiplication. + + for (int i = k; i < m; i++) + { + U[i][k] = A[i][k]; + } + } + if (k < nrt) + { + + // Compute the k-th row transformation and place the + // k-th super-diagonal in e[k]. + // Compute 2-norm without under/overflow. + e[k] = 0; + for (int i = k + 1; i < n; i++) + { + e[k] = Maths.Hypot(e[k], e[i]); + } + if (e[k] != 0.0m) + { + if (e[k + 1] < 0.0m) + { + e[k] = - e[k]; + } + for (int i = k + 1; i < n; i++) + { + e[i] /= e[k]; + } + e[k + 1] += 1.0m; + } + e[k] = - e[k]; + if ((k + 1 < m) & (e[k] != 0.0m)) + { + + // Apply the transformation. + + for (int i = k + 1; i < m; i++) + { + work[i] = 0.0m; + } + for (int j = k + 1; j < n; j++) + { + for (int i = k + 1; i < m; i++) + { + work[i] += e[j] * A[i][j]; + } + } + for (int j = k + 1; j < n; j++) + { + decimal t = (- e[j]) / e[k + 1]; + for (int i = k + 1; i < m; i++) + { + A[i][j] += t * work[i]; + } + } + } + if (wantv) + { + + // Place the transformation in V for subsequent + // back multiplication. + + for (int i = k + 1; i < n; i++) + { + V[i][k] = e[i]; + } + } + } + } + + // Set up the final bidiagonal matrix or order p. + + int p = System.Math.Min(n, m + 1); + if (nct < n) + { + s[nct] = A[nct][nct]; + } + if (m < p) + { + s[p - 1] = 0.0m; + } + if (nrt + 1 < p) + { + e[nrt] = A[nrt][p - 1]; + } + e[p - 1] = 0.0m; + + // If required, generate U. + + if (wantu) + { + for (int j = nct; j < nu; j++) + { + for (int i = 0; i < m; i++) + { + U[i][j] = 0.0m; + } + U[j][j] = 1.0m; + } + for (int k = nct - 1; k >= 0; k--) + { + if (s[k] != 0.0m) + { + for (int j = k + 1; j < nu; j++) + { + decimal t = 0; + for (int i = k; i < m; i++) + { + t += U[i][k] * U[i][j]; + } + t = (- t) / U[k][k]; + for (int i = k; i < m; i++) + { + U[i][j] += t * U[i][k]; + } + } + for (int i = k; i < m; i++) + { + U[i][k] = - U[i][k]; + } + U[k][k] = 1.0m + U[k][k]; + for (int i = 0; i < k - 1; i++) + { + U[i][k] = 0.0m; + } + } + else + { + for (int i = 0; i < m; i++) + { + U[i][k] = 0.0m; + } + U[k][k] = 1.0m; + } + } + } + + // If required, generate V. + + if (wantv) + { + for (int k = n - 1; k >= 0; k--) + { + if ((k < nrt) & (e[k] != 0.0m)) + { + for (int j = k + 1; j < nu; j++) + { + decimal t = 0; + for (int i = k + 1; i < n; i++) + { + t += V[i][k] * V[i][j]; + } + t = (- t) / V[k + 1][k]; + for (int i = k + 1; i < n; i++) + { + V[i][j] += t * V[i][k]; + } + } + } + for (int i = 0; i < n; i++) + { + V[i][k] = 0.0m; + } + V[k][k] = 1.0m; + } + } + + // Main iteration loop for the singular values. + + int pp = p - 1; + int iter = 0; + decimal eps = (decimal)Math.Pow(2.0f, - 52.0f); + while (p > 0) + { + int k, kase; + + // Here is where a test for too many iterations would go. + + // This section of the program inspects for + // negligible elements in the s and e arrays. On + // completion the variables kase and k are set as follows. + + // kase = 1 if s(p) and e[k-1] are negligible and k

= - 1; k--) + { + if (k == - 1) + { + break; + } + if (System.Math.Abs(e[k]) <= eps * (System.Math.Abs(s[k]) + System.Math.Abs(s[k + 1]))) + { + e[k] = 0.0m; + break; + } + } + if (k == p - 2) + { + kase = 4; + } + else + { + int ks; + for (ks = p - 1; ks >= k; ks--) + { + if (ks == k) + { + break; + } + decimal t = (ks != p?System.Math.Abs(e[ks]):0.0m) + (ks != k + 1?System.Math.Abs(e[ks - 1]):0.0m); + if (System.Math.Abs(s[ks]) <= eps * t) + { + s[ks] = 0.0m; + break; + } + } + if (ks == k) + { + kase = 3; + } + else if (ks == p - 1) + { + kase = 1; + } + else + { + kase = 2; + k = ks; + } + } + k++; + + // Perform the task indicated by kase. + + switch (kase) + { + + + // Deflate negligible s(p). + case 1: + { + decimal f = e[p - 2]; + e[p - 2] = 0.0m; + for (int j = p - 2; j >= k; j--) + { + decimal t = Maths.Hypot(s[j], f); + decimal cs = s[j] / t; + decimal sn = f / t; + s[j] = t; + if (j != k) + { + f = (- sn) * e[j - 1]; + e[j - 1] = cs * e[j - 1]; + } + if (wantv) + { + for (int i = 0; i < n; i++) + { + t = cs * V[i][j] + sn * V[i][p - 1]; + V[i][p - 1] = (- sn) * V[i][j] + cs * V[i][p - 1]; + V[i][j] = t; + } + } + } + } + break; + + // Split at negligible s(k). + + + case 2: + { + decimal f = e[k - 1]; + e[k - 1] = 0.0m; + for (int j = k; j < p; j++) + { + decimal t = Maths.Hypot(s[j], f); + decimal cs = s[j] / t; + decimal sn = f / t; + s[j] = t; + f = (- sn) * e[j]; + e[j] = cs * e[j]; + if (wantu) + { + for (int i = 0; i < m; i++) + { + t = cs * U[i][j] + sn * U[i][k - 1]; + U[i][k - 1] = (- sn) * U[i][j] + cs * U[i][k - 1]; + U[i][j] = t; + } + } + } + } + break; + + // Perform one qr step. + + + case 3: + { + // Calculate the shift. + + decimal scale = System.Math.Max(System.Math.Max(System.Math.Max(System.Math.Max(System.Math.Abs(s[p - 1]), System.Math.Abs(s[p - 2])), System.Math.Abs(e[p - 2])), System.Math.Abs(s[k])), System.Math.Abs(e[k])); + decimal sp = s[p - 1] / scale; + decimal spm1 = s[p - 2] / scale; + decimal epm1 = e[p - 2] / scale; + decimal sk = s[k] / scale; + decimal ek = e[k] / scale; + decimal b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0m; + decimal c = (sp * epm1) * (sp * epm1); + decimal shift = 0.0m; + if ((b != 0.0m) | (c != 0.0m)) + { + shift = (decimal)DecimalMath.Sqrt(b * b + c); + if (b < 0.0m) + { + shift = - shift; + } + shift = c / (b + shift); + } + decimal f = (sk + sp) * (sk - sp) + shift; + decimal g = sk * ek; + + // Chase zeros. + + for (int j = k; j < p - 1; j++) + { + decimal t = Maths.Hypot(f, g); + decimal cs = f / t; + decimal sn = g / t; + if (j != k) + { + e[j - 1] = t; + } + f = cs * s[j] + sn * e[j]; + e[j] = cs * e[j] - sn * s[j]; + g = sn * s[j + 1]; + s[j + 1] = cs * s[j + 1]; + if (wantv) + { + for (int i = 0; i < n; i++) + { + t = cs * V[i][j] + sn * V[i][j + 1]; + V[i][j + 1] = (- sn) * V[i][j] + cs * V[i][j + 1]; + V[i][j] = t; + } + } + t = Maths.Hypot(f, g); + cs = f / t; + sn = g / t; + s[j] = t; + f = cs * e[j] + sn * s[j + 1]; + s[j + 1] = (- sn) * e[j] + cs * s[j + 1]; + g = sn * e[j + 1]; + e[j + 1] = cs * e[j + 1]; + if (wantu && (j < m - 1)) + { + for (int i = 0; i < m; i++) + { + t = cs * U[i][j] + sn * U[i][j + 1]; + U[i][j + 1] = (- sn) * U[i][j] + cs * U[i][j + 1]; + U[i][j] = t; + } + } + } + e[p - 2] = f; + iter = iter + 1; + } + break; + + // Convergence. + + + case 4: + { + // Make the singular values positive. + + if (s[k] <= 0.0m) + { + s[k] = (s[k] < 0.0m?- s[k]:0.0m); + if (wantv) + { + for (int i = 0; i <= pp; i++) + { + V[i][k] = - V[i][k]; + } + } + } + + // Order the singular values. + + while (k < pp) + { + if (s[k] >= s[k + 1]) + { + break; + } + decimal t = s[k]; + s[k] = s[k + 1]; + s[k + 1] = t; + if (wantv && (k < n - 1)) + { + for (int i = 0; i < n; i++) + { + t = V[i][k + 1]; V[i][k + 1] = V[i][k]; V[i][k] = t; + } + } + if (wantu && (k < m - 1)) + { + for (int i = 0; i < m; i++) + { + t = U[i][k + 1]; U[i][k + 1] = U[i][k]; U[i][k] = t; + } + } + k++; + } + iter = 0; + p--; + } + break; + } + } + } + #endregion //Constructor + + #region Public Properties + ///

Return the one-dimensional array of singular values + /// diagonal of S. + /// + virtual public decimal[] SingularValues + { + get + { + return s; + } + } + + /// Return the diagonal matrix of singular values + /// S + /// + virtual public GeneralMatrix S + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] S = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + S[i][j] = 0.0m; + } + S[i][i] = this.s[i]; + } + return X; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Return the left singular vectors + /// U + /// + + public virtual GeneralMatrix GetU() + { + return new GeneralMatrix(U, m, System.Math.Min(m + 1, n)); + } + + /// Return the right singular vectors + /// V + /// + + public virtual GeneralMatrix GetV() + { + return new GeneralMatrix(V, n, n); + } + + /// Two norm + /// max(S) + /// + + public virtual decimal Norm2() + { + return s[0]; + } + + /// Two norm condition number + /// max(S)/min(S) + /// + + public virtual decimal Condition() + { + return s[0] / s[System.Math.Min(m, n) - 1]; + } + + /// Effective numerical matrix rank + /// Number of nonnegligible singular values. + /// + + public virtual int Rank() + { + decimal eps = (decimal)System.Math.Pow(2.0f, - 52.0f); + decimal tol = System.Math.Max(m, n) * s[0] * eps; + int r = 0; + for (int i = 0; i < s.Length; i++) + { + if (s[i] > tol) + { + r++; + } + } + return r; + } + #endregion //Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Matrix/SingularValueDecomposition.cs.meta b/Assets/Scripts/Matrix/SingularValueDecomposition.cs.meta new file mode 100644 index 0000000..9c59ded --- /dev/null +++ b/Assets/Scripts/Matrix/SingularValueDecomposition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 834d344a2e4c6e0468fcd799e751ff9b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NumericalMethods.cs b/Assets/Scripts/NumericalMethods.cs new file mode 100644 index 0000000..a87922b --- /dev/null +++ b/Assets/Scripts/NumericalMethods.cs @@ -0,0 +1,621 @@ +ïğżusing DotNetMatrix; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using UnityEngine; + +public class NumericalMethods +{ + #region GaussSeidal Yap BurayÄħ + /*public static List Method_GaussSeidal(List _eq, Dictionary initialValues, int iterationCount) + { + //yakÄħnsama ĊŸartÄħ (3x3 matris i�§in) -> |a11|>|a12|+|a13| && |a22|>|a21|+|a23| && |a33|>|a31|+|a32| + + bool convergence = true; + List dominantTerms = new List(); + for (int i = 0; i < _eq.Count; i++) + { + int currentDominant = -1; + bool dominantFound = false; + for (int j = 0; j < _eq.Count; j++) + { + decimal sum0 = 0; + + for (int k = 0; k < _eq.Count; k++) + { + if (k != j) + { + sum0 += Mathf.Abs(_eq[i].Coefficients[k]); + } + } + + if (Mathf.Abs(_eq[i].Coefficients[j]) > sum0) + { + currentDominant = j; + dominantFound = true; + break; + } + } + + if (dominantFound) + { + dominantTerms.Add(currentDominant); + } + else + { + dominantTerms.Add(-1); + } + } + + for (int i = 0; i < dominantTerms.Count && convergence; i++) + { + for (int j = 0; j < dominantTerms.Count; j++) + { + if (i != j) + { + if (dominantTerms[i] == dominantTerms[j]) + { + convergence = false; + break; + } + } + } + } + + if (convergence == false) + { + Debug.LogError("This matris cannot be solved with Gauss-Seidal Method!"); + return new List(); + } + else + { + List answers = initialValues; + for (int i = 0; i < iterationCount; i++) + { + for (int j = 0; j < _eq.Count; j++) + { + decimal sum = _eq[j].Constant + _eq[j].Coefficients[j] * answers[j]; + for (int k = 0; k < _eq.Count; k++) + { + sum += -_eq[j].Coefficients[k] * answers[k]; + } + answers[j] = sum / _eq[j].Coefficients[j]; + } + } + string ansdeb = ""; + for (int i = 0; i < answers.Count; i++) + { + ansdeb += answers[i] + ((i == answers.Count - 1) ? "" : ", "); + } + Debug.Log(ansdeb); + + return answers; + } + }*/ + #endregion + + + public static decimal Method_EvaluateFunction(string eq, string variable, decimal point) + { + string newEq = eq; + + newEq = newEq.Replace(variable, point.ToString(/*new CultureInfo("en-US")*/)); + + Function f = new Function(); + f.Parse(newEq); + f.Infix2Postfix(); + f.EvaluatePostfix(); + return f.m_result; + } + public static decimal MethodMultiVar_EvaluateFunction(string eq, Dictionary points) + { + string newEq = eq; + foreach (KeyValuePair pt in points) + { + newEq = newEq.Replace(pt.Key, pt.Value.ToString(/*new CultureInfo("en-US")*/)); + } + //Debug.Log(newEq); + + Function f = new Function(); + f.Parse(newEq); + f.Infix2Postfix(); + f.EvaluatePostfix(); + //Debug.Log(f.ErrorDescription); + //Debug.Log(Math.Round(f.m_result, 5)); + return f.m_result; + + } + + + public static Dictionary MethodMultiVar_SolveEquationSystem(List eqs, Dictionary initPoints, int iterationCount = 5, decimal h = 0.001m) + { + Dictionary dynamicPoints = initPoints; + for (int itC = 0; itC < iterationCount; itC++) + { + List linearizedEqs = new List(), variablesStr = new List(); + List leftVector = new List(); + for (int i = 0; i < eqs.Count; i++) + { + string le = MethodMultiVar_TaylorSeries(eqs[i], 1, dynamicPoints, h); + + int charCount = 0; + for (int j = 0; j < le.Length; j++) + { + if ((le[j] == '+' || le[j] == '-') && j != 0) break; + if (le[j] == '*') + { + charCount = 0; + break; + } + charCount++; + if (j == le.Length - 1 && charCount != 0) charCount = 0; + } + + //Debug.Log(le + " | " + charCount); + + decimal leftV = charCount != 0 ? decimal.Parse(le.Substring(0, charCount)) * -1 : 0; + + + string sum = ""; + foreach (KeyValuePair p in dynamicPoints) + { + sum += p.Key + ": " + p.Value.ToString("0." + new string('#', 339)) + ", "; + } + + //Debug.Log(le + " | " + charCount + " | " + sum + " | " + leftV); + + le = le.Remove(0, le[charCount] == '-' ? charCount : charCount + 1); + + + foreach (KeyValuePair p in dynamicPoints) + { + le = le.Replace("(" + p.Key + (p.Value < 0 ? "+" + DecimalMath.Abs(p.Value).ToString("0." + new string('#', 339)) : "-" + p.Value.ToString("0." + new string('#', 339))) + ")", p.Key); + } + //Debug.Log(le); + + + linearizedEqs.Add(le); + leftVector.Add(leftV); + } + + foreach (KeyValuePair p in dynamicPoints) + { + variablesStr.Add(p.Key); + } + + decimal[][] jacobianMatrix = Matrix.ConvertLinearEquationsToMatrix(linearizedEqs, variablesStr); + decimal[] leftHandVector = leftVector.ToArray(); + + decimal[] newPoints = Matrix.SolveEquation(jacobianMatrix, leftHandVector); + + + List newPointsList = new List(); + + for (int i = 0; i < newPoints.Length; i++) + { + newPointsList.Add(newPoints[i]); + } + + Dictionary tempDynamicPoints = new Dictionary(); + + foreach (KeyValuePair p in dynamicPoints) + { + tempDynamicPoints.Add(p.Key, p.Value); + } + + foreach (KeyValuePair p in dynamicPoints) + { + tempDynamicPoints[p.Key] = newPointsList[0] + p.Value; + newPointsList.RemoveAt(0); + } + dynamicPoints = tempDynamicPoints; + } + + return dynamicPoints; + } + + + public static string Method_TaylorSeries(string eq, int degree, string variable, decimal point, decimal h = 0.001m) + { + decimal constant = Method_EvaluateFunction(eq, variable, point); + constant = DecimalMath.Abs(constant) <= 0.001m ? 0 : constant; + string newEq = constant != 0 ? constant.ToString("0." + new string('#', 339)) : ""; + for (int i = 1; i < degree + 1; i++) + { + //decimal der = Method_Derivative(eq, i, variable, point); + decimal der = Method_NumericalDifferentiation(eq, i, variable, point, 4, h); + decimal fact = Factorial(i); + decimal coeff = (der / fact); + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (point < 0) + { + addingSTR = "+" + DecimalMath.Abs(point).ToString("0." + new string('#', 339)); + } + else if (point > 0) + { + addingSTR = "-" + point.ToString("0." + new string('#', 339)); + } + + varSTR += coeff + "*(" + variable + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339)) + ""); + newEq += varSTR; + } + return newEq; + } + /*public static string Method_TaylorSeries2(string eq, int degree, string variable, decimal point) + { + decimal constant = Method_EvaluateFunction(eq, variable, point); + constant = DecimalMath.Abs(constant) <= 0.0001m ? 0 : constant; + + string newEq = constant.ToString("0." + new string('#', 339)); + for (int i = 1; i < degree + 1; i++) + { + decimal der = Method_Derivative(eq, i, variable, point); + //Debug.Log("derivative at " + i + ": " + der.ToString()); + if (DecimalMath.Abs(der) <= 0.0001m) + { + der = 0; + Debug.Log(der + ": " + 0); + } + decimal fact = Factorial(i); + decimal coeff = (der / fact); + + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (point < 0) + { + addingSTR = "+" + DecimalMath.Abs(point).ToString("0." + new string('#', 339)); + } + else if (point > 0) + { + addingSTR = "-" + point.ToString("0." + new string('#', 339)); + } + + varSTR += coeff + "*(" + variable + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339))); + newEq += varSTR; + } + return newEq; + }*/ + public static string MethodMultiVar_TaylorSeries(string eq, int degree, Dictionary points, decimal h = 0.001m) + { + decimal constant = MethodMultiVar_EvaluateFunction(eq, points); + constant = DecimalMath.Abs(constant) <= 0.0001m ? 0 : constant; + string newEq = constant != 0 ? constant.ToString("0." + new string('#', 339)) : ""; + for (int i = 1; i < degree + 1; i++) + { + foreach (KeyValuePair pt in points) + { + decimal partDer = Method_NumericalPartialDifferentiation(eq, i, pt.Key, points, 4, h); + //decimal partDer = Method_PartialDerivative(eq, i, pt.Key, points, h); + decimal fact = Factorial(i); + decimal coeff = partDer / fact; + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (pt.Value < 0) + { + addingSTR = "+" + DecimalMath.Abs(pt.Value).ToString("0." + new string('#', 339)); + } + else if (pt.Value > 0) + { + addingSTR = "-" + pt.Value.ToString("0." + new string('#', 339)); + } + varSTR += coeff + "*(" + pt.Key + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339))); + newEq += varSTR; + } + } + //Debug.Log(newEq + " + " + constant + " | " + eq); + if (constant == 0) newEq.Substring(0, 1); + return newEq; + } + + + public static decimal Method_NewtonRaphson(string eq, string variable, decimal initialValue, int iterationCount, decimal h = 0.001m) + { + decimal Lipschitz = Method_EvaluateFunction(eq, variable, initialValue) * Method_NumericalDifferentiation(eq, 2, variable, initialValue, 6, h) / + Method_NumericalDifferentiation(eq, 1, variable, initialValue, 6, h) / Method_NumericalDifferentiation(eq, 1, variable, initialValue, 6, h); + + if (Lipschitz < 1) { } + else + { + Debug.LogError("Wrong initial value!"); + return 0; + } + + decimal init = initialValue; + for (int i = 0; i < iterationCount; i++) + { + //decimal next = init - Method_EvaluateFunction(eq, variable, init) / Method_Derivative(eq, 1, variable, init, h); + decimal next = init - Method_EvaluateFunction(eq, variable, init) / Method_NumericalDifferentiation(eq, 1, variable, init, 6, h); + init = next; + } + return init; + } + public static decimal Method_BisectionMethod(string eq, string variable, decimal lowerValue, decimal higherValue, int iterationCount) + { + if (lowerValue >= higherValue) + return 0; + + decimal mp = (lowerValue + higherValue) / 2; + + for (int i = 0; i < iterationCount; i++) + { + mp = (lowerValue + higherValue) / 2; + + decimal evLower = Method_EvaluateFunction(eq, variable, lowerValue); + decimal evHigher = Method_EvaluateFunction(eq, variable, higherValue); + decimal evMiddle = Method_EvaluateFunction(eq, variable, mp); + + if (evLower * evMiddle < 0) + { + higherValue = mp; + } + else + { + lowerValue = mp; + } + } + + return mp; + } + + + public static decimal Method_Derivative(string eq, int degree, string variable, decimal point, decimal h = 0.001m) + { + decimal sum = 0; + for (int i = 0; i <= degree; i++) + { + sum += DecimalMath.Pow(-1, i) * Combination(degree, i) * Method_EvaluateFunction(eq, variable, point + (degree - i) * h); + //Debug.Log(sum); + } + + decimal res = sum / DecimalMath.Pow(h, degree); + + //Debug.Log(sum.ToString("0." + new string('#', 339)) + " || " + Math.Pow((double)h, degree).ToString() + " | " + Math.Pow((double)h, degree).ToString("0." + new string('#', 339))); + //Debug.Log(res + " || " + sum.ToString("0." + new string('#', 339)) + " || " + DecimalMath.Pow(h, degree).ToString() + " | " + DecimalMath.Pow(h, degree).ToString("0." + new string('#', 339))); + + return res; + } + public static decimal Method_PartialDerivative(string eq, int degree, string toVar, Dictionary points, decimal h = 0.001m) + { + decimal sum = 0; + Dictionary testPS = new Dictionary(); + foreach (KeyValuePair item in points) + { + testPS.Add(item.Key, item.Value); + } + decimal firstToVar = testPS[toVar]; + for (int i = 0; i <= degree; i++) + { + testPS[toVar] = firstToVar + (degree - i) * h; + sum += DecimalMath.Pow(-1, i) * Combination(degree, i) * MethodMultiVar_EvaluateFunction(eq, testPS); + } + decimal res = sum / DecimalMath.Pow(h, degree); + return res; + } + + + public static decimal Method_NumericalDifferentiation(string eq, int degree, string variable, decimal point, int accuracy = 2, decimal h = 0.001m) + { + decimal result = 0; + + int m = degree, n = accuracy; + int p = (2 * Mathf.FloorToInt((m + 1) / 2) - 2 + n) / 2; + + decimal[][] _matrix = new decimal[2 * p + 1][]; + decimal[] _rhsVector = new decimal[2 * p + 1], functionPointsX = new decimal[2 * p + 1], + functionPointsY = new decimal[2 * p + 1]; + + + for (int i = 0; i < _matrix.Length; i++) + { + _matrix[i] = new decimal[2 * p + 1]; + for (int j = 0; j < _matrix[i].Length; j++) + { + _matrix[i][j] = (decimal)Mathf.Pow(-p + j, i); + } + + + if (i != m) + { + _rhsVector[i] = 0; + } + else if (i == m) + { + _rhsVector[i] = Factorial(m); + } + + + functionPointsX[i] = point - (p - i) * h; + functionPointsY[i] = Method_EvaluateFunction(eq, variable, functionPointsX[i]); + } + + GeneralMatrix _A = new GeneralMatrix(_matrix); + GeneralMatrix _b = new GeneralMatrix(_rhsVector.Length, 1); + + for (int i = 0; i < _rhsVector.Length; i++) + { + _b.Array[i][0] = _rhsVector[i]; + } + + //decimal[] coeffs = Matrix.SolveEquation(_matrix, _rhsVector); + GeneralMatrix coeffs = _A.Solve(_b); + + decimal sum = 0; + + for (int i = 0; i < coeffs.Array.Length; i++) + { + sum += coeffs.Array[i][0] * functionPointsY[i]; + } + + result = sum / DecimalMath.Pow(h, degree); + + return result; + } + public static decimal Method_NumericalPartialDifferentiation(string eq, int degree, string toVar, Dictionary points, int accuracy = 2, decimal h = 0.001m) + { + decimal result = 0; + + int m = degree, n = accuracy; + int p = (2 * Mathf.FloorToInt((m + 1) / 2) - 2 + n) / 2; + + decimal[][] _matrix = new decimal[2 * p + 1][]; + Dictionary functionPointsDomain = new Dictionary(); + decimal[] _rhsVector = new decimal[2 * p + 1], functionPointsRange = new decimal[2 * p + 1]; + + + for (int i = 0; i < _matrix.Length; i++) + { + _matrix[i] = new decimal[2 * p + 1]; + for (int j = 0; j < _matrix[i].Length; j++) + { + _matrix[i][j] = (decimal)Mathf.Pow(-p + j, i); + } + + if (i != m) + { + _rhsVector[i] = 0; + } + else if (i == m) + { + _rhsVector[i] = Factorial(m); + } + } + + foreach (KeyValuePair item in points) + { + decimal[] ps = new decimal[2 * p + 1]; + + if (item.Key == toVar) + { + for (int i = 0; i < ps.Length; i++) + { + ps[i] = points[item.Key] - (p - i) * h; + } + } + else + { + for (int i = 0; i < ps.Length; i++) + { + ps[i] = points[item.Key]; + } + } + + functionPointsDomain.Add(item.Key, ps); + } + + + for (int i = 0; i < 2 * p + 1; i++) + { + Dictionary pair = new Dictionary(); + + foreach (KeyValuePair item in functionPointsDomain) + { + pair.Add(item.Key, item.Value[i]); + } + + functionPointsRange[i] = MethodMultiVar_EvaluateFunction(eq, pair); + } + + + GeneralMatrix _A = new GeneralMatrix(_matrix); + GeneralMatrix _b = new GeneralMatrix(_rhsVector.Length, 1); + + for (int i = 0; i < _rhsVector.Length; i++) + { + _b.Array[i][0] = _rhsVector[i]; + } + + //decimal[] coeffs = Matrix.SolveEquation(_matrix, _rhsVector); + GeneralMatrix coeffs = _A.Solve(_b); + + decimal sum = 0; + + for (int i = 0; i < coeffs.Array.Length; i++) + { + sum += coeffs.Array[i][0] * functionPointsRange[i]; + } + + result = sum / DecimalMath.Pow(h, degree); + + return result; + } + + #region testPow + /*public static decimal Pow(decimal x, uint y) + { + decimal A = 1m; + BitArray e = new BitArray(BitConverter.GetBytes(y)); + int t = e.Count; + + for (int i = t - 1; i >= 0; --i) + { + A *= A; + if (e[i] == true) + { + A *= x; + } + } + return A; + }*/ + #endregion + + public static int Factorial(int num) + { + if (num >= 2) + { + return num * Factorial(num -1); + } + else + { + return 1; + } + } + public static int Combination(int n, int k) + { + int top = Factorial(n); + int bot1 = Factorial(n - k); + int bot2 = Factorial(k); + + return top / bot1 / bot2; + } + public static int Permutation(int n, int k) + { + int top = Factorial(n); + int bot = Factorial(n - k); + + return top / bot; + } + + public static string GenerateCombinations(string chars, string prefix, int length) + { + StringBuilder sb = new StringBuilder(); + + GenerateCombinationsRecursive(prefix, chars, length, sb); + + return sb.ToString(); + } + static void GenerateCombinationsRecursive(string prefix, string chars, int length, StringBuilder sb) + { + if (length == 0) + { + sb.AppendLine(prefix); + return; + } + + foreach (char c in chars) + { + GenerateCombinationsRecursive(prefix + c, chars, length - 1, sb); + } + } +} + diff --git a/Assets/Scripts/NumericalMethods.cs.meta b/Assets/Scripts/NumericalMethods.cs.meta new file mode 100644 index 0000000..c2674fe --- /dev/null +++ b/Assets/Scripts/NumericalMethods.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eabb80de3b87ba64497fe5d6b0644c47 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Old.meta b/Assets/Scripts/Old.meta new file mode 100644 index 0000000..4721a3a --- /dev/null +++ b/Assets/Scripts/Old.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82b9a4758390a7b44822597c7c1b24a4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Old/EquationSystem.cs b/Assets/Scripts/Old/EquationSystem.cs new file mode 100644 index 0000000..cfdd5c2 --- /dev/null +++ b/Assets/Scripts/Old/EquationSystem.cs @@ -0,0 +1,158 @@ +ïğżusing System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EquationSystem : MonoBehaviour +{ + public static List Equations = new List(); + public static int VarCount = 3; +} + +public class Equation +{ + public string EquationString = ""; + public bool MultiVariable = false; + + public List Coefficients = new List(); + public List Variables = new List(); + public float Constant; + public List Operations = new List(); + + public Equation(List coeffs, float cons, List vars = null, bool multiVar = false) + { + Coefficients = coeffs; + Variables = vars; + Constant = cons; + MultiVariable = multiVar; + EquationString = ConvertEquationToString(); + } + public Equation(string eq) + { + List coeffs = new List(); + float cons = 0; + string testSTR = ""; + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '+' || eq[i] == '-') + { + testSTR = ""; + } + if (eq[i] == '*') + { + coeffs.Add(float.Parse(testSTR)); + testSTR = ""; + } + testSTR += eq[i]; + } + + char op = 'a'; + testSTR = ""; + for (int i = eq.Length - 1; i >= 0; i--) + { + if (eq[i] == '+' || eq[i] == '-') + { + op = eq[i]; + string newstr = ""; + for (int j = testSTR.Length - 1; j >= 0; j--) + { + newstr += testSTR[j]; + } + testSTR = op + newstr; + cons = (testSTR.Length > 0) ? float.Parse(testSTR) : 0f; + break; + } + testSTR += eq[i]; + } + + Coefficients = coeffs; + Constant = cons; + Variables = null; + MultiVariable = false; + } + + public string ConvertEquationToString() + { + string newEq = ""; + for(int i = 0; i < Coefficients.Count; i++) + { + if (i == Coefficients.Count - 1) + { + if (Coefficients[i] > 0) + { + newEq += "+" + Coefficients[i].ToString() + "*x"; + } + else if (Coefficients[i] < 0) + { + newEq += Coefficients[i].ToString() + "*x"; + } + else if (Coefficients[i] == 0) + { + continue; + } + } + else if (i == 0) + { + if (Coefficients[i] != 0) + { + newEq += Coefficients[i].ToString() + "*x^" + (Coefficients.Count - i).ToString(); + } + else + { + continue; + } + } + else + { + if (Coefficients[i] > 0) + { + newEq += "+" + Coefficients[i].ToString() + "*x^" + (Coefficients.Count - i).ToString(); + } + else if (Coefficients[i] < 0) + { + newEq += Coefficients[i].ToString() + "*x^" + (Coefficients.Count - i).ToString(); + } + else if (Coefficients[i] == 0) + { + continue; + } + } + } + if (Constant > 0) + { + newEq += "+" + Constant; + } + else if (Constant < 0) + { + newEq += Constant; + } + + string newSTR = ""; + for (int i = 0; i < newEq.Length; i++) + { + if (newEq[i] == ',') + { + newSTR += '.'; + } + else + { + newSTR += newEq[i]; + } + } + newEq = newSTR; + + return newEq; + } + + public void SubstituteEquation(Equation eq) + { + if (!MultiVariable) + { + + } + } +} + +public enum Operation +{ + ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION, EXPONENTIATION +} diff --git a/Assets/Scripts/Old/EquationSystem.cs.meta b/Assets/Scripts/Old/EquationSystem.cs.meta new file mode 100644 index 0000000..018f7cd --- /dev/null +++ b/Assets/Scripts/Old/EquationSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c57eddf0ac8df46468098df8caebdc48 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Old/EquationSystem2.cs b/Assets/Scripts/Old/EquationSystem2.cs new file mode 100644 index 0000000..d937ecb --- /dev/null +++ b/Assets/Scripts/Old/EquationSystem2.cs @@ -0,0 +1,36 @@ +ïğżusing System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EquationSystem2 : MonoBehaviour +{ + +} + + + +public class Equation2 +{ + public static char[] AllVariables = new char[] { 'x', 'y', 'z', 't', 'w', 'r' }; + + public string EquationString = ""; + + public enum Type { Variable, Value, UnaryOperator, Operator, Function, Result, Bracket, Comma, Error } + public struct Symbol + { + string SYM_Name; + double SYM_Value; + Type SYM_Type; + public override string ToString() + { + return SYM_Name; + } + } + + public ArrayList m_equation = new ArrayList(); + + public Equation2(string eq) + { + EquationString = eq; + } +} diff --git a/Assets/Scripts/Old/EquationSystem2.cs.meta b/Assets/Scripts/Old/EquationSystem2.cs.meta new file mode 100644 index 0000000..bd24e38 --- /dev/null +++ b/Assets/Scripts/Old/EquationSystem2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86ef5945fb00cd74db15c2c37e803dce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Old/FunctionEvaluator2.cs b/Assets/Scripts/Old/FunctionEvaluator2.cs new file mode 100644 index 0000000..9fde986 --- /dev/null +++ b/Assets/Scripts/Old/FunctionEvaluator2.cs @@ -0,0 +1,306 @@ +ïğżusing System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FunctionEvaluator2 : MonoBehaviour +{ + public List Chars = new List(); + List Operators = new List { '+', '-', '*', '/', '^' }; + + string Evaluate(string eq) + { + int deepestP = FindDeepestParenthesis(eq); + int closeDeepestP = (deepestP == -1) ? -1 : FindClosedParenthesis(eq, deepestP); + + if (closeDeepestP != -1) + { + string newEq = eq.Substring(deepestP + 1, closeDeepestP - deepestP - 1); + return Evaluate(newEq); + } + else + { + Chars.Clear(); + string newChar = ""; + bool containsOperator = true; + + while (containsOperator) + { + for (int i = 0; i < eq.Length; i++) + { + if (Operators.Contains(eq[i])) + { + Chars.Add(newChar); + newChar = eq[i].ToString(); + Chars.Add(newChar); + newChar = ""; + } + else + { + if (eq[i] != '(' && eq[i] != ')') + { + newChar += eq[i]; + } + if (i == eq.Length - 1) + { + Chars.Add(newChar); + } + } + } + + if (Chars.Contains("^")) + { + int pow = (int)Mathf.Pow(GetLeftNumber(eq, FindClosestPower(eq)), GetRightNumber(eq, FindClosestPower(eq))); + + eq = ReplaceWith(eq, pow.ToString(), GetLeftNumberIndex(eq, FindClosestPower(eq)), GetRightNumberIndex(eq, FindClosestPower(eq))); + } + else if (Chars.Contains("*")) + { + int mult = GetLeftNumber(eq, FindClosestMultiplication(eq)) * GetRightNumber(eq, FindClosestMultiplication(eq)); + + eq = ReplaceWith(eq, mult.ToString(), GetLeftNumberIndex(eq, FindClosestMultiplication(eq)), GetRightNumberIndex(eq, FindClosestMultiplication(eq))); + } + else if (Chars.Contains("/")) + { + int div = (int)(GetLeftNumber(eq, FindClosestDivision(eq)) / GetRightNumber(eq, FindClosestDivision(eq))); + + eq = ReplaceWith(eq, div.ToString(), GetLeftNumberIndex(eq, FindClosestDivision(eq)), GetRightNumberIndex(eq, FindClosestDivision(eq))); + } + else if (Chars.Contains("+")) + { + int sum = GetLeftNumber(eq, FindClosestAddition(eq)) + GetRightNumber(eq, FindClosestAddition(eq)); + + eq = ReplaceWith(eq, sum.ToString(), GetLeftNumberIndex(eq, FindClosestAddition(eq)), GetRightNumberIndex(eq, FindClosestAddition(eq))); + } + else if (Chars.Contains("-")) + { + int sub = GetLeftNumber(eq, FindClosestSubtraction(eq)) - GetRightNumber(eq, FindClosestSubtraction(eq)); + + eq = ReplaceWith(eq, sub.ToString(), GetLeftNumberIndex(eq, FindClosestSubtraction(eq)), GetRightNumberIndex(eq, FindClosestSubtraction(eq))); + } + + + bool contains = false; + for (int i = 0; i < eq.Length; i++) + { + if (Operators.Contains(eq[i])) + { + contains = true; + } + } + + containsOperator = contains; + } + + + return eq; + } + } + + string ReplaceWith(string replacedStr, string replacingStr, int start, int end) + { + string ans = replacedStr; + ans = ans.Remove(start, end - start); + + string newStr = ""; + for (int i = start; i < ans.Length; i++) + { + newStr += ans[i]; + } + ans = ans.Remove(start); + + ans += replacingStr; + ans += newStr; + + return ans; + } + + int GetLeftNumber(string eq, int index) + { + string ans = ""; + for (int i = 0; i < index; i++) + { + ans += eq[i]; + if (Operators.Contains(eq[i])) + { + ans = ""; + } + Debug.Log(ans + " / " + index + " / " + i); + } + Debug.Log(ans + " / " + index); + + return int.Parse(ans); + } + int GetLeftNumberIndex(string eq, int index) + { + int ans = -1; + for (int i = index - 1; i >= 0; i--) + { + if (Operators.Contains(eq[i])) + { + ans = i + 1; + break; + } + if (i == 0) + ans = 0; + } + return ans; + } + int GetRightNumber(string eq, int index) + { + string ans = ""; + for (int i = index + 1; i < eq.Length; i++) + { + if (Operators.Contains(eq[i])) + { + break; + } + else + { + ans += eq[i]; + } + } + return int.Parse(ans); + } + int GetRightNumberIndex(string eq, int index) + { + int ans = -1; + for (int i = index + 1; i < eq.Length; i++) + { + if (Operators.Contains(eq[i])) + { + ans = i - 1; + break; + } + } + return ans; + } + + int FindDeepestParenthesis(string eq) + { + int openedCount = 0, deepestIndex = -1, maxOpenedCount = 0; + if (eq.Contains("(")) + { + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '(') + { + openedCount++; + } + else if (eq[i] == ')') + { + openedCount--; + } + + if (openedCount > maxOpenedCount) + { + maxOpenedCount = openedCount; + deepestIndex = i; + } + } + } + return deepestIndex; + } + + int FindClosedParenthesis(string eq, int index) + { + if (eq[index] == '(') + { + int openedCount = 1, result = -1; + bool counted = false; + for (int i = index + 1; i < eq.Length; i++) + { + if (eq[i] == '(') + { + if (!counted) + counted = true; + openedCount++; + } + + else if (eq[i] == ')') + { + if (!counted) + counted = true; + openedCount--; + } + + if (counted && openedCount == 0) + { + result = i; + break; + } + } + return result; + } + else + { + return -1; + } + } + + int FindClosestPower(string eq) + { + int ans = -1; + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '^') + { + ans = i; + break; + } + } + return ans; + } + + int FindClosestMultiplication(string eq) + { + int ans = -1; + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '*') + { + ans = i; + break; + } + } + return ans; + } + int FindClosestDivision(string eq) + { + int ans = -1; + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '/') + { + ans = i; + break; + } + } + return ans; + } + int FindClosestAddition(string eq) + { + int ans = -1; + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '+') + { + ans = i; + break; + } + } + return ans; + } + int FindClosestSubtraction(string eq) + { + int ans = -1; + for (int i = 0; i < eq.Length; i++) + { + if (eq[i] == '-') + { + ans = i; + break; + } + } + return ans; + } +} diff --git a/Assets/Scripts/Old/FunctionEvaluator2.cs.meta b/Assets/Scripts/Old/FunctionEvaluator2.cs.meta new file mode 100644 index 0000000..11a4861 --- /dev/null +++ b/Assets/Scripts/Old/FunctionEvaluator2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 271c85a86fed81142b038a88741dda40 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Old/NumericalMethods2.cs b/Assets/Scripts/Old/NumericalMethods2.cs new file mode 100644 index 0000000..5c8d448 --- /dev/null +++ b/Assets/Scripts/Old/NumericalMethods2.cs @@ -0,0 +1,246 @@ +ïğżusing System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NumericalMethods2 +{ + public List Equations = new List(); + + #region Create + /*public void Create() + { + Equation eq1 = new Equation(new List { -6, 4, -1 }, -4); + Equation eq2 = new Equation(new List { 1, 4, -1 }, 2); + Equation eq3 = new Equation(new List { -2, 4, -7 }, 18); + Equations.Add(eq1); + Equations.Add(eq2); + Equations.Add(eq3); + + + Equations.Clear(); + + for (int i = 0; i < EquationSystem.VarCount; i++) + { + List coeffs = new List(); + for (int j = 0; j < EquationSystem.VarCount; j++) + { + coeffs.Add(Random.Range(-10f, 10f)); + } + Equation eq = new Equation(coeffs, Random.Range(-10f, 10f)); + Equations.Add(eq); + } + + string log = ""; + for (int i = 0; i < EquationSystem.VarCount; i++) + { + for (int j = 0; j < EquationSystem.VarCount; j++) + { + log += Equations[i].Coefficients[j] + ((j == EquationSystem.VarCount - 1) ? " " + Equations[i].Constant + "\n" : " "); + } + } + Debug.Log(log); + + MethodLinear_GaussSeidal(Equations, new List { 2f, 2f, 2f }, 3); + }*/ + #endregion + + public static List Method_GaussSeidal(List _eq, List initialValues, int iterationCount) + { + //yakÄħnsama ĊŸartÄħ (3x3 matris i�§in) -> |a11|>|a12|+|a13| && |a22|>|a21|+|a23| && |a33|>|a31|+|a32| + + bool convergence = true; + List dominantTerms = new List(); + for (int i = 0; i < _eq.Count; i++) + { + int currentDominant = -1; + bool dominantFound = false; + for (int j = 0; j < _eq.Count; j++) + { + float sum0 = 0; + + for (int k = 0; k < _eq.Count; k++) + { + if (k != j) + { + sum0 += Mathf.Abs(_eq[i].Coefficients[k]); + } + } + + if (Mathf.Abs(_eq[i].Coefficients[j]) > sum0) + { + currentDominant = j; + dominantFound = true; + break; + } + } + + if (dominantFound) + { + dominantTerms.Add(currentDominant); + } + else + { + dominantTerms.Add(-1); + } + } + + for (int i = 0; i < dominantTerms.Count && convergence; i++) + { + for (int j = 0; j < dominantTerms.Count; j++) + { + if (i != j) + { + if (dominantTerms[i] == dominantTerms[j]) + { + convergence = false; + break; + } + } + } + } + + if (convergence == false) + { + Debug.LogError("This matris cannot be solved with Gauss-Seidal Method!"); + return new List(); + } + else + { + List answers = initialValues; + for (int i = 0; i < iterationCount; i++) + { + for (int j = 0; j < _eq.Count; j++) + { + float sum = _eq[j].Constant + _eq[j].Coefficients[j] * answers[j]; + for (int k = 0; k < _eq.Count; k++) + { + sum += -_eq[j].Coefficients[k] * answers[k]; + } + answers[j] = sum / _eq[j].Coefficients[j]; + } + } + string ansdeb = ""; + for (int i = 0; i < answers.Count; i++) + { + ansdeb += answers[i] + ((i == answers.Count - 1) ? "" : ", "); + } + Debug.Log(ansdeb); + + return answers; + } + } + + + public static float Method_EvaluateFunction(Equation eq, float point) + { + float result = 0; + if (!eq.MultiVariable) + { + float sum = 0; + for (int i = 0; i < eq.Coefficients.Count; i++) + { + sum += eq.Coefficients[i] * Mathf.Pow(point, eq.Coefficients.Count - i); + } + result = sum + eq.Constant; + } + else + { + Debug.LogError("Method_EvaluateFunction: The equation is multivariable!"); + } + return result; + } + + + public static Equation Method_TaylorSeries(Equation eq, int degree) + { + float constant = Method_EvaluateFunction(eq, 0); + List coeffs = new List(); + for (int i = 1; i < degree + 1; i++) + { + float c = Method_Derivative(eq, i, 0, 0.1f) / Factorial(i); + coeffs.Add(c); + } + + coeffs.Reverse(); + + Equation taylorEq = new Equation(coeffs, constant); + return taylorEq; + } + + public static float Method_NewtonRaphson(Equation eq, float initialValue, int iterationCount) + { + float Lipschitz = Method_EvaluateFunction(eq, initialValue) * Method_SecondDerivative(eq, initialValue, 0.1f) / + Method_FirstDerivative(eq, initialValue, 0.1f) / Method_FirstDerivative(eq, initialValue, 0.1f); + + if (Lipschitz < 1) { } + else + { + Debug.LogError("Wrong initial value!"); + return 0; + } + + float init = initialValue; + for (int i = 0; i < iterationCount; i++) + { + float next = init - Method_EvaluateFunction(eq, init) / Method_FirstDerivative(eq, init, 0.1f); + init = next; + } + return init; + } + + public static float Method_Derivative(Equation eq, int degree, float point, float h) + { + Equation mainEq = eq, resEq = eq; + float sum = 0; + for (int i = 0; i <= degree; i++) + { + sum += Mathf.Pow(-1, i) * Combination(degree, i) * Method_EvaluateFunction(eq, point + (degree - i) * h); + } + float res = sum / Mathf.Pow(h, degree); + return res; + } + + public static float Method_FirstDerivative(Equation eq, float point, float h) + { + float fxi = Method_EvaluateFunction(eq, point), fxi1 = Method_EvaluateFunction(eq, point - h), fxi2 = Method_EvaluateFunction(eq, point - 2 * h); + return (3 * fxi + fxi2 - 4 * fxi1) / 2 / h; + } + public static float Method_SecondDerivative(Equation eq, float point, float h) + { + float fxi = Method_EvaluateFunction(eq, point), fxi1 = Method_EvaluateFunction(eq, point - h), fxi2 = Method_EvaluateFunction(eq, point - 2 * h); + return (fxi + fxi2 - 2 * fxi1) / h / h; + } + public static float Method_ThirdDerivative(Equation eq, float point, float h) + { + float fxi = Method_EvaluateFunction(eq, point), fxi1 = Method_EvaluateFunction(eq, point - h), fxi2 = Method_EvaluateFunction(eq, point - 2 * h), + fxi3 = Method_EvaluateFunction(eq, point - 3 * h), fxi4 = Method_EvaluateFunction(eq, point - 4 * h); + return (3 * fxi4 - 14 * fxi3 + 24 * fxi2 - 18 * fxi1 + 5 * fxi) / 2 / h / h / h; + + } + public static float Method_FourthDerivative(Equation eq, float point, float h) + { + float fxi = Method_EvaluateFunction(eq, point), fxi1 = Method_EvaluateFunction(eq, point - h), fxi2 = Method_EvaluateFunction(eq, point - 2 * h), + fxi3 = Method_EvaluateFunction(eq, point - 3 * h), fxi4 = Method_EvaluateFunction(eq, point - 4 * h), fxi5 = Method_EvaluateFunction(eq, point - 5 * h); + return (-2 * fxi5 + 11 * fxi4 - 24 * fxi3 + 26 * fxi2 - 14 * fxi1 + 3 * fxi) / h / h / h / h; + } + + public static int Factorial(int num) + { + if (num >= 1) + { + return num * Factorial(num - 1); + } + else + { + return 1; + } + } + public static int Combination(int n, int k) + { + int top = Factorial(n); + int bot1 = Factorial(n - k); + int bot2 = Factorial(k); + + return top / bot1 / bot2; + } +} diff --git a/Assets/Scripts/Old/NumericalMethods2.cs.meta b/Assets/Scripts/Old/NumericalMethods2.cs.meta new file mode 100644 index 0000000..1df8e41 --- /dev/null +++ b/Assets/Scripts/Old/NumericalMethods2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ba64140c4b91bfe479878f521a339495 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UIController.cs b/Assets/Scripts/UIController.cs new file mode 100644 index 0000000..833ede0 --- /dev/null +++ b/Assets/Scripts/UIController.cs @@ -0,0 +1,184 @@ +ïğżusing System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class UIController : MonoBehaviour +{ + public GameObject PNLMainMenu, PNLEquationRootFinder, PNLEquationSystemSolver, INPTEquation, INPTMinX, INPTMaxX, + INPTRoot, INPTRoots, TGLNewtonRaphson, INPTNRInitialPoint, INPTEqVariable, INPTIterationCount, INPTEquationCount, + INPTEquationPrefab, INPTVariablePrefab, INPTInitialPointPrefab, ESEquationParent, ESVariableParent, ESInitialPointParent, + INPTESIterationCount; + public string INPTRootText, INPTRootsText; + public bool isNewtonRaphson; + + public void BTNEquationRootFinder() + { + PNLMainMenu.SetActive(false); + PNLEquationRootFinder.SetActive(true); + PNLEquationSystemSolver.SetActive(false); + } + public void BTNEquationSystemSolver() + { + PNLMainMenu.SetActive(false); + PNLEquationRootFinder.SetActive(false); + PNLEquationSystemSolver.SetActive(true); + } + + public void BTNMainMenuERF() + { + PNLMainMenu.SetActive(true); + PNLEquationRootFinder.SetActive(false); + PNLEquationSystemSolver.SetActive(false); + + INPTNRInitialPoint.GetComponent().text = ""; + INPTMaxX.GetComponent().text = ""; + INPTMinX.GetComponent().text = ""; + INPTEqVariable.GetComponent().text = ""; + INPTIterationCount.GetComponent().text = ""; + INPTEquation.GetComponent().text = ""; + } + public void BTNMainMenuESS() + { + PNLMainMenu.SetActive(true); + PNLEquationRootFinder.SetActive(false); + PNLEquationSystemSolver.SetActive(false); + + for (int i = 0; i < Equations.Count; i++) + { + Destroy(Equations[i]); + Destroy(Variables[i]); + Destroy(InitialPoints[i]); + } + + Equations.Clear(); + Variables.Clear(); + InitialPoints.Clear(); + + INPTEquationCount.GetComponent().text = "0"; + } + + public void BTNFindEquationRoot() + { + string eq = INPTEquation.GetComponent().text; + string variable = INPTEqVariable.GetComponent().text; + int iterCount = int.Parse(INPTIterationCount.GetComponent().text); + + decimal res = 0; + + if (isNewtonRaphson) + { + decimal initialP = decimal.Parse(INPTNRInitialPoint.GetComponent().text); + res = NumericalMethods.Method_NewtonRaphson(eq, variable, initialP, iterCount); + } + else + { + decimal minX = decimal.Parse(INPTMinX.GetComponent().text); + decimal maxX = decimal.Parse(INPTMaxX.GetComponent().text); + res = NumericalMethods.Method_BisectionMethod(eq, variable, minX, maxX, iterCount); + } + INPTRootText = res.ToString(); + INPTRoot.GetComponent().text = res.ToString(); + } + public void TGLNewtonRaphsonBisection() + { + if (TGLNewtonRaphson.GetComponent().isOn) + { + isNewtonRaphson = true; + INPTNRInitialPoint.SetActive(true); + INPTMaxX.SetActive(false); + INPTMinX.SetActive(false); + + INPTNRInitialPoint.GetComponent().text = ""; + INPTMaxX.GetComponent().text = ""; + INPTMinX.GetComponent().text = ""; + } + else + { + isNewtonRaphson = false; + INPTNRInitialPoint.SetActive(false); + INPTMaxX.SetActive(true); + INPTMinX.SetActive(true); + + INPTNRInitialPoint.GetComponent().text = ""; + INPTMaxX.GetComponent().text = ""; + INPTMinX.GetComponent().text = ""; + } + } + + public void INPTRootChanged() + { + INPTRoot.GetComponent().text = INPTRootText; + } + public void INPTRootsChanged() + { + INPTRoots.GetComponent().text = INPTRootsText; + } + + List Equations = new List(), Variables = new List(), InitialPoints = new List(); + public void INPTEquationCountChanged() + { + int eqCount = INPTEquationCount.GetComponent().text != "" ? int.Parse(INPTEquationCount.GetComponent().text) : 0; + + for (int i = 0; i < Equations.Count; i++) + { + Destroy(Equations[i]); + Destroy(Variables[i]); + Destroy(InitialPoints[i]); + } + + Equations.Clear(); + Variables.Clear(); + InitialPoints.Clear(); + + for (int i = 0; i < eqCount; i++) + { + GameObject GO1 = Instantiate(INPTEquationPrefab); + GO1.transform.SetParent(ESEquationParent.transform); + GO1.transform.localScale = Vector3.one; + Equations.Add(GO1); + + GameObject GO2 = Instantiate(INPTVariablePrefab); + GO2.transform.SetParent(ESVariableParent.transform); + GO2.transform.localScale = Vector3.one; + Variables.Add(GO2); + + GameObject GO3 = Instantiate(INPTInitialPointPrefab); + GO3.transform.SetParent(ESInitialPointParent.transform); + GO3.transform.localScale = Vector3.one; + InitialPoints.Add(GO3); + } + } + + Dictionary dict = new Dictionary(); + public void BTNFindEquationSystemRoots() + { + List Eqs = new List(); + + dict.Clear(); + for (int i = 0; i < Equations.Count; i++) + { + dict.Add(Variables[i].GetComponent().text, decimal.Parse(InitialPoints[i].GetComponent().text)); + Eqs.Add(Equations[i].GetComponent().text); + } + + int iterCount = int.Parse(INPTESIterationCount.GetComponent().text); + + Dictionary results = NumericalMethods.MethodMultiVar_SolveEquationSystem(Eqs, dict, iterCount); + + string sum = ""; + + foreach (KeyValuePair p in results) + { + sum += p.Key + ": " + p.Value + ", "; + } + + INPTRootsText = sum; + INPTRoots.GetComponent().text = INPTRootsText; + } + + public void ExitTheProgram() + { + Application.Quit(); + } +} diff --git a/Assets/Scripts/UIController.cs.meta b/Assets/Scripts/UIController.cs.meta new file mode 100644 index 0000000..1f5b463 --- /dev/null +++ b/Assets/Scripts/UIController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a1b44d2e6ad183849baa8b9136dac8ab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/MathApp/MathApp/Controls/GraphPlotterControl.Designer.cs b/MathApp/MathApp/Controls/GraphPlotterControl.Designer.cs new file mode 100644 index 0000000..080ccf5 --- /dev/null +++ b/MathApp/MathApp/Controls/GraphPlotterControl.Designer.cs @@ -0,0 +1,174 @@ + +namespace MathApp.Controls +{ + partial class GraphPlotterControl + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.lblTitle = new System.Windows.Forms.Label(); + this.pnlControls = new System.Windows.Forms.Panel(); + this.pnlGraphConfig = new System.Windows.Forms.Panel(); + this.pnlCanvas = new System.Windows.Forms.Panel(); + + this.lblEquation = new System.Windows.Forms.Label(); + this.txtEquation = new System.Windows.Forms.TextBox(); + this.lblMinX = new System.Windows.Forms.Label(); + this.txtMinX = new System.Windows.Forms.TextBox(); + this.lblMaxX = new System.Windows.Forms.Label(); + this.txtMaxX = new System.Windows.Forms.TextBox(); + this.btnPlot = new System.Windows.Forms.Button(); + + this.pnlControls.SuspendLayout(); + this.pnlGraphConfig.SuspendLayout(); + this.SuspendLayout(); + + // + // lblTitle + // + this.lblTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lblTitle.Font = new System.Drawing.Font("Segoe UI Light", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.lblTitle.ForeColor = System.Drawing.Color.White; + this.lblTitle.Location = new System.Drawing.Point(0, 0); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(800, 60); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "Graph Plotter"; + this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + // pnlControls + // + this.pnlControls.Controls.Add(this.pnlGraphConfig); + this.pnlControls.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlControls.Location = new System.Drawing.Point(0, 60); + this.pnlControls.Name = "pnlControls"; + this.pnlControls.Size = new System.Drawing.Size(800, 80); + this.pnlControls.TabIndex = 1; + + // + // pnlGraphConfig + // + this.pnlGraphConfig.Controls.Add(this.btnPlot); + this.pnlGraphConfig.Controls.Add(this.txtMaxX); + this.pnlGraphConfig.Controls.Add(this.lblMaxX); + this.pnlGraphConfig.Controls.Add(this.txtMinX); + this.pnlGraphConfig.Controls.Add(this.lblMinX); + this.pnlGraphConfig.Controls.Add(this.txtEquation); + this.pnlGraphConfig.Controls.Add(this.lblEquation); + this.pnlGraphConfig.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlGraphConfig.Location = new System.Drawing.Point(0, 0); + this.pnlGraphConfig.Name = "pnlGraphConfig"; + this.pnlGraphConfig.Size = new System.Drawing.Size(800, 80); + this.pnlGraphConfig.TabIndex = 0; + + int xPos = 20; int yPos = 25; + + // Equation + this.lblEquation.AutoSize = true; + this.lblEquation.ForeColor = System.Drawing.Color.White; + this.lblEquation.Text = "y = "; + this.lblEquation.Location = new System.Drawing.Point(xPos, yPos); + xPos += 30; + + this.txtEquation.Location = new System.Drawing.Point(xPos, yPos-3); + this.txtEquation.Size = new System.Drawing.Size(200, 23); + this.txtEquation.BackColor = System.Drawing.Color.FromArgb(40,40,40); + this.txtEquation.ForeColor = System.Drawing.Color.White; + this.txtEquation.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + xPos += 220; + + // Min X + this.lblMinX.AutoSize = true; + this.lblMinX.ForeColor = System.Drawing.Color.White; + this.lblMinX.Text = "Min X:"; + this.lblMinX.Location = new System.Drawing.Point(xPos, yPos); + xPos += 50; + + this.txtMinX.Location = new System.Drawing.Point(xPos, yPos-3); + this.txtMinX.Size = new System.Drawing.Size(50, 23); + this.txtMinX.Text = "-10"; + this.txtMinX.BackColor = System.Drawing.Color.FromArgb(40,40,40); + this.txtMinX.ForeColor = System.Drawing.Color.White; + this.txtMinX.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + xPos += 70; + + // Max X + this.lblMaxX.AutoSize = true; + this.lblMaxX.ForeColor = System.Drawing.Color.White; + this.lblMaxX.Text = "Max X:"; + this.lblMaxX.Location = new System.Drawing.Point(xPos, yPos); + xPos += 50; + + this.txtMaxX.Location = new System.Drawing.Point(xPos, yPos-3); + this.txtMaxX.Size = new System.Drawing.Size(50, 23); + this.txtMaxX.Text = "10"; + this.txtMaxX.BackColor = System.Drawing.Color.FromArgb(40,40,40); + this.txtMaxX.ForeColor = System.Drawing.Color.White; + this.txtMaxX.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + xPos += 70; + + // Plot Button + this.btnPlot.Location = new System.Drawing.Point(xPos, yPos-5); + this.btnPlot.Size = new System.Drawing.Size(100, 30); + this.btnPlot.Text = "Plot"; + this.btnPlot.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnPlot.BackColor = System.Drawing.Color.FromArgb(0, 120, 215); + this.btnPlot.ForeColor = System.Drawing.Color.White; + this.btnPlot.FlatAppearance.BorderSize = 0; + + + // + // pnlCanvas + // + this.pnlCanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlCanvas.Location = new System.Drawing.Point(0, 140); + this.pnlCanvas.Name = "pnlCanvas"; + this.pnlCanvas.Size = new System.Drawing.Size(800, 460); + this.pnlCanvas.TabIndex = 2; + this.pnlCanvas.BackColor = System.Drawing.Color.FromArgb(30, 30, 30); + this.pnlCanvas.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlCanvas_Paint); + this.pnlCanvas.Resize += new System.EventHandler(this.pnlCanvas_Resize); + + // + // GraphPlotterControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Controls.Add(this.pnlCanvas); + this.Controls.Add(this.pnlControls); + this.Controls.Add(this.lblTitle); + this.Name = "GraphPlotterControl"; + this.Size = new System.Drawing.Size(800, 600); + this.pnlControls.ResumeLayout(false); + this.pnlGraphConfig.ResumeLayout(false); + this.pnlGraphConfig.PerformLayout(); + this.ResumeLayout(false); + + } + + private System.Windows.Forms.Label lblTitle; + private System.Windows.Forms.Panel pnlControls; + private System.Windows.Forms.Panel pnlGraphConfig; + private System.Windows.Forms.Panel pnlCanvas; + + private System.Windows.Forms.Label lblEquation; + private System.Windows.Forms.TextBox txtEquation; + private System.Windows.Forms.Label lblMinX; + private System.Windows.Forms.TextBox txtMinX; + private System.Windows.Forms.Label lblMaxX; + private System.Windows.Forms.TextBox txtMaxX; + private System.Windows.Forms.Button btnPlot; + } +} diff --git a/MathApp/MathApp/Controls/GraphPlotterControl.cs b/MathApp/MathApp/Controls/GraphPlotterControl.cs new file mode 100644 index 0000000..ad1d431 --- /dev/null +++ b/MathApp/MathApp/Controls/GraphPlotterControl.cs @@ -0,0 +1,339 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using System.Collections.Generic; + +namespace MathApp.Controls +{ + public partial class GraphPlotterControl : UserControl + { + private List points = new List(); + private List markedPoints = new List(); // Points marked by user + + // Logical ranges + private float rangeMinX = -10; + private float rangeMaxX = 10; + private float rangeMinY = -10; + private float rangeMaxY = 10; + + private string currentEq = ""; + + // Mouse interaction state + private bool isDragging = false; + private Point lastMousePos; + + public GraphPlotterControl() + { + InitializeComponent(); + btnPlot.Click += BtnPlot_Click; + + // Enable double buffering + SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); + UpdateStyles(); + + // Attach mouse events to the canvas panel + pnlCanvas.MouseDown += PnlCanvas_MouseDown; + pnlCanvas.MouseMove += PnlCanvas_MouseMove; + pnlCanvas.MouseUp += PnlCanvas_MouseUp; + pnlCanvas.MouseClick += PnlCanvas_MouseClick; + pnlCanvas.Resize += pnlCanvas_Resize; + pnlCanvas.Paint += pnlCanvas_Paint; + } + + private void BtnPlot_Click(object sender, EventArgs e) + { + currentEq = txtEquation.Text; + markedPoints.Clear(); // Clear marks on new plot? Or keep them? Let's clear for fresh start. + if (string.IsNullOrWhiteSpace(currentEq)) return; + + rangeMinX = parse(txtMinX.Text, -10); + rangeMaxX = parse(txtMaxX.Text, 10); + + GeneratePoints(); + pnlCanvas.Invalidate(); + } + + private float parse(string s, float def) + { + if (float.TryParse(s, out float v)) return v; + return def; + } + + private void GeneratePoints() + { + points.Clear(); + float step = (rangeMaxX - rangeMinX) / 2000f; // Higher resolution + + float tempMinY = float.MaxValue; + float tempMaxY = float.MinValue; + + for (float x = rangeMinX; x <= rangeMaxX; x += step) + { + try + { + decimal val = NumericalMethods.Method_EvaluateFunction(currentEq, "x", (decimal)x); + float y = (float)val; + + // Clamp excessively large values to avoid float overflow issues in GDI+ + if (y > 10000) y = 10000; + if (y < -10000) y = -10000; + + points.Add(new PointF(x, y)); + + if (y < tempMinY) tempMinY = y; + if (y > tempMaxY) tempMaxY = y; + } + catch + { + // Ignore calculation errors (e.g. division by zero, out of domain) + } + } + + // Auto-scale Y if it's the first plot or if we want to snap to range + // But if we are panning, we probably shouldn't auto-reset Y every time unless explicit. + // For now, let's set Y range based on data with some padding + if (tempMinY < tempMaxY) + { + float h = tempMaxY - tempMinY; + if (h == 0) h = 10; + rangeMinY = tempMinY - h * 0.1f; + rangeMaxY = tempMaxY + h * 0.1f; + } + else + { + rangeMinY = -10; + rangeMaxY = 10; + } + } + + // --- Mouse Interaction --- + + protected override void OnMouseWheel(MouseEventArgs e) + { + // Zoom Factor + float zoom = (e.Delta > 0) ? 0.9f : 1.1f; + + // Calculate center + float rangeW = rangeMaxX - rangeMinX; + float rangeH = rangeMaxY - rangeMinY; + + float midX = (rangeMaxX + rangeMinX) / 2; + float midY = (rangeMaxY + rangeMinY) / 2; + + // Apply zoom centered + float halfW = (rangeW * zoom) / 2; + float halfH = (rangeH * zoom) / 2; + + rangeMinX = midX - halfW; + rangeMaxX = midX + halfW; + rangeMinY = midY - halfH; + rangeMaxY = midY + halfH; + + GeneratePoints(); + pnlCanvas.Invalidate(); + + base.OnMouseWheel(e); // Let it bubble if needed + } + + private void PnlCanvas_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + isDragging = true; + lastMousePos = e.Location; + Cursor = Cursors.SizeAll; + } + } + + private void PnlCanvas_MouseMove(object sender, MouseEventArgs e) + { + if (isDragging) + { + float dx = e.X - lastMousePos.X; + float dy = e.Y - lastMousePos.Y; + + float rangeW = rangeMaxX - rangeMinX; + float rangeH = rangeMaxY - rangeMinY; + + float w = pnlCanvas.Width; + float h = pnlCanvas.Height; + + // Scale pixel delta to logical delta + // Note: dy is inverted because screen Y grows down, but math Y grows up + float moveX = -dx * (rangeW / w); + float moveY = dy * (rangeH / h); + + rangeMinX += moveX; + rangeMaxX += moveX; + rangeMinY += moveY; + rangeMaxY += moveY; + + lastMousePos = e.Location; + + // Re-generate points if we moved significantly to ensure we cover the new X range? + // Or just shift the view? + // If we shift X, we need new data points for the new X area. + // So we should re-generate. + GeneratePoints(); + + pnlCanvas.Invalidate(); + } + } + + private void PnlCanvas_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + isDragging = false; + Cursor = Cursors.Default; + } + } + + private void PnlCanvas_MouseClick(object sender, MouseEventArgs e) + { + // Right click or simple click (if not dragging) to mark point + if (!isDragging && e.Button == MouseButtons.Left) + { + // Unmap screen to logical + float w = pnlCanvas.Width; + float h = pnlCanvas.Height; + + float xPct = e.X / w; + float yPct = (h - e.Y) / h; // Invert Y + + float logX = rangeMinX + xPct * (rangeMaxX - rangeMinX); + float logY = rangeMinY + yPct * (rangeMaxY - rangeMinY); + + markedPoints.Add(new PointF(logX, logY)); + pnlCanvas.Invalidate(); + } + } + + // --- Rendering --- + + private void pnlCanvas_Paint(object sender, PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + + float w = pnlCanvas.Width; + float h = pnlCanvas.Height; + + // Map functions + float MapX(float x) => (x - rangeMinX) / (rangeMaxX - rangeMinX) * w; + float MapY(float y) => h - ((y - rangeMinY) / (rangeMaxY - rangeMinY) * h); + + // 1. Draw Grid + DrawGrid(g, w, h, MapX, MapY); + + // 2. Draw Axes + using (Pen axisPen = new Pen(Color.White, 2)) + { + float y0 = MapY(0); + float x0 = MapX(0); + + if (y0 >= 0 && y0 <= h) g.DrawLine(axisPen, 0, y0, w, y0); + if (x0 >= 0 && x0 <= w) g.DrawLine(axisPen, x0, 0, x0, h); + } + + // 3. Draw Function + if (points.Count > 1) + { + using (Pen graphPen = new Pen(Color.Cyan, 2)) + { + List screenPoints = new List(); + foreach (var p in points) + { + screenPoints.Add(new PointF(MapX(p.X), MapY(p.Y))); + } + + // Draw valid segments + // We shouldn't connect jumps between valid/invalid or huge leaps + // For simplicity, we draw lines. + try + { + // Clipping helps performance but GDI+ handles basic out-of-bounds well + // unless coordinates are floats.NaN or Infinity. + g.DrawLines(graphPen, screenPoints.ToArray()); + } + catch { } + } + } + + // 4. Draw Marked Points + using(Brush markBrush = new SolidBrush(Color.Yellow)) + using(Pen markPen = new Pen(Color.Red, 2)) + using(Font markFont = new Font("Segoe UI", 9)) + { + foreach(var p in markedPoints) + { + float sx = MapX(p.X); + float sy = MapY(p.Y); + + // Draw X mark + float r = 5; + g.DrawLine(markPen, sx - r, sy - r, sx + r, sy + r); + g.DrawLine(markPen, sx + r, sy - r, sx - r, sy + r); + + // Draw coordinates text + string coord = $"({p.X:F2}, {p.Y:F2})"; + g.DrawString(coord, markFont, markBrush, sx + 5, sy - 20); + } + } + } + + private void DrawGrid(Graphics g, float w, float h, Func mapX, Func mapY) + { + using (Pen gridPen = new Pen(Color.FromArgb(50, 50, 50), 1)) + using (Font font = new Font("Segoe UI", 8)) + using (Brush brush = new SolidBrush(Color.Gray)) + { + // Calculate roughly how many lines we want + int targetLinesW = 10; + int targetLinesH = 10; + + float rangeW = rangeMaxX - rangeMinX; + float stepW = CalculateStep(rangeW, targetLinesW); + + float rangeH = rangeMaxY - rangeMinY; + float stepH = CalculateStep(rangeH, targetLinesH); + + // Vertical Grid Lines + float startX = (float)Math.Floor(rangeMinX / stepW) * stepW; + for (float x = startX; x <= rangeMaxX; x += stepW) + { + float sx = mapX(x); + g.DrawLine(gridPen, sx, 0, sx, h); + g.DrawString(x.ToString("0.##"), font, brush, sx + 2, h - 20); + } + + // Horizontal Grid Lines + float startY = (float)Math.Floor(rangeMinY / stepH) * stepH; + for (float y = startY; y <= rangeMaxY; y += stepH) + { + float sy = mapY(y); + g.DrawLine(gridPen, 0, sy, w, sy); + g.DrawString(y.ToString("0.##"), font, brush, 5, sy - 15); + } + } + } + + private float CalculateStep(float range, int targetSteps) + { + float rawStep = range / targetSteps; + float mag = (float)Math.Pow(10, Math.Floor(Math.Log10(rawStep))); + float normStep = rawStep / mag; + + if (normStep < 1.5) return 1 * mag; + if (normStep < 3.5) return 2 * mag; + if (normStep < 7.5) return 5 * mag; + return 10 * mag; + } + + private void pnlCanvas_Resize(object sender, EventArgs e) + { + pnlCanvas.Invalidate(); + } + } +} diff --git a/MathApp/MathApp/Controls/MultivariableTaylorControl.Designer.cs b/MathApp/MathApp/Controls/MultivariableTaylorControl.Designer.cs new file mode 100644 index 0000000..ca92646 --- /dev/null +++ b/MathApp/MathApp/Controls/MultivariableTaylorControl.Designer.cs @@ -0,0 +1,204 @@ + +namespace MathApp.Controls +{ + partial class MultivariableTaylorControl + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.lblTitle = new System.Windows.Forms.Label(); + this.lblEquation = new System.Windows.Forms.Label(); + this.txtEquation = new System.Windows.Forms.TextBox(); + this.lblOrder = new System.Windows.Forms.Label(); + this.numOrder = new System.Windows.Forms.NumericUpDown(); + this.grpVariables = new System.Windows.Forms.GroupBox(); + this.pnlVariables = new System.Windows.Forms.FlowLayoutPanel(); + this.btnAddVar = new System.Windows.Forms.Button(); + this.btnCalculate = new System.Windows.Forms.Button(); + this.lblResult = new System.Windows.Forms.Label(); + this.txtResult = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.numOrder)).BeginInit(); + this.grpVariables.SuspendLayout(); + this.SuspendLayout(); + // + // lblTitle + // + this.lblTitle.AutoSize = true; + this.lblTitle.Font = new System.Drawing.Font("Segoe UI Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.lblTitle.ForeColor = System.Drawing.Color.White; + this.lblTitle.Location = new System.Drawing.Point(20, 20); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(280, 32); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "Multivariable Taylor Series"; + // + // lblEquation + // + this.lblEquation.AutoSize = true; + this.lblEquation.ForeColor = System.Drawing.Color.White; + this.lblEquation.Location = new System.Drawing.Point(23, 70); + this.lblEquation.Name = "lblEquation"; + this.lblEquation.Size = new System.Drawing.Size(89, 15); + this.lblEquation.TabIndex = 1; + this.lblEquation.Text = "Function f(...) ="; + // + // txtEquation + // + this.txtEquation.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtEquation.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtEquation.ForeColor = System.Drawing.Color.White; + this.txtEquation.Location = new System.Drawing.Point(118, 68); + this.txtEquation.Name = "txtEquation"; + this.txtEquation.Size = new System.Drawing.Size(300, 23); + this.txtEquation.TabIndex = 2; + this.txtEquation.Text = "sin(x)*cos(y)"; + // + // lblOrder + // + this.lblOrder.AutoSize = true; + this.lblOrder.ForeColor = System.Drawing.Color.White; + this.lblOrder.Location = new System.Drawing.Point(440, 70); + this.lblOrder.Name = "lblOrder"; + this.lblOrder.Size = new System.Drawing.Size(74, 15); + this.lblOrder.TabIndex = 3; + this.lblOrder.Text = "Series Order:"; + // + // numOrder + // + this.numOrder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.numOrder.ForeColor = System.Drawing.Color.White; + this.numOrder.Location = new System.Drawing.Point(520, 68); + this.numOrder.Maximum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numOrder.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numOrder.Name = "numOrder"; + this.numOrder.Size = new System.Drawing.Size(60, 23); + this.numOrder.TabIndex = 4; + this.numOrder.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); + // + // grpVariables + // + this.grpVariables.Controls.Add(this.pnlVariables); + this.grpVariables.Controls.Add(this.btnAddVar); + this.grpVariables.ForeColor = System.Drawing.Color.White; + this.grpVariables.Location = new System.Drawing.Point(23, 110); + this.grpVariables.Name = "grpVariables"; + this.grpVariables.Size = new System.Drawing.Size(557, 200); + this.grpVariables.TabIndex = 5; + this.grpVariables.TabStop = false; + this.grpVariables.Text = "Variables & Expansion Points"; + // + // pnlVariables + // + this.pnlVariables.AutoScroll = true; + this.pnlVariables.Location = new System.Drawing.Point(10, 25); + this.pnlVariables.Name = "pnlVariables"; + this.pnlVariables.Size = new System.Drawing.Size(530, 130); + this.pnlVariables.TabIndex = 1; + // + // btnAddVar + // + this.btnAddVar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); + this.btnAddVar.FlatAppearance.BorderSize = 0; + this.btnAddVar.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAddVar.Location = new System.Drawing.Point(10, 165); + this.btnAddVar.Name = "btnAddVar"; + this.btnAddVar.Size = new System.Drawing.Size(120, 25); + this.btnAddVar.TabIndex = 0; + this.btnAddVar.Text = "+ Add Variable"; + this.btnAddVar.UseVisualStyleBackColor = false; + // + // btnCalculate + // + this.btnCalculate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.btnCalculate.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnCalculate.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.btnCalculate.ForeColor = System.Drawing.Color.White; + this.btnCalculate.Location = new System.Drawing.Point(23, 330); + this.btnCalculate.Name = "btnCalculate"; + this.btnCalculate.Size = new System.Drawing.Size(150, 40); + this.btnCalculate.TabIndex = 6; + this.btnCalculate.Text = "Calculate Expansion"; + this.btnCalculate.UseVisualStyleBackColor = false; + // + // lblResult + // + this.lblResult.AutoSize = true; + this.lblResult.ForeColor = System.Drawing.Color.White; + this.lblResult.Location = new System.Drawing.Point(23, 390); + this.lblResult.Name = "lblResult"; + this.lblResult.Size = new System.Drawing.Size(42, 15); + this.lblResult.TabIndex = 7; + this.lblResult.Text = "Result:"; + // + // txtResult + // + this.txtResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.txtResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtResult.Font = new System.Drawing.Font("Consolas", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.txtResult.ForeColor = System.Drawing.Color.Cyan; + this.txtResult.Location = new System.Drawing.Point(23, 410); + this.txtResult.Multiline = true; + this.txtResult.Name = "txtResult"; + this.txtResult.ReadOnly = true; + this.txtResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtResult.Size = new System.Drawing.Size(557, 150); + this.txtResult.TabIndex = 8; + // + // MultivariableTaylorControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Controls.Add(this.txtResult); + this.Controls.Add(this.lblResult); + this.Controls.Add(this.btnCalculate); + this.Controls.Add(this.grpVariables); + this.Controls.Add(this.numOrder); + this.Controls.Add(this.lblOrder); + this.Controls.Add(this.txtEquation); + this.Controls.Add(this.lblEquation); + this.Controls.Add(this.lblTitle); + this.Name = "MultivariableTaylorControl"; + this.Size = new System.Drawing.Size(600, 600); + ((System.ComponentModel.ISupportInitialize)(this.numOrder)).EndInit(); + this.grpVariables.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + private System.Windows.Forms.Label lblTitle; + private System.Windows.Forms.Label lblEquation; + private System.Windows.Forms.TextBox txtEquation; + private System.Windows.Forms.Label lblOrder; + private System.Windows.Forms.NumericUpDown numOrder; + private System.Windows.Forms.GroupBox grpVariables; + private System.Windows.Forms.FlowLayoutPanel pnlVariables; + private System.Windows.Forms.Button btnAddVar; + private System.Windows.Forms.Button btnCalculate; + private System.Windows.Forms.Label lblResult; + private System.Windows.Forms.TextBox txtResult; + } +} diff --git a/MathApp/MathApp/Controls/MultivariableTaylorControl.cs b/MathApp/MathApp/Controls/MultivariableTaylorControl.cs new file mode 100644 index 0000000..c8f41cd --- /dev/null +++ b/MathApp/MathApp/Controls/MultivariableTaylorControl.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using System.Globalization; + +namespace MathApp.Controls +{ + public partial class MultivariableTaylorControl : UserControl + { + private List variableRows = new List(); + + public MultivariableTaylorControl() + { + InitializeComponent(); + btnAddVar.Click += BtnAddVar_Click; + btnCalculate.Click += BtnCalculate_Click; + + // Add initial variables inputs (x and y default) + AddVariableRow("x", "0"); + AddVariableRow("y", "0"); + } + + private void BtnAddVar_Click(object sender, EventArgs e) + { + AddVariableRow("", "0"); + } + + private void AddVariableRow(string varName, string val) + { + VariableInputRow row = new VariableInputRow(varName, val); + row.OnRemove += (s, e) => + { + pnlVariables.Controls.Remove(row.Panel); + variableRows.Remove(row); + }; + + pnlVariables.Controls.Add(row.Panel); + variableRows.Add(row); + } + + private void BtnCalculate_Click(object sender, EventArgs e) + { + try + { + string eq = txtEquation.Text; + int degree = (int)numOrder.Value; + Dictionary points = new Dictionary(); + + foreach(var row in variableRows) + { + string v = row.Variable; + if(string.IsNullOrWhiteSpace(v)) continue; + + decimal p = 0; + if(!decimal.TryParse(row.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out p)) + { + txtResult.Text = "Invalid number format for variable: " + v; + return; + } + + if(points.ContainsKey(v)) + { + txtResult.Text = "Duplicate variable: " + v; + return; + } + points.Add(v, p); + } + + if(points.Count == 0) + { + txtResult.Text = "Please add at least one variable."; + return; + } + + string result = NumericalMethods.MethodMultiVar_TaylorSeries(eq, degree, points); + + // Formatting clean up + result = result.Replace("+ -", "- ").Replace("+-", "- ").Replace("*", " * "); + + txtResult.Text = result; + } + catch (Exception ex) + { + txtResult.Text = "Error: " + ex.Message; + } + } + } + + // Helper class for dynamic rows + public class VariableInputRow + { + public Panel Panel { get; private set; } + public TextBox TxtVariable { get; private set; } + public TextBox TxtValue { get; private set; } + public EventHandler OnRemove; + + public string Variable => TxtVariable.Text.Trim(); + public string Value => TxtValue.Text.Trim(); + + public VariableInputRow(string varName, string val) + { + Panel = new Panel(); + Panel.Size = new Size(500, 30); + + Label lblVar = new Label { Text = "Var:", Location = new Point(0, 5), AutoSize = true, ForeColor = Color.White }; + TxtVariable = new TextBox { Text = varName, Location = new Point(40, 2), Size = new Size(100, 23), BackColor = Color.FromArgb(40,40,40), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle }; + + Label lblVal = new Label { Text = "Point:", Location = new Point(160, 5), AutoSize = true, ForeColor = Color.White }; + TxtValue = new TextBox { Text = val, Location = new Point(210, 2), Size = new Size(100, 23), BackColor = Color.FromArgb(40,40,40), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle }; + + Button btnRemove = new Button { Text = "X", Location = new Point(330, 2), Size = new Size(30, 23), BackColor = Color.Red, ForeColor = Color.White, FlatStyle = FlatStyle.Flat }; + btnRemove.FlatAppearance.BorderSize = 0; + btnRemove.Click += (s, e) => OnRemove?.Invoke(this, EventArgs.Empty); + + Panel.Controls.Add(lblVar); + Panel.Controls.Add(TxtVariable); + Panel.Controls.Add(lblVal); + Panel.Controls.Add(TxtValue); + Panel.Controls.Add(btnRemove); + } + } +} diff --git a/MathApp/MathApp/Controls/RootFinderControl.Designer.cs b/MathApp/MathApp/Controls/RootFinderControl.Designer.cs new file mode 100644 index 0000000..ef4f577 --- /dev/null +++ b/MathApp/MathApp/Controls/RootFinderControl.Designer.cs @@ -0,0 +1,222 @@ + +namespace MathApp.Controls +{ + partial class RootFinderControl + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.lblTitle = new System.Windows.Forms.Label(); + this.pnlContent = new System.Windows.Forms.Panel(); + + this.lblMethod = new System.Windows.Forms.Label(); + this.cmbMethod = new System.Windows.Forms.ComboBox(); + this.lblEquation = new System.Windows.Forms.Label(); + this.txtEquation = new System.Windows.Forms.TextBox(); + this.lblVariable = new System.Windows.Forms.Label(); + this.txtVariable = new System.Windows.Forms.TextBox(); + this.lblInitialPoint = new System.Windows.Forms.Label(); + this.txtInitialPoint = new System.Windows.Forms.TextBox(); + this.lblMinX = new System.Windows.Forms.Label(); + this.txtMinX = new System.Windows.Forms.TextBox(); + this.lblMaxX = new System.Windows.Forms.Label(); + this.txtMaxX = new System.Windows.Forms.TextBox(); + this.lblIterations = new System.Windows.Forms.Label(); + this.txtIterations = new System.Windows.Forms.TextBox(); + this.btnFindRoot = new System.Windows.Forms.Button(); + this.lblResult = new System.Windows.Forms.Label(); + this.txtResult = new System.Windows.Forms.TextBox(); + + this.pnlContent.SuspendLayout(); + this.SuspendLayout(); + + // + // lblTitle + // + this.lblTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lblTitle.Font = new System.Drawing.Font("Segoe UI Light", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.lblTitle.ForeColor = System.Drawing.Color.White; + this.lblTitle.Location = new System.Drawing.Point(0, 0); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(800, 60); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "Equation Root Finder"; + this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + // pnlContent + // + this.pnlContent.Controls.Add(this.txtResult); + this.pnlContent.Controls.Add(this.lblResult); + this.pnlContent.Controls.Add(this.btnFindRoot); + this.pnlContent.Controls.Add(this.txtIterations); + this.pnlContent.Controls.Add(this.lblIterations); + this.pnlContent.Controls.Add(this.txtMaxX); + this.pnlContent.Controls.Add(this.lblMaxX); + this.pnlContent.Controls.Add(this.txtMinX); + this.pnlContent.Controls.Add(this.lblMinX); + this.pnlContent.Controls.Add(this.txtInitialPoint); + this.pnlContent.Controls.Add(this.lblInitialPoint); + this.pnlContent.Controls.Add(this.txtVariable); + this.pnlContent.Controls.Add(this.lblVariable); + this.pnlContent.Controls.Add(this.txtEquation); + this.pnlContent.Controls.Add(this.lblEquation); + this.pnlContent.Controls.Add(this.cmbMethod); + this.pnlContent.Controls.Add(this.lblMethod); + this.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlContent.Location = new System.Drawing.Point(0, 60); + this.pnlContent.Name = "pnlContent"; + this.pnlContent.Size = new System.Drawing.Size(800, 540); + this.pnlContent.TabIndex = 1; + + // Simple layout similar to previous, but styling updated in logic or here + int yObject = 20; + + // Helper to style labels + void StyleLabel(System.Windows.Forms.Label l) { + l.AutoSize = true; + l.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + l.ForeColor = System.Drawing.Color.White; + } + + StyleLabel(this.lblMethod); + this.lblMethod.Location = new System.Drawing.Point(20, yObject); + this.lblMethod.Text = "Method:"; + + this.cmbMethod.FormattingEnabled = true; + this.cmbMethod.Items.AddRange(new object[] { "Newton-Raphson", "Bisection", "Secant", "Regula Falsi" }); + this.cmbMethod.Location = new System.Drawing.Point(150, yObject); + this.cmbMethod.Name = "cmbMethod"; + this.cmbMethod.Size = new System.Drawing.Size(200, 25); + this.cmbMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + yObject += 50; + + StyleLabel(this.lblEquation); + this.lblEquation.Location = new System.Drawing.Point(20, yObject); + this.lblEquation.Text = "Equation:"; + this.txtEquation.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtEquation.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtEquation.ForeColor = System.Drawing.Color.White; + this.txtEquation.Location = new System.Drawing.Point(150, yObject); + this.txtEquation.Size = new System.Drawing.Size(400, 25); + yObject += 50; + + StyleLabel(this.lblVariable); + this.lblVariable.Location = new System.Drawing.Point(20, yObject); + this.lblVariable.Text = "Variable (e.g. x):"; + this.txtVariable.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtVariable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtVariable.ForeColor = System.Drawing.Color.White; + this.txtVariable.Location = new System.Drawing.Point(150, yObject); + this.txtVariable.Size = new System.Drawing.Size(100, 25); + yObject += 50; + + StyleLabel(this.lblInitialPoint); + this.lblInitialPoint.Location = new System.Drawing.Point(20, yObject); + this.lblInitialPoint.Text = "Initial Point:"; + this.txtInitialPoint.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtInitialPoint.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtInitialPoint.ForeColor = System.Drawing.Color.White; + this.txtInitialPoint.Location = new System.Drawing.Point(150, yObject); + this.txtInitialPoint.Size = new System.Drawing.Size(100, 25); + + StyleLabel(this.lblMinX); + this.lblMinX.Location = new System.Drawing.Point(20, yObject); + this.lblMinX.Text = "Min X:"; + this.txtMinX.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtMinX.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtMinX.ForeColor = System.Drawing.Color.White; + this.txtMinX.Location = new System.Drawing.Point(150, yObject); + this.txtMinX.Size = new System.Drawing.Size(100, 25); + + StyleLabel(this.lblMaxX); + this.lblMaxX.Location = new System.Drawing.Point(280, yObject); + this.lblMaxX.Text = "Max X:"; + this.txtMaxX.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtMaxX.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtMaxX.ForeColor = System.Drawing.Color.White; + this.txtMaxX.Location = new System.Drawing.Point(340, yObject); + this.txtMaxX.Size = new System.Drawing.Size(100, 25); + yObject += 50; + + StyleLabel(this.lblIterations); + this.lblIterations.Location = new System.Drawing.Point(20, yObject); + this.lblIterations.Text = "Iterations:"; + this.txtIterations.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtIterations.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtIterations.ForeColor = System.Drawing.Color.White; + this.txtIterations.Location = new System.Drawing.Point(150, yObject); + this.txtIterations.Size = new System.Drawing.Size(100, 25); + this.txtIterations.Text = "100"; + yObject += 60; + + this.btnFindRoot.Location = new System.Drawing.Point(150, yObject); + this.btnFindRoot.Name = "btnFindRoot"; + this.btnFindRoot.Size = new System.Drawing.Size(150, 40); + this.btnFindRoot.Text = "Find Root"; + this.btnFindRoot.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnFindRoot.BackColor = System.Drawing.Color.FromArgb(0, 120, 215); + this.btnFindRoot.ForeColor = System.Drawing.Color.White; + this.btnFindRoot.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnFindRoot.FlatAppearance.BorderSize = 0; + yObject += 60; + + StyleLabel(this.lblResult); + this.lblResult.Location = new System.Drawing.Point(20, yObject); + this.lblResult.Text = "Result:"; + this.txtResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.txtResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtResult.ForeColor = System.Drawing.Color.White; + this.txtResult.Location = new System.Drawing.Point(150, yObject); + this.txtResult.Size = new System.Drawing.Size(600, 150); + this.txtResult.Multiline = true; + this.txtResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtResult.Font = new System.Drawing.Font("Consolas", 10F); + + // + // RootFinderControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Controls.Add(this.pnlContent); + this.Controls.Add(this.lblTitle); + this.Name = "RootFinderControl"; + this.Size = new System.Drawing.Size(800, 600); + this.pnlContent.ResumeLayout(false); + this.pnlContent.PerformLayout(); + this.ResumeLayout(false); + + } + + private System.Windows.Forms.Label lblTitle; + private System.Windows.Forms.Panel pnlContent; + private System.Windows.Forms.Label lblMethod; + public System.Windows.Forms.ComboBox cmbMethod; + private System.Windows.Forms.Label lblEquation; + public System.Windows.Forms.TextBox txtEquation; + private System.Windows.Forms.Label lblVariable; + public System.Windows.Forms.TextBox txtVariable; + private System.Windows.Forms.Label lblInitialPoint; + public System.Windows.Forms.TextBox txtInitialPoint; + private System.Windows.Forms.Label lblMinX; + public System.Windows.Forms.TextBox txtMinX; + private System.Windows.Forms.Label lblMaxX; + public System.Windows.Forms.TextBox txtMaxX; + private System.Windows.Forms.Label lblIterations; + public System.Windows.Forms.TextBox txtIterations; + public System.Windows.Forms.Button btnFindRoot; + private System.Windows.Forms.Label lblResult; + public System.Windows.Forms.TextBox txtResult; + } +} diff --git a/MathApp/MathApp/Controls/RootFinderControl.cs b/MathApp/MathApp/Controls/RootFinderControl.cs new file mode 100644 index 0000000..7dbb85a --- /dev/null +++ b/MathApp/MathApp/Controls/RootFinderControl.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace MathApp.Controls +{ + public partial class RootFinderControl : UserControl + { + public RootFinderControl() + { + InitializeComponent(); + cmbMethod.SelectedIndex = 0; + UpdateVisibility(); + cmbMethod.SelectedIndexChanged += (s, e) => UpdateVisibility(); + btnFindRoot.Click += BtnFindRoot_Click; + } + + private void UpdateVisibility() + { + string method = cmbMethod.SelectedItem?.ToString() ?? ""; + bool isBracket = method == "Bisection" || method == "Regula Falsi"; + + lblInitialPoint.Visible = !isBracket; + txtInitialPoint.Visible = !isBracket; + + lblMinX.Visible = isBracket; + txtMinX.Visible = isBracket; + lblMaxX.Visible = isBracket; + txtMaxX.Visible = isBracket; + } + + private void BtnFindRoot_Click(object sender, EventArgs e) + { + try + { + string eq = txtEquation.Text; + string variable = txtVariable.Text; + int iterCount = 100; + int.TryParse(txtIterations.Text, out iterCount); + string method = cmbMethod.SelectedItem.ToString(); + + List logs = new List(); + + if (method == "Newton-Raphson") + { + decimal initialP = decimal.Parse(txtInitialPoint.Text); + logs = NumericalMethods.Method_NewtonRaphson(eq, initialP, iterCount); + } + else if (method == "Bisection") + { + decimal minX = decimal.Parse(txtMinX.Text); + decimal maxX = decimal.Parse(txtMaxX.Text); + logs = NumericalMethods.Method_Bisection(eq, minX, maxX, iterCount); + } + else if (method == "Secant") + { + decimal minX = decimal.Parse(txtMinX.Text); + decimal maxX = decimal.Parse(txtMaxX.Text); + logs = NumericalMethods.Method_Secant(eq, minX, maxX, iterCount); + } + else if (method == "Regula Falsi") + { + decimal minX = decimal.Parse(txtMinX.Text); + decimal maxX = decimal.Parse(txtMaxX.Text); + logs = NumericalMethods.Method_RegulaFalsi(eq, minX, maxX, iterCount); + } + else + { + logs = new List { method + " method not yet active." }; + } + + txtResult.Text = string.Join(Environment.NewLine, logs); + } + catch (Exception ex) + { + txtResult.Text = "Error: " + ex.Message; + } + } + } +} diff --git a/MathApp/MathApp/Controls/SimpleCalculatorControl.Designer.cs b/MathApp/MathApp/Controls/SimpleCalculatorControl.Designer.cs new file mode 100644 index 0000000..8bcbcab --- /dev/null +++ b/MathApp/MathApp/Controls/SimpleCalculatorControl.Designer.cs @@ -0,0 +1,76 @@ + +namespace MathApp.Controls +{ + partial class SimpleCalculatorControl + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.txtDisplay = new System.Windows.Forms.TextBox(); + this.pnlButtons = new System.Windows.Forms.TableLayoutPanel(); + this.SuspendLayout(); + + // + // txtDisplay + // + this.txtDisplay.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); + this.txtDisplay.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtDisplay.Dock = System.Windows.Forms.DockStyle.Top; + this.txtDisplay.Font = new System.Drawing.Font("Segoe UI", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.txtDisplay.ForeColor = System.Drawing.Color.White; + this.txtDisplay.Location = new System.Drawing.Point(0, 0); + this.txtDisplay.Name = "txtDisplay"; + this.txtDisplay.ReadOnly = true; + this.txtDisplay.Size = new System.Drawing.Size(600, 64); + this.txtDisplay.TabIndex = 0; + this.txtDisplay.Text = "0"; + this.txtDisplay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + + // + // pnlButtons + // + this.pnlButtons.ColumnCount = 4; + this.pnlButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.pnlButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.pnlButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.pnlButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.pnlButtons.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlButtons.Location = new System.Drawing.Point(0, 64); + this.pnlButtons.Name = "pnlButtons"; + this.pnlButtons.RowCount = 5; + this.pnlButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.pnlButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.pnlButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.pnlButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.pnlButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.pnlButtons.Size = new System.Drawing.Size(600, 536); + this.pnlButtons.TabIndex = 1; + + // + // SimpleCalculatorControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Controls.Add(this.pnlButtons); + this.Controls.Add(this.txtDisplay); + this.Name = "SimpleCalculatorControl"; + this.Size = new System.Drawing.Size(600, 600); + this.ResumeLayout(false); + this.PerformLayout(); + } + + private System.Windows.Forms.TextBox txtDisplay; + private System.Windows.Forms.TableLayoutPanel pnlButtons; + } +} diff --git a/MathApp/MathApp/Controls/SimpleCalculatorControl.cs b/MathApp/MathApp/Controls/SimpleCalculatorControl.cs new file mode 100644 index 0000000..4253b87 --- /dev/null +++ b/MathApp/MathApp/Controls/SimpleCalculatorControl.cs @@ -0,0 +1,251 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace MathApp.Controls +{ + public partial class SimpleCalculatorControl : UserControl + { + private string currentExpression = ""; + private bool isResultShown = false; + + public SimpleCalculatorControl() + { + InitializeComponent(); + InitializeButtons(); + } + + private void InitializeButtons() + { + // ... (Keeping initialization logic same, but for brevity I will rewrite it to ensure file integrity) + // Actually, I should preserve the exact logic. + // Re-implementing InitializeButtons to Match previous content exactly + + this.pnlButtons.RowCount = 5; + this.pnlButtons.RowStyles.Clear(); + for(int i=0; i<5; i++) this.pnlButtons.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); + + string[] gridLayout = { + "C", "(", ")", "/", + "7", "8", "9", "*", + "4", "5", "6", "-", + "1", "2", "3", "+", + "0", ".", "DEL", "=" + }; + + int index = 0; + foreach (string text in gridLayout) + { + Button btn = new Button(); + btn.Text = text; + btn.Dock = DockStyle.Fill; + btn.FlatStyle = FlatStyle.Flat; + btn.FlatAppearance.BorderSize = 0; + btn.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); + btn.ForeColor = Color.White; + btn.Click += Btn_Click; + + // Tag lookup for keyboard maybe? + btn.Tag = text; + + if (IsOperator(text)) + { + btn.BackColor = Color.FromArgb(40, 40, 40); + btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(60, 60, 60); + } + else if (text == "=") + { + btn.BackColor = Color.FromArgb(0, 120, 215); + btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(0, 140, 240); + } + else if (text == "C" || text == "DEL") + { + btn.BackColor = Color.FromArgb(50, 50, 50); + btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(70, 70, 70); + } + else + { + btn.BackColor = Color.FromArgb(30, 30, 30); + btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(50, 50, 50); + } + + pnlButtons.Controls.Add(btn, index % 4, index / 4); + index++; + } + } + + private bool IsOperator(string text) + { + return text == "+" || text == "-" || text == "*" || text == "/"; + } + + // --- Keyboard Support --- + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + // Map keys + string input = ""; + bool handled = true; + + switch (keyData) + { + case Keys.NumPad0: + case Keys.D0: input = "0"; break; + case Keys.NumPad1: + case Keys.D1: input = "1"; break; + case Keys.NumPad2: + case Keys.D2: input = "2"; break; + case Keys.NumPad3: + case Keys.D3: input = "3"; break; + case Keys.NumPad4: + case Keys.D4: input = "4"; break; + case Keys.NumPad5: + case Keys.D5: input = "5"; break; + case Keys.NumPad6: + case Keys.D6: input = "6"; break; + case Keys.NumPad7: + case Keys.D7: input = "7"; break; + case Keys.NumPad8: + case Keys.D8: input = "8"; break; + case Keys.NumPad9: + case Keys.D9: input = "9"; break; + + case Keys.Add: + case Keys.Oemplus: // Careful with Shift+= + input = "+"; break; + case Keys.Subtract: + case Keys.OemMinus: + input = "-"; break; + case Keys.Multiply: + input = "*"; break; + case Keys.Divide: + case Keys.OemQuestion: // / + input = "/"; break; + + case Keys.Decimal: + case Keys.OemPeriod: + case Keys.Oemcomma: + input = "."; break; + + case Keys.Back: + case Keys.Delete: + input = "DEL"; break; + + case Keys.Escape: + input = "C"; break; + + case Keys.Enter: + case Keys.Return: + input = "="; break; + + // Shift+8 (*) etc are handled by KeyChar usually vs Keys, + // but ProcessCmdKey sees Keys. + // For simplicity let's stick to Numpad and basics. + // Shift handling in ProcessCmdKey is tricky (keyData & Keys.Shift) + default: + // Check for shift combinations + if (keyData == (Keys.Shift | Keys.D8)) input = "*"; + else if (keyData == (Keys.Shift | Keys.D9)) input = "("; + else if (keyData == (Keys.Shift | Keys.D0)) input = ")"; + else if (keyData == (Keys.Shift | Keys.Oemplus)) input = "+"; + else handled = false; + break; + } + + if (handled && input != "") + { + ProcessInput(input); + return true; + } + + return base.ProcessCmdKey(ref msg, keyData); + } + + private void Btn_Click(object sender, EventArgs e) + { + Button btn = sender as Button; + if (btn == null) return; + ProcessInput(btn.Text); + + // Remove focus from button so future key presses go to control/form? + // Actually ProcessCmdKey bubbles up so it's fine. + // But if button has focus, Enter triggers Click AND ProcessCmdKey might double trigger + // if we are not careful. + // ProcessCmdKey is called BEFORE key events. returning true eats it. + // So Enter won't click the focused button if we return true. + } + + private void ProcessInput(string text) + { + if (text == "C") + { + currentExpression = ""; + txtDisplay.Text = "0"; + isResultShown = false; + } + else if (text == "DEL") + { + if (isResultShown) + { + currentExpression = ""; + txtDisplay.Text = "0"; + isResultShown = false; + } + else if (currentExpression.Length > 0) + { + currentExpression = currentExpression.Substring(0, currentExpression.Length - 1); + txtDisplay.Text = currentExpression.Length > 0 ? currentExpression : "0"; + } + } + else if (text == "=") + { + Evaluate(); + } + else + { + if (isResultShown) + { + if (IsOperator(text)) + { + isResultShown = false; // Continue with result + } + else + { + currentExpression = ""; // Start new + isResultShown = false; + } + } + currentExpression += text; + txtDisplay.Text = currentExpression; + } + } + + private void Evaluate() + { + try + { + Function f = new Function(); + f.Parse(currentExpression); + f.Infix2Postfix(); + f.EvaluatePostfix(); + + decimal result = f.m_result; + string resStr = result.ToString("G29", System.Globalization.CultureInfo.InvariantCulture); + + txtDisplay.Text = resStr; + currentExpression = resStr; + isResultShown = true; + } + catch (Exception) + { + txtDisplay.Text = "Error"; + currentExpression = ""; + isResultShown = true; // allow typing to clear + } + } + + private bool IsOperator(string text) // Redundant but kept for safety if used elsewhere + { + return text == "+" || text == "-" || text == "*" || text == "/"; + } + } +} diff --git a/MathApp/MathApp/Controls/SystemSolverControl.Designer.cs b/MathApp/MathApp/Controls/SystemSolverControl.Designer.cs new file mode 100644 index 0000000..4bffe2d --- /dev/null +++ b/MathApp/MathApp/Controls/SystemSolverControl.Designer.cs @@ -0,0 +1,165 @@ + +namespace MathApp.Controls +{ + partial class SystemSolverControl + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.lblTitle = new System.Windows.Forms.Label(); + this.pnlContent = new System.Windows.Forms.Panel(); + + this.lblEqCount = new System.Windows.Forms.Label(); + this.numEqCount = new System.Windows.Forms.NumericUpDown(); + this.btnGenerate = new System.Windows.Forms.Button(); + this.pnlEquations = new System.Windows.Forms.FlowLayoutPanel(); + this.lblSystemIterations = new System.Windows.Forms.Label(); + this.txtSystemIterations = new System.Windows.Forms.TextBox(); + this.btnSolveSystem = new System.Windows.Forms.Button(); + this.lblSystemResult = new System.Windows.Forms.Label(); + this.txtSystemResult = new System.Windows.Forms.TextBox(); + + this.pnlContent.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numEqCount)).BeginInit(); + this.SuspendLayout(); + + // + // lblTitle + // + this.lblTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lblTitle.Font = new System.Drawing.Font("Segoe UI Light", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.lblTitle.ForeColor = System.Drawing.Color.White; + this.lblTitle.Location = new System.Drawing.Point(0, 0); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(800, 60); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "Equation System Solver"; + this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + // pnlContent + // + this.pnlContent.Controls.Add(this.txtSystemResult); + this.pnlContent.Controls.Add(this.lblSystemResult); + this.pnlContent.Controls.Add(this.btnSolveSystem); + this.pnlContent.Controls.Add(this.txtSystemIterations); + this.pnlContent.Controls.Add(this.lblSystemIterations); + this.pnlContent.Controls.Add(this.pnlEquations); + this.pnlContent.Controls.Add(this.btnGenerate); + this.pnlContent.Controls.Add(this.numEqCount); + this.pnlContent.Controls.Add(this.lblEqCount); + this.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlContent.Location = new System.Drawing.Point(0, 60); + this.pnlContent.Name = "pnlContent"; + this.pnlContent.Size = new System.Drawing.Size(800, 540); + this.pnlContent.TabIndex = 1; + + // Simple layout + int yObject = 20; + void StyleLabel(System.Windows.Forms.Label l) { + l.AutoSize = true; + l.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + l.ForeColor = System.Drawing.Color.White; + } + + StyleLabel(this.lblEqCount); + this.lblEqCount.Location = new System.Drawing.Point(20, yObject); + this.lblEqCount.Text = "Number of Equations:"; + + this.numEqCount.Location = new System.Drawing.Point(180, yObject); + this.numEqCount.Minimum = 1; + this.numEqCount.Value = 2; + this.numEqCount.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.numEqCount.ForeColor = System.Drawing.Color.White; + this.numEqCount.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.btnGenerate.Location = new System.Drawing.Point(310, yObject - 2); + this.btnGenerate.Text = "Generate"; + this.btnGenerate.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnGenerate.BackColor = System.Drawing.Color.FromArgb(60, 60, 60); + this.btnGenerate.ForeColor = System.Drawing.Color.White; + this.btnGenerate.Size = new System.Drawing.Size(100, 25); + this.btnGenerate.FlatAppearance.BorderSize = 0; + yObject += 50; + + this.pnlEquations.Location = new System.Drawing.Point(20, yObject); + this.pnlEquations.Size = new System.Drawing.Size(750, 300); + this.pnlEquations.AutoScroll = true; + this.pnlEquations.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.pnlEquations.WrapContents = false; + this.pnlEquations.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.pnlEquations.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25))))); + yObject += 320; + + StyleLabel(this.lblSystemIterations); + this.lblSystemIterations.Location = new System.Drawing.Point(20, yObject); + this.lblSystemIterations.Text = "Iterations:"; + this.txtSystemIterations.Location = new System.Drawing.Point(100, yObject); + this.txtSystemIterations.Text = "100"; + this.txtSystemIterations.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtSystemIterations.ForeColor = System.Drawing.Color.White; + this.txtSystemIterations.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + yObject += 50; + + this.btnSolveSystem.Location = new System.Drawing.Point(20, yObject); + this.btnSolveSystem.Text = "Solve System"; + this.btnSolveSystem.Size = new System.Drawing.Size(150, 40); + this.btnSolveSystem.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnSolveSystem.BackColor = System.Drawing.Color.FromArgb(0, 120, 215); + this.btnSolveSystem.ForeColor = System.Drawing.Color.White; + this.btnSolveSystem.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnSolveSystem.FlatAppearance.BorderSize = 0; + yObject += 60; + + StyleLabel(this.lblSystemResult); + this.lblSystemResult.Location = new System.Drawing.Point(20, yObject); + this.lblSystemResult.Text = "Result:"; + this.txtSystemResult.Location = new System.Drawing.Point(100, yObject); + this.txtSystemResult.Size = new System.Drawing.Size(650, 100); + this.txtSystemResult.Multiline = true; + this.txtSystemResult.Font = new System.Drawing.Font("Consolas", 10F); + this.txtSystemResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.txtSystemResult.ForeColor = System.Drawing.Color.White; + this.txtSystemResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + + // + // SystemSolverControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Controls.Add(this.pnlContent); + this.Controls.Add(this.lblTitle); + this.Name = "SystemSolverControl"; + this.Size = new System.Drawing.Size(800, 600); + this.pnlContent.ResumeLayout(false); + this.pnlContent.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numEqCount)).EndInit(); + this.ResumeLayout(false); + + } + + private System.Windows.Forms.Label lblTitle; + private System.Windows.Forms.Panel pnlContent; + private System.Windows.Forms.Label lblEqCount; + public System.Windows.Forms.NumericUpDown numEqCount; + public System.Windows.Forms.Button btnGenerate; + public System.Windows.Forms.FlowLayoutPanel pnlEquations; + private System.Windows.Forms.Label lblSystemIterations; + public System.Windows.Forms.TextBox txtSystemIterations; + public System.Windows.Forms.Button btnSolveSystem; + private System.Windows.Forms.Label lblSystemResult; + public System.Windows.Forms.TextBox txtSystemResult; + } +} diff --git a/MathApp/MathApp/Controls/SystemSolverControl.cs b/MathApp/MathApp/Controls/SystemSolverControl.cs new file mode 100644 index 0000000..d398df1 --- /dev/null +++ b/MathApp/MathApp/Controls/SystemSolverControl.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace MathApp.Controls +{ + public partial class SystemSolverControl : UserControl + { + private List equationsInputs = new List(); + private List variablesInputs = new List(); + private List initialPointsInputs = new List(); + + public SystemSolverControl() + { + InitializeComponent(); + btnGenerate.Click += BtnGenerate_Click; + btnSolveSystem.Click += BtnSolveSystem_Click; + } + + private void BtnGenerate_Click(object sender, EventArgs e) + { + pnlEquations.Controls.Clear(); + equationsInputs.Clear(); + variablesInputs.Clear(); + initialPointsInputs.Clear(); + + int count = (int)numEqCount.Value; + + for (int i = 0; i < count; i++) + { + Panel p = new Panel(); + p.Size = new Size(720, 30); + p.BackColor = Color.FromArgb(30,30,30); + + Label lblEq = new Label { Text = "Eq " + (i+1), Location = new Point(0, 5), AutoSize = true, ForeColor = Color.White }; + TextBox txtEq = new TextBox { Location = new Point(50, 3), Size = new Size(300, 23), BackColor = Color.FromArgb(40,40,40), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle }; + + Label lblVar = new Label { Text = "Var", Location = new Point(360, 5), AutoSize = true, ForeColor = Color.White }; + TextBox txtVar = new TextBox { Location = new Point(390, 3), Size = new Size(50, 23), BackColor = Color.FromArgb(40,40,40), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle }; + + Label lblInit = new Label { Text = "Init", Location = new Point(450, 5), AutoSize = true, ForeColor = Color.White }; + TextBox txtInit = new TextBox { Location = new Point(480, 3), Size = new Size(50, 23), Text="0", BackColor = Color.FromArgb(40,40,40), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle }; + + p.Controls.Add(lblEq); + p.Controls.Add(txtEq); + p.Controls.Add(lblVar); + p.Controls.Add(txtVar); + p.Controls.Add(lblInit); + p.Controls.Add(txtInit); + + pnlEquations.Controls.Add(p); + + equationsInputs.Add(txtEq); + variablesInputs.Add(txtVar); + initialPointsInputs.Add(txtInit); + } + } + + private void BtnSolveSystem_Click(object sender, EventArgs e) + { + try + { + List eqs = new List(); + Dictionary dict = new Dictionary(); + + for(int i=0; i results = NumericalMethods.MethodMultiVar_SolveEquationSystem(eqs, dict, iterCount); + + if (results != null) + { + List resLines = new List(); + foreach(var kvp in results) + { + resLines.Add(kvp.Key + ": " + kvp.Value.ToString("F8")); + } + txtSystemResult.Text = string.Join(Environment.NewLine, resLines); + } + else + txtSystemResult.Text = "Failed to solve."; + } + catch (Exception ex) + { + txtSystemResult.Text = "Error: " + ex.Message; + } + } + } +} diff --git a/MathApp/MathApp/Controls/TaylorSeriesControl.Designer.cs b/MathApp/MathApp/Controls/TaylorSeriesControl.Designer.cs new file mode 100644 index 0000000..deb5520 --- /dev/null +++ b/MathApp/MathApp/Controls/TaylorSeriesControl.Designer.cs @@ -0,0 +1,177 @@ + +namespace MathApp.Controls +{ + partial class TaylorSeriesControl + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.lblTitle = new System.Windows.Forms.Label(); + this.pnlContent = new System.Windows.Forms.Panel(); + + this.lblFunction = new System.Windows.Forms.Label(); + this.txtFunction = new System.Windows.Forms.TextBox(); + this.lblVariable = new System.Windows.Forms.Label(); + this.txtVariable = new System.Windows.Forms.TextBox(); + this.lblCenterPoint = new System.Windows.Forms.Label(); + this.txtCenterPoint = new System.Windows.Forms.TextBox(); + this.lblOrder = new System.Windows.Forms.Label(); + this.numOrder = new System.Windows.Forms.NumericUpDown(); + this.btnCalculate = new System.Windows.Forms.Button(); + this.lblResult = new System.Windows.Forms.Label(); + this.txtResult = new System.Windows.Forms.TextBox(); + + this.pnlContent.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numOrder)).BeginInit(); + this.SuspendLayout(); + + // + // lblTitle + // + this.lblTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lblTitle.Font = new System.Drawing.Font("Segoe UI Light", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.lblTitle.ForeColor = System.Drawing.Color.White; + this.lblTitle.Location = new System.Drawing.Point(0, 0); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(800, 60); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "Taylor Series Calculator"; + this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + // pnlContent + // + this.pnlContent.Controls.Add(this.txtResult); + this.pnlContent.Controls.Add(this.lblResult); + this.pnlContent.Controls.Add(this.btnCalculate); + this.pnlContent.Controls.Add(this.numOrder); + this.pnlContent.Controls.Add(this.lblOrder); + this.pnlContent.Controls.Add(this.txtCenterPoint); + this.pnlContent.Controls.Add(this.lblCenterPoint); + this.pnlContent.Controls.Add(this.txtVariable); + this.pnlContent.Controls.Add(this.lblVariable); + this.pnlContent.Controls.Add(this.txtFunction); + this.pnlContent.Controls.Add(this.lblFunction); + this.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlContent.Location = new System.Drawing.Point(0, 60); + this.pnlContent.Name = "pnlContent"; + this.pnlContent.Size = new System.Drawing.Size(800, 540); + this.pnlContent.TabIndex = 1; + + int yObject = 20; + + void StyleLabel(System.Windows.Forms.Label l) { + l.AutoSize = true; + l.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + l.ForeColor = System.Drawing.Color.White; + } + + StyleLabel(this.lblFunction); + this.lblFunction.Location = new System.Drawing.Point(20, yObject); + this.lblFunction.Text = "Function f(x):"; + + this.txtFunction.Location = new System.Drawing.Point(150, yObject); + this.txtFunction.Size = new System.Drawing.Size(400, 25); + this.txtFunction.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtFunction.ForeColor = System.Drawing.Color.White; + this.txtFunction.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + yObject += 50; + + StyleLabel(this.lblVariable); + this.lblVariable.Location = new System.Drawing.Point(20, yObject); + this.lblVariable.Text = "Variable (e.g. x):"; + this.txtVariable.Location = new System.Drawing.Point(150, yObject); + this.txtVariable.Size = new System.Drawing.Size(100, 25); + this.txtVariable.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtVariable.ForeColor = System.Drawing.Color.White; + this.txtVariable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtVariable.Text = "x"; + yObject += 50; + + StyleLabel(this.lblCenterPoint); + this.lblCenterPoint.Location = new System.Drawing.Point(20, yObject); + this.lblCenterPoint.Text = "Center Point (a):"; + this.txtCenterPoint.Location = new System.Drawing.Point(150, yObject); + this.txtCenterPoint.Size = new System.Drawing.Size(100, 25); + this.txtCenterPoint.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.txtCenterPoint.ForeColor = System.Drawing.Color.White; + this.txtCenterPoint.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtCenterPoint.Text = "0"; + yObject += 50; + + StyleLabel(this.lblOrder); + this.lblOrder.Location = new System.Drawing.Point(20, yObject); + this.lblOrder.Text = "Order (n):"; + this.numOrder.Location = new System.Drawing.Point(150, yObject); + this.numOrder.Minimum = 1; + this.numOrder.Maximum = 20; + this.numOrder.Value = 4; + this.numOrder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.numOrder.ForeColor = System.Drawing.Color.White; + this.numOrder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + yObject += 60; + + this.btnCalculate.Location = new System.Drawing.Point(150, yObject); + this.btnCalculate.Text = "Calculate Series"; + this.btnCalculate.Size = new System.Drawing.Size(150, 40); + this.btnCalculate.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnCalculate.BackColor = System.Drawing.Color.FromArgb(0, 120, 215); + this.btnCalculate.ForeColor = System.Drawing.Color.White; + this.btnCalculate.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnCalculate.FlatAppearance.BorderSize = 0; + yObject += 60; + + StyleLabel(this.lblResult); + this.lblResult.Location = new System.Drawing.Point(20, yObject); + this.lblResult.Text = "Result:"; + this.txtResult.Location = new System.Drawing.Point(150, yObject); + this.txtResult.Size = new System.Drawing.Size(600, 150); + this.txtResult.Multiline = true; + this.txtResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtResult.Font = new System.Drawing.Font("Consolas", 10F); + this.txtResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.txtResult.ForeColor = System.Drawing.Color.White; + this.txtResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + // + // TaylorSeriesControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Controls.Add(this.pnlContent); + this.Controls.Add(this.lblTitle); + this.Name = "TaylorSeriesControl"; + this.Size = new System.Drawing.Size(800, 600); + this.pnlContent.ResumeLayout(false); + this.pnlContent.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numOrder)).EndInit(); + this.ResumeLayout(false); + + } + + private System.Windows.Forms.Label lblTitle; + private System.Windows.Forms.Panel pnlContent; + private System.Windows.Forms.Label lblFunction; + private System.Windows.Forms.TextBox txtFunction; + private System.Windows.Forms.Label lblVariable; + private System.Windows.Forms.TextBox txtVariable; + private System.Windows.Forms.Label lblCenterPoint; + private System.Windows.Forms.TextBox txtCenterPoint; + private System.Windows.Forms.Label lblOrder; + private System.Windows.Forms.NumericUpDown numOrder; + private System.Windows.Forms.Button btnCalculate; + private System.Windows.Forms.Label lblResult; + private System.Windows.Forms.TextBox txtResult; + } +} diff --git a/MathApp/MathApp/Controls/TaylorSeriesControl.cs b/MathApp/MathApp/Controls/TaylorSeriesControl.cs new file mode 100644 index 0000000..24d1d02 --- /dev/null +++ b/MathApp/MathApp/Controls/TaylorSeriesControl.cs @@ -0,0 +1,36 @@ +using System; +using System.Windows.Forms; + +namespace MathApp.Controls +{ + public partial class TaylorSeriesControl : UserControl + { + public TaylorSeriesControl() + { + InitializeComponent(); + btnCalculate.Click += BtnCalculate_Click; + } + + private void BtnCalculate_Click(object sender, EventArgs e) + { + try + { + string eq = txtFunction.Text; + string variable = txtVariable.Text; + int degree = (int)numOrder.Value; + decimal center = decimal.Parse(txtCenterPoint.Text); + + string result = NumericalMethods.Method_TaylorSeries(eq, degree, variable, center); + // Clean up result for display if needed + result = result.Replace("+ -", "- ").Replace("+-", "- "); + + txtResult.Text = "Taylor Series approximation for f(x) =" + Environment.NewLine + + result; + } + catch (Exception ex) + { + txtResult.Text = "Error: " + ex.Message; + } + } + } +} diff --git a/MathApp/MathApp/Core/DecimalMath.cs b/MathApp/MathApp/Core/DecimalMath.cs new file mode 100644 index 0000000..6c72917 --- /dev/null +++ b/MathApp/MathApp/Core/DecimalMath.cs @@ -0,0 +1,541 @@ +using System; + +/// +/// Analogy of System.Math class for decimal types +/// +public static class DecimalMath +{ + /* ... (Content from original file, confirmed no Unity deps) ... */ + + /// + /// represents PI + /// + public const decimal PI = 3.14159265358979323846264338327950288419716939937510M; + + /// + /// represents PI + /// + public const decimal Epsilon = 0.0000000000000000001M; + + /// + /// represents 2*PI + /// + private const decimal PIx2 = 6.28318530717958647692528676655900576839433879875021M; + + /// + /// represents E + /// + public const decimal E = 2.7182818284590452353602874713526624977572470936999595749M; + + /// + /// represents PI/2 + /// + private const decimal PIdiv2 = 1.570796326794896619231321691639751442098584699687552910487M; + + /// + /// represents PI/4 + /// + private const decimal PIdiv4 = 0.785398163397448309615660845819875721049292349843776455243M; + + /// + /// represents 1.0/E + /// + private const decimal Einv = 0.3678794411714423215955237701614608674458111310317678M; + + /// + /// log(10,E) factor + /// + private const decimal Log10Inv = 0.434294481903251827651128918916605082294397005803666566114M; + + /// + /// Zero + /// + public const decimal Zero = 0.0M; + + /// + /// One + /// + public const decimal One = 1.0M; + + /// + /// Represents 0.5M + /// + private const decimal Half = 0.5M; + + /// + /// Max iterations count in Taylor series + /// + private const int MaxIteration = 100; + + /// + /// Analogy of Math.Exp method + /// + /// + /// + public static decimal Exp(decimal x) + { + var count = 0; + + if (x > One) + { + count = decimal.ToInt32(decimal.Truncate(x)); + x -= decimal.Truncate(x); + } + + if (x < Zero) + { + count = decimal.ToInt32(decimal.Truncate(x) - 1); + x = One + (x - decimal.Truncate(x)); + } + + var iteration = 1; + var result = One; + var factorial = One; + decimal cachedResult; + do + { + cachedResult = result; + factorial *= x / iteration++; + result += factorial; + } while (cachedResult != result); + + if (count == 0) + return result; + return result * PowerN(E, count); + } + + /// + /// Analogy of Math.Pow method + /// + /// + /// + /// + public static decimal Pow(decimal value, decimal pow) + { + if (pow == Zero) return One; + if (pow == One) return value; + if (value == One) return One; + + if (value == Zero) + { + if (pow > Zero) + { + return Zero; + } + + throw new Exception("Invalid Operation: zero base and negative power"); + } + + if (pow == -One) return One / value; + + var isPowerInteger = IsInteger(pow); + if (value < Zero && !isPowerInteger) + { + throw new Exception("Invalid Operation: negative base and non-integer power"); + } + + if (isPowerInteger && value > Zero) + { + int powerInt = (int)pow; + return PowerN(value, powerInt); + } + + if (isPowerInteger && value < Zero) + { + int powerInt = (int)pow; + if (powerInt % 2 == 0) + { + return Exp(pow * Log(-value)); + } + + return -Exp(pow * Log(-value)); + } + + return Exp(pow * Log(value)); + } + + private static bool IsInteger(decimal value) + { + var longValue = (long)value; + return Abs(value - longValue) <= Epsilon; + } + + /// + /// Power to the integer value + /// + /// + /// + /// + public static decimal PowerN(decimal value, int power) + { + while (true) + { + if (power == Zero) return One; + if (power < Zero) + { + value = One / value; + power = -power; + continue; + } + + var q = power; + var prod = One; + var current = value; + while (q > 0) + { + if (q % 2 == 1) + { + // detects the 1s in the binary expression of power + prod = current * prod; // picks up the relevant power + q--; + } + + current *= current; // value^i -> value^(2*i) + q >>= 1; + } + + return prod; + } + } + + /// + /// Analogy of Math.Log10 + /// + /// + /// + public static decimal Log10(decimal x) + { + return Log(x) * Log10Inv; + } + + /// + /// Analogy of Math.Log + /// + /// + /// + public static decimal Log(decimal x) + { + if (x <= Zero) + { + throw new ArgumentException("x must be greater than zero"); + } + var count = 0; + while (x >= One) + { + x *= Einv; + count++; + } + while (x <= Einv) + { + x *= E; + count--; + } + x--; + if (x == Zero) return count; + var result = Zero; + var iteration = 0; + var y = One; + var cacheResult = result - One; + while (cacheResult != result && iteration < MaxIteration) + { + iteration++; + cacheResult = result; + y *= -x; + result += y / iteration; + } + return count - result; + } + + /// + /// Analogy of Math.Cos + /// + /// + /// + public static decimal Cos(decimal x) + { + //truncating to [-2*PI;2*PI] + TruncateToPeriodicInterval(ref x); + + // now x in (-2pi,2pi) + if (x >= PI && x <= PIx2) + { + return -Cos(x - PI); + } + if (x >= -PIx2 && x <= -PI) + { + return -Cos(x + PI); + } + + x *= x; + //y=1-x/2!+x^2/4!-x^3/6!... + var xx = -x * Half; + var y = One + xx; + var cachedY = y - One;//init cache with different value + for (var i = 1; cachedY != y && i < MaxIteration; i++) + { + cachedY = y; + decimal factor = i * ((i << 1) + 3) + 1; //2i^2+2i+i+1=2i^2+3i+1 + factor = -Half / factor; + xx *= x * factor; + y += xx; + } + return y; + } + + /// + /// Analogy of Math.Tan + /// + /// + /// + public static decimal Tan(decimal x) + { + var cos = Cos(x); + if (cos == Zero) throw new ArgumentException(nameof(x)); + //calculate sin using cos + var sin = CalculateSinFromCos(x, cos); + return sin / cos; + } + /// + /// Helper function for calculating sin(x) from cos(x) + /// + /// + /// + /// + private static decimal CalculateSinFromCos(decimal x, decimal cos) + { + var moduleOfSin = Sqrt(One - (cos * cos)); + var sineIsPositive = IsSignOfSinePositive(x); + if (sineIsPositive) return moduleOfSin; + return -moduleOfSin; + } + /// + /// Analogy of Math.Sin + /// + /// + /// + public static decimal Sin(decimal x) + { + var cos = Cos(x); + return CalculateSinFromCos(x, cos); + } + + + /// + /// Truncates to [-2*PI;2*PI] + /// + /// + private static void TruncateToPeriodicInterval(ref decimal x) + { + while (x >= PIx2) + { + var divide = Math.Abs(decimal.ToInt32(x / PIx2)); + x -= divide * PIx2; + } + + while (x <= -PIx2) + { + var divide = Math.Abs(decimal.ToInt32(x / PIx2)); + x += divide * PIx2; + } + } + + + private static bool IsSignOfSinePositive(decimal x) + { + //truncating to [-2*PI;2*PI] + TruncateToPeriodicInterval(ref x); + + //now x in [-2*PI;2*PI] + if (x >= -PIx2 && x <= -PI) return true; + if (x >= -PI && x <= Zero) return false; + if (x >= Zero && x <= PI) return true; + if (x >= PI && x <= PIx2) return false; + + //will not be reached + throw new ArgumentException(nameof(x)); + } + + /// + /// Analogy of Math.Sqrt + /// + /// + /// lasts iteration while error less than this epsilon + /// + public static decimal Sqrt(decimal x, decimal epsilon = Zero) + { + if (x < Zero) throw new OverflowException("Cannot calculate square root from a negative number"); + //initial approximation + decimal current = (decimal)Math.Sqrt((double)x), previous; + do + { + previous = current; + if (previous == Zero) return Zero; + current = (previous + x / previous) * Half; + } while (Abs(previous - current) > epsilon); + return current; + } + /// + /// Analogy of Math.Sinh + /// + /// + /// + public static decimal Sinh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y - yy) * Half; + } + + /// + /// Analogy of Math.Cosh + /// + /// + /// + public static decimal Cosh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y + yy) * Half; + } + + /// + /// Analogy of Math.Sign + /// + /// + /// + public static int Sign(decimal x) + { + return x < Zero ? -1 : (x > Zero ? 1 : 0); + } + + /// + /// Analogy of Math.Tanh + /// + /// + /// + public static decimal Tanh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y - yy) / (y + yy); + } + + /// + /// Analogy of Math.Abs + /// + /// + /// + public static decimal Abs(decimal x) + { + if (x <= Zero) + { + return -x; + } + return x; + } + + /// + /// Analogy of Math.Asin + /// + /// + /// + public static decimal Asin(decimal x) + { + if (x > One || x < -One) + { + throw new ArgumentException("x must be in [-1,1]"); + } + //known values + if (x == Zero) return Zero; + if (x == One) return PIdiv2; + //asin function is odd function + if (x < Zero) return -Asin(-x); + + //my optimize trick here + + // used a math formula to speed up : + // asin(x)=0.5*(pi/2-asin(1-2*x*x)) + // if x>=0 is true + + var newX = One - 2 * x * x; + + //for calculating new value near to zero than current + //because we gain more speed with values near to zero + if (Abs(x) > Abs(newX)) + { + var t = Asin(newX); + return Half * (PIdiv2 - t); + } + var y = Zero; + var result = x; + decimal cachedResult; + var i = 1; + y += result; + var xx = x * x; + do + { + cachedResult = result; + result *= xx * (One - Half / (i)); + y += result / ((i << 1) + 1); + i++; + } while (cachedResult != result); + return y; + } + + /// + /// Analogy of Math.Atan + /// + /// + /// + public static decimal Atan(decimal x) + { + if (x == Zero) return Zero; + if (x == One) return PIdiv4; + return Asin(x / Sqrt(One + x * x)); + } + /// + /// Analogy of Math.Acos + /// + /// + /// + public static decimal Acos(decimal x) + { + if (x == Zero) return PIdiv2; + if (x == One) return Zero; + if (x < Zero) return PI - Acos(-x); + return PIdiv2 - Asin(x); + } + + /// + /// Analogy of Math.Atan2 + /// for more see this + /// + /// + /// + /// + /// + public static decimal Atan2(decimal y, decimal x) + { + if (x > Zero) + { + return Atan(y / x); + } + if (x < Zero && y >= Zero) + { + return Atan(y / x) + PI; + } + if (x < Zero && y < Zero) + { + return Atan(y / x) - PI; + } + if (x == Zero && y > Zero) + { + return PIdiv2; + } + if (x == Zero && y < Zero) + { + return -PIdiv2; + } + throw new ArgumentException("invalid atan2 arguments"); + } +} diff --git a/MathApp/MathApp/Core/Function.cs b/MathApp/MathApp/Core/Function.cs new file mode 100644 index 0000000..899dc1d --- /dev/null +++ b/MathApp/MathApp/Core/Function.cs @@ -0,0 +1,721 @@ +using System; +using System.Collections; +using System.Collections.Generic; + + +/// +/// +/// +public enum Type { Variable, Value, UnaryOperator, Operator, Function, Result, Bracket, Comma, Error } +public struct Symbol +{ + public string m_name; + public decimal m_value; + public Type m_type; + public override string ToString() + { + return m_name; + } +} +public delegate Symbol EvaluateFunctionDelegate(string name, params Object[] args); +public class Function +{ + public decimal Result + { + get + { + return m_result; + } + } + + public ArrayList Equation + { + get + { + return (ArrayList)m_equation.Clone(); + } + } + public ArrayList Postfix + { + get + { + return (ArrayList)m_postfix.Clone(); + } + } + + public EvaluateFunctionDelegate DefaultFunctionEvaluation + { + set + { + m_defaultFunctionEvaluation = value; + } + } + + public bool Error + { + get + { + return m_bError; + } + } + + public string ErrorDescription + { + get + { + return m_sErrorDescription; + } + } + + public ArrayList Variables + { + get + { + ArrayList var = new ArrayList(); + foreach (Symbol sym in m_equation) + { + if ((sym.m_type == Type.Variable) && (!var.Contains(sym))) + var.Add(sym); + } + return var; + } + set + { + foreach (Symbol sym in value) + { + for (int i = 0; i < m_postfix.Count; i++) + { + if ((sym.m_name == ((Symbol)m_postfix[i]).m_name) && (((Symbol)m_postfix[i]).m_type == Type.Variable)) + { + Symbol sym1 = (Symbol)m_postfix[i]; + sym1.m_value = sym.m_value; + m_postfix[i] = sym1; + } + } + } + } + } + + public Function() + { } + + public void Parse(string equation) + { + int state = 1; + string temp = ""; + Symbol ctSymbol = new Symbol(); // Initialized to avoid error + + m_bError = false; + m_sErrorDescription = "None"; + + m_equation.Clear(); + m_postfix.Clear(); + + int nPos = 0; + //-- Remove all white spaces from the equation string -- + equation = equation.Trim(); + while ((nPos = equation.IndexOf(' ')) != -1) + equation = equation.Remove(nPos, 1); + + for (int i = 0; i < equation.Length; i++) + { + switch (state) + { + case 1: + if (Char.IsNumber(equation[i])) + { + state = 2; + temp += equation[i]; + } + else if (Char.IsLetter(equation[i])) + { + state = 3; + temp += equation[i]; + } + else + { + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + case ".": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + } + break; + case 2: + if ((Char.IsNumber(equation[i])) || (equation[i] == '.') || (equation[i] == ',')) + temp += equation[i]; + else if (!Char.IsLetter(equation[i])) + { + state = 1; + ctSymbol.m_name = temp; + ctSymbol.m_value = Decimal.Parse(temp, System.Globalization.CultureInfo.InvariantCulture); + ctSymbol.m_type = Type.Value; + m_equation.Add(ctSymbol); + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + temp = ""; + } + break; + case 3: + if (Char.IsLetterOrDigit(equation[i])) + temp += equation[i]; + else + { + state = 1; + ctSymbol.m_name = temp; + ctSymbol.m_value = 0; + if (equation[i] == '(') + ctSymbol.m_type = Type.Function; + else + { + if (ctSymbol.m_name == "pi") + ctSymbol.m_value = DecimalMath.PI; + else if (ctSymbol.m_name == "e") + ctSymbol.m_value = DecimalMath.E; + ctSymbol.m_type = Type.Variable; + } + m_equation.Add(ctSymbol); + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + temp = ""; + } + break; + } + } + if (temp != "") + { + ctSymbol.m_name = temp; + if (state == 2) + { + ctSymbol.m_value = Decimal.Parse(temp, System.Globalization.CultureInfo.InvariantCulture); + ctSymbol.m_type = Type.Value; + } + else + { + if (ctSymbol.m_name == "pi") + ctSymbol.m_value = DecimalMath.PI; + else if (ctSymbol.m_name == "e") + ctSymbol.m_value = DecimalMath.E; + else + ctSymbol.m_value = 0; + ctSymbol.m_type = Type.Variable; + } + m_equation.Add(ctSymbol); + } + } + + public void Infix2Postfix() + { + Symbol tpSym; + Stack tpStack = new Stack(); + foreach (Symbol sym in m_equation) + { + if ((sym.m_type == Type.Value) || (sym.m_type == Type.Variable)) + m_postfix.Add(sym); + else if ((sym.m_name == "(") || (sym.m_name == "[") || (sym.m_name == "{")) + tpStack.Push(sym); + else if ((sym.m_name == ")") || (sym.m_name == "]") || (sym.m_name == "}")) + { + if (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + while ((tpSym.m_name != "(") && (tpSym.m_name != "[") && (tpSym.m_name != "{")) + { + m_postfix.Add(tpSym); + tpSym = (Symbol)tpStack.Pop(); + } + } + } + else if (sym.m_type == Type.UnaryOperator) + { + tpStack.Push(sym); + } + else + { + if (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + while ((tpStack.Count != 0) && ((tpSym.m_type == Type.UnaryOperator) || (tpSym.m_type == Type.Operator) || (tpSym.m_type == Type.Function) || (tpSym.m_type == Type.Comma)) && (Precedence(tpSym) >= Precedence(sym))) + { + m_postfix.Add(tpSym); + tpSym = (Symbol)tpStack.Pop(); + } + if (((tpSym.m_type == Type.UnaryOperator) || (tpSym.m_type == Type.Operator) || (tpSym.m_type == Type.Function) || (tpSym.m_type == Type.Comma)) && (Precedence(tpSym) >= Precedence(sym))) + m_postfix.Add(tpSym); + else + tpStack.Push(tpSym); + } + tpStack.Push(sym); + } + } + while (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + m_postfix.Add(tpSym); + } + } + + public void EvaluatePostfix() + { + Symbol tpSym1, tpSym2, tpResult; + Stack tpStack = new Stack(); + ArrayList fnParam = new ArrayList(); + m_bError = false; + foreach (Symbol sym in m_postfix) + { + if ((sym.m_type == Type.Value) || (sym.m_type == Type.Variable) || (sym.m_type == Type.Result)) + tpStack.Push(sym); + else if (sym.m_type == Type.UnaryOperator) + { + tpSym1 = (Symbol)tpStack.Pop(); + tpResult = Evaluate(sym, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (sym.m_type == Type.Operator) + { + tpSym1 = (Symbol)tpStack.Pop(); + tpSym2 = (Symbol)tpStack.Pop(); + tpResult = Evaluate(tpSym2, sym, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (sym.m_type == Type.Comma) + { + tpStack.Push(sym); + } + else if (sym.m_type == Type.Function) + { + fnParam.Clear(); + tpSym1 = (Symbol)tpStack.Pop(); + if ((tpSym1.m_type == Type.Value) || (tpSym1.m_type == Type.Variable) || (tpSym1.m_type == Type.Result)) + { + tpResult = EvaluateFunction(sym.m_name, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (tpSym1.m_type == Type.Comma) + { + while (tpSym1.m_type == Type.Comma) + { + tpSym1 = (Symbol)tpStack.Pop(); + fnParam.Add(tpSym1); + tpSym1 = (Symbol)tpStack.Pop(); + } + fnParam.Add(tpSym1); + tpResult = EvaluateFunction(sym.m_name, fnParam.ToArray()); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else + { + tpStack.Push(tpSym1); + tpResult = EvaluateFunction(sym.m_name); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + } + } + if (tpStack.Count == 1) + { + tpResult = (Symbol)tpStack.Pop(); + m_result = tpResult.m_value; + } + } + + protected int Precedence(Symbol sym) + { + switch (sym.m_type) + { + case Type.Bracket: + return 7; + case Type.Function: + return 5; + case Type.UnaryOperator: + return 4; + case Type.Comma: + return 0; + } + switch (sym.m_name) + { + case "^": + return 3; + case "/": + case "*": + case "%": + return 2; + case "+": + case "-": + return 1; + } + return -1; + } + + protected Symbol Evaluate(Symbol opr, Symbol sym1) + { + Symbol result; + result.m_name = opr.m_name + sym1.m_name; + result.m_type = Type.Result; + result.m_value = 0; + switch (opr.m_name) + { + case "+": + result.m_value = sym1.m_value; ; + break; + case "-": + result.m_value = -1 * sym1.m_value; + break; + default: + result.m_type = Type.Error; + result.m_name = "Undefine unary operator: " + opr.m_name + "."; + break; + } + return result; + } + + protected Symbol Evaluate(Symbol sym1, Symbol opr, Symbol sym2) + { + Symbol result; + result.m_name = sym1.m_name + opr.m_name + sym2.m_name; + result.m_type = Type.Result; + result.m_value = 0; + switch (opr.m_name) + { + case "^": + result.m_value = DecimalMath.Pow(sym1.m_value, sym2.m_value); + break; + case "/": + { + if (sym2.m_value != 0) + result.m_value = sym1.m_value / sym2.m_value; + else + { + result.m_name = "Divide by Zero."; + result.m_type = Type.Error; + } + break; + } + case "*": + result.m_value = sym1.m_value * sym2.m_value; + break; + case "%": + result.m_value = sym1.m_value % sym2.m_value; + break; + case "+": + result.m_value = sym1.m_value + sym2.m_value; + break; + case "-": + result.m_value = sym1.m_value - sym2.m_value; + break; + default: + result.m_type = Type.Error; + result.m_name = "Undefine operator: " + opr.m_name + "."; + break; + } + return result; + } + + protected Symbol EvaluateFunction(string name, params Object[] args) + { + Symbol result; + result.m_name = ""; + result.m_type = Type.Result; + result.m_value = 0; + switch (name) + { + case "cos": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Cos(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sin": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sin(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "tan": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Tan(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "cosh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Cosh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sinh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sinh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "tanh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Tanh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "log": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log10(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "ln": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "logn": + if (args.Length == 2) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + "'" + ((Symbol)args[1]).m_value.ToString() + ")"; + // log_b(x) = ln(x) / ln(b) + result.m_value = DecimalMath.Log(((Symbol)args[0]).m_value) / DecimalMath.Log(((Symbol)args[1]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sqrt": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sqrt(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "abs": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Abs(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "acos": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Acos(((Symbol)args[0]).m_value) * 180 / DecimalMath.PI; + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "asin": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Asin(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "atan": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Atan(((Symbol)args[0]).m_value) * 180 / DecimalMath.PI; + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "exp": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Exp(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + default: + if (m_defaultFunctionEvaluation != null) + result = m_defaultFunctionEvaluation(name, args); + else + { + result.m_name = "Function: " + name + ", not found."; + result.m_type = Type.Error; + } + break; + } + return result; + } + + protected bool m_bError = false; + protected string m_sErrorDescription = "None"; + public decimal m_result = 0; + public ArrayList m_equation = new ArrayList(); + public ArrayList m_postfix = new ArrayList(); + protected EvaluateFunctionDelegate m_defaultFunctionEvaluation; +} diff --git a/MathApp/MathApp/Core/Matrix.cs b/MathApp/MathApp/Core/Matrix.cs new file mode 100644 index 0000000..ff51221 --- /dev/null +++ b/MathApp/MathApp/Core/Matrix.cs @@ -0,0 +1,318 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; + +public class Matrix +{ + private static Random random = new Random(); + + public static decimal[][] GenerateRandomMatrix(int rows, int columns, decimal min, decimal max) + { + decimal[][] res = new decimal[rows][]; + for (int i = 0; i < rows; i++) + { + res[i] = new decimal[columns]; + for (int j = 0; j < columns; j++) + { + // Replaced UnityEngine.Random with System.Random + double range = (double)(max - min); + double sample = random.NextDouble(); + double scaled = (sample * range) + (double)min; + decimal value = (decimal)System.Math.Round(scaled, 2); + res[i][j] = value; + } + } + return res; + } + + public static decimal[][] Transpoze(decimal[][] _m) + { + decimal[][] res = new decimal[_m[0].Length][]; + for (int i = 0; i < _m[0].Length; i++) + { + res[i] = new decimal[_m.Length]; + } + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + res[j][i] = _m[i][j]; + } + } + return res; + } + + public static decimal MatrixDeterminant(decimal[][] _m) + { + if (_m.Length == _m[0].Length) + { + int c = _m.Length; + if (c == 2) + { + return (decimal)Math.Round(_m[0][0] * _m[1][1] - _m[0][1] * _m[1][0], 5); + } + else if (c == 1) + { + return (decimal)Math.Round(_m[0][0], 5); + } + else if (c == 0) + { + Console.WriteLine("Matrix is empty!"); + return 0; + } + else + { + decimal resDet = 0; + for (int i = 0; i < c; i++) + { + for (int j = 0; j < c; j++) + { + decimal[][] newM = new decimal[c - 1][]; + for (int k = 0; k < c - 1; k++) + { + newM[k] = new decimal[c - 1]; + } + + bool isAddedK = false, isAddedL = false; + int offsetK = 0, offsetL = 0; + + for (int k = 0; k < c; k++) + { + isAddedL = false; + offsetL = 0; + for (int l = 0; l < c; l++) + { + if (!(k == i || l == j)) + { + newM[k + offsetK][l + offsetL] = _m[k][l]; + } + else + { + if (!isAddedK && k == i) + { + offsetK = -1; + isAddedK = true; + } + if (!isAddedL && l == j) + { + offsetL = -1; + isAddedL = true; + } + } + } + } + + decimal cofactor = (decimal)Math.Pow(-1, 0 + j + 2) * MatrixDeterminant(newM); + resDet += cofactor * _m[0][j]; + } + } + return (decimal)Math.Round(resDet, 5); + } + } + else + { + Console.WriteLine("This matrix is not a square matrix!"); + return 0; + } + } + + public static decimal[] SolveEquation(decimal[][] _m, decimal[] _v) + { + int len = _m.Length; + + decimal[] res = new decimal[len]; + decimal d0 = MatrixDeterminant(_m); + + for (int i = 0; i < len; i++) + { + decimal[][] testMa = new decimal[len][]; + for (int j = 0; j < len; j++) + { + testMa[j] = new decimal[len]; + for (int k = 0; k < len; k++) + { + testMa[j][k] = _m[j][k]; + } + } + for (int j = 0; j < len; j++) + { + testMa[j][i] = _v[j]; + } + decimal di = MatrixDeterminant(testMa); + res[i] = (decimal)Math.Round(di / d0, 5); + } + + return res; + } + + public static decimal[][] ConvertLinearEquationsToMatrix(List equations, List variables) + { + if (equations.Count != variables.Count) return null; + + decimal[][] res = new decimal[equations.Count][]; + for (int i = 0; i < equations.Count; i++) + { + res[i] = new decimal[equations.Count]; + string eq = equations[i].Replace(" ", ""); // Remove spaces + + // Split by operators but keep them? + // Better approach: Go through each variable and find its coefficient in the string + + for (int k = 0; k < variables.Count; k++) + { + string varName = variables[k]; + // Find all occurrences? A variable should appear once per equation linearly. + // We need to look for "...[coeff]varName..." + // Simple parser: Scan the equation string. + + // Let's use a robust approach: Replace all other variables with 0 and evaluate? + // No, that requires an expression evaluator. + + // String manipulation approach (as per original code intent but fixed): + int varIndex = eq.IndexOf(varName); + if (varIndex != -1) + { + // Find coefficient ending at varIndex - 1 + string coeffStr = ""; + int curr = varIndex - 1; + + // Scan backwards to find numbers or sign + while (curr >= 0) + { + char c = eq[curr]; + if (char.IsDigit(c) || c == '.') + { + coeffStr = c + coeffStr; + curr--; + } + else if (c == '+' || c == '-') + { + coeffStr = c + coeffStr; + break; // Sign is the start of the coefficient + } + else + { + break; // Another char (maybe another variable?) + } + } + + if (string.IsNullOrEmpty(coeffStr) || coeffStr == "+") + { + res[i][k] = 1; + } + else if (coeffStr == "-") + { + res[i][k] = -1; + } + else + { + if (decimal.TryParse(coeffStr, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal val)) + { + res[i][k] = val; + } + else + { + // Parse error fallback + res[i][k] = 1; + } + } + } + else + { + res[i][k] = 0; + } + } + } + return res; + } + + public static decimal[][] MatrixMultiplication(decimal[][] _m1, decimal[][] _m2) + { + if (_m1[0].Length == _m2.Length) + { + decimal[][] res = new decimal[_m1.Length][]; + for (int i = 0; i < _m1.Length; i++) + { + res[i] = new decimal[_m2[0].Length]; + } + + for (int i = 0; i < res.Length; i++) + { + for (int j = 0; j < res[0].Length; j++) + { + decimal sum = 0; + for (int k = 0; k < _m2.Length; k++) + { + sum += _m1[i][k] * _m2[k][j]; + } + res[i][j] = sum; + } + } + return res; + } + else + { + Console.WriteLine("Matrices cannot be multiplied!"); + return null; + } + } + public static decimal[][] MatrixMultiplication(decimal[][] _m, decimal _c) + { + decimal[][] res = _m; + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + res[i][j] *= _c; + } + } + return res; + } + + public static decimal[] TurnListToVector(List _vec) + { + decimal[] res = new decimal[_vec.Count]; + for (int i = 0; i < _vec.Count; i++) + { + res[i] = _vec[i]; + } + return res; + } + public static decimal[][] TurnListToMatrix(List> _m) + { + decimal[][] res = new decimal[_m.Count][]; + for (int i = 0; i < _m.Count; i++) + { + res[i] = new decimal[_m[i].Count]; + for (int j = 0; j < _m[i].Count; j++) + { + res[i][j] = _m[i][j]; + } + } + return res; + } + + public static string DebugMatrix(decimal[][] _m, string _sep = " ") + { + string sum = ""; + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + sum += _m[i][j] + ((j == _m[0].Length - 1) ? "\n" : _sep); + } + } + return sum; + } + public static string DebugVector(decimal[] _v, string _sep = " ") + { + string sum = ""; + for (int i = 0; i < _v.Length; i++) + { + sum += _v[i] + "\n"; + } + return sum; + } + +} diff --git a/MathApp/MathApp/Core/Matrix/CholeskyDecomposition.cs b/MathApp/MathApp/Core/Matrix/CholeskyDecomposition.cs new file mode 100644 index 0000000..2f13915 --- /dev/null +++ b/MathApp/MathApp/Core/Matrix/CholeskyDecomposition.cs @@ -0,0 +1,174 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// Cholesky Decomposition. + /// For a symmetric, positive definite matrix A, the Cholesky decomposition + /// is an lower triangular matrix L so that A = L*L'. + /// If the matrix is not symmetric or positive definite, the constructor + /// returns a partial decomposition and sets an internal flag that may + /// be queried by the isSPD() method. + /// + + [Serializable] + public class CholeskyDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] L; + + /// Row and column dimension (square matrix). + /// @serial matrix dimension. + /// + private int n; + + /// Symmetric and positive definite flag. + /// @serial is symmetric and positive definite flag. + /// + private bool isspd; + + #endregion // Class variables + + #region Constructor + + /// Cholesky algorithm for symmetric and positive definite matrix. + /// Square, symmetric matrix. + /// + /// Structure to access L and isspd flag. + /// + + public CholeskyDecomposition(GeneralMatrix Arg) + { + // Initialize. + decimal[][] A = Arg.Array; + n = Arg.RowDimension; + L = new decimal[n][]; + for (int i = 0; i < n; i++) + { + L[i] = new decimal[n]; + } + isspd = (Arg.ColumnDimension == n); + // Main loop. + for (int j = 0; j < n; j++) + { + decimal[] Lrowj = L[j]; + decimal d = 0.0m; + for (int k = 0; k < j; k++) + { + decimal[] Lrowk = L[k]; + decimal s = 0.0m; + for (int i = 0; i < k; i++) + { + s += Lrowk[i] * Lrowj[i]; + } + Lrowj[k] = s = (A[j][k] - s) / L[k][k]; + d = d + s * s; + isspd = isspd & (A[k][j] == A[j][k]); + } + d = A[j][j] - d; + isspd = isspd & (d > 0.0m); + L[j][j] = (decimal)Math.Sqrt(Math.Max((double)d, 0)); + for (int k = j + 1; k < n; k++) + { + L[j][k] = 0.0m; + } + } + } + + #endregion // Constructor + + #region Public Properties + /// Is the matrix symmetric and positive definite? + /// true if A is symmetric and positive definite. + /// + virtual public bool SPD + { + get + { + return isspd; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Return triangular factor. + /// L + /// + + public virtual GeneralMatrix GetL() + { + return new GeneralMatrix(L, n, n); + } + + /// Solve A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X so that L*L'*X = B + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is not symmetric positive definite. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != n) + { + throw new System.ArgumentException("Matrix row dimensions must agree."); + } + if (!isspd) + { + throw new System.SystemException("Matrix is not symmetric positive definite."); + } + + // Copy right hand side. + decimal[][] X = B.ArrayCopy; + int nx = B.ColumnDimension; + + // Solve L*Y = B; + for (int k = 0; k < n; k++) + { + for (int i = k + 1; i < n; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * L[i][k]; + } + } + for (int j = 0; j < nx; j++) + { + X[k][j] /= L[k][k]; + } + } + + // Solve L'*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= L[k][k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * L[k][i]; + } + } + } + return new GeneralMatrix(X, n, nx); + } + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/Core/Matrix/EigenvalueDecomposition.cs b/MathApp/MathApp/Core/Matrix/EigenvalueDecomposition.cs new file mode 100644 index 0000000..9a8a49b --- /dev/null +++ b/MathApp/MathApp/Core/Matrix/EigenvalueDecomposition.cs @@ -0,0 +1,928 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + [Serializable] + public class EigenvalueDecomposition : System.Runtime.Serialization.ISerializable + { + private int n; + private bool issymmetric; + private decimal[] d, e; + private decimal[][] V; + private decimal[][] H; + private decimal[] ort; + + private void tred2() + { + for (int j = 0; j < n; j++) + { + d[j] = V[n - 1][j]; + } + + for (int i = n - 1; i > 0; i--) + { + decimal scale = 0.0m; + decimal h = 0.0m; + for (int k = 0; k < i; k++) + { + scale = scale + System.Math.Abs(d[k]); + } + if (scale == 0.0m) + { + e[i] = d[i - 1]; + for (int j = 0; j < i; j++) + { + d[j] = V[i - 1][j]; + V[i][j] = 0.0m; + V[j][i] = 0.0m; + } + } + else + { + for (int k = 0; k < i; k++) + { + d[k] /= scale; + h += d[k] * d[k]; + } + decimal f = d[i - 1]; + decimal g = (decimal)DecimalMath.Sqrt(h); + if (f > 0) + { + g = - g; + } + e[i] = scale * g; + h = h - f * g; + d[i - 1] = f - g; + for (int j = 0; j < i; j++) + { + e[j] = 0.0m; + } + + for (int j = 0; j < i; j++) + { + f = d[j]; + V[j][i] = f; + g = e[j] + V[j][j] * f; + for (int k = j + 1; k <= i - 1; k++) + { + g += V[k][j] * d[k]; + e[k] += V[k][j] * f; + } + e[j] = g; + } + f = 0.0m; + for (int j = 0; j < i; j++) + { + e[j] /= h; + f += e[j] * d[j]; + } + decimal hh = f / (h + h); + for (int j = 0; j < i; j++) + { + e[j] -= hh * d[j]; + } + for (int j = 0; j < i; j++) + { + f = d[j]; + g = e[j]; + for (int k = j; k <= i - 1; k++) + { + V[k][j] -= (f * e[k] + g * d[k]); + } + d[j] = V[i - 1][j]; + V[i][j] = 0.0m; + } + } + d[i] = h; + } + + for (int i = 0; i < n - 1; i++) + { + V[n - 1][i] = V[i][i]; + V[i][i] = 1.0m; + decimal h = d[i + 1]; + if (h != 0.0m) + { + for (int k = 0; k <= i; k++) + { + d[k] = V[k][i + 1] / h; + } + for (int j = 0; j <= i; j++) + { + decimal g = 0.0m; + for (int k = 0; k <= i; k++) + { + g += V[k][i + 1] * V[k][j]; + } + for (int k = 0; k <= i; k++) + { + V[k][j] -= g * d[k]; + } + } + } + for (int k = 0; k <= i; k++) + { + V[k][i + 1] = 0.0m; + } + } + for (int j = 0; j < n; j++) + { + d[j] = V[n - 1][j]; + V[n - 1][j] = 0.0m; + } + V[n - 1][n - 1] = 1.0m; + e[0] = 0.0m; + } + + private void tql2() + { + for (int i = 1; i < n; i++) + { + e[i - 1] = e[i]; + } + e[n - 1] = 0.0m; + + decimal f = 0.0m; + decimal tst1 = 0.0m; + decimal eps = (decimal)DecimalMath.Pow(2.0m, - 52.0m); + for (int l = 0; l < n; l++) + { + tst1 = System.Math.Max(tst1, System.Math.Abs(d[l]) + System.Math.Abs(e[l])); + int m = l; + while (m < n) + { + if (System.Math.Abs(e[m]) <= eps * tst1) + { + break; + } + m++; + } + + if (m > l) + { + int iter = 0; + do + { + iter = iter + 1; + decimal g = d[l]; + decimal p = (d[l + 1] - g) / (2.0m * e[l]); + decimal r = Maths.Hypot(p, 1.0m); + if (p < 0) + { + r = - r; + } + d[l] = e[l] / (p + r); + d[l + 1] = e[l] * (p + r); + decimal dl1 = d[l + 1]; + decimal h = g - d[l]; + for (int i = l + 2; i < n; i++) + { + d[i] -= h; + } + f = f + h; + + p = d[m]; + decimal c = 1.0m; + decimal c2 = c; + decimal c3 = c; + decimal el1 = e[l + 1]; + decimal s = 0.0m; + decimal s2 = 0.0m; + for (int i = m - 1; i >= l; i--) + { + c3 = c2; + c2 = c; + s2 = s; + g = c * e[i]; + h = c * p; + r = Maths.Hypot(p, e[i]); + e[i + 1] = s * r; + s = e[i] / r; + c = p / r; + p = c * d[i] - s * g; + d[i + 1] = h + s * (c * g + s * d[i]); + + for (int k = 0; k < n; k++) + { + h = V[k][i + 1]; + V[k][i + 1] = s * V[k][i] + c * h; + V[k][i] = c * V[k][i] - s * h; + } + } + p = (- s) * s2 * c3 * el1 * e[l] / dl1; + e[l] = s * p; + d[l] = c * p; + } + while (System.Math.Abs(e[l]) > eps * tst1); + } + d[l] = d[l] + f; + e[l] = 0.0m; + } + + for (int i = 0; i < n - 1; i++) + { + int k = i; + decimal p = d[i]; + for (int j = i + 1; j < n; j++) + { + if (d[j] < p) + { + k = j; + p = d[j]; + } + } + if (k != i) + { + d[k] = d[i]; + d[i] = p; + for (int j = 0; j < n; j++) + { + p = V[j][i]; + V[j][i] = V[j][k]; + V[j][k] = p; + } + } + } + } + + private void orthes() + { + int low = 0; + int high = n - 1; + + for (int m = low + 1; m <= high - 1; m++) + { + decimal scale = 0.0m; + for (int i = m; i <= high; i++) + { + scale = scale + System.Math.Abs(H[i][m - 1]); + } + if (scale != 0.0m) + { + decimal h = 0.0m; + for (int i = high; i >= m; i--) + { + ort[i] = H[i][m - 1] / scale; + h += ort[i] * ort[i]; + } + decimal g = (decimal)DecimalMath.Sqrt(h); + if (ort[m] > 0) + { + g = - g; + } + h = h - ort[m] * g; + ort[m] = ort[m] - g; + + for (int j = m; j < n; j++) + { + decimal f = 0.0m; + for (int i = high; i >= m; i--) + { + f += ort[i] * H[i][j]; + } + f = f / h; + for (int i = m; i <= high; i++) + { + H[i][j] -= f * ort[i]; + } + } + + for (int i = 0; i <= high; i++) + { + decimal f = 0.0m; + for (int j = high; j >= m; j--) + { + f += ort[j] * H[i][j]; + } + f = f / h; + for (int j = m; j <= high; j++) + { + H[i][j] -= f * ort[j]; + } + } + ort[m] = scale * ort[m]; + H[m][m - 1] = scale * g; + } + } + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + V[i][j] = (i == j?1.0m:0.0m); + } + } + + for (int m = high - 1; m >= low + 1; m--) + { + if (H[m][m - 1] != 0.0m) + { + for (int i = m + 1; i <= high; i++) + { + ort[i] = H[i][m - 1]; + } + for (int j = m; j <= high; j++) + { + decimal g = 0.0m; + for (int i = m; i <= high; i++) + { + g += ort[i] * V[i][j]; + } + g = (g / ort[m]) / H[m][m - 1]; + for (int i = m; i <= high; i++) + { + V[i][j] += g * ort[i]; + } + } + } + } + } + + + [NonSerialized()] + private decimal cdivr, cdivi; + + private void cdiv(decimal xr, decimal xi, decimal yr, decimal yi) + { + decimal r, d; + if (System.Math.Abs(yr) > System.Math.Abs(yi)) + { + r = yi / yr; + d = yr + r * yi; + cdivr = (xr + r * xi) / d; + cdivi = (xi - r * xr) / d; + } + else + { + r = yr / yi; + d = yi + r * yr; + cdivr = (r * xr + xi) / d; + cdivi = (r * xi - xr) / d; + } + } + + private void hqr2() + { + int nn = this.n; + int n = nn - 1; + int low = 0; + int high = nn - 1; + decimal eps = (decimal)DecimalMath.Pow(2.0m, - 52.0m); + decimal exshift = 0.0m; + decimal p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y; + + decimal norm = 0.0m; + for (int i = 0; i < nn; i++) + { + if (i < low | i > high) + { + d[i] = H[i][i]; + e[i] = 0.0m; + } + for (int j = System.Math.Max(i - 1, 0); j < nn; j++) + { + norm = norm + System.Math.Abs(H[i][j]); + } + } + + int iter = 0; + while (n >= low) + { + int l = n; + while (l > low) + { + s = System.Math.Abs(H[l - 1][l - 1]) + System.Math.Abs(H[l][l]); + if (s == 0.0m) + { + s = norm; + } + if (System.Math.Abs(H[l][l - 1]) < eps * s) + { + break; + } + l--; + } + + if (l == n) + { + H[n][n] = H[n][n] + exshift; + d[n] = H[n][n]; + e[n] = 0.0m; + n--; + iter = 0; + } + else if (l == n - 1) + { + w = H[n][n - 1] * H[n - 1][n]; + p = (H[n - 1][n - 1] - H[n][n]) / 2.0m; + q = p * p + w; + z = (decimal)DecimalMath.Sqrt(System.Math.Abs(q)); + H[n][n] = H[n][n] + exshift; + H[n - 1][n - 1] = H[n - 1][n - 1] + exshift; + x = H[n][n]; + + if (q >= 0) + { + if (p >= 0) + { + z = p + z; + } + else + { + z = p - z; + } + d[n - 1] = x + z; + d[n] = d[n - 1]; + if (z != 0.0m) + { + d[n] = x - w / z; + } + e[n - 1] = 0.0m; + e[n] = 0.0m; + x = H[n][n - 1]; + s = System.Math.Abs(x) + System.Math.Abs(z); + p = x / s; + q = z / s; + r = (decimal)DecimalMath.Sqrt(p * p + q * q); + p = p / r; + q = q / r; + + for (int j = n - 1; j < nn; j++) + { + z = H[n - 1][j]; + H[n - 1][j] = q * z + p * H[n][j]; + H[n][j] = q * H[n][j] - p * z; + } + + for (int i = 0; i <= n; i++) + { + z = H[i][n - 1]; + H[i][n - 1] = q * z + p * H[i][n]; + H[i][n] = q * H[i][n] - p * z; + } + + for (int i = low; i <= high; i++) + { + z = V[i][n - 1]; + V[i][n - 1] = q * z + p * V[i][n]; + V[i][n] = q * V[i][n] - p * z; + } + + } + else + { + d[n - 1] = x + p; + d[n] = x + p; + e[n - 1] = z; + e[n] = - z; + } + n = n - 2; + iter = 0; + + } + else + { + x = H[n][n]; + y = 0.0m; + w = 0.0m; + if (l < n) + { + y = H[n - 1][n - 1]; + w = H[n][n - 1] * H[n - 1][n]; + } + + if (iter == 10) + { + exshift += x; + for (int i = low; i <= n; i++) + { + H[i][i] -= x; + } + s = System.Math.Abs(H[n][n - 1]) + System.Math.Abs(H[n - 1][n - 2]); + x = y = 0.75m * s; + w = (- 0.4375m) * s * s; + } + + if (iter == 30) + { + s = (y - x) / 2.0m; + s = s * s + w; + if (s > 0) + { + s = (decimal)DecimalMath.Sqrt(s); + if (y < x) + { + s = - s; + } + s = x - w / ((y - x) / 2.0m + s); + for (int i = low; i <= n; i++) + { + H[i][i] -= s; + } + exshift += s; + x = y = w = 0.964m; + } + } + + iter = iter + 1; + + int m = n - 2; + while (m >= l) + { + z = H[m][m]; + r = x - z; + s = y - z; + p = (r * s - w) / H[m + 1][m] + H[m][m + 1]; + q = H[m + 1][m + 1] - z - r - s; + r = H[m + 2][m + 1]; + s = System.Math.Abs(p) + System.Math.Abs(q) + System.Math.Abs(r); + p = p / s; + q = q / s; + r = r / s; + if (m == l) + { + break; + } + if (System.Math.Abs(H[m][m - 1]) * (System.Math.Abs(q) + System.Math.Abs(r)) < eps * (System.Math.Abs(p) * (System.Math.Abs(H[m - 1][m - 1]) + System.Math.Abs(z) + System.Math.Abs(H[m + 1][m + 1])))) + { + break; + } + m--; + } + + for (int i = m + 2; i <= n; i++) + { + H[i][i - 2] = 0.0m; + if (i > m + 2) + { + H[i][i - 3] = 0.0m; + } + } + + for (int k = m; k <= n - 1; k++) + { + bool notlast = (k != n - 1); + if (k != m) + { + p = H[k][k - 1]; + q = H[k + 1][k - 1]; + r = (notlast?H[k + 2][k - 1]:0.0m); + x = System.Math.Abs(p) + System.Math.Abs(q) + System.Math.Abs(r); + if (x != 0.0m) + { + p = p / x; + q = q / x; + r = r / x; + } + } + if (x == 0.0m) + { + break; + } + s = (decimal)DecimalMath.Sqrt(p * p + q * q + r * r); + if (p < 0) + { + s = - s; + } + if (s != 0) + { + if (k != m) + { + H[k][k - 1] = (- s) * x; + } + else if (l != m) + { + H[k][k - 1] = - H[k][k - 1]; + } + p = p + s; + x = p / s; + y = q / s; + z = r / s; + q = q / p; + r = r / p; + + for (int j = k; j < nn; j++) + { + p = H[k][j] + q * H[k + 1][j]; + if (notlast) + { + p = p + r * H[k + 2][j]; + H[k + 2][j] = H[k + 2][j] - p * z; + } + H[k][j] = H[k][j] - p * x; + H[k + 1][j] = H[k + 1][j] - p * y; + } + + for (int i = 0; i <= System.Math.Min(n, k + 3); i++) + { + p = x * H[i][k] + y * H[i][k + 1]; + if (notlast) + { + p = p + z * H[i][k + 2]; + H[i][k + 2] = H[i][k + 2] - p * r; + } + H[i][k] = H[i][k] - p; + H[i][k + 1] = H[i][k + 1] - p * q; + } + + for (int i = low; i <= high; i++) + { + p = x * V[i][k] + y * V[i][k + 1]; + if (notlast) + { + p = p + z * V[i][k + 2]; + V[i][k + 2] = V[i][k + 2] - p * r; + } + V[i][k] = V[i][k] - p; + V[i][k + 1] = V[i][k + 1] - p * q; + } + } + } + } + } + + if (norm == 0.0m) + { + return ; + } + + for (n = nn - 1; n >= 0; n--) + { + p = d[n]; + q = e[n]; + + if (q == 0) + { + int l = n; + H[n][n] = 1.0m; + for (int i = n - 1; i >= 0; i--) + { + w = H[i][i] - p; + r = 0.0m; + for (int j = l; j <= n; j++) + { + r = r + H[i][j] * H[j][n]; + } + if (e[i] < 0.0m) + { + z = w; + s = r; + } + else + { + l = i; + if (e[i] == 0.0m) + { + if (w != 0.0m) + { + H[i][n] = (- r) / w; + } + else + { + H[i][n] = (- r) / (eps * norm); + } + } + else + { + x = H[i][i + 1]; + y = H[i + 1][i]; + q = (d[i] - p) * (d[i] - p) + e[i] * e[i]; + t = (x * s - z * r) / q; + H[i][n] = t; + if (System.Math.Abs(x) > System.Math.Abs(z)) + { + H[i + 1][n] = (- r - w * t) / x; + } + else + { + H[i + 1][n] = (- s - y * t) / z; + } + } + + t = System.Math.Abs(H[i][n]); + if ((eps * t) * t > 1) + { + for (int j = i; j <= n; j++) + { + H[j][n] = H[j][n] / t; + } + } + } + } + } + else if (q < 0) + { + int l = n - 1; + if (System.Math.Abs(H[n][n - 1]) > System.Math.Abs(H[n - 1][n])) + { + H[n - 1][n - 1] = q / H[n][n - 1]; + H[n - 1][n] = (- (H[n][n] - p)) / H[n][n - 1]; + } + else + { + cdiv(0.0m, - H[n - 1][n], H[n - 1][n - 1] - p, q); + H[n - 1][n - 1] = cdivr; + H[n - 1][n] = cdivi; + } + H[n][n - 1] = 0.0m; + H[n][n] = 1.0m; + for (int i = n - 2; i >= 0; i--) + { + decimal ra, sa, vr, vi; + ra = 0.0m; + sa = 0.0m; + for (int j = l; j <= n; j++) + { + ra = ra + H[i][j] * H[j][n - 1]; + sa = sa + H[i][j] * H[j][n]; + } + w = H[i][i] - p; + + if (e[i] < 0.0m) + { + z = w; + r = ra; + s = sa; + } + else + { + l = i; + if (e[i] == 0) + { + cdiv(- ra, - sa, w, q); + H[i][n - 1] = cdivr; + H[i][n] = cdivi; + } + else + { + x = H[i][i + 1]; + y = H[i + 1][i]; + vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q; + vi = (d[i] - p) * 2.0m * q; + if (vr == 0.0m & vi == 0.0m) + { + vr = eps * norm * (System.Math.Abs(w) + System.Math.Abs(q) + System.Math.Abs(x) + System.Math.Abs(y) + System.Math.Abs(z)); + } + cdiv(x * r - z * ra + q * sa, x * s - z * sa - q * ra, vr, vi); + H[i][n - 1] = cdivr; + H[i][n] = cdivi; + if (System.Math.Abs(x) > (System.Math.Abs(z) + System.Math.Abs(q))) + { + H[i + 1][n - 1] = (- ra - w * H[i][n - 1] + q * H[i][n]) / x; + H[i + 1][n] = (- sa - w * H[i][n] - q * H[i][n - 1]) / x; + } + else + { + cdiv(- r - y * H[i][n - 1], - s - y * H[i][n], z, q); + H[i + 1][n - 1] = cdivr; + H[i + 1][n] = cdivi; + } + } + + t = System.Math.Max(System.Math.Abs(H[i][n - 1]), System.Math.Abs(H[i][n])); + if ((eps * t) * t > 1) + { + for (int j = i; j <= n; j++) + { + H[j][n - 1] = H[j][n - 1] / t; + H[j][n] = H[j][n] / t; + } + } + } + } + } + } + + for (int i = 0; i < nn; i++) + { + if (i < low | i > high) + { + for (int j = i; j < nn; j++) + { + V[i][j] = H[i][j]; + } + } + } + + for (int j = nn - 1; j >= low; j--) + { + for (int i = low; i <= high; i++) + { + z = 0.0m; + for (int k = low; k <= System.Math.Min(j, high); k++) + { + z = z + V[i][k] * H[k][j]; + } + V[i][j] = z; + } + } + } + + public EigenvalueDecomposition(GeneralMatrix Arg) + { + decimal[][] A = Arg.Array; + n = Arg.ColumnDimension; + V = new decimal[n][]; + for (int i = 0; i < n; i++) + { + V[i] = new decimal[n]; + } + d = new decimal[n]; + e = new decimal[n]; + + issymmetric = true; + for (int j = 0; (j < n) & issymmetric; j++) + { + for (int i = 0; (i < n) & issymmetric; i++) + { + issymmetric = (A[i][j] == A[j][i]); + } + } + + if (issymmetric) + { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + V[i][j] = A[i][j]; + } + } + + tred2(); + tql2(); + } + else + { + H = new decimal[n][]; + for (int i2 = 0; i2 < n; i2++) + { + H[i2] = new decimal[n]; + } + ort = new decimal[n]; + + for (int j = 0; j < n; j++) + { + for (int i = 0; i < n; i++) + { + H[i][j] = A[i][j]; + } + } + + orthes(); + hqr2(); + } + } + + virtual public decimal[] RealEigenvalues + { + get + { + return d; + } + } + virtual public decimal[] ImagEigenvalues + { + get + { + return e; + } + } + virtual public GeneralMatrix D + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] D = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + D[i][j] = 0.0m; + } + D[i][i] = d[i]; + if (e[i] > 0) + { + D[i][i + 1] = e[i]; + } + else if (e[i] < 0) + { + D[i][i - 1] = e[i]; + } + } + return X; + } + } + + public virtual GeneralMatrix GetV() + { + return new GeneralMatrix(V, n, n); + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/Core/Matrix/GeneralMatrix.cs b/MathApp/MathApp/Core/Matrix/GeneralMatrix.cs new file mode 100644 index 0000000..a026b32 --- /dev/null +++ b/MathApp/MathApp/Core/Matrix/GeneralMatrix.cs @@ -0,0 +1,767 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + internal class Maths + { + public static decimal Hypot(decimal a, decimal b) + { + decimal r; + if (Math.Abs(a) > Math.Abs(b)) + { + r = b/a; + r = Math.Abs(a) * (decimal)DecimalMath.Sqrt(1 + r * r); + } + else if (b != 0) + { + r = a/b; + r = Math.Abs(b) * (decimal)DecimalMath.Sqrt(1 + r * r); + } + else + { + r = 0.0m; + } + return r; + } + } + + [Serializable] + public class GeneralMatrix : System.ICloneable, System.Runtime.Serialization.ISerializable, System.IDisposable + { + private decimal[][] A; + private int m, n; + + public GeneralMatrix(int m, int n) + { + this.m = m; + this.n = n; + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + } + } + + public GeneralMatrix(int m, int n, decimal s) + { + this.m = m; + this.n = n; + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + for (int j = 0; j < n; j++) + { + A[i][j] = s; + } + } + } + + public GeneralMatrix(decimal[][] A) + { + m = A.Length; + n = A[0].Length; + for (int i = 0; i < m; i++) + { + if (A[i].Length != n) + { + throw new System.ArgumentException("All rows must have the same length."); + } + } + this.A = A; + } + + public GeneralMatrix(decimal[][] A, int m, int n) + { + this.A = A; + this.m = m; + this.n = n; + } + + public GeneralMatrix(decimal[] vals, int m) + { + this.m = m; + n = (m != 0?vals.Length / m:0); + if (m * n != vals.Length) + { + throw new System.ArgumentException("Array length must be a multiple of m."); + } + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + for (int j = 0; j < n; j++) + { + A[i][j] = vals[i + j * m]; + } + } + } + + public virtual decimal[][] Array + { + get + { + return A; + } + } + + public virtual decimal[][] ArrayCopy + { + get + { + decimal[][] C = new decimal[m][]; + for (int i = 0; i < m; i++) + { + C[i] = new decimal[n]; + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return C; + } + } + + public virtual decimal[] ColumnPackedCopy + { + get + { + decimal[] vals = new decimal[m * n]; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + vals[i + j * m] = A[i][j]; + } + } + return vals; + } + } + + public virtual decimal[] RowPackedCopy + { + get + { + decimal[] vals = new decimal[m * n]; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + vals[i * n + j] = A[i][j]; + } + } + return vals; + } + } + + public virtual int RowDimension + { + get + { + return m; + } + } + + public virtual int ColumnDimension + { + get + { + return n; + } + } + + public static GeneralMatrix ConstructWithCopy(decimal[][] A) + { + int m = A.Length; + int n = A[0].Length; + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + if (A[i].Length != n) + { + throw new System.ArgumentException("All rows must have the same length."); + } + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix Copy() + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return X; + } + + public virtual decimal GetElement(int i, int j) + { + return A[i][j]; + } + + public virtual GeneralMatrix GetMatrix(int i0, int i1, int j0, int j1) + { + GeneralMatrix X = new GeneralMatrix(i1 - i0 + 1, j1 - j0 + 1); + decimal[][] B = X.Array; + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = j0; j <= j1; j++) + { + B[i - i0][j - j0] = A[i][j]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual GeneralMatrix GetMatrix(int[] r, int[] c) + { + GeneralMatrix X = new GeneralMatrix(r.Length, c.Length); + decimal[][] B = X.Array; + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = 0; j < c.Length; j++) + { + B[i][j] = A[r[i]][c[j]]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual GeneralMatrix GetMatrix(int i0, int i1, int[] c) + { + GeneralMatrix X = new GeneralMatrix(i1 - i0 + 1, c.Length); + decimal[][] B = X.Array; + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = 0; j < c.Length; j++) + { + B[i - i0][j] = A[i][c[j]]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual GeneralMatrix GetMatrix(int[] r, int j0, int j1) + { + GeneralMatrix X = new GeneralMatrix(r.Length, j1 - j0 + 1); + decimal[][] B = X.Array; + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = j0; j <= j1; j++) + { + B[i][j - j0] = A[r[i]][j]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual void SetElement(int i, int j, decimal s) + { + A[i][j] = s; + } + + public virtual void SetMatrix(int i0, int i1, int j0, int j1, GeneralMatrix X) + { + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = j0; j <= j1; j++) + { + A[i][j] = X.GetElement(i - i0, j - j0); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual void SetMatrix(int[] r, int[] c, GeneralMatrix X) + { + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = 0; j < c.Length; j++) + { + A[r[i]][c[j]] = X.GetElement(i, j); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual void SetMatrix(int[] r, int j0, int j1, GeneralMatrix X) + { + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = j0; j <= j1; j++) + { + A[r[i]][j] = X.GetElement(i, j - j0); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual void SetMatrix(int i0, int i1, int[] c, GeneralMatrix X) + { + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = 0; j < c.Length; j++) + { + A[i][c[j]] = X.GetElement(i - i0, j); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual GeneralMatrix Transpose() + { + GeneralMatrix X = new GeneralMatrix(n, m); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[j][i] = A[i][j]; + } + } + return X; + } + + public virtual decimal Norm1() + { + decimal f = 0; + for (int j = 0; j < n; j++) + { + decimal s = 0; + for (int i = 0; i < m; i++) + { + s += System.Math.Abs(A[i][j]); + } + f = System.Math.Max(f, s); + } + return f; + } + + public virtual decimal NormInf() + { + decimal f = 0; + for (int i = 0; i < m; i++) + { + decimal s = 0; + for (int j = 0; j < n; j++) + { + s += System.Math.Abs(A[i][j]); + } + f = System.Math.Max(f, s); + } + return f; + } + + public virtual decimal NormF() + { + decimal f = 0; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + f = Maths.Hypot(f, A[i][j]); + } + } + return f; + } + + public virtual GeneralMatrix UnaryMinus() + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = - A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix Add(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] + B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix AddEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] + B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix Subtract(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] - B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix SubtractEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] - B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix ArrayMultiply(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] * B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix ArrayMultiplyEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] * B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix ArrayRightDivide(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] / B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix ArrayRightDivideEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] / B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix ArrayLeftDivide(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = B.A[i][j] / A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix ArrayLeftDivideEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = B.A[i][j] / A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix Multiply(decimal s) + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = s * A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix MultiplyEquals(decimal s) + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = s * A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix Multiply(GeneralMatrix B) + { + if (B.m != n) + { + throw new System.ArgumentException("GeneralMatrix inner dimensions must agree."); + } + GeneralMatrix X = new GeneralMatrix(m, B.n); + decimal[][] C = X.Array; + decimal[] Bcolj = new decimal[n]; + for (int j = 0; j < B.n; j++) + { + for (int k = 0; k < n; k++) + { + Bcolj[k] = B.A[k][j]; + } + for (int i = 0; i < m; i++) + { + decimal[] Arowi = A[i]; + decimal s = 0; + for (int k = 0; k < n; k++) + { + s += Arowi[k] * Bcolj[k]; + } + C[i][j] = s; + } + } + return X; + } + + public static GeneralMatrix operator +(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Add(m2); + } + + public static GeneralMatrix operator -(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Subtract(m2); + } + + public static GeneralMatrix operator *(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Multiply(m2); + } + + public virtual LUDecomposition LUD() + { + return new LUDecomposition(this); + } + + public virtual QRDecomposition QRD() + { + return new QRDecomposition(this); + } + + public virtual CholeskyDecomposition chol() + { + return new CholeskyDecomposition(this); + } + + public virtual SingularValueDecomposition SVD() + { + return new SingularValueDecomposition(this); + } + + public virtual EigenvalueDecomposition Eigen() + { + return new EigenvalueDecomposition(this); + } + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + return (m == n ? (new LUDecomposition(this)).Solve(B):(new QRDecomposition(this)).Solve(B)); + } + + public virtual GeneralMatrix SolveTranspose(GeneralMatrix B) + { + return Transpose().Solve(B.Transpose()); + } + + public virtual GeneralMatrix Inverse() + { + return Solve(Identity(m, m)); + } + + public virtual decimal Determinant() + { + return new LUDecomposition(this).Determinant(); + } + + public virtual int Rank() + { + return new SingularValueDecomposition(this).Rank(); + } + + public virtual decimal Condition() + { + return new SingularValueDecomposition(this).Condition(); + } + + public virtual decimal Trace() + { + decimal t = 0; + for (int i = 0; i < System.Math.Min(m, n); i++) + { + t += A[i][i]; + } + return t; + } + + public static GeneralMatrix Identity(int m, int n) + { + GeneralMatrix A = new GeneralMatrix(m, n); + decimal[][] X = A.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + X[i][j] = (i == j ? 1.0m : 0.0m); + } + } + return A; + } + + private void CheckMatrixDimensions(GeneralMatrix B) + { + if (B.m != m || B.n != n) + { + throw new System.ArgumentException("GeneralMatrix dimensions must agree."); + } + } + + public void Dispose() + { + Dispose(true); + } + + private void Dispose(bool disposing) + { + if (disposing) + GC.SuppressFinalize(this); + } + + ~GeneralMatrix() + { + Dispose(false); + } + + public System.Object Clone() + { + return this.Copy(); + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/Core/Matrix/LUDecomposition.cs b/MathApp/MathApp/Core/Matrix/LUDecomposition.cs new file mode 100644 index 0000000..a30d86f --- /dev/null +++ b/MathApp/MathApp/Core/Matrix/LUDecomposition.cs @@ -0,0 +1,322 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// LU Decomposition. + /// For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n + /// unit lower triangular matrix L, an n-by-n upper triangular matrix U, + /// and a permutation vector piv of length m so that A(piv,:) = L*U. + /// If m < n, then L is m-by-m and U is m-by-n. + /// The LU decompostion with pivoting always exists, even if the matrix is + /// singular, so the constructor will never fail. The primary use of the + /// LU decomposition is in the solution of square systems of simultaneous + /// linear equations. This will fail if IsNonSingular() returns false. + /// + + [Serializable] + public class LUDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] LU; + + /// Row and column dimensions, and pivot sign. + /// @serial column dimension. + /// @serial row dimension. + /// @serial pivot sign. + /// + private int m, n, pivsign; + + /// Internal storage of pivot vector. + /// @serial pivot vector. + /// + private int[] piv; + + #endregion // Class variables + + #region Constructor + + /// LU Decomposition + /// Rectangular matrix + /// + /// Structure to access L, U and piv. + /// + + public LUDecomposition(GeneralMatrix A) + { + // Use a "left-looking", dot-product, Crout/Doolittle algorithm. + + LU = A.ArrayCopy; + m = A.RowDimension; + n = A.ColumnDimension; + piv = new int[m]; + for (int i = 0; i < m; i++) + { + piv[i] = i; + } + pivsign = 1; + decimal[] LUrowi; + decimal[] LUcolj = new decimal[m]; + + // Outer loop. + + for (int j = 0; j < n; j++) + { + + // Make a copy of the j-th column to localize references. + + for (int i = 0; i < m; i++) + { + LUcolj[i] = LU[i][j]; + } + + // Apply previous transformations. + + for (int i = 0; i < m; i++) + { + LUrowi = LU[i]; + + // Most of the time is spent in the following dot product. + + int kmax = System.Math.Min(i, j); + decimal s = 0.0m; + for (int k = 0; k < kmax; k++) + { + s += LUrowi[k] * LUcolj[k]; + } + + LUrowi[j] = LUcolj[i] -= s; + } + + // Find pivot and exchange if necessary. + + int p = j; + for (int i = j + 1; i < m; i++) + { + if (System.Math.Abs(LUcolj[i]) > System.Math.Abs(LUcolj[p])) + { + p = i; + } + } + if (p != j) + { + for (int k = 0; k < n; k++) + { + decimal t = LU[p][k]; LU[p][k] = LU[j][k]; LU[j][k] = t; + } + int k2 = piv[p]; piv[p] = piv[j]; piv[j] = k2; + pivsign = - pivsign; + } + + // Compute multipliers. + + if (j < m & LU[j][j] != 0.0m) + { + for (int i = j + 1; i < m; i++) + { + LU[i][j] /= LU[j][j]; + } + } + } + } + #endregion // Constructor + + #region Public Properties + /// Is the matrix nonsingular? + /// true if U, and hence A, is nonsingular. + /// + virtual public bool IsNonSingular + { + get + { + for (int j = 0; j < n; j++) + { + if (LU[j][j] == 0) + return false; + } + return true; + } + } + + /// Return lower triangular factor + /// L + /// + virtual public GeneralMatrix L + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] L = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + if (i > j) + { + L[i][j] = LU[i][j]; + } + else if (i == j) + { + L[i][j] = 1.0m; + } + else + { + L[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Return upper triangular factor + /// U + /// + virtual public GeneralMatrix U + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] U = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i <= j) + { + U[i][j] = LU[i][j]; + } + else + { + U[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Return pivot permutation vector + /// piv + /// + virtual public int[] Pivot + { + get + { + int[] p = new int[m]; + for (int i = 0; i < m; i++) + { + p[i] = piv[i]; + } + return p; + } + } + + /// Return pivot permutation vector as a one-dimensional decimal array + /// (decimal) piv + /// + virtual public decimal[] decimalPivot + { + get + { + decimal[] vals = new decimal[m]; + for (int i = 0; i < m; i++) + { + vals[i] = (decimal) piv[i]; + } + return vals; + } + } + + #endregion // Public Properties + + #region Public Methods + + /// Determinant + /// det(A) + /// + /// Matrix must be square + /// + + public virtual decimal Determinant() + { + if (m != n) + { + throw new System.ArgumentException("Matrix must be square."); + } + decimal d = (decimal) pivsign; + for (int j = 0; j < n; j++) + { + d *= LU[j][j]; + } + return d; + } + + /// Solve A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X so that L*U*X = B(piv,:) + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is singular. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != m) + { + throw new System.ArgumentException("Matrix row dimensions must agree."); + } + if (!this.IsNonSingular) + { + throw new System.SystemException("Matrix is singular."); + } + + // Copy right hand side with pivoting + int nx = B.ColumnDimension; + GeneralMatrix Xmat = B.GetMatrix(piv, 0, nx - 1); + decimal[][] X = Xmat.Array; + + // Solve L*Y = B(piv,:) + for (int k = 0; k < n; k++) + { + for (int i = k + 1; i < n; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * LU[i][k]; + } + } + } + // Solve U*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= LU[k][k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * LU[i][k]; + } + } + } + return Xmat; + } + + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/Core/Matrix/QRDecomposition.cs b/MathApp/MathApp/Core/Matrix/QRDecomposition.cs new file mode 100644 index 0000000..8702b0f --- /dev/null +++ b/MathApp/MathApp/Core/Matrix/QRDecomposition.cs @@ -0,0 +1,287 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// QR Decomposition. + /// For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n + /// orthogonal matrix Q and an n-by-n upper triangular matrix R so that + /// A = Q*R. + /// + /// The QR decompostion always exists, even if the matrix does not have + /// full rank, so the constructor will never fail. The primary use of the + /// QR decomposition is in the least squares solution of nonsquare systems + /// of simultaneous linear equations. This will fail if IsFullRank() + /// returns false. + /// + + [Serializable] + public class QRDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] QR; + + /// Row and column dimensions. + /// @serial column dimension. + /// @serial row dimension. + /// + private int m, n; + + /// Array for internal storage of diagonal of R. + /// @serial diagonal of R. + /// + private decimal[] Rdiag; + + #endregion // Class variables + + #region Constructor + + /// QR Decomposition, computed by Householder reflections. + /// Rectangular matrix + /// + /// Structure to access R and the Householder vectors and compute Q. + /// + + public QRDecomposition(GeneralMatrix A) + { + // Initialize. + QR = A.ArrayCopy; + m = A.RowDimension; + n = A.ColumnDimension; + Rdiag = new decimal[n]; + + // Main loop. + for (int k = 0; k < n; k++) + { + // Compute 2-norm of k-th column without under/overflow. + decimal nrm = 0; + for (int i = k; i < m; i++) + { + nrm = Maths.Hypot(nrm, QR[i][k]); + } + + if (nrm != 0.0m) + { + // Form k-th Householder vector. + if (QR[k][k] < 0) + { + nrm = - nrm; + } + for (int i = k; i < m; i++) + { + QR[i][k] /= nrm; + } + QR[k][k] += 1.0m; + + // Apply transformation to remaining columns. + for (int j = k + 1; j < n; j++) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * QR[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + QR[i][j] += s * QR[i][k]; + } + } + } + Rdiag[k] = - nrm; + } + } + + #endregion // Constructor + + #region Public Properties + + /// Is the matrix full rank? + /// true if R, and hence A, has full rank. + /// + virtual public bool FullRank + { + get + { + for (int j = 0; j < n; j++) + { + if (Rdiag[j] == 0) + return false; + } + return true; + } + } + + /// Return the Householder vectors + /// Lower trapezoidal matrix whose columns define the reflections + /// + virtual public GeneralMatrix H + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] H = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + if (i >= j) + { + H[i][j] = QR[i][j]; + } + else + { + H[i][j] = 0.0m; + } + } + } + return X; + } + + } + + /// Return the upper triangular factor + /// R + /// + virtual public GeneralMatrix R + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] R = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i < j) + { + R[i][j] = QR[i][j]; + } + else if (i == j) + { + R[i][j] = Rdiag[i]; + } + else + { + R[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Generate and return the (economy-sized) orthogonal factor + /// Q + /// + virtual public GeneralMatrix Q + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] Q = X.Array; + for (int k = n - 1; k >= 0; k--) + { + for (int i = 0; i < m; i++) + { + Q[i][k] = 0.0m; + } + Q[k][k] = 1.0m; + for (int j = k; j < n; j++) + { + if (QR[k][k] != 0) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * Q[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + Q[i][j] += s * QR[i][k]; + } + } + } + } + return X; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Least squares solution of A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X that minimizes the two norm of Q*R*X-B. + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is rank deficient. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != m) + { + throw new System.ArgumentException("GeneralMatrix row dimensions must agree."); + } + if (!this.FullRank) + { + throw new System.SystemException("Matrix is rank deficient."); + } + + // Copy right hand side + int nx = B.ColumnDimension; + decimal[][] X = B.ArrayCopy; + + // Compute Y = transpose(Q)*B + for (int k = 0; k < n; k++) + { + for (int j = 0; j < nx; j++) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * X[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + X[i][j] += s * QR[i][k]; + } + } + } + // Solve R*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= Rdiag[k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * QR[i][k]; + } + } + } + + return (new GeneralMatrix(X, n, nx).GetMatrix(0, n - 1, 0, nx - 1)); + } + + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/Core/Matrix/SingularValueDecomposition.cs b/MathApp/MathApp/Core/Matrix/SingularValueDecomposition.cs new file mode 100644 index 0000000..3a51b8e --- /dev/null +++ b/MathApp/MathApp/Core/Matrix/SingularValueDecomposition.cs @@ -0,0 +1,512 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + [Serializable] + public class SingularValueDecomposition : System.Runtime.Serialization.ISerializable + { + private decimal[][] U, V; + private decimal[] s; + private int m, n; + + public SingularValueDecomposition(GeneralMatrix Arg) + { + decimal[][] A = Arg.ArrayCopy; + m = Arg.RowDimension; + n = Arg.ColumnDimension; + int nu = System.Math.Min(m, n); + s = new decimal[System.Math.Min(m + 1, n)]; + U = new decimal[m][]; + for (int i = 0; i < m; i++) + { + U[i] = new decimal[nu]; + } + V = new decimal[n][]; + for (int i2 = 0; i2 < n; i2++) + { + V[i2] = new decimal[n]; + } + decimal[] e = new decimal[n]; + decimal[] work = new decimal[m]; + bool wantu = true; + bool wantv = true; + + int nct = System.Math.Min(m - 1, n); + int nrt = System.Math.Max(0, System.Math.Min(n - 2, m)); + for (int k = 0; k < System.Math.Max(nct, nrt); k++) + { + if (k < nct) + { + s[k] = 0; + for (int i = k; i < m; i++) + { + s[k] = Maths.Hypot(s[k], A[i][k]); + } + if (s[k] != 0.0m) + { + if (A[k][k] < 0.0m) + { + s[k] = - s[k]; + } + for (int i = k; i < m; i++) + { + A[i][k] /= s[k]; + } + A[k][k] += 1.0m; + } + s[k] = - s[k]; + } + for (int j = k + 1; j < n; j++) + { + if ((k < nct) & (s[k] != 0.0m)) + { + decimal t = 0; + for (int i = k; i < m; i++) + { + t += A[i][k] * A[i][j]; + } + t = (- t) / A[k][k]; + for (int i = k; i < m; i++) + { + A[i][j] += t * A[i][k]; + } + } + e[j] = A[k][j]; + } + if (wantu & (k < nct)) + { + for (int i = k; i < m; i++) + { + U[i][k] = A[i][k]; + } + } + if (k < nrt) + { + e[k] = 0; + for (int i = k + 1; i < n; i++) + { + e[k] = Maths.Hypot(e[k], e[i]); + } + if (e[k] != 0.0m) + { + if (e[k + 1] < 0.0m) + { + e[k] = - e[k]; + } + for (int i = k + 1; i < n; i++) + { + e[i] /= e[k]; + } + e[k + 1] += 1.0m; + } + e[k] = - e[k]; + if ((k + 1 < m) & (e[k] != 0.0m)) + { + for (int i = k + 1; i < m; i++) + { + work[i] = 0.0m; + } + for (int j = k + 1; j < n; j++) + { + for (int i = k + 1; i < m; i++) + { + work[i] += e[j] * A[i][j]; + } + } + for (int j = k + 1; j < n; j++) + { + decimal t = (- e[j]) / e[k + 1]; + for (int i = k + 1; i < m; i++) + { + A[i][j] += t * work[i]; + } + } + } + if (wantv) + { + for (int i = k + 1; i < n; i++) + { + V[i][k] = e[i]; + } + } + } + } + + int p = System.Math.Min(n, m + 1); + if (nct < n) + { + s[nct] = A[nct][nct]; + } + if (m < p) + { + s[p - 1] = 0.0m; + } + if (nrt + 1 < p) + { + e[nrt] = A[nrt][p - 1]; + } + e[p - 1] = 0.0m; + + if (wantu) + { + for (int j = nct; j < nu; j++) + { + for (int i = 0; i < m; i++) + { + U[i][j] = 0.0m; + } + U[j][j] = 1.0m; + } + for (int k = nct - 1; k >= 0; k--) + { + if (s[k] != 0.0m) + { + for (int j = k + 1; j < nu; j++) + { + decimal t = 0; + for (int i = k; i < m; i++) + { + t += U[i][k] * U[i][j]; + } + t = (- t) / U[k][k]; + for (int i = k; i < m; i++) + { + U[i][j] += t * U[i][k]; + } + } + for (int i = k; i < m; i++) + { + U[i][k] = - U[i][k]; + } + U[k][k] = 1.0m + U[k][k]; + for (int i = 0; i < k - 1; i++) + { + U[i][k] = 0.0m; + } + } + else + { + for (int i = 0; i < m; i++) + { + U[i][k] = 0.0m; + } + U[k][k] = 1.0m; + } + } + } + + if (wantv) + { + for (int k = n - 1; k >= 0; k--) + { + if ((k < nrt) & (e[k] != 0.0m)) + { + for (int j = k + 1; j < nu; j++) + { + decimal t = 0; + for (int i = k + 1; i < n; i++) + { + t += V[i][k] * V[i][j]; + } + t = (- t) / V[k + 1][k]; + for (int i = k + 1; i < n; i++) + { + V[i][j] += t * V[i][k]; + } + } + } + for (int i = 0; i < n; i++) + { + V[i][k] = 0.0m; + } + V[k][k] = 1.0m; + } + } + + int pp = p - 1; + int iter = 0; + decimal eps = (decimal)Math.Pow(2.0f, - 52.0f); + while (p > 0) + { + int k, kase; + for (k = p - 2; k >= - 1; k--) + { + if (k == - 1) + { + break; + } + if (System.Math.Abs(e[k]) <= eps * (System.Math.Abs(s[k]) + System.Math.Abs(s[k + 1]))) + { + e[k] = 0.0m; + break; + } + } + if (k == p - 2) + { + kase = 4; + } + else + { + int ks; + for (ks = p - 1; ks >= k; ks--) + { + if (ks == k) + { + break; + } + decimal t = (ks != p?System.Math.Abs(e[ks]):0.0m) + (ks != k + 1?System.Math.Abs(e[ks - 1]):0.0m); + if (System.Math.Abs(s[ks]) <= eps * t) + { + s[ks] = 0.0m; + break; + } + } + if (ks == k) + { + kase = 3; + } + else if (ks == p - 1) + { + kase = 1; + } + else + { + kase = 2; + k = ks; + } + } + k++; + + switch (kase) + { + case 1: + { + decimal f = e[p - 2]; + e[p - 2] = 0.0m; + for (int j = p - 2; j >= k; j--) + { + decimal t = Maths.Hypot(s[j], f); + decimal cs = s[j] / t; + decimal sn = f / t; + s[j] = t; + if (j != k) + { + f = (- sn) * e[j - 1]; + e[j - 1] = cs * e[j - 1]; + } + if (wantv) + { + for (int i = 0; i < n; i++) + { + t = cs * V[i][j] + sn * V[i][p - 1]; + V[i][p - 1] = (- sn) * V[i][j] + cs * V[i][p - 1]; + V[i][j] = t; + } + } + } + } + break; + case 2: + { + decimal f = e[k - 1]; + e[k - 1] = 0.0m; + for (int j = k; j < p; j++) + { + decimal t = Maths.Hypot(s[j], f); + decimal cs = s[j] / t; + decimal sn = f / t; + s[j] = t; + f = (- sn) * e[j]; + e[j] = cs * e[j]; + if (wantu) + { + for (int i = 0; i < m; i++) + { + t = cs * U[i][j] + sn * U[i][k - 1]; + U[i][k - 1] = (- sn) * U[i][j] + cs * U[i][k - 1]; + U[i][j] = t; + } + } + } + } + break; + case 3: + { + decimal scale = System.Math.Max(System.Math.Max(System.Math.Max(System.Math.Max(System.Math.Abs(s[p - 1]), System.Math.Abs(s[p - 2])), System.Math.Abs(e[p - 2])), System.Math.Abs(s[k])), System.Math.Abs(e[k])); + decimal sp = s[p - 1] / scale; + decimal spm1 = s[p - 2] / scale; + decimal epm1 = e[p - 2] / scale; + decimal sk = s[k] / scale; + decimal ek = e[k] / scale; + decimal b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0m; + decimal c = (sp * epm1) * (sp * epm1); + decimal shift = 0.0m; + if ((b != 0.0m) | (c != 0.0m)) + { + shift = (decimal)DecimalMath.Sqrt(b * b + c); + if (b < 0.0m) + { + shift = - shift; + } + shift = c / (b + shift); + } + decimal f = (sk + sp) * (sk - sp) + shift; + decimal g = sk * ek; + + for (int j = k; j < p - 1; j++) + { + decimal t = Maths.Hypot(f, g); + decimal cs = f / t; + decimal sn = g / t; + if (j != k) + { + e[j - 1] = t; + } + f = cs * s[j] + sn * e[j]; + e[j] = cs * e[j] - sn * s[j]; + g = sn * s[j + 1]; + s[j + 1] = cs * s[j + 1]; + if (wantv) + { + for (int i = 0; i < n; i++) + { + t = cs * V[i][j] + sn * V[i][j + 1]; + V[i][j + 1] = (- sn) * V[i][j] + cs * V[i][j + 1]; + V[i][j] = t; + } + } + t = Maths.Hypot(f, g); + cs = f / t; + sn = g / t; + s[j] = t; + f = cs * e[j] + sn * s[j + 1]; + s[j + 1] = (- sn) * e[j] + cs * s[j + 1]; + g = sn * e[j + 1]; + e[j + 1] = cs * e[j + 1]; + if (wantu && (j < m - 1)) + { + for (int i = 0; i < m; i++) + { + t = cs * U[i][j] + sn * U[i][j + 1]; + U[i][j + 1] = (- sn) * U[i][j] + cs * U[i][j + 1]; + U[i][j] = t; + } + } + } + e[p - 2] = f; + iter = iter + 1; + } + break; + case 4: + { + if (s[k] <= 0.0m) + { + s[k] = (s[k] < 0.0m?- s[k]:0.0m); + if (wantv) + { + for (int i = 0; i <= pp; i++) + { + V[i][k] = - V[i][k]; + } + } + } + while (k < pp) + { + if (s[k] >= s[k + 1]) + { + break; + } + decimal t = s[k]; + s[k] = s[k + 1]; + s[k + 1] = t; + if (wantv && (k < n - 1)) + { + for (int i = 0; i < n; i++) + { + t = V[i][k + 1]; V[i][k + 1] = V[i][k]; V[i][k] = t; + } + } + if (wantu && (k < m - 1)) + { + for (int i = 0; i < m; i++) + { + t = U[i][k + 1]; U[i][k + 1] = U[i][k]; U[i][k] = t; + } + } + k++; + } + iter = 0; + p--; + } + break; + } + } + } + + virtual public decimal[] SingularValues + { + get + { + return s; + } + } + + virtual public GeneralMatrix S + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] S = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + S[i][j] = 0.0m; + } + S[i][i] = this.s[i]; + } + return X; + } + } + + public virtual GeneralMatrix GetU() + { + return new GeneralMatrix(U, m, System.Math.Min(m + 1, n)); + } + + public virtual GeneralMatrix GetV() + { + return new GeneralMatrix(V, n, n); + } + + public virtual decimal Norm2() + { + return s[0]; + } + + public virtual decimal Condition() + { + return s[0] / s[System.Math.Min(m, n) - 1]; + } + + public virtual int Rank() + { + decimal eps = (decimal)System.Math.Pow(2.0f, - 52.0f); + decimal tol = System.Math.Max(m, n) * s[0] * eps; + int r = 0; + for (int i = 0; i < s.Length; i++) + { + if (s[i] > tol) + { + r++; + } + } + return r; + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/Core/NumericalMethods.cs b/MathApp/MathApp/Core/NumericalMethods.cs new file mode 100644 index 0000000..6d0677b --- /dev/null +++ b/MathApp/MathApp/Core/NumericalMethods.cs @@ -0,0 +1,543 @@ +using DotNetMatrix; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Text.RegularExpressions; +using System.Text; +using System.Linq; +using System; + +public class NumericalMethods +{ + // --- Original Methods Ported --- + + public static decimal Method_EvaluateFunction(string eq, string variable, decimal point) + { + string newEq = eq; + newEq = newEq.Replace(variable, point.ToString(CultureInfo.InvariantCulture)); + Function f = new Function(); + f.Parse(newEq); + f.Infix2Postfix(); + f.EvaluatePostfix(); + return f.m_result; + } + + public static decimal MethodMultiVar_EvaluateFunction(string eq, Dictionary points) + { + string newEq = eq; + foreach (KeyValuePair pt in points) + { + newEq = newEq.Replace(pt.Key, pt.Value.ToString(CultureInfo.InvariantCulture)); + } + Function f = new Function(); + f.Parse(newEq); + f.Infix2Postfix(); + f.EvaluatePostfix(); + return f.m_result; + } + + public static Dictionary MethodMultiVar_SolveEquationSystem(List eqs, Dictionary initPoints, int iterationCount = 5, decimal h = 0.001m) + { + Dictionary dynamicPoints = new Dictionary(initPoints); + for (int itC = 0; itC < iterationCount; itC++) + { + List linearizedEqs = new List(); + List variablesStr = new List(); + List leftVector = new List(); + + for (int i = 0; i < eqs.Count; i++) + { + string le = MethodMultiVar_TaylorSeries(eqs[i], 1, dynamicPoints, h); + + decimal leftV = 0; + Match m = Regex.Match(le, @"^([-+]?[0-9]*\.?[0-9]+)"); + if (m.Success) + { + if (m.Index + m.Length < le.Length && le[m.Index + m.Length] == '*') + { + leftV = 0; + } + else + { + leftV = decimal.Parse(m.Value, CultureInfo.InvariantCulture) * -1; + le = le.Substring(m.Length); + } + } + + string sum = ""; + foreach (KeyValuePair p in dynamicPoints) + { + sum += p.Key + ": " + p.Value.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) + ", "; + } + + + + foreach (KeyValuePair p in dynamicPoints) + { + le = le.Replace("(" + p.Key + (p.Value < 0 ? "+" + DecimalMath.Abs(p.Value).ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) : "-" + p.Value.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture)) + ")", p.Key); + le = le.Replace("(" + p.Key + ")", p.Key); + } + + linearizedEqs.Add(le); + leftVector.Add(leftV); + } + + foreach (KeyValuePair p in dynamicPoints) + { + variablesStr.Add(p.Key); + } + + decimal[][] jacobianMatrix = Matrix.ConvertLinearEquationsToMatrix(linearizedEqs, variablesStr); + decimal[] leftHandVector = leftVector.ToArray(); + + // Using DotNetMatrix to solve J * delta = -F + // Verify if Matrix.SolveEquation is ported or if we should use GeneralMatrix + // Matrix.cs in core likely has SolveEquation if I ported it. + // Let's assume Matrix.cs has it or we use GeneralMatrix directly. + // The original used Matrix.SolveEquation. + // My ported Matrix.cs from step 20 (viewed 1-663) has SolveEquation. + + decimal[] newPoints = Matrix.SolveEquation(jacobianMatrix, leftHandVector); + + List newPointsList = new List(); + for (int i = 0; i < newPoints.Length; i++) + { + newPointsList.Add(newPoints[i]); + } + + Dictionary tempDynamicPoints = new Dictionary(); + foreach (KeyValuePair p in dynamicPoints) + { + tempDynamicPoints.Add(p.Key, p.Value); + } + + foreach (KeyValuePair p in dynamicPoints) + { + tempDynamicPoints[p.Key] = newPointsList[0] + p.Value; + newPointsList.RemoveAt(0); + } + dynamicPoints = tempDynamicPoints; + } + + return dynamicPoints; + } + + public static string Method_TaylorSeries(string eq, int degree, string variable, decimal point, decimal h = 0.001m) + { + decimal constant = Method_EvaluateFunction(eq, variable, point); + constant = DecimalMath.Abs(constant) <= 0.001m ? 0 : constant; + string newEq = constant != 0 ? constant.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) : ""; + for (int i = 1; i < degree + 1; i++) + { + decimal der = Method_NumericalDifferentiation(eq, i, variable, point, 4, h); + decimal fact = Factorial(i); + decimal coeff = (der / fact); + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (point < 0) + { + addingSTR = "+" + DecimalMath.Abs(point).ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + else if (point > 0) + { + addingSTR = "-" + point.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + + varSTR += coeff.ToString(CultureInfo.InvariantCulture) + "*(" + variable + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) + ""); + newEq += varSTR; + } + if (constant == 0 && newEq.Length > 0 && newEq[0] == '+') newEq = newEq.Substring(1); + return newEq; + } + + public static string MethodMultiVar_TaylorSeries(string eq, int degree, Dictionary points, decimal h = 0.001m) + { + decimal constant = MethodMultiVar_EvaluateFunction(eq, points); + constant = DecimalMath.Abs(constant) <= 0.0001m ? 0 : constant; + string newEq = constant != 0 ? constant.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) : ""; + for (int i = 1; i < degree + 1; i++) + { + foreach (KeyValuePair pt in points) + { + decimal partDer = Method_NumericalPartialDifferentiation(eq, i, pt.Key, points, 4, h); + decimal fact = Factorial(i); + decimal coeff = partDer / fact; + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (pt.Value < 0) + { + addingSTR = "+" + DecimalMath.Abs(pt.Value).ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + else if (pt.Value > 0) + { + addingSTR = "-" + pt.Value.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + varSTR += coeff.ToString(CultureInfo.InvariantCulture) + "*(" + pt.Key + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture)); + newEq += varSTR; + } + } + if (constant == 0 && newEq.Length > 0 && newEq[0] == '+') newEq = newEq.Substring(1); + // Assuming intent was to do nothing or it's buggy. I'll leave it as is (or fix it). + return newEq; + } + + public static decimal Method_NewtonRaphson(string eq, string variable, decimal initialValue, int iterationCount, decimal h = 0.001m) + { + // Lipschitz check suppressed/incomplete in original + decimal init = initialValue; + for (int i = 0; i < iterationCount; i++) + { + decimal next = init - Method_EvaluateFunction(eq, variable, init) / Method_NumericalDifferentiation(eq, 1, variable, init, 6, h); + init = next; + } + return init; + } + + // Overload for single-variable Newton-Raphson from UIController's simpler usage (assuming UIController calls this one if I didn't verify signature) + // UIController calls: NumericalMethods.Method_NewtonRaphson(eq, variable, initialP, iterCount); + // Matches the one above. + + // My previous implementation had a simplified one. I should keep the one matching signature. + + public static decimal Method_BisectionMethod(string eq, string variable, decimal lowerValue, decimal higherValue, int iterationCount) + { + if (lowerValue >= higherValue) + return 0; + + decimal mp = (lowerValue + higherValue) / 2; + + for (int i = 0; i < iterationCount; i++) + { + mp = (lowerValue + higherValue) / 2; + + decimal evLower = Method_EvaluateFunction(eq, variable, lowerValue); + // decimal evHigher = Method_EvaluateFunction(eq, variable, higherValue); // unused + decimal evMiddle = Method_EvaluateFunction(eq, variable, mp); + + if (evLower * evMiddle < 0) + { + higherValue = mp; + } + else + { + lowerValue = mp; + } + } + + return mp; + } + + public static decimal Method_Derivative(string eq, int degree, string variable, decimal point, decimal h = 0.001m) + { + decimal sum = 0; + for (int i = 0; i <= degree; i++) + { + sum += DecimalMath.Pow(-1, i) * Combination(degree, i) * Method_EvaluateFunction(eq, variable, point + (degree - i) * h); + } + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Method_PartialDerivative(string eq, int degree, string toVar, Dictionary points, decimal h = 0.001m) + { + decimal sum = 0; + Dictionary testPS = new Dictionary(points); + decimal firstToVar = testPS[toVar]; + for (int i = 0; i <= degree; i++) + { + testPS[toVar] = firstToVar + (degree - i) * h; + sum += DecimalMath.Pow(-1, i) * Combination(degree, i) * MethodMultiVar_EvaluateFunction(eq, testPS); + } + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Method_NumericalDifferentiation(string eq, int degree, string variable, decimal point, int accuracy = 2, decimal h = 0.001m) + { + int m = degree, n = accuracy; + int p = (2 * (int)Math.Floor((m + 1) / 2.0) - 2 + n) / 2; + + decimal[][] _matrix = new decimal[2 * p + 1][]; + decimal[] _rhsVector = new decimal[2 * p + 1], functionPointsX = new decimal[2 * p + 1], + functionPointsY = new decimal[2 * p + 1]; + + for (int i = 0; i < _matrix.Length; i++) + { + _matrix[i] = new decimal[2 * p + 1]; + for (int j = 0; j < _matrix[i].Length; j++) + { + _matrix[i][j] = (decimal)Math.Pow(-p + j, i); + } + + if (i != m) + { + _rhsVector[i] = 0; + } + else if (i == m) + { + _rhsVector[i] = Factorial(m); + } + + functionPointsX[i] = point - (p - i) * h; + functionPointsY[i] = Method_EvaluateFunction(eq, variable, functionPointsX[i]); + } + + GeneralMatrix _A = new GeneralMatrix(_matrix); + GeneralMatrix _b = new GeneralMatrix(_rhsVector.Length, 1); + + for (int i = 0; i < _rhsVector.Length; i++) + { + _b.Array[i][0] = _rhsVector[i]; + } + + GeneralMatrix coeffs = _A.Solve(_b); + decimal sum = 0; + + for (int i = 0; i < coeffs.Array.Length; i++) + { + sum += coeffs.Array[i][0] * functionPointsY[i]; + } + + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Method_NumericalPartialDifferentiation(string eq, int degree, string toVar, Dictionary points, int accuracy = 2, decimal h = 0.001m) + { + int m = degree, n = accuracy; + int p = (2 * (int)Math.Floor((m + 1) / 2.0) - 2 + n) / 2; + + decimal[][] _matrix = new decimal[2 * p + 1][]; + Dictionary functionPointsDomain = new Dictionary(); + decimal[] _rhsVector = new decimal[2 * p + 1], functionPointsRange = new decimal[2 * p + 1]; + + for (int i = 0; i < _matrix.Length; i++) + { + _matrix[i] = new decimal[2 * p + 1]; + for (int j = 0; j < _matrix[i].Length; j++) + { + _matrix[i][j] = (decimal)Math.Pow(-p + j, i); + } + + if (i != m) _rhsVector[i] = 0; + else if (i == m) _rhsVector[i] = Factorial(m); + } + + foreach (KeyValuePair item in points) + { + decimal[] ps = new decimal[2 * p + 1]; + if (item.Key == toVar) + { + for (int i = 0; i < ps.Length; i++) ps[i] = points[item.Key] - (p - i) * h; + } + else + { + for (int i = 0; i < ps.Length; i++) ps[i] = points[item.Key]; + } + functionPointsDomain.Add(item.Key, ps); + } + + for (int i = 0; i < 2 * p + 1; i++) + { + Dictionary pair = new Dictionary(); + foreach (KeyValuePair item in functionPointsDomain) + { + pair.Add(item.Key, item.Value[i]); + } + functionPointsRange[i] = MethodMultiVar_EvaluateFunction(eq, pair); + } + + GeneralMatrix _A = new GeneralMatrix(_matrix); + GeneralMatrix _b = new GeneralMatrix(_rhsVector.Length, 1); + + for (int i = 0; i < _rhsVector.Length; i++) _b.Array[i][0] = _rhsVector[i]; + + GeneralMatrix coeffs = _A.Solve(_b); + decimal sum = 0; + + for (int i = 0; i < coeffs.Array.Length; i++) + { + sum += coeffs.Array[i][0] * functionPointsRange[i]; + } + + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Factorial(int num) + { + if (num >= 2) return num * Factorial(num - 1); + else return 1; + } + + public static decimal Combination(int n, int k) + { + return Factorial(n) / (Factorial(n - k) * Factorial(k)); + } + + public static decimal Permutation(int n, int k) + { + return Factorial(n) / Factorial(n - k); + } + + public static string GenerateCombinations(string chars, string prefix, int length) + { + StringBuilder sb = new StringBuilder(); + GenerateCombinationsRecursive(prefix, chars, length, sb); + return sb.ToString(); + } + static void GenerateCombinationsRecursive(string prefix, string chars, int length, StringBuilder sb) + { + if (length == 0) + { + sb.AppendLine(prefix); + return; + } + + foreach (char c in chars) + { + GenerateCombinationsRecursive(prefix + c, chars, length - 1, sb); + } + } + + // --- Added Linear Solvers (Optional but kept for completeness if UI uses them) --- + // Update: UI uses MethodMultiVar_SolveEquationSystem for System Solver now (based on UIController) + // But I implemented btnSolveSystem_Click in MainForm.cs to use Method_LUDecomposition previously. + // I should update MainForm.cs to use MethodMultiVar_SolveEquationSystem if it's non-linear or general. + // The original app used MethodMultiVar_SolveEquationSystem (Newton-Raphson) for general systems. + + // So I should keep MethodMultiVar_SolveEquationSystem and update MainForm to use IT instead of LUDecomposition if I want to match original behavior. + + // I'll keep the linear solvers just in case. + + public static List Method_Inverse(List _eq, List _vars) + { + // Implementation from previous turn + decimal[][] A = Matrix.ConvertLinearEquationsToMatrix(_eq, _vars); + if (A == null) return null; + decimal[] B = new decimal[_eq.Count]; + for (int i = 0; i < _eq.Count; i++) + { + int ind = _eq[i].IndexOf('='); + if (ind != -1) B[i] = decimal.Parse(_eq[i].Substring(ind + 1), CultureInfo.InvariantCulture); + else B[i] = 0; + } + + GeneralMatrix gA = new GeneralMatrix(A); + GeneralMatrix gB = new GeneralMatrix(B, B.Length); + GeneralMatrix gX = gA.Solve(gB); + decimal[] X = gX.ColumnPackedCopy; + + List res = new List(); + for (int i = 0; i < X.Length; i++) res.Add(_vars[i] + " = " + X[i].ToString("F5", CultureInfo.InvariantCulture)); + return res; + } + + public static List Method_LUDecomposition(List _eq, List _vars) + { + // Implementation from previous turn + decimal[][] A = Matrix.ConvertLinearEquationsToMatrix(_eq, _vars); + if (A == null) return null; + decimal[] B = new decimal[_eq.Count]; + for (int i = 0; i < _eq.Count; i++) + { + int ind = _eq[i].IndexOf('='); + if (ind != -1) B[i] = decimal.Parse(_eq[i].Substring(ind + 1), CultureInfo.InvariantCulture); + else B[i] = 0; + } + + GeneralMatrix gA = new GeneralMatrix(A); + GeneralMatrix gB = new GeneralMatrix(B, B.Length); + GeneralMatrix gX = gA.Solve(gB); + decimal[] X = gX.ColumnPackedCopy; + + List res = new List(); + for (int i = 0; i < X.Length; i++) res.Add(_vars[i] + " = " + X[i].ToString("F5", CultureInfo.InvariantCulture)); + return res; + } + + // Additional wrappers for MainForm compatibility if needed + public static List Method_NewtonRaphson(string _eq, decimal _initialPoint, int _iterationCount) + { + // Wrapper for UI + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + decimal res = Method_NewtonRaphson(_eq, "x", _initialPoint, _iterationCount); + return new List { res.ToString(CultureInfo.InvariantCulture) }; + } + + public static List Method_Bisection(string _eq, decimal _min, decimal _max, int _iterationCount) + { + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + decimal res = Method_BisectionMethod(_eq, "x", _min, _max, _iterationCount); + return new List { res.ToString(CultureInfo.InvariantCulture) }; + } + + public static List Method_Secant(string _eq, decimal _min, decimal _max, int _iterationCount) + { + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + + decimal x0 = _min; + decimal x1 = _max; + decimal x2 = 0; + + for(int i=0; i<_iterationCount; i++) + { + decimal f0 = Method_EvaluateFunction(_eq, "x", x0); + decimal f1 = Method_EvaluateFunction(_eq, "x", x1); + + if (f1 - f0 == 0) break; // Avoid divide by zero + + x2 = x1 - f1 * (x1 - x0) / (f1 - f0); + x0 = x1; + x1 = x2; + + if (DecimalMath.Abs(f1) < 0.00000001m) break; + } + + return new List { x2.ToString(CultureInfo.InvariantCulture) }; + } + + public static List Method_RegulaFalsi(string _eq, decimal _min, decimal _max, int _iterationCount) + { + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + + decimal a = _min; + decimal b = _max; + decimal c = 0; + + for(int i=0; i<_iterationCount; i++) + { + decimal fa = Method_EvaluateFunction(_eq, "x", a); + decimal fb = Method_EvaluateFunction(_eq, "x", b); + + if (fa * fb >= 0) return new List { "Root not bracketed or multiple roots" }; + + c = (a * fb - b * fa) / (fb - fa); + decimal fc = Method_EvaluateFunction(_eq, "x", c); + + if (fc == 0) break; + else if (fa * fc < 0) b = c; + else a = c; + } + + return new List { c.ToString(CultureInfo.InvariantCulture) }; + } +} diff --git a/MathApp/MathApp/GenerateLogo.ps1 b/MathApp/MathApp/GenerateLogo.ps1 new file mode 100644 index 0000000..fcb9f00 --- /dev/null +++ b/MathApp/MathApp/GenerateLogo.ps1 @@ -0,0 +1,37 @@ + +Add-Type -AssemblyName System.Drawing +$width = 256 +$height = 256 +$bmp = New-Object System.Drawing.Bitmap $width, $height +$g = [System.Drawing.Graphics]::FromImage($bmp) +$g.Clear([System.Drawing.Color]::FromArgb(30,30,30)) +$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias + +$pen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(0, 188, 212)), 12 +$points = @( + New-Object System.Drawing.PointF 128, 30 + New-Object System.Drawing.PointF 213, 79 + New-Object System.Drawing.PointF 213, 177 + New-Object System.Drawing.PointF 128, 226 + New-Object System.Drawing.PointF 43, 177 + New-Object System.Drawing.PointF 43, 79 +) +$g.DrawPolygon($pen, $points) + +$font = New-Object System.Drawing.Font "Segoe UI", 110, [System.Drawing.FontStyle]::Bold +$brush = [System.Drawing.Brushes]::White +$format = New-Object System.Drawing.StringFormat +$format.Alignment = [System.Drawing.StringAlignment]::Center +$format.LineAlignment = [System.Drawing.StringAlignment]::Center +$g.DrawString("M", $font, $brush, 130, 135, $format) + +$iconName = "c:/Users/tolga/Desktop/Math/MathApp/MathApp/logo.ico" +$hicon = $bmp.GetHicon() +$icon = [System.Drawing.Icon]::FromHandle([IntPtr]$hicon) + +$fs = [System.IO.File]::OpenWrite($iconName) +$icon.Save($fs) +$fs.Close() +$g.Dispose() +$bmp.Dispose() +Write-Host "Logo created successfully at $iconName" diff --git a/MathApp/MathApp/MainForm.Designer.cs b/MathApp/MathApp/MainForm.Designer.cs new file mode 100644 index 0000000..66bafe2 --- /dev/null +++ b/MathApp/MathApp/MainForm.Designer.cs @@ -0,0 +1,139 @@ + +namespace MathApp +{ + partial class MainForm + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.pnlSidebar = new System.Windows.Forms.Panel(); + this.pnlContent = new System.Windows.Forms.Panel(); + this.btnNavCalc = new System.Windows.Forms.Button(); + this.btnNavRoot = new System.Windows.Forms.Button(); + this.btnNavSystem = new System.Windows.Forms.Button(); + this.pnlLogo = new System.Windows.Forms.Panel(); + this.lblLogo = new System.Windows.Forms.Label(); + + this.btnNavTaylor = new System.Windows.Forms.Button(); + this.btnNavMultiTaylor = new System.Windows.Forms.Button(); // New + this.btnNavGraph = new System.Windows.Forms.Button(); + + this.pnlSidebar.SuspendLayout(); + this.pnlLogo.SuspendLayout(); + this.SuspendLayout(); + + // + // pnlSidebar + // + this.pnlSidebar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + this.pnlSidebar.Controls.Add(this.btnNavGraph); + this.pnlSidebar.Controls.Add(this.btnNavMultiTaylor); // New + this.pnlSidebar.Controls.Add(this.btnNavTaylor); + this.pnlSidebar.Controls.Add(this.btnNavSystem); + this.pnlSidebar.Controls.Add(this.btnNavRoot); + this.pnlSidebar.Controls.Add(this.btnNavCalc); + this.pnlSidebar.Controls.Add(this.pnlLogo); + this.pnlSidebar.Dock = System.Windows.Forms.DockStyle.Right; // Sidebar on Right as requested + this.pnlSidebar.Location = new System.Drawing.Point(600, 0); + this.pnlSidebar.Name = "pnlSidebar"; + this.pnlSidebar.Size = new System.Drawing.Size(200, 600); + this.pnlSidebar.TabIndex = 0; + + // + // pnlLogo + // + this.pnlLogo.Controls.Add(this.lblLogo); + this.pnlLogo.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlLogo.Location = new System.Drawing.Point(0, 0); + this.pnlLogo.Name = "pnlLogo"; + this.pnlLogo.Size = new System.Drawing.Size(200, 100); + this.pnlLogo.TabIndex = 0; + + // + // lblLogo + // + this.lblLogo.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblLogo.Font = new System.Drawing.Font("Segoe UI Light", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.lblLogo.ForeColor = System.Drawing.Color.White; + this.lblLogo.Location = new System.Drawing.Point(0, 0); + this.lblLogo.Name = "lblLogo"; + this.lblLogo.Size = new System.Drawing.Size(200, 100); + this.lblLogo.TabIndex = 0; + this.lblLogo.Text = "Math App"; + this.lblLogo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // Helper for Nav Buttons + void StyleNavButton(System.Windows.Forms.Button btn, string text, int index) + { + btn.Dock = System.Windows.Forms.DockStyle.Top; + btn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + btn.FlatAppearance.BorderSize = 0; + btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(60, 60, 60); + btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(0, 120, 215); + btn.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + btn.ForeColor = System.Drawing.Color.White; + btn.Location = new System.Drawing.Point(0, 100 + (index * 60)); + btn.Name = "btnNav" + index; + btn.Size = new System.Drawing.Size(200, 60); + btn.TabIndex = index + 1; + btn.Text = text; + btn.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + btn.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0); + btn.UseVisualStyleBackColor = true; + } + + StyleNavButton(this.btnNavCalc, "Calculator", 0); + StyleNavButton(this.btnNavRoot, "Root Finder", 1); + StyleNavButton(this.btnNavSystem, "System Solver", 2); + StyleNavButton(this.btnNavTaylor, "Taylor Series", 3); + StyleNavButton(this.btnNavMultiTaylor, "MultiVar Taylor", 4); // New + StyleNavButton(this.btnNavGraph, "Graph Plotter", 5); + + // + // pnlContent + // + this.pnlContent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); // Dark Content Area + this.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlContent.Location = new System.Drawing.Point(0, 0); + this.pnlContent.Name = "pnlContent"; + this.pnlContent.Size = new System.Drawing.Size(600, 600); + this.pnlContent.TabIndex = 1; + + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 600); + this.Controls.Add(this.pnlContent); + this.Controls.Add(this.pnlSidebar); + this.Name = "MainForm"; + this.Text = "Math Application"; + this.pnlSidebar.ResumeLayout(false); + this.pnlLogo.ResumeLayout(false); + this.ResumeLayout(false); + + } + + private System.Windows.Forms.Panel pnlSidebar; + private System.Windows.Forms.Panel pnlContent; + private System.Windows.Forms.Button btnNavCalc; + private System.Windows.Forms.Button btnNavRoot; + private System.Windows.Forms.Button btnNavSystem; + private System.Windows.Forms.Button btnNavTaylor; + private System.Windows.Forms.Button btnNavMultiTaylor; // New + private System.Windows.Forms.Button btnNavGraph; + private System.Windows.Forms.Panel pnlLogo; + private System.Windows.Forms.Label lblLogo; + } +} diff --git a/MathApp/MathApp/MainForm.cs b/MathApp/MathApp/MainForm.cs new file mode 100644 index 0000000..2c0f6a7 --- /dev/null +++ b/MathApp/MathApp/MainForm.cs @@ -0,0 +1,79 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using MathApp.Controls; + +namespace MathApp +{ + public partial class MainForm : Form + { + private SimpleCalculatorControl calcControl; + private RootFinderControl rootControl; + private SystemSolverControl systemControl; + private TaylorSeriesControl taylorControl; + private MultivariableTaylorControl multiTaylorControl; + private GraphPlotterControl graphControl; + + public MainForm() + { + InitializeComponent(); + try { this.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath); } catch { } + + ThemeHelper.ApplyTheme(this); + InitializeControls(); + + // Default View + ShowControl(calcControl); + HighlightButton(btnNavCalc); + + btnNavCalc.Click += (s, e) => { ShowControl(calcControl); HighlightButton(btnNavCalc); }; + btnNavRoot.Click += (s, e) => { ShowControl(rootControl); HighlightButton(btnNavRoot); }; + btnNavSystem.Click += (s, e) => { ShowControl(systemControl); HighlightButton(btnNavSystem); }; + btnNavTaylor.Click += (s, e) => { ShowControl(taylorControl); HighlightButton(btnNavTaylor); }; + btnNavMultiTaylor.Click += (s, e) => { ShowControl(multiTaylorControl); HighlightButton(btnNavMultiTaylor); }; + btnNavGraph.Click += (s, e) => { ShowControl(graphControl); HighlightButton(btnNavGraph); }; + } + + private void InitializeControls() + { + calcControl = new SimpleCalculatorControl(); + calcControl.Dock = DockStyle.Fill; + + rootControl = new RootFinderControl(); + rootControl.Dock = DockStyle.Fill; + + systemControl = new SystemSolverControl(); + systemControl.Dock = DockStyle.Fill; + + taylorControl = new TaylorSeriesControl(); + taylorControl.Dock = DockStyle.Fill; + + multiTaylorControl = new MultivariableTaylorControl(); + multiTaylorControl.Dock = DockStyle.Fill; + + graphControl = new GraphPlotterControl(); + graphControl.Dock = DockStyle.Fill; + } + + private void ShowControl(UserControl control) + { + pnlContent.Controls.Clear(); + pnlContent.Controls.Add(control); + } + + private void HighlightButton(Button activeBtn) + { + Color activeColor = Color.FromArgb(0, 120, 215); // Accent Blue + Color idleColor = Color.FromArgb(40, 40, 40); // Sidebar BG + + btnNavCalc.BackColor = idleColor; + btnNavRoot.BackColor = idleColor; + btnNavSystem.BackColor = idleColor; + btnNavTaylor.BackColor = idleColor; + btnNavMultiTaylor.BackColor = idleColor; + btnNavGraph.BackColor = idleColor; + + activeBtn.BackColor = activeColor; + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/CholeskyDecomposition.cs b/MathApp/MathApp/MathApp.Tests/CholeskyDecomposition.cs new file mode 100644 index 0000000..2f13915 --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/CholeskyDecomposition.cs @@ -0,0 +1,174 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// Cholesky Decomposition. + /// For a symmetric, positive definite matrix A, the Cholesky decomposition + /// is an lower triangular matrix L so that A = L*L'. + /// If the matrix is not symmetric or positive definite, the constructor + /// returns a partial decomposition and sets an internal flag that may + /// be queried by the isSPD() method. + /// + + [Serializable] + public class CholeskyDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] L; + + /// Row and column dimension (square matrix). + /// @serial matrix dimension. + /// + private int n; + + /// Symmetric and positive definite flag. + /// @serial is symmetric and positive definite flag. + /// + private bool isspd; + + #endregion // Class variables + + #region Constructor + + /// Cholesky algorithm for symmetric and positive definite matrix. + /// Square, symmetric matrix. + /// + /// Structure to access L and isspd flag. + /// + + public CholeskyDecomposition(GeneralMatrix Arg) + { + // Initialize. + decimal[][] A = Arg.Array; + n = Arg.RowDimension; + L = new decimal[n][]; + for (int i = 0; i < n; i++) + { + L[i] = new decimal[n]; + } + isspd = (Arg.ColumnDimension == n); + // Main loop. + for (int j = 0; j < n; j++) + { + decimal[] Lrowj = L[j]; + decimal d = 0.0m; + for (int k = 0; k < j; k++) + { + decimal[] Lrowk = L[k]; + decimal s = 0.0m; + for (int i = 0; i < k; i++) + { + s += Lrowk[i] * Lrowj[i]; + } + Lrowj[k] = s = (A[j][k] - s) / L[k][k]; + d = d + s * s; + isspd = isspd & (A[k][j] == A[j][k]); + } + d = A[j][j] - d; + isspd = isspd & (d > 0.0m); + L[j][j] = (decimal)Math.Sqrt(Math.Max((double)d, 0)); + for (int k = j + 1; k < n; k++) + { + L[j][k] = 0.0m; + } + } + } + + #endregion // Constructor + + #region Public Properties + /// Is the matrix symmetric and positive definite? + /// true if A is symmetric and positive definite. + /// + virtual public bool SPD + { + get + { + return isspd; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Return triangular factor. + /// L + /// + + public virtual GeneralMatrix GetL() + { + return new GeneralMatrix(L, n, n); + } + + /// Solve A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X so that L*L'*X = B + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is not symmetric positive definite. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != n) + { + throw new System.ArgumentException("Matrix row dimensions must agree."); + } + if (!isspd) + { + throw new System.SystemException("Matrix is not symmetric positive definite."); + } + + // Copy right hand side. + decimal[][] X = B.ArrayCopy; + int nx = B.ColumnDimension; + + // Solve L*Y = B; + for (int k = 0; k < n; k++) + { + for (int i = k + 1; i < n; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * L[i][k]; + } + } + for (int j = 0; j < nx; j++) + { + X[k][j] /= L[k][k]; + } + } + + // Solve L'*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= L[k][k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * L[k][i]; + } + } + } + return new GeneralMatrix(X, n, nx); + } + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/DecimalMath.cs b/MathApp/MathApp/MathApp.Tests/DecimalMath.cs new file mode 100644 index 0000000..6c72917 --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/DecimalMath.cs @@ -0,0 +1,541 @@ +using System; + +/// +/// Analogy of System.Math class for decimal types +/// +public static class DecimalMath +{ + /* ... (Content from original file, confirmed no Unity deps) ... */ + + /// + /// represents PI + /// + public const decimal PI = 3.14159265358979323846264338327950288419716939937510M; + + /// + /// represents PI + /// + public const decimal Epsilon = 0.0000000000000000001M; + + /// + /// represents 2*PI + /// + private const decimal PIx2 = 6.28318530717958647692528676655900576839433879875021M; + + /// + /// represents E + /// + public const decimal E = 2.7182818284590452353602874713526624977572470936999595749M; + + /// + /// represents PI/2 + /// + private const decimal PIdiv2 = 1.570796326794896619231321691639751442098584699687552910487M; + + /// + /// represents PI/4 + /// + private const decimal PIdiv4 = 0.785398163397448309615660845819875721049292349843776455243M; + + /// + /// represents 1.0/E + /// + private const decimal Einv = 0.3678794411714423215955237701614608674458111310317678M; + + /// + /// log(10,E) factor + /// + private const decimal Log10Inv = 0.434294481903251827651128918916605082294397005803666566114M; + + /// + /// Zero + /// + public const decimal Zero = 0.0M; + + /// + /// One + /// + public const decimal One = 1.0M; + + /// + /// Represents 0.5M + /// + private const decimal Half = 0.5M; + + /// + /// Max iterations count in Taylor series + /// + private const int MaxIteration = 100; + + /// + /// Analogy of Math.Exp method + /// + /// + /// + public static decimal Exp(decimal x) + { + var count = 0; + + if (x > One) + { + count = decimal.ToInt32(decimal.Truncate(x)); + x -= decimal.Truncate(x); + } + + if (x < Zero) + { + count = decimal.ToInt32(decimal.Truncate(x) - 1); + x = One + (x - decimal.Truncate(x)); + } + + var iteration = 1; + var result = One; + var factorial = One; + decimal cachedResult; + do + { + cachedResult = result; + factorial *= x / iteration++; + result += factorial; + } while (cachedResult != result); + + if (count == 0) + return result; + return result * PowerN(E, count); + } + + /// + /// Analogy of Math.Pow method + /// + /// + /// + /// + public static decimal Pow(decimal value, decimal pow) + { + if (pow == Zero) return One; + if (pow == One) return value; + if (value == One) return One; + + if (value == Zero) + { + if (pow > Zero) + { + return Zero; + } + + throw new Exception("Invalid Operation: zero base and negative power"); + } + + if (pow == -One) return One / value; + + var isPowerInteger = IsInteger(pow); + if (value < Zero && !isPowerInteger) + { + throw new Exception("Invalid Operation: negative base and non-integer power"); + } + + if (isPowerInteger && value > Zero) + { + int powerInt = (int)pow; + return PowerN(value, powerInt); + } + + if (isPowerInteger && value < Zero) + { + int powerInt = (int)pow; + if (powerInt % 2 == 0) + { + return Exp(pow * Log(-value)); + } + + return -Exp(pow * Log(-value)); + } + + return Exp(pow * Log(value)); + } + + private static bool IsInteger(decimal value) + { + var longValue = (long)value; + return Abs(value - longValue) <= Epsilon; + } + + /// + /// Power to the integer value + /// + /// + /// + /// + public static decimal PowerN(decimal value, int power) + { + while (true) + { + if (power == Zero) return One; + if (power < Zero) + { + value = One / value; + power = -power; + continue; + } + + var q = power; + var prod = One; + var current = value; + while (q > 0) + { + if (q % 2 == 1) + { + // detects the 1s in the binary expression of power + prod = current * prod; // picks up the relevant power + q--; + } + + current *= current; // value^i -> value^(2*i) + q >>= 1; + } + + return prod; + } + } + + /// + /// Analogy of Math.Log10 + /// + /// + /// + public static decimal Log10(decimal x) + { + return Log(x) * Log10Inv; + } + + /// + /// Analogy of Math.Log + /// + /// + /// + public static decimal Log(decimal x) + { + if (x <= Zero) + { + throw new ArgumentException("x must be greater than zero"); + } + var count = 0; + while (x >= One) + { + x *= Einv; + count++; + } + while (x <= Einv) + { + x *= E; + count--; + } + x--; + if (x == Zero) return count; + var result = Zero; + var iteration = 0; + var y = One; + var cacheResult = result - One; + while (cacheResult != result && iteration < MaxIteration) + { + iteration++; + cacheResult = result; + y *= -x; + result += y / iteration; + } + return count - result; + } + + /// + /// Analogy of Math.Cos + /// + /// + /// + public static decimal Cos(decimal x) + { + //truncating to [-2*PI;2*PI] + TruncateToPeriodicInterval(ref x); + + // now x in (-2pi,2pi) + if (x >= PI && x <= PIx2) + { + return -Cos(x - PI); + } + if (x >= -PIx2 && x <= -PI) + { + return -Cos(x + PI); + } + + x *= x; + //y=1-x/2!+x^2/4!-x^3/6!... + var xx = -x * Half; + var y = One + xx; + var cachedY = y - One;//init cache with different value + for (var i = 1; cachedY != y && i < MaxIteration; i++) + { + cachedY = y; + decimal factor = i * ((i << 1) + 3) + 1; //2i^2+2i+i+1=2i^2+3i+1 + factor = -Half / factor; + xx *= x * factor; + y += xx; + } + return y; + } + + /// + /// Analogy of Math.Tan + /// + /// + /// + public static decimal Tan(decimal x) + { + var cos = Cos(x); + if (cos == Zero) throw new ArgumentException(nameof(x)); + //calculate sin using cos + var sin = CalculateSinFromCos(x, cos); + return sin / cos; + } + /// + /// Helper function for calculating sin(x) from cos(x) + /// + /// + /// + /// + private static decimal CalculateSinFromCos(decimal x, decimal cos) + { + var moduleOfSin = Sqrt(One - (cos * cos)); + var sineIsPositive = IsSignOfSinePositive(x); + if (sineIsPositive) return moduleOfSin; + return -moduleOfSin; + } + /// + /// Analogy of Math.Sin + /// + /// + /// + public static decimal Sin(decimal x) + { + var cos = Cos(x); + return CalculateSinFromCos(x, cos); + } + + + /// + /// Truncates to [-2*PI;2*PI] + /// + /// + private static void TruncateToPeriodicInterval(ref decimal x) + { + while (x >= PIx2) + { + var divide = Math.Abs(decimal.ToInt32(x / PIx2)); + x -= divide * PIx2; + } + + while (x <= -PIx2) + { + var divide = Math.Abs(decimal.ToInt32(x / PIx2)); + x += divide * PIx2; + } + } + + + private static bool IsSignOfSinePositive(decimal x) + { + //truncating to [-2*PI;2*PI] + TruncateToPeriodicInterval(ref x); + + //now x in [-2*PI;2*PI] + if (x >= -PIx2 && x <= -PI) return true; + if (x >= -PI && x <= Zero) return false; + if (x >= Zero && x <= PI) return true; + if (x >= PI && x <= PIx2) return false; + + //will not be reached + throw new ArgumentException(nameof(x)); + } + + /// + /// Analogy of Math.Sqrt + /// + /// + /// lasts iteration while error less than this epsilon + /// + public static decimal Sqrt(decimal x, decimal epsilon = Zero) + { + if (x < Zero) throw new OverflowException("Cannot calculate square root from a negative number"); + //initial approximation + decimal current = (decimal)Math.Sqrt((double)x), previous; + do + { + previous = current; + if (previous == Zero) return Zero; + current = (previous + x / previous) * Half; + } while (Abs(previous - current) > epsilon); + return current; + } + /// + /// Analogy of Math.Sinh + /// + /// + /// + public static decimal Sinh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y - yy) * Half; + } + + /// + /// Analogy of Math.Cosh + /// + /// + /// + public static decimal Cosh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y + yy) * Half; + } + + /// + /// Analogy of Math.Sign + /// + /// + /// + public static int Sign(decimal x) + { + return x < Zero ? -1 : (x > Zero ? 1 : 0); + } + + /// + /// Analogy of Math.Tanh + /// + /// + /// + public static decimal Tanh(decimal x) + { + var y = Exp(x); + var yy = One / y; + return (y - yy) / (y + yy); + } + + /// + /// Analogy of Math.Abs + /// + /// + /// + public static decimal Abs(decimal x) + { + if (x <= Zero) + { + return -x; + } + return x; + } + + /// + /// Analogy of Math.Asin + /// + /// + /// + public static decimal Asin(decimal x) + { + if (x > One || x < -One) + { + throw new ArgumentException("x must be in [-1,1]"); + } + //known values + if (x == Zero) return Zero; + if (x == One) return PIdiv2; + //asin function is odd function + if (x < Zero) return -Asin(-x); + + //my optimize trick here + + // used a math formula to speed up : + // asin(x)=0.5*(pi/2-asin(1-2*x*x)) + // if x>=0 is true + + var newX = One - 2 * x * x; + + //for calculating new value near to zero than current + //because we gain more speed with values near to zero + if (Abs(x) > Abs(newX)) + { + var t = Asin(newX); + return Half * (PIdiv2 - t); + } + var y = Zero; + var result = x; + decimal cachedResult; + var i = 1; + y += result; + var xx = x * x; + do + { + cachedResult = result; + result *= xx * (One - Half / (i)); + y += result / ((i << 1) + 1); + i++; + } while (cachedResult != result); + return y; + } + + /// + /// Analogy of Math.Atan + /// + /// + /// + public static decimal Atan(decimal x) + { + if (x == Zero) return Zero; + if (x == One) return PIdiv4; + return Asin(x / Sqrt(One + x * x)); + } + /// + /// Analogy of Math.Acos + /// + /// + /// + public static decimal Acos(decimal x) + { + if (x == Zero) return PIdiv2; + if (x == One) return Zero; + if (x < Zero) return PI - Acos(-x); + return PIdiv2 - Asin(x); + } + + /// + /// Analogy of Math.Atan2 + /// for more see this + /// + /// + /// + /// + /// + public static decimal Atan2(decimal y, decimal x) + { + if (x > Zero) + { + return Atan(y / x); + } + if (x < Zero && y >= Zero) + { + return Atan(y / x) + PI; + } + if (x < Zero && y < Zero) + { + return Atan(y / x) - PI; + } + if (x == Zero && y > Zero) + { + return PIdiv2; + } + if (x == Zero && y < Zero) + { + return -PIdiv2; + } + throw new ArgumentException("invalid atan2 arguments"); + } +} diff --git a/MathApp/MathApp/MathApp.Tests/EigenvalueDecomposition.cs b/MathApp/MathApp/MathApp.Tests/EigenvalueDecomposition.cs new file mode 100644 index 0000000..9a8a49b --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/EigenvalueDecomposition.cs @@ -0,0 +1,928 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + [Serializable] + public class EigenvalueDecomposition : System.Runtime.Serialization.ISerializable + { + private int n; + private bool issymmetric; + private decimal[] d, e; + private decimal[][] V; + private decimal[][] H; + private decimal[] ort; + + private void tred2() + { + for (int j = 0; j < n; j++) + { + d[j] = V[n - 1][j]; + } + + for (int i = n - 1; i > 0; i--) + { + decimal scale = 0.0m; + decimal h = 0.0m; + for (int k = 0; k < i; k++) + { + scale = scale + System.Math.Abs(d[k]); + } + if (scale == 0.0m) + { + e[i] = d[i - 1]; + for (int j = 0; j < i; j++) + { + d[j] = V[i - 1][j]; + V[i][j] = 0.0m; + V[j][i] = 0.0m; + } + } + else + { + for (int k = 0; k < i; k++) + { + d[k] /= scale; + h += d[k] * d[k]; + } + decimal f = d[i - 1]; + decimal g = (decimal)DecimalMath.Sqrt(h); + if (f > 0) + { + g = - g; + } + e[i] = scale * g; + h = h - f * g; + d[i - 1] = f - g; + for (int j = 0; j < i; j++) + { + e[j] = 0.0m; + } + + for (int j = 0; j < i; j++) + { + f = d[j]; + V[j][i] = f; + g = e[j] + V[j][j] * f; + for (int k = j + 1; k <= i - 1; k++) + { + g += V[k][j] * d[k]; + e[k] += V[k][j] * f; + } + e[j] = g; + } + f = 0.0m; + for (int j = 0; j < i; j++) + { + e[j] /= h; + f += e[j] * d[j]; + } + decimal hh = f / (h + h); + for (int j = 0; j < i; j++) + { + e[j] -= hh * d[j]; + } + for (int j = 0; j < i; j++) + { + f = d[j]; + g = e[j]; + for (int k = j; k <= i - 1; k++) + { + V[k][j] -= (f * e[k] + g * d[k]); + } + d[j] = V[i - 1][j]; + V[i][j] = 0.0m; + } + } + d[i] = h; + } + + for (int i = 0; i < n - 1; i++) + { + V[n - 1][i] = V[i][i]; + V[i][i] = 1.0m; + decimal h = d[i + 1]; + if (h != 0.0m) + { + for (int k = 0; k <= i; k++) + { + d[k] = V[k][i + 1] / h; + } + for (int j = 0; j <= i; j++) + { + decimal g = 0.0m; + for (int k = 0; k <= i; k++) + { + g += V[k][i + 1] * V[k][j]; + } + for (int k = 0; k <= i; k++) + { + V[k][j] -= g * d[k]; + } + } + } + for (int k = 0; k <= i; k++) + { + V[k][i + 1] = 0.0m; + } + } + for (int j = 0; j < n; j++) + { + d[j] = V[n - 1][j]; + V[n - 1][j] = 0.0m; + } + V[n - 1][n - 1] = 1.0m; + e[0] = 0.0m; + } + + private void tql2() + { + for (int i = 1; i < n; i++) + { + e[i - 1] = e[i]; + } + e[n - 1] = 0.0m; + + decimal f = 0.0m; + decimal tst1 = 0.0m; + decimal eps = (decimal)DecimalMath.Pow(2.0m, - 52.0m); + for (int l = 0; l < n; l++) + { + tst1 = System.Math.Max(tst1, System.Math.Abs(d[l]) + System.Math.Abs(e[l])); + int m = l; + while (m < n) + { + if (System.Math.Abs(e[m]) <= eps * tst1) + { + break; + } + m++; + } + + if (m > l) + { + int iter = 0; + do + { + iter = iter + 1; + decimal g = d[l]; + decimal p = (d[l + 1] - g) / (2.0m * e[l]); + decimal r = Maths.Hypot(p, 1.0m); + if (p < 0) + { + r = - r; + } + d[l] = e[l] / (p + r); + d[l + 1] = e[l] * (p + r); + decimal dl1 = d[l + 1]; + decimal h = g - d[l]; + for (int i = l + 2; i < n; i++) + { + d[i] -= h; + } + f = f + h; + + p = d[m]; + decimal c = 1.0m; + decimal c2 = c; + decimal c3 = c; + decimal el1 = e[l + 1]; + decimal s = 0.0m; + decimal s2 = 0.0m; + for (int i = m - 1; i >= l; i--) + { + c3 = c2; + c2 = c; + s2 = s; + g = c * e[i]; + h = c * p; + r = Maths.Hypot(p, e[i]); + e[i + 1] = s * r; + s = e[i] / r; + c = p / r; + p = c * d[i] - s * g; + d[i + 1] = h + s * (c * g + s * d[i]); + + for (int k = 0; k < n; k++) + { + h = V[k][i + 1]; + V[k][i + 1] = s * V[k][i] + c * h; + V[k][i] = c * V[k][i] - s * h; + } + } + p = (- s) * s2 * c3 * el1 * e[l] / dl1; + e[l] = s * p; + d[l] = c * p; + } + while (System.Math.Abs(e[l]) > eps * tst1); + } + d[l] = d[l] + f; + e[l] = 0.0m; + } + + for (int i = 0; i < n - 1; i++) + { + int k = i; + decimal p = d[i]; + for (int j = i + 1; j < n; j++) + { + if (d[j] < p) + { + k = j; + p = d[j]; + } + } + if (k != i) + { + d[k] = d[i]; + d[i] = p; + for (int j = 0; j < n; j++) + { + p = V[j][i]; + V[j][i] = V[j][k]; + V[j][k] = p; + } + } + } + } + + private void orthes() + { + int low = 0; + int high = n - 1; + + for (int m = low + 1; m <= high - 1; m++) + { + decimal scale = 0.0m; + for (int i = m; i <= high; i++) + { + scale = scale + System.Math.Abs(H[i][m - 1]); + } + if (scale != 0.0m) + { + decimal h = 0.0m; + for (int i = high; i >= m; i--) + { + ort[i] = H[i][m - 1] / scale; + h += ort[i] * ort[i]; + } + decimal g = (decimal)DecimalMath.Sqrt(h); + if (ort[m] > 0) + { + g = - g; + } + h = h - ort[m] * g; + ort[m] = ort[m] - g; + + for (int j = m; j < n; j++) + { + decimal f = 0.0m; + for (int i = high; i >= m; i--) + { + f += ort[i] * H[i][j]; + } + f = f / h; + for (int i = m; i <= high; i++) + { + H[i][j] -= f * ort[i]; + } + } + + for (int i = 0; i <= high; i++) + { + decimal f = 0.0m; + for (int j = high; j >= m; j--) + { + f += ort[j] * H[i][j]; + } + f = f / h; + for (int j = m; j <= high; j++) + { + H[i][j] -= f * ort[j]; + } + } + ort[m] = scale * ort[m]; + H[m][m - 1] = scale * g; + } + } + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + V[i][j] = (i == j?1.0m:0.0m); + } + } + + for (int m = high - 1; m >= low + 1; m--) + { + if (H[m][m - 1] != 0.0m) + { + for (int i = m + 1; i <= high; i++) + { + ort[i] = H[i][m - 1]; + } + for (int j = m; j <= high; j++) + { + decimal g = 0.0m; + for (int i = m; i <= high; i++) + { + g += ort[i] * V[i][j]; + } + g = (g / ort[m]) / H[m][m - 1]; + for (int i = m; i <= high; i++) + { + V[i][j] += g * ort[i]; + } + } + } + } + } + + + [NonSerialized()] + private decimal cdivr, cdivi; + + private void cdiv(decimal xr, decimal xi, decimal yr, decimal yi) + { + decimal r, d; + if (System.Math.Abs(yr) > System.Math.Abs(yi)) + { + r = yi / yr; + d = yr + r * yi; + cdivr = (xr + r * xi) / d; + cdivi = (xi - r * xr) / d; + } + else + { + r = yr / yi; + d = yi + r * yr; + cdivr = (r * xr + xi) / d; + cdivi = (r * xi - xr) / d; + } + } + + private void hqr2() + { + int nn = this.n; + int n = nn - 1; + int low = 0; + int high = nn - 1; + decimal eps = (decimal)DecimalMath.Pow(2.0m, - 52.0m); + decimal exshift = 0.0m; + decimal p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y; + + decimal norm = 0.0m; + for (int i = 0; i < nn; i++) + { + if (i < low | i > high) + { + d[i] = H[i][i]; + e[i] = 0.0m; + } + for (int j = System.Math.Max(i - 1, 0); j < nn; j++) + { + norm = norm + System.Math.Abs(H[i][j]); + } + } + + int iter = 0; + while (n >= low) + { + int l = n; + while (l > low) + { + s = System.Math.Abs(H[l - 1][l - 1]) + System.Math.Abs(H[l][l]); + if (s == 0.0m) + { + s = norm; + } + if (System.Math.Abs(H[l][l - 1]) < eps * s) + { + break; + } + l--; + } + + if (l == n) + { + H[n][n] = H[n][n] + exshift; + d[n] = H[n][n]; + e[n] = 0.0m; + n--; + iter = 0; + } + else if (l == n - 1) + { + w = H[n][n - 1] * H[n - 1][n]; + p = (H[n - 1][n - 1] - H[n][n]) / 2.0m; + q = p * p + w; + z = (decimal)DecimalMath.Sqrt(System.Math.Abs(q)); + H[n][n] = H[n][n] + exshift; + H[n - 1][n - 1] = H[n - 1][n - 1] + exshift; + x = H[n][n]; + + if (q >= 0) + { + if (p >= 0) + { + z = p + z; + } + else + { + z = p - z; + } + d[n - 1] = x + z; + d[n] = d[n - 1]; + if (z != 0.0m) + { + d[n] = x - w / z; + } + e[n - 1] = 0.0m; + e[n] = 0.0m; + x = H[n][n - 1]; + s = System.Math.Abs(x) + System.Math.Abs(z); + p = x / s; + q = z / s; + r = (decimal)DecimalMath.Sqrt(p * p + q * q); + p = p / r; + q = q / r; + + for (int j = n - 1; j < nn; j++) + { + z = H[n - 1][j]; + H[n - 1][j] = q * z + p * H[n][j]; + H[n][j] = q * H[n][j] - p * z; + } + + for (int i = 0; i <= n; i++) + { + z = H[i][n - 1]; + H[i][n - 1] = q * z + p * H[i][n]; + H[i][n] = q * H[i][n] - p * z; + } + + for (int i = low; i <= high; i++) + { + z = V[i][n - 1]; + V[i][n - 1] = q * z + p * V[i][n]; + V[i][n] = q * V[i][n] - p * z; + } + + } + else + { + d[n - 1] = x + p; + d[n] = x + p; + e[n - 1] = z; + e[n] = - z; + } + n = n - 2; + iter = 0; + + } + else + { + x = H[n][n]; + y = 0.0m; + w = 0.0m; + if (l < n) + { + y = H[n - 1][n - 1]; + w = H[n][n - 1] * H[n - 1][n]; + } + + if (iter == 10) + { + exshift += x; + for (int i = low; i <= n; i++) + { + H[i][i] -= x; + } + s = System.Math.Abs(H[n][n - 1]) + System.Math.Abs(H[n - 1][n - 2]); + x = y = 0.75m * s; + w = (- 0.4375m) * s * s; + } + + if (iter == 30) + { + s = (y - x) / 2.0m; + s = s * s + w; + if (s > 0) + { + s = (decimal)DecimalMath.Sqrt(s); + if (y < x) + { + s = - s; + } + s = x - w / ((y - x) / 2.0m + s); + for (int i = low; i <= n; i++) + { + H[i][i] -= s; + } + exshift += s; + x = y = w = 0.964m; + } + } + + iter = iter + 1; + + int m = n - 2; + while (m >= l) + { + z = H[m][m]; + r = x - z; + s = y - z; + p = (r * s - w) / H[m + 1][m] + H[m][m + 1]; + q = H[m + 1][m + 1] - z - r - s; + r = H[m + 2][m + 1]; + s = System.Math.Abs(p) + System.Math.Abs(q) + System.Math.Abs(r); + p = p / s; + q = q / s; + r = r / s; + if (m == l) + { + break; + } + if (System.Math.Abs(H[m][m - 1]) * (System.Math.Abs(q) + System.Math.Abs(r)) < eps * (System.Math.Abs(p) * (System.Math.Abs(H[m - 1][m - 1]) + System.Math.Abs(z) + System.Math.Abs(H[m + 1][m + 1])))) + { + break; + } + m--; + } + + for (int i = m + 2; i <= n; i++) + { + H[i][i - 2] = 0.0m; + if (i > m + 2) + { + H[i][i - 3] = 0.0m; + } + } + + for (int k = m; k <= n - 1; k++) + { + bool notlast = (k != n - 1); + if (k != m) + { + p = H[k][k - 1]; + q = H[k + 1][k - 1]; + r = (notlast?H[k + 2][k - 1]:0.0m); + x = System.Math.Abs(p) + System.Math.Abs(q) + System.Math.Abs(r); + if (x != 0.0m) + { + p = p / x; + q = q / x; + r = r / x; + } + } + if (x == 0.0m) + { + break; + } + s = (decimal)DecimalMath.Sqrt(p * p + q * q + r * r); + if (p < 0) + { + s = - s; + } + if (s != 0) + { + if (k != m) + { + H[k][k - 1] = (- s) * x; + } + else if (l != m) + { + H[k][k - 1] = - H[k][k - 1]; + } + p = p + s; + x = p / s; + y = q / s; + z = r / s; + q = q / p; + r = r / p; + + for (int j = k; j < nn; j++) + { + p = H[k][j] + q * H[k + 1][j]; + if (notlast) + { + p = p + r * H[k + 2][j]; + H[k + 2][j] = H[k + 2][j] - p * z; + } + H[k][j] = H[k][j] - p * x; + H[k + 1][j] = H[k + 1][j] - p * y; + } + + for (int i = 0; i <= System.Math.Min(n, k + 3); i++) + { + p = x * H[i][k] + y * H[i][k + 1]; + if (notlast) + { + p = p + z * H[i][k + 2]; + H[i][k + 2] = H[i][k + 2] - p * r; + } + H[i][k] = H[i][k] - p; + H[i][k + 1] = H[i][k + 1] - p * q; + } + + for (int i = low; i <= high; i++) + { + p = x * V[i][k] + y * V[i][k + 1]; + if (notlast) + { + p = p + z * V[i][k + 2]; + V[i][k + 2] = V[i][k + 2] - p * r; + } + V[i][k] = V[i][k] - p; + V[i][k + 1] = V[i][k + 1] - p * q; + } + } + } + } + } + + if (norm == 0.0m) + { + return ; + } + + for (n = nn - 1; n >= 0; n--) + { + p = d[n]; + q = e[n]; + + if (q == 0) + { + int l = n; + H[n][n] = 1.0m; + for (int i = n - 1; i >= 0; i--) + { + w = H[i][i] - p; + r = 0.0m; + for (int j = l; j <= n; j++) + { + r = r + H[i][j] * H[j][n]; + } + if (e[i] < 0.0m) + { + z = w; + s = r; + } + else + { + l = i; + if (e[i] == 0.0m) + { + if (w != 0.0m) + { + H[i][n] = (- r) / w; + } + else + { + H[i][n] = (- r) / (eps * norm); + } + } + else + { + x = H[i][i + 1]; + y = H[i + 1][i]; + q = (d[i] - p) * (d[i] - p) + e[i] * e[i]; + t = (x * s - z * r) / q; + H[i][n] = t; + if (System.Math.Abs(x) > System.Math.Abs(z)) + { + H[i + 1][n] = (- r - w * t) / x; + } + else + { + H[i + 1][n] = (- s - y * t) / z; + } + } + + t = System.Math.Abs(H[i][n]); + if ((eps * t) * t > 1) + { + for (int j = i; j <= n; j++) + { + H[j][n] = H[j][n] / t; + } + } + } + } + } + else if (q < 0) + { + int l = n - 1; + if (System.Math.Abs(H[n][n - 1]) > System.Math.Abs(H[n - 1][n])) + { + H[n - 1][n - 1] = q / H[n][n - 1]; + H[n - 1][n] = (- (H[n][n] - p)) / H[n][n - 1]; + } + else + { + cdiv(0.0m, - H[n - 1][n], H[n - 1][n - 1] - p, q); + H[n - 1][n - 1] = cdivr; + H[n - 1][n] = cdivi; + } + H[n][n - 1] = 0.0m; + H[n][n] = 1.0m; + for (int i = n - 2; i >= 0; i--) + { + decimal ra, sa, vr, vi; + ra = 0.0m; + sa = 0.0m; + for (int j = l; j <= n; j++) + { + ra = ra + H[i][j] * H[j][n - 1]; + sa = sa + H[i][j] * H[j][n]; + } + w = H[i][i] - p; + + if (e[i] < 0.0m) + { + z = w; + r = ra; + s = sa; + } + else + { + l = i; + if (e[i] == 0) + { + cdiv(- ra, - sa, w, q); + H[i][n - 1] = cdivr; + H[i][n] = cdivi; + } + else + { + x = H[i][i + 1]; + y = H[i + 1][i]; + vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q; + vi = (d[i] - p) * 2.0m * q; + if (vr == 0.0m & vi == 0.0m) + { + vr = eps * norm * (System.Math.Abs(w) + System.Math.Abs(q) + System.Math.Abs(x) + System.Math.Abs(y) + System.Math.Abs(z)); + } + cdiv(x * r - z * ra + q * sa, x * s - z * sa - q * ra, vr, vi); + H[i][n - 1] = cdivr; + H[i][n] = cdivi; + if (System.Math.Abs(x) > (System.Math.Abs(z) + System.Math.Abs(q))) + { + H[i + 1][n - 1] = (- ra - w * H[i][n - 1] + q * H[i][n]) / x; + H[i + 1][n] = (- sa - w * H[i][n] - q * H[i][n - 1]) / x; + } + else + { + cdiv(- r - y * H[i][n - 1], - s - y * H[i][n], z, q); + H[i + 1][n - 1] = cdivr; + H[i + 1][n] = cdivi; + } + } + + t = System.Math.Max(System.Math.Abs(H[i][n - 1]), System.Math.Abs(H[i][n])); + if ((eps * t) * t > 1) + { + for (int j = i; j <= n; j++) + { + H[j][n - 1] = H[j][n - 1] / t; + H[j][n] = H[j][n] / t; + } + } + } + } + } + } + + for (int i = 0; i < nn; i++) + { + if (i < low | i > high) + { + for (int j = i; j < nn; j++) + { + V[i][j] = H[i][j]; + } + } + } + + for (int j = nn - 1; j >= low; j--) + { + for (int i = low; i <= high; i++) + { + z = 0.0m; + for (int k = low; k <= System.Math.Min(j, high); k++) + { + z = z + V[i][k] * H[k][j]; + } + V[i][j] = z; + } + } + } + + public EigenvalueDecomposition(GeneralMatrix Arg) + { + decimal[][] A = Arg.Array; + n = Arg.ColumnDimension; + V = new decimal[n][]; + for (int i = 0; i < n; i++) + { + V[i] = new decimal[n]; + } + d = new decimal[n]; + e = new decimal[n]; + + issymmetric = true; + for (int j = 0; (j < n) & issymmetric; j++) + { + for (int i = 0; (i < n) & issymmetric; i++) + { + issymmetric = (A[i][j] == A[j][i]); + } + } + + if (issymmetric) + { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + V[i][j] = A[i][j]; + } + } + + tred2(); + tql2(); + } + else + { + H = new decimal[n][]; + for (int i2 = 0; i2 < n; i2++) + { + H[i2] = new decimal[n]; + } + ort = new decimal[n]; + + for (int j = 0; j < n; j++) + { + for (int i = 0; i < n; i++) + { + H[i][j] = A[i][j]; + } + } + + orthes(); + hqr2(); + } + } + + virtual public decimal[] RealEigenvalues + { + get + { + return d; + } + } + virtual public decimal[] ImagEigenvalues + { + get + { + return e; + } + } + virtual public GeneralMatrix D + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] D = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + D[i][j] = 0.0m; + } + D[i][i] = d[i]; + if (e[i] > 0) + { + D[i][i + 1] = e[i]; + } + else if (e[i] < 0) + { + D[i][i - 1] = e[i]; + } + } + return X; + } + } + + public virtual GeneralMatrix GetV() + { + return new GeneralMatrix(V, n, n); + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/Function.cs b/MathApp/MathApp/MathApp.Tests/Function.cs new file mode 100644 index 0000000..899dc1d --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/Function.cs @@ -0,0 +1,721 @@ +using System; +using System.Collections; +using System.Collections.Generic; + + +/// +/// +/// +public enum Type { Variable, Value, UnaryOperator, Operator, Function, Result, Bracket, Comma, Error } +public struct Symbol +{ + public string m_name; + public decimal m_value; + public Type m_type; + public override string ToString() + { + return m_name; + } +} +public delegate Symbol EvaluateFunctionDelegate(string name, params Object[] args); +public class Function +{ + public decimal Result + { + get + { + return m_result; + } + } + + public ArrayList Equation + { + get + { + return (ArrayList)m_equation.Clone(); + } + } + public ArrayList Postfix + { + get + { + return (ArrayList)m_postfix.Clone(); + } + } + + public EvaluateFunctionDelegate DefaultFunctionEvaluation + { + set + { + m_defaultFunctionEvaluation = value; + } + } + + public bool Error + { + get + { + return m_bError; + } + } + + public string ErrorDescription + { + get + { + return m_sErrorDescription; + } + } + + public ArrayList Variables + { + get + { + ArrayList var = new ArrayList(); + foreach (Symbol sym in m_equation) + { + if ((sym.m_type == Type.Variable) && (!var.Contains(sym))) + var.Add(sym); + } + return var; + } + set + { + foreach (Symbol sym in value) + { + for (int i = 0; i < m_postfix.Count; i++) + { + if ((sym.m_name == ((Symbol)m_postfix[i]).m_name) && (((Symbol)m_postfix[i]).m_type == Type.Variable)) + { + Symbol sym1 = (Symbol)m_postfix[i]; + sym1.m_value = sym.m_value; + m_postfix[i] = sym1; + } + } + } + } + } + + public Function() + { } + + public void Parse(string equation) + { + int state = 1; + string temp = ""; + Symbol ctSymbol = new Symbol(); // Initialized to avoid error + + m_bError = false; + m_sErrorDescription = "None"; + + m_equation.Clear(); + m_postfix.Clear(); + + int nPos = 0; + //-- Remove all white spaces from the equation string -- + equation = equation.Trim(); + while ((nPos = equation.IndexOf(' ')) != -1) + equation = equation.Remove(nPos, 1); + + for (int i = 0; i < equation.Length; i++) + { + switch (state) + { + case 1: + if (Char.IsNumber(equation[i])) + { + state = 2; + temp += equation[i]; + } + else if (Char.IsLetter(equation[i])) + { + state = 3; + temp += equation[i]; + } + else + { + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + case ".": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + } + break; + case 2: + if ((Char.IsNumber(equation[i])) || (equation[i] == '.') || (equation[i] == ',')) + temp += equation[i]; + else if (!Char.IsLetter(equation[i])) + { + state = 1; + ctSymbol.m_name = temp; + ctSymbol.m_value = Decimal.Parse(temp, System.Globalization.CultureInfo.InvariantCulture); + ctSymbol.m_type = Type.Value; + m_equation.Add(ctSymbol); + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + temp = ""; + } + break; + case 3: + if (Char.IsLetterOrDigit(equation[i])) + temp += equation[i]; + else + { + state = 1; + ctSymbol.m_name = temp; + ctSymbol.m_value = 0; + if (equation[i] == '(') + ctSymbol.m_type = Type.Function; + else + { + if (ctSymbol.m_name == "pi") + ctSymbol.m_value = DecimalMath.PI; + else if (ctSymbol.m_name == "e") + ctSymbol.m_value = DecimalMath.E; + ctSymbol.m_type = Type.Variable; + } + m_equation.Add(ctSymbol); + ctSymbol.m_name = equation[i].ToString(); + ctSymbol.m_value = 0; + switch (ctSymbol.m_name) + { + case ",": + ctSymbol.m_type = Type.Comma; + break; + case "(": + case ")": + case "[": + case "]": + case "{": + case "}": + ctSymbol.m_type = Type.Bracket; + break; + default: + if (m_equation.Count == 0) + ctSymbol.m_type = Type.UnaryOperator; + else if ((((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Value) || (((Symbol)m_equation[m_equation.Count - 1]).m_type == Type.Variable) + || (((Symbol)m_equation[m_equation.Count - 1]).m_name == ")") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "]") || (((Symbol)m_equation[m_equation.Count - 1]).m_name == "}")) + ctSymbol.m_type = Type.Operator; + else + ctSymbol.m_type = Type.UnaryOperator; + break; + } + m_equation.Add(ctSymbol); + temp = ""; + } + break; + } + } + if (temp != "") + { + ctSymbol.m_name = temp; + if (state == 2) + { + ctSymbol.m_value = Decimal.Parse(temp, System.Globalization.CultureInfo.InvariantCulture); + ctSymbol.m_type = Type.Value; + } + else + { + if (ctSymbol.m_name == "pi") + ctSymbol.m_value = DecimalMath.PI; + else if (ctSymbol.m_name == "e") + ctSymbol.m_value = DecimalMath.E; + else + ctSymbol.m_value = 0; + ctSymbol.m_type = Type.Variable; + } + m_equation.Add(ctSymbol); + } + } + + public void Infix2Postfix() + { + Symbol tpSym; + Stack tpStack = new Stack(); + foreach (Symbol sym in m_equation) + { + if ((sym.m_type == Type.Value) || (sym.m_type == Type.Variable)) + m_postfix.Add(sym); + else if ((sym.m_name == "(") || (sym.m_name == "[") || (sym.m_name == "{")) + tpStack.Push(sym); + else if ((sym.m_name == ")") || (sym.m_name == "]") || (sym.m_name == "}")) + { + if (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + while ((tpSym.m_name != "(") && (tpSym.m_name != "[") && (tpSym.m_name != "{")) + { + m_postfix.Add(tpSym); + tpSym = (Symbol)tpStack.Pop(); + } + } + } + else if (sym.m_type == Type.UnaryOperator) + { + tpStack.Push(sym); + } + else + { + if (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + while ((tpStack.Count != 0) && ((tpSym.m_type == Type.UnaryOperator) || (tpSym.m_type == Type.Operator) || (tpSym.m_type == Type.Function) || (tpSym.m_type == Type.Comma)) && (Precedence(tpSym) >= Precedence(sym))) + { + m_postfix.Add(tpSym); + tpSym = (Symbol)tpStack.Pop(); + } + if (((tpSym.m_type == Type.UnaryOperator) || (tpSym.m_type == Type.Operator) || (tpSym.m_type == Type.Function) || (tpSym.m_type == Type.Comma)) && (Precedence(tpSym) >= Precedence(sym))) + m_postfix.Add(tpSym); + else + tpStack.Push(tpSym); + } + tpStack.Push(sym); + } + } + while (tpStack.Count > 0) + { + tpSym = (Symbol)tpStack.Pop(); + m_postfix.Add(tpSym); + } + } + + public void EvaluatePostfix() + { + Symbol tpSym1, tpSym2, tpResult; + Stack tpStack = new Stack(); + ArrayList fnParam = new ArrayList(); + m_bError = false; + foreach (Symbol sym in m_postfix) + { + if ((sym.m_type == Type.Value) || (sym.m_type == Type.Variable) || (sym.m_type == Type.Result)) + tpStack.Push(sym); + else if (sym.m_type == Type.UnaryOperator) + { + tpSym1 = (Symbol)tpStack.Pop(); + tpResult = Evaluate(sym, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (sym.m_type == Type.Operator) + { + tpSym1 = (Symbol)tpStack.Pop(); + tpSym2 = (Symbol)tpStack.Pop(); + tpResult = Evaluate(tpSym2, sym, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (sym.m_type == Type.Comma) + { + tpStack.Push(sym); + } + else if (sym.m_type == Type.Function) + { + fnParam.Clear(); + tpSym1 = (Symbol)tpStack.Pop(); + if ((tpSym1.m_type == Type.Value) || (tpSym1.m_type == Type.Variable) || (tpSym1.m_type == Type.Result)) + { + tpResult = EvaluateFunction(sym.m_name, tpSym1); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else if (tpSym1.m_type == Type.Comma) + { + while (tpSym1.m_type == Type.Comma) + { + tpSym1 = (Symbol)tpStack.Pop(); + fnParam.Add(tpSym1); + tpSym1 = (Symbol)tpStack.Pop(); + } + fnParam.Add(tpSym1); + tpResult = EvaluateFunction(sym.m_name, fnParam.ToArray()); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + else + { + tpStack.Push(tpSym1); + tpResult = EvaluateFunction(sym.m_name); + if (tpResult.m_type == Type.Error) + { + m_bError = true; + m_sErrorDescription = tpResult.m_name; + return; + } + tpStack.Push(tpResult); + } + } + } + if (tpStack.Count == 1) + { + tpResult = (Symbol)tpStack.Pop(); + m_result = tpResult.m_value; + } + } + + protected int Precedence(Symbol sym) + { + switch (sym.m_type) + { + case Type.Bracket: + return 7; + case Type.Function: + return 5; + case Type.UnaryOperator: + return 4; + case Type.Comma: + return 0; + } + switch (sym.m_name) + { + case "^": + return 3; + case "/": + case "*": + case "%": + return 2; + case "+": + case "-": + return 1; + } + return -1; + } + + protected Symbol Evaluate(Symbol opr, Symbol sym1) + { + Symbol result; + result.m_name = opr.m_name + sym1.m_name; + result.m_type = Type.Result; + result.m_value = 0; + switch (opr.m_name) + { + case "+": + result.m_value = sym1.m_value; ; + break; + case "-": + result.m_value = -1 * sym1.m_value; + break; + default: + result.m_type = Type.Error; + result.m_name = "Undefine unary operator: " + opr.m_name + "."; + break; + } + return result; + } + + protected Symbol Evaluate(Symbol sym1, Symbol opr, Symbol sym2) + { + Symbol result; + result.m_name = sym1.m_name + opr.m_name + sym2.m_name; + result.m_type = Type.Result; + result.m_value = 0; + switch (opr.m_name) + { + case "^": + result.m_value = DecimalMath.Pow(sym1.m_value, sym2.m_value); + break; + case "/": + { + if (sym2.m_value != 0) + result.m_value = sym1.m_value / sym2.m_value; + else + { + result.m_name = "Divide by Zero."; + result.m_type = Type.Error; + } + break; + } + case "*": + result.m_value = sym1.m_value * sym2.m_value; + break; + case "%": + result.m_value = sym1.m_value % sym2.m_value; + break; + case "+": + result.m_value = sym1.m_value + sym2.m_value; + break; + case "-": + result.m_value = sym1.m_value - sym2.m_value; + break; + default: + result.m_type = Type.Error; + result.m_name = "Undefine operator: " + opr.m_name + "."; + break; + } + return result; + } + + protected Symbol EvaluateFunction(string name, params Object[] args) + { + Symbol result; + result.m_name = ""; + result.m_type = Type.Result; + result.m_value = 0; + switch (name) + { + case "cos": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Cos(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sin": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sin(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "tan": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Tan(((Symbol)args[0]).m_value * DecimalMath.PI / 180); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "cosh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Cosh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sinh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sinh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "tanh": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Tanh(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "log": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log10(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "ln": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Log(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "logn": + if (args.Length == 2) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + "'" + ((Symbol)args[1]).m_value.ToString() + ")"; + // log_b(x) = ln(x) / ln(b) + result.m_value = DecimalMath.Log(((Symbol)args[0]).m_value) / DecimalMath.Log(((Symbol)args[1]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "sqrt": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Sqrt(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "abs": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Abs(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "acos": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Acos(((Symbol)args[0]).m_value) * 180 / DecimalMath.PI; + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "asin": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Asin(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "atan": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Atan(((Symbol)args[0]).m_value) * 180 / DecimalMath.PI; + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + case "exp": + if (args.Length == 1) + { + result.m_name = name + "(" + ((Symbol)args[0]).m_value.ToString() + ")"; + result.m_value = DecimalMath.Exp(((Symbol)args[0]).m_value); + } + else + { + result.m_name = "Invalid number of parameters in: " + name + "."; + result.m_type = Type.Error; + } + break; + default: + if (m_defaultFunctionEvaluation != null) + result = m_defaultFunctionEvaluation(name, args); + else + { + result.m_name = "Function: " + name + ", not found."; + result.m_type = Type.Error; + } + break; + } + return result; + } + + protected bool m_bError = false; + protected string m_sErrorDescription = "None"; + public decimal m_result = 0; + public ArrayList m_equation = new ArrayList(); + public ArrayList m_postfix = new ArrayList(); + protected EvaluateFunctionDelegate m_defaultFunctionEvaluation; +} diff --git a/MathApp/MathApp/MathApp.Tests/GeneralMatrix.cs b/MathApp/MathApp/MathApp.Tests/GeneralMatrix.cs new file mode 100644 index 0000000..a026b32 --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/GeneralMatrix.cs @@ -0,0 +1,767 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + internal class Maths + { + public static decimal Hypot(decimal a, decimal b) + { + decimal r; + if (Math.Abs(a) > Math.Abs(b)) + { + r = b/a; + r = Math.Abs(a) * (decimal)DecimalMath.Sqrt(1 + r * r); + } + else if (b != 0) + { + r = a/b; + r = Math.Abs(b) * (decimal)DecimalMath.Sqrt(1 + r * r); + } + else + { + r = 0.0m; + } + return r; + } + } + + [Serializable] + public class GeneralMatrix : System.ICloneable, System.Runtime.Serialization.ISerializable, System.IDisposable + { + private decimal[][] A; + private int m, n; + + public GeneralMatrix(int m, int n) + { + this.m = m; + this.n = n; + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + } + } + + public GeneralMatrix(int m, int n, decimal s) + { + this.m = m; + this.n = n; + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + for (int j = 0; j < n; j++) + { + A[i][j] = s; + } + } + } + + public GeneralMatrix(decimal[][] A) + { + m = A.Length; + n = A[0].Length; + for (int i = 0; i < m; i++) + { + if (A[i].Length != n) + { + throw new System.ArgumentException("All rows must have the same length."); + } + } + this.A = A; + } + + public GeneralMatrix(decimal[][] A, int m, int n) + { + this.A = A; + this.m = m; + this.n = n; + } + + public GeneralMatrix(decimal[] vals, int m) + { + this.m = m; + n = (m != 0?vals.Length / m:0); + if (m * n != vals.Length) + { + throw new System.ArgumentException("Array length must be a multiple of m."); + } + A = new decimal[m][]; + for (int i = 0; i < m; i++) + { + A[i] = new decimal[n]; + for (int j = 0; j < n; j++) + { + A[i][j] = vals[i + j * m]; + } + } + } + + public virtual decimal[][] Array + { + get + { + return A; + } + } + + public virtual decimal[][] ArrayCopy + { + get + { + decimal[][] C = new decimal[m][]; + for (int i = 0; i < m; i++) + { + C[i] = new decimal[n]; + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return C; + } + } + + public virtual decimal[] ColumnPackedCopy + { + get + { + decimal[] vals = new decimal[m * n]; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + vals[i + j * m] = A[i][j]; + } + } + return vals; + } + } + + public virtual decimal[] RowPackedCopy + { + get + { + decimal[] vals = new decimal[m * n]; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + vals[i * n + j] = A[i][j]; + } + } + return vals; + } + } + + public virtual int RowDimension + { + get + { + return m; + } + } + + public virtual int ColumnDimension + { + get + { + return n; + } + } + + public static GeneralMatrix ConstructWithCopy(decimal[][] A) + { + int m = A.Length; + int n = A[0].Length; + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + if (A[i].Length != n) + { + throw new System.ArgumentException("All rows must have the same length."); + } + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix Copy() + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j]; + } + } + return X; + } + + public virtual decimal GetElement(int i, int j) + { + return A[i][j]; + } + + public virtual GeneralMatrix GetMatrix(int i0, int i1, int j0, int j1) + { + GeneralMatrix X = new GeneralMatrix(i1 - i0 + 1, j1 - j0 + 1); + decimal[][] B = X.Array; + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = j0; j <= j1; j++) + { + B[i - i0][j - j0] = A[i][j]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual GeneralMatrix GetMatrix(int[] r, int[] c) + { + GeneralMatrix X = new GeneralMatrix(r.Length, c.Length); + decimal[][] B = X.Array; + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = 0; j < c.Length; j++) + { + B[i][j] = A[r[i]][c[j]]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual GeneralMatrix GetMatrix(int i0, int i1, int[] c) + { + GeneralMatrix X = new GeneralMatrix(i1 - i0 + 1, c.Length); + decimal[][] B = X.Array; + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = 0; j < c.Length; j++) + { + B[i - i0][j] = A[i][c[j]]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual GeneralMatrix GetMatrix(int[] r, int j0, int j1) + { + GeneralMatrix X = new GeneralMatrix(r.Length, j1 - j0 + 1); + decimal[][] B = X.Array; + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = j0; j <= j1; j++) + { + B[i][j - j0] = A[r[i]][j]; + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + return X; + } + + public virtual void SetElement(int i, int j, decimal s) + { + A[i][j] = s; + } + + public virtual void SetMatrix(int i0, int i1, int j0, int j1, GeneralMatrix X) + { + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = j0; j <= j1; j++) + { + A[i][j] = X.GetElement(i - i0, j - j0); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual void SetMatrix(int[] r, int[] c, GeneralMatrix X) + { + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = 0; j < c.Length; j++) + { + A[r[i]][c[j]] = X.GetElement(i, j); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual void SetMatrix(int[] r, int j0, int j1, GeneralMatrix X) + { + try + { + for (int i = 0; i < r.Length; i++) + { + for (int j = j0; j <= j1; j++) + { + A[r[i]][j] = X.GetElement(i, j - j0); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual void SetMatrix(int i0, int i1, int[] c, GeneralMatrix X) + { + try + { + for (int i = i0; i <= i1; i++) + { + for (int j = 0; j < c.Length; j++) + { + A[i][c[j]] = X.GetElement(i - i0, j); + } + } + } + catch (System.IndexOutOfRangeException e) + { + throw new System.IndexOutOfRangeException("Submatrix indices", e); + } + } + + public virtual GeneralMatrix Transpose() + { + GeneralMatrix X = new GeneralMatrix(n, m); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[j][i] = A[i][j]; + } + } + return X; + } + + public virtual decimal Norm1() + { + decimal f = 0; + for (int j = 0; j < n; j++) + { + decimal s = 0; + for (int i = 0; i < m; i++) + { + s += System.Math.Abs(A[i][j]); + } + f = System.Math.Max(f, s); + } + return f; + } + + public virtual decimal NormInf() + { + decimal f = 0; + for (int i = 0; i < m; i++) + { + decimal s = 0; + for (int j = 0; j < n; j++) + { + s += System.Math.Abs(A[i][j]); + } + f = System.Math.Max(f, s); + } + return f; + } + + public virtual decimal NormF() + { + decimal f = 0; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + f = Maths.Hypot(f, A[i][j]); + } + } + return f; + } + + public virtual GeneralMatrix UnaryMinus() + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = - A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix Add(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] + B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix AddEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] + B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix Subtract(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] - B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix SubtractEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] - B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix ArrayMultiply(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] * B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix ArrayMultiplyEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] * B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix ArrayRightDivide(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = A[i][j] / B.A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix ArrayRightDivideEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = A[i][j] / B.A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix ArrayLeftDivide(GeneralMatrix B) + { + CheckMatrixDimensions(B); + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = B.A[i][j] / A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix ArrayLeftDivideEquals(GeneralMatrix B) + { + CheckMatrixDimensions(B); + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = B.A[i][j] / A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix Multiply(decimal s) + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] C = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + C[i][j] = s * A[i][j]; + } + } + return X; + } + + public virtual GeneralMatrix MultiplyEquals(decimal s) + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + A[i][j] = s * A[i][j]; + } + } + return this; + } + + public virtual GeneralMatrix Multiply(GeneralMatrix B) + { + if (B.m != n) + { + throw new System.ArgumentException("GeneralMatrix inner dimensions must agree."); + } + GeneralMatrix X = new GeneralMatrix(m, B.n); + decimal[][] C = X.Array; + decimal[] Bcolj = new decimal[n]; + for (int j = 0; j < B.n; j++) + { + for (int k = 0; k < n; k++) + { + Bcolj[k] = B.A[k][j]; + } + for (int i = 0; i < m; i++) + { + decimal[] Arowi = A[i]; + decimal s = 0; + for (int k = 0; k < n; k++) + { + s += Arowi[k] * Bcolj[k]; + } + C[i][j] = s; + } + } + return X; + } + + public static GeneralMatrix operator +(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Add(m2); + } + + public static GeneralMatrix operator -(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Subtract(m2); + } + + public static GeneralMatrix operator *(GeneralMatrix m1, GeneralMatrix m2) + { + return m1.Multiply(m2); + } + + public virtual LUDecomposition LUD() + { + return new LUDecomposition(this); + } + + public virtual QRDecomposition QRD() + { + return new QRDecomposition(this); + } + + public virtual CholeskyDecomposition chol() + { + return new CholeskyDecomposition(this); + } + + public virtual SingularValueDecomposition SVD() + { + return new SingularValueDecomposition(this); + } + + public virtual EigenvalueDecomposition Eigen() + { + return new EigenvalueDecomposition(this); + } + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + return (m == n ? (new LUDecomposition(this)).Solve(B):(new QRDecomposition(this)).Solve(B)); + } + + public virtual GeneralMatrix SolveTranspose(GeneralMatrix B) + { + return Transpose().Solve(B.Transpose()); + } + + public virtual GeneralMatrix Inverse() + { + return Solve(Identity(m, m)); + } + + public virtual decimal Determinant() + { + return new LUDecomposition(this).Determinant(); + } + + public virtual int Rank() + { + return new SingularValueDecomposition(this).Rank(); + } + + public virtual decimal Condition() + { + return new SingularValueDecomposition(this).Condition(); + } + + public virtual decimal Trace() + { + decimal t = 0; + for (int i = 0; i < System.Math.Min(m, n); i++) + { + t += A[i][i]; + } + return t; + } + + public static GeneralMatrix Identity(int m, int n) + { + GeneralMatrix A = new GeneralMatrix(m, n); + decimal[][] X = A.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + X[i][j] = (i == j ? 1.0m : 0.0m); + } + } + return A; + } + + private void CheckMatrixDimensions(GeneralMatrix B) + { + if (B.m != m || B.n != n) + { + throw new System.ArgumentException("GeneralMatrix dimensions must agree."); + } + } + + public void Dispose() + { + Dispose(true); + } + + private void Dispose(bool disposing) + { + if (disposing) + GC.SuppressFinalize(this); + } + + ~GeneralMatrix() + { + Dispose(false); + } + + public System.Object Clone() + { + return this.Copy(); + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/LUDecomposition.cs b/MathApp/MathApp/MathApp.Tests/LUDecomposition.cs new file mode 100644 index 0000000..a30d86f --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/LUDecomposition.cs @@ -0,0 +1,322 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// LU Decomposition. + /// For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n + /// unit lower triangular matrix L, an n-by-n upper triangular matrix U, + /// and a permutation vector piv of length m so that A(piv,:) = L*U. + /// If m < n, then L is m-by-m and U is m-by-n. + /// The LU decompostion with pivoting always exists, even if the matrix is + /// singular, so the constructor will never fail. The primary use of the + /// LU decomposition is in the solution of square systems of simultaneous + /// linear equations. This will fail if IsNonSingular() returns false. + /// + + [Serializable] + public class LUDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] LU; + + /// Row and column dimensions, and pivot sign. + /// @serial column dimension. + /// @serial row dimension. + /// @serial pivot sign. + /// + private int m, n, pivsign; + + /// Internal storage of pivot vector. + /// @serial pivot vector. + /// + private int[] piv; + + #endregion // Class variables + + #region Constructor + + /// LU Decomposition + /// Rectangular matrix + /// + /// Structure to access L, U and piv. + /// + + public LUDecomposition(GeneralMatrix A) + { + // Use a "left-looking", dot-product, Crout/Doolittle algorithm. + + LU = A.ArrayCopy; + m = A.RowDimension; + n = A.ColumnDimension; + piv = new int[m]; + for (int i = 0; i < m; i++) + { + piv[i] = i; + } + pivsign = 1; + decimal[] LUrowi; + decimal[] LUcolj = new decimal[m]; + + // Outer loop. + + for (int j = 0; j < n; j++) + { + + // Make a copy of the j-th column to localize references. + + for (int i = 0; i < m; i++) + { + LUcolj[i] = LU[i][j]; + } + + // Apply previous transformations. + + for (int i = 0; i < m; i++) + { + LUrowi = LU[i]; + + // Most of the time is spent in the following dot product. + + int kmax = System.Math.Min(i, j); + decimal s = 0.0m; + for (int k = 0; k < kmax; k++) + { + s += LUrowi[k] * LUcolj[k]; + } + + LUrowi[j] = LUcolj[i] -= s; + } + + // Find pivot and exchange if necessary. + + int p = j; + for (int i = j + 1; i < m; i++) + { + if (System.Math.Abs(LUcolj[i]) > System.Math.Abs(LUcolj[p])) + { + p = i; + } + } + if (p != j) + { + for (int k = 0; k < n; k++) + { + decimal t = LU[p][k]; LU[p][k] = LU[j][k]; LU[j][k] = t; + } + int k2 = piv[p]; piv[p] = piv[j]; piv[j] = k2; + pivsign = - pivsign; + } + + // Compute multipliers. + + if (j < m & LU[j][j] != 0.0m) + { + for (int i = j + 1; i < m; i++) + { + LU[i][j] /= LU[j][j]; + } + } + } + } + #endregion // Constructor + + #region Public Properties + /// Is the matrix nonsingular? + /// true if U, and hence A, is nonsingular. + /// + virtual public bool IsNonSingular + { + get + { + for (int j = 0; j < n; j++) + { + if (LU[j][j] == 0) + return false; + } + return true; + } + } + + /// Return lower triangular factor + /// L + /// + virtual public GeneralMatrix L + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] L = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + if (i > j) + { + L[i][j] = LU[i][j]; + } + else if (i == j) + { + L[i][j] = 1.0m; + } + else + { + L[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Return upper triangular factor + /// U + /// + virtual public GeneralMatrix U + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] U = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i <= j) + { + U[i][j] = LU[i][j]; + } + else + { + U[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Return pivot permutation vector + /// piv + /// + virtual public int[] Pivot + { + get + { + int[] p = new int[m]; + for (int i = 0; i < m; i++) + { + p[i] = piv[i]; + } + return p; + } + } + + /// Return pivot permutation vector as a one-dimensional decimal array + /// (decimal) piv + /// + virtual public decimal[] decimalPivot + { + get + { + decimal[] vals = new decimal[m]; + for (int i = 0; i < m; i++) + { + vals[i] = (decimal) piv[i]; + } + return vals; + } + } + + #endregion // Public Properties + + #region Public Methods + + /// Determinant + /// det(A) + /// + /// Matrix must be square + /// + + public virtual decimal Determinant() + { + if (m != n) + { + throw new System.ArgumentException("Matrix must be square."); + } + decimal d = (decimal) pivsign; + for (int j = 0; j < n; j++) + { + d *= LU[j][j]; + } + return d; + } + + /// Solve A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X so that L*U*X = B(piv,:) + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is singular. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != m) + { + throw new System.ArgumentException("Matrix row dimensions must agree."); + } + if (!this.IsNonSingular) + { + throw new System.SystemException("Matrix is singular."); + } + + // Copy right hand side with pivoting + int nx = B.ColumnDimension; + GeneralMatrix Xmat = B.GetMatrix(piv, 0, nx - 1); + decimal[][] X = Xmat.Array; + + // Solve L*Y = B(piv,:) + for (int k = 0; k < n; k++) + { + for (int i = k + 1; i < n; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * LU[i][k]; + } + } + } + // Solve U*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= LU[k][k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * LU[i][k]; + } + } + } + return Xmat; + } + + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/Matrix.cs b/MathApp/MathApp/MathApp.Tests/Matrix.cs new file mode 100644 index 0000000..3b32f59 --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/Matrix.cs @@ -0,0 +1,290 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; + +public class Matrix +{ + private static Random random = new Random(); + + public static decimal[][] GenerateRandomMatrix(int rows, int columns, decimal min, decimal max) + { + decimal[][] res = new decimal[rows][]; + for (int i = 0; i < rows; i++) + { + res[i] = new decimal[columns]; + for (int j = 0; j < columns; j++) + { + // Replaced UnityEngine.Random with System.Random + double range = (double)(max - min); + double sample = random.NextDouble(); + double scaled = (sample * range) + (double)min; + decimal value = (decimal)System.Math.Round(scaled, 2); + res[i][j] = value; + } + } + return res; + } + + public static decimal[][] Transpoze(decimal[][] _m) + { + decimal[][] res = new decimal[_m[0].Length][]; + for (int i = 0; i < _m[0].Length; i++) + { + res[i] = new decimal[_m.Length]; + } + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + res[j][i] = _m[i][j]; + } + } + return res; + } + + public static decimal MatrixDeterminant(decimal[][] _m) + { + if (_m.Length == _m[0].Length) + { + int c = _m.Length; + if (c == 2) + { + return (decimal)Math.Round(_m[0][0] * _m[1][1] - _m[0][1] * _m[1][0], 5); + } + else if (c == 1) + { + return (decimal)Math.Round(_m[0][0], 5); + } + else if (c == 0) + { + Console.WriteLine("Matrix is empty!"); + return 0; + } + else + { + decimal resDet = 0; + for (int i = 0; i < c; i++) + { + for (int j = 0; j < c; j++) + { + decimal[][] newM = new decimal[c - 1][]; + for (int k = 0; k < c - 1; k++) + { + newM[k] = new decimal[c - 1]; + } + + bool isAddedK = false, isAddedL = false; + int offsetK = 0, offsetL = 0; + + for (int k = 0; k < c; k++) + { + isAddedL = false; + offsetL = 0; + for (int l = 0; l < c; l++) + { + if (!(k == i || l == j)) + { + newM[k + offsetK][l + offsetL] = _m[k][l]; + } + else + { + if (!isAddedK && k == i) + { + offsetK = -1; + isAddedK = true; + } + if (!isAddedL && l == j) + { + offsetL = -1; + isAddedL = true; + } + } + } + } + + decimal cofactor = (decimal)Math.Pow(-1, 0 + j + 2) * MatrixDeterminant(newM); + resDet += cofactor * _m[0][j]; + } + } + return (decimal)Math.Round(resDet, 5); + } + } + else + { + Console.WriteLine("This matrix is not a square matrix!"); + return 0; + } + } + + public static decimal[] SolveEquation(decimal[][] _m, decimal[] _v) + { + int len = _m.Length; + + decimal[] res = new decimal[len]; + decimal d0 = MatrixDeterminant(_m); + + for (int i = 0; i < len; i++) + { + decimal[][] testMa = new decimal[len][]; + for (int j = 0; j < len; j++) + { + testMa[j] = new decimal[len]; + for (int k = 0; k < len; k++) + { + testMa[j][k] = _m[j][k]; + } + } + for (int j = 0; j < len; j++) + { + testMa[j][i] = _v[j]; + } + decimal di = MatrixDeterminant(testMa); + res[i] = (decimal)Math.Round(di / d0, 5); + } + + return res; + } + + public static decimal[][] ConvertLinearEquationsToMatrix(List equations, List variables) + { + if (equations.Count == variables.Count) + { + decimal[][] res = new decimal[equations.Count][]; + for (int i = 0; i < res.Length; i++) + { + res[i] = new decimal[equations.Count]; + } + for (int i = 0; i < equations.Count; i++) + { + for (int j = 0; j < equations[i].Length; j++) + { + for (int k = 0; k < variables.Count; k++) + { + if (equations[i][j] == variables[k][0]) + { + string coeff = ""; + for (int l = j - 1; l >= 0; l--) + { + if (equations[i][l] != '*' && equations[i][l] != '+' && equations[i][l] != '-') + { + coeff += equations[i][l]; + } + if (equations[i][l] == '-') + { + coeff += '-'; + break; + } + if (equations[i][l] == '+') + { + break; + } + } + char[] charArray = coeff.ToCharArray(); + Array.Reverse(charArray); + string currentCoeff = new string(charArray); // Renamed 'coeff' to 'currentCoeff' + // Console.WriteLine("Parsing Coeff for " + variables[k] + ": '" + currentCoeff + "'"); + try { + res[i][k] = decimal.Parse(currentCoeff, CultureInfo.InvariantCulture); + } catch (Exception ex) { + Console.WriteLine($"ERROR parsing coeff '{currentCoeff}': {ex.Message}"); + throw; + } + } + } + } + } + return res; + } + else return null; + } + + public static decimal[][] MatrixMultiplication(decimal[][] _m1, decimal[][] _m2) + { + if (_m1[0].Length == _m2.Length) + { + decimal[][] res = new decimal[_m1.Length][]; + for (int i = 0; i < _m1.Length; i++) + { + res[i] = new decimal[_m2[0].Length]; + } + + for (int i = 0; i < res.Length; i++) + { + for (int j = 0; j < res[0].Length; j++) + { + decimal sum = 0; + for (int k = 0; k < _m2.Length; k++) + { + sum += _m1[i][k] * _m2[k][j]; + } + res[i][j] = sum; + } + } + return res; + } + else + { + Console.WriteLine("Matrices cannot be multiplied!"); + return null; + } + } + public static decimal[][] MatrixMultiplication(decimal[][] _m, decimal _c) + { + decimal[][] res = _m; + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + res[i][j] *= _c; + } + } + return res; + } + + public static decimal[] TurnListToVector(List _vec) + { + decimal[] res = new decimal[_vec.Count]; + for (int i = 0; i < _vec.Count; i++) + { + res[i] = _vec[i]; + } + return res; + } + public static decimal[][] TurnListToMatrix(List> _m) + { + decimal[][] res = new decimal[_m.Count][]; + for (int i = 0; i < _m.Count; i++) + { + res[i] = new decimal[_m[i].Count]; + for (int j = 0; j < _m[i].Count; j++) + { + res[i][j] = _m[i][j]; + } + } + return res; + } + + public static string DebugMatrix(decimal[][] _m, string _sep = " ") + { + string sum = ""; + for (int i = 0; i < _m.Length; i++) + { + for (int j = 0; j < _m[0].Length; j++) + { + sum += _m[i][j] + ((j == _m[0].Length - 1) ? "\n" : _sep); + } + } + return sum; + } + public static string DebugVector(decimal[] _v, string _sep = " ") + { + string sum = ""; + for (int i = 0; i < _v.Length; i++) + { + sum += _v[i] + "\n"; + } + return sum; + } + +} diff --git a/MathApp/MathApp/MathApp.Tests/NumericalMethods.cs b/MathApp/MathApp/MathApp.Tests/NumericalMethods.cs new file mode 100644 index 0000000..5b64409 --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/NumericalMethods.cs @@ -0,0 +1,551 @@ +using DotNetMatrix; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Text.RegularExpressions; +using System.Text; +using System.Linq; +using System; + +public class NumericalMethods +{ + // --- Original Methods Ported --- + + public static decimal Method_EvaluateFunction(string eq, string variable, decimal point) + { + string newEq = eq; + newEq = newEq.Replace(variable, point.ToString(CultureInfo.InvariantCulture)); + Function f = new Function(); + f.Parse(newEq); + f.Infix2Postfix(); + f.EvaluatePostfix(); + return f.m_result; + } + + public static decimal MethodMultiVar_EvaluateFunction(string eq, Dictionary points) + { + string newEq = eq; + foreach (KeyValuePair pt in points) + { + newEq = newEq.Replace(pt.Key, pt.Value.ToString(CultureInfo.InvariantCulture)); + } + Function f = new Function(); + f.Parse(newEq); + f.Infix2Postfix(); + f.EvaluatePostfix(); + return f.m_result; + } + + public static Dictionary MethodMultiVar_SolveEquationSystem(List eqs, Dictionary initPoints, int iterationCount = 5, decimal h = 0.001m) + { + Dictionary dynamicPoints = new Dictionary(initPoints); + for (int itC = 0; itC < iterationCount; itC++) + { + Console.WriteLine("Iteration: " + itC); + List linearizedEqs = new List(); + List variablesStr = new List(); + List leftVector = new List(); + + for (int i = 0; i < eqs.Count; i++) + { + string le = MethodMultiVar_TaylorSeries(eqs[i], 1, dynamicPoints, h); + // Console.WriteLine("LE: " + le); + + decimal leftV = 0; + Match m = Regex.Match(le, @"^([-+]?[0-9]*\.?[0-9]+)"); + if (m.Success) + { + // Check if followed by * + if (m.Index + m.Length < le.Length && le[m.Index + m.Length] == '*') + { + leftV = 0; + // Do not strip anything, it's a coefficient + } + else + { + Console.WriteLine("Matched Constant: '" + m.Value + "'"); + try { + leftV = decimal.Parse(m.Value, CultureInfo.InvariantCulture) * -1; + } catch (OverflowException) { + Console.WriteLine("OVERFLOW parsing constant! Value too large/small."); + leftV = 0; // Fallback + } + le = le.Substring(m.Length); + } + } + + string sum = ""; + foreach (KeyValuePair p in dynamicPoints) + { + sum += p.Key + ": " + p.Value.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) + ", "; + } + + + foreach (KeyValuePair p in dynamicPoints) + { + le = le.Replace("(" + p.Key + (p.Value < 0 ? "+" + DecimalMath.Abs(p.Value).ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) : "-" + p.Value.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture)) + ")", p.Key); + le = le.Replace("(" + p.Key + ")", p.Key); + } + + linearizedEqs.Add(le); + leftVector.Add(leftV); + } + + foreach (KeyValuePair p in dynamicPoints) + { + variablesStr.Add(p.Key); + } + Console.WriteLine("Calling ConvertLinearEquationsToMatrix"); + decimal[][] jacobianMatrix = Matrix.ConvertLinearEquationsToMatrix(linearizedEqs, variablesStr); + decimal[] leftHandVector = leftVector.ToArray(); + + // Matrix.cs in core likely has SolveEquation if I ported it. + // Let's assume Matrix.cs has it or we use GeneralMatrix directly. + // The original used Matrix.SolveEquation. + // My ported Matrix.cs from step 20 (viewed 1-663) has SolveEquation. + + Console.WriteLine("Calling Matrix.SolveEquation"); + decimal[] newPoints = Matrix.SolveEquation(jacobianMatrix, leftHandVector); + + List newPointsList = new List(); + for (int i = 0; i < newPoints.Length; i++) + { + newPointsList.Add(newPoints[i]); + } + + Dictionary tempDynamicPoints = new Dictionary(); + foreach (KeyValuePair p in dynamicPoints) + { + tempDynamicPoints.Add(p.Key, p.Value); + } + + foreach (KeyValuePair p in dynamicPoints) + { + tempDynamicPoints[p.Key] = newPointsList[0] + p.Value; + newPointsList.RemoveAt(0); + } + dynamicPoints = tempDynamicPoints; + } + + return dynamicPoints; + } + + public static string Method_TaylorSeries(string eq, int degree, string variable, decimal point, decimal h = 0.001m) + { + decimal constant = Method_EvaluateFunction(eq, variable, point); + constant = DecimalMath.Abs(constant) <= 0.001m ? 0 : constant; + string newEq = constant != 0 ? constant.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) : ""; + for (int i = 1; i < degree + 1; i++) + { + decimal der = Method_NumericalDifferentiation(eq, i, variable, point, 4, h); + decimal fact = Factorial(i); + decimal coeff = (der / fact); + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (point < 0) + { + addingSTR = "+" + DecimalMath.Abs(point).ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + else if (point > 0) + { + addingSTR = "-" + point.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + + varSTR += coeff.ToString(CultureInfo.InvariantCulture) + "*(" + variable + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) + ""); + newEq += varSTR; + } + if (constant == 0 && newEq.Length > 0 && newEq[0] == '+') newEq = newEq.Substring(1); + return newEq; + } + + public static string MethodMultiVar_TaylorSeries(string eq, int degree, Dictionary points, decimal h = 0.001m) + { + decimal constant = MethodMultiVar_EvaluateFunction(eq, points); + constant = DecimalMath.Abs(constant) <= 0.0001m ? 0 : constant; + string newEq = constant != 0 ? constant.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture) : ""; + for (int i = 1; i < degree + 1; i++) + { + foreach (KeyValuePair pt in points) + { + decimal partDer = Method_NumericalPartialDifferentiation(eq, i, pt.Key, points, 4, h); + decimal fact = Factorial(i); + decimal coeff = partDer / fact; + string varSTR = ""; + if (coeff > 0) varSTR = "+"; + if (coeff == 0) continue; + + string addingSTR = ""; + if (pt.Value < 0) + { + addingSTR = "+" + DecimalMath.Abs(pt.Value).ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + else if (pt.Value > 0) + { + addingSTR = "-" + pt.Value.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture); + } + varSTR += coeff.ToString(CultureInfo.InvariantCulture) + "*(" + pt.Key + addingSTR + (i == 1 ? ")" : ")^" + i.ToString("0." + new string('#', 339), CultureInfo.InvariantCulture)); + newEq += varSTR; + } + } + if (constant == 0 && newEq.Length > 0 && newEq[0] == '+') newEq = newEq.Substring(1); + // Assuming intent was to do nothing or it's buggy. I'll leave it as is (or fix it). + return newEq; + } + + public static decimal Method_NewtonRaphson(string eq, string variable, decimal initialValue, int iterationCount, decimal h = 0.001m) + { + // Lipschitz check suppressed/incomplete in original + decimal init = initialValue; + for (int i = 0; i < iterationCount; i++) + { + decimal next = init - Method_EvaluateFunction(eq, variable, init) / Method_NumericalDifferentiation(eq, 1, variable, init, 6, h); + init = next; + } + return init; + } + + // Overload for single-variable Newton-Raphson from UIController's simpler usage (assuming UIController calls this one if I didn't verify signature) + // UIController calls: NumericalMethods.Method_NewtonRaphson(eq, variable, initialP, iterCount); + // Matches the one above. + + // My previous implementation had a simplified one. I should keep the one matching signature. + + public static decimal Method_BisectionMethod(string eq, string variable, decimal lowerValue, decimal higherValue, int iterationCount) + { + if (lowerValue >= higherValue) + return 0; + + decimal mp = (lowerValue + higherValue) / 2; + + for (int i = 0; i < iterationCount; i++) + { + mp = (lowerValue + higherValue) / 2; + + decimal evLower = Method_EvaluateFunction(eq, variable, lowerValue); + // decimal evHigher = Method_EvaluateFunction(eq, variable, higherValue); // unused + decimal evMiddle = Method_EvaluateFunction(eq, variable, mp); + + if (evLower * evMiddle < 0) + { + higherValue = mp; + } + else + { + lowerValue = mp; + } + } + + return mp; + } + + public static decimal Method_Derivative(string eq, int degree, string variable, decimal point, decimal h = 0.001m) + { + decimal sum = 0; + for (int i = 0; i <= degree; i++) + { + sum += DecimalMath.Pow(-1, i) * Combination(degree, i) * Method_EvaluateFunction(eq, variable, point + (degree - i) * h); + } + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Method_PartialDerivative(string eq, int degree, string toVar, Dictionary points, decimal h = 0.001m) + { + decimal sum = 0; + Dictionary testPS = new Dictionary(points); + decimal firstToVar = testPS[toVar]; + for (int i = 0; i <= degree; i++) + { + testPS[toVar] = firstToVar + (degree - i) * h; + sum += DecimalMath.Pow(-1, i) * Combination(degree, i) * MethodMultiVar_EvaluateFunction(eq, testPS); + } + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Method_NumericalDifferentiation(string eq, int degree, string variable, decimal point, int accuracy = 2, decimal h = 0.001m) + { + int m = degree, n = accuracy; + int p = (2 * (int)Math.Floor((m + 1) / 2.0) - 2 + n) / 2; + + decimal[][] _matrix = new decimal[2 * p + 1][]; + decimal[] _rhsVector = new decimal[2 * p + 1], functionPointsX = new decimal[2 * p + 1], + functionPointsY = new decimal[2 * p + 1]; + + for (int i = 0; i < _matrix.Length; i++) + { + _matrix[i] = new decimal[2 * p + 1]; + for (int j = 0; j < _matrix[i].Length; j++) + { + _matrix[i][j] = (decimal)Math.Pow(-p + j, i); + } + + if (i != m) + { + _rhsVector[i] = 0; + } + else if (i == m) + { + _rhsVector[i] = Factorial(m); + } + + functionPointsX[i] = point - (p - i) * h; + functionPointsY[i] = Method_EvaluateFunction(eq, variable, functionPointsX[i]); + } + + GeneralMatrix _A = new GeneralMatrix(_matrix); + GeneralMatrix _b = new GeneralMatrix(_rhsVector.Length, 1); + + for (int i = 0; i < _rhsVector.Length; i++) + { + _b.Array[i][0] = _rhsVector[i]; + } + + GeneralMatrix coeffs = _A.Solve(_b); + decimal sum = 0; + + for (int i = 0; i < coeffs.Array.Length; i++) + { + sum += coeffs.Array[i][0] * functionPointsY[i]; + } + + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Method_NumericalPartialDifferentiation(string eq, int degree, string toVar, Dictionary points, int accuracy = 2, decimal h = 0.001m) + { + int m = degree, n = accuracy; + int p = (2 * (int)Math.Floor((m + 1) / 2.0) - 2 + n) / 2; + + decimal[][] _matrix = new decimal[2 * p + 1][]; + Dictionary functionPointsDomain = new Dictionary(); + decimal[] _rhsVector = new decimal[2 * p + 1], functionPointsRange = new decimal[2 * p + 1]; + + for (int i = 0; i < _matrix.Length; i++) + { + _matrix[i] = new decimal[2 * p + 1]; + for (int j = 0; j < _matrix[i].Length; j++) + { + _matrix[i][j] = (decimal)Math.Pow(-p + j, i); + } + + if (i != m) _rhsVector[i] = 0; + else if (i == m) _rhsVector[i] = Factorial(m); + } + + foreach (KeyValuePair item in points) + { + decimal[] ps = new decimal[2 * p + 1]; + if (item.Key == toVar) + { + for (int i = 0; i < ps.Length; i++) ps[i] = points[item.Key] - (p - i) * h; + } + else + { + for (int i = 0; i < ps.Length; i++) ps[i] = points[item.Key]; + } + functionPointsDomain.Add(item.Key, ps); + } + + for (int i = 0; i < 2 * p + 1; i++) + { + Dictionary pair = new Dictionary(); + foreach (KeyValuePair item in functionPointsDomain) + { + pair.Add(item.Key, item.Value[i]); + } + functionPointsRange[i] = MethodMultiVar_EvaluateFunction(eq, pair); + } + + GeneralMatrix _A = new GeneralMatrix(_matrix); + GeneralMatrix _b = new GeneralMatrix(_rhsVector.Length, 1); + + for (int i = 0; i < _rhsVector.Length; i++) _b.Array[i][0] = _rhsVector[i]; + + GeneralMatrix coeffs = _A.Solve(_b); + decimal sum = 0; + + for (int i = 0; i < coeffs.Array.Length; i++) + { + sum += coeffs.Array[i][0] * functionPointsRange[i]; + } + + return sum / DecimalMath.Pow(h, degree); + } + + public static decimal Factorial(int num) + { + if (num >= 2) return num * Factorial(num - 1); + else return 1; + } + + public static decimal Combination(int n, int k) + { + return Factorial(n) / (Factorial(n - k) * Factorial(k)); + } + + public static decimal Permutation(int n, int k) + { + return Factorial(n) / Factorial(n - k); + } + + public static string GenerateCombinations(string chars, string prefix, int length) + { + StringBuilder sb = new StringBuilder(); + GenerateCombinationsRecursive(prefix, chars, length, sb); + return sb.ToString(); + } + static void GenerateCombinationsRecursive(string prefix, string chars, int length, StringBuilder sb) + { + if (length == 0) + { + sb.AppendLine(prefix); + return; + } + + foreach (char c in chars) + { + GenerateCombinationsRecursive(prefix + c, chars, length - 1, sb); + } + } + + // --- Added Linear Solvers (Optional but kept for completeness if UI uses them) --- + // Update: UI uses MethodMultiVar_SolveEquationSystem for System Solver now (based on UIController) + // But I implemented btnSolveSystem_Click in MainForm.cs to use Method_LUDecomposition previously. + // I should update MainForm.cs to use MethodMultiVar_SolveEquationSystem if it's non-linear or general. + // The original app used MethodMultiVar_SolveEquationSystem (Newton-Raphson) for general systems. + + // So I should keep MethodMultiVar_SolveEquationSystem and update MainForm to use IT instead of LUDecomposition if I want to match original behavior. + + // I'll keep the linear solvers just in case. + + public static List Method_Inverse(List _eq, List _vars) + { + // Implementation from previous turn + decimal[][] A = Matrix.ConvertLinearEquationsToMatrix(_eq, _vars); + if (A == null) return null; + decimal[] B = new decimal[_eq.Count]; + for (int i = 0; i < _eq.Count; i++) + { + int ind = _eq[i].IndexOf('='); + if (ind != -1) B[i] = decimal.Parse(_eq[i].Substring(ind + 1), CultureInfo.InvariantCulture); + else B[i] = 0; + } + + GeneralMatrix gA = new GeneralMatrix(A); + GeneralMatrix gB = new GeneralMatrix(B, B.Length); + GeneralMatrix gX = gA.Solve(gB); + decimal[] X = gX.ColumnPackedCopy; + + List res = new List(); + for (int i = 0; i < X.Length; i++) res.Add(_vars[i] + " = " + X[i].ToString("F5", CultureInfo.InvariantCulture)); + return res; + } + + public static List Method_LUDecomposition(List _eq, List _vars) + { + // Implementation from previous turn + decimal[][] A = Matrix.ConvertLinearEquationsToMatrix(_eq, _vars); + if (A == null) return null; + decimal[] B = new decimal[_eq.Count]; + for (int i = 0; i < _eq.Count; i++) + { + int ind = _eq[i].IndexOf('='); + if (ind != -1) B[i] = decimal.Parse(_eq[i].Substring(ind + 1), CultureInfo.InvariantCulture); + else B[i] = 0; + } + + GeneralMatrix gA = new GeneralMatrix(A); + GeneralMatrix gB = new GeneralMatrix(B, B.Length); + GeneralMatrix gX = gA.Solve(gB); + decimal[] X = gX.ColumnPackedCopy; + + List res = new List(); + for (int i = 0; i < X.Length; i++) res.Add(_vars[i] + " = " + X[i].ToString("F5", CultureInfo.InvariantCulture)); + return res; + } + + // Additional wrappers for MainForm compatibility if needed + public static List Method_NewtonRaphson(string _eq, decimal _initialPoint, int _iterationCount) + { + // Wrapper for UI + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + decimal res = Method_NewtonRaphson(_eq, "x", _initialPoint, _iterationCount); + return new List { res.ToString(CultureInfo.InvariantCulture) }; + } + + public static List Method_Bisection(string _eq, decimal _min, decimal _max, int _iterationCount) + { + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + decimal res = Method_BisectionMethod(_eq, "x", _min, _max, _iterationCount); + return new List { res.ToString(CultureInfo.InvariantCulture) }; + } + + public static List Method_Secant(string _eq, decimal _min, decimal _max, int _iterationCount) + { + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + + decimal x0 = _min; + decimal x1 = _max; + decimal x2 = 0; + + for(int i=0; i<_iterationCount; i++) + { + decimal f0 = Method_EvaluateFunction(_eq, "x", x0); + decimal f1 = Method_EvaluateFunction(_eq, "x", x1); + + if (f1 - f0 == 0) break; // Avoid divide by zero + + x2 = x1 - f1 * (x1 - x0) / (f1 - f0); + x0 = x1; + x1 = x2; + + if (DecimalMath.Abs(f1) < 0.00000001m) break; + } + + return new List { x2.ToString(CultureInfo.InvariantCulture) }; + } + + public static List Method_RegulaFalsi(string _eq, decimal _min, decimal _max, int _iterationCount) + { + if (_eq.Contains("=")) + { + string[] parts = _eq.Split('='); + _eq = parts[0] + "-(" + parts[1] + ")"; + } + + decimal a = _min; + decimal b = _max; + decimal c = 0; + + for(int i=0; i<_iterationCount; i++) + { + decimal fa = Method_EvaluateFunction(_eq, "x", a); + decimal fb = Method_EvaluateFunction(_eq, "x", b); + + if (fa * fb >= 0) return new List { "Root not bracketed or multiple roots" }; + + c = (a * fb - b * fa) / (fb - fa); + decimal fc = Method_EvaluateFunction(_eq, "x", c); + + if (fc == 0) break; + else if (fa * fc < 0) b = c; + else a = c; + } + + return new List { c.ToString(CultureInfo.InvariantCulture) }; + } +} diff --git a/MathApp/MathApp/MathApp.Tests/Program.cs b/MathApp/MathApp/MathApp.Tests/Program.cs new file mode 100644 index 0000000..c61f58e --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/Program.cs @@ -0,0 +1,33 @@ +ïğżusing System; +using System.Collections.Generic; +using System.Globalization; +using DotNetMatrix; + +namespace MathApp.Tests +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("DEBUG SOLVER STARTED"); + try + { + List eqs = new List { "x+y-3", "x-y-1" }; + Dictionary init = new Dictionary { { "x", 0 }, { "y", 0 } }; + + Console.WriteLine("Calling SolveEquationSystem..."); + var res = NumericalMethods.MethodMultiVar_SolveEquationSystem(eqs, init, 2, 0.001m); + + Console.WriteLine("Result count: " + (res == null ? "NULL" : res.Count.ToString())); + if(res != null) + { + foreach(var kv in res) Console.WriteLine(kv.Key + "=" + kv.Value); + } + } + catch(Exception ex) + { + Console.WriteLine("EXCEPTION CAUGHT: " + ex.ToString()); + } + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/QRDecomposition.cs b/MathApp/MathApp/MathApp.Tests/QRDecomposition.cs new file mode 100644 index 0000000..8702b0f --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/QRDecomposition.cs @@ -0,0 +1,287 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + + /// QR Decomposition. + /// For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n + /// orthogonal matrix Q and an n-by-n upper triangular matrix R so that + /// A = Q*R. + /// + /// The QR decompostion always exists, even if the matrix does not have + /// full rank, so the constructor will never fail. The primary use of the + /// QR decomposition is in the least squares solution of nonsquare systems + /// of simultaneous linear equations. This will fail if IsFullRank() + /// returns false. + /// + + [Serializable] + public class QRDecomposition : System.Runtime.Serialization.ISerializable + { + #region Class variables + + /// Array for internal storage of decomposition. + /// @serial internal array storage. + /// + private decimal[][] QR; + + /// Row and column dimensions. + /// @serial column dimension. + /// @serial row dimension. + /// + private int m, n; + + /// Array for internal storage of diagonal of R. + /// @serial diagonal of R. + /// + private decimal[] Rdiag; + + #endregion // Class variables + + #region Constructor + + /// QR Decomposition, computed by Householder reflections. + /// Rectangular matrix + /// + /// Structure to access R and the Householder vectors and compute Q. + /// + + public QRDecomposition(GeneralMatrix A) + { + // Initialize. + QR = A.ArrayCopy; + m = A.RowDimension; + n = A.ColumnDimension; + Rdiag = new decimal[n]; + + // Main loop. + for (int k = 0; k < n; k++) + { + // Compute 2-norm of k-th column without under/overflow. + decimal nrm = 0; + for (int i = k; i < m; i++) + { + nrm = Maths.Hypot(nrm, QR[i][k]); + } + + if (nrm != 0.0m) + { + // Form k-th Householder vector. + if (QR[k][k] < 0) + { + nrm = - nrm; + } + for (int i = k; i < m; i++) + { + QR[i][k] /= nrm; + } + QR[k][k] += 1.0m; + + // Apply transformation to remaining columns. + for (int j = k + 1; j < n; j++) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * QR[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + QR[i][j] += s * QR[i][k]; + } + } + } + Rdiag[k] = - nrm; + } + } + + #endregion // Constructor + + #region Public Properties + + /// Is the matrix full rank? + /// true if R, and hence A, has full rank. + /// + virtual public bool FullRank + { + get + { + for (int j = 0; j < n; j++) + { + if (Rdiag[j] == 0) + return false; + } + return true; + } + } + + /// Return the Householder vectors + /// Lower trapezoidal matrix whose columns define the reflections + /// + virtual public GeneralMatrix H + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] H = X.Array; + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + if (i >= j) + { + H[i][j] = QR[i][j]; + } + else + { + H[i][j] = 0.0m; + } + } + } + return X; + } + + } + + /// Return the upper triangular factor + /// R + /// + virtual public GeneralMatrix R + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] R = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i < j) + { + R[i][j] = QR[i][j]; + } + else if (i == j) + { + R[i][j] = Rdiag[i]; + } + else + { + R[i][j] = 0.0m; + } + } + } + return X; + } + } + + /// Generate and return the (economy-sized) orthogonal factor + /// Q + /// + virtual public GeneralMatrix Q + { + get + { + GeneralMatrix X = new GeneralMatrix(m, n); + decimal[][] Q = X.Array; + for (int k = n - 1; k >= 0; k--) + { + for (int i = 0; i < m; i++) + { + Q[i][k] = 0.0m; + } + Q[k][k] = 1.0m; + for (int j = k; j < n; j++) + { + if (QR[k][k] != 0) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * Q[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + Q[i][j] += s * QR[i][k]; + } + } + } + } + return X; + } + } + #endregion // Public Properties + + #region Public Methods + + /// Least squares solution of A*X = B + /// A Matrix with as many rows as A and any number of columns. + /// + /// X that minimizes the two norm of Q*R*X-B. + /// + /// Matrix row dimensions must agree. + /// + /// Matrix is rank deficient. + /// + + public virtual GeneralMatrix Solve(GeneralMatrix B) + { + if (B.RowDimension != m) + { + throw new System.ArgumentException("GeneralMatrix row dimensions must agree."); + } + if (!this.FullRank) + { + throw new System.SystemException("Matrix is rank deficient."); + } + + // Copy right hand side + int nx = B.ColumnDimension; + decimal[][] X = B.ArrayCopy; + + // Compute Y = transpose(Q)*B + for (int k = 0; k < n; k++) + { + for (int j = 0; j < nx; j++) + { + decimal s = 0.0m; + for (int i = k; i < m; i++) + { + s += QR[i][k] * X[i][j]; + } + s = (- s) / QR[k][k]; + for (int i = k; i < m; i++) + { + X[i][j] += s * QR[i][k]; + } + } + } + // Solve R*X = Y; + for (int k = n - 1; k >= 0; k--) + { + for (int j = 0; j < nx; j++) + { + X[k][j] /= Rdiag[k]; + } + for (int i = 0; i < k; i++) + { + for (int j = 0; j < nx; j++) + { + X[i][j] -= X[k][j] * QR[i][k]; + } + } + } + + return (new GeneralMatrix(X, n, nx).GetMatrix(0, n - 1, 0, nx - 1)); + } + + #endregion // Public Methods + + // A method called when serializing this class. + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/SingularValueDecomposition.cs b/MathApp/MathApp/MathApp.Tests/SingularValueDecomposition.cs new file mode 100644 index 0000000..3a51b8e --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/SingularValueDecomposition.cs @@ -0,0 +1,512 @@ +using System; +using System.Runtime.Serialization; + +namespace DotNetMatrix +{ + [Serializable] + public class SingularValueDecomposition : System.Runtime.Serialization.ISerializable + { + private decimal[][] U, V; + private decimal[] s; + private int m, n; + + public SingularValueDecomposition(GeneralMatrix Arg) + { + decimal[][] A = Arg.ArrayCopy; + m = Arg.RowDimension; + n = Arg.ColumnDimension; + int nu = System.Math.Min(m, n); + s = new decimal[System.Math.Min(m + 1, n)]; + U = new decimal[m][]; + for (int i = 0; i < m; i++) + { + U[i] = new decimal[nu]; + } + V = new decimal[n][]; + for (int i2 = 0; i2 < n; i2++) + { + V[i2] = new decimal[n]; + } + decimal[] e = new decimal[n]; + decimal[] work = new decimal[m]; + bool wantu = true; + bool wantv = true; + + int nct = System.Math.Min(m - 1, n); + int nrt = System.Math.Max(0, System.Math.Min(n - 2, m)); + for (int k = 0; k < System.Math.Max(nct, nrt); k++) + { + if (k < nct) + { + s[k] = 0; + for (int i = k; i < m; i++) + { + s[k] = Maths.Hypot(s[k], A[i][k]); + } + if (s[k] != 0.0m) + { + if (A[k][k] < 0.0m) + { + s[k] = - s[k]; + } + for (int i = k; i < m; i++) + { + A[i][k] /= s[k]; + } + A[k][k] += 1.0m; + } + s[k] = - s[k]; + } + for (int j = k + 1; j < n; j++) + { + if ((k < nct) & (s[k] != 0.0m)) + { + decimal t = 0; + for (int i = k; i < m; i++) + { + t += A[i][k] * A[i][j]; + } + t = (- t) / A[k][k]; + for (int i = k; i < m; i++) + { + A[i][j] += t * A[i][k]; + } + } + e[j] = A[k][j]; + } + if (wantu & (k < nct)) + { + for (int i = k; i < m; i++) + { + U[i][k] = A[i][k]; + } + } + if (k < nrt) + { + e[k] = 0; + for (int i = k + 1; i < n; i++) + { + e[k] = Maths.Hypot(e[k], e[i]); + } + if (e[k] != 0.0m) + { + if (e[k + 1] < 0.0m) + { + e[k] = - e[k]; + } + for (int i = k + 1; i < n; i++) + { + e[i] /= e[k]; + } + e[k + 1] += 1.0m; + } + e[k] = - e[k]; + if ((k + 1 < m) & (e[k] != 0.0m)) + { + for (int i = k + 1; i < m; i++) + { + work[i] = 0.0m; + } + for (int j = k + 1; j < n; j++) + { + for (int i = k + 1; i < m; i++) + { + work[i] += e[j] * A[i][j]; + } + } + for (int j = k + 1; j < n; j++) + { + decimal t = (- e[j]) / e[k + 1]; + for (int i = k + 1; i < m; i++) + { + A[i][j] += t * work[i]; + } + } + } + if (wantv) + { + for (int i = k + 1; i < n; i++) + { + V[i][k] = e[i]; + } + } + } + } + + int p = System.Math.Min(n, m + 1); + if (nct < n) + { + s[nct] = A[nct][nct]; + } + if (m < p) + { + s[p - 1] = 0.0m; + } + if (nrt + 1 < p) + { + e[nrt] = A[nrt][p - 1]; + } + e[p - 1] = 0.0m; + + if (wantu) + { + for (int j = nct; j < nu; j++) + { + for (int i = 0; i < m; i++) + { + U[i][j] = 0.0m; + } + U[j][j] = 1.0m; + } + for (int k = nct - 1; k >= 0; k--) + { + if (s[k] != 0.0m) + { + for (int j = k + 1; j < nu; j++) + { + decimal t = 0; + for (int i = k; i < m; i++) + { + t += U[i][k] * U[i][j]; + } + t = (- t) / U[k][k]; + for (int i = k; i < m; i++) + { + U[i][j] += t * U[i][k]; + } + } + for (int i = k; i < m; i++) + { + U[i][k] = - U[i][k]; + } + U[k][k] = 1.0m + U[k][k]; + for (int i = 0; i < k - 1; i++) + { + U[i][k] = 0.0m; + } + } + else + { + for (int i = 0; i < m; i++) + { + U[i][k] = 0.0m; + } + U[k][k] = 1.0m; + } + } + } + + if (wantv) + { + for (int k = n - 1; k >= 0; k--) + { + if ((k < nrt) & (e[k] != 0.0m)) + { + for (int j = k + 1; j < nu; j++) + { + decimal t = 0; + for (int i = k + 1; i < n; i++) + { + t += V[i][k] * V[i][j]; + } + t = (- t) / V[k + 1][k]; + for (int i = k + 1; i < n; i++) + { + V[i][j] += t * V[i][k]; + } + } + } + for (int i = 0; i < n; i++) + { + V[i][k] = 0.0m; + } + V[k][k] = 1.0m; + } + } + + int pp = p - 1; + int iter = 0; + decimal eps = (decimal)Math.Pow(2.0f, - 52.0f); + while (p > 0) + { + int k, kase; + for (k = p - 2; k >= - 1; k--) + { + if (k == - 1) + { + break; + } + if (System.Math.Abs(e[k]) <= eps * (System.Math.Abs(s[k]) + System.Math.Abs(s[k + 1]))) + { + e[k] = 0.0m; + break; + } + } + if (k == p - 2) + { + kase = 4; + } + else + { + int ks; + for (ks = p - 1; ks >= k; ks--) + { + if (ks == k) + { + break; + } + decimal t = (ks != p?System.Math.Abs(e[ks]):0.0m) + (ks != k + 1?System.Math.Abs(e[ks - 1]):0.0m); + if (System.Math.Abs(s[ks]) <= eps * t) + { + s[ks] = 0.0m; + break; + } + } + if (ks == k) + { + kase = 3; + } + else if (ks == p - 1) + { + kase = 1; + } + else + { + kase = 2; + k = ks; + } + } + k++; + + switch (kase) + { + case 1: + { + decimal f = e[p - 2]; + e[p - 2] = 0.0m; + for (int j = p - 2; j >= k; j--) + { + decimal t = Maths.Hypot(s[j], f); + decimal cs = s[j] / t; + decimal sn = f / t; + s[j] = t; + if (j != k) + { + f = (- sn) * e[j - 1]; + e[j - 1] = cs * e[j - 1]; + } + if (wantv) + { + for (int i = 0; i < n; i++) + { + t = cs * V[i][j] + sn * V[i][p - 1]; + V[i][p - 1] = (- sn) * V[i][j] + cs * V[i][p - 1]; + V[i][j] = t; + } + } + } + } + break; + case 2: + { + decimal f = e[k - 1]; + e[k - 1] = 0.0m; + for (int j = k; j < p; j++) + { + decimal t = Maths.Hypot(s[j], f); + decimal cs = s[j] / t; + decimal sn = f / t; + s[j] = t; + f = (- sn) * e[j]; + e[j] = cs * e[j]; + if (wantu) + { + for (int i = 0; i < m; i++) + { + t = cs * U[i][j] + sn * U[i][k - 1]; + U[i][k - 1] = (- sn) * U[i][j] + cs * U[i][k - 1]; + U[i][j] = t; + } + } + } + } + break; + case 3: + { + decimal scale = System.Math.Max(System.Math.Max(System.Math.Max(System.Math.Max(System.Math.Abs(s[p - 1]), System.Math.Abs(s[p - 2])), System.Math.Abs(e[p - 2])), System.Math.Abs(s[k])), System.Math.Abs(e[k])); + decimal sp = s[p - 1] / scale; + decimal spm1 = s[p - 2] / scale; + decimal epm1 = e[p - 2] / scale; + decimal sk = s[k] / scale; + decimal ek = e[k] / scale; + decimal b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0m; + decimal c = (sp * epm1) * (sp * epm1); + decimal shift = 0.0m; + if ((b != 0.0m) | (c != 0.0m)) + { + shift = (decimal)DecimalMath.Sqrt(b * b + c); + if (b < 0.0m) + { + shift = - shift; + } + shift = c / (b + shift); + } + decimal f = (sk + sp) * (sk - sp) + shift; + decimal g = sk * ek; + + for (int j = k; j < p - 1; j++) + { + decimal t = Maths.Hypot(f, g); + decimal cs = f / t; + decimal sn = g / t; + if (j != k) + { + e[j - 1] = t; + } + f = cs * s[j] + sn * e[j]; + e[j] = cs * e[j] - sn * s[j]; + g = sn * s[j + 1]; + s[j + 1] = cs * s[j + 1]; + if (wantv) + { + for (int i = 0; i < n; i++) + { + t = cs * V[i][j] + sn * V[i][j + 1]; + V[i][j + 1] = (- sn) * V[i][j] + cs * V[i][j + 1]; + V[i][j] = t; + } + } + t = Maths.Hypot(f, g); + cs = f / t; + sn = g / t; + s[j] = t; + f = cs * e[j] + sn * s[j + 1]; + s[j + 1] = (- sn) * e[j] + cs * s[j + 1]; + g = sn * e[j + 1]; + e[j + 1] = cs * e[j + 1]; + if (wantu && (j < m - 1)) + { + for (int i = 0; i < m; i++) + { + t = cs * U[i][j] + sn * U[i][j + 1]; + U[i][j + 1] = (- sn) * U[i][j] + cs * U[i][j + 1]; + U[i][j] = t; + } + } + } + e[p - 2] = f; + iter = iter + 1; + } + break; + case 4: + { + if (s[k] <= 0.0m) + { + s[k] = (s[k] < 0.0m?- s[k]:0.0m); + if (wantv) + { + for (int i = 0; i <= pp; i++) + { + V[i][k] = - V[i][k]; + } + } + } + while (k < pp) + { + if (s[k] >= s[k + 1]) + { + break; + } + decimal t = s[k]; + s[k] = s[k + 1]; + s[k + 1] = t; + if (wantv && (k < n - 1)) + { + for (int i = 0; i < n; i++) + { + t = V[i][k + 1]; V[i][k + 1] = V[i][k]; V[i][k] = t; + } + } + if (wantu && (k < m - 1)) + { + for (int i = 0; i < m; i++) + { + t = U[i][k + 1]; U[i][k + 1] = U[i][k]; U[i][k] = t; + } + } + k++; + } + iter = 0; + p--; + } + break; + } + } + } + + virtual public decimal[] SingularValues + { + get + { + return s; + } + } + + virtual public GeneralMatrix S + { + get + { + GeneralMatrix X = new GeneralMatrix(n, n); + decimal[][] S = X.Array; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + S[i][j] = 0.0m; + } + S[i][i] = this.s[i]; + } + return X; + } + } + + public virtual GeneralMatrix GetU() + { + return new GeneralMatrix(U, m, System.Math.Min(m + 1, n)); + } + + public virtual GeneralMatrix GetV() + { + return new GeneralMatrix(V, n, n); + } + + public virtual decimal Norm2() + { + return s[0]; + } + + public virtual decimal Condition() + { + return s[0] / s[System.Math.Min(m, n) - 1]; + } + + public virtual int Rank() + { + decimal eps = (decimal)System.Math.Pow(2.0f, - 52.0f); + decimal tol = System.Math.Max(m, n) * s[0] * eps; + int r = 0; + for (int i = 0; i < s.Length; i++) + { + if (s[i] > tol) + { + r++; + } + } + return r; + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + } + } +} diff --git a/MathApp/MathApp/MathApp.Tests/build_err.txt b/MathApp/MathApp/MathApp.Tests/build_err.txt new file mode 100644 index 0000000..fbb4d40 --- /dev/null +++ b/MathApp/MathApp/MathApp.Tests/build_err.txt @@ -0,0 +1,88 @@ +MSBuild version 17.3.4+a400405ba for .NET + Geri yklenecek projeler belirleniyor... + Geri ykleme i‡in tm projeler gncel. +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(88,41): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(88,76): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(90,39): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(99,12): warning CS8618: Null atanamaz alan 'm_defaultFunctionEvaluation', oluŸturucudan ‡kŸ yaparken null olmayan bir de§er i‡ermelidir. alan alann null atanabilir olarak bildirmeyi dŸnn. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(156,44): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(156,113): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(157,40): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(157,102): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(157,164): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(194,44): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(194,113): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(195,40): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(195,102): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(195,164): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(242,44): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(242,113): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(243,40): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(243,102): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(243,164): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Matrix.cs(187,73): error CS0103: 'CultureInfo' ad ge‡erli ba§lamda yok [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Matrix.cs(198,21): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Matrix.cs(228,20): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(291,29): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(295,33): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(307,29): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(311,33): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(323,21): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(340,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(352,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(353,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(370,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(386,34): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(388,34): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(391,61): warning CS8620: 'object?[]' trndeki ba§msz de§iŸken, baŸvuru trlerinin null atanabilirlik farkllklar nedeniyle 'Symbol Function.EvaluateFunction(string name, params object[] args)' i‡inde 'object[]' trndeki 'args' parametresi i‡in kullanlamaz. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(416,24): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\NumericalMethods.cs(427,31): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\NumericalMethods.cs(450,32): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\EigenvalueDecomposition.cs(823,10): warning CS8618: Null atanamaz alan 'H', oluŸturucudan ‡kŸ yaparken null olmayan bir de§er i‡ermelidir. alan alann null atanabilir olarak bildirmeyi dŸnn. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\EigenvalueDecomposition.cs(823,10): warning CS8618: Null atanamaz alan 'ort', oluŸturucudan ‡kŸ yaparken null olmayan bir de§er i‡ermelidir. alan alann null atanabilir olarak bildirmeyi dŸnn. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] + +OluŸturma BAžARISIZ OLDU. + +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(88,41): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(88,76): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(90,39): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(99,12): warning CS8618: Null atanamaz alan 'm_defaultFunctionEvaluation', oluŸturucudan ‡kŸ yaparken null olmayan bir de§er i‡ermelidir. alan alann null atanabilir olarak bildirmeyi dŸnn. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(156,44): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(156,113): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(157,40): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(157,102): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(157,164): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(194,44): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(194,113): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(195,40): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(195,102): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(195,164): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(242,44): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(242,113): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(243,40): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(243,102): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(243,164): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Matrix.cs(198,21): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Matrix.cs(228,20): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(291,29): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(295,33): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(307,29): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(311,33): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(323,21): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(340,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(352,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(353,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(370,26): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(386,34): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(388,34): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(391,61): warning CS8620: 'object?[]' trndeki ba§msz de§iŸken, baŸvuru trlerinin null atanabilirlik farkllklar nedeniyle 'Symbol Function.EvaluateFunction(string name, params object[] args)' i‡inde 'object[]' trndeki 'args' parametresi i‡in kullanlamaz. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Function.cs(416,24): warning CS8605: Olas bir null de§eri kutudan ‡karma. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\NumericalMethods.cs(427,31): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\NumericalMethods.cs(450,32): warning CS8603: Olas null baŸvuru d”nŸ. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\EigenvalueDecomposition.cs(823,10): warning CS8618: Null atanamaz alan 'H', oluŸturucudan ‡kŸ yaparken null olmayan bir de§er i‡ermelidir. alan alann null atanabilir olarak bildirmeyi dŸnn. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\EigenvalueDecomposition.cs(823,10): warning CS8618: Null atanamaz alan 'ort', oluŸturucudan ‡kŸ yaparken null olmayan bir de§er i‡ermelidir. alan alann null atanabilir olarak bildirmeyi dŸnn. [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] +C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\Matrix.cs(187,73): error CS0103: 'CultureInfo' ad ge‡erli ba§lamda yok [C:\Users\tolga\Desktop\Math\MathApp\MathApp\MathApp.Tests\MathApp.Tests.csproj] + 38 Uyar + 1 Hata + +Ge‡en Sre 00:00:02.21 diff --git a/MathApp/MathApp/MathApp.Tests/out_ascii.txt b/MathApp/MathApp/MathApp.Tests/out_ascii.txt new file mode 100644 index 0000000..f58633a Binary files /dev/null and b/MathApp/MathApp/MathApp.Tests/out_ascii.txt differ diff --git a/MathApp/MathApp/MathApp.Tests/test_results.txt b/MathApp/MathApp/MathApp.Tests/test_results.txt new file mode 100644 index 0000000..f58633a Binary files /dev/null and b/MathApp/MathApp/MathApp.Tests/test_results.txt differ diff --git a/MathApp/MathApp/Program.cs b/MathApp/MathApp/Program.cs new file mode 100644 index 0000000..60b22fd --- /dev/null +++ b/MathApp/MathApp/Program.cs @@ -0,0 +1,18 @@ +using System; +using System.Windows.Forms; + +namespace MathApp +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + ApplicationConfiguration.Initialize(); + Application.Run(new MainForm()); + } + } +} diff --git a/MathApp/MathApp/ThemeHelper.cs b/MathApp/MathApp/ThemeHelper.cs new file mode 100644 index 0000000..633b832 --- /dev/null +++ b/MathApp/MathApp/ThemeHelper.cs @@ -0,0 +1,69 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace MathApp +{ + public static class ThemeHelper + { + // Color Palette + public static Color DarkBackground = Color.FromArgb(32, 32, 32); + public static Color DarkPanel = Color.FromArgb(45, 45, 48); + public static Color LightText = Color.FromArgb(241, 241, 241); + public static Color AccentBlue = Color.FromArgb(0, 122, 204); + public static Color AccentDarkBlue = Color.FromArgb(14, 99, 156); + public static Color BorderColor = Color.FromArgb(63, 63, 70); + + public static void ApplyTheme(Form form) + { + form.BackColor = DarkBackground; + form.ForeColor = LightText; + + ApplyRecursively(form.Controls); + } + + public static void ApplyRecursively(Control.ControlCollection controls) + { + foreach (Control c in controls) + { + if (c is Button btn) + { + btn.FlatStyle = FlatStyle.Flat; + btn.FlatAppearance.BorderSize = 0; + btn.BackColor = DarkPanel; + btn.ForeColor = LightText; + + // Simple hover effect hook if not already handled + // But we don't want to override custom event handlers easily. + // Just set initial properties. + } + else if (c is TextBox txt) + { + txt.BackColor = Color.FromArgb(30, 30, 30); + txt.ForeColor = LightText; + txt.BorderStyle = BorderStyle.FixedSingle; + } + else if (c is Panel pnl) + { + // pnl.BackColor = DarkBackground; // Don't override panel colors if they are structural + // Apply to children + ApplyRecursively(pnl.Controls); + } + else if (c is Label lbl) + { + lbl.ForeColor = LightText; + } + else if (c is GroupBox grp) + { + grp.ForeColor = LightText; + ApplyRecursively(grp.Controls); + } + + if (c.HasChildren && !(c is Panel) && !(c is GroupBox)) + { + ApplyRecursively(c.Controls); + } + } + } + } +} diff --git a/MathApp/MathApp/build_err_main.txt b/MathApp/MathApp/build_err_main.txt new file mode 100644 index 0000000..8e3f13f Binary files /dev/null and b/MathApp/MathApp/build_err_main.txt differ diff --git a/MathApp/MathApp/build_log.txt b/MathApp/MathApp/build_log.txt new file mode 100644 index 0000000..97992be Binary files /dev/null and b/MathApp/MathApp/build_log.txt differ diff --git a/MathApp/MathApp/logo.ico b/MathApp/MathApp/logo.ico new file mode 100644 index 0000000..e4daa72 Binary files /dev/null and b/MathApp/MathApp/logo.ico differ diff --git a/Packages/manifest.json b/Packages/manifest.json new file mode 100644 index 0000000..8c109dd --- /dev/null +++ b/Packages/manifest.json @@ -0,0 +1,43 @@ +{ + "dependencies": { + "com.unity.collab-proxy": "1.14.18", + "com.unity.ide.rider": "1.2.1", + "com.unity.ide.visualstudio": "2.0.15", + "com.unity.ide.vscode": "1.2.5", + "com.unity.test-framework": "1.1.31", + "com.unity.textmeshpro": "2.1.4", + "com.unity.timeline": "1.2.18", + "com.unity.ugui": "1.0.0", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json new file mode 100644 index 0000000..c0c39ee --- /dev/null +++ b/Packages/packages-lock.json @@ -0,0 +1,326 @@ +{ + "dependencies": { + "com.unity.collab-proxy": { + "version": "1.14.18", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ext.nunit": { + "version": "1.0.6", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ide.rider": { + "version": "1.2.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.1" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.visualstudio": { + "version": "2.0.15", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.9" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.vscode": { + "version": "1.2.5", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.test-framework": { + "version": "1.1.31", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.6", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.textmeshpro": { + "version": "2.1.4", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.timeline": { + "version": "1.2.18", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ugui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0" + } + }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.androidjni": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.animation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.assetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.audio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.cloth": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.director": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.animation": "1.0.0" + } + }, + "com.unity.modules.imageconversion": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.imgui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.jsonserialize": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.screencapture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.subsystems": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.terrain": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, + "com.unity.modules.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics2d": "1.0.0" + } + }, + "com.unity.modules.ui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.uielements": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.umbra": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unityanalytics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.unitywebrequest": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unitywebrequestassetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestaudio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.audio": "1.0.0" + } + }, + "com.unity.modules.unitywebrequesttexture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestwww": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.vehicles": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.video": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.vr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } + }, + "com.unity.modules.wind": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.xr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.subsystems": "1.0.0" + } + } + } +} diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..07ebfb0 --- /dev/null +++ b/ProjectSettings/AudioManager.asset @@ -0,0 +1,19 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 1024 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_AmbisonicDecoderPlugin: + m_DisableAudio: 0 + m_VirtualizeEffects: 1 + m_RequestedDSPBufferSize: 1024 diff --git a/ProjectSettings/ClusterInputManager.asset b/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..e7886b2 --- /dev/null +++ b/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..cdc1f3e --- /dev/null +++ b/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_DefaultSolverIterations: 6 + m_DefaultSolverVelocityIterations: 1 + m_QueriesHitBackfaces: 0 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_ClothInterCollisionDistance: 0 + m_ClothInterCollisionStiffness: 0 + m_ContactsGeneration: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_AutoSimulation: 1 + m_AutoSyncTransforms: 0 + m_ReuseCollisionCallbacks: 1 + m_ClothInterCollisionSettingsToggle: 0 + m_ContactPairsMode: 0 + m_BroadphaseType: 0 + m_WorldBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 250, y: 250, z: 250} + m_WorldSubdivisions: 8 + m_FrictionType: 0 + m_EnableEnhancedDeterminism: 0 + m_EnableUnifiedHeightmaps: 1 + m_DefaultMaxAngluarSpeed: 7 diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..40917b0 --- /dev/null +++ b/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: + - enabled: 1 + path: Assets/Scenes/SampleScene.unity + guid: 9fc0d4010bbf28b4594072e72b8655ab + m_configObjects: {} diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..f920544 --- /dev/null +++ b/ProjectSettings/EditorSettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_ExternalVersionControlSupport: Visible Meta Files + m_SerializationMode: 2 + m_LineEndingsForNewScripts: 0 + m_DefaultBehaviorMode: 0 + m_PrefabRegularEnvironment: {fileID: 0} + m_PrefabUIEnvironment: {fileID: 0} + m_SpritePackerMode: 0 + m_SpritePackerPaddingPower: 1 + m_EtcTextureCompressorBehavior: 1 + m_EtcTextureFastCompressor: 1 + m_EtcTextureNormalCompressor: 2 + m_EtcTextureBestCompressor: 4 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref + m_ProjectGenerationRootNamespace: + m_CollabEditorSettings: + inProgressEnabled: 1 + m_EnableTextureStreamingInEditMode: 1 + m_EnableTextureStreamingInPlayMode: 1 + m_AsyncShaderCompilation: 1 + m_EnterPlayModeOptionsEnabled: 0 + m_EnterPlayModeOptions: 3 + m_ShowLightmapResolutionOverlay: 1 + m_UseLegacyProbeSampleCount: 0 + m_AssetPipelineMode: 1 + m_CacheServerMode: 0 + m_CacheServerEndpoint: + m_CacheServerNamespacePrefix: default + m_CacheServerEnableDownload: 1 + m_CacheServerEnableUpload: 1 diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..29dbc66 --- /dev/null +++ b/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,83 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_CustomRenderPipeline: {fileID: 0} + m_TransparencySortMode: 0 + m_TransparencySortAxis: {x: 0, y: 0, z: 1} + m_DefaultRenderingPath: 1 + m_DefaultMobileRenderingPath: 1 + m_TierSettings: + - serializedVersion: 5 + m_BuildTarget: 14 + m_Tier: 0 + m_Settings: + standardShaderQuality: 0 + renderingPath: 1 + hdrMode: 2 + realtimeGICPUUsage: 25 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 + useHDR: 0 + useDetailNormalMap: 0 + useCascadedShadowMaps: 0 + prefer32BitShadowMaps: 0 + enableLPPV: 0 + useDitherMaskForAlphaBlendedShadows: 0 + m_Automatic: 1 + m_LightmapStripping: 0 + m_FogStripping: 0 + m_InstancingStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepShadowMask: 1 + m_LightmapKeepSubtractive: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 + m_AlbedoSwatchInfos: [] + m_LightsUseLinearIntensity: 0 + m_LightsUseColorTemperature: 0 + m_LogWhenShaderIsCompiled: 0 + m_AllowEnlightenSupportForUpgradedProject: 0 diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..17c8f53 --- /dev/null +++ b/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/ProjectSettings/NavMeshAreas.asset b/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3b0b7c3 --- /dev/null +++ b/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshProjectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + m_LastAgentTypeID: -887442657 + m_Settings: + - serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.75 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_SettingNames: + - Humanoid diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset new file mode 100644 index 0000000..6920e3a --- /dev/null +++ b/ProjectSettings/PackageManagerSettings.asset @@ -0,0 +1,38 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 61 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} + m_Name: + m_EditorClassIdentifier: + m_ScopedRegistriesSettingsExpanded: 1 + oneTimeWarningShown: 0 + m_Registries: + - m_Id: main + m_Name: + m_Url: https://packages.unity.com + m_Scopes: [] + m_IsDefault: 1 + m_UserSelectedRegistryName: + m_UserAddingNewScopedRegistry: 0 + m_RegistryInfoDraft: + m_ErrorMessage: + m_Original: + m_Id: + m_Name: + m_Url: + m_Scopes: [] + m_IsDefault: 0 + m_Modified: 0 + m_Name: + m_Url: + m_Scopes: + - + m_SelectedScopeIndex: 0 diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..47880b1 --- /dev/null +++ b/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,56 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 4 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_DefaultContactOffset: 0.01 + m_JobOptions: + serializedVersion: 2 + useMultithreading: 0 + useConsistencySorting: 0 + m_InterpolationPosesPerJob: 100 + m_NewContactsPerJob: 30 + m_CollideContactsPerJob: 100 + m_ClearFlagsPerJob: 200 + m_ClearBodyForcesPerJob: 200 + m_SyncDiscreteFixturesPerJob: 50 + m_SyncContinuousFixturesPerJob: 50 + m_FindNearestContactsPerJob: 100 + m_UpdateTriggerContactsPerJob: 100 + m_IslandSolverCostThreshold: 100 + m_IslandSolverBodyCostScale: 1 + m_IslandSolverContactCostScale: 10 + m_IslandSolverJointCostScale: 10 + m_IslandSolverBodiesPerJob: 50 + m_IslandSolverContactsPerJob: 50 + m_AutoSimulation: 1 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_CallbacksOnDisable: 1 + m_ReuseCollisionCallbacks: 1 + m_AutoSyncTransforms: 0 + m_AlwaysShowColliders: 0 + m_ShowColliderSleep: 1 + m_ShowColliderContacts: 0 + m_ShowColliderAABB: 0 + m_ContactArrowScale: 0.2 + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/ProjectSettings/PresetManager.asset b/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..67a94da --- /dev/null +++ b/ProjectSettings/PresetManager.asset @@ -0,0 +1,7 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_DefaultPresets: {} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..4965625 --- /dev/null +++ b/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,672 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 20 + productGUID: d8b1de0afd9b5b14189c97dce69ab4d0 + AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: DefaultCompany + productName: Math + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 0 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 0 + m_MTRendering: 1 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + iosUseCustomAppBackgroundBehavior: 0 + iosAllowHTTPDownload: 1 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 + disableDepthAndStencilBuffers: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidUseSwappy: 0 + androidBlitType: 0 + defaultIsNativeResolution: 1 + macRetinaSupport: 1 + runInBackground: 1 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + useFlipModelSwapchain: 1 + resizableWindow: 0 + useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games + gpuSkinning: 1 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 1 + allowFullscreenSwitch: 1 + fullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 + xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + xboxOneDisableEsram: 0 + xboxOneEnableTypeOptimization: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 0 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + switchNVNMaxPublicTextureIDCount: 0 + switchNVNMaxPublicSamplerIDCount: 0 + stadiaPresentMode: 0 + stadiaTargetFramerate: 0 + vulkanNumSwapchainBuffers: 3 + vulkanEnableSetSRGBWrite: 0 + vulkanEnableLateAcquireNextImage: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleVersion: 0.1 + preloadedAssets: [] + metroInputSource: 0 + wsaTransparentSwapchain: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 1 + xboxOneEnable7thCore: 1 + vrSettings: + cardboard: + depthFormat: 0 + enableTransitionView: 0 + daydream: + depthFormat: 0 + useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 + hololens: + depthFormat: 1 + depthBufferSharingEnabled: 1 + lumin: + depthFormat: 0 + frameTiming: 2 + enableGLCache: 0 + glCacheMaxBlobSize: 524288 + glCacheMaxFileSize: 8388608 + oculus: + sharedDepthBuffer: 1 + dashSupport: 1 + lowOverheadMode: 0 + protectedContext: 0 + v2Signing: 1 + enable360StereoCapture: 0 + isWsaHolographicRemotingEnabled: 0 + enableFrameTimingStats: 0 + useHDRDisplay: 0 + D3DHDRBitDepth: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 + resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: + Standalone: com.TAN.Math + buildNumber: {} + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 19 + AndroidTargetSdkVersion: 0 + AndroidPreferredInstallLocation: 1 + aotOptions: + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + keepLoadedShadersAlive: 0 + StripUnusedMeshComponents: 1 + VertexChannelCompressionMask: 4054 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: 10.0 + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 10.0 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] + tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] + tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: + iOSDeviceRequirements: [] + iOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 1 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 0 + iosCopyPluginsCodeInsteadOfSymlink: 0 + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 + appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 + clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea + templatePackageId: com.unity.template.3d@4.2.8 + templateDefaultScene: Assets/Scenes/SampleScene.unity + AndroidTargetArchitectures: 1 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: + AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 + AndroidTVCompatibility: 0 + AndroidIsGame: 1 + AndroidEnableTango: 0 + androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 + m_BuildTargetIcons: [] + m_BuildTargetPlatformIcons: [] + m_BuildTargetBatching: + - m_BuildTarget: Standalone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: tvOS + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: Android + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: iPhone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: WebGL + m_StaticBatching: 0 + m_DynamicBatching: 0 + m_BuildTargetGraphicsJobs: + - m_BuildTarget: MacStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: Switch + m_GraphicsJobs: 1 + - m_BuildTarget: MetroSupport + m_GraphicsJobs: 1 + - m_BuildTarget: AppleTVSupport + m_GraphicsJobs: 0 + - m_BuildTarget: BJMSupport + m_GraphicsJobs: 1 + - m_BuildTarget: LinuxStandaloneSupport + m_GraphicsJobs: 1 + - m_BuildTarget: PS4Player + m_GraphicsJobs: 1 + - m_BuildTarget: iOSSupport + m_GraphicsJobs: 0 + - m_BuildTarget: WindowsStandaloneSupport + m_GraphicsJobs: 1 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobs: 1 + - m_BuildTarget: LuminSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AndroidPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: WebGLSupport + m_GraphicsJobs: 0 + m_BuildTargetGraphicsJobMode: + - m_BuildTarget: PS4Player + m_GraphicsJobMode: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobMode: 0 + m_BuildTargetGraphicsAPIs: + - m_BuildTarget: AndroidPlayer + m_APIs: 150000000b000000 + m_Automatic: 0 + - m_BuildTarget: iOSSupport + m_APIs: 10000000 + m_Automatic: 1 + - m_BuildTarget: AppleTVSupport + m_APIs: 10000000 + m_Automatic: 0 + - m_BuildTarget: WebGLSupport + m_APIs: 0b000000 + m_Automatic: 1 + m_BuildTargetVRSettings: + - m_BuildTarget: Standalone + m_Enabled: 0 + m_Devices: + - Oculus + - OpenVR + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + openGLRequireES32: 0 + m_TemplateCustomTags: {} + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupLightmapSettings: [] + playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchTouchScreenUsage: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchRatingsInt_12: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 + switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 + switchSupportedNpadStyles: 22 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 11 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 + ps4VideoOutReprojectionRate: 60 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4ExtraSceSysFile: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 + ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4UseLowGarlicFragmentationMode: 1 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4CompatibilityPS5: 0 + ps4GPU800MHz: 1 + ps4attribEyeToEyeDistanceSettingVR: 0 + ps4IncludedModules: [] + ps4attribVROutputEnabled: 0 + monoEnv: + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 + spritePackerPolicy: + webGLMemorySize: 16 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLDataCaching: 1 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 + webGLWasmStreaming: 0 + scriptingDefineSymbols: {} + platformArchitecture: {} + scriptingBackend: {} + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} + incrementalIl2cppBuild: {} + allowUnsafeCode: 0 + additionalIl2CppArgs: + scriptingRuntimeVersion: 1 + gcIncremental: 0 + assemblyVersionValidation: 1 + gcWBarrierValidation: 0 + apiCompatibilityLevelPerPlatform: {} + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: Template_3D + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: Template_3D + wsaImages: {} + metroTileShortName: Math + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 2 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, + a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroTargetDeviceFamilies: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnhancedXboxCompatibilityMode: 0 + XboxOneEnableGPUVariability: 1 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 + XboxOneOverrideIdentityName: + XboxOneOverrideIdentityPublisher: + vrEditorSettings: + daydream: + daydreamIconForeground: {fileID: 0} + daydreamIconBackground: {fileID: 0} + cloudServicesEnabled: + UNet: 1 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_SignPackage: 1 + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: + apiCompatibilityLevel: 6 + cloudProjectId: + framebufferDepthMemorylessMode: 0 + projectName: + organizationId: + cloudEnabled: 0 + enableNativePlatformBackendsForNewInputSystem: 0 + disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..a3c678a --- /dev/null +++ b/ProjectSettings/ProjectVersion.txt @@ -0,0 +1,2 @@ +m_EditorVersion: 2019.4.41f1 +m_EditorVersionWithRevision: 2019.4.41f1 (fb553f8fdd6c) diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..7b7658d --- /dev/null +++ b/ProjectSettings/QualitySettings.asset @@ -0,0 +1,232 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Very Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Medium + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 1 + lodBias: 0.7 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: High + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Very High + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Ultra + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 2 + Lumin: 5 + Nintendo 3DS: 5 + Nintendo Switch: 5 + PS4: 5 + PSP2: 2 + Stadia: 5 + Standalone: 5 + WebGL: 3 + Windows Store Apps: 5 + XboxOne: 5 + iPhone: 2 + tvOS: 2 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..1c92a78 --- /dev/null +++ b/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..558a017 --- /dev/null +++ b/ProjectSettings/TimeManager.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.33333334 + m_TimeScale: 1 + Maximum Particle Timestep: 0.03 diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..fa0b146 --- /dev/null +++ b/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 1 + m_Enabled: 0 + m_TestMode: 0 + m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events + m_EventUrl: https://cdp.cloud.unity3d.com/v1/events + m_ConfigUrl: https://config.uca.cloud.unity3d.com + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com + m_Enabled: 0 + m_LogBufferSize: 10 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 0 + m_TestMode: 0 + m_InitializeOnStartup: 1 + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 diff --git a/ProjectSettings/VFXManager.asset b/ProjectSettings/VFXManager.asset new file mode 100644 index 0000000..3a95c98 --- /dev/null +++ b/ProjectSettings/VFXManager.asset @@ -0,0 +1,12 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!937362698 &1 +VFXManager: + m_ObjectHideFlags: 0 + m_IndirectShader: {fileID: 0} + m_CopyBufferShader: {fileID: 0} + m_SortShader: {fileID: 0} + m_StripUpdateShader: {fileID: 0} + m_RenderPipeSettingsPath: + m_FixedTimeStep: 0.016666668 + m_MaxDeltaTime: 0.05 diff --git a/ProjectSettings/XRSettings.asset b/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file