bool
ConstraintMatrix::is_inhomogeneously_constrained (const unsigned int index) const
{
- return (is_constrained(index) &&
- lines[lines_cache[calculate_line_index(index)]].inhomogeneity != 0);
+ // check whether the entry is
+ // constrained. could use is_constrained, but
+ // that means computing the line index twice
+ const unsigned int line_index = calculate_line_index(index);
+ if (line_index > lines_cache.size() ||
+ lines_cache[line_index] == numbers::invalid_unsigned_int ||
+ lines[lines_cache[line_index]].inhomogeneity == 0)
+ return false;
+ else
+ return true;
}
const std::vector<std::pair<unsigned int,double> >*
ConstraintMatrix::get_constraint_entries (unsigned int line) const
{
- if (is_constrained(line))
- return &lines[lines_cache[calculate_line_index(line)]].entries;
- else
+ // check whether the entry is
+ // constrained. could use is_constrained, but
+ // that means computing the line index twice
+ const unsigned int line_index = calculate_line_index(line);
+ if (line_index > lines_cache.size() ||
+ lines_cache[line_index] == numbers::invalid_unsigned_int)
return 0;
+ else
+ return &lines[lines_cache[line_index]].entries;
}
double
ConstraintMatrix::get_inhomogeneity (unsigned int line) const
{
- if (is_constrained(line))
- return lines[lines_cache[calculate_line_index(line)]].inhomogeneity;
- else
+ // check whether the entry is
+ // constrained. could use is_constrained, but
+ // that means computing the line index twice
+ const unsigned int line_index = calculate_line_index(line);
+ if (line_index > lines_cache.size() ||
+ lines_cache[line_index] == numbers::invalid_unsigned_int)
return 0;
+ else
+ return lines[lines_cache[line_index]].inhomogeneity;
}
inline bool
-ConstraintMatrix::can_store_line(unsigned int line_index) const
+ConstraintMatrix::can_store_line (unsigned int line_index) const
{
return !local_lines.size() || local_lines.is_element(line_index);
}