-
Notifications
You must be signed in to change notification settings - Fork 13
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
Refer to indices by cytnx_int64 or cytnx_uint64 #444
Comments
There is. Originally some of the API are design for large Tensor. Meaning that if you don't need to support -1 for indexing like python, the C++ side can utilize full 64bit address indexing. the API that using int64 is only to make compatible with Python -1 indexing |
I see. But perumte does not work with negative indices anyways in the current implementation, at least for BlockUniTensor |
Can we do it at Pybind11 level to make C++ code consistent? |
Here is a crop from the Google C++ style guide that we apply. In short, only use unsigned integers when representing a bit pattern and use
|
I suggest use C++20 has std::ssize() function for containers, so it is safe to write eg The MPToolkit is currently C++14 and not ready to use C++20 yet (not enough compiler support), but meanwhile I'm just going to add some ssize() function myself. In new code, my feeling is always use a signed integer, unless it is actually bit-flipping. Having a container using See also: Bjarne also advocates for making all |
When referring to positive numbers like index or block numbers, the data structure is either a
cytnx_int64
or acytnx_uint64
.For example,
UniTensor.permute(std::vector<cytnx_int64>)
andUniTensor.at(std::vector<cytnx_uint64>)
.For
UniTensor.get_block()
both versions exist and the difference (if any) is not obvious to me.This is a bit confusing and inconstant. While it should not cause problems on the Python side, the mix leads to difficulties with C++ because the two types are not automatically converted, at least when combined in vectors.
Is there a reason for different conventions? Could everything be changed to one convention? How can this be done without breaking compatibility with existing code, tests, etc?
The text was updated successfully, but these errors were encountered: