changed ldm.r: does not compute inverse