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

Refactor Storage with templates #469

Draft
wants to merge 9 commits into
base: dev-master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,958 changes: 0 additions & 1,958 deletions include/Tensor.old.hpp

This file was deleted.

17 changes: 6 additions & 11 deletions include/UniTensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@ namespace cytnx {
std::vector<Tensor> _interface_block; // this is serves as interface for get_blocks_();
return this;
} else {
// TODO: Do not allocate the memory twice.
boost::intrusive_ptr<UniTensor_base> out = this->clone();
out->to_(device);
out->get_block_() = out->get_block_().to(device);
return out;
}
}
Expand Down Expand Up @@ -1155,8 +1156,11 @@ namespace cytnx {
if (this->device() == device) {
return this;
} else {
// TODO: Do not allocate the memory twice.
boost::intrusive_ptr<UniTensor_base> out = this->clone();
out->to_(device);
for (cytnx_uint64 i = 0; i < out->get_blocks_(true).size(); i++) {
out->get_blocks_(true)[i] = out->get_blocks_(true)[i].to(device);
}
return out;
}
};
Expand Down Expand Up @@ -1891,15 +1895,6 @@ namespace cytnx {
const int &device = Device.cpu, const bool &is_diag = false,
const std::string &name = "")
: _impl(new UniTensor_base()) {
#ifdef UNI_DEBUG
cytnx_warning_msg(
true,
"[DEBUG] message: entry for UniTensor(const std::vector<Bond> &bonds, const "
"std::vector<std::string> &in_labels={}, const cytnx_int64 &rowrank=-1, const unsigned "
"int "
"&dtype=Type.Double, const int &device = Device.cpu, const bool &is_diag=false)%s",
"\n");
#endif
this->Init(bonds, in_labels, rowrank, dtype, device, is_diag, name);
}

Expand Down
6 changes: 6 additions & 0 deletions include/backend/Scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2848,6 +2848,12 @@ namespace cytnx {
}

// casting
/// @brief The explicit casting operator of the Scalar class to cytnx::cytnx_complex128.
explicit operator cytnx_complex128() const { return this->_impl->to_cytnx_complex128(); }

/// @brief The explicit casting operator of the Scalar class to cytnx::cytnx_complex64.
explicit operator cytnx_complex64() const { return this->_impl->to_cytnx_complex64(); }

/// @brief The explicit casting operator of the Scalar class to cytnx::cytnx_double.
explicit operator cytnx_double() const { return this->_impl->to_cytnx_double(); }

Expand Down
Loading
Loading