--- /dev/null
+New: FECollection gained an equality comparison operator. Both FiniteElement
+and FECollcetion have a non-equality comparison operator now.
+<br>
+(Daniel Arndt, 2018/04/25)
//@}
/**
- * Comparison operator. We also check for equality of the constraint matrix,
- * which is quite an expensive operation. Do therefore use this function
- * with care, if possible only for debugging purposes.
+ * Comparison operator. We also check for equality of the name returned by
+ * get_name() and for equality of the constraint matrix, which is quite an
+ * expensive operation. Do therefore use this function with care, if
+ * possible only for debugging purposes.
*
- * Since this function is not that important, we avoid an implementational
- * question about comparing arrays and do not compare the matrix arrays
- * #restriction and #prolongation.
+ * We do not compare the matrix arrays #restriction and #prolongation.
*/
bool operator == (const FiniteElement<dim,spacedim> &) const;
+ /**
+ * Non-equality comparison operator. Defined in terms of the equality comparison operator.
+ */
+ bool operator != (const FiniteElement<dim,spacedim> &) const;
+
/**
* @name Index computations
* @{
FECollection<dim, spacedim> &
operator= (FECollection<dim,spacedim> &&) = default; // NOLINT
+ /**
+ * Equality comparison operator. All stored FiniteElement objects are compared in order.
+ */
+ bool
+ operator== (const FECollection<dim,spacedim> &fe_collection) const;
+
+ /**
+ * Non-equality comparison operator. All stored FiniteElement objects are compared in order.
+ */
+ bool
+ operator!= (const FECollection<dim,spacedim> &fe_collection) const;
+
/**
* Add a finite element. This function generates a copy of the given
* element, i.e. you can do things like <tt>push_back(FE_Q<dim>(1));</tt>.
}
+
+ template <int dim, int spacedim>
+ inline
+ bool
+ FECollection<dim,spacedim>::operator== (const FECollection<dim,spacedim> &fe_collection) const
+ {
+ const unsigned int n_elements = size();
+ if (n_elements != fe_collection.size())
+ return false;
+
+ for (unsigned int i=0; i<n_elements; ++i)
+ if (!(*finite_elements[i] == fe_collection[i]))
+ return false;
+
+ return true;
+ }
+
+
+
+ template <int dim, int spacedim>
+ inline
+ bool
+ FECollection<dim,spacedim>::operator != (const FECollection<dim,spacedim> &fe_collection) const
+ {
+ return !(*this == fe_collection);
+ }
+
+
+
template <int dim, int spacedim>
inline
const FiniteElement<dim,spacedim> &
{
return ((static_cast<const FiniteElementData<dim>&>(*this) ==
static_cast<const FiniteElementData<dim>&>(f)) &&
- (interface_constraints == f.interface_constraints));
+ (interface_constraints == f.interface_constraints) &&
+ (this->get_name() == f.get_name()));
+}
+
+
+
+template <int dim, int spacedim>
+bool
+FiniteElement<dim,spacedim>::operator != (const FiniteElement<dim,spacedim> &f) const
+{
+ return !(*this == f);
}