boostorg / boostorg/ublas

Wrong implementation of copy constructor for the different type of layout

Open
#166 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
122
Forks
151
PR merge metrics
No merged PRs in 30d

Description

The dynamic and static rank tensors have a constructor, which takes the tensor of different layouts, implemented incorrectly with an unknown or unimplemented member function. To fix the issue, we have to use the `copy` algorithm, but instead, we are just copying the whole container, without considering the layout. Furthermore, we are not asserting or checking the type of the tensor if it matches the current tensor.

Current Implementation

```cpp
template
explicit inline tensor_core (const tensor_core &other)
: tensor_expression_type{}
, _extents (ublas::begin(other.extents ()), ublas::end (other.extents ()))
, _strides (ublas::begin(other.extents ()), ublas::end (other.extents ()))
, _container( std::begin(other.container()), std::end (other.container()))
{
}
```
To fix:
- use the method `tensor::base` instead of unknown method `tensor::container`
- use the `copy` algorithm from the `boost/numeric/ublas/tensor/algorithm.hpp`
- static assert to check if the types are the same or not.

After the fix, enable the test that tests the construction of the other layout.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.