*/
const Tensor<rank_-1,dim,Number> &operator [] (const unsigned int i) const;
+ /**
+ * Read access using TableIndices <tt>indices</tt>
+ */
+ Number operator [](const TableIndices<rank_> & indices) const;
+
+ /**
+ * Read and write access using TableIndices <tt>indices</tt>
+ */
+ Number &operator [](const TableIndices<rank_> & indices);
+
/**
* Assignment operator.
*/
return subtensor[i];
}
+template <int rank_, int dim, typename Number>
+inline
+Number
+Tensor<rank_,dim,Number>::operator[] (const TableIndices<rank_> & indices) const
+{
+ const unsigned int outer_ind = indices[rank_-1];
+ TableIndices<rank_-1> indices1;
+ for (unsigned int i = 0; i < rank_-1;i++)
+ indices1[i] = indices[i];
+ return (subtensor[outer_ind])[indices1];
+}
+template <int rank_, int dim, typename Number>
+inline
+Number &
+Tensor<rank_,dim,Number>::operator[] (const TableIndices<rank_> & indices)
+{
+ const unsigned int outer_ind = indices[rank_-1];
+ TableIndices<rank_-1> indices1;
+ for (unsigned int i = 0; i < rank_-1;i++)
+ indices1[i] = indices[i];
+ return (subtensor[outer_ind])[indices1];
+}
template <int rank_, int dim, typename Number>
inline
* backcompatibility.
*/
Number &operator [] (const unsigned int index);
+
+ /**
+ * Read access using TableIndices <tt>indices</tt>
+ */
+ Number operator [](const TableIndices<1> & indices) const;
+
+ /**
+ * Read and write access using TableIndices <tt>indices</tt>
+ */
+ Number &operator [](const TableIndices<1> & indices);
/**
* Assignment operator.
return values[index];
}
+template <int dim, typename Number>
+inline
+Number Tensor<1,dim,Number>::operator [] (const TableIndices<1> & indices) const
+{
+ Assert (indices[0]<dim, ExcIndexRange (indices[0], 0, dim));
+ return values[indices[0]];
+}
+
+template <int dim, typename Number>
+inline
+Number &Tensor<1,dim,Number>::operator [] (const TableIndices<1> & indices)
+{
+ Assert (indices[0]<dim, ExcIndexRange (indices[0], 0, dim));
+ return values[indices[0]];
+}
+
template <>