Changeset 3750 in Sophya for trunk


Ignore:
Timestamp:
Mar 3, 2010, 9:44:38 PM (16 years ago)
Author:
ansari
Message:

Prise en charge de float 128 bits (r_16, complex<r_16>) par les NDataBlock<T> et PPersist, controlee par le flag de compilation SO_LDBLE128 defini ds machdefs.h , Reza 03/03/2010

Location:
trunk/SophyaLib/BaseTools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/datatype.cc

    r3619 r3750  
    3131  else if (typeid(T) == typeid(complex<r_4>)) return(" complex<r_4> ");
    3232  else if (typeid(T) == typeid(complex<r_8>)) return(" complex<r_8> ");
     33#ifdef SO_LDBLE128
     34  else if (typeid(T) == typeid(r_16)) return("r_16");
     35  else if (typeid(T) == typeid(complex<r_16>)) return(" complex<r_16> ");
     36#endif
    3337  else return("???unknowntype???");
    3438}
     
    4852  else if (typeid(T) == typeid(complex<r_4>)) return(11);
    4953  else if (typeid(T) == typeid(complex<r_8>)) return(12);
     54#ifdef SO_LDBLE128
     55  else if (typeid(T) == typeid(r_16)) return(13);
     56  else if (typeid(T) == typeid(complex<r_16>)) return(14);
     57#endif
    5058  else return(0);
    5159}
     
    7886DECL_TEMP_SPEC
    7987string DataTypeInfo< complex<r_8> >::getTypeName() { return(" complex<r_8> "); }
    80 
     88#ifdef SO_LDBLE128
     89DECL_TEMP_SPEC
     90string DataTypeInfo<r_16>::getTypeName() { return("r_16"); }
     91DECL_TEMP_SPEC
     92string DataTypeInfo< complex<r_16> >::getTypeName() { return(" complex<r_16> "); }
     93#endif
    8194/*!
    8295  \ brief Return an identifier associated to T
     
    114127DECL_TEMP_SPEC
    115128int DataTypeInfo< complex<r_8> >::getTypeId() { return(12); }
     129#ifdef SO_LDBLE128
     130DECL_TEMP_SPEC
     131int DataTypeInfo<r_16>::getTypeId() { return(13); }
     132DECL_TEMP_SPEC
     133int DataTypeInfo< complex<r_16> >::getTypeId() { return(14); }
     134#endif
     135
    116136#endif
    117137
     
    185205#pragma define_template DataTypeInfo< complex<r_4> >
    186206#pragma define_template DataTypeInfo< complex<r_8> >
     207#ifdef SO_LDBLE128
     208#pragma define_template DataTypeInfo<r_16>
     209#pragma define_template DataTypeInfo< complex<r_16> >
     210#endif
     211
    187212#endif
    188213
     
    200225template class DataTypeInfo< complex<r_4> >;
    201226template class DataTypeInfo< complex<r_8> >;
     227#ifdef SO_LDBLE128
     228template class DataTypeInfo<r_16>;
     229template class DataTypeInfo< complex<r_16> >;
     230#endif
     231
    202232#endif
    203233
  • trunk/SophyaLib/BaseTools/fiondblock.cc

    r3661 r3750  
    139139inline void PIOSReadArray(PInPersist & is, complex<double> * arr, size_t n)
    140140{ r_8 * pr = (r_8 *)arr; is.Get(pr, n*2); }
     141#ifdef SO_LDBLE128
     142// ces fonctions ne devraient jamais etre appelees ( pas de r_16 en V_PPF <= 3 )
     143inline void PIOSReadArray(PInPersist & is, r_16 * arr, size_t n) 
     144{ is.Get(arr, n); } 
     145inline void PIOSReadArray(PInPersist & is, complex<long double> * arr, size_t n)
     146{ r_16 * pr = (r_16 *)arr; is.Get(pr, n*2); }
     147#endif
    141148//---------------------------------------------------------------------------
    142149
     
    196203#pragma define_template FIO_NDataBlock< complex<r_4> >
    197204#pragma define_template FIO_NDataBlock< complex<r_8> >
     205#ifdef SO_LDBLE128
     206#pragma define_template FIO_NDataBlock<r_16>
     207#pragma define_template FIO_NDataBlock< complex<r_16> >
     208#endif
     209
    198210#endif
    199211
     
    213225template class FIO_NDataBlock< complex<r_4> >;
    214226template class FIO_NDataBlock< complex<r_8> >;
    215 }
    216 #endif
     227#ifdef SO_LDBLE128
     228template class FIO_NDataBlock<r_16>;
     229template class FIO_NDataBlock< complex<r_16> >;
     230#endif
     231}
     232#endif
  • trunk/SophyaLib/BaseTools/machdefs_mkmf.h

    r3535 r3750  
    66  - SO_NOFPIC  : disable fPIC flag (Position Independent Code) default fPIC enabled
    77  - SO_SASIZET64 : select 64 bits size for array indices (default 32 bits)
     8  - SO_LDBLE128  : enable support for 128 bits floating point numbers (default NO 128 bits floats)
    89  - SO_BOUNDCHECKING : activate bound checking (in accessing array elements)
    910  - SOPHYA_DEBUG : debug flag ( --> if set, SO_BOUNDCHECKING is also set)
     
    8384typedef float r_4;
    8485typedef double r_8;
     86#ifdef SO_LDBLE128
     87/* 128 bits floating point numbers */
     88typedef long double r_16;
     89#endif
    8590
    8691/* --------------------------------------------------------------- */
  • trunk/SophyaLib/BaseTools/mutyv.h

    r3661 r3750  
    6464  inline MuTyV & operator= (r_4 v)  { typ = MTVFloat; dv = (r_8)v; iv = (int_8)v;  dv_im = 0.;  return(*this); }
    6565  inline MuTyV & operator= (r_8 v) { typ = MTVFloat; dv = v; iv = (int_8)v;  dv_im = 0.;  return(*this); }
    66   inline MuTyV & operator= (complex<r_4> const& v) { typ = MTVComplex; dv = (r_8)v.real();  dv_im = v.imag();
     66  inline MuTyV & operator= (complex<r_4> const& v) { typ = MTVComplex; dv = (r_8)v.real();  dv_im = (r_8)v.imag();
    6767                                                    iv = (int_8)dv;  return(*this); }
    6868  inline MuTyV & operator= (complex<r_8> const& v) { typ = MTVComplex; dv = (r_8)v.real();  dv_im = v.imag();
    6969                                                    iv = (int_8)dv;  return(*this); }
    70          const char*  operator= (const char* s);
    71          string const& operator= (string const & s);
    72          TimeStamp const& operator= (TimeStamp const & s);
     70#ifdef SO_LDBLE128
     71  inline MuTyV & operator= (r_16 v) { typ = MTVFloat; dv = (r_8)v; iv = (int_8)v;  dv_im = 0.;  return(*this); }
     72  inline MuTyV & operator= (complex<r_16> const& v) { typ = MTVComplex; dv = (r_8)v.real();  dv_im = (r_8)v.imag();
     73                                                    iv = (int_8)dv;  return(*this); }
     74#endif
     75  const char*  operator= (const char* s);
     76  string const& operator= (string const & s);
     77  TimeStamp const& operator= (TimeStamp const & s);
    7378
    7479  inline operator uint_1() const { return((uint_1)iv); }
     
    8489  inline operator complex<r_4>() const { return(complex<r_4>((r_4)dv, (r_4)dv_im)); }
    8590  inline operator complex<r_8>() const { return(complex<r_8>(dv, dv_im)); }
     91#ifdef SO_LDBLE128
     92  inline operator r_16() const  { return((r_16)dv); }
     93  inline operator complex<r_16>() const { return(complex<r_16>((r_16)dv, (r_16)dv_im)); }
     94#endif
    8695
    87          operator string() const ;
    88          operator TimeStamp() const ;
     96  operator string() const ;
     97  operator TimeStamp() const ;
    8998
    9099  inline uint_1 Convert(uint_1& x) const { x = (uint_1)iv; return x; }
     
    102111  inline complex<r_8> Convert(complex<r_8> & x) const
    103112    { x = complex< r_8 > (dv, dv_im); return x; }
    104  
     113#ifdef SO_LDBLE128
     114  inline r_16 Convert(r_16& x) const { x = (r_16)dv; return x; }
     115  inline complex<r_16> Convert(complex<r_16> & x) const
     116    { x = complex< r_16 > ((r_16)dv, (r_16)dv_im); return x; }
     117#endif 
    105118  string&  Convert(string& x) const ;
    106119  TimeStamp& Convert(TimeStamp& x) const ;
  • trunk/SophyaLib/BaseTools/ndatablock.cc

    r3661 r3750  
    822822#pragma define_template NDataBlock< complex<r_4> >
    823823#pragma define_template NDataBlock< complex<r_8> >
     824#ifdef SO_LDBLE128
     825#pragma define_template NDataBlock<r_16>
     826#pragma define_template NDataBlock< complex<r_16> >
     827#endif
     828
    824829#endif
    825830
     
    838843template class NDataBlock< complex<r_4> >;
    839844template class NDataBlock< complex<r_8> >;
    840 }
     845#ifdef SO_LDBLE128
     846template class NDataBlock<r_16>;
     847template class NDataBlock< complex<r_16> >;
    841848#endif
     849}
     850#endif
  • trunk/SophyaLib/BaseTools/ppfbinstream.cc

    r3619 r3750  
    2121
    2222
     23static inline void bswap16(void* p)
     24{
     25  uint_8* p8 = (uint_8*)p;
     26  uint_8 tmp1 = *(p8);
     27  uint_8 tmp = *(p8+1);
     28  *(p8)   = ((tmp >> (7*8)) & 0x000000FF) |
     29            ((tmp >> (5*8)) & 0x0000FF00) |
     30            ((tmp >> (3*8)) & 0x00FF0000) |
     31            ((tmp >> (1*8)) & 0xFF000000) |
     32            ((tmp & 0xFF000000) << (1*8))  |
     33            ((tmp & 0x00FF0000) << (3*8))  |
     34            ((tmp & 0x0000FF00) << (5*8))  |
     35            ((tmp & 0x000000FF) << (7*8));
     36  *(p8+1) = ((tmp1 >> (7*8)) & 0x000000FF) |
     37            ((tmp1 >> (5*8)) & 0x0000FF00) |
     38            ((tmp1 >> (3*8)) & 0x00FF0000) |
     39            ((tmp1 >> (1*8)) & 0xFF000000) |
     40            ((tmp1 & 0xFF000000) << (1*8))  |
     41            ((tmp1 & 0x00FF0000) << (3*8))  |
     42            ((tmp1 & 0x0000FF00) << (5*8))  |
     43            ((tmp1 & 0x000000FF) << (7*8));
     44}
     45
    2346static inline void bswap8(void* p)
    2447{
     
    4871  *(uint_2*)p = ((tmp >> 8) & 0x00FF) |
    4972                ((tmp & 0x00FF) << 8);
     73}
     74
     75// Convertit la taille de donnees (2 (int_2), 4 (int_4, r_4), 8 (r_8) ...) en taille codee dans le tag
     76static inline unsigned char datasize2tagsize( unsigned char sz)
     77{
     78  // Taille permises 1,2,4,8,16
     79  // Pour les tailles <= 8, c'est directement la taille
     80  if (sz<=8) return sz;
     81  else {
     82    if (sz==16) return 10;
     83    else return 0;  // signale une erreur
     84  }
     85}
     86// Convertit la taille codee dans le tag en taille de donnees (2 (int_2), 4 (int_4, r_4), 8 (r_8) ...) en
     87static inline unsigned char tagsize2datasize( unsigned char sz)
     88{
     89  // Taille permises 1,2,4,8,16
     90  // Pour les tailles <= 8, c'est directement la taille
     91  if (sz<=8) return sz;
     92  else {
     93    if (sz==10) return 10;
     94    else return 0;  // signale une erreur
     95  }
    5096}
    5197
     
    653699
    654700void
    655 PPFBinaryInputStream::CheckTag(short datasz, short datatype)
     701PPFBinaryInputStream::CheckTag(unsigned char datasz, unsigned char datatype)
    656702// datatype = PPS_DATATYPE_CHAR or PPS_DATATYPE_FLOAT or PPS_DATATYPE_INTEGER or PPS_DATATYPE_UNSIGNED
    657703{
    658704  unsigned char ppstype;
    659705  GetTypeTag(ppstype);
    660   if (ppstype != PPS_SIMPLE + datasz + datatype)
     706  if (ppstype != PPS_SIMPLE + datasize2tagsize(datasz) + datatype)
    661707    throw FileFormatExc("PPFBinaryInputStream::CheckTag   bad type in ppersist file");
    662708}
    663709
    664710void
    665 PPFBinaryInputStream::CheckArrayTag(short datasz, size_t sz, short datatype)
     711PPFBinaryInputStream::CheckArrayTag(unsigned char datasz, size_t sz, unsigned char datatype)
    666712// datatype = PPS_DATATYPE_CHAR or PPS_DATATYPE_FLOAT or PPS_DATATYPE_INTEGER or PPS_DATATYPE_UNSIGNED
    667713{
     
    670716  size_t filesz;
    671717  if (sz <= 0x7fffffff) {
    672     if (ppstype != PPS_SIMPLE_ARRAY4 + datasz + datatype)
     718    if (ppstype != PPS_SIMPLE_ARRAY4 + datasize2tagsize(datasz) + datatype)
    673719      throw FileFormatExc("PPFBinaryInputStream::CheckArrayTag   bad type in ppersist file");
    674720    int_4 ff;
    675721    GetRawI4(ff); filesz=ff;
    676722  } else {
    677     if (ppstype != PPS_SIMPLE_ARRAY8 + datasz + datatype)
     723    if (ppstype != PPS_SIMPLE_ARRAY8 + datasize2tagsize(datasz) + datatype)
    678724      throw FileFormatExc("PPFBinaryInputStream::CheckArrayTag   bad type in ppersist file");
    679725    uint_8 ff;
     
    691737}
    692738
    693 
    694739void
    695740PPFBinaryInputStream::GetBytes(void* ptr, size_t bytes)
     
    698743  GetRawBytes(ptr, bytes);
    699744}
     745
    700746void
    701747PPFBinaryInputStream::GetR4   (r_4& result)
     
    715761  if (bigEndian == IS_BIG_ENDIAN) return;
    716762
    717   for (unsigned int i=0; i<n; i++)
    718     bswap4(tab+i);
     763  for (size_t i=0; i<n; i++)  bswap4(tab+i);
    719764
    720765  return;
     
    737782  if (bigEndian == IS_BIG_ENDIAN) return;
    738783
    739   for (unsigned int i=0; i<n; i++)
    740     bswap8(tab+i);
     784  for (size_t i=0; i<n; i++)  bswap8(tab+i);
    741785
    742786  return;
     
    787831  if (bigEndian == IS_BIG_ENDIAN) return;
    788832
    789   for (unsigned int i=0; i<n; i++)
    790     bswap2(tab+i);
     833  for (size_t i=0; i<n; i++)  bswap2(tab+i);
    791834
    792835  return;
     
    809852  if (bigEndian == IS_BIG_ENDIAN) return;
    810853
    811   for (unsigned int i=0; i<n; i++)
    812     bswap2(tab+i);
     854  for (size_t i=0; i<n; i++)  bswap2(tab+i);
    813855
    814856  return;
     
    831873  if (bigEndian == IS_BIG_ENDIAN) return;
    832874
    833   for (unsigned int i=0; i<n; i++)
    834     bswap4(tab+i);
     875  for (size_t i=0; i<n; i++)  bswap4(tab+i);
    835876
    836877  return;
     
    853894  if (bigEndian == IS_BIG_ENDIAN) return;
    854895
    855   for (unsigned int i=0; i<n; i++)
    856     bswap4(tab+i);
     896  for (size_t i=0; i<n; i++)  bswap4(tab+i);
    857897
    858898  return;
     
    876916  if (bigEndian == IS_BIG_ENDIAN) return;
    877917
    878   for (unsigned int i=0; i<n; i++)
    879     bswap8(tab+i);
     918  for (size_t i=0; i<n; i++)  bswap8(tab+i);
    880919
    881920  return;
     
    898937  if (bigEndian == IS_BIG_ENDIAN) return;
    899938
    900   for (unsigned int i=0; i<n; i++)
    901     bswap8(tab+i);
     939  for (size_t i=0; i<n; i++)  bswap8(tab+i);
    902940
    903941  return;
     
    951989
    952990  r_4 * p = (r_4 *)tab;
    953   for (unsigned int i=0; i<n; i++) {
     991  for (size_t i=0; i<n; i++) {
    954992    bswap4(p);  p++;
    955993    bswap4(p);  p++;
     
    9791017
    9801018  r_8 * p = (r_8 *)tab;
    981   for (unsigned int i=0; i<n; i++) {
     1019  for (size_t i=0; i<n; i++) {
    9821020    bswap8(p);  p++;
    9831021    bswap8(p);  p++;
     
    9861024}
    9871025
     1026// Support pour les long double (128 bits floating point numbers)
     1027#ifdef SO_LDBLE128
     1028void
     1029PPFBinaryInputStream::GetR16  (r_16& result)
     1030{
     1031  CheckTag(16,PPS_DATATYPE_FLOAT);
     1032  GetRawBytes(&result, sizeof(r_16));
     1033  if (bigEndian != IS_BIG_ENDIAN)
     1034    bswap16(&result);
     1035}
     1036
     1037void
     1038PPFBinaryInputStream::GetR16s  (r_16* tab, size_t n)
     1039{
     1040  CheckArrayTag(16,n,PPS_DATATYPE_FLOAT);
     1041  GetRawBytes(tab, n*sizeof(r_16));
     1042  if (bigEndian == IS_BIG_ENDIAN) return;
     1043
     1044  for (size_t i=0; i<n; i++)  bswap16(tab+i);
     1045
     1046  return;
     1047}
     1048
     1049void
     1050PPFBinaryInputStream::GetZ16   (complex<r_16>& result)
     1051{
     1052  CheckTag(16,PPS_DATATYPE_COMPLEX);
     1053  r_16 reim[2];
     1054  GetRawBytes(reim, 2*sizeof(r_16));
     1055  if (bigEndian != IS_BIG_ENDIAN) {
     1056    bswap16(reim);
     1057    bswap16(reim+1);
     1058  }
     1059  result = complex<r_16>(reim[0], reim[1]);
     1060}
     1061
     1062void
     1063PPFBinaryInputStream::GetZ16s  (complex<r_16>* tab, size_t n)
     1064{
     1065  CheckArrayTag(16,n,PPS_DATATYPE_COMPLEX);
     1066  GetRawBytes(tab, n*2*sizeof(r_16));
     1067  if (bigEndian == IS_BIG_ENDIAN) return;
     1068
     1069  r_16 * p = (r_16 *)tab;
     1070  for (size_t i=0; i<n; i++) {
     1071    bswap16(p);  p++;
     1072    bswap16(p);  p++;
     1073  }
     1074  return;
     1075}
     1076#endif
    9881077
    9891078void
     
    11851274      else if (ppst3 == PPS_DATATYPE_INTEGER) dtype = "INTEGER x";
    11861275      else if (ppst3 == PPS_DATATYPE_UNSIGNED) dtype = "UNSIGNED x";
    1187       int_4 dsize = ppst1;
     1276      int_4 dsize = (int_4)tagsize2datasize(ppst1);
    11881277      int_8 dsizeskip = dsize;
    11891278      if (ppst30 == PPS_DATATYPE_COMPLEX) {
     
    12361325
    12371326
    1238 //++
    1239 // Class        POutPersist
    1240 // Lib          Outils++
    1241 // include      ppersist.h
    1242 //
    1243 //      Fichier d'objets persistants, en écriture.
    1244 //--
    1245 
    1246 
    1247 //++
    1248 //  POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE)
    1249 //
    1250 //      Crée un nouveau fichier ppersist. Par défaut, il est petit=boutien
    1251 //      sur machines petit-boutiennes, et gros-boutien sur machines
    1252 //      gros-boutiennes. On peut explicitement spécifier PPersist::PPS_LITTLE_ENDIAN
    1253 //      ou PPersist::PPS_BIG_ENDIAN.
    1254 //--
    1255 
    12561327/*!
    12571328   \class SOPHYA::PPFBinaryInputStream
     
    13021373  version = 3;
    13031374  // Header
    1304   PutRawBytes("SOS-SOPHYA-PPersistFile V3               ",32);
     1375  PutRawBytes("SOS-SOPHYA-PPersistFile V4               ",32);
    13051376  PutRawBytes(bigEndian
    13061377           ? "BIG-ENDIAN                             "
     
    14821553
    14831554void
    1484 PPFBinaryOutputStream::PutArrayTag(short datasz, size_t sz, short datatype)
     1555PPFBinaryOutputStream::PutArrayTag(unsigned char datasz, size_t sz, unsigned char datatype)
    14851556// datatype = PPS_DATATYPE_CHAR or PPS_DATATYPE_FLOAT or PPS_DATATYPE_INTEGER or PPS_DATATYPE_UNSIGNED
    14861557{
    14871558  if (sz <= 0x7fffffff) {
    1488     PutRawUByte(PPS_SIMPLE_ARRAY4 + datasz + datatype);
     1559    PutRawUByte(PPS_SIMPLE_ARRAY4 + datasize2tagsize(datasz) + datatype);
    14891560    PutRawI4(sz);
    14901561  } else {
    1491     PutRawUByte(PPS_SIMPLE_ARRAY8 + datasz + datatype);
     1562    PutRawUByte(PPS_SIMPLE_ARRAY8 + datasize2tagsize(datasz) + datatype);
    14921563    PutRawU8(sz);
    14931564  }
     
    14971568PPFBinaryOutputStream::PutByte(char c)
    14981569{
    1499   PutRawByte(PPS_SIMPLE + 1 + PPS_DATATYPE_CHAR);
     1570  PutRawByte(PPS_SIMPLE + datasize2tagsize(1) + PPS_DATATYPE_CHAR);
    15001571  PutRawBytes(&c, 1);
    15011572}
     
    15131584PPFBinaryOutputStream::PutR4   (r_4 val)
    15141585{
    1515   PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_FLOAT);
     1586  PutRawUByte(PPS_SIMPLE + datasize2tagsize(4) + PPS_DATATYPE_FLOAT);
    15161587 
    15171588  if (bigEndian != IS_BIG_ENDIAN)
     
    15291600    PutRawBytes(tab, n*sizeof(r_4));
    15301601  } else {
    1531     for (unsigned int i=0; i<n; i++) {
     1602    for (size_t i=0; i<n; i++) {
    15321603      r_4 val = tab[i];
    15331604      bswap4(&val);
     
    15401611PPFBinaryOutputStream::PutR8   (r_8 val)
    15411612{
    1542   PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_FLOAT);
     1613  PutRawUByte(PPS_SIMPLE + datasize2tagsize(8) + PPS_DATATYPE_FLOAT);
    15431614
    15441615  if (bigEndian != IS_BIG_ENDIAN)
     
    15561627    PutRawBytes(tab, n*sizeof(r_8));
    15571628  } else {
    1558     for (unsigned int i=0; i<n; i++) {
     1629    for (size_t i=0; i<n; i++) {
    15591630      r_8 val = tab[i];
    15601631      bswap8(&val);
     
    15671638PPFBinaryOutputStream::PutI1   (int_1 val)
    15681639{
    1569   PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_INTEGER);
     1640  PutRawUByte(PPS_SIMPLE + datasize2tagsize(1) + PPS_DATATYPE_INTEGER);
    15701641  PutRawBytes(&val, sizeof(int_1));
    15711642}
     
    15811652PPFBinaryOutputStream::PutU1   (uint_1 val)
    15821653{
    1583   PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_UNSIGNED);
     1654  PutRawUByte(PPS_SIMPLE + datasize2tagsize(1) + PPS_DATATYPE_UNSIGNED);
    15841655  PutRawBytes(&val, sizeof(uint_1));
    15851656}
     
    15951666PPFBinaryOutputStream::PutI2   (int_2 val)
    15961667{
    1597   PutRawUByte(PPS_SIMPLE + 2 + PPS_DATATYPE_INTEGER);
     1668  PutRawUByte(PPS_SIMPLE + datasize2tagsize(2) + PPS_DATATYPE_INTEGER);
    15981669
    15991670  if (bigEndian != IS_BIG_ENDIAN)
     
    16111682    PutRawBytes(tab, n*sizeof(int_2));
    16121683  } else {
    1613     for (unsigned int i=0; i<n; i++) {
     1684    for (size_t i=0; i<n; i++) {
    16141685      int_2 val = tab[i];
    16151686      bswap2(&val);
     
    16221693PPFBinaryOutputStream::PutU2   (uint_2 val)
    16231694{
    1624   PutRawUByte(PPS_SIMPLE + 2 + PPS_DATATYPE_UNSIGNED);
     1695  PutRawUByte(PPS_SIMPLE + datasize2tagsize(2) + PPS_DATATYPE_UNSIGNED);
    16251696
    16261697  if (bigEndian != IS_BIG_ENDIAN)
     
    16381709    PutRawBytes(tab, n*sizeof(uint_2));
    16391710  } else {
    1640     for (unsigned int i=0; i<n; i++) {
     1711    for (size_t i=0; i<n; i++) {
    16411712      uint_2 val = tab[i];
    16421713      bswap2(&val);
     
    16491720PPFBinaryOutputStream::PutI4   (int_4 val)
    16501721{
    1651   PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_INTEGER);
     1722  PutRawUByte(PPS_SIMPLE + datasize2tagsize(4) + PPS_DATATYPE_INTEGER);
    16521723
    16531724  if (bigEndian != IS_BIG_ENDIAN)
     
    16651736    PutRawBytes(tab, n*sizeof(int_4));
    16661737  } else {
    1667     for (unsigned int i=0; i<n; i++) {
     1738    for (size_t i=0; i<n; i++) {
    16681739      int_4 val = tab[i];
    16691740      bswap4(&val);
     
    16761747PPFBinaryOutputStream::PutU4   (uint_4 val)
    16771748{
    1678   PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_UNSIGNED);
     1749  PutRawUByte(PPS_SIMPLE + datasize2tagsize(4) + PPS_DATATYPE_UNSIGNED);
    16791750
    16801751  if (bigEndian != IS_BIG_ENDIAN)
     
    16921763    PutRawBytes(tab, n*sizeof(uint_4));
    16931764  } else {
    1694     for (unsigned int i=0; i<n; i++) {
     1765    for (size_t i=0; i<n; i++) {
    16951766      uint_4 val = tab[i];
    16961767      bswap4(&val);
     
    17031774PPFBinaryOutputStream::PutI8   (int_8 val)
    17041775{
    1705   PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_INTEGER);
     1776  PutRawUByte(PPS_SIMPLE + datasize2tagsize(8) + PPS_DATATYPE_INTEGER);
    17061777
    17071778  if (bigEndian != IS_BIG_ENDIAN)
     
    17191790    PutRawBytes(tab, n*sizeof(int_8));
    17201791  } else {
    1721     for (unsigned int i=0; i<n; i++) {
     1792    for (size_t i=0; i<n; i++) {
    17221793      int_8 val = tab[i];
    17231794      bswap8(&val);
     
    17301801PPFBinaryOutputStream::PutU8   (uint_8 val)
    17311802{
    1732   PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_UNSIGNED);
     1803  PutRawUByte(PPS_SIMPLE + datasize2tagsize(8) + PPS_DATATYPE_UNSIGNED);
    17331804
    17341805  if (bigEndian != IS_BIG_ENDIAN)
     
    17461817    PutRawBytes(tab, n*sizeof(uint_8));
    17471818  } else {
    1748     for (unsigned int i=0; i<n; i++) {
     1819    for (size_t i=0; i<n; i++) {
    17491820      uint_8 val = tab[i];
    17501821      bswap8(&val);
     
    17731844PPFBinaryOutputStream::PutZ4   (complex<r_4> val)
    17741845{
    1775   PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_COMPLEX);
     1846  PutRawUByte(PPS_SIMPLE + datasize2tagsize(4) + PPS_DATATYPE_COMPLEX);
    17761847  r_4 reim[2];
    17771848  reim[0] = val.real();
     
    17921863    PutRawBytes(tab, n*2*sizeof(r_4));
    17931864  } else {
    1794     for (unsigned int i=0; i<n; i++) {
     1865    for (size_t i=0; i<n; i++) {
    17951866      r_4 reim[2];
    17961867      reim[0] = tab[i].real();
     
    18061877PPFBinaryOutputStream::PutZ8   (complex<r_8> val)
    18071878{
    1808   PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_COMPLEX);
     1879  PutRawUByte(PPS_SIMPLE + datasize2tagsize(8) + PPS_DATATYPE_COMPLEX);
    18091880  r_8 reim[2];
    18101881  reim[0] = val.real();
     
    18251896    PutRawBytes(tab, n*2*sizeof(r_8));
    18261897  } else {
    1827     for (unsigned int i=0; i<n; i++) {
     1898    for (size_t i=0; i<n; i++) {
    18281899      r_8 reim[2];
    18291900      reim[0] = tab[i].real();
     
    18361907}
    18371908
     1909// Support pour les long double (128 bits floating point numbers)
     1910#ifdef SO_LDBLE128
     1911void
     1912PPFBinaryOutputStream::PutR16   (r_16 val)
     1913{
     1914  PutRawUByte(PPS_SIMPLE + datasize2tagsize(16) + PPS_DATATYPE_FLOAT);
     1915
     1916  if (bigEndian != IS_BIG_ENDIAN)
     1917    bswap16(&val);
     1918
     1919  PutRawBytes(&val, sizeof(r_16));
     1920}
     1921
     1922void
     1923PPFBinaryOutputStream::PutR16s  (r_16 const* tab, size_t n)
     1924{
     1925  PutArrayTag(16, n, PPS_DATATYPE_FLOAT);
     1926
     1927  if (bigEndian == IS_BIG_ENDIAN) {
     1928    PutRawBytes(tab, n*sizeof(r_16));
     1929  } else {
     1930    for (size_t i=0; i<n; i++) {
     1931      r_16 val = tab[i];
     1932      bswap16(&val);
     1933      PutRawBytes(&val, sizeof(r_16));
     1934    }
     1935  }
     1936}
     1937
     1938void
     1939PPFBinaryOutputStream::PutZ16   (complex<r_16> val)
     1940{
     1941  PutRawUByte(PPS_SIMPLE + datasize2tagsize(16) + PPS_DATATYPE_COMPLEX);
     1942  r_16 reim[2];
     1943  reim[0] = val.real();
     1944  reim[1] = val.imag();
     1945  if (bigEndian != IS_BIG_ENDIAN) {
     1946    bswap16(reim);
     1947    bswap16(reim+1);
     1948  }
     1949  PutRawBytes(reim, 2*sizeof(r_16));
     1950}
     1951
     1952void
     1953PPFBinaryOutputStream::PutZ16s  (complex<r_16> const* tab, size_t n)
     1954{
     1955  PutArrayTag(16, n, PPS_DATATYPE_COMPLEX);
     1956
     1957  if (bigEndian == IS_BIG_ENDIAN) {
     1958    PutRawBytes(tab, n*2*sizeof(r_16));
     1959  } else {
     1960    for (size_t i=0; i<n; i++) {
     1961      r_16 reim[2];
     1962      reim[0] = tab[i].real();
     1963      reim[1] = tab[i].imag();
     1964      bswap16(reim);
     1965      bswap16(reim+1);
     1966      PutRawBytes(reim, 2*sizeof(r_16));
     1967    }
     1968  }
     1969}
     1970#endif
     1971
    18381972void
    18391973PPFBinaryOutputStream::PutPosTagTable(int_8 const * ptab, size_t sz)
  • trunk/SophyaLib/BaseTools/ppfbinstream.h

    r2485 r3750  
    142142  void   GetZ8   (complex<r_8> &);
    143143  void   GetZ8s  (complex<r_8> *, size_t);
     144#ifdef SO_LDBLE128
     145  void   GetR16  (r_16&);
     146  void   GetR16s (r_16*, size_t);
     147  void   GetZ16  (complex<r_16> &);
     148  void   GetZ16s (complex<r_16> *, size_t);
     149#endif
    144150 
    145151  inline void   Get(char&   c) {GetByte(c);}
     
    170176  inline void   Get(complex<r_4> * x, size_t n) { GetZ4s(x, n); }
    171177  inline void   Get(complex<r_8> * x, size_t n) { GetZ8s(x, n); }
    172  
     178#ifdef SO_LDBLE128
     179  inline void   Get(r_16&   x) {GetR16(x);}
     180  inline void   Get(r_16*   x, size_t n) {GetR16s(x,n);}
     181  inline void   Get(complex<r_16> & x) {GetZ16(x);}
     182  inline void   Get(complex<r_16> * x, size_t n) { GetZ16s(x, n); }
     183#endif 
    173184  // Reading a list (table) of position tags
    174185  void    GetPosTagTable(int_8*, size_t);
     
    184195  void   SkipItem(bool fgrdi=true, unsigned char itag=0);
    185196
    186   void   CheckTag   (short datasz, short datatype);
    187   void   CheckArrayTag(short datasz, size_t sz, short datatype);
     197  void   CheckTag   (unsigned char datasz, unsigned char datatype);
     198  void   CheckArrayTag(unsigned char datasz, size_t sz, unsigned char datatype);
    188199  void   GetTypeTag (unsigned char& c);
    189200  void   GetRawByte (char& c);
     
    245256  void PutZ8   (complex<r_8>);
    246257  void PutZ8s  (complex<r_8> const*, size_t);
    247  
     258#ifdef SO_LDBLE128
     259  void PutR16  (r_16);
     260  void PutR16s (r_16 const*, size_t);
     261  void PutZ16  (complex<r_16>);
     262  void PutZ16s (complex<r_16> const*, size_t);
     263#endif 
    248264 
    249265  void   Put(char   c) {PutByte(c);}
     
    264280  void   Put(complex<r_4> const*    x, size_t n) {PutZ4s(x,n);}
    265281  void   Put(complex<r_8> const*    x, size_t n) {PutZ8s(x,n);}
     282#ifdef SO_LDBLE128
     283  void   Put(r_16   x) {PutR16(x);}
     284  void   Put(r_16 const*   x, size_t n) {PutR16s(x,n);}
     285  void   Put(complex<r_16>  x) {PutZ16(x);}
     286  void   Put(complex<r_16> const*   x, size_t n) {PutZ16s(x,n);}
     287#endif
    266288  void   Put(uint_1 const* x, size_t n) {PutU1s(x,n);}
    267289  void   Put(int_1 const*  x, size_t n) {PutI1s(x,n);}
     
    284306  void     WriteNameTagTableV2();
    285307
    286   void     PutArrayTag(short datasz, size_t sz, short datatype);
     308  void     PutArrayTag(unsigned char datasz, size_t sz, unsigned char datatype);
    287309  void     PutRawByte (char);
    288310  void     PutRawUByte (unsigned char);
  • trunk/SophyaLib/BaseTools/sophyainit.cc

    r3663 r3750  
    3636//  - Exceptions sophya heritent de std::exception  (mars 09)
    3737//  - Extension / ajout de classes generateur aleatoires (Mersenne-Twister ...avril 09)     
    38 // Module version number - 2.20 ,  Avr09     
    39 #define MOD_VERS   2.20
     38// Module version number - 2.20 ,  Avr09
     39//  - Ajout type long double (r_16) et prise en chage des r_16 et complex<r_16>
     40//    par les PPersist (fev 2010)
     41// Module version number - 2.30 ,  Fev10
     42     
     43#define MOD_VERS   2.30
    4044
    4145// Pour garder la liste des modules et leurs numeros de version
     
    98102  PPRegister(FIO_NDataBlock< complex<r_8> >);
    99103  DObjRegister(FIO_NDataBlock< complex<r_8> >, NDataBlock< complex<r_8> >);
    100 
     104#ifdef SO_LDBLE128
     105  PPRegister(FIO_NDataBlock<r_16>);
     106  DObjRegister(FIO_NDataBlock<r_16>, NDataBlock<r_16>);
     107  PPRegister(FIO_NDataBlock< complex<r_16> >);
     108  DObjRegister(FIO_NDataBlock< complex<r_16> >, NDataBlock< complex<r_16> >);
     109#endif
    101110  // Enregistrement des handlers PPF pour les TimeStamp
    102111  PPRegister(ObjFileIO<TimeStamp>);
  • trunk/SophyaLib/BaseTools/sversion.h

    r3737 r3750  
    33
    44#define SOPHYA_VERSION   2.1
    5 #define SOPHYA_REVISION  45
    6 #define SOPHYA_TAG       "V_Jan2010"
     5#define SOPHYA_REVISION  50
     6#define SOPHYA_TAG       "V_Mar2010"
    77
    88#endif
Note: See TracChangeset for help on using the changeset viewer.