00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_TABLE_H 00024 #define O2SCL_TABLE_H 00025 00026 #include <iostream> 00027 #include <fstream> 00028 #include <string> 00029 #include <cmath> 00030 #include <sstream> 00031 #include <o2scl/misc.h> 00032 #include <o2scl/err_hnd.h> 00033 #include <o2scl/multi_funct.h> 00034 #include <o2scl/collection.h> 00035 #include <o2scl/search_vec.h> 00036 #include <o2scl/ovector_tlate.h> 00037 #include <o2scl/smart_interp.h> 00038 00039 #ifndef DOXYGENP 00040 namespace o2scl { 00041 #endif 00042 00043 /** \brief Data table 00044 00045 A class to contain and manipulate several equally-sized 00046 columns of data. 00047 00048 <B> Data representation </b> \n 00049 00050 Each individual column is just an ovector_view (or any 00051 descendant of an ovector_view) The columns can be referred to in 00052 one of two ways: 00053 - A numerical index from 0 to C-1 (where C is the number of 00054 columns). For example, data can be accessed through \ref 00055 table::get(size_t c, size_t r) and \ref table::set(size_t c, size_t r, 00056 double val), or the overloaded [] operator, table[c][r]. 00057 - A name of the column which is a string with no whitespace. 00058 For example, data can be accessed with table::get(string cname, 00059 int r) and table::set(string cname, int r, double val). 00060 00061 The columns are organized in a both a <map> and a <vector> 00062 structure so that finding a column by its index ( string 00063 table::get_column_name(int index), and double 00064 *table::get_column(int index) ) takes only constant time, and 00065 finding a column by its name ( int \ref lookup_column() and 00066 double * \ref table::get_column() ) is O(log(C)). Insertion of a 00067 column ( \ref new_column() ) is O(log(C)), but deletion ( \ref 00068 delete_column() )is O(C). Adding a row of data can be either 00069 O(1) or O(C), but row insertion and deletion is slow, since the 00070 all of the columns must be shifted accordingly. 00071 00072 Ownership of any column may be changed at any time, but care 00073 must be taken to ensure that memory allocation errors do not 00074 occur. These errors should not occur when no columns are 00075 owned by the user. 00076 00077 Because of the structure, this class is not suitable for the 00078 matrix manipulation. The classes \ref omatrix and \ref umatrix 00079 are better used for that purpose. 00080 00081 \b Column \b size \n 00082 00083 The columns grow automatically (similar to the STL <vector>) 00084 in reponse to an attempt to call set() for a row that does not 00085 presently exist or in a call to line_of_data() when the table is 00086 already full. However, this forces memory rearrangments that are 00087 O(R*C). Columns which are not owned by the table are not 00088 modified, so the table will not allow an increase in the number 00089 of lines beyond the size of the smallest user-owned column. If 00090 the user has a good estimate of the number of rows beforehand, 00091 it is best to either specify this in the constructor, or in an 00092 explicit call to inc_maxlines(). 00093 00094 <B> Lookup, differentiation, integration, and interpolation </b> 00095 \n Lookup, differentiation, integration, and interpolation are 00096 automatically implemented using splines from the class 00097 smart_interp_vecp. A caching mechanism is implemented so that 00098 successive interpolations, derivative evaluations or 00099 integrations over the same two columns are fast. 00100 00101 <B> Sorting </b>\n 00102 00103 The columns are automatically sorted by name for speed, the 00104 results can be accessed by table::get_sorted_name(i). Individual 00105 columns can be sorted, or the entire table can be sorted by one 00106 column. 00107 00108 <B> Allowable column names</b> \n 00109 00110 In general, column names may be of any form as long as they 00111 don't contain whitespace, e.g. \c 123".#@$%xy~ is a 00112 legitmate column name. The column name should be restricted to contain 00113 only letters, numbers, and underscores and may not begin with a 00114 digit. 00115 00116 <B> Thread-safety </b> \n 00117 00118 Generally, the member functions are thread-safe in the sense 00119 that one would expect. Simple get() and set() functions are 00120 thread-safe, while insertion and deletion operations are not. It 00121 makes little sense to try to make insertion and deletion 00122 thread-safe. The interpolation routines are not thread-safe. 00123 00124 \b I/O \b and \b command-line \b manipulation \n 00125 00126 When data from an object of type \ref table is output to 00127 a file through the \ref collection class, the table 00128 can be manipulated on the command-line through 00129 the acol utility. 00130 00131 \todo Move the discussion above to the user guide? 00132 00133 \todo Add interp() and related functions which avoid caching and 00134 can thus be const (This has been started with interp_const() ) 00135 00136 \future The nlines vs. maxlines and automatic resizing of 00137 table-owned vs. user-owned vectors could be reconsidered, 00138 especially now that ovectors can automatically resize on their 00139 own. 10/16/07: This issue may be unimportant, as it might 00140 be better to just move to a template based approach with 00141 a user-specified vector type. The interpolation is now flexible 00142 enough to handle different types. Might check to ensure sorting 00143 works with other types. 00144 00145 \future The present structure, \c 00146 std::map<std::string,col,string_comp> atree and \c 00147 std::vector<aiter> alist; could be replaced with \c 00148 std::vector<col> list and \c s td::map<std::string,int> tree 00149 where the map just stores the index of the the column in the 00150 list 00151 */ 00152 class table { 00153 public: 00154 00155 /** \brief Create a new table with space for nlines<=cmaxlines. 00156 */ 00157 table(int cmaxlines=0); 00158 00159 virtual ~table(); 00160 00161 // -------------------------------------------------------- 00162 /** \name Basic get and set methods */ 00163 //@{ 00164 /** \brief Set row \c row of column named \c col to value \c val - 00165 O(log(C)). 00166 00167 This function adds the column \c col if it does not 00168 already exist and adds rows using inc_maxlines() and 00169 set_nlines() to create at least \c (row+1) rows if they do not 00170 already exist. 00171 */ 00172 int set(std::string col, size_t row, double val); 00173 00174 /** \brief Set row \c row of column number \c icol to value \c val - O(1). 00175 */ 00176 int set(size_t icol, size_t row, double val); 00177 00178 /** \brief Get value from row \c row of column named \c col - O(log(C)). 00179 */ 00180 double get(std::string col, size_t row) const; 00181 00182 /** \brief Get value from row \c row of column number \c icol - O(1). 00183 */ 00184 double get(size_t icol, size_t row); 00185 00186 /** \brief Return the number of columns 00187 */ 00188 int get_ncolumns() const {return atree.size();}; 00189 00190 /** \brief Return the number of lines 00191 */ 00192 size_t get_nlines() const {return nlines;}; 00193 00194 /** 00195 \brief Set the number of lines 00196 00197 This function is stingy about increasing the table memory space 00198 and will only increase it enough to fit \c il lines, which 00199 is useful if you have columns not owned by the table. 00200 */ 00201 int set_nlines(size_t il); 00202 00203 /** 00204 \brief Set the number of lines 00205 00206 \todo Resolve whether set() should really use this approach. 00207 Also, resolve whether this should replace set_nlines() (It could 00208 be that the answer is no, because as the documentation 00209 in the other version states, the other version is useful if 00210 you have columns not owned by the table.) 00211 */ 00212 int set_nlines_auto(size_t il); 00213 00214 /** \brief Return the maximum number of lines 00215 */ 00216 int get_maxlines() {return maxlines;}; 00217 00218 /** \brief Returns a pointer to the column named \c col - O(log(C)) 00219 */ 00220 ovector_view *get_column(std::string col); 00221 00222 /** \brief Returns a pointer to the column named \c col - O(log(C)) 00223 */ 00224 const ovector_view *get_column_const(std::string col) const; 00225 00226 /** 00227 \brief Returns a pointer to the column of index \c icol - O(1). 00228 00229 Note that several of the methods require reallocation 00230 of memory and pointers previously returned by this function 00231 will be incorrect. 00232 */ 00233 ovector_view *get_column(size_t icol) { 00234 return (alist[icol]->second.dat); 00235 } 00236 00237 /** 00238 \brief Returns a pointer to the column of index \c icol - O(1). 00239 00240 Note that several of the methods require reallocation 00241 of memory and pointers previously returned by this function 00242 will be incorrect. 00243 */ 00244 const ovector_view *get_column(size_t icol) const { 00245 return (alist[icol]->second.dat); 00246 } 00247 00248 /** 00249 \brief Returns the column of index \c icol - O(1) (const version) 00250 00251 This does not do any sort of bounds checking and is 00252 quite fast. 00253 00254 Note that several of the methods require reallocation of 00255 memory and refereces previously returned by this function will 00256 be incorrect. 00257 */ 00258 const ovector_view &operator[] (size_t icol) const { 00259 return (*alist[icol]->second.dat); 00260 } 00261 00262 /** 00263 \brief Returns the column of index \c icol - O(1). 00264 00265 This does not do any sort of bounds checking and is 00266 quite fast. 00267 00268 Note that several of the methods require reallocation of 00269 memory and refereces previously returned by this function will 00270 be incorrect. 00271 */ 00272 ovector_view &operator[] (size_t icol) { 00273 return (*alist[icol]->second.dat); 00274 } 00275 00276 /** 00277 \brief Returns the column named \c scol - O(log(C)) (const version) 00278 00279 No error checking is performed. 00280 00281 Note that several of the methods require reallocation of 00282 memory and refereces previously returned by this function will 00283 be incorrect. 00284 */ 00285 const ovector_view &operator[](std::string scol) const { 00286 aciter it=atree.find(scol); 00287 return *(it->second.dat); 00288 } 00289 00290 /** 00291 \brief Returns the column named \c scol - O(log(C)) 00292 00293 No error checking is performed. 00294 00295 Note that several of the methods require reallocation of 00296 memory and refereces previously returned by this function will 00297 be incorrect. 00298 */ 00299 ovector_view &operator[](std::string scol) { 00300 aiter it=atree.find(scol); 00301 return *(it->second.dat); 00302 } 00303 00304 /** \brief Returns a pointer to a copy of the row with value \c val 00305 in column \c col - O(R*C) */ 00306 int get_row(std::string col, double val, ovector &row) const; 00307 00308 /** \brief Returns a pointer to a copy of row number \c irow - O(C) 00309 */ 00310 int get_row(size_t irow, ovector &row) const; 00311 //@} 00312 00313 // -------------------------------------------------------- 00314 /** \name Column manipulation */ 00315 //@{ 00316 00317 /** \brief Returns the name of column \c col - O(1). 00318 */ 00319 std::string get_column_name(size_t col) const; 00320 00321 /** \brief Returns the name of column \c col in sorted order - O(1). 00322 */ 00323 std::string get_sorted_name(size_t col); 00324 00325 /** \brief Add a new column owned by the table - O(log(C)). 00326 */ 00327 int new_column(std::string name); 00328 00329 /** 00330 \brief Add a new column owned by the user - O(log(C)). 00331 00332 This function does not modify the number of lines of data in 00333 the table. 00334 00335 \todo We've got to figure out what to do if ldat is too small. 00336 If it's smaller than nlines, obviously we should just 00337 fail, but what if it's size is between nlines and maxlines? 00338 */ 00339 int new_column(std::string name, ovector_view *ldat); 00340 00341 /** 00342 \brief Find the index for column named \c name - O(log(C)). 00343 00344 If the column is not present, this does not call the error 00345 handler, but quietly sets \c ix to zero and returns \ref 00346 gsl_notfound. 00347 */ 00348 int lookup_column(std::string name, int &ix); 00349 00350 /** 00351 \brief Rename column named \c olds to \c news - O(C). 00352 00353 This is slow since we have to delete the column and re-insert 00354 it. This process in turn mangles all of the 00355 iterators in the list. 00356 */ 00357 int rename_column(std::string olds, std::string news); 00358 00359 /** \brief Make a new column named \c dest equal to \c src - O(log(C)*R). 00360 */ 00361 int copy_column(std::string src, std::string dest); 00362 00363 /// Create (using \c new) a generic array from column \c col 00364 double *create_array(std::string col) const; 00365 00366 /** \brief Initialize all values of column named \c scol to \c val - 00367 O(log(C)*R). 00368 00369 Note that this does not initialize elements beyond 00370 nlines so that if the number of rows is increased afterwards, the 00371 new rows will have uninitialized values. 00372 */ 00373 int init_column(std::string scol, double val); 00374 00375 /** 00376 \brief Modify ownership - O(log(C)). 00377 00378 \warning columns allocated using malloc() should never be 00379 owned by the table object since it uses delete instead of 00380 free(). 00381 */ 00382 int ch_owner(std::string name, bool ow); 00383 00384 /** \brief Get ownership - O(log(C)). 00385 */ 00386 bool get_owner(std::string name) const; 00387 00388 /** 00389 \brief Get a gsl_vector from column \c name - O(log(C)). 00390 */ 00391 const gsl_vector *get_gsl_vector(std::string name) const; 00392 00393 /** \brief Return 0 if the tree and list are properly synchronized 00394 */ 00395 int check_synchro() const; 00396 00397 /** 00398 \brief Insert a column from a separate table, interpolating 00399 it into a new column 00400 00401 Given a pair of columns ( \c src_index, \c src_col ) in a 00402 separate table (\c source), this creates a new column in the 00403 present table named \c src_col which interpolates \c loc_index 00404 into \c src_index. The interpolation objects from the \c 00405 source table will be used. If there is already a column in the 00406 present table named \c src_col, then this will fail. 00407 00408 If there is an error in the interpolation for any particular 00409 row, then the value of \c src_col in that row will be set to 00410 zero. 00411 */ 00412 int add_col_from_table(std::string loc_index, table &source, 00413 std::string src_index, std::string src_col, 00414 std::string dest_col=""); 00415 //@} 00416 00417 // -------------------------------------------------------- 00418 /** \name Row maninpulation and data input */ 00419 //@{ 00420 00421 /** \brief Insert a row before row \c n 00422 */ 00423 int new_row(size_t n); 00424 00425 /** \brief Copy the data in row \c src to row \c dest 00426 */ 00427 int copy_row(size_t src, size_t dest); 00428 00429 /** \brief Insert a row of data before row \c n 00430 */ 00431 int insert_data(size_t n, size_t nv, double *v); 00432 00433 /** \brief Insert a row of data before row \c n 00434 */ 00435 int insert_data(size_t n, size_t nv, double **v); 00436 00437 /** 00438 \brief Read a new set of names from \c newheads 00439 */ 00440 int line_of_names(std::string newheads); 00441 00442 /** \brief Read a line of data from an array 00443 */ 00444 template<class vec_t> int line_of_data(size_t nv, const vec_t &v) { 00445 if (maxlines==0) inc_maxlines(5); 00446 if (nlines>=maxlines) inc_maxlines(maxlines); 00447 00448 if (intp_set) { 00449 intp_set=false; 00450 delete si; 00451 } 00452 00453 if (nlines<maxlines && nv<=(atree.size())) { 00454 00455 for(size_t i=0;i<nv;i++) { 00456 (*this)[i][nlines]=v[i]; 00457 } 00458 nlines++; 00459 00460 return 0; 00461 } 00462 00463 set_err("Not enough lines or columns in line_of_data().",gsl_einval); 00464 return gsl_einval; 00465 } 00466 //@} 00467 00468 // -------------------------------------------------------- 00469 /** \name Lookup and search methods */ 00470 //@{ 00471 00472 /** 00473 \brief Look for a value in an ordered column 00474 00475 O(log(C)*log(R)) 00476 */ 00477 size_t ordered_lookup(std::string col, double val); 00478 00479 /// Exhaustively search column \c col for the value \c val - O(log(C)*R). 00480 size_t lookup(std::string col, double val) const; 00481 00482 /// Search column \c col for the value \c val and return value in \c col2 00483 double lookup_val(std::string col, double val, std::string col2) const; 00484 00485 /// Exhaustively search column \c col for the value \c val - O(log(C)*R). 00486 size_t lookup(int col, double val) const; 00487 00488 /** \brief Exhaustively search column \c col for many occurences 00489 of \c val - O(log(C)*R). 00490 */ 00491 size_t mlookup(std::string col, double val, std::vector<double> &results, 00492 double threshold=0.0) const; 00493 00494 /** 00495 \brief Search for row with maximum value of formula 00496 00497 This searches the table for the maximum value of the specified 00498 formula. For example, to find the row for which the column \c 00499 mu is 2 and \c T is 3, you can use 00500 \code 00501 table::lookup_form("-abs(mu-2)-abs(T-3)"); 00502 \endcode 00503 00504 */ 00505 int lookup_form(std::string formula, double &maxval); 00506 //@} 00507 00508 // -------------------------------------------------------- 00509 /** \name Interpolation, differentiation, and integration, max, and min */ 00510 //@{ 00511 00512 /** 00513 \brief Interpolate \c x0 from \c sx into \c sy 00514 00515 O(log(C)*log(R)) but can be as bad as O(log(C)*R) if 00516 the relevant columns are not well ordered. 00517 */ 00518 double interp(std::string sx, double x0, std::string sy); 00519 00520 /** 00521 \brief Interpolate \c x0 from \c sx into \c sy 00522 00523 O(log(C)*log(R)) but can be as bad as O(log(C)*R) if 00524 the relevant columns are not well ordered. 00525 */ 00526 double interp_const(std::string sx, double x0, std::string sy) const; 00527 00528 /** 00529 \brief Interpolate \c x0 from \c ix into \c iy 00530 00531 O(log(R)) but can be as bad as O(R) if 00532 the relevant columns are not well ordered. 00533 */ 00534 double interp(size_t ix, double x0, size_t iy); 00535 00536 /** \brief Make a new column \c yp which is the derivative y'(x) - 00537 O(log(C)*R). 00538 */ 00539 int deriv(std::string x, std::string y, std::string yp); 00540 00541 /** 00542 \brief The first derivative of the function sy(sx) at sx=x0. 00543 00544 O(log(C)*log(R)) but can be as bad as O(log(C)*R) if 00545 the relevant columns are not well ordered. 00546 */ 00547 double deriv(std::string sx, double x0, std::string sy); 00548 00549 /** 00550 \brief The first derivative of the function iy(ix) at ix=x0. 00551 00552 O(log(R)) but can be as bad as O(R) if 00553 the relevant columns are not well ordered. 00554 */ 00555 double deriv(size_t ix, double x0, size_t iy); 00556 00557 /** 00558 \brief Make a new column \c yp which is 00559 \f$ y^{\prime \prime}(x) \f$ - O(log(C)*R). 00560 */ 00561 int deriv2(std::string x, std::string y, std::string yp); 00562 00563 /** 00564 \brief The second derivative of the function sy(sx) at sx=x0. 00565 00566 O(log(C)*log(R)) but can be as bad as O(log(C)*R) if 00567 the relevant columns are not well ordered. 00568 */ 00569 double deriv2(std::string sx, double x0, std::string sy); 00570 00571 /** 00572 \brief The second derivative of the function iy(ix) at ix=x0. 00573 00574 O(log(R)) but can be as bad as O(R) if 00575 the relevant columns are not well ordered. 00576 */ 00577 double deriv2(size_t ix, double x0, size_t iy); 00578 00579 /** 00580 \brief The integral of the function sy(sx) from sx=x1 to sx=x2. 00581 00582 O(log(C)*log(R)) but can be as bad as O(log(C)*R) if 00583 the relevant columns are not well ordered. 00584 */ 00585 double integ(std::string sx, double x1, double x2, std::string sy); 00586 00587 /** 00588 \brief The integral of the function iy(ix) from ix=x1 to ix=x2. 00589 00590 O(log(R)) but can be as bad as O(R) if 00591 the relevant columns are not well ordered. 00592 */ 00593 double integ(size_t ix, double x1, double x2, size_t iy); 00594 00595 /** 00596 \brief The integral of the function iy(ix) 00597 00598 O(log(R)) but can be as bad as O(R) if the relevant columns 00599 are not well ordered. 00600 */ 00601 int integ(std::string x, std::string y, std::string ynew); 00602 00603 /** \brief Return column maximum. Makes no assumptions about 00604 ordering - O(R). 00605 */ 00606 double max(std::string col) const; 00607 00608 /** \brief Return column minimum. Makes no assumptions about 00609 ordering - O(R). 00610 */ 00611 double min(std::string col) const; 00612 //@} 00613 00614 // -------------------------------------------------------- 00615 /** \name Subtable method */ 00616 //@{ 00617 00618 /** 00619 \brief Make a subtable 00620 00621 Uses the columns specified in \c list from the row \c top 00622 to the row of index \c bottom. If \c linked is false 00623 the the data will be independent from the original table. 00624 */ 00625 table *subtable(std::string list, size_t top, size_t bottom, 00626 bool linked=true); 00627 //@} 00628 00629 // -------------------------------------------------------- 00630 /** \name Add space */ 00631 //@{ 00632 00633 /** \brief Manually increase the maximum number of lines 00634 */ 00635 int inc_maxlines(size_t llines); 00636 //@} 00637 00638 // -------------------------------------------------------- 00639 /** \name Delete methods */ 00640 //@{ 00641 00642 /** \brief Delete column named \c scol - O(C). 00643 00644 This is slow because 00645 the iterators in alist are mangled and we have to call 00646 reset_list to get them back. 00647 */ 00648 00649 int delete_column(std::string scol); 00650 00651 /** \brief Delete the row with the value \c val in column \c scol. 00652 */ 00653 int delete_row(std::string scol, double val); 00654 00655 /** \brief Delete the row of index \c irow. 00656 */ 00657 int delete_row(size_t irow); 00658 //@} 00659 00660 // -------------------------------------------------------- 00661 /** \name Clear methods */ 00662 //@{ 00663 00664 /** \brief Zero the data entries but keep the column names 00665 and nlines fixed 00666 */ 00667 void zero_table(); 00668 00669 /** \brief Clear the table and the column names 00670 */ 00671 void clear_table(); 00672 00673 /** \brief Remove all of the data by setting the number 00674 of lines to zero 00675 00676 This leaves the column names intact and does not remove 00677 the constants. 00678 */ 00679 void clear_data() { 00680 nlines=0; 00681 if (intp_set==true) { 00682 delete si; 00683 intp_set=false; 00684 } 00685 return; 00686 }; 00687 //@} 00688 00689 // -------------------------------------------------------- 00690 /** \name Sorting methods */ 00691 //@{ 00692 00693 /** \brief Sort the entire table by the column \c scol 00694 */ 00695 int sort_table(std::string scol); 00696 00697 /** \brief Individually sort the column \c scol 00698 */ 00699 int sort_column(std::string scol); 00700 //@} 00701 00702 // -------------------------------------------------------- 00703 /** \name Summary method */ 00704 //@{ 00705 /** \brief Output a summary of the information stored 00706 00707 Outputs the number of constants, the number of columns, 00708 a list of the column names, and the number of lines of 00709 data. 00710 */ 00711 int summary(std::ostream *out, int ncol=79) const; 00712 //@} 00713 00714 /// Set the base interpolation objects 00715 int set_interp(base_interp<ovector_view> &bi1, 00716 base_interp<ovector_const_subvector> &bi2) { 00717 intp1=&bi1; 00718 intp2=&bi2; 00719 return 0; 00720 } 00721 00722 /// Add a constant 00723 virtual int add_constant(std::string name, double val) { 00724 constants.insert(make_pair(name,val)); 00725 return 0; 00726 } 00727 00728 /// Remove a constant 00729 virtual int remove_constant(std::string name) { 00730 constants.erase(name); 00731 return 0; 00732 } 00733 00734 /// The list of constants 00735 std::map<std::string,double> constants; 00736 00737 protected: 00738 00739 #ifndef DOXYGEN_INTERNAL 00740 00741 friend class io_tlate<table>; 00742 00743 /** \brief Set the elements of alist with the appropriate 00744 iterators from atree - O(C). 00745 00746 Generally, the end-user shouldn't need this method. It is 00747 only used in delete_column() to rearrange the list when 00748 a column is deleted from the tree. 00749 */ 00750 int reset_list(); 00751 00752 /// Column structure 00753 typedef struct col_s { 00754 /// Pointer to column 00755 ovector_view *dat; 00756 /// Owner of column 00757 bool owner; 00758 /// Column index 00759 int index; 00760 } col; 00761 00762 /// \name Iterator types 00763 //@{ 00764 typedef std::map<std::string,col,string_comp>::iterator aiter; 00765 typedef std::map<std::string,col,string_comp>::const_iterator aciter; 00766 typedef std::vector<aiter>::iterator aviter; 00767 //@} 00768 00769 /// \name Actual data 00770 //@{ 00771 /// The size of allocated memory 00772 size_t maxlines; 00773 /// The size of presently used memory 00774 size_t nlines; 00775 /// The tree of columns 00776 std::map<std::string,col,string_comp> atree; 00777 /// The list of tree iterators 00778 std::vector<aiter> alist; 00779 //@} 00780 00781 /// \name Column manipulation methods 00782 //@{ 00783 /// Return the iterator for a column 00784 aiter get_iterator(std::string lname); 00785 /// Return the column structure for a column 00786 col *get_col_struct(std::string lname); 00787 /// Return the beginning of the column tree 00788 aiter begin() {return atree.begin();}; 00789 /// Return the end of the column tree 00790 aiter end() {return atree.end();}; 00791 //@} 00792 00793 /// The sorting function 00794 static int sortd_comp(const void *a, const void *b); 00795 00796 /// A structure for sorting 00797 typedef struct sortd_s { 00798 /// Value to sort 00799 double val; 00800 /// Sorted index 00801 int indx; 00802 } sortd; 00803 00804 /// \name Interpolation 00805 //@{ 00806 /// The interpolation object 00807 sm_interp_vec *si; 00808 00809 /// A pointer to the interpolation object 00810 base_interp<ovector_view> *intp1; 00811 /// A pointer to the subvector interpolation object 00812 base_interp<ovector_const_subvector> *intp2; 00813 00814 /// The default interpolation object 00815 cspline_interp<ovector_view> cintp1; 00816 /// The default subvector interpolation object 00817 cspline_interp<ovector_const_subvector> cintp2; 00818 00819 /// The vector-searching object 00820 /* 00821 #ifdef DOXYGENP 00822 search_vec<vec_t> se; 00823 #else 00824 search_vec<ovector> se; 00825 #endif 00826 */ 00827 search_vec<ovector> se; 00828 00829 /// True if the interpolation type has been set 00830 bool intp_set; 00831 00832 /// The last x-column interpolated 00833 std::string intp_colx; 00834 00835 /// The last y-column interpolated 00836 std::string intp_coly; 00837 00838 //@} 00839 00840 #endif 00841 00842 }; 00843 00844 /// Input specialization 00845 template<> int io_tlate<table>::input 00846 (cinput *co, o2scl::in_file_format *ins, table *ta); 00847 /// Output specialization 00848 template<> int io_tlate<table>::output 00849 (coutput *co, o2scl::out_file_format *outs, 00850 table *at); 00851 /// \fn Type specialization 00852 template<> const char *io_tlate<table>::type(); 00853 00854 typedef io_tlate<table> table_io_type; 00855 00856 #ifndef DOXYGENP 00857 } 00858 #endif 00859 00860 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page