*/
unsigned int n_constraints () const;
+ /**
+ * Return whether the degree of
+ * freedom with number #index# is
+ * a constrained one.
+ *
+ * Note that if #close# was
+ * called before, then this
+ * function is significantly
+ * faster, since then the
+ * constrained degrees of freedom
+ * are sorted and we can do a
+ * binary search, while before
+ * #close# was called, we have to
+ * perform a linear search
+ * through all entries.
+ */
+ bool is_constrained (const unsigned int index) const;
+
/**
* Condense a given sparsity pattern. This
* function assumes the uncondensed
-bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintMatrix::ConstraintLine &a) const
+inline
+bool
+ConstraintMatrix::ConstraintLine::operator < (const ConstraintLine &a) const
{
return line < a.line;
};
-unsigned int ConstraintMatrix::n_constraints () const {
+unsigned int ConstraintMatrix::n_constraints () const
+{
return lines.size();
};
+bool ConstraintMatrix::is_constrained (const unsigned int index) const
+{
+ if (sorted == true)
+ {
+
+ ConstraintLine index_comparison;
+ index_comparison.line = index;
+
+ return binary_search (lines.begin (),
+ lines.end (),
+ index_comparison);
+ }
+ else
+ {
+ for (vector<ConstraintLine>::const_iterator i=lines.begin();
+ i!=lines.end(); ++i)
+ if (i->line == index)
+ return true;
+
+ return false;
+ };
+};
+
+
+
void ConstraintMatrix::print (ostream &out) const {
for (unsigned int i=0; i!=lines.size(); ++i)
for (unsigned int j=0; j!=lines[i].entries.size(); ++j)