Author Archives: Julia on EPH

Learning algorithmic techniques: dynamic programming

By: Julia on EPH

Re-posted from: https://ericphanson.com/blog/2019/learning-algorithmic-techniques-dynamic-programming/

Three nice techniques In the past months, I’ve found myself really appreciating some nice techniques for constructing algorithms. These are probably quite familiar to those with a computer science background, but are new to me. There are three in particular that I have in mind; I’ll just highlight the first two here, and then discuss the third in detail.
The first such technique I learned about was solving the traveling salesman problem via mixed-integer programming, using lazy constraints.

Another example of using type domain information in Julia

By: Julia on EPH

Re-posted from: https://ericphanson.com/blog/2019/another-example-of-using-type-domain-information-in-julia/

In a previous post, I discussed using type domain information to speed up generation of random density matrices with small dimension in Julia. There, we gave the Julia compiler knowledge of the dimension of the matrices at the time it generates code, instead of passing that dimension as a runtime variable, and saw significant runtime speedups as a consequence. This time, let’s push this further by giving the compiler a whole vector of numbers instead of a single integer.

Fast small random density matrices

By: Julia on EPH

Re-posted from: https://ericphanson.com/blog/2018/fast-small-random-density-matrices/

Update (19 January 2019): I looked at this code again, and realized I had made a few basic mistakes, such as constructing a statically sized normally-distributed random matrix via SMatrix{d,d,Float64, d*d}(randn(Float64, d,d)) which constructs a random matrix (allocating memory dynamically) and then converts it to a static SMatrix, instead of randn(SMatrix{d,d,Float64}) which directly constructs an SMatrix without dynamic memory allocation. I also hadn’t written the function randsimplexpt in a very good way.