Skip to content

Commit 490c423

Browse files
committed
-implemented Pow and Pow_ for Block(Fermionic)UniTensor
-fixed typos
1 parent 88fd88e commit 490c423

File tree

3 files changed

+29
-39
lines changed

3 files changed

+29
-39
lines changed

src/Network_base.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,70 +12,73 @@ namespace cytnx {
1212
void Network_base::Contract_plan(const std::vector<UniTensor> &utensors, const std::string &Tout,
1313
const std::vector<std::string> &alias,
1414
const std::string &contract_order) {
15-
cytnx_error_msg(true, "[ERROR][Network][Contract_plan] call from uninitialize network.%s",
15+
cytnx_error_msg(true, "[ERROR][Network][Contract_plan] call from uninitialized network.%s",
1616
"\n");
1717
}
1818
void Network_base::Fromfile(const std::string &fname) {
19-
cytnx_error_msg(true, "[ERROR][Network][Fromfile] call from uninitialize network.%s", "\n");
19+
cytnx_error_msg(true, "[ERROR][Network][Fromfile] call from uninitialized network.%s", "\n");
2020
}
2121
void Network_base::FromString(const std::vector<std::string> &fname) {
22-
cytnx_error_msg(true, "[ERROR][Network][FromString] call from uninitialize network.%s", "\n");
22+
cytnx_error_msg(true, "[ERROR][Network][FromString] call from uninitialized network.%s", "\n");
2323
}
2424
void Network_base::Savefile(const std::string &fname) {
25-
cytnx_error_msg(true, "[ERROR][Network][Savefile] call from uninitialize network.%s", "\n");
25+
cytnx_error_msg(true, "[ERROR][Network][Savefile] call from uninitialized network.%s", "\n");
2626
}
2727
void Network_base::PutUniTensor(const std::string &name, const UniTensor &utensor) {
28-
cytnx_error_msg(true, "[ERROR][Network][PutUniTensor] call from uninitialize network.%s", "\n");
28+
cytnx_error_msg(true, "[ERROR][Network][PutUniTensor] call from uninitialized network.%s",
29+
"\n");
2930
}
3031
void Network_base::PutUniTensor(const cytnx_uint64 &idx, const UniTensor &utensor) {
31-
cytnx_error_msg(true, "[ERROR][Network][PutUniTensor] call from uninitialize network.%s", "\n");
32+
cytnx_error_msg(true, "[ERROR][Network][PutUniTensor] call from uninitialized network.%s",
33+
"\n");
3234
}
3335
void Network_base::RmUniTensor(const std::string &name) {
34-
cytnx_error_msg(true, "[ERROR][Network][RmUniTensor] call from uninitialize network.%s", "\n");
36+
cytnx_error_msg(true, "[ERROR][Network][RmUniTensor] call from uninitialized network.%s", "\n");
3537
}
3638
void Network_base::RmUniTensor(const cytnx_uint64 &idx) {
37-
cytnx_error_msg(true, "[ERROR][Network][RmUniTensor] call from uninitialize network.%s", "\n");
39+
cytnx_error_msg(true, "[ERROR][Network][RmUniTensor] call from uninitialized network.%s", "\n");
3840
}
3941
void Network_base::RmUniTensors(const std::vector<string> &names) {
40-
cytnx_error_msg(true, "[ERROR][Network][RmUniTensors] call from uninitialize network.%s", "\n");
42+
cytnx_error_msg(true, "[ERROR][Network][RmUniTensors] call from uninitialized network.%s",
43+
"\n");
4144
}
4245
void Network_base::PutUniTensors(const std::vector<string> &names,
4346
const std::vector<UniTensor> &utensors) {
44-
cytnx_error_msg(true, "[ERROR][Network][PutUniTensors] call from uninitialize network.%s",
47+
cytnx_error_msg(true, "[ERROR][Network][PutUniTensors] call from uninitialized network.%s",
4548
"\n");
4649
}
4750
void Network_base::clear() {
48-
cytnx_error_msg(true, "[ERROR][Network][Clear] call from uninitialize network.%s", "\n");
51+
cytnx_error_msg(true, "[ERROR][Network][Clear] call from uninitialized network.%s", "\n");
4952
}
5053
std::string Network_base::getOptimalOrder() {
51-
cytnx_error_msg(true, "[ERROR][Network][getOptimalOrder] call from uninitialize network.%s",
54+
cytnx_error_msg(true, "[ERROR][Network][getOptimalOrder] call from uninitialized network.%s",
5255
"\n");
5356
return "";
5457
}
5558

5659
void Network_base::setOrder(const bool &optimal, const std::string &contract_order) {
57-
cytnx_error_msg(true, "[ERROR][Network][setOrder] call from uninitialize network.%s", "\n");
60+
cytnx_error_msg(true, "[ERROR][Network][setOrder] call from uninitialized network.%s", "\n");
5861
}
5962

6063
std::string Network_base::getOrder() {
61-
cytnx_error_msg(true, "[ERROR][Network][getOrder] call from uninitialize network.%s", "\n");
64+
cytnx_error_msg(true, "[ERROR][Network][getOrder] call from uninitialized network.%s", "\n");
6265
return "";
6366
}
6467

6568
UniTensor Network_base::Launch() {
66-
cytnx_error_msg(true, "[ERROR][Network][Launch] call from uninitialize network.%s", "\n");
69+
cytnx_error_msg(true, "[ERROR][Network][Launch] call from uninitialized network.%s", "\n");
6770
return UniTensor();
6871
}
6972

7073
void Network_base::construct(const std::vector<std::string> &alias,
7174
const std::vector<std::vector<std::string>> &labels,
7275
const std::vector<std::string> &outlabel, const cytnx_int64 &outrk,
7376
const std::string &order, const bool optim) {
74-
cytnx_error_msg(true, "[ERROR][Network][construct] call from uninitialize network.%s", "\n");
77+
cytnx_error_msg(true, "[ERROR][Network][construct] call from uninitialized network.%s", "\n");
7578
}
7679

7780
boost::intrusive_ptr<Network_base> Network_base::clone() {
78-
cytnx_error_msg(true, "[ERROR][Network][clone] call from uninitialize network. %s", "\n");
81+
cytnx_error_msg(true, "[ERROR][Network][clone] call from uninitialized network. %s", "\n");
7982
return nullptr;
8083
}
8184
void Network_base::PrintNet(std::ostream &os) {

src/linalg/Pow.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,11 @@ namespace cytnx {
7474
if (Tin.uten_type() == UTenType.Dense) {
7575
out = Tin.clone();
7676
out.get_block_().Pow_(p);
77-
} else if (Tin.uten_type() == UTenType.Block) {
78-
cytnx_error_msg(true,
79-
"[Pow][BlockUniTensor] Powers of BlockUniTensors cannot be calculated. "
80-
"This would destroy the Symmetry structure and is thus not implemented.%s",
81-
"\n");
82-
} else if (Tin.uten_type() == UTenType.BlockFermionic) {
83-
cytnx_error_msg(
84-
true,
85-
"[Pow][BlockFermionicUniTensor] Powers of BlockFermionicUniTensors cannot be calculated. "
86-
"This would destroy the Symmetry structure and is thus not implemented.%s",
87-
"\n");
77+
} else if (Tin.uten_type() == UTenType.Block || Tin.uten_type() == UTenType.BlockFermionic) {
78+
out = Tin.clone();
79+
for (auto &blk : out.get_blocks_()) {
80+
blk.Pow_(p);
81+
}
8882
} else {
8983
// cytnx_error_msg(true,"[Pow][SparseUniTensor] Developing%s","\n");
9084
out = Tin.clone();

src/linalg/Pow_.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,10 @@ namespace cytnx {
5959
void Pow_(UniTensor &Tin, const double &p) {
6060
if (Tin.uten_type() == UTenType.Dense) {
6161
Tin.get_block_().Pow_(p);
62-
} else if (Tin.uten_type() == UTenType.Block) {
63-
cytnx_error_msg(true,
64-
"[Pow_][BlockUniTensor] Powers of BlockUniTensors cannot be calculated. "
65-
"This would destroy the Symmetry structure and is thus not implemented.%s",
66-
"\n");
67-
} else if (Tin.uten_type() == UTenType.BlockFermionic) {
68-
cytnx_error_msg(
69-
true,
70-
"[Pow_][BlockFermionicUniTensor] Powers of BlockFermionicUniTensors cannot be "
71-
"calculated. This would destroy the Symmetry structure and is thus not implemented.%s",
72-
"\n");
62+
} else if (Tin.uten_type() == UTenType.Block || Tin.uten_type() == UTenType.BlockFermionic) {
63+
for (auto &blk : Tin.get_blocks_()) {
64+
blk.Pow_(p);
65+
}
7366
} else {
7467
// cytnx_error_msg(true,"[Pow][SparseUniTensor] Developing%s","\n");
7568
auto tmp = Tin.get_blocks_();

0 commit comments

Comments
 (0)