BTAS/BTAS — pull request #30 by emstoudenmire (2014-01-31 21:41:55+00:00)
Title: Fixed major StorageRef bug. Created diag, group, and flatten Range/TensorView slicing methods.

Found and fixed a major StorageRef related bug that came up e.g. when using permute to create a TensorView, then assigning that TensorView to a new Tensor. The bug was that StorageRef was automatically converting to nonconst_storage_type, creating a temporary that was getting plugged into the StorageRef constructor only to then vanish leaving a pair of invalid iterators.

Also created the following Range slicing methods and related TensorView slicing methods:
* diag(r): take the diagonal part of a Range r, i.e. Range values where all indices are equal
* group(r,istart,iend): group a set of adjacent indices [istart,iend) into a new combined index
* flatten(r): similar to group but group all indices into one

Possible issues/future improvements: currently even if the input Range to group has a lobound != {0,0,0,...} the grouped index still starts at 0. This may be ok (doesn't lead to any index out-of-range errors) but masks some information about the original Range.