Author jbrea
1 Star
Updated Last
8 Months Ago
Started In
October 2018


Efficient growing and shrinking of positive definite matrices thanks to preallocated memory.

Lifecycle Build Status codecov.io


In addition to the functions defined in the common PDMats interface, ElasticPDMat <: AbstractPDMat can grow with append!

a = rand(10, 10); m = a'a; 
e = ElasticPDMat(m[1:8, 1:8))
append!(e, m[:, 9:10])

and shrink with deleteat!

deleteat!(e, [3, 8, 7])

Growing and shrinking is usually efficient, because no entries are recomputed and (basically no) new memory needs to be allocated. ElasticMat(capacity = 10^3, stepsize = 10^3) allocates capacity x capacity matrices and creates (initially 0-dimensional) views to represent positive definite matrices. Whenever the current capacity is reached, e.g. due to several append! operations, the capacity increases to capacity += stepsize. Caution: increasing the capacity involves allocating new memory and copying old values, which is slow. For optimal performance, the capacity and the stepsize should be chosen wisely. For an already initialized e = ElasticPDMat() they can be set with the helper functions setcapacity!(e, 100) and setstepsize!(e, 100).

Additionally to ElasticPDMat this package exports view based elastic arrays of any dimension AllElasticArray, ElasticSymmetricMatrix, ElasticCholesky and the helper functions setcapacity!, setstepsize! and setdimension!.

Required Packages