fix set-nd bug with AMatrix