redid matrix lib