Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buggy behaviour of non-contiguous xadaptor and scalar assignment #2773

Open
ewoudwempe opened this issue Feb 8, 2024 · 0 comments
Open

Buggy behaviour of non-contiguous xadaptor and scalar assignment #2773

ewoudwempe opened this issue Feb 8, 2024 · 0 comments

Comments

@ewoudwempe
Copy link
Contributor

Hi,
When assigning with a scalar on a xadaptor with non-contiguous strides, there is some problem where contiguous assignment is done instead, producing unexpected results.
For instance, the following does not work:

void test_strided_scalar_assign() {
  auto data = std::vector<double>(8);
  std::fill(data.begin(), data.end(), 0.);
  auto adapter_strided_noncont = xt::adapt(
      data.data(), 6, xt::no_ownership(), std::vector<size_t>{2, 3},
      std::vector<size_t>{4, 1});
  xt::noalias(adapter_strided_noncont) += 1;
  auto expected = std::vector<double>({1, 1, 1, 0, 1, 1, 1, 0});
  assert(expected == data);
}

When running this, the first 6 values of data are incremented, instead of taking into account the {4,1} strides.
What's do you think the best way is to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant