Added casts to long at any ncols*nrows.  Suspect an integer overflow.