26 #ifndef O2SCL_CONTOUR_H
27 #define O2SCL_CONTOUR_H
31 #include <gsl/gsl_math.h>
33 #include <boost/numeric/ublas/vector.hpp>
34 #include <boost/numeric/ublas/matrix.hpp>
36 #include <o2scl/interp.h>
37 #include <o2scl/uniform_grid.h>
39 #ifndef DOXYGEN_NO_O2NS
59 std::vector<double>
x;
61 std::vector<double>
y;
76 if (
this==&c)
return *
this;
128 if (
this==&ec)
return *
this;
262 template<
class vec_t,
class mat_t>
263 void set_data(
size_t sizex,
size_t sizey,
const vec_t &x_fun,
264 const vec_t &y_fun,
const mat_t &udata) {
266 if (sizex<2 || sizey<2) {
267 O2SCL_ERR(
"Not enough data (must be at least 2x2) in set_data().",
276 for(
int i=0;i<nx;i++) xfun[i]=x_fun[i];
277 for(
int i=0;i<ny;i++) yfun[i]=y_fun[i];
278 for(
int i=0;i<nx;i++) {
279 for(
int j=0;j<ny;j++) {
280 data(i,j)=udata(i,j);
298 template<
class mat_t>
301 const mat_t &udata) {
306 if (sizex<2 || sizey<2) {
307 O2SCL_ERR(
"Not enough data (must be at least 2x2) in set_data().",
316 for(
int i=0;i<nx;i++) xfun[i]=ugx[i];
317 for(
int i=0;i<ny;i++) yfun[i]=ugy[i];
318 for(
int i=0;i<nx;i++) {
319 for(
int j=0;j<ny;j++) {
320 data(i,j)=udata(i,j);
334 template<
class vec_t>
void set_levels(
size_t nlevels, vec_t &ulevels) {
336 levels.resize(nlevels);
337 for(
size_t i=0;i<nlevels;i++) {
338 levels[i]=ulevels[i];
403 std::vector<edge_crossings> &bm_edges) {
431 static const int empty=0;
432 static const int edge=1;
433 static const int contourp=2;
434 static const int endpoint=3;
437 #ifndef DOXYGEN_INTERNAL
443 static const int dright=0;
444 static const int dbottom=1;
449 static const int efound=1;
450 static const int enot_found=0;
468 std::vector<edge_crossings>
red;
470 std::vector<edge_crossings>
bed;
474 int &dir_next,
int nsw,
480 int &dir_next,
int nsw,
497 void process_line(
int j,
int k,
int dir, std::vector<double> &x,
498 std::vector<double> &y,
514 #ifndef DOXYGEN_NO_O2NS
edge_crossings()
Create an empty object.
Edges for the contour class.
void check_data()
Check to ensure the x- and y-arrays are monotonic.
contour_line()
Create an empty line.
void get_edges(std::vector< edge_crossings > &rt_edges, std::vector< edge_crossings > &bm_edges)
Return the edges for each contour level.
std::vector< edge_crossings > bed
Bottom edge list.
edge_crossings(const edge_crossings &ec)
Copy constructor.
int find_next_point_right(int j, int k, int &jnext, int &knext, int &dir_next, int nsw, edge_crossings &right, edge_crossings &bottom)
Find next point starting from a point on a right edge.
invalid argument supplied by user
contour_line(const contour_line &c)
Copy constructor.
int find_next_point_bottom(int j, int k, int &jnext, int &knext, int &dir_next, int nsw, edge_crossings &right, edge_crossings &bottom)
Find next point starting from a point on a bottom edge.
void set_data(size_t sizex, size_t sizey, const vec_t &x_fun, const vec_t &y_fun, const mat_t &udata)
Set the data.
void process_line(int j, int k, int dir, std::vector< double > &x, std::vector< double > &y, bool first, edge_crossings &right, edge_crossings &bottom)
Create a contour line from a starting edge.
Cubic spline for natural boundary conditions.
void get_data(size_t &sizex, size_t &sizey, ubvector *&x_fun, ubvector *&y_fun, ubmatrix *&udata)
Get the data.
Calculate contour lines from a two-dimensional data set.
ubmatrix_int status
Edge status.
ubmatrix values
Edge values.
void right_edges(double level, interp< ubvector > &si, edge_crossings &right)
Interpolate all right edge crossings.
std::vector< edge_crossings > red
Right edge list.
std::vector< double > x
The line x coordinates.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
void bottom_edges(double level, interp< ubvector > &si, edge_crossings &bottom)
Interpolate all bottom edge crossings.
void set_data(const uniform_grid< double > &ugx, const uniform_grid< double > &ugy, const mat_t &udata)
Set the data.
double lev_adjust
(default )
int verbose
Verbosity parameter (default 0)
double level
The contour level.
void set_levels(size_t nlevels, vec_t &ulevels)
Set the contour levels.
void calc_contours(std::vector< contour_line > &clines)
Calculate the contours.
edge_crossings & operator=(const edge_crossings &ec)
Copy constructor with operator=()
void find_intersections(size_t ilev, double &level, edge_crossings &right, edge_crossings &bottom)
Find all of the intersections of the edges with the contour level.
contour_line & operator=(const contour_line &c)
Copy constructor with operator=()
void print_edges(edge_crossings &right, edge_crossings &bottom)
Print out the edges to cout.
std::vector< double > y
The line y coordinates.
Interpolation class for general vectors.
void regrid_data(size_t xfact, size_t yfact, size_t interp_type=o2scl::itp_cspline)
Regrid the data.