Skip to content

Commit

Permalink
add error when B["ii"] = A["i"] is done when B is not supplied with a…
Browse files Browse the repository at this point in the history
… multiplicative identity (#91)
  • Loading branch information
solomonik committed Nov 12, 2020
1 parent 51069cb commit 36b1f6d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/interface/idx_tensor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ namespace CTF {
if (sr->has_mul()){
sr->safecopy(scale,sr->addid());
} else {
for (int i=0; i<this->parent->order; i++){
for (int j=0; j<i; j++){
if (this->idx_map[i] == this->idx_map[j]){
printf("CTF ERROR: operations such as B[\"...i...i...\"] = A[\"...i...\"] are not supported when B is defined on an algebraic structure that does not have a multiplicative identity (and here we CTF wants to try to do B[\"...i...i...\"] = 0*B[\"...i...i...\"] + A[\"...i...\"]), a workaround is to supply a multiplicative operator that outputs the additive identity element when any element is multiplied by a multiplicative identity element\n");
IASSERT(0);
return;
}
}
}
this->parent->set_zero();
}
B.execute(*this);
Expand All @@ -204,6 +213,15 @@ namespace CTF {
if (sr->has_mul()){
sr->safecopy(scale,sr->addid());
} else {
for (int i=0; i<this->parent->order; i++){
for (int j=0; j<i; j++){
if (this->idx_map[i] == this->idx_map[j]){
printf("CTF ERROR: operations such as B[\"...i...i...\"] = A[\"...i...\"] are not supported (only += is ok if an output index is repeated) when B is defined on an algebraic structure that does not have a multiplicative identity (and here we CTF wants to try to do B[\"...i...i...\"] = 0*B[\"...i...i...\"] + A[\"...i...\"]), a workaround is to supply a multiplicative operator that outputs the additive identity element when any element is multiplied by a multiplicative identity element\n");
IASSERT(0);
return;
}
}
}
this->parent->set_zero();
}
B.execute(*this);
Expand Down

0 comments on commit 36b1f6d

Please sign in to comment.