فهرست منبع

fixed incorrect assertion

Former-commit-id: b817b409e074b4275023d6989b2a7471066da324
Alec Jacobson 10 سال پیش
والد
کامیت
09e4761524
1فایلهای تغییر یافته به همراه19 افزوده شده و 15 حذف شده
  1. 19 15
      include/igl/min_quad_with_fixed.cpp

+ 19 - 15
include/igl/min_quad_with_fixed.cpp

@@ -51,18 +51,18 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
   // default is to have 0 linear equality constraints
   // default is to have 0 linear equality constraints
   if(Aeq.size() != 0)
   if(Aeq.size() != 0)
   {
   {
-    assert(n == Aeq.cols());
+    assert(n == Aeq.cols() && "#Aeq.cols() should match A.rows()");
   }
   }
 
 
-  assert(A.rows() == n);
-  assert(A.cols() == n);
+  assert(A.rows() == n && "A should be square");
+  assert(A.cols() == n && "A should be square");
 
 
   // number of known rows
   // number of known rows
   int kr = known.size();
   int kr = known.size();
 
 
-  assert(kr == 0 || known.minCoeff() >= 0);
-  assert(kr == 0 || known.maxCoeff() < n);
-  assert(neq <= n);
+  assert((kr == 0 || known.minCoeff() >= 0)&& "known indices should be in [0,n)");
+  assert((kr == 0 || known.maxCoeff() < n) && "known indices should be in [0,n)");
+  assert(neq <= n && "Number of equality constraints should be less than DOFs");
 
 
   // cache known
   // cache known
   data.known = known;
   data.known = known;
@@ -95,7 +95,7 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
 
 
   SparseMatrix<T> Auu;
   SparseMatrix<T> Auu;
   slice(A,data.unknown,data.unknown,Auu);
   slice(A,data.unknown,data.unknown,Auu);
-  assert(Auu.size() > 0 && "All DOFs seem to be fixed.");
+  assert(Auu.size() > 0 && "There should be at least one unknown.");
 
 
   // Positive definiteness is *not* determined, rather it is given as a
   // Positive definiteness is *not* determined, rather it is given as a
   // parameter
   // parameter
@@ -106,7 +106,8 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
     data.Auu_sym = true;
     data.Auu_sym = true;
     // This is an annoying assertion unless EPS can be chosen in a nicer way.
     // This is an annoying assertion unless EPS can be chosen in a nicer way.
     //assert(is_symmetric(Auu,EPS<double>()));
     //assert(is_symmetric(Auu,EPS<double>()));
-    assert(is_symmetric(Auu,1.0));
+    assert(is_symmetric(Auu,1.0) && 
+      "Auu should be symmetric if positive definite");
   }else
   }else
   {
   {
     // determine if A(unknown,unknown) is symmetric and/or positive definite
     // determine if A(unknown,unknown) is symmetric and/or positive definite
@@ -125,8 +126,10 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
 #endif
 #endif
     // QR decomposition to determine row rank in Aequ
     // QR decomposition to determine row rank in Aequ
     slice(Aeq,data.unknown,2,data.Aequ);
     slice(Aeq,data.unknown,2,data.Aequ);
-    assert(data.Aequ.rows() == neq);
-    assert(data.Aequ.cols() == data.unknown.size());
+    assert(data.Aequ.rows() == neq && 
+      "#Rows in Aequ should match #constraints");
+    assert(data.Aequ.cols() == data.unknown.size() && 
+      "#cols in Aequ should match #unknowns");
     data.AeqTQR.compute(data.Aequ.transpose().eval());
     data.AeqTQR.compute(data.Aequ.transpose().eval());
 #ifdef MIN_QUAD_WITH_FIXED_CPP_DEBUG
 #ifdef MIN_QUAD_WITH_FIXED_CPP_DEBUG
     cout<<endl<<matlab_format(SparseMatrix<T>(data.Aequ.transpose().eval()),"AeqT")<<endl<<endl;
     cout<<endl<<matlab_format(SparseMatrix<T>(data.Aequ.transpose().eval()),"AeqT")<<endl<<endl;
@@ -146,7 +149,8 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
         return false;
         return false;
     }
     }
     nc = data.AeqTQR.rank();
     nc = data.AeqTQR.rank();
-    assert(nc<=neq);
+    assert(nc<=neq && 
+      "Rank of reduced constraints should be <= #original constraints");
     data.Aeq_li = nc == neq;
     data.Aeq_li = nc == neq;
     //cout<<"data.Aeq_li: "<<data.Aeq_li<<endl;
     //cout<<"data.Aeq_li: "<<data.Aeq_li<<endl;
   }else
   }else
@@ -304,10 +308,10 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
     I.setIdentity();
     I.setIdentity();
     data.AeqTE = data.AeqTQR.colsPermutation() * I;
     data.AeqTE = data.AeqTQR.colsPermutation() * I;
     data.AeqTET = data.AeqTQR.colsPermutation().transpose() * I;
     data.AeqTET = data.AeqTQR.colsPermutation().transpose() * I;
-    assert(AeqTR.rows() == neq);
-    assert(AeqTQ.rows() == nu);
-    assert(AeqTQ.cols() == nu);
-    assert(AeqTR.cols() == neq);
+    assert(AeqTR.rows() == nu   && "#rows in AeqTR should match #unknowns");
+    assert(AeqTR.cols() == neq  && "#cols in AeqTR should match #constraints");
+    assert(AeqTQ.rows() == nu && "#rows in AeqTQ should match #unknowns");
+    assert(AeqTQ.cols() == nu && "#cols in AeqTQ should match #unknowns");
     //cout<<"    slice"<<endl;
     //cout<<"    slice"<<endl;
 #ifdef MIN_QUAD_WITH_FIXED_CPP_DEBUG
 #ifdef MIN_QUAD_WITH_FIXED_CPP_DEBUG
     cout<<"    slice"<<endl;
     cout<<"    slice"<<endl;