Mercurial > hg > kwantix
changeset 30:d22bce6382d7
Finalise removal of all namespaces, one namespace to rule them all.
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Wed, 03 Feb 2010 19:30:20 -0600 |
parents | 24f3c4ed5c84 |
children | 9a2279c9d003 |
files | Makefile src/Makefile src/bvp.cpp src/ddm.cpp src/diff_op.cpp src/error.cpp src/func.cpp src/include/func.hpp src/include/interpolator.hpp src/include/utils.hpp src/interp_values.cpp src/interpolator.cpp src/linalg.cpp src/main-Laplace.cpp src/main-ddm-diff-adv.cpp src/main-diff-adv.cpp src/main-linear-wave-eq.cpp src/main-poisson.cpp src/main-profiling.cpp src/main-sw-euler.cpp src/main-sw-rk4.cpp src/main.cpp src/rbf.cpp src/terrain_test.tcl src/utils.cpp vtk/terrain_test.tcl |
diffstat | 24 files changed, 154 insertions(+), 187 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bvp.cpp +++ b/src/bvp.cpp @@ -9,8 +9,7 @@ #include "include/func.hpp" -namespace bvp{ - using utils::contains; +namespace kwantxi{ using std::pair; using std::make_pair; @@ -28,9 +27,6 @@ } domain::domain(string intr, string bdry, string ns){ - using namespace utils; - using namespace linalg; - using namespace error_handling; bool intr_empty, bdry_empty; @@ -165,7 +161,7 @@ void domain::add_to_normals(const map<point, vector> &ns){ for(map<point, vector>::const_iterator I = ns.begin(); I != ns.end(); I++){ - if (!utils::contains(boundary, I->first)){ + if (!kwantxi::contains(boundary, I->first)){ badArgument exc; exc.reason = "Bad normal given: must match a point on the boundary."; exc.line = __LINE__; @@ -184,7 +180,7 @@ } void domain::add_to_normals(const point &bdry, const vector &n){ - if (!utils::contains(boundary, bdry)){ + if (!kwantxi::contains(boundary, bdry)){ badArgument exc; exc.reason = "Bad normal given: must match a point on the boundary."; exc.line = __LINE__; @@ -218,9 +214,9 @@ //Is point in this domain, whether interior or boundary? bool domain::contains(const point& p) const{ - if(utils::contains(interior, p)) + if(kwantxi::contains(interior, p)) return true; - if(utils::contains(boundary, p)) + if(kwantxi::contains(boundary, p)) return true; return false; }
--- a/src/ddm.cpp +++ b/src/ddm.cpp @@ -12,10 +12,9 @@ //debug #include <iostream> -namespace bvp{ +namespace kwantxi{ using namespace std; - using namespace linalg; - using linalg::vector; + using kwantxi::vector; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -33,7 +32,7 @@ double ddm_bdry_diff_op::at(const realfunc &f, const point &p) const { - if( utils::contains(intr_bdry_pts, p)) + if( kwantxi::contains(intr_bdry_pts, p)) return Bprime -> at(f,p); return B -> at(f,p); @@ -42,7 +41,7 @@ double ddm_bdry_diff_op::at(const realfunc &f, const point &p, const vector &n) const { - if( utils::contains(intr_bdry_pts, p)) + if( kwantxi::contains(intr_bdry_pts, p)) return Bprime -> at(f,p,n); return B -> at(f,p,n); @@ -81,7 +80,7 @@ throw exc; } - if(!utils::includes(boundary,union_boundary) ){ + if(!kwantxi::includes(boundary,union_boundary) ){ badArgument exc; exc.reason = "Bad argument in domain decomposition method constructor: \n" @@ -353,8 +352,8 @@ for(map<point, shared_ptr<const overlapping_domain> >::const_iterator i = bdry_asst.begin(); i != bdry_asst.end(); i++) { - if(!utils::contains(ols, i->second) or - !utils::contains(bdry_copy, i->first)){ + if(!kwantxi::contains(ols, i->second) or + !kwantxi::contains(bdry_copy, i->first)){ badArgument exc; exc.reason = "Bad argument in overlapping_domain constructor: \n" @@ -386,7 +385,7 @@ shared_ptr<const overlapping_domain> overlapping_domain::which_domain(const point& p) const { - if(!utils::contains(boundary_assignments, p)){ + if(!kwantxi::contains(boundary_assignments, p)){ shared_ptr<const overlapping_domain> zero; return zero; } @@ -397,7 +396,7 @@ overlapping_domain:: set_overlapper_info(const point& p, const shared_ptr<overlapping_domain> o) { - if(utils::contains(this -> get_boundary(), p)) + if(kwantxi::contains(this -> get_boundary(), p)) boundary_assignments[p] = o; } @@ -413,7 +412,7 @@ for(set<shared_ptr<overlapping_domain> >::iterator d_other = domains.begin(); d_other != domains.end(); d_other++) if( - utils::contains((*d_other ) -> get_interior(), *p) + kwantxi::contains((*d_other ) -> get_interior(), *p) ){ (*d) -> boundary_assignments[*p] = *d_other; (*d) -> overlappers.insert(*d_other); @@ -426,8 +425,6 @@ //Instantiations - using namespace rbf; - template class additive_schwarz_ddm<piecewise_polynomial>; template class additive_schwarz_ddm<thin_plate_spline>; template class additive_schwarz_ddm<multiquadric>;
--- a/src/diff_op.cpp +++ b/src/diff_op.cpp @@ -3,11 +3,8 @@ #include "include/func.hpp" -namespace bvp{ +namespace kwantxi{ using namespace std; - using namespace linalg; - using namespace error_handling; - //************** Differential operator functions ********************* double diff_op::operator()(const realfunc &f, const point &p) const
--- a/src/error.cpp +++ b/src/error.cpp @@ -1,7 +1,7 @@ // File with a few function definitions. #include "include/error.hpp" -namespace error_handling{ +namespace kwantxi{ void errorHandler(const char * reason, const char * file, int line, int gsl_errno){ //This exception is so common that we will want more information @@ -86,4 +86,4 @@ } } //ends void handler(const char*, const char*, int, int); -} //Ends the error_handling namespace. +}
--- a/src/func.cpp +++ b/src/func.cpp @@ -4,7 +4,7 @@ #include <cmath> #include <limits> -namespace bvp{ +namespace kwantxi{ //The static variables... double realfunc::eps = 0; @@ -101,9 +101,9 @@ return 0; } - error_handling::badArgument + kwantxi::badArgument realfunc::no_init(int line, string file) const{ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.line = line; exc.file = file; exc.reason = "Did not assign a function pointer to a realfunc object.";
--- a/src/include/func.hpp +++ b/src/include/func.hpp @@ -23,7 +23,7 @@ * \f$\mathbb{R}\f$ . * * That is, a realfunc is a real-valued function that takes in - * linalg::point and returns doubles. This class is meant to be + * kwantxi::point and returns doubles. This class is meant to be * generic and any other real-valued function (e.g. a * radial_basis_function) should derive from this one. * @@ -64,10 +64,10 @@ /// Have already initialised epsilon above? static bool initialised ; private: - /// Pointer to a function that takes linalg::point and returns double + /// Pointer to a function that takes kwantxi::point and returns double double (*myfunc)(const point &p); /// Exception builder - error_handling::badArgument + kwantxi::badArgument no_init(int line, string file) const; };
--- a/src/include/interpolator.hpp +++ b/src/include/interpolator.hpp @@ -38,8 +38,8 @@ * * The interpolator can be used in various ways, initialised by * either a BVP::linear_bvp2 or by interpolation data - * (i.e. std::map< linalg::point, double>). Once an interpolator is - * initialised, it becomes a bona fide bvp::realfunc, so that its + * (i.e. std::map< kwantxi::point, double>). Once an interpolator is + * initialised, it becomes a bona fide kwantxi::realfunc, so that its * evaluations and derivatives become available. For certain * problems, it is convenient to be able to evaluate the * interpolator or its derivatives at all points of the domain. It
--- a/src/include/utils.hpp +++ b/src/include/utils.hpp @@ -30,19 +30,19 @@ bool includes(const std::set<E>& s1, const std::set<E>& s2); ///Reads matrices from filenames. - linalg::matrix read_matrix(std::string filename); + kwantxi::matrix read_matrix(std::string filename); ///Reads vectors from filenames. - linalg::vector read_vector(std::string filename); + kwantxi::vector read_vector(std::string filename); /*! \brief Reads map<point,double> from a matrix. * *Last column is the value at each point which is represented in *turn by the rest of the row. */ - std::map<linalg::point, double> read_pd_map(std::string filename); + std::map<kwantxi::point, double> read_pd_map(std::string filename); ///Outputs some information about generic exceptions. - void show_exception(error_handling::error exc); + void show_exception(kwantxi::error exc); }
--- a/src/interp_values.cpp +++ b/src/interp_values.cpp @@ -2,7 +2,7 @@ //debug #include <iostream> -namespace bvp{ +namespace kwantxi{ // ************************ interp_values stuff ***************** badArgument interp_values::different_rbfs(int line, string file) const @@ -83,7 +83,7 @@ { if(v.size() == m+n){ //Lower part of the vector contains the boundary - linalg::slice s(n+1,v.size()); + kwantxi::slice s(n+1,v.size()); v = v(s); } else if(v.size() != m){ @@ -102,7 +102,7 @@ { if(v.size() == m+n){ //Upper part of the vector contains the boundary - linalg::slice s(1,n); + kwantxi::slice s(1,n); v = v(s); } else if(v.size() != n){ @@ -117,10 +117,10 @@ //*************** normals stuff ************************************* normals::normals(size_t rbfs_hash_in, - const map<point, linalg::vector>& normals_in, + const map<point, kwantxi::vector>& normals_in, size_t n_in) : rbfs_hash(rbfs_hash_in), n(n_in) { - map<point, linalg::vector>::const_iterator I; + map<point, kwantxi::vector>::const_iterator I; size_t rows = normals_in.size(); size_t cols = normals_in.begin() -> second.size(); slice s(1,cols); @@ -158,7 +158,7 @@ interp_values operator-(double a, const interp_values& v) { - linalg::vector w(v.v.size(),a); + kwantxi::vector w(v.v.size(),a); return interp_values(w-v.v, v.rbfs_hash,v.n,v.m); } @@ -169,7 +169,7 @@ interp_values operator/(double a, const interp_values& v) { - linalg::vector w(v.v.size(),a); + kwantxi::vector w(v.v.size(),a); return interp_values(w/v.v, v.rbfs_hash,v.n,v.m); } }
--- a/src/interpolator.cpp +++ b/src/interpolator.cpp @@ -15,7 +15,7 @@ #include <boost/functional/hash.hpp> #include <boost/shared_ptr.hpp> -namespace bvp{ +namespace kwantxi{ using boost::shared_ptr; template<typename RBF> @@ -61,9 +61,9 @@ for(map<point, double>::const_iterator I = Xi.begin(); I != Xi.end(); I++) { - if(utils::contains(Omega -> get_interior(), I -> first)) + if(kwantxi::contains(Omega -> get_interior(), I -> first)) f[I -> first] = I -> second; - else if(utils::contains(Omega -> get_boundary(), I -> first)) + else if(kwantxi::contains(Omega -> get_boundary(), I -> first)) g[I -> first] = I -> second; else { @@ -165,7 +165,6 @@ { thebvp = bvp; - using namespace linalg; using std::set; shared_ptr<const domain> Omega = bvp -> get_domain(); @@ -223,7 +222,7 @@ rbfs_hash = hash_value(rbfs); - bvp::normals nrmls_tmp(rbfs_hash, normals, n); + kwantxi::normals nrmls_tmp(rbfs_hash, normals, n); nrmls = nrmls_tmp; initted = true; @@ -415,7 +414,7 @@ // ------------------- Whole domain evaluations ---------------- template<typename RBF> - error_handling::badArgument + kwantxi::badArgument interpolator<RBF>::not_precomputed(int line, string file) const { badArgument exc; @@ -608,7 +607,7 @@ std::vector<size_t> alpha; //empty, corresponds to evaluation if(precomp_values_vec.find(alpha) == precomp_values_vec.end()) at(); - linalg::vector rhs = precomp_values_vec[alpha]; + kwantxi::vector rhs = precomp_values_vec[alpha]; slice s1(1,n), s2(n+1,n+m); rhs(s2) = b_new.v; coeffs = precomp_rbfs[alpha].inv(rhs); @@ -628,7 +627,7 @@ } template<typename RBF> - error_handling::badArgument + kwantxi::badArgument interpolator<RBF>::not_initted(int line, string file) const { badArgument exc; @@ -642,7 +641,7 @@ template<typename RBF> void interpolator<RBF>::computecoeffs(bool rhs_defined) { - linalg::vector rhs(n+m); + kwantxi::vector rhs(n+m); //Compute the RBF coefficients if(rhs_defined){ @@ -672,7 +671,7 @@ typename map<std::vector<size_t>, matrix>::const_iterator I; for(I = precomp_rbfs.begin(); I != precomp_rbfs.end(); I++){ - linalg::vector vals = (I->second)*coeffs; + kwantxi::vector vals = (I->second)*coeffs; precomp_values_vec[I -> first] = vals; precomp_values[I -> first] = valsvec2map(vals); } @@ -681,7 +680,7 @@ template<typename RBF> map<point, double> interpolator<RBF>:: - valsvec2map(const linalg::vector& values) const + valsvec2map(const kwantxi::vector& values) const { map<point, double> out; { @@ -703,7 +702,7 @@ template<typename RBF> void interpolator<RBF>::into_os(std::ostream& os) const { - linalg::vector values; + kwantxi::vector values; size_t i; set<point>::const_iterator I; @@ -713,7 +712,7 @@ values = precomp_values_vec[alpha]; } else{ - linalg::vector tmp(n+m); + kwantxi::vector tmp(n+m); for(i = 1, I=thebvp->get_domain()->get_interior().begin() ; i<=n; i++, I++) { @@ -744,7 +743,6 @@ } //Instantiations - using namespace rbf; template class interpolator<piecewise_polynomial>; template class interpolator<thin_plate_spline>; template class interpolator<multiquadric>;
--- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -11,8 +11,7 @@ #include <gsl/gsl_math.h> //For floating-point comparison. //Matrix stuff -namespace linalg{ - using namespace error_handling; +namespace kwantxi{ const double matrix::eps = std::numeric_limits<double>::epsilon(); const double vector::eps = std::numeric_limits<double>::epsilon(); @@ -355,7 +354,7 @@ //***************** LUmatrix stuff ********************************** -namespace linalg{ +namespace kwantxi{ matrix::LUmatrix::LUmatrix(gsl_matrix* M){ A = gsl_matrix_alloc(M -> size1, M -> size2); gsl_matrix_memcpy(A,M); @@ -418,8 +417,7 @@ //Vector stuff -namespace linalg{ - using namespace error_handling; +namespace kwantxi{ // **************** Vector allocation stuff ********************* @@ -625,7 +623,7 @@ } //************************* Vector view stuff ******************************* -namespace linalg{ +namespace kwantxi{ vector_view::vector_view(){ x = 0; } @@ -718,8 +716,7 @@ //Slice stuff -namespace linalg{ - using namespace error_handling; +namespace kwantxi{ slice::slice(size_t a, size_t b, size_t k) { set(a,b,k); @@ -762,7 +759,7 @@ } //Non-member functions -namespace linalg{ +namespace kwantxi{ // ************* I/O ************************ @@ -782,7 +779,7 @@ bool colvector = true; bool shouldbedone = false; while(getline(is, s)){ - s = utils::trim(s); + s = kwantxi::trim(s); if(s[0] == '#' or s.size() == 0) //Blank line or comment character continue; @@ -848,7 +845,7 @@ size_t rows = 0; size_t cols = 0; while(getline(is, line)){ - line = utils::trim(line); + line = kwantxi::trim(line); //Blank row or comment character. if(line[0] == '#' or line.length() == 0) continue;
--- a/src/main-Laplace.cpp +++ b/src/main-Laplace.cpp @@ -28,9 +28,7 @@ #define RBF_TYPE inverse_multiquadric //Replace by template later. using namespace std; -using namespace linalg; -using namespace rbf; -using namespace bvp; +using namespace kwantxi; //Some arbitrary interior function for Poisson equation (change to //"return 0*p(1);", for example, for Laplace equation). @@ -50,10 +48,10 @@ void output_result(const interpolator<RBF_TYPE>& u); int main(){ - using linalg::vector; + using kwantxi::vector; try{ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); //Define the domain from given data shared_ptr<domain> Omega(new domain("data/interior.matrix", @@ -79,7 +77,7 @@ } catch(error& exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); } return 0;
--- a/src/main-ddm-diff-adv.cpp +++ b/src/main-ddm-diff-adv.cpp @@ -11,9 +11,7 @@ #include "include/ddm.hpp" #include "include/func.hpp" -using namespace linalg; -using namespace bvp; -using namespace rbf; +using namespace kwantxi; class conv_diff : public linear_diff_op2{ public: @@ -47,12 +45,12 @@ dirichlet_op D; }; -double f(const linalg::point& p){ +double f(const kwantxi::point& p){ p.size(); return 0; } -double g(const linalg::point& p){ +double g(const kwantxi::point& p){ if(p(1) == 0) return 1; if(p(1) == 1) @@ -64,11 +62,11 @@ int main(){ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try{ using namespace std; - using linalg::vector; + using kwantxi::vector; shared_ptr<domain> Omega(new domain("data/intr.v", "data/bdry.v", "data/nrml.v")); @@ -100,7 +98,7 @@ piecewise_polynomial::set_n(7); thin_plate_spline::set_n(8); - c_infty_rbf::set_epsilon(7.234); + c_infty_kwantxi::set_epsilon(7.234); additive_schwarz_ddm<thin_plate_spline> solver(dd_in, thebvp); @@ -132,7 +130,7 @@ } catch(error exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); } return 0; }
--- a/src/main-diff-adv.cpp +++ b/src/main-diff-adv.cpp @@ -11,9 +11,7 @@ #include "include/diff_op.hpp" #include "include/ddm.hpp" -using namespace linalg; -using namespace bvp; -using namespace rbf; +using namespace kwantxi; class conv_diff : public linear_diff_op2{ public: @@ -144,12 +142,12 @@ dirichlet_op D; }; -double f(const linalg::point& p){ +double f(const kwantxi::point& p){ p.size(); return 0; } -double g(const linalg::point& p){ +double g(const kwantxi::point& p){ if(p(1) == 0) return 1; if(p(1) == 1) @@ -161,11 +159,11 @@ int main(){ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try{ using namespace std; - using linalg::vector; + using kwantxi::vector; shared_ptr<domain> Omega(new domain("data/intr.v", "data/bdry.v", "data/nrml.v")); @@ -201,7 +199,7 @@ piecewise_polynomial::set_n(7); thin_plate_spline::set_n(6); - c_infty_rbf::set_epsilon(20.534); + c_infty_kwantxi::set_epsilon(20.534); interpolator<piecewise_polynomial> solver(thebvp); @@ -245,7 +243,7 @@ } catch(error exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); } return 0; }
--- a/src/main-linear-wave-eq.cpp +++ b/src/main-linear-wave-eq.cpp @@ -12,9 +12,7 @@ #include "include/interpolator.hpp" #include "include/func.hpp" -using namespace linalg; -using namespace bvp; -using namespace rbf; +using namespace kwantxi; class wave_op : public linear_diff_op2{ public: @@ -57,18 +55,18 @@ }; int main(){ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try{ using namespace std; - using linalg::vector; + using kwantxi::vector; shared_ptr<domain> Omega(new domain("data/circ_intr.matrix", "data/circ_bdry.matrix", "data/circ_nrml.matrix") ); //Interior conditions, init them - map<point,double> u_init = utils::read_pd_map("data/wave_init.map"); + map<point,double> u_init = kwantxi::read_pd_map("data/wave_init.map"); //Boundary conditions, Dirichlet, set to zero (clamped membrane) zero_func g; @@ -99,7 +97,7 @@ return 0; } catch(error exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); return 1; }
--- a/src/main-poisson.cpp +++ b/src/main-poisson.cpp @@ -28,9 +28,7 @@ #define RBF_TYPE inverse_multiquadric //Replace by template later. using namespace std; -using namespace linalg; -using namespace rbf; -using namespace bvp; +using namespace kwantxi; //Some arbitrary interior function for Poisson equation (change to //"return 0*p(1);", for example, for Laplace equation). @@ -50,10 +48,10 @@ void output_result(const interpolator<RBF_TYPE>& u); int main(){ - using linalg::vector; + using kwantxi::vector; try{ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); //Define the domain from given data shared_ptr<domain> Omega(new domain("data/interior.matrix", @@ -79,7 +77,7 @@ } catch(error& exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); } return 0;
--- a/src/main-profiling.cpp +++ b/src/main-profiling.cpp @@ -12,20 +12,20 @@ //********************** Main ****************************************** int main(){ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try { using namespace std; - using namespace linalg; + using namespace kwantxi point p(2),q(2); p(1) = P1; p(2) = P2; q(1) = Q1; q(2) = Q2; - rbf::radial_basis_function::set_dimension(2); - rbf::multiquadric phi(p); + kwantxi::radial_basis_function::set_dimension(2); + kwantxi::multiquadric phi(p); double out; for(size_t i = 0; i < 10000000; i++){ // out = phi(q); @@ -45,9 +45,9 @@ cout << out << endl; return 0; } - catch(error_handling::error exc) + catch(kwantxi::error exc) { - utils::show_exception(exc); + kwantxi::show_exception(exc); return 1; }
--- a/src/main-sw-euler.cpp +++ b/src/main-sw-euler.cpp @@ -15,10 +15,9 @@ #include "include/interpolator.hpp" #include "include/func.hpp" -using namespace linalg; -using namespace bvp; +using namespace kwantxi; -#define RBF_TYPE rbf::conical +#define RBF_TYPE kwantxi::conical //Will solve the system // @@ -133,13 +132,13 @@ //********************** Main ****************************************** int main(){ - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try{ using namespace std; using boost::shared_ptr; - map<point, double> h_init = utils::read_pd_map("data/h_init.map"); + map<point, double> h_init = kwantxi::read_pd_map("data/h_init.map"); shared_ptr<domain> Omega(new domain("data/circ_intr.matrix", "data/circ_bdry.matrix", @@ -158,9 +157,8 @@ double dt = 0.0005; //init the interps. - using namespace rbf; conical::set_n(5); thin_plate_spline::set_n(6); - c_infty_rbf::set_epsilon(0.01); + c_infty_kwantxi::set_epsilon(0.01); cout << "Initialising... please wait." << endl; @@ -205,7 +203,7 @@ return 0; } catch(error exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); return 1; } @@ -275,7 +273,7 @@ iter_neumann::iter_neumann(size_t u_or_v_in) { if(u_or_v_in < 1 or u_or_v_in > 2){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Argument to iter_neumann constructor must be 1 or 2"; exc.line = __LINE__; exc.file = __FILE__; @@ -340,11 +338,9 @@ } template<typename RBF> -linalg::vector at_bdry(const interpolator<RBF>& u, +kwantxi::vector at_bdry(const interpolator<RBF>& u, const boost::shared_ptr<domain> Omega) { - using namespace linalg; - vector out(Omega -> get_boundary().size()); std::set<point>::const_iterator I = Omega -> get_boundary().begin(); @@ -363,7 +359,7 @@ Gu_or_v<RBF_TYPE> gu(2, Omega), gv(1, Omega); double err = 1; do{ - linalg::vector u_old, u_new, v_old, v_new; + kwantxi::vector u_old, u_new, v_old, v_new; u_old = at_bdry(u,Omega); gu.set_other(v); u.set_g(gu);
--- a/src/main-sw-rk4.cpp +++ b/src/main-sw-rk4.cpp @@ -16,10 +16,9 @@ #include "include/interpolator.hpp" #include "include/func.hpp" -using namespace linalg; -using namespace bvp; +using namespace kwantxi; -#define RBF_TYPE rbf::conical +#define RBF_TYPE kwantxi::conical //Will solve the system // @@ -62,7 +61,7 @@ using Fgen<RBF>::h; using Fgen<RBF>::dt; public: - bvp::interp_values at() const; + kwantxi::interp_values at() const; }; template<typename RBF> @@ -72,7 +71,7 @@ using Fgen<RBF>::h; using Fgen<RBF>::dt; public: - bvp::interp_values at() const; + kwantxi::interp_values at() const; }; template<typename RBF> @@ -82,7 +81,7 @@ using Fgen<RBF>::h; using Fgen<RBF>::dt; public: - bvp::interp_values at() const; + kwantxi::interp_values at() const; }; class zero_func : public realfunc{ @@ -104,13 +103,13 @@ //********************** Main ****************************************** int main() { - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try{ using namespace std; using boost::shared_ptr; - map<point, double> h_init = utils::read_pd_map("data/h_init.map"); + map<point, double> h_init = kwantxi::read_pd_map("data/h_init.map"); shared_ptr<domain> Omega(new domain("data/circ_intr.matrix", "data/circ_bdry.matrix", @@ -127,9 +126,8 @@ //init the interps. - using namespace rbf; conical::set_n(7); thin_plate_spline::set_n(6); - c_infty_rbf::set_epsilon(0.01); + c_infty_kwantxi::set_epsilon(0.01); cout << "Initialising... please wait." << endl; @@ -235,7 +233,7 @@ return 0; } catch(error exc){ - utils::show_exception(exc); + kwantxi::show_exception(exc); return 1; } @@ -334,11 +332,11 @@ if(false){ //debug double r, th, N, M; N = 30; M = 70; - linalg::matrix out(static_cast<size_t>(N),static_cast<size_t>(M)); + kwantxi::matrix out(static_cast<size_t>(N),static_cast<size_t>(M)); size_t i,j; for(r = 0, j=1; j <= N; r += 1/(N-1),j++){ for(th = 0,i=1; i <= M; th += 2*pi/(M-1),i++){ - linalg::vector p(2); + kwantxi::vector p(2); p(1) = r*cos(th); p(2) = r*sin(th); out(j,i) = u(p); @@ -353,8 +351,8 @@ template<typename RBF> void set_bdry_conds(interpolator<RBF> & u, interpolator<RBF> & v) { - bvp::bdry_values u_bdry(u.at()), v_bdry(v.at()); - bvp::normals N=u.get_normals(), M=v.get_normals(); + kwantxi::bdry_values u_bdry(u.at()), v_bdry(v.at()); + kwantxi::normals N=u.get_normals(), M=v.get_normals(); if(N != M){ failure exc; exc.reason="u and v have incompatible domains. This should never" @@ -363,8 +361,8 @@ } //Project the vector (u,v) onto the perp of (N(1),N(2)) = (-N(2),N(1)). - bvp::bdry_values u_bdry_new = u_bdry*N(2)*N(2) - v_bdry*N(1)*N(2); - bvp::bdry_values v_bdry_new = v_bdry*N(1)*N(1) - u_bdry*N(1)*N(2); + kwantxi::bdry_values u_bdry_new = u_bdry*N(2)*N(2) - v_bdry*N(1)*N(2); + kwantxi::bdry_values v_bdry_new = v_bdry*N(1)*N(1) - u_bdry*N(1)*N(2); u.set_bdry_values(u_bdry_new); v.set_bdry_values(v_bdry_new);
--- a/src/main.cpp +++ b/src/main.cpp @@ -16,10 +16,10 @@ #include "include/interpolator.hpp" #include "include/func.hpp" -using namespace linalg; -using namespace bvp; +using namespace kwantxi; -#define RBF_TYPE rbf::conical +//Define the RBF type here. +typedef kwantxi::conical RBF_TYPE; const double pi = 3.141592653589793238462643383279502; @@ -45,14 +45,14 @@ int main() { - gsl_set_error_handler(&error_handling::errorHandler); + gsl_set_error_handler(&kwantxi::errorHandler); try { using namespace std; using boost::shared_ptr; - map<point, double> u_init = utils::read_pd_map("data/wave_init.map"); + map<point, double> u_init = kwantxi::read_pd_map("data/wave_init.map"); shared_ptr<domain> Omega(new domain("data/circ_intr.matrix", "data/circ_bdry.matrix", @@ -67,7 +67,7 @@ shared_ptr<linear_BVP2> the_bvp(new linear_BVP2(Omega, W, D, u_init, g)); - rbf::conical::set_n(5); + kwantxi::conical::set_n(5); interpolator<RBF_TYPE> u(the_bvp); u.precompute_ev(); interpolator<RBF_TYPE> u0 = u, u1 = u; @@ -86,7 +86,7 @@ } catch(error exc) { - utils::show_exception(exc); + kwantxi::show_exception(exc); return 1; }
--- a/src/rbf.cpp +++ b/src/rbf.cpp @@ -10,9 +10,7 @@ #include <typeinfo> //Radial basis function stuff -namespace rbf{ - using namespace linalg; - using namespace error_handling; +namespace kwantxi{ size_t radial_basis_function::dimension = 0; double c_infty_rbf::eps = 1; @@ -50,7 +48,7 @@ void radial_basis_function::bad_dimension(string file, int line, size_t dim) const{ - error_handling::badDimension exc; + kwantxi::badDimension exc; if(dimension == 0) exc.reason = "Vector of wrong dimensionality passed to " @@ -82,7 +80,7 @@ if(x.size() != dimension) bad_dimension(__FILE__, __LINE__, x.size()); else if(k < 1 or k > dimension){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Cannot differentiate wrt given index: out of bounds."; exc.line = __LINE__; exc.file = __FILE__; @@ -102,7 +100,7 @@ if(x.size() != dimension) bad_dimension(__FILE__, __LINE__, x.size()); else if(k1 < 1 or k1 > dimension or k2 < 1 or k2 > dimension){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Cannot differentiate wrt given indices: out of bounds."; exc.line = __LINE__; exc.file = __FILE__; @@ -147,7 +145,7 @@ // ***************** Two important subclasses ******************** -namespace rbf{ +namespace kwantxi{ piecewise_smooth_rbf::piecewise_smooth_rbf(){ //Nothing to create! @@ -202,7 +200,7 @@ // ***************** Specific RBFs ******************************* //Piecewise polynomial -namespace rbf{ +namespace kwantxi{ double piecewise_polynomial::operator()(double r) const{ if(n == 0){ badArgument exc; @@ -280,7 +278,7 @@ } //Thin-plate spline -namespace rbf{ +namespace kwantxi{ double thin_plate_spline::operator()(double r) const { if(n == 0){ badArgument exc; @@ -367,7 +365,7 @@ } //Multiquadric -namespace rbf{ +namespace kwantxi{ double multiquadric::operator()(double r) const { return sqrt(1 + gsl_pow_2(eps*r)); } @@ -384,7 +382,7 @@ } //Inverse multiquadric -namespace rbf{ +namespace kwantxi{ double inverse_multiquadric::operator()(double r) const { return 1/sqrt(1 + gsl_pow_2(eps*r)); } @@ -401,7 +399,7 @@ } //Inverse quadratic -namespace rbf{ +namespace kwantxi{ double inverse_quadratic::operator()(double r) const { return 1/(1 + gsl_pow_2(eps*r)); } @@ -420,7 +418,7 @@ } //Gaussian -namespace rbf{ +namespace kwantxi{ double gaussian::operator()(double r) const { return exp(-gsl_pow_2(eps*r)); }
--- a/src/utils.cpp +++ b/src/utils.cpp @@ -7,7 +7,7 @@ #include "include/linalg.hpp" #include "include/error.hpp" -namespace utils{ +namespace kwantxi{ std::string trim(const std::string& s){ if(s.length() == 0) return s; @@ -33,13 +33,13 @@ return std::includes(s2.begin(), s2.end(), s1.begin(), s1.end()); } - using linalg::vector; - using linalg::matrix; + using kwantxi::vector; + using kwantxi::matrix; matrix read_matrix(std::string filename){ std::ifstream ifs(filename.c_str()); if(!ifs){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Cannot open file "; exc.reason += filename; exc.line = __LINE__; @@ -54,7 +54,7 @@ vector read_vector(std::string filename){ std::ifstream ifs(filename.c_str()); if(!ifs){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Cannot open file "; exc.reason += filename; exc.line = __LINE__; @@ -66,10 +66,10 @@ return v; } - std::map<linalg::point, double> read_pd_map(std::string filename){ + std::map<kwantxi::point, double> read_pd_map(std::string filename){ std::ifstream ifs(filename.c_str()); if(!ifs){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Cannot open file "; exc.reason += filename; exc.line = __LINE__; @@ -80,7 +80,7 @@ ifs >> M; if(M.cols() < 2){ - error_handling::badArgument exc; + kwantxi::badArgument exc; exc.reason = "Input matrix to read_pd_map is too narrow. \n" "Need at least two columns in the input matrix"; @@ -89,15 +89,15 @@ throw exc; } - std::map <linalg::point, double> result; + std::map <kwantxi::point, double> result; size_t m = M.cols(); - linalg::slice s(1,m-1); + kwantxi::slice s(1,m-1); for(size_t i = 1; i <= M.rows(); i++) result[M(i,s)] = M(i,m); return result; } - void show_exception(error_handling::error exc){ + void show_exception(kwantxi::error exc){ using namespace std; cerr << exc.file << ": ""Caught an exception!" << endl; @@ -110,19 +110,19 @@ #include <boost/shared_ptr.hpp> #include "include/ddm.hpp" //Instantiations -namespace utils{ +namespace kwantxi{ using boost::shared_ptr; - template bool contains(const std::set<linalg::point>&, linalg::point E); - template bool contains(const std::map<linalg::point,linalg::vector>& m, - linalg::point thing); - template bool includes(const std::set<linalg::point>& s1, - const std::set<linalg::point>& s2); - template bool contains(const std::map<linalg::point, - shared_ptr<const bvp::overlapping_domain> >&, - linalg::point ); + template bool contains(const std::set<kwantxi::point>&, kwantxi::point E); + template bool contains(const std::map<kwantxi::point, kwantxi::vector>& m, + kwantxi::point thing); + template bool includes(const std::set<kwantxi::point>& s1, + const std::set<kwantxi::point>& s2); + template bool contains(const std::map<kwantxi::point, + shared_ptr<const kwantxi::overlapping_domain> >&, + kwantxi::point ); template bool contains(const std::set<shared_ptr - <const bvp::overlapping_domain> >&, - shared_ptr<const bvp::overlapping_domain> E); + <const kwantxi::overlapping_domain> >&, + shared_ptr<const kwantxi::overlapping_domain> E); }