Distributed-memory dense and sparse-direct linear algebra and optimization