Use function call operator for indexing instead of at
- Dominant language
- C++
- Stars
- 122
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
Description
### Discussed in https://github.com/boostorg/ublas/discussions/141
Originally posted by **bassoy** October 21, 2021
Right now index accessing is performed using the `at` member function in tensor e.g. in [tensor_dynamic](https://github.com/boostorg/ublas/blob/develop/include/boost/numeric/ublas/tensor/tensor/tensor_dynamic.hpp), see also in [example](https://github.com/boostorg/ublas/blob/develop/examples/tensor/access_tensor.cpp).
```cpp
for(auto i = 0u; i < B.size(0); ++i)
for(auto j = 0u; j < B.size(1); ++j)
C.at(i,j) = std::conj(B.at(i,j));
```
Is it possible to overload `operator()` for this purpose? Note that `operator()` will also be used for creating subtensors.
```cpp
for(auto i = 0u; i < B.size(0); ++i)
for(auto j = 0u; j < B.size(1); ++j)
C(i,j) = std::conj(B(i,j));
```
We could also use `operator[]` for accessing single indices and multi-indices.
```cpp
for(auto i = 0u; i < B.size(0); ++i)
for(auto j = 0u; j < B.size(1); ++j)
C[i,j] = std::conj(B[i,j]);
```
This will be again closer to a Matlab or Octave or R notation.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.