00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, 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_TABLE3D_H 00024 #define O2SCL_TABLE3D_H 00025 00026 #include <iostream> 00027 #include <fstream> 00028 #include <vector> 00029 #include <string> 00030 #include <cmath> 00031 #include <sstream> 00032 #include <o2scl/misc.h> 00033 #include <o2scl/err_hnd.h> 00034 #include <o2scl/multi_funct.h> 00035 #include <o2scl/collection.h> 00036 #include <o2scl/search_vec.h> 00037 #include <o2scl/ovector_tlate.h> 00038 #include <o2scl/interp.h> 00039 #include <o2scl/smart_interp.h> 00040 #include <o2scl/table.h> 00041 00042 #ifndef DOXYGENP 00043 namespace o2scl { 00044 #endif 00045 00046 /** 00047 \brief A data structure containing many slices of two-dimensional 00048 data points defined on a grid 00049 00050 \future Improve interpolation and derivative caching 00051 \future Make a 'const' version of the interpolation functions 00052 \future Write a 2d histogram functions using 00053 multiple applications of search_vec's find_interval(). 00054 */ 00055 class table3d { 00056 00057 public: 00058 00059 /** \brief Create a new 3D \table 00060 */ 00061 table3d(); 00062 00063 virtual ~table3d(); 00064 00065 /// \name Initialization 00066 //@{ 00067 /** 00068 \brief Initialize the x-y grid 00069 00070 This function will not allow you to redefine the grid when 00071 there is data in the \table if a grid of a different size was 00072 already set from a previous call to either set_xy() or 00073 set_size(). However, you may freely redefine the grid 00074 after a call to clear_data() or clear_table(). You may change 00075 individual grid points at any time with set_grid_x() and 00076 set_grid_y(). 00077 00078 */ 00079 template<class vec2_t> int set_xy(std::string x_name, size_t nx, 00080 const vec2_t &x, std::string y_name, 00081 size_t ny, const vec2_t &y) { 00082 if (has_slice && (size_set || xy_set) && (nx!=numx || ny!=numy)) { 00083 O2SCL_ERR_RET("Size cannot be reset in table3d::set_xy().", 00084 o2scl::gsl_einval); 00085 } 00086 if (xy_set) { 00087 xval.free(); 00088 yval.free(); 00089 } 00090 numx=nx; 00091 numy=ny; 00092 xname=x_name; 00093 yname=y_name; 00094 xval.allocate(nx); 00095 yval.allocate(ny); 00096 for(size_t i=0;i<nx;i++) (xval)[i]=x[i]; 00097 for(size_t i=0;i<ny;i++) (yval)[i]=y[i]; 00098 size_set=true; 00099 xy_set=true; 00100 return 0; 00101 } 00102 00103 /** 00104 \brief Initialize \table size 00105 00106 This function will not allow you to resize the \table if it 00107 already has data or if the size has already been set with the 00108 set_xy() function, unless you clear the data with clear_data() 00109 or the \table with clear_table() first. 00110 */ 00111 int set_size(size_t nx, size_t ny); 00112 //@} 00113 00114 // -------------------------------------------------------- 00115 /// \name On-grid get and set methods 00116 //@{ 00117 00118 /** \brief Set element in slice \c name at location <tt>ix,iy</tt> 00119 to value \c val 00120 */ 00121 int set(size_t ix, size_t iy, std::string name, double val); 00122 00123 /** \brief Set element in slice of index \c z at location 00124 <tt>ix,iy</tt> to value \c val . 00125 */ 00126 int set(size_t ix, size_t iy, size_t z, double val); 00127 00128 /** \brief Get element in slice \c name at location 00129 <tt>ix,iy</tt> 00130 */ 00131 double &get(size_t ix, size_t iy, std::string name); 00132 00133 /** \brief Get element in slice \c name at location 00134 <tt>ix,iy</tt> (const version) 00135 */ 00136 const double &get(size_t ix, size_t iy, std::string name) const; 00137 00138 /** \brief Get element in slice of index \c z at location 00139 <tt>ix,iy</tt> 00140 */ 00141 double &get(size_t ix, size_t iy, size_t z); 00142 00143 /** \brief Get element in slice of index \c z at location 00144 <tt>ix,iy</tt> (const version) 00145 */ 00146 const double &get(size_t ix, size_t iy, size_t z) const; 00147 //@} 00148 00149 // -------------------------------------------------------- 00150 /** \name Off-grid get and set methods 00151 00152 These methods return the value of a slice on the grid 00153 point nearest to a user-specified location. For 00154 interpolation into a point off the grid, use 00155 \ref table3d::interp(). 00156 */ 00157 //@{ 00158 00159 /** \brief Set element in slice \c name at the nearest location to 00160 <tt>x,y</tt> to value \c val 00161 */ 00162 int set_val(double x, double y, std::string name, double val); 00163 00164 /** \brief Set element in slice of index \c z at the nearest 00165 location to <tt>x,y</tt> to value \c val 00166 */ 00167 int set_val(double x, double y, size_t z, double val); 00168 00169 /** \brief Get element in slice \c name at location closest to 00170 <tt>x,y</tt> 00171 */ 00172 double &get_val(double x, double y, std::string name); 00173 00174 /** \brief Get element in slice \c name at location closest to 00175 <tt>x,y</tt> 00176 */ 00177 const double &get_val(double x, double y, std::string name) const; 00178 00179 /** \brief Get element in slice of index \c z at location closest 00180 to <tt>x,y</tt> 00181 */ 00182 double &get_val(double x, double y, size_t z); 00183 00184 /** \brief Get element in slice of index \c z at location closest 00185 to <tt>x,y</tt> 00186 */ 00187 const double &get_val(double x, double y, size_t z) const; 00188 00189 /** \brief Set elements in the first <tt>nv</tt> slices at the 00190 nearest location to <tt>x,y</tt> to value \c val 00191 */ 00192 template<class vec_t> 00193 int set_slices(double x, double y, size_t nv, vec_t &vals) { 00194 size_t ix, iy; 00195 lookup_x(x,ix); 00196 lookup_y(y,iy); 00197 00198 for(size_t i=0;i<nv && i<list.size();i++) { 00199 list[i][ix][iy]=vals[i]; 00200 } 00201 return 0; 00202 } 00203 00204 /** \brief Get the data for every slice at the nearest location to 00205 <tt>x,y</tt> 00206 */ 00207 template<class vec_t> 00208 int get_slices(double x, double y, size_t nv, vec_t &v) { 00209 00210 size_t ix, iy; 00211 00212 lookup_x(x,ix); 00213 lookup_y(y,iy); 00214 00215 for(size_t i=0;i<nv && i<list.size();i++) { 00216 v[i]=list[i][ix][iy]; 00217 } 00218 00219 return 0; 00220 } 00221 00222 //@} 00223 00224 // -------------------------------------------------------- 00225 /// \name Off-grid get and set methods returning nearest point 00226 //@{ 00227 00228 /** \brief Set element in slice \c name at the nearest location to 00229 <tt>x,y</tt> to value \c val 00230 */ 00231 int set_val_ret(double &x, double &y, std::string name, double val); 00232 00233 /** \brief Set element in slice of index \c z at the nearest 00234 location to <tt>x,y</tt> to value \c val 00235 */ 00236 int set_val_ret(double &x, double &y, size_t z, double val); 00237 00238 /** \brief Get element in slice \c name at location closest to 00239 <tt>x,y</tt>, and also return the corresponding values of \c x 00240 and \c y 00241 */ 00242 double &get_val_ret(double &x, double &y, std::string name); 00243 00244 /** \brief Get element in slice \c name at location closest to 00245 <tt>x,y</tt>, and also return the corresponding values of \c x 00246 and \c y 00247 */ 00248 const double &get_val_ret(double &x, double &y, std::string name) const; 00249 00250 /** \brief Get element in slice of index \c z at location closest 00251 to <tt>x,y</tt>, and also return the corresponding values of 00252 \c x and \c y 00253 */ 00254 double &get_val_ret(double &x, double &y, size_t z); 00255 00256 /** \brief Get element in slice of index \c z at location closest 00257 to <tt>x,y</tt>, and also return the corresponding values of 00258 \c x and \c y 00259 */ 00260 const double &get_val_ret(double &x, double &y, size_t z) const; 00261 00262 /** \brief Set elements in the first <tt>nv</tt> slices at the 00263 nearest location to <tt>x,y</tt> to value \c val 00264 */ 00265 template<class vec_t> 00266 int set_slices_ret(double &x, double &y, size_t nv, vec_t &vals) { 00267 size_t ix, iy; 00268 lookup_x(x,ix); 00269 lookup_y(y,iy); 00270 x=xval[ix]; 00271 y=yval[iy]; 00272 00273 for(size_t i=0;i<nv && i<list.size();i++) { 00274 list[i][ix][iy]=vals[i]; 00275 } 00276 return 0; 00277 } 00278 00279 /** \brief Get elements in the first <tt>nv</tt> slices at the 00280 nearest location to <tt>x,y</tt> to value \c val 00281 */ 00282 template<class vec_t> 00283 int get_slices_ret(double &x, double &y, size_t nv, vec_t &vals) { 00284 size_t ix, iy; 00285 lookup_x(x,ix); 00286 lookup_y(y,iy); 00287 x=xval[ix]; 00288 y=yval[iy]; 00289 00290 for(size_t i=0;i<nv && i<list.size();i++) { 00291 vals[i]=list[i][ix][iy]; 00292 } 00293 return 0; 00294 } 00295 00296 //@} 00297 00298 // -------------------------------------------------------- 00299 /// \name Grid information get and set methods 00300 //@{ 00301 00302 /// Set x grid point at index \c ix 00303 int set_grid_x(size_t ix, double val); 00304 00305 /// Set y grid point at index \c iy 00306 int set_grid_y(size_t iy, double val); 00307 00308 /// Get x grid point at index \c ix 00309 double get_grid_x(size_t ix); 00310 00311 /// Get y grid point at index \c iy 00312 double get_grid_y(size_t iy); 00313 00314 /// Get the name of the x grid variable 00315 std::string get_x_name() { 00316 return xname; 00317 } 00318 00319 /// Get the name of the y grid variable 00320 std::string get_y_name() { 00321 return yname; 00322 } 00323 00324 /// Set the name of the x grid variable 00325 int set_x_name(std::string name) { 00326 xname=name; 00327 return 0; 00328 } 00329 00330 /// Set the name of the y grid variable 00331 int set_y_name(std::string name) { 00332 yname=name; 00333 return 0; 00334 } 00335 00336 /// Get a const reference to the full x grid 00337 const ovector &get_x_data() const { return xval; } 00338 00339 /// Get a const reference to the full y grid 00340 const ovector &get_y_data() const { return yval; } 00341 00342 //@} 00343 00344 // -------------------------------------------------------- 00345 /// \name Size get methods 00346 //@{ 00347 00348 /// Get the size of the slices 00349 int get_size(size_t &nx, size_t &ny) const; 00350 00351 /// Get the x size 00352 int get_nx() const { 00353 return numx; 00354 } 00355 00356 /// Get the y size 00357 int get_ny() const { 00358 return numy; 00359 } 00360 00361 /// Get the number of slices 00362 int get_nslices() const; 00363 00364 //@} 00365 00366 // -------------------------------------------------------- 00367 /// \name Slice manipulation 00368 //@{ 00369 00370 /// Create a set of new slices specified in the string \c names 00371 int line_of_names(std::string names); 00372 00373 /** \brief Returns the name of slice with index \c z 00374 */ 00375 std::string get_slice_name(size_t z) const; 00376 00377 /** \brief Add a new slice 00378 */ 00379 int new_slice(std::string name); 00380 00381 /** \brief Set all of the values in slice \c name to \c val 00382 */ 00383 int set_slice_all(std::string name, double val); 00384 00385 /** 00386 \brief Find the index for column named \c name 00387 */ 00388 int lookup_slice(std::string name, size_t &ix) const; 00389 00390 /** 00391 \brief Return true if slice is already present 00392 */ 00393 bool is_slice(std::string name, int &ix); 00394 00395 /** \brief Rename slice named \c olds to \c news 00396 00397 This is slow since we have to delete the column and re-insert 00398 it. This process in turn mangles all of the iterators in the 00399 list. 00400 */ 00401 int rename_slice(std::string olds, std::string news); 00402 00403 /** \brief Make a new slice named \c dest which is a copy 00404 of the slice with name given in \c src. 00405 */ 00406 int copy_slice(std::string src, std::string dest); 00407 00408 /** \brief Initialize all values of slice named \c scol to \c val 00409 */ 00410 int init_slice(std::string scol, double val); 00411 00412 /// Return a constant reference to a slice 00413 const omatrix &get_slice(std::string scol) const; 00414 00415 /// Return a constant reference to a slice 00416 const omatrix &get_slice(size_t iz) const; 00417 00418 /** \brief Return a constant reference to all the slice data 00419 00420 \comment 00421 This isn't designated const, i.e. as 00422 const std::vector<omatrix> &get_data() const; 00423 because it would then have to be 00424 const std::vector<const omatrix> &get_data() const; 00425 \endcomment 00426 */ 00427 const std::vector<omatrix> &get_data(); 00428 //@} 00429 00430 // -------------------------------------------------------- 00431 /// \name Lookup and search methods 00432 //@{ 00433 00434 /** 00435 \brief Look for a value in the x grid 00436 */ 00437 int lookup_x(double val, size_t &ix) const; 00438 00439 /** 00440 \brief Look for a value in the y grid 00441 */ 00442 int lookup_y(double val, size_t &iy) const; 00443 00444 /** 00445 \brief Look for a value in a specified slice 00446 */ 00447 int lookup(double val, std::string slice, size_t &ix, size_t &iy) const; 00448 //@} 00449 00450 // -------------------------------------------------------- 00451 /// \name Interpolation, differentiation, and integration 00452 //@{ 00453 00454 /** 00455 \brief Specify the base interpolation objects to use 00456 */ 00457 int set_interp(base_interp_mgr<ovector_const_view> &b1, 00458 base_interp_mgr<ovector_const_subvector> &b2); 00459 00460 /** 00461 \brief Interpolate \c x and \c y in slice named \c name 00462 00463 */ 00464 double interp(double x, double y, std::string name); 00465 00466 /** 00467 \brief Interpolate the derivative of the data with 00468 respect to the x grid at point 00469 \c x and \c y in slice named \c name 00470 */ 00471 double deriv_x(double x, double y, std::string name); 00472 00473 /** 00474 \brief Interpolate the derivative of the data with 00475 respect to the y grid at point 00476 \c x and \c y in slice named \c name 00477 */ 00478 double deriv_y(double x, double y, std::string name); 00479 00480 /** 00481 \brief Interpolate the mixed second 00482 derivative of the data at point 00483 \c x and \c y in slice named \c name 00484 */ 00485 double deriv_xy(double x, double y, std::string name); 00486 00487 /** 00488 \brief Interpolate the integral of the data 00489 respect to the x grid 00490 */ 00491 double integ_x(double x1, double x2, double y, std::string name); 00492 00493 /** 00494 \brief Interpolate the integral of the data 00495 respect to the y grid 00496 */ 00497 double integ_y(double x, double y1, double y2, std::string name); 00498 00499 /** \brief Fill a vector of interpolated values from each slice at the 00500 point <tt>x,y</tt> 00501 */ 00502 template<class vec_t> 00503 int interp_slices(double x, double y, size_t nv, vec_t &v) { 00504 00505 for (size_t i=0;i<list.size();i++) { 00506 std::string name=get_slice_name(i); 00507 v[i]=interp(x,y,name); 00508 } 00509 00510 return 0; 00511 } 00512 00513 //@} 00514 00515 // -------------------------------------------------------- 00516 /// \name Extract 2-dimensional tables 00517 //@{ 00518 /// Extract a table at a fixed x grid point 00519 int extract_x(double x, table &t); 00520 00521 /// Extract a table at a fixed y grid point 00522 int extract_y(double y, table &t); 00523 //@} 00524 00525 // -------------------------------------------------------- 00526 /// \name Clear methods 00527 //@{ 00528 /** \brief Zero the data entries but keep the slice names 00529 and grid 00530 */ 00531 int zero_table(); 00532 00533 /** \brief Clear the table and the slice names 00534 */ 00535 void clear_table(); 00536 00537 /** \brief Remove all of the data by setting the number 00538 of lines to zero 00539 00540 This leaves the column names intact and does not remove 00541 the constants. 00542 */ 00543 void clear_data(); 00544 //@} 00545 00546 // -------------------------------------------------------- 00547 /// \name Summary method 00548 //@{ 00549 /** 00550 \brief Output a summary of the information stored 00551 00552 Outputs the number of constants, the grid information, 00553 and a list of the slice names 00554 */ 00555 int summary(std::ostream *out, int ncol=79) const; 00556 //@} 00557 00558 #ifdef NEVER_DEFINED 00559 // -------------------------------------------------------- 00560 /// \name Contour lines method 00561 //@{ 00562 00563 /** \brief Create contour lines from the slice named \c name 00564 00565 This uses \ref contour to compute contour lines (stored in \c 00566 clines) from slice \c name given \c nlev contour levels in \c 00567 levs . 00568 */ 00569 template<class vec_t> 00570 int slice_contours(std::string name, size_t nlev, vec_t &levs, 00571 std::vector<contour_line> &clines) { 00572 size_t z=0; 00573 int ret=lookup_slice(name,z); 00574 00575 contour co; 00576 // Note that the contour class stores the matrix data in (y,x) 00577 // order, not (x,y) so the order has to be reversed here. 00578 co.set_data(numy,numx,yval,xval,list[z]); 00579 co.set_levels(nlev,levs); 00580 co.calc_contours(clines); 00581 00582 return 0; 00583 } 00584 //@} 00585 #endif 00586 00587 // -------------------------------------------------------- 00588 /// \name Manipulating constants 00589 //@{ 00590 /// Add a constant 00591 virtual int add_constant(std::string name, double val); 00592 00593 /// Remove a constant 00594 virtual int remove_constant(std::string name); 00595 00596 /// Add a constant 00597 virtual int set_constant(std::string name, double val); 00598 00599 /// Get a constant 00600 virtual double get_constant(std::string name); 00601 //@} 00602 00603 /// \name Default interpolation objects 00604 //@{ 00605 def_interp_mgr<ovector_const_view,cspline_interp> dim1; 00606 00607 def_interp_mgr<ovector_const_subvector,cspline_interp> dim2; 00608 //@} 00609 00610 /// Return the type, \c "table3d". 00611 virtual const char *type() { return "table3d"; } 00612 00613 protected: 00614 00615 #ifndef DOXYGEN_INTERNAL 00616 00617 /// \name Interpolation data 00618 //@{ 00619 /// The base interpolation object 00620 base_interp_mgr< ovector_const_view> *bimp1; 00621 00622 /// The subvector base interpolation object 00623 base_interp_mgr< ovector_const_subvector> *bimp2; 00624 00625 /// The array of sm_interp_vec pointers 00626 sm_interp_vec **si; 00627 /// Matrices for interpolation 00628 omatrix_col **aci; 00629 //@} 00630 00631 friend class table3d_io_type; 00632 00633 /// \name Iterator types 00634 //@{ 00635 typedef std::map<std::string,size_t, string_comp>::iterator map_iter; 00636 typedef std::map<std::string,size_t, string_comp>::const_iterator 00637 map_const_iter; 00638 //@} 00639 00640 /// \name Data storage 00641 //@{ 00642 /// The list of constants 00643 std::map<std::string,double> constants; 00644 00645 /// The size of the x grid 00646 size_t numx; 00647 00648 /// The size of the y grid 00649 size_t numy; 00650 00651 /// A tree connecting column names to list indexes 00652 std::map<std::string,size_t, string_comp> tree; 00653 00654 /// The name for the x grid 00655 std::string xname; 00656 00657 /// The name for the y grid 00658 std::string yname; 00659 00660 /// The pointers to the matrices 00661 std::vector<omatrix> list; 00662 00663 /// The x grid 00664 ovector xval; 00665 00666 /// The y grid 00667 ovector yval; 00668 00669 /// True if the grid has been set 00670 bool xy_set; 00671 00672 /// True if the size of the grid has been set 00673 bool size_set; 00674 00675 /// True if the table has at least one slice 00676 bool has_slice; 00677 //@} 00678 00679 /// \name Tree iterator boundaries 00680 //@{ 00681 /// Return the beginning of the slice tree 00682 map_iter begin() {return tree.begin();}; 00683 /// Return the end of the slice tree 00684 map_iter end() {return tree.end();}; 00685 /// Return the beginning of the slice tree 00686 map_const_iter const_begin() const {return tree.begin();}; 00687 /// Return the end of the slice tree 00688 map_const_iter const_end() const {return tree.end();}; 00689 //@} 00690 00691 #endif 00692 00693 }; 00694 00695 class table3d_io_type : public io_tlate<table3d> { 00696 public: 00697 00698 table3d_io_type() : io_tlate<table3d>() {}; 00699 00700 virtual const char *type() { return "table3d"; } 00701 00702 virtual int input( cinput *ci, in_file_format *ins, 00703 table3d *at) { 00704 00705 bool size_set, xy_set; 00706 int nx, ny, nt, ncons, r1; 00707 double dtemp; 00708 std::string name, nmt; 00709 00710 // Constants 00711 ins->int_in(ncons,"const"); 00712 for(int i=0;i<ncons;i++) { 00713 ins->word_in(name); 00714 ins->double_in(dtemp); 00715 r1=at->add_constant(name,dtemp); 00716 if (r1!=0) { 00717 O2SCL_ERR_RET("Failed to add constant in table3d_io_type::input.", 00718 gsl_esanity); 00719 } 00720 } 00721 00722 ins->bool_in(size_set); 00723 if (size_set) { 00724 00725 // Grid 00726 ins->int_in(nx,"nx"); 00727 ins->int_in(ny,"ny"); 00728 ins->bool_in(xy_set); 00729 00730 if (xy_set) { 00731 std::string xname, yname; 00732 ins->word_in(xname); 00733 ins->word_in(yname); 00734 double *xv=new double[nx]; 00735 double *yv=new double[ny]; 00736 for(int i=0;i<nx;i++) ins->double_in(xv[i]); 00737 for(int i=0;i<ny;i++) ins->double_in(yv[i]); 00738 r1=at->set_xy(xname,((size_t)nx),xv,yname,((size_t)ny),yv); 00739 if (r1!=0) { 00740 O2SCL_ERR_RET("Failed to set grid in table3d_io_type::input.", 00741 gsl_esanity); 00742 } 00743 delete[] xv; 00744 delete[] yv; 00745 } 00746 00747 ins->int_in(nt,"nt"); 00748 if (nt>0) { 00749 00750 // Slice names 00751 std::string str="", tmp; 00752 for(int i=0;i<nt;i++) { 00753 ins->word_in(tmp); 00754 str+=tmp; 00755 str+=" "; 00756 } 00757 r1=at->line_of_names(str); 00758 if (r1!=0) { 00759 O2SCL_ERR_RET("Failed to add names in table3d_io_type::input().", 00760 gsl_esanity); 00761 } 00762 00763 // Data 00764 for(int i=0;i<nt;i++) { 00765 for(int j=0;j<nx;j++) { 00766 for(int k=0;k<ny;k++) { 00767 ins->double_in(dtemp); 00768 r1=at->set(j,k,i,dtemp); 00769 if (r1!=0) { 00770 O2SCL_ERR2_RET("Failed to set() in ", 00771 "table3d_io_type::input().",gsl_esanity); 00772 } 00773 } 00774 } 00775 } 00776 } 00777 } 00778 return 0; 00779 } 00780 00781 virtual int output(coutput *co, out_file_format *outs, 00782 table3d *at) { 00783 00784 // Constants 00785 outs->int_out(at->constants.size(),"const"); 00786 std::map<std::string,double>::iterator mit; 00787 for(mit=at->constants.begin();mit!=at->constants.end();mit++) { 00788 outs->word_out(mit->first); 00789 outs->double_out(mit->second); 00790 outs->end_line(); 00791 } 00792 00793 outs->bool_out(at->size_set); 00794 if (at->size_set) { 00795 00796 // Grid 00797 outs->int_out(at->numx,"nx"); 00798 outs->int_out(at->numy,"ny"); 00799 outs->bool_out(at->xy_set); 00800 if (at->xy_set) { 00801 outs->end_line(); 00802 outs->word_out(at->xname); 00803 outs->word_out(at->yname); 00804 for(size_t i=0;i<at->numx;i++) outs->double_out((at->xval)[i]); 00805 for(size_t i=0;i<at->numy;i++) outs->double_out((at->yval)[i]); 00806 } 00807 outs->end_line(); 00808 00809 outs->int_out(at->tree.size(),"nt"); 00810 if (at->tree.size()>0) { 00811 00812 // Slice names 00813 for(size_t i=0;i<at->tree.size();i++) { 00814 outs->word_out(at->get_slice_name(i)); 00815 } 00816 outs->end_line(); 00817 00818 // Data 00819 for(size_t i=0;i<at->tree.size();i++) { 00820 for(size_t j=0;j<at->numx;j++) { 00821 for(size_t k=0;k<at->numy;k++) { 00822 outs->double_out(at->get(j,k,i)); 00823 } 00824 } 00825 outs->end_line(); 00826 } 00827 } 00828 00829 } 00830 return 0; 00831 } 00832 00833 }; 00834 00835 #ifndef DOXYGENP 00836 } 00837 #endif 00838 00839 #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