aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-10-26 14:29:26 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-10-26 14:29:26 -0700
commit1c8312c811344beaa06f7ae9258f66c38337c607 (patch)
tree4436a04ce900a997aa6adf9d42d0c6dab0a07fac /unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
parent1f4c98abb1634bdbdd6583b55ba36dcc09ef5773 (diff)
Started to add support for tensors of rank 0
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorIO.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorIO.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h b/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
index 3b6f2c730..38a833f82 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h
@@ -33,7 +33,10 @@ std::ostream& operator << (std::ostream& os, const TensorBase<T, ReadOnlyAccesso
const Index total_size = internal::array_prod(tensor.dimensions());
// Print the tensor as a 1d vector or a 2d matrix.
- if (internal::array_size<Dimensions>::value == 1) {
+ static const int rank = internal::array_size<Dimensions>::value;
+ if (rank == 0) {
+ os << tensor.coeff(0);
+ } else if (rank == 1) {
Map<const Array<Scalar, Dynamic, 1> > array(const_cast<Scalar*>(tensor.data()), total_size);
os << array;
} else {