Fix bugs in magma and cusparse bindings reported by Dr. Feng Wang.