return ret.str();
}
-/*!
- * 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
- */
-std::string DataArrayDouble::reprNotTooLong() const
-{
- std::ostringstream ret;
- reprNotTooLongStream(ret);
- return ret.str();
-}
-
void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const
{
static const char SPACE[4]={' ',' ',' ',' '};
ofs << std::endl << idt << "</DataArray>\n";
}
-void DataArrayDouble::reprStream(std::ostream& stream) const
-{
- stream << "Name of double array : \"" << _name << "\"\n";
- reprWithoutNameStream(stream);
-}
-
-void DataArrayDouble::reprZipStream(std::ostream& stream) const
-{
- stream << "Name of double array : \"" << _name << "\"\n";
- reprZipWithoutNameStream(stream);
-}
-
-void DataArrayDouble::reprNotTooLongStream(std::ostream& stream) const
-{
- stream << "Name of double array : \"" << _name << "\"\n";
- reprNotTooLongWithoutNameStream(stream);
-}
-
-void DataArrayDouble::reprWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- stream.precision(17);
- _mem.repr(getNumberOfComponents(),stream);
-}
-
-void DataArrayDouble::reprZipWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- stream.precision(17);
- _mem.reprZip(getNumberOfComponents(),stream);
-}
-
-void DataArrayDouble::reprNotTooLongWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- stream.precision(17);
- _mem.reprNotTooLong(getNumberOfComponents(),stream);
-}
-
void DataArrayDouble::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples(getNumberOfTuples()),nbComp(getNumberOfComponents());
return ret.str();
}
-/*!
- * 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
- */
-std::string DataArrayInt::reprNotTooLong() const
-{
- std::ostringstream ret;
- reprNotTooLongStream(ret);
- return ret.str();
-}
-
void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const
{
static const char SPACE[4]={' ',' ',' ',' '};
ofs << std::endl << idt << "</DataArray>\n";
}
-void DataArrayInt::reprStream(std::ostream& stream) const
-{
- stream << "Name of int array : \"" << _name << "\"\n";
- reprWithoutNameStream(stream);
-}
-
-void DataArrayInt::reprZipStream(std::ostream& stream) const
-{
- stream << "Name of int array : \"" << _name << "\"\n";
- reprZipWithoutNameStream(stream);
-}
-
-void DataArrayInt::reprNotTooLongStream(std::ostream& stream) const
-{
- stream << "Name of int array : \"" << _name << "\"\n";
- reprNotTooLongWithoutNameStream(stream);
-}
-
-void DataArrayInt::reprWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- _mem.repr(getNumberOfComponents(),stream);
-}
-
-void DataArrayInt::reprZipWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- _mem.reprZip(getNumberOfComponents(),stream);
-}
-
-void DataArrayInt::reprNotTooLongWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- stream.precision(17);
- _mem.reprNotTooLong(getNumberOfComponents(),stream);
-}
-
void DataArrayInt::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *performCopyOrIncrRef(bool dCpy) const;
MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *sumPerTuple() const;
MEDCOUPLING_EXPORT void iota(T init=(T)0);
+ MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
protected:
static typename Traits<T>::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self);
template<class OP>
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<float>::mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafeSlice(bg,end2,step); }
- MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
public:// non abstract but essential
- MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
- MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT bool isEqual(const DataArrayFloat& other, float prec) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const;
MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const;
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
- MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const;
- MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
MEDCOUPLING_EXPORT DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }//ok
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
- MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
- MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
ptr[i]=init+(T)i;
this->declareAsNew();
}
+
+ 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();
+ }
/////////////////////////////////
return new DataArrayFloat(*this);
}
-void DataArrayFloat::reprStream(std::ostream& stream) const
-{
- stream << "Name of float array : \"" << _name << "\"\n";
- reprWithoutNameStream(stream);
-}
-
-void DataArrayFloat::reprZipStream(std::ostream& stream) const
-{
- stream << "Name of float array : \"" << _name << "\"\n";
- reprZipWithoutNameStream(stream);
-}
-
-void DataArrayFloat::reprZipWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- stream.precision(7);
- _mem.repr(getNumberOfComponents(),stream);
-}
-
void DataArrayFloat::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples(getNumberOfTuples()),nbComp(getNumberOfComponents());
stream << "]";
}
-std::string DataArrayFloat::reprNotTooLong() const
-{
- std::ostringstream ret;
- reprNotTooLongStream(ret);
- return ret.str();
-}
-
-void DataArrayFloat::reprNotTooLongStream(std::ostream& stream) const
-{
- stream << "Name of float array : \"" << _name << "\"\n";
- reprNotTooLongWithoutNameStream(stream);
-}
-
-void DataArrayFloat::reprNotTooLongWithoutNameStream(std::ostream& stream) const
-{
- DataArray::reprWithoutNameStream(stream);
- stream.precision(7);
- _mem.reprNotTooLong(getNumberOfComponents(),stream);
-}
-
bool DataArrayFloat::isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const
{
if(!areInfoEqualsIfNotWhy(other,reason))
const char Traits<double>::NPYStr[]="FLOAT64";
+const char Traits<double>::ReprStr[]="double";
+
const char Traits<float>::ArrayTypeName[]="DataArrayFloat";
const char Traits<float>::FieldTypeName[]="MEDCouplingFieldFloat";
const char Traits<float>::NPYStr[]="FLOAT32";
+const char Traits<float>::ReprStr[]="float";
+
const char Traits<int>::ArrayTypeName[]="DataArrayInt";
const char Traits<int>::FieldTypeName[]="MEDCouplingFieldInt";
+const char Traits<int>::NPYStr[]="INT32";
+
+const char Traits<int>::ReprStr[]="int";
+
const char Traits<char>::ArrayTypeName[]="DataArrayChar";
const char Traits<Int64>::ArrayTypeName[]="DataArrayInt64";
const char Traits<Int64>::FieldTypeName[]="MEDCouplingFieldInt64";
const char Traits<Int64>::NPYStr[]="INT64";
+
+const char Traits<Int64>::ReprStr[]="int64";
static const char ArrayTypeName[];
static const char FieldTypeName[];
static const char NPYStr[];
+ static const char ReprStr[];
typedef DataArrayDouble ArrayType;
typedef DataArrayDouble ArrayTypeCh;
typedef MEDCouplingFieldDouble FieldType;
static const char ArrayTypeName[];
static const char FieldTypeName[];
static const char NPYStr[];
+ static const char ReprStr[];
typedef DataArrayFloat ArrayType;
typedef DataArrayFloat ArrayTypeCh;
typedef MEDCouplingFieldFloat FieldType;
{
static const char ArrayTypeName[];
static const char FieldTypeName[];
+ static const char NPYStr[];
+ static const char ReprStr[];
typedef DataArrayInt32 ArrayType;
typedef DataArrayInt32 ArrayTypeCh;
typedef MEDCouplingFieldInt FieldType;
static const char ArrayTypeName[];
static const char FieldTypeName[];
static const char NPYStr[];
+ static const char ReprStr[];
typedef DataArrayInt64 ArrayType;
typedef DataArrayInt64 ArrayTypeCh;
//typedef MEDCouplingFieldInt64 FieldType;