translation to linear matrix code passes simple tests