`rand` sampling from an array accepts an optional rng

Fixes #5978.
Optimize pinv for diagonal matrices

In general, the pseudoinverse is determined to only half of the machine
precision for general dense ill-conditioned matrices. For diagonal and
certain other matrices (e.g., tridiagonal matrices), the pseudoinverse
can be determined more accurately. We try to detect if the matrix is
diagonal immediately after the call to pinv and invert the diagonal elements
only whithout invoking ths svdfact function which is both faster and
more accurate.

Since the default threshold can not be determined in advance for arbitrary
matrices, provide a user-selectable parameter tol and provide a simple
scheme for automatic threshold selection.

pinv(A) sets the threshold tol to eps(one(T))*maximum(size(A)).

pinv(A,tol) sets the user-selectable threshold tol.

pinv(A,0) attempts to determine the threshold tol by forming two pseudoinverses
for tol=eps(one(T))*maximum(size(A)) and tol=sqrt(eps(one(T)) and estimating
the error in the first Moore-Penrose relation a*pinv(a)*a = a. This can be done
with very little overhead (since svdvals is an expensive call) while using
about twice as much intermediate memory.

Add pinv method for Diagonal type.

Check and fix zero and sub-normal matrices.
Merge pull request #9065 from JuliaLang/rf/rand-ranges-use-mt

`rand` sampling from an array accepts an optional rng
New debug flag MEMNOFREE that disables all calls to free
Remove unused function jl_gc_counted_realloc

Its cousin jl_gc_counted_realloc_with_old_size remains.
Merge pull request #9008 from zgimbutas/optimize-pinv

Optimize pinv for diagonal matrices
Correct "touch" option

--no-create does not exist on OS X; use -c instead
Merge branch 'touch-no-create'
Merge branch 'memnofree'
Merge branch 'no-counted-realloc'