Changeset 1405 in Sophya for trunk/SophyaLib/HiStats
- Timestamp:
- Feb 15, 2001, 6:58:16 PM (25 years ago)
- Location:
- trunk/SophyaLib/HiStats
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/ntuple.cc
r1371 r1405 16 16 Simple NTuple class (a Table or 2-D data set) with floating value 17 17 columns. 18 \sa SOPHYA::ObjFileIO<NTuple> 19 20 \code 21 #include "ntuple.h" 22 // ... 23 char * names[3] = {"XPos", "YPos", "Val"}; 24 // NTuple (Table) creation with 3 columns 25 NTuple nt(3, names); 26 // Filling the NTuple 27 r_4 x[3]; 28 for(int i=0; i<63; i++) { 29 x[0] = (i%9)-4.; x[1] = (i/9)-3.; x[2] = x[0]*x[0]+x[1]*x[1]; 30 nt.Fill(x); 31 } 32 // Printing table info 33 cout << nt ; 34 // Saving object into a PPF file 35 POutPersist po("nt.ppf"); 36 po << nt ; 37 \endcode 18 38 */ 19 39 … … 32 52 33 53 /* --Methode-- */ 54 //! Default constructor 34 55 //++ 35 56 NTuple::NTuple() … … 46 67 47 68 69 //! Constructor with specification of number of columns and column name 70 /*! 71 \param nvar : Number of columns in the table 72 \param noms : Array of column names (length(name) < 8 characters) 73 \param blk : Optional argument specifying number of table lines 74 in a given data block 75 */ 48 76 //++ 49 77 NTuple::NTuple(int nvar, char** noms, int blk) … … 77 105 } 78 106 107 //! Copy constructor - Copies the table definition and associated data 79 108 // cmv 8/10/99 80 109 //++ … … 108 137 109 138 /* --Methode-- */ 139 //! Constructor with table initialized from a PPF file 110 140 //++ 111 141 NTuple::NTuple(char *flnm) … … 131 161 132 162 /* --Methode-- */ 163 //! Clear the data table definition and deletes the associated data 133 164 void NTuple::Clean() 134 165 { … … 149 180 150 181 /* --Methode-- cmv 08/10/99 */ 182 //! = operator, copies the data table definition and its contents 151 183 //++ 152 184 NTuple& NTuple::operator = (const NTuple& NT) … … 181 213 182 214 /* --Methode-- */ 215 //! Adds an entry (a line) to the table 216 /*! 217 \param x : content of the line to be appended to the table 218 */ 183 219 //++ 184 220 void NTuple::Fill(r_4* x) … … 317 353 318 354 /* --Methode-- */ 355 //! Prints table definition and number of entries 319 356 //++ 320 357 void NTuple::Show(ostream& os) const … … 339 376 340 377 /* --Methode-- */ 378 //! Fills the table, reading lines from an ascii file 379 /*! 380 \param fn : file name 381 \param defval : default value for empty cells in the ascii file 382 */ 341 383 //++ 342 384 int NTuple::FillFromASCIIFile(string const& fn, float defval) … … 544 586 } 545 587 588 /*! 589 \class SOPHYA::ObjFileIO<NTuple> 590 \ingroup HiStats 591 Persistence (serialisation) handler for class NTuple 592 */ 546 593 547 594 /* --Methode-- */ -
trunk/SophyaLib/HiStats/ntuple.h
r1046 r1405 97 97 }; 98 98 99 /*! Prints table information on stream \b s (nt.Show(os)) */ 99 100 inline ostream& operator << (ostream& s, NTuple const & nt) 100 101 { nt.Show(s); return(s); } 101 102 103 /*! Writes the object in the POutPersist stream \b os */ 102 104 inline POutPersist& operator << (POutPersist& os, NTuple & obj) 103 105 { ObjFileIO<NTuple> fio(&obj); fio.Write(os); return(os); } 106 /*! Reads the object from the PInPersist stream \b is */ 104 107 inline PInPersist& operator >> (PInPersist& is, NTuple & obj) 105 108 { ObjFileIO<NTuple> fio(&obj); fio.Read(is); return(is); } -
trunk/SophyaLib/HiStats/xntuple.cc
r1371 r1405 20 20 columns with int, float or string type content. In addition, this class 21 21 can handle large data sets, using swap space on disk. 22 \sa SOPHYA::ObjFileIO<XNTuple> 23 24 \code 25 #include "xntuple.h" 26 // ... 27 char * names[4] = {"X", "X2", "XInt","XStr"}; 28 // XNTuple (Table) creation with 4 columns, of integer, 29 // double(2) and string type 30 XNTuple xnt(2,0,1,1, names); 31 // Filling the NTuple 32 r_8 xd[2]; 33 int_4 xi[2]; 34 char xss[2][32]; 35 char * xs[2] = {xss[0], xss[1]} ; 36 for(int i=0; i<50; i++) { 37 xi[0] = i; xd[0] = i+0.5; xd[1] = xd[0]*xd[0]; 38 sprintf(xs[0],"X=%g", xd[0]); 39 xnt.Fill(xd, NULL, xi, xs); 40 } 41 // Printing table info 42 cout << xnt ; 43 // Saving object into a PPF file 44 POutPersist po("xnt.ppf"); 45 po << xnt ; 46 \endcode 47 22 48 */ 23 49 … … 218 244 //-- 219 245 246 //! Constructor with specification colum types and names 247 /*! 248 \param ndvar : Number of columns with type double (r_8) 249 \param nfvar : Number of columns with type float (r_4) 250 \param nivar : Number of columns with type integer (int_4) 251 \param nsvar : Number of columns with type string 252 \param vnames : Column names (in the order r_8 r_4 int_4 string) 253 (colum names are limited to 31 characters) 254 \param blk : data block size (in number of table lines) 255 \param maxblk : Maximum number of data block in memory 256 \param strsz : string length (for string type columns) 257 */ 220 258 XNTuple::XNTuple(int ndvar, int nfvar, int nivar, int nsvar, 221 259 char** vnames, … … 249 287 250 288 289 //! Constructor with table initialized from a PPF file 251 290 XNTuple::XNTuple(string const& flnm) 252 291 : mNEnt(0), mNBlk(0), mNSwBlk(0), … … 268 307 269 308 309 //! Copy constructor - Copies the table definition and associated data 270 310 XNTuple::XNTuple(XNTuple const& nt) 271 311 : mNEnt(0), mNBlk(0), mNSwBlk(0), … … 294 334 295 335 336 //! Clear the data table definition and deletes the associated data 296 337 void XNTuple::clean() 297 338 { … … 341 382 // Opérateur égal (=) , copie "nt" dans le premier NTuple 342 383 //-- 384 //! Appends an entry (line) to the table 385 /*! 386 \param d_data : double (r_8) line elements 387 \param f_data : float (r_4) line elements 388 \param i_data : integer (int_4) line elements 389 \param s_data : string line elements 390 */ 343 391 void XNTuple::Fill(r_8* d_data, r_4* f_data, int_4* i_data, char** s_data) 344 392 { … … 552 600 //-- 553 601 602 //! Returns the associated DVList object 554 603 DVList& XNTuple::Info() 555 604 { … … 597 646 598 647 648 //! Prints table definition and number of entries 599 649 void XNTuple::Show(ostream& os) const 600 650 { … … 636 686 } 637 687 688 //! NOT YET IMPLEMENTED ! - Fills table from an ascii file 638 689 int XNTuple::FillFromASCIIFile(string const& fn, r_8 ddval, r_4 dfval, 639 690 int dival, const char * dsval) … … 646 697 647 698 699 //! Defines swap file path for XNTuple objects (Default=/tmp) 648 700 void XNTuple::SetSwapPath(char* p) 649 701 { … … 843 895 } 844 896 897 /*! 898 \class SOPHYA::ObjFileIO<XNTuple> 899 \ingroup HiStats 900 Persistence (serialisation) handler for class XNTuple 901 */ 845 902 846 903 void ObjFileIO<XNTuple>::WriteSelf(POutPersist& ppout) const -
trunk/SophyaLib/HiStats/xntuple.h
r1046 r1405 159 159 }; 160 160 161 161 /*! Prints table information on stream \b s (nt.Show(os)) */ 162 162 inline ostream& operator << (ostream& s, XNTuple const & nt) 163 163 { nt.Show(s); return(s); } 164 164 165 /*! Writes the object in the POutPersist stream \b os */ 165 166 inline POutPersist& operator << (POutPersist& os, XNTuple & obj) 166 167 { ObjFileIO<XNTuple> fio(&obj); fio.Write(os); return(os); } 168 /*! Reads the object from the PInPersist stream \b is */ 167 169 inline PInPersist& operator >> (PInPersist& is, XNTuple & obj) 168 170 { ObjFileIO<XNTuple> fio(&obj); fio.Read(is); return(is); }
Note:
See TracChangeset
for help on using the changeset viewer.