Abstract: Methods and devices for encoding a sparse signal x to generate a compressed encoded signal. The methods employ directionless grammar-based dimension coding. Using labelled subsets and the finding of disjoint repeated subsets in order to build a directionless grammar, the non-zero positions of the sparse signal are encoded in a directionless grammar-based dimension encoder. Element values are encoded in a conditional non-zero encoder. The coding process facilitates random access.