I love the generically sized I
as the UniformScaling
operator in Julia. It makes linear algebra code elegant (and I suspect either efficient now or in the future)
Another common element that comes up in linear algebra are vectors of 1s and vectors of 0s which you want to be generically sized. For a nice symbol people could add, the common \mathbf{1} or \mathbf{0} although sometimes \vec{1} and others are used and appear to be in https://docs.julialang.org/en/release-0.4/manual/unicode-input/
Written generically, a function that comes up in asset pricing of a discrete markov chain looks something like
n = 2
β = 0.9
A = rand(n,n)
onevec = ones(n,1)
inv(I - β *A) * onevec
This could be rewritten with something like this as
n = 2
β = 0.9
A = rand(n,n)
inv(I - β *A) * 𝟏
Not only is the size of the onevec unnecessary, but I can imagine there are behind-the-scenes optimizations that could happen with more complicated code than this.
Similarly, the 𝟏 and 𝟎 come up all the time when stacking up matrices. For example,
A = rand(2,2)
B = rand(3,1)
c = 4
zerovec = zeros(2,1)
onemat = ones(3,2)
D = [A zerovec;
c zerovec';
onemat B]
could become
A = rand(2,2)
B = rand(3,1)
c = 4
D = [ A 𝟎;
c 𝟎;
𝟏 B]
Any thoughts on whether this could be written and makes sense? I wasn’t sure if this was the sort of thing covered by https://github.com/JuliaLang/julia/issues/24595 althought I couldn’t tell if the oneunit
was implemented (and it didn’t seem to be generically size).