A linear code for the sawtooth and cat maps