throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : input array is NULL !");
if(!isAllocated() || !otherBBoxFrmt->isAllocated())
throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : this and input array must be allocated !");
- std::size_t nbOfComp(getNumberOfComponents());
- int nbOfTuples(getNumberOfTuples());
- int nbOfComp(getNumberOfComponents()),nbOfTuples(getNumberOfTuples());
++ std::size_t nbOfComp(getNumberOfComponents()),nbOfTuples(getNumberOfTuples());
if(nbOfComp!=otherBBoxFrmt->getNumberOfComponents())
{
std::ostringstream oss; oss << "DataArrayDouble::computeNbOfInteractionsWith : this number of components (" << nbOfComp << ") must be equal to the number of components of input array (" << otherBBoxFrmt->getNumberOfComponents() << ") !";
this->declareAsNew();
}
- int nbOfTuples(this->getNumberOfTuples());
+ template<class T>
+ struct ImplReprTraits { static void SetPrecision(std::ostream& oss) { } };
+
+ template<>
+ struct ImplReprTraits<double> { static void SetPrecision(std::ostream& oss) { oss.precision(17); } };
+
+ template<>
+ struct ImplReprTraits<float> { static void SetPrecision(std::ostream& oss) { oss.precision(7); } };
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::reprStream(std::ostream& stream) const
+ {
+ stream << "Name of " << Traits<T>::ReprStr << " array : \"" << this->_name << "\"\n";
+ reprWithoutNameStream(stream);
+ }
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::reprZipStream(std::ostream& stream) const
+ {
+ stream << "Name of " << Traits<T>::ReprStr << " array : \"" << this->_name << "\"\n";
+ reprZipWithoutNameStream(stream);
+ }
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::reprNotTooLongStream(std::ostream& stream) const
+ {
+ stream << "Name of "<< Traits<T>::ReprStr << " array : \"" << this->_name << "\"\n";
+ reprNotTooLongWithoutNameStream(stream);
+ }
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::reprWithoutNameStream(std::ostream& stream) const
+ {
+ DataArray::reprWithoutNameStream(stream);
+ ImplReprTraits<T>::SetPrecision(stream);
+ this->_mem.repr(this->getNumberOfComponents(),stream);
+ }
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::reprZipWithoutNameStream(std::ostream& stream) const
+ {
+ DataArray::reprWithoutNameStream(stream);
+ ImplReprTraits<T>::SetPrecision(stream);
+ this->_mem.reprZip(this->getNumberOfComponents(),stream);
+ }
+
+ template<class T>
+ void DataArrayTemplateClassic<T>::reprNotTooLongWithoutNameStream(std::ostream& stream) const
+ {
+ DataArray::reprWithoutNameStream(stream);
+ ImplReprTraits<T>::SetPrecision(stream);
+ this->_mem.reprNotTooLong(this->getNumberOfComponents(),stream);
+ }
+
+ /*!
+ * This method is close to repr method except that when \a this has more than 1000 tuples, all tuples are not
+ * printed out to avoid to consume too much space in interpretor.
+ * \sa repr
+ */
+ template<class T>
+ std::string DataArrayTemplateClassic<T>::reprNotTooLong() const
+ {
+ std::ostringstream ret;
+ reprNotTooLongStream(ret);
+ return ret.str();
+ }
+
+ /////////////////////////////////
+
+ /*!
+ * Checks if all values in \a this array are equal to \a val at precision \a eps.
+ * \param [in] val - value to check equality of array values to.
+ * \param [in] eps - precision to check the equality.
+ * \return bool - \a true if all values are in range (_val_ - _eps_; _val_ + _eps_),
+ * \a false else.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this is not allocated.
+ */
+ template<class T>
+ bool DataArrayTemplateFP<T>::isUniform(T val, T eps) const
+ {
+ this->checkAllocated();
+ if(this->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::isUniform : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
+ const T *w(this->begin()),*end2(this->end());
+ const T vmin(val-eps),vmax(val+eps);
+ for(;w!=end2;w++)
+ if(*w<vmin || *w>vmax)
+ return false;
+ return true;
+ }
+
/*!
* Equivalent to DataArrayInt::isEqual except that if false the reason of
* mismatch is given.