Skip to content
Open
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
41 changes: 35 additions & 6 deletions src/DenseUniTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace cytnx {
} else {
// check bonds & labels dim
cytnx_error_msg(bonds.size() != in_labels.size(), "%s",
"[ERROR] labels must have same lenth as # of bonds.");
"[ERROR] labels must have same length as # of bonds.");

std::vector<std::string> tmp = vec_unique(in_labels);
cytnx_error_msg(tmp.size() != in_labels.size(),
Expand Down Expand Up @@ -1299,8 +1299,14 @@ namespace cytnx {
i);
}
}

this->_block += rhs->get_block_();
if (this->_is_diag == rhs->_is_diag) {
this->_block += rhs->get_block_();
} else if (this->_is_diag) {
this->to_dense_();
this->_block += rhs->get_block_();
} else {
this->_block += linalg::Diag(rhs->get_block_());
}
}
void DenseUniTensor::Add_(const Scalar &rhs) {
// cout << rhs << endl;
Expand Down Expand Up @@ -1329,7 +1335,14 @@ namespace cytnx {
i);
}
}
this->_block -= rhs->get_block_();
if (this->_is_diag == rhs->_is_diag) {
this->_block -= rhs->get_block_();
} else if (this->_is_diag) {
this->to_dense_();
this->_block -= rhs->get_block_();
} else {
this->_block -= linalg::Diag(rhs->get_block_());
}
}
void DenseUniTensor::Sub_(const Scalar &rhs) {
// cytnx_error_msg(this->is_tag(),"[ERROR] cannot perform arithmetic on tagged unitensor
Expand Down Expand Up @@ -1362,7 +1375,14 @@ namespace cytnx {
i);
}
}
this->_block *= rhs->get_block_();
if (this->_is_diag == rhs->_is_diag) {
this->_block *= rhs->get_block_();
} else if (this->_is_diag) {
this->to_dense_();
this->_block *= rhs->get_block_();
} else {
this->_block *= linalg::Diag(rhs->get_block_());
}
}
void DenseUniTensor::Mul_(const Scalar &rhs) {
// cytnx_error_msg(this->is_tag(),"[ERROR] cannot perform arithmetic on tagged unitensor
Expand Down Expand Up @@ -1390,7 +1410,16 @@ namespace cytnx {
i);
}
}
this->_block /= rhs->get_block_();
if (this->_is_diag == rhs->_is_diag) {
this->_block /= rhs->get_block_();
} else {
cytnx_error_msg(rhs->_is_diag,
"[Div] Dividing a non-diagonal DenseUnitensor by a diagonal one would lead "
"to divisions by zero!%s",
"\n");
this->to_dense_();
this->_block /= rhs->get_block_();
}
}
void DenseUniTensor::Div_(const Scalar &rhs) {
// cytnx_error_msg(this->is_tag(),"[ERROR] cannot perform arithmetic on tagged unitensor
Expand Down
Loading
Loading