rescale matrix A and data g