ENH: speed-up of triangular matrix functions

* `np.tri` now produces less intermediate arrays. Runs about 40% faster for
  general dtypes, up to 3x faster for boolean arrays.
* `np.tril` now does smarter type conversions (thanks Julian!), and together
  with the improvements in `np.tri` now runs about 30% faster. `np.triu`
  runs almost 2x faster than before, but still runs 20% slower than
  `np.tril`, which is an improvement over the 50% difference before.
* `np.triu_indices` and `np.tril_indices` do not call `np.mask_indices`,
  instead they call `np.where` directly on a boolean array created with
  `np.tri`. They now run roughly 2x faster.
* Removed the constraint for the array to be square in calls to
  `np.triu_indices`, `np.tril_indices`, `np.triu_indices_from` and
  `np.tril_indices_from`.
Merge pull request #4509 from jaimefrio/twodim-speedup

ENH: speed-up of triangular matrix functions