BoostGSoC18 / tensor

Adding tensor support to boostorg/ublas
4 stars 1 forks source link

[Un]-Bounded Array #7

Open bassoy opened 6 years ago

bassoy commented 6 years ago
stefanseefeld commented 6 years ago

The Storage concept is documented in https://www.boost.org/doc/libs/1_67_0/libs/numeric/ublas/doc/storage_concept.html. To cite from https://www.boost.org/doc/libs/1_67_0/libs/numeric/ublas/doc/unbounded_array.html: "The unbounded array is similar to a std::vector in that in can grow in size beyond any fixed bound. However unbounded_array is aimed at optimal performance. Therefore unbounded_array does not model a Sequence like std::vector does. "

bassoy commented 6 years ago

Yes. However, I am not sure of what optimal performance refers to and why unbounded array should not model a sequence container just because the resizing strategy might be different. Also there has been a discussion about this, see CppCoreGuidelines.

stefanseefeld commented 6 years ago

As far as I understand this is all about std::vector (and other sequences) initializing their elements, which we don't want / need as initialization is done by the tensor class itself.

bassoy commented 6 years ago

std::vector and other containers have a default constructor constructing an empty container. boost::numeric::ublas::tensor has also a default constructor with the same behavior. So boost::numeric::ublas::tensor<float> A; does not allocate memory and does not initialize itself.