Skip to content

Commit 2de3fef

Browse files
committed
HPolytope Normalization Flag
1 parent 6dc3108 commit 2de3fef

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

include/convex_bodies/hpolytope.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class HPolytope {
5656
MT A; //matrix A
5757
VT b; // vector b, s.t.: Ax<=b
5858
std::pair<Point, NT> _inner_ball;
59+
bool normalized = 0;
5960

6061
public:
6162
//TODO: the default implementation of the Big3 should be ok. Recheck.
@@ -881,14 +882,23 @@ class HPolytope {
881882
return A;
882883
}
883884

885+
886+
bool is_normalized()
887+
{
888+
return normalized;
889+
}
890+
884891
void normalize()
885892
{
886-
NT row_norm;
887-
for (int i = 0; i < num_of_hyperplanes(); ++i)
888-
{
889-
row_norm = A.row(i).norm();
890-
A.row(i) = A.row(i) / row_norm;
891-
b(i) = b(i) / row_norm;
893+
if(!is_normalized()){
894+
NT row_norm;
895+
for (int i = 0; i < num_of_hyperplanes(); ++i)
896+
{
897+
row_norm = A.row(i).norm();
898+
A.row(i) = A.row(i) / row_norm;
899+
b(i) = b(i) / row_norm;
900+
}
901+
normalized = true;
892902
}
893903
}
894904

0 commit comments

Comments
 (0)