Adding valid() and index(n) methods to NDIterator.

Define method bool valid() which tests if the iterator's operator* references a valid tensor element.
Define method const shape_type::value_type& index(const size_type& n) const method which returns the nth index of the iterator.

Also pulls in some patches that were merged into BTAS/BTAS.