-
-
Save George9000/1f2ea7734c3198c263fda861d9e27af0 to your computer and use it in GitHub Desktop.
Julia file used as an example for unicode glyphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 โ [1, 2, 3] | |
f โ g(x) | |
function hom(v::SVector) | |
push(v,1) | |
end | |
function T(๐::AbstractArray, ๐::Tuple{AbstractArray, Vararg{AbstractArray}}, ๐::Tuple{AbstractArray, Vararg{AbstractArray}}) | |
โ = kron | |
l = length(๐) | |
๐โ = SMatrix{l,l}(1.0I) | |
๐โ = SMatrix{1,1}(1.0I) | |
๐ = @SMatrix zeros(l,l) | |
N = length(๐[1]) | |
โณ, โณสน = ๐ | |
ฮโ, ฮโ = ๐ | |
๐ฒโ = @MMatrix zeros(4,4) | |
๐โ = @SMatrix [1.0; 0.0; 0.0] | |
๐โ = @SMatrix [0.0; 1.0; 0.0] | |
for n = 1: N | |
index = SVector(1,2) | |
๐ฒโ[1:2,1:2] .= ฮโ[n][index,index] | |
๐ฒโ[3:4,3:4] .= ฮโ[n][index,index] | |
๐ฆ = hom(โณ[n]) | |
๐ฆสน= hom(โณสน[n]) | |
๐โ = (๐ฆ โ ๐ฆสน) | |
โโ๐ฎโ = [(๐โ โ ๐ฆสน) (๐โ โ ๐ฆสน) (๐ฆ โ ๐โ) (๐ฆ โ ๐โ)] | |
๐โ = โโ๐ฎโ * ๐ฒโ * โโ๐ฎโ' | |
๐บโ = ๐' * ๐โ * ๐ | |
๐บโโปยน = inv(๐บโ) | |
๐โ = @SMatrix zeros(Float64,l,l) | |
for k = 1:l | |
๐โ = ๐โ[:,k] | |
โ๐โ๐บโ = (๐โ โ ๐โ') * ๐โ * (๐โ โ ๐) + (๐โ โ ๐') * ๐โ * (๐โ โ ๐โ) | |
# Accumulating the result in ๐โ allocates memory, even though | |
# the two terms in the summation are both SArrays. | |
๐โ = ๐โ + ๐โ * ๐บโโปยน * (โ๐โ๐บโ) * ๐บโโปยน * ๐โ' * ๐ * ๐โ' | |
end | |
๐ = ๐ + ๐โ | |
end | |
๐ | |
end | |
# Some sample data | |
N = 300 | |
โณ = [@SVector rand(2) for i = 1:N] | |
โณสน = [@SVector rand(2) for i = 1:N] | |
ฮโ = [SMatrix{3,3}(Matrix(Diagonal([1.0,1.0,0.0]))) for i = 1:length(โณ)] | |
ฮโ = [SMatrix{3,3}(Matrix(Diagonal([1.0,1.0,0.0]))) for i = 1:length(โณ)] | |
F = @SMatrix rand(3,3) | |
๐ = (ฮโ,ฮโ) | |
๐ = (โณ, โณสน) | |
T(vec(F),๐,๐) | |
@btime T(vec($F),$๐,$๐) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment