37 #include <boost/numeric/ublas/vector.hpp> 38 #include <boost/numeric/ublas/matrix.hpp> 40 #include <o2scl/misc.h> 41 #include <o2scl/interp.h> 43 #include <o2scl/shunting_yard.h> 45 #ifndef DOXYGEN_NO_O2NS 49 template<
class vec_t>
class table;
68 #ifndef DOXYGEN_NO_O2NS 192 template<
class vec_t=std::vector<
double> >
class table {
210 if (intp_set==
true) {
219 size_t nc=t.get_nconsts();
220 for(
size_t i=0;i<nc;i++) {
223 t.get_constant(i,name,val);
224 constants.insert(make_pair(name,val));
231 nlines=t.get_nlines();
234 for(
size_t i=0;i<t.get_ncolumns();i++) {
237 std::string cname=t.get_column_name(i);
241 s.
dat.resize(nlines);
242 s.
index=atree.size();
243 atree.insert(make_pair(cname,s));
246 aiter it=atree.find(cname);
250 for(
size_t j=0;j<t.get_nlines();j++) {
251 it->second.dat[j]=t.get(cname,j);
270 size_t nc=t.get_nconsts();
271 for(
size_t i=0;i<nc;i++) {
274 t.get_constant(i,name,val);
275 constants.insert(make_pair(name,val));
279 nlines=t.get_nlines();
285 for(
size_t i=0;i<t.get_ncolumns();i++) {
288 std::string cname=t.get_column_name(i);
292 s.
dat.resize(nlines);
293 s.
index=atree.size();
294 atree.insert(make_pair(cname,s));
297 aiter it=atree.find(cname);
301 for(
size_t j=0;j<t.get_nlines();j++) {
302 it->second.dat[j]=t.get(cname,j);
329 void set(std::string scol,
size_t row,
double val) {
340 if (maxlines==0) inc_maxlines(row+1);
341 while(row>maxlines-1) inc_maxlines(maxlines);
342 if (row>=nlines) set_nlines_auto(row+1);
344 if ((intp_colx==scol || intp_coly==scol) && intp_set==
true) {
349 aiter it=atree.find(scol);
350 if (it==atree.end()) {
354 if (it==atree.end()) {
355 O2SCL_ERR((((std::string)
"Refused to add column '")+scol+
356 "' in table::set(string,size_t,double).").c_str(),
361 it->second.dat[row]=val;
368 void set(
size_t icol,
size_t row,
double val) {
383 if (icol>=atree.size()) {
384 std::string err=((std::string)
"Column out of range, ")+
szttos(icol)+
385 ">="+
szttos(atree.size())+
", in table::set(size_t,size_t,double).";
389 while(row>maxlines-1) inc_maxlines(maxlines);
390 if (row>=nlines) set_nlines_auto(row+1);
392 std::string scol=get_column_name(icol);
393 if ((intp_colx==scol || intp_coly==scol) && intp_set==
true) {
398 alist[icol]->second.dat[row]=val;
407 template<
class size_vec_t>
void set_row(
size_t row, size_vec_t &v) {
408 if (row>=get_nlines()) {
409 std::string err=((std::string)
"Row out of range, ")+
410 itos(row)+
">="+
itos(get_nlines())+
", in table::set_row().";
413 for(
size_t i=0;i<get_ncolumns() && i<v.size();i++) {
414 alist[i]->second.dat[row]=v[i];
422 double get(std::string scol,
size_t row)
const {
424 aciter it=atree.find(scol);
425 if (it==atree.end()) {
426 O2SCL_ERR((((std::string)
"Column '")+scol+
427 "' not found in table::get(string,size_t).").c_str(),
431 tmp=it->second.dat[row];
439 double get(
size_t icol,
size_t row)
const {
440 if (icol>=atree.size()) {
441 std::string err=((std::string)
"Column out of range, ")+
442 itos(icol)+
">="+
itos(atree.size())+
", in table::get(size_t,size_t).";
447 std::string err=((std::string)
"Row out of range, ")+
448 itos(row)+
">="+
itos(nlines)+
", in table::get(size_t,size_t).";
452 return alist[icol]->second.dat[row];
479 inc_maxlines(il-maxlines);
512 template<
class resize_vec_t>
513 void get_row(std::string scol,
double val, resize_vec_t &row)
const {
515 int irow=lookup(scol,val);
517 O2SCL_ERR((((std::string)
"Column '")+scol+
"' not found in "+
518 "table::get_row(string,double,vec_t) const.").c_str(),
538 template<
class resize_vec_t>
539 void get_row(
size_t irow, resize_vec_t &row)
const {
543 "' not found in table::get_row(size_t,vec_t).").c_str(),
550 row.allocate(atree.size());
551 for(i=0,it=atree.begin();it!=atree.end();it++,i++) {
552 row[i]=(it->second.dat)[irow];
571 size_t inc=il-maxlines;
572 if (inc<maxlines) inc=maxlines;
597 for(
aiter it=atree.begin();it!=atree.end();it++) {
600 temp_col.resize(maxlines+llines);
601 for(
size_t j=0;j<maxlines;j++) {
602 temp_col[j]=it->second.dat[j];
606 it->second.dat.resize(maxlines+llines);
609 for(
size_t j=0;j<maxlines;j++) {
610 it->second.dat[j]=temp_col[j];
628 if (llines==maxlines)
return;
630 O2SCL_ERR2(
"Cannot set maximum number of lines to be smaller ",
631 "than current size in table::set_maxlines().",
641 for(
aiter it=atree.begin();it!=atree.end();it++) {
644 temp_col.resize(llines);
645 for(
size_t j=0;j<nlines;j++) {
646 temp_col[j]=it->second.dat[j];
650 it->second.dat.resize(llines);
653 for(
size_t j=0;j<nlines;j++) {
654 it->second.dat[j]=temp_col[j];
672 aciter it=atree.find(scol);
673 if (it==atree.end()) {
674 O2SCL_ERR((((std::string)
"Column '")+scol+
675 "' not found in table::get_column() const.").c_str(),
679 return it->second.dat;
696 const vec_t &operator[] (
size_t icol)
const {
697 #if !O2SCL_NO_RANGE_CHECK 698 if (icol>=atree.size()) {
701 " in table::operator[size_t] const. Size: "+
703 " (index should be less than size).").c_str(),
exc_eindex);
707 return (alist[icol]->second.dat);
725 aciter it=atree.find(scol);
726 #if !O2SCL_NO_RANGE_CHECK 727 if (it==atree.end()) {
728 O2SCL_ERR((((std::string)
"Column '")+scol+
"' not found in table::"+
733 return (it->second.dat);
743 if (head.length()==0) {
744 O2SCL_ERR2(
"Cannot add column with empty name in ",
747 if (is_column(head)==
true) {
748 O2SCL_ERR((((std::string)
"Column '")+head+
749 "' already present in table::new_column().").c_str(),
752 for(
int i=0;i<((int)head.size());i++) {
753 if (head[i]==
' ' || head[i]==
'\t' || head[i]==
'\n' || head[i]==
'\r' 754 || head[i]==
'\v' || head[i]==
'\f') {
755 O2SCL_ERR((((std::string)
"Invalid column name '")+head+
756 "' in table::new_column().").c_str(),
761 s.
dat.resize(maxlines);
762 s.
index=((int)atree.size());
763 atree.insert(make_pair(head,s));
764 aiter it=atree.find(head);
783 size_t sz, vec2_t &v) {
787 "table::new_column(string,size_t,vec2_t)",
792 int ret=new_column(name);
793 if (ret!=0)
return ret;
797 if (sz>get_nlines()) mxl=get_nlines();
798 for(
size_t i=0;i<mxl;i++) {
811 if (icol+1>atree.size()) {
813 " larger than number of "+
814 "columns in table::get_column_name().").c_str(),
817 return alist[icol]->first;
830 aiter its=atree.find(scol);
831 if (its==atree.end()) {
832 O2SCL_ERR((((std::string)
"Column '")+scol+
833 " not found in table::swap_column_data().").c_str(),
837 if (v.size()!=its->second.dat.size()) {
838 O2SCL_ERR2(
"Vector sizes not commensurate in ",
841 std::swap(its->second.dat,v);
849 aiter its=atree.find(src);
850 if (its==atree.end()) {
851 O2SCL_ERR((((std::string)
"Column '")+src+
852 " not found in table::rename_column().").c_str(),
857 aiter itd=atree.find(dest);
858 std::swap(its->second.dat,itd->second.dat);
871 aiter it=atree.find(scol);
872 if (it==atree.end()) {
873 O2SCL_ERR((((std::string)
"Column '")+scol+
874 " not found in table::delete_column().").c_str(),
881 vit+=it->second.index;
886 alist[alist.size()-1]->second.index=it->second.index;
895 if ((intp_colx==scol || intp_coly==scol) && intp_set==
true) {
907 if (icol+1>atree.size()) {
911 for(
size_t i=0;i<icol;i++) it++;
931 aiter it=atree.find(scol);
932 if (it==atree.end()) {
933 O2SCL_ERR((((std::string)
"Column '")+scol+
934 "' not found in table::init_column()").c_str(),
938 for(
size_t i=0;i<nlines;i++) {
939 it->second.dat[i]=val;
941 if (intp_set && (scol==intp_colx || scol==intp_coly)) {
954 aciter it=atree.find(scol);
955 if (it==atree.end())
return false;
966 aciter it=atree.find(lname);
967 if (it==atree.end()) {
968 O2SCL_ERR(
"Column not found in table::lookup_column().",
971 return it->second.index;
979 if (!is_column(dest)) new_column(dest);
980 aiter its=atree.find(src);
981 if (its==atree.end()) {
982 O2SCL_ERR((((std::string)
"Column '")+src+
983 " not found in table::copy_column().").c_str(),
987 aiter itd=atree.find(dest);
988 if (itd==atree.end()) {
989 O2SCL_ERR((((std::string)
"Destination column '")+dest+
990 " not found in table::copy_column().").c_str(),
994 for(
size_t i=0;i<nlines;i++) {
995 itd->second.dat[i]=its->second.dat[i];
1005 template<
class resize_vec_t>
1008 for(
size_t i=0;i<nlines;i++) {
1009 v[i]=this->
get(scol,i);
1019 template<
class vec2_t>
1021 for(
size_t i=0;i<nlines;i++) {
1022 this->
set(scol,i,v[i]);
1037 template<
class vec2_t>
1039 std::string src_index, std::string src_col,
1040 std::string dest_index, std::string dest_col=
"") {
1042 if (dest_col==
"") dest_col=src_col;
1045 if (!is_column(dest_col)) new_column(dest_col);
1048 for(
size_t i=0;i<nlines;i++) {
1049 set(dest_col,i,source.interp(src_index,
get(dest_index,i),src_col));
1059 template<
class vec2_t>
1061 bool allow_extrap=
true, std::string dest_index=
"") {
1063 if (dest_index==
"") dest_index=src_index;
1066 double min=source.min(src_index);
1067 double max=source.max(src_index);
1068 if (allow_extrap==
false) {
1069 if (!std::isfinite(min) || !std::isfinite(max)) {
1070 O2SCL_ERR2(
"Minimum or maximum of source index not finite ",
1076 std::vector<std::string> col_list;
1077 for(
size_t i=0;i<source.get_ncolumns();i++) {
1078 std::string col_name=source.get_column_name(i);
1079 if (col_name!=src_index && col_name!=dest_index &&
1080 is_column(col_name)==
false) {
1081 col_list.push_back(col_name);
1086 for(
size_t i=0;i<col_list.size();i++) {
1087 new_column(col_list[i]);
1088 for(
size_t j=0;j<get_nlines();j++) {
1089 double val=
get(dest_index,j);
1090 if (allow_extrap || (val>=min && val<=max)) {
1091 set(col_list[i],j,source.interp(src_index,val,col_list[i]));
1111 if (nlines>=maxlines) inc_maxlines(maxlines);
1114 for(
int i=((
int)nlines)-2;i>=((int)n);i--) {
1129 for(
int i=0;i<((int)atree.size());i++) {
1130 set(i,dest,
get(i,src));
1145 size_t irow=lookup(scol,val);
1153 for(
aiter it=atree.begin();it!=atree.end();it++) {
1155 for(
int i=((
int)irow);i<((int)nlines)-1;i++) {
1156 it->second.dat[i]=it->second.dat[i+1];
1160 if (intp_set==
true) {
1174 size_t new_nlines=0;
1175 for(
size_t i=0;i<nlines;i++) {
1176 double val=row_function(func,i);
1182 if (i!=new_nlines) {
1183 for(
aiter it=atree.begin();it!=atree.end();it++) {
1184 it->second.dat[new_nlines]=it->second.dat[i];
1191 if (intp_set==
true) {
1207 template<
class vec2_t>
1211 for(
size_t i=0;i<get_ncolumns();i++) {
1212 std::string cname=get_column_name(i);
1213 if (dest.is_column(cname)==
false) {
1214 dest.new_column(cname);
1218 size_t new_lines=dest.get_nlines();
1219 for(
size_t i=0;i<nlines;i++) {
1220 double val=row_function(func,i);
1222 dest.set_nlines_auto(new_lines+1);
1223 for(
size_t j=0;j<get_ncolumns();j++) {
1224 std::string cname=get_column_name(j);
1225 dest.set(cname,new_lines);
1250 if (row_start>=nlines || row_end>=nlines) {
1251 O2SCL_ERR2(
"Row specifications beyond end of table in ",
1252 "table::delete_rows(size_t,size_t).",
exc_einval);
1254 size_t new_nlines=0;
1255 for(
size_t i=0;i<nlines;i++) {
1256 if ((row_start<=row_end && (i<row_start || i>row_end)) ||
1257 (row_start>row_end && (i<row_start && i>row_end))) {
1258 for(
aiter it=atree.begin();it!=atree.end();it++) {
1259 it->second.dat[new_nlines]=it->second.dat[i];
1265 if (intp_set==
true) {
1278 template<
class vec_
size_t>
1282 for(
size_t j=0;j<row_list.size();j++) {
1283 if (row_list[j]>nlines) {
1284 O2SCL_ERR(
"Invalid row in table<>::delete_rows(vec_size_t &)",
1291 size_t new_nlines=0;
1292 for(
size_t i=0;i<nlines;i++) {
1294 for(
size_t j=0;j<row_list.size();j++) {
1295 if (row_list[j]==i) found=
true;
1298 for(
aiter it=atree.begin();it!=atree.end();it++) {
1299 it->second.dat[new_nlines]=it->second.dat[i];
1307 if (intp_set==
true) {
1324 std::vector<size_t> row_list;
1325 for(
size_t i=0;i<nlines-1;i++) {
1327 for(
aiter it=atree.begin();it!=atree.end() && match==
true;it++) {
1328 if (it->second.dat[i+1]!=it->second.dat[i]) match=
false;
1330 if (match) row_list.push_back(i+1);
1333 delete_rows(row_list);
1356 std::istringstream is(newheads);
1362 O2SCL_ERR2(
"At least one new column failed in ",
1379 if (maxlines==0) inc_maxlines(1);
1380 if (nlines>=maxlines) inc_maxlines(maxlines);
1387 if (nlines<maxlines && nv<=(atree.size())) {
1389 set_nlines(nlines+1);
1390 for(
size_t i=0;i<nv;i++) {
1391 (*this).set(i,nlines-1,v[i]);
1411 line_of_data(v.size(),v);
1430 if (!std::isfinite(val)) {
1432 "' not finite for column '"+
1433 scol+
"' in table::ordered_lookup()").c_str(),
exc_einval);
1436 aciter it=atree.find(scol);
1437 if (it==atree.end()) {
1438 O2SCL_ERR((((std::string)
"Column '")+scol+
1439 " not found in table::ordered_lookup().").c_str(),
1452 size_t lookup(std::string scol,
double val)
const {
1453 if (!std::isfinite(val)) {
1455 "' not finite for column '"+
1456 scol+
"' in table::lookup()").c_str(),
exc_einval);
1459 aciter it=atree.find(scol);
1460 if (it==atree.end()) {
1461 O2SCL_ERR((((std::string)
"Column '")+scol+
" not found in "+
1470 const vec_t &ov=it->second.dat;
1474 while(!std::isfinite(ov[i]) && i<nlines-1) i++;
1482 double best=ov[i], bdiff=fabs(ov[i]-val);
1483 for(;i<nlines;i++) {
1484 if (std::isfinite(ov[i]) && fabs(ov[i]-val)<bdiff) {
1487 bdiff=fabs(ov[i]-val);
1495 double lookup_val(std::string scol,
double val, std::string scol2)
const {
1497 if (!std::isfinite(val)) {
1499 "' not finite for column '"+
1500 scol+
"' in table::lookup_val()").c_str(),
exc_einval);
1503 aciter it=atree.find(scol);
1504 if (it==atree.end()) {
1505 O2SCL_ERR((((std::string)
"Column '")+scol+
" not found in "+
1509 return get(scol2,it->second.dat->lookup(val));
1516 return lookup(get_column_name(icol),val);
1522 size_t mlookup(std::string scol,
double val, std::vector<size_t> &results,
1523 double threshold=0.0)
const {
1525 if (!std::isfinite(val)) {
1527 "' not finite for column '"+
1528 scol+
"' in table::mlookup()").c_str(),
exc_einval);
1531 aciter it=atree.find(scol);
1532 if (it==atree.end()) {
1533 O2SCL_ERR((((std::string)
"Column '")+scol+
" not found in "+
1537 if (threshold==0.0) {
1538 for(i=0;i<nlines;i++) {
1539 if (it->second.dat[i]==val) {
1540 results.push_back(i);
1544 for(i=0;i<nlines;i++) {
1545 if (fabs(it->second.dat[i]-val)<threshold) {
1546 results.push_back(i);
1550 return results.size();
1581 double interp(std::string sx,
double x0, std::string sy) {
1583 aiter itx=atree.find(sx), ity=atree.find(sy);
1584 if (itx==atree.end() || ity==atree.end()) {
1585 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1586 "' not found in table::interp().").c_str(),
1590 if (!std::isfinite(x0)) {
1594 if (intp_set==
false || sx!=intp_colx || sy!=intp_coly) {
1595 if (intp_set==
true) {
1601 ity->second.dat,itype);
1618 aciter itx=atree.find(sx), ity=atree.find(sy);
1619 if (itx==atree.end() || ity==atree.end()) {
1620 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1621 "' not found in table::interp_const().").c_str(),
1625 if (!std::isfinite(x0)) {
1639 double interp(
size_t ix,
double x0,
size_t iy) {
1640 return interp(get_column_name(ix),x0,get_column_name(iy));
1647 return interp_const(get_column_name(ix),x0,get_column_name(iy));
1654 void deriv(std::string x, std::string y, std::string yp) {
1655 aiter itx, ity, ityp;
1660 ityp=atree.find(yp);
1662 if (itx==atree.end() || ity==atree.end() || ityp==atree.end()) {
1663 O2SCL_ERR(
"Column not found in table::deriv(string,string,string).",
1668 size_t ix=lookup_column(x);
1669 size_t iy=lookup_column(y);
1670 for(
int i=0;i<((int)nlines);i++) {
1671 ityp->second.dat[i]=deriv(ix,(itx->second.dat)[i],iy);
1684 double deriv(std::string sx,
double x0, std::string sy) {
1686 aiter itx=atree.find(sx), ity=atree.find(sy);
1687 if (itx==atree.end() || ity==atree.end()) {
1688 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1689 "' not found in table::deriv(string,double,string).").c_str(),
1693 if (!std::isfinite(x0)) {
1694 O2SCL_ERR(
"x0 not finite in table::deriv(string,double,string).",
1698 if (intp_set==
false || sx!=intp_colx || sy!=intp_coly) {
1699 if (intp_set==
true) {
1705 (nlines,itx->second.dat,ity->second.dat,itype);
1723 aciter itx=atree.find(sx), ity=atree.find(sy);
1724 if (itx==atree.end() || ity==atree.end()) {
1725 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1726 "' not found in table::deriv_const().").c_str(),
1730 if (!std::isfinite(x0)) {
1735 (nlines,itx->second.dat,ity->second.dat,itype);
1747 double deriv(
size_t ix,
double x0,
size_t iy) {
1748 return deriv(get_column_name(ix),x0,get_column_name(iy));
1759 return deriv_const(get_column_name(ix),x0,get_column_name(iy));
1768 void deriv2(std::string x, std::string y, std::string yp) {
1769 aiter itx, ity, ityp;
1774 ityp=atree.find(yp);
1776 if (itx==atree.end() || ity==atree.end() || ityp==atree.end()) {
1777 O2SCL_ERR(
"Column not found in table::deriv2(string,string,string).",
1782 size_t ix=lookup_column(x);
1783 size_t iy=lookup_column(y);
1784 for(
int i=0;i<((int)nlines);i++) {
1785 ityp->second.dat[i]=deriv2(ix,itx->second.dat[i],iy);
1798 double deriv2(std::string sx,
double x0, std::string sy) {
1800 aiter itx=atree.find(sx), ity=atree.find(sy);
1801 if (itx==atree.end() || ity==atree.end()) {
1802 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1803 "' not found in table::deriv2(string,double,string).").c_str(),
1807 if (!std::isfinite(x0)) {
1808 O2SCL_ERR(
"x0 not finite in table::deriv2(string,double,string).",
1812 if (intp_set==
false || sx!=intp_colx || sy!=intp_coly) {
1813 if (intp_set==
true) {
1819 (nlines,itx->second.dat,ity->second.dat,itype);
1837 aciter itx=atree.find(sx), ity=atree.find(sy);
1838 if (itx==atree.end() || ity==atree.end()) {
1839 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1840 "' not found in table::deriv2_const().").c_str(),
1844 if (!std::isfinite(x0)) {
1849 (nlines,itx->second.dat,ity->second.dat,itype);
1861 double deriv2(
size_t ix,
double x0,
size_t iy) {
1862 return deriv2(get_column_name(ix),x0,get_column_name(iy));
1873 return deriv2_const(get_column_name(ix),x0,get_column_name(iy));
1883 double integ(std::string sx,
double x1,
double x2, std::string sy) {
1885 aiter itx=atree.find(sx), ity=atree.find(sy);
1886 if (itx==atree.end() || ity==atree.end()) {
1887 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1888 "' not found in table::integ(string,double,double,string).").c_str(),
1892 if (!std::isfinite(x1) || !std::isfinite(x2)) {
1893 std::string msg=((std::string)
"Value x1=")+
dtos(x1)+
" or x2="+
1894 dtos(x2)+
" not finite in table.integ(string,double,double,string).";
1897 if (intp_set==
false || sx!=intp_colx || sy!=intp_coly) {
1898 if (intp_set==
true) {
1904 (nlines,itx->second.dat,ity->second.dat,itype);
1909 ret=si->
integ(x1,x2);
1922 std::string sy)
const {
1924 aciter itx=atree.find(sx), ity=atree.find(sy);
1925 if (itx==atree.end() || ity==atree.end()) {
1926 O2SCL_ERR((((std::string)
"Columns '")+sx+
"' or '"+sy+
1927 "' not found in table::integ_const().").c_str(),
1931 if (!std::isfinite(x1) || !std::isfinite(x2)) {
1936 (nlines,itx->second.dat,ity->second.dat,itype);
1937 ret=sic.
integ(x1,x2);
1949 return integ(get_column_name(ix),x1,x2,
1950 get_column_name(iy));
1962 return integ_const(get_column_name(ix),x1,x2,
1963 get_column_name(iy));
1974 void integ(std::string x, std::string y, std::string ynew) {
1975 aiter itx, ity, itynew;
1980 itynew=atree.find(ynew);
1982 if (itx==atree.end() || ity==atree.end() || itynew==atree.end()) {
1983 O2SCL_ERR(
"Column not found in table::integ(string,string,string).",
1988 size_t ix=lookup_column(x);
1989 size_t iy=lookup_column(y);
1990 for(
size_t i=0;i<nlines;i++) {
1991 itynew->second.dat[i]=integ(ix,(itx->second.dat)[0],
1992 (itx->second.dat)[i],iy);
2001 double max(std::string scol)
const {
2004 if (is_column(scol)==
false) {
2005 O2SCL_ERR((((std::string)
"Column '")+scol+
2009 const vec_t &dcol=get_column(scol);
2011 for(i=0;i<((int)nlines);i++) {
2012 if (std::isfinite(dcol[i])) {
2016 }
else if (dcol[i]>ret) {
2022 O2SCL_ERR((((std::string)
"No finite values in column '")+scol+
2032 double min(std::string scol)
const {
2035 if (is_column(scol)==
false) {
2036 O2SCL_ERR((((std::string)
"Column '")+scol+
2040 const vec_t &dcol=get_column(scol);
2042 for(i=0;i<((int)nlines);i++) {
2043 if (std::isfinite(dcol[i])) {
2047 }
else if (dcol[i]<ret) {
2053 O2SCL_ERR((((std::string)
"No finite values in column '")+scol+
2084 sublines=bottom-top+1;
2086 O2SCL_ERR2(
"Can't make a subtable of an empty table. ",
2087 "Returning 0 in table::subtable().",
2091 if (bottom+1>nlines) {
2092 O2SCL_ERR2(
"Requested row beyond nlines. Adjusting ",
2093 "and continuing in table::subtable().",
exc_einval);
2097 std::istringstream is(list);
2099 tnew.set_nlines(sublines);
2101 it=atree.find(head);
2102 if (it==atree.end()) {
2104 ((((std::string)
"Couldn't find column named ")+head+
2105 " in table::subtable(). Returning 0.").c_str(),
2108 tnew.new_column(head);
2109 vec_t &dcol=tnew.get_column(head);
2110 for(i=0;i<sublines;i++) {
2111 dcol[i]=it->second.dat[i+top];
2114 if (tnew.get_ncolumns()==0) {
2115 O2SCL_ERR(
"Subtable has no columns in table::subtable().",
2119 tnew.nlines=sublines;
2134 for(it=atree.begin();it!=atree.end();it++) {
2135 for(
int j=0;j<((int)nlines);j++) {
2136 it->second.dat[j]=0.0;
2162 if (intp_set==
true) {
2177 if (intp_set==
true) {
2202 size_t ncols=get_ncolumns(), nlins=get_nlines();
2206 for(
size_t i=0;i<ncols;i++) {
2207 for(
size_t j=0;j<nlins;j++) {
2208 data_copy(i,j)=
get(i,j);
2213 aiter it=atree.find(scol);
2214 vec_t &data=it->second.dat;
2216 for(
size_t i=0;i<ncols;i++) {
2217 for(
size_t j=0;j<nlins;j++) {
2218 set(i,j,data_copy(i,order[j]));
2234 aiter it=atree.find(scol);
2235 if (it==atree.end()) {
2236 O2SCL_ERR((((std::string)
"Column '")+scol+
2237 " not found in table::sort_column().").c_str(),
2244 if (intp_set && (scol==intp_colx || scol==intp_coly)) {
2262 virtual void summary(std::ostream *out,
size_t ncol=79)
const {
2264 if (constants.size()==1) {
2265 (*out) <<
"1 constant:" << std::endl;
2267 (*out) << constants.size() <<
" constants:" << std::endl;
2269 std::map<std::string,double>::const_iterator mit;
2270 for(mit=constants.begin();mit!=constants.end();mit++) {
2271 (*out) << mit->first <<
" " << mit->second << std::endl;
2275 size_t nh=get_ncolumns(), nh2;
2279 (*out) <<
"No columns." << std::endl;
2284 (*out) <<
"1 column: " << std::endl;
2286 (*out) << nh <<
" columns: " << std::endl;
2288 std::vector<std::string> h(nh);
2289 for(
size_t i=0;i<nh;i++) {
2290 h[i]=
szttos(i)+
". "+get_column_name(i);
2293 std::vector<std::string> h2;
2299 for(
size_t i=0;i<nh2;i++) {
2300 (*out) << h2[i] << std::endl;
2305 if (get_nlines()==0) (*out) <<
"No lines of data." << std::endl;
2306 else if (get_nlines()==1) (*out) <<
"One line of data." << std::endl;
2307 (*out) << get_nlines() <<
" lines of data." << std::endl;
2319 if (constants.find(name)!=constants.end()) {
2320 constants.find(name)->second=val;
2323 constants.insert(make_pair(name,val));
2338 bool err_on_notfound=
true) {
2339 if (constants.find(name)!=constants.end()) {
2340 constants.find(name)->second=val;
2343 if (err_on_notfound) {
2344 std::string err=((std::string)
"No constant with name '")+name+
2345 "' in table::set_constant().";
2353 if (constants.find(name)==constants.end()) {
2361 if (constants.find(name)==constants.end()) {
2362 std::string err=((std::string)
"No constant with name '")+name+
2363 "' in table::get_constant(string).";
2366 return constants.find(name)->second;
2371 return constants.size();
2375 virtual void get_constant(
size_t ix, std::string &name,
double &val)
const {
2376 if (ix<constants.size()) {
2377 std::map<std::string,double>::const_iterator cit=constants.begin();
2378 for(
size_t i=0;i<ix;i++) cit++;
2383 O2SCL_ERR(
"Index too large in table::get_constant(size_t,string,double).",
2390 constants.erase(name);
2405 std::vector<std::string> onames, nnames;
2407 std::istringstream is(line);
2408 while (is >> cname) {
2409 onames.push_back(cname);
2411 std::cout <<
"Read possible column name: " << cname << std::endl;
2417 for(
size_t i=0;i<onames.size();i++) {
2423 if (n_nums==onames.size()) {
2426 std::cout <<
"First row looks like it contains numerical values." 2428 std::cout <<
"Creating generic column names: ";
2431 for(
size_t i=0;i<onames.size();i++) {
2432 nnames.push_back(((std::string)
"c")+
szttos(i+1));
2433 if (verbose>0) std::cout << nnames[i] <<
" ";
2436 if (verbose>0) std::cout << std::endl;
2439 for(
size_t i=0;i<nnames.size();i++) {
2440 new_column(nnames[i]);
2444 for(
size_t i=0;i<onames.size();i++) {
2452 for(
size_t i=0;i<onames.size();i++) {
2453 std::string temps=onames[i];
2454 make_fp_varname(temps);
2455 make_unique_name(temps,nnames);
2456 nnames.push_back(temps);
2457 if (temps!=onames[i] && verbose>0) {
2458 std::cout <<
"Converted column named '" << onames[i] <<
"' to '" 2459 << temps <<
"'." << std::endl;
2464 for(
size_t i=0;i<nnames.size();i++) {
2465 new_column(nnames[i]);
2471 while ((fin) >> data) {
2473 for(
size_t i=1;i<get_ncolumns();i++) {
2491 if (atree.size()!=alist.size()) {
2492 O2SCL_ERR2(
"Size of table and list do not match in ",
2496 for(
aciter it=atree.begin();it!=atree.end();it++) {
2497 if (it->second.index!=alist[it->second.index]->second.index) {
2498 O2SCL_ERR((((std::string)
"Problem with iterator for entry '")+
2499 it->first+
"' in list in table::check_synchro().").c_str(),
2503 for(
int i=0;i<((int)atree.size());i++) {
2504 if (alist[i]->second.index!=i) {
2505 O2SCL_ERR((((std::string)
"Problem with index of entry ")+
2506 itos(i)+
" in list in table::check_synchro().").c_str(),
2515 virtual const char *
type() {
return "table"; }
2552 std::vector<std::string> funcs, names;
2555 std::istringstream is(list);
2556 while(is >> stemp) funcs.push_back(stemp);
2557 for(
size_t i=0;i<(funcs.size());i++) {
2558 names.push_back(funcs[i].substr(0,funcs[i].find(
"=")));
2559 funcs[i]=funcs[i].substr(funcs[i].find(
"=")+1,
2560 funcs[i].length()-funcs[i].find(
"=")-1);
2561 if (names[i].length()==0 || funcs[i].length()==0) {
2568 std::map<std::string,double> vars;
2569 std::map<std::string,double>::const_iterator mit;
2570 for(mit=constants.begin();mit!=constants.end();mit++) {
2571 vars[mit->first]=mit->second;
2574 std::vector<calculator> calcs(funcs.size());
2575 std::vector<vec_t> newcols(funcs.size());
2577 for(
size_t j=0;j<funcs.size();j++) {
2578 calcs[j].compile(funcs[j].c_str(),&vars);
2579 newcols[j].resize(maxlines);
2583 for(
size_t i=0;i<nlines;i++) {
2586 for(
size_t j=0;j<atree.size();j++) {
2587 vars[get_column_name(j)]=(*this)[j][i];
2591 for(
size_t j=0;j<funcs.size();j++) {
2592 newcols[j][i]=calcs[j].eval(&vars);
2596 for(
size_t j=0;j<funcs.size();j++) {
2597 if (!is_column(names[j])) {
2598 new_column(names[j]);
2600 swap_column_data(names[j],newcols[j]);
2619 if (!is_column(scol)) {
2624 aiter it2=atree.find(scol);
2625 vec_t &colp=it2->second.dat;
2628 function_vector(
function,colp);
2646 template<
class resize_vec_t>
2648 bool throw_on_err=
true) {
2652 std::map<std::string,double> vars;
2653 std::map<std::string,double>::const_iterator mit;
2654 for(mit=constants.begin();mit!=constants.end();mit++) {
2655 vars[mit->first]=mit->second;
2657 calc.
compile(
function.c_str(),&vars);
2660 if (vec.size()<nlines) vec.resize(nlines);
2663 std::vector<double> vals(atree.size());
2666 for(
size_t j=0;j<nlines;j++) {
2667 for(
aciter it=atree.begin();it!=atree.end();it++) {
2668 vars[it->first]=it->second.dat[j];
2670 vec[j]=calc.
eval(&vars);
2682 std::map<std::string,double> vars;
2683 std::map<std::string,double>::const_iterator mit;
2684 for(mit=constants.begin();mit!=constants.end();mit++) {
2685 vars[mit->first]=mit->second;
2687 calc.
compile(
function.c_str(),&vars);
2689 for(
aciter it=atree.begin();it!=atree.end();it++) {
2690 vars[it->first]=it->second.dat[row];
2693 double dret=calc.
eval(&vars);
2703 std::map<std::string,double> vars;
2704 std::map<std::string,double>::const_iterator mit;
2705 for(mit=constants.begin();mit!=constants.end();mit++) {
2706 vars[mit->first]=mit->second;
2708 calc.
compile(
function.c_str(),&vars);
2710 double best_val=0.0;
2712 for(
size_t row=0;row<nlines-1;row++) {
2713 for(
aciter it=atree.begin();it!=atree.end();it++) {
2714 vars[it->first]=it->second.dat[row];
2716 double dtemp=calc.
eval(&vars);
2720 if (dtemp>best_val) {
2733 friend void o2scl_hdf::hdf_output
2739 friend void o2scl_hdf::hdf_output_data
2747 #ifndef DOXYGEN_INTERNAL 2764 for(it=atree.begin();it!=atree.end();it++) {
2765 alist[it->second.index]=it;
2774 if (s==
"abs" || s==
"acos" || s==
"acosh" || s==
"asin" ||
2775 s==
"asinh" || s==
"atan" || s==
"atan2" || s==
"atanh" ||
2776 s==
"ceil" || s==
"cos" || s==
"cosh" || s==
"cot" || s==
"csc" ||
2777 s==
"eval" || s==
"exp" || s==
"floor" || s==
"if" || s==
"int" ||
2778 s==
"log" || s==
"log10" || s==
"max" || s==
"min" || s==
"sec" ||
2779 s==
"sin" || s==
"sinh" || s==
"sqrt" || s==
"tan" || s==
"tanh") {
2780 s=((std::string)
"v_")+s;
2781 }
else if (s[0]>=
'0' && s[0]<=
'9') {
2782 s=((std::string)
"v_")+s;
2785 for(
size_t i=0;i<s.length();i++) {
2786 if (!isalpha(s[i]) && !isdigit(s[i]) && s[i]!=
'_') s[i]=
'_';
2798 for(
size_t i=0;i<cnames.size();i++) {
2799 if (colx==cnames[i]) {
2807 }
while (done==
false);
2828 typedef typename std::map<std::string,
col,
2829 std::greater<std::string> >::iterator
aiter;
2831 typedef typename std::map<std::string,col,
2832 std::greater<std::string> >::const_iterator
2835 typedef typename std::vector<aiter>::iterator
aviter;
2845 std::map<std::string,col,std::greater<std::string> >
atree;
2854 aiter it=atree.find(lname);
2855 if (it==atree.end()) {
2856 O2SCL_ERR((((std::string)
"Column '")+lname+
2857 " not found in table::get_iterator().").c_str(),
2864 aiter it=atree.find(lname);
2865 if (it==atree.end()) {
2866 O2SCL_ERR((((std::string)
"Column '")+lname+
2867 " not found in table::get_col_struct().").c_str(),
2871 return &(it->second);
2876 aiter
end() {
return atree.end(); }
2904 #ifndef DOXYGEN_NO_O2NS void delete_rows(size_t row_start, size_t row_end)
Delete all rows between row_start and row_end .
size_t mlookup(std::string scol, double val, std::vector< size_t > &results, double threshold=0.0) const
Exhaustively search column col for many occurences of val .
virtual void delete_column(std::string scol)
Delete column named scol .
size_t nlines
The size of presently used memory.
aiter begin()
Return the beginning of the column tree.
void deriv(std::string x, std::string y, std::string yp)
Make a new column named yp which is the derivative formed from columns named x and y ...
double max(std::string scol) const
Return column maximum. Makes no assumptions about ordering, .
void clear_table()
Clear the table and the column names (but leave constants)
const vec_t & operator[](std::string scol) const
Returns the column named scol (const version). .
void line_of_data(const vec2_t &v)
Read a line of data and store in a new row of the table.
void copy_to_column(vec2_t &v, std::string scol)
Copy to a column from a generic vector object.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
std::string intp_coly
The last y-column interpolated.
size_t get_nlines() const
Return the number of lines.
double integ(size_t ix, double x1, double x2, size_t iy)
Compute the integral of the function defined by x-values stored in column with index ix and y-values ...
void delete_rows(vec_size_t &row_list)
Delete all rows in a specified list.
interp_vec< vec_t > * si
Interpolation object.
double min(std::string scol) const
Return column minimum. Makes no assumptions about ordering, .
double deriv(std::string sx, double x0, std::string sy)
Compute the first derivative of the function defined by x-values stored in column named sx and y-valu...
double integ_const(size_t ix, double x1, double x2, size_t iy) const
Compute the integral of the function defined by x-values stored in column with index ix and y-values ...
void hdf_input_data(hdf_file &hf, o2scl::table< vec_t > &t)
Internal function for inputting a o2scl::table object.
void compile(const char *expr, std::map< std::string, double > *vars=0, bool debug=false, std::map< std::string, int > opPrec=opPrecedence)
Compile expression expr using variables specified in vars.
void copy_rows(std::string func, table< vec2_t > &dest)
Copy all rows matching a particular condition to a new table.
virtual double deriv2(const double x0) const
Give the value of the second derivative .
void subtable(std::string list, size_t top, size_t bottom, table< vec_t > &tnew) const
Make a subtable.
void zero_table()
Zero the data entries but keep the column names and nlines fixed.
void set_nlines(size_t il)
Set the number of lines.
void functions_columns(std::string list)
Create new columns or recompute from a list of functions.
void new_row(size_t n)
Insert a row before row n.
sanity check failed - shouldn't happen
int function_vector(std::string function, resize_vec_t &vec, bool throw_on_err=true)
Compute a column from a function specified in a string.
aiter get_iterator(std::string lname)
Return the iterator for a column.
double deriv_const(std::string sx, double x0, std::string sy) const
Compute the first derivative of the function defined by x-values stored in column named sx and y-valu...
invalid argument supplied by user
void deriv2(std::string x, std::string y, std::string yp)
Create a new column named yp which is equal to the second derivative of the function defined by x-val...
virtual int set_constant(std::string name, double val, bool err_on_notfound=true)
Set a constant equal to a value, but don't add it if not already present.
void set_nlines_auto(size_t il)
Set the number of lines, increasing the size more agressively.
double deriv(size_t ix, double x0, size_t iy)
Compute the first derivative of the function defined by x-values stored in column with index ix and y...
std::string intp_colx
The last x-column interpolated.
virtual void remove_constant(std::string name)
Remove a constant.
double integ_const(std::string sx, double x1, double x2, std::string sy) const
Compute the integral of the function defined by x-values stored in column named sx and y-values store...
A class for representing permutations.
virtual ~table()
Table destructor.
void make_fp_varname(std::string &s)
Ensure a variable name does not match a function or contain non-alphanumeric characters.
void delete_idadj_rows()
Delete all rows which are identical to adjacent rows.
double interp_const(size_t ix, double x0, size_t iy) const
Interpolate value x0 from column with index ix into column with index iy .
virtual double deriv(const double x0) const
Give the value of the derivative .
int new_column(std::string name, size_t sz, vec2_t &v)
Add a new column by copying data from another vector.
virtual size_t get_nconsts() const
Get the number of constants.
table & operator=(const table &t)
Copy constructor.
double interp_const(std::string sx, double x0, std::string sy) const
Interpolate value x0 from column named sx into column named sy (const version)
std::map< std::string, col, std::greater< std::string > >::const_iterator aciter
Const map iterator type.
void check_synchro() const
Return 0 if the tree and list are properly synchronized.
Generic "not found" result.
void insert_table(table< vec2_t > &source, std::string src_index, bool allow_extrap=true, std::string dest_index="")
Insert columns from a source table into the new table by interpolation (or extrapolation) ...
vec_t empty_col
An empty vector for get_column()
std::vector< aiter > alist
The list of tree iterators.
const vec_t & get_column(std::string scol) const
Returns a reference to the column named col. .
size_t get_interp_type() const
Get the interpolation type.
double integ(std::string sx, double x1, double x2, std::string sy)
Compute the integral of the function defined by x-values stored in column named sx and y-values store...
virtual double get_constant(std::string name) const
Get a constant.
void clear_data()
Remove all of the data by setting the number of lines to zero.
void reset_list()
Set the elements of alist with the appropriate iterators from atree. .
std::map< std::string, double > constants
The list of constants.
void vector_sort_index(size_t n, const vec_t &data, vec_size_t &order)
Create a permutation which sorts a vector (in increasing order)
size_t get_maxlines()
Return the maximum number of lines before a reallocation is required.
Cubic spline for natural boundary conditions.
double interp(std::string sx, double x0, std::string sy)
Interpolate value x0 from column named sx into column named sy.
size_t maxlines
The size of allocated memory.
void sort_column(std::string scol)
Individually sort the column scol.
double lookup_val(std::string scol, double val, std::string scol2) const
Search column col for the value val and return value in col2.
void line_of_names(std::string newheads)
Read a new set of names from newheads.
void init_column(std::string scol, double val)
Initialize all values of column named scol to val .
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
Column structure for table [protected].
The O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl namespace ...
std::string dtos(double x, int prec=6, bool auto_prec=false)
Convert a double to a string.
double deriv2(std::string sx, double x0, std::string sy)
Compute the second derivative of the function defined by x-values stored in column named sx and y-val...
size_t ordered_lookup(std::string scol, double val) const
Look for a value in an ordered column .
virtual double integ(const double x1, const double x2) const
Give the value of the integral .
virtual void copy_column(std::string src, std::string dest)
Copy data from column named src to column named dest, creating a new column if necessary ...
col * get_col_struct(std::string lname)
Return the column structure for a column.
double interp(size_t ix, double x0, size_t iy)
Interpolate value x0 from column with index ix into column with index iy .
void get_row(std::string scol, double val, resize_vec_t &row) const
Returns a copy of the row with value val in column col. .
table(const table &t)
Copy constructor.
virtual const char * type()
Return the type, "table".
void screenify(size_t nin, const string_arr_t &in_cols, std::vector< std::string > &out_cols, size_t max_size=80)
Reformat the columns for output of width size.
double eval(std::map< std::string, double > *vars=0)
Evalate the previously compiled expression using variables specified in vars.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
void make_unique_name(std::string &colx, std::vector< std::string > &cnames)
Make sure a name is unique.
void line_of_data(size_t nv, const vec2_t &v)
Read a line of data from the first nv entries in a vector and store as a new row in the table...
void copy_row(size_t src, size_t dest)
Copy the data in row src to row dest.
virtual void add_constant(std::string name, double val)
Add a constant, or if the constant already exists, change its value.
void delete_row(std::string scol, double val)
Delete the row with the entry closest to the value val in column scol .
void set_interp_type(size_t interp_type)
Set the base interpolation objects.
bool is_number(std::string s)
Return true if the string s is likely a integral or floating point number.
size_t ordered_lookup(const double x0) const
Find the index of x0 in the ordered array x.
Evaluate a mathematical expression in a string.
double deriv2(size_t ix, double x0, size_t iy)
Compute the second derivative of the function defined by x-values stored in column with index ix and ...
void delete_rows(std::string func)
Delete all rows where func evaluates to a number greater than 0.5 .
double deriv2_const(size_t ix, double x0, size_t iy) const
Compute the second derivative of the function defined by x-values stored in column with index ix and ...
void delete_row(size_t irow)
Delete the row of index irow .
size_t get_ncolumns() const
Return the number of columns.
double stod(std::string s)
Convert a string to a double.
virtual bool is_constant(std::string name) const
Test if name is a constant.
void new_column(std::string head)
Add a new column owned by the table table .
void clear()
Clear everything.
virtual void summary(std::ostream *out, size_t ncol=79) const
Output a summary of the information stored.
aiter end()
Return the end of the column tree.
void set_maxlines(size_t llines)
Manually set the maximum number of lines.
void column_to_vector(std::string scol, resize_vec_t &v) const
Copy a column to a generic vector object.
void function_column(std::string function, std::string scol)
Make a column from the function specified in function and add it to the table.
void integ(std::string x, std::string y, std::string ynew)
Create a new column named ynew which is equal to the integral of the function defined by x-values sto...
bool is_column(std::string scol) const
Return true if scol is a column in the current table table .
Searching class for monotonic data with caching.
size_t lookup(int icol, double val) const
Exhaustively search column col for the value val .
std::map< std::string, col, std::greater< std::string > >::iterator aiter
Map iterator type.
virtual void get_constant(size_t ix, std::string &name, double &val) const
Get a constant by index.
Store data in an O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$sc...
void set_row(size_t row, size_vec_t &v)
Set an entire row of data.
table(size_t cmaxlines=0)
Create a new table with space for nlines<=cmaxlines.
bool intp_set
True if the interpolation object is up-to-date.
double row_function(std::string function, size_t row) const
Compute a value by applying a function to a row.
std::map< std::string, col, std::greater< std::string > > atree
The tree of columns.
void get_row(size_t irow, resize_vec_t &row) const
Returns a copy of row number irow. .
size_t function_find_row(std::string function) const
Find a row which maximizes a function.
Invalid index for array or matrix.
size_t itype
Current interpolation type.
virtual int read_generic(std::istream &fin, int verbose=0)
Clear the current table and read from a generic data file.
void add_col_from_table(table< vec2_t > &source, std::string src_index, std::string src_col, std::string dest_index, std::string dest_col="")
Insert a column from a separate table, interpolating it into a new column.
std::string itos(int x)
Convert an integer to a string.
static const double x2[5]
virtual double eval(const double x0) const
Give the value of the function .
std::string get_column_name(size_t icol) const
Returns the name of column col .
static const double x1[5]
std::string szttos(size_t x)
Convert a size_t to a string.
void hdf_input(hdf_file &hf, o2scl::table< vec_t > &t, std::string name)
Input a o2scl::table object from a hdf_file.
vec_t dat
Pointer to column.
std::vector< aiter >::iterator aviter
Vector iterator type.
void clear_constants()
CLear all constants.
void vector_sort_double(size_t n, vec_t &data)
Sort a vector of doubles (in increasing order)
double deriv2_const(std::string sx, double x0, std::string sy) const
The Compute the second derivative of the function defined by x-values stored in column named sx and y...
double deriv_const(size_t ix, double x0, size_t iy) const
Compute the first derivative of the function defined by x-values stored in column with index ix and y...
size_t lookup_column(std::string lname) const
Find the index for column named name .
size_t lookup(std::string scol, double val) const
Exhaustively search column col for the value val .
Interpolation class for general vectors.
void inc_maxlines(size_t llines)
Manually increase the maximum number of lines.
virtual void swap_column_data(std::string scol, vec_t &v)
Swap the data in column scol with that in vector v.
std::string get_sorted_name(size_t icol) const
Returns the name of column col in sorted order. .
void sort_table(std::string scol)
Sort the entire table by the column scol.
virtual void rename_column(std::string src, std::string dest)
Rename column named src to dest .