1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

diagnostic functions raise_error and invalid_matrix

This commit is contained in:
Zeno Rogue 2019-05-29 20:21:19 +02:00
parent 182df69535
commit c9655a29a5
2 changed files with 15 additions and 0 deletions

View File

@ -5489,4 +5489,7 @@ namespace dual {
inline reaction_t mayboth(reaction_t what) { return [=] { may_split_or_do(what); }; } inline reaction_t mayboth(reaction_t what) { return [=] { may_split_or_do(what); }; }
} }
void raise_error();
bool invalid_matrix(const transmatrix T);
} }

View File

@ -782,6 +782,18 @@ bool invis_point(const hyperpoint h) {
return h[2] < 0; return h[2] < 0;
} }
void raise_error() {
println(hlog, "something wrong");
}
bool invalid_matrix(const transmatrix T) {
for(int i=0; i<DIM; i++) for(int j=0; j<DIM; j++)
if(std::isnan(T[i][j]) || T[i][j] > 1e8 || T[i][j] < -1e8 || std::isinf(T[i][j]))
return true;
for(int i=0; i<DIM; i++) for(int j=0; j<DIM; j++) if(T[i][j] > .5 || T[i][j] < -.5) return false;
return true;
}
bool invalid_point(const hyperpoint h) { bool invalid_point(const hyperpoint h) {
return std::isnan(h[DIM]) || h[DIM] > 1e8 || std::isinf(h[DIM]); return std::isnan(h[DIM]) || h[DIM] > 1e8 || std::isinf(h[DIM]);
} }