From 439cdbf74601c9269fa979f34d4b5986a6942e77 Mon Sep 17 00:00:00 2001 From: Aron T Date: Thu, 19 Sep 2024 22:10:48 +0300 Subject: [PATCH 1/5] fix reflection --- src/linear_algebra.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/linear_algebra.jl b/src/linear_algebra.jl index 82e74a9..aa66f26 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra.jl @@ -81,10 +81,10 @@ end """ function reflection(v::Vector, w::Vector) -> Vector -The projection P from 'w' onto 'v' is the midpoint of the reflection of w around v +The projection P from 'v' to the line along [1,2] is the midpoint of the reflection of w around v """ -function reflection(v::Vector, w::Vector) - P = orthproj(v,w) +function reflection(v::Vector) + P = orthproj([1,2],v) (2 * P ) - X end From 75f45204d5bdb1bab9791c32be9365b98bc9a06e Mon Sep 17 00:00:00 2001 From: Aron T Date: Sat, 21 Sep 2024 12:54:50 +0300 Subject: [PATCH 2/5] rename basics --- src/{linear_algebra.jl => linear_algebra_basic.jl} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename src/{linear_algebra.jl => linear_algebra_basic.jl} (97%) diff --git a/src/linear_algebra.jl b/src/linear_algebra_basic.jl similarity index 97% rename from src/linear_algebra.jl rename to src/linear_algebra_basic.jl index aa66f26..e767bd5 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra_basic.jl @@ -81,11 +81,11 @@ end """ function reflection(v::Vector, w::Vector) -> Vector -The projection P from 'v' to the line along [1,2] is the midpoint of the reflection of w around v +The midpoint of the segment from `v` to the reflection of `v` is the projection P from 'v' to the line along 'w' """ -function reflection(v::Vector) - P = orthproj([1,2],v) - (2 * P ) - X +function reflection(v::Vector,w::Vector) + P = orthproj(w,v) + (2 * P ) - w end """ @@ -279,3 +279,4 @@ function intersection_2_implicit_lines(a₁::Number, b₁::Number, c₁::Number, # solve the system using left division of the matrix by the vector A\b end + From 0aecae9dc3c667e7d822115fe66c2d14c7e8156a Mon Sep 17 00:00:00 2001 From: Aron T Date: Sat, 21 Sep 2024 13:11:29 +0300 Subject: [PATCH 3/5] projection matrix --- src/linear_algebra_transform.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/linear_algebra_transform.jl diff --git a/src/linear_algebra_transform.jl b/src/linear_algebra_transform.jl new file mode 100644 index 0000000..b8abdfb --- /dev/null +++ b/src/linear_algebra_transform.jl @@ -0,0 +1,15 @@ +using Symbolics +include("./linear_algebra_basic.jl") + +""" + function projection_matrix_symbolic() -> Matrix +Create matrix for projection on [u, v] using E₁ = [1,0] and E₂ =[0,1] +""" +function projection_matrix_symbolic() + [orthproj([u, v], [1, 0])[1] orthproj([u, v], [1, 0])[2]; orthproj([u, v], [0, 1])[1] orthproj([u, v], [0, 1])[2]] +end + +function projection_matrix(x::Vector) + Symbolics.value.(substitute.(projection_matrix_symbolic(), (Dict(u =>x[1], v=> x[2]), ))) +end + From b7d0d1545d6687b929504baf81e62d0d67fbd0b2 Mon Sep 17 00:00:00 2001 From: Aron T Date: Sat, 21 Sep 2024 13:40:11 +0300 Subject: [PATCH 4/5] projextion matrix symbolic polar --- src/linear_algebra_transform.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/linear_algebra_transform.jl b/src/linear_algebra_transform.jl index b8abdfb..6ee1fc0 100644 --- a/src/linear_algebra_transform.jl +++ b/src/linear_algebra_transform.jl @@ -1,15 +1,22 @@ using Symbolics include("./linear_algebra_basic.jl") +@variables u v """ function projection_matrix_symbolic() -> Matrix -Create matrix for projection on [u, v] using E₁ = [1,0] and E₂ =[0,1] +Create symbolic matrix for projection on [u, v] using E₁ = [1,0] and E₂ =[0,1] to get first and second row """ function projection_matrix_symbolic() - [orthproj([u, v], [1, 0])[1] orthproj([u, v], [1, 0])[2]; orthproj([u, v], [0, 1])[1] orthproj([u, v], [0, 1])[2]] + [orthproj([u, v], [1, 0])[1] orthproj([u, v], [0, 1])[1]; orthproj([u, v], [1, 0])[2] orthproj([u, v], [0, 1])[2]] end +function projection_matrix_symbolic_polar() + simplify.(substitute.(projection_matrix_symbolic(),(Dict(u => cos(θ), v => sin(θ)),))) +end +""" + function projection_matrix(x::Vector) -> Matrix +value of Matrix with an actual x +""" function projection_matrix(x::Vector) Symbolics.value.(substitute.(projection_matrix_symbolic(), (Dict(u =>x[1], v=> x[2]), ))) end - From 1ae305b7ee290ce036e8b026d607664321cc8a23 Mon Sep 17 00:00:00 2001 From: Aron T Date: Sat, 21 Sep 2024 15:30:57 +0300 Subject: [PATCH 5/5] 20240921 update --- Manifest.toml | 58 +++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index f2e79d0..d093e6e 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -5,9 +5,9 @@ manifest_format = "2.0" project_hash = "f55cdbfce13a30a8b925c0d3d45ee9001a4d7fba" [[deps.ADTypes]] -git-tree-sha1 = "99a6f5d0ce1c7c6afdb759daa30226f71c54f6b0" +git-tree-sha1 = "5a5eafb8344b81b8c2237f8a6f6b3602b3f6180e" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" -version = "1.7.1" +version = "1.8.1" [deps.ADTypes.extensions] ADTypesChainRulesCoreExt = "ChainRulesCore" @@ -28,24 +28,28 @@ uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" version = "0.4.5" [[deps.Accessors]] -deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "LinearAlgebra", "MacroTools", "Markdown", "Test"] -git-tree-sha1 = "f61b15be1d76846c0ce31d3fcfac5380ae53db6a" +deps = ["CompositionsBase", "ConstructionBase", "InverseFunctions", "LinearAlgebra", "MacroTools", "Markdown"] +git-tree-sha1 = "b392ede862e506d451fc1616e79aa6f4c673dab8" uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" -version = "0.1.37" +version = "0.1.38" [deps.Accessors.extensions] AccessorsAxisKeysExt = "AxisKeys" + AccessorsDatesExt = "Dates" AccessorsIntervalSetsExt = "IntervalSets" AccessorsStaticArraysExt = "StaticArrays" AccessorsStructArraysExt = "StructArrays" + AccessorsTestExt = "Test" AccessorsUnitfulExt = "Unitful" [deps.Accessors.weakdeps] AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5" + Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" Requires = "ae029012-a4dd-5104-9daa-d747884805df" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [[deps.Adapt]] @@ -128,9 +132,9 @@ version = "1.18.0+2" [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra"] -git-tree-sha1 = "71acdbf594aab5bbb2cec89b208c41b4c411e49f" +git-tree-sha1 = "3e4b134270b372f2ed4d4d0e936aabaefc1802bc" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.24.0" +version = "1.25.0" weakdeps = ["SparseArrays"] [deps.ChainRulesCore.extensions] @@ -651,9 +655,9 @@ version = "3.0.0+1" [[deps.LLVMOpenMP_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "e16271d212accd09d52ee0ae98956b8a05c4b626" +git-tree-sha1 = "78211fb6cbc872f77cad3fc0b6cf647d923f4929" uuid = "1d63c593-3942-5779-bab2-d838dc0a180e" -version = "17.0.6+0" +version = "18.1.7+0" [[deps.LZO_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] @@ -1037,9 +1041,9 @@ version = "6.7.1+1" [[deps.QuadGK]] deps = ["DataStructures", "LinearAlgebra"] -git-tree-sha1 = "1d587203cf851a51bf1ea31ad7ff89eff8d625ea" +git-tree-sha1 = "cda3b045cf9ef07a08ad46731f5a3165e56cf3da" uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" -version = "2.11.0" +version = "2.11.1" [deps.QuadGK.extensions] QuadGKEnzymeExt = "Enzyme" @@ -1123,15 +1127,15 @@ version = "1.3.0" [[deps.Rmath]] deps = ["Random", "Rmath_jll"] -git-tree-sha1 = "f65dcb5fa46aee0cf9ed6274ccbd597adc49aa7b" +git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4" uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" -version = "0.7.1" +version = "0.8.0" [[deps.Rmath_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "e60724fd3beea548353984dc61c943ecddb0e29a" +git-tree-sha1 = "58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8" uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f" -version = "0.4.3+0" +version = "0.5.1+0" [[deps.RuntimeGeneratedFunctions]] deps = ["ExprTools", "SHA", "Serialization"] @@ -1145,9 +1149,9 @@ version = "0.7.0" [[deps.SciMLBase]] deps = ["ADTypes", "Accessors", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "Expronicon", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"] -git-tree-sha1 = "85db52701c4f9044a6ebe5887948443bcca3626d" +git-tree-sha1 = "82584ea03bda16156ceaa6af75f9c8e1287029d3" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" -version = "2.52.1" +version = "2.53.2" [deps.SciMLBase.extensions] SciMLBaseChainRulesCoreExt = "ChainRulesCore" @@ -1207,9 +1211,9 @@ uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" version = "1.0.3" [[deps.SimpleBufferStream]] -git-tree-sha1 = "874e8867b33a00e784c8a7e4b60afe9e037b74e1" +git-tree-sha1 = "f305871d2f381d21527c770d4788c06c097c9bc1" uuid = "777ac1f9-54b0-4bf8-805c-2214025038e7" -version = "1.1.0" +version = "1.2.0" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -1270,9 +1274,9 @@ version = "0.34.3" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] -git-tree-sha1 = "cef0472124fab0695b58ca35a77c6fb942fdab8a" +git-tree-sha1 = "b423576adc27097764a90e163157bcfc9acf0f46" uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" -version = "1.3.1" +version = "1.3.2" weakdeps = ["ChainRulesCore", "InverseFunctions"] [deps.StatsFuns.extensions] @@ -1315,9 +1319,9 @@ version = "0.2.2" [[deps.SymbolicUtils]] deps = ["AbstractTrees", "ArrayInterface", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "TermInterface", "TimerOutputs", "Unityper"] -git-tree-sha1 = "9d983078d9e99421fcca44c373e4304b8421fdde" +git-tree-sha1 = "3927e02dc7648a45ec6aa592bcd8374094a44740" uuid = "d1185830-fcd6-423d-90d6-eec64667417b" -version = "3.6.0" +version = "3.7.1" [deps.SymbolicUtils.extensions] SymbolicUtilsLabelledArraysExt = "LabelledArrays" @@ -1329,14 +1333,14 @@ version = "3.6.0" [[deps.Symbolics]] deps = ["ADTypes", "ArrayInterface", "Bijections", "CommonWorldInvalidations", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "IfElse", "LaTeXStrings", "LambertW", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "PrecompileTools", "Primes", "RecipesBase", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArraysCore", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"] -git-tree-sha1 = "5dfc8740670144385c76517388598bd859410034" +git-tree-sha1 = "8b48697e7fec6d4b7c4a9fe892857a5ed2bae7e8" uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7" -version = "6.6.0" +version = "6.12.0" [deps.Symbolics.extensions] SymbolicsForwardDiffExt = "ForwardDiff" SymbolicsGroebnerExt = "Groebner" - SymbolicsLuxCoreExt = "LuxCore" + SymbolicsLuxExt = "Lux" SymbolicsNemoExt = "Nemo" SymbolicsPreallocationToolsExt = ["PreallocationTools", "ForwardDiff"] SymbolicsSymPyExt = "SymPy" @@ -1344,7 +1348,7 @@ version = "6.6.0" [deps.Symbolics.weakdeps] ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" Groebner = "0b43b601-686d-58a3-8a1c-6623616c7cd4" - LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623" + Lux = "b2108857-7c20-44ae-9111-449ecde12c47" Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a" PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46" SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"