{"text": "/* $Id: step-1.cc 27657 2012-11-21 13:19:08Z bangerth $\n *\n * Copyright (C) 1999-2003, 2005-2007, 2009, 2011-2012 by the deal.II authors\n *\n * This file is subject to QPL and may not be  distributed\n * without copyright and license information. Please refer\n * to the file deal.II/doc/license.html for the  text  and\n * further information on this license.\n */\n\n// @sect3{Include files}\n\n// The most fundamental class in the library is the Triangulation class, which\n// is declared here:\n#include <deal.II/grid/tria.h>\n// We need the following two includes for loops over cells and/or faces:\n#include <deal.II/grid/tria_accessor.h>\n#include <deal.II/grid/tria_iterator.h>\n// Here are some functions to generate standard grids:\n#include <deal.II/grid/grid_generator.h>\n// We would like to use boundaries which are not straight lines, so we import\n// some classes which predefine some boundary descriptions:\n#include <deal.II/grid/tria_boundary_lib.h>\n// Output of grids in various graphics formats:\n#include <deal.II/grid/grid_out.h>\n\n// This is needed for C++ output:\n#include <fstream>\n// And this for the declarations of the `sqrt' and `fabs' functions:\n#include <cmath>\n\n// The final step in importing deal.II is this: All deal.II functions and\n// classes are in a namespace <code>dealii</code>, to make sure they don't\n// clash with symbols from other libraries you may want to use in conjunction\n// with deal.II. One could use these functions and classes by prefixing every\n// use of these names by <code>dealii::</code>, but that would quickly become\n// cumbersome and annoying. Rather, we simply import the entire deal.II\n// namespace for general use:\nusing namespace dealii;\n\n// @sect3{Creating the first mesh}\n\n// In the following, first function, we simply use the unit square as domain\n// and produce a globally refined grid from it.\nvoid first_grid ()\n{\n  // The first thing to do is to define an object for a triangulation of a\n  // two-dimensional domain:\n  Triangulation<2> triangulation;\n  // Here and in many following cases, the string \"<2>\" after a class name\n  // indicates that this is an object that shall work in two space\n  // dimensions. Likewise, there are versions of the triangulation class that\n  // are working in one (\"<1>\") and three (\"<3>\") space dimensions. The way\n  // this works is through some template magic that we will investigate in\n  // some more detail in later example programs; there, we will also see how\n  // to write programs in an essentially dimension independent way.\n\n  // Next, we want to fill the triangulation with a single cell for a square\n  // domain. The triangulation is the refined four times, to yield 4^4=256\n  // cells in total:\n  GridGenerator::hyper_cube (triangulation);\n  triangulation.refine_global (4);\n\n  // Now we want to write a graphical representation of the mesh to an output\n  // file. The GridOut class of deal.II can do that in a number of different\n  // output formats; here, we choose encapsulated postscript (eps) format:\n  std::ofstream out (\"grid-1.eps\");\n  GridOut grid_out;\n  grid_out.write_eps (triangulation, out);\n}\n\n\n\n// @sect3{Creating the second mesh}\n\n// The grid in the following, second function is slightly more complicated in\n// that we use a ring domain and refine the result once globally.\nvoid second_grid ()\n{\n  // We start again by defining an object for a triangulation of a\n  // two-dimensional domain:\n  Triangulation<2> triangulation;\n\n  // We then fill it with a ring domain. The center of the ring shall be the\n  // point (1,0), and inner and outer radius shall be 0.5 and 1. The number of\n  // circumferential cells could be adjusted automatically by this function,\n  // but we choose to set it explicitely to 10 as the last argument:\n  const Point<2> center (1,0);\n  const double inner_radius = 0.5,\n               outer_radius = 1.0;\n  GridGenerator::hyper_shell (triangulation,\n                              center, inner_radius, outer_radius,\n                              10);\n  // By default, the triangulation assumes that all boundaries are straight\n  // and given by the cells of the coarse grid (which we just created). It\n  // uses this information when cells at the boundary are refined and new\n  // points need to be introduced on the boundary; if the boundary is assumed\n  // to be straight, then new points will simply be in the middle of the\n  // surrounding ones.\n  //\n  // Here, however, we would like to have a curved boundary. Fortunately, some\n  // good soul implemented an object which describes the boundary of a ring\n  // domain; it only needs the center of the ring and automatically figures\n  // out the inner and outer radius when needed. Note that we associate this\n  // boundary object with that part of the boundary that has the \"boundary\n  // indicator\" zero. By default (at least in 2d and 3d, the 1d case is\n  // slightly different), all boundary parts have this number, but you can\n  // change this number for some parts of the boundary. In that case, the\n  // curved boundary thus associated with number zero will not apply on those\n  // parts with a non-zero boundary indicator, but other boundary description\n  // objects can be associated with those non-zero indicators. If no boundary\n  // description is associated with a particular boundary indicator, a\n  // straight boundary is implied.\n  const HyperShellBoundary<2> boundary_description(center);\n  triangulation.set_boundary (0, boundary_description);\n\n  // In order to demonstrate how to write a loop over all cells, we will\n  // refine the grid in five steps towards the inner circle of the domain:\n  for (unsigned int step=0; step<5; ++step)\n    {\n      // Next, we need an iterator which points to a cell and which we will\n      // move over all active cells one by one (active cells are those that\n      // are not further refined, and the only ones that can be marked for\n      // further refinement, obviously). By convention, we almost always use\n      // the names <code>cell</code> and <code>endc</code> for the iterator\n      // pointing to the present cell and to the <code>one-past-the-end</code>\n      // iterator:\n      Triangulation<2>::active_cell_iterator\n      cell = triangulation.begin_active(),\n      endc = triangulation.end();\n\n      // The loop over all cells is then rather trivial, and looks like any\n      // loop involving pointers instead of iterators:\n      for (; cell!=endc; ++cell)\n        // Next, we want to loop over all vertices of the cells. Since we are\n        // in 2d, we know that each cell has exactly four vertices. However,\n        // instead of penning down a 4 in the loop bound, we make a first\n        // attempt at writing it in a dimension-independent way by which we\n        // find out about the number of vertices of a cell. Using the\n        // GeometryInfo class, we will later have an easier time getting the\n        // program to also run in 3d: we only have to change all occurrences\n        // of <code>&lt;2&gt;</code> to <code>&lt;3&gt;</code>, and do not\n        // have to audit our code for the hidden appearance of magic numbers\n        // like a 4 that needs to be replaced by an 8:\n        for (unsigned int v=0;\n             v < GeometryInfo<2>::vertices_per_cell;\n             ++v)\n          {\n            // If this cell is at the inner boundary, then at least one of its\n            // vertices must sit on the inner ring and therefore have a radial\n            // distance from the center of exactly 0.5, up to floating point\n            // accuracy. Compute this distance, and if we have found a vertex\n            // with this property flag this cell for later refinement. We can\n            // then also break the loop over all vertices and move on to the\n            // next cell.\n            const double distance_from_center\n              = center.distance (cell->vertex(v));\n\n            if (std::fabs(distance_from_center - inner_radius) < 1e-10)\n              {\n                cell->set_refine_flag ();\n                break;\n              }\n          }\n\n      // Now that we have marked all the cells that we want refined, we let\n      // the triangulation actually do this refinement. The function that does\n      // so owes its long name to the fact that one can also mark cells for\n      // coarsening, and the function does coarsening and refinement all at\n      // once:\n      triangulation.execute_coarsening_and_refinement ();\n    }\n\n\n  // Finally, after these five iterations of refinement, we want to again\n  // write the resulting mesh to a file, again in eps format. This works just\n  // as above:\n  std::ofstream out (\"grid-2.eps\");\n  GridOut grid_out;\n  grid_out.write_eps (triangulation, out);\n\n\n  // At this point, all objects created in this function will be destroyed in\n  // reverse order. Unfortunately, we defined the boundary object after the\n  // triangulation, which still has a pointer to it and the library will\n  // produce an error if the boundary object is destroyed before the\n  // triangulation. We therefore have to release it, which can be done as\n  // follows. Note that this sets the boundary object used for part \"0\" of the\n  // boundary back to a default object, over which the triangulation has full\n  // control.\n  triangulation.set_boundary (0);\n  // An alternative to doing so, and one that is frequently more convenient,\n  // would have been to declare the boundary object before the triangulation\n  // object. In that case, the triangulation would have let lose of the\n  // boundary object upon its destruction, and everything would have been\n  // fine.\n}\n\n\n\n// @sect3{The main function}\n\n// Finally, the main function. There isn't much to do here, only to call the\n// two subfunctions, which produce the two grids.\nint main ()\n{\n  first_grid ();\n  second_grid ();\n}\n", "meta": {"hexsha": "2da4f71da2cae933bae8fc87027396b4198ba2ce", "size": 9799, "ext": "cc", "lang": "C++", "max_stars_repo_path": "MHD/examples/step-1/step-1.cc", "max_stars_repo_name": "wathen/PhD", "max_stars_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2020-10-25T13:30:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T21:27:30.000Z", "max_issues_repo_path": "MHD/examples/step-1/step-1.cc", "max_issues_repo_name": "wathen/PhD", "max_issues_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MHD/examples/step-1/step-1.cc", "max_forks_repo_name": "wathen/PhD", "max_forks_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3.0, "max_forks_repo_forks_event_min_datetime": "2019-10-28T16:12:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-13T13:59:44.000Z", "avg_line_length": 46.6619047619, "max_line_length": 78, "alphanum_fraction": 0.7018063068, "num_tokens": 2312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4186968948485237, "lm_q2_score": 0.23370636225126956, "lm_q1q2_score": 0.09785212818095079}}
{"text": "#include <boost/numeric/ublas/assignment.hpp>\n#include <boost/numeric/ublas/banded.hpp>\n#include <boost/numeric/ublas/blas.hpp>\n#include <boost/numeric/ublas/doxydoc.hpp>\n#include <boost/numeric/ublas/exception.hpp>\n#include <boost/numeric/ublas/expression_types.hpp>\n#include <boost/numeric/ublas/functional.hpp>\n#include <boost/numeric/ublas/fwd.hpp>\n#include <boost/numeric/ublas/hermitian.hpp>\n#include <boost/numeric/ublas/io.hpp>\n#include <boost/numeric/ublas/lu.hpp>\n#include <boost/numeric/ublas/matrix_expression.hpp>\n#include <boost/numeric/ublas/matrix.hpp>\n#include <boost/numeric/ublas/matrix_proxy.hpp>\n#include <boost/numeric/ublas/matrix_sparse.hpp>\n#include <boost/numeric/ublas/matrix_vector.hpp>\n#include <boost/numeric/ublas/operation_blocked.hpp>\n#include <boost/numeric/ublas/operation.hpp>\n#include <boost/numeric/ublas/operations.hpp>\n#include <boost/numeric/ublas/operation_sparse.hpp>\n#include <boost/numeric/ublas/storage.hpp>\n#include <boost/numeric/ublas/storage_sparse.hpp>\n#include <boost/numeric/ublas/symmetric.hpp>\n#include <boost/numeric/ublas/tags.hpp>\n#include <boost/numeric/ublas/tensor.hpp>\n#include <boost/numeric/ublas/traits.hpp>\n#include <boost/numeric/ublas/triangular.hpp>\n#include <boost/numeric/ublas/vector_expression.hpp>\n#include <boost/numeric/ublas/vector.hpp>\n#include <boost/numeric/ublas/vector_of_vector.hpp>\n#include <boost/numeric/ublas/vector_proxy.hpp>\n#include <boost/numeric/ublas/vector_sparse.hpp>\n\nint\nmain ()\n{\n  return 0;\n}\n", "meta": {"hexsha": "85c26346bc39bb1af8b2011cb27f034d0b6992c5", "size": 1492, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libboost-numeric-ublas/tests/basics/driver.cpp", "max_stars_repo_name": "build2-packaging/boost", "max_stars_repo_head_hexsha": "203d505dd3ba04ea50785bc8b247a295db5fc718", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 4.0, "max_stars_repo_stars_event_min_datetime": "2021-02-23T11:24:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-11T20:10:46.000Z", "max_issues_repo_path": "libboost-numeric-ublas/tests/basics/driver.cpp", "max_issues_repo_name": "build2-packaging/boost", "max_issues_repo_head_hexsha": "203d505dd3ba04ea50785bc8b247a295db5fc718", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libboost-numeric-ublas/tests/basics/driver.cpp", "max_forks_repo_name": "build2-packaging/boost", "max_forks_repo_head_hexsha": "203d505dd3ba04ea50785bc8b247a295db5fc718", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2564102564, "max_line_length": 52, "alphanum_fraction": 0.7969168901, "num_tokens": 402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.18242551936144574, "lm_q1q2_score": 0.09690614582737564}}
{"text": "#ifndef VIENNACL_TRAITS_SIZE_HPP_\r\n#define VIENNACL_TRAITS_SIZE_HPP_\r\n\r\n/* =========================================================================\r\n   Copyright (c) 2010-2013, Institute for Microelectronics,\r\n                            Institute for Analysis and Scientific Computing,\r\n                            TU Wien.\r\n   Portions of this software are copyright by UChicago Argonne, LLC.\r\n\r\n                            -----------------\r\n                  ViennaCL - The Vienna Computing Library\r\n                            -----------------\r\n\r\n   Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at\r\n               \r\n   (A list of authors and contributors can be found in the PDF manual)\r\n\r\n   License:         MIT (X11), see file LICENSE in the base directory\r\n============================================================================= */\r\n\r\n/** @file viennacl/traits/size.hpp\r\n    @brief Generic size and resize functionality for different vector and matrix types\r\n*/\r\n\r\n#include <string>\r\n#include <fstream>\r\n#include <sstream>\r\n#include \"viennacl/forwards.h\"\r\n#include \"viennacl/meta/result_of.hpp\"\r\n#include \"viennacl/meta/predicate.hpp\"\r\n\r\n#ifdef VIENNACL_WITH_UBLAS  \r\n#include <boost/numeric/ublas/matrix_sparse.hpp>\r\n#include <boost/numeric/ublas/matrix.hpp>\r\n#endif\r\n\r\n#ifdef VIENNACL_WITH_EIGEN  \r\n#include <Eigen/Core>\r\n#include <Eigen/Sparse>\r\n#endif\r\n\r\n#ifdef VIENNACL_WITH_MTL4\r\n#include <boost/numeric/mtl/mtl.hpp>\r\n#endif\r\n\r\n#include <vector>\r\n#include <map>\r\n\r\nnamespace viennacl\r\n{\r\n\r\n  namespace traits\r\n  {\r\n    //\r\n    // Resize: Change the size of vectors and matrices\r\n    //\r\n    /** @brief Generic resize routine for resizing a matrix (ViennaCL, uBLAS, etc.) to a new size/dimension */\r\n    template <typename MatrixType>\r\n    void resize(MatrixType & matrix, std::size_t rows, std::size_t cols)\r\n    {\r\n      matrix.resize(rows, cols); \r\n    }\r\n    \r\n    /** @brief Generic resize routine for resizing a vector (ViennaCL, uBLAS, etc.) to a new size */\r\n    template <typename VectorType>\r\n    void resize(VectorType & vec, std::size_t new_size)\r\n    {\r\n      vec.resize(new_size); \r\n    }\r\n    \r\n    /** \\cond */\r\n    #ifdef VIENNACL_WITH_UBLAS  \r\n    //ublas needs separate treatment:\r\n    template <typename ScalarType>\r\n    void resize(boost::numeric::ublas::compressed_matrix<ScalarType> & matrix,\r\n                std::size_t rows,\r\n                std::size_t cols)\r\n    {\r\n      matrix.resize(rows, cols, false); //Note: omitting third parameter leads to compile time error (not implemented in ublas <= 1.42) \r\n    }\r\n    #endif  \r\n    \r\n    \r\n    #ifdef VIENNACL_WITH_MTL4\r\n    template <typename ScalarType>\r\n    void resize(mtl::compressed2D<ScalarType> & matrix,\r\n                std::size_t rows,\r\n                std::size_t cols)\r\n    {\r\n      matrix.change_dim(rows, cols);\r\n    }\r\n    \r\n    template <typename ScalarType>\r\n    void resize(mtl::dense_vector<ScalarType> & vec,\r\n                std::size_t new_size)\r\n    {\r\n      vec.change_dim(new_size);\r\n    }\r\n    #endif      \r\n\r\n    #ifdef VIENNACL_WITH_EIGEN\r\n    inline void resize(Eigen::MatrixXf & m,\r\n                       std::size_t new_rows,\r\n                       std::size_t new_cols)\r\n    {\r\n      m.resize(new_rows, new_cols);\r\n    }\r\n    \r\n    inline void resize(Eigen::MatrixXd & m,\r\n                       std::size_t new_rows,\r\n                       std::size_t new_cols)\r\n    {\r\n      m.resize(new_rows, new_cols);\r\n    }\r\n    \r\n    template <typename T, int options>\r\n    inline void resize(Eigen::SparseMatrix<T, options> & m,\r\n                       std::size_t new_rows,\r\n                       std::size_t new_cols)\r\n    {\r\n      m.resize(new_rows, new_cols);\r\n    }    \r\n    \r\n    inline void resize(Eigen::VectorXf & v,\r\n                       std::size_t new_size)\r\n    {\r\n      v.resize(new_size);\r\n    }\r\n    \r\n    inline void resize(Eigen::VectorXd & v,\r\n                       std::size_t new_size)\r\n    {\r\n      v.resize(new_size);\r\n    }\r\n    #endif\r\n    /** \\endcond */\r\n\r\n\r\n    //\r\n    // size: Returns the length of vectors\r\n    //\r\n    /** @brief Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.) */\r\n    template <typename VectorType>\r\n    vcl_size_t size(VectorType const & vec)\r\n    {\r\n      return vec.size(); \r\n    }\r\n\r\n    /** \\cond */\r\n    template <typename LHS, typename RHS, typename OP>\r\n    vcl_size_t size(vector_expression<LHS, RHS, OP> const & proxy)\r\n    {\r\n      return size(proxy.lhs());\r\n    }\r\n\r\n    template <typename SparseMatrixType, typename VectorType>\r\n    typename viennacl::enable_if< viennacl::is_any_sparse_matrix<SparseMatrixType>::value,\r\n                                  vcl_size_t >::type\r\n    size(vector_expression<const SparseMatrixType, const VectorType, op_prod> const & proxy)\r\n    {\r\n      return proxy.lhs().size1(); \r\n    }\r\n    \r\n    template <typename NumericT, typename F>\r\n    vcl_size_t size(vector_expression<const matrix_base<NumericT, F>, const vector_base<NumericT>, op_prod> const & proxy)  //matrix-vector product\r\n    {\r\n      return proxy.lhs().size1();\r\n    }\r\n\r\n    template <typename NumericT, typename F>\r\n    vcl_size_t size(vector_expression<const matrix_expression<const matrix_base<NumericT, F>, const matrix_base<NumericT, F>, op_trans>,\r\n                                      const vector_base<NumericT>,\r\n                                      op_prod> const & proxy)  //transposed matrix-vector product\r\n    {\r\n      return proxy.lhs().lhs().size2();\r\n    }\r\n    \r\n    \r\n    #ifdef VIENNACL_WITH_MTL4\r\n    template <typename ScalarType>\r\n    vcl_size_t size(mtl::dense_vector<ScalarType> const & vec) { return vec.used_memory(); }\r\n    #endif\r\n    \r\n    #ifdef VIENNACL_WITH_EIGEN\r\n    inline vcl_size_t size(Eigen::VectorXf const & v) { return v.rows(); }\r\n    inline vcl_size_t size(Eigen::VectorXd const & v) { return v.rows(); }\r\n    #endif\r\n    /** \\endcond */\r\n\r\n    \r\n    //\r\n    // size1: No. of rows for matrices\r\n    //\r\n    /** @brief Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.) */\r\n    template <typename MatrixType>\r\n    vcl_size_t\r\n    size1(MatrixType const & mat) { return mat.size1(); }\r\n\r\n    /** \\cond */\r\n    template <typename RowType>\r\n    vcl_size_t\r\n    size1(std::vector< RowType > const & mat) { return mat.size(); }\r\n    \r\n    #ifdef VIENNACL_WITH_EIGEN\r\n    inline vcl_size_t size1(Eigen::MatrixXf const & m) { return m.rows(); }\r\n    inline vcl_size_t size1(Eigen::MatrixXd const & m) { return m.rows(); }\r\n    template <typename T, int options>\r\n    inline vcl_size_t size1(Eigen::SparseMatrix<T, options> & m) { return m.rows(); }    \r\n    #endif\r\n    /** \\endcond */\r\n\r\n    //\r\n    // size2: No. of columns for matrices\r\n    //\r\n    /** @brief Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc.) */\r\n    template <typename MatrixType>\r\n    typename result_of::size_type<MatrixType>::type\r\n    size2(MatrixType const & mat) { return mat.size2(); }\r\n \r\n    /** \\cond */\r\n    #ifdef VIENNACL_WITH_EIGEN\r\n    inline vcl_size_t size2(Eigen::MatrixXf const & m) { return m.cols(); }\r\n    inline vcl_size_t size2(Eigen::MatrixXd const & m) { return m.cols(); }\r\n    template <typename T, int options>\r\n    inline vcl_size_t size2(Eigen::SparseMatrix<T, options> & m) { return m.cols(); }    \r\n    #endif\r\n    /** \\endcond */\r\n \r\n    //\r\n    // internal_size: Returns the internal (padded) length of vectors\r\n    //\r\n    /** @brief Helper routine for obtaining the buffer length of a ViennaCL vector  */\r\n    template <typename NumericT>\r\n    vcl_size_t internal_size(vector_base<NumericT> const & vec)\r\n    {\r\n      return vec.internal_size(); \r\n    }\r\n\r\n\r\n    //\r\n    // internal_size1: No. of internal (padded) rows for matrices\r\n    //\r\n    /** @brief Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix  */\r\n    template <typename NumericT, typename F>\r\n    vcl_size_t internal_size1(matrix_base<NumericT, F> const & mat) { return mat.internal_size1(); }\r\n    \r\n\r\n    //\r\n    // internal_size2: No. of internal (padded) columns for matrices\r\n    //\r\n    /** @brief Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix  */\r\n    template <typename NumericT, typename F>\r\n    vcl_size_t internal_size2(matrix_base<NumericT, F> const & mat) { return mat.internal_size2(); }\r\n \r\n \r\n  } //namespace traits\r\n} //namespace viennacl\r\n    \r\n\r\n#endif\r\n", "meta": {"hexsha": "28c187af27e95e91a127ea004feaaacfa8d3b50d", "size": 8479, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/opencl/viennacl/traits/size.hpp", "max_stars_repo_name": "Samsung/FFTF", "max_stars_repo_head_hexsha": "846ca9e571c916860fcb6ef50276f56dfe0ccc21", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 9.0, "max_stars_repo_stars_event_min_datetime": "2015-11-10T08:08:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-18T03:14:14.000Z", "max_issues_repo_path": "src/opencl/viennacl/traits/size.hpp", "max_issues_repo_name": "vmarkovtsev/FFTF", "max_issues_repo_head_hexsha": "846ca9e571c916860fcb6ef50276f56dfe0ccc21", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/opencl/viennacl/traits/size.hpp", "max_forks_repo_name": "vmarkovtsev/FFTF", "max_forks_repo_head_hexsha": "846ca9e571c916860fcb6ef50276f56dfe0ccc21", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 8.0, "max_forks_repo_forks_event_min_datetime": "2015-08-13T19:19:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-26T04:00:17.000Z", "avg_line_length": 32.4865900383, "max_line_length": 148, "alphanum_fraction": 0.5905177497, "num_tokens": 1998, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47657965106367595, "lm_q2_score": 0.19930800266002902, "lm_q1q2_score": 0.09498613836191483}}
{"text": "//------------------------------------------------------------------------------\n/// \\file PointersArraysReferences_tests.cpp\n/// \\ref Bjarne Stroustrup. The C++ Programming Language, 4th Edition.\n/// Addison-Wesley Professional. May 19, 2013. ISBN-13: 978-0321563842\n//------------------------------------------------------------------------------\n#include <boost/test/unit_test.hpp>\n#include <cstring>\n#include <iostream>\n#include <string>\n\nBOOST_AUTO_TEST_SUITE(Cpp)\nBOOST_AUTO_TEST_SUITE(PointersArraysReferences)\nBOOST_AUTO_TEST_SUITE(PointersArraysReferences_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(PointerDeclarations)\n{\n  // cf. Stroustrup (2013). 6.3.1, pp. 153. Definition of an array of C-style\n  // strings.\n\n  // Postfix declarator, e.g. [], bind tighter than prefix ones, e.g. *\n  // array of pointers to char\n  const char* kings[] = {\"Antigonus\", \"Seleucus\", \"Ptolemy\"};\n\n  BOOST_TEST(kings[0] == \"Antigonus\");\n  BOOST_TEST(kings[1] == \"Seleucus\");\n  BOOST_TEST(kings[2] == \"Ptolemy\");\n\n  // Pointer to an array of `char`\n  char(*one_king)[5];\n\n  char a_king[] = {'L', 'o', 'u', 'i', 's'};\n\n  one_king = &a_king;\n\n  BOOST_TEST((*one_king)[0] == 'L');\n  BOOST_TEST((*one_king)[1] == 'o');\n  BOOST_TEST((*one_king)[2] == 'u');\n  BOOST_TEST((*one_king)[3] == 'i');\n  BOOST_TEST((*one_king)[4] == 's');\n\n  int* pi; // pointer to int\n  char** ppc; // pointer to pointer to char\n  int* ap[15]; // array of 15 pointers to ints\n  int (*fp)(char*); // pointer to function taking a char* argument; returns an\n  // int\n  int* f(char*); // function taking a char* argument; returns a pointer to int\n\n  BOOST_TEST(true);\n}\n\nvoid void_pointer_points(int* pi)\n{\n  void* pv = pi; // OK: implicit conversion of int* to void*\n  // *pv; // error: can't deference void*\n  // ++pv; // error: can't increment void* (the size of the object pointed to is\n  // unknown)\n\n  int* pi2 = static_cast<int*>(pv); // explicit conversion back to int*\n\n  // double* pd1 = pv; // error\n  // double* pd2 = pi; // error\n  // double* pd3 = static_cast<double*>(pv); // unsafe (Sec. 11.5.2)\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(VoidPointerExplicitlyConvertsToAnotherPointer)\n{\n  {\n    const int pi_value {42};\n    const int* pi = &pi_value;\n    BOOST_TEST(true);\n  }\n  int pi_value {42};\n  int* pi = &pi_value;\n\n  void_pointer_points(pi);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(NullptrAssignedToAnyPointerType)\n{\n  int* pi = nullptr;\n  int* pi2 {nullptr};\n  double* pd = nullptr;\n  //int i = nullptr; // error: i is not a pointer.\n  BOOST_TEST(true);\n}\n\n// cf. 7.3 Arrays, pp. 174, Stroustrup (2013)\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DeclareAndAssignToArrays)\n{\n  float v[3]; // array of 3 floats\n  char* a[32]; // array of 32 pointers to char\n\n  int aa[10];\n  aa[6] = 9; // assign to aa's 7th element\n\n  BOOST_TEST(true);\n}\n\n// cf. 7.3.1 Array Initializers, pp. 175, Stroustrup (2013)\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ArraysCanBeInitialized)\n{\n  int v1[] = {1, 2, 3, 4};\n  char v2[] = {'a', 'b', 'c', 0};\n\n  // char v3[2]= {'a', 'b', 0}; // error: too many initializers\n  char v4[3] = {'a', 'b', 0};\n\n  // If initializer supplies too few elements for an array, 0 used for the rest\n  int v5[8] = {1, 2, 3, 4};\n  BOOST_TEST(v5[0] == 1);\n  BOOST_TEST(v5[1] == 2);\n  BOOST_TEST(v5[2] == 3);\n  BOOST_TEST(v5[3] == 4);\n  BOOST_TEST(v5[4] == 0);\n  BOOST_TEST(v5[5] == 0);\n  BOOST_TEST(v5[6] == 0);\n  BOOST_TEST(v5[7] == 0);\n}\n\nconst char* error_message_returning_str_literal(int i)\n{\n  i + 1;\n  return \"range error\";\n}\n// cf. 7.3.2 String Literals, pp. 176, Stroustrup (2013)\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(StringLiteralsInitializeArrays)\n{\n  \"this is a string\";\n\n  // A string literal contains 1 more character than it appears to have; it's\n  // terminated by null character, '\\0', with value 0\n\n  BOOST_TEST(sizeof(\"Bohr\") == 5);\n\n  // char* p =\"Plato\"; // error, C++ forbids converting string constant to char*\n\n  // If we want a string we are guranteed to be able to modify, we must place\n  // characters in a non-const array\n\n  char p[] = \"Zeno\"; // p is an array of 5 char\n  BOOST_TEST(sizeof(p) == 5);\n  p[0] = 'R'; // OK\n  BOOST_TEST(std::string {p} == \"Reno\");\n\n  BOOST_TEST(std::string{error_message_returning_str_literal(5)} ==\n    \"range error\");\n\n  // Long strings can be broken by whitespace to make the program text neater.\n  char alpha[] = \"abcdefghijklmnopqrstuvwxyz\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n  BOOST_TEST(std::string{alpha} ==\n    \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\");\n}\n\n// cf. 7.3.2.1 Raw Character Strings, pp. 177, Stroustrup (2013)\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(RawCharacterStrings)\n{\n  std::string s {R\"(\\w\\\\w)\"};\n\n  BOOST_TEST(s == R\"(\\w\\\\w)\");\n\n  // \"( and )\" is the only default delimiter pair.\n\n  s = R\"***(\"quoted string containing the usual terminator (\"))\")***\";\n  BOOST_TEST(s == \"\\\"quoted string containing the usual terminator (\\\"))\\\"\");\n\n  std::string counts {R\"(1\n22\n333)\"};\n\n  std::string x {\"1\\n22\\n333\"};\n\n  BOOST_TEST(counts == x);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ImplicitConversionFromArrayToPointer)\n{\n  int v[] = {1, 2, 3, 4};\n  int* p1 = v; // pointer to initial element (implicit conversion)\n  int* p2 = &v[0]; // pointer to initial element\n  int* p3 = v + 4; // pointer to one beyond-last element\n\n  BOOST_TEST(*p1 == 1);\n  BOOST_TEST(*p2 == 1);\n\n  {\n    char v[] = \"Annemarie\";\n    char* p = v; // implicit conversion of char[] to char*\n    BOOST_TEST(strlen(p) == 9);\n    BOOST_TEST(strlen(v) == 9); // implicit conversion of char[] to char*\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(NavigateArraysByPointerArithmetic)\n{\n  char v[] {\"123456789\"};\n  BOOST_TEST_REQUIRE(sizeof(v) == 10);\n  for (int i {0}; v[i] != 0; ++i)\n  {\n    BOOST_TEST(v[i] == static_cast<char>(i + '1'));\n  }\n\n  char p[] {\"abcdefghijklmnopqrstuvwxyz\"};\n  BOOST_TEST_REQUIRE(sizeof(p) == 27);\n  int i {0};\n  for (char* ptr = p; *ptr != 0; ++ptr)\n  {\n    BOOST_TEST(*ptr == static_cast<char>('a' + i));\n    ++i;\n  }\n\n  // The prefix * operator dereferences a pointer so that *p is the character\n  // pointed to by p, and ++ increments the pointer so that it refers to the\n  // next element of the array.\n\n  const char a[] {\"ABCDEFGH\"} ; \n\n  constexpr int j {2};\n\n  BOOST_TEST(a[j] == *(&a[0] + j)); \n  BOOST_TEST(*(&a[0] + j) == *(a+j));\n  BOOST_TEST(*(a+j) == *(j + a));\n  BOOST_TEST(*(j + a) == j[a]);\n  BOOST_TEST(3[\"Texas\"] == \"Texas\"[3]);\n  BOOST_TEST(\"Texas\"[3] == 'a');\n}\n\n// Remember, reinterpret_cast is resolved at compile-time; it's nothing more\n// than \"look to a pointer that's pointing to type A with eyes of who is\n// looking for type B\".\n// https://stackoverflow.com/questions/27309604/do-constant-and-reinterpret-cast-happen-at-compile-time/27309763\ntemplate <typename T>\nint byte_diff(T* p, T* q)\n{\n  return reinterpret_cast<char*>(q) - reinterpret_cast<char*>(p);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ApplySubtractionForPointerArithmetic)\n{\n  std::cout << \"\\n ApplySubtractionForPointerArithmetic \\n\";\n\n  int vi[10];\n  short vs[10];\n\n  // Pointer values printed using default hexadecimal notation.\n  // e.g. \n  // 0x7ffe36969950 0x7ffe36969954\n  // 0x7ffe36969930 0x7ffe36969932\n  std::cout << vi << ' ' << &vi[1] << '\\n';\n  std::cout << vs << ' ' << &vs[1] << '\\n';\n\n  // Result is number of array elements in the sequence [p:q) (an integer).\n  BOOST_TEST((&vi[1] - vi) == 1);\n  BOOST_TEST((&vs[1] - vs) == 1);\n  BOOST_TEST((&vi[1] - &vi[0]) == 1);\n  BOOST_TEST((&vs[1] - &vs[0]) == 1);\n\n  BOOST_TEST(byte_diff(&vi[0], &vi[1]) == 4);\n  BOOST_TEST(byte_diff(&vs[0], &vs[1]) == 2);\n\n  int v1[10];\n  int v2[10];\n\n  int i1 = &v1[5] - &v1[3];\n  BOOST_TEST(i1 == 2);\n  // int i2 = &v1[5] - &v2[3]; // result undefined\n\n  int* p1 = v2 + 2; // p1 - &v2[2]\n  // int*p2 = v2 - 2 // *p2 undefined\n}\n\nvoid fp(char v[], int size)\n{\n  for (int i {0}; i != size; ++i)\n  {\n    BOOST_TEST(v[i] == i + 'a');\n  }\n\n  // for (int x : v)\n  //  use(x); // error: range-for does not work for pointers\n\n  constexpr int N {7};\n  char v2[N];\n  for (int i {0}; i != N; ++i)\n  {\n    v2[i];\n  }\n  for (int x : v2)\n  {\n    x; // range-for works for arrays of known size.\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ArrayTraverseRequiresExplicitlyStatedSize)\n{\n  char v[] {\"abcdefgh\"};\n  int size {8};\n  fp(v, size);\n  BOOST_TEST(true);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DeclareMultidimensionalArrays)\n{\n  int ma[3][5]; // 3 arrays with 5 ints each\n\n  BOOST_TEST(true);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(InitializeMultidimensionalArrays)\n{\n  int ma[3][5]; // 3 arrays with 5 ints each\n\n  for (int i {0}; i != 3; ++i)\n  {\n    for (int j {0}; j != 5; ++j)\n    {\n      ma[i][j] = 10 * i + j;\n    }\n  }\n\n  for (int k {0}; k < 15; ++k)\n  {\n    BOOST_TEST(\n      ma[ k / 5][ k - 5 * (k / 5)] == 10 * (k / 5) + (k - 5 * (k / 5)));\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(MultidimensionalArraysAreRowMajor)\n{\n  int ma[3][5]; // 3 arrays with 5 ints each\n\n  // Initialize array.\n  for (int i {0}; i != 3; ++i)\n  {\n    for (int j {0}; j != 5; ++j)\n    {\n      ma[i][j] = 10 * i + j;\n    }\n  }\n\n  for (int i {0}; i < 2; ++i)\n  {\n    // size of int (4 bytes) * 5 elements in a \"row\"\n    BOOST_TEST(byte_diff(&ma[i], &ma[i + 1]) == 20);\n  }\n\n  for (int i {0}; i < 3; ++i)\n  {\n    for (int j {0}; j < 4; ++j)\n    {\n      BOOST_TEST(byte_diff(&ma[i][j], &ma[i][j + 1]) == 4);\n    }\n  }\n\n  // Need 2nd. dimension to locate actual first element.\n  int* ptr {&ma[0][0]};\n\n  for (int k {0}; k < 15; ++k)\n  {\n    BOOST_TEST(*(ptr + k) == 10 * (k / 5) + (k - 5 * (k / 5)));\n  }\n}\n\n// cf. 7.4.3 Passing Arrays, pp. 184, Stroustrup (2013)\n\nvoid comp(double arg[10]) // arg is a double*\n{\n  for (int i {0}; i != 10; ++i)\n  {\n    arg[i] += 99;\n  }\n}\n\n// This function is equivalent to comp.\nvoid comp2(double* arg) // arg is a double*\n{\n  for (int i {0}; i != 10; ++i)\n  {\n    arg[i] += 99;\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(PassArraysAsPointerToFirstElement)\n{\n  double a1[10];\n  double a2[5];\n  double a3[100];\n\n  comp(a1);\n  // The following line comp(a2) compiles\n  // comp(a2); // disaster!\n  comp(a3); // uses only the first 10 elements\n\n  for (int i {0}; i < 10; ++i)\n  {\n    a1[i] == 99;\n    a3[i] == 99;\n  }\n\n  comp2(a1);\n  comp2(a3);\n\n  for (int i {0}; i < 10; ++i)\n  {\n    a1[i] == 189;\n    a3[i] == 189;\n  }\n}\n\n// cf. 7.4.3 Passing Arrays, pp. 184-185, Stroustrup (2013)\n// If dimensions are known at compile time, passing arrays as pointer.\n\nint expected_v[3][5] {\n  {0, 1, 2, 3, 4},\n  {10, 11, 12, 13, 14},\n  {20, 21, 22, 23, 24}\n};\n\nvoid print_m35(int m[3][5])\n{\n  for (int i {0}; i != 3; ++i)\n  {\n    for (int j {0}; j != 5; ++j)\n    {\n      BOOST_TEST(m[i][j] == expected_v[i][j]);\n    }\n  }\n}\n\nvoid print_mi5(int m[][5], int dim1)\n{\n  for (int i {0}; i != dim1; ++i)\n  {\n    for (int j {0}; j != 5; ++j)\n    {\n      BOOST_TEST(m[i][j] == expected_v[i][j]);\n    }\n  }\n}\n\n// argument declaration m[][] is illegal because 2nd. dimension of a\n// multidimensional array must be known in order to find location of an element.\n//void print_mij(int m[][], int dim1, int dim2)\n// To call this function, we pass a matrix as an ordinary pointer.\nvoid print_mij(int* m, int dim1, int dim2)\n{\n  for (int i {0}; i != dim1; ++i)\n  {\n    for (int j {0}; j != dim2; ++j)\n    {\n      BOOST_TEST(m[i * dim2 + j] == expected_v[i][j]);\n    }\n  }\n}\n\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(PassArraysAsPointerIfDimensionsKnown)\n{\n  int v[3][5] {\n    {0, 1, 2, 3, 4},\n    {10, 11, 12, 13, 14},\n    {20, 21, 22, 23, 24}\n  };\n\n  print_m35(v);\n  print_mi5(v, 3);\n\n  print_mij(&v[0][0], 3, 5);\n}\n\n// cf. Sec. 7.5, Pointers and const, Stroustrup (2013), pp. 186\n\nvoid f1(char* p)\n{\n  char s[] = \"Gorm\";\n  const char* pc = s; // pointer to constant\n\n  const char* pc2 {s}; \n  // pc[3] = 'g'; // error: pc points to constant\n\n  pc = p; // OK\n  \n  char* const cp = s; // constant pointer\n  cp[3] = 'a'; // OK\n  // cp = p; // error: cp is constant\n\n  const char* const cpc = s; // const pointer to const\n  //cpc[3] = 'a'; // error: cpc points to constant\n  //cpc = p; // error: cpc is constant  \n\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DeclareWithConst)\n{\n  const int model = 90; // mode is a const\n  const int v[] = {1, 2, 3, 4}; // v[i] is a const\n  //const int x; // error; no initializer\n\n  char* p;\n\n  f1(p);\n\n  // error: uninitalized const\n  //char* const cp; // const pointer to char\n  char* const cp {p};\n\n  char const* pc; // pointer to const char\n  const char* pc2; // pointer to const char\n\n  BOOST_TEST(true);\n}\n\n// This 1st version is used for strings where elements mustn't be modified and\n// returns a pointer to const that does not allow modification.\nconst char* strchr(const char* p, char c); // find first occurrence of c in p\n\n// 2nd version used for mutable strings\nchar* strchr(char* p, char c);\n\nBOOST_AUTO_TEST_SUITE(References)\n\nvoid f(std::vector<double>& v)\n{\n  double d1 = v[1]; // copy the value of the double referred to by\n  // v.operator[](1) into d1\n  v[2] = 7;\n\n  v.push_back(d1); // give push_back() a reference to d1 to work with\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ReferenceUsedToSpecifyArguments)\n{\n  std::vector<double> v {0.0, 1.2, 1.3};\n  BOOST_TEST_REQUIRE(v.size() == 3);\n  f(v);\n  BOOST_TEST(v[0] == 0.0);\n  BOOST_TEST(v[1] == 1.2);\n  BOOST_TEST(v[2] == 7);\n  BOOST_TEST(v[3] == 1.2);  \n  BOOST_TEST(v.size() == 4);\n}\n\nBOOST_AUTO_TEST_SUITE_END() // References\n\nBOOST_AUTO_TEST_SUITE_END() // PointersArraysReferences_tests\nBOOST_AUTO_TEST_SUITE_END() // PointersArraysReferences\nBOOST_AUTO_TEST_SUITE_END() // Cpp", "meta": {"hexsha": "a9bf2ff9ff3a75dddcdb63b971cffcf97b6c206b", "size": 16122, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Cpp/PointersArraysReferences_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Cpp/PointersArraysReferences_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Cpp/PointersArraysReferences_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6061643836, "max_line_length": 112, "alphanum_fraction": 0.490075673, "num_tokens": 4476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.41489886026626094, "lm_q2_score": 0.22815650740914753, "lm_q1q2_score": 0.09466187488638603}}
{"text": "/**\n * @file stabrk3.cc\n * @brief NPDE homework StabRK3 code\n * @author Unknown, Oliver Rietmann\n * @date 04.04.2021\n * @copyright Developed at ETH Zurich\n */\n\n#include \"stabrk3.h\"\n\n#include <Eigen/Core>\n#include <vector>\n\n#include \"rkintegrator.h\"\n\nnamespace StabRK3 {\n\n/* SAM_LISTING_BEGIN_0 */\nEigen::Vector2d predPrey(Eigen::Vector2d y0, double T, unsigned int N) {\n  double h = T / N;\n  Eigen::Vector2d y = y0;\n\n  //====================\n  // Your code goes here\n  //====================\n\n  return y;\n}\n/* SAM_LISTING_END_0 */\n\n/* SAM_LISTING_BEGIN_1 */\nstd::vector<Eigen::Vector2d> simulatePredPrey(\n    const std::vector<unsigned int> &N_list) {\n  int M = N_list.size();\n  std::vector<Eigen::Vector2d> yT_list(M);\n\n  //====================\n  // Your code goes here\n  //====================\n\n  return yT_list;\n}\n/* SAM_LISTING_END_1 */\n\n}  // namespace StabRK3\n", "meta": {"hexsha": "e921539595458998b477a07b028b3b409997b5bc", "size": 866, "ext": "cc", "lang": "C++", "max_stars_repo_path": "homeworks/StabRK3/templates/stabrk3.cc", "max_stars_repo_name": "kryo4096/NPDECODES", "max_stars_repo_head_hexsha": "3498c0e4abec6ba21447849ba2ddc9286c068ea1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "homeworks/StabRK3/templates/stabrk3.cc", "max_issues_repo_name": "kryo4096/NPDECODES", "max_issues_repo_head_hexsha": "3498c0e4abec6ba21447849ba2ddc9286c068ea1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homeworks/StabRK3/templates/stabrk3.cc", "max_forks_repo_name": "kryo4096/NPDECODES", "max_forks_repo_head_hexsha": "3498c0e4abec6ba21447849ba2ddc9286c068ea1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.8260869565, "max_line_length": 72, "alphanum_fraction": 0.6027713626, "num_tokens": 261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091946, "lm_q2_score": 0.1895210890408168, "lm_q1q2_score": 0.09402024282775791}}
{"text": "\n\n/* --------------------------------------------------------------------- \n * \n * Copyright (C) 2009 - 2021 by the deal.II authors \n * \n * This file is part of the deal.II library. \n * \n * The deal.II library is free software; you can use it, redistribute \n * it, and/or modify it under the terms of the GNU Lesser General \n * Public License as published by the Free Software Foundation; either \n * version 2.1 of the License, or (at your option) any later version. \n * The full text of the license can be found in the file LICENSE.md at \n * the top level directory of deal.II. \n * \n * --------------------------------------------------------------------- \n * \n * Author: Wolfgang Bangerth, Texas A&M University, 2009, 2010 \n *         Timo Heister, University of Goettingen, 2009, 2010 \n */ \n\n\n// @sect3{Include files}  \n\n// \u6211\u4eec\u5728\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\u9700\u8981\u7684\u5927\u90e8\u5206\u5305\u542b\u6587\u4ef6\u5df2\u7ecf\u5728\u4ee5\u524d\u7684\u7a0b\u5e8f\u4e2d\u8ba8\u8bba\u8fc7\u4e86\u3002\u7279\u522b\u662f\uff0c\u4ee5\u4e0b\u6240\u6709\u7684\u6587\u4ef6\u90fd\u5e94\u8be5\u5df2\u7ecf\u662f\u719f\u6089\u7684\u670b\u53cb\u4e86\u3002\n\n#include <deal.II/base/quadrature_lib.h> \n#include <deal.II/base/function.h> \n#include <deal.II/base/timer.h> \n\n#include <deal.II/lac/generic_linear_algebra.h> \n\n// \u8fd9\u4e2a\u7a0b\u5e8f\u53ef\u4ee5\u4f7f\u7528PETSc\u6216Trilinos\u6765\u6ee1\u8db3\u5176\u5e76\u884c\u4ee3\u6570\u7684\u9700\u8981\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679cdeal.II\u5df2\u7ecf\u88ab\u914d\u7f6e\u4e3aPETSc\uff0c\u5b83\u5c06\u4f7f\u7528PETSc\u3002\u5426\u5219\uff0c\u4e0b\u9762\u51e0\u884c\u5c06\u68c0\u67e5deal.II\u662f\u5426\u5df2\u88ab\u914d\u7f6e\u4e3aTrilinos\uff0c\u5e76\u91c7\u7528\u5b83\u3002\n\n// \u4f46\u662f\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5373\u4f7fdeal.II\u4e5f\u88ab\u914d\u7f6e\u4e3aPETSc\uff0c\u4f60\u8fd8\u662f\u60f3\u4f7f\u7528Trilinos\uff0c\u4f8b\u5982\uff0c\u6bd4\u8f83\u8fd9\u4e24\u4e2a\u5e93\u7684\u6027\u80fd\u3002\u8981\u505a\u5230\u8fd9\u4e00\u70b9\uff0c\u8bf7\u5728\u6e90\u4ee3\u7801\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u7684\\#define\u3002\n// @code\n//  #define FORCE_USE_OF_TRILINOS\n//  @endcode\n\n// \u4f7f\u7528\u8fd9\u4e2a\u903b\u8f91\uff0c\u4e0b\u9762\u51e0\u884c\u5c06\u5bfc\u5165PETSc\u6216Trilinos\u5305\u88c5\u5668\u5230\u547d\u540d\u7a7a\u95f4`LA`\uff08\u4ee3\u8868 \"\u7ebf\u6027\u4ee3\u6570\"\uff09\u3002\u5728\u524d\u4e00\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8fd8\u8981\u5b9a\u4e49\u5b8f `USE_PETSC_LA`\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u68c0\u6d4b\u5230\u6211\u4eec\u662f\u5426\u5728\u4f7f\u7528PETSc\uff08\u53c2\u89c1solve()\u4e2d\u9700\u8981\u7528\u5230\u7684\u4f8b\u5b50\uff09\u3002\n\nnamespace LA \n{ \n#if defined(DEAL_II_WITH_PETSC) && !defined(DEAL_II_PETSC_WITH_COMPLEX) && \\ \n  !(defined(DEAL_II_WITH_TRILINOS) && defined(FORCE_USE_OF_TRILINOS)) \n  using namespace dealii::LinearAlgebraPETSc; \n#  define USE_PETSC_LA \n#elif defined(DEAL_II_WITH_TRILINOS) \n  using namespace dealii::LinearAlgebraTrilinos; \n#else \n#  error DEAL_II_WITH_PETSC or DEAL_II_WITH_TRILINOS required \n#endif \n} // namespace LA \n\n#include <deal.II/lac/vector.h> \n#include <deal.II/lac/full_matrix.h> \n#include <deal.II/lac/solver_cg.h> \n#include <deal.II/lac/affine_constraints.h> \n#include <deal.II/lac/dynamic_sparsity_pattern.h> \n\n#include <deal.II/grid/grid_generator.h> \n#include <deal.II/dofs/dof_handler.h> \n#include <deal.II/dofs/dof_tools.h> \n#include <deal.II/fe/fe_values.h> \n#include <deal.II/fe/fe_q.h> \n#include <deal.II/numerics/vector_tools.h> \n#include <deal.II/numerics/data_out.h> \n#include <deal.II/numerics/error_estimator.h> \n\n// \u7136\u800c\uff0c\u4e0b\u9762\u8fd9\u4e9b\u5c06\u662f\u65b0\u7684\uff0c\u6216\u5728\u65b0\u7684\u89d2\u8272\u4e2d\u4f7f\u7528\u3002\u8ba9\u6211\u4eec\u6765\u770b\u770b\u5b83\u4eec\u3002\u5176\u4e2d\u7b2c\u4e00\u4e2a\u5c06\u63d0\u4f9b Utilities::System \u547d\u540d\u7a7a\u95f4\u7684\u5de5\u5177\uff0c\u6211\u4eec\u5c06\u7528\u5b83\u6765\u67e5\u8be2\u8bf8\u5982\u4e0e\u5f53\u524dMPI\u5b87\u5b99\u76f8\u5173\u7684\u5904\u7406\u5668\u6570\u91cf\uff0c\u6216\u8005\u8fd9\u4e2a\u4f5c\u4e1a\u8fd0\u884c\u7684\u5904\u7406\u5668\u5728\u8fd9\u4e2a\u5b87\u5b99\u4e2d\u7684\u7f16\u53f7\u3002\n\n#include <deal.II/base/utilities.h> \n\n// \u4e0b\u4e00\u4e2a\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7c7b\uff0cConditionOStream\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u7f16\u5199\u4ee3\u7801\uff0c\u5c06\u4e1c\u897f\u8f93\u51fa\u5230\u4e00\u4e2a\u6d41\u4e2d\uff08\u4f8b\u5982\u5728\u6bcf\u4e2a\u5904\u7406\u5668\u4e0a\u7684 <code>std::cout</code> \uff0c\u4f46\u5728\u9664\u4e86\u4e00\u4e2a\u5904\u7406\u5668\u4ee5\u5916\u7684\u6240\u6709\u5904\u7406\u5668\u4e0a\u90fd\u5c06\u6587\u672c\u6254\u6389\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u5730\u5728\u6bcf\u4e2a\u53ef\u80fd\u4ea7\u751f\u8f93\u51fa\u7684\u5730\u65b9\u524d\u9762\u653e\u4e00\u4e2a <code>if</code> \u8bed\u53e5\u6765\u5b9e\u73b0\u540c\u6837\u7684\u76ee\u7684\uff0c\u4f46\u8fd9\u5e76\u4e0d\u80fd\u4f7f\u4ee3\u7801\u66f4\u6f02\u4eae\u3002\u6b64\u5916\uff0c\u8fd9\u4e2a\u5904\u7406\u5668\u662f\u5426\u5e94\u8be5\u5411\u5c4f\u5e55\u8f93\u51fa\u7684\u6761\u4ef6\u6bcf\u6b21\u90fd\u662f\u4e00\u6837\u7684--\u56e0\u6b64\uff0c\u628a\u5b83\u653e\u5728\u4ea7\u751f\u8f93\u51fa\u7684\u8bed\u53e5\u4e2d\u5e94\u8be5\u662f\u5f88\u7b80\u5355\u7684\u3002\n\n#include <deal.II/base/conditional_ostream.h> \n\n// \u5728\u8fd9\u4e9b\u9884\u6f14\u4e4b\u540e\uff0c\u8fd9\u91cc\u53d8\u5f97\u66f4\u52a0\u6709\u8da3\u3002\u6b63\u5982\u5728 @ref distributed \u6a21\u5757\u4e2d\u63d0\u5230\u7684\uff0c\u5728\u5927\u91cf\u5904\u7406\u5668\u4e0a\u89e3\u51b3\u95ee\u9898\u7684\u4e00\u4e2a\u57fa\u672c\u4e8b\u5b9e\u662f\uff0c\u4efb\u4f55\u5904\u7406\u5668\u90fd\u4e0d\u53ef\u80fd\u5b58\u50a8\u6240\u6709\u7684\u4e1c\u897f\uff08\u4f8b\u5982\uff0c\u5173\u4e8e\u7f51\u683c\u4e2d\u6240\u6709\u5355\u5143\u7684\u4fe1\u606f\uff0c\u6240\u6709\u7684\u81ea\u7531\u5ea6\uff0c\u6216\u8005\u89e3\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u503c\uff09\u3002\u76f8\u53cd\uff0c\u6bcf\u4e2a\u5904\u7406\u5668\u90fd\u4f1a<i>own</i>\u5176\u4e2d\u7684\u51e0\u4e2a\uff0c\u5982\u679c\u6709\u5fc5\u8981\uff0c\u8fd8\u53ef\u80fd<i>know</i>\u53e6\u5916\u51e0\u4e2a\uff0c\u4f8b\u5982\uff0c\u4f4d\u4e8e\u4e0e\u8be5\u5904\u7406\u5668\u81ea\u5df1\u62e5\u6709\u7684\u5355\u5143\u76f8\u90bb\u7684\u90a3\u4e9b\u5355\u5143\u3002\u6211\u4eec\u901a\u5e38\u79f0\u540e\u8005\u4e3a<i>ghost cells</i>\u3001<i>ghost nodes</i>\u6216<i>ghost elements of a vector</i>\u3002\u8fd9\u91cc\u8ba8\u8bba\u7684\u91cd\u70b9\u662f\uff0c\u6211\u4eec\u9700\u8981\u6709\u4e00\u79cd\u65b9\u6cd5\u6765\u8868\u660e\u4e00\u4e2a\u7279\u5b9a\u7684\u5904\u7406\u5668\u62e5\u6709\u6216\u9700\u8981\u77e5\u9053\u54ea\u4e9b\u5143\u7d20\u3002\u8fd9\u5c31\u662fIndexSet\u7c7b\u7684\u9886\u57df\uff1a\u5982\u679c\u603b\u5171\u6709 $N$ \u4e2a\u5355\u5143\u3001\u81ea\u7531\u5ea6\u6216\u5411\u91cf\u5143\u7d20\uff0c\u4e0e\uff08\u975e\u8d1f\uff09\u79ef\u5206\u6307\u6570 $[0,N)$ \u76f8\u5173\uff0c\u90a3\u4e48\u5f53\u524d\u5904\u7406\u5668\u62e5\u6709\u7684\u5143\u7d20\u96c6\u4ee5\u53ca\u5b83\u9700\u8981\u4e86\u89e3\u7684\uff08\u53ef\u80fd\u66f4\u5927\uff09\u6307\u6570\u96c6\u90fd\u662f\u96c6\u5408 $[0,N)$ \u7684\u5b50\u96c6\u3002IndexSet\u662f\u4e00\u4e2a\u7c7b\uff0c\u5b83\u4ee5\u4e00\u79cd\u6709\u6548\u7684\u683c\u5f0f\u5b58\u50a8\u8fd9\u4e2a\u96c6\u5408\u7684\u5b50\u96c6\u3002\n\n#include <deal.II/base/index_set.h> \n\n// \u4e0b\u4e00\u4e2a\u5934\u6587\u4ef6\u662f\u4e00\u4e2a\u5355\u4e00\u7684\u51fd\u6570\u6240\u5fc5\u9700\u7684\uff0c  SparsityTools::distribute_sparsity_pattern.  \u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5c06\u5728\u4e0b\u9762\u89e3\u91ca\u3002\n\n#include <deal.II/lac/sparsity_tools.h> \n\n// \u6700\u540e\u4e24\u4e2a\u65b0\u7684\u5934\u6587\u4ef6\u63d0\u4f9b\u4e86\u7c7b parallel::distributed::Triangulation \uff0c\u5b83\u63d0\u4f9b\u4e86\u5206\u5e03\u5728\u53ef\u80fd\u975e\u5e38\u591a\u7684\u5904\u7406\u5668\u4e0a\u7684\u7f51\u683c\uff0c\u800c\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u63d0\u4f9b\u4e86\u547d\u540d\u7a7a\u95f4 parallel::distributed::GridRefinement \uff0c\u5b83\u63d0\u4f9b\u4e86\u53ef\u4ee5\u81ea\u9002\u5e94\u7ec6\u5316\u8fd9\u79cd\u5206\u5e03\u5f0f\u7f51\u683c\u7684\u51fd\u6570\u3002\n\n#include <deal.II/distributed/tria.h> \n#include <deal.II/distributed/grid_refinement.h> \n\n#include <fstream> \n#include <iostream> \n\nnamespace Step40 \n{ \n  using namespace dealii; \n// @sect3{The <code>LaplaceProblem</code> class template}  \n\n// \u63a5\u4e0b\u6765\u6211\u4eec\u6765\u58f0\u660e\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u4e3b\u7c7b\u3002\u5b83\u7684\u7ed3\u6784\u51e0\u4e4e\u4e0e step-6 \u7684\u6559\u7a0b\u7a0b\u5e8f\u4e00\u6a21\u4e00\u6837\u3002\u552f\u4e00\u663e\u8457\u7684\u533a\u522b\u662f\u3002\n\n// --  <code>mpi_communicator</code> \u53d8\u91cf\uff0c\u5b83\u63cf\u8ff0\u4e86\u6211\u4eec\u5e0c\u671b\u8fd9\u6bb5\u4ee3\u7801\u8fd0\u884c\u5728\u54ea\u4e00\u7ec4\u5904\u7406\u5668\u4e0a\u3002\u5728\u5b9e\u8df5\u4e2d\uff0c\u8fd9\u5c06\u662fMPI_COMM_WORLD\uff0c\u5373\u6279\u5904\u7406\u8c03\u5ea6\u7cfb\u7edf\u5206\u914d\u7ed9\u8fd9\u4e2a\u7279\u5b9a\u4f5c\u4e1a\u7684\u6240\u6709\u5904\u7406\u5668\u3002\n\n// - ConditionOStream\u7c7b\u578b\u7684 <code>pcout</code> \u53d8\u91cf\u7684\u5b58\u5728\u3002\n\n// - \u660e\u663e\u4f7f\u7528 parallel::distributed::Triangulation \u800c\u4e0d\u662fTriangulation\u3002\n\n// - \u4e24\u4e2aIndexSet\u5bf9\u8c61\u7684\u5b58\u5728\uff0c\u8868\u793a\u6211\u4eec\u5728\u5f53\u524d\u5904\u7406\u5668\u4e0a\u62e5\u6709\u54ea\u4e9b\u81ea\u7531\u5ea6\u96c6\uff08\u4ee5\u53ca\u89e3\u548c\u53f3\u624b\u5411\u91cf\u7684\u76f8\u5173\u5143\u7d20\uff09\uff0c\u4ee5\u53ca\u6211\u4eec\u9700\u8981\u54ea\u4e9b\uff08\u4f5c\u4e3a\u5e7d\u7075\u5143\u7d20\uff09\u6765\u4f7f\u672c\u7a0b\u5e8f\u4e2d\u7684\u7b97\u6cd5\u5de5\u4f5c\u3002\n\n// - \u73b0\u5728\u6240\u6709\u7684\u77e9\u9635\u548c\u5411\u91cf\u90fd\u662f\u5206\u5e03\u5f0f\u7684\u3002\u6211\u4eec\u4f7f\u7528PETSc\u6216Trilinos\u5305\u88c5\u7c7b\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528Hypre\uff08\u4f7f\u7528PETSc\uff09\u6216ML\uff08\u4f7f\u7528Trilinos\uff09\u63d0\u4f9b\u7684\u590d\u6742\u7684\u9884\u5904\u7406\u5668\u4e4b\u4e00\u3002\u8bf7\u6ce8\u610f\uff0c\u4f5c\u4e3a\u8fd9\u4e2a\u7c7b\u7684\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u5b58\u50a8\u7684\u89e3\u5411\u91cf\u4e0d\u4ec5\u5305\u542b\u5f53\u524d\u5904\u7406\u5668\u62e5\u6709\u7684\u81ea\u7531\u5ea6\uff0c\u8fd8\u5305\u62ec\uff08\u4f5c\u4e3a\u9b3c\u9b42\u5143\u7d20\uff09\u6240\u6709\u5bf9\u5e94\u4e8e \"\u672c\u5730\u76f8\u5173 \"\u81ea\u7531\u5ea6\u7684\u5411\u91cf\u5143\u7d20\uff08\u5373\u6240\u6709\u751f\u6d3b\u5728\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u6216\u56f4\u7ed5\u5b83\u7684\u9b3c\u9b42\u5355\u5143\u5c42\u7684\u81ea\u7531\u5ea6\uff09\u3002\n\n  template <int dim> \n  class LaplaceProblem \n  { \n  public: \n    LaplaceProblem(); \n\n    void run(); \n\n  private: \n    void setup_system(); \n    void assemble_system(); \n    void solve(); \n    void refine_grid(); \n    void output_results(const unsigned int cycle) const; \n\n    MPI_Comm mpi_communicator; \n\n    parallel::distributed::Triangulation<dim> triangulation; \n\n    FE_Q<dim>       fe; \n    DoFHandler<dim> dof_handler; \n\n    IndexSet locally_owned_dofs; \n    IndexSet locally_relevant_dofs; \n\n    AffineConstraints<double> constraints; \n\n    LA::MPI::SparseMatrix system_matrix; \n    LA::MPI::Vector       locally_relevant_solution; \n    LA::MPI::Vector       system_rhs; \n\n    ConditionalOStream pcout; \n    TimerOutput        computing_timer; \n  }; \n// @sect3{The <code>LaplaceProblem</code> class implementation}  \n// @sect4{Constructor}  \n\n// \u6784\u9020\u51fd\u6570\u548c\u6790\u6784\u51fd\u6570\u662f\u76f8\u5f53\u5fae\u4e0d\u8db3\u9053\u7684\u3002\u9664\u4e86\u6211\u4eec\u5728 step-6 \u4e2d\u6240\u505a\u7684\uff0c\u6211\u4eec\u5c06\u6211\u4eec\u60f3\u8981\u5de5\u4f5c\u7684\u5904\u7406\u5668\u96c6\u5408\u8bbe\u7f6e\u4e3a\u6240\u6709\u53ef\u7528\u7684\u673a\u5668\uff08MPI_COMM_WORLD\uff09\uff1b\u8981\u6c42\u4e09\u89d2\u5316\u4ee5\u786e\u4fdd\u7f51\u683c\u4fdd\u6301\u5e73\u6ed1\u5e76\u81ea\u7531\u7cbe\u70bc\u5c9b\u5c7f\uff0c\u4f8b\u5982\uff1b\u5e76\u521d\u59cb\u5316 <code>pcout</code> \u53d8\u91cf\uff0c\u53ea\u5141\u8bb8\u5904\u7406\u56680\u8f93\u51fa\u4efb\u4f55\u4e1c\u897f\u3002\u6700\u540e\u4e00\u5757\u662f\u521d\u59cb\u5316\u4e00\u4e2a\u5b9a\u65f6\u5668\uff0c\u6211\u4eec\u7528\u5b83\u6765\u51b3\u5b9a\u7a0b\u5e8f\u7684\u4e0d\u540c\u90e8\u5206\u9700\u8981\u591a\u5c11\u8ba1\u7b97\u65f6\u95f4\u3002\n\n  template <int dim> \n  LaplaceProblem<dim>::LaplaceProblem() \n    : mpi_communicator(MPI_COMM_WORLD) \n    , triangulation(mpi_communicator, \n                    typename Triangulation<dim>::MeshSmoothing( \n                      Triangulation<dim>::smoothing_on_refinement | \n                      Triangulation<dim>::smoothing_on_coarsening)) \n    , fe(2) \n    , dof_handler(triangulation) \n    , pcout(std::cout, \n            (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)) \n    , computing_timer(mpi_communicator, \n                      pcout, \n                      TimerOutput::summary, \n                      TimerOutput::wall_times) \n  {} \n\n//  @sect4{LaplaceProblem::setup_system}  \n\n// \u4e0b\u9762\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u8bf4\u662f\u6574\u4e2a\u7a0b\u5e8f\u4e2d\u6700\u6709\u8da3\u7684\u4e00\u4e2a\uff0c\u56e0\u4e3a\u5b83\u6d89\u53ca\u5230\u4e86%\u5e76\u884c  step-40  \u548c\u987a\u5e8f  step-6  \u7684\u6838\u5fc3\u533a\u522b\u3002\n\n// \u5728\u9876\u90e8\u6211\u4eec\u505a\u4e86\u6211\u4eec\u4e00\u76f4\u5728\u505a\u7684\u4e8b\u60c5\uff1a\u544a\u8bc9DoFHandler\u5bf9\u8c61\u6765\u5206\u914d\u81ea\u7531\u5ea6\u3002\u7531\u4e8e\u6211\u4eec\u5728\u8fd9\u91cc\u4f7f\u7528\u7684\u4e09\u89d2\u6d4b\u91cf\u662f\u5206\u5e03\u5f0f\u7684\uff0cDoFHandler\u5bf9\u8c61\u8db3\u591f\u806a\u660e\uff0c\u5b83\u8ba4\u8bc6\u5230\u5728\u6bcf\u4e2a\u5904\u7406\u5668\u4e0a\u53ea\u80fd\u5728\u5b83\u6240\u62e5\u6709\u7684\u5355\u5143\u4e0a\u5206\u914d\u81ea\u7531\u5ea6\uff1b\u63a5\u4e0b\u6765\u662f\u4e00\u4e2a\u4ea4\u6362\u6b65\u9aa4\uff0c\u5904\u7406\u5668\u4e92\u76f8\u544a\u8bc9\u5bf9\u65b9\u5173\u4e8eghost\u5355\u5143\u7684\u81ea\u7531\u5ea6\u3002\u7ed3\u679c\u662fDoFHandler\u77e5\u9053\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u548c\u5e7d\u7075\u5355\u5143\uff08\u5373\u4e0e\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u76f8\u90bb\u7684\u5355\u5143\uff09\u7684\u81ea\u7531\u5ea6\uff0c\u4f46\u5bf9\u66f4\u8fdc\u7684\u5355\u5143\u5219\u4e00\u65e0\u6240\u77e5\uff0c\u8fd9\u4e0e\u5206\u5e03\u5f0f\u8ba1\u7b97\u7684\u57fa\u672c\u7406\u5ff5\u4e00\u81f4\uff0c\u5373\u6ca1\u6709\u5904\u7406\u5668\u53ef\u4ee5\u77e5\u9053\u6240\u6709\u7684\u4e8b\u60c5\u3002\n\n  template <int dim> \n  void LaplaceProblem<dim>::setup_system() \n  { \n    TimerOutput::Scope t(computing_timer, \"setup\"); \n\n    dof_handler.distribute_dofs(fe); \n\n// \u63a5\u4e0b\u6765\u7684\u4e24\u884c\u63d0\u53d6\u4e86\u4e00\u4e9b\u6211\u4eec\u4ee5\u540e\u9700\u8981\u7684\u4fe1\u606f\uff0c\u5373\u4e24\u4e2a\u7d22\u5f15\u96c6\uff0c\u63d0\u4f9b\u4e86\u5173\u4e8e\u54ea\u4e9b\u81ea\u7531\u5ea6\u4e3a\u5f53\u524d\u5904\u7406\u5668\u6240\u62e5\u6709\u7684\u4fe1\u606f\uff08\u8fd9\u4e9b\u4fe1\u606f\u5c06\u88ab\u7528\u6765\u521d\u59cb\u5316\u89e3\u548c\u53f3\u624b\u5411\u91cf\u4ee5\u53ca\u7cfb\u7edf\u77e9\u9635\uff0c\u8868\u660e\u54ea\u4e9b\u5143\u7d20\u8981\u5b58\u50a8\u5728\u5f53\u524d\u5904\u7406\u5668\u4e0a\uff0c\u54ea\u4e9b\u8981\u671f\u671b\u5b58\u50a8\u5728\u5176\u4ed6\u5730\u65b9\uff09\uff1b\u4ee5\u53ca\u4e00\u4e2a\u7d22\u5f15\u96c6\uff0c\u8868\u660e\u54ea\u4e9b\u81ea\u7531\u5ea6\u662f\u672c\u5730\u76f8\u5173\u7684\uff08\u5373\u751f\u6d3b\u5728\u5f53\u524d\u5904\u7406\u5668\u6240\u62e5\u6709\u7684\u5355\u5143\u4e0a\u6216\u672c\u5730\u6240\u62e5\u6709\u7684\u5355\u5143\u5468\u56f4\u7684\u9b3c\u9b42\u5355\u5143\u4e0a\uff1b\u6211\u4eec\u5c06\u628a\u8fd9\u4e9b\u81ea\u7531\u5ea6\u5b58\u50a8\u5728\u5f53\u524d\u5904\u7406\u5668\u4e0a\u3002 \u4f8b\u5982\uff0c\u751f\u6d3b\u5728\u5f53\u524d\u5904\u7406\u5668\u62e5\u6709\u7684\u5355\u5143\u4e0a\u6216\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u5468\u56f4\u7684\u5e7d\u7075\u5355\u5143\u5c42\u4e0a\uff1b\u4f8b\u5982\uff0c\u6211\u4eec\u9700\u8981\u6240\u6709\u8fd9\u4e9b\u81ea\u7531\u5ea6\u6765\u4f30\u8ba1\u672c\u5730\u5355\u5143\u7684\u8bef\u5dee\uff09\u3002)\n\n    locally_owned_dofs = dof_handler.locally_owned_dofs(); \n    DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs); \n\n// \u63a5\u4e0b\u6765\uff0c\u8ba9\u6211\u4eec\u521d\u59cb\u5316\u89e3\u548c\u53f3\u624b\u8fb9\u7684\u5411\u91cf\u3002\u5982\u4e0a\u6240\u8ff0\uff0c\u6211\u4eec\u5bfb\u6c42\u7684\u89e3\u5411\u91cf\u4e0d\u4ec5\u5b58\u50a8\u4e86\u6211\u4eec\u81ea\u5df1\u7684\u5143\u7d20\uff0c\u8fd8\u5b58\u50a8\u4e86\u5e7d\u7075\u6761\u76ee\uff1b\u53e6\u4e00\u65b9\u9762\uff0c\u53f3\u624b\u5411\u91cf\u53ea\u9700\u8981\u6709\u5f53\u524d\u5904\u7406\u5668\u62e5\u6709\u7684\u6761\u76ee\uff0c\u56e0\u4e3a\u6211\u4eec\u6240\u505a\u7684\u53ea\u662f\u5411\u5176\u4e2d\u5199\u5165\uff0c\u800c\u4e0d\u662f\u4ece\u5176\u4e2d\u8bfb\u53d6\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\uff08\u5f53\u7136\uff0c\u7ebf\u6027\u6c42\u89e3\u5668\u4f1a\u4ece\u5176\u4e2d\u8bfb\u53d6\uff0c\u4f46\u5b83\u4eec\u5e76\u4e0d\u5173\u5fc3\u81ea\u7531\u5ea6\u7684\u51e0\u4f55\u4f4d\u7f6e\uff09\u3002\n\n    locally_relevant_solution.reinit(locally_owned_dofs, \n                                     locally_relevant_dofs, \n                                     mpi_communicator); \n    system_rhs.reinit(locally_owned_dofs, mpi_communicator); \n\n// \u4e0b\u4e00\u6b65\u662f\u8ba1\u7b97\u60ac\u6302\u8282\u70b9\u548c\u8fb9\u754c\u503c\u7ea6\u675f\uff0c\u6211\u4eec\u5c06\u5176\u5408\u5e76\u4e3a\u4e00\u4e2a\u5b58\u50a8\u6240\u6709\u7ea6\u675f\u7684\u5bf9\u8c61\u3002\n\n// \u5c31\u50cf\u5728%parallel\u4e2d\u7684\u6240\u6709\u5176\u4ed6\u4e8b\u60c5\u4e00\u6837\uff0c\u53e3\u5934\u7985\u5fc5\u987b\u662f\uff1a\u6ca1\u6709\u4e00\u4e2a\u5904\u7406\u5668\u53ef\u4ee5\u5b58\u50a8\u6574\u4e2a\u5b87\u5b99\u7684\u6240\u6709\u4fe1\u606f\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u544a\u8bc9AffineConstraints\u5bf9\u8c61\u54ea\u4e9b\u81ea\u7531\u5ea6\u53ef\u4ee5\u5b58\u50a8\u7ea6\u675f\u6761\u4ef6\uff0c\u54ea\u4e9b\u53ef\u4ee5\u4e0d\u671f\u671b\u5b58\u50a8\u4efb\u4f55\u4fe1\u606f\u3002\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u6b63\u5982 @ref distributed \u6a21\u5757\u6240\u89e3\u91ca\u7684\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bcf\u4e2a\u5904\u7406\u5668\u4e0a\u5173\u5fc3\u7684\u81ea\u7531\u5ea6\u662f\u672c\u5730\u76f8\u5173\u7684\u81ea\u7531\u5ea6\uff0c\u6240\u4ee5\u6211\u4eec\u628a\u8fd9\u4e2a\u4f20\u9012\u7ed9 AffineConstraints::reinit \u51fd\u6570\u3002\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u5fd8\u8bb0\u4f20\u9012\u8fd9\u4e2a\u53c2\u6570\uff0cAffineConstraints\u7c7b\u5c06\u5206\u914d\u4e00\u4e2a\u957f\u5ea6\u7b49\u4e8e\u5b83\u76ee\u524d\u770b\u5230\u7684\u6700\u5927\u81ea\u7531\u5ea6\u7d22\u5f15\u7684\u6570\u7ec4\u3002\u5bf9\u4e8eMPI\u8fdb\u7a0b\u6570\u5f88\u9ad8\u7684\u5904\u7406\u5668\u6765\u8bf4\uff0c\u8fd9\u53ef\u80fd\u662f\u975e\u5e38\u5927\u7684 -- \u4e5f\u8bb8\u662f\u6570\u5341\u4ebf\u7684\u6570\u91cf\u7ea7\u3002\u7136\u540e\uff0c\u7a0b\u5e8f\u5c06\u4e3a\u8fd9\u4e2a\u5355\u4e00\u7684\u6570\u7ec4\u5206\u914d\u6bd4\u5176\u4ed6\u6240\u6709\u64cd\u4f5c\u52a0\u8d77\u6765\u8fd8\u8981\u591a\u7684\u5185\u5b58\u3002\n\n    constraints.clear(); \n    constraints.reinit(locally_relevant_dofs); \n    DoFTools::make_hanging_node_constraints(dof_handler, constraints); \n    VectorTools::interpolate_boundary_values(dof_handler, \n                                             0, \n                                             Functions::ZeroFunction<dim>(), \n                                             constraints); \n    constraints.close(); \n\n// \u8fd9\u4e2a\u51fd\u6570\u7684\u6700\u540e\u4e00\u90e8\u5206\u6d89\u53ca\u5230\u7528\u4f34\u968f\u7684\u7a00\u758f\u6a21\u5f0f\u521d\u59cb\u5316\u77e9\u9635\u3002\u548c\u4ee5\u524d\u7684\u6559\u7a0b\u7a0b\u5e8f\u4e00\u6837\uff0c\u6211\u4eec\u4f7f\u7528DynamicSparsityPattern\u4f5c\u4e3a\u4e00\u4e2a\u4e2d\u4ecb\uff0c\u7136\u540e\u7528\u5b83\u6765\u521d\u59cb\u5316\u7cfb\u7edf\u77e9\u9635\u3002\u4e3a\u4e86\u505a\u5230\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u5fc5\u987b\u544a\u8bc9\u7a00\u758f\u6a21\u5f0f\u5b83\u7684\u5927\u5c0f\uff0c\u4f46\u5982\u4e0a\u6240\u8ff0\uff0c\u6240\u4ea7\u751f\u7684\u5bf9\u8c61\u4e0d\u53ef\u80fd\u4e3a\u6bcf\u4e2a\u5168\u5c40\u81ea\u7531\u5ea6\u5b58\u50a8\u54ea\u6015\u4e00\u4e2a\u6307\u9488\uff1b\u6211\u4eec\u6700\u597d\u7684\u5e0c\u671b\u662f\u5b83\u80fd\u5b58\u50a8\u6bcf\u4e2a\u5c40\u90e8\u76f8\u5173\u81ea\u7531\u5ea6\u7684\u4fe1\u606f\uff0c\u5373\u6240\u6709\u6211\u4eec\u5728\u7ec4\u88c5\u77e9\u9635\u7684\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u63a5\u89e6\u5230\u7684\u81ea\u7531\u5ea6\uff08 @ref distributed_paper \"\u5206\u5e03\u5f0f\u8ba1\u7b97\u8bba\u6587 \"\u6709\u5f88\u957f\u7684\u8ba8\u8bba\uff0c\u4e3a\u4ec0\u4e48\u6211\u4eec\u771f\u7684\u9700\u8981\u5c40\u90e8\u76f8\u5173\u81ea\u7531\u5ea6\uff0c\u800c\u4e0d\u662f\u5728\u6b64\u80cc\u666f\u4e0b\u7684\u5c0f\u7684\u5c40\u90e8\u6d3b\u52a8\u81ea\u7531\u5ea6\u96c6\uff09\u3002\n\n// \u6240\u4ee5\u6211\u4eec\u544a\u8bc9\u7a00\u758f\u6a21\u5f0f\u5b83\u7684\u5927\u5c0f\u548c\u8981\u5b58\u50a8\u4ec0\u4e48\u81ea\u7531\u5ea6\uff0c\u7136\u540e\u8981\u6c42 DoFTools::make_sparsity_pattern \u6765\u586b\u5145\u5b83\uff08\u8fd9\u4e2a\u51fd\u6570\u5ffd\u7565\u4e86\u6240\u6709\u4e0d\u5c5e\u4e8e\u672c\u5730\u7684\u5355\u5143\uff0c\u6a21\u4eff\u6211\u4eec\u4e0b\u9762\u5728\u88c5\u914d\u8fc7\u7a0b\u4e2d\u7684\u505a\u6cd5\uff09\u3002\u5728\u8fd9\u4e4b\u540e\uff0c\u6211\u4eec\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\uff0c\u5728\u5904\u7406\u5668\u4e4b\u95f4\u4ea4\u6362\u8fd9\u4e9b\u7a00\u758f\u6a21\u5f0f\u7684\u6761\u76ee\uff0c\u4ee5\u4fbf\u6700\u540e\u6bcf\u4e2a\u5904\u7406\u5668\u771f\u6b63\u77e5\u9053\u5b83\u5c06\u62e5\u6709\u7684\u90a3\u90e8\u5206\u6709\u9650\u5143\u77e9\u9635\u4e2d\u7684\u6240\u6709\u6761\u76ee\u3002\u6700\u540e\u4e00\u6b65\u662f\u7528\u7a00\u758f\u6a21\u5f0f\u521d\u59cb\u5316\u77e9\u9635\u3002\n\n    DynamicSparsityPattern dsp(locally_relevant_dofs); \n\n    DoFTools::make_sparsity_pattern(dof_handler, dsp, constraints, false); \n    SparsityTools::distribute_sparsity_pattern(dsp, \n                                               dof_handler.locally_owned_dofs(), \n                                               mpi_communicator, \n                                               locally_relevant_dofs); \n\n    system_matrix.reinit(locally_owned_dofs, \n                         locally_owned_dofs, \n                         dsp, \n                         mpi_communicator); \n  } \n\n//  @sect4{LaplaceProblem::assemble_system}  \n\n// \u7136\u540e\u7ec4\u88c5\u7ebf\u6027\u7cfb\u7edf\u7684\u51fd\u6570\u76f8\u5bf9\u6765\u8bf4\u6bd4\u8f83\u65e0\u804a\uff0c\u51e0\u4e4e\u548c\u6211\u4eec\u4e4b\u524d\u770b\u5230\u7684\u4e00\u6a21\u4e00\u6837\u3002\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\u662f\u3002\n\n// - \u88c5\u914d\u5fc5\u987b\u53ea\u5728\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u4e0a\u5faa\u73af\u3002\u6709\u591a\u79cd\u65b9\u6cd5\u6765\u6d4b\u8bd5\uff1b\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5355\u5143\u7684subdomain_id\u4e0e\u4e09\u89d2\u5f62\u7684\u4fe1\u606f\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982<code>cell->subdomain_id() == triangulation.local_owned_subdomain()</code>\uff0c\u6216\u8005\u8df3\u8fc7\u6240\u6709\u6761\u4ef6<code>cell->is_ghost() || cell->is_artificial()</code>\u4e3a\u771f\u7684\u5355\u5143\u3002\u7136\u800c\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u7b80\u5355\u5730\u8be2\u95ee\u5355\u5143\u683c\u662f\u5426\u4e3a\u672c\u5730\u5904\u7406\u5668\u6240\u62e5\u6709\u3002\n\n// - \u5c06\u672c\u5730\u8d21\u732e\u590d\u5236\u5230\u5168\u5c40\u77e9\u9635\u4e2d\u5fc5\u987b\u5305\u62ec\u5206\u914d\u7ea6\u675f\u548c\u8fb9\u754c\u503c\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u6211\u4eec\u4e0d\u80fd\uff08\u5c31\u50cf\u6211\u4eec\u5728 step-6 \u4e2d\u6240\u505a\u7684\u90a3\u6837\uff09\u9996\u5148\u5c06\u6bcf\u4e2a\u672c\u5730\u8d21\u732e\u590d\u5236\u5230\u5168\u5c40\u77e9\u9635\u4e2d\uff0c\u7136\u540e\u5728\u540e\u9762\u7684\u6b65\u9aa4\u4e2d\u624d\u5904\u7406\u60ac\u6302\u8282\u70b9\u7684\u7ea6\u675f\u548c\u8fb9\u754c\u503c\u3002\u539f\u56e0\u662f\uff0c\u6b63\u5982\u5728 step-17 \u4e2d\u6240\u8ba8\u8bba\u7684\u90a3\u6837\uff0c\u4e00\u65e6\u77e9\u9635\u4e2d\u7684\u4efb\u610f\u5143\u7d20\u88ab\u7ec4\u88c5\u5230\u77e9\u9635\u4e2d\uff0c\u5e76\u884c\u77e2\u91cf\u7c7b\u5c31\u4e0d\u80fd\u63d0\u4f9b\u5bf9\u8fd9\u4e9b\u5143\u7d20\u7684\u8bbf\u95ee--\u90e8\u5206\u539f\u56e0\u662f\u5b83\u4eec\u53ef\u80fd\u4e0d\u518d\u5b58\u5728\u4e8e\u5f53\u524d\u7684\u5904\u7406\u5668\u4e2d\uff0c\u800c\u662f\u88ab\u8fd0\u5230\u4e86\u4e0d\u540c\u7684\u673a\u5668\u4e0a\u3002\n\n// - \u6211\u4eec\u8ba1\u7b97\u53f3\u624b\u8fb9\u7684\u65b9\u5f0f\uff08\u8003\u8651\u5230\u4ecb\u7ecd\u4e2d\u7684\u516c\u5f0f\uff09\u53ef\u80fd\u4e0d\u662f\u6700\u4f18\u96c5\u7684\uff0c\u4f46\u5bf9\u4e8e\u91cd\u70b9\u5728\u67d0\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u5730\u65b9\u7684\u7a0b\u5e8f\u6765\u8bf4\u662f\u53ef\u4ee5\u7684\u3002\n\n  template <int dim> \n  void LaplaceProblem<dim>::assemble_system() \n  { \n    TimerOutput::Scope t(computing_timer, \"assembly\"); \n\n    const QGauss<dim> quadrature_formula(fe.degree + 1); \n\n    FEValues<dim> fe_values(fe, \n                            quadrature_formula, \n                            update_values | update_gradients | \n                              update_quadrature_points | update_JxW_values); \n\n    const unsigned int dofs_per_cell = fe.n_dofs_per_cell(); \n    const unsigned int n_q_points    = quadrature_formula.size(); \n\n    FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell); \n    Vector<double>     cell_rhs(dofs_per_cell); \n\n    std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell); \n\n    for (const auto &cell : dof_handler.active_cell_iterators()) \n      if (cell->is_locally_owned()) \n        { \n          cell_matrix = 0.; \n          cell_rhs    = 0.; \n\n          fe_values.reinit(cell); \n\n          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point) \n            { \n              const double rhs_value = \n                (fe_values.quadrature_point(q_point)[1] > \n                     0.5 + \n                       0.25 * std::sin(4.0 * numbers::PI * \n                                       fe_values.quadrature_point(q_point)[0]) ? \n                   1. : \n                   -1.); \n\n              for (unsigned int i = 0; i < dofs_per_cell; ++i) \n                { \n                  for (unsigned int j = 0; j < dofs_per_cell; ++j) \n                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) * \n                                         fe_values.shape_grad(j, q_point) * \n                                         fe_values.JxW(q_point); \n\n                  cell_rhs(i) += rhs_value *                         // \n                                 fe_values.shape_value(i, q_point) * // \n                                 fe_values.JxW(q_point); \n                } \n            } \n\n          cell->get_dof_indices(local_dof_indices); \n          constraints.distribute_local_to_global(cell_matrix, \n                                                 cell_rhs, \n                                                 local_dof_indices, \n                                                 system_matrix, \n                                                 system_rhs); \n        } \n\n// \u6ce8\u610f\uff0c\u4e0a\u9762\u7684\u88c5\u914d\u53ea\u662f\u4e00\u4e2a\u5c40\u90e8\u64cd\u4f5c\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5f62\u6210 \"\u5168\u5c40 \"\u7ebf\u6027\u7cfb\u7edf\uff0c\u9700\u8981\u5728\u6240\u6709\u5904\u7406\u5668\u4e4b\u95f4\u8fdb\u884c\u540c\u6b65\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u51fd\u6570compress()\u6765\u5b9e\u73b0\u3002\u53c2\u89c1 @ref GlossCompress \"\u538b\u7f29\u5206\u5e03\u5f0f\u5bf9\u8c61\"\uff0c\u4ee5\u4e86\u89e3\u66f4\u591a\u5173\u4e8ecompress()\u7684\u8bbe\u8ba1\u76ee\u7684\u7684\u4fe1\u606f\u3002\n\n    system_matrix.compress(VectorOperation::add); \n    system_rhs.compress(VectorOperation::add); \n  } \n\n//  @sect4{LaplaceProblem::solve}  \n\n// \u5c3d\u7ba1\u5728\u53ef\u80fd\u662f\u6570\u4ee5\u4e07\u8ba1\u7684\u5904\u7406\u5668\u4e0a\u6c42\u89e3\u7ebf\u6027\u7cfb\u7edf\u5230\u76ee\u524d\u4e3a\u6b62\u5e76\u4e0d\u662f\u4e00\u9879\u5fae\u4e0d\u8db3\u9053\u7684\u5de5\u4f5c\uff0c\u4f46\u5b8c\u6210\u8fd9\u9879\u5de5\u4f5c\u7684\u51fd\u6570--\u81f3\u5c11\u5728\u5916\u8868\u4e0a--\u76f8\u5bf9\u7b80\u5355\u3002\u5927\u90e8\u5206\u7684\u90e8\u5206\u4f60\u90fd\u89c1\u8fc7\u4e86\u3002\u771f\u6b63\u503c\u5f97\u4e00\u63d0\u7684\u53ea\u6709\u4e24\u4ef6\u4e8b\u3002\n\n// - \u89e3\u7b97\u5668\u548c\u9884\u5904\u7406\u5668\u662f\u5efa\u7acb\u5728PETSc\u548cTrilinos\u529f\u80fd\u7684deal.II\u5305\u88c5\u4e0a\u7684\u3002\u4f17\u6240\u5468\u77e5\uff0c\u5927\u89c4\u6a21\u5e76\u884c\u7ebf\u6027\u6c42\u89e3\u5668\u7684\u4e3b\u8981\u74f6\u9888\u5b9e\u9645\u4e0a\u4e0d\u662f\u5904\u7406\u5668\u4e4b\u95f4\u7684\u901a\u4fe1\uff0c\u800c\u662f\u5f88\u96be\u4ea7\u751f\u80fd\u591f\u5f88\u597d\u5730\u6269\u5c55\u5230\u5927\u91cf\u5904\u7406\u5668\u7684\u9884\u5904\u7406\u7a0b\u5e8f\u3002\u572821\u4e16\u7eaa\u524d\u5341\u5e74\u7684\u540e\u534a\u6bb5\uff0c\u4ee3\u6570\u591a\u7f51\u683c\uff08AMG\uff09\u65b9\u6cd5\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u663e\u7136\u662f\u975e\u5e38\u6709\u6548\u7684\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u5176\u4e2d\u7684\u4e00\u79cd\u65b9\u6cd5--\u8981\u4e48\u662f\u53ef\u4ee5\u901a\u8fc7PETSc\u63a5\u53e3\u7684Hypre\u8f6f\u4ef6\u5305\u7684BoomerAMG\u5b9e\u73b0\uff0c\u8981\u4e48\u662f\u7531ML\u63d0\u4f9b\u7684\u9884\u5904\u7406\u7a0b\u5e8f\uff0c\u5b83\u662fTrilinos\u7684\u4e00\u90e8\u5206--\u7528\u4e8e\u5f53\u524d\u7684\u7a0b\u5e8f\u3002\u89e3\u7b97\u5668\u672c\u8eab\u7684\u5176\u4f59\u90e8\u5206\u662f\u6a21\u677f\uff0c\u4e4b\u524d\u5df2\u7ecf\u5c55\u793a\u8fc7\u4e86\u3002\u7531\u4e8e\u7ebf\u6027\u7cfb\u7edf\u662f\u5bf9\u79f0\u548c\u6b63\u5b9a\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528CG\u65b9\u6cd5\u4f5c\u4e3a\u5916\u89e3\u5668\u3002\n\n// - \u6700\u7ec8\uff0c\u6211\u4eec\u60f3\u8981\u4e00\u4e2a\u5411\u91cf\uff0c\u5b83\u4e0d\u4ec5\u5b58\u50a8\u4e86\u5f53\u524d\u5904\u7406\u5668\u62e5\u6709\u7684\u81ea\u7531\u5ea6\u7684\u89e3\u7684\u5143\u7d20\uff0c\u800c\u4e14\u8fd8\u5b58\u50a8\u4e86\u6240\u6709\u5176\u4ed6\u672c\u5730\u76f8\u5173\u7684\u81ea\u7531\u5ea6\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u6c42\u89e3\u5668\u672c\u8eab\u9700\u8981\u4e00\u4e2a\u5728\u5904\u7406\u5668\u4e4b\u95f4\u552f\u4e00\u5206\u5272\u7684\u5411\u91cf\uff0c\u6ca1\u6709\u4efb\u4f55\u91cd\u53e0\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u8fd9\u4e2a\u51fd\u6570\u7684\u5f00\u5934\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u8fd9\u4e9b\u7279\u6027\u7684\u5411\u91cf\uff0c\u7528\u5b83\u6765\u6c42\u89e3\u7ebf\u6027\u7cfb\u7edf\uff0c\u5e76\u5728\u6700\u540e\u624d\u628a\u5b83\u5206\u914d\u7ed9\u6211\u4eec\u60f3\u8981\u7684\u5411\u91cf\u3002\u8fd9\u6700\u540e\u4e00\u6b65\u786e\u4fdd\u6240\u6709\u7684\u9b3c\u9b42\u5143\u7d20\u4e5f\u5728\u5fc5\u8981\u65f6\u88ab\u590d\u5236\u3002\n\n  template <int dim> \n  void LaplaceProblem<dim>::solve() \n  { \n    TimerOutput::Scope t(computing_timer, \"solve\"); \n    LA::MPI::Vector    completely_distributed_solution(locally_owned_dofs, \n                                                    mpi_communicator); \n\n    SolverControl solver_control(dof_handler.n_dofs(), 1e-12); \n\n#ifdef USE_PETSC_LA \n    LA::SolverCG solver(solver_control, mpi_communicator); \n#else \n    LA::SolverCG solver(solver_control); \n#endif \n\n    LA::MPI::PreconditionAMG preconditioner; \n\n    LA::MPI::PreconditionAMG::AdditionalData data; \n\n#ifdef USE_PETSC_LA \n    data.symmetric_operator = true; \n#else \n/* Trilinos\u7684\u9ed8\u8ba4\u503c\u662f\u597d\u7684  */ \n#endif \n    preconditioner.initialize(system_matrix, data); \n\n    solver.solve(system_matrix, \n                 completely_distributed_solution, \n                 system_rhs, \n                 preconditioner); \n\n    pcout << \"   Solved in \" << solver_control.last_step() << \" iterations.\" \n          << std::endl; \n\n    constraints.distribute(completely_distributed_solution); \n\n    locally_relevant_solution = completely_distributed_solution; \n  } \n\n//  @sect4{LaplaceProblem::refine_grid}  \n\n// \u4f30\u8ba1\u8bef\u5dee\u548c\u7ec6\u5316\u7f51\u683c\u7684\u51fd\u6570\u53c8\u4e0e  step-6  \u4e2d\u7684\u51fd\u6570\u51e0\u4e4e\u5b8c\u5168\u4e00\u6837\u3002\u552f\u4e00\u4e0d\u540c\u7684\u662f\uff0c\u6807\u5fd7\u7740\u8981\u7ec6\u5316\u7684\u5355\u5143\u683c\u7684\u51fd\u6570\u73b0\u5728\u5728\u547d\u540d\u7a7a\u95f4  parallel::distributed::GridRefinement  \u4e2d -- \u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u7684\u51fd\u6570\u53ef\u4ee5\u5728\u6240\u6709\u53c2\u4e0e\u7684\u5904\u7406\u5668\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\uff0c\u5e76\u786e\u5b9a\u5168\u5c40\u9608\u503c\uff0c\u7528\u4e8e\u51b3\u5b9a\u54ea\u4e9b\u5355\u5143\u683c\u8981\u7ec6\u5316\uff0c\u54ea\u4e9b\u8981\u7c97\u5316\u3002\n\n// \u6ce8\u610f\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u5bf9KellyErrorEstimator\u7c7b\u505a\u4efb\u4f55\u7279\u6b8a\u5904\u7406\uff1a\u6211\u4eec\u53ea\u662f\u7ed9\u5b83\u4e00\u4e2a\u5411\u91cf\uff0c\u5176\u5143\u7d20\u6570\u91cf\u4e0e\u672c\u5730\u4e09\u89d2\u5f62\u7684\u5355\u5143\uff08\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u3001\u5e7d\u7075\u5355\u5143\u548c\u4eba\u5de5\u5355\u5143\uff09\u4e00\u6837\u591a\uff0c\u4f46\u5b83\u53ea\u586b\u5165\u90a3\u4e9b\u5bf9\u5e94\u4e8e\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u7684\u6761\u76ee\u3002\n\n  template <int dim> \n  void LaplaceProblem<dim>::refine_grid() \n  { \n    TimerOutput::Scope t(computing_timer, \"refine\"); \n\n    Vector<float> estimated_error_per_cell(triangulation.n_active_cells()); \n    KellyErrorEstimator<dim>::estimate( \n      dof_handler, \n      QGauss<dim - 1>(fe.degree + 1), \n      std::map<types::boundary_id, const Function<dim> *>(), \n      locally_relevant_solution, \n      estimated_error_per_cell); \n    parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number( \n      triangulation, estimated_error_per_cell, 0.3, 0.03); \n    triangulation.execute_coarsening_and_refinement(); \n  } \n\n//  @sect4{LaplaceProblem::output_results}  \n\n// \u4e0e step-6 \u4e2d\u7684\u76f8\u5e94\u51fd\u6570\u76f8\u6bd4\uff0c\u8fd9\u91cc\u7684\u51fd\u6570\u8981\u590d\u6742\u4e00\u70b9\u3002\u6709\u4e24\u4e2a\u539f\u56e0\uff1a\u7b2c\u4e00\u4e2a\u539f\u56e0\u662f\uff0c\u6211\u4eec\u4e0d\u53ea\u662f\u60f3\u8f93\u51fa\u89e3\u51b3\u65b9\u6848\uff0c\u8fd8\u60f3\u8f93\u51fa\u6bcf\u4e2a\u5355\u5143\u7684\u5904\u7406\u5668\uff08\u5373\u5b83\u5728\u54ea\u4e2a \"\u5b50\u57df\"\uff09\u3002\u5176\u6b21\uff0c\u6b63\u5982\u5728 step-17 \u548c step-18 \u4e2d\u8be6\u7ec6\u8ba8\u8bba\u7684\u90a3\u6837\uff0c\u751f\u6210\u56fe\u5f62\u6570\u636e\u53ef\u80fd\u662f\u5e76\u884c\u5316\u7684\u4e00\u4e2a\u74f6\u9888\u3002\u5728 step-18 \u4e2d\uff0c\u6211\u4eec\u5c06\u8fd9\u4e00\u6b65\u9aa4\u4ece\u5b9e\u9645\u8ba1\u7b97\u4e2d\u79fb\u51fa\uff0c\u800c\u662f\u5c06\u5176\u8f6c\u79fb\u5230\u4e00\u4e2a\u5355\u72ec\u7684\u7a0b\u5e8f\u4e2d\uff0c\u968f\u540e\u5c06\u5404\u4e2a\u5904\u7406\u5668\u7684\u8f93\u51fa\u5408\u5e76\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\u3002\u4f46\u8fd9\u5e76\u4e0d\u5177\u89c4\u6a21\uff1a\u5982\u679c\u5904\u7406\u5668\u7684\u6570\u91cf\u5f88\u5927\uff0c\u8fd9\u53ef\u80fd\u610f\u5473\u7740\u5728\u5355\u4e2a\u5904\u7406\u5668\u4e0a\u5408\u5e76\u6570\u636e\u7684\u6b65\u9aa4\u540e\u6765\u6210\u4e3a\u7a0b\u5e8f\u4e2d\u8fd0\u884c\u65f6\u95f4\u6700\u957f\u7684\u90e8\u5206\uff0c\u6216\u8005\u5b83\u53ef\u80fd\u4ea7\u751f\u4e00\u4e2a\u5927\u5230\u65e0\u6cd5\u518d\u53ef\u89c6\u5316\u7684\u6587\u4ef6\u3002\u6211\u4eec\u5728\u8fd9\u91cc\u9075\u5faa\u4e00\u4e2a\u66f4\u5408\u7406\u7684\u65b9\u6cd5\uff0c\u5373\u4e3a\u6bcf\u4e2aMPI\u8fdb\u7a0b\u521b\u5efa\u5355\u72ec\u7684\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u7559\u7ed9\u53ef\u89c6\u5316\u7a0b\u5e8f\u6765\u7406\u89e3\u3002\n\n// \u9996\u5148\uff0c\u51fd\u6570\u7684\u9876\u90e8\u770b\u8d77\u6765\u548c\u5e73\u65f6\u4e00\u6837\u3002\u9664\u4e86\u9644\u52a0\u89e3\u51b3\u65b9\u6848\u5411\u91cf\uff08\u5305\u542b\u6240\u6709\u672c\u5730\u76f8\u5173\u5143\u7d20\u7684\u6761\u76ee\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u672c\u5730\u62e5\u6709\u7684\u5143\u7d20\uff09\u5916\uff0c\u6211\u4eec\u8fd8\u9644\u52a0\u4e00\u4e2a\u6570\u636e\u5411\u91cf\uff0c\u4e3a\u6bcf\u4e2a\u5355\u5143\u5b58\u50a8\u8be5\u5355\u5143\u6240\u5c5e\u7684\u5b50\u57df\u3002\u8fd9\u7a0d\u5fae\u6709\u70b9\u68d8\u624b\uff0c\u56e0\u4e3a\u5f53\u7136\u4e0d\u662f\u6bcf\u4e2a\u5904\u7406\u5668\u90fd\u77e5\u9053\u6bcf\u4e2a\u5355\u5143\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9644\u52a0\u7684\u5411\u91cf\u6709\u4e00\u4e2a\u5f53\u524d\u5904\u7406\u5668\u5728\u5176\u7f51\u683c\u4e2d\u62e5\u6709\u7684\u6bcf\u4e2a\u5355\u5143\u7684\u6761\u76ee\uff08\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u3001\u5e7d\u7075\u5355\u5143\u548c\u4eba\u9020\u5355\u5143\uff09\uff0c\u4f46DataOut\u7c7b\u5c06\u5ffd\u7565\u6240\u6709\u5bf9\u5e94\u4e8e\u4e0d\u5c5e\u4e8e\u5f53\u524d\u5904\u7406\u5668\u7684\u5355\u5143\u7684\u6761\u76ee\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u8fd9\u4e9b\u5411\u91cf\u6761\u76ee\u4e2d\u5199\u5165\u4ec0\u4e48\u503c\u5b9e\u9645\u4e0a\u5e76\u4e0d\u91cd\u8981\uff1a\u6211\u4eec\u53ea\u9700\u7528\u5f53\u524dMPI\u8fdb\u7a0b\u7684\u7f16\u53f7\uff08\u5373\u5f53\u524d\u8fdb\u7a0b\u7684\u5b50\u57df_id\uff09\u6765\u586b\u5145\u6574\u4e2a\u5411\u91cf\uff1b\u8fd9\u5c31\u6b63\u786e\u5730\u8bbe\u7f6e\u4e86\u6211\u4eec\u5173\u5fc3\u7684\u503c\uff0c\u5373\u5bf9\u5e94\u4e8e\u672c\u5730\u62e5\u6709\u7684\u5355\u5143\u7684\u6761\u76ee\uff0c\u800c\u4e3a\u6240\u6709\u5176\u4ed6\u5143\u7d20\u63d0\u4f9b\u4e86\u9519\u8bef\u7684\u503c--\u4f46\u65e0\u8bba\u5982\u4f55\u8fd9\u4e9b\u90fd\u4f1a\u88ab\u5ffd\u7565\u3002\n\n  template <int dim> \n  void LaplaceProblem<dim>::output_results(const unsigned int cycle) const \n  { \n    DataOut<dim> data_out; \n    data_out.attach_dof_handler(dof_handler); \n    data_out.add_data_vector(locally_relevant_solution, \"u\"); \n\n    Vector<float> subdomain(triangulation.n_active_cells()); \n    for (unsigned int i = 0; i < subdomain.size(); ++i) \n      subdomain(i) = triangulation.locally_owned_subdomain(); \n    data_out.add_data_vector(subdomain, \"subdomain\"); \n\n    data_out.build_patches(); \n\n// \u4e0b\u4e00\u6b65\u662f\u628a\u8fd9\u4e9b\u6570\u636e\u5199\u5230\u78c1\u76d8\u4e0a\u3002\u5728MPI-IO\u7684\u5e2e\u52a9\u4e0b\uff0c\u6211\u4eec\u6700\u591a\u53ef\u4ee5\u5e76\u884c\u5199\u51658\u4e2aVTU\u6587\u4ef6\u3002\u6b64\u5916\uff0c\u8fd8\u4ea7\u751f\u4e86\u4e00\u4e2aPVTU\u8bb0\u5f55\uff0c\u5b83\u5c06\u5199\u5165\u7684VTU\u6587\u4ef6\u5206\u7ec4\u3002\n\n    data_out.write_vtu_with_pvtu_record( \n      \"./\", \"solution\", cycle, mpi_communicator, 2, 8); \n  } \n\n//  @sect4{LaplaceProblem::run}  \n\n// \u63a7\u5236\u7a0b\u5e8f\u6574\u4f53\u884c\u4e3a\u7684\u51fd\u6570\u53c8\u548c  step-6  \u4e2d\u7684\u4e00\u6837\u3002\u5c0f\u7684\u533a\u522b\u662f\u4f7f\u7528 <code>pcout</code> instead of <code>std::cout</code> \u6765\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff08\u4e5f\u89c1 step-17 \uff09\uff0c\u800c\u4e14\u6211\u4eec\u53ea\u5728\u6700\u591a\u6d89\u53ca32\u4e2a\u5904\u7406\u5668\u7684\u60c5\u51b5\u4e0b\u4ea7\u751f\u56fe\u5f62\u8f93\u51fa\u3002\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\u9650\u5236\uff0c\u4eba\u4eec\u5f88\u5bb9\u6613\u5728\u6ca1\u6709\u9605\u8bfb\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u60c5\u51b5\u4e0b\u7c97\u5fc3\u5927\u610f\u5730\u8fd0\u884c\u8fd9\u4e2a\u7a0b\u5e8f\uff0c\u4ece\u800c\u5bfc\u81f4\u96c6\u7fa4\u4e92\u8fde\u4e2d\u65ad\uff0c\u5e76\u586b\u6ee1\u4efb\u4f55\u53ef\u7528\u7684\u6587\u4ef6\u7cfb\u7edf :-)\n\n// \u4e0e step-6 \u7684\u4e00\u4e2a\u529f\u80fd\u4e0a\u7684\u533a\u522b\u662f\u4f7f\u7528\u4e86\u4e00\u4e2a\u6b63\u65b9\u5f62\u57df\uff0c\u5e76\u4e14\u6211\u4eec\u4ece\u4e00\u4e2a\u7a0d\u7ec6\u7684\u7f51\u683c\u5f00\u59cb\uff085\u4e2a\u5168\u5c40\u7ec6\u5316\u5468\u671f\uff09--\u57284\u4e2a\u5355\u5143\u4e0a\u5f00\u59cb\u663e\u793a\u4e00\u4e2a\u5927\u89c4\u6a21\u7684%\u5e76\u884c\u7a0b\u5e8f\u6ca1\u6709\u4ec0\u4e48\u610f\u4e49\uff08\u5c3d\u7ba1\u627f\u8ba4\u57281024\u5355\u5143\u4e0a\u5f00\u59cb\u663e\u793a\u7684\u610f\u4e49\u53ea\u662f\u7a0d\u5f3a\uff09\u3002\n\n  template <int dim> \n  void LaplaceProblem<dim>::run() \n  { \n    pcout << \"Running with \" \n#ifdef USE_PETSC_LA \n          << \"PETSc\" \n#else \n          << \"Trilinos\" \n#endif \n          << \" on \" << Utilities::MPI::n_mpi_processes(mpi_communicator) \n          << \" MPI rank(s)...\" << std::endl; \n\n    const unsigned int n_cycles = 8; \n    for (unsigned int cycle = 0; cycle < n_cycles; ++cycle) \n      { \n        pcout << \"Cycle \" << cycle << ':' << std::endl; \n\n        if (cycle == 0) \n          { \n            GridGenerator::hyper_cube(triangulation); \n            triangulation.refine_global(5); \n          } \n        else \n          refine_grid(); \n\n        setup_system(); \n\n        pcout << \"   Number of active cells:       \" \n              << triangulation.n_global_active_cells() << std::endl \n              << \"   Number of degrees of freedom: \" << dof_handler.n_dofs() \n              << std::endl; \n\n        assemble_system(); \n        solve(); \n\n        if (Utilities::MPI::n_mpi_processes(mpi_communicator) <= 32) \n          { \n            TimerOutput::Scope t(computing_timer, \"output\"); \n            output_results(cycle); \n          } \n\n        computing_timer.print_summary(); \n        computing_timer.reset(); \n\n        pcout << std::endl; \n      } \n  } \n} // namespace Step40 \n\n//  @sect4{main()}  \n\n// \u6700\u540e\u4e00\u4e2a\u51fd\u6570\uff0c  <code>main()</code>  \uff0c\u540c\u6837\u5177\u6709\u4e0e\u6240\u6709\u5176\u4ed6\u7a0b\u5e8f\u76f8\u540c\u7684\u7ed3\u6784\uff0c\u7279\u522b\u662f  step-6  \u3002\u50cf\u5176\u4ed6\u4f7f\u7528MPI\u7684\u7a0b\u5e8f\u4e00\u6837\uff0c\u6211\u4eec\u5fc5\u987b\u521d\u59cb\u5316\u548c\u6700\u7ec8\u786e\u5b9aMPI\uff0c\u8fd9\u662f\u7528\u8f85\u52a9\u5bf9\u8c61  Utilities::MPI::MPI_InitFinalize.  \u5b8c\u6210\u7684\u3002\u8be5\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4e5f\u521d\u59cb\u5316\u4e86\u4f9d\u8d56MPI\u7684\u5e93\uff0c\u5982p4est\u3001PETSc\u3001SLEPc\u548cZoltan\uff08\u5c3d\u7ba1\u6700\u540e\u4e24\u4e2a\u5728\u672c\u6559\u7a0b\u4e2d\u6ca1\u6709\u4f7f\u7528\uff09\u3002\u8fd9\u91cc\u7684\u987a\u5e8f\u5f88\u91cd\u8981\uff1a\u5728\u8fd9\u4e9b\u5e93\u88ab\u521d\u59cb\u5316\u4e4b\u524d\uff0c\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528\u5b83\u4eec\uff0c\u6240\u4ee5\u5728\u521b\u5efa  Utilities::MPI::MPI_InitFinalize.  \u7684\u5b9e\u4f8b\u4e4b\u524d\u505a\u4efb\u4f55\u4e8b\u60c5\u90fd\u6ca1\u6709\u610f\u4e49\u3002\n\n// \u5728\u6c42\u89e3\u5668\u5b8c\u6210\u540e\uff0cLaplaceProblem\u89e3\u6784\u5668\u5c06\u8fd0\u884c\uff0c\u7136\u540e\u662f Utilities::MPI::MPI_InitFinalize::~MPI_InitFinalize().  \u8fd9\u4e2a\u987a\u5e8f\u4e5f\u5f88\u91cd\u8981\uff1a Utilities::MPI::MPI_InitFinalize::~MPI_InitFinalize() \u8c03\u7528 <code>PetscFinalize</code> \uff08\u4ee5\u53ca\u5176\u4ed6\u5e93\u7684\u6700\u7ec8\u786e\u5b9a\u51fd\u6570\uff09\uff0c\u8fd9\u5c06\u5220\u9664\u4efb\u4f55\u6b63\u5728\u4f7f\u7528\u7684PETSc\u5bf9\u8c61\u3002\u8fd9\u5fc5\u987b\u5728\u6211\u4eec\u89e3\u6784\u62c9\u666e\u62c9\u65af\u6c42\u89e3\u5668\u4e4b\u540e\u8fdb\u884c\uff0c\u4ee5\u907f\u514d\u53cc\u91cd\u5220\u9664\u9519\u8bef\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u7531\u4e8eC++\u7684\u6790\u6784\u5668\u8c03\u7528\u987a\u5e8f\u89c4\u5219\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u62c5\u5fc3\u8fd9\u4e9b\uff1a\u4e00\u5207\u90fd\u4ee5\u6b63\u786e\u7684\u987a\u5e8f\u53d1\u751f\uff08\u5373\uff0c\u4e0e\u6784\u9020\u987a\u5e8f\u76f8\u53cd\uff09\u3002\u7531 Utilities::MPI::MPI_InitFinalize::~MPI_InitFinalize() \u8c03\u7528\u7684\u6700\u540e\u4e00\u4e2a\u51fd\u6570\u662f <code>MPI_Finalize</code> \uff1a\u4e5f\u5c31\u662f\u8bf4\uff0c\u4e00\u65e6\u8fd9\u4e2a\u5bf9\u8c61\u88ab\u6790\u6784\uff0c\u7a0b\u5e8f\u5e94\u8be5\u9000\u51fa\uff0c\u56e0\u4e3aMPI\u5c06\u4e0d\u518d\u53ef\u7528\u3002\n\nint main(int argc, char *argv[]) \n{ \n  try \n    { \n      using namespace dealii; \n      using namespace Step40; \n\n      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); \n\n      LaplaceProblem<2> laplace_problem_2d; \n      laplace_problem_2d.run(); \n    } \n  catch (std::exception &exc) \n    { \n      std::cerr << std::endl \n                << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n      std::cerr << \"Exception on processing: \" << std::endl \n                << exc.what() << std::endl \n                << \"Aborting!\" << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n\n      return 1; \n    } \n  catch (...) \n    { \n      std::cerr << std::endl \n                << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n      std::cerr << \"Unknown exception!\" << std::endl \n                << \"Aborting!\" << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n      return 1; \n    } \n\n  return 0; \n} \n\n", "meta": {"hexsha": "8a092d585907c50062f3308e84fd9c7eb042ae4a", "size": 20081, "ext": "cc", "lang": "C++", "max_stars_repo_path": "Translator_file/examples/step-40/step-40.cc", "max_stars_repo_name": "jiaqiwang969/deal.ii-course-practice", "max_stars_repo_head_hexsha": "0da5ad1537d8152549d8a0e4de5872efe7619c8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Translator_file/examples/step-40/step-40.cc", "max_issues_repo_name": "jiaqiwang969/deal.ii-course-practice", "max_issues_repo_head_hexsha": "0da5ad1537d8152549d8a0e4de5872efe7619c8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Translator_file/examples/step-40/step-40.cc", "max_forks_repo_name": "jiaqiwang969/deal.ii-course-practice", "max_forks_repo_head_hexsha": "0da5ad1537d8152549d8a0e4de5872efe7619c8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.4044265594, "max_line_length": 458, "alphanum_fraction": 0.6705841343, "num_tokens": 8844, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.34158248603300034, "lm_q2_score": 0.2720245510940225, "lm_q1q2_score": 0.09291882242470713}}
{"text": "/*! \\file demo_point_markers.cpp\n  \\brief Demonstration of some marking data-point options.\n  \\details Includes Quickbook markup.\n  \\author Paul A Bristow\n*/\n\n// Copyright Jacob Voytko 2007\n// Copyright Paul A Bristow 2008, 2020\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// An example to demonstrate some of the point plot markers available.\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[demo_point_markers_1\n\n/*`As ever, we need a few includes to use Boost.Plot\n*/\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\n  //using namespace boost::svg;\n  //using boost::svg::svg_1d_plot;\n\n#include <iostream>\n  //using std::cout;\n  //using std::endl;\n\n#include <vector>\n // using std::vector;\n\n#include <limits>\n // using std::numeric_limits;\n\n#include <boost/svg_plot/show_1d_settings.hpp>  // Only required for diagnostics display of all settings.\n\n//] [demo_point_markers_1]\n\nint main()\n{\n  // Construct two data-sets as std::vectors.\n  std::vector<double> my_data_1;\n  my_data_1.push_back(-10.0);\n  my_data_1.push_back(-9.0);\n  my_data_1.push_back(-1.0);\n  my_data_1.push_back(1.23456); // Data value-label will be rounded to 1.23 with my_1d_plot.x_values_precision(3); \n  my_data_1.push_back(2.0);\n  my_data_1.push_back(8.0987); // Rounded to 8.1 \n  my_data_1.push_back(99.0); // Finite value that is too big to fit into the plot window (shows as a point-right triangle in green).\n\n  // Add some not-normal values to show how they are displayed.\n  my_data_1.push_back(-std::numeric_limits<double>::infinity()); // Minus infinity shows as a point-left triangle or cone.\n  my_data_1.push_back(+std::numeric_limits<double>::infinity()); // Plus infinity shows as a point-right triangle or cone.\n  my_data_1.push_back(std::numeric_limits<double>::quiet_NaN()); // NaN (NotANumber) shows as a point-down triangle, at the origin (0, 0).\n\n  // Second data-set.\n  std::vector<double> my_data_2;\n  my_data_2.push_back(-6.0);\n  my_data_2.push_back(-4.0);\n  my_data_2.push_back(+4.0);\n  my_data_2.push_back(+6.0);\n\n  using namespace boost::svg; // Convenient to ensure all color are available as CSS words, for example: red, blue, green, pink, purple...\n  using boost::svg::svg_1d_plot;  \n\n//[demo_point_markers_2\n\n  try\n  { // try'n'catch blocks are needed to ensure error messages from any exceptions are shown.\n\n    svg_1d_plot my_1d_plot; // Construct a plot with all the default constructor values.\n\n    my_1d_plot.title(\"Demo point markers 1D\") // Add a string title of the plot.\n      .x_label(\"length (m)\"); // Add a label for the X-axis, including a unit.\n\n/*`Add the one data-series, `my_data` and a description, and how the data-points are to be marked,\nhere a blue diamond shape with a size of 10 pixels.\n*/\n    my_1d_plot.plot(my_data_1, \"1D Values\").shape(diamond).size(10).stroke_color(red).fill_color(blue);\n\n    my_1d_plot.plot(my_data_2, \"More 1D Values\").shape(circlet).size(10).stroke_color(blue).fill_color(red);\n\n/*`To put a decimal digit value-label against each data point, switch on the option:\n*/\n    my_1d_plot.x_values_on(true); // Add data decimal digit values as labels above the X-axis.\n\n    my_1d_plot.x_values_precision(3); // Decimal digits precision for the X-axis value-label, for example \"1.23\".\n    // if data-point value = 1.23456, then Data value-label will be 1.23 with my_1d_plot.x_values_precision(3); \n    my_1d_plot.x_values_rotation(steepup); // Orientation for the X-axis value-labels.\n    my_1d_plot.x_values_font_size(7); // Font Size for the X-axis value-labels.\n\n    my_1d_plot.x_values_alignment(align_style::right_align); // has no effect\n    // And we can show these settings:\n    std::cout << \"alignment is \" << my_1d_plot.x_values_alignment() << std::endl; // alignment is left\n    std::cout << \"rotation is \" << show_rotation(my_1d_plot.x_values_rotation()) << std::endl; // rotation is steepup (-60)\n\n/*`If the default size and color are not to your taste, set more options, like:\n*/\n    my_1d_plot.x_values_font_size(14) // Change font size for the X-axis value-labels.\n      .x_values_font_family(\"Times New Roman\") // Change font for the X-axis value-labels.\n      .x_values_color(red); // Change x-values font-color from default black to red.\n\n /*` The 'at limit' values (+/- infinity or NaN) markers can be customised, for example:\n    my_1d_plot.nan_limit_color(purple);\n    my_1d_plot.nan_limit_fill_color(green); // No effect on fill color?\n    my_1d_plot.nan_limit_size(20); \n    // But this currently makes + and - infinity and NaN all solid purple.\n  NaN limit points stroke color RGB(128,0,128)  purple\n  NaN limit points fill color RGB(0,128,0) green\n  NaN limit points size 20\n\n  +infinity limit points stroke color RGB(255,0,0)    red\n  +infinity limit points fill color RGB(255,255,255)  white\n  +infinity limit points size 10\n\n  -infinity limit points stroke color RGB(0,0,255)  blue\n  -infinity limit points fill color  RGB(255,255,255)  white\n */\n\n    /*`To use all these settings, finally write the plot to file.\n*/\n    my_1d_plot.write(\"demo_point_markers.svg\");\n\n//`If chosen settings do not have the expected effect, is may be helpful to show them.\n\n    std::cout << \"my_1d_plot.x_values_font_size() \" << my_1d_plot.x_values_font_size() << std::endl;\n    std::cout << \"my_1d_plot.x_values_font_family() \" << my_1d_plot.x_values_font_family() << std::endl;\n    std::cout << \"my_1d_plot.x_values_color() \" << my_1d_plot.x_values_color() << std::endl;\n    std::cout << \"my_1d_plot.x_values_precision() \" << my_1d_plot.x_values_precision() << std::endl;\n    std::cout << \"my_1d_plot.x_values_ioflags() \" << std::hex << my_1d_plot.x_values_ioflags() << std::dec << std::endl;\n\n    std::cout << \"NaN limit points stroke color \" << my_1d_plot.nan_limit_color() << std::endl;\n    std::cout << \"NaN limit points fill color \" << my_1d_plot.nan_limit_fill_color() << std::endl;\n    std::cout << \"NaN limit points size \" << my_1d_plot.nan_limit_size() << std::endl;\n    std::cout << \"+infinity limit points stroke color \" << my_1d_plot.plus_inf_limit_color() << std::endl;\n    std::cout << \"+infinity limit points fill color \" << my_1d_plot.plus_inf_limit_fill_color() << std::endl;\n    std::cout << \"+infinity limit points size \" << my_1d_plot.plus_inf_limit_size() << std::endl;\n    std::cout << \"-infinity limit points stroke color \" << my_1d_plot.minus_inf_limit_color() << std::endl;\n    std::cout << \"-infinity limit points fill color \" << my_1d_plot.minus_inf_limit_fill_color() << std::endl;\n    std::cout << \"-infinity limit points size \" << my_1d_plot.minus_inf_limit_size() << std::endl;\n\n//] [demo_point_markers_2]\n\n// (Or all (over one hundred) settings can be displayed with `show_1d_plot_settings(my_1d_plot)`, commented out below.\n   // show_1d_plot_settings(my_1d_plot);\n\n  }\n  catch(const std::exception& e)\n  {\n    std::cout <<\n      \"\\n\"\"Message from thrown exception was:\\n   \" << e.what() << std::endl;\n  }\n  return 0;\n} // int main()\n\n/*\n\n//[demo_point_markers_output\n\nOutput:\n\nCompiling...\ndemo_point_markers.cpp\nLinking...\nEmbedding manifest...\nAutorun \"j:\\Cpp\\SVG\\debug\\demo_point_markers.exe\"\nmy_1d_plot.x_values_font_size() 14\nmy_1d_plot.x_values_font_family() Times New Roman\nmy_1d_plot.x_values_color() RGB(255,0,0)\nmy_1d_plot.x_values_precision() 3\nmy_1d_plot.x_values_ioflags() 200\nBuild Time 0:02\n*/\n\n", "meta": {"hexsha": "c53cade4433cf39b0ee87ad21670f5380fe37a12", "size": 7733, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_point_markers.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_point_markers.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_point_markers.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 42.2568306011, "max_line_length": 138, "alphanum_fraction": 0.7171860856, "num_tokens": 2177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.35220178204788966, "lm_q2_score": 0.2598256379609837, "lm_q1q2_score": 0.09151105271158826}}
{"text": "/*\r\n [auto_generated]\r\n libs/numeric/odeint/test_external/eigen/resize.cpp\r\n\r\n [begin_description]\r\n tba.\r\n [end_description]\r\n\r\n Copyright 2013 Karsten Ahnert\r\n Copyright 2013 Mario Mulansky\r\n\r\n Distributed under the Boost Software License, Version 1.0.\r\n (See accompanying file LICENSE_1_0.txt or\r\n copy at http://www.boost.org/LICENSE_1_0.txt)\r\n */\r\n\r\n#include <boost/config.hpp>\r\n#ifdef BOOST_MSVC\r\n    #pragma warning(disable:4996)\r\n#endif\r\n\r\n#define BOOST_TEST_MODULE odeint_eigen_resize\r\n\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/numeric/odeint/external/eigen/eigen_resize.hpp>\r\n\r\n\r\nusing namespace boost::unit_test;\r\nusing namespace boost::numeric::odeint;\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE( eigen_resize )\r\n\r\nBOOST_AUTO_TEST_CASE( test_compile_time_matrix )\r\n{\r\n    typedef Eigen::Matrix< double , 1 , 1 > matrix_type;\r\n    matrix_type a , b;\r\n    boost::numeric::odeint::resize( a , b );\r\n    BOOST_CHECK( boost::numeric::odeint::same_size( a , b ) );\r\n    BOOST_CHECK_EQUAL( a.rows() , 1 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 1 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( test_rumtime_matrix )\r\n{\r\n    typedef Eigen::Matrix< double , Eigen::Dynamic , Eigen::Dynamic > matrix_type;\r\n    matrix_type a( 5 , 2 ) , b;\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 0 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 0 );\r\n    BOOST_CHECK( !boost::numeric::odeint::same_size( a , b ) );\r\n\r\n    boost::numeric::odeint::resize( b , a );\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 2 );\r\n\r\n    BOOST_CHECK( boost::numeric::odeint::same_size( a , b ) );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( test_rumtime_matrix2 )\r\n{\r\n    typedef Eigen::Matrix< double , Eigen::Dynamic , Eigen::Dynamic > matrix_type;\r\n    matrix_type a( 5 , 2 ) , b( 2 , 3 );\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 2 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 3 );\r\n    BOOST_CHECK( !boost::numeric::odeint::same_size( a , b ) );\r\n\r\n    boost::numeric::odeint::resize( b , a );\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 2 );\r\n\r\n    BOOST_CHECK( boost::numeric::odeint::same_size( a , b ) );\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( test_compile_time_array )\r\n{\r\n    typedef Eigen::Array< double , 1 , 1 > array_type;\r\n    array_type a , b;\r\n    boost::numeric::odeint::resize( a , b );\r\n    BOOST_CHECK( boost::numeric::odeint::same_size( a , b ) );\r\n    BOOST_CHECK_EQUAL( a.rows() , 1 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 1 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( test_rumtime_array )\r\n{\r\n    typedef Eigen::Array< double , Eigen::Dynamic , Eigen::Dynamic > array_type;\r\n    array_type a( 5 , 2 ) , b;\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 0 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 0 );\r\n    BOOST_CHECK( !boost::numeric::odeint::same_size( a , b ) );\r\n\r\n    boost::numeric::odeint::resize( b , a );\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 2 );\r\n\r\n    BOOST_CHECK( boost::numeric::odeint::same_size( a , b ) );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( test_rumtime_array2 )\r\n{\r\n    typedef Eigen::Array< double , Eigen::Dynamic , Eigen::Dynamic > array_type;\r\n    array_type a( 5 , 2 ) , b( 2 , 3 );\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 2 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 3 );\r\n    BOOST_CHECK( !boost::numeric::odeint::same_size( a , b ) );\r\n\r\n    boost::numeric::odeint::resize( b , a );\r\n\r\n    BOOST_CHECK_EQUAL( a.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( a.cols() , 2 );\r\n    BOOST_CHECK_EQUAL( b.rows() , 5 );\r\n    BOOST_CHECK_EQUAL( b.cols() , 2 );\r\n\r\n    BOOST_CHECK( boost::numeric::odeint::same_size( a , b ) );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "eed40a8f484dc3e7fa1cebca388c451200ba1c66", "size": 4127, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test_external/eigen/resize.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test_external/eigen/resize.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test_external/eigen/resize.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 28.2671232877, "max_line_length": 83, "alphanum_fraction": 0.626847589, "num_tokens": 1158, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48047867804790706, "lm_q2_score": 0.18952109132967757, "lm_q1q2_score": 0.09106084342428014}}
{"text": "//  (C) Copyright John Maddock 2006.\n//  Use, modification and distribution are subject to the\n//  Boost Software License, Version 1.0. (See accompanying file\n//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n#include <pch.hpp>\n\n#include <boost/math/concepts/real_concept.hpp>\n#include <boost/math/special_functions/gamma.hpp>\n#include <boost/test/test_exec_monitor.hpp>\n#include <boost/test/results_collector.hpp>\n#include <boost/test/unit_test.hpp>\n#include <boost/test/floating_point_comparison.hpp>\n#include <boost/math/tools/stats.hpp>\n#include <boost/math/tools/test.hpp>\n#include <boost/math/constants/constants.hpp>\n#include <boost/type_traits/is_floating_point.hpp>\n#include <boost/array.hpp>\n#include \"functor.hpp\"\n\n#include \"test_gamma_hooks.hpp\"\n#include \"handle_test_result.hpp\"\n\n#if !defined(TEST_FLOAT) && !defined(TEST_DOUBLE) && !defined(TEST_LDOUBLE) && !defined(TEST_REAL_CONCEPT)\n#  define TEST_FLOAT\n#  define TEST_DOUBLE\n#  define TEST_LDOUBLE\n#  define TEST_REAL_CONCEPT\n#endif\n\n//\n// DESCRIPTION:\n// ~~~~~~~~~~~~\n//\n// This file tests the incomplete gamma function inverses \n// gamma_p_inv and gamma_q_inv. There are three sets of tests:\n// 1) Spot tests which compare our results with selected values \n// computed using the online special function calculator at \n// functions.wolfram.com, \n// 2) Accuracy tests use values generated with NTL::RR at \n// 1000-bit precision and our generic versions of these functions.\n// 3) Round trip sanity checks, use the test data for the forward\n// functions, and verify that we can get (approximately) back\n// where we started.\n//\n// Note that when this file is first run on a new platform many of\n// these tests will fail: the default accuracy is 1 epsilon which\n// is too tight for most platforms.  In this situation you will \n// need to cast a human eye over the error rates reported and make\n// a judgement as to whether they are acceptable.  Either way please\n// report the results to the Boost mailing list.  Acceptable rates of\n// error are marked up below as a series of regular expressions that\n// identify the compiler/stdlib/platform/data-type/test-data/test-function\n// along with the maximum expected peek and RMS mean errors for that\n// test.\n//\n\nvoid expected_results()\n{\n   //\n   // Define the max and mean errors expected for\n   // various compilers and platforms.\n   //\n   const char* largest_type;\n#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS\n   if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())\n   {\n      largest_type = \"(long\\\\s+)?double\";\n   }\n   else\n   {\n      largest_type = \"long double\";\n   }\n#else\n   largest_type = \"(long\\\\s+)?double\";\n#endif\n   //\n   // Large exponent range causes more extreme test cases to be evaluated:\n   //\n   if(std::numeric_limits<long double>::max_exponent > std::numeric_limits<double>::max_exponent)\n   {\n      add_expected_result(\n         \"[^|]*\",                          // compiler\n         \"[^|]*\",                          // stdlib\n         \"[^|]*\",                          // platform\n         largest_type,                     // test type(s)\n         \"[^|]*small[^|]*\",                    // test data group\n         \"[^|]*\", 200000, 10000);              // test function\n      add_expected_result(\n         \"[^|]*\",                          // compiler\n         \"[^|]*\",                          // stdlib\n         \"[^|]*\",                          // platform\n         \"real_concept\",                     // test type(s)\n         \"[^|]*small[^|]*\",                   // test data group\n         \"[^|]*\", 70000, 8000);                  // test function\n   }\n   //\n   // These high error rates are seen on on some Linux\n   // architectures:\n   //\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"linux.*\",                          // platform\n      largest_type,                     // test type(s)\n      \"[^|]*medium[^|]*\",                   // test data group\n      \"[^|]*\", 350, 5);                  // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"linux.*\",                          // platform\n      largest_type,                     // test type(s)\n      \"[^|]*large[^|]*\",                   // test data group\n      \"[^|]*\", 150, 5);                  // test function\n\n\n   //\n   // Catch all cases come last:\n   //\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      largest_type,                     // test type(s)\n      \"[^|]*medium[^|]*\",                   // test data group\n      \"[^|]*\", 20, 5);                  // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      largest_type,                     // test type(s)\n      \"[^|]*large[^|]*\",                    // test data group\n      \"[^|]*\", 5, 2);                   // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      largest_type,                     // test type(s)\n      \"[^|]*small[^|]*\",                    // test data group\n      \"[^|]*\", 2100, 500);              // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      \"float|double\",                   // test type(s)\n      \"[^|]*small[^|]*\",                    // test data group\n      \"boost::math::gamma_p_inv\", 500, 60);   // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      \"float|double\",                   // test type(s)\n      \"[^|]*\",                          // test data group\n      \"boost::math::gamma_q_inv\", 350, 60);   // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      \"float|double\",                   // test type(s)\n      \"[^|]*\",                          // test data group\n      \"[^|]*\", 4, 2);                   // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      \"real_concept\",                     // test type(s)\n      \"[^|]*medium[^|]*\",                   // test data group\n      \"[^|]*\", 20, 5);                  // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      \"real_concept\",                     // test type(s)\n      \"[^|]*large[^|]*\",                   // test data group\n      \"[^|]*\", 1000, 500);                  // test function\n   add_expected_result(\n      \"[^|]*\",                          // compiler\n      \"[^|]*\",                          // stdlib\n      \"[^|]*\",                          // platform\n      \"real_concept\",                     // test type(s)\n      \"[^|]*small[^|]*\",                   // test data group\n      \"[^|]*\", 3700, 500);                  // test function\n\n   //\n   // Finish off by printing out the compiler/stdlib/platform names,\n   // we do this to make it easier to mark up expected error rates.\n   //\n   std::cout << \"Tests run with \" << BOOST_COMPILER << \", \" \n      << BOOST_STDLIB << \", \" << BOOST_PLATFORM << std::endl;\n}\n\n#define BOOST_CHECK_CLOSE_EX(a, b, prec, i) \\\n   {\\\n      unsigned int failures = boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed;\\\n      BOOST_CHECK_CLOSE(a, b, prec); \\\n      if(failures != boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed)\\\n      {\\\n         std::cerr << \"Failure was at row \" << i << std::endl;\\\n         std::cerr << std::setprecision(35); \\\n         std::cerr << \"{ \" << data[i][0] << \" , \" << data[i][1] << \" , \" << data[i][2];\\\n         std::cerr << \" , \" << data[i][3] << \" , \" << data[i][4] << \" , \" << data[i][5] << \" } \" << std::endl;\\\n      }\\\n   }\n\ntemplate <class T>\nvoid do_test_gamma_2(const T& data, const char* type_name, const char* test_name)\n{\n   //\n   // test gamma_p_inv(T, T) against data:\n   //\n   using namespace std;\n   typedef typename T::value_type row_type;\n   typedef typename row_type::value_type value_type;\n\n   std::cout << test_name << \" with type \" << type_name << std::endl;\n\n   //\n   // These sanity checks test for a round trip accuracy of one half\n   // of the bits in T, unless T is type float, in which case we check\n   // for just one decimal digit.  The problem here is the sensitivity\n   // of the functions, not their accuracy.  This test data was generated\n   // for the forward functions, which means that when it is used as\n   // the input to the inverses then it is necessarily inexact.  This rounding\n   // of the input is what makes the data unsuitable for use as an accuracy check,\n   // and also demonstrates that you can't in general round-trip these functions.\n   // It is however a useful sanity check.\n   //\n   value_type precision = static_cast<value_type>(ldexp(1.0, 1-boost::math::policies::digits<value_type, boost::math::policies::policy<> >()/2)) * 100;\n   if(boost::math::policies::digits<value_type, boost::math::policies::policy<> >() < 50)\n      precision = 1;   // 1% or two decimal digits, all we can hope for when the input is truncated to float\n\n   for(unsigned i = 0; i < data.size(); ++i)\n   {\n      //\n      // These inverse tests are thrown off if the output of the\n      // incomplete gamma is too close to 1: basically there is insuffient\n      // information left in the value we're using as input to the inverse\n      // to be able to get back to the original value.\n      //\n      if(data[i][5] == 0)\n         BOOST_CHECK_EQUAL(boost::math::gamma_p_inv(data[i][0], data[i][5]), value_type(0));\n      else if((1 - data[i][5] > 0.001) \n         && (fabs(data[i][5]) > 2 * boost::math::tools::min_value<value_type>()) \n         && (fabs(data[i][5]) > 2 * boost::math::tools::min_value<double>()))\n      {\n         value_type inv = boost::math::gamma_p_inv(data[i][0], data[i][5]);\n         BOOST_CHECK_CLOSE_EX(data[i][1], inv, precision, i);\n      }\n      else if(1 == data[i][5])\n         BOOST_CHECK_EQUAL(boost::math::gamma_p_inv(data[i][0], data[i][5]), boost::math::tools::max_value<value_type>());\n      else\n      {\n         // not enough bits in our input to get back to x, but we should be in\n         // the same ball park:\n         value_type inv = boost::math::gamma_p_inv(data[i][0], data[i][5]);\n         BOOST_CHECK_CLOSE_EX(data[i][1], inv, 100000, i);\n      }\n\n      if(data[i][3] == 0)\n         BOOST_CHECK_EQUAL(boost::math::gamma_q_inv(data[i][0], data[i][3]), boost::math::tools::max_value<value_type>());\n      else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) > 2 * boost::math::tools::min_value<value_type>()))\n      {\n         value_type inv = boost::math::gamma_q_inv(data[i][0], data[i][3]);\n         BOOST_CHECK_CLOSE_EX(data[i][1], inv, precision, i);\n      }\n      else if(1 == data[i][3])\n         BOOST_CHECK_EQUAL(boost::math::gamma_q_inv(data[i][0], data[i][3]), value_type(0));\n      else if(fabs(data[i][3]) > 2 * boost::math::tools::min_value<value_type>())\n      {\n         // not enough bits in our input to get back to x, but we should be in\n         // the same ball park:\n         value_type inv = boost::math::gamma_q_inv(data[i][0], data[i][3]);\n         BOOST_CHECK_CLOSE_EX(data[i][1], inv, 100, i);\n      }\n   }\n   std::cout << std::endl;\n}\n\ntemplate <class T>\nvoid do_test_gamma_inv(const T& data, const char* type_name, const char* test_name)\n{\n   typedef typename T::value_type row_type;\n   typedef typename row_type::value_type value_type;\n\n   typedef value_type (*pg)(value_type, value_type);\n#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)\n   pg funcp = boost::math::gamma_p_inv<value_type, value_type>;\n#else\n   pg funcp = boost::math::gamma_p_inv;\n#endif\n\n   boost::math::tools::test_result<value_type> result;\n\n   std::cout << \"Testing \" << test_name << \" with type \" << type_name\n      << \"\\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n\";\n\n   //\n   // test gamma_p_inv(T, T) against data:\n   //\n   result = boost::math::tools::test(\n      data,\n      bind_func(funcp, 0, 1),\n      extract_result(2));\n   handle_test_result(result, data[result.worst()], result.worst(), type_name, \"boost::math::gamma_p_inv\", test_name);\n   //\n   // test gamma_q_inv(T, T) against data:\n   //\n#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)\n   funcp = boost::math::gamma_q_inv<value_type, value_type>;\n#else\n   funcp = boost::math::gamma_q_inv;\n#endif\n   result = boost::math::tools::test(\n      data,\n      bind_func(funcp, 0, 1),\n      extract_result(3));\n   handle_test_result(result, data[result.worst()], result.worst(), type_name, \"boost::math::gamma_q_inv\", test_name);\n}\n\ntemplate <class T>\nvoid test_gamma(T, const char* name)\n{\n   //\n   // The actual test data is rather verbose, so it's in a separate file\n   //\n   // First the data for the incomplete gamma function, each\n   // row has the following 6 entries:\n   // Parameter a, parameter z,\n   // Expected tgamma(a, z), Expected gamma_q(a, z)\n   // Expected tgamma_lower(a, z), Expected gamma_p(a, z)\n   //\n#  include \"igamma_med_data.ipp\"\n\n   do_test_gamma_2(igamma_med_data, name, \"Running round trip sanity checks on incomplete gamma medium sized values\");\n\n#  include \"igamma_small_data.ipp\"\n\n   do_test_gamma_2(igamma_small_data, name, \"Running round trip sanity checks on incomplete gamma small values\");\n\n#  include \"igamma_big_data.ipp\"\n\n   do_test_gamma_2(igamma_big_data, name, \"Running round trip sanity checks on incomplete gamma large values\");\n\n#  include \"gamma_inv_data.ipp\"\n\n   do_test_gamma_inv(gamma_inv_data, name, \"incomplete gamma inverse(a, z) medium values\");\n\n#  include \"gamma_inv_big_data.ipp\"\n\n   do_test_gamma_inv(gamma_inv_big_data, name, \"incomplete gamma inverse(a, z) large values\");\n\n#  include \"gamma_inv_small_data.ipp\"\n\n   do_test_gamma_inv(gamma_inv_small_data, name, \"incomplete gamma inverse(a, z) small values\");\n}\n\ntemplate <class T>\nvoid test_spots(T, const char* type_name)\n{\n   std::cout << \"Running spot checks for type \" << type_name << std::endl;\n   //\n   // basic sanity checks, tolerance is 150 epsilon expressed as a percentage:\n   //\n   T tolerance = boost::math::tools::epsilon<T>() * 15000;\n   if(tolerance < 1e-25f)\n      tolerance = 1e-25f;  // limit of test data?\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(1)/100, static_cast<T>(1.0/128)), static_cast<T>(0.35767144525455121503672919307647515332256996883787L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(1)/100, static_cast<T>(0.5)), static_cast<T>(4.4655350189103486773248562646452806745879516124613e-31L), tolerance*10);\n   //\n   // We can't test in this region against Mathworld's data as the results produced\n   // by functions.wolfram.com appear to be in error, and do *not* round trip with\n   // their own version of gamma_q.  Using our output from the inverse as input to \n   // their version of gamma_q *does* round trip however.  It should be pointed out\n   // that the functions in this area are very sensitive with nearly infinite\n   // first derivatives, it's also questionable how useful these functions are\n   // in this part of the domain.\n   //\n   //BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(1e-2), static_cast<T>(1.0-1.0/128)), static_cast<T>(3.8106736649978161389878528903698068142257930575497e-181L), tolerance);\n   //\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(0.5), static_cast<T>(1.0/128)), static_cast<T>(3.5379794687984498627918583429482809311448951189097L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(0.5), static_cast<T>(1.0/2)), static_cast<T>(0.22746821155978637597125832348982469815821055329511L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(0.5), static_cast<T>(1.0-1.0/128)), static_cast<T>(0.000047938431649305382237483273209405461203600840052182L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(10), static_cast<T>(1.0/128)), static_cast<T>(19.221865946801723949866005318845155649972164294057L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(10), static_cast<T>(1.0/2)), static_cast<T>(9.6687146147141311517500637401166726067778162022664L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(10), static_cast<T>(1.0-1.0/128)), static_cast<T>(3.9754602513640844712089002210120603689809432130520L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(10000), static_cast<T>(1.0/128)), static_cast<T>(10243.369973939134157953734588122880006091919872879L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(10000), static_cast<T>(1.0/2)), static_cast<T>(9999.6666686420474237369661574633153551436435884101L), tolerance);\n   BOOST_CHECK_CLOSE(::boost::math::gamma_q_inv(static_cast<T>(10000), static_cast<T>(1.0-1.0/128)), static_cast<T>(9759.8597223369324083191194574874497413261589080204L), tolerance);\n}\n\nint test_main(int, char* [])\n{\n   expected_results();\n   BOOST_MATH_CONTROL_FP;\n\n#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS\n#ifdef TEST_FLOAT\n   test_spots(0.0F, \"float\");\n#endif\n#endif\n#ifdef TEST_DOUBLE\n   test_spots(0.0, \"double\");\n#endif\n#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS\n#ifdef TEST_LDOUBLE\n   test_spots(0.0L, \"long double\");\n#endif\n#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))\n#ifdef TEST_REAL_CONCEPT\n   test_spots(boost::math::concepts::real_concept(0.1), \"real_concept\");\n#endif\n#endif\n#endif\n\n#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS\n#ifdef TEST_FLOAT\n   test_gamma(0.1F, \"float\");\n#endif\n#endif\n#ifdef TEST_DOUBLE\n   test_gamma(0.1, \"double\");\n#endif\n#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS\n#ifdef TEST_LDOUBLE\n   test_gamma(0.1L, \"long double\");\n#endif\n#ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS\n#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))\n#ifdef TEST_REAL_CONCEPT\n   test_gamma(boost::math::concepts::real_concept(0.1), \"real_concept\");\n#endif\n#endif\n#endif\n#else\n   std::cout << \"<note>The long double tests have been disabled on this platform \"\n      \"either because the long double overloads of the usual math functions are \"\n      \"not available at all, or because they are too inaccurate for these tests \"\n      \"to pass.</note>\" << std::cout;\n#endif\n   return 0;\n}\n\n\n\n", "meta": {"hexsha": "8123694796349960dac3b2f7c1fa9dff75aefdcb", "size": 19311, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/math/test/test_igamma_inv.cpp", "max_stars_repo_name": "coxlab/boost_patched_for_objcplusplus", "max_stars_repo_head_hexsha": "5316cd54bbd03994ae785185efcde62b57fd5e93", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-08-22T17:17:41.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-22T17:17:41.000Z", "max_issues_repo_path": "external/boost/libs/math/test/test_igamma_inv.cpp", "max_issues_repo_name": "dchandran/evolvenetworks", "max_issues_repo_head_hexsha": "072f9e1292552f691a86457ffd16a5743724fb5e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "external/boost/libs/math/test/test_igamma_inv.cpp", "max_forks_repo_name": "dchandran/evolvenetworks", "max_forks_repo_head_hexsha": "072f9e1292552f691a86457ffd16a5743724fb5e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-03-07T05:20:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-07T05:20:43.000Z", "avg_line_length": 43.395505618, "max_line_length": 188, "alphanum_fraction": 0.5928745275, "num_tokens": 5021, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48438008427698437, "lm_q2_score": 0.18476750391438243, "lm_q1q2_score": 0.0894976991176966}}
{"text": "// Test for sorting procedures in sort.h\r\n\r\n#define CATCH_CONFIG_MAIN\r\n#include <test/catch.hpp>\r\n\r\n// File to test\r\n#include <alglib/sort/sort.h>\r\n\r\n#include <vector>\r\n\r\nusing namespace alglib::sort;\r\n\r\n/* All the sorting procedures are differentially tested against\r\n * the std::sort function. The following cases are tested for \r\n * each sorting function:\r\n * \t1. Empty containers\r\n *  2. Randomly filled containers\r\n *  3. Several different types - float, strings\r\n *  4. Invalid inputs - non-containers, non-iterable\r\n *  5. For each valid iterator category.  \r\n */\r\n\r\ntemplate<typename Container>\r\nContainer random_int_list (int sz)\r\n{\r\n\tContainer C;\r\n\tauto it = std::back_inserter (C);\r\n\r\n\t/* fill up the container */\r\n\tsrand (time (0));\r\n\tstd::generate_n (it, sz, rand);\r\n\r\n\treturn C;\r\n}\r\n\r\n\r\n/* A test is performed as follows:\r\n * \t1. Create two identical containers filled randomly.\r\n *  2. Sort one of them - call it std_sorted - using std::sort.\r\n *  3. Sort the other, test_sorted, using the procedure under test.\r\n *  4. Assert their equality.\r\n */\r\n\r\nTEST_CASE (\"Merge sort\", \"[merge_sort]\")\r\n{\r\n\tstd::vector<int> test_sorted, std_sorted;\r\n\r\n\tstd::vector<int> sizes = {0, 1000, 1000000};\r\n\r\n\tfor (int size : sizes)\r\n    {\r\n\t\ttest_sorted = std_sorted = std::move(random_int_list<decltype(std_sorted)> (size));\r\n\r\n\t\tmerge_sort (test_sorted.begin(), test_sorted.end());\r\n\t\tstd::sort (std_sorted.begin(), std_sorted.end());\r\n\r\n\t\tREQUIRE (test_sorted == std_sorted);\r\n\t}\r\n\r\n    // const_iterators are invalid.\r\n    // REQUIRE_THROWS (merge_sort (test_sorted.cbegin (), test_sorted.cend ()));\r\n    \r\n    // Check if it works for non-random access iterators.\r\n}\r\n\r\n\r\n\r\n\r\n\r\n", "meta": {"hexsha": "f32a1cd5a4a16b55211e5124d6dfdb00679447ba", "size": 1681, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/sort/merge_sort.cpp", "max_stars_repo_name": "divkakwani/alglib", "max_stars_repo_head_hexsha": "464441c26ff802e0c7eb58106201c840dc37047b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2015-01-26T13:37:52.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-02T12:30:03.000Z", "max_issues_repo_path": "test/sort/merge_sort.cpp", "max_issues_repo_name": "divkakwani/alglib", "max_issues_repo_head_hexsha": "464441c26ff802e0c7eb58106201c840dc37047b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/sort/merge_sort.cpp", "max_forks_repo_name": "divkakwani/alglib", "max_forks_repo_head_hexsha": "464441c26ff802e0c7eb58106201c840dc37047b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2.0, "max_forks_repo_forks_event_min_datetime": "2020-04-21T14:07:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T10:30:28.000Z", "avg_line_length": 24.0142857143, "max_line_length": 86, "alphanum_fraction": 0.6668649613, "num_tokens": 415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.1778108760134381, "lm_q1q2_score": 0.08890543800671905}}
{"text": "/**\n * @file newproblem_test.cc\n * @brief NPDE homework NewProblem code\n * @author Oliver Rietmann, Erick Schulz\n * @date 01.01.2020\n * @copyright Developed at ETH Zurich\n */\n\n#include <Eigen/Core>\n\n#include <gtest/gtest.h>\n\n#include \"../newproblem.h\"\n\nnamespace NewProblem::test {\n\nTEST(NewProblem, dummyFunction) {\n  double x = 0.0;\n  int n = 0;\n\n  Eigen::Vector2d v = NewProblem::dummyFunction(x, n);\n\n  Eigen::Vector2d v_ref = {1.0, 1.0};\n\n  double tol = 1.0e-8;\n  ASSERT_NEAR(0.0, (v - v_ref).lpNorm<Eigen::Infinity>(), tol);\n}\n\n}  // namespace NewProblem::test\n", "meta": {"hexsha": "11750589694d5ca063bf64becb2391ba342e6789", "size": 567, "ext": "cc", "lang": "C++", "max_stars_repo_path": "scripts/NewProblem/mastersolution/test/newproblem_test.cc", "max_stars_repo_name": "padomu/NPDECODES", "max_stars_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15.0, "max_stars_repo_stars_event_min_datetime": "2019-04-29T11:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T05:10:58.000Z", "max_issues_repo_path": "scripts/NewProblem/mastersolution/test/newproblem_test.cc", "max_issues_repo_name": "padomu/NPDECODES", "max_issues_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12.0, "max_issues_repo_issues_event_min_datetime": "2020-02-29T15:05:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T13:51:07.000Z", "max_forks_repo_path": "scripts/NewProblem/mastersolution/test/newproblem_test.cc", "max_forks_repo_name": "padomu/NPDECODES", "max_forks_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 26.0, "max_forks_repo_forks_event_min_datetime": "2020-01-09T15:59:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T16:27:33.000Z", "avg_line_length": 18.9, "max_line_length": 63, "alphanum_fraction": 0.6666666667, "num_tokens": 179, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.4843800842769843, "lm_q2_score": 0.18242552158390105, "lm_q1q2_score": 0.08836328951908282}}
{"text": "//------------------------------------------------------------------------------\n/// \\file Max_tests.cpp\n/// \\ref Vandevoorde, Josuttis, Gregor. C++ Templates: The Complete Guide. 2nd\n/// Ed. Addison-Wesley Professional. 2017.\n//------------------------------------------------------------------------------\n#include \"Cpp/Templates/FunctionT/Max.h\"\n\n#include <boost/test/unit_test.hpp>\n#include <complex>\n#include <string>\n\nusing Cpp::Templates::FunctionTemplates::max;\nusing Cpp::Templates::FunctionTemplates::max_with_const;\n\nBOOST_AUTO_TEST_SUITE(Cpp)\nBOOST_AUTO_TEST_SUITE(Templates)\nBOOST_AUTO_TEST_SUITE(FunctionTemplates)\nBOOST_AUTO_TEST_SUITE(Max_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateMax)\n{\n\t{\n\t\t// Works for ints\n\t\tconst int a {4};\n\t\tconst int b {5};\n\t\tBOOST_TEST(::max(a, b) == b);\n\t}\n}\n\n// cf. VJG (2017), pp. 4, 1.1.2 Using the Template\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ShowHowToUseMax)\n{\n  constexpr int i {42};\n\n  // Note that each call of max() template qualified with ::. This is to ensure\n  // that our max() template is found in the global namespace. There is also a\n  // std::max() template in standard library.\n  BOOST_TEST(::max(7, i) == i);\n\n  constexpr double f1 {3.4};\n  constexpr double f2 {-6.7};\n\n  BOOST_TEST(::max(f1, f2) == f1);\n\n  const std::string s1 {\"mathematics\"};\n  const std::string s2 {\"math\"};\n\n  // The process of replacing template parameters by concrete types is called\n  // instantiation. It results in an instance of a template.\n  BOOST_TEST(::max(s1, s2) == s1);\n\n  // Templates aren't compiled into single entities that can handle any type.\n  // Instead, different entities are generated from template for every type for\n  // which template is used. Thus, max() compiled for each of these 3 types.\n}\n\n// void is a valid template argument.\ntemplate <typename T>\nT foo(T*)\n{  \n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(VoidIsAValidTemplateArgument)\n{\n  void* vp = nullptr;\n\n  foo(vp); // OK: deduces void foo(void*)\n\n  BOOST_TEST(true);\n}\n\n// cf. pp. 6, 1.1.3 Two-Phase Translation, VJG (2017)\n// An attempt to instantiate a template for type that doesn't support all the\n// operations used within it will result in compile-time error.\n\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(InstantiateWithTypeThatDoesNotSupportAllOperations)\n{\n  std::complex<float> c1, c2;\n  c1 = {3.0, -5.0};\n  c2 = {42.0, -69.0};\n\n  //::max(c1, c2); // ERROR at compile time.\n\n  BOOST_TEST(true);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TemplateArgumentDeducedAsPartOfConstReferenceType)\n{\n  std::complex<float> c1, c2;\n  c1 = {3.0, -5.0};\n  c2 = {42.0, -69.0};\n\n  //::max(c1, c2); // ERROR at compile time.\n\n  BOOST_TEST(true);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TypeConversionsDuringTypeDeductionByValueDecay)\n{\n  constexpr int c {42};\n  int i {64};\n  BOOST_TEST_REQUIRE(max(i, c) == i); // OK: T is deduced as int\n  BOOST_TEST_REQUIRE(max(i, c) == i); // OK: T is deduced as int\n\n  int& ir {i};\n  BOOST_TEST_REQUIRE(max(i, ir) == i); // OK: T is deduced as int\n  //int arr[4];\n  //BOOST_TEST(max(&i, arr) == &i);\n\n  // ERROR: T can be deduced as int or double.\n  //max(4, 7.2);\n\n  std::string s;\n\n  // ERROR: T can be deduced as char const[6] or std::string\n  //max(\"hello\", s);\n\n  // 3 ways to handle such errors:\n\n  // 1. Cast the arguments so that they both match:\n  BOOST_TEST(max(static_cast<double>(4), 7.2) == 7.2); // OK\n\n  // 2. Specify (or qualify) explicitly the type of T to prevent from attempting\n  // type deduction:\n  BOOST_TEST(max<double>(4, 7.2) == 7.2);\n\n  // 3. Specify that parameters may have different types.\n  \n  BOOST_TEST(true);\n}\n\ntemplate <typename T>\nvoid f(T =\"\")\n{\n  return;\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TypeDeductionForDefaultArguments)\n{\n  f(1); // OK: deduced T to be int, so that it calls f<int>(1)\n  //  error: no matching function for call to \u2018f()\u2019\n  //f(); // ERROR: cannot deduce T\n  BOOST_TEST(true);\n}\n\n// Declare argument for the template parameter.\ntemplate <typename T = std::string>\nvoid f1(T =\"\")\n{\n  return;\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TypeDeductionForDefaultTemplateArgument)\n{\n  f1(); // OK\n  BOOST_TEST(true);\n}\n\n// pp. 15, Sec. 1.5 Overloaindg Function Templates\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(OverloadingFunctionTemplates)\n{\n  BOOST_TEST(max(7, 42) == 42); // calls nontemplate for 2 ints.\n  BOOST_TEST(max(7.0, 42.0) == 42.0); // call max <double> (by argument\n    //deduction)\n  BOOST_TEST(max('a', 'b') == 'b'); // calls max<char> (by argument deduction)\n  BOOST_TEST(max<>(7, 42) == 42); // call max<int> (by argument deduction)\n  BOOST_TEST(max<double>(7, 42) == 42.0); // calls max<double> (no argument\n  // deduction)\n  BOOST_TEST(max('a', 42.7) == 97); // call the nontemplate for two ints \n}\n\n\nBOOST_AUTO_TEST_SUITE_END() // Max_tests\n\nBOOST_AUTO_TEST_SUITE_END() // FunctionTemplates\nBOOST_AUTO_TEST_SUITE_END() // Templates\nBOOST_AUTO_TEST_SUITE_END() // Cpp", "meta": {"hexsha": "4c4147037ea38b17012494bb93b2a8fdce8a795c", "size": 6209, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Cpp/Templates/FunctionT/Max_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Cpp/Templates/FunctionT/Max_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Cpp/Templates/FunctionT/Max_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.6785714286, "max_line_length": 80, "alphanum_fraction": 0.5073280722, "num_tokens": 1388, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4416730056646256, "lm_q2_score": 0.19930799552605397, "lm_q1q2_score": 0.08802896143698401}}
{"text": "/* $Id: step-15.cc 27656 2012-11-21 13:12:20Z bangerth $ */\n/* Author: Sven Wetterauer, University of Heidelberg, 2012 */\n\n/*    $Id: step-15.cc 27656 2012-11-21 13:12:20Z bangerth $       */\n/*                                                                */\n/*    Copyright (C) 2012 by the deal.II authors */\n/*                                                                */\n/*    This file is subject to QPL and may not be  distributed     */\n/*    without copyright and license information. Please refer     */\n/*    to the file deal.II/doc/license.html for the  text  and     */\n/*    further information on this license.                        */\n\n// @sect3{Include files}\n\n// The first few files have already been covered in previous examples and will\n// thus not be further commented on.\n#include <deal.II/base/quadrature_lib.h>\n#include <deal.II/base/function.h>\n#include <deal.II/base/logstream.h>\n#include <deal.II/base/utilities.h>\n\n#include <deal.II/lac/vector.h>\n#include <deal.II/lac/full_matrix.h>\n#include <deal.II/lac/sparse_matrix.h>\n#include <deal.II/lac/compressed_sparsity_pattern.h>\n#include <deal.II/lac/solver_cg.h>\n#include <deal.II/lac/precondition.h>\n#include <deal.II/lac/constraint_matrix.h>\n\n#include <deal.II/grid/tria.h>\n#include <deal.II/grid/grid_generator.h>\n#include <deal.II/grid/tria_accessor.h>\n#include <deal.II/grid/tria_iterator.h>\n#include <deal.II/grid/tria_boundary_lib.h>\n#include <deal.II/grid/grid_refinement.h>\n\n#include <deal.II/dofs/dof_handler.h>\n#include <deal.II/dofs/dof_accessor.h>\n#include <deal.II/dofs/dof_tools.h>\n\n#include <deal.II/fe/fe_values.h>\n#include <deal.II/fe/fe_q.h>\n\n#include <deal.II/numerics/vector_tools.h>\n#include <deal.II/numerics/matrix_tools.h>\n#include <deal.II/numerics/data_out.h>\n#include <deal.II/numerics/error_estimator.h>\n\n\n#include <fstream>\n#include <iostream>\n\n// We will use adaptive mesh refinement between Newton interations. To do so,\n// we need to be able to work with a solution on the new mesh, although it was\n// computed on the old one. The SolutionTransfer class transfers the solution\n// from the old to the new mesh:\n\n#include <deal.II/numerics/solution_transfer.h>\n\n// We then open a namepsace for this program and import everything from the\n// dealii namespace into it, as in previous programs:\nnamespace Step15\n{\n  using namespace dealii;\n\n\n  // @sect3{The <code>MinimalSurfaceProblem</code> class template}\n\n  // The class template is basically the same as in step-6.  Three additions\n  // are made:\n  // - There are two solution vectors, one for the Newton update\n  //   $\\delta u^n$, and one for the current iterate $u^n$.\n  // - The <code>setup_system</code> function takes an argument that denotes whether\n  //   this is the first time it is called or not. The difference is that the\n  //   first time around we need to distributed degrees of freedom and set the\n  //   solution vector for $u^n$ to the correct size. The following times, the\n  //   function is called after we have already done these steps as part of\n  //   refining the mesh in <code>refine_mesh</code>.\n  // - We then also need new functions: <code>set_boundary_values()</code>\n  //   takes care of setting the boundary values on the solution vector\n  //   correctly, as discussed at the end of the\n  //   introduction. <code>compute_residual()</code> is a function that computes\n  //   the norm of the nonlinear (discrete) residual. We use this function to\n  //   monitor convergence of the Newton iteration. The function takes a step\n  //   length $\\alpha^n$ as argument to compute the residual of $u^n + \\alpha^n\n  //   \\; \\delta u^n$. This is something one typically needs for step length\n  //   control, although we will not use this feature here. Finally,\n  //   <code>determine_step_length()</code> computes the step length $\\alpha^n$\n  //   in each Newton iteration. As discussed in the introduction, we here use a\n  //   fixed step length and leave implementing a better strategy as an\n  //   exercise.\n\n  template <int dim>\n  class MinimalSurfaceProblem\n  {\n  public:\n    MinimalSurfaceProblem ();\n    ~MinimalSurfaceProblem ();\n\n    void run ();\n\n  private:\n    void setup_system (const bool initial_step);\n    void assemble_system ();\n    void solve ();\n    void refine_mesh ();\n    void set_boundary_values ();\n    double compute_residual (const double alpha) const;\n    double determine_step_length () const;\n\n    Triangulation<dim>   triangulation;\n\n    DoFHandler<dim>      dof_handler;\n    FE_Q<dim>            fe;\n\n    ConstraintMatrix     hanging_node_constraints;\n\n    SparsityPattern      sparsity_pattern;\n    SparseMatrix<double> system_matrix;\n\n    Vector<double>       present_solution;\n    Vector<double>       newton_update;\n    Vector<double>       system_rhs;\n  };\n\n  // @sect3{Boundary condition}\n\n  // The boundary condition is implemented just like in step-4.  It is chosen\n  // as $g(x,y)=\\sin(2 \\pi (x+y))$:\n\n  template <int dim>\n  class BoundaryValues : public Function<dim>\n  {\n  public:\n    BoundaryValues () : Function<dim>() {}\n\n    virtual double value (const Point<dim>   &p,\n                          const unsigned int  component = 0) const;\n  };\n\n\n  template <int dim>\n  double BoundaryValues<dim>::value (const Point<dim> &p,\n                                     const unsigned int /*component*/) const\n  {\n    return std::sin(2 * numbers::PI * (p[0]+p[1]));\n  }\n\n  // @sect3{The <code>MinimalSurfaceProblem</code> class implementation}\n\n  // @sect4{MinimalSurfaceProblem::MinimalSurfaceProblem}\n\n  // The constructor and destructor of the class are the same as in the first\n  // few tutorials.\n\n  template <int dim>\n  MinimalSurfaceProblem<dim>::MinimalSurfaceProblem ()\n    :\n    dof_handler (triangulation),\n    fe (2)\n  {}\n\n\n\n  template <int dim>\n  MinimalSurfaceProblem<dim>::~MinimalSurfaceProblem ()\n  {\n    dof_handler.clear ();\n  }\n\n  // @sect4{MinimalSurfaceProblem::setup_system}\n\n  // As always in the setup-system function, we setup the variables of the\n  // finite element method. There are same differences to step-6, because\n  // there we start solving the PDE from scratch in every refinement cycle\n  // whereas here we need to take the solution from the previous mesh onto the\n  // current mesh. Consequently, we can't just reset solution vectors. The\n  // argument passed to this function thus indicates whether we can\n  // distributed degrees of freedom (plus compute constraints) and set the\n  // solution vector to zero or whether this has happened elsewhere already\n  // (specifically, in <code>refine_mesh()</code>).\n\n  template <int dim>\n  void MinimalSurfaceProblem<dim>::setup_system (const bool initial_step)\n  {\n    if (initial_step)\n      {\n        dof_handler.distribute_dofs (fe);\n        present_solution.reinit (dof_handler.n_dofs());\n\n        hanging_node_constraints.clear ();\n        DoFTools::make_hanging_node_constraints (dof_handler,\n                                                 hanging_node_constraints);\n        hanging_node_constraints.close ();\n      }\n\n\n    // The remaining parts of the function are the same as in step-6.\n\n    newton_update.reinit (dof_handler.n_dofs());\n    system_rhs.reinit (dof_handler.n_dofs());\n\n    CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());\n    DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);\n\n    hanging_node_constraints.condense (c_sparsity);\n\n    sparsity_pattern.copy_from(c_sparsity);\n    system_matrix.reinit (sparsity_pattern);\n  }\n\n  // @sect4{MinimalSurfaceProblem::assemble_system}\n\n  // This function does the same as in the previous tutorials except that now,\n  // of course, the matrix and right hand side functions depend on the\n  // previous iteration's solution. As discussed in the introduction, we need\n  // to use zero boundary values for the Newton updates; we compute them at\n  // the end of this function.\n  //\n  // The top of the function contains the usual boilerplate code, setting up\n  // the objects that allow us to evaluate shape functions at quadrature\n  // points and temporary storage locations for the local matrices and\n  // vectors, as well as for the gradients of the previous solution at the\n  // quadrature points. We then start the loop over all cells:\n  template <int dim>\n  void MinimalSurfaceProblem<dim>::assemble_system ()\n  {\n    const QGauss<dim>  quadrature_formula(3);\n\n    system_matrix = 0;\n    system_rhs = 0;\n\n    FEValues<dim> fe_values (fe, quadrature_formula,\n                             update_gradients         |\n                             update_quadrature_points |\n                             update_JxW_values);\n\n    const unsigned int           dofs_per_cell = fe.dofs_per_cell;\n    const unsigned int           n_q_points    = quadrature_formula.size();\n\n    FullMatrix<double>           cell_matrix (dofs_per_cell, dofs_per_cell);\n    Vector<double>               cell_rhs (dofs_per_cell);\n\n    std::vector<Tensor<1, dim> > old_solution_gradients(n_q_points);\n\n    std::vector<unsigned int>    local_dof_indices (dofs_per_cell);\n\n    typename DoFHandler<dim>::active_cell_iterator\n    cell = dof_handler.begin_active(),\n    endc = dof_handler.end();\n    for (; cell!=endc; ++cell)\n      {\n        cell_matrix = 0;\n        cell_rhs = 0;\n\n        fe_values.reinit (cell);\n\n        // For the assembly of the linear system, we have to obtain the values\n        // of the previous solution's gradients at the quadrature\n        // points. There is a standard way of doing this: the\n        // FEValues::get_function function takes a vector that represents a\n        // finite element field defined on a DoFHandler, and evaluates the\n        // gradients of this field at the quadrature points of the cell with\n        // which the FEValues object has last been reinitialized. The values\n        // of the gradients at all quadrature points are then written into the\n        // second argument:\n        fe_values.get_function_gradients(present_solution,\n                                         old_solution_gradients);\n\n        // With this, we can then do the integration loop over all quadrature\n        // points and shape functions.  Having just computed the gradients of\n        // the old solution in the quadrature points, we are able to compute\n        // the coefficients $a_{n}$ in these points.  The assembly of the\n        // system itself then looks similar to what we always do with the\n        // exception of the nonlinear terms, as does copying the results from\n        // the local objects into the global ones:\n        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)\n          {\n            const double coeff\n              = 1.0 / std::sqrt(1 +\n                                old_solution_gradients[q_point] *\n                                old_solution_gradients[q_point]);\n\n            for (unsigned int i=0; i<dofs_per_cell; ++i)\n              {\n                for (unsigned int j=0; j<dofs_per_cell; ++j)\n                  {\n                    cell_matrix(i, j) += (fe_values.shape_grad(i, q_point)\n                                          * coeff\n                                          * (fe_values.shape_grad(j, q_point)\n                                             -\n                                             coeff * coeff\n                                             * (fe_values.shape_grad(j, q_point)\n                                                *\n                                                old_solution_gradients[q_point])\n                                             * old_solution_gradients[q_point]\n                                            )\n                                          * fe_values.JxW(q_point));\n                  }\n\n                cell_rhs(i) -= (fe_values.shape_grad(i, q_point)\n                                * coeff\n                                * old_solution_gradients[q_point]\n                                * fe_values.JxW(q_point));\n              }\n          }\n\n        cell->get_dof_indices (local_dof_indices);\n        for (unsigned int i=0; i<dofs_per_cell; ++i)\n          {\n            for (unsigned int j=0; j<dofs_per_cell; ++j)\n              system_matrix.add (local_dof_indices[i],\n                                 local_dof_indices[j],\n                                 cell_matrix(i,j));\n\n            system_rhs(local_dof_indices[i]) += cell_rhs(i);\n          }\n      }\n\n    // Finally, we remove hanging nodes from the system and apply zero\n    // boundary values to the linear system that defines the Newton updates\n    // $\\delta u^n$:\n    hanging_node_constraints.condense (system_matrix);\n    hanging_node_constraints.condense (system_rhs);\n\n    std::map<unsigned int,double> boundary_values;\n    VectorTools::interpolate_boundary_values (dof_handler,\n                                              0,\n                                              ZeroFunction<dim>(),\n                                              boundary_values);\n    MatrixTools::apply_boundary_values (boundary_values,\n                                        system_matrix,\n                                        newton_update,\n                                        system_rhs);\n  }\n\n\n\n  // @sect4{MinimalSurfaceProblem::solve}\n\n  // The solve function is the same as always. At the end of the solution\n  // process we update the current solution by setting\n  // $u^{n+1}=u^n+\\alpha^n\\;\\delta u^n$.\n  template <int dim>\n  void MinimalSurfaceProblem<dim>::solve ()\n  {\n    SolverControl solver_control (system_rhs.size(),\n                                  system_rhs.l2_norm()*1e-6);\n    SolverCG<>    solver (solver_control);\n\n    PreconditionSSOR<> preconditioner;\n    preconditioner.initialize(system_matrix, 1.2);\n\n    solver.solve (system_matrix, newton_update, system_rhs,\n                  preconditioner);\n\n    hanging_node_constraints.distribute (newton_update);\n\n    const double alpha = determine_step_length();\n    present_solution.add (alpha, newton_update);\n  }\n\n\n  // @sect4{MinimalSurfaceProblem::refine_mesh}\n\n  // The first part of this function is the same as in step-6... However,\n  // after refining the mesh we have to transfer the old solution to the new\n  // one which we do with the help of the SolutionTransfer class. The process\n  // is slightly convoluted, so let us describe it in detail:\n  template <int dim>\n  void MinimalSurfaceProblem<dim>::refine_mesh ()\n  {\n    Vector<float> estimated_error_per_cell (triangulation.n_active_cells());\n\n    KellyErrorEstimator<dim>::estimate (dof_handler,\n                                        QGauss<dim-1>(3),\n                                        typename FunctionMap<dim>::type(),\n                                        present_solution,\n                                        estimated_error_per_cell);\n\n    GridRefinement::refine_and_coarsen_fixed_number (triangulation,\n                                                     estimated_error_per_cell,\n                                                     0.3, 0.03);\n\n    // Then we need an additional step: if, for example, you flag a cell that\n    // is once more refined than its neighbor, and that neighbor is not\n    // flagged for refinement, we would end up with a jump of two refinement\n    // levels across a cell interface.  To avoid these situations, the library\n    // will silently also have to refine the neighbor cell once. It does so by\n    // calling the Triangulation::prepare_coarsening_and_refinement function\n    // before actually doing the refinement and coarsening.  This function\n    // flags a set of additional cells for refinement or coarsening, to\n    // enforce rules like the one-hanging-node rule.  The cells that are\n    // flagged for refinement and coarsening after calling this function are\n    // exactly the ones that will actually be refined or coarsened. Usually,\n    // you don't have to do this by hand\n    // (Triangulation::execute_coarsening_and_refinement does this for\n    // you). However, we need to initialize the SolutionTransfer class and it\n    // needs to know the final set of cells that will be coarsened or refined\n    // in order to store the data from the old mesh and transfer to the new\n    // one. Thus, we call the function by hand:\n    triangulation.prepare_coarsening_and_refinement ();\n\n    // With this out of the way, we initialize a SolutionTransfer object with\n    // the present DoFHandler and attach the solution vector to it, followed\n    // by doing the actual refinement and distribution of degrees of freedom\n    // on the new mesh\n    SolutionTransfer<dim> solution_transfer(dof_handler);\n    solution_transfer.prepare_for_coarsening_and_refinement(present_solution);\n\n    triangulation.execute_coarsening_and_refinement();\n\n    dof_handler.distribute_dofs(fe);\n\n    // Finally, we retrieve the old solution interpolated to the new\n    // mesh. Since the SolutionTransfer function does not actually store the\n    // values of the old solution, but rather indices, we need to preserve the\n    // old solution vector until we have gotten the new interpolated\n    // values. Thus, we have the new values written into a temporary vector,\n    // and only afterwards write them into the solution vector object. Once we\n    // have this solution we have to make sure that the $u^n$ we now have\n    // actually has the correct boundary values. As explained at the end of\n    // the introduction, this is not automatically the case even if the\n    // solution before refinement had the correct boundary values, and so we\n    // have to explicitly make sure that it now has:\n    Vector<double> tmp(dof_handler.n_dofs());\n    solution_transfer.interpolate(present_solution, tmp);\n    present_solution = tmp;\n\n    set_boundary_values ();\n\n    // On the new mesh, there are different hanging nodes, which we have to\n    // compute again. To ensure there are no hanging nodes of the old mesh in\n    // the object, it's first cleared.  To be on the safe side, we then also\n    // make sure that the current solution's vector entries satisfy the\n    // hanging node constraints:\n\n    hanging_node_constraints.clear();\n\n    DoFTools::make_hanging_node_constraints(dof_handler,\n                                            hanging_node_constraints);\n    hanging_node_constraints.close();\n\n    hanging_node_constraints.distribute (present_solution);\n\n    // We end the function by updating all the remaining data structures,\n    // indicating to <code>setup_dofs()</code> that this is not the first\n    // go-around and that it needs to preserve the content of the solution\n    // vector:\n    setup_system (false);\n  }\n\n\n\n  // @sect4{MinimalSurfaceProblem::set_boundary_values}\n\n  // The next function ensures that the solution vector's entries respect the\n  // boundary values for our problem.  Having refined the mesh (or just\n  // started computations), there might be new nodal points on the\n  // boundary. These have values that are simply interpolated from the\n  // previous mesh (or are just zero), instead of the correct boundary\n  // values. This is fixed up by setting all boundary nodes explicit to the\n  // right value:\n  template <int dim>\n  void MinimalSurfaceProblem<dim>::set_boundary_values ()\n  {\n    std::map<unsigned int, double> boundary_values;\n    VectorTools::interpolate_boundary_values (dof_handler,\n                                              0,\n                                              BoundaryValues<dim>(),\n                                              boundary_values);\n    for (std::map<unsigned int, double>::const_iterator\n         p = boundary_values.begin();\n         p != boundary_values.end(); ++p)\n      present_solution(p->first) = p->second;\n  }\n\n\n  // @sect4{MinimalSurfaceProblem::compute_residual}\n\n  // In order to monitor convergence, we need a way to compute the norm of the\n  // (discrete) residual, i.e., the norm of the vector\n  // $\\left<F(u^n),\\varphi_i\\right>$ with $F(u)=-\\nabla \\cdot \\left(\n  // \\frac{1}{\\sqrt{1+|\\nabla u|^{2}}}\\nabla u \\right)$ as discussed in the\n  // introduction. It turns out that (although we don't use this feature in\n  // the current version of the program) one needs to compute the residual\n  // $\\left<F(u^n+\\alpha^n\\;\\delta u^n),\\varphi_i\\right>$ when determining\n  // optimal step lengths, and so this is what we implement here: the function\n  // takes the step length $\\alpha^n$ as an argument. The original\n  // functionality is of course obtained by passing a zero as argument.\n  //\n  // In the function below, we first set up a vector for the residual, and\n  // then a vector for the evaluation point $u^n+\\alpha^n\\;\\delta u^n$. This\n  // is followed by the same boilerplate code we use for all integration\n  // operations:\n  template <int dim>\n  double MinimalSurfaceProblem<dim>::compute_residual (const double alpha) const\n  {\n    Vector<double> residual (dof_handler.n_dofs());\n\n    Vector<double> evaluation_point (dof_handler.n_dofs());\n    evaluation_point = present_solution;\n    evaluation_point.add (alpha, newton_update);\n\n    const QGauss<dim>  quadrature_formula(3);\n    FEValues<dim> fe_values (fe, quadrature_formula,\n                             update_gradients         |\n                             update_quadrature_points |\n                             update_JxW_values);\n\n    const unsigned int           dofs_per_cell = fe.dofs_per_cell;\n    const unsigned int           n_q_points    = quadrature_formula.size();\n\n    Vector<double>               cell_rhs (dofs_per_cell);\n    std::vector<Tensor<1, dim> > gradients(n_q_points);\n\n    std::vector<unsigned int>    local_dof_indices (dofs_per_cell);\n\n    typename DoFHandler<dim>::active_cell_iterator\n    cell = dof_handler.begin_active(),\n    endc = dof_handler.end();\n    for (; cell!=endc; ++cell)\n      {\n        cell_rhs = 0;\n        fe_values.reinit (cell);\n\n        // The actual computation is much as in\n        // <code>assemble_system()</code>. We first evaluate the gradients of\n        // $u^n+\\alpha^n\\,\\delta u^n$ at the quadrature points, then compute\n        // the coefficient $a_n$, and then plug it all into the formula for\n        // the residual:\n        fe_values.get_function_gradients (evaluation_point,\n                                          gradients);\n\n\n        for (unsigned int q_point=0; q_point<n_q_points; ++q_point)\n          {\n            const double coeff = 1/std::sqrt(1 +\n                                             gradients[q_point] *\n                                             gradients[q_point]);\n\n            for (unsigned int i = 0; i < dofs_per_cell; ++i)\n              cell_rhs(i) -= (fe_values.shape_grad(i, q_point)\n                              * coeff\n                              * gradients[q_point]\n                              * fe_values.JxW(q_point));\n          }\n\n        cell->get_dof_indices (local_dof_indices);\n        for (unsigned int i=0; i<dofs_per_cell; ++i)\n          residual(local_dof_indices[i]) += cell_rhs(i);\n      }\n\n    // At the end of this function we also have to deal with the hanging node\n    // constraints and with the issue of boundary values. With regard to the\n    // latter, we have to set to zero the elements of the residual vector for\n    // all entries that correspond to degrees of freedom that sit at the\n    // boundary. The reason is that because the value of the solution there is\n    // fixed, they are of course no \"real\" degrees of freedom and so, strictly\n    // speaking, we shouldn't have assembled entries in the residual vector\n    // for them. However, as we always do, we want to do exactly the same\n    // thing on every cell and so we didn't not want to deal with the question\n    // of whether a particular degree of freedom sits at the boundary in the\n    // integration above. Rather, we will simply set to zero these entries\n    // after the fact. To this end, we first need to determine which degrees\n    // of freedom do in fact belong to the boundary and then loop over all of\n    // those and set the residual entry to zero. This happens in the following\n    // lines which we have already seen used in step-11:\n    hanging_node_constraints.condense (residual);\n\n    std::vector<bool> boundary_dofs (dof_handler.n_dofs());\n    DoFTools::extract_boundary_dofs (dof_handler,\n                                     ComponentMask(),\n                                     boundary_dofs);\n    for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)\n      if (boundary_dofs[i] == true)\n        residual(i) = 0;\n\n    // At the end of the function, we return the norm of the residual:\n    return residual.l2_norm();\n  }\n\n\n\n  // @sect4{MinimalSurfaceProblem::determine_step_length}\n\n  // As discussed in the introduction, Newton's method frequently does not\n  // converge if we always take full steps, i.e., compute $u^{n+1}=u^n+\\delta\n  // u^n$. Rather, one needs a damping parameter (step length) $\\alpha^n$ and\n  // set $u^{n+1}=u^n+\\alpha^n\\; delta u^n$. This function is the one called\n  // to compute $\\alpha^n$.\n  //\n  // Here, we simply always return 0.1. This is of course a sub-optimal\n  // choice: ideally, what one wants is that the step size goes to one as we\n  // get closer to the solution, so that we get to enjoy the rapid quadratic\n  // convergence of Newton's method. We will discuss better strategies below\n  // in the results section.\n  template <int dim>\n  double MinimalSurfaceProblem<dim>::determine_step_length() const\n  {\n    return 0.1;\n  }\n\n\n\n  // @sect4{MinimalSurfaceProblem::run}\n\n  // In the run function, we build the first grid and then have the top-level\n  // logic for the Newton iteration. The function has two variables, one that\n  // indicates whether this is the first time we solve for a Newton update and\n  // one that indicates the refinement level of the mesh:\n  template <int dim>\n  void MinimalSurfaceProblem<dim>::run ()\n  {\n    unsigned int refinement = 0;\n    bool         first_step = true;\n\n    // As described in the introduction, the domain is the unit disk around\n    // the origin, created in the same way as shown in step-6. The mesh is\n    // globally refined twice followed later on by several adaptive cycles:\n    GridGenerator::hyper_ball (triangulation);\n    static const HyperBallBoundary<dim> boundary;\n    triangulation.set_boundary (0, boundary);\n    triangulation.refine_global(2);\n\n    // The Newton iteration starts next. During the first step we do not have\n    // information about the residual prior to this step and so we continue\n    // the Newton iteration until we have reached at least one iteration and\n    // until residual is less than $10^{-3}$.\n    //\n    // At the beginning of the loop, we do a bit of setup work. In the first\n    // go around, we compute the solution on the twice globally refined mesh\n    // after setting up the basic data structures. In all following mesh\n    // refinement loops, the mesh will be refined adaptively.\n    double previous_res = 0;\n    while (first_step || (previous_res>1e-3))\n      {\n        if (first_step == true)\n          {\n            std::cout << \"******** Initial mesh \"\n                      << \" ********\"\n                      << std::endl;\n\n            setup_system (true);\n            set_boundary_values ();\n          }\n        else\n          {\n            ++refinement;\n            std::cout << \"******** Refined mesh \" << refinement\n                      << \" ********\"\n                      << std::endl;\n\n            refine_mesh();\n          }\n\n        // On every mesh we do exactly five Newton steps. We print the initial\n        // residual here and then start the iterations on this mesh.\n        //\n        // In every Newton step the system matrix and the right hand side have\n        // to be computed first, after which we store the norm of the right\n        // hand side as the residual to check against when deciding whether to\n        // stop the iterations. We then solve the linear system (the function\n        // also updates $u^{n+1}=u^n+\\alpha^n\\;\\delta u^n$) and output the\n        // residual at the end of this Newton step:\n        std::cout << \"  Initial residual: \"\n                  << compute_residual(0)\n                  << std::endl;\n\n        for (unsigned int inner_iteration=0; inner_iteration<5; ++inner_iteration)\n          {\n            assemble_system ();\n            previous_res = system_rhs.l2_norm();\n\n            solve ();\n\n            first_step = false;\n            std::cout << \"  Residual: \"\n                      << compute_residual(0)\n                      << std::endl;\n          }\n\n        // Every fifth iteration, i.e., just before we refine the mesh again,\n        // we output the solution as well as the Newton update. This happens\n        // as in all programs before:\n        DataOut<dim> data_out;\n\n        data_out.attach_dof_handler (dof_handler);\n        data_out.add_data_vector (present_solution, \"solution\");\n        data_out.add_data_vector (newton_update, \"update\");\n        data_out.build_patches ();\n        const std::string filename = \"solution-\" +\n                                     Utilities::int_to_string (refinement, 2) +\n                                     \".vtk\";\n        std::ofstream output (filename.c_str());\n        data_out.write_vtk (output);\n\n      }\n  }\n}\n\n// @sect4{The main function}\n\n// Finally the main function. This follows the scheme of all other main\n// functions:\nint main ()\n{\n  try\n    {\n      using namespace dealii;\n      using namespace Step15;\n\n      deallog.depth_console (0);\n\n      MinimalSurfaceProblem<2> laplace_problem_2d;\n      laplace_problem_2d.run ();\n    }\n  catch (std::exception &exc)\n    {\n      std::cerr << std::endl << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n      std::cerr << \"Exception on processing: \" << std::endl\n                << exc.what() << std::endl\n                << \"Aborting!\" << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n\n      return 1;\n    }\n  catch (...)\n    {\n      std::cerr << std::endl << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n      std::cerr << \"Unknown exception!\" << std::endl\n                << \"Aborting!\" << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n      return 1;\n    }\n  return 0;\n}\n", "meta": {"hexsha": "611921edad071675986aafeb10817561907b7ffc", "size": 30413, "ext": "cc", "lang": "C++", "max_stars_repo_path": "MHD/examples/step-15/step-15.cc", "max_stars_repo_name": "wathen/PhD", "max_stars_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2020-10-25T13:30:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T21:27:30.000Z", "max_issues_repo_path": "MHD/examples/step-15/step-15.cc", "max_issues_repo_name": "wathen/PhD", "max_issues_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MHD/examples/step-15/step-15.cc", "max_forks_repo_name": "wathen/PhD", "max_forks_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3.0, "max_forks_repo_forks_event_min_datetime": "2019-10-28T16:12:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-13T13:59:44.000Z", "avg_line_length": 40.877688172, "max_line_length": 84, "alphanum_fraction": 0.6241081117, "num_tokens": 6719, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.1732882016598637, "lm_q1q2_score": 0.08664410082993185}}
{"text": "//  Copyright John Maddock 2007.\r\n//  Copyright Paul A. Bristow 2010\r\n\r\n//  Use, modification and distribution are subject to the\r\n//  Boost Software License, Version 1.0. (See accompanying file\r\n//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n// Note that this file contains quickbook mark-up as well as code\r\n// and comments, don't change any of the special comment mark-ups!\r\n\r\n#include <iostream>\r\nusing std::cout;  using std::endl;\r\n#include <cerrno> // for ::errno\r\n\r\n//[policy_eg_4\r\n\r\n/*`\r\nSuppose we want `C::foo()` to behave in a C-compatible way and set\r\n`::errno` on error rather than throwing any exceptions.\r\n\r\nWe'll begin by including the needed header for our function:\r\n*/\r\n\r\n#include <boost/math/special_functions.hpp>\r\n//using boost::math::tgamma; // Not needed because using C::tgamma.\r\n\r\n/*`\r\nOpen up the \"C\" namespace that we'll use for our functions, and\r\ndefine the policy type we want: in this case a C-style one that sets\r\n::errno and returns a standard value, rather than throwing exceptions.\r\n\r\nAny policies we don't specify here will inherit the defaults.\r\n*/\r\n\r\nnamespace C\r\n{ // To hold our C-style policy.\r\n  //using namespace boost::math::policies; or explicitly:\r\n  using boost::math::policies::policy;\r\n\r\n  using boost::math::policies::domain_error;\r\n  using boost::math::policies::pole_error;\r\n  using boost::math::policies::overflow_error;\r\n  using boost::math::policies::evaluation_error;\r\n  using boost::math::policies::errno_on_error;\r\n\r\n  typedef policy<\r\n     domain_error<errno_on_error>,\r\n     pole_error<errno_on_error>,\r\n     overflow_error<errno_on_error>,\r\n     evaluation_error<errno_on_error>\r\n  > c_policy;\r\n\r\n/*`\r\nAll we need do now is invoke the BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS\r\nmacro passing our policy type c_policy as the single argument:\r\n*/\r\n\r\nBOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(c_policy)\r\n\r\n} // close namespace C\r\n\r\n/*`\r\nWe now have a set of forwarding functions defined in namespace C\r\nthat all look something like this:\r\n\r\n``\r\ntemplate <class RealType>\r\ninline typename boost::math::tools::promote_args<RT>::type\r\n   tgamma(RT z)\r\n{\r\n   return boost::math::tgamma(z, c_policy());\r\n}\r\n``\r\n\r\nSo that when we call `C::tgamma(z)`, we really end up calling\r\n`boost::math::tgamma(z, C::c_policy())`:\r\n*/\r\n\r\nint main()\r\n{\r\n   errno = 0;\r\n   cout << \"Result of tgamma(30000) is: \"\r\n      << C::tgamma(30000) << endl; // Note using C::tgamma\r\n   cout << \"errno = \" << errno << endl; // errno = 34\r\n   cout << \"Result of tgamma(-10) is: \"\r\n      << C::tgamma(-10) << endl;\r\n   cout << \"errno = \" << errno << endl; // errno = 33, overwriting previous value of 34.\r\n}\r\n\r\n/*`\r\n\r\nWhich outputs:\r\n\r\n[pre\r\nResult of C::tgamma(30000) is: 1.#INF\r\nerrno = 34\r\nResult of C::tgamma(-10) is: 1.#QNAN\r\nerrno = 33\r\n]\r\n\r\nThis mechanism is particularly useful when we want to define a project-wide policy,\r\nand don't want to modify the Boost source,\r\nor to set project wide build macros (possibly fragile and easy to forget).\r\n\r\n*/\r\n//] //[/policy_eg_4]\r\n\r\n", "meta": {"hexsha": "1bb316e4bfdca896d8d9918defda16f893cd2b55", "size": 3023, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/math/example/policy_eg_4.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 198.0, "max_stars_repo_stars_event_min_datetime": "2015-01-13T05:47:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T04:46:46.000Z", "max_issues_repo_path": "libs/boost/libs/math/example/policy_eg_4.cpp", "max_issues_repo_name": "flingone/frameworks_base_cmds_remoted", "max_issues_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 9.0, "max_issues_repo_issues_event_min_datetime": "2015-01-28T16:33:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T23:03:28.000Z", "max_forks_repo_path": "libs/boost/libs/math/example/policy_eg_4.cpp", "max_forks_repo_name": "flingone/frameworks_base_cmds_remoted", "max_forks_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 139.0, "max_forks_repo_forks_event_min_datetime": "2015-01-15T20:09:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-31T15:21:16.000Z", "avg_line_length": 27.9907407407, "max_line_length": 89, "alphanum_fraction": 0.6834270592, "num_tokens": 787, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4571367168274948, "lm_q2_score": 0.18713269122913015, "lm_q1q2_score": 0.08554522407957789}}
{"text": "/******************************************************************************\\\n* Author: Matthew Beauregard Smith                                             *\n* Affiliation: The University of Texas at Austin                               *\n* Department: Oden Institute and Institute for Cellular and Molecular Biology  *\n* PI: Edward Marcotte                                                          *\n* Project: Protein Fluorosequencing                                            *\n\\******************************************************************************/\n\n// Boost unit test framework (recommended to be the first include):\n#include <boost/test/unit_test.hpp>\n\n// File under test:\n#include \"leaf-node.h\"\n\n// Standard C++ library headers:\n#include <vector>\n\n// External headers:\n#include \"fakeit.hpp\"\n\n// Local project headers:\n#include \"test-util/fakeit.h\"  // in test directory\n\nnamespace whatprot {\nnamespace kd_tree {\n\nnamespace {\nusing boost::unit_test::tolerance;\nusing fakeit::_;\nusing fakeit::Fake;\nusing fakeit::Mock;\nusing fakeit::Verify;\nusing fakeit::VerifyNoOtherInvocations;\nusing std::vector;\nusing whatprot::test_util::Close;\nusing whatprot::test_util::Ptr;\nconst double TOL = 0.000000001;\n}  // namespace\n\n// Class we can use as a template parameter for E.\nclass Vec {\npublic:\n    Vec(vector<double> v) : v(v), hits(1) {}\n    Vec(vector<double> v, int hits) : v(v), hits(hits) {}\n    double& operator[](int d) {\n        return v[d];\n    }\n    double operator[](int d) const {\n        return v[d];\n    }\n    // Needed to check arguments with FakeIt.\n    bool operator==(const Vec& other) const {\n        return (v == other.v) && (hits == other.hits);\n    }\n    vector<double> v;\n    int hits;\n};\n\nBOOST_AUTO_TEST_SUITE(kd_tree_suite)\nBOOST_AUTO_TEST_SUITE(leaf_node_suite)\n\nBOOST_AUTO_TEST_CASE(constructor_test, *tolerance(TOL)) {\n    int d = 3;\n    vector<Vec> vecs(2, Vec(vector<double>(3, 0)));\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    BOOST_TEST(leaf.d == d);\n    BOOST_TEST(leaf.begin == &vecs[0]);\n    BOOST_TEST(leaf.end == &vecs[2]);\n}\n\nBOOST_AUTO_TEST_CASE(consider_success_test, *tolerance(TOL)) {\n    int d = 3;\n    vector<Vec> vecs(2, Vec(vector<double>(3, 0)));\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    vector<double> query(3, 0);\n    query[0] = 1.0;\n    query[1] = 1.1;\n    query[2] = 1.2;\n    Vec entry(vector<double>(3, 0));\n    entry[0] = 2.00;\n    entry[1] = 2.11;\n    entry[2] = 2.22;\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq = 1e9;\n    leaf.consider(query, &entry, k_best);\n    double dist_sq = 1.0 * 1.0 + 1.01 * 1.01 + 1.02 * 1.02;\n    Verify(Method(k_best_mock, insert).Using(Close(dist_sq, TOL), Ptr(entry)));\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_CASE(consider_failure_test, *tolerance(TOL)) {\n    int d = 3;\n    vector<Vec> vecs(2, Vec(vector<double>(3, 0)));\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    vector<double> query(3, 0);\n    query[0] = 1.0;\n    query[1] = 1.1;\n    query[2] = 1.2;\n    Vec entry(vector<double>(3, 0));\n    entry[0] = 2.00;\n    entry[1] = 2.11;\n    entry[2] = 2.22;\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq = 1e-2;\n    leaf.consider(query, &entry, k_best);\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_CASE(consider_success_big_d_test, *tolerance(TOL)) {\n    int d = 6;\n    vector<Vec> vecs(2, Vec(vector<double>(6, 0)));\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    vector<double> query(6, 0);\n    query[0] = 1.0;\n    query[1] = 1.1;\n    query[2] = 1.2;\n    query[3] = 1.3;\n    query[4] = 1.4;\n    query[5] = 1.5;\n    Vec entry(vector<double>(6, 0));\n    entry[0] = 2.00;\n    entry[1] = 2.11;\n    entry[2] = 2.22;\n    entry[3] = 2.33;\n    entry[4] = 2.44;\n    entry[5] = 2.55;\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq = 1e9;\n    leaf.consider(query, &entry, k_best);\n    double dist_sq = 1.0 * 1.0 + 1.01 * 1.01 + 1.02 * 1.02 + 1.03 * 1.03\n                     + 1.04 * 1.04 + 1.05 * 1.05;\n    Verify(Method(k_best_mock, insert).Using(Close(dist_sq, TOL), Ptr(entry)));\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_CASE(consider_failure_big_d_test, *tolerance(TOL)) {\n    int d = 6;\n    vector<Vec> vecs(2, Vec(vector<double>(6, 0)));\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    vector<double> query(6, 0);\n    query[0] = 1.0;\n    query[1] = 1.1;\n    query[2] = 1.2;\n    query[3] = 1.3;\n    query[4] = 1.4;\n    query[5] = 1.5;\n    Vec entry(vector<double>(6, 0));\n    entry[0] = 2.00;\n    entry[1] = 2.11;\n    entry[2] = 2.22;\n    entry[3] = 2.33;\n    entry[4] = 2.44;\n    entry[5] = 2.55;\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq = 1e-2;\n    leaf.consider(query, &entry, k_best);\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_CASE(consider_barely_failure_big_d_test, *tolerance(TOL)) {\n    int d = 6;\n    vector<Vec> vecs(2, Vec(vector<double>(6, 0)));\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    vector<double> query(6, 0);\n    query[0] = 1.0;\n    query[1] = 1.1;\n    query[2] = 1.2;\n    query[3] = 1.3;\n    query[4] = 1.4;\n    query[5] = 1.5;\n    Vec entry(vector<double>(6, 0));\n    entry[0] = 2.00;\n    entry[1] = 2.11;\n    entry[2] = 2.22;\n    entry[3] = 2.33;\n    entry[4] = 2.44;\n    entry[5] = 2.55;\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq =\n            1.0 * 1.0 + 1.01 * 1.01 + 1.02 * 1.02 + 1.03 * 1.03 - 1e-7;\n    leaf.consider(query, &entry, k_best);\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_CASE(search_success_test, *tolerance(TOL)) {\n    int d = 3;\n    vector<Vec> vecs(2, Vec(vector<double>(3, 0)));\n    vecs[0][0] = 0.0;\n    vecs[0][1] = 0.1;\n    vecs[0][2] = 0.2;\n    vecs[1][0] = 1.0;\n    vecs[1][1] = 1.1;\n    vecs[1][2] = 1.2;\n    vector<double> query(3, 0);\n    query[0] = 0.2;\n    query[1] = 0.3;\n    query[2] = 0.5;\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq = 1e9;\n    leaf.search(query, k_best);\n    double dst1 = 0.0;\n    dst1 += (0.2 - 0.0) * (0.2 - 0.0);\n    dst1 += (0.3 - 0.1) * (0.3 - 0.1);\n    dst1 += (0.5 - 0.2) * (0.5 - 0.2);\n    Vec v1(vector<double>(3, 0));\n    v1[0] = 0.0;\n    v1[1] = 0.1;\n    v1[2] = 0.2;\n    Verify(Method(k_best_mock, insert).Using(Close(dst1, TOL), Ptr(v1)))\n            .Exactly(1);\n    double dst2 = 0.0;\n    dst2 += (0.2 - 1.0) * (0.2 - 1.0);\n    dst2 += (0.3 - 1.1) * (0.3 - 1.1);\n    dst2 += (0.5 - 1.2) * (0.5 - 1.2);\n    Vec v2(vector<double>(3, 0));\n    v2[0] = 1.0;\n    v2[1] = 1.1;\n    v2[2] = 1.2;\n    Verify(Method(k_best_mock, insert).Using(Close(dst2, TOL), Ptr(v2)))\n            .Exactly(1);\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_CASE(search_failure_test, *tolerance(TOL)) {\n    int d = 3;\n    vector<Vec> vecs(2, Vec(vector<double>(3, 0)));\n    vecs[0][0] = 0.0;\n    vecs[0][1] = 0.1;\n    vecs[0][2] = 0.2;\n    vecs[1][0] = 1.0;\n    vecs[1][1] = 1.1;\n    vecs[1][2] = 1.2;\n    vector<double> query(3, 0);\n    query[0] = 0.2;\n    query[1] = 0.3;\n    query[2] = 0.5;\n    LeafNode<Vec, vector<double>> leaf(d, &vecs[0], &vecs[2]);\n    Mock<KBest<Vec>> k_best_mock;\n    Fake(Method(k_best_mock, insert));\n    KBest<Vec>* k_best = &k_best_mock.get();\n    k_best->kth_dist_sq = 1e-2;\n    leaf.search(query, k_best);\n    VerifyNoOtherInvocations(k_best_mock);\n}\n\nBOOST_AUTO_TEST_SUITE_END()  // leaf_node_suite\nBOOST_AUTO_TEST_SUITE_END()  // kd_tree_suite\n\n}  // namespace kd_tree\n}  // namespace whatprot\n", "meta": {"hexsha": "331caa70057211905f9e222a7d7ec02f687f4301", "size": 8090, "ext": "cc", "lang": "C++", "max_stars_repo_path": "cc_code/src/kd-tree/leaf-node.test.cc", "max_stars_repo_name": "erisyon/whatprot", "max_stars_repo_head_hexsha": "176cd7e6ee99ea3f91794dcf1ec14f3578b7ee3c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cc_code/src/kd-tree/leaf-node.test.cc", "max_issues_repo_name": "erisyon/whatprot", "max_issues_repo_head_hexsha": "176cd7e6ee99ea3f91794dcf1ec14f3578b7ee3c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2021-06-12T00:50:08.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-15T17:59:12.000Z", "max_forks_repo_path": "cc_code/src/kd-tree/leaf-node.test.cc", "max_forks_repo_name": "erisyon/whatprot", "max_forks_repo_head_hexsha": "176cd7e6ee99ea3f91794dcf1ec14f3578b7ee3c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-06-11T19:34:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-11T19:34:43.000Z", "avg_line_length": 30.6439393939, "max_line_length": 80, "alphanum_fraction": 0.5713226205, "num_tokens": 2848, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4687906266262437, "lm_q2_score": 0.1824255304737224, "lm_q1q2_score": 0.08551937874340124}}
{"text": "/*    Copyright (c) 2010-2019, Delft University of Technology\r\n *    All rigths reserved\r\n *\r\n *    This file is part of the Tudat. Redistribution and use in source and\r\n *    binary forms, with or without modification, are permitted exclusively\r\n *    under the terms of the Modified BSD license. You should have received\r\n *    a copy of the license with this file. If not, please or visit:\r\n *    http://tudat.tudelft.nl/LICENSE.\r\n */\r\n\r\n#define BOOST_TEST_MAIN\r\n\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/make_shared.hpp>\r\n\r\n#include \"Tudat/Basics/testMacros.h\"\r\n\r\n#include \"Tudat/Astrodynamics/Ephemerides/itrsToGcrsRotationModel.h\"\r\n#include \"Tudat/Astrodynamics/EarthOrientation/UnitTests/sofaEarthOrientationCookbookExamples.h\"\r\n#include \"Tudat/External/SpiceInterface/spiceInterface.h\"\r\n\r\nnamespace tudat\r\n{\r\nnamespace unit_tests\r\n{\r\n\r\nusing namespace ephemerides;\r\nusing namespace earth_orientation;\r\nusing namespace basic_astrodynamics;\r\n\r\nBOOST_AUTO_TEST_SUITE( test_itrs_to_gcrs_rotation )\r\n\r\n//! Test ITRS <-> GCRS rotation by compariong against Spice\r\nBOOST_AUTO_TEST_CASE( test_ItrsToGcrsRotationAgainstSpice )\r\n{\r\n\r\n    spice_interface::loadSpiceKernelInTudat( input_output::getSpiceKernelPath( ) + \"naif0012.tls\" );\r\n    spice_interface::loadSpiceKernelInTudat( input_output::getSpiceKernelPath( ) + \"earth_latest_high_prec.bpc\" );\r\n    spice_interface::loadSpiceKernelInTudat( input_output::getSpiceKernelPath( ) + \"earth_fixed.tf\" );\r\n\r\n    // Create rotation model\r\n    std::shared_ptr< GcrsToItrsRotationModel > earthRotationModel =\r\n            std::make_shared< GcrsToItrsRotationModel >(\r\n                earth_orientation::createStandardEarthOrientationCalculator( ) );\r\n\r\n    // Compare spice vs. Tudat for list of evaluation times\r\n    std::vector< double > testTimes;\r\n    testTimes.push_back( 1.0E8 );\r\n    testTimes.push_back( 1.0E7 );\r\n    testTimes.push_back( 0.0 );\r\n    for( unsigned test = 0; test < testTimes.size( ); test++ )\r\n    {\r\n        Eigen::Matrix3d sofaRotation = earthRotationModel->getRotationToBaseFrame( testTimes.at( test ) ).toRotationMatrix( );\r\n        Eigen::Matrix3d sofaRotationDerivative = earthRotationModel->getDerivativeOfRotationToBaseFrame( testTimes.at( test ) );\r\n        Eigen::Matrix3d spiceRotation = spice_interface::computeRotationQuaternionBetweenFrames(\r\n                    \"ITRF93\", \"J2000\", testTimes.at( test ) ).toRotationMatrix( );\r\n        Eigen::Matrix3d spiceRotationDerivative = spice_interface::computeRotationMatrixDerivativeBetweenFrames(\r\n                    \"ITRF93\", \"J2000\", testTimes.at( test ) );\r\n\r\n        // Check whether Spice and Tudat give same result. Note that Spice model is not accurate up to IERS standards. Comparison\r\n        // is done at 10 cm position difference on Earth surface (per component).\r\n        double tolerance = 0.1 / 6378.0E3;\r\n\r\n        for( unsigned int i = 0; i < 3; i++ )\r\n        {\r\n            for( unsigned int j = 0; j < 3; j++ )\r\n            {\r\n                BOOST_CHECK_SMALL( sofaRotation( i, j ) - spiceRotation( i, j ), tolerance );\r\n                BOOST_CHECK_SMALL( sofaRotationDerivative( i, j ) - spiceRotationDerivative( i, j ), 5.0E-12 );\r\n\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n//! Test ITRS <-> GCRS rotation by compariong against Sofa\r\nBOOST_AUTO_TEST_CASE( test_ItrsToGcrsRotationAgainstSofaCookbook )\r\n{\r\n\r\n    // Get UTC time for evaluation\r\n    int year = 2007;\r\n    int month = 4;\r\n    int day = 5;\r\n    int hour = 12;\r\n    int minutes = 0;\r\n    double seconds = 0.0;\r\n    double sofaCookbookTime = convertCalendarDateToJulianDaysSinceEpoch(\r\n                year, month, day, hour, minutes, seconds, JULIAN_DAY_ON_J2000 ) *\r\n            physical_constants::JULIAN_DAY;\r\n\r\n    // Create Earth rotation model\r\n    std::shared_ptr< GcrsToItrsRotationModel > earthRotationModelFromUtc =\r\n            std::make_shared< GcrsToItrsRotationModel >(\r\n                earth_orientation::createStandardEarthOrientationCalculator( ),\r\n                utc_scale );\r\n\r\n    // Test Tudat vs. Sofa implementations, with default Sofa EOP corrections (as defined in cookbook\r\n    {\r\n        Eigen::Matrix3d sofaCookbookResult = getSofaEarthOrientationExamples( 3 ).transpose( );\r\n        Eigen::Matrix3d tudatResult = earthRotationModelFromUtc->getRotationToBaseFrame( sofaCookbookTime ).toRotationMatrix( );\r\n\r\n        // Check sofa against Tudat result, small difference due to slightly different values of EOP corrections.\r\n        for( unsigned int i = 0; i < 3; i++ )\r\n        {\r\n            for( unsigned int j = 0; j < 3; j++ )\r\n            {\r\n                BOOST_CHECK_SMALL( sofaCookbookResult( i, j ) - tudatResult( i, j ), 2.0E-9 );\r\n            }\r\n        }\r\n    }\r\n\r\n    // Test Tudat vs. Sofa implementations with identical EOP corrections.\r\n    {\r\n        // Set current time in UTC and TT\r\n        double interpolationUtc = sofaCookbookTime;\r\n        double interpolationTt = earthRotationModelFromUtc->getAnglesCalculator( )->getTerrestrialTimeScaleConverter( )->\r\n                getCurrentTime( utc_scale, tt_scale, interpolationUtc );\r\n\r\n        // Get EOP corrections\r\n        double Xcorrection = earthRotationModelFromUtc->getAnglesCalculator( )->getPrecessionNutationCalculator( )->\r\n                getDailyCorrectionInterpolator( )->interpolate( interpolationUtc ).x( );\r\n        double Ycorrection = earthRotationModelFromUtc->getAnglesCalculator( )->getPrecessionNutationCalculator( )->\r\n                getDailyCorrectionInterpolator( )->interpolate( interpolationUtc ).y( );\r\n        double xPolarMotion = earthRotationModelFromUtc->getAnglesCalculator( )->getPolarMotionCalculator( )->\r\n                getPositionOfCipInItrs( interpolationTt, interpolationUtc ).x( );\r\n        double yPolarMotion = earthRotationModelFromUtc->getAnglesCalculator( )->getPolarMotionCalculator( )->\r\n                getPositionOfCipInItrs( interpolationTt, interpolationUtc ).y( );\r\n        double ut1Correction = earthRotationModelFromUtc->getAnglesCalculator( )->getTerrestrialTimeScaleConverter( )->\r\n                getUt1Correction( utc_scale, Time( sofaCookbookTime ) );\r\n\r\n        // Compute Sofa rotation matrix\r\n        Eigen::Matrix3d  sofaCookbookResult = getSofaEarthOrientationExamples(\r\n                    3, unit_conversions::convertRadiansToArcSeconds( Xcorrection ) * 1000.0,\r\n                    unit_conversions::convertRadiansToArcSeconds( Ycorrection ) * 1000.0,\r\n                    unit_conversions::convertRadiansToArcSeconds( xPolarMotion ),\r\n                    unit_conversions::convertRadiansToArcSeconds( yPolarMotion ), ut1Correction ).transpose( );\r\n\r\n        // Compute Tudat rotation matrix\r\n        Eigen::Matrix3d tudatResult = earthRotationModelFromUtc->getRotationToBaseFrame( sofaCookbookTime ).toRotationMatrix( );\r\n\r\n        // Check sofa against Tudat result, small difference due to rounding errors, in particular in Earth rotation angle\r\n        for( unsigned int i = 0; i < 3; i++ )\r\n        {\r\n            for( unsigned int j = 0; j < 3; j++ )\r\n            {\r\n                if( i < 2 && j < 2 )\r\n                {\r\n                    BOOST_CHECK_SMALL( sofaCookbookResult( i, j ) - tudatResult( i, j ), 1.0E-11 );\r\n                }\r\n                else\r\n                {\r\n                    BOOST_CHECK_SMALL( sofaCookbookResult( i, j ) - tudatResult( i, j ), 1.0E-14 );\r\n                }\r\n            }\r\n        }\r\n\r\n        // Compute Tudat rotation matrix with high-precision time input\r\n        long double sofaCookbookExtendedTime = convertCalendarDateToJulianDaysSinceEpoch< long double >(\r\n                    year, month, day, hour, minutes, seconds, JULIAN_DAY_ON_J2000 ) *\r\n                physical_constants::JULIAN_DAY_LONG;\r\n        Eigen::Matrix3d tudatResultPrecise = earthRotationModelFromUtc->getRotationToBaseFrameFromExtendedTime(\r\n                    Time( sofaCookbookExtendedTime ) ).toRotationMatrix( );\r\n\r\n        // Check sofa against Tudat result\r\n        for( unsigned int i = 0; i < 3; i++ )\r\n        {\r\n            for( unsigned int j = 0; j < 3; j++ )\r\n            {\r\n                BOOST_CHECK_SMALL( sofaCookbookResult( i, j ) - tudatResultPrecise( i, j ), 1.0E-15 );\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END( )\r\n\r\n}\r\n\r\n}\r\n", "meta": {"hexsha": "297e89a5e2b7f5bb030992eb2c8216c0abbf508a", "size": 8297, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestItrsToGcrsRotationModel.cpp", "max_stars_repo_name": "sebranchett/tudat", "max_stars_repo_head_hexsha": "24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestItrsToGcrsRotationModel.cpp", "max_issues_repo_name": "sebranchett/tudat", "max_issues_repo_head_hexsha": "24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestItrsToGcrsRotationModel.cpp", "max_forks_repo_name": "sebranchett/tudat", "max_forks_repo_head_hexsha": "24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0944444444, "max_line_length": 130, "alphanum_fraction": 0.6521634326, "num_tokens": 2010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47657965106367595, "lm_q2_score": 0.1778108760134381, "lm_q1q2_score": 0.08474104524581087}}
{"text": "/*\r\n [auto_generated]\r\n libs/numeric/odeint/test/resizing.cpp\r\n\r\n [begin_description]\r\n This file tests the resizing mechanism of odeint.\r\n [end_description]\r\n\r\n Copyright 2010-2012 Karsten Ahnert\r\n Copyright 2010-2012 Mario Mulansky\r\n\r\n Distributed under the Boost Software License, Version 1.0.\r\n (See accompanying file LICENSE_1_0.txt or\r\n copy at http://www.boost.org/LICENSE_1_0.txt)\r\n */\r\n\r\n// disable checked iterator warning for msvc\r\n#include <boost/config.hpp>\r\n#ifdef BOOST_MSVC\r\n    #pragma warning(disable:4996)\r\n#endif\r\n\r\n#define BOOST_TEST_MODULE odeint_resize\r\n\r\n#include <vector>\r\n#include <cmath>\r\n\r\n#include <boost/array.hpp>\r\n#include <boost/bind.hpp>\r\n#include <boost/utility.hpp>\r\n#include <boost/type_traits/integral_constant.hpp>\r\n\r\n#include <boost/test/unit_test.hpp>\r\n\r\n#include <boost/mpl/vector.hpp>\r\n#include <boost/mpl/int.hpp>\r\n#include <boost/mpl/at.hpp>\r\n\r\n#include <boost/numeric/odeint/stepper/euler.hpp>\r\n#include <boost/numeric/odeint/stepper/runge_kutta4_classic.hpp>\r\n#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>\r\n#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>\r\n\r\n#include <boost/numeric/odeint/util/resizer.hpp>\r\n#include <boost/numeric/odeint/util/is_resizeable.hpp>\r\n\r\n#include \"resizing_test_state_type.hpp\"\r\n\r\nusing namespace boost::unit_test;\r\nusing namespace boost::numeric::odeint;\r\n\r\nnamespace mpl = boost::mpl;\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid constant_system( const test_array_type &x , test_array_type &dxdt , double t ) { dxdt[0] = 1.0; }\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE( check_resize_test )\r\n\r\n\r\ntypedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > euler_manual_type;\r\ntypedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > euler_initially_type;\r\ntypedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > euler_always_type;\r\n\r\ntypedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > rk4_manual_type;\r\ntypedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > rk4_initially_type;\r\ntypedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > rk4_always_type;\r\n\r\n\r\ntypedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > rk4_gen_manual_type;\r\ntypedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > rk4_gen_initially_type;\r\ntypedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > rk4_gen_always_type;\r\n\r\n\r\ntypedef mpl::vector<\r\n    mpl::vector< euler_manual_type , mpl::int_<1> , mpl::int_<0> > ,\r\n    mpl::vector< euler_initially_type , mpl::int_<1> , mpl::int_<1> > ,\r\n    mpl::vector< euler_always_type , mpl::int_<1> , mpl::int_<3> > ,\r\n    mpl::vector< rk4_manual_type , mpl::int_<5> , mpl::int_<0> > ,\r\n    mpl::vector< rk4_initially_type , mpl::int_<5> , mpl::int_<1> > ,\r\n    mpl::vector< rk4_always_type , mpl::int_<5> , mpl::int_<3> > ,\r\n    mpl::vector< rk4_gen_manual_type , mpl::int_<5> , mpl::int_<0> > ,\r\n    mpl::vector< rk4_gen_initially_type , mpl::int_<5> , mpl::int_<1> > ,\r\n    mpl::vector< rk4_gen_always_type , mpl::int_<5> , mpl::int_<3> >\r\n    >::type resize_check_types;\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( test_resize , T, resize_check_types )\r\n{\r\n    typedef typename mpl::at< T , mpl::int_< 0 > >::type stepper_type;\r\n    const size_t resize_calls = mpl::at< T , mpl::int_< 1 > >::type::value;\r\n    const size_t multiplicity = mpl::at< T , mpl::int_< 2 > >::type::value;\r\n    adjust_size_count = 0;\r\n\r\n    stepper_type stepper;\r\n    test_array_type x;\r\n    stepper.do_step( constant_system , x , 0.0 , 0.1 );\r\n    stepper.do_step( constant_system , x , 0.0 , 0.1 );\r\n    stepper.do_step( constant_system , x , 0.0 , 0.1 );\r\n\r\n    BOOST_TEST_MESSAGE( \"adjust_size_count : \" << adjust_size_count );\r\n    BOOST_CHECK_MESSAGE( adjust_size_count == resize_calls * multiplicity , \"adjust_size_count : \" << adjust_size_count << \" expected: \" << resize_calls * multiplicity );\r\n}\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "c5d4df4d61062b1a93b3d45706930a5fead55e4b", "size": 4466, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/resizing.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/resizing.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-03-04T11:21:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-24T01:36:31.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/resizing.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 40.2342342342, "max_line_length": 171, "alphanum_fraction": 0.7313031796, "num_tokens": 1163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4571367168274948, "lm_q2_score": 0.1847675151370785, "lm_q1q2_score": 0.08446401524613852}}
{"text": "//---------------------------------------------------------------------------//\r\n// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>\r\n//\r\n// Distributed under the Boost Software License, Version 1.0\r\n// See accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt\r\n//\r\n// See http://boostorg.github.com/compute for more information.\r\n//---------------------------------------------------------------------------//\r\n\r\n#define BOOST_TEST_MODULE TestSortByKey\r\n#include <boost/test/unit_test.hpp>\r\n\r\n#include <boost/compute/system.hpp>\r\n#include <boost/compute/algorithm/sort_by_key.hpp>\r\n#include <boost/compute/algorithm/is_sorted.hpp>\r\n#include <boost/compute/container/vector.hpp>\r\n\r\n#include \"check_macros.hpp\"\r\n#include \"context_setup.hpp\"\r\n\r\nnamespace compute = boost::compute;\r\n\r\n// test trivial sorting of zero element vectors\r\nBOOST_AUTO_TEST_CASE(sort_int_0)\r\n{\r\n    compute::vector<int> keys(context);\r\n    compute::vector<int> values(context);\r\n    BOOST_CHECK_EQUAL(keys.size(), size_t(0));\r\n    BOOST_CHECK_EQUAL(values.size(), size_t(0));\r\n    BOOST_CHECK(compute::is_sorted(keys.begin(), keys.end()) == true);\r\n    BOOST_CHECK(compute::is_sorted(values.begin(), values.end()) == true);\r\n    compute::sort_by_key(keys.begin(), keys.end(), values.begin(), queue);\r\n}\r\n\r\n// test trivial sorting of one element vectors\r\nBOOST_AUTO_TEST_CASE(sort_int_1)\r\n{\r\n    int keys_data[] = { 11 };\r\n    int values_data[] = { 100 };\r\n\r\n    compute::vector<int> keys(keys_data, keys_data + 1, queue);\r\n    compute::vector<int> values(values_data, values_data + 1, queue);\r\n\r\n    BOOST_CHECK(compute::is_sorted(keys.begin(), keys.end(), queue) == true);\r\n    BOOST_CHECK(compute::is_sorted(values.begin(), values.end(), queue) == true);\r\n\r\n    compute::sort_by_key(keys.begin(), keys.end(), values.begin(), queue);\r\n}\r\n\r\n// test trivial sorting of two element vectors\r\nBOOST_AUTO_TEST_CASE(sort_int_2)\r\n{\r\n    int keys_data[] = { 4, 2 };\r\n    int values_data[] = { 42, 24 };\r\n\r\n    compute::vector<int> keys(keys_data, keys_data + 2, queue);\r\n    compute::vector<int> values(values_data, values_data + 2, queue);\r\n\r\n    BOOST_CHECK(compute::is_sorted(keys.begin(), keys.end(), queue) == false);\r\n    BOOST_CHECK(compute::is_sorted(values.begin(), values.end(), queue) == false);\r\n\r\n    compute::sort_by_key(keys.begin(), keys.end(), values.begin(), queue);\r\n\r\n    BOOST_CHECK(compute::is_sorted(keys.begin(), keys.end(), queue) == true);\r\n    BOOST_CHECK(compute::is_sorted(values.begin(), values.end(), queue) == true);\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(sort_char_by_int)\r\n{\r\n    int keys_data[] = { 6, 2, 1, 3, 4, 7, 5, 0 };\r\n    char values_data[] = { 'g', 'c', 'b', 'd', 'e', 'h', 'f', 'a' };\r\n\r\n    compute::vector<int> keys(keys_data, keys_data + 8, queue);\r\n    compute::vector<char> values(values_data, values_data + 8, queue);\r\n\r\n    compute::sort_by_key(keys.begin(), keys.end(), values.begin(), queue);\r\n\r\n    CHECK_RANGE_EQUAL(int, 8, keys, (0, 1, 2, 3, 4, 5, 6, 7));\r\n    CHECK_RANGE_EQUAL(char, 8, values, ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(sort_int_and_float)\r\n{\r\n    int n = 1024;\r\n    std::vector<int> host_keys(n);\r\n    std::vector<float> host_values(n);\r\n    for(int i = 0; i < n; i++){\r\n        host_keys[i] = n - i;\r\n        host_values[i] = (n - i) / 2.f;\r\n    }\r\n\r\n    compute::vector<int> keys(host_keys.begin(), host_keys.end(), queue);\r\n    compute::vector<float> values(host_values.begin(), host_values.end(), queue);\r\n\r\n    BOOST_CHECK(compute::is_sorted(keys.begin(), keys.end(), queue) == false);\r\n    BOOST_CHECK(compute::is_sorted(values.begin(), values.end(), queue) == false);\r\n\r\n    compute::sort_by_key(keys.begin(), keys.end(), values.begin(), queue);\r\n\r\n    BOOST_CHECK(compute::is_sorted(keys.begin(), keys.end(), queue) == true);\r\n    BOOST_CHECK(compute::is_sorted(values.begin(), values.end(), queue) == true);\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "401b1b5d4e54b44b0c653d6f7d9ce118b446e147", "size": 3945, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/compute/test/test_sort_by_key.cpp", "max_stars_repo_name": "snichols/boost_1_61_0", "max_stars_repo_head_hexsha": "10142fe2415a0c4ddb72207b5f235cce20f72649", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-05-06T09:03:52.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-06T09:03:52.000Z", "max_issues_repo_path": "libs/compute/test/test_sort_by_key.cpp", "max_issues_repo_name": "snichols/boost_1_61_0", "max_issues_repo_head_hexsha": "10142fe2415a0c4ddb72207b5f235cce20f72649", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/compute/test/test_sort_by_key.cpp", "max_forks_repo_name": "snichols/boost_1_61_0", "max_forks_repo_head_hexsha": "10142fe2415a0c4ddb72207b5f235cce20f72649", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2169811321, "max_line_length": 83, "alphanum_fraction": 0.6256020279, "num_tokens": 989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4649015713733885, "lm_q2_score": 0.18010666848732088, "lm_q1q2_score": 0.08373187319458143}}
{"text": "/**\\file\n * \\page \"Unit Tests\"\r\n *\n * Source: main.cpp (current working version of test code here)\r\n *\r\n * **Unit tests for C++ classes for Category datatype, RDataframe7\n *         datatype and UtilCSV37 CSV Manipulation**\r\n *\r\n *\r\n * @author David York <david@debian2x8david>\r\n * @date Sunday September 4, 2016\r\n * @version 0.3\r\n *\r\n * @brief This is the main() module for Unit testing of the classes related to\n *        the RDataframe data type ( Dataframe )and relevant other code including\n *        that for the category data type the node data type ( Node ) and the CSV\n *        file utilities ( UtilCSV ).\r\n *\r\n *\r\n * &copy; 2016 David York\r\n */\n#include <cstdio>\r\n#include <cstdlib>\r\n#include <cctype>\r\n#include <iostream>\r\n#include <ostream>\r\n#include <fstream>\r\n#include <sstream>\r\n#include <string>\r\n#include <vector>\r\n#include <map>\r\n#include <tuple>\r\n#include <algorithm>\n#include <typeinfo>\n#include <cxxabi.h>\n#include <array>\n#include <initializer_list>\n#include <boost/any.hpp>\n\n#include \"node.hpp\"\n#include \"dataframe.hpp\"\n#include \"utilCSV.hpp\"\n#include \"category.hpp\"\n\nusing namespace std;\n\n/**\n * \\page \"Unit Tests\"\n *  @brief The main() function is a non-member function related to testing of the\n *  classes  Node, RDataframe, Category, UtilCSV\n * \\fn \"the main function\"\n *  The Unit Test suite for the Node and Dataframe classes\n *  @param argc, an int argument (optional)\n *  @param argv, a character array\n *  @return an int, 0 if runs successfully (ie. no errors)\n */\n\nint main(int argc, char **argv)\n{\n/**\n * \\page \" \"\n * \\section \"RDataframe Unit Tests\"\n *  \\subsection \"Test Documentation\"\n * This part of the main() function is related to both the Node class\n * and the Dataframe class. When run is complete it will have called all\n * functions of the two classes as well as any external calls to the UtilsCSV\n * library in order to test import of disk file datasets into the Dataframe\n * objects.\n */\n\n    cout << \"   Dataframe Unit Test Suite:\" << endl;\n    cout << \"   =========================\" << endl << endl;\n    cout << \"       Getting test data. . .\" << endl << endl;\r\n    /** Make working data arrays for unit tests\r\n    *   from AirPassengers.csv, a base R dataset */\r\n    initializer_list<int> data[13];\r\n    initializer_list<string> colHead = {\"Date\",\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"};\r\n    data[0] = {1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960};\r\n    data[1] = {112, 115, 145, 171, 196, 204, 242, 284, 315, 340, 360, 417};\r\n    data[2] = {118, 126, 150, 180, 196, 188, 233, 277, 301, 318, 342, 391};\r\n    data[3] = {132, 141, 178, 193, 236, 235, 267, 317, 356,362, 406, 419};\r\n    data[4] = {129, 135, 163, 181, 235, 227, 269, 313, 348, 348, 396, 461};\r\n    data[5] = {121, 125, 172, 183, 229, 234, 270, 318, 355, 363, 420, 472};\r\n    data[6] = {135, 149, 178, 218, 243, 264, 315, 374, 422, 435, 472, 535};\r\n    data[7] = {148, 170, 199, 230, 264, 302, 364, 413, 465, 491, 548, 622};\r\n    data[8] = {148, 170, 199, 242, 272, 293, 347, 405, 467, 505, 559, 606};\r\n    data[9] = {136, 158, 184, 209, 237, 259, 312, 355, 404, 404, 463, 508};\r\n    data[10] = {119, 133, 162, 191, 211, 229, 274, 306, 347, 359, 407, 461};\r\n    data[11] = {104, 114, 146, 172, 180, 203, 237, 271, 305, 310, 362, 390};\r\n    data[12] = {118, 140, 166, 194, 201, 229, 278, 306, 336, 337, 405, 432};\r\n    vector<string> cnames {colHead};\r\n    vector<int> year {data[0]};\r\n    vector<int> jan {data[1]};\r\n    vector<int> feb {data[2]};\r\n    vector<int> mar {data[3]};\r\n    vector<int> apr {data[4]};\r\n    vector<int> may {data[5]};\r\n    vector<int> jun {data[6]};\r\n    vector<int> jul {data[7]};\r\n    vector<int> aug {data[8]};\r\n    vector<int> sep {data[9]};\r\n    vector<int> oct {data[10]};\r\n    vector<int> nov {data[11]};\r\n    vector<int> dec {data[12]};\r\n\r\n\n    /** NODE TESTS */\n    cout << endl << \"  Node Specific Tests \" << endl;\n    cout << \"  ------------------- \" << endl << endl;\n    string vName;\n    string vType;\r\n    int vNumber;\n    void* pVData;\n    int r;\n\n    /** test default constructors*/\r\n    vName = \"Date\";\r\n    vType = \"int\";\r\n    vNumber = 0;\n    pVData =&year;\n    r = year.size();\r\n    node variable1;\r\n    variable1.setNodeContent(r, vName, vType, vNumber, pVData);\r\n    cout << \" NODE #: \" << vNumber << endl;\r\n    variable1.displayNode();\n    cout << endl;\n\n /** test full constructors */\n    vName = \"Jan\";\r\n    vType = \"int\";\r\n    vNumber = 1;\n    pVData = &jan;\n    r = jan.size();\n\r\n    node variable2(r, vName, vType, vNumber, pVData);\r\n    cout << \"NODE #: \" << vNumber << endl;\r\n    variable2.displayNode();\n    cout << endl << endl;\n\n\r\n\n\n    /** test various class methods */\n    /**    Setters */\n    cout << \" testing setters . . .\"<<endl;\n    cout << \"   change variable name and type\" << endl;\n    cout<<endl;\n    variable2.setVarName(\"other\");\n    variable2.setVarType(\"long\");\n    cout << \"   show new or adjusted name and type\"<< endl;\n    variable2.displayName_Type();\n    cout << \"   change position number \" <<endl;\n    variable2.setVarNumber(3);\n    variable2.setVarDataRows(30);\n    cout << \"   show changed position number and nrows and display the whole amended node,\" << endl;\n    variable2.displayNode();\n    cout<<endl;\n\n    r = jan.size();\n    cout << \"  return contents to original and display the node again.\" <<endl;\n    variable2.setNodeContent(r, vName, vType, vNumber, pVData);\n    cout << \" show meta-data and data vector now . . \" << endl;\n    cout << \" NODE #: \" << vNumber << endl;\n    variable2.displayNode();\n    cout << endl << endl;\n\n    cout << \" Check Node.toString() function, \" << endl << variable2.toString() << endl << endl;\n\n    /**    Getters */\n    cout << \" Check All the Getters,\" << endl;\n    cout << \"   getting variable data pointer: \" << variable1.getVarData() << endl;\n    cout << \"   getting variable name:         \" << variable1.getVarName() << endl;\n    cout << \"   getting variable type:         \" << variable1.getVarType() << endl;\n    cout << \"   getting variable position number: \" << variable1.getVarNumber() << endl;\n    cout << \"   getting number of variable data rows: \" << variable1.getNRows() << endl<< endl;\n    cout << \"   get variable data range:          \" << endl;\n    void* retDataPtr = variable2.getVarDataRange(4,10);\n    vector<int>* extrIntDataPtr = ((vector<int>*)retDataPtr);\n    cout << \"returned recast vector size: \" << (*extrIntDataPtr).size() << endl;\n    vector<int> extrData = (*extrIntDataPtr);\n    cout << \"returned recast vector size: \" << extrData.size() << endl;\n    for(unsigned int i = 0; i < extrData.size(); ++i) {\n                    cout << extrData[i] << endl;\n                }\n    cout << endl;\n\n\n    /** Testing different data types\n     *  string */\n    cout << endl << endl;\n    cout << \"  Create and test a string variable \" << endl << endl;\n    initializer_list<string> strData = {\"Date\",\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"};\n    vector<string> months {strData};\n    vName = \"Month\";\r\n    vType = \"string\";\r\n    vNumber = 0;\n    pVData = &months;\n    r = months.size();\n\r\n    node variable5s(r, vName, vType, vNumber, pVData);\r\n    cout << \"NODE #: \" << vNumber << endl;\r\n    variable5s.displayNode();\n\n    cout << endl;\n    cout << \"extract some elements fro the string variable vector\" << endl;\n    retDataPtr = variable5s.getVarDataRange(4,10);\n    vector<string>* extrStrDataPtr = ((vector<string>*)retDataPtr);\n    cout << \"returned recast vector size: \" << (*extrStrDataPtr).size() << endl;\n    vector<string> extrStrData = (*extrStrDataPtr);\n    cout << \"returned recast vector size: \" << extrStrData.size() << endl;\n    for(unsigned int i = 0; i < extrStrData.size(); ++i) {\n        cout << extrStrData[i] << endl;\n    }\n    cout << endl << endl;\n\n\n    /** double type */\n    cout << \"  Create and test a double variable\" << endl << endl;\n    initializer_list<double> dblData {2.3413,5.23, 23.56, 198.0, 7.11042, 734.9992, 19.1945, 3.1415962, 45, 30.2, 7565.11, 629.023};\n    vector<double> rndNumbs {dblData};\n    vName = \"randoms\";\r\n    vType = \"double\";\r\n    vNumber = 0;\n    pVData = &rndNumbs;\n    r = rndNumbs.size();\n\r\n    node variable5d(r, vName, vType, vNumber, pVData);\r\n    cout << \"NODE #: \" << vNumber << endl;\r\n    variable5d.displayNode();\n\n    cout << endl;\n    cout << \"extract some elements fro the double variable vector\" << endl;\n    retDataPtr = variable5d.getVarDataRange(4,10);\n    vector<double>* extrDblDataPtr = ((vector<double>*)retDataPtr);\n    cout << \"returned recast vector size: \" << (*extrDblDataPtr).size() << endl;\n    vector<double> extrDblData = (*extrDblDataPtr);\n    cout << \"returned recast vector size: \" << extrDblData.size() << endl;\n    for(unsigned int i = 0; i < extrDblData.size(); ++i) {\n        cout << extrDblData[i] << endl;\n    }\n    cout << endl;\n    cout << endl << endl;\n    cout << \"  ************************************* \" << endl <<endl;\n    /** DATAFRAME TESTS */\n    /** test default constructors*/\n    cout << \"  Dataframe SpecificTests \"<< endl;\n    cout << \"  ----------------------- \" <<endl << endl;\n    dataframe dfTest;\n    cout << \"  dfTest an empty dataframe constructed, awaits meta-data and data variables \" << endl<<endl;\n\n    /** test full constructors */\n\n    /** test various class methods */\n\n    cout << endl << \"  ************************************* \" << endl;\n\n\n\n/**\n * \\section \"UtilCSV Unit Tests\"\n *  \\subsection \"Test Documentation\"\n * This part of the main() function is related to both the UtilCSB class\n * and thefunctions there-in. When the run is complete it will have called\n * all functions of the class as well as any external calls in\n * order to test import of disk file datasets.\n */\n\n    /** UTILCSV TESTS*/\n    string frmCSV =\"./data/AirPassengersNoHeader.csv\";\n    bool hHeader = true;\n    utilCSV Airpass(frmCSV, hHeader);\n    cout << \"  UtilCSV Unit Test Suite:\" << endl;\n    cout << \"  =======================\" << endl<< endl;\n    cout << \" Getting test data. . .\"<< endl<<endl;\n    cout << \" no. cols: \" << Airpass.getNcols() << endl;\n    cout << \" no. rows: \" << Airpass.getNrows() << endl;\r\n    Airpass.displayInternCSV();\n    Airpass.displayColNames();\n    Airpass.displayStrDataStruct();\n    vector<vector<string> > strDStruct = Airpass.getStrDataStruct();\r\n    Airpass.writeCSV(strDStruct, \"datafile.csv\");\n    vector<string> newCols;\n        newCols.push_back(\"Date\");\n        newCols.push_back(\"Jan\");\n        newCols.push_back(\"Feb\");\n        newCols.push_back(\"Mar\");\n        newCols.push_back(\"Apr\");\n        newCols.push_back(\"May\");\n        newCols.push_back(\"Jun\");\n        newCols.push_back(\"Jul\");\n        newCols.push_back(\"Aug\");\n        newCols.push_back(\"Sep\");\n        newCols.push_back(\"Oct\");\n        newCols.push_back(\"Nov\");\n        newCols.push_back(\"Dec\");\n    Airpass.setColNames(newCols);\n    Airpass.displayInternCSV();\n    Airpass.displayColNames();\n    Airpass.displayStrDataStruct();\n    vector<vector<string> > sDS = Airpass.getStrDataStruct();\n    Airpass.writeCSV(Airpass.getStrDataStruct(), \"./data/newHeader.csv\");\n    cout << endl << endl;\n\n\n    // Now make a df from the string data structure and stor in a data frame\n    dataframe dfAirpass(\"dfAirPass\", 11, 13);\n    cout << \"  New dataframe:  \" << dfAirpass.getDataFrameName() << endl<< endl;\n    cout << \"  old string frame: again \" << endl << endl<< endl;\n    Airpass.displayStrDataStruct();\n    vector<vector<string> > sDStruct = sDS;\n    // read nR = 11 elements into column colNumber = 12\n    dfAirpass.readRowsSDS(sDS, 11, 5);\n    // read all 11 elements of all 12 columns\n    dfAirpass.convertCSVtoDF(sDStruct, 11, 13);\n\n\n\n    /** Category data type TESTS */\n    cout << endl<<endl<<endl;\n    cout << \"  ==============================\" << endl;\n    cout << \"  CATEGORY type Unit Test Suite:\" << endl;\n    cout << \"  ==============================\" << endl<< endl;\n    cout << endl<<endl;\n\n\n\n\n    cout << \"   All Tests Completed\"<< endl;\n\n    return 0;\n}\n", "meta": {"hexsha": "c362f17dcba82ff791fbd19971a8c2d9a4e3395e", "size": 12029, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "main.cpp", "max_stars_repo_name": "medmatix/libanalysis", "max_stars_repo_head_hexsha": "140629153d8921dae4bc3105989762ee7f8f311e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.cpp", "max_issues_repo_name": "medmatix/libanalysis", "max_issues_repo_head_hexsha": "140629153d8921dae4bc3105989762ee7f8f311e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.cpp", "max_forks_repo_name": "medmatix/libanalysis", "max_forks_repo_head_hexsha": "140629153d8921dae4bc3105989762ee7f8f311e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.2319277108, "max_line_length": 132, "alphanum_fraction": 0.5925679608, "num_tokens": 3510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3629692055196168, "lm_q2_score": 0.22541661583507672, "lm_q1q2_score": 0.08181928996057847}}
{"text": "//  (C) Copyright Gennadiy Rozental 2001-2015.\r\n//  Distributed under the Boost Software License, Version 1.0.\r\n//  (See accompanying file LICENSE_1_0.txt or copy at \r\n//  http://www.boost.org/LICENSE_1_0.txt)\r\n//\r\n//  See http://www.boost.org/libs/test for the library home page.\r\n//\r\n\r\n//[snippet12\r\n#define __BOOST_TEST_MODULE__ MyTest\r\n#include <boost/test/unit_test.hpp>\r\n\r\nint add( int i, int j ) { return i + j; }\r\n\r\n__BOOST_AUTO_TEST_CASE__(my_test)\r\n{\r\n  // six ways to detect and report the same error:\r\n\r\n  // continues on error\r\n  __BOOST_TEST__( add(2, 2) == 4 );          /*<\r\n                                          This approach uses tool __BOOST_TEST__, which displays an error message (by default on `std::cout`) that includes\r\n                                          the expression that failed, as well as the values on the two side of the equation, the source file name,\r\n                                          and the source file line number. It also increments the error count. At program termination,\r\n                                          the error count will be displayed automatically by the __UTF__.>*/\r\n  \r\n  // throws on error\r\n  __BOOST_TEST_REQUIRE__( add(2, 2) == 4 );  /*<\r\n                                          This approach uses tool __BOOST_TEST_REQUIRE__, is similar to approach #1, except that after displaying the error,\r\n                                          an exception is thrown, to be caught by the __UTF__. This approach is suitable when writing an\r\n                                          explicit test program, and the error would be so severe as to make further testing impractical.\r\n                                          >*/\r\n  \r\n  //continues on error\r\n  if (add(2, 2) != 4)\r\n    __BOOST_ERROR__( \"Ouch...\" );            /*< \r\n                                          This approach is similar to approach #1, except that the error detection and error reporting are coded separately.\r\n                                          This is most useful when the specific condition being tested requires several independent statements and/or is\r\n                                          not indicative of the reason for failure.\r\n                                          >*/\r\n  \r\n  // throws on error\r\n  if (add(2, 2) != 4)\r\n    __BOOST_FAIL__( \"Ouch...\" );             /*<\r\n                                         This approach is similar to approach #2, except that the error detection and error reporting are coded separately.\r\n                                         This is most useful when the specific condition being tested requires several independent statements and/or is\r\n                                         not indicative of the reason for failure.\r\n                                         >*/\r\n  \r\n  // throws on error\r\n  if (add(2, 2) != 4)\r\n    throw \"Ouch...\";                     /*<\r\n                                         This approach throws an exception, which will be caught and reported by the __UTF__. The error\r\n                                         message displayed when the exception is caught will be most meaningful if the exception is derived from\r\n                                         `std::exception`, or is a `char*` or `std::string`.\r\n                                         >*/\r\n  \r\n  // continues on error\r\n  __BOOST_TEST__( add(2, 2) == 4,            /*<\r\n                                                           This approach uses tool __BOOST_TEST__ with additional message argument, is similar to approach #1, \r\n                                                           except that similar to the approach #3 displays an alternative error message specified as a second argument.\r\n                                                           >*/\r\n              \"2 plus 2 is not 4 but \" << add(2, 2));\r\n}\r\n//]\r\n", "meta": {"hexsha": "3a47a79f7c307b86edcc89358acf2ecc6bbc9aea", "size": 3839, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/snippet/snippet12.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/snippet/snippet12.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-03-04T11:21:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-24T01:36:31.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/snippet/snippet12.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 59.0615384615, "max_line_length": 168, "alphanum_fraction": 0.5121125293, "num_tokens": 715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4532618480153861, "lm_q2_score": 0.1801066684873209, "lm_q1q2_score": 0.08163548139845758}}
{"text": "// Use, modification and distribution are subject to the\r\n// Boost Software License, Version 1.0.\r\n// (See accompanying file LICENSE_1_0.txt\r\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n// Copyright Paul A. Bristow 2015.\r\n// Copyright Christopher Kormanyos 2015.\r\n// Copyright Nikhar Agrawal 2015.\r\n\r\n// This file is written to be included from a Quickbook .qbk document.\r\n// It can be compiled by the C++ compiler, and run. Any output can\r\n// also be added here as comment or included or pasted in elsewhere.\r\n// Caution: this file contains Quickbook markup as well as code\r\n// and comments: don't change any of the special comment markups!\r\n\r\n// This file also includes Doxygen-style documentation about the function of the code.\r\n// See http://www.doxygen.org for details.\r\n\r\n//! \\file\r\n\r\n// Below are snippets of code that can be included into a Quickbook file.\r\n\r\n#include <iostream>\r\n#include <iomanip>\r\n#include <exception>\r\n#include <typeinfo>\r\n#include <limits>\r\n\r\n#include <boost/cstdint.hpp>\r\n\r\n//[fixed_point_include_1\r\n#include <boost/fixed_point/fixed_point.hpp>\r\n//] [/fixed_point_include_1]\r\n\r\n/*\r\n! Show numeric_limits values for a type.\r\n\\tparam T floating-point, fixed-point type.\r\n\\param os std::ostream, default @c std::cout\r\n*/\r\n\r\n// static int Functions to access template parameters for fixed_point \r\n// that are missing for fundamental integral and floating-point types.\r\n// Version selected on whether is not arithmetic, is floating_point or is integral.\r\n\r\ntemplate <typename NumericalType,\r\n          typename EnableType = void>\r\nstruct numerical_details\r\n{\r\n  static int get_range     () { return 0; }\r\n  static int get_resolution() { return 0; }\r\n};\r\n\r\n/*! Deduce fixed-point if @c std::is_class (so exclude @c bool, @c int...) and not arithmetic (exclude @c float, @c double...).\r\n*/\r\ntemplate <typename NumericalType>\r\nstruct numerical_details<NumericalType,\r\n                         typename std::enable_if<   (std::is_arithmetic<NumericalType>::value == false)\r\n                                                 && (std::is_class<NumericalType>::value      == true)>::type>\r\n{\r\n  static int get_range     () { return NumericalType::range; }\r\n  static int get_resolution() { return NumericalType::resolution; }\r\n};\r\n\r\n/*! Deduce fundamental floating-point type @c float, @c double or @c long double. \r\n*/\r\n\r\ntemplate <typename NumericalType>\r\nstruct numerical_details<NumericalType,\r\n                         typename std::enable_if<std::is_floating_point<NumericalType>::value>::type>\r\n{\r\n  static int get_range     () { return 0; }\r\n  static int get_resolution() { return std::numeric_limits<NumericalType>::digits; }\r\n};\r\n\r\n/*! Deduce fundamental integral type.\r\n*/\r\ntemplate <typename NumericalType>\r\nstruct numerical_details<NumericalType,\r\n                         typename std::enable_if<std::is_integral<NumericalType>::value>::type>\r\n{\r\n  static int get_range     () { return std::numeric_limits<NumericalType>::digits; }\r\n  static int get_resolution() { return 0; }\r\n};\r\n\r\ntemplate <typename T>\r\nvoid show_fixed_point(std::ostream& os = std::cout)\r\n{\r\n  using boost::fixed_point::negatable;\r\n\r\n  os.precision(std::numeric_limits<T>::max_digits10);\r\n\r\n  os << \"Numeric_limits of type: \"\r\n     << typeid(T).name()\r\n     << \"\\n range        = \" << numerical_details<T>::get_range() // \r\n     << \"\\n resolution   = \" << numerical_details<T>::get_resolution()\r\n     << \"\\n radix        = \" << std::numeric_limits<T>::radix  // Always 2 for fixed-point.\r\n     << \"\\n digits       = \" << std::numeric_limits<T>::digits; // Does not include any sign bit.\r\n\r\n  if (std::is_signed<T>::value == true)\r\n  {\r\n    os << \"\\n signed \"\r\n       << \"\\n total bits =   \" << std::numeric_limits<T>::digits + 1; // DOES include sign bit.\r\n  }\r\n\r\n  if (std::numeric_limits<T>::is_exact == false)\r\n  { // epsilon has meaning.\r\n    os << \"\\n epsilon      = \" << std::numeric_limits<T>::epsilon();\r\n  }\r\n  else\r\n  {\r\n    os << \"\\n exact        = \"  << std::numeric_limits<T>::is_exact;\r\n  }\r\n\r\n  // Avoid char values showing as a character or squiggle.\r\n  BOOST_CONSTEXPR_OR_CONST bool is_any_character_type = (   std::is_same<T, signed char>::value \r\n                                                         || std::is_same<T, unsigned char>::value\r\n                                                         || std::is_same<T, char16_t>::value\r\n                                                         || std::is_same<T, char32_t>::value);\r\n\r\n  os << \"\\n lowest       = \";\r\n  if(is_any_character_type)\r\n  {\r\n    os << static_cast<boost::int32_t>(std::numeric_limits<T>::lowest());\r\n  }\r\n  else\r\n  {\r\n    os << std::numeric_limits<T>::lowest();\r\n  }\r\n\r\n  BOOST_CONSTEXPR_OR_CONST bool is_8bit_character_type = (   std::is_same<T, signed char>::value\r\n                                                          || std::is_same<T, unsigned char>::value);\r\n\r\n  os << \"\\n min          = \";\r\n  if(is_8bit_character_type)\r\n  {\r\n    os << static_cast<boost::int32_t>((std::numeric_limits<T>::min)());\r\n  }\r\n  else\r\n  {\r\n    os << (std::numeric_limits<T>::min)();\r\n  }\r\n\r\n  os << \"\\n max          = \";\r\n  if(is_8bit_character_type)\r\n  {\r\n    os << static_cast<boost::int32_t>((std::numeric_limits<T>::max)());\r\n  }\r\n  else\r\n  {\r\n    os << (std::numeric_limits<T>::max)();\r\n  }\r\n\r\n  os << \"\\n max_exponent = \" << std::numeric_limits<T>::max_exponent\r\n     << \"\\n min_exponent = \" << std::numeric_limits<T>::min_exponent\r\n     << \"\\n digits10     = \" << std::numeric_limits<T>::digits10\r\n     << \"\\n max_digits10 = \" << std::numeric_limits<T>::max_digits10\r\n     << \"\\n\"\r\n     << std::endl;\r\n} // template <typename T> void show_fixed_point\r\n\r\nint main()\r\n{\r\n  using boost::fixed_point::negatable;\r\n\r\n  typedef negatable<15,  -16> fixed_point_type_15m16;\r\n  typedef negatable<11,  -20> fixed_point_type_11m20;\r\n  typedef negatable< 0,  -31> fixed_point_type_0m31;\r\n  typedef negatable<29,   -2> fixed_point_type_29m2;\r\n  typedef negatable<0,  -168> fixed_point_type_0m168;\r\n  typedef negatable<20, -148> fixed_point_type_20m148;\r\n\r\n  try\r\n  {\r\n    std::cout.setf(std::ios_base::boolalpha | std::ios_base::showpoint); // Show any trailing zeros.\r\n    std::cout << std::endl;\r\n\r\n//[fixed_example_1\r\n\r\n\r\n    // Show all the significant digits for this particular type.\r\n\r\n    // Fundamental (built-in) integral types.\r\n    show_fixed_point<bool>              ();\r\n    show_fixed_point<signed char>       ();\r\n    show_fixed_point<unsigned char>     ();\r\n    show_fixed_point<char16_t>          (); // Shows as type unsigned short.\r\n    show_fixed_point<char32_t>          (); // Shows as type unsigned int.\r\n    show_fixed_point<short int>         ();\r\n    show_fixed_point<unsigned short int>();\r\n    show_fixed_point<int>               ();\r\n    show_fixed_point<unsigned int>      ();\r\n\r\n   // Fundamental (built-in) floating-point types.\r\n    show_fixed_point<float>();\r\n    // digits 24 (leaving 8 for decimal exponent).\r\n    // epsilon 1.2e-7.\r\n\r\n    show_fixed_point<double>();\r\n    // digits 53 (leaving 10 for decimal exponent).\r\n    // epsilon 2.2e-16.\r\n    show_fixed_point<long double>();\r\n    // Varies with compiler\r\n    // Using MSVC double == long double\r\n\r\n//] [/fixed_example_1]\r\n\r\n\r\n// Some fixed_point types using only a single 8-bit byte (signed char).\r\n\r\n//[fixed_point_15m16\r\n\r\n    // Some fixed_point types using 32 bits, and more.\r\n    show_fixed_point<fixed_point_type_15m16> (); // Even split bits between range and resolution. \r\n    show_fixed_point<fixed_point_type_11m20> (); // More resolution than range.\r\n    show_fixed_point<fixed_point_type_0m31>  (); // All bits used for resolution.\r\n    show_fixed_point<fixed_point_type_29m2>  (); // Most bits used for range.\r\n    show_fixed_point<fixed_point_type_0m168> ();\r\n    show_fixed_point<fixed_point_type_20m148>();\r\n\r\n    //std::cout << \"fixed_point_type(123) / 100 = \"\r\n    //  << x // 1.22999573 is the nearest representation of decimal digit string 1.23.\r\n    //  << std::endl;\r\n  }\r\n  catch (std::exception ex)\r\n  {\r\n    std::cout << ex.what() << std::endl;\r\n  }\r\n}\r\n\r\n/*\r\n//[fixed_point_type_examples_output_1\r\n\r\n\r\n//] [/fixed_point_type_examples_output_1]\r\n*/\r\n", "meta": {"hexsha": "4cdd8c26b8b9e7df1b417f89b3c3c3fbb6e37006", "size": 8163, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/fixed_point_type_examples.cpp", "max_stars_repo_name": "BoostGSoC15/fixed-point", "max_stars_repo_head_hexsha": "d71b4a622ded821a2429d8d857097441c2a10246", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "example/fixed_point_type_examples.cpp", "max_issues_repo_name": "BoostGSoC15/fixed-point", "max_issues_repo_head_hexsha": "d71b4a622ded821a2429d8d857097441c2a10246", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "example/fixed_point_type_examples.cpp", "max_forks_repo_name": "BoostGSoC15/fixed-point", "max_forks_repo_head_hexsha": "d71b4a622ded821a2429d8d857097441c2a10246", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5889830508, "max_line_length": 128, "alphanum_fraction": 0.6241577851, "num_tokens": 2010, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4960938145706678, "lm_q2_score": 0.16451645880021026, "lm_q1q2_score": 0.08161559760585442}}
{"text": "/*\r\n [auto_generated]\r\n libs/numeric/odeint/test/n_step_iterator.cpp\r\n\r\n [begin_description]\r\n This file tests the n-step iterator.\r\n [end_description]\r\n\r\n Copyright 2009-2013 Karsten Ahnert\r\n Copyright 2009-2013 Mario Mulansky\r\n\r\n Distributed under the Boost Software License, Version 1.0.\r\n (See accompanying file LICENSE_1_0.txt or\r\n copy at http://www.boost.org/LICENSE_1_0.txt)\r\n */\r\n\r\n\r\n#define BOOST_TEST_MODULE odeint_n_step_iterator\r\n\r\n#include <iterator>\r\n#include <algorithm>\r\n#include <vector>\r\n\r\n#include <boost/numeric/odeint/config.hpp>\r\n#include <boost/array.hpp>\r\n#include <boost/range/algorithm/for_each.hpp>\r\n#include <boost/range/algorithm/copy.hpp>\r\n#include <boost/mpl/vector.hpp>\r\n\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/test/floating_point_comparison.hpp>\r\n\r\n#include <boost/numeric/odeint/iterator/n_step_iterator.hpp>\r\n#include \"dummy_steppers.hpp\"\r\n#include \"dummy_odes.hpp\"\r\n#include \"dummy_observers.hpp\"\r\n\r\nnamespace mpl = boost::mpl;\r\nusing namespace boost::numeric::odeint;\r\n\r\ntypedef dummy_stepper::state_type state_type;\r\ntypedef dummy_stepper::value_type value_type;\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE( n_step_iterator_test )\r\n\r\ntypedef mpl::vector<\r\n    dummy_stepper\r\n    , dummy_dense_output_stepper\r\n    > dummy_steppers;\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers )\r\n{\r\n    typedef n_step_iterator< Stepper , empty_system , state_type > iterator_type;\r\n    state_type x = {{ 1.0 }};\r\n    iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.1 , 10 );\r\n    iterator_type iter2 = iter1;\r\n    BOOST_CHECK_EQUAL( &(*iter1) , &(*iter2) );\r\n    BOOST_CHECK_EQUAL( &(*iter1) , &x );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n}\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers )\r\n{\r\n    typedef n_step_iterator< Stepper , empty_system , state_type > iterator_type;\r\n    state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};\r\n    iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.1 , 10 );\r\n    iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.2 , 10 );\r\n    BOOST_CHECK_EQUAL( &(*iter1) , &x1 );\r\n    BOOST_CHECK_EQUAL( &(*iter2) , &x2 );\r\n    BOOST_CHECK( !iter1.same( iter2 ) );\r\n    iter2 = iter1;\r\n    BOOST_CHECK_EQUAL( &(*iter1) , &x1 );\r\n    BOOST_CHECK_EQUAL( &(*iter2) , &x1 );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers )\r\n{\r\n    Stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    std::for_each(\r\n        make_n_step_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.1 , 10 ) ,\r\n        make_n_step_iterator_end( stepper , boost::ref( system ) , x ) ,\r\n        dummy_observer() );\r\n\r\n    // dummy_steppers just add 0.25 at each step, the above for_each leads to 10 do_step calls so x should be 3.5\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-13 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers )\r\n{\r\n    Stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    boost::for_each( make_n_step_range( stepper , boost::ref( system ) , x , 0.0 , 0.1 , 10 ) ,\r\n                     dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-13 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers )\r\n{\r\n    Stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    std::for_each(\r\n        make_n_step_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.1 , 10 ) ,\r\n        make_n_step_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,\r\n        dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-13 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers )\r\n{\r\n    Stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    boost::for_each( make_n_step_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.1 , 10 ) ,\r\n                     dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-13 );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )\r\n{\r\n    typedef n_step_iterator< Stepper , empty_system , state_type > stepper_iterator;\r\n\r\n    state_type x = {{ 1.0 }};\r\n    stepper_iterator first1( Stepper() , empty_system() , x , 2.5 , 0.1 , 0 );\r\n    stepper_iterator last1( Stepper() , empty_system() , x );\r\n    stepper_iterator last2( Stepper() , empty_system() , x );\r\n\r\n    BOOST_CHECK( last1 == last2 );\r\n    BOOST_CHECK( first1 != last1 );\r\n    BOOST_CHECK( ++first1 == last1 );\r\n}\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )\r\n{\r\n    typedef n_step_iterator< Stepper , empty_system , state_type > stepper_iterator;\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    stepper_iterator first( Stepper() , empty_system() , x , 0.0 , 0.1 , 3 );\r\n    stepper_iterator last( Stepper() , empty_system() , x );\r\n\r\n    std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 1.75 , 1.0e-14 );     // the iterator should not iterate over the end\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_negative_time_step , Stepper , dummy_steppers )\r\n{\r\n    typedef n_step_iterator< Stepper , empty_system , state_type > stepper_iterator;\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    stepper_iterator first( Stepper() , empty_system() , x , 0.3 , -0.1 , 3 );\r\n    stepper_iterator last( Stepper() , empty_system() , x );\r\n\r\n    std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 1.75 , 1.0e-14 );\r\n}\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )\r\n{\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    std::copy( make_n_step_iterator_begin( Stepper() , empty_system() , x , 0.0 , 0.1 , 3 ) ,\r\n               make_n_step_iterator_end( Stepper() , empty_system() , x ) ,\r\n               std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 1.75 , 1.0e-14 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )\r\n{\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    boost::range::copy( make_n_step_range( Stepper() , empty_system() , x , 0.0 , 0.1 , 3 ) ,\r\n                        std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 1.75 , 1.0e-14 );\r\n}\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "6a8c00e608e53027ac4b24b0233781dfa72b9d4e", "size": 7859, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/n_step_iterator.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/n_step_iterator.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/n_step_iterator.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 34.7743362832, "max_line_length": 114, "alphanum_fraction": 0.6399032956, "num_tokens": 2343, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.43014734858584286, "lm_q2_score": 0.1895210844630953, "lm_q1q2_score": 0.08152199198291402}}
{"text": "/** nonfinite_num_facet_serialization.cpp\r\n *\r\n * Copyright (c) 2011 Francois Mauger\r\n * Copyright (c) 2011 Paul A. Bristow\r\n *\r\n * Distributed under the Boost Software License, Version 1.0.\r\n * (See accompanying file LICENSE_1_0.txt\r\n * or copy at http://www.boost.org/LICENSE_1_0.txt)\r\n *\r\n * This sample program by Francois Mauger illustrates how to use the\r\n * `boost/math/nonfinite_num_facets.hpp'  material  from the  original\r\n * Floating Point  Utilities contribution by  Johan Rade.  Here  it is\r\n * shown  how  non  finite  floating  number  can  be  serialized  and\r\n * deserialized from  I/O streams and/or Boost  text/XML archives.  It\r\n * produces two archives stored in `test.txt' and `test.xml' files.\r\n *\r\n * Tested with Boost 1.44, gcc 4.4.1, Linux/i686 (32bits).\r\n * Tested with Boost.1.46.1  MSVC 10.0 32 bit.\r\n */\r\n\r\n#ifdef _MSC_VER\r\n#   pragma warning(push)\r\n//#   pragma warning(disable : 4100) // unreferenced formal parameter.\r\n#endif\r\n\r\n#include <iostream>\r\n#include <sstream>\r\n#include <fstream>\r\n#include <limits>\r\n\r\n#include <boost/cstdint.hpp>\r\n#include <boost/serialization/nvp.hpp>\r\n#include <boost/archive/text_oarchive.hpp>\r\n#include <boost/archive/text_iarchive.hpp>\r\n#include <boost/archive/xml_oarchive.hpp>\r\n#include <boost/archive/xml_iarchive.hpp>\r\n#include <boost/archive/codecvt_null.hpp>\r\n\r\n// from the Floating Point Utilities :\r\n#include <boost/math/special_functions/nonfinite_num_facets.hpp>\r\n\r\nstatic const char sep = ','; // Separator of bracketed float and double values.\r\n\r\n// Use max_digits10 (or equivalent) to obtain \r\n// all potentially significant decimal digits for the floating-point types.\r\n    \r\n#ifdef BOOST_NO_CXX11_NUMERIC_LIMITS\r\n  std::streamsize  max_digits10_float = 2 + std::numeric_limits<float>::digits * 30103UL / 100000UL;\r\n  std::streamsize  max_digits10_double = 2 + std::numeric_limits<double>::digits * 30103UL / 100000UL;\r\n#else\r\n  // Can use new C++0X max_digits10 (the maximum potentially significant digits).\r\n  std::streamsize  max_digits10_float = std::numeric_limits<float>::max_digits10;\r\n  std::streamsize  max_digits10_double = std::numeric_limits<double>::max_digits10;\r\n#endif\r\n\r\n\r\n/* A class with a float and a double */\r\nstruct foo\r\n{\r\n  foo () : fvalue (3.1415927F), dvalue (3.1415926535897931)\r\n  { // Construct using 32 and 64-bit max_digits10 decimal digits value of pi.\r\n  }\r\n  // Set the values at -infinity :\r\n  void minus_infinity ()\r\n  {\r\n    fvalue = -std::numeric_limits<float>::infinity ();\r\n    dvalue = -std::numeric_limits<double>::infinity ();\r\n    return;\r\n  }\r\n  // Set the values at +infinity :\r\n  void plus_infinity ()\r\n  {\r\n    fvalue = +std::numeric_limits<float>::infinity ();\r\n    dvalue = +std::numeric_limits<double>::infinity ();\r\n    return;\r\n  }\r\n  // Set the values at NaN :\r\n  void nan ()\r\n  {\r\n    fvalue = +std::numeric_limits<float>::quiet_NaN ();\r\n    dvalue = +std::numeric_limits<double>::quiet_NaN ();\r\n    return;\r\n  }\r\n  // Print :\r\n  void print (std::ostream & a_out, const std::string & a_title)\r\n  {\r\n    if (a_title.empty ()) a_out << \"foo\";\r\n    else a_out << a_title;\r\n    a_out << \" : \" << std::endl;\r\n    a_out << \"|-- \" << \"fvalue = \";\r\n    a_out.precision (7);\r\n    a_out << fvalue << std::endl;\r\n    a_out << \"`-- \" << \"dvalue = \";\r\n    a_out.precision (15);\r\n    a_out << dvalue << std::endl;\r\n    return;\r\n  }\r\n\r\n  // I/O operators :\r\n  friend std::ostream & operator<< (std::ostream & a_out, const foo & a_foo);\r\n  friend std::istream & operator>> (std::istream & a_in, foo & a_foo);\r\n\r\n  // Boost serialization :\r\n  template <class Archive>\r\n  void serialize (Archive & ar, int /*version*/)\r\n  {\r\n    ar & BOOST_SERIALIZATION_NVP (fvalue);\r\n    ar & BOOST_SERIALIZATION_NVP (dvalue);\r\n    return;\r\n  }\r\n\r\n  // Attributes :\r\n  float  fvalue; // Single precision floating-point number.\r\n  double dvalue; // Double precision floating-point number.\r\n};\r\n\r\nstd::ostream & operator<< (std::ostream & a_out, const foo & a_foo)\r\n{ // Output bracketed FPs, for example \"(3.1415927,3.1415926535897931)\"\r\n  a_out.precision (max_digits10_float);\r\n  a_out << \"(\" << a_foo.fvalue << sep ;\r\n  a_out.precision (max_digits10_double);\r\n  a_out << a_foo.dvalue << \")\";\r\n  return a_out;\r\n}\r\n\r\nstd::istream & operator>> (std::istream & a_in, foo & a_foo)\r\n{ // Input bracketed floating-point values into a foo structure,\r\n  // for example from \"(3.1415927,3.1415926535897931)\"\r\n  char c = 0;\r\n  a_in.get (c);\r\n  if (c != '(')\r\n  {\r\n    std::cerr << \"ERROR: operator>> No ( \" << std::endl;\r\n    a_in.setstate(std::ios::failbit);\r\n    return a_in;\r\n  }\r\n  float f;\r\n  a_in >> std::ws >> f;\r\n  if (! a_in)\r\n  {\r\n    return a_in;\r\n  }\r\n  a_in >> std::ws;\r\n  a_in.get (c);\r\n  if (c != sep)\r\n  {\r\n    std::cerr << \"ERROR: operator>> c='\" << c << \"'\" << std::endl;\r\n    std::cerr << \"ERROR: operator>> No '\" << sep << \"'\" << std::endl;\r\n    a_in.setstate(std::ios::failbit);\r\n    return a_in;\r\n  }\r\n  double d;\r\n  a_in >> std::ws >> d;\r\n  if (! a_in)\r\n  {\r\n    return a_in;\r\n  }\r\n  a_in >> std::ws;\r\n  a_in.get (c);\r\n  if (c != ')')\r\n  {\r\n    std::cerr << \"ERROR: operator>> No ) \" << std::endl;\r\n    a_in.setstate(std::ios::failbit);\r\n    return a_in;\r\n  }\r\n  a_foo.fvalue = f;\r\n  a_foo.dvalue = d;\r\n  return a_in;\r\n}\r\n\r\nint main (void)\r\n{\r\n  std::clog << std::endl\r\n      << \"Nonfinite_serialization.cpp' example program.\" << std::endl;\r\n\r\n#ifdef BOOST_NO_CXX11_NUMERIC_LIMITS\r\n  std::cout << \"BOOST_NO_CXX11_NUMERIC_LIMITS is defined, so no max_digits10 available either,\"\r\n     \"using our own version instead.\" << std::endl;\r\n#endif  \r\n  std::cout << \"std::numeric_limits<float>::max_digits10 is \" << max_digits10_float << std::endl;\r\n  std::cout << \"std::numeric_limits<double>::max_digits10 is \" << max_digits10_double << std::endl;\r\n\r\n  std::locale the_default_locale (std::locale::classic (),\r\n          new boost::archive::codecvt_null<char>);\r\n\r\n  // Demonstrate use of nonfinite facets with stringstreams.\r\n  {\r\n    std::clog << \"Construct some foo structures with a finite and nonfinites.\" << std::endl;\r\n    foo f0;\r\n    foo f1; f1.minus_infinity ();\r\n    foo f2; f2.plus_infinity ();\r\n    foo f3; f3.nan ();\r\n    // Display them.\r\n    f0.print (std::clog, \"f0\");\r\n    f1.print (std::clog, \"f1\");\r\n    f2.print (std::clog, \"f2\");\r\n    f3.print (std::clog, \"f3\");\r\n    std::clog << \" Write to a string buffer.\" << std::endl;\r\n\r\n    std::ostringstream oss;\r\n    std::locale the_out_locale (the_default_locale, new boost::math::nonfinite_num_put<char>);\r\n    oss.imbue (the_out_locale);\r\n    oss.precision (max_digits10_double);\r\n    oss << f0 << f1 << f2 << f3;\r\n    std::clog << \"Output is: `\" << oss.str () << \"'\" << std::endl;\r\n    std::clog << \"Done output to ostringstream.\" << std::endl;\r\n  }\r\n\r\n  {\r\n    std::clog << \"Read foo structures from a string buffer.\" << std::endl;\r\n\r\n    std::string the_string = \"(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)\";\r\n    std::clog << \"Input is: `\" << the_string << \"'\" << std::endl;\r\n\r\n    std::locale the_in_locale (the_default_locale, new boost::math::nonfinite_num_get<char>);\r\n    std::istringstream iss (the_string);\r\n    iss.imbue (the_in_locale);\r\n\r\n    foo f0, f1, f2, f3;\r\n    iss >> f0 >> f1 >> f2 >> f3;\r\n    if (! iss)\r\n    {\r\n      std::cerr << \"Format error !\" << std::endl;\r\n    }\r\n    else\r\n    {\r\n      std::cerr << \"Read OK.\" << std::endl;\r\n      f0.print (std::clog, \"f0\");\r\n      f1.print (std::clog, \"f1\");\r\n      f2.print (std::clog, \"f2\");\r\n      f3.print (std::clog, \"f3\");\r\n    }\r\n    std::clog << \"Done input from istringstream.\" << std::endl;\r\n  }\r\n\r\n  {  // Demonstrate use of nonfinite facets for Serialization with Boost text archives.\r\n    std::clog << \"Serialize (using Boost text archive).\" << std::endl;\r\n    // Construct some foo structures with a finite and nonfinites.\r\n    foo f0;\r\n    foo f1; f1.minus_infinity ();\r\n    foo f2; f2.plus_infinity ();\r\n    foo f3; f3.nan ();\r\n    // Display them.\r\n    f0.print (std::clog, \"f0\");\r\n    f1.print (std::clog, \"f1\");\r\n    f2.print (std::clog, \"f2\");\r\n    f3.print (std::clog, \"f3\");\r\n\r\n    std::locale the_out_locale (the_default_locale, new boost::math::nonfinite_num_put<char>);\r\n    std::ofstream fout (\"nonfinite_archive_test.txt\");\r\n    fout.imbue (the_out_locale);\r\n    boost::archive::text_oarchive toar (fout, boost::archive::no_codecvt);\r\n    // Write to archive.\r\n    toar & f0;\r\n    toar & f1;\r\n    toar & f2;\r\n    toar & f3;\r\n    std::clog << \"Done.\" << std::endl;\r\n  }\r\n\r\n  {\r\n    std::clog << \"Deserialize (Boost text archive)...\" << std::endl;\r\n    std::locale the_in_locale (the_default_locale, new boost::math::nonfinite_num_get<char>);\r\n    std::ifstream fin (\"nonfinite_archive_test.txt\");\r\n    fin.imbue (the_in_locale);\r\n    boost::archive::text_iarchive tiar (fin, boost::archive::no_codecvt);\r\n    foo f0, f1, f2, f3;\r\n    // Read from archive.\r\n    tiar & f0;\r\n    tiar & f1;\r\n    tiar & f2;\r\n    tiar & f3;\r\n    // Display foos.\r\n    f0.print (std::clog, \"f0\");\r\n    f1.print (std::clog, \"f1\");\r\n    f2.print (std::clog, \"f2\");\r\n    f3.print (std::clog, \"f3\");\r\n\r\n    std::clog << \"Done.\" << std::endl;\r\n  }\r\n\r\n  {   // Demonstrate use of nonfinite facets for Serialization with Boost XML Archive.\r\n    std::clog << \"Serialize (Boost XML archive)...\" << std::endl;\r\n    // Construct some foo structures with a finite and nonfinites.\r\n    foo f0;\r\n    foo f1; f1.minus_infinity ();\r\n    foo f2; f2.plus_infinity ();\r\n    foo f3; f3.nan ();\r\n     // Display foos.\r\n    f0.print (std::clog, \"f0\");\r\n    f1.print (std::clog, \"f1\");\r\n    f2.print (std::clog, \"f2\");\r\n    f3.print (std::clog, \"f3\");\r\n\r\n    std::locale the_out_locale (the_default_locale, new boost::math::nonfinite_num_put<char>);\r\n    std::ofstream fout (\"nonfinite_XML_archive_test.txt\");\r\n    fout.imbue (the_out_locale);\r\n    boost::archive::xml_oarchive xoar (fout, boost::archive::no_codecvt);\r\n\r\n    xoar & BOOST_SERIALIZATION_NVP (f0);\r\n    xoar & BOOST_SERIALIZATION_NVP (f1);\r\n    xoar & BOOST_SERIALIZATION_NVP (f2);\r\n    xoar & BOOST_SERIALIZATION_NVP (f3);\r\n    std::clog << \"Done.\" << std::endl;\r\n  }\r\n\r\n  {\r\n    std::clog << \"Deserialize (Boost XML archive)...\" << std::endl;\r\n    std::locale the_in_locale (the_default_locale, new boost::math::nonfinite_num_get<char>);\r\n    std::ifstream fin (\"nonfinite_XML_archive_test.txt\");\r\n    fin.imbue (the_in_locale);\r\n    boost::archive::xml_iarchive xiar (fin, boost::archive::no_codecvt);\r\n    foo f0, f1, f2, f3;\r\n\r\n    xiar & BOOST_SERIALIZATION_NVP (f0);\r\n    xiar & BOOST_SERIALIZATION_NVP (f1);\r\n    xiar & BOOST_SERIALIZATION_NVP (f2);\r\n    xiar & BOOST_SERIALIZATION_NVP (f3);\r\n\r\n    f0.print (std::clog, \"f0\");\r\n    f1.print (std::clog, \"f1\");\r\n    f2.print (std::clog, \"f2\");\r\n    f3.print (std::clog, \"f3\");\r\n\r\n    std::clog << \"Done.\" << std::endl;\r\n  }\r\n\r\n  std::clog << \"End nonfinite_serialization.cpp' example program.\" << std::endl;\r\n  return 0;\r\n}\r\n\r\n/*\r\n\r\nOutput:\r\n\r\n  Nonfinite_serialization.cpp' example program.\r\n  std::numeric_limits<float>::max_digits10 is 8\r\n  std::numeric_limits<double>::max_digits10 is 17\r\n  Construct some foo structures with a finite and nonfinites.\r\n  f0 : \r\n  |-- fvalue = 3.141593\r\n  `-- dvalue = 3.14159265358979\r\n  f1 : \r\n  |-- fvalue = -1.#INF\r\n  `-- dvalue = -1.#INF\r\n  f2 : \r\n  |-- fvalue = 1.#INF\r\n  `-- dvalue = 1.#INF\r\n  f3 : \r\n  |-- fvalue = 1.#QNAN\r\n  `-- dvalue = 1.#QNAN\r\n   Write to a string buffer.\r\n  Output is: `(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)'\r\n  Done output to ostringstream.\r\n  Read foo structures from a string buffer.\r\n  Input is: `(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)'\r\n  Read OK.\r\n  f0 : \r\n  |-- fvalue = 3.141593\r\n  `-- dvalue = 3.14159265358979\r\n  f1 : \r\n  |-- fvalue = -1.#INF\r\n  `-- dvalue = -1.#INF\r\n  f2 : \r\n  |-- fvalue = 1.#INF\r\n  `-- dvalue = 1.#INF\r\n  f3 : \r\n  |-- fvalue = 1.#QNAN\r\n  `-- dvalue = 1.#QNAN\r\n  Done input from istringstream.\r\n  Serialize (using Boost text archive).\r\n  f0 : \r\n  |-- fvalue = 3.141593\r\n  `-- dvalue = 3.14159265358979\r\n  f1 : \r\n  |-- fvalue = -1.#INF\r\n  `-- dvalue = -1.#INF\r\n  f2 : \r\n  |-- fvalue = 1.#INF\r\n  `-- dvalue = 1.#INF\r\n  f3 : \r\n  |-- fvalue = 1.#QNAN\r\n  `-- dvalue = 1.#QNAN\r\n  Done.\r\n  Deserialize (Boost text archive)...\r\n  f0 : \r\n  |-- fvalue = 3.141593\r\n  `-- dvalue = 3.14159265358979\r\n  f1 : \r\n  |-- fvalue = -1.#INF\r\n  `-- dvalue = -1.#INF\r\n  f2 : \r\n  |-- fvalue = 1.#INF\r\n  `-- dvalue = 1.#INF\r\n  f3 : \r\n  |-- fvalue = 1.#QNAN\r\n  `-- dvalue = 1.#QNAN\r\n  Done.\r\n  Serialize (Boost XML archive)...\r\n  f0 : \r\n  |-- fvalue = 3.141593\r\n  `-- dvalue = 3.14159265358979\r\n  f1 : \r\n  |-- fvalue = -1.#INF\r\n  `-- dvalue = -1.#INF\r\n  f2 : \r\n  |-- fvalue = 1.#INF\r\n  `-- dvalue = 1.#INF\r\n  f3 : \r\n  |-- fvalue = 1.#QNAN\r\n  `-- dvalue = 1.#QNAN\r\n  Done.\r\n  Deserialize (Boost XML archive)...\r\n  f0 : \r\n  |-- fvalue = 3.141593\r\n  `-- dvalue = 3.14159265358979\r\n  f1 : \r\n  |-- fvalue = -1.#INF\r\n  `-- dvalue = -1.#INF\r\n  f2 : \r\n  |-- fvalue = 1.#INF\r\n  `-- dvalue = 1.#INF\r\n  f3 : \r\n  |-- fvalue = 1.#QNAN\r\n  `-- dvalue = 1.#QNAN\r\n  Done.\r\n  End nonfinite_serialization.cpp' example program.\r\n\r\n  */\r\n", "meta": {"hexsha": "5e67ed65ac9bcaa19c85e4e3427cb92b65c22393", "size": 13089, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/math/example/nonfinite_num_facet_serialization.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 85.0, "max_stars_repo_stars_event_min_datetime": "2015-02-08T20:36:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T20:38:31.000Z", "max_issues_repo_path": "libs/boost/libs/math/example/nonfinite_num_facet_serialization.cpp", "max_issues_repo_name": "flingone/frameworks_base_cmds_remoted", "max_issues_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 9.0, "max_issues_repo_issues_event_min_datetime": "2015-01-28T16:33:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T23:03:28.000Z", "max_forks_repo_path": "libs/boost/libs/math/example/nonfinite_num_facet_serialization.cpp", "max_forks_repo_name": "flingone/frameworks_base_cmds_remoted", "max_forks_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 27.0, "max_forks_repo_forks_event_min_datetime": "2015-01-28T16:33:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-12T05:04:39.000Z", "avg_line_length": 30.4395348837, "max_line_length": 103, "alphanum_fraction": 0.6040950416, "num_tokens": 4071, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.16238003463996278, "lm_q1q2_score": 0.08119001731998139}}
{"text": "// Date Last Altered: $Date: 2008-08-04 22:55:41 -0600 (Mon, 04 Aug 2008) $\n// Revision Number: $Revision: 344 $\n//----------------------------------*-C++-*------------------------------------//\n/*! \\file Dimension.hh\n *  \\author Greg Davidson\n *  \\date August 4, 2007\n *\n *  \\brief Provides the \\c Dimension class template and \\c DimensionConcept \n *         concept.\n *\n *  This file provides the \\c Dimension class template and the \n *  \\c DimensionConcept concept.  The \\c Dimension class stores what spatial \n *  dimension we are working in.  The \\c DimensionConcept sets the functionality \n *  that a \\c Dimension type must satisfy. */\n\n#ifndef DIMENSION_HH\n#define DIMENSION_HH\n\n#include <boost/static_assert.hpp>\n#include <boost/concept_check.hpp>\n\n#include \"Types.hh\"\n\nusing boost::function_requires;\nusing boost::UnsignedIntegerConcept;\n\n/*! \\addtogroup MeshMod Mesh Module\n *  @{  */\n \n/// Defines the type that stores the dimension number.\ntypedef UnsignedInt2  DimensionValue;\n\n/*! \\brief Stores what spatial dimension we are working in.\n *\n *  This class depicts what spatial dimension we are working\n *  in.\n *  \\par Template Parameters: \n *     <dl> <dt> \\e val </dt>\n *          <dd> This is the numerical value of the spatial dimension.  Valid\n *               values are 1, 2, and 3. </dd> </dl> */\ntemplate<DimensionValue val>\nclass Dimension\n{\npublic:\n   /*! \\brief This static assert is used to ensure that only spatial\n    *         values of 1, 2, or 3 are used. */\n   BOOST_STATIC_ASSERT(val <= 3 && val != 0);\n   \n   /// Define \\c type as the type of this class.\n   typedef Dimension<val>     type;\n   /// Define the type of the spatial dimension value.\n   typedef DimensionValue     value_type;\n   /// Stores the numerical value of the spatial dimension.\n   static const value_type    value = val;\n};\n\n/// Defines the \\c OneD type as a \\c Dimension<1>.\ntypedef Dimension<1>   OneD;\n/// Defines the \\c TwoD type as a \\c Dimension<2>.\ntypedef Dimension<2>   TwoD;\n/// Defines the \\c ThreeD type as a \\c Dimension<3>.\ntypedef Dimension<3>   ThreeD;\n\n\n/*! \\brief The \\c DimensionConcept concept class ensures that a type\n *         provides the \\c Dimension functionality.\n *\n *  The \\c DimensionConcept concept class ensures that a type\n *  provides the functionality necessary to function as a \\c Dimension\n *  instantiation.\n *  \\par Template Parameters:\n *     <dl> <dt> \\e dimension_type </dt>\n *          <dd> This is the type we wish to check for concept \n *               compatibility. </dd> </dl>\n *  \\par Concept Requirements:\n *       The following types must be provided by the \\c dimension_type type:\n *       <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n *          <TR>  <TD> \\arg \\c type </TD> \n *                <TD> The type of the \\c Dimension template. </TD> </TR>\n *          <TR>  <TD> \\arg \\c value_type </TD> \n *                <TD> The value of the spatial dimension. </TD> </TR>\n *       </TABLE>\n *       The following functionality must be provided by the \\c dimension_type type:\n *       \\arg The \\c value_type type must satisfy the \\c boost::UnsignedIntegerConcept concept.\n *       \\arg The \\a value must be between 1 and 3 inclusively.\n *  \\remarks  It should be noted that this class is compiled but never executed, so concept\n *            checking does not imply any runtime overhead. */\ntemplate<typename dimension_type>\nclass DimensionConcept\n{\npublic:\n   /// Alias the \\c dimension_type as a \\c DimensionType.\n   typedef dimension_type                       DimensionType;\n   /// Require the \\c DimensionType to provide a \\c type.\n   typedef typename DimensionType::type         type;\n   /// Require the \\c DimensionType to provide a \\c value_type.\n   typedef typename DimensionType::value_type   value_type;\n\n   /*! \\brief The constraints method tests that the \\c dimension_type \n    *         provides certain functionality. */\n   void constraints()\n   {\n      function_requires< UnsignedIntegerConcept<value_type> >();\n      \n      BOOST_STATIC_ASSERT(DimensionType::value <= 3 \n                              && DimensionType::value != 0);\n   }\n};\n\n///  @}\n\n#endif\n\n", "meta": {"hexsha": "7bc0e404a51505201a2ca51342049b406d9ccf68", "size": 4150, "ext": "hh", "lang": "C++", "max_stars_repo_path": "Code/trunk/cpp/Geometry/CartesianMesh/Dimension.hh", "max_stars_repo_name": "jlconlin/PhDThesis", "max_stars_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Code/trunk/cpp/Geometry/CartesianMesh/Dimension.hh", "max_issues_repo_name": "jlconlin/PhDThesis", "max_issues_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Code/trunk/cpp/Geometry/CartesianMesh/Dimension.hh", "max_forks_repo_name": "jlconlin/PhDThesis", "max_forks_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4035087719, "max_line_length": 95, "alphanum_fraction": 0.6448192771, "num_tokens": 1014, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4263215779698935, "lm_q2_score": 0.18952109590739918, "lm_q1q2_score": 0.08079693266582595}}
{"text": "/*! \\file demo_annotation.cpp\n    \\brief Demonstration of 2D 'note' annotation.\n    \\details Adding a text annotation to a plot, changing its color, font and/or orientation.\n*/\n\n// Copyright Paul A. Bristow 2009, 2020\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[demo_2d_annotation_1\n\n/*`First we need some includes to use Boost.Plot and C++ Standard Library:\n*/#include <boost/svg_plot/svg_2d_plot.hpp>\nusing namespace boost::svg;\n\n//#include <boost/svg_plot/show_2d_settings.hpp>\n// using boost::svg::show_2d_plot_settings - Only needed for showing which settings in use.\n\n#include <map>\n  //using std::map;\n\n#include <iostream>\n  // using std::cout;\n //  using std::endl;\n   //using std::scientific;\n   //using std::hex;\n   //using std::ios;\n   //using std::boolalpha;\n\nint main()\n{\n  try\n  {\n//[demo_2d_annotation_2\n\n/*`\nThis shows how to add notes to a plot, for example to identify a particular area or point.\n*/\n\n  std::map<double, double> my_data;\n\n  my_data[1.1] = 3.2;\n  my_data[4.3] = 3.1;\n  my_data[0.25] = 1.4;\n\n  \n  /*`\n  First construct, size and draw a simple plot ready to add some sample annotation.\n  */\n  svg_2d_plot my_plot;\n  my_plot.size(400, 300);\n  my_plot.plot(my_data, \"my_data\").fill_color(red);\n  /*`Now add a string note at the SVG coordinates X = 100 and Y =200.\n  */\n  my_plot.draw_note(150, 200, \"My 1st (default) Note\");\n\n  text_style mini_note_style(7, \"verdana\", \"italic\", \"bold\"); \n  // Used for note showing origin at top left and bottom right below.\n  /*`\n  Note that for SVG coordinates, Y increases *down* the page, so Y = 0 is the top and Y = 300 is the bottom.\n  Defaults are provided for size, text style = no_text_style, center alignment and rotation horizontal.\n  */\n  my_plot.draw_note(7, 7, \"top left (0, 0)\", rotate_style::downward , align_style::left_align, red, mini_note_style);\n  my_plot.draw_note(my_plot.image_x_size()-3, my_plot.image_y_size()-3, \"bottom right(400, 300)\", rotate_style::horizontal, align_style::right_align, red, mini_note_style);\n\n/*`Using enum center_align is strongly recommended because it will ensure that note will center correctly\n(even if note-string is made much longer because it contains Unicode,\nfor example Greek, taking about 6 characters per symbol)\nbecause the render engine does the centering.\n\nYou can use either plain char space or Unicode spaces like \\&#x00A0;\n*/\n  my_plot.draw_note(150, 100, \"Greek Unicode &#x3A9;&#x3A6;&#x221A;&#x00A0;&#x221E;&#x3B6; &#x00B1;\");\n/*`You can change the font, but defining a new text_style, for example: */\n  \n  text_style my_note_style(16, \"verdana\", \"italic\", \"bold\"); // Used for note below.\n  \n/*`and you can change the alignment and rotation using enums align_style and rotate_style.\n*/\n  my_plot.draw_note(350, 70, \"My 2nd Note\", slopeup, align_style::right_align, black, my_note_style);\n\n/*`To change the color to red (and text style, alignment and rotation too, just for fun:)\n*/\n  text_style my_red_note_style(16, \"arial\", \"italic\", \"bold\");\n\n  std::cout << \"my_red_note_style \" << my_red_note_style << std::endl;\n  // my_red_note_style text_style(16, \"arial\", \"bold\", \"italic\", \"\", \"\")\n  my_plot.draw_note(350, 170, \"Red upsidedown Note\",  rotate_style::upsidedown, align_style::left_align, red, my_red_note_style);\n  my_plot.draw_note(300, 210, \"Blue steepup Note\", rotate_style::steepup, align_style::center_align, blue);\n\n  my_plot.write(\"./demo_annotation\");\n\n  // show_2d_plot_settings(my_plot); // Optional diagnostics.\n\n  //] [/demo_2d_annotation_2]\n  \n  }\n  catch (const std::exception& e)\n  {\n    std::cout <<\n      \"\\n\"\"Message from thrown exception was:\\n   \" << e.what() << std::endl;\n  }\n  return 0;\n} // int main()\n\n/*\n\nOutput :\n\n*/\n/*\n\n*/\n", "meta": {"hexsha": "cecfa9722f8d94c4adf7ab379627c3c0b1c34121", "size": 4181, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_annotation.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_annotation.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_annotation.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 33.9918699187, "max_line_length": 172, "alphanum_fraction": 0.7079646018, "num_tokens": 1171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.341582512843634, "lm_q2_score": 0.23651623106411435, "lm_q1q2_score": 0.08078980853518575}}
{"text": "//==============================================================================\n//         Copyright 2003 - 2012   LASMEA UMR 6602 CNRS/Univ. Clermont II\n//         Copyright 2009 - 2012   LRI    UMR 8623 CNRS/Univ Paris Sud XI\n//\n//          Distributed under the Boost Software License, Version 1.0.\n//                 See accompanying file LICENSE.txt or copy at\n//                     http://www.boost.org/LICENSE_1_0.txt\n//==============================================================================\n#include <boost/simd/boolean/include/functions/logical_ornot.hpp>\n#include <boost/simd/sdk/simd/io.hpp>\n#include <boost/dispatch/meta/as_integer.hpp>\n#include <nt2/sdk/unit/tests/relation.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/unit/tests/type_expr.hpp>\n#include <nt2/sdk/meta/as_logical.hpp>\n#include <nt2/sdk/meta/as_integer.hpp>\n\n#include <boost/simd/include/constants/one.hpp>\n#include <boost/simd/include/constants/inf.hpp>\n#include <boost/simd/include/constants/zero.hpp>\n#include <boost/simd/include/constants/minf.hpp>\n#include <boost/simd/include/constants/mone.hpp>\n#include <boost/simd/include/constants/nan.hpp>\n#include <boost/simd/include/constants/true.hpp>\n#include <boost/simd/include/constants/false.hpp>\n#include <boost/simd/sdk/simd/io.hpp>\n\nNT2_TEST_CASE_TPL ( logical_ornot_real__2_0,  BOOST_SIMD_REAL_TYPES)\n{\n\n  using boost::simd::logical_ornot;\n  using boost::simd::tag::logical_ornot_;\n  using boost::simd::logical;\n  using boost::simd::True;\n  using boost::simd::False;\n  typedef typename boost::dispatch::meta::call<logical_ornot_(T, T)>::type r_t;\n  typedef typename nt2::meta::as_logical<T>::type lT;\n  typedef lT wished_r_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n  // specific values tests\n  NT2_TEST_EQUAL(logical_ornot(T(0), T(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(T(1), T(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Inf<T>(),  T(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Minf<T>(), T(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Nan<T>(),  T(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Zero<T>(), T(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(False<lT>(), T(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(True<lT>(), T(1)), True<lT>());\n\n\n} // end of test for floating_\n\nNT2_TEST_CASE_TPL ( logical_ornot_signed_int__2_0,  BOOST_SIMD_INTEGRAL_SIGNED_TYPES)\n{\n\n  using boost::simd::logical_ornot;\n  using boost::simd::tag::logical_ornot_;\n  using boost::simd::logical;\n  using boost::simd::False;\n  using boost::simd::True;\n  typedef typename boost::dispatch::meta::call<logical_ornot_(T, T)>::type r_t;\n  typedef typename nt2::meta::as_logical<T>::type lT;\n  typedef lT wished_r_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n  // specific values tests\n  NT2_TEST_EQUAL(logical_ornot(T(0), T(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(T(1), T(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(False<lT>(), T(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(True<lT>(), T(1)), True<lT>());\n} // end of test for signed_int_\n\nNT2_TEST_CASE_TPL ( logical_ornot_mix,  BOOST_SIMD_REAL_TYPES)\n{\n\n  using boost::simd::logical_ornot;\n  using boost::simd::tag::logical_ornot_;\n  using boost::simd::logical;\n  using boost::simd::True;\n  using boost::simd::False;\n  typedef typename boost::dispatch::meta::call<logical_ornot_(T, T)>::type r_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::as_logical<T>::type lT;\n  typedef lT wished_r_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n  // specific values tests\n  NT2_TEST_EQUAL(logical_ornot(T(0), iT(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(T(1), iT(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Inf<T>(),  iT(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Minf<T>(), iT(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Nan<T>(),  iT(0)), True<lT>());\n  NT2_TEST_EQUAL(logical_ornot(boost::simd::Zero<T>(), iT(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(False<lT>(), iT(1)), False<lT>());\n  NT2_TEST_EQUAL(logical_ornot(True<lT>(), iT(1)), True<lT>());\n\n\n} // end of test for floating_\n", "meta": {"hexsha": "6be53037a93e5df75f71585949705adfe130a2e0", "size": 4278, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/boost/simd/base/unit/boolean/scalar/logical_ornot.cpp", "max_stars_repo_name": "psiha/nt2", "max_stars_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 34.0, "max_stars_repo_stars_event_min_datetime": "2017-05-19T18:10:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T02:18:13.000Z", "max_issues_repo_path": "modules/boost/simd/base/unit/boolean/scalar/logical_ornot.cpp", "max_issues_repo_name": "psiha/nt2", "max_issues_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/boost/simd/base/unit/boolean/scalar/logical_ornot.cpp", "max_forks_repo_name": "psiha/nt2", "max_forks_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 7.0, "max_forks_repo_forks_event_min_datetime": "2017-12-02T12:59:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-31T12:46:14.000Z", "avg_line_length": 40.358490566, "max_line_length": 85, "alphanum_fraction": 0.6792893876, "num_tokens": 1249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4921881357207955, "lm_q2_score": 0.16238004072020704, "lm_q1q2_score": 0.07992152952034556}}
{"text": "/*! \\file \n    \\brief Demonstration of showing the 1D values.\n    \\details  Showing the 1D values of items from the data set.\n\n    Some of the many possible formatting options are demonstrated,\n    including controlling the precision and iosflags,\n    and prefix and suffix also useful for giving units.\n\n    Quickbook markup to include in documentation.\n*/\n\n// demo_1d_values.cpp\n// \n// Copyright Jacob Voytko 2007\n// Copyright Paul A Bristow 2008, 2009, 2021\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n//   or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// An example to demonstrate labelling data-points with their values and other information.\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[demo_1d_values_1\n\n/*` Showing the 1-D values of items from the data set.\n    Some of the many possible formatting options are demonstrated.\n\n    As ever, we need a few includes to use Boost.Plot\n*/\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\n  using namespace boost::svg;\n  using boost::svg::svg_1d_plot;\n\n  #include <boost/svg_plot/show_1d_settings.hpp>\n// using boost::svg::show_1d_plot_settings - Only needed for showing which settings in use.\n\n#include <iostream>\n  using std::cout;\n  using std::endl;\n  using std::hex;\n\n#include <vector>\n  using std::vector;\n//] [demo_1d_values_1]\n\nint main()\n{\n//[demo_1d_values_2\n/*`Some fictional data is pushed into an STL container, here `vector<double>`:*/\n  vector<double> my_data;\n  my_data.push_back(-1.6);\n  my_data.push_back(2.0);\n  my_data.push_back(4.2563);\n  my_data.push_back(0.00333974);\n  my_data.push_back(5.4);\n  my_data.push_back(6.556);\n\n  try\n  { // try'n'catch blocks are needed to ensure error messages from any exceptions are shown.\n    svg_1d_plot my_1d_plot; // Construct a plot with all the default constructor values.\n\n    my_1d_plot.title(\"Default 1D Values Demo\") // Add a string title of the plot.\n      .x_range(-5, 10) // Add a range for the X-axis.\n      .x_label(\"length (m)\"); // Add a label for the X-axis.\n\n/*`Add the one data series, `my_data` and a description, and how the data points are to marked,\nhere a circle with a diameter of 5 pixels.\n*/\n    my_1d_plot.plot(my_data, \"1D Values\").shape(circlet).size(5);\n\n/*`To put a value-label against each data point, switch on the option:\n*/\n    my_1d_plot.x_values_on(true); // Add a label for the X-axis.\n\n/*`If the default size and color are not to your taste, set more options, like:\n*/\n    my_1d_plot.size(500, 350) // Change from default size\n      .x_values_font_size(14) // Change font size for the X-axis value-labels.\n      .x_values_font_family(\"Times New Roman\") // Change font for the X-axis value-labels.\n      .x_values_color(red); // Change color from default black to red.\n\n/*`The format of the values may also not be ideal,\nso we can use the normal `iostream precision` and `ioflags` to change,\nhere to reduce the number of digits used from default precision 6 down to a more readable 2,\nreducing the risk of collisions between adjacent values.\n(Obviously the most suitable precision depends on the range of the data points.\nIf values are very close to each other, a higher precision wil be needed to differentiate them).\n*/\n    my_1d_plot.x_values_precision(2); // precision label for the X-axis value-label.\n\n/*`We can also prescribe the use of scientific format and force a positive sign:\n*/\n   my_1d_plot.x_values_ioflags(std::ios::scientific | std::ios::showpos);\n\n/*`By default, any unnecessary spacing-wasting zeros in the exponent field are removed.\n(If, perversely, the full 1.123456e+012 format is required, the stripping can be switched off with:\n  `my_1d_plot.x_labels_strip_e0s(false);` )\n\nIn general, sticking to the defaults usually produces the neatest presentation of the values.\n*/\n\n/*`The default value-label is horizontal, centered above the data point marker,\nbut, depending on the type and density of data points, and the length of the values\n(controlled in turn by the `precision` and `ioflags` in use),\nit is often clearer to use a different orientation.\nThis can be controlled in steps of 45 degrees, using an 'enum rotate_style`.\n\n* `uphill` - writing up at 45 degree slope is often a good choice,\n* `upward` - writing vertically up and\n* `backup` are also useful.\n\n(For 1-D plots other directions are less attractive,\nplacing the values below the horizontal Y-axis line,\nbut for 2-D plots all writing orientations can be useful).\n*/\n   my_1d_plot.x_values_rotation(steepup); // Orientation for the X-axis value-labels, nearly vertical.\n\n   my_1d_plot.x_decor(\" [ x = \", \"\", \"&#x00A0;sec]\"); // Note the need for a Unicode space A0 as &#x00A0; .\n\n/*`To use all these settings, finally write the plot to file.\n*/\n    my_1d_plot.write(\"demo_1d_values.svg\");\n\n/*`If chosen settings do not have the effect that you expect, it may be helpful to display some of them!\n(All the myriad settings can be displayed with `show_1d_plot_settings(my_1d_plot)`.)\n*/\n    //show_1d_plot_settings(my_1d_plot);\n    using boost::svg::detail::operator<<;\n    cout << \"my_1d_plot.image_size() \" << my_1d_plot.size() << endl;\n    cout << \"my_1d_plot.image x_size() \" << my_1d_plot.x_size() << endl;\n    cout << \"my_1d_plot.image y_size() \" << my_1d_plot.y_size() << endl;\n    cout << \"my_1d_plot.x_values_font_size() \" << my_1d_plot.x_values_font_size() << endl;\n    cout << \"my_1d_plot.x_values_font_family() \" << my_1d_plot.x_values_font_family() << endl;\n    cout << \"my_1d_plot.x_values_color() \" << my_1d_plot.x_values_color() << endl;\n    cout << \"my_1d_plot.x_values_precision() \" << my_1d_plot.x_values_precision() << endl;\n    cout << \"my_1d_plot.x_values_ioflags() \" << hex << my_1d_plot.x_values_ioflags() << endl;\n//] [demo_1d_values_2]\n  }\n  catch(const std::exception& e)\n  {\n    std::cout <<\n      \"\\n\"\"Message from thrown exception was:\\n   \" << e.what() << std::endl;\n  }\n  return 0;\n} // int main()\n\n/*\n\n//[demo_1d_values_output\n\nOutput:\n\ndemo_1d_values.cpp\nPlot written to file demo_1d_values.svg.\nmy_1d_plot.image_size() 500, 350\nmy_1d_plot.image x_size() 500\nmy_1d_plot.image y_size() 350\nmy_1d_plot.x_values_font_size() 14\nmy_1d_plot.x_values_font_family() Times New Roman\nmy_1d_plot.x_values_color() RGB(255,0,0)\nmy_1d_plot.x_values_precision() 2\nmy_1d_plot.x_values_ioflags() 1020\n\n//] [demo_1d_values_output]\n*/\n\n", "meta": {"hexsha": "d01eeb6e25ac06dda4a2ae85793096b4774f5ea8", "size": 6674, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_1d_values.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_1d_values.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_1d_values.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 37.9204545455, "max_line_length": 107, "alphanum_fraction": 0.7278993108, "num_tokens": 1829, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.37022540649291935, "lm_q2_score": 0.21469142916152645, "lm_q1q2_score": 0.07948422163187192}}
{"text": "// Boost.Geometry (aka GGL, Generic Geometry Library)\r\n\r\n// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.\r\n\r\n// This file was modified by Oracle on 2013, 2014, 2015, 2017.\r\n// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates.\r\n// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle\r\n\r\n// Use, modification and distribution is subject to the Boost Software License,\r\n// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n#ifndef BOOST_GEOMETRY_TEST_RELATE_HPP\r\n#define BOOST_GEOMETRY_TEST_RELATE_HPP\r\n\r\n#include <geometry_test_common.hpp>\r\n\r\n#include <boost/variant.hpp>\r\n\r\n#include <boost/geometry/core/ring_type.hpp>\r\n#include <boost/geometry/algorithms/relate.hpp>\r\n#include <boost/geometry/algorithms/relation.hpp>\r\n#include <boost/geometry/strategies/strategies.hpp>\r\n#include <boost/geometry/geometries/geometries.hpp>\r\n#include <boost/geometry/geometries/point_xy.hpp>\r\n\r\n#include <boost/geometry/io/wkt/read.hpp>\r\n\r\n#include <boost/geometry/strategies/cartesian/point_in_box.hpp>\r\n#include <boost/geometry/strategies/cartesian/box_in_box.hpp>\r\n#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>\r\n\r\nnamespace bgdr = bg::detail::relate;\r\n\r\nstd::string transposed(std::string matrix)\r\n{\r\n    if ( !matrix.empty() )\r\n    {\r\n        std::swap(matrix[1], matrix[3]);\r\n        std::swap(matrix[2], matrix[6]);\r\n        std::swap(matrix[5], matrix[7]);\r\n    }\r\n    return matrix;\r\n}\r\n\r\nbool matrix_compare(std::string const& m1, std::string const& m2)\r\n{\r\n    BOOST_ASSERT(m1.size() == 9 && m2.size() == 9);\r\n    for ( size_t i = 0 ; i < 9 ; ++i )\r\n    {\r\n        if ( m1[i] == '*' || m2[i] == '*' )\r\n            continue;\r\n\r\n        if ( m1[i] != m2[i] )\r\n            return false;\r\n    }\r\n    return true;\r\n}\r\n\r\nbool matrix_compare(std::string const& m, std::string const& res1, std::string const& res2)\r\n{\r\n    return matrix_compare(m, res1)\r\n        || ( !res2.empty() ? matrix_compare(m, res2) : false );\r\n}\r\n\r\nstd::string matrix_format(std::string const& matrix1, std::string const& matrix2)\r\n{\r\n    return matrix1\r\n         + ( !matrix2.empty() ? \" || \" : \"\" ) + matrix2;\r\n}\r\n\r\ntemplate <typename M>\r\nchar get_ii(M const& m)\r\n{\r\n    using bg::detail::relate::interior;\r\n    return m.template get<interior, interior>();\r\n}\r\n\r\ntemplate <typename M>\r\nchar get_ee(M const& m)\r\n{\r\n    using bg::detail::relate::exterior;\r\n    return m.template get<exterior, exterior>();\r\n}\r\n\r\nvoid check_mask()\r\n{\r\n    bg::de9im::mask m1(\"\");\r\n    bg::de9im::mask m2(\"TTT\");\r\n    bg::de9im::mask m3(\"000111222\");\r\n    bg::de9im::mask m4(\"000111222FFFF\");\r\n    bg::de9im::mask m5(std::string(\"\"));\r\n    bg::de9im::mask m6(std::string(\"TTT\"));\r\n    bg::de9im::mask m7(std::string(\"000111222\"));\r\n    bg::de9im::mask m8(std::string(\"000111222FFFF\"));\r\n\r\n    using bg::detail::relate::interior;\r\n    using bg::detail::relate::exterior;\r\n\r\n    BOOST_CHECK(get_ii(m1) == '*' && get_ee(m1) == '*');\r\n    BOOST_CHECK(get_ii(m2) == 'T' && get_ee(m2) == '*');\r\n    BOOST_CHECK(get_ii(m3) == '0' && get_ee(m3) == '2');\r\n    BOOST_CHECK(get_ii(m4) == '0' && get_ee(m4) == '2');\r\n    BOOST_CHECK(get_ii(m5) == '*' && get_ee(m5) == '*');\r\n    BOOST_CHECK(get_ii(m6) == 'T' && get_ee(m6) == '*');\r\n    BOOST_CHECK(get_ii(m7) == '0' && get_ee(m7) == '2');\r\n    BOOST_CHECK(get_ii(m8) == '0' && get_ee(m8) == '2');\r\n}\r\n\r\ntemplate <typename Geometry1, typename Geometry2>\r\nvoid check_geometry(Geometry1 const& geometry1,\r\n                    Geometry2 const& geometry2,\r\n                    std::string const& wkt1,\r\n                    std::string const& wkt2,\r\n                    std::string const& expected1,\r\n                    std::string const& expected2 = std::string())\r\n{\r\n    boost::variant<Geometry1> variant1 = geometry1;\r\n    boost::variant<Geometry2> variant2 = geometry2;\r\n\r\n    {\r\n        std::string res_str = bg::relation(geometry1, geometry2).str();\r\n        bool ok = matrix_compare(res_str, expected1, expected2);\r\n        BOOST_CHECK_MESSAGE(ok,\r\n            \"relate: \" << wkt1\r\n            << \" and \" << wkt2\r\n            << \" -> Expected: \" << matrix_format(expected1, expected2)\r\n            << \" detected: \" << res_str);\r\n\r\n        typedef typename bg::strategy::relate::services::default_strategy\r\n            <\r\n                Geometry1, Geometry2\r\n            >::type strategy_type;\r\n        std::string res_str0 = bg::relation(geometry1, geometry2, strategy_type()).str();\r\n        BOOST_CHECK(res_str == res_str0);\r\n\r\n        // test variants\r\n        boost::variant<Geometry1> v1 = geometry1;\r\n        boost::variant<Geometry2> v2 = geometry2;\r\n        std::string res_str1 = bg::relation(geometry1, variant2).str();\r\n        std::string res_str2 = bg::relation(variant1, geometry2).str();\r\n        std::string res_str3 = bg::relation(variant1, variant2).str();\r\n        BOOST_CHECK(res_str == res_str1);\r\n        BOOST_CHECK(res_str == res_str2);\r\n        BOOST_CHECK(res_str == res_str3);\r\n    }\r\n\r\n    // changed sequence of geometries - transposed result\r\n    {\r\n        std::string res_str = bg::relation(geometry2, geometry1).str();\r\n        std::string expected1_tr = transposed(expected1);\r\n        std::string expected2_tr = transposed(expected2);\r\n        bool ok = matrix_compare(res_str, expected1_tr, expected2_tr);\r\n        BOOST_CHECK_MESSAGE(ok,\r\n            \"relate: \" << wkt2\r\n            << \" and \" << wkt1\r\n            << \" -> Expected: \" << matrix_format(expected1_tr, expected2_tr)\r\n            << \" detected: \" << res_str);\r\n    }\r\n\r\n    if ( expected2.empty() )\r\n    {\r\n        {\r\n            bool result = bg::relate(geometry1, geometry2, bg::de9im::mask(expected1));\r\n            // TODO: SHOULD BE !interrupted - CHECK THIS!\r\n            BOOST_CHECK_MESSAGE(result, \r\n                \"relate: \" << wkt1\r\n                << \" and \" << wkt2\r\n                << \" -> Expected: \" << expected1);\r\n\r\n            typedef typename bg::strategy::relate::services::default_strategy\r\n                <\r\n                    Geometry1, Geometry2\r\n                >::type strategy_type;\r\n            bool result0 = bg::relate(geometry1, geometry2, bg::de9im::mask(expected1), strategy_type());\r\n            BOOST_CHECK(result == result0);\r\n\r\n            // test variants\r\n            bool result1 = bg::relate(geometry1, variant2, bg::de9im::mask(expected1));\r\n            bool result2 = bg::relate(variant1, geometry2, bg::de9im::mask(expected1));\r\n            bool result3 = bg::relate(variant1, variant2, bg::de9im::mask(expected1));\r\n            BOOST_CHECK(result == result1);\r\n            BOOST_CHECK(result == result2);\r\n            BOOST_CHECK(result == result3);\r\n        }\r\n\r\n        if ( BOOST_GEOMETRY_CONDITION((\r\n                bg::detail::relate::interruption_enabled<Geometry1, Geometry2>::value )) )\r\n        {\r\n            // brake the expected output\r\n            std::string expected_interrupt = expected1;\r\n            bool changed = false;\r\n            BOOST_FOREACH(char & c, expected_interrupt)\r\n            {\r\n                if ( c >= '0' && c <= '9' )\r\n                {\r\n                    if ( c == '0' )\r\n                        c = 'F';\r\n                    else\r\n                        --c;\r\n\r\n                    changed = true;\r\n                }\r\n            }\r\n\r\n            if ( changed )\r\n            {\r\n                bool result = bg::relate(geometry1, geometry2, bg::de9im::mask(expected_interrupt));\r\n                // TODO: SHOULD BE interrupted - CHECK THIS!\r\n                BOOST_CHECK_MESSAGE(!result,\r\n                    \"relate: \" << wkt1\r\n                    << \" and \" << wkt2\r\n                    << \" -> Expected interrupt for:\" << expected_interrupt);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\ntemplate <typename Geometry1, typename Geometry2>\r\nvoid test_geometry(std::string const& wkt1,\r\n                   std::string const& wkt2,\r\n                   std::string const& expected1,\r\n                   std::string const& expected2 = std::string())\r\n{\r\n    Geometry1 geometry1;\r\n    Geometry2 geometry2;\r\n    bg::read_wkt(wkt1, geometry1);\r\n    bg::read_wkt(wkt2, geometry2);\r\n    check_geometry(geometry1, geometry2, wkt1, wkt2, expected1, expected2);\r\n}\r\n\r\n#endif // BOOST_GEOMETRY_TEST_RELATE_HPP\r\n", "meta": {"hexsha": "f552a759956f09104e5a38367cb2d53f618eced8", "size": 8307, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/test/algorithms/relational_operations/relate/test_relate.hpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/test/algorithms/relational_operations/relate/test_relate.hpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/test/algorithms/relational_operations/relate/test_relate.hpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 35.652360515, "max_line_length": 106, "alphanum_fraction": 0.567954737, "num_tokens": 2109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4921881357207955, "lm_q2_score": 0.1581743507642642, "lm_q1q2_score": 0.07785153882151039}}
{"text": "/*\r\nThis file is a part of NNTL project (https://github.com/Arech/nntl)\r\n\r\nCopyright (c) 2015-2021, Arech (aradvert@gmail.com; https://github.com/Arech)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are met:\r\n\r\n* Redistributions of source code must retain the above copyright notice, this\r\nlist of conditions and the following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above copyright notice,\r\nthis list of conditions and the following disclaimer in the documentation\r\nand/or other materials provided with the distribution.\r\n\r\n* Neither the name of NNTL nor the names of its\r\ncontributors may be used to endorse or promote products derived from\r\nthis software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n// tests.cpp : Defines the entry point for the console application.\r\n//\r\n\r\n#include \"stdafx.h\"\r\n\r\n//to get rid of '... decorated name length exceeded, name was truncated'\r\n#pragma warning( disable : 4503 )\r\n\r\n#include \"../nntl/nntl.h\"\r\n#include \"../nntl/_supp/io/binfile.h\"\r\n#include \"../nntl/_supp/io/matfile.h\"\r\n\r\n#include \"../nntl/weights_init/LsuvExt.h\"\r\n\r\n#include \"asserts.h\"\r\n#include \"common_routines.h\"\r\n\r\n#include \"nn_base_arch.h\"\r\n\r\nusing namespace nntl;\r\n\r\n\r\ntemplate<typename ArchPrmsT>\r\nstruct GC_ALPHADROPOUT : public nntl_tests::NN_base_arch_td<ArchPrmsT> {\r\n\ttypedef nntl::LFC_DO<activation::selu<real_t>, myGradWorks> testedLFC;\r\n\r\n\ttestedLFC lFinal;\r\n\r\n\t~GC_ALPHADROPOUT()noexcept {}\r\n\tGC_ALPHADROPOUT(const ArchPrms_t& Prms)noexcept\r\n\t\t: lFinal(100, Prms.learningRate, \"lFinal\")\r\n\t{\r\n\t\tlFinal.dropoutPercentActive(Prms.specialDropoutAlivePerc);\r\n\t}\r\n};\r\nTEST(TestSelu, GradCheck_alphaDropout) {\r\n#pragma warning(disable:4459)\r\n\ttypedef double real_t;\r\n\ttypedef nntl_tests::NN_base_params<real_t, nntl::inspector::GradCheck<real_t>> ArchPrms_t;\r\n#pragma warning(default:4459)\r\n\r\n\tnntl::inmem_train_data<real_t> td;\r\n\treadTd(td);\r\n\r\n\tArchPrms_t Prms(td);\r\n\tPrms.specialDropoutAlivePerc = real_t(.75);\r\n\r\n\tnntl_tests::NN_arch<GC_ALPHADROPOUT<ArchPrms_t>> nnArch(Prms);\r\n\r\n\tauto ec = nnArch.warmup(td, 5, 200);\r\n\tASSERT_EQ(decltype(nnArch)::ErrorCode_t::Success, ec) << \"Reason: \" << nnArch.NN.get_error_str(ec);\r\n\r\n\tgradcheck_settings<real_t> ngcSetts(true, true, 1e-4);\r\n\t//ngcSetts.evalSetts.bIgnoreZerodLdWInUndelyingLayer = true;\r\n\tngcSetts.evalSetts.dLdW_setts.relErrFailThrsh = real_t(1e-1);//big error is possible due to selu derivative kink :(\r\n\t//need some handling for it :(\r\n\tSTDCOUTL(\"*** WARNING: there's no handling of SELU discontinious derivative, therefore occational failures are possible :(\");\r\n\tngcSetts.evalSetts.dLdA_setts.percOfZeros = 70;\r\n\tngcSetts.evalSetts.dLdW_setts.percOfZeros = 70;\r\n\tASSERT_TRUE(nnArch.NN.gradcheck(td.train_x(), td.train_y(), 5, ngcSetts));\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//////////////////////////////////////////////////////////////////////////\r\n#pragma warning(push,3)\r\n#include <boost/accumulators/accumulators.hpp>\r\n#include <boost/accumulators/statistics/stats.hpp>\r\n#include <boost/accumulators/statistics/mean.hpp>\r\n#include <boost/accumulators/statistics/variance.hpp>\r\n#pragma warning(pop)\r\n\r\ntemplate<typename RealT, bool bAdjustForSampleVar>\r\nstruct inspector_act_var_checker : public inspector::_impl::_base<RealT> {\r\nprotected:\r\n\ttypedef utils::layer_idx_keeper<layer_index_t, _NoLayerIdxSpecified, 32> keeper_t;\r\n\tkeeper_t m_curLayer;\r\n\r\n\tlayer_index_t m_lastLayerIdxToCheck;\r\n\r\n\t//note that we don't compare variances, calculated with different algos now. We just need precise variance value, and no more\r\n\ttypedef ::boost::accumulators::accumulator_set<ext_real_t\r\n\t\t, ::boost::accumulators::stats<\r\n\t\t::boost::accumulators::tag::mean\r\n\t\t, ::boost::accumulators::tag::lazy_variance\r\n\t\t>\r\n\t> stats_t;\r\n\r\n\tstruct layers_stats_t {\r\n\t\tstats_t sMean;\r\n\t\tstats_t sVar;\r\n\t};\r\n\r\n\ttypedef ::std::vector<layers_stats_t> a_layers_stat_t;\r\n\ta_layers_stat_t m_layersStats;\r\n\r\n\tvoid _calc_neuronwise_stats(const realmtx_t& act, const layer_index_t lidx)noexcept {\r\n\t\tauto& lStats = m_layersStats[lidx];\r\n\r\n\t\tconst ptrdiff_t tr = act.rows();\r\n\t\tauto pA = act.data();\r\n\t\tconst auto pAE = act.colDataAsVec(act.cols_no_bias());\r\n\t\tNNTL_ASSERT(tr > 1);\r\n\t\tconst ext_real_t adjVar = bAdjustForSampleVar ? (static_cast<ext_real_t>(tr) / (tr - 1)) : ext_real_t(1);\r\n\r\n\t\twhile (pA != pAE) {\r\n\t\t\tstats_t st;\r\n\t\t\tconst auto pAEr = pA + tr;\r\n\t\t\twhile (pA != pAEr) {\r\n\t\t\t\tst(*pA++);\r\n\t\t\t}\r\n\r\n\t\t\tlStats.sMean(::boost::accumulators::extract_result<::boost::accumulators::tag::mean>(st));\r\n\t\t\tlStats.sVar(adjVar*::boost::accumulators::extract_result<::boost::accumulators::tag::lazy_variance>(st));\r\n\t\t}\r\n\t}\r\n\r\npublic:\r\n\tvoid init_nnet(const size_t totalLayers, const numel_cnt_t totalEpochs)noexcept {\r\n\t\tNNTL_UNREF(totalEpochs);\r\n\t\tm_lastLayerIdxToCheck = static_cast<layer_index_t>(totalLayers - 2);\r\n\t\tm_layersStats.resize(totalLayers - 1);\r\n\t}\r\n\tvoid fprop_begin(const layer_index_t lIdx, const realmtx_t& prevAct, const bool bTrainingMode) noexcept {\r\n\t\tNNTL_UNREF(prevAct); NNTL_UNREF(bTrainingMode);\r\n\t\tm_curLayer.push(lIdx);\r\n\t}\r\n\tvoid fprop_end(const realmtx_t& act) noexcept {\r\n\t\tif (m_curLayer <= m_lastLayerIdxToCheck) {\r\n\t\t\t_calc_neuronwise_stats(act, m_curLayer);\r\n\t\t}\r\n\r\n\t\tm_curLayer.pop();\r\n\t}\r\n\r\n\ttemplate<typename base_t> struct stats_EPS {};\r\n\ttemplate<> struct stats_EPS<double> {\r\n\t\tstatic constexpr double mean_eps = .07;\r\n\t\tstatic constexpr double var_eps = .17;\r\n\t};\r\n\ttemplate<> struct stats_EPS<float> { \r\n\t\tstatic constexpr float mean_eps = .07f;\r\n\t\tstatic constexpr float var_eps = .17f;\r\n\t};\r\n\r\n\tvoid report_stats(bool bDoAsserts = true)const noexcept {\r\n\t\tfor (unsigned i = 0; i <= m_lastLayerIdxToCheck; ++i) {\r\n\t\t\tSTDCOUTL(\"Reporting data distribution for layer#\" << i << (i ? \" -- SELU\" : \" -- input data\"));\r\n\r\n\t\t\tconst auto& lStats = m_layersStats[i];\r\n\r\n\t\t\tconst ext_real_t _cnt = static_cast<ext_real_t>(::boost::accumulators::count(lStats.sMean));\r\n\t\t\tNNTL_ASSERT(_cnt > 1);\r\n\t\t\tconst ext_real_t adjVar = bAdjustForSampleVar ? (_cnt / (_cnt - 1)) : ext_real_t(1);\r\n\r\n\t\t\tconst auto mean_of_mean = ::boost::accumulators::extract_result<::boost::accumulators::tag::mean>(lStats.sMean);\r\n\t\t\tconst auto var_of_mean = adjVar*::boost::accumulators::extract_result<::boost::accumulators::tag::lazy_variance>(lStats.sMean);\r\n\t\t\tconst auto mean_of_var = ::boost::accumulators::extract_result<::boost::accumulators::tag::mean>(lStats.sVar);\r\n\t\t\tconst auto var_of_var = adjVar*::boost::accumulators::extract_result<::boost::accumulators::tag::lazy_variance>(lStats.sVar);\r\n\r\n\t\t\tprintf_s(\"mean = %05.3f +/- %06.4f, variance = %05.3f +/- %06.4f\\n\", mean_of_mean, ::std::sqrt(var_of_mean)\r\n\t\t\t\t, mean_of_var, ::std::sqrt(var_of_var));\r\n\r\n\t\t\tif (bDoAsserts) {\r\n\t\t\t\t//real_t is a type of underlying data, but we compare calculated statistics value with pre-set value, so with ext_real_t\r\n\t\t\t\tASSERT_NEAR(mean_of_mean, ext_real_t(0), stats_EPS<real_t>::mean_eps);\r\n\t\t\t\tASSERT_NEAR(mean_of_var, ext_real_t(1), stats_EPS<real_t>::var_eps);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n};\r\n\r\ntemplate<typename iRngT>\r\nvoid _test_selu_make_td(inmem_train_data< typename iRngT::real_t >& td, const vec_len_t tr_cnt, const neurons_count_t xwidth, iRngT& iR)noexcept\r\n{\r\n\ttypedef typename iRngT::real_t real_t;\r\n\ttypedef typename iRngT::realmtxdef_t realmtxdef_t;\r\n\r\n\trealmtxdef_t trX(tr_cnt, xwidth, true), trY(tr_cnt, 1), tX(2, xwidth, true), tY(2, 1);\r\n\r\n\trng::distr_normal_naive<iRngT> rg(iR, real_t(0), real_t(1));\r\n\trg.gen_matrix_no_bias(trX); rg.gen_matrix_no_bias(tX);\r\n\r\n\tiR.binary_matrix(trY), iR.binary_matrix(tY);\r\n\r\n\tASSERT_TRUE(td.absorb(::std::move(trX), ::std::move(trY), ::std::move(tX), ::std::move(tY)));\r\n}\r\n\r\n//template<ADCorr corrType, typename RealT>\r\ntemplate<typename RealT>\r\nvoid test_selu_distr(const size_t seedVal, const RealT dpa, const neurons_count_t xwidth = 10, const neurons_count_t nc = 30\r\n\t, const bool bApplyWeightNorm = false, const bool bVerbose = true\r\n\t, const vec_len_t batchSize = 1000, const vec_len_t batchesCnt = 100)noexcept\r\n{\r\n\ttypedef RealT real_t;\r\n\r\n\tconstexpr unsigned _scopeMsgLen = 128;\r\n\tchar _scopeMsg[_scopeMsgLen];\r\n\tsprintf_s(_scopeMsg, \"SELU_Distribution for X=%d/nc=%d with dropout dpa=%04.3f\", xwidth, nc, dpa);\r\n\tSCOPED_TRACE(_scopeMsg);\r\n\tSTDCOUTL(_scopeMsg);\r\n\r\n\tconst real_t learningRate(::std::numeric_limits<real_t>::min());\r\n\r\n\tstruct myIntf : public d_int_nI<real_t> {\r\n\t\ttypedef inspector_act_var_checker<real_t, true> iInspect_t;\r\n\t};\r\n\ttypedef grad_works_f<myIntf\r\n\t\t, GW::ILR_dummy\r\n\t\t, GW::Loss_Addendums_dummy\r\n\t> GrW;\r\n\r\n\t//typedef activation::selu<real_t, 0, 0, 0, 1000000, corrType> mySelu_t;\r\n\ttypedef activation::selu<real_t, 0, 0, 0, 1000000> mySelu_t;\r\n\r\n\tlayer_input<myIntf> inp(xwidth);\r\n\tLFC_DO<mySelu_t, GrW> fcl(nc, learningRate);\r\n\tfcl.dropoutPercentActive(dpa);\r\n#ifndef TESTS_SKIP_LONGRUNNING\r\n\tLFC_DO<mySelu_t, GrW> fcl2(nc, learningRate);\r\n\tfcl2.dropoutPercentActive(dpa);\r\n\tLFC_DO<mySelu_t, GrW> fcl3(nc, learningRate);\r\n\tfcl3.dropoutPercentActive(dpa);\r\n\tLFC_DO<mySelu_t, GrW> fcl4(nc, learningRate);\r\n\tfcl4.dropoutPercentActive(dpa);\r\n#endif\r\n\r\n\tlayer_output<activation::softsigm_quad_loss<real_t>, GrW> outp(1, learningRate);\r\n\r\n#ifdef TESTS_SKIP_LONGRUNNING\r\n\tauto lp = make_layers(inp, fcl, outp);\r\n#else\r\n\tauto lp = make_layers(inp, fcl, fcl2, fcl3, fcl4, outp);\r\n#endif\r\n\r\n\tnnet_train_opts<real_t, training_observer_stdcout<real_t, eval_classification_binary_cached<real_t>>> opts(1);\r\n\topts.batchSize(batchSize);\r\n\r\n\tauto nn = make_nnet(lp);\r\n\r\n\tnn.get_iRng().seed64(seedVal);\r\n\r\n\tinmem_train_data<real_t> td;\r\n\t_test_selu_make_td(td, batchesCnt*batchSize, xwidth, nn.get_iRng());\r\n\r\n\r\n\tif (bApplyWeightNorm) {\r\n\t\ttypedef weights_init::procedural::LSUVExt<decltype(nn), ::std::decay_t<decltype(td)>> winit_t;\r\n\t\twinit_t::LayerSetts_t def, outpS;\r\n\r\n\t\tdef.bOverPreActivations = false;\r\n\t\tdef.bCentralNormalize = true;\r\n\t\tdef.bScaleNormalize = true;\r\n\t\tdef.bOnInvidualNeurons = true;\r\n\t\tdef.maxTries = 10;\r\n\t\tdef.targetScale = real_t(1.);\r\n\t\tdef.bVerbose = bVerbose;\r\n\r\n\t\toutpS.bCentralNormalize = false;\r\n\t\toutpS.bScaleNormalize = false;\r\n\t\toutpS.bVerbose = bVerbose;\r\n\r\n\t\twinit_t obj(nn, td, def);\r\n\t\t\r\n\t\tobj.setts().add(outp.get_layer_idx(), outpS);\r\n\r\n\t\t//individual neuron stats requires a lot of data to be correctly evaluated\r\n\t\tif (!obj.run()) {\r\n\t\t\tSTDCOUTL(\"*** Layer with ID=\" << obj.m_firstFailedLayerIdx << \" was the first to fail convergence. There might be more of them.\");\r\n\t\t}\r\n\t}\r\n\r\n\tnn.get_iRng().seed64(seedVal + 1);\r\n\r\n\tauto ec = nn.train(td, opts);\r\n\tASSERT_EQ(decltype(nn)::ErrorCode::Success, ec) << \"Error code description: \" << nn.get_last_error_string();\r\n\r\n\tASSERT_NO_FATAL_FAILURE(nn.get_iInspect().report_stats(bVerbose));\r\n\r\n}\r\n\r\nTEST(TestSelu, SELU_Distribution) {\r\n\ttypedef float real_t;\r\n\t\r\n\t//#TODO\r\n\tSTDCOUTL(\"#The test may generate some false failures b/c of data variance. Need to redesign it.\");\r\n\r\n\tconst size_t t = ::std::time(0);\r\n\tconst real_t dpa = real_t(.8);\r\n\r\n\tSTDCOUTL(\"================ No weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, real_t(1.), 10, 50, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, real_t(1.), 10, 50, true));\r\n\r\n\tSTDCOUTL(\"================ No weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, dpa, 10, 50, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, dpa, 10, 50, true));\r\n\r\n#ifndef TESTS_SKIP_LONGRUNNING\r\n\tSTDCOUTL(\"================ No weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, real_t(1.), 100, 400, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, real_t(1.), 100, 400, true));\r\n\r\n\tSTDCOUTL(\"================ No weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, dpa, 100, 400, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr(t, dpa, 100, 400, true));\r\n#endif\r\n\r\n\t/*STDCOUTL(\"================ No weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, real_t(1.), 10, 50, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, real_t(1.), 10, 50, true));\r\n\r\n\tSTDCOUTL(\"================ No weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, dpa, 10, 50, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, dpa, 10, 50, true));\r\n\r\n#ifndef TESTS_SKIP_LONGRUNNING\r\n\tSTDCOUTL(\"================ No weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, real_t(1.), 100, 400, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, real_t(1.), 100, 400, true));\r\n\r\n\tSTDCOUTL(\"================ No weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, dpa, 100, 400, false));\r\n\tSTDCOUTL(\"================ With weight renormalizing + AlphaDropout ================\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::no>(t, dpa, 100, 400, true));\r\n\r\n\tSTDCOUTL(\"Assessing corrections (without weight renormalizing)\");\r\n\tSTDCOUTL(\"ADCorr::correctVar\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::correctVar>(t, dpa, 100, 400, false));\r\n\tSTDCOUTL(\"ADCorr::correctDoVal\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::correctDoVal>(t, dpa, 100, 400, false));\r\n\tSTDCOUTL(\"ADCorr::correctDoAndVar\");\r\n\tASSERT_NO_FATAL_FAILURE(test_selu_distr<ADCorr::correctDoAndVar>(t, dpa, 100, 400, false));\r\n#endif*/\r\n}\r\n\r\n/*\r\nTEST(TestSelu, AlphaDropoutDistributionWithCorrection) {\r\n\ttypedef float real_t;\r\n\r\n\tconst size_t t = ::std::time(0);\r\n\r\n\tvec_len_t xW = 20;\r\n\r\n\tfor (neurons_count_t nc = 5; nc <= 30; nc+=5) {\r\n\t\treal_t dpa = real_t(0.97);\r\n\t\tSTDCOUTL(::std::endl<<\"================ No correction ================\");\r\n\t\tASSERT_NO_FATAL_FAILURE((test_selu_distr<real_t, false>(t, dpa, xW, nc, true, false)));\r\n\t\tSTDCOUTL(\"================ With correction ================\");\r\n\t\tASSERT_NO_FATAL_FAILURE((test_selu_distr<real_t, true>(t, dpa, xW, nc, true, false)));\r\n\r\n\t\tdpa = real_t(0.7);\r\n\t\tSTDCOUTL(\"================ No correction ================\");\r\n\t\tASSERT_NO_FATAL_FAILURE((test_selu_distr<real_t, false>(t, dpa, xW, nc, true, false)));\r\n\t\tSTDCOUTL(\"================ With correction ================\");\r\n\t\tASSERT_NO_FATAL_FAILURE((test_selu_distr<real_t, true>(t, dpa, xW, nc, true, false)));\r\n\t}\r\n\r\n}*/", "meta": {"hexsha": "e74758b9c44dd3fd33ec02416c67fe0ff297a090", "size": 15805, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/test_selu.cpp", "max_stars_repo_name": "Arech/nntl", "max_stars_repo_head_hexsha": "fdcd7f33216c6414547acea3c4c172734ef9412a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 12.0, "max_stars_repo_stars_event_min_datetime": "2015-12-22T19:55:56.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-28T13:10:19.000Z", "max_issues_repo_path": "tests/test_selu.cpp", "max_issues_repo_name": "Arech/nntl", "max_issues_repo_head_hexsha": "fdcd7f33216c6414547acea3c4c172734ef9412a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/test_selu.cpp", "max_forks_repo_name": "Arech/nntl", "max_forks_repo_head_hexsha": "fdcd7f33216c6414547acea3c4c172734ef9412a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2017-10-15T11:12:33.000Z", "max_forks_repo_forks_event_max_datetime": "2017-10-15T11:12:33.000Z", "avg_line_length": 39.8110831234, "max_line_length": 145, "alphanum_fraction": 0.6909838659, "num_tokens": 4418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.16451645675203383, "lm_q1q2_score": 0.07776421073882643}}
{"text": "//\n// Copyright (c) 2002--2010\n// Toon Knapen, Karl Meerbergen, Kresimir Fresl,\n// Thomas Klimpel and Rutger ter Borg\n//\n// Distributed under the Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt or copy at\n// http://www.boost.org/LICENSE_1_0.txt)\n//\n// THIS FILE IS AUTOMATICALLY GENERATED\n// PLEASE DO NOT EDIT!\n//\n\n#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_AUXILIARY_LARFG_HPP\n#define BOOST_NUMERIC_BINDINGS_LAPACK_AUXILIARY_LARFG_HPP\n\n#include <boost/assert.hpp>\n#include <boost/numeric/bindings/begin.hpp>\n#include <boost/numeric/bindings/is_complex.hpp>\n#include <boost/numeric/bindings/is_mutable.hpp>\n#include <boost/numeric/bindings/is_real.hpp>\n#include <boost/numeric/bindings/remove_imaginary.hpp>\n#include <boost/numeric/bindings/size.hpp>\n#include <boost/numeric/bindings/stride.hpp>\n#include <boost/numeric/bindings/value_type.hpp>\n#include <boost/static_assert.hpp>\n#include <boost/type_traits/is_same.hpp>\n#include <boost/type_traits/remove_const.hpp>\n#include <boost/utility/enable_if.hpp>\n\n//\n// The LAPACK-backend for larfg is the netlib-compatible backend.\n//\n#include <boost/numeric/bindings/lapack/detail/lapack.h>\n#include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>\n\nnamespace boost {\nnamespace numeric {\nnamespace bindings {\nnamespace lapack {\n\n//\n// The detail namespace contains value-type-overloaded functions that\n// dispatch to the appropriate back-end LAPACK-routine.\n//\nnamespace detail {\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * float value-type.\n//\ninline std::ptrdiff_t larfg( const fortran_int_t n, float& alpha, float* x,\n        const fortran_int_t incx, float& tau ) {\n    fortran_int_t info(0);\n    LAPACK_SLARFG( &n, &alpha, x, &incx, &tau );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * double value-type.\n//\ninline std::ptrdiff_t larfg( const fortran_int_t n, double& alpha, double* x,\n        const fortran_int_t incx, double& tau ) {\n    fortran_int_t info(0);\n    LAPACK_DLARFG( &n, &alpha, x, &incx, &tau );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * complex<float> value-type.\n//\ninline std::ptrdiff_t larfg( const fortran_int_t n, std::complex<float>& alpha,\n        std::complex<float>* x, const fortran_int_t incx,\n        std::complex<float>& tau ) {\n    fortran_int_t info(0);\n    LAPACK_CLARFG( &n, &alpha, x, &incx, &tau );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * complex<double> value-type.\n//\ninline std::ptrdiff_t larfg( const fortran_int_t n,\n        std::complex<double>& alpha, std::complex<double>* x,\n        const fortran_int_t incx, std::complex<double>& tau ) {\n    fortran_int_t info(0);\n    LAPACK_ZLARFG( &n, &alpha, x, &incx, &tau );\n    return info;\n}\n\n} // namespace detail\n\n//\n// Value-type based template class. Use this class if you need a type\n// for dispatching to larfg.\n//\ntemplate< typename Value, typename Enable = void >\nstruct larfg_impl {};\n\n//\n// This implementation is enabled if Value is a real type.\n//\ntemplate< typename Value >\nstruct larfg_impl< Value, typename boost::enable_if< is_real< Value > >::type > {\n\n    typedef Value value_type;\n    typedef typename remove_imaginary< Value >::type real_type;\n\n    //\n    // Static member function, that\n    // * Deduces the required arguments for dispatching to LAPACK, and\n    // * Asserts that most arguments make sense.\n    //\n    template< typename VectorX >\n    static std::ptrdiff_t invoke( const fortran_int_t n, real_type& alpha,\n            VectorX& x, real_type& tau ) {\n        namespace bindings = ::boost::numeric::bindings;\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );\n        return detail::larfg( n, alpha, bindings::begin_value(x),\n                bindings::stride(x), tau );\n    }\n\n};\n\n//\n// This implementation is enabled if Value is a complex type.\n//\ntemplate< typename Value >\nstruct larfg_impl< Value, typename boost::enable_if< is_complex< Value > >::type > {\n\n    typedef Value value_type;\n    typedef typename remove_imaginary< Value >::type real_type;\n\n    //\n    // Static member function, that\n    // * Deduces the required arguments for dispatching to LAPACK, and\n    // * Asserts that most arguments make sense.\n    //\n    template< typename VectorX >\n    static std::ptrdiff_t invoke( const fortran_int_t n, value_type& alpha,\n            VectorX& x, value_type& tau ) {\n        namespace bindings = ::boost::numeric::bindings;\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );\n        return detail::larfg( n, alpha, bindings::begin_value(x),\n                bindings::stride(x), tau );\n    }\n\n};\n\n\n//\n// Functions for direct use. These functions are overloaded for temporaries,\n// so that wrapped types can still be passed and used for write-access. In\n// addition, if applicable, they are overloaded for user-defined workspaces.\n// Calls to these functions are passed to the larfg_impl classes. In the \n// documentation, most overloads are collapsed to avoid a large number of\n// prototypes which are very similar.\n//\n\n//\n// Overloaded function for larfg. Its overload differs for\n//\ntemplate< typename VectorX >\ninline std::ptrdiff_t larfg( const fortran_int_t n,\n        typename remove_imaginary< typename bindings::value_type<\n        VectorX >::type >::type& alpha, VectorX& x, typename remove_imaginary<\n        typename bindings::value_type< VectorX >::type >::type& tau ) {\n    return larfg_impl< typename bindings::value_type<\n            VectorX >::type >::invoke( n, alpha, x, tau );\n}\n\n//\n// Overloaded function for larfg. Its overload differs for\n//\ntemplate< typename VectorX >\ninline std::ptrdiff_t larfg( const fortran_int_t n,\n        typename bindings::value_type< VectorX >::type& alpha, VectorX& x,\n        typename bindings::value_type< VectorX >::type& tau ) {\n    return larfg_impl< typename bindings::value_type<\n            VectorX >::type >::invoke( n, alpha, x, tau );\n}\n\n} // namespace lapack\n} // namespace bindings\n} // namespace numeric\n} // namespace boost\n\n#endif\n", "meta": {"hexsha": "10fc21338b873caf166f34c4b85873f6a86c6b7e", "size": 6278, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/auxiliary/larfg.hpp", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137.0, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/auxiliary/larfg.hpp", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381.0, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/auxiliary/larfg.hpp", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 32.0306122449, "max_line_length": 84, "alphanum_fraction": 0.7024530105, "num_tokens": 1558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583464, "lm_q2_score": 0.1581743507642642, "lm_q1q2_score": 0.07723390903988922}}
{"text": "/*! \\file demo_1d_plot.cpp\n    \\brief Demonstration of many features for 1D plots.\n    \\details Contains Quickbook markup.\n\n    \\author Paul A. Bristow\n*/\n\n// Copyright Jacob Voytko 2007\n// Copyright Paul A Bristow 2008, 2020\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[demo_1d_plot_1\n// An entirely contrived example designed to demonstration\n// as many features as possible in a single example.\n// The results is not intended to be useful,\n// nor is it intended to be pretty, but solely to highlight features used!\n// See other examples for more practical (and tasteful) examples using typical features.\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\n  using namespace boost::svg;\n  using boost::svg::svg_1d_plot;\n\n#include <boost/svg_plot/show_1d_settings.hpp>\n// void boost::svg::show_1d_plot_settings(svg_1d_plot&);\n\n#include <boost/svg_plot/svg_fwd.hpp> // forward declarations.\n// for testing its correctness.\n\n#include <iostream> // for debugging.\n // using std::cout;\n // using std::endl;\n\n#include <vector>\n // using std::vector;\n\n#include <limits>\n//  using std::numeric_limits;\n\nint main()\n{\n  std::vector<double> my_data1;\n  // Initialize my_data here with some entirely fictional data.\n  my_data1.push_back(0.1);\n  my_data1.push_back(1.1);\n  my_data1.push_back(4.2);\n  my_data1.push_back(3.3);\n  my_data1.push_back(5.4);\n  my_data1.push_back(6.5);\n\n  std::vector<double> my_data2;\n  // Initialize my_data here with some more entirely fictional data.\n  my_data2.push_back(0.5);\n  my_data2.push_back(1.5);\n  my_data2.push_back(4.7);\n\n  std::vector<double> my_data3;\n  // Initialize my_data here with some more entirely fictional data.\n  my_data3.push_back(0.7);\n  my_data3.push_back(2.5);\n  my_data3.push_back(5.8);\n\n  std::vector<double> my_data4;\n  // Initialize my_data with some integral values so can check points are marked exactly right.\n  my_data4.push_back(1.);\n  my_data4.push_back(2.);\n  my_data4.push_back(3.);\n  my_data4.push_back(6.);\n  my_data4.push_back(7.);\n  my_data4.push_back(8.);\n\n  std::vector<double> my_data5;\n  my_data5.push_back(0.);\n  my_data5.push_back(-1.);\n  my_data5.push_back(+1.);\n  // Include an out-of-axis range value:\n  my_data5.push_back(999.9);\n  // Max and min values.\n  my_data5.push_back((std::numeric_limits<double>::max)());\n  my_data5.push_back((std::numeric_limits<double>::min)());\n  // and non-finite values.\n  my_data5.push_back((std::numeric_limits<double>::quiet_NaN)());\n  my_data5.push_back((std::numeric_limits<double>::infinity)());\n\n  svg_1d_plot my_1d_plot; // Construct with all the default constructor values.\n  std::cout << \"Image x & y \" << my_1d_plot.x_size() << \" by \" << my_1d_plot.y_size() << std::endl;\n  //my_1d_plot.size(100,100); // Alter both together.\n  //cout << \"Image x & y \" << my_1d_plot.x_size() << \" by \" << my_1d_plot.y_size() << endl;\n  //// And alter both separately.\n  //my_1d_plot.x_size(200);\n  //my_1d_plot.y_size(600);\n  //cout << \"Image x & y \" << my_1d_plot.x_size() << \" by \" << my_1d_plot.y_size() << endl;\n\n  my_1d_plot.document_title(\"Document title demo_1d_plot\"); // This text shows on the browser tab.\n  my_1d_plot.description(\"My demo_1d_plot description\");\n  my_1d_plot.copyright_date(\"2008-03-29\");\n  my_1d_plot.copyright_holder(\"Paul A. Bristow\");\n  my_1d_plot.license(\"permits\", \"permits\", \"requires\", \"permits\", \"permits\"); // Require notice only.\n  //see  http://creativecommons.org/licenses/ for details.\n  my_1d_plot.coord_precision(4);\n\n std::cout << \"font-family was \" << my_1d_plot.title_font_family() << std::endl;\n\n  my_1d_plot\n  .y_size(250)\n  .background_color(ghostwhite) // whole image.\n  .background_border_color(aqua) //\n  .background_border_width(10.) //\n  .plot_window_on(true) //\n  .plot_background_color(aliceblue) // just the plot area.\n  .plot_border_color(pink)\n  .plot_border_width(5.)\n  .title(\"Demo 1D plot <sup>-&#945; </sup> &#x3A9; &#x3A6; &#x221A; &#x221E; &#x3B6; &#x00B1;\")\n    // domain of the random variable is [0, &#8734;]\") //  Capital Omega <superscript> &#x3A9; </superscript>\") doesn't work yet.\n  .title_font_size(20)\n  .title_font_family(\"Times New Roman\")\n  .title_color(magenta)\n  .legend_on(true)\n  .legend_background_color(beige)\n  .legend_border_color(chocolate)\n  .legend_title(\"My Legend &#956;\") // generates <em>&#956;</em>  greek mu\n  .legend_title_font_size(12)\n  .legend_font_family(\"arial\") // \"arial\", \"impact\", \"courier\", \"lucida console\",  \"Lucida sans unicode\", \"verdana\"\n  .legend_font_weight(\"bold\")\n  .legend_color(darkgreen)\n  .legend_lines(false) // Horizontal sample color line not useful if already showing values with colored shapes.\n  .x_label_on(true) // show x-axis text label.\n  .x_label(\"volume\") // Care: this doesn't show unless .x_label_on() == true!\n  .x_axis_color(blue)\n  .x_label_color(blue)\n  //.x_label_font_family(\"Verdana\")\n  .x_label_font_family(\"Lucida sans unicode\")\n//  .x_label_font_family(\"Times New Roman\")\n  .x_label_units_on(true)\n  .x_label_font_size(12)\n  .x_label_units(\" (meter&#179; or m&#179;)\") // super 2 = &#xB2; super 3 = &#179;\n  // Note you must provide any space and any brackets if required.\n  // Care: this doesn't show unless .x_label_units_on() == true!\n  // Ticks\n  .x_ticks_up_on(true) //\n  .x_ticks_down_on(true) // So have Up and downward ticks.\n  // Add grid - not very useful for 1D.\n  .x_major_tick_width(3)\n  .x_major_tick_length(10)\n  .x_minor_tick_length(7)\n  .x_major_grid_on(true)\n  .x_major_grid_width(2)\n  .x_major_grid_color(lightblue)\n  .x_minor_grid_on(true)\n  .x_minor_grid_width(1)\n  .x_minor_grid_color(pink)\n  .nan_limit_color(red)\n  .nan_limit_fill_color(green)\n  .x_ticks_on_window_or_axis(0) // -1 bottom, 0 on axis, +1 top\n\n  .x_range(-1., 7.); // Display range.\n\n  //my_1d_plot.plot(my_data1, \"my values 1\");\n\n  //my_1d_plot.plot(my_data2, \"my values round\").shape(round).size(10).fill_color(pink);\n\n  //my_1d_plot.plot(my_data1, \"my values 1\").shape(vertical_tick);\n\n  //my_1d_plot.plot(my_data2, \"my red values \").stroke_color(red).fill_color(blue);\n\n  my_1d_plot.plot(my_data3, \"data3\").shape(diamond).size(10).stroke_color(red).fill_color(blue);\n  my_1d_plot.plot(my_data4, \"data4\").shape(symbol).size(20);\n  my_1d_plot.plot(my_data5, \"data5\").shape(cone).symbols(\"&#x3A9;\").stroke_color(magenta).fill_color(aqua);\n  //my_1d_plot.plot(my_data4, \"data4\").shape(symbol).symbols(\"&#x2721;\").stroke_color(magenta).fill_color(aqua);\n // // U+2721 is Star of David or hexagram http://en.wikipedia.org/wiki/Hexagram\n\n  my_1d_plot.write(\"demo_1d_plot.svg\");\n\n  show_1d_plot_settings(my_1d_plot);\n\n//] [/demo_1d_plot_1]\n\n  return 0;\n} // int main()\n\n/*\n\nCompiling...\ndemo_1d_plot.cpp\nLinking...\nEmbedding manifest...\nAutorun \"j:\\Cpp\\SVG\\debug\\demo_1d_plot.exe\"\nBuild Time 0:11\n\n*/\n\n", "meta": {"hexsha": "26711b0d9b42a1d3daaa823523d9b662619ac8b7", "size": 7210, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_1d_plot.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_1d_plot.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_1d_plot.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 35.6930693069, "max_line_length": 129, "alphanum_fraction": 0.7131761442, "num_tokens": 2170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46101677931231594, "lm_q2_score": 0.16451647108926923, "lm_q1q2_score": 0.07584485364540264}}
{"text": "/**\n * \\file libs/numeric/ublasx/test/for_each.cpp\n *\n * \\brief Test suite for the \\c for_each operation.\n *\n * Copyright (c) 2010, Marco Guazzone\n * \n * Distributed under the Boost Software License, Version 1.0. (See\n * accompanying file LICENSE_1_0.txt or copy at\n * http://www.boost.org/LICENSE_1_0.txt)\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\n\n#include <boost/bind.hpp>\n#include <boost/numeric/ublas/matrix.hpp>\n#include <boost/numeric/ublasx/operation/for_each.hpp>\n#include <boost/numeric/ublasx/tags.hpp>\n#include <cstddef>\n#include <functional>\n#include <iostream>\n#include \"libs/numeric/ublasx/test/utils.hpp\"\n\n\nnamespace ublas = ::boost::numeric::ublas;\nnamespace ublasx = ::boost::numeric::ublasx;\n\n\nstatic const double tol = 1.0e-5;\n\n\ntemplate <typename T>\nstatic void my_function(T const& x)\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"x = \" << x);\n}\n\n\ntemplate <typename T>\nstruct my_functor: public std::unary_function<T,void>\n{\n\tvoid operator()(T const& x) const\n\t{\n\t\tBOOST_UBLASX_DEBUG_TRACE(\"x = \" << x);\n\t}\n};\n\n\ntemplate <typename T>\nvoid my_add(T const& x, T& s)\n{\n\ts += x;\n}\n\n\ntemplate <typename T>\nstruct my_adder\n{\n\tvoid operator()(T const& x, T& s) const\n\t{\n\t\ts += x;\n\t}\n};\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_function )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Vector - Function\");\n\n\ttypedef double value_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\n\tconst std::size_t n(4);\n\n\tvector_type v(n);\n\tv(0) =  1;\n\tv(1) = -2;\n\tv(2) = -3;\n\tv(3) =  4;\n\n\tublasx::for_each(v, my_function<value_type>);\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_functor )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Vector - Functor\");\n\n\ttypedef double value_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\n\tconst std::size_t n(4);\n\n\tvector_type v(n);\n\tv(0) =  1;\n\tv(1) = -2;\n\tv(2) = -3;\n\tv(3) =  4;\n\n\tublasx::for_each(v, my_functor<value_type>());\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_bound_function )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Vector - Bound Function\");\n\n\ttypedef double value_type;\n\ttypedef std::size_t size_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\n\tconst size_type n(4);\n\n\tvector_type v(n);\n\tv(0) =  1;\n\tv(1) = -2;\n\tv(2) = -3;\n\tv(3) =  4;\n\n\tvalue_type res(0);\n\tvalue_type expect_res(0);\n\n\tublasx::for_each(v, boost::bind<void>(my_add<value_type>, _1, boost::ref(res)));\n\n\tBOOST_UBLASX_DEBUG_TRACE( \"res = \" << res );\n\n\tfor (size_type i = 0; i < n; ++i)\n\t{\n\t\texpect_res += v(i);\n\t}\n\n\tBOOST_UBLASX_TEST_CHECK_CLOSE( res, expect_res, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_bound_functor )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Vector - Bound Functor\");\n\n\ttypedef double value_type;\n\ttypedef std::size_t size_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\n\tconst size_type n(4);\n\n\tvector_type v(n);\n\tv(0) =  1;\n\tv(1) = -2;\n\tv(2) = -3;\n\tv(3) =  4;\n\n\tvalue_type res(0);\n\tvalue_type expect_res(0);\n\n\tublasx::for_each(v, boost::bind<void>(my_adder<value_type>(), _1, boost::ref(res)));\n\n\tBOOST_UBLASX_DEBUG_TRACE( \"res = \" << res );\n\n\tfor (size_type i = 0; i < n; ++i)\n\t{\n\t\texpect_res += v(i);\n\t}\n\n\tBOOST_UBLASX_TEST_CHECK_CLOSE( res, expect_res, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_function )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Function\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each(A, my_function<value_type>);\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_functor )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Functor\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each(A, my_functor<value_type>());\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_bound_function )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Bound Function\");\n\n\ttypedef double value_type;\n\ttypedef std::size_t size_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst size_type nr(2);\n\tconst size_type nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tvalue_type res(0);\n\tvalue_type expect_res(0);\n\n\tublasx::for_each(A, boost::bind<void>(my_add<value_type>, _1, boost::ref(res)));\n\n\tBOOST_UBLASX_DEBUG_TRACE( \"res = \" << res );\n\n\tfor (size_type r = 0; r < nr; ++r)\n\t{\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect_res += A(r,c);\n\t\t}\n\t}\n\n\tBOOST_UBLASX_TEST_CHECK_CLOSE( res, expect_res, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_bound_functor )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Bound Function\");\n\n\ttypedef double value_type;\n\ttypedef std::size_t size_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst size_type nr(2);\n\tconst size_type nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tvalue_type res(0);\n\tvalue_type expect_res(0);\n\n\tublasx::for_each(A, boost::bind<void>(my_adder<value_type>(), _1, boost::ref(res)));\n\n\tBOOST_UBLASX_DEBUG_TRACE( \"res = \" << res );\n\n\tfor (size_type r = 0; r < nr; ++r)\n\t{\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect_res += A(r,c);\n\t\t}\n\t}\n\n\tBOOST_UBLASX_TEST_CHECK_CLOSE( res, expect_res, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_function_dim1 )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Function - By Dimension: 1\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each<1>(A, my_function<value_type>);\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_functor_dim1 )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Functor - By Dimension: 1\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each<1>(A, my_functor<value_type>());\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_function_dim2 )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Function - By Dimension: 2\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each<2>(A, my_function<value_type>);\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_functor_dim2 )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Functor - By Dimension: 2\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each<2>(A, my_functor<value_type>());\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_function_dim_major )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Function - By Dimension: Major\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each_by_tag<ublasx::tag::major>(A, my_function<value_type>);\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_functor_dim_major )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Functor - By Dimension: Major\");\n\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each_by_tag<ublasx::tag::major>(A, my_functor<value_type>());\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_function_dim_minor )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Function - By Dimension: Minor\");\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each_by_tag<ublasx::tag::minor>(A, my_function<value_type>);\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_functor_dim_minor )\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Case: Matrix - Functor - By Dimension: Minor\");\n\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\n\tconst std::size_t nr(2);\n\tconst std::size_t nc(3);\n\n\tmatrix_type A(nr,nc);\n\tA(0,0) =  1; A(0,1) = -2; A(0,2) = -3;\n\tA(1,0) =  4; A(1,1) =  5; A(1,2) =  6;\n\n\tublasx::for_each_by_tag<ublasx::tag::minor>(A, my_functor<value_type>());\n\n\tBOOST_UBLASX_TEST_CHECK(true);\n}\n\n\nint main()\n{\n    BOOST_UBLASX_DEBUG_TRACE(\"Test Suite: 'for_each' operation\");\n\n\tBOOST_UBLASX_TEST_BEGIN();\n\n\tBOOST_UBLASX_TEST_DO( test_vector_function );\n\tBOOST_UBLASX_TEST_DO( test_vector_functor );\n\tBOOST_UBLASX_TEST_DO( test_matrix_function );\n\tBOOST_UBLASX_TEST_DO( test_matrix_functor );\n\tBOOST_UBLASX_TEST_DO( test_matrix_function_dim1 );\n\tBOOST_UBLASX_TEST_DO( test_matrix_functor_dim1 );\n\tBOOST_UBLASX_TEST_DO( test_matrix_function_dim2 );\n\tBOOST_UBLASX_TEST_DO( test_matrix_functor_dim2 );\n\tBOOST_UBLASX_TEST_DO( test_matrix_function_dim_major );\n\tBOOST_UBLASX_TEST_DO( test_matrix_functor_dim_major );\n\tBOOST_UBLASX_TEST_DO( test_matrix_function_dim_minor );\n\tBOOST_UBLASX_TEST_DO( test_matrix_functor_dim_minor );\n\tBOOST_UBLASX_TEST_DO( test_vector_bound_function );\n\tBOOST_UBLASX_TEST_DO( test_vector_bound_functor );\n\tBOOST_UBLASX_TEST_DO( test_matrix_bound_function );\n\tBOOST_UBLASX_TEST_DO( test_matrix_bound_functor );\n\n\tBOOST_UBLASX_TEST_END();\n}\n", "meta": {"hexsha": "003c1becbe1aac5b7fd72286f06e5b5a303c8ed8", "size": 10209, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/numeric/ublasx/test/for_each.cpp", "max_stars_repo_name": "comcon1/boost-ublasx", "max_stars_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "libs/numeric/ublasx/test/for_each.cpp", "max_issues_repo_name": "comcon1/boost-ublasx", "max_issues_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/numeric/ublasx/test/for_each.cpp", "max_forks_repo_name": "comcon1/boost-ublasx", "max_forks_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.8608137045, "max_line_length": 85, "alphanum_fraction": 0.6912528161, "num_tokens": 3512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4687906266262438, "lm_q2_score": 0.15817435870093427, "lm_q1q2_score": 0.07415065673161524}}
{"text": "/**\n * @ file\n * @ brief NPDE homework TEMPLATE MAIN FILE\n * @ author Tobias Rohner\n * @ date 25-03-2022\n * @ copyright Developed at SAM, ETH Zurich\n */\n\n#include <Eigen/Core>\n#include <iostream>\n\n#include \"mehrstellenverfahren.h\"\n\nint main(int /*argc*/, char** /*argv*/) {\n  mehrstellenverfahren::tabulateMehrstellenError();\n  return 0;\n}\n", "meta": {"hexsha": "58e145c5666bfbf1685a6bf21d2599adae4335b6", "size": 340, "ext": "cc", "lang": "C++", "max_stars_repo_path": "developers/Mehrstellenverfahren/mastersolution/mehrstellenverfahren_main.cc", "max_stars_repo_name": "rjs02/NPDECODES", "max_stars_repo_head_hexsha": "e15e492f7fd5a0a02a6c27c31673d2afc925b7d5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-02-22T10:59:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T10:59:19.000Z", "max_issues_repo_path": "developers/Mehrstellenverfahren/mastersolution/mehrstellenverfahren_main.cc", "max_issues_repo_name": "rjs02/NPDECODES", "max_issues_repo_head_hexsha": "e15e492f7fd5a0a02a6c27c31673d2afc925b7d5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "developers/Mehrstellenverfahren/mastersolution/mehrstellenverfahren_main.cc", "max_forks_repo_name": "rjs02/NPDECODES", "max_forks_repo_head_hexsha": "e15e492f7fd5a0a02a6c27c31673d2afc925b7d5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.8888888889, "max_line_length": 51, "alphanum_fraction": 0.6794117647, "num_tokens": 93, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.4186969093556867, "lm_q2_score": 0.17553807362342935, "lm_q1q2_score": 0.07349724890038085}}
{"text": "//\n// Copyright (c) 2002--2010\n// Toon Knapen, Karl Meerbergen, Kresimir Fresl,\n// Thomas Klimpel and Rutger ter Borg\n//\n// Distributed under the Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt or copy at\n// http://www.boost.org/LICENSE_1_0.txt)\n//\n// THIS FILE IS AUTOMATICALLY GENERATED\n// PLEASE DO NOT EDIT!\n//\n\n#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_DRIVER_GTSV_HPP\n#define BOOST_NUMERIC_BINDINGS_LAPACK_DRIVER_GTSV_HPP\n\n#include <boost/assert.hpp>\n#include <boost/numeric/bindings/begin.hpp>\n#include <boost/numeric/bindings/is_column_major.hpp>\n#include <boost/numeric/bindings/is_mutable.hpp>\n#include <boost/numeric/bindings/remove_imaginary.hpp>\n#include <boost/numeric/bindings/size.hpp>\n#include <boost/numeric/bindings/stride.hpp>\n#include <boost/numeric/bindings/value_type.hpp>\n#include <boost/static_assert.hpp>\n#include <boost/type_traits/is_same.hpp>\n#include <boost/type_traits/remove_const.hpp>\n\n//\n// The LAPACK-backend for gtsv is the netlib-compatible backend.\n//\n#include <boost/numeric/bindings/lapack/detail/lapack.h>\n#include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>\n\nnamespace boost {\nnamespace numeric {\nnamespace bindings {\nnamespace lapack {\n\n//\n// The detail namespace contains value-type-overloaded functions that\n// dispatch to the appropriate back-end LAPACK-routine.\n//\nnamespace detail {\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * float value-type.\n//\ninline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,\n        float* dl, float* d, float* du, float* b, const fortran_int_t ldb ) {\n    fortran_int_t info(0);\n    LAPACK_SGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * double value-type.\n//\ninline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,\n        double* dl, double* d, double* du, double* b,\n        const fortran_int_t ldb ) {\n    fortran_int_t info(0);\n    LAPACK_DGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * complex<float> value-type.\n//\ninline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,\n        std::complex<float>* dl, std::complex<float>* d,\n        std::complex<float>* du, std::complex<float>* b,\n        const fortran_int_t ldb ) {\n    fortran_int_t info(0);\n    LAPACK_CGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * complex<double> value-type.\n//\ninline std::ptrdiff_t gtsv( const fortran_int_t n, const fortran_int_t nrhs,\n        std::complex<double>* dl, std::complex<double>* d,\n        std::complex<double>* du, std::complex<double>* b,\n        const fortran_int_t ldb ) {\n    fortran_int_t info(0);\n    LAPACK_ZGTSV( &n, &nrhs, dl, d, du, b, &ldb, &info );\n    return info;\n}\n\n} // namespace detail\n\n//\n// Value-type based template class. Use this class if you need a type\n// for dispatching to gtsv.\n//\ntemplate< typename Value >\nstruct gtsv_impl {\n\n    typedef Value value_type;\n    typedef typename remove_imaginary< Value >::type real_type;\n\n    //\n    // Static member function, that\n    // * Deduces the required arguments for dispatching to LAPACK, and\n    // * Asserts that most arguments make sense.\n    //\n    template< typename VectorDL, typename VectorD, typename VectorDU,\n            typename MatrixB >\n    static std::ptrdiff_t invoke( const fortran_int_t n, VectorDL& dl,\n            VectorD& d, VectorDU& du, MatrixB& b ) {\n        namespace bindings = ::boost::numeric::bindings;\n        BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixB >::value) );\n        BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<\n                typename bindings::value_type< VectorDL >::type >::type,\n                typename remove_const< typename bindings::value_type<\n                VectorD >::type >::type >::value) );\n        BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<\n                typename bindings::value_type< VectorDL >::type >::type,\n                typename remove_const< typename bindings::value_type<\n                VectorDU >::type >::type >::value) );\n        BOOST_STATIC_ASSERT( (boost::is_same< typename remove_const<\n                typename bindings::value_type< VectorDL >::type >::type,\n                typename remove_const< typename bindings::value_type<\n                MatrixB >::type >::type >::value) );\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorDL >::value) );\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorD >::value) );\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorDU >::value) );\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixB >::value) );\n        BOOST_ASSERT( bindings::size(d) >= n );\n        BOOST_ASSERT( bindings::size(dl) >= n-1 );\n        BOOST_ASSERT( bindings::size(du) >= n-1 );\n        BOOST_ASSERT( bindings::size_column(b) >= 0 );\n        BOOST_ASSERT( bindings::size_minor(b) == 1 ||\n                bindings::stride_minor(b) == 1 );\n        BOOST_ASSERT( bindings::stride_major(b) >= std::max< std::ptrdiff_t >(1,\n                n) );\n        BOOST_ASSERT( n >= 0 );\n        return detail::gtsv( n, bindings::size_column(b),\n                bindings::begin_value(dl), bindings::begin_value(d),\n                bindings::begin_value(du), bindings::begin_value(b),\n                bindings::stride_major(b) );\n    }\n\n};\n\n\n//\n// Functions for direct use. These functions are overloaded for temporaries,\n// so that wrapped types can still be passed and used for write-access. In\n// addition, if applicable, they are overloaded for user-defined workspaces.\n// Calls to these functions are passed to the gtsv_impl classes. In the \n// documentation, most overloads are collapsed to avoid a large number of\n// prototypes which are very similar.\n//\n\n//\n// Overloaded function for gtsv. Its overload differs for\n//\ntemplate< typename VectorDL, typename VectorD, typename VectorDU,\n        typename MatrixB >\ninline std::ptrdiff_t gtsv( const fortran_int_t n, VectorDL& dl,\n        VectorD& d, VectorDU& du, MatrixB& b ) {\n    return gtsv_impl< typename bindings::value_type<\n            VectorDL >::type >::invoke( n, dl, d, du, b );\n}\n\n} // namespace lapack\n} // namespace bindings\n} // namespace numeric\n} // namespace boost\n\n#endif\n", "meta": {"hexsha": "a829d9d9cad7e52d695fa4a930425fdc99a5dc85", "size": 6595, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/driver/gtsv.hpp", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137.0, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/driver/gtsv.hpp", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381.0, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/driver/gtsv.hpp", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 36.2362637363, "max_line_length": 80, "alphanum_fraction": 0.6762699014, "num_tokens": 1657, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4765796510636759, "lm_q2_score": 0.1540575704593912, "lm_q1q2_score": 0.07342070317325432}}
{"text": "/**\n * @file advectionfv2d_test.cc\n * @brief NPDE homework AdvectionFV2D code\n * @author Philipp Egg\n * @date 01.01.2020\n * @copyright Developed at ETH Zurich\n */\n\n#include <Eigen/Core>\n\n#include <gtest/gtest.h>\n\n#include \"../advectionfv2d.h\"\n\nnamespace AdvectionFV2D::test {\n\nTEST(AdvectionFV2D, dummyFunction) {\n  double x = 0.0;\n  int n = 0;\n\n  // Eigen::Vector2d v = AdvectionFV2D::dummyFunction(x, n);\n  Eigen::Vector2d v = {1.0, 1.0};\n\n  Eigen::Vector2d v_ref = {1.0, 1.0};\n\n  double tol = 1.0e-8;\n  ASSERT_NEAR(0.0, (v - v_ref).lpNorm<Eigen::Infinity>(), tol);\n}\n\n}  // namespace AdvectionFV2D::test\n", "meta": {"hexsha": "f4bb639a176e64c6761bbc38fe33e0ddc727a0fd", "size": 607, "ext": "cc", "lang": "C++", "max_stars_repo_path": "developers/AdvectionFV2D/mastersolution/test/advectionfv2d_test.cc", "max_stars_repo_name": "hanyao8/NPDECODES", "max_stars_repo_head_hexsha": "b8e317665e80fd7a0025f71bb598e093b4b275ce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "developers/AdvectionFV2D/mastersolution/test/advectionfv2d_test.cc", "max_issues_repo_name": "hanyao8/NPDECODES", "max_issues_repo_head_hexsha": "b8e317665e80fd7a0025f71bb598e093b4b275ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "developers/AdvectionFV2D/mastersolution/test/advectionfv2d_test.cc", "max_forks_repo_name": "hanyao8/NPDECODES", "max_forks_repo_head_hexsha": "b8e317665e80fd7a0025f71bb598e093b4b275ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.5806451613, "max_line_length": 63, "alphanum_fraction": 0.6622734761, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44552953503957277, "lm_q2_score": 0.16238004274695514, "lm_q1q2_score": 0.07234510494475688}}
{"text": "//------------------------------------------------------------------------------\n/// \\file Pointers_tests.cpp\n/// \\ref \n//------------------------------------------------------------------------------\n#include <boost/test/unit_test.hpp>\n#include <iostream>\n#include <memory>\n#include <optional>\n#include <string>\n#include <utility>\n\nBOOST_AUTO_TEST_SUITE(Cpp) // The C++ Language\nBOOST_AUTO_TEST_SUITE(Pointers_test)\n\nstd::optional<bool> is_Foo_constructed {std::nullopt};\n\nstruct Foo\n{\n  Foo()\n  {\n    std::cout << \"Foo...\\n\";\n\n    is_Foo_constructed = true;\n  }\n\n  ~Foo()\n  {\n    std::cout << \"~Foo...\\n\";\n    is_Foo_constructed = false;\n  }\n};\n\nstruct D\n{\n  void operator()(Foo* p)\n  {\n    std::cout << \"Calling delete for Foo object...\\n\";\n    delete p;\n  }\n};\n\nstd::optional<bool> is_Quantity_constructed {std::nullopt};\n\nclass Quantity\n{\n  public:\n    Quantity() = delete;\n\n    Quantity(const double x):\n      x_{x}\n    {\n      is_Quantity_constructed = true;\n    }\n\n    ~Quantity()\n    {\n      is_Quantity_constructed = false;\n    }\n\n    double x() const\n    {\n      return x_;\n    }\n\n  private:\n    double x_;\n};\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstratePointers)\n{\n  {\n    // For type T, T* is type \"pointer to T\", i.e.\n    // variable of type T* can hold address of an object of type T\n    char c = 'a';\n    char* p = &c;\n\n    BOOST_TEST(c == 'a');\n    std::cout << \" c : \" << c << \" p : \" << p << \" c as unsigned int : \" <<\n      static_cast<unsigned int>(c) << \" *p : \" << *p << \" &p : \" << &p <<\n        \" &c : \" << &c <<  '\\n';\n    BOOST_TEST(*p == 'a');\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(PointerSizes)\n{\n  {\n    int x {10};\n    int* xPtr = &x;\n    char y {'a'};\n    char* yPtr {&y};\n    float z {3.f};\n    float* zptr {&z};\n\n    BOOST_TEST(sizeof(x) == 4); // 4 bytes, 32 bit\n    BOOST_TEST(sizeof(xPtr) == 8); // 8 byte, 64 bit\n    BOOST_TEST(sizeof(y) == 1); // 1 byte, 8 bit\n    BOOST_TEST(sizeof(yPtr) == 8); // 8 byte, 64 bit\n    BOOST_TEST(sizeof(z) == 4); // 4 byte, 32 bit\n    BOOST_TEST(sizeof(zptr) == 8); // 8 byte, 64 bit\n  }\n}\n\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateNullPtr)\n{\n  {\n    void* x {nullptr};\n\n    &x;\n\n    BOOST_TEST(true);\n\n    x;\n\n    BOOST_TEST(true);\n\n    // error: 'void*' is not a pointer-to-object type\n    //*x;\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateUniquePointers)\n{\n  {\n    // https://en.cppreference.com/w/cpp/memory/unique_ptr/reset\n\n    // Creating new Foo...\\n, D is a custom deleter\n    std::cout << \"Creating new Foo...\\n\";\n    BOOST_TEST(!static_cast<bool>(is_Foo_constructed));\n\n    std::unique_ptr<Foo, D> up {new Foo(), D()}; // up owns the Foo pointer\n    // (deleter D)\n    BOOST_TEST(static_cast<bool>(is_Foo_constructed));\n    BOOST_TEST(is_Foo_constructed.value());\n\n    // Replace owned Foo with a new Foo...\\n\n    std::cout << \"Replace owned Foo with a new Foo...\\n\";\n    up.reset(new Foo()); // calls deleter for the old one\n\n    BOOST_TEST(static_cast<bool>(is_Foo_constructed));\n    BOOST_TEST(!is_Foo_constructed.value());\n\n    std::cout << \"Release and delete the owned Foo...\\n\";\n\n    up.reset(nullptr);\n\n    BOOST_TEST(static_cast<bool>(is_Foo_constructed));\n    BOOST_TEST(!is_Foo_constructed.value());\n  }\n  {\n    std::unique_ptr<Quantity> u_ptr {std::make_unique<Quantity>(3)};\n\n    BOOST_TEST(u_ptr->x() == 3.);\n\n    Quantity q1 {5};\n\n    // Releases the ownership of the managed object if any.\n    u_ptr.release();\n    \n    // SIGABRT applicat abort requested\n    //u_ptr.reset(&q1);\n\n    // THIS WORKS\n    u_ptr = std::make_unique<Quantity>(q1);\n\n    BOOST_TEST(u_ptr->x() == 5.);\n\n    Quantity q2 {8};\n\n    is_Quantity_constructed = true;\n\n    u_ptr = std::make_unique<Quantity>(q2);\n\n    BOOST_TEST(u_ptr->x() == 8.);\n    BOOST_TEST(q2.x() == 8.);\n\n    // This refers to q1 going out of scope and being deleted.\n    BOOST_TEST(is_Quantity_constructed.value() == false);\n  }\n  {\n    Quantity q1 {42};\n    std::unique_ptr<Quantity> u_ptr {nullptr};\n    u_ptr = std::make_unique<Quantity>(q1);\n    BOOST_TEST(u_ptr->x() == 42);\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateUniquePointersInClasses)\n{\n  // TODO\n}\n\nclass IntString\n{\n  public:\n\n    IntString(const int x, const std::string& s):\n      x_{x},\n      s_{s}\n    {}\n\n    int x() const\n    {\n      return x_;\n    }\n\n    const std::string& s() const\n    {\n      return s_;\n    }\n\n    void x(const int x)\n    {\n      x_ = x;\n    }\n\n    void s(const std::string& s)\n    {\n      s_ = s;\n    }\n\n  private:\n\n    int x_;\n    std::string s_;\n};\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateReleasingUniquePointers)\n{\n  {\n    IntString int_string {42, \"Peek\"};\n    const IntString const_int_string {43, \"Linked List\"};\n\n    std::unique_ptr<IntString> u_ptr {std::make_unique<IntString>(int_string)};\n\n    BOOST_TEST(u_ptr->x() == 42);\n    BOOST_TEST(u_ptr->s() == \"Peek\");\n\n    u_ptr.release();\n\n    BOOST_TEST(int_string.x() == 42);\n    BOOST_TEST(int_string.s() == \"Peek\");\n\n    u_ptr = std::make_unique<IntString>(const_int_string);\n\n    BOOST_TEST(u_ptr->x() == 43);\n    BOOST_TEST(u_ptr->s() == \"Linked List\");\n\n    BOOST_TEST(const_int_string.x() == 43);\n    BOOST_TEST(const_int_string.s() == \"Linked List\");\n\n    std::cout << \" &u_ptr : \" << &u_ptr << '\\n';\n\n    auto released_ptr = u_ptr.release();\n\n    std::cout << \" u_ptr release: \" << &released_ptr << ' ' << released_ptr << '\\n';\n\n    u_ptr = std::make_unique<IntString>(int_string);\n\n    BOOST_TEST(int_string.x() == 42);\n    BOOST_TEST(int_string.s() == \"Peek\");\n\n    int_string.x(69);\n    int_string.s(\"Last-in First-Out\");\n\n    BOOST_TEST(int_string.x() == 69);\n    BOOST_TEST(int_string.s() == \"Last-in First-Out\");\n\n    BOOST_TEST(u_ptr->x() == 42);\n    BOOST_TEST(u_ptr->s() == \"Peek\");\n\n    std::cout << \" &u_ptr : \" << &u_ptr << '\\n';\n\n    auto released_ptr1 = u_ptr.release();\n\n    std::cout << \" u_ptr release1: \" << &released_ptr1 << ' ' << released_ptr1 << '\\n';\n\n    u_ptr = std::make_unique<IntString>(std::move(int_string));\n\n    BOOST_TEST(u_ptr->x() == 69);\n    BOOST_TEST(u_ptr->s() == \"Last-in First-Out\");\n\n    int_string.x(70);\n    int_string.s(\"Queues\");\n\n    BOOST_TEST(int_string.x() == 70);\n    BOOST_TEST(int_string.s() == \"Queues\");\n\n    BOOST_TEST(u_ptr->x() == 69);\n    BOOST_TEST(u_ptr->s() == \"Last-in First-Out\");\n\n    u_ptr->x(70);\n    u_ptr->s(\"Queues\");\n\n    BOOST_TEST(u_ptr->x() == 70);\n    BOOST_TEST(u_ptr->s() == \"Queues\");\n\n    std::cout << \" &u_ptr : \" << &u_ptr << '\\n';\n\n    auto released_ptr2 = u_ptr.release();\n\n    std::cout << \" u_ptr release2: \" << &released_ptr2 << ' ' << released_ptr2 << '\\n';\n\n  }\n}\n\nBOOST_AUTO_TEST_SUITE_END() // Pointers_test\nBOOST_AUTO_TEST_SUITE_END() // Cpp", "meta": {"hexsha": "9338240820e0d1f69b19d294067b60084e214134", "size": 7561, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Cpp/Std/Pointers_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Cpp/Std/Pointers_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Cpp/Std/Pointers_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.554517134, "max_line_length": 87, "alphanum_fraction": 0.5000661288, "num_tokens": 1915, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.2942149721629888, "lm_q2_score": 0.24508500210441891, "lm_q1q2_score": 0.07210767707171767}}
{"text": "/*\n\nCopyright (c) 2005-2016, University of Oxford.\nAll rights reserved.\n\nUniversity of Oxford means the Chancellor, Masters and Scholars of the\nUniversity of Oxford, having an administrative office at Wellington\nSquare, Oxford OX1 2JD, UK.\n\nThis file is part of Chaste.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n * Redistributions of source code must retain the above copyright notice,\n   this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of the University of Oxford nor the names of its\n   contributors may be used to endorse or promote products derived from this\n   software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\nGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef TESTGOLDBETER1991ODESYSTEM_HPP_\n#define TESTGOLDBETER1991ODESYSTEM_HPP_\n\n\n#include <cxxtest/TestSuite.h>\n\n#include <boost/archive/text_oarchive.hpp>\n#include <boost/archive/text_iarchive.hpp>\n\n#include <ctime>\n#include <vector>\n#include <iostream>\n\n#include \"OutputFileHandler.hpp\"\n#include \"Goldbeter1991OdeSystem.hpp\"\n#include \"RungeKutta4IvpOdeSolver.hpp\"\n#include \"EulerIvpOdeSolver.hpp\"\n\n//#include \"RungeKutta4IvpOdeSolver.hpp\"\n//#include \"RungeKuttaFehlbergIvpOdeSolver.hpp\"\n//#include \"BackwardEulerIvpOdeSolver.hpp\"\n#include \"CvodeAdaptor.hpp\"\n\n//This test is always run sequentially (never in parallel)\n#include \"FakePetscSetup.hpp\"\n\n\n\n/*\n * Basic tests only - no archiving test\n *\n */\n\n\nclass TestGoldbeter1991OdeSystem : public CxxTest::TestSuite\n{\npublic:\n\n    void TestGoldbeter1991Equation()\n    {\n        Goldbeter1991OdeSystem ode_system;\n\n        double time = 0.0;\n        std::vector<double> initial_conditions;\n        initial_conditions.push_back(0.01);\n        initial_conditions.push_back(0.01);\n        initial_conditions.push_back(0.01);\n\n        std::vector<double> derivs(initial_conditions.size());\n        ode_system.EvaluateYDerivatives(time, initial_conditions, derivs);\n\n        // Test derivatives are correct\n        TS_ASSERT_DELTA(derivs[0], 0.0240, 1e-4);\n        TS_ASSERT_DELTA(derivs[1], -0.9414, 1e-4);\n        TS_ASSERT_DELTA(derivs[2], -0.3233, 1e-4);\n    }\n\n\n    void TestGoldbeter1991OSolver() throw(Exception)\n    {\n        Goldbeter1991OdeSystem ode_system;\n\n        RungeKutta4IvpOdeSolver ode_solver;\n\n        OdeSolution solutions;\n\n        std::vector<double> initial_conditions = ode_system.GetInitialConditions();\n        double start_time = 0.0;\n        double end_time = 100.0;\n        double h_value = 0.01; // 1.0 // maximum tolerance\n\n        //Test the hard coded ics\n        TS_ASSERT_DELTA(initial_conditions[0], 0.01, 1e-6);\n        TS_ASSERT_DELTA(initial_conditions[1], 0.01, 1e-6);\n        TS_ASSERT_DELTA(initial_conditions[2], 0.01, 1e-6);\n\n        double cpu_start_time = (double) std::clock();\n        solutions = ode_solver.Solve(&ode_system, initial_conditions, start_time, end_time, h_value, h_value);\n        double cpu_end_time = (double) std::clock();\n        double cpu_elapsed_time = (cpu_end_time - cpu_start_time)/(CLOCKS_PER_SEC);\n        std::cout <<  \"1. Solver Elapsed time = \" << cpu_elapsed_time << \"\\n\";\n\n        // Test solutions are OK for a small time increase...\n        int end = solutions.rGetSolutions().size() - 1;\n        // Tests the simulation is ending at the right time...(going into S phase at 7.8 hours)\n        TS_ASSERT_DELTA(solutions.rGetTimes()[end], end_time, 1e-2);\n        //std::cout <<  \"End time = \" << solutions.rGetTimes()[end] << \"\\n\";\n        // Decent results - checked with numpy # [ 0.54706214  0.29369527  0.00678837]\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][0], 0.5470, 1e-4);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][1], 0.2936, 1e-4);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][2], 0.0067, 1e-4);\n    }\n\n    void TestArchiving()\n    {\n        OutputFileHandler handler(\"archive\", false);\n        std::string archive_filename = handler.GetOutputDirectoryFullPath() + \"gb1991_ode.arch\";\n\n        {\n\n            std::vector<double> state_variables;\n            state_variables.push_back(3.0);\n            state_variables.push_back(4.0);\n            state_variables.push_back(5.0);\n\n            Goldbeter1991OdeSystem ode_system(state_variables);\n\n            ode_system.SetDefaultInitialCondition(2, 3.25);\n\n            std::vector<double> initial_conditions = ode_system.GetInitialConditions();\n            TS_ASSERT_EQUALS(initial_conditions.size(), 3u);\n            TS_ASSERT_DELTA(initial_conditions[0], 0.01, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[1], 0.01, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[2], 3.2500, 1e-4);\n\n            double var1 = ode_system.GetStateVariable(0);\n            double var2 = ode_system.GetStateVariable(1);\n            double var3 = ode_system.GetStateVariable(2);\n\n            TS_ASSERT_DELTA(var1, 3.0, 1e-3);\n            TS_ASSERT_DELTA(var2, 4.0, 1e-3);\n            TS_ASSERT_DELTA(var3, 5.0, 1e-3);\n\n            // Create an output archive\n            std::ofstream ofs(archive_filename.c_str());\n            boost::archive::text_oarchive output_arch(ofs);\n\n            // Archive ODE system\n            AbstractOdeSystem* const p_const_ode_system = &ode_system;\n            output_arch << p_const_ode_system;\n        }\n\n        {\n            AbstractOdeSystem* p_ode_system;\n\n            // Create an input archive\n            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);\n            boost::archive::text_iarchive input_arch(ifs);\n\n            // Restore from the archive\n            input_arch >> p_ode_system;\n\n            // Check that archiving worked correctly\n            std::vector<double> initial_conditions = p_ode_system->GetInitialConditions();\n            TS_ASSERT_EQUALS(initial_conditions.size(), 3u);\n            TS_ASSERT_DELTA(initial_conditions[0], 0.01, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[1], 0.01, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[2], 0.01, 1e-4);\n\n            double var1 = p_ode_system->GetStateVariable(0);\n            double var2 = p_ode_system->GetStateVariable(1);\n            double var3 = p_ode_system->GetStateVariable(2);\n\n            TS_ASSERT_DELTA(var1, 3.0, 1e-3);\n            TS_ASSERT_DELTA(var2, 4.0, 1e-3);\n            TS_ASSERT_DELTA(var3, 5.0, 1e-3);\n\n            // Tidy up\n            delete p_ode_system;\n        }\n    }\n};\n\n#endif /* TESTGOLDBETER1991ODESYSTEM_HPP_ */\n", "meta": {"hexsha": "b9f8edb48b6065f6518a2ea3ffb5f52e75733b9e", "size": 7429, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "cell_based/test/odes/TestGoldbeter1991OdeSystem.hpp", "max_stars_repo_name": "uofs-simlab/ChasteOS", "max_stars_repo_head_hexsha": "04d98998e2ebad3f29086b8eaa1d89c08c6fccf6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cell_based/test/odes/TestGoldbeter1991OdeSystem.hpp", "max_issues_repo_name": "uofs-simlab/ChasteOS", "max_issues_repo_head_hexsha": "04d98998e2ebad3f29086b8eaa1d89c08c6fccf6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cell_based/test/odes/TestGoldbeter1991OdeSystem.hpp", "max_forks_repo_name": "uofs-simlab/ChasteOS", "max_forks_repo_head_hexsha": "04d98998e2ebad3f29086b8eaa1d89c08c6fccf6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.145, "max_line_length": 110, "alphanum_fraction": 0.6846143492, "num_tokens": 1866, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48047867804790706, "lm_q2_score": 0.15002882054202774, "lm_q1q2_score": 0.07208564936312017}}
{"text": "/*\n\nCopyright (c) 2005-2016, University of Oxford.\nAll rights reserved.\n\nUniversity of Oxford means the Chancellor, Masters and Scholars of the\nUniversity of Oxford, having an administrative office at Wellington\nSquare, Oxford OX1 2JD, UK.\n\nThis file is part of Chaste.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n * Redistributions of source code must retain the above copyright notice,\n   this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of the University of Oxford nor the names of its\n   contributors may be used to endorse or promote products derived from this\n   software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\nGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef TESTTYSONNOVAK2001ODESYSTEM_HPP_\n#define TESTTYSONNOVAK2001ODESYSTEM_HPP_\n\n#include <cxxtest/TestSuite.h>\n\n#include <boost/archive/text_oarchive.hpp>\n#include <boost/archive/text_iarchive.hpp>\n\n#include <vector>\n#include <iostream>\n\n#include \"TysonNovak2001OdeSystem.hpp\"\n#include \"BackwardEulerIvpOdeSolver.hpp\"\n#include \"EulerIvpOdeSolver.hpp\"\n#include \"RungeKutta4IvpOdeSolver.hpp\"\n#include \"ColumnDataWriter.hpp\"\n#include \"Timer.hpp\"\n\n#include \"PetscTools.hpp\"\n#include \"PetscSetupAndFinalize.hpp\"\n\nclass TestTysonNovak2001OdeSystem : public CxxTest::TestSuite\n{\npublic:\n\n    void TestTysonNovakEquation()\n    {\n        TysonNovak2001OdeSystem tyson_novak_system;\n\n        double time = 0.0;\n        std::vector<double> initial_conditions;\n        initial_conditions.push_back(0.6);\n        initial_conditions.push_back(0.1);\n        initial_conditions.push_back(1.5);\n        initial_conditions.push_back(0.6);\n        initial_conditions.push_back(0.6);\n        initial_conditions.push_back(0.85);\n\n        std::vector<double> derivs(initial_conditions.size());\n        tyson_novak_system.EvaluateYDerivatives(time, initial_conditions, derivs);\n\n        // Test derivatives are correct\n        // Divided by 60 to change to hours\n        TS_ASSERT_DELTA(derivs[0], -4.400000000000000e-02*60.0, 1e-5);\n        TS_ASSERT_DELTA(derivs[1], -6.047872340425530e+00*60.0, 1e-5);\n        TS_ASSERT_DELTA(derivs[2], 3.361442884485838e-02*60.0, 1e-5);\n        TS_ASSERT_DELTA(derivs[3], 4.016602000735009e-02*60.0, 1e-5);\n        TS_ASSERT_DELTA(derivs[4], 8.400000000000001e-03*60.0, 1e-5);\n        TS_ASSERT_DELTA(derivs[5], 7.777500000000001e-03*60.0, 1e-5);\n    }\n\n    void TestTysonNovakSolver() throw(Exception)\n    {\n        TysonNovak2001OdeSystem tyson_novak_system;\n\n        // Solve system using backward Euler solver\n\n        // Matlab's strictest bit uses 0.01 below and relaxes it on flatter bits\n\n        double dt = 0.1/60.0;\n\n        //Euler solver solution worked out\n        BackwardEulerIvpOdeSolver backward_euler_solver(6);\n\n        std::vector<double> state_variables = tyson_novak_system.GetInitialConditions();\n\n        Timer::Reset();\n        OdeSolution solutions = backward_euler_solver.Solve(&tyson_novak_system, state_variables, 0.0, 75.8350/60.0, dt, dt);\n        Timer::Print(\"1. Tyson Novak Backward Euler\");\n\n        // If you run it up to about 75min the ODE will stop, anything less and it will not and this test will fail\n        TS_ASSERT_EQUALS(backward_euler_solver.StoppingEventOccurred(), true);\n\n        unsigned end = solutions.rGetSolutions().size() - 1;\n\n        // The following code provides nice output for gnuplot\n        // use the command\n        // plot \"tyson_novak.dat\" u 1:2\n        // or\n        // plot \"tyson_novak.dat\" u 1:3 etc. for the various proteins...\n\n//        OutputFileHandler handler(\"\");\n//        out_stream file=handler.OpenOutputFile(\"tyson_novak.dat\");\n//        for (unsigned i=0; i<=end; i++)\n//        {\n//            (*file) << solutions.rGetTimes()[i]<< \"\\t\" << solutions.rGetSolutions()[i][0] << \"\\t\" << solutions.rGetSolutions()[i][1] << \"\\t\" << solutions.rGetSolutions()[i][2] << \"\\t\" << solutions.rGetSolutions()[i][3] << \"\\t\" << solutions.rGetSolutions()[i][4] << \"\\t\" << solutions.rGetSolutions()[i][5] << \"\\n\" << std::flush;\n//        }\n//        file->close();\n\n        ColumnDataWriter writer(\"TysonNovak\", \"TysonNovak\");\n        if (PetscTools::AmMaster()) // if master process\n        {\n            int step_per_row = 1;\n            int time_var_id = writer.DefineUnlimitedDimension(\"Time\", \"s\");\n\n            std::vector<int> var_ids;\n            for (unsigned i=0; i<tyson_novak_system.rGetStateVariableNames().size(); i++)\n            {\n                var_ids.push_back(writer.DefineVariable(tyson_novak_system.rGetStateVariableNames()[i],\n                                                        tyson_novak_system.rGetStateVariableUnits()[i]));\n            }\n            writer.EndDefineMode();\n\n            for (unsigned i = 0; i < solutions.rGetSolutions().size(); i+=step_per_row)\n            {\n                writer.PutVariable(time_var_id, solutions.rGetTimes()[i]);\n                for (unsigned j=0; j<var_ids.size(); j++)\n                {\n                    writer.PutVariable(var_ids[j], solutions.rGetSolutions()[i][j]);\n                }\n                writer.AdvanceAlongUnlimitedDimension();\n            }\n            writer.Close();\n        }\n        PetscTools::Barrier();\n\n        // Proper values calculated using the Matlab stiff ODE solver ode15s. Note that\n        // large tolerances are required for the tests to pass with both chaste solvers\n        // and CVODE.\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][0],0.10000000000000, 1e-2);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][1],0.98913684535843, 1e-2);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][2],1.54216806705641, 1e-1);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][3],1.40562614481544, 1e-1);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][4],0.67083371879876, 1e-2);\n        TS_ASSERT_DELTA(solutions.rGetSolutions()[end][5],0.95328206604519, 2e-2);\n    }\n\n    void TestArchiving()\n    {\n        OutputFileHandler handler(\"archive\", false);\n        std::string archive_filename = handler.GetOutputDirectoryFullPath() + \"tn_ode.arch\";\n\n        {\n            TysonNovak2001OdeSystem ode_system;\n\n            ode_system.SetDefaultInitialCondition(2, 3.25);\n\n            std::vector<double> initial_conditions = ode_system.GetInitialConditions();\n            TS_ASSERT_EQUALS(initial_conditions.size(), 6u);\n            TS_ASSERT_DELTA(initial_conditions[0], 0.0999, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[1], 0.9890, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[2], 3.2500, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[3], 1.4211, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[4], 0.6728, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[5], 0.4854, 1e-4);\n\n            // Create an output archive\n            std::ofstream ofs(archive_filename.c_str());\n            boost::archive::text_oarchive output_arch(ofs);\n\n            // Archive ODE system\n            AbstractOdeSystem* const p_const_ode_system = &ode_system;\n            output_arch << p_const_ode_system;\n        }\n\n        {\n            AbstractOdeSystem* p_ode_system;\n\n            // Create an input archive\n            std::ifstream ifs(archive_filename.c_str(), std::ios::binary);\n            boost::archive::text_iarchive input_arch(ifs);\n\n            // Restore from the archive\n            input_arch >> p_ode_system;\n\n            // Check that archiving worked correctly\n            std::vector<double> initial_conditions = p_ode_system->GetInitialConditions();\n            TS_ASSERT_EQUALS(initial_conditions.size(), 6u);\n            TS_ASSERT_DELTA(initial_conditions[0], 0.0999, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[1], 0.9890, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[2], 3.2500, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[3], 1.4211, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[4], 0.6728, 1e-4);\n            TS_ASSERT_DELTA(initial_conditions[5], 0.4854, 1e-4);\n\n            // Tidy up\n            delete p_ode_system;\n        }\n    }\n};\n\n#endif /*TESTTYSONNOVAK2001ODESYSTEM_HPP_*/\n", "meta": {"hexsha": "ba4040095d4daf1fa1e6c217ca40abfdce68e5e2", "size": 9114, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "cell_based/test/odes/TestTysonNovak2001OdeSystem.hpp", "max_stars_repo_name": "uofs-simlab/ChasteOS", "max_stars_repo_head_hexsha": "04d98998e2ebad3f29086b8eaa1d89c08c6fccf6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cell_based/test/odes/TestTysonNovak2001OdeSystem.hpp", "max_issues_repo_name": "uofs-simlab/ChasteOS", "max_issues_repo_head_hexsha": "04d98998e2ebad3f29086b8eaa1d89c08c6fccf6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cell_based/test/odes/TestTysonNovak2001OdeSystem.hpp", "max_forks_repo_name": "uofs-simlab/ChasteOS", "max_forks_repo_head_hexsha": "04d98998e2ebad3f29086b8eaa1d89c08c6fccf6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.8073394495, "max_line_length": 329, "alphanum_fraction": 0.6686416502, "num_tokens": 2341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.1520322397011398, "lm_q1q2_score": 0.07186312762032576}}
{"text": "/* ----------------------------------------------------------------------------\n\n * GTSAM Copyright 2010, Georgia Tech Research Corporation, \n * Atlanta, Georgia 30332-0415\n * All Rights Reserved\n * Authors: Frank Dellaert, et al. (see THANKS for the full author list)\n\n * See LICENSE for the license information\n\n * -------------------------------------------------------------------------- */\n\n/**\n * @file    testVectorValues.cpp\n * @author  Richard Roberts\n * @date    Sep 16, 2010\n */\n\n#include <boost/assign/std/vector.hpp>\n\n#include <gtsam/base/Testable.h>\n#include <gtsam/linear/VectorValues.h>\n#include <gtsam/inference/Permutation.h>\n\n#include <CppUnitLite/TestHarness.h>\n\nusing namespace std;\nusing namespace boost::assign;\nusing namespace gtsam;\n\n/* ************************************************************************* */\nTEST(VectorValues, insert) {\n\n  // insert, with out-of-order indices\n  VectorValues actual;\n  actual.insert(0, Vector_(1, 1.0));\n  actual.insert(1, Vector_(2, 2.0, 3.0));\n  actual.insert(5, Vector_(2, 6.0, 7.0));\n  actual.insert(2, Vector_(2, 4.0, 5.0));\n\n  // Check dimensions\n  LONGS_EQUAL(6, actual.size());\n  LONGS_EQUAL(7, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(2, actual.dim(5));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(!actual.exists(3));\n  EXPECT(!actual.exists(4));\n  EXPECT(actual.exists(5));\n  EXPECT(!actual.exists(6));\n\n  // Check values\n  EXPECT(assert_equal(Vector_(1, 1.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n  EXPECT(assert_equal(Vector_(2, 6.0, 7.0), actual[5]));\n  EXPECT(assert_equal(Vector_(7, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), actual.vector()));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(1, Vector()), invalid_argument);\n  CHECK_EXCEPTION(actual.dim(3), out_of_range);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, dimsConstructor) {\n\tvector<size_t> dims;\n\tdims.push_back(1);\n\tdims.push_back(2);\n\tdims.push_back(2);\n\n\tVectorValues actual(dims);\n\tactual[0] = Vector_(1, 1.0);\n\tactual[1] = Vector_(2, 2.0, 3.0);\n\tactual[2] = Vector_(2, 4.0, 5.0);\n\n\t// Check dimensions\n\tLONGS_EQUAL(3, actual.size());\n\tLONGS_EQUAL(5, actual.dim());\n\tLONGS_EQUAL(1, actual.dim(0));\n\tLONGS_EQUAL(2, actual.dim(1));\n\tLONGS_EQUAL(2, actual.dim(2));\n\n\t// Check values\n\tEXPECT(assert_equal(Vector_(1, 1.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n  EXPECT(assert_equal(Vector_(5, 1.0, 2.0, 3.0, 4.0, 5.0), actual.vector()));\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, copyConstructor) {\n\n  // insert, with out-of-order indices\n  VectorValues original;\n  original.insert(0, Vector_(1, 1.0));\n  original.insert(1, Vector_(2, 2.0, 3.0));\n  original.insert(5, Vector_(2, 6.0, 7.0));\n  original.insert(2, Vector_(2, 4.0, 5.0));\n\n  VectorValues actual(original);\n\n  // Check dimensions\n  LONGS_EQUAL(6, actual.size());\n  LONGS_EQUAL(7, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(2, actual.dim(5));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(!actual.exists(3));\n  EXPECT(!actual.exists(4));\n  EXPECT(actual.exists(5));\n  EXPECT(!actual.exists(6));\n\n  // Check values\n  EXPECT(assert_equal(Vector_(1, 1.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n  EXPECT(assert_equal(Vector_(2, 6.0, 7.0), actual[5]));\n  EXPECT(assert_equal(Vector_(7, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), actual.vector()));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(1, Vector()), invalid_argument);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, assignment) {\n\n  VectorValues actual;\n\n  {\n    // insert, with out-of-order indices\n    VectorValues original;\n    original.insert(0, Vector_(1, 1.0));\n    original.insert(1, Vector_(2, 2.0, 3.0));\n    original.insert(5, Vector_(2, 6.0, 7.0));\n    original.insert(2, Vector_(2, 4.0, 5.0));\n    actual = original;\n  }\n\n  // Check dimensions\n  LONGS_EQUAL(6, actual.size());\n  LONGS_EQUAL(7, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(2, actual.dim(5));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(!actual.exists(3));\n  EXPECT(!actual.exists(4));\n  EXPECT(actual.exists(5));\n  EXPECT(!actual.exists(6));\n\n  // Check values\n  EXPECT(assert_equal(Vector_(1, 1.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n  EXPECT(assert_equal(Vector_(2, 6.0, 7.0), actual[5]));\n  EXPECT(assert_equal(Vector_(7, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), actual.vector()));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(1, Vector()), invalid_argument);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, SameStructure) {\n  // insert, with out-of-order indices\n  VectorValues original;\n  original.insert(0, Vector_(1, 1.0));\n  original.insert(1, Vector_(2, 2.0, 3.0));\n  original.insert(5, Vector_(2, 6.0, 7.0));\n  original.insert(2, Vector_(2, 4.0, 5.0));\n\n  VectorValues actual(VectorValues::SameStructure(original));\n\n  // Check dimensions\n  LONGS_EQUAL(6, actual.size());\n  LONGS_EQUAL(7, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(2, actual.dim(5));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(!actual.exists(3));\n  EXPECT(!actual.exists(4));\n  EXPECT(actual.exists(5));\n  EXPECT(!actual.exists(6));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(1, Vector()), invalid_argument);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, Zero_fromModel) {\n  // insert, with out-of-order indices\n  VectorValues original;\n  original.insert(0, Vector_(1, 1.0));\n  original.insert(1, Vector_(2, 2.0, 3.0));\n  original.insert(5, Vector_(2, 6.0, 7.0));\n  original.insert(2, Vector_(2, 4.0, 5.0));\n\n  VectorValues actual(VectorValues::Zero(original));\n\n  // Check dimensions\n  LONGS_EQUAL(6, actual.size());\n  LONGS_EQUAL(7, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(2, actual.dim(5));\n\n  // Values\n  EXPECT(assert_equal(Vector::Zero(1), actual[0]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[1]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[5]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[2]));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(!actual.exists(3));\n  EXPECT(!actual.exists(4));\n  EXPECT(actual.exists(5));\n  EXPECT(!actual.exists(6));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(1, Vector()), invalid_argument);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, Zero_fromDims) {\n  vector<size_t> dims;\n  dims.push_back(1);\n  dims.push_back(2);\n  dims.push_back(2);\n\n  VectorValues actual(VectorValues::Zero(dims));\n\n  // Check dimensions\n  LONGS_EQUAL(3, actual.size());\n  LONGS_EQUAL(5, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n\n  // Values\n  EXPECT(assert_equal(Vector::Zero(1), actual[0]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[1]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[2]));\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, Zero_fromUniform) {\n  VectorValues actual(VectorValues::Zero(3, 2));\n\n  // Check dimensions\n  LONGS_EQUAL(3, actual.size());\n  LONGS_EQUAL(6, actual.dim());\n  LONGS_EQUAL(2, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n\n  // Values\n  EXPECT(assert_equal(Vector::Zero(2), actual[0]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[1]));\n  EXPECT(assert_equal(Vector::Zero(2), actual[2]));\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, resizeLike) {\n  // insert, with out-of-order indices\n  VectorValues original;\n  original.insert(0, Vector_(1, 1.0));\n  original.insert(1, Vector_(2, 2.0, 3.0));\n  original.insert(5, Vector_(2, 6.0, 7.0));\n  original.insert(2, Vector_(2, 4.0, 5.0));\n\n  VectorValues actual(10, 3);\n  actual.resizeLike(original);\n\n  // Check dimensions\n  LONGS_EQUAL(6, actual.size());\n  LONGS_EQUAL(7, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(2, actual.dim(5));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(!actual.exists(3));\n  EXPECT(!actual.exists(4));\n  EXPECT(actual.exists(5));\n  EXPECT(!actual.exists(6));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(1, Vector()), invalid_argument);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, resize_fromUniform) {\n  VectorValues actual(4, 10);\n  actual.resize(3, 2);\n\n  actual[0] = Vector_(2, 1.0, 2.0);\n  actual[1] = Vector_(2, 2.0, 3.0);\n  actual[2] = Vector_(2, 4.0, 5.0);\n\n  // Check dimensions\n  LONGS_EQUAL(3, actual.size());\n  LONGS_EQUAL(6, actual.dim());\n  LONGS_EQUAL(2, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n\n  // Check values\n  EXPECT(assert_equal(Vector_(2, 1.0, 2.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n  EXPECT(assert_equal(Vector_(6, 1.0, 2.0, 2.0, 3.0, 4.0, 5.0), actual.vector()));\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, resize_fromDims) {\n  vector<size_t> dims;\n  dims.push_back(1);\n  dims.push_back(2);\n  dims.push_back(2);\n\n  VectorValues actual(4, 10);\n  actual.resize(dims);\n  actual[0] = Vector_(1, 1.0);\n  actual[1] = Vector_(2, 2.0, 3.0);\n  actual[2] = Vector_(2, 4.0, 5.0);\n\n  // Check dimensions\n  LONGS_EQUAL(3, actual.size());\n  LONGS_EQUAL(5, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n\n  // Check values\n  EXPECT(assert_equal(Vector_(1, 1.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n  EXPECT(assert_equal(Vector_(5, 1.0, 2.0, 3.0, 4.0, 5.0), actual.vector()));\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, append) {\n  // insert\n  VectorValues actual;\n  actual.insert(0, Vector_(1, 1.0));\n  actual.insert(1, Vector_(2, 2.0, 3.0));\n  actual.insert(2, Vector_(2, 4.0, 5.0));\n\n  // append\n  vector<size_t> dims(2);\n  dims[0] = 3;\n  dims[1] = 5;\n  actual.append(dims);\n\n  // Check dimensions\n  LONGS_EQUAL(5, actual.size());\n  LONGS_EQUAL(13, actual.dim());\n  LONGS_EQUAL(1, actual.dim(0));\n  LONGS_EQUAL(2, actual.dim(1));\n  LONGS_EQUAL(2, actual.dim(2));\n  LONGS_EQUAL(3, actual.dim(3));\n  LONGS_EQUAL(5, actual.dim(4));\n\n  // Logic\n  EXPECT(actual.exists(0));\n  EXPECT(actual.exists(1));\n  EXPECT(actual.exists(2));\n  EXPECT(actual.exists(3));\n  EXPECT(actual.exists(4));\n  EXPECT(!actual.exists(5));\n\n  // Check values\n  EXPECT(assert_equal(Vector_(1, 1.0), actual[0]));\n  EXPECT(assert_equal(Vector_(2, 2.0, 3.0), actual[1]));\n  EXPECT(assert_equal(Vector_(2, 4.0, 5.0), actual[2]));\n\n  // Check exceptions\n  CHECK_EXCEPTION(actual.insert(3, Vector()), invalid_argument);\n}\n\n/* ************************************************************************* */\nTEST(VectorValues, hasSameStructure) {\n  VectorValues v1(2, 3);\n  VectorValues v2(3, 2);\n  VectorValues v3(4, 2);\n  VectorValues v4(4, 2);\n\n  EXPECT(!v1.hasSameStructure(v2));\n  EXPECT(!v2.hasSameStructure(v3));\n  EXPECT(v3.hasSameStructure(v4));\n  EXPECT(VectorValues().hasSameStructure(VectorValues()));\n  EXPECT(!v1.hasSameStructure(VectorValues()));\n}\n\n\n/* ************************************************************************* */\nTEST(VectorValues, permute) {\n\n\tVectorValues original;\n\toriginal.insert(0, Vector_(1, 1.0));\n\toriginal.insert(1, Vector_(2, 2.0, 3.0));\n\toriginal.insert(2, Vector_(2, 4.0, 5.0));\n\toriginal.insert(3, Vector_(2, 6.0, 7.0));\n\n\tVectorValues expected;\n\texpected.insert(0, Vector_(2, 4.0, 5.0)); // from 2\n\texpected.insert(1, Vector_(1, 1.0)); // from 0\n\texpected.insert(2, Vector_(2, 6.0, 7.0)); // from 3\n\texpected.insert(3, Vector_(2, 2.0, 3.0)); // from 1\n\n\tPermutation permutation(4);\n\tpermutation[0] = 2;\n\tpermutation[1] = 0;\n\tpermutation[2] = 3;\n\tpermutation[3] = 1;\n\n\tVectorValues actual = original.permute(permutation);\n\n\tEXPECT(assert_equal(expected, actual));\n}\n\n/* ************************************************************************* */\nint main() {\n  TestResult tr; return TestRegistry::runAllTests(tr);\n}\n/* ************************************************************************* */\n", "meta": {"hexsha": "17230854add1a06ee1a00a5268f128c901ae69d3", "size": 13475, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "gtsam/linear/tests/testVectorValues.cpp", "max_stars_repo_name": "sdmiller/gtsam_pcl", "max_stars_repo_head_hexsha": "1e607bd75090d35e325a8fb37a6c5afe630f1207", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11.0, "max_stars_repo_stars_event_min_datetime": "2015-02-04T16:41:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-10T07:02:44.000Z", "max_issues_repo_path": "gtsam/linear/tests/testVectorValues.cpp", "max_issues_repo_name": "sdmiller/gtsam_pcl", "max_issues_repo_head_hexsha": "1e607bd75090d35e325a8fb37a6c5afe630f1207", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gtsam/linear/tests/testVectorValues.cpp", "max_forks_repo_name": "sdmiller/gtsam_pcl", "max_forks_repo_head_hexsha": "1e607bd75090d35e325a8fb37a6c5afe630f1207", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 6.0, "max_forks_repo_forks_event_min_datetime": "2015-09-10T12:06:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-10T07:02:48.000Z", "avg_line_length": 29.5504385965, "max_line_length": 87, "alphanum_fraction": 0.5962152134, "num_tokens": 4011, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.45326184801538616, "lm_q2_score": 0.15817435274843167, "lm_q1q2_score": 0.07169439943539171}}
{"text": "/* ----------------------------------------------------------------------------\n\n * GTSAM Copyright 2010, Georgia Tech Research Corporation,\n * Atlanta, Georgia 30332-0415\n * All Rights Reserved\n * Authors: Frank Dellaert, et al. (see THANKS for the full author list)\n\n * See LICENSE for the license information\n\n * -------------------------------------------------------------------------- */\n\n/*\n * testDecisionTreeFactor.cpp\n *\n *  @date Feb 5, 2012\n *  @author Frank Dellaert\n *  @author Duy-Nguyen Ta\n */\n\n#include <CppUnitLite/TestHarness.h>\n#include <gtsam/base/Testable.h>\n#include <gtsam/discrete/DecisionTreeFactor.h>\n#include <gtsam/discrete/DiscreteDistribution.h>\n#include <gtsam/discrete/Signature.h>\n\n#include <boost/assign/std/map.hpp>\nusing namespace boost::assign;\n\nusing namespace std;\nusing namespace gtsam;\n\n/* ************************************************************************* */\nTEST( DecisionTreeFactor, constructors)\n{\n  // Declare a bunch of keys\n  DiscreteKey X(0,2), Y(1,3), Z(2,2);\n\n  // Create factors\n  DecisionTreeFactor f1(X, {2, 8});\n  DecisionTreeFactor f2(X & Y, \"2 5 3 6 4 7\");\n  DecisionTreeFactor f3(X & Y & Z, \"2 5 3 6 4 7 25 55 35 65 45 75\");\n  EXPECT_LONGS_EQUAL(1,f1.size());\n  EXPECT_LONGS_EQUAL(2,f2.size());\n  EXPECT_LONGS_EQUAL(3,f3.size());\n\n  DiscreteValues values;\n  values[0] = 1; // x\n  values[1] = 2; // y\n  values[2] = 1; // z\n  EXPECT_DOUBLES_EQUAL(8, f1(values), 1e-9);\n  EXPECT_DOUBLES_EQUAL(7, f2(values), 1e-9);\n  EXPECT_DOUBLES_EQUAL(75, f3(values), 1e-9);\n}\n\n/* ************************************************************************* */\nTEST(DecisionTreeFactor, multiplication) {\n  DiscreteKey v0(0, 2), v1(1, 2), v2(2, 2);\n\n  // Multiply with a DiscreteDistribution, i.e., Bayes Law!\n  DiscreteDistribution prior(v1 % \"1/3\");\n  DecisionTreeFactor f1(v0 & v1, \"1 2 3 4\");\n  DecisionTreeFactor expected(v0 & v1, \"0.25 1.5 0.75 3\");\n  CHECK(assert_equal(expected, static_cast<DecisionTreeFactor>(prior) * f1));\n  CHECK(assert_equal(expected, f1 * prior));\n\n  // Multiply two factors\n  DecisionTreeFactor f2(v1 & v2, \"5 6 7 8\");\n  DecisionTreeFactor actual = f1 * f2;\n  DecisionTreeFactor expected2(v0 & v1 & v2, \"5 6 14 16 15 18 28 32\");\n  CHECK(assert_equal(expected2, actual));\n}\n\n/* ************************************************************************* */\nTEST( DecisionTreeFactor, sum_max)\n{\n  DiscreteKey v0(0,3), v1(1,2);\n  DecisionTreeFactor f1(v0 & v1, \"1 2  3 4  5 6\");\n\n  DecisionTreeFactor expected(v1, \"9 12\");\n  DecisionTreeFactor::shared_ptr actual = f1.sum(1);\n  CHECK(assert_equal(expected, *actual, 1e-5));\n\n  DecisionTreeFactor expected2(v1, \"5 6\");\n  DecisionTreeFactor::shared_ptr actual2 = f1.max(1);\n  CHECK(assert_equal(expected2, *actual2));\n\n  DecisionTreeFactor f2(v1 & v0, \"1 2  3 4  5 6\");\n  DecisionTreeFactor::shared_ptr actual22 = f2.sum(1);\n}\n\n/* ************************************************************************* */\n// Check enumerate yields the correct list of assignment/value pairs.\nTEST(DecisionTreeFactor, enumerate) {\n  DiscreteKey A(12, 3), B(5, 2);\n  DecisionTreeFactor f(A & B, \"1 2  3 4  5 6\");\n  auto actual = f.enumerate();\n  std::vector<std::pair<DiscreteValues, double>> expected;\n  DiscreteValues values;\n  for (size_t a : {0, 1, 2}) {\n    for (size_t b : {0, 1}) {\n      values[12] = a;\n      values[5] = b;\n      expected.emplace_back(values, f(values));\n    }\n  }\n  EXPECT(actual == expected);\n}\n\n/* ************************************************************************* */\nTEST(DecisionTreeFactor, DotWithNames) {\n  DiscreteKey A(12, 3), B(5, 2);\n  DecisionTreeFactor f(A & B, \"1 2  3 4  5 6\");\n  auto formatter = [](Key key) { return key == 12 ? \"A\" : \"B\"; };\n\n  for (bool showZero:{true, false}) {  \n    string actual = f.dot(formatter, showZero);\n    // pretty weak test, as ids are pointers and not stable across platforms.\n    string expected = \"digraph G {\";\n    EXPECT(actual.substr(0, 11) == expected);\n  }\n}\n\n/* ************************************************************************* */\n// Check markdown representation looks as expected.\nTEST(DecisionTreeFactor, markdown) {\n  DiscreteKey A(12, 3), B(5, 2);\n  DecisionTreeFactor f(A & B, \"1 2  3 4  5 6\");\n  string expected =\n      \"|A|B|value|\\n\"\n      \"|:-:|:-:|:-:|\\n\"\n      \"|0|0|1|\\n\"\n      \"|0|1|2|\\n\"\n      \"|1|0|3|\\n\"\n      \"|1|1|4|\\n\"\n      \"|2|0|5|\\n\"\n      \"|2|1|6|\\n\";\n  auto formatter = [](Key key) { return key == 12 ? \"A\" : \"B\"; };\n  string actual = f.markdown(formatter);\n  EXPECT(actual == expected);\n}\n\n/* ************************************************************************* */\n// Check markdown representation with a value formatter.\nTEST(DecisionTreeFactor, markdownWithValueFormatter) {\n  DiscreteKey A(12, 3), B(5, 2);\n  DecisionTreeFactor f(A & B, \"1 2  3 4  5 6\");\n  string expected =\n      \"|A|B|value|\\n\"\n      \"|:-:|:-:|:-:|\\n\"\n      \"|Zero|-|1|\\n\"\n      \"|Zero|+|2|\\n\"\n      \"|One|-|3|\\n\"\n      \"|One|+|4|\\n\"\n      \"|Two|-|5|\\n\"\n      \"|Two|+|6|\\n\";\n  auto keyFormatter = [](Key key) { return key == 12 ? \"A\" : \"B\"; };\n  DecisionTreeFactor::Names names{{12, {\"Zero\", \"One\", \"Two\"}},\n                                  {5, {\"-\", \"+\"}}};\n  string actual = f.markdown(keyFormatter, names);\n  EXPECT(actual == expected);\n}\n\n/* ************************************************************************* */\n// Check html representation with a value formatter.\nTEST(DecisionTreeFactor, htmlWithValueFormatter) {\n  DiscreteKey A(12, 3), B(5, 2);\n  DecisionTreeFactor f(A & B, \"1 2  3 4  5 6\");\n  string expected =\n      \"<div>\\n\"\n      \"<table class='DecisionTreeFactor'>\\n\"\n      \"  <thead>\\n\"\n      \"    <tr><th>A</th><th>B</th><th>value</th></tr>\\n\"\n      \"  </thead>\\n\"\n      \"  <tbody>\\n\"\n      \"    <tr><th>Zero</th><th>-</th><td>1</td></tr>\\n\"\n      \"    <tr><th>Zero</th><th>+</th><td>2</td></tr>\\n\"\n      \"    <tr><th>One</th><th>-</th><td>3</td></tr>\\n\"\n      \"    <tr><th>One</th><th>+</th><td>4</td></tr>\\n\"\n      \"    <tr><th>Two</th><th>-</th><td>5</td></tr>\\n\"\n      \"    <tr><th>Two</th><th>+</th><td>6</td></tr>\\n\"\n      \"  </tbody>\\n\"\n      \"</table>\\n\"\n      \"</div>\";\n  auto keyFormatter = [](Key key) { return key == 12 ? \"A\" : \"B\"; };\n  DecisionTreeFactor::Names names{{12, {\"Zero\", \"One\", \"Two\"}},\n                                  {5, {\"-\", \"+\"}}};\n  string actual = f.html(keyFormatter, names);\n  EXPECT(actual == expected);\n}\n\n/* ************************************************************************* */\nint main() {\n  TestResult tr;\n  return TestRegistry::runAllTests(tr);\n}\n/* ************************************************************************* */\n\n", "meta": {"hexsha": "846653c3833e3d2319ae631b84b2cc6ff6cea9a7", "size": 6605, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "gtsam/discrete/tests/testDecisionTreeFactor.cpp", "max_stars_repo_name": "h-rover/gtsam", "max_stars_repo_head_hexsha": "a0206e210d8f47b6ee295a1fbf95af84d98c5cf0", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-03-04T07:01:48.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T07:01:48.000Z", "max_issues_repo_path": "gtsam/discrete/tests/testDecisionTreeFactor.cpp", "max_issues_repo_name": "h-rover/gtsam", "max_issues_repo_head_hexsha": "a0206e210d8f47b6ee295a1fbf95af84d98c5cf0", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gtsam/discrete/tests/testDecisionTreeFactor.cpp", "max_forks_repo_name": "h-rover/gtsam", "max_forks_repo_head_hexsha": "a0206e210d8f47b6ee295a1fbf95af84d98c5cf0", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2022-03-21T06:58:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T06:58:34.000Z", "avg_line_length": 33.3585858586, "max_line_length": 80, "alphanum_fraction": 0.515669947, "num_tokens": 1995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4921881357207955, "lm_q2_score": 0.14414885303274058, "lm_q1q2_score": 0.07094835524047553}}
{"text": "/*! \\file\n    \\brief Demonstration of showing the 1D data point values rotated at various angles.\n    \\details  Showing the 1D values of items from the data set.\n\n    Some of the many possible formatting options are demonstrated,\n    including controlling the precision and iosflags,\n    and prefix and suffix also useful for giving units.\n\n    Quickbook markup to include in documentation.\n*/\n\n// 1d_value_label_rotation.cpp\n// \n// Copyright Paul A Bristow 2021\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n//   or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// An example to demonstrate labelling data-points with their values and rotation.\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[1d_value_label_rotation\n\n/*` Showing the 1-D values of items from the data set.\n    Some of the many possible formatting options are demonstrated.\n\n    As ever, we need a few includes to use Boost.Plot\n*/\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\nusing namespace boost::svg;\nusing boost::svg::svg_1d_plot;\n\n#include <boost/svg_plot/show_1d_settings.hpp>\n// using boost::svg::show_1d_plot_settings - Only needed for showing which settings in use.\n\n#include <iostream>\nusing std::cout;\nusing std::endl;\nusing std::hex;\n\n#include <vector>\nusing std::vector;\n//] [1d_value_label_rotation]\n\nint main()\n{\n  //[demo_1d_values_2\n  /*`Some fictional data is pushed into an STL container, here `vector<double>`:*/\n  vector<double> my_data;\n  //my_data.push_back(+1.1);\n  my_data.push_back(2.2);\n//  my_data.push_back(3.3);\n  //my_data.push_back(4.4);\n // my_data.push_back(5.5);\n\n  try\n  { // try'n'catch blocks are needed to ensure error messages from any exceptions are shown.\n    svg_1d_plot my_1d_plot; // Construct a plot with all the default constructor values.\n\n    my_1d_plot\n      .title(\"Rotating 1D value-labelling\") // Add a string title of the plot.\n      .title_on(false) // Avoid showing title for this test as an issue in handling of title causes second plot to not have a title.\n      .x_range(-0, 4) // Add a range for the X-axis.\n      .x_major_interval(1.)\n      .x_num_minor_ticks(4)\n      .x_label(\"length (m)\"); // Add a label for the X-axis.\n\n/*`Add the one data series, `my_data` and a description, and how the data points are to marked,\nhere a circle with a diameter of 5 pixels.\n*/\n    my_1d_plot.plot(my_data, \"1D Values\").shape(circlet).size(10).stroke_color(red).fill_color(blue);\n\n    /*`To put a value-label against each data point, switch on the option:\n    */\n    my_1d_plot.x_values_on(true); // Add a label for the X-axis.\n\n/*`If the default size and color are not to your taste, set more options, like:\n*/\n    my_1d_plot.size(500, 250) // Change from default size.\n      .x_values_font_size(10) // Change font size for the X-axis value-labels.\n      .x_values_font_family(\"Times New Roman\") // Change font for the X-axis value-labels.\n      .x_values_color(red); // Change color of value-label text from default black to red.\n\n/*`The format of the values may also not be ideal,\nso we can use the normal `iostream precision` and `ioflags` to change,\nhere to reduce the number of digits used from default precision 6 down to a more readable 2,\nreducing the risk of collisions between adjacent values.\n(Obviously the most suitable precision depends on the range of the data points.\nIf values are very close to each other, a higher precision wil be needed to differentiate them).\n*/\n    my_1d_plot.x_values_precision(2); // precision label for the X-axis value-label.\n\n/*`We can also prescribe the use of scientific format and force a positive sign:\n*/\n    //my_1d_plot.x_values_ioflags(std::ios::scientific | std::ios::showpos);\n\n    /*`By default, any unnecessary spacing-wasting zeros in the exponent field are removed.\n    (If, perversely, the full 1.123456e+012 format is required, the stripping can be switched off with:\n      `my_1d_plot.x_labels_strip_e0s(false);` )\n\n    In general, sticking to the defaults usually produces the neatest presentation of the values.\n    */\n     my_1d_plot.x_decor(\"[ x=\", \"\", \"&#x00A0;s]\"); \n   // my_1d_plot.x_decor(\"&#x00A0; [x=\", \"\", \" s]\"); \n    // Note Leading Normal spaces are ignored!  \n    // To get a real space you may need one or more of the several Unicode spaces, for example: A0 as &#x00A0; .\n\n     /*`[note Code is shared between 1D and 2D variants, so arrangement is never perfect. [br]\n     1D data-point markers are usually above the X-axis line, so many will overwrite the line.\n     Prefix Unicode space(s) can avoid this, but the marker and value-label are then further apart.\n     */\n\n    /*`The default value-label is horizontal, centered above the data point marker,\n    but, depending on the type and density of data points, and the length of the values\n    (controlled in turn by the `precision` and `ioflags` in use),\n    it is often clearer to use a different orientation.\n    This can be controlled in steps of 45 degrees, using an 'enum rotate_style` whose possible values are:\n   ``\n    enum rotate_style\n    {\n      // Also need a no_rotate, = -1; ??\n      horizontal = 0, //!< normal horizontal left to right, centered.\n      slopeup = -30, //!< slope up.\n      uphill = -45, //!< 45 steep up.\n      steepup = -60, //!< up near vertical.\n      upward = -90, //!< vertical writing up.\n      backup = -135, //!< slope up backwards - upside down!\n      leftward= -180, //!< horizontal to left.\n      rightward = 360, //!< horizontal to right.\n      slopedownhill = 30, //!< 30 gentle slope down.\n      downhill = 45, //!< 45 down.\n      steepdown = 60, //!<  60 steeply down.\n      downward = 90,  //!< vertical writing down.\n      backdown = 135, //!< slope down backwards.\n      upsidedown = 180 //!< upside down!  (== -180)\n    };\n``\n    * `uphill` - writing up at 45 degree slope is often a good choice,\n    * `upward` - writing vertically up and\n    * `backup` are also useful.\n\n    (For 1-D plots other directions are less attractive,\n    placing the values below the horizontal Y-axis line,\n    but for 2-D plots all writing orientations can be useful).\n    */\n\n    // Orientation for the X-axis value-labels,\n   //  my_1d_plot.x_values_rotation(steepup);  //  Nearly vertically upwards. OK Best compromise?\n    // my_1d_plot.x_values_rotation(slopeup); // OK but is a bit high.\n    // my_1d_plot.x_values_rotation(uphill); // OK but is a bit high.\n    // my_1d_plot.x_values_rotation(upward); //  Vertically upwards. OK, but may need height for long labels. \n    // my_1d_plot.x_values_rotation(horizontal);  // Default Centered above, OK, but nearby values can collide, especially long labels. \n    // my_1d_plot.x_values_rotation(backup); // OK \n    // my_1d_plot.x_values_rotation(steepdown); // For 1D, Clashes with the y = 0 axis line, so need a few leading spaces, for example\n    // my_1d_plot.x_decor(\"&#x00A0; [x=\", \"\", \" s]\"); \n    // Or put the X-axis tick value-labels above the y= 0 axis line, and the markers below the axis line.\n    // my_1d_plot.x_values_rotation(slopedown); //  Clashes with X axis line.\n    //  my_1d_plot.x_values_rotation(downhill); //  Clashes with X axis line.\n    //   my_1d_plot.x_values_rotation(downward); // Straight down - Clashes with X axis line.\n    // my_1d_plot.x_values_rotation(backdown); // Clashes with X axis line.\n    // my_1d_plot.x_values_rotation(upsidedown); // Upside down and Clashes with X axis line.\n\n  //  my_1d_plot.x_values_rotation(leftward); // OK, but can clash with nearby points. \n  //  my_1d_plot.x_values_rotation(rightward); // OK, but can clash with nearby points. \n     // default orientation write value-labels horizontally above the markers.\n\n /*`To use all these settings, finally write the plot to file.\n */\n    my_1d_plot.write(\"1d_value_label_rotation.svg\");\n    \n    // Repeat for testing labelling rotation.\n    my_1d_plot.x_values_rotation(leftward); // \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    my_1d_plot.x_values_rotation(upward); // \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    // See note above about issue in title means that second (and subsequent?) plots have not title and so are offset down.\n    my_1d_plot.x_values_rotation(rightward); // OK, but can clash with nearby points. \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    my_1d_plot.x_values_rotation(uphill); // \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    my_1d_plot.x_values_rotation(backup); // \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    // Vertical below axis line, but collides.\n    my_1d_plot.x_values_rotation(upward); // \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    my_1d_plot.x_values_rotation(downward); // \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n\n    my_1d_plot.x_values_rotation(backdown); // Below with X axis line.\n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n\n    my_1d_plot.x_values_rotation(upsidedown); // Upside down - clashes a bitwith X axis line.\n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n\n    my_1d_plot.x_values_rotation(downhill); // downhill - clashes a with X axis line.\n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    my_1d_plot.x_values_rotation(slopedownhill); // downsteep - clashes a with X axis line (and downhill).  \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    my_1d_plot.x_values_rotation(steepdown); //steepdown - clashes a with X axis line (and downhill).  \n    my_1d_plot.write(\"1d_value_label_rotation_all.svg\");\n    // Displays all layouts around the point above the line.\n    // Probably also will work OK if ticks and tick-value-labels are above the y=0 X-axis horizontal line and the marker is below.\n\n    /*`If chosen settings do not have the effect that you expect, it may be helpful to display some of them!\n    (All the myriad settings can be displayed with `show_1d_plot_settings(my_1d_plot)`.)\n    */\n    //show_1d_plot_settings(my_1d_plot);\n    using boost::svg::detail::operator<<;\n    //] [demo_1d_values_2]\n  }\n  catch (const std::exception& e)\n  {\n    std::cout <<\n      \"\\n\"\"Message from thrown exception was:\\n   \" << e.what() << std::endl;\n  }\n  return 0;\n} // int main()\n\n/*\n\n//[demo_1d_values_output\n\nOutput:\n\ndemo_1d_values.cpp\nPlot written to file demo_1d_values.svg.\nmy_1d_plot.image_size() 500, 350\nmy_1d_plot.image x_size() 500\nmy_1d_plot.image y_size() 350\nmy_1d_plot.x_values_font_size() 14\nmy_1d_plot.x_values_font_family() Times New Roman\nmy_1d_plot.x_values_color() RGB(255,0,0)\nmy_1d_plot.x_values_precision() 2\nmy_1d_plot.x_values_ioflags() 1020\n\n//] [demo_1d_values_output]\n*/\n\n", "meta": {"hexsha": "ccc86c2e7e64e4cd85c567c54addd58297e9ebe1", "size": 10968, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/1d_value_label_rotation.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/1d_value_label_rotation.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/1d_value_label_rotation.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 44.2258064516, "max_line_length": 136, "alphanum_fraction": 0.7122538293, "num_tokens": 2927, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.310694383214554, "lm_q2_score": 0.22815649691270323, "lm_q1q2_score": 0.07088694208468563}}
{"text": "/* Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004 */\n\n/*    $Id: step-17.cc 28351 2013-02-12 23:23:18Z heister $       */\n/*                                                                */\n/*    Copyright (C) 2000, 2004-2009, 2011-2012 by the deal.II authors */\n/*                                                                */\n/*    This file is subject to QPL and may not be  distributed     */\n/*    without copyright and license information. Please refer     */\n/*    to the file deal.II/doc/license.html for the  text  and     */\n/*    further information on this license.                        */\n\n\n// First the usual assortment of header files we have already used in previous\n// example programs:\n#include <deal.II/base/quadrature_lib.h>\n#include <deal.II/base/function.h>\n#include <deal.II/base/logstream.h>\n#include <deal.II/lac/vector.h>\n#include <deal.II/lac/full_matrix.h>\n#include <deal.II/lac/constraint_matrix.h>\n#include <deal.II/grid/tria.h>\n#include <deal.II/grid/grid_generator.h>\n#include <deal.II/grid/grid_refinement.h>\n#include <deal.II/grid/tria_accessor.h>\n#include <deal.II/grid/tria_iterator.h>\n#include <deal.II/grid/tria_boundary_lib.h>\n#include <deal.II/dofs/dof_handler.h>\n#include <deal.II/dofs/dof_accessor.h>\n#include <deal.II/dofs/dof_tools.h>\n#include <deal.II/fe/fe_values.h>\n#include <deal.II/fe/fe_system.h>\n#include <deal.II/fe/fe_q.h>\n#include <deal.II/numerics/vector_tools.h>\n#include <deal.II/numerics/matrix_tools.h>\n#include <deal.II/numerics/data_out.h>\n#include <deal.II/numerics/error_estimator.h>\n\n// And here come the things that we need particularly for this example program\n// and that weren't in step-8. First, we replace the standard output\n// <code>std::cout</code> by a new stream <code>pcout</code> which is used in\n// %parallel computations for generating output only on one of the MPI\n// processes.\n#include <deal.II/base/conditional_ostream.h>\n// We are going to query the number of processes and the number of the present\n// process by calling the respective functions in the Utilities::MPI\n// namespace.\n#include <deal.II/base/utilities.h>\n// Then, we are going to replace all linear algebra components that involve\n// the (global) linear system by classes that wrap interfaces similar to our\n// own linear algebra classes around what PETSc offers (PETSc is a library\n// written in C, and deal.II comes with wrapper classes that provide the PETSc\n// functionality with an interface that is similar to the interface we already\n// had for our own linear algebra classes). In particular, we need vectors and\n// matrices that are distributed across several processes in MPI programs (and\n// simply map to sequential, local vectors and matrices if there is only a\n// single process, i.e. if you are running on only one machine, and without\n// MPI support):\n#include <deal.II/lac/petsc_vector.h>\n#include <deal.II/lac/petsc_parallel_vector.h>\n#include <deal.II/lac/petsc_parallel_sparse_matrix.h>\n// Then we also need interfaces for solvers and preconditioners that PETSc\n// provides:\n#include <deal.II/lac/petsc_solver.h>\n#include <deal.II/lac/petsc_precondition.h>\n// And in addition, we need some algorithms for partitioning our meshes so\n// that they can be efficiently distributed across an MPI network. The\n// partitioning algorithm is implemented in the <code>GridTools</code> class,\n// and we need an additional include file for a function in\n// <code>DoFRenumbering</code> that allows to sort the indices associated with\n// degrees of freedom so that they are numbered according to the subdomain\n// they are associated with:\n#include <deal.II/grid/grid_tools.h>\n#include <deal.II/dofs/dof_renumbering.h>\n\n// And this is simply C++ again:\n#include <fstream>\n#include <iostream>\n#include <sstream>\n\n// The last step is as in all previous programs:\nnamespace Step17\n{\n  using namespace dealii;\n\n  // Now, here comes the declaration of the main class and of various other\n  // things below it. As mentioned in the introduction, almost all of this has\n  // been copied verbatim from step-8, so we only comment on the few things\n  // that are different. There is one (cosmetic) change in that we let\n  // <code>solve</code> return a value, namely the number of iterations it\n  // took to converge, so that we can output this to the screen at the\n  // appropriate place. In addition, we introduce a stream-like variable\n  // <code>pcout</code>, explained below:\n  template <int dim>\n  class ElasticProblem\n  {\n  public:\n    ElasticProblem ();\n    ~ElasticProblem ();\n    void run ();\n\n  private:\n    void setup_system ();\n    void assemble_system ();\n    unsigned int solve ();\n    void refine_grid ();\n    void output_results (const unsigned int cycle) const;\n\n    // The first variable is basically only for convenience: in %parallel\n    // program, if each process outputs status information, then there quickly\n    // is a lot of clutter. Rather, we would want to only have one process\n    // output everything once, for example the one with process number\n    // zero. <code>ConditionalOStream</code> does exactly this: it acts as if\n    // it were a stream, but only forwards to a real, underlying stream if a\n    // flag is set. By setting this condition to\n    // <code>this_mpi_process==0</code>, we make sure that output is only\n    // generated from the first process and that we don't get the same lines\n    // of output over and over again, once per process.\n    //\n    // With this simple trick, we make sure that we don't have to guard each\n    // and every write to <code>std::cout</code> by a prefixed\n    // <code>if(this_mpi_process==0)</code>.\n    ConditionalOStream pcout;\n\n    // The next few variables are taken verbatim from step-8:\n    Triangulation<dim>   triangulation;\n    DoFHandler<dim>      dof_handler;\n\n    FESystem<dim>        fe;\n\n    ConstraintMatrix     hanging_node_constraints;\n\n    // In step-8, this would have been the place where we would have declared\n    // the member variables for the sparsity pattern, the system matrix, right\n    // hand, and solution vector. We change these declarations to use\n    // %parallel PETSc objects instead (note that the fact that we use the\n    // %parallel versions is denoted the fact that we use the classes from the\n    // <code>PETScWrappers::MPI</code> namespace; sequential versions of these\n    // classes are in the <code>PETScWrappers</code> namespace, i.e. without\n    // the <code>MPI</code> part). Note also that we do not use a separate\n    // sparsity pattern, since PETSc manages that as part of its matrix data\n    // structures.\n    PETScWrappers::MPI::SparseMatrix system_matrix;\n\n    PETScWrappers::MPI::Vector       solution;\n    PETScWrappers::MPI::Vector       system_rhs;\n\n    // The next change is that we have to declare a variable that indicates\n    // the MPI communicator over which we are supposed to distribute our\n    // computations. Note that if this is a sequential job without support by\n    // MPI, then PETSc provides some dummy type for <code>MPI_Comm</code>, so\n    // we do not have to care here whether the job is really a %parallel one:\n    MPI_Comm mpi_communicator;\n\n    // Then we have two variables that tell us where in the %parallel world we\n    // are. The first of the following variables, <code>n_mpi_processes</code>\n    // tells us how many MPI processes there exist in total, while the second\n    // one, <code>this_mpi_process</code>, indicates which is the number of\n    // the present process within this space of processes. The latter variable\n    // will have a unique value for each process between zero and (less than)\n    // <code>n_mpi_processes</code>. If this program is run on a single\n    // machine without MPI support, then their values are <code>1</code> and\n    // <code>0</code>, respectively.\n    const unsigned int n_mpi_processes;\n    const unsigned int this_mpi_process;\n  };\n\n\n  // The following is again taken from step-8 without change:\n  template <int dim>\n  class RightHandSide :  public Function<dim>\n  {\n  public:\n    RightHandSide ();\n\n    virtual void vector_value (const Point<dim> &p,\n                               Vector<double>   &values) const;\n\n    virtual void vector_value_list (const std::vector<Point<dim> > &points,\n                                    std::vector<Vector<double> >   &value_list) const;\n  };\n\n\n  template <int dim>\n  RightHandSide<dim>::RightHandSide () :\n    Function<dim> (dim)\n  {}\n\n\n  template <int dim>\n  inline\n  void RightHandSide<dim>::vector_value (const Point<dim> &p,\n                                         Vector<double>   &values) const\n  {\n    Assert (values.size() == dim,\n            ExcDimensionMismatch (values.size(), dim));\n    Assert (dim >= 2, ExcInternalError());\n\n    Point<dim> point_1, point_2;\n    point_1(0) = 0.5;\n    point_2(0) = -0.5;\n\n    if (((p-point_1).square() < 0.2*0.2) ||\n        ((p-point_2).square() < 0.2*0.2))\n      values(0) = 1;\n    else\n      values(0) = 0;\n\n    if (p.square() < 0.2*0.2)\n      values(1) = 1;\n    else\n      values(1) = 0;\n  }\n\n\n\n  template <int dim>\n  void RightHandSide<dim>::vector_value_list (const std::vector<Point<dim> > &points,\n                                              std::vector<Vector<double> >   &value_list) const\n  {\n    const unsigned int n_points = points.size();\n\n    Assert (value_list.size() == n_points,\n            ExcDimensionMismatch (value_list.size(), n_points));\n\n    for (unsigned int p=0; p<n_points; ++p)\n      RightHandSide<dim>::vector_value (points[p],\n                                        value_list[p]);\n  }\n\n\n  // The first step in the actual implementation of things is the constructor\n  // of the main class. Apart from initializing the same member variables that\n  // we already had in step-8, we here initialize the MPI communicator\n  // variable we shall use with the global MPI communicator linking all\n  // processes together (in more complex applications, one could here use a\n  // communicator object that only links a subset of all processes), and call\n  // the Utilities helper functions to determine the number of processes and\n  // where the present one fits into this picture. In addition, we make sure\n  // that output is only generated by the (globally) first process. As,\n  // this_mpi_process is determined after creation of pcout, we cannot set the\n  // condition through the constructor, i.e. by pcout(std::cout,\n  // this_mpi_process==0), but set the condition separately.\n  template <int dim>\n  ElasticProblem<dim>::ElasticProblem ()\n    :\n    pcout (std::cout),\n    dof_handler (triangulation),\n    fe (FE_Q<dim>(1), dim),\n    mpi_communicator (MPI_COMM_WORLD),\n    n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator)),\n    this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator))\n  {\n    pcout.set_condition(this_mpi_process == 0);\n  }\n\n\n\n  template <int dim>\n  ElasticProblem<dim>::~ElasticProblem ()\n  {\n    dof_handler.clear ();\n  }\n\n\n  // The second step is the function in which we set up the various variables\n  // for the global linear system to be solved.\n  template <int dim>\n  void ElasticProblem<dim>::setup_system ()\n  {\n    // Before we even start out setting up the system, there is one thing to\n    // do for a %parallel program: we need to assign cells to each of the\n    // processes. We do this by splitting (<code>partitioning</code>) the mesh\n    // cells into as many chunks (<code>subdomains</code>) as there are\n    // processes in this MPI job (if this is a sequential job, then there is\n    // only one job and all cells will get a zero as subdomain\n    // indicator). This is done using an interface to the METIS library that\n    // does this in a very efficient way, trying to minimize the number of\n    // nodes on the interfaces between subdomains. All this is hidden behind\n    // the following call to a deal.II library function:\n    GridTools::partition_triangulation (n_mpi_processes, triangulation);\n\n    // As for the linear system: First, we need to generate an enumeration for\n    // the degrees of freedom in our problem. Further below, we will show how\n    // we assign each cell to one of the MPI processes before we even get\n    // here. What we then need to do is to enumerate the degrees of freedom in\n    // a way so that all degrees of freedom associated with cells in subdomain\n    // zero (which resides on process zero) come before all DoFs associated\n    // with cells on subdomain one, before those on cells on process two, and\n    // so on. We need this since we have to split the global vectors for right\n    // hand side and solution, as well as the matrix into contiguous chunks of\n    // rows that live on each of the processors, and we will want to do this\n    // in a way that requires minimal communication. This is done using the\n    // following two functions, which first generates an initial ordering of\n    // all degrees of freedom, and then re-sort them according to above\n    // criterion:\n    dof_handler.distribute_dofs (fe);\n    DoFRenumbering::subdomain_wise (dof_handler);\n\n    // While we're at it, let us also count how many degrees of freedom there\n    // exist on the present process:\n    const unsigned int n_local_dofs\n      = DoFTools::count_dofs_with_subdomain_association (dof_handler,\n                                                         this_mpi_process);\n\n    // Then we initialize the system matrix, solution, and right hand side\n    // vectors. Since they all need to work in %parallel, we have to pass them\n    // an MPI communication object, as well as their global sizes (both\n    // dimensions are equal to the number of degrees of freedom), and also how\n    // many rows out of this global size are to be stored locally\n    // (<code>n_local_dofs</code>). In addition, PETSc needs to know how to\n    // partition the columns in the chunk of the matrix that is stored\n    // locally; for square matrices, the columns should be partitioned in the\n    // same way as the rows (indicated by the second <code>n_local_dofs</code>\n    // in the call) but in the case of rectangular matrices one has to\n    // partition the columns in the same way as vectors are partitioned with\n    // which the matrix is multiplied, while rows have to partitioned in the\n    // same way as destination vectors of matrix-vector multiplications:\n    system_matrix.reinit (mpi_communicator,\n                          dof_handler.n_dofs(),\n                          dof_handler.n_dofs(),\n                          n_local_dofs,\n                          n_local_dofs,\n                          dof_handler.max_couplings_between_dofs());\n\n    solution.reinit (mpi_communicator, dof_handler.n_dofs(), n_local_dofs);\n    system_rhs.reinit (mpi_communicator, dof_handler.n_dofs(), n_local_dofs);\n\n    // Finally, we need to initialize the objects denoting hanging node\n    // constraints for the present grid. Note that since PETSc handles the\n    // sparsity pattern internally to the matrix, there is no need to set up\n    // an independent sparsity pattern here, and to condense it for\n    // constraints, as we have done in all other example programs.\n    hanging_node_constraints.clear ();\n    DoFTools::make_hanging_node_constraints (dof_handler,\n                                             hanging_node_constraints);\n    hanging_node_constraints.close ();\n  }\n\n\n  // The third step is to actually assemble the matrix and right hand side of\n  // the problem. There are some things worth mentioning before we go into\n  // detail. First, we will be assembling the system in %parallel, i.e. each\n  // process will be responsible for assembling on cells that belong to this\n  // particular processor. Note that the degrees of freedom are split in a way\n  // such that all DoFs in the interior of cells and between cells belonging\n  // to the same subdomain belong to the process that <code>owns</code> the\n  // cell. However, even then we sometimes need to assemble on a cell with a\n  // neighbor that belongs to a different process, and in these cases when we\n  // write the local contributions into the global matrix or right hand side\n  // vector, we actually have to transfer these entries to the other\n  // process. Fortunately, we don't have to do this by hand, PETSc does all\n  // this for us by caching these elements locally, and sending them to the\n  // other processes as necessary when we call the <code>compress()</code>\n  // functions on the matrix and vector at the end of this function.\n  //\n  // The second point is that once we have handed over matrix and vector\n  // contributions to PETSc, it is a) hard, and b) very inefficient to get\n  // them back for modifications. This is not only the fault of PETSc, it is\n  // also a consequence of the distributed nature of this program: if an entry\n  // resides on another processor, then it is necessarily expensive to get\n  // it. The consequence of this is that where we previously first assembled\n  // the matrix and right hand side as if there were no hanging node\n  // constraints and boundary values, and then eliminated these in a second\n  // step, we should now try to do that while still assembling the local\n  // systems, and before handing these entries over to PETSc. At least as far\n  // as eliminating hanging nodes is concerned, this is actually possible,\n  // though removing boundary nodes isn't that simple. deal.II provides\n  // functions to do this first part: instead of copying elements by hand into\n  // the global matrix, we use the <code>distribute_local_to_global</code>\n  // functions below to take care of hanging nodes at the same time. The\n  // second step, elimination of boundary nodes, is then done in exactly the\n  // same way as in all previous example programs.\n  //\n  // So, here is the actual implementation:\n  template <int dim>\n  void ElasticProblem<dim>::assemble_system ()\n  {\n    // The infrastructure to assemble linear systems is the same as in all the\n    // other programs, and in particular unchanged from step-8. Note that we\n    // still use the deal.II full matrix and vector types for the local\n    // systems.\n    QGauss<dim>  quadrature_formula(2);\n    FEValues<dim> fe_values (fe, quadrature_formula,\n                             update_values   | update_gradients |\n                             update_quadrature_points | update_JxW_values);\n\n    const unsigned int   dofs_per_cell = fe.dofs_per_cell;\n    const unsigned int   n_q_points    = quadrature_formula.size();\n\n    FullMatrix<double>   cell_matrix (dofs_per_cell, dofs_per_cell);\n    Vector<double>       cell_rhs (dofs_per_cell);\n\n    std::vector<unsigned int> local_dof_indices (dofs_per_cell);\n\n    std::vector<double>     lambda_values (n_q_points);\n    std::vector<double>     mu_values (n_q_points);\n\n    ConstantFunction<dim> lambda(1.), mu(1.);\n\n    RightHandSide<dim>      right_hand_side;\n    std::vector<Vector<double> > rhs_values (n_q_points,\n                                             Vector<double>(dim));\n\n\n    // The next thing is the loop over all elements. Note that we do not have\n    // to do all the work: our job here is only to assemble the system on\n    // cells that actually belong to this MPI process, all other cells will be\n    // taken care of by other processes. This is what the if-clause\n    // immediately after the for-loop takes care of: it queries the subdomain\n    // identifier of each cell, which is a number associated with each cell\n    // that tells which process handles it. In more generality, the subdomain\n    // id is used to split a domain into several parts (we do this above, at\n    // the beginning of <code>setup_system</code>), and which allows to\n    // identify which subdomain a cell is living on. In this application, we\n    // have each process handle exactly one subdomain, so we identify the\n    // terms <code>subdomain</code> and <code>MPI process</code> with each\n    // other.\n    //\n    // Apart from this, assembling the local system is relatively uneventful\n    // if you have understood how this is done in step-8, and only becomes\n    // interesting again once we start distributing it into the global matrix\n    // and right hand sides.\n    typename DoFHandler<dim>::active_cell_iterator\n    cell = dof_handler.begin_active(),\n    endc = dof_handler.end();\n    for (; cell!=endc; ++cell)\n      if (cell->subdomain_id() == this_mpi_process)\n        {\n          cell_matrix = 0;\n          cell_rhs = 0;\n\n          fe_values.reinit (cell);\n\n          lambda.value_list (fe_values.get_quadrature_points(), lambda_values);\n          mu.value_list     (fe_values.get_quadrature_points(), mu_values);\n\n          for (unsigned int i=0; i<dofs_per_cell; ++i)\n            {\n              const unsigned int\n              component_i = fe.system_to_component_index(i).first;\n\n              for (unsigned int j=0; j<dofs_per_cell; ++j)\n                {\n                  const unsigned int\n                  component_j = fe.system_to_component_index(j).first;\n\n                  for (unsigned int q_point=0; q_point<n_q_points;\n                       ++q_point)\n                    {\n//TODO investigate really small values here\n                      cell_matrix(i,j)\n                      +=\n                        (\n                          (fe_values.shape_grad(i,q_point)[component_i] *\n                           fe_values.shape_grad(j,q_point)[component_j] *\n                           lambda_values[q_point])\n                          +\n                          (fe_values.shape_grad(i,q_point)[component_j] *\n                           fe_values.shape_grad(j,q_point)[component_i] *\n                           mu_values[q_point])\n                          +\n                          ((component_i == component_j) ?\n                           (fe_values.shape_grad(i,q_point) *\n                            fe_values.shape_grad(j,q_point) *\n                            mu_values[q_point])  :\n                           0)\n                        )\n                        *\n                        fe_values.JxW(q_point);\n                    }\n                }\n            }\n\n          right_hand_side.vector_value_list (fe_values.get_quadrature_points(),\n                                             rhs_values);\n          for (unsigned int i=0; i<dofs_per_cell; ++i)\n            {\n              const unsigned int\n              component_i = fe.system_to_component_index(i).first;\n\n              for (unsigned int q_point=0; q_point<n_q_points; ++q_point)\n                cell_rhs(i) += fe_values.shape_value(i,q_point) *\n                               rhs_values[q_point](component_i) *\n                               fe_values.JxW(q_point);\n            }\n\n          // Now we have the local system, and need to transfer it into the\n          // global objects. However, as described in the introduction to this\n          // function, we want to avoid any operations to matrix and vector\n          // entries after handing them off to PETSc (i.e. after distributing\n          // to the global objects). Therefore, we will take care of hanging\n          // node constraints already here. This is not quite trivial since\n          // the rows and columns of constrained nodes have to be distributed\n          // to the rows and columns of those nodes to which they are\n          // constrained. This can't be done on a purely local basis (because\n          // the degrees of freedom to which hanging nodes are constrained may\n          // not be associated with the cell we are presently treating, and\n          // are therefore not represented in the local matrix and vector),\n          // but it can be done while distributing the local system to the\n          // global one. This is what the following call does, i.e. we\n          // distribute to the global objects and at the same time make sure\n          // that hanging node constraints are taken care of:\n          cell->get_dof_indices (local_dof_indices);\n          hanging_node_constraints\n          .distribute_local_to_global(cell_matrix, cell_rhs,\n                                       local_dof_indices,\n                                       system_matrix, system_rhs);\n        }\n\n    // Now compress the vector and the system matrix:\n    system_matrix.compress();\n    system_rhs.compress(VectorOperation::add);\n\n    // The global matrix and right hand side vectors have now been\n    // formed. Note that since we took care of this already above, we do not\n    // have to condense away hanging node constraints any more.\n    //\n    // However, we still have to apply boundary values, in the same way as we\n    // always do:\n    std::map<unsigned int,double> boundary_values;\n    VectorTools::interpolate_boundary_values (dof_handler,\n                                              0,\n                                              ZeroFunction<dim>(dim),\n                                              boundary_values);\n    MatrixTools::apply_boundary_values (boundary_values,\n                                        system_matrix, solution,\n                                        system_rhs, false);\n    // The last argument to the call just performed allows for some\n    // optimizations. It controls whether we should also delete the column\n    // corresponding to a boundary node, or keep it (and passing\n    // <code>true</code> as above means: yes, do eliminate the column). If we\n    // do, then the resulting matrix will be symmetric again if it was before;\n    // if we don't, then it won't. The solution of the resulting system should\n    // be the same, though. The only reason why we may want to make the system\n    // symmetric again is that we would like to use the CG method, which only\n    // works with symmetric matrices.  Experience tells that CG also works\n    // (and works almost as well) if we don't remove the columns associated\n    // with boundary nodes, which can be easily explained by the special\n    // structure of the non-symmetry. Since eliminating columns from dense\n    // matrices is not expensive, though, we let the function do it; not doing\n    // so is more important if the linear system is either non-symmetric\n    // anyway, or we are using the non-local version of this function (as in\n    // all the other example programs before) and want to save a few cycles\n    // during this operation.\n  }\n\n\n\n  // The fourth step is to solve the linear system, with its distributed\n  // matrix and vector objects. Fortunately, PETSc offers a variety of\n  // sequential and %parallel solvers, for which we have written wrappers that\n  // have almost the same interface as is used for the deal.II solvers used in\n  // all previous example programs.\n  template <int dim>\n  unsigned int ElasticProblem<dim>::solve ()\n  {\n    // First, we have to set up a convergence monitor, and assign it the\n    // accuracy to which we would like to solve the linear system. Next, an\n    // actual solver object using PETSc's CG solver which also works with\n    // %parallel (distributed) vectors and matrices. And finally a\n    // preconditioner; we choose to use a block Jacobi preconditioner which\n    // works by computing an incomplete LU decomposition on each block\n    // (i.e. the chunk of matrix that is stored on each MPI process). That\n    // means that if you run the program with only one process, then you will\n    // use an ILU(0) as a preconditioner, while if it is run on many\n    // processes, then we will have a number of blocks on the diagonal and the\n    // preconditioner is the ILU(0) of each of these blocks.\n    SolverControl           solver_control (solution.size(),\n                                            1e-8*system_rhs.l2_norm());\n    PETScWrappers::SolverCG cg (solver_control,\n                                mpi_communicator);\n\n    PETScWrappers::PreconditionBlockJacobi preconditioner(system_matrix);\n\n    // Then solve the system:\n    cg.solve (system_matrix, solution, system_rhs,\n              preconditioner);\n\n    // The next step is to distribute hanging node constraints. This is a\n    // little tricky, since to fill in the value of a constrained node you\n    // need access to the values of the nodes to which it is constrained (for\n    // example, for a Q1 element in 2d, we need access to the two nodes on the\n    // big side of a hanging node face, to compute the value of the\n    // constrained node in the middle). Since PETSc (and, for that matter, the\n    // MPI model on which it is built) does not allow to query the value of\n    // another node in a simple way if we should need it, what we do here is\n    // to get a copy of the distributed vector where we keep all elements\n    // locally. This is simple, since the deal.II wrappers have a conversion\n    // constructor for the non-MPI vector class:\n    PETScWrappers::Vector localized_solution (solution);\n\n    // Then we distribute hanging node constraints on this local copy, i.e. we\n    // compute the values of all constrained nodes:\n    hanging_node_constraints.distribute (localized_solution);\n\n    // Then transfer everything back into the global vector. The following\n    // operation copies those elements of the localized solution that we store\n    // locally in the distributed solution, and does not touch the other\n    // ones. Since we do the same operation on all processors, we end up with\n    // a distributed vector that has all the constrained nodes fixed.\n    solution = localized_solution;\n\n    // Finally return the number of iterations it took to converge, to allow\n    // for some output:\n    return solver_control.last_step();\n  }\n\n\n\n  // Step five is to output the results we computed in this iteration. This is\n  // actually the same as done in step-8 before, with two small\n  // differences. First, all processes call this function, but not all of them\n  // need to do the work associated with generating output. In fact, they\n  // shouldn't, since we would try to write to the same file multiple times at\n  // once. So we let only the first job do this, and all the other ones idle\n  // around during this time (or start their work for the next iteration, or\n  // simply yield their CPUs to other jobs that happen to run at the same\n  // time). The second thing is that we not only output the solution vector,\n  // but also a vector that indicates which subdomain each cell belongs\n  // to. This will make for some nice pictures of partitioned domains.\n  //\n  // In practice, the present implementation of the output function is a major\n  // bottleneck of this program, since generating graphical output is\n  // expensive and doing so only on one process does, of course, not scale if\n  // we significantly increase the number of processes. In effect, this\n  // function will consume most of the run-time if you go to very large\n  // numbers of unknowns and processes, and real applications should limit the\n  // number of times they generate output through this function.\n  //\n  // The solution to this is to have each process generate output data only\n  // for it's own local cells, and write them to separate files, one file per\n  // process. This would distribute the work of generating the output to all\n  // processes equally. In a second step, separate from running this program,\n  // we would then take all the output files for a given cycle and merge these\n  // parts into one single output file. This has to be done sequentially, but\n  // can be done on a different machine, and should be relatively\n  // cheap. However, the necessary functionality for this is not yet\n  // implemented in the library, and since we are too close to the next\n  // release, we do not want to do such major destabilizing changes any\n  // more. This has been fixed in the meantime, though, and a better way to do\n  // things is explained in the step-18 example program.\n  template <int dim>\n  void ElasticProblem<dim>::output_results (const unsigned int cycle) const\n  {\n    // One point to realize is that when we want to generate output on process\n    // zero only, we need to have access to all elements of the solution\n    // vector. So we need to get a local copy of the distributed vector, which\n    // is in fact simple:\n    const PETScWrappers::Vector localized_solution (solution);\n    // The thing to notice, however, is that we do this localization operation\n    // on all processes, not only the one that actually needs the data. This\n    // can't be avoided, however, with the communication model of MPI: MPI\n    // does not have a way to query data on another process, both sides have\n    // to initiate a communication at the same time. So even though most of\n    // the processes do not need the localized solution, we have to place the\n    // call here so that all processes execute it.\n    //\n    // (In reality, part of this work can in fact be avoided. What we do is\n    // send the local parts of all processes to all other processes. What we\n    // would really need to do is to initiate an operation on all processes\n    // where each process simply sends its local chunk of data to process\n    // zero, since this is the only one that actually needs it, i.e. we need\n    // something like a gather operation. PETSc can do this, but for\n    // simplicity's sake we don't attempt to make use of this here. We don't,\n    // since what we do is not very expensive in the grand scheme of things:\n    // it is one vector communication among all processes , which has to be\n    // compared to the number of communications we have to do when solving the\n    // linear system, setting up the block-ILU for the preconditioner, and\n    // other operations.)\n\n    // This being done, process zero goes ahead with setting up the output\n    // file as in step-8, and attaching the (localized) solution vector to the\n    // output object:. (The code to generate the output file name is stolen\n    // and slightly modified from step-5, since we expect that we can do a\n    // number of cycles greater than 10, which is the maximum of what the code\n    // in step-8 could handle.)\n    if (this_mpi_process == 0)\n      {\n        std::ostringstream filename;\n        filename << \"solution-\" << cycle << \".gmv\";\n\n        std::ofstream output (filename.str().c_str());\n\n        DataOut<dim> data_out;\n        data_out.attach_dof_handler (dof_handler);\n\n        std::vector<std::string> solution_names;\n        switch (dim)\n          {\n          case 1:\n            solution_names.push_back (\"displacement\");\n            break;\n          case 2:\n            solution_names.push_back (\"x_displacement\");\n            solution_names.push_back (\"y_displacement\");\n            break;\n          case 3:\n            solution_names.push_back (\"x_displacement\");\n            solution_names.push_back (\"y_displacement\");\n            solution_names.push_back (\"z_displacement\");\n            break;\n          default:\n            Assert (false, ExcInternalError());\n          }\n\n        data_out.add_data_vector (localized_solution, solution_names);\n\n        // The only thing we do here additionally is that we also output one\n        // value per cell indicating which subdomain (i.e. MPI process) it\n        // belongs to. This requires some conversion work, since the data the\n        // library provides us with is not the one the output class expects,\n        // but this is not difficult. First, set up a vector of integers, one\n        // per cell, that is then filled by the number of subdomain each cell\n        // is in:\n        std::vector<unsigned int> partition_int (triangulation.n_active_cells());\n        GridTools::get_subdomain_association (triangulation, partition_int);\n\n        // Then convert this integer vector into a floating point vector just\n        // as the output functions want to see:\n        const Vector<double> partitioning(partition_int.begin(),\n                                          partition_int.end());\n\n        // And finally add this vector as well:\n        data_out.add_data_vector (partitioning, \"partitioning\");\n\n        // This all being done, generate the intermediate format and write it\n        // out in GMV output format:\n        data_out.build_patches ();\n        data_out.write_gmv (output);\n      }\n  }\n\n\n\n  // The sixth step is to take the solution just computed, and evaluate some\n  // kind of refinement indicator to refine the mesh. The problem is basically\n  // the same as with distributing hanging node constraints: in order to\n  // compute the error indicator, we need access to all elements of the\n  // solution vector. We then compute the indicators for the cells that belong\n  // to the present process, but then we need to distribute the refinement\n  // indicators into a distributed vector so that all processes have the\n  // values of the refinement indicator for all cells. But then, in order for\n  // each process to refine its copy of the mesh, they need to have acces to\n  // all refinement indicators locally, so they have to copy the global vector\n  // back into a local one. That's a little convoluted, but thinking about it\n  // quite straightforward nevertheless. So here's how we do it:\n  template <int dim>\n  void ElasticProblem<dim>::refine_grid ()\n  {\n    // So, first part: get a local copy of the distributed solution\n    // vector. This is necessary since the error estimator needs to get at the\n    // value of neighboring cells even if they do not belong to the subdomain\n    // associated with the present MPI process:\n    const PETScWrappers::Vector localized_solution (solution);\n\n    // Second part: set up a vector of error indicators for all cells and let\n    // the Kelly class compute refinement indicators for all cells belonging\n    // to the present subdomain/process. Note that the last argument of the\n    // call indicates which subdomain we are interested in. The three\n    // arguments before it are various other default arguments that one\n    // usually doesn't need (and doesn't state values for, but rather uses the\n    // defaults), but which we have to state here explicitly since we want to\n    // modify the value of a following argument (i.e. the one indicating the\n    // subdomain):\n    Vector<float> local_error_per_cell (triangulation.n_active_cells());\n    KellyErrorEstimator<dim>::estimate (dof_handler,\n                                        QGauss<dim-1>(2),\n                                        typename FunctionMap<dim>::type(),\n                                        localized_solution,\n                                        local_error_per_cell,\n                                        ComponentMask(),\n                                        0,\n                                        multithread_info.n_default_threads,\n                                        this_mpi_process);\n\n    // Now all processes have computed error indicators for their own cells\n    // and stored them in the respective elements of the\n    // <code>local_error_per_cell</code> vector. The elements of this vector\n    // for cells not on the present process are zero. However, since all\n    // processes have a copy of a copy of the entire triangulation and need to\n    // keep these copies in synch, they need the values of refinement\n    // indicators for all cells of the triangulation. Thus, we need to\n    // distribute our results. We do this by creating a distributed vector\n    // where each process has its share, and sets the elements it has\n    // computed. We will then later generate a local sequential copy of this\n    // distributed vector to allow each process to access all elements of this\n    // vector.\n    //\n    // So in the first step, we need to set up a %parallel vector. For\n    // simplicity, every process will own a chunk with as many elements as\n    // this process owns cells, so that the first chunk of elements is stored\n    // with process zero, the next chunk with process one, and so on. It is\n    // important to remark, however, that these elements are not necessarily\n    // the ones we will write to. This is so, since the order in which cells\n    // are arranged, i.e. the order in which the elements of the vector\n    // correspond to cells, is not ordered according to the subdomain these\n    // cells belong to. In other words, if on this process we compute\n    // indicators for cells of a certain subdomain, we may write the results\n    // to more or less random elements if the distributed vector, that do not\n    // necessarily lie within the chunk of vector we own on the present\n    // process. They will subsequently have to be copied into another\n    // process's memory space then, an operation that PETSc does for us when\n    // we call the <code>compress</code> function. This inefficiency could be\n    // avoided with some more code, but we refrain from it since it is not a\n    // major factor in the program's total runtime.\n    //\n    // So here's how we do it: count how many cells belong to this process,\n    // set up a distributed vector with that many elements to be stored\n    // locally, and copy over the elements we computed locally, then compress\n    // the result. In fact, we really only copy the elements that are nonzero,\n    // so we may miss a few that we computed to zero, but this won't hurt\n    // since the original values of the vector is zero anyway.\n    const unsigned int n_local_cells\n      = GridTools::count_cells_with_subdomain_association (triangulation,\n                                                           this_mpi_process);\n    PETScWrappers::MPI::Vector\n    distributed_all_errors (mpi_communicator,\n                            triangulation.n_active_cells(),\n                            n_local_cells);\n\n    for (unsigned int i=0; i<local_error_per_cell.size(); ++i)\n      if (local_error_per_cell(i) != 0)\n        distributed_all_errors(i) = local_error_per_cell(i);\n    distributed_all_errors.compress (VectorOperation::insert);\n\n\n    // So now we have this distributed vector out there that contains the\n    // refinement indicators for all cells. To use it, we need to obtain a\n    // local copy...\n    const Vector<float> localized_all_errors (distributed_all_errors);\n\n    // ...which we can the subsequently use to finally refine the grid:\n    GridRefinement::refine_and_coarsen_fixed_number (triangulation,\n                                                     localized_all_errors,\n                                                     0.3, 0.03);\n    triangulation.execute_coarsening_and_refinement ();\n  }\n\n\n\n  // Lastly, here is the driver function. It is almost unchanged from step-8,\n  // with the exception that we replace <code>std::cout</code> by the\n  // <code>pcout</code> stream. Apart from this, the only other cosmetic\n  // change is that we output how many degrees of freedom there are per\n  // process, and how many iterations it took for the linear solver to\n  // converge:\n  template <int dim>\n  void ElasticProblem<dim>::run ()\n  {\n    for (unsigned int cycle=0; cycle<10; ++cycle)\n      {\n        pcout << \"Cycle \" << cycle << ':' << std::endl;\n\n        if (cycle == 0)\n          {\n            GridGenerator::hyper_cube (triangulation, -1, 1);\n            triangulation.refine_global (3);\n          }\n        else\n          refine_grid ();\n\n        pcout << \"   Number of active cells:       \"\n              << triangulation.n_active_cells()\n              << std::endl;\n\n        setup_system ();\n\n        pcout << \"   Number of degrees of freedom: \"\n              << dof_handler.n_dofs()\n              << \" (by partition:\";\n        for (unsigned int p=0; p<n_mpi_processes; ++p)\n          pcout << (p==0 ? ' ' : '+')\n                << (DoFTools::\n                    count_dofs_with_subdomain_association (dof_handler,\n                                                           p));\n        pcout << \")\" << std::endl;\n\n        assemble_system ();\n        const unsigned int n_iterations = solve ();\n\n        pcout << \"   Solver converged in \" << n_iterations\n              << \" iterations.\" << std::endl;\n\n        output_results (cycle);\n      }\n  }\n}\n\n\n// So that's it, almost. <code>main()</code> works the same way as most of the\n// main functions in the other example programs, i.e. it delegates work to the\n// <code>run</code> function of a master object, and only wraps everything\n// into some code to catch exceptions:\nint main (int argc, char **argv)\n{\n  try\n    {\n      using namespace dealii;\n      using namespace Step17;\n\n      // Here is the only real difference: PETSc requires that we initialize\n      // it at the beginning of the program, and un-initialize it at the\n      // end. The class MPI_InitFinalize takes care of that. The original code\n      // sits in between, enclosed in braces to make sure that the\n      // <code>elastic_problem</code> variable goes out of scope (and is\n      // destroyed) before PETSc is closed with\n      // <code>PetscFinalize</code>. (If we wouldn't use braces, the\n      // destructor of <code>elastic_problem</code> would run after\n      // <code>PetscFinalize</code>; since the destructor involves calls to\n      // PETSc functions, we would get strange error messages from PETSc.)\n      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);\n\n      {\n        deallog.depth_console (0);\n\n        ElasticProblem<2> elastic_problem;\n        elastic_problem.run ();\n      }\n    }\n  catch (std::exception &exc)\n    {\n      std::cerr << std::endl << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n      std::cerr << \"Exception on processing: \" << std::endl\n                << exc.what() << std::endl\n                << \"Aborting!\" << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n\n      return 1;\n    }\n  catch (...)\n    {\n      std::cerr << std::endl << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n      std::cerr << \"Unknown exception!\" << std::endl\n                << \"Aborting!\" << std::endl\n                << \"----------------------------------------------------\"\n                << std::endl;\n      return 1;\n    }\n\n  return 0;\n}\n", "meta": {"hexsha": "8c3cb2605c9f62fa2aa7f7c14ad21c732dd18716", "size": 46208, "ext": "cc", "lang": "C++", "max_stars_repo_path": "MHD/examples/step-17/step-17.cc", "max_stars_repo_name": "wathen/PhD", "max_stars_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2020-10-25T13:30:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-10T21:27:30.000Z", "max_issues_repo_path": "MHD/examples/step-17/step-17.cc", "max_issues_repo_name": "wathen/PhD", "max_issues_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MHD/examples/step-17/step-17.cc", "max_forks_repo_name": "wathen/PhD", "max_forks_repo_head_hexsha": "35524f40028541a4d611d8c78574e4cf9ddc3278", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3.0, "max_forks_repo_forks_event_min_datetime": "2019-10-28T16:12:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-13T13:59:44.000Z", "avg_line_length": 48.7940865892, "max_line_length": 95, "alphanum_fraction": 0.660037223, "num_tokens": 10323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4843800842769843, "lm_q2_score": 0.14608724890715238, "lm_q1q2_score": 0.07076175393743926}}
{"text": "#include <gtest/gtest.h>\n#include <cctype>\n#include <algorithm>\n#include <functional>\n#include <iterator>\n#include <boost/utility/string_ref.hpp>\n#include <ka/parse.hpp>\n#include <ka/testutils.hpp>\n#include <ka/conceptpredicate.hpp>\n#include <ka/src.hpp>\n\nusing namespace ka;\nusing namespace ka::parse;\nusing namespace ka::test;\n\n// A result of parsing is Regular.\nTEST(ParseResult, Regular) {\n  A const c[4];\n  auto const t = type_t<A>{};\n  // `ok` and `err` returns parsing results. Iterators are arbitrary values here.\n  EXPECT_TRUE(is_regular({ ok(A{9}, c+0), ok(A{0}, c+1), err(t, c+2), err(t, c+3) }));\n}\n\n// A result of parsing contains optionally a value and an iterator to what\n// remains to parse.\nTEST(ParseResult, Basic) {\n  auto const a = A{4};\n  auto const i = &a + 1;\n  {\n    auto const res = ok(a, i); // Ok: contains a value.\n    EXPECT_EQ(a, src(res));\n    EXPECT_EQ(i, iter(res));\n  }\n  {\n    auto const res = err(type_t<A>{}, i); // Ko: does not contain a value.\n    EXPECT_TRUE(ka::empty(res)); // Therefore, calling `src` is undefined behavior.\n    EXPECT_EQ(i, iter(res)); // Always ok to get the iterator.\n  }\n}\n\n// A result of parsing is convertible to an optional.\nTEST(ParseResult, ToOpt) {\n  using std::get;\n  auto const t = type_t<A>{};\n  auto test_data = array_fn(\n    //           input             expected output\n    //           ----------------  ---------------\n    ka::product( ok(A{4}, &t),     ka::opt(A{4})  ), // Iterators are arbitrary.\n    ka::product( err(t, &t + 3),   ka::opt_t<A>() ),\n    ka::product( ok(A{9}, &t + 1), ka::opt(A{9})  )\n  );\n  for (auto const& x: test_data) {\n    EXPECT_EQ(get<1>(x), to_opt(get<0>(x)));\n  }\n}\n\nstruct equ_fn_res_t {\n  // Function<res_t<B, I> (res_t<A, I>)> F, G\n  template<typename F, typename G>\n  auto operator()(F f, G g) const -> bool {\n    auto const a = A{45};\n    auto const t = type_t<A>{};\n    for (auto const& x: array_fn(ok(A{4}, &a), ok(A{5}, &a+1), ok(A{81}, &a+2),\n        err(t, &a), err(t, &a+1), err(t, &a+2))) {\n      if (f(x) != g(x)) return false;\n    }\n    return true;\n  }\n};\n\n// `parse::res_t` is a functor on its value type.\nTEST(ParseResult, Functor) {\n  // Composable functions.\n  auto const f = [](A a) -> B { return B{2 * a.value}; };\n  auto const g = [](B b) -> C { return C{b.value + 1}; };\n\n  EXPECT_TRUE(is_functor(ka::fmap, array_fn(ka::product(g, f)), equ_fn_res_t{}));\n}\n\n// A parser is a function from a range of elements to a parsing result.\n// Range of elements is bound by a pair of iterators.\n// A parser can succeed or fail. If it fails, input is not consumed (i.e. begin\n// iterator is returned).\nTEST(ParseElement, Basic) {\n  using namespace ka::parse;\n  auto p = symbol_t{}; // Parser of one symbol.\n  A const v[] = {A{5}, A{-46}};\n\n  // Succeeds.\n  EXPECT_EQ(ok(v[0], v + 1), p(v + 0, v + 2));\n\n  // Fails.\n  auto const t = type_t<A>{};\n  EXPECT_EQ(err(t, v + 1), p(v + 1, v + 1)); // empty range\n}\n\n// Linearizable<Linearizable> L\n// Relation<ParseResult> R\ntemplate<typename L, typename R = equal_t>\nstruct equ_parser_t {\n  L ranges;\n  R equiv; // equivalence(equiv)\n\n  template<typename PA, typename PB>\n  auto operator()(PA pa, PB pb) const -> bool {\n    for (auto const& r: ranges) {\n      auto b = r.begin();\n      auto e = r.end();\n      if (! equiv(pa(b, e), pb(b, e))) return false;\n    }\n    return true;\n  }\n};\n\ntemplate<typename L, typename R = equal_t>\nauto equ_parser(L ranges, R equiv = {}) -> equ_parser_t<L, R> {\n  return {mv(ranges), mv(equiv)};\n}\n\nstruct equ_fn_symbol_t {\n  // Function<Parser<A> (Parser)> F, G\n  template<typename F, typename G>\n  auto operator()(F f, G g) const -> bool {\n    using V = std::vector<A>;\n    auto equ = equ_parser(array_fn(V{}, V{A{4}}, V{A{0}, A{9}, A{-8}, A{836}}));\n    return equ(f(symbol), g(symbol));\n  }\n};\n\n// A parametrized parser is a functor on its value type.\nTEST(ParseFunctor, Basic) {\n  // Composable functions.\n  auto const f = [](A a) -> B {return B{2 * a.value};};\n  auto const g = [](B b) -> C {return C{b.value + 1};};\n\n  // Functor test algorithm:\n  // 1) Lift functions f,g to functions of parsers.\n  //    (f: A -> B)   -> (f': symbol_t -> symbol_t)  // Done via\n  //    (g: B -> C)   -> (g': symbol_t -> symbol_t)  // ka::fmap.\n  //    (g\u2218f: A -> C) -> ((g\u2218f)': symbol_t -> symbol_t)\n  //\n  // 2) Compare lifted functions through the given equivalence:\n  //    g' \u2218 f' ~ (g'\u2218f')\n  EXPECT_TRUE(is_functor(ka::fmap, array_fn(ka::product(g, f)), equ_fn_symbol_t{}));\n}\n\nnamespace test_parse {\n  // Characters associated to test types, for parsing purpose.\n  auto char_(type_t<A>) -> char {return 'A';}\n  auto char_(type_t<B>) -> char {return 'B';}\n  auto char_(type_t<C>) -> char {return 'C';}\n\n  // Simple parser for test purpose.\n  // Expected format: char digit\n  //  (where `char` depends on type `T`)\n  // Example of valid input for type `A`: \"A4\"\n  template<typename T>\n  struct sym_t {\n  // Regular:\n    KA_GENERATE_FRIEND_REGULAR_OPS_0(sym_t)\n  // Parser:\n    template<typename I> constexpr\n    auto operator()(I b, I e) const -> parse::res_t<T, I> {\n      return (b != e && *b == char_(type_t<T>{}) && ++b != e && std::isdigit(*b))\n        ? ok(T{*b - '0'}, std::next(b))\n        : err(type_t<T>{}, b);\n    }\n  // Functor:\n    template<typename F>\n    auto fmap(F f) const -> fmapped_t<F, sym_t> {\n      return {mv(f), *this};\n    }\n  };\n\n  auto input_sample() -> std::array<boost::string_ref, 14> const& {\n    static auto const a = std::array<boost::string_ref, 14>{\n      \"\", \"A3\", \"A3A6\", \"A3A6A7\", \"B3\", \"B3A6\", \"3A\", \"$jH9w_?\", \"A3B5\", \"A3C7\",\n      \"B8A7A\", \"C0A1\", \"B9C7A8A8\", \"C0B0\"\n    };\n    return a;\n  }\n} // namespace test_parse\n\n// Product of parsers succeeds if the sequence of all of them succeeds.\nTEST(ParseProduct, Basic) {\n  auto const s = std::string(\"A5B2C5\");\n  auto const b = s.begin();\n  auto const e = s.end();\n  auto const pa = test_parse::sym_t<A>{};\n  auto const pb = test_parse::sym_t<B>{};\n\n  // Ok.\n  EXPECT_EQ(ok(ka::product(A{5}, B{2}), b + 4), parse::product(pa, pb)(b, e));\n\n  // Ko: first parser failed (could not parse a `B`).\n  auto const t0 = type_t<ka::product_t<B, A>>{};\n  EXPECT_EQ(err(t0, b), parse::product(pb, pa)(b, e));\n\n  // Ko: second parser failed (could not parse an `A`).\n  auto const t1 = type_t<ka::product_t<A, A>>{};\n  EXPECT_EQ(err(t1, b), parse::product(pa, pa)(b, e));\n}\n\n// Product operator is associative.\n// Product operator flattens products, instead of nesting them.\n// E.g. `pa * pb * pc` has type `parse::product<PA, PB, PC>` instead of\n// `parse::product<parse::product<PA, PB>, PC>`.\nTEST(ParseProductMonoid, Operator) {\n  using parse::ops::operator*;\n  auto pa = test_parse::sym_t<A>{};\n  auto pb = test_parse::sym_t<B>{};\n  auto pc = test_parse::sym_t<C>{};\n\n  EXPECT_EQ((pa * pb) * pc, pa * (pb * pc));\n\n  EXPECT_EQ(parse::product(pa, pb), pa * pb);\n  EXPECT_EQ(parse::product(pa, pb, pc), pa * pb * pc);\n  EXPECT_EQ(parse::product(pa, pb, pc, pb, pa), pa * pb * pc * pb * pa);\n}\n\n// Unit-parser always succeeds without consuming input and returns ka::unit.\nTEST(ParseUnit, Basic) {\n  {\n    auto const v = std::array<A, 3>{A{5}, A{1}, A{9}};\n    EXPECT_EQ(ok(ka::unit, v.begin()), parse::unit(v.begin(), v.end()));\n  } {\n    auto const v = std::array<B, 2>{B{7}, B{1}};\n    EXPECT_EQ(ok(ka::unit, v.begin()), parse::unit(v.begin(), v.end()));\n  }\n}\n\nnamespace test_parse {\n  // Makes res_t<T, I> comparable with res_t<product_t<T>, I> to implement logic\n  // \"up to isomorphism\" (T is isomorphic to product_t<T>).\n  template<typename T, typename I>\n  auto extract(parse::res_t<T, I> const& a) -> parse::res_t<T, I> const& {\n    return a;\n  }\n\n  template<typename T, typename I>\n  auto extract(parse::res_t<ka::product_t<T>, I> const& a) -> parse::res_t<T, I> {\n    return a.fmap([](ka::product_t<T> const& p) -> T {\n      return std::get<0>(p);\n    });\n  }\n\n  // A \u2245 (A)\n  // (A) \u2245 A\n  struct equiv_res_product_t {\n    template<typename T, typename I, typename U>\n    auto operator()(parse::res_t<T, I> const& a, parse::res_t<U, I> const& b) const\n      -> bool {\n      return extract(a) == extract(b);\n    }\n  } equiv_res_product;\n} // namespace test_parse\n\n// Unit-parser is the unit of the parser product (up to isomorphism).\nTEST(ParseProductMonoid, Unit) {\n  using parse::ops::operator*;\n  using namespace test_parse;\n  auto p = sym_t<A>{};\n  auto equ = equ_parser(input_sample(), test_parse::equiv_res_product);\n  auto _1 = parse::unit;\n  EXPECT_EQ(_1, parse::product());\n  EXPECT_TRUE(equ(_1 * _1, _1));\n  EXPECT_TRUE(equ(p * _1, p));\n  EXPECT_TRUE(equ(_1 * p, p));\n}\n\n// Sum of parsers succeeds if any succeeds. Parsers are tried in left-to-right\n// order.\nTEST(ParseSum, Basic) {\n  auto const s = std::string(\"A5B2C5\");\n  auto const b = s.begin();\n  auto const e = s.end();\n  auto const pa = test_parse::sym_t<A>{};\n  auto const pb = test_parse::sym_t<B>{};\n  auto const pc = test_parse::sym_t<C>{};\n\n  { // Ok: First alternative.\n    using sum = SumValue<A, B>;\n    EXPECT_EQ(ok(sum{indexed<0>(A{5})}, b + 2), parse::sum(pa, pb)(b, e));\n  }\n  { // Ok: second alternative.\n    using sum = SumValue<B, A>;\n    EXPECT_EQ(ok(sum{indexed<1>(A{5})}, b + 2), parse::sum(pb, pa)(b, e));\n  }\n  { // Ko.\n    using sum = SumValue<B, C>;\n    auto t = type_t<sum>{};\n    EXPECT_EQ(err(t, b), parse::sum(pb, pc)(b, e));\n  }\n}\n\n// Sum operator is associative.\n// Sum operator flattens sums, instead of nesting them.\n// E.g. `pa + pb + pc` has type `parse::sum<PA, PB, PC>` instead of\n// `parse::sum<parse::sum<PA, PB>, PC>`.\nTEST(ParseSumMonoid, Operator) {\n  using parse::ops::operator+;\n  auto pa = test_parse::sym_t<A>{};\n  auto pb = test_parse::sym_t<B>{};\n  auto pc = test_parse::sym_t<C>{};\n\n  EXPECT_EQ((pa + pb) + pc, pa + (pb + pc));\n  EXPECT_EQ(parse::sum(pa, pb), pa + pb);\n  EXPECT_EQ(parse::sum(pa, pb, pc), pa + pb + pc);\n  EXPECT_EQ(parse::sum(pa, pb, pc, pb, pa), pa + pb + pc + pb + pa);\n}\n\n// Zero-parser always failed without consuming input. Its value type is\n// uninstantiable (sum of zero type).\nTEST(ParseZero, Basic) {\n  auto const t = type_t<ka::zero_t>{};\n  {\n    auto const v = std::array<A, 3>{A{5}, A{1}, A{9}};\n    EXPECT_EQ(err(t, v.begin()), parse::zero(v.begin(), v.end()));\n  } {\n    auto const v = std::array<B, 2>{B{7}, B{1}};\n    EXPECT_EQ(err(t, v.begin()), parse::zero(v.begin(), v.end()));\n  }\n}\n\nnamespace test_parse {\n  // The following functions implement parsing result equality up-to-isomorphism.\n  // Their precondition is that results are not empty.\n  struct equiv_res_zero_t {\n    // 0 + 0 = 0\n    // Should not be defined, but linker complains...\n    auto equ_val(SumValue<ka::zero_t, ka::zero_t>, ka::zero_t) const -> bool {\n      return true;\n    }\n    // A + 0 \u2245 A\n    template<typename A>\n    auto equ_val(SumValue<A, ka::zero_t> x, A y) const -> bool {\n      return *boost::get<indexed_t<0, A>>(x) == y;\n    }\n    // 0 + A \u2245 A\n    template<typename A, int = 0> // TODO: remove the int when MSVC > 2015\n    auto equ_val(SumValue<ka::zero_t, A> x, A y) const -> bool {\n      return *boost::get<indexed_t<1, A>>(x) == y;\n    }\n    // 0 \u2245 0 * A\n    // Should not be defined, but linker complains...\n    template<typename A>\n    auto equ_val(ka::zero_t, ka::product_t<ka::zero_t, A>) const -> bool {\n      return true;\n    }\n    // 0 \u2245 A * 0\n    // Should not be defined, but linker complains...\n    template<typename A>\n    auto equ_val(ka::zero_t, ka::product_t<A, ka::zero_t>) const -> bool {\n      return true;\n    }\n    template<typename A, typename I, typename B>\n    auto operator()(res_t<A, I> const& a, res_t<B, I> const& b) const -> bool {\n      auto ea = a.empty();\n      auto eb = b.empty();\n      return ea == eb && iter(a) == iter(b) && (ea || equ_val(src(a), src(b)));\n    }\n  } equiv_res_zero;\n\n} // namespace test_parse\n\n// Zero-parser is the unit of the parser sum (up to isomorphism).\nTEST(ParseSumMonoid, Zero) {\n  using parse::ops::operator+;\n  using namespace test_parse;\n  auto equ = equ_parser(input_sample(), equiv_res_zero);\n  auto _0 = parse::zero;\n  auto p = sym_t<A>{};\n  EXPECT_EQ(_0, parse::sum());\n  EXPECT_TRUE(equ(_0 + _0, _0));\n  EXPECT_TRUE(equ(p + _0, p));\n  EXPECT_TRUE(equ(_0 + p, p));\n}\n\n// A semiring relates sum and product in the usual manner:\n//  - 0 \u2260 1 (ensured by type system)\n//  - annihilation property (this test):\n///     0 = 0 * a = a * 0\n//  - distributivity (next test):\n//      a * (b + c) = (a * b) + (a * c)\n//      (b + c) * a = (b * a) + (c * a)\nTEST(ParseQuasiSemiring, AnnihilationProperty) {\n  using parse::ops::operator*;\n  using namespace test_parse;\n  auto equ = equ_parser(input_sample(), equiv_res_zero);\n  auto a = sym_t<A>{};\n  auto _0 = parse::zero;\n  EXPECT_TRUE(equ(_0, _0 * a));\n  EXPECT_TRUE(equ(_0, a * _0));\n}\n\nnamespace test_parse {\n  struct equiv_res_distrib_t {\n    template<typename IndexedPtr>\n    auto src_idx(IndexedPtr p) const -> decltype(&**p) {\n      return p != nullptr ? &**p : nullptr;\n    }\n    // Used by test for distributivity.\n    template<typename A, typename B, typename C>\n    auto distrib_equ(A& x_a, B* x_b, C* x_c, A& y_a, B* y_b, C* y_c) const -> bool {\n      if ( (x_b == nullptr) != (y_b == nullptr)\n        || (x_c == nullptr) != (y_c == nullptr)) return false;\n      return x_a == y_a\n        && (x_b != nullptr\n            ? *x_b == *y_b\n            : *x_c == *y_c);\n    }\n    // A * (B + C) \u2245 (A * B) + (A * C)\n    template<typename A, typename B, typename C>\n    auto equ_val(\n      ka::product_t<                                     // *\n        A,                                               // A\n        boost::variant<indexed_t<0, B>, indexed_t<1, C>> // B + C\n      > const& x,\n      boost::variant<                      // +\n        indexed_t<0, ka::product_t<A, B>>, // A * B\n        indexed_t<1, ka::product_t<A, C>>  // A * C\n      > const& y) const -> bool {\n\n      auto* y_ab = src_idx(boost::get<indexed_t<0, ka::product_t<A, B>>>(&y));\n      auto* y_ac = src_idx(boost::get<indexed_t<1, ka::product_t<A, C>>>(&y));\n      auto& y_a = y_ab != nullptr ? std::get<0>(*y_ab) : std::get<0>(*y_ac);\n      auto* y_b = y_ab != nullptr ? &std::get<1>(*y_ab) : nullptr;\n      auto* y_c = y_ac != nullptr ? &std::get<1>(*y_ac) : nullptr;\n      auto& x_a = std::get<0>(x);\n      auto* x_b = src_idx(boost::get<indexed_t<0, B>>(&std::get<1>(x)));\n      auto* x_c = src_idx(boost::get<indexed_t<1, C>>(&std::get<1>(x)));\n      return distrib_equ(x_a, x_b, x_c, y_a, y_b, y_c);\n    }\n\n    // (B + C) * A \u2245 (B * A) + (C * A)\n    // Factorization seems more trouble than having two versions.\n    template<typename A, typename B, typename C>\n    auto equ_val(\n      ka::product_t<                                      // *\n        boost::variant<indexed_t<0, B>, indexed_t<1, C>>, // B + C\n        A                                                 // A\n      > const& x,\n      boost::variant<                      // +\n        indexed_t<0, ka::product_t<B, A>>, // B * A\n        indexed_t<1, ka::product_t<C, A>>  // C * A\n      > const& y) const -> bool {\n\n      auto* y_ba = src_idx(boost::get<indexed_t<0, ka::product_t<B, A>>>(&y));\n      auto* y_ca = src_idx(boost::get<indexed_t<1, ka::product_t<C, A>>>(&y));\n      auto& y_a = y_ba != nullptr ? std::get<1>(*y_ba) : std::get<1>(*y_ca);\n      auto* y_b = y_ba != nullptr ? &std::get<0>(*y_ba) : nullptr;\n      auto* y_c = y_ca != nullptr ? &std::get<0>(*y_ca) : nullptr;\n      auto& x_a = std::get<1>(x);\n      auto* x_b = src_idx(boost::get<indexed_t<0, B>>(&std::get<0>(x)));\n      auto* x_c = src_idx(boost::get<indexed_t<1, C>>(&std::get<0>(x)));\n      return distrib_equ(x_a, x_b, x_c, y_a, y_b, y_c);\n    }\n    template<typename A, typename I, typename B>\n    auto operator()(res_t<A, I> const& a, res_t<B, I> const& b) const -> bool {\n      auto ea = a.empty();\n      auto eb = b.empty();\n      return ea == eb && iter(a) == iter(b) && (ea || equ_val(src(a), src(b)));\n    }\n  } equiv_res_distrib;\n} // namespace test_parse\n\nTEST(ParseQuasiSemiring, Distributivity) {\n  using parse::ops::operator*;\n  using parse::ops::operator+;\n  using namespace test_parse;\n  auto equ = equ_parser(input_sample(), equiv_res_distrib);\n  auto a = sym_t<A>{};\n  auto b = sym_t<B>{};\n  auto c = sym_t<C>{};\n  EXPECT_TRUE(equ(a * (b + c), (a * b) + (a * c)));\n  EXPECT_TRUE(equ((b + c) * a, (b * a) + (c * a)));\n}\n\nnamespace test_parse {\n  struct equiv_res_opt_t {\n    // ka::opt_t<A> \u2245 A + 1\n    template<typename A>\n    auto equ_val(ka::opt_t<A> x, SumValue<A, ka::unit_t> y) const -> bool {\n      using ka::src;\n      auto* y_a = boost::get<indexed_t<0, A>>(&y);\n      return x.empty()\n        ? y_a == nullptr\n        : src(x) == src(src(y_a));\n    }\n    template<typename A, typename I, typename B>\n    auto operator()(res_t<A, I> const& a, res_t<B, I> const& b) const -> bool {\n      auto ea = a.empty();\n      auto eb = b.empty();\n      return ea == eb && iter(a) == iter(b) && (ea || equ_val(src(a), src(b)));\n    }\n  } equiv_res_opt;\n\n} // namespace test_parse\n\n// An optional parser of `A` always succeeds: if `A` cannot be parsed, it\n// returns unit.\n// opt(p) \u2245 p + 1\nTEST(ParseOpt, Basic) {\n  using parse::ops::operator+;\n  using namespace test_parse;\n  auto _1 = parse::unit;\n  auto p = sym_t<A>{};\n  auto equ = equ_parser(input_sample(), equiv_res_opt);\n  EXPECT_TRUE(equ(parse::opt(p), p + _1));\n}\n\nTEST(ParseQuantify, Basic) {\n  auto const pa = test_parse::sym_t<A>{};\n  using V = std::vector<A>;\n  {\n    { // Ok: No element.\n      auto const s = std::string(\"A5A2B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      auto p = quantify(pa, 0, 0);\n      EXPECT_EQ(ok(V{}, b), p(b, e));\n      EXPECT_EQ(ok(V{}, b), p(b, b)); // empty range\n    }\n    { // Ok: No element.\n      auto const s = std::string(\"C5A2B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      EXPECT_EQ(ok(V{}, b), quantify(pa, 0, 1)(b, e));\n      EXPECT_EQ(ok(V{}, b), quantify(pa, 0, 2)(b, e));\n      EXPECT_EQ(ok(V{}, b), quantify(pa, 0, 3)(b, e));\n      EXPECT_EQ(ok(V{}, b), quantify(pa, 0)(b, e));\n    }\n    { // Ok: One element.\n      auto const s = std::string(\"A5C2B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 0, 1)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 0, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 0, 3)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 0)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 1, 1)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 1, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 1, 3)(b, e));\n      EXPECT_EQ(ok(V{A{5}}, b + 2), quantify(pa, 1)(b, e));\n    }\n    { // Ok: One or two elements.\n      auto const s = std::string(\"A5A2B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      EXPECT_EQ(ok(V{A{5}},       b + 2), quantify(pa, 0, 1)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 0, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 0, 3)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 0)(b, e));\n      EXPECT_EQ(ok(V{A{5}},       b + 2), quantify(pa, 1, 1)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 1, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 1, 3)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 1)(b, e));\n    }\n    { // Ok: Two elements.\n      auto const s = std::string(\"A5A2B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 0, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 0)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 1, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 1)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 2, 2)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 2, 3)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 2, 4)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), quantify(pa, 2)(b, e));\n    }\n    { // Ok: From two to three elements.\n      auto const s = std::string(\"A5A2A6A9B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      EXPECT_EQ(ok(V{A{5}, A{2}, A{6}}, b + 6), quantify(pa, 2, 3)(b, e));\n      EXPECT_EQ(ok(V{A{5}, A{2}, A{6}}, b + 6), quantify(pa, 2, 3)(b, b + 6));\n    }\n    { // Ko: At least one element.\n      auto const s = std::string(\"B5A2A6A9B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      auto const t = type_t<V>{};\n      EXPECT_EQ(err(t, b), quantify(pa, 1, 1)(b, e));\n      EXPECT_EQ(err(t, b), quantify(pa, 1, 2)(b, e));\n      EXPECT_EQ(err(t, b), quantify(pa, 1, 3)(b, e));\n      EXPECT_EQ(err(t, b), quantify(pa, 1)(b, e));\n    }\n    { // Ko: From three to four elements.\n      auto const s = std::string(\"A5A2B5\");\n      auto const b = s.begin();\n      auto const e = s.end();\n      auto const t = type_t<V>{};\n      EXPECT_EQ(err(t, b), quantify(pa, 3, 4)(b, e));\n    }\n  }\n}\n\nnamespace test_parse {\n  struct list_fn_t {\n    template<typename PA> constexpr\n    auto operator()(PA&& pa) const -> decltype(list(fwd<PA>(pa))) {\n      return list(fwd<PA>(pa));\n    }\n  };\n\n  struct quantify_0_fn_t {\n    template<typename PA> constexpr\n    auto operator()(PA&& pa) const -> decltype(quantify(fwd<PA>(pa), 0)) {\n      return quantify(fwd<PA>(pa), 0);\n    }\n  };\n\n  using list_types = testing::Types<\n    list_fn_t,\n    quantify_0_fn_t\n  >;\n} // namespace test_parse\n\ntemplate<typename T> struct ParseList : testing::Test {};\nTYPED_TEST_SUITE(ParseList, test_parse::list_types);\n\n// List of a parser applies it as much as possible.\nTYPED_TEST(ParseList, Basic) {\n  auto list = TypeParam{};\n  auto const pa = test_parse::sym_t<A>{};\n  using V = std::vector<A>;\n\n  { // Ok: No element.\n    auto const s = std::string(\"C5A2B5\");\n    auto const b = s.begin();\n    auto const e = s.end();\n    EXPECT_EQ(ok(V{}, b), list(pa)(b, e));\n  }\n  { // Ok: One element.\n    auto const s = std::string(\"A5B2B5\");\n    auto const b = s.begin();\n    auto const e = s.end();\n    EXPECT_EQ(ok(V{A{5}}, b + 2), list(pa)(b, e));\n  }\n  { // Ok: Two elements, range's end not reached.\n    auto const s = std::string(\"A5A2C5\");\n    auto const b = s.begin();\n    auto const e = s.end();\n    EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), list(pa)(b, e));\n  }\n  { // Ok: Two elements, range's end reached.\n    auto const s = std::string(\"A5A2\");\n    auto const b = s.begin();\n    auto const e = s.end();\n    EXPECT_EQ(ok(V{A{5}, A{2}}, b + 4), list(pa)(b, e));\n  }\n  { // Ok: Five elements, range's end not reached.\n    auto const s = std::string(\"A5A2A8A9A0B7\");\n    auto const b = s.begin();\n    auto const e = s.end();\n    EXPECT_EQ(ok(V{A{5}, A{2}, A{8}, A{9}, A{0}}, b + 10), list(pa)(b, e));\n  }\n}\n\n// List operator flattens lists, instead of nesting them.\n// E.g. `**pa` has type `parse::list<PA>` instead of\n// `parse::list<parse::list<PA>>`.\nTEST(ParseList, Operator) {\n  using parse::ops::operator*;\n  auto pa = test_parse::sym_t<A>{};\n  EXPECT_EQ(list(pa), *pa);\n  EXPECT_EQ(*pa, **pa);\n  EXPECT_EQ(*pa, ***pa);\n  EXPECT_EQ(*pa, ************pa);\n}\n\n// TODO: Test list concatenation when available.\n// TODO: Test empty list when available.\n// TODO: Test list monoid when available.\n", "meta": {"hexsha": "421801f9a35361bd654abbea13fde9ca8ffbca61", "size": 23247, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/ka/test_parse.cpp", "max_stars_repo_name": "Maelic/libqi", "max_stars_repo_head_hexsha": "0a92452be48376004e5e5ebfe2bd0683725d033e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/ka/test_parse.cpp", "max_issues_repo_name": "Maelic/libqi", "max_issues_repo_head_hexsha": "0a92452be48376004e5e5ebfe2bd0683725d033e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/ka/test_parse.cpp", "max_forks_repo_name": "Maelic/libqi", "max_forks_repo_head_hexsha": "0a92452be48376004e5e5ebfe2bd0683725d033e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.3890532544, "max_line_length": 86, "alphanum_fraction": 0.5671699574, "num_tokens": 7622, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4455295350395727, "lm_q2_score": 0.15817435671676672, "lm_q1q2_score": 0.07047134760320459}}
{"text": "#include \"Algorithms/HackerRank/InsertionSort.h\"\n#include \"Tools/CaptureCout.h\"\n\n#include <boost/test/unit_test.hpp>\n#include <string>\n#include <vector>\n\nusing Algorithms::HackerRank::Sorting::InsertionSort::insertion_sort;\nusing Algorithms::HackerRank::Sorting::InsertionSort::insertion_sort_1;\nusing Algorithms::HackerRank::Sorting::InsertionSort::running_time;\nusing Tools::CaptureCoutFixture;\nusing std::string;\nusing std::vector;\n\nBOOST_AUTO_TEST_SUITE(Algorithms)\nBOOST_AUTO_TEST_SUITE(HackerRank)\nBOOST_AUTO_TEST_SUITE(Sorting)\nBOOST_AUTO_TEST_SUITE(InsertionSort_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_FIXTURE_TEST_CASE(InsertionSort1PrintsSwapsAndInsertions,\n\tCaptureCoutFixture)\n{\n\tvector<int> arr {1, 2, 4, 5, 3};\n\tBOOST_TEST_REQUIRE(arr[arr.size() - 1] == 3);\n\tBOOST_TEST_REQUIRE(arr[arr.size() - 2] == 5);\n\n\tinsertion_sort_1(arr.size(), arr);\n\n\trestore_cout();\n\n  BOOST_TEST(local_oss_.str() == \"1 2 4 5 5 \\n1 2 4 4 5 \\n1 2 3 4 5 \");\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_FIXTURE_TEST_CASE(InsertionSort1PrintsSwapsAndInsertionsExample2,\n\tCaptureCoutFixture)\n{\n\tvector<int> arr {2, 4, 6, 8, 3};\n\tBOOST_TEST_REQUIRE(arr[arr.size() - 1] == 3);\n\tBOOST_TEST_REQUIRE(arr[arr.size() - 2] == 8);\n\n\tinsertion_sort_1(arr.size(), arr);\n\n\trestore_cout();\n\n  BOOST_TEST(local_oss_.str() ==\n  \t\"2 4 6 8 8 \\n2 4 6 6 8 \\n2 4 4 6 8 \\n2 3 4 6 8 \");\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_FIXTURE_TEST_CASE(InsertionSort1PrintsSwapsAndInsertionsTestCase2,\n\tCaptureCoutFixture)\n{\n\tvector<int> arr {2, 3, 4, 5, 6, 7, 8, 9, 10, 1};\n\tBOOST_TEST_REQUIRE(arr[arr.size() - 1] == 1);\n\tBOOST_TEST_REQUIRE(arr[arr.size() - 2] == 10);\n\n\tinsertion_sort_1(arr.size(), arr);\n\n\trestore_cout();\n\n\tstring expected {\"2 3 4 5 6 7 8 9 10 10 \\n\"};\n\texpected += \"2 3 4 5 6 7 8 9 9 10 \\n\";\n\texpected += \"2 3 4 5 6 7 8 8 9 10 \\n\";\n\texpected += \"2 3 4 5 6 7 7 8 9 10 \\n\";\n\texpected += \"2 3 4 5 6 6 7 8 9 10 \\n\";\n\texpected += \"2 3 4 5 5 6 7 8 9 10 \\n\";\n\texpected += \"2 3 4 4 5 6 7 8 9 10 \\n\";\n\texpected += \"2 3 3 4 5 6 7 8 9 10 \\n\";\n\texpected += \"2 2 3 4 5 6 7 8 9 10 \\n\";\n\texpected += \"1 2 3 4 5 6 7 8 9 10 \";\n\n  BOOST_TEST(local_oss_.str() == expected);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(InsertionSortSorts)\n{\n\tint arr[] {4, 1, 3, 5, 6, 2};\n\n\tinsertion_sort(6, arr);\n\n\tBOOST_TEST(arr[0] == 1);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(RunningTimeCountsShifts)\n{\n\t{\n\t\tvector<int> arr {2, 1, 3, 1, 2};\n\n\t\tBOOST_TEST(running_time(arr) == 4);\n\n\t\tBOOST_TEST(arr[0] == 1);\n\t\tBOOST_TEST(arr[1] == 1);\n\t\tBOOST_TEST(arr[2] == 2);\n\t\tBOOST_TEST(arr[3] == 2);\n\t\tBOOST_TEST(arr[4] == 3);\n\t}\n}\n\n// https://www.hackerrank.com/challenges/runningtime/problem?h_r=next-challenge&h_v=zen\n// SampleTestCase1\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(RunningTimeCountsNoShiftsOnSortedList)\n{\n\tvector<int> arr {1, 1, 2, 2, 3, 3, 5, 5, 7, 7, 9, 9};\n\n\tBOOST_TEST(running_time(arr) == 0);\n}\n\nBOOST_AUTO_TEST_SUITE_END() // InsertionSort_tests\nBOOST_AUTO_TEST_SUITE_END() // Sorting\nBOOST_AUTO_TEST_SUITE_END() // HackerRank\nBOOST_AUTO_TEST_SUITE_END() // Algorithms", "meta": {"hexsha": "97275c9c3eecc9d509295c9c2167d3c97841416e", "size": 3851, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Algorithms/HackerRank/InsertionSort_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Algorithms/HackerRank/InsertionSort_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Algorithms/HackerRank/InsertionSort_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.5655737705, "max_line_length": 87, "alphanum_fraction": 0.5177875876, "num_tokens": 1094, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4882833952958347, "lm_q2_score": 0.14414885670945196, "lm_q1q2_score": 0.07038549318210396}}
{"text": "/**\n * @file    Format.cc\n * @brief   Implementation of double formatting strings\n * @author  [Yi-Mu \"Enoch\" Chen](https://github.com/yimuchen)\n */\n\n#ifdef CMSSW_GIT_HASH\n#include \"UserUtils/Common/interface/Format.hpp\"\n#include \"UserUtils/Common/interface/Maths.hpp\"\n#include \"UserUtils/Common/interface/STLUtils/StringUtils.hpp\"\n#else\n#include \"UserUtils/Common/Format.hpp\"\n#include \"UserUtils/Common/Maths.hpp\"\n#include \"UserUtils/Common/STLUtils/StringUtils.hpp\"\n#endif\n\n#include <boost/algorithm/string.hpp>\n#include <cmath>\n#include <regex>\n#include <string>\n\nnamespace usr {\n\nnamespace fmt {\n\nnamespace base {\n\n/*-----------------------------------------------------------------------------\n *  Default settings control variables\n   --------------------------------------------------------------------------*/\n\n/**\n * @details default precision is set such that loss of precision due to IO would\n * not be of too much concern, while avoiding artifacts in decimal--binary\n * conversions (ex. 1.7=1.6999999999999999556 )\n */\nint precision_default = 8;\n\n/**\n * @details spacing between digits should be universal (i.e. three digits), but\n * can be changed if publishing to journal using another number system.\n */\nunsigned spacesep_default = 3;\n\n/**\n * @details Defaults to none, as it is easier on the eyes when testing code with\n * screen I/O, but you might want to set it to the latex \"\\,\" string when\n * mass producing numbers for publication.\n */\nstd::string spacestr_default = \"\";\n\n/**\n * @details library specifically doesn't allow more digits then 27 to be\n * printed after the decimal point. This is pretty close to the recommended\n * precision limit of doubles anyway.\n */\nconst unsigned max_precision = 27;\n\n/**\n * @brief generating string to represent double as a string in decimal.\n */\nstd::string\ndecimal::str() const\n{\n  const unsigned op_precision = std::min( abs( _precision ), abs( max_precision ) );\n  std::string retstr          = usr::fstr( usr::fstr( \"%%.%df\", op_precision ), _input );\n\n  // stripping trailing zero after decimal point\n  if( _precision < 0 && retstr.find( '.' ) != std::string::npos ){\n    boost::trim_right_if( retstr, boost::is_any_of( \"0\" ) );\n    boost::trim_right_if( retstr, boost::is_any_of( \".\" ) );\n  }\n\n  // Adding spacing string every _spacesep digits away from decimal point\n  // Largest double is around e308\n  if( _spacesep != 0 && _spacestr != \"\" ){\n    int space = ( ( (int)( retstr.length()/_spacesep ) ) + 1 ) * _spacesep;\n\n    while( space > 0 ){\n      if( retstr.find( '.' ) != std::string::npos ){\n        // If decimal point exists, expand around decimal point\n        const std::regex before( usr::fstr( \"(.*\\\\d)(\\\\d{%d}\\\\..*)\", space ) );\n        const std::regex after(  usr::fstr( \"(.*\\\\.\\\\d{%d})(\\\\d.*)\", space ) );\n        retstr = std::regex_replace( retstr, before, \"$1\"+_spacestr+\"$2\" );\n        retstr = std::regex_replace( retstr, after,  \"$1\"+_spacestr+\"$2\" );\n      } else {\n        // If decimal point doesn't exist, expand around right most side\n        const std::regex beforedec(  usr::fstr( \"(.*\\\\d)(\\\\d{%d})\", space ) );\n        retstr = std::regex_replace( retstr, beforedec, \"$1\"+_spacestr+\"$2\" );\n      }\n      space -= _spacesep;\n    }\n  }\n  return retstr;\n}\n\n\n/**\n * @brief Requires explicit specification of precision (cannot be negative)\n */\nscientific::scientific( const double x, const unsigned p )\n{\n  precision( p );\n  _mant = x;\n  _exp  = ReduceToMant( _mant );\n}\n\n/**\n * @brief Generating string to represent double as string in scientific\n *  notations.\n */\nstd::string\nscientific::str() const\n{\n  const std::string base = decimal( _mant, _precision ).dupsetting( *this ).str();\n  // largest exponent should be around ~300\n  // no need of additional formatting.\n  const std::string ans\n    = ( _exp == 0 ) ?  base : usr::fstr( \"%s \\\\times 10^{%d}\", base, _exp );\n  return ans;\n}\n\n}/* base */\n\n}/* fmt */\n\n}/* usr */\n", "meta": {"hexsha": "6c83d0e924ad5e48b8c27c3321fb6aa16a25fc99", "size": 3915, "ext": "cc", "lang": "C++", "max_stars_repo_path": "Common/src/Format.cc", "max_stars_repo_name": "yimuchen/UserUtils", "max_stars_repo_head_hexsha": "1a5c55d286f325424f4cfd23f22da63cfa6fb6a9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Common/src/Format.cc", "max_issues_repo_name": "yimuchen/UserUtils", "max_issues_repo_head_hexsha": "1a5c55d286f325424f4cfd23f22da63cfa6fb6a9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2021-12-10T15:04:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-10T18:56:53.000Z", "max_forks_repo_path": "Common/src/Format.cc", "max_forks_repo_name": "yimuchen/UserUtils", "max_forks_repo_head_hexsha": "1a5c55d286f325424f4cfd23f22da63cfa6fb6a9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2018-06-05T14:08:08.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-05T14:08:08.000Z", "avg_line_length": 30.5859375, "max_line_length": 89, "alphanum_fraction": 0.6314176245, "num_tokens": 1001, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.14033624229926062, "lm_q1q2_score": 0.07016812114963031}}
{"text": "/*! \\file demo_1d_tick_values.cpp\n    \\brief Demonstration of some simple 1D tick value label formatting.\n    \\details Quickbook markup to include in documentation.\n    \\date 19 Jul 2009\n    \\author Paul A. Bristow\n*/\n\n// Copyright Paul A Bristow 2009\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// An example to demonstrate simple 1D settings but tick value formatting.\n// See also demo_1d_plot.cpp for a wider range of use.\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[demo_1d_tick_values_1\n\n/*`As ever, we need a few includes to use Boost.Plot and an STL container.\n*/\n//] [demo_1d_tick_values_1]\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\n  using namespace boost::svg;\n  using boost::svg::svg_1d_plot;\n\n  #include <boost/svg_plot/show_1d_settings.hpp>\n// using boost::svg::show_1d_plot_settings - Only needed for showing which settings in use.\n\n#include <iostream>\n  using std::cout;\n  using std::endl;\n  using std::hex;\n  using std::dec;\n  using std::ios_base;\n  using std::fixed;\n  using std::scientific;\n\n#include <iomanip>\n  using std::setprecision;\n  using std::setiosflags;\n\n#include <vector>\n  using std::vector;\n\nint main()\n{\n //[demo_1d_tick_values_2\n/*`Some fictional data is pushed into an STL container, here vector<double>:*/\n  vector<double> my_data;\n  my_data.push_back(-1.6);\n  my_data.push_back(4.2563);\n  my_data.push_back(0.00333974);\n  my_data.push_back(5.4);\n  my_data.push_back(6.556);\n\n  try\n  { // try'n'catch blocks are needed to ensure error messages from any exceptions are shown.\n    svg_1d_plot my_1d_plot; // Construct a plot with all the default constructor values.\n\n    my_1d_plot.title(\"Demo 1D Tick Values\") // Add a string title of the plot.\n      .x_range(-5, 10) // Add a range for the X-axis.\n      .x_label(\"temp (&#x00B0;C)\"); // Add a label for the X-axis, using Unicode degree symbol.\n\n/*`Add the one data series, `my_data` and a description,\nand how the data points are to be marked, a circle with a diameter of 7 pixels.\n*/\n    my_1d_plot.plot(my_data, \"1D Values\").shape(circlet).size(7);\n\n/*`If the default size and color are not to your taste, set more options, like:\n*/\n    my_1d_plot.size(500, 150) // Change plot window from the default image size.\n      // Change the X-axis label style:\n      .x_axis_label_color(green)\n      .x_label_font_family(\"Arial\")\n      .x_label_font_size(18)\n\n      // Change the style of the X (major) ticks:\n      .x_ticks_values_color(magenta)\n      //.x_ticks_values_font_family(\"Times New Roman\")\n      .x_ticks_values_font_family(\"arial\")\n      .x_ticks_values_font_size(15)\n\n/*`The format of the tick value labels may not suit your data and its range,\nso we can use the normal `iostream precision` and `ioflags` to change,\nhere to reduce the number of digits used from default precision 6 down to a more readable 2,\nreducing the risk of collisions between adjacent values.\nIf values are very close to each other (a small range on the axis),\na higher precision wil be needed to differentiate them).\nWe could also prescribe the use of scientific format and force a positive sign:\nBy default, any unnecessary spacing-wasting zeros in the exponent field are removed.\n\nIf, perversely, the full 1.123456e+012 format is required, the stripping can be switched off with:\n  `my_1d_plot.x_ticks_values_strip_e0s(false);`\n*/\n      // Change the format from the default \"-4\", \"-2\", \"0\" \"2\", \"4\" ...\n      // (which makes a 'best guess' at the format)\n      // to \"-4.00\", \"-2.00\", ...\"+2.00\", \"4.00\"\n      // showing trailing zeros and a leading positive sign.\n      .x_ticks_values_ioflags(ios_base::fixed | std::ios::showpos)\n      .x_ticks_values_precision(1) // \n\n      // One could use ios_base::scientific for e format.\n      //.x_ticks_values_ioflags(ios_base::fixed | std::ios::showpos )\n      //.x_ticks_values_ioflags(std::ios::showpoint | std::ios::showpos)\n      //.x_ticks_values_ioflags(std::ios::scientific)\n     ;\n\n/*`To use all these settings, finally write the plot to file.\n*/\n    my_1d_plot.write(\"demo_1d_tick_values.svg\");\n\n/*`If chosen settings do not have the effect that you expect, it may be helpful to display them.\n\n(All the myriad settings can be displayed with `show_1d_plot_settings(my_1d_plot)`.)\n*/\n    //show_1d_plot_settings(my_1d_plot);\n    using boost::svg::detail::operator<<;\n    cout << \"my_1d_plot.size() \" << my_1d_plot.size() << endl;\n    cout << \"my_1d_plot.x_size() \" << my_1d_plot.x_size() << endl;\n    cout << \"my_1d_plot.y_size() \" << my_1d_plot.y_size() << endl;\n\n    cout << \"my_1d_plot.x_axis_label_color() \" << my_1d_plot.x_axis_label_color() << endl;\n    cout << \"my_1d_plot.x_label_font_family() \" << my_1d_plot.x_label_font_family() << endl;\n    cout << \"my_1d_plot.x_label_font_size() \" << my_1d_plot.x_label_font_size() << endl;\n\n    cout << \"my_1d_plot.x_ticks_values_font_family() \" << my_1d_plot.x_ticks_values_font_family() << endl;\n    cout << \"my_1d_plot.x_ticks_values_font_size() \" << my_1d_plot.x_ticks_values_font_size() << endl;\n    cout << \"my_1d_plot.x_ticks_values_color() \" << my_1d_plot.x_ticks_values_color() << endl;\n    \n    cout << \"my_1d_plot.x_ticks_values_precision() \" << my_1d_plot.x_ticks_values_precision() << endl;\n    cout << \"my_1d_plot.x_ticks_values_ioflags() \" << hex << my_1d_plot.x_ticks_values_ioflags() << endl;\n\n/*`See demo_1d_ticks_values.cpp for full source code.\n*/\n\n//] [demo_1d_tick_values_2]\n  }\n  catch(const std::exception& e)\n  {\n    std::cout <<\n      \"\\n\"\"Message from thrown exception was:\\n   \" << e.what() << std::endl;\n  }\n  return 0;\n} // int main()\n\n/*\n\n//[demo_1d_tick_values_output\n\nOutput:\n\nutorun \"j:\\Cpp\\SVG\\Debug\\demo_1d_ticks_values.exe\nmy_1d_plot.image_size() 500, 150\nmy_1d_plot.image_x_size() 500\nmy_1d_plot.image_y_size() 150\nmy_1d_plot.x_axis_label_color() RGB(0,128,0)\nmy_1d_plot.x_label_font_family() Arial\nmy_1d_plot.x_label_font_size() 18\nmy_1d_plot.x_ticks_values_font_family() Verdana\nmy_1d_plot.x_ticks_values_font_size() 12\nmy_1d_plot.x_ticks_values_color() RGB(255,0,255)\nmy_1d_plot.x_ticks_values_precision() 1\nmy_1d_plot.x_ticks_values_ioflags() 2020\n\n//] [demo_1d_tick_values_output]\n\n*/\n", "meta": {"hexsha": "e922fdbaba62b37594725a860410ad3bd31bb564", "size": 6548, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_1d_tick_values.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_1d_tick_values.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_1d_tick_values.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 36.9943502825, "max_line_length": 106, "alphanum_fraction": 0.7176237019, "num_tokens": 1861, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3174262785020255, "lm_q2_score": 0.22000709974589316, "lm_q1q2_score": 0.06983603491636278}}
{"text": "//////////////////////////////////////////////////////////////////////////////\n///   Copyright 2003 and onward LASMEA UMR 6602 CNRS/U.B.P Clermont-Ferrand\n///   Copyright 2009 and onward LRI    UMR 8623 CNRS/Univ Paris Sud XI\n///\n///          Distributed under the Boost Software License, Version 1.0\n///                 See accompanying file LICENSE.txt or copy at\n///                     http://www.boost.org/LICENSE_1_0.txt\n//////////////////////////////////////////////////////////////////////////////\n#define NT2_UNIT_MODULE \"nt2 bitwise toolbox - lo/scalar Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// Test behavior of bitwise components in scalar mode\n//////////////////////////////////////////////////////////////////////////////\n/// created  by jt the 18/02/2011\n/// modified by jt the 16/03/2011\n#include <boost/type_traits/is_same.hpp>\n#include <nt2/sdk/functor/meta/call.hpp>\n#include <nt2/sdk/unit/tests.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/memory/buffer.hpp>\n#include <nt2/sdk/constant/real.hpp>\n#include <nt2/sdk/constant/infinites.hpp>\n#include <nt2/include/functions/ulpdist.hpp>\n#include <nt2/toolbox/bitwise/include/lo.hpp>\n// specific includes for arity 1 tests\n#include<nt2/sdk/meta/downgrade.hpp>\n\nNT2_TEST_CASE_TPL ( lo_real__1,  NT2_REAL_TYPES)\n{\n  \n  using nt2::lo;\n  using nt2::tag::lo_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<lo_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(lo(nt2::Nan<T>()), nt2::Mone<r_t>());\n  NT2_TEST_EQUAL(lo(nt2::One<T>()), nt2::Zero<r_t>());\n  NT2_TEST_EQUAL(lo(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for real_\n\nNT2_TEST_CASE_TPL ( lo_int64__1,  (int64_t)(uint64_t))\n{\n  \n  using nt2::lo;\n  using nt2::tag::lo_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<lo_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(lo(nt2::One<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(lo(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for int64_\n\nNT2_TEST_CASE_TPL ( lo_int32__1,  (int32_t)(uint32_t))\n{\n  \n  using nt2::lo;\n  using nt2::tag::lo_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<lo_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(lo(nt2::One<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(lo(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for int32_\n\nNT2_TEST_CASE_TPL ( lo_int16__1,  (int16_t)(uint16_t))\n{\n  \n  using nt2::lo;\n  using nt2::tag::lo_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<lo_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(lo(nt2::One<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(lo(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for int16_\n", "meta": {"hexsha": "405bebd6a9ce11d73a888a210e8626715203a6cf", "size": 4157, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/bitwise/unit/scalar/lo.cpp", "max_stars_repo_name": "brycelelbach/nt2", "max_stars_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-03-24T03:35:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T03:35:10.000Z", "max_issues_repo_path": "modules/bitwise/unit/scalar/lo.cpp", "max_issues_repo_name": "brycelelbach/nt2", "max_issues_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/bitwise/unit/scalar/lo.cpp", "max_forks_repo_name": "brycelelbach/nt2", "max_forks_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5241935484, "max_line_length": 78, "alphanum_fraction": 0.629540534, "num_tokens": 1214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4843800693903656, "lm_q2_score": 0.14414885119438492, "lm_q1q2_score": 0.06982283054407765}}
{"text": "//  Copyright (c) 2019 Rustam Abdumalikov\r\n//\r\n//  \"eswitch_v4\" library\r\n//\r\n// Distributed under the Boost Software License, Version 1.0. (See\r\n// accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n#include \"qs.cpp\"\r\n#include \"qs_pivot.cpp\"\r\n#include <iostream>\r\n#include <vector>\r\n#include <boost/range/adaptor/indexed.hpp>\r\n#include <chrono>\r\n\r\n#include <random>\r\n\r\n#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file\r\n#include \"catch2/catch.hpp\"\r\n\r\nstd::vector<int64_t> getRandomList( int64_t n )\r\n{\r\n    std::random_device rd; // obtain a random number from hardware\r\n    std::mt19937 gen(rd()); // seed the generator\r\n    std::uniform_int_distribution<> distr(0, n*n); // define the range\r\n\r\n    std::vector<int64_t> output;\r\n    output.reserve( n );\r\n\r\n    for(int64_t i=0; i<n; ++i)\r\n        output.push_back( distr(gen) );\r\n\r\n    return output;\r\n}\r\n\r\nvoid printList( const std::vector< int64_t > & pivots ) {\r\n    for( auto p : pivots )\r\n        std::cout << p << \", \";\r\n    std::cout << std::endl;\r\n}\r\n\r\nTEST_CASE( \"sort_pivots2\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"sort_pivots\" ) {\r\n        vector<int64_t> values { 4, 1, 2, 0, 1 };\r\n        vector<int64_t> pivots { 4, 2, 0, 3 };\r\n        sort_pivots2( values, 0, values.size(), pivots );\r\n\r\n        REQUIRE( values == vector<int64_t>{ 0, 1, 1, 2, 4 } );\r\n        REQUIRE( pivots == vector<int64_t>{ 0, 2, 3, 4 } );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_1\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"sort_pivots\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 5, 7, 6 };\r\n        vector< int64_t > pivots = {6};\r\n        const auto results = sort_pivots( values, 0, values.size(), std::move(pivots) );\r\n\r\n        REQUIRE( values == vector<int64_t>{ 6, 2, 3, 4, 5, 7, 1  } );\r\n        REQUIRE( results == vector<int64_t>{ 0 } );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_2\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {5,6};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 1, 2, 3, 4, 5, 7, 6 };\r\n            \r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 0, values.size(), std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 6, 7, 3, 4, 5, 1, 2} );\r\n            REQUIRE( results == vector<int64_t>{ 0, 1 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_3\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {0, 3, 6};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 4, 2, 3, 6, 5, 7, 1 };\r\n\r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 0, values.size(), std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 1, 4, 6, 2, 5, 7, 3 } );\r\n            REQUIRE( results == vector<int64_t>{ 0, 1, 2 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_4\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {0, 1, 2, 3};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 4, 2, 3, 6, 5, 7, 1 };\r\n\r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 0, values.size(), std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 2, 3, 4, 6, 5, 7, 1 } );\r\n            REQUIRE( results == vector<int64_t>{ 0, 1, 2, 3 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_5\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {2, 3, 4, 5, 6};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 4, 2, 3, 6, 5, 7, 1 };\r\n\r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 0, values.size(), std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 1, 3, 5, 6, 7, 2, 4 } );\r\n            REQUIRE( results == vector<int64_t>{ 0, 1, 2, 3, 4 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_narrow_range_middle\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {1, 2, 3};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 4, 6, 2, 3, 5, 7, 1 };\r\n\r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 0, 4, std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 2, 3, 6, 4, 5, 7, 1 } );\r\n            REQUIRE( results == vector<int64_t>{ 0, 1, 2 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_narrow_range_begin\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {1, 2, 3};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 4, 6, 2, 3, 5, 7, 1 };\r\n\r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 0, 3, std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 2, 3, 6, 4, 5, 7, 1 } );\r\n            REQUIRE( results == vector<int64_t>{ 0, 1, 2 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"sort_pivots_narrow_range_end\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"all_permutations\" ) {\r\n        vector< int64_t > pivots = {4, 5, 6};\r\n        do {\r\n            //printList( pivots );\r\n            \r\n            vector< int64_t > values = { 4, 6, 2, 3, 5, 7, 1 };\r\n\r\n            auto ps = pivots;\r\n            const auto results = sort_pivots( values, 3, 6, std::move(ps) );\r\n\r\n            REQUIRE( values == vector<int64_t>{ 4, 6, 2, 1, 5, 7, 3 } );\r\n            REQUIRE( results == vector<int64_t>{ 3, 4, 5 } );\r\n        } while( std::next_permutation(std::begin(pivots), std::end(pivots)) );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"get_pivots_narrow_pivot_numbers\", \"1-10\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"full size\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\r\n\r\n        const auto results = get_pivot( values, 0, values.size()-1, values.size() );\r\n\r\n        REQUIRE( results.size() == (values.size()-1)/ 2 );\r\n        REQUIRE( results[0] >= 0 );        \r\n        REQUIRE( results[0] <= 4 );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"get_pivots_1\", \"1-10\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"0-9\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\r\n\r\n        const auto results = get_pivot( values, 0, values.size()-1, 1 );\r\n\r\n        REQUIRE( results.size() == 1 );\r\n        REQUIRE( results[0] >= 0 );        \r\n        REQUIRE( results[0] <= 9 );\r\n    }\r\n\r\n    SECTION( \"0-4\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\r\n\r\n        const auto results = get_pivot( values, 0, 4, 1 );\r\n\r\n        REQUIRE( results.size() == 1 );\r\n        REQUIRE( results[0] >= 0 );        \r\n        REQUIRE( results[0] <= 4 );\r\n    }\r\n\r\n    SECTION( \"5-9\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\r\n\r\n        const auto results = get_pivot( values, 0, 4, 1 );\r\n\r\n        REQUIRE( results.size() == 1 );\r\n        REQUIRE( results[0] >= 0 );        \r\n        REQUIRE( results[0] <= 4 );\r\n    }\r\n}\r\n\r\nTEST_CASE( \"general_partition\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"1_pivot\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 6, 7, 8, 9, 10 };\r\n\r\n        do {\r\n            vector< int64_t > new_values;\r\n            new_values.push_back( 5 );\r\n\r\n            for( auto v : values ) new_values.push_back( v );\r\n\r\n            vector< int64_t > pivots = { 0 };\r\n            \r\n            const auto results = general_partition( new_values, 0, new_values.size()-1, pivots );\r\n            \r\n            REQUIRE( new_values[results[0]] == 5 );\r\n\r\n            for( int i = 0; i < new_values.size(); ++i )\r\n            {\r\n                if( i == results[0] ) continue;\r\n                if( i < results[0] )\r\n                    REQUIRE( new_values[i] <= new_values[results[0]] );\r\n                else if( i > results[0] )\r\n                    REQUIRE( new_values[i] > new_values[results[0]] );\r\n            }\r\n\r\n        } while( std::next_permutation(std::begin(values), std::end(values)) );\r\n\r\n    }\r\n}\r\n\r\nTEST_CASE( \"general_partition2\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"2_pivot\" ) {\r\n        vector< int64_t > values = { 1, 2, 3, 4, 9, 10, 11 };\r\n\r\n        do {\r\n            vector< int64_t > new_values;\r\n            new_values.push_back( 5 );\r\n            new_values.push_back( 8 );\r\n\r\n            for( auto v : values ) new_values.push_back( v );\r\n\r\n            vector< int64_t > pivots = { 0, 1 };\r\n            \r\n            const auto results = general_partition( new_values, 0, new_values.size()-1, pivots );\r\n            \r\n            REQUIRE( new_values[results[0]] == 5 );\r\n            REQUIRE( new_values[results[1]] == 8 );\r\n\r\n            for( int i = 0; i < new_values.size(); ++i )\r\n            {\r\n                if( i == results[0] || i == results[1] ) continue;\r\n                \r\n                if( i < results[0] )\r\n                    REQUIRE( new_values[i] <= new_values[results[0]] );\r\n                else if( i > results[0] && i < results[1] )\r\n                {\r\n                    REQUIRE( new_values[i] > new_values[results[0]] );\r\n                    REQUIRE( new_values[i] <= new_values[results[1]] );\r\n                }\r\n                else if( i > results[0] && i > results[1] )\r\n                {\r\n                    REQUIRE( new_values[i] > new_values[results[1]] );\r\n                }\r\n            }\r\n\r\n        } while( std::next_permutation(std::begin(values), std::end(values)) );\r\n\r\n    }\r\n}\r\n\r\nTEST_CASE( \"auxiliary_functions\", \"\" ) \r\n{\r\n    SECTION( \"less_or_equal_1\" ) {\r\n        std::vector< int64_t > values = { 1, 2, 3, 4, 9, 10, 11 };\r\n        std::vector< int64_t > pivots = { 0, 1, 2, 3, 4, 5, 6 };\r\n        int64_t val;\r\n        std::vector< bool > correctResults = { 1, 1, 1, 1, 1, 1, 1, 1 };\r\n        \r\n        int i =0;\r\n        for(auto v: values){\r\n            val=v;\r\n            auto results=less_or_equal(values,pivots,val);\r\n            REQUIRE(results==correctResults);\r\n            correctResults[i]=0;\r\n            i++;\r\n        }\r\n        \r\n    }\r\n    SECTION( \"greater_1\" ) {\r\n        std::vector< int64_t > values = { 1, 2, 3, 4, 9, 10, 11 };\r\n        std::vector< int64_t > pivots = { 0, 1, 2, 3, 4, 5, 6 };\r\n        int64_t val;\r\n        std::vector< bool > correctResults = { 1, 0, 0, 0, 0, 0, 0, 0 };\r\n        \r\n        int i =0;\r\n        for(auto v: values){\r\n            val=v;\r\n            auto results=greater(values,pivots,val);\r\n            REQUIRE(results==correctResults);\r\n            i++;\r\n            correctResults[i]=1;\r\n        }\r\n        \r\n    }\r\n}\r\n\r\nTEST_CASE( \"quicksort\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"100_entries\" ) {\r\n        for( int64_t np = 1; np <= 90; ++np ) {\r\n            std::vector< int64_t > v = getRandomList( 100 );            \r\n            quicksort( v, np );\r\n\r\n            REQUIRE( std::is_sorted( std::begin( v ), std::end( v ) ) );\r\n        }\r\n    }\r\n\r\n    SECTION( \"1000_entries\" ) {\r\n        for( int64_t np = 1; np <= 900; ++np ) {\r\n            std::vector< int64_t > v = getRandomList( 1000 );            \r\n            quicksort( v, np );\r\n\r\n            REQUIRE( std::is_sorted( std::begin( v ), std::end( v ) ) );\r\n        }\r\n    }\r\n\r\n    SECTION( \"10000_entries\" ) {\r\n        for( int64_t np = 1; np <= 50; ++np ) {\r\n            std::vector< int64_t > v = getRandomList( 10000 );            \r\n            quicksort( v, np );\r\n\r\n            REQUIRE( std::is_sorted( std::begin( v ), std::end( v ) ) );\r\n        }\r\n    }\r\n}\r\n\r\n\r\nTEST_CASE( \"qs::range\", \"\" ) \r\n{\r\n    using namespace std;\r\n\r\n    SECTION( \"inside_range\" ) {\r\n    for( auto num_of_entries : { 100000} ) {\r\n        for( int64_t np = 1; np <= 30; ++np ) {\r\n            double total_duration = 0.0;\r\n            int64_t num_durations = 0;\r\n            \r\n            for( int64_t i = 1; i < 90; ++i ) {\r\n                std::vector< int64_t > v = getRandomList( num_of_entries );\r\n\r\n                std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();\r\n\r\n                quicksort( v, np );\r\n                \r\n                // std::qsort(\r\n                //     v.data(),\r\n                //     v.size(),\r\n                //     sizeof(int64_t),\r\n                //     [](const void* x, const void* y) {\r\n                //         return ( *(int64_t*)x - *(int64_t*)y );\r\n                //     });\r\n                \r\n                std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();\r\n\r\n                if( !std::is_sorted( std::begin( v ), std::end( v ) ) )\r\n                {\r\n                    std::cout << \"Failed to sort!!!\" << std::endl;\r\n                    break;\r\n                }\r\n                \r\n                total_duration +=  std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();\r\n                \r\n                ++num_durations;\r\n                \r\n            }\r\n\r\n            std::cout << \"[\" << np << \"]\" << \"[\" << num_of_entries << \"] Time difference = \" << total_duration/num_durations << \"[ms]\" << std::endl;\r\n        }\r\n\r\n        REQUIRE( true );\r\n    }\r\n    }\r\n}\r\n\r\ntemplate< int Index >\r\nvoid ct_quicksort() \r\n{\r\n    double total_duration = 0.0;\r\n    int64_t num_durations = 0;\r\n    \r\n    for( int64_t i = 1; i < 30; ++i ) {\r\n        std::vector< int64_t > v = getRandomList( 100000 );\r\n\r\n        std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();\r\n\r\n        tmpl::quicksort<Index>( v );\r\n        \r\n        std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();\r\n\r\n        if( !std::is_sorted( std::begin( v ), std::end( v ) ) )\r\n        {\r\n            std::cout << \"Failed to sort!!!\" << std::endl;\r\n            break;\r\n        }\r\n        \r\n        total_duration +=  std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();\r\n        \r\n        ++num_durations;\r\n    }\r\n\r\n    std::cout << \"[\" << Index << \"] Time difference = \" << total_duration/num_durations << \"[ms]\" << std::endl;\r\n}\r\n\r\ntemplate< int End, int Index >\r\nvoid for_loop()\r\n{\r\n    if constexpr( End < Index ) {\r\n        ct_quicksort<Index>();\r\n        for_loop< End,Index+1 >();\r\n    }\r\n}\r\n\r\n// TEST_CASE( \"qs::range2\", \"\" ) \r\n// {\r\n//     using namespace std;\r\n\r\n//     SECTION( \"inside_range\" ) {\r\n//         for_loop< 5, 1 >();\r\n\r\n//         REQUIRE( true );\r\n//     }\r\n// }\r\n\r\n\r\n// bool test_partitioning()\r\n// {\r\n//     for( int64_t i = 0; i < 100; ++i )\r\n//     {\r\n//         std::vector< int64_t > v = getRandomList( 50 );\r\n\r\n//         auto l = get_pivot( v, 0, v.size() - 1, 4 );\r\n        \r\n//         general_partition( v, 0, v.size() - 1,  l );\r\n\r\n//         for( auto pivot : l )\r\n//         {\r\n//             for( int64_t j = 0; j <= pivot; ++j )\r\n//             {\r\n//                 if( v[pivot] < v[j] ) { printf( \"Error\" ); return false; }\r\n//             }\r\n//         }\r\n\r\n//         auto lastIdx = *(l.rbegin());\r\n\r\n//         for( auto k = lastIdx+1; k < v.size(); ++k )\r\n//         {\r\n//             if( !(v[k] > v[lastIdx]) ) { printf( \"Error\" ); return false; }\r\n//         }\r\n//     }\r\n\r\n//     return true;\r\n// }\r\n", "meta": {"hexsha": "42acfcb130a4e8846503cafbdc33a84e5351d028", "size": 15907, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/qs_tests.cpp", "max_stars_repo_name": "rabdumalikov/multipivot_quicksort", "max_stars_repo_head_hexsha": "9bf97fa7e3b8ef78c2a835bb9b58de28cfa82643", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/qs_tests.cpp", "max_issues_repo_name": "rabdumalikov/multipivot_quicksort", "max_issues_repo_head_hexsha": "9bf97fa7e3b8ef78c2a835bb9b58de28cfa82643", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/qs_tests.cpp", "max_forks_repo_name": "rabdumalikov/multipivot_quicksort", "max_forks_repo_head_hexsha": "9bf97fa7e3b8ef78c2a835bb9b58de28cfa82643", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0132075472, "max_line_length": 149, "alphanum_fraction": 0.467341422, "num_tokens": 4682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48047867804790706, "lm_q2_score": 0.14414885119438492, "lm_q1q2_score": 0.06926044946400253}}
{"text": "/*\n * GraphBLAS Template Library (GBTL), Version 3.0\n *\n * Copyright 2020 Carnegie Mellon University, Battelle Memorial Institute, and\n * Authors.\n *\n * THIS MATERIAL WAS PREPARED AS AN ACCOUNT OF WORK SPONSORED BY AN AGENCY OF\n * THE UNITED STATES GOVERNMENT.  NEITHER THE UNITED STATES GOVERNMENT NOR THE\n * UNITED STATES DEPARTMENT OF ENERGY, NOR THE UNITED STATES DEPARTMENT OF\n * DEFENSE, NOR CARNEGIE MELLON UNIVERSITY, NOR BATTELLE, NOR ANY OF THEIR\n * EMPLOYEES, NOR ANY JURISDICTION OR ORGANIZATION THAT HAS COOPERATED IN THE\n * DEVELOPMENT OF THESE MATERIALS, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR\n * ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS,\n * OR USEFULNESS OR ANY INFORMATION, APPARATUS, PRODUCT, SOFTWARE, OR PROCESS\n * DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED\n * RIGHTS.\n *\n * Released under a BSD-style license, please see LICENSE file or contact\n * permission@sei.cmu.edu for full terms.\n *\n * [DISTRIBUTION STATEMENT A] This material has been approved for public release\n * and unlimited distribution.  Please see Copyright notice for non-US\n * Government use and distribution.\n *\n * This Software includes and/or makes use of the following Third-Party Software\n * subject to its own license:\n *\n * 1. Boost Unit Test Framework\n * (https://www.boost.org/doc/libs/1_45_0/libs/test/doc/html/utf.html)\n * Copyright 2001 Boost software license, Gennadiy Rozental.\n *\n * DM20-0442\n */\n\n#define GRAPHBLAS_LOGGING_LEVEL 0\n\n#include <graphblas/graphblas.hpp>\n\nusing namespace grb;\n\n#define BOOST_TEST_MAIN\n#define BOOST_TEST_MODULE extract_stdmat_test_suite\n\n#include <boost/test/included/unit_test.hpp>\n\nBOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)\n\n//****************************************************************************\n// extract standard matrix error tests\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_bad_dimensions)\n{\n    IndexArrayType i      = {0, 0, 0, 1, 1, 1, 2, 2};\n    IndexArrayType j      = {1, 2, 3, 0, 2, 3, 0, 1};\n    std::vector<double> v = {1, 2, 3, 4, 6, 7, 8, 9};\n    Matrix<double, DirectedMatrixTag> A(3, 4);\n    A.build(i, j, v);\n\n    Matrix<double, DirectedMatrixTag> C(2, 3);\n\n\n    // Standard matrix version:\n    // 1. nrows(C) != nrows(M)\n    {\n        // Too many mask rows\n        std::vector<std::vector<bool>> matMask = {{true, false, true},\n                                                  {true, true,  false},\n                                                  {false, true, true}};\n        Matrix<bool, DirectedMatrixTag> M(matMask, false);\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, M, NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n    {\n        // Too few mask rows\n        std::vector<std::vector<bool>> matMask = {{false, true, true}};\n        Matrix<bool, DirectedMatrixTag> M(matMask, false);\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, M, NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n    // 2. ncols(C) != ncols(M)\n    {\n        // Too many mask cols\n        std::vector<std::vector<bool>> matMask = {{false, true, false, true},\n                                                  {true, true, false, false}};\n        Matrix<bool, DirectedMatrixTag> M(matMask, false);\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, M, NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n    {\n        // Too few mask cols\n        std::vector<std::vector<bool>> matMask = {{false, true},\n                                                  {true, true}};\n        Matrix<bool, DirectedMatrixTag> M(matMask, false);\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, M, NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n\n    // 3. nrows(C) != |I|\n    {\n        IndexArrayType vect_I({0, 2, 1}); // too many rows for C\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, NoMask(), NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n    {\n        IndexArrayType vect_I({0}); // too few rows for C\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, NoMask(), NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n    // 4. ncols(C) != |J|\n    {\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 2, 1, 2}); // too many cols for C\n        BOOST_CHECK_THROW(\n            extract(C, NoMask(), NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n\n    {\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 1}); // too many cols for C\n        BOOST_CHECK_THROW(\n            extract(C, NoMask(), NoAccumulate(), A, vect_I, vect_J),\n            DimensionException);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_index_out_of_bounds)\n{\n    IndexArrayType i    = {0, 0, 0, 1, 1, 1, 2, 2};\n    IndexArrayType j    = {1, 2, 3, 0, 2, 3, 0, 1};\n    std::vector<double> v = {1, 2, 3, 4, 6, 7, 8, 9};\n    Matrix<double, DirectedMatrixTag> A(3, 4);\n    A.build(i, j, v);\n\n    Matrix<double, DirectedMatrixTag> C(2, 3);\n\n\n    // Standard matrix version:\n    // J index out of range\n    {\n        std::vector<std::vector<bool>> matMask = {{true, false, true},\n                                                  {true, true,  false}};\n        Matrix<bool, DirectedMatrixTag> M(matMask, false);\n        IndexArrayType vect_I({0, 2});\n        IndexArrayType vect_J({0, 4, 2});\n        BOOST_CHECK_THROW(\n            extract(C, M, NoAccumulate(), A, vect_I, vect_J),\n            IndexOutOfBoundsException);\n\n        BOOST_CHECK_THROW(\n            extract(C, NoMask(), NoAccumulate(), A, vect_I, vect_J),\n            IndexOutOfBoundsException);\n    }\n\n    // I index out of range\n    {\n        std::vector<std::vector<bool>> matMask = {{true, false, true},\n                                                  {true, true,  false}};\n        Matrix<bool, DirectedMatrixTag> M(matMask, false);\n        IndexArrayType vect_I({3, 2});\n        IndexArrayType vect_J({0, 1, 2});\n        BOOST_CHECK_THROW(\n            extract(C, M, NoAccumulate(), A, vect_I, vect_J),\n            IndexOutOfBoundsException);\n        BOOST_CHECK_THROW(\n            extract(C, NoMask(), NoAccumulate(), A, vect_I, vect_J),\n            IndexOutOfBoundsException);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_allindices_too_small)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double, DirectedMatrixTag> mA(matA, 0);\n\n    // result is too small when I = AllIndices will pass\n    {\n        std::vector<std::vector<double>> matAnswer = {{8, 1, 6},\n                                                      {0, 5, 7}};\n        Matrix<double> answer(matAnswer, 0);\n        Matrix<double> result(2, 3);\n\n        extract(result, NoMask(), NoAccumulate(),\n                mA, AllIndices(), AllIndices());\n\n        BOOST_CHECK_EQUAL(result, answer);\n    }\n\n    // result is too big when I = AllIndices will pass\n    {\n        std::vector<std::vector<double>> matAnswer = {{8, 1, 6, 0, 0, 0},\n                                                      {0, 5, 7, 9, 0, 0},\n                                                      {4, 0, 2, 0, 0, 0},\n                                                      {0, 0, 0, 0, 0, 0}};\n        Matrix<double> answer(matAnswer, 0);\n        Matrix<double> result(4, 6);\n\n        extract(result, NoMask(), NoAccumulate(),\n                mA, AllIndices(), AllIndices());\n\n        BOOST_CHECK_EQUAL(result, answer);\n    }\n}\n\n//****************************************************************************\n// Standard matrix passing test cases:\n//\n// Simplified test structure (12 test cases total):\n//\n// Mask cases (x3):  nomask,  noscmp, scmp\n// Accum cases (x2): noaccum, accum\n// Trans cases (x2): notrans, trans\n//\n// Within each test case: 5 checks will be run:\n//\n// row_ind: AllIndices, nodup/ordered, nodup/permute, dup/ordered, dup/permute\n// col_ind: AllIndices, nodup/ordered, nodup/permute, dup/ordered, dup/permute\n//****************************************************************************\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_nomask_noaccum_notrans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(3, 4);\n        extract(C, NoMask(), NoAccumulate(), A, AllIndices(), AllIndices());\n\n        Matrix<double> answer(A);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(2,3);\n        extract(C, NoMask(), NoAccumulate(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 0},\n                                                  {4, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(2,3);\n        extract(C, NoMask(), NoAccumulate(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0},\n                                                  {0, 8, 1}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(3,4);\n        extract(C, NoMask(), NoAccumulate(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 1, 0},\n                                                  {8, 1, 1, 0},\n                                                  {4, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(3,4);\n        extract(C, NoMask(), NoAccumulate(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0, 4},\n                                                  {0, 8, 1, 8},\n                                                  {0, 4, 0, 4}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_nomask_noaccum_trans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(4,3);\n        extract(C, NoMask(), NoAccumulate(), transpose(A),\n                AllIndices(), AllIndices());\n\n        std::vector<std::vector<double>> ansMat = {{8, 0, 4},\n                                                   {1, 5, 0},\n                                                   {6, 7, 2},\n                                                   {0, 9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(3,2);\n        extract(C, NoMask(), NoAccumulate(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{8, 4},\n                                                  {1, 0},\n                                                  {0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(3,2);\n        extract(C, NoMask(), NoAccumulate(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0},\n                                                  {4, 8},\n                                                  {0, 1}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(4,3);\n        extract(C, NoMask(), NoAccumulate(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{8, 8, 4},\n                                                  {1, 1, 0},\n                                                  {1, 1, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(4,3);\n        extract(C, NoMask(), NoAccumulate(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0, 0},\n                                                  {4, 8, 4},\n                                                  {0, 1, 0},\n                                                  {4, 8, 4}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_nomask_accum_notrans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    std::vector<std::vector<double>> matC3x4 = {{9, 9, 9, 9},\n                                                {9, 9, 9, 9},\n                                                {9, 9, 9, 0}};\n    std::vector<std::vector<double>> matC2x3 = {{9, 9, 9},\n                                                {9, 9, 0}};\n    Matrix<double> A(matA, 0);\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, NoMask(), Plus<double>(), A, AllIndices(), AllIndices());\n\n        std::vector<std::vector<double>> ansMat = {{17, 10, 15,  9},\n                                                   { 9, 14, 16, 18},\n                                                   {13,  9, 11,  0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, NoMask(), Plus<double>(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 9},\n                                                  {13,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, NoMask(), Plus<double>(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{9, 13,  9},\n                                                  {9, 17,  1}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, NoMask(), Plus<double>(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 10, 9},\n                                                  {17, 10, 10, 9},\n                                                  {13,  9,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, NoMask(), Plus<double>(), A, arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{9, 13,  9, 13},\n                                                  {9, 17, 10, 17},\n                                                  {9, 13,  9, 4}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_nomask_accum_trans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    std::vector<std::vector<double>> matC4x3 = {{9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 0}};\n    std::vector<std::vector<double>> matC3x2 = {{9, 9},\n                                                {9, 9},\n                                                {9, 0}};\n    Matrix<double> A(matA, 0);\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, NoMask(), Plus<double>(), transpose(A),\n                AllIndices(), AllIndices());\n\n        std::vector<std::vector<double>> ansMat = {{17,  9, 13},\n                                                   {10, 14,  9},\n                                                   {15, 16, 11},\n                                                   { 9, 18,  0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, NoMask(), Plus<double>(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{17, 13},\n                                                  {10,  9},\n                                                  { 9,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, NoMask(), Plus<double>(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{ 9,  9},\n                                                  {13, 17},\n                                                  { 9, 1}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, NoMask(), Plus<double>(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{17, 17, 13},\n                                                  {10, 10,  9},\n                                                  {10, 10,  9},\n                                                  { 9,  9,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, NoMask(), Plus<double>(), transpose(A), arrayI, arrayJ);\n\n        std::vector<std::vector<double>> ansMat ={{ 9,  9,  9},\n                                                  {13, 17, 13},\n                                                  { 9, 10,  9},\n                                                  {13, 17,  4}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_noscmp_noaccum_notrans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n\n    std::vector<std::vector<uint8_t>> matMask2x3 = {{1, 1, 0},    // stored 0\n                                                    {1,99, 0}};\n    std::vector<std::vector<uint8_t>> matMask3x4 = {{1, 1, 1, 0}, // stored 0\n                                                    {1, 1,99, 0},\n                                                    {1,99,99, 0}};\n    Matrix<uint8_t> mask2x3(matMask2x3, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask3x4(matMask3x4, 99);\n\n    std::vector<std::vector<double>> matC3x4 = {{9, 9, 9, 9},\n                                                {9, 9, 9, 9},\n                                                {9, 9, 9, 0}};\n    std::vector<std::vector<double>> matC2x3 = {{9, 9, 9},\n                                                {9, 9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, NoAccumulate(), A, AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 1, 6, 0},\n                                                   {0, 5, 0, 0},\n                                                   {4, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, NoAccumulate(), A, AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 1, 6, 9},\n                                                   {0, 5, 9, 9},\n                                                   {4, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 0},\n                                                  {4, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 9},\n                                                  {4, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 9},\n                                                  {0, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 1, 0},\n                                                  {8, 1, 0, 0},\n                                                  {4, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 1, 9},\n                                                  {8, 1, 9, 9},\n                                                  {4, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0, 0},\n                                                  {0, 8, 0, 0},\n                                                  {0, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0, 9},\n                                                  {0, 8, 9, 9},\n                                                  {0, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_noscmp_noaccum_trans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n    std::vector<std::vector<uint8_t>> matMask3x2 = {{1, 1},    // stored 0\n                                                    {1,99},    // stored 0\n                                                    {0, 0}};\n    std::vector<std::vector<uint8_t>> matMask4x3 = {{1, 1, 1}, // stored 0\n                                                    {1, 1,99}, // stored 0\n                                                    {1,99,99},\n                                                    {0, 0, 0}};\n    Matrix<uint8_t> mask3x2(matMask3x2, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask4x3(matMask4x3, 99);\n\n    std::vector<std::vector<double>> matC4x3 = {{9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 0}};\n    std::vector<std::vector<double>> matC3x2 = {{9, 9},\n                                                {9, 9},\n                                                {9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, NoAccumulate(), transpose(A),\n                AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 0, 4},\n                                                   {1, 5, 0},\n                                                   {6, 0, 0},\n                                                   {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, NoAccumulate(), transpose(A),\n                AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 0, 4},\n                                                   {1, 5, 9},\n                                                   {6, 9, 9},\n                                                   {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 4},\n                                                  {1, 0},\n                                                  {0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 4},\n                                                  {1, 9},\n                                                  {9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0},\n                                                  {4, 0},\n                                                  {0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0},\n                                                  {4, 9},\n                                                  {9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 8, 4},\n                                                  {1, 1, 0},\n                                                  {1, 0, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 8, 4},\n                                                  {1, 1, 9},\n                                                  {1, 9, 9},\n                                                  {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0, 0},\n                                                  {4, 8, 0},\n                                                  {0, 0, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0, 0},\n                                                  {4, 8, 9},\n                                                  {0, 9, 9},\n                                                  {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_noscmp_accum_notrans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n\n    std::vector<std::vector<uint8_t>> matMask2x3 = {{1, 1, 0},    // stored 0\n                                                    {1,99, 0}};\n    std::vector<std::vector<uint8_t>> matMask3x4 = {{1, 1, 1, 0}, // stored 0\n                                                    {1, 1,99, 0},\n                                                    {1,99,99, 0}};\n    Matrix<uint8_t> mask2x3(matMask2x3, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask3x4(matMask3x4, 99);\n\n    std::vector<std::vector<double>> matC3x4 = {{9, 9, 9, 9},\n                                                {9, 9, 9, 9},\n                                                {9, 9, 9, 0}};\n    std::vector<std::vector<double>> matC2x3 = {{9, 9, 9},\n                                                {9, 9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, Plus<double>(), A, AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{17, 10, 15, 0},\n                                                   { 9, 14,  0, 0},\n                                                   {13,  0,  0, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, Plus<double>(), A, AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{17, 10, 15, 9},\n                                                   { 9, 14,  9, 9},\n                                                   {13,  9,  9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 0},\n                                                  {13,  0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 9},\n                                                  {13,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 0},\n                                                  {9, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, mask2x3, Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 9},\n                                                  {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 10, 0},\n                                                  {17, 10,  0, 0},\n                                                  {13,  0,  0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 10, 9},\n                                                  {17, 10,  9, 9},\n                                                  {13,  9,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 9, 0},\n                                                  {9,17, 0, 0},\n                                                  {9, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, mask3x4, Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 9, 9},\n                                                  {9,17, 9, 9},\n                                                  {9, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_noscmp_accum_trans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n    std::vector<std::vector<uint8_t>> matMask3x2 = {{1, 1},    // stored 0\n                                                    {1,99},    // stored 0\n                                                    {0, 0}};\n    std::vector<std::vector<uint8_t>> matMask4x3 = {{1, 1, 1}, // stored 0\n                                                    {1, 1,99}, // stored 0\n                                                    {1,99,99},\n                                                    {0, 0, 0}};\n    Matrix<uint8_t> mask3x2(matMask3x2, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask4x3(matMask4x3, 99);\n\n    std::vector<std::vector<double>> matC4x3 = {{9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 0}};\n    std::vector<std::vector<double>> matC3x2 = {{9, 9},\n                                                {9, 9},\n                                                {9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, Plus<double>(), transpose(A),\n                AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{17,  9, 13},\n                                                   {10, 14,  0},\n                                                   {15,  0,  0},\n                                                   { 0,  0,  0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, Plus<double>(), transpose(A),\n                AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{17,  9, 13},\n                                                   {10, 14,  9},\n                                                   {15,  9,  9},\n                                                   { 9,  9,  0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 13},\n                                                  {10,  0},\n                                                  { 0,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 13},\n                                                  {10,  9},\n                                                  { 9,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9, 9},\n                                                  {13, 0},\n                                                  { 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, mask3x2, Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9, 9},\n                                                  {13, 9},\n                                                  { 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 17, 13},\n                                                  {10, 10,  0},\n                                                  {10,  0,  0},\n                                                  { 0,  0,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 17, 13},\n                                                  {10, 10,  9},\n                                                  {10,  9,  9},\n                                                  { 9,  9,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9,  9, 9},\n                                                  {13, 17, 0},\n                                                  { 9,  0, 0},\n                                                  { 0,  0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, mask4x3, Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9,  9, 9},\n                                                  {13, 17, 9},\n                                                  { 9,  9, 9},\n                                                  { 9,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_scmp_noaccum_notrans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n\n    // complements of masks from the noscmp case\n    std::vector<std::vector<uint8_t>> matMask2x3 = {{0,99, 1},    // stored 0\n                                                    {0, 1, 1}};\n    std::vector<std::vector<uint8_t>> matMask3x4 = {{0,99,99, 1}, // stored 0\n                                                    {0,99, 1, 1},\n                                                    {0, 1, 1, 1}};\n    Matrix<uint8_t> mask2x3(matMask2x3, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask3x4(matMask3x4, 99);\n\n    std::vector<std::vector<double>> matC3x4 = {{9, 9, 9, 9},\n                                                {9, 9, 9, 9},\n                                                {9, 9, 9, 0}};\n    std::vector<std::vector<double>> matC2x3 = {{9, 9, 9},\n                                                {9, 9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), NoAccumulate(), A, AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 1, 6, 0},\n                                                   {0, 5, 0, 0},\n                                                   {4, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), NoAccumulate(), A, AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 1, 6, 9},\n                                                   {0, 5, 9, 9},\n                                                   {4, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 0},\n                                                  {4, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 9},\n                                                  {4, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 9},\n                                                  {0, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 1, 0},\n                                                  {8, 1, 0, 0},\n                                                  {4, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 1, 1, 9},\n                                                  {8, 1, 9, 9},\n                                                  {4, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), NoAccumulate(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0, 0},\n                                                  {0, 8, 0, 0},\n                                                  {0, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), NoAccumulate(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 4, 0, 9},\n                                                  {0, 8, 9, 9},\n                                                  {0, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_scmp_noaccum_trans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n    std::vector<std::vector<uint8_t>> matMask3x2 = {{ 0, 0},    // stored 0\n                                                    {99, 1},    // stored 0\n                                                    { 1, 1}};\n    std::vector<std::vector<uint8_t>> matMask4x3 = {{ 0, 0, 0}, // stored 0\n                                                    {99,99, 1}, // stored 0\n                                                    {99, 1, 1},\n                                                    { 1, 1, 1}};\n    Matrix<uint8_t> mask3x2(matMask3x2, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask4x3(matMask4x3, 99);\n\n    std::vector<std::vector<double>> matC4x3 = {{9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 0}};\n    std::vector<std::vector<double>> matC3x2 = {{9, 9},\n                                                {9, 9},\n                                                {9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), NoAccumulate(), transpose(A),\n                AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 0, 4},\n                                                   {1, 5, 0},\n                                                   {6, 0, 0},\n                                                   {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), NoAccumulate(), transpose(A),\n                AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{8, 0, 4},\n                                                   {1, 5, 9},\n                                                   {6, 9, 9},\n                                                   {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 4},\n                                                  {1, 0},\n                                                  {0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 4},\n                                                  {1, 9},\n                                                  {9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0},\n                                                  {4, 0},\n                                                  {0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0},\n                                                  {4, 9},\n                                                  {9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 8, 4},\n                                                  {1, 1, 0},\n                                                  {1, 0, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{8, 8, 4},\n                                                  {1, 1, 9},\n                                                  {1, 9, 9},\n                                                  {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), NoAccumulate(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0, 0},\n                                                  {4, 8, 0},\n                                                  {0, 0, 0},\n                                                  {0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), NoAccumulate(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{0, 0, 0},\n                                                  {4, 8, 9},\n                                                  {0, 9, 9},\n                                                  {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_scmp_accum_notrans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n\n    std::vector<std::vector<uint8_t>> matMask2x3 = {{0,99, 1},    // stored 0\n                                                    {0, 1, 1}};\n    std::vector<std::vector<uint8_t>> matMask3x4 = {{0,99,99, 1}, // stored 0\n                                                    {0,99, 1, 1},\n                                                    {0, 1, 1, 1}};\n    Matrix<uint8_t> mask2x3(matMask2x3, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask3x4(matMask3x4, 99);\n\n    std::vector<std::vector<double>> matC3x4 = {{9, 9, 9, 9},\n                                                {9, 9, 9, 9},\n                                                {9, 9, 9, 0}};\n    std::vector<std::vector<double>> matC2x3 = {{9, 9, 9},\n                                                {9, 9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), Plus<double>(), A, AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{17, 10, 15, 0},\n                                                   { 9, 14,  0, 0},\n                                                   {13,  0,  0, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), Plus<double>(), A, AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{17, 10, 15, 9},\n                                                   { 9, 14,  9, 9},\n                                                   {13,  9,  9, 0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 0},\n                                                  {13,  0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,2});\n        IndexArrayType arrayJ({0,1,3});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 9},\n                                                  {13,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 0},\n                                                  {9, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0});\n        IndexArrayType arrayJ({3,0,1});\n\n        Matrix<double> C(matC2x3, 0);\n        extract(C, complement(mask2x3), Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 9},\n                                                  {9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 10, 0},\n                                                  {17, 10,  0, 0},\n                                                  {13,  0,  0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,0,2});\n        IndexArrayType arrayJ({0,1,1,3});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 10, 10, 9},\n                                                  {17, 10,  9, 9},\n                                                  {13,  9,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), Plus<double>(), A, arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 9, 0},\n                                                  {9,17, 0, 0},\n                                                  {9, 0, 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({2,0,2});\n        IndexArrayType arrayJ({3,0,1,0});\n\n        Matrix<double> C(matC3x4, 0);\n        extract(C, complement(mask3x4), Plus<double>(), A, arrayI, arrayJ, MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{9,13, 9, 9},\n                                                  {9,17, 9, 9},\n                                                  {9, 9, 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\n//****************************************************************************\nBOOST_AUTO_TEST_CASE(extract_stdmat_test_scmp_accum_trans)\n{\n    std::vector<std::vector<double>> matA = {{8, 1, 6, 0},\n                                             {0, 5, 7, 9},\n                                             {4, 0, 2, 0}};\n    Matrix<double> A(matA, 0);\n    std::vector<std::vector<uint8_t>> matMask3x2 = {{ 0, 0},    // stored 0\n                                                    {99, 1},    // stored 0\n                                                    { 1, 1}};\n    std::vector<std::vector<uint8_t>> matMask4x3 = {{ 0, 0, 0}, // stored 0\n                                                    {99,99, 1}, // stored 0\n                                                    {99, 1, 1},\n                                                    { 1, 1, 1}};\n    Matrix<uint8_t> mask3x2(matMask3x2, 99); // turn 99's into implicit 0's\n    Matrix<uint8_t> mask4x3(matMask4x3, 99);\n\n    std::vector<std::vector<double>> matC4x3 = {{9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 9},\n                                                {9, 9, 0}};\n    std::vector<std::vector<double>> matC3x2 = {{9, 9},\n                                                {9, 9},\n                                                {9, 0}};\n\n    // I,J - AllIndices\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), Plus<double>(), transpose(A),\n                AllIndices(), AllIndices(), REPLACE);\n\n        std::vector<std::vector<double>> ansMat = {{17,  9, 13},\n                                                   {10, 14,  0},\n                                                   {15,  0,  0},\n                                                   { 0,  0,  0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), Plus<double>(), transpose(A),\n                AllIndices(), AllIndices(), MERGE);\n\n        std::vector<std::vector<double>> ansMat = {{17,  9, 13},\n                                                   {10, 14,  9},\n                                                   {15,  9,  9},\n                                                   { 9,  9,  0}};\n        Matrix<double> answer(ansMat, 0);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, ordered\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 13},\n                                                  {10,  0},\n                                                  { 0,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,3});\n        IndexArrayType arrayJ({0,2});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 13},\n                                                  {10,  9},\n                                                  { 9,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - no dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9, 9},\n                                                  {13, 0},\n                                                  { 0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1});\n        IndexArrayType arrayJ({2,0});\n\n        Matrix<double> C(matC3x2, 0);\n        extract(C, complement(mask3x2), Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9, 9},\n                                                  {13, 9},\n                                                  { 9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, ordered\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 17, 13},\n                                                  {10, 10,  0},\n                                                  {10,  0,  0},\n                                                  { 0,  0,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({0,1,1,3});\n        IndexArrayType arrayJ({0,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{17, 17, 13},\n                                                  {10, 10,  9},\n                                                  {10,  9,  9},\n                                                  { 9,  9,  0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n\n    // I,J - dup, permuted\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), Plus<double>(), transpose(A), arrayI, arrayJ, REPLACE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9,  9, 9},\n                                                  {13, 17, 0},\n                                                  { 9,  0, 0},\n                                                  { 0,  0, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n    {\n        IndexArrayType arrayI({3,0,1,0});\n        IndexArrayType arrayJ({2,0,2});\n\n        Matrix<double> C(matC4x3, 0);\n        extract(C, complement(mask4x3), Plus<double>(), transpose(A), arrayI, arrayJ,MERGE);\n\n        std::vector<std::vector<double>> ansMat ={{ 9,  9, 9},\n                                                  {13, 17, 9},\n                                                  { 9,  9, 9},\n                                                  { 9,  9, 0}};\n        Matrix<double> answer(ansMat, 0.);\n        BOOST_CHECK_EQUAL(C, answer);\n    }\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "0eb46d965fd9dab52b91c74c1d4f18c0a8a37da8", "size": 70116, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/test/test_extract_stdmat.cpp", "max_stars_repo_name": "KIwabuchi/gbtl", "max_stars_repo_head_hexsha": "62c6b1e3262f3623359e793edb5ec4fa7bb471f0", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 112.0, "max_stars_repo_stars_event_min_datetime": "2016-04-26T05:54:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T05:56:16.000Z", "max_issues_repo_path": "src/test/test_extract_stdmat.cpp", "max_issues_repo_name": "KIwabuchi/gbtl", "max_issues_repo_head_hexsha": "62c6b1e3262f3623359e793edb5ec4fa7bb471f0", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 21.0, "max_issues_repo_issues_event_min_datetime": "2016-03-22T19:06:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T15:40:18.000Z", "max_forks_repo_path": "src/test/test_extract_stdmat.cpp", "max_forks_repo_name": "KIwabuchi/gbtl", "max_forks_repo_head_hexsha": "62c6b1e3262f3623359e793edb5ec4fa7bb471f0", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 22.0, "max_forks_repo_forks_event_min_datetime": "2016-04-26T05:54:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-21T03:33:20.000Z", "avg_line_length": 37.5152487961, "max_line_length": 96, "alphanum_fraction": 0.4208739803, "num_tokens": 18224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4687906266262437, "lm_q2_score": 0.1460872451894389, "lm_q1q2_score": 0.06848433121445878}}
{"text": "//  (C) Copyright Gennadiy Rozental 2015.\r\n//  Distributed under the Boost Software License, Version 1.0.\r\n//  (See accompanying file LICENSE_1_0.txt or copy at\r\n//  http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n//  See http://www.boost.org/libs/test for the library home page.\r\n//\r\n/// @file\r\n/// @brief tests collection comparison implementation\r\n// ***************************************************************************\r\n\r\n// Boost.Test\r\n#define BOOST_TEST_MODULE Test collection`s comparisons\r\n#include <boost/test/unit_test.hpp>\r\nnamespace tt = boost::test_tools;\r\nnamespace ut = boost::unit_test;\r\n\r\nBOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(std::vector<int>)\r\n\r\n#define VALIDATE_OP( op )                           \\\r\n{                                                   \\\r\n    BOOST_TEST_INFO( \"validating operator \" #op );  \\\r\n    bool expected = (c1 op c2);                     \\\r\n    auto const& res = (tt::assertion::seed()->* c1 op c2).evaluate();      \\\r\n    BOOST_TEST( expected == !!res );                \\\r\n}                                                   \\\r\n/**/\r\n\r\ntemplate<typename Col>\r\nvoid\r\nvalidate_comparisons(Col const& c1, Col const& c2 )\r\n{\r\n    VALIDATE_OP( == )\r\n    VALIDATE_OP( != )\r\n    VALIDATE_OP( < )\r\n    VALIDATE_OP( > )\r\n    VALIDATE_OP( <= )\r\n    VALIDATE_OP( >= )\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( test_against_overloaded_comp_op )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n    std::vector<int> c{1, 2, 3};\r\n    std::vector<int> d{1, 2, 3, 4};\r\n\r\n    BOOST_TEST_CONTEXT( \"validating comparisons of a and b\" )\r\n        validate_comparisons(a, b);\r\n    BOOST_TEST_CONTEXT( \"validating comparisons of a and c\" )\r\n        validate_comparisons(a, c);\r\n    BOOST_TEST_CONTEXT( \"validating comparisons of a and d\" )\r\n        validate_comparisons(a, d);\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_per_element_eq, * ut::expected_failures(2) )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( a == b, tt::per_element() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_per_element_ne, * ut::expected_failures(1) )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( a != b, tt::per_element() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_per_element_lt, * ut::expected_failures(2) )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( a < b, tt::per_element() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_per_element_ge, * ut::expected_failures(1) )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( b >= a, tt::per_element() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_lexicographic_lt )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( a < b, tt::lexicographic() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_lexicographic_le )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( a <= b, tt::lexicographic() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_lexicographic_gt )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( b > a, tt::lexicographic() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_lexicographic_ge )\r\n{\r\n    std::vector<int> a{1, 2, 3};\r\n    std::vector<int> b{1, 3, 2};\r\n\r\n    BOOST_TEST( b >= a, tt::lexicographic() );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\nBOOST_AUTO_TEST_CASE( test_collection_of_collection_comp )\r\n{\r\n    BOOST_TEST( std::string(\"abc\") == std::string(\"abc\") );\r\n}\r\n\r\n//____________________________________________________________________________//\r\n\r\n// this one does not have const_iterator nor a size, but should be forward iterable\r\n// and possible to use in the collection comparison\r\nstruct fwd_iterable_custom {\r\n  typedef std::vector<int>::const_iterator custom_iterator; // named \"exotic\" on purpose\r\n\r\n  custom_iterator begin() const { return values.begin(); }\r\n  custom_iterator end() const { return values.end(); }\r\n\r\n#if !defined(BOOST_MSVC) || (BOOST_MSVC_FULL_VER > 180040629)\r\n#define MY_TEST_HAS_INIT_LIST\r\n  // this does not work on VC++ 2013 update 5\r\n  fwd_iterable_custom(std::initializer_list<int> ilist) : values{ilist}\r\n  {}\r\n#else\r\n  fwd_iterable_custom(int v1, int v2, int v3) {\r\n    values.push_back(v1);\r\n    values.push_back(v2);\r\n    values.push_back(v3);\r\n  }\r\n#endif\r\nprivate:\r\n  std::vector<int> values;\r\n};\r\n\r\nBOOST_AUTO_TEST_CASE( test_collection_requirement_type )\r\n{\r\n#ifdef MY_TEST_HAS_INIT_LIST\r\n    fwd_iterable_custom a{3,4,5};\r\n    fwd_iterable_custom b{3,4,6};\r\n    fwd_iterable_custom c{3,4,5};\r\n#else\r\n    fwd_iterable_custom a(3,4,5);\r\n    fwd_iterable_custom b(3,4,6);\r\n    fwd_iterable_custom c(3,4,5);\r\n#endif\r\n\r\n    BOOST_TEST( a == a, tt::per_element() );\r\n    //BOOST_TEST( a != b, tt::per_element() );\r\n    BOOST_TEST( a == c, tt::per_element() );\r\n\r\n    BOOST_TEST( a < b, tt::lexicographic() );\r\n    BOOST_TEST( a <= c, tt::lexicographic() );\r\n    BOOST_TEST( b > c, tt::lexicographic() );\r\n\r\n    BOOST_TEST( a <= b, tt::per_element() );\r\n    BOOST_TEST( a <= c, tt::per_element() );\r\n}\r\n\r\n// EOF\r\n", "meta": {"hexsha": "04331041a7c88a18703efe9c93a30ededfb15f99", "size": 5765, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/test/writing-test-ts/collection-comparison-test.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/test/writing-test-ts/collection-comparison-test.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/test/writing-test-ts/collection-comparison-test.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 29.7164948454, "max_line_length": 89, "alphanum_fraction": 0.6456201214, "num_tokens": 1450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4263215925474903, "lm_q2_score": 0.16026603633858208, "lm_q1q2_score": 0.06832487184313826}}
{"text": "/*-----------------------------------------------------------------------------+    \r\nCopyright (c) 2008-2009: Joachim Faulhaber\r\n+------------------------------------------------------------------------------+\r\n   Distributed under the Boost Software License, Version 1.0.\r\n      (See accompanying file LICENCE.txt or copy at\r\n           http://www.boost.org/LICENSE_1_0.txt)\r\n+-----------------------------------------------------------------------------*/\r\n#define BOOST_TEST_MODULE icl::interval_set_mixed unit test\r\n#include <libs/icl/test/disable_test_warnings.hpp>\r\n#include <string>\r\n#include <boost/mpl/list.hpp>\r\n#include \"../unit_test_unwarned.hpp\"\r\n\r\n// interval instance types\r\n#include \"../test_type_lists.hpp\"\r\n#include \"../test_value_maker.hpp\"\r\n\r\n#include <boost/icl/interval_set.hpp>\r\n#include <boost/icl/separate_interval_set.hpp>\r\n#include <boost/icl/split_interval_set.hpp>\r\n\r\nusing namespace std;\r\nusing namespace boost;\r\nusing namespace unit_test;\r\nusing namespace boost::icl;\r\n\r\n#include \"../test_interval_set_mixed.hpp\"\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_ctor_4_ordered_types)\r\n{            interval_set_mixed_ctor_4_ordered_types<int>(); }\r\n\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_equal_4_ordered_types)\r\n{            interval_set_mixed_equal_4_ordered_types<std::string>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_assign_4_ordered_types)\r\n{            interval_set_mixed_assign_4_ordered_types<float>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_ctor_4_bicremental_types)\r\n{            interval_set_mixed_ctor_4_bicremental_types<bicremental_type_1>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_assign_4_bicremental_types)\r\n{            interval_set_mixed_assign_4_bicremental_types<bicremental_type_2>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_equal_4_bicremental_types)\r\n{            interval_set_mixed_equal_4_bicremental_types<bicremental_type_3>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_contains_4_bicremental_types)\r\n{            interval_set_mixed_contains_4_bicremental_types<bicremental_type_4>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_add_4_bicremental_types)\r\n{            interval_set_mixed_add_4_bicremental_types<bicremental_type_5>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_subtract_4_bicremental_types)\r\n{            interval_set_mixed_subtract_4_bicremental_types<bicremental_type_6>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_erase_4_bicremental_types)\r\n{            interval_set_mixed_erase_4_bicremental_types<bicremental_type_7>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_basic_intersect_4_bicremental_types)\r\n{            interval_set_mixed_basic_intersect_4_bicremental_types<bicremental_type_8>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_disjoint_4_bicremental_types)\r\n{            interval_set_mixed_disjoint_4_bicremental_types<bicremental_type_1>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_infix_plus_overload_4_bicremental_types)\r\n{            interval_set_mixed_infix_plus_overload_4_bicremental_types<bicremental_type_2>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_infix_pipe_overload_4_bicremental_types)\r\n{            interval_set_mixed_infix_pipe_overload_4_bicremental_types<bicremental_type_3>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_infix_minus_overload_4_bicremental_types)\r\n{            interval_set_mixed_infix_minus_overload_4_bicremental_types<bicremental_type_4>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_infix_et_overload_4_bicremental_types)\r\n{            interval_set_mixed_infix_et_overload_4_bicremental_types<bicremental_type_5>(); }\r\n\r\nBOOST_AUTO_TEST_CASE\r\n(fastest_icl_interval_set_mixed_infix_caret_overload_4_bicremental_types)\r\n{            interval_set_mixed_infix_caret_overload_4_bicremental_types<bicremental_type_6>(); }\r\n", "meta": {"hexsha": "40ca5c8ac7f16209f2a9fbe71768c3895308ae77", "size": 4019, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/icl/test/fastest_interval_set_mixed_/fastest_interval_set_mixed.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 198.0, "max_stars_repo_stars_event_min_datetime": "2015-01-13T05:47:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T04:46:46.000Z", "max_issues_repo_path": "libs/boost/libs/icl/test/fastest_interval_set_mixed_/fastest_interval_set_mixed.cpp", "max_issues_repo_name": "flingone/frameworks_base_cmds_remoted", "max_issues_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 9.0, "max_issues_repo_issues_event_min_datetime": "2015-01-28T16:33:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T23:03:28.000Z", "max_forks_repo_path": "libs/boost/libs/icl/test/fastest_interval_set_mixed_/fastest_interval_set_mixed.cpp", "max_forks_repo_name": "flingone/frameworks_base_cmds_remoted", "max_forks_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 139.0, "max_forks_repo_forks_event_min_datetime": "2015-01-15T20:09:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-31T15:21:16.000Z", "avg_line_length": 41.4329896907, "max_line_length": 98, "alphanum_fraction": 0.7601393381, "num_tokens": 990, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583464, "lm_q2_score": 0.13846179412408713, "lm_q1q2_score": 0.06760859495366212}}
{"text": "/*! \\file 1d_full_layout.cpp\n    \\brief Example of 1 D plot of 3 different STL container types using several layout features.\n    \\details Creates file 1d_full_layout.svg\n    \\author Jacob Voytko\n*/\n\n// Copyright Jacob Voytko 2007\n// Copyright Paul a. Bristow 2020\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\n// for using namespace boost::svg; // Convenient to access colors and many other svg_plot items.\n#include <boost/svg_plot/svg_color.hpp>\n// for boost::svg::svg_plot::svg_color\n\n#include <boost/svg_plot/show_1d_settings.hpp>\n\n#include <array> //   using std::array;\n#include <vector> // using std::vector;\n#include <deque> // using std::deque;\n#include <cmath> //  using std::sqrt;\n\n// Some random functions to create the data to plot.\ndouble f(double x)\n{\n  return std::sqrt(x);\n}\n\ndouble g(double x)\n{\n  return -2 + x*x;\n}\n\ndouble h(double x)\n{\n  return -1 + 2*x;\n}\n\nint main()\n{\n  using namespace boost::svg; // Convenient to access colors and many other svg_plot items.\n  using boost::svg::svg_color; // Explicitly access SVG colors. \n  using boost::svg::svg_1d_plot; // Explicitly access 1D SVG plot.\n\n  try\n  {\n    // Three containers of different types (just for show):\n    std::vector<double> data1;\n    std::deque<double> data2;\n    std::array<double, 10> data3;\n\n    // Fill the three containers with some randomish data :\n    int j = 0;\n    for (double i = 0; i < 9.5; i += 1.)\n    {\n      data1.push_back(f(i));\n      data2.push_front(g(i));\n      data3[j++] = h(i);\n    }\n\n    svg_1d_plot my_plot;\n\n    // Size/scale settings for the plot.\n    my_plot.size(500, 200)\n      .x_range(-3, 10);\n\n    // Text settings (note chaining 2nd and 3rd settings).\n    my_plot.title(\"Animal Lives\")\n      .title_font_size(29)\n      .x_label_on(true) // Do want to show X-axis label text.\n      .x_axis_label_color(white)\n      .x_label(\"life-time (months)\"); \n\n    // Commands.\n    my_plot.legend_on(true) // Do want a legend box - see legend settings below.\n      .plot_window_on(true) // Do want the plot in its own window.\n      .x_major_labels_side(true); \n\n    // Color settings.\n    my_plot.background_color(gray) // \n      // or .background_color(svg_color(47, 79, 79)) //  darkslategray in svg_color.hpp\n      .legend_background_color(azure)\n      .legend_border_color(gold)\n      .plot_background_color(lightgoldenrodyellow)\n      .title_color(white);\n\n    // Axis settings.\n    my_plot.x_major_interval(2)\n      .x_major_tick_length(14)\n      .x_major_tick_width(1)\n      .x_minor_tick_length(7)\n      .x_minor_tick_width(1)\n      .x_num_minor_ticks(3);\n\n    // Legend settings.\n    my_plot.legend_title(\"Animal\")\n      .legend_title_font_size(15)\n      ;\n\n    // Add the data to the plot:\n    my_plot.plot(data1, \"Lions\").stroke_color(blue);\n    my_plot.plot(data2, \"Tigers\").stroke_color(orange);\n    my_plot.plot(data3, \"Bears\").stroke_color(red);\n\n    // Write the final plot in SVG format.\n    my_plot.write(\"./1d_full_layout.svg\");\n\n    using boost::svg::show_1d_plot_settings;\n    show_1d_plot_settings(my_plot);\n  }\n  catch (std::exception& ex)\n  { // Report about any exceptions. \n    std::cout << \"std::exception thown \" << ex.what() << std::endl;\n  }\n  return 0;\n} // int main()\n\n// 1d_full_layout.cpp\n", "meta": {"hexsha": "7a9795ec6c4fe52379bbea1f8380b6457bc60a08", "size": 3421, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/1d_full_layout.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/1d_full_layout.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/1d_full_layout.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 27.8130081301, "max_line_length": 96, "alphanum_fraction": 0.6676410406, "num_tokens": 943, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.13477592611118108, "lm_q1q2_score": 0.06738796305559054}}
{"text": "//------------------------------------------------------------------------------\n// \\file DataStructures_tests.cpp\n//------------------------------------------------------------------------------\n#include <array>\n#include <boost/test/unit_test.hpp>\n#include <deque>\n#include <forward_list>\n#include <list>\n#include <memory>\n#include <stack>\n#include <string>\n#include <type_traits>\n#include <utility>\n#include <vector>\n\nBOOST_AUTO_TEST_SUITE(DataStructures)\nBOOST_AUTO_TEST_SUITE(DataStructures_tests)\n\nBOOST_AUTO_TEST_SUITE(StdForwardList_tests)\n\n// cf. https://www.geeksforgeeks.org/forward-list-c-set-1-introduction-important-functions/\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateStdForwardListAsLinkedList)\n{\n  {\n    // Declaring forward list\n    std::forward_list<int> flist1;\n\n    // Declaring another forward list\n    std::forward_list<int> flist2;\n\n    // assigns values to container\n    flist1.assign({1, 2, 3});\n\n    // Assigning repeating values using assing()\n    // 5 elements with value 10\n    flist2.assign(5, 10);\n\n    // Displaying forward lists\n\n    int index {1};\n    for (int& a : flist1)\n    {\n      BOOST_TEST(a == index);\n      index++;\n    }\n\n    for (int& b : flist2)\n    {\n      BOOST_TEST(b == 10);\n    }\n  }\n  {\n    std::forward_list flist {10, 20, 30, 40, 50};\n\n    // push_front pushes to last in at \"[0] of flist[0]\", the head\n\n    // Inserting value using push front()\n    // Inserts 60 at front\n    flist.push_front(60); // 60, 10, 20, 30, 40, 50\n\n    std::size_t index {0};\n    std::vector<int> check_by_vec {60, 10, 20, 30, 40, 50};\n    for (int& c : flist)\n    {\n      BOOST_TEST(check_by_vec[index] == c);\n      index++;\n      //std::cout << c << ' ';\n    }\n\n    // Inserting value using emplace_front()\n    // Inserts 70 at front\n    flist.emplace_front(70);\n\n    check_by_vec.assign({70, 60, 10, 20, 30, 40, 50});\n    index = 0;\n    for (int& c : flist)\n    {\n      BOOST_TEST(check_by_vec[index] = c);\n      index++;\n      //std::cout << c << ' ';\n    }\n\n    // Deleting first value using pop_front()\n    // Pops 70\n    flist.pop_front();\n\n    check_by_vec.assign({60, 10, 20, 30, 40, 50});\n    index = 0;\n    for (int& c : flist)\n    {\n      BOOST_TEST(check_by_vec[index] = c);\n      index++;\n      //std::cout << c << ' ';\n    }\n  }\n\n  {\n    // Initializing forward list\n    std::forward_list<int> flist {10, 20, 30};\n\n    // Declaring a forward list iterator\n    std::forward_list<int>::iterator ptr;\n\n    // Inserting value using insert_after()\n    // starts insertion from second position\n    // Iterator to inserted element. typically, but in this case\n    // iterator to last element inserted\n\n    // insert *after* means insert after\n    ptr = flist.insert_after(flist.begin(), {1, 2, 3});\n\n    std::vector<int> check_by_vec {10, 1, 2, 3, 20, 30};\n\n    std::size_t index {0};\n    for (int& c : flist)\n    {\n      BOOST_TEST(check_by_vec[index] == c);\n      index++;\n      //std::cout << c << ' ';\n    }\n    //std::cout << \"\\n\";\n\n    // Inerting value using emplace_after()\n    // inserts 2 after ptr\n    ptr = flist.emplace_after(ptr, 2);\n\n    check_by_vec.assign({10, 1, 2, 3, 2, 20, 30});\n\n    index = 0;\n    for (int& c : flist)\n    {\n      BOOST_TEST(check_by_vec[index] == c);\n      index++;\n      //std::cout << c << ' ';\n    }\n\n  }\n}\n\nBOOST_AUTO_TEST_SUITE_END() // StdForwardList_tests\n\nBOOST_AUTO_TEST_SUITE(StdStack_tests)\n\n// cf. https://en.cppreference.com/w/cpp/header/stack\n// cf. https://www.geeksforgeeks.org/stack-in-cpp-stl/\n// Stacks are LIFO (Last In First Out)\n\ntemplate <typename T>\nstd::vector<T> copy_stack(const std::stack<T>& s)\n{\n  // https://en.cppreference.com/w/cpp/container/stack/operator%3D\n  std::stack<T> copy_of_s = s;\n\n  std::vector<T> result;\n\n  while (!copy_of_s.empty())\n  {\n    result.emplace_back(copy_of_s.top());\n    copy_of_s.pop();\n  }\n\n  return result;\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateStdStack)\n{\n  {\n    // LIFO\n    std::stack<int> s;\n    s.push(10);\n    s.push(30);\n    s.push(20);\n    s.push(5);\n    s.push(1);\n\n    std::vector<int> result {copy_stack(s)};\n\n    BOOST_TEST((result == std::vector<int> {1, 5, 20, 30, 10}));\n\n    BOOST_TEST(s.size() == 5);\n    BOOST_TEST(s.top() == 1);\n    s.pop();\n    result = copy_stack(s);\n    BOOST_TEST((result == std::vector<int> {5, 20, 30, 10}));        \n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TopReferencesOnEmptyStack)\n{\n  std::stack<int> s;\n  const auto& top_reference_on_empty = s.top();\n\n  // Undefined behavior?\n  //BOOST_TEST((&top_reference_on_empty > 0));\n}\n\nBOOST_AUTO_TEST_SUITE_END() // StdStack_tests\n\nBOOST_AUTO_TEST_SUITE(StdDeque_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DemonstrateStdDeque)\n{\n  {\n    // Create a deque containing integers\n    std::deque<int> d {7, 5, 16, 8};\n\n    // Add an integer to the beginning and end of the deque\n    d.push_front(13);\n    d.push_back(25);\n\n    const std::vector<int> target {13, 7, 5, 16, 8, 25};\n\n    std::size_t index {0};\n    for (int n : d)\n    {\n      BOOST_TEST(n == target[index]);\n      index++;\n    }\n  }\n  // FIFO\n  {\n    std::deque<int> d;\n    d.push_back(25);\n    d.push_back(8);\n    d.push_back(16);\n    d.push_back(5);\n    d.push_back(7);\n    d.push_back(13);\n\n    BOOST_TEST(d.back() == 13);\n\n    // if push_back is the enqueue (add to queue)\n    // pop_front is the dequeue (first in, first out)\n    d.pop_front();\n\n    BOOST_TEST(d.front() == 8);    \n  }\n\n  {\n    std::deque<int> d;\n    d.push_front(25);\n    d.push_front(8);\n    d.push_front(16);\n    d.push_front(5);\n    d.push_front(7);\n    d.push_front(13);\n\n    BOOST_TEST(d.back() == 25);\n\n    // if push_front is the enqueue (add to queue)\n    // pop_back is the dequeue (first in, first out)\n    d.pop_back();\n\n    BOOST_TEST(d.back() == 8);\n  }\n\n}\n\nBOOST_AUTO_TEST_SUITE_END() // StdDeque_tests\n\nBOOST_AUTO_TEST_SUITE_END() // DataStructures_tests\nBOOST_AUTO_TEST_SUITE_END() // DataStructures", "meta": {"hexsha": "17a90b0772dd4110358df4fe39ea4618d378f3c5", "size": 6484, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/DataStructures/DataStructures_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/DataStructures/DataStructures_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/DataStructures/DataStructures_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0148148148, "max_line_length": 91, "alphanum_fraction": 0.5343923504, "num_tokens": 1700, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.31742626558767584, "lm_q2_score": 0.21206880435710534, "lm_q1q2_score": 0.06731620861471939}}
{"text": "// **********************************************************************\n// This file is part of the LehrFEM++ finite element library developed\n// from 2018 at the Seminar of Applied Mathematics of ETH Zurich for\n// teaching purposes.\n// This header must not be removed.\n// **********************************************************************\n/**\n * @file\n * @brief Driver function for simple LehrFEM++ demo\n * @author Ralf Hiptmair\n * @date   January 2019\n * @copyright MIT License\n */\n\n#include <boost/program_options.hpp>\n\n#include \"lecturedemoassemble.h\"\n#include \"lecturedemodof.h\"\n#include \"lecturedemomesh.h\"\n#include \"lecturedemomeshfunction.h\"\n#include \"lecturedemoquad.h\"\n#include \"lecturedemorefine.h\"\n#include \"lecturedemotwonorm.h\"\n\nint main(int argc, char **argv) {\n  // We rely on Boost's program_option library for parsing command line\n  // arguments\n  namespace po = boost::program_options;\n  // We specify what to do for the two allowed options -h and -d, which are\n  // linked to the keys 'help' and 'demo_number'. We tell the computer that -d\n  // expects an integer argument and that the default value is 0\n  po::options_description desc(\"Allowed options\");\n  // clang-format off\n  desc.add_options()\n  (\"help,h\", \"This message\")\n  (\"demo_number,d\", po::value<int>()->default_value(0), \"Selector for demo code\");\n  // clang-format on\n  po::variables_map vm;\n  po::store(po::parse_command_line(argc, argv, desc), vm);\n  if (vm.count(\"help\") > 0) {\n    std::cout << desc << std::endl;\n    std::cout << \"No arg: run all demos\" << std::endl;\n    std::cout << \"N = 1: demo of LehrFEM++ mesh capabilities\" << std::endl;\n    std::cout << \"N = 2: demo of LehrFEM++ DofHandler capabilities\"\n              << std::endl;\n    std::cout << \"N = 3: demo of LehrFEM++ assembly of LSE\" << std::endl;\n    std::cout << \"N = 4: demo of numerical quadrature in LehrFEM++\"\n              << std::endl;\n    std::cout << \"N = 5: demo of solving a Dirichlet BVP\" << std::endl;\n    std::cout << \"N = 6: demo of mesh refinement\" << std::endl;\n    std::cout << \"N = 7: Various of ways of computing an L2-norm\" << std::endl;\n    std::cout << \"N = 8: Demo for MeshFunction\" << std::endl;\n  } else {\n    int selector = vm[\"demo_number\"].as<int>();\n    if ((selector == 1) || (selector == 0)) {\n      lecturedemo::lecturedemomesh();\n    }\n    if ((selector == 2) || (selector == 0)) {\n      lecturedemo::lecturedemodof();\n    }\n    if ((selector == 3) || (selector == 0)) {\n      lecturedemo::lecturedemoassemble();\n    }\n    if ((selector == 4) || (selector == 0)) {\n      lecturedemo::lecturedemoquad();\n    }\n    if ((selector == 5) || (selector == 0)) {\n      lecturedemo::lecturedemoDirichlet();\n    }\n    if ((selector == 6) || (selector == 0)) {\n      lecturedemo::lecturedemorefine();\n    }\n    if ((selector == 7) || (selector == 0)) {\n      lecturedemo::lecturedemotwonorm();\n    }\n    if ((selector == 8) || (selector == 0)) {\n      lecturedemo::lecturedemomeshfunction();\n    }\n  }\n  return 0L;\n}\n", "meta": {"hexsha": "b11be188961693cd1cfd6da96fb76711a947f4b6", "size": 3001, "ext": "cc", "lang": "C++", "max_stars_repo_path": "examples/lecturedemos/lecturedemomain.cc", "max_stars_repo_name": "Fytch/lehrfempp", "max_stars_repo_head_hexsha": "c804b3e350aa893180f1a02ce57a93b3d7686e91", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16.0, "max_stars_repo_stars_event_min_datetime": "2018-08-30T19:55:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T16:38:06.000Z", "max_issues_repo_path": "examples/lecturedemos/lecturedemomain.cc", "max_issues_repo_name": "Fytch/lehrfempp", "max_issues_repo_head_hexsha": "c804b3e350aa893180f1a02ce57a93b3d7686e91", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 151.0, "max_issues_repo_issues_event_min_datetime": "2018-05-27T13:01:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-04T14:50:50.000Z", "max_forks_repo_path": "examples/lecturedemos/lecturedemomain.cc", "max_forks_repo_name": "Fytch/lehrfempp", "max_forks_repo_head_hexsha": "c804b3e350aa893180f1a02ce57a93b3d7686e91", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 20.0, "max_forks_repo_forks_event_min_datetime": "2018-11-13T13:46:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-18T17:33:52.000Z", "avg_line_length": 36.5975609756, "max_line_length": 82, "alphanum_fraction": 0.5928023992, "num_tokens": 846, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.36658973632215985, "lm_q2_score": 0.18242552602881168, "lm_q1q2_score": 0.06687532548533338}}
{"text": "//\n// Copyright 2020 Debabrata Mandal <mandaldebabrata123@gmail.com>\n//\n// Distributed under the Boost Software License, Version 1.0\n// See accompanying file LICENSE_1_0.txt or copy at\n// http://www.boost.org/LICENSE_1_0.txt\n//\n\n#ifndef BOOST_GIL_HISTOGRAM_HPP\n#define BOOST_GIL_HISTOGRAM_HPP\n\n#include <boost/gil/concepts/concept_check.hpp>\n#include <boost/gil/metafunctions.hpp>\n#include <boost/gil/pixel.hpp>\n\n#include <boost/mp11.hpp>\n#include <boost/type_traits.hpp>\n#include <boost/functional/hash.hpp>\n\n#include <iostream>\n#include <tuple>\n#include <utility>\n#include <vector>\n#include <type_traits>\n#include <map>\n#include <unordered_map>\n\nnamespace boost { namespace gil {\n\n//////////////////////////////////////////////////////////\n/// Histogram\n//////////////////////////////////////////////////////////\n/// \\defgroup Histogram Histogram\n/// \\brief Contains description of the boost.gil.histogram class, extensions provided in place\n///        of the default class, algorithms over the histogram class (both extensions and the\n///        default class)\n///\n\nnamespace detail {\n\n/// \\defgroup Histogram-Helpers Histogram-Helpers\n/// \\brief Helper implementations supporting the histogram class.\n\n/// \\ingroup Histogram-Helpers\n///\ntemplate <std::size_t Index, typename... T>\ninline typename std::enable_if<Index == sizeof...(T), void>::type\n    hash_tuple_impl(std::size_t&, std::tuple<T...> const&)\n{\n}\n\n/// \\ingroup Histogram-Helpers\n///\ntemplate <std::size_t Index, typename... T>\ninline typename std::enable_if<Index != sizeof...(T), void>::type\n    hash_tuple_impl(std::size_t& seed, std::tuple<T...> const& t)\n{\n    boost::hash_combine(seed, std::get<Index>(t));\n    hash_tuple_impl<Index + 1>(seed, t);\n}\n\n/// \\ingroup Histogram-Helpers\n/// \\brief Functor provided for the hashing of tuples. \n///        The following approach makes use hash_combine from \n///        boost::container_hash. Although there is a direct hashing \n///        available for tuples, this approach will ease adopting in\n///        future to a std::hash_combine. In case std::hash extends\n///        support to tuples this functor as well as the helper \n///        implementation hash_tuple_impl can be removed.\n///\ntemplate <typename... T>\nstruct hash_tuple\n{\n    std::size_t operator()(std::tuple<T...> const& t) const\n    {\n        std::size_t seed = 0;\n        hash_tuple_impl<0>(seed, t);\n        return seed;\n    }\n};\n\n/// \\ingroup Histogram-Helpers\n/// \\todo With C++14 and using auto we don't need the decltype anymore\n///\ntemplate <typename Pixel, std::size_t... I>\nauto pixel_to_tuple(Pixel const& p, boost::mp11::index_sequence<I...>)\n    -> decltype(std::make_tuple(p[I]...))\n{\n    return std::make_tuple(p[I]...);\n}\n\n/// \\ingroup Histogram-Helpers\n/// \\todo With C++14 and using auto we don't need the decltype anymore\n///\ntemplate <typename Tuple, std::size_t... I>\nauto tuple_to_tuple(Tuple const& t, boost::mp11::index_sequence<I...>)\n    -> decltype(std::make_tuple(std::get<I>(t)...))\n{\n    return std::make_tuple(std::get<I>(t)...);\n}\n\n/// \\ingroup Histogram-Helpers\n///\ntemplate <typename Tuple, std::size_t... I>\nbool tuple_compare(Tuple const& t1, Tuple const& t2, boost::mp11::index_sequence<I...>)\n{\n    std::array<bool, std::tuple_size<Tuple>::value> comp_list;\n    comp_list = {std::get<I>(t1) <= std::get<I>(t2)...};\n    bool comp = true;\n    for (std::size_t i = 0; i < comp_list.size(); i++)\n    {\n        comp = comp & comp_list[i];\n    }\n    return comp;\n}\n\n/// \\ingroup Histogram-Helpers\n/// \\brief Compares 2 tuples and outputs t1 <= t2 \n///        Comparison is not in a lexicographic manner but on every element of the tuple hence\n///        (2, 2) > (1, 3) evaluates to false\n///\ntemplate <typename Tuple>\nbool tuple_compare(Tuple const& t1, Tuple const& t2)\n{\n    std::size_t const tuple_size = std::tuple_size<Tuple>::value;\n    auto index_list              = boost::mp11::make_index_sequence<tuple_size>{};\n    return tuple_compare(t1, t2, index_list);\n}\n\n/// \\ingroup Histogram-Helpers\n/// \\brief Provides equivalent of std::numeric_limits for type std::tuple\n///        tuple_limit gets called with only tuples having integral elements\n///\ntemplate <typename Tuple>\nstruct tuple_limit\n{\n    static constexpr Tuple min()\n    {\n        return min_impl(boost::mp11::make_index_sequence<std::tuple_size<Tuple>::value>{});\n    }\n    static constexpr Tuple max()\n    {\n        return max_impl(boost::mp11::make_index_sequence<std::tuple_size<Tuple>::value>{});\n    }\n\nprivate:\n    template <std::size_t... I>\n    static constexpr Tuple min_impl(boost::mp11::index_sequence<I...>)\n    {\n        return std::make_tuple(\n            std::numeric_limits<typename std::tuple_element<I, Tuple>::type>::min()...);\n    }\n\n    template <std::size_t... I>\n    static constexpr Tuple max_impl(boost::mp11::index_sequence<I...>)\n    {\n        return std::make_tuple(\n            std::numeric_limits<typename std::tuple_element<I, Tuple>::type>::max()...);\n    }\n};\n\n/// \\ingroup Histogram-Helpers\n/// \\brief Filler is used to fill the histogram class with all values between a specified range\n///        This functor is used when sparsefill is false, since all the keys need to be present\n///        in that case.\n///        Currently on 1D implementation is available, extend by adding specialization for 2D\n///        and higher dimensional cases.\n///\ntemplate <std::size_t Dimension>\nstruct filler\n{\n    template <typename Container, typename Tuple>\n    void operator()(Container&, Tuple&, Tuple&, std::size_t)\n    {\n    }\n};\n\n/// \\ingroup Histogram-Helpers\n/// \\brief Specialisation for 1D histogram.\ntemplate <>\nstruct filler<1>\n{\n    template <typename Container, typename Tuple>\n    void operator()(Container& hist, Tuple& lower, Tuple& upper, std::size_t bin_width = 1)\n    {\n        for (auto i = std::get<0>(lower); static_cast<std::size_t>(std::get<0>(upper) - i) >= bin_width; i += bin_width)\n        {\n            hist(i / bin_width) = 0;\n        }\n        hist(std::get<0>(upper) / bin_width) = 0;\n    }\n};\n\n}  //namespace detail\n\n///\n/// \\class boost::gil::histogram\n/// \\ingroup Histogram\n/// \\brief Default histogram class provided by boost::gil.\n///\n/// The class inherits over the std::unordered_map provided by STL. A complete example/tutorial\n/// of how to use the class resides in the docs. \n/// Simple calling syntax for a 3D dimensional histogram :\n/// \\code\n/// histogram<int, int , int> h;\n/// h(1, 1, 1) = 0;\n/// \\endcode\n/// This is just a starter to what all can be achieved with it, refer to the docs for the \n/// full demo.\n///\ntemplate <typename... T>\nclass histogram : public std::unordered_map<std::tuple<T...>, double, detail::hash_tuple<T...>>\n{\n    using base_t   = std::unordered_map<std::tuple<T...>, double, detail::hash_tuple<T...>>;\n    using bin_t    = boost::mp11::mp_list<T...>;\n    using key_t    = typename base_t::key_type;\n    using mapped_t = typename base_t::mapped_type;\n    using value_t  = typename base_t::value_type;\n\npublic:\n    histogram() = default;\n\n    /// \\brief Returns the number of dimensions(axes) the class supports.\n    static constexpr std::size_t dimension()\n    {\n        return std::tuple_size<key_t>::value;\n    }\n\n    /// \\brief Returns bin value corresponding to specified tuple\n    mapped_t& operator()(T... indices)\n    {\n        auto key                              = std::make_tuple(indices...);\n        std::size_t const index_dimension     = std::tuple_size<std::tuple<T...>>::value;\n        std::size_t const histogram_dimension = dimension();\n        static_assert(histogram_dimension == index_dimension, \"Dimensions do not match.\");\n\n        return base_t::operator[](key);\n    }\n\n    /// \\brief Checks if 2 histograms are equal. Ignores type, and checks if \n    ///        the keys (after type casting) match.\n    template <typename OtherType>\n    bool equals(OtherType const& otherhist) const\n    {\n        bool check = (dimension() == otherhist.dimension());\n\n        using other_value_t = typename OtherType::value_type;\n        std::for_each(otherhist.begin(), otherhist.end(), [&](other_value_t const& v) {\n            key_t key = key_from_tuple(v.first);\n            if (base_t::find(key) != base_t::end())\n            {\n                check = check & (base_t::at(key) == otherhist.at(v.first));\n            }\n            else\n            {\n                check = false;\n            }\n        });\n        return check;\n    }\n    \n    /// \\brief Checks if the histogram class is compatible to be used with\n    ///        a GIL image type\n    static constexpr bool is_pixel_compatible()\n    {\n        using bin_types = boost::mp11::mp_list<T...>;\n        return boost::mp11::mp_all_of<bin_types, std::is_arithmetic>::value;\n    }\n\n    /// \\brief Checks if the histogram class is compatible to be used with\n    ///        the specified tuple type\n    template <typename Tuple>\n    bool is_tuple_compatible(Tuple const&)\n    {\n        std::size_t const tuple_size     = std::tuple_size<Tuple>::value;\n        std::size_t const histogram_size = dimension();\n        // TODO : Explore consequence of using if-constexpr\n        using sequence_type = typename std::conditional\n        <\n            tuple_size >= histogram_size,\n            boost::mp11::make_index_sequence<histogram_size>,\n            boost::mp11::make_index_sequence<tuple_size>\n        >::type;\n\n        if (is_tuple_size_compatible<Tuple>())\n            return is_tuple_type_compatible<Tuple>(sequence_type{});\n        else\n            return false;\n    }\n\n    /// \\brief Returns a key compatible to be used as the histogram key\n    ///        from the input tuple\n    template <std::size_t... Dimensions, typename Tuple>\n    key_t key_from_tuple(Tuple const& t) const\n    {\n        using index_list                      = boost::mp11::mp_list_c<std::size_t, Dimensions...>;\n        std::size_t const index_list_size     = boost::mp11::mp_size<index_list>::value;\n        std::size_t const tuple_size          = std::tuple_size<Tuple>::value;\n        std::size_t const histogram_dimension = dimension();\n\n        static_assert(\n            ((index_list_size != 0 && index_list_size == histogram_dimension) ||\n             (tuple_size == histogram_dimension)),\n            \"Tuple and histogram key of different sizes\");\n\n        using new_index_list = typename std::conditional\n        <\n            index_list_size == 0,\n            boost::mp11::mp_list_c<std::size_t, 0>,\n            index_list\n        >::type;\n\n        std::size_t const min =\n            boost::mp11::mp_min_element<new_index_list, boost::mp11::mp_less>::value;\n\n        std::size_t const max =\n            boost::mp11::mp_max_element<new_index_list, boost::mp11::mp_less>::value;\n\n        static_assert((0 <= min && max < tuple_size) || index_list_size == 0, \"Index out of Range\");\n\n        using seq1 = boost::mp11::make_index_sequence<histogram_dimension>;\n        using seq2 = boost::mp11::index_sequence<Dimensions...>;\n        // TODO : Explore consequence of using if-constexpr\n        using sequence_type = typename std::conditional<index_list_size == 0, seq1, seq2>::type;\n\n        auto key = detail::tuple_to_tuple(t, sequence_type{});\n        static_assert(\n            is_tuple_type_compatible<Tuple>(seq1{}),\n            \"Tuple type and histogram type not compatible.\");\n\n        return make_histogram_key(key, seq1{});\n    }\n\n    /// \\brief Returns a histogram compatible key from the input pixel which\n    ///        can be directly used\n    template <std::size_t... Dimensions, typename Pixel>\n    key_t key_from_pixel(Pixel const& p) const\n    {\n        using index_list                      = boost::mp11::mp_list_c<std::size_t, Dimensions...>;\n        std::size_t const index_list_size     = boost::mp11::mp_size<index_list>::value;\n        std::size_t const pixel_dimension     = num_channels<Pixel>::value;\n        std::size_t const histogram_dimension = dimension();\n\n        static_assert(\n            ((index_list_size != 0 && index_list_size == histogram_dimension) ||\n            (index_list_size == 0 && pixel_dimension == histogram_dimension)) &&\n            is_pixel_compatible(),\n            \"Pixels and histogram key are not compatible.\");\n\n        using  new_index_list = typename std::conditional\n        <\n            index_list_size == 0,\n            boost::mp11::mp_list_c<std::size_t, 0>,\n            index_list\n        >::type;\n\n        std::size_t const min =\n            boost::mp11::mp_min_element<new_index_list, boost::mp11::mp_less>::value;\n\n        std::size_t const max =\n            boost::mp11::mp_max_element<new_index_list, boost::mp11::mp_less>::value;\n\n        static_assert(\n            (0 <= min && max < pixel_dimension) || index_list_size == 0, \"Index out of Range\");\n\n        using seq1          = boost::mp11::make_index_sequence<histogram_dimension>;\n        using seq2          = boost::mp11::index_sequence<Dimensions...>;\n        using sequence_type = typename std::conditional<index_list_size == 0, seq1, seq2>::type;\n\n        auto key = detail::pixel_to_tuple(p, sequence_type{});\n        return make_histogram_key(key, seq1{});\n    }\n\n    /// \\brief Return nearest smaller key to specified histogram key\n    key_t nearest_key(key_t const& k) const\n    {\n        using check_list = boost::mp11::mp_list<boost::has_less<T>...>;\n        static_assert(\n            boost::mp11::mp_all_of<check_list, boost::mp11::mp_to_bool>::value,\n            \"Keys are not comparable.\");\n        auto nearest_k = k;\n        if (base_t::find(k) != base_t::end())\n        {\n            return nearest_k;\n        }\n        else\n        {\n            bool once = true;\n            std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n                if (v.first <= k)\n                {\n                    if (once)\n                    {\n                        once      = !once;\n                        nearest_k = v.first;\n                    }\n                    else if (nearest_k < v.first)\n                        nearest_k = v.first;\n                }\n            });\n            return nearest_k;\n        }\n    }\n\n    /// \\brief Fills the histogram with the input image view\n    template <std::size_t... Dimensions, typename SrcView>\n    void fill(\n        SrcView const& srcview,\n        std::size_t bin_width               = 1,\n        bool applymask                      = false,\n        std::vector<std::vector<bool>> mask = {},\n        key_t lower                         = key_t(),\n        key_t upper                         = key_t(),\n        bool setlimits                      = false)\n    {\n        gil_function_requires<ImageViewConcept<SrcView>>();\n        using channel_t = typename channel_type<SrcView>::type;\n\n        for (std::ptrdiff_t src_y = 0; src_y < srcview.height(); ++src_y)\n        {\n            auto src_it = srcview.row_begin(src_y);\n            for (std::ptrdiff_t src_x = 0; src_x < srcview.width(); ++src_x)\n            {\n                if (applymask && !mask[src_y][src_x])\n                    continue;\n                auto scaled_px = src_it[src_x];\n                static_for_each(scaled_px, [&](channel_t& ch) {\n                    ch = ch / bin_width;\n                });\n                auto key = key_from_pixel<Dimensions...>(scaled_px);\n                if (!setlimits ||\n                    (detail::tuple_compare(lower, key) && detail::tuple_compare(key, upper)))\n                    base_t::operator[](key)++;\n            }\n        }\n    }\n\n    /// \\brief Can return a subset or a mask over the current histogram\n    template <std::size_t... Dimensions, typename Tuple>\n    histogram sub_histogram(Tuple const& t1, Tuple const& t2)\n    {\n        using index_list                      = boost::mp11::mp_list_c<std::size_t, Dimensions...>;\n        std::size_t const index_list_size     = boost::mp11::mp_size<index_list>::value;\n        std::size_t const histogram_dimension = dimension();\n\n        std::size_t const min =\n            boost::mp11::mp_min_element<index_list, boost::mp11::mp_less>::value;\n\n        std::size_t const max =\n            boost::mp11::mp_max_element<index_list, boost::mp11::mp_less>::value;\n\n        static_assert(\n            (0 <= min && max < histogram_dimension) && index_list_size < histogram_dimension,\n            \"Index out of Range\");\n\n        using seq1 = boost::mp11::make_index_sequence<dimension()>;\n        using seq2 = boost::mp11::index_sequence<Dimensions...>;\n\n        static_assert(\n            is_tuple_type_compatible<Tuple>(seq1{}),\n            \"Tuple type and histogram type not compatible.\");\n\n        auto low      = make_histogram_key(t1, seq1{});\n        auto low_key  = detail::tuple_to_tuple(low, seq2{});\n        auto high     = make_histogram_key(t2, seq1{});\n        auto high_key = detail::tuple_to_tuple(high, seq2{});\n\n        histogram sub_h;\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& k) {\n            auto tmp_key = detail::tuple_to_tuple(k.first, seq2{});\n            if (low_key <= tmp_key && tmp_key <= high_key)\n                sub_h[k.first] += base_t::operator[](k.first);\n        });\n        return sub_h;\n    }\n\n    /// \\brief Returns a sub-histogram over specified axes\n    template <std::size_t... Dimensions>\n    histogram<boost::mp11::mp_at<bin_t, boost::mp11::mp_size_t<Dimensions>>...> sub_histogram()\n    {\n        using index_list                      = boost::mp11::mp_list_c<std::size_t, Dimensions...>;\n        std::size_t const index_list_size     = boost::mp11::mp_size<index_list>::value;\n        std::size_t const histogram_dimension = dimension();\n\n        std::size_t const min =\n            boost::mp11::mp_min_element<index_list, boost::mp11::mp_less>::value;\n\n        std::size_t const max =\n            boost::mp11::mp_max_element<index_list, boost::mp11::mp_less>::value;\n\n        static_assert(\n            (0 <= min && max < histogram_dimension) && index_list_size < histogram_dimension,\n            \"Index out of Range\");\n\n        histogram<boost::mp11::mp_at<bin_t, boost::mp11::mp_size_t<Dimensions>>...> sub_h;\n\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            auto sub_key =\n                detail::tuple_to_tuple(v.first, boost::mp11::index_sequence<Dimensions...>{});\n            sub_h[sub_key] += base_t::operator[](v.first);\n        });\n        return sub_h;\n    }\n\n    /// \\brief Normalize this histogram class \n    void normalize()\n    {\n        double sum = 0.0;\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            sum += v.second;\n        });\n        // std::cout<<(long int)sum<<\"asfe\";\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            base_t::operator[](v.first) = v.second / sum;\n        });\n    }\n\n    /// \\brief Return the sum count of all bins\n    double sum() const\n    {\n        double sum = 0.0;\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            sum += v.second;\n        });\n        return sum;\n    }\n\n    /// \\brief Return the minimum key in histogram\n    key_t min_key() const\n    {\n        key_t min_key = base_t::begin()->first;\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            if (v.first < min_key)\n                min_key = v.first;\n        });\n        return min_key;\n    }\n\n    /// \\brief Return the maximum key in histogram\n    key_t max_key() const\n    {\n        key_t max_key = base_t::begin()->first;\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            if (v.first > max_key)\n                max_key = v.first;\n        });\n        return max_key;\n    }\n\n    /// \\brief Return sorted keys in a vector\n    std::vector<key_t> sorted_keys() const\n    {\n        std::vector<key_t> sorted_keys;\n        std::for_each(base_t::begin(), base_t::end(), [&](value_t const& v) {\n            sorted_keys.push_back(v.first);\n        });\n        std::sort(sorted_keys.begin(), sorted_keys.end());\n        return sorted_keys;\n    }\n\nprivate:\n    template <typename Tuple, std::size_t... I>\n    key_t make_histogram_key(Tuple const& t, boost::mp11::index_sequence<I...>) const\n    {\n        return std::make_tuple(\n            static_cast<typename boost::mp11::mp_at<bin_t, boost::mp11::mp_size_t<I>>>(\n                std::get<I>(t))...);\n    }\n\n    template <typename Tuple, std::size_t... I>\n    static constexpr bool is_tuple_type_compatible(boost::mp11::index_sequence<I...>)\n    {\n        using tp = boost::mp11::mp_list\n        <\n            typename std::is_convertible\n            <\n                boost::mp11::mp_at<bin_t, boost::mp11::mp_size_t<I>>,\n                typename std::tuple_element<I, Tuple>::type\n            >::type...\n        >;\n        return boost::mp11::mp_all_of<tp, boost::mp11::mp_to_bool>::value;\n    }\n\n    template <typename Tuple>\n    static constexpr bool is_tuple_size_compatible()\n    {\n        return (std::tuple_size<Tuple>::value == dimension());\n    }\n};\n\n///\n/// \\fn void fill_histogram\n/// \\ingroup Histogram Algorithms\n/// \\tparam SrcView Input image view\n/// \\tparam Container Input histogram container\n/// \\brief Overload this function to provide support for boost::gil::histogram or \n/// any other external histogram\n///\n/// Example :\n/// \\code\n/// histogram<int> h;\n/// fill_histogram(view(img), h);\n/// \\endcode\n///\ntemplate <typename SrcView, typename Container>\nvoid fill_histogram(SrcView const&, Container&);\n\n///\n/// \\fn void fill_histogram\n/// \\ingroup Histogram Algorithms\n/// @param srcview     Input  Input image view\n/// @param hist        Output Histogram to be filled\n/// @param bin_width   Input  Specify the bin widths for the histogram.\n/// @param accumulate  Input  Specify whether to accumulate over the values already present in h (default = false)\n/// @param sparsaefill Input  Specify whether to have a sparse or continuous histogram (default = true)\n/// @param applymask   Input  Specify if image mask is to be specified\n/// @param mask        Input  Mask as a 2D vector. Used only if prev argument specified\n/// @param lower       Input  Lower limit on the values in histogram (default numeric_limit::min() on axes)\n/// @param upper       Input  Upper limit on the values in histogram (default numeric_limit::max() on axes)\n/// @param setlimits   Input  Use specified limits if this is true (default is false)\n/// \\brief Overload version of fill_histogram \n///\n/// Takes a third argument to determine whether to clear container before filling.\n/// For eg, when there is a need to accumulate the histograms do\n/// \\code\n/// fill_histogram(view(img), hist, true);\n/// \\endcode\n///\ntemplate <std::size_t... Dimensions, typename SrcView, typename... T>\nvoid fill_histogram(\n    SrcView const& srcview,\n    histogram<T...>& hist,\n    std::size_t bin_width               = 1,\n    bool accumulate                     = false,\n    bool sparsefill                     = true,\n    bool applymask                      = false,\n    std::vector<std::vector<bool>> mask = {},\n    typename histogram<T...>::key_type lower =\n        detail::tuple_limit<typename histogram<T...>::key_type>::min(),\n    typename histogram<T...>::key_type upper =\n        detail::tuple_limit<typename histogram<T...>::key_type>::max(),\n    bool setlimits = false)\n{\n    if (!accumulate)\n        hist.clear();\n    \n    detail::filler<histogram<T...>::dimension()> f;\n    if (!sparsefill)\n        f(hist, lower, upper, bin_width);\n    \n    hist.template fill<Dimensions...>(srcview, bin_width, applymask, mask, lower, upper, setlimits);\n}\n\n///\n/// \\fn void cumulative_histogram(Container&)\n/// \\ingroup Histogram Algorithms\n/// \\tparam Container Input histogram container\n/// \\brief Optionally overload this function with any external histogram class\n///\n/// Cumulative histogram is calculated over any arbitrary dimensional\n/// histogram. The only tradeoff could be the runtime complexity which in\n/// the worst case would be max( #pixel_values , #bins ) * #dimensions.\n/// For single dimensional histograms the complexity has been brought down to\n/// #bins * log( #bins ) by sorting the keys and then calculating the cumulative version.\n///\ntemplate <typename Container>\nContainer cumulative_histogram(Container const&);\n\ntemplate <typename... T>\nhistogram<T...> cumulative_histogram(histogram<T...> const& hist)\n{\n    using check_list = boost::mp11::mp_list<boost::has_less<T>...>;\n    static_assert(\n        boost::mp11::mp_all_of<check_list, boost::mp11::mp_to_bool>::value,\n        \"Cumulative histogram not possible of this type\");\n    \n    using histogram_t = histogram<T...>;\n    using pair_t  = std::pair<typename histogram_t::key_type, typename histogram_t::mapped_type>;\n    using value_t = typename histogram_t::value_type;\n\n    histogram_t cumulative_hist;\n    std::size_t const dims = histogram_t::dimension();\n    if (dims == 1)\n    {\n        std::vector<pair_t> sorted_keys(hist.size());\n        std::size_t counter = 0;\n        std::for_each(hist.begin(), hist.end(), [&](value_t const& v) {\n            sorted_keys[counter++] = std::make_pair(v.first, v.second);\n        });\n        std::sort(sorted_keys.begin(), sorted_keys.end());\n        auto cumulative_counter = static_cast<typename histogram_t::mapped_type>(0);\n        for (std::size_t i = 0; i < sorted_keys.size(); ++i)\n        {\n            cumulative_counter += sorted_keys[i].second;\n            cumulative_hist[(sorted_keys[i].first)] = cumulative_counter;\n        }\n    }\n    else\n    {\n        std::for_each(hist.begin(), hist.end(), [&](value_t const& v1) {\n            auto cumulative_counter = static_cast<typename histogram_t::mapped_type>(0);\n            std::for_each(hist.begin(), hist.end(), [&](value_t const& v2) {\n                bool comp = detail::tuple_compare(\n                    v2.first, v1.first,\n                    boost::mp11::make_index_sequence<histogram_t::dimension()>{});\n                if (comp)\n                    cumulative_counter += hist.at(v2.first);\n            });\n            cumulative_hist[v1.first] = cumulative_counter;\n        });\n    }\n    return cumulative_hist;\n}\n\n}}  //namespace boost::gil\n\n#endif\n", "meta": {"hexsha": "a74b590033b8e39f3a7e19c9ae990b7b2a5fc39e", "size": 26207, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "include/boost/gil/histogram.hpp", "max_stars_repo_name": "harsh-4/gil", "max_stars_repo_head_hexsha": "6da59cc3351e5657275d3a536e0b6e7a1b6ac738", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 153.0, "max_stars_repo_stars_event_min_datetime": "2015-02-03T06:03:54.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T15:06:34.000Z", "max_issues_repo_path": "include/boost/gil/histogram.hpp", "max_issues_repo_name": "harsh-4/gil", "max_issues_repo_head_hexsha": "6da59cc3351e5657275d3a536e0b6e7a1b6ac738", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 429.0, "max_issues_repo_issues_event_min_datetime": "2015-03-22T09:49:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T08:32:08.000Z", "max_forks_repo_path": "include/boost/gil/histogram.hpp", "max_forks_repo_name": "harsh-4/gil", "max_forks_repo_head_hexsha": "6da59cc3351e5657275d3a536e0b6e7a1b6ac738", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 215.0, "max_forks_repo_forks_event_min_datetime": "2015-03-15T09:20:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T12:40:07.000Z", "avg_line_length": 36.5, "max_line_length": 120, "alphanum_fraction": 0.607967337, "num_tokens": 6151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4455295350395727, "lm_q2_score": 0.1500288243424251, "lm_q1q2_score": 0.06684227235181438}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Tests for the SparseMatrixCSR class\n */\n\n#define BOOST_TEST_MODULE SparseMatrixCSR\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n#include <stdexcept>\n\n#include \"SparseMatrixCSR.h\"\n#include \"Error.h\"\n\nusing namespace cupcfd::data_structures;\n\n// =========================================================================\n// === Constructor Tests ===\n// =========================================================================\n// Test 1: Default Constructor\nBOOST_AUTO_TEST_CASE(constructor_test1)\n{\n\tSparseMatrixCSR<int, int> matrix;\n\n\tBOOST_CHECK_EQUAL(matrix.m, 1);\n\tBOOST_CHECK_EQUAL(matrix.n, 1);\n\tBOOST_CHECK_EQUAL(matrix.baseIndex, 0);\n\tBOOST_CHECK_EQUAL(matrix.nnz, 0);\n}\n\n// Test 2:\nBOOST_AUTO_TEST_CASE(constructor_test2)\n{\n\tSparseMatrixCSR<int, int> matrix(4, 7);\n\n\tBOOST_CHECK_EQUAL(matrix.m, 4);\n\tBOOST_CHECK_EQUAL(matrix.n, 7);\n\tBOOST_CHECK_EQUAL(matrix.baseIndex, 0);\n\tBOOST_CHECK_EQUAL(matrix.nnz, 0);\n}\n\n// Test 3:\nBOOST_AUTO_TEST_CASE(constructor_test3)\n{\n\tSparseMatrixCSR<int, int> matrix(6, 9, 5);\n\n\tBOOST_CHECK_EQUAL(matrix.m, 6);\n\tBOOST_CHECK_EQUAL(matrix.n, 9);\n\tBOOST_CHECK_EQUAL(matrix.baseIndex, 5);\n\tBOOST_CHECK_EQUAL(matrix.nnz, 0);\n}\n\n// === setElement Tests ===\n// Test 1: Add non-existing entry\nBOOST_AUTO_TEST_CASE(setElement_test1)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 0);\n\n\tint elements[4] = {2, 4, 3, 20};\n\tint rows[4] = {0, 1, 0, 1};\n\tint columns[4] = {0, 1, 1, 0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint rowsCmp[3] = {0, 2, 4};\n\tint colsCmp[4] = {0, 1, 0, 1};\n\tint valCmp[4] = {2, 3, 20, 4};\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.IA[0], &matrix.IA[0] + 3, rowsCmp, rowsCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.JA[0], &matrix.JA[0] + 4, colsCmp, colsCmp + 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.A[0], &matrix.A[0] + 4, valCmp, valCmp + 4);\n\n\tBOOST_CHECK_EQUAL(matrix.nnz, 4);\n}\n\n// Test 2: Overwrite existing non-zero entry\nBOOST_AUTO_TEST_CASE(setElement_test2)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 0);\n\n\t// Set the values such that (0, 0) = 20, (1, 0) = 3\n\t// but these are overwriting 2 and 4 respectively.\n\tint elements[4] = {2, 4, 3, 20};\n\tint rows[4] = {0, 1, 1, 0};\n\tint columns[4] = {0, 0, 0, 0};\n\n\t// Check nnz count is 4\n\tBOOST_CHECK_EQUAL(matrix.nnz, 0);\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint rowsCmp[3] = {0, 1, 2};\n\tint colsCmp[2] = {0, 0};\n\tint valCmp[2] = {20, 3};\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.IA[0], &matrix.IA[0] + 3, rowsCmp, rowsCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.JA[0], &matrix.JA[0] + 2, colsCmp, colsCmp + 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.A[0], &matrix.A[0] + 2, valCmp, valCmp + 2);\n\n\t// NNZ Count should be 2 since we added 2, and overwrote 2\n\tBOOST_CHECK_EQUAL(matrix.nnz, 2);\n}\n\n// Test 3: Attempt to set an element outside the lower row bounds\nBOOST_AUTO_TEST_CASE(setElement_test3)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 0);\n\n\tcupcfd::error::eCodes status = matrix.setElement(-1, 0, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 4: Attempt to set an element outside the lower column bounds\nBOOST_AUTO_TEST_CASE(setElement_test4)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 0);\n\n\tcupcfd::error::eCodes status = matrix.setElement(0, -1, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// Test 5: Attempt to set an element outside the upper row bounds\nBOOST_AUTO_TEST_CASE(setElement_test5)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 0);\n\n\tcupcfd::error::eCodes status = matrix.setElement(2, 0, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 6: Attempt to set an element outside the upper column bounds\nBOOST_AUTO_TEST_CASE(setElement_test6)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 0);\n\n\tcupcfd::error::eCodes status = matrix.setElement(0, 2, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// Test 7: Overwrite non-existing zero entry with a non-zero base index\nBOOST_AUTO_TEST_CASE(setElement_test7)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 4);\n\n\tint elements[4] = {2, 4, 3, 20};\n\tint rows[4] = {4, 5, 4, 5};\n\tint columns[4] = {4, 5, 5, 4};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint rowsCmp[3] = {0, 2, 4};\n\tint colsCmp[4] = {4, 5, 4, 5};\n\tint valCmp[4] = {2, 3, 20, 4};\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.IA[0], &matrix.IA[0] + 3, rowsCmp, rowsCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.JA[0], &matrix.JA[0] + 4, colsCmp, colsCmp + 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.A[0], &matrix.A[0] + 4, valCmp, valCmp + 4);\n}\n\n// Test 8: Overwrite existing non-zero entry with a non-zero base matrix index\nBOOST_AUTO_TEST_CASE(setElement_test8)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 4);\n\n\t// Set the values such that (4, 4) = 20, (5, 4) = 3\n\t// but these are overwriting 2 and 4 respectively.\n\tint elements[4] = {2, 4, 3, 20};\n\tint rows[4] = {4, 5, 5, 4};\n\tint columns[4] = {4, 4, 4, 4};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint rowsCmp[3] = {0, 1, 2};\n\tint colsCmp[2] = {4, 4};\n\tint valCmp[2] = {20, 3};\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.IA[0], &matrix.IA[0] + 3, rowsCmp, rowsCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.JA[0], &matrix.JA[0] + 2, colsCmp, colsCmp + 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(&matrix.A[0], &matrix.A[0] + 2, valCmp, valCmp + 2);\n}\n\n// Test 9: Attempt to set an element outside the lower row bounds with a non-zero base matrix index\nBOOST_AUTO_TEST_CASE(setElement_test9)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 4);\n\n\tcupcfd::error::eCodes status = matrix.setElement(3, 4, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 10: Attempt to set an element outside the lower column bounds with a non-zero base matrix index\nBOOST_AUTO_TEST_CASE(setElement_test10)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 4);\n\n\tcupcfd::error::eCodes status = matrix.setElement(4, 3, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// Test 11: Attempt to set an element outside the upper row bounds with a non-zero base matrix index\nBOOST_AUTO_TEST_CASE(setElement_test11)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 4);\n\n\tcupcfd::error::eCodes status = matrix.setElement(6, 4, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 12: Attempt to set an element outside the upper column bounds with a non-zero base matrix index\nBOOST_AUTO_TEST_CASE(setElement_test12)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(2, 2, 4);\n\n\tcupcfd::error::eCodes status = matrix.setElement(4, 6, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// === getElement Tests ===\n// Test 1: Correctly get a value that is non-zero with a base index of 0\nBOOST_AUTO_TEST_CASE(getElement_test1)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\tint rows[4] = {0, 4, 6, 7};\n\tint columns[4] = {0, 1, 5, 3};\n\tint elements[4] = {2, 4, 3, 20};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint vals[4];\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.getElement(rows[i], columns[i], vals + i);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(vals, vals + 4, elements, elements + 4);\n}\n\n// Test 2: Correctly get a value that is not set (zero) with a base index of 0\nBOOST_AUTO_TEST_CASE(getElement_test2)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\tint rows[4] = {0, 4, 6, 7};\n\tint columns[4] = {0, 1, 5, 3};\n\tint elements[4] = {2, 4, 3, 20};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(3, 6, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(val, 0);\n}\n\n// Test 3: Catch the error case where we exceed the row bounds\n// of an index scheme where the base Index is 0\nBOOST_AUTO_TEST_CASE(getElement_test3)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(-1, 4, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 4: Catch the error case where we exceed the column bounds\n// of an index scheme where the base Index is 0\nBOOST_AUTO_TEST_CASE(getElement_test4)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(4, -1, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// Test 5: Catch the error case where we exceed the upper row bounds\n// of an index scheme where the base Index is 0\nBOOST_AUTO_TEST_CASE(getElement_test5)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(8, 4, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 6: Catch the error case where we exceed the upper column bounds\n// of an index scheme where the base Index is 0\nBOOST_AUTO_TEST_CASE(getElement_test6)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(4, 8, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// Test 7: Correctly get a value that is non-zero with a non-zero base-index\nBOOST_AUTO_TEST_CASE(getElement_test7)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 7);\n\n\tint rows[4] = {7, 11, 13, 14};\n\tint columns[4] = {7, 8, 12, 10};\n\tint elements[4] = {2, 4, 3, 20};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint vals[4];\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.getElement(rows[i], columns[i], vals + i);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(vals, vals + 4, elements, elements + 4);\n}\n\n// Test 8: Correctly set a value that is not set (zero) with a non-zero base-index\nBOOST_AUTO_TEST_CASE(getElement_test8)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 7);\n\n\tint rows[4] = {7, 11, 13, 14};\n\tint columns[4] = {7, 8, 12, 10};\n\tint elements[4] = {2, 4, 3, 20};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::error::eCodes status = matrix.setElement(rows[i], columns[i], elements[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(10, 13, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(val, 0);\n}\n\n// Test 9: Catch the error case where we exceed the lower row bounds\n// of an index scheme with a non-zero base-index\nBOOST_AUTO_TEST_CASE(getElement_test9)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 8);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(7, 9, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 10: Catch the error case where we exceed the lower column bounds\n// of an index scheme with a non-zero base-index\nBOOST_AUTO_TEST_CASE(getElement_test10)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 8);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(9, 7, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n\n// Test 11: Catch the error case where we exceed the upper row bounds\n// of an index scheme with a non-zero base-index\nBOOST_AUTO_TEST_CASE(getElement_test11)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 8);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(16, 9, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 12: Catch the error case where we exceed the upper column bounds\n// of an index scheme with a non-zero base-index\nBOOST_AUTO_TEST_CASE(getElement_test12)\n{\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 8);\n\n\tint val;\n\tcupcfd::error::eCodes status = matrix.getElement(9, 16, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_COL_OOB);\n}\n\n// === clear ===\n// Test 1: Check that the matrix vectors are cleared after calling clear\nBOOST_AUTO_TEST_CASE(clear_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 0);\n\n\t// Setup data so that there is at least two elements\n\tstatus = matrix.setElement(3, 4, 15);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(7, 7, 19);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.clear();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check sizes are 0\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(matrix.IA.size(), 9);\n\tBOOST_CHECK_EQUAL(matrix.JA.size(), 0);\n\tBOOST_CHECK_EQUAL(matrix.A.size(), 0);\n\n\t// Check that retrieving the previously set index now has a value of 0\n\tint val;\n\tstatus = matrix.getElement(3, 4, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(val, 0);\n}\n\n// === resize ===\n// Test 1: Check that an existing matrix resets to appropriate values after a resize\n// Data should also be cleared\nBOOST_AUTO_TEST_CASE(resize_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\t// Setup\n\tSparseMatrixCSR<int, int> matrix(8, 8, 2);\n\n\t// Setup data so that there is at least two elements\n\tstatus = matrix.setElement(4, 5, 15);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(8, 8, 19);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(matrix.m, 8);\n\tBOOST_CHECK_EQUAL(matrix.n, 8);\n\tBOOST_CHECK_EQUAL(matrix.nnz, 2);\n\n\t// Test and Check\n\tstatus = matrix.resize(4, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check that the values of m, n and nnz are reset\n\tBOOST_CHECK_EQUAL(matrix.m, 4);\n\tBOOST_CHECK_EQUAL(matrix.n, 4);\n\tBOOST_CHECK_EQUAL(matrix.nnz, 0);\n\n\t// Check that the baseIndex is still the same\n\tBOOST_CHECK_EQUAL(matrix.baseIndex, 2);\n\n\t// Check sizes are correct\n\tBOOST_CHECK_EQUAL(matrix.A.size(), 0);\n\tBOOST_CHECK_EQUAL(matrix.IA.size(), 5);\t// Rows + 1\n\tBOOST_CHECK_EQUAL(matrix.JA.size(), 0);\n\n\t// Check that retrieving the previously set index now has a value of 0\n\tint val;\n\tstatus = matrix.getElement(4, 5, &val);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(val, 0);\n}\n\n// === getNonZeroRowIndexes ===\n// Test 1: Get correct row indexes for rows with set values\nBOOST_AUTO_TEST_CASE(getNonZeroRowIndexes_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 0);\n\n\tstatus = matrix.setElement(0, 0, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(3, 1, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(0, 1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(3, 0, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * rowIndexes;\n\tint  nRowIndexes;\n\n\tstatus = matrix.getNonZeroRowIndexes(&rowIndexes, &nRowIndexes);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nRowIndexes, 2);\n\tBOOST_CHECK_EQUAL(rowIndexes[0], 0);\n\tBOOST_CHECK_EQUAL(rowIndexes[1], 3);\n\tfree(rowIndexes);\n}\n\n// === getRowColumnIndexes ===\n// Test 1: Get correct column indexes for a row\nBOOST_AUTO_TEST_CASE(getRowColumnIndexes_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 0);\n\n\tstatus = matrix.setElement(0, 3, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tstatus = matrix.setElement(0, 0, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tstatus = matrix.setElement(3, 1, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tstatus = matrix.setElement(3, 0, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tstatus = matrix.setElement(1, 1, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * colIndexes;\n\tint  nColIndexes;\n\n\tstatus = matrix.getRowColumnIndexes(0, &colIndexes, &nColIndexes);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nColIndexes, 2);\n\tBOOST_CHECK_EQUAL(colIndexes[0], 0);\n\tBOOST_CHECK_EQUAL(colIndexes[1], 3);\n\tfree(colIndexes);\n\n\tstatus = matrix.getRowColumnIndexes(1, &colIndexes, &nColIndexes);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nColIndexes, 1);\n\tBOOST_CHECK_EQUAL(colIndexes[0], 1);\n\tfree(colIndexes);\n\n\tstatus = matrix.getRowColumnIndexes(3, &colIndexes, &nColIndexes);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nColIndexes, 2);\n\tBOOST_CHECK_EQUAL(colIndexes[0], 0);\n\tBOOST_CHECK_EQUAL(colIndexes[1], 1);\n\tfree(colIndexes);\n}\n\n// Test 2: Check for error if row index is lower than matrix index range\nBOOST_AUTO_TEST_CASE(getRowColumnIndexes_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 3);\n\n\tstatus = matrix.setElement(3, 3, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * colIndexes;\n\tint  nColIndexes;\n\n\tstatus = matrix.getRowColumnIndexes(2, &colIndexes, &nColIndexes);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 3: Check for error if row index is higher than matrix index range\nBOOST_AUTO_TEST_CASE(getRowColumnIndexes_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 3);\n\n\tstatus = matrix.setElement(3, 3, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * colIndexes;\n\tint  nColIndexes;\n\n\tstatus = matrix.getRowColumnIndexes(8, &colIndexes, &nColIndexes);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// === getRowNNZValues ===\n// Test 1: Get correct values for a row\nBOOST_AUTO_TEST_CASE(getRowNNZValues_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 0);\n\n\tstatus = matrix.setElement(0, 3, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(0, 0, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(3, 1, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(3, 0, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = matrix.setElement(1, 1, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * nnzValues;\n\tint  nNNZValues;\n\n\tstatus = matrix.getRowNNZValues(0, &nnzValues, &nNNZValues);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nNNZValues, 2);\n\tBOOST_CHECK_EQUAL(nnzValues[0], 2);\n\tBOOST_CHECK_EQUAL(nnzValues[1], 3);\n\tfree(nnzValues);\n\n\tstatus = matrix.getRowNNZValues(1, &nnzValues, &nNNZValues);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nNNZValues, 1);\n\tBOOST_CHECK_EQUAL(nnzValues[0], 2);\n\tfree(nnzValues);\n\n\tstatus = matrix.getRowNNZValues(3, &nnzValues, &nNNZValues);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(nNNZValues, 2);\n\tBOOST_CHECK_EQUAL(nnzValues[0], 20);\n\tBOOST_CHECK_EQUAL(nnzValues[1], 4);\n\tfree(nnzValues);\n}\n\n\n// Test 2: Check for error if row index is lower than matrix index range\nBOOST_AUTO_TEST_CASE(getRowNNZValues_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 3);\n\n\tstatus = matrix.setElement(3, 3, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * nnzValues;\n\tint  nNNZValues;\n\n\tstatus = matrix.getRowNNZValues(2, &nnzValues, &nNNZValues);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n\n// Test 3: Check for error if row index is higher than matrix index range\nBOOST_AUTO_TEST_CASE(getRowNNZValues_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tSparseMatrixCSR<int, int> matrix(4, 4, 3);\n\n\tstatus = matrix.setElement(3, 3, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tint * nnzValues;\n\tint  nNNZValues;\n\n\tstatus = matrix.getRowNNZValues(8, &nnzValues, &nNNZValues);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MATRIX_ROW_OOB);\n}\n", "meta": {"hexsha": "5607fc034fc49ac4e94e9f1cb55eb52beae3124c", "size": 20591, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/data_structures/implementation/component/SparseMatrixCSRTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/data_structures/implementation/component/SparseMatrixCSRTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/data_structures/implementation/component/SparseMatrixCSRTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 28.5589459085, "max_line_length": 103, "alphanum_fraction": 0.7102617648, "num_tokens": 6480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.38121956625614994, "lm_q2_score": 0.17328820806405806, "lm_q1q2_score": 0.06606085551548568}}
{"text": "//  Copyright (c) 2011 David Bellot\r\n//\r\n//  Distributed under the Boost Software License, Version 1.0. (See\r\n//  accompanying file LICENSE_1_0.txt or copy at\r\n//  http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n#include <cmath>\r\n#include <boost/numeric/ublas/traits/const_iterator_type.hpp>\r\n#include <boost/numeric/ublas/traits/iterator_type.hpp>\r\n#include <boost/numeric/ublas/traits/c_array.hpp>\r\n#include <boost/numeric/ublas/fwd.hpp>\r\n#include <boost/numeric/ublas/matrix.hpp>\r\n#include <boost/numeric/ublas/matrix_expression.hpp>\r\n#include <boost/numeric/ublas/operation/begin.hpp>\r\n#include <boost/numeric/ublas/operation/end.hpp>\r\n#include <boost/numeric/ublas/tags.hpp>\r\n#include <boost/numeric/ublas/vector.hpp>\r\n#include <boost/numeric/ublas/vector_expression.hpp>\r\n#include <iostream>\r\n#include \"utils.hpp\"\r\n\r\n\r\nstatic const double TOL(1.0e-5); ///< Used for comparing two real numbers.\r\n\r\n#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION\r\n#error \"sorry this feature is not supported by your compiler\"\r\n#endif\r\n\r\nBOOST_UBLAS_TEST_DEF( test_vector_iteration )\r\n{\r\n    BOOST_UBLAS_DEBUG_TRACE( \"TEST Vector Iteration\" );\r\n\r\n    typedef double value_type;\r\n    typedef boost::numeric::ublas::vector<value_type> vector_type;\r\n\r\n    vector_type v(5);\r\n\r\n    v(0) = 0.555950;\r\n    v(1) = 0.108929;\r\n    v(2) = 0.948014;\r\n    v(3) = 0.023787;\r\n    v(4) = 1.023787;\r\n\r\n\r\n    vector_type::size_type ix = 0;\r\n    for (\r\n            boost::numeric::ublas::iterator_type<vector_type>::type it = boost::numeric::ublas::begin<vector_type>(v);\r\n            it != boost::numeric::ublas::end<vector_type>(v);\r\n            ++it\r\n    ) {\r\n        BOOST_UBLAS_DEBUG_TRACE( \"*it = \" << *it << \" ==> \" << v(ix) );\r\n        BOOST_UBLAS_TEST_CHECK( std::abs(*it - v(ix)) <= TOL );\r\n        ++ix;\r\n    }\r\n}\r\n\r\n\r\nBOOST_UBLAS_TEST_DEF( test_vector_const_iteration )\r\n{\r\n    BOOST_UBLAS_DEBUG_TRACE( \"TEST Vector Const Iteration\" );\r\n\r\n    typedef double value_type;\r\n    typedef boost::numeric::ublas::vector<value_type> vector_type;\r\n\r\n    vector_type v(5);\r\n\r\n    v(0) = 0.555950;\r\n    v(1) = 0.108929;\r\n    v(2) = 0.948014;\r\n    v(3) = 0.023787;\r\n    v(4) = 1.023787;\r\n\r\n\r\n    vector_type::size_type ix = 0;\r\n    for (\r\n            boost::numeric::ublas::const_iterator_type<vector_type>::type it = boost::numeric::ublas::begin<vector_type>(v);\r\n            it != boost::numeric::ublas::end<vector_type>(v);\r\n            ++it\r\n    ) {\r\n        BOOST_UBLAS_DEBUG_TRACE( \"*it = \" << *it << \" ==> \" << v(ix) );\r\n        BOOST_UBLAS_TEST_CHECK( std::abs(*it - v(ix)) <= TOL );\r\n        ++ix;\r\n    }\r\n}\r\n\r\n\r\nBOOST_UBLAS_TEST_DEF( test_row_major_matrix_iteration )\r\n{\r\n    BOOST_UBLAS_DEBUG_TRACE( \"TEST Row-major Matrix Iteration\" );\r\n\r\n    typedef double value_type;\r\n    typedef boost::numeric::ublas::matrix<value_type, boost::numeric::ublas::row_major> matrix_type;\r\n    typedef boost::numeric::ublas::iterator_type<matrix_type, boost::numeric::ublas::tag::major>::type outer_iterator_type;\r\n    typedef boost::numeric::ublas::iterator_type<matrix_type, boost::numeric::ublas::tag::minor>::type inner_iterator_type;\r\n\r\n    matrix_type A(5,4);\r\n\r\n    A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938;\r\n    A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283;\r\n    A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152;\r\n    A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332;\r\n    A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332;\r\n\r\n\r\n    matrix_type::size_type row(0);\r\n    for (\r\n            outer_iterator_type outer_it = boost::numeric::ublas::begin<boost::numeric::ublas::tag::major>(A);\r\n            outer_it != boost::numeric::ublas::end<boost::numeric::ublas::tag::major>(A);\r\n            ++outer_it\r\n    ) {\r\n        matrix_type::size_type col(0);\r\n\r\n        for (\r\n                inner_iterator_type inner_it = boost::numeric::ublas::begin(outer_it);\r\n                inner_it != boost::numeric::ublas::end(outer_it);\r\n                ++inner_it\r\n        ) {\r\n            BOOST_UBLAS_DEBUG_TRACE( \"*it = \" << *inner_it << \" ==> \" << A(row,col) );\r\n            BOOST_UBLAS_TEST_CHECK( std::abs(*inner_it - A(row,col)) <= TOL );\r\n\r\n            ++col;\r\n        }\r\n\r\n        ++row;\r\n    }\r\n}\r\n\r\n\r\nBOOST_UBLAS_TEST_DEF( test_col_major_matrix_iteration )\r\n{\r\n    BOOST_UBLAS_DEBUG_TRACE( \"TEST Column-major Matrix Iteration\" );\r\n\r\n    typedef double value_type;\r\n    typedef boost::numeric::ublas::matrix<value_type, boost::numeric::ublas::column_major> matrix_type;\r\n    typedef boost::numeric::ublas::iterator_type<matrix_type, boost::numeric::ublas::tag::major>::type outer_iterator_type;\r\n    typedef boost::numeric::ublas::iterator_type<matrix_type, boost::numeric::ublas::tag::minor>::type inner_iterator_type;\r\n\r\n    matrix_type A(5,4);\r\n\r\n    A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938;\r\n    A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283;\r\n    A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152;\r\n    A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332;\r\n    A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332;\r\n\r\n\r\n    matrix_type::size_type col(0);\r\n    for (\r\n            outer_iterator_type outer_it = boost::numeric::ublas::begin<boost::numeric::ublas::tag::major>(A);\r\n            outer_it != boost::numeric::ublas::end<boost::numeric::ublas::tag::major>(A);\r\n            ++outer_it\r\n    ) {\r\n        matrix_type::size_type row(0);\r\n\r\n        for (\r\n                inner_iterator_type inner_it = boost::numeric::ublas::begin(outer_it);\r\n                inner_it != boost::numeric::ublas::end(outer_it);\r\n                ++inner_it\r\n        ) {\r\n            BOOST_UBLAS_DEBUG_TRACE( \"*it = \" << *inner_it << \" ==> \" << A(row,col) );\r\n            BOOST_UBLAS_TEST_CHECK( std::abs(*inner_it - A(row,col)) <= TOL );\r\n\r\n            ++row;\r\n        }\r\n\r\n        ++col;\r\n    }\r\n}\r\n\r\n\r\nint main()\r\n{\r\n    BOOST_UBLAS_TEST_BEGIN();\r\n\r\n    BOOST_UBLAS_TEST_DO( test_vector_iteration );\r\n    BOOST_UBLAS_TEST_DO( test_vector_const_iteration );\r\n    BOOST_UBLAS_TEST_DO( test_row_major_matrix_iteration );\r\n    BOOST_UBLAS_TEST_DO( test_col_major_matrix_iteration );\r\n\r\n    BOOST_UBLAS_TEST_END();\r\n}\r\n", "meta": {"hexsha": "3bc859a5d26b573a142c103f242accbbb2dbce75", "size": 6338, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/ublas/test/begin_end.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/ublas/test/begin_end.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/ublas/test/begin_end.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 34.8241758242, "max_line_length": 125, "alphanum_fraction": 0.6088671505, "num_tokens": 1995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48438008427698437, "lm_q2_score": 0.13477592784882603, "lm_q1q2_score": 0.06528277528992311}}
{"text": "// (C) Copyright 2007-2009 Andrew Sutton\n//\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0 (See accompanying file\n// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)\n\n#ifndef BOOST_GRAPH_CLIQUE_HPP\n#define BOOST_GRAPH_CLIQUE_HPP\n\n#include <vector>\n#include <deque>\n#include <boost/config.hpp>\n\n#include <boost/graph/graph_concepts.hpp>\n#include <boost/graph/lookup_edge.hpp>\n\n#include <boost/concept/detail/concept_def.hpp>\nnamespace boost {\n    namespace concepts {\n        BOOST_concept(CliqueVisitor,(Visitor)(Clique)(Graph))\n        {\n            BOOST_CONCEPT_USAGE(CliqueVisitor)\n            {\n                vis.clique(k, g);\n            }\n        private:\n            Visitor vis;\n            Graph g;\n            Clique k;\n        };\n    } /* namespace concepts */\nusing concepts::CliqueVisitorConcept;\n} /* namespace boost */\n#include <boost/concept/detail/concept_undef.hpp>\n\nnamespace boost\n{\n// The algorithm implemented in this paper is based on the so-called\n// Algorithm 457, published as:\n//\n//     @article{362367,\n//         author = {Coen Bron and Joep Kerbosch},\n//         title = {Algorithm 457: finding all cliques of an undirected graph},\n//         journal = {Communications of the ACM},\n//         volume = {16},\n//         number = {9},\n//         year = {1973},\n//         issn = {0001-0782},\n//         pages = {575--577},\n//         doi = {http://doi.acm.org/10.1145/362342.362367},\n//             publisher = {ACM Press},\n//             address = {New York, NY, USA},\n//         }\n//\n// Sort of. This implementation is adapted from the 1st version of the\n// algorithm and does not implement the candidate selection optimization\n// described as published - it could, it just doesn't yet.\n//\n// The algorithm is given as proportional to (3.14)^(n/3) power. This is\n// not the same as O(...), but based on time measures and approximation.\n//\n// Unfortunately, this implementation may be less efficient on non-\n// AdjacencyMatrix modeled graphs due to the non-constant implementation\n// of the edge(u,v,g) functions.\n//\n// TODO: It might be worthwhile to provide functionality for passing\n// a connectivity matrix to improve the efficiency of those lookups\n// when needed. This could simply be passed as a BooleanMatrix\n// s.t. edge(u,v,B) returns true or false. This could easily be\n// abstracted for adjacency matricies.\n//\n// The following paper is interesting for a number of reasons. First,\n// it lists a number of other such algorithms and second, it describes\n// a new algorithm (that does not appear to require the edge(u,v,g)\n// function and appears fairly efficient. It is probably worth investigating.\n//\n//      @article{DBLP:journals/tcs/TomitaTT06,\n//          author = {Etsuji Tomita and Akira Tanaka and Haruhisa Takahashi},\n//          title = {The worst-case time complexity for generating all maximal cliques and computational experiments},\n//          journal = {Theor. Comput. Sci.},\n//          volume = {363},\n//          number = {1},\n//          year = {2006},\n//          pages = {28-42}\n//          ee = {http://dx.doi.org/10.1016/j.tcs.2006.06.015}\n//      }\n\n/**\n * The default clique_visitor supplies an empty visitation function.\n */\nstruct clique_visitor\n{\n    template <typename VertexSet, typename Graph>\n    void clique(const VertexSet&, Graph&)\n    { }\n};\n\n/**\n * The max_clique_visitor records the size of the maximum clique (but not the\n * clique itself).\n */\nstruct max_clique_visitor\n{\n    max_clique_visitor(std::size_t& max)\n        : maximum(max)\n    { }\n\n    template <typename Clique, typename Graph>\n    inline void clique(const Clique& p, const Graph& g)\n    {\n        BOOST_USING_STD_MAX();\n        maximum = max BOOST_PREVENT_MACRO_SUBSTITUTION (maximum, p.size());\n    }\n    std::size_t& maximum;\n};\n\ninline max_clique_visitor find_max_clique(std::size_t& max)\n{ return max_clique_visitor(max); }\n\nnamespace detail\n{\n    template <typename Graph>\n    inline bool\n    is_connected_to_clique(const Graph& g,\n                            typename graph_traits<Graph>::vertex_descriptor u,\n                            typename graph_traits<Graph>::vertex_descriptor v,\n                            typename graph_traits<Graph>::undirected_category)\n    {\n        return lookup_edge(u, v, g).second;\n    }\n\n    template <typename Graph>\n    inline bool\n    is_connected_to_clique(const Graph& g,\n                            typename graph_traits<Graph>::vertex_descriptor u,\n                            typename graph_traits<Graph>::vertex_descriptor v,\n                            typename graph_traits<Graph>::directed_category)\n    {\n        // Note that this could alternate between using an || to determine\n        // full connectivity. I believe that this should produce strongly\n        // connected components. Note that using && instead of || will\n        // change the results to a fully connected subgraph (i.e., symmetric\n        // edges between all vertices s.t., if a->b, then b->a.\n        return lookup_edge(u, v, g).second && lookup_edge(v, u, g).second;\n    }\n\n    template <typename Graph, typename Container>\n    inline void\n    filter_unconnected_vertices(const Graph& g,\n                                typename graph_traits<Graph>::vertex_descriptor v,\n                                const Container& in,\n                                Container& out)\n    {\n        function_requires< GraphConcept<Graph> >();\n\n        typename graph_traits<Graph>::directed_category cat;\n        typename Container::const_iterator i, end = in.end();\n        for(i = in.begin(); i != end; ++i) {\n            if(is_connected_to_clique(g, v, *i, cat)) {\n                out.push_back(*i);\n            }\n        }\n    }\n\n    template <\n        typename Graph,\n        typename Clique,        // compsub type\n        typename Container,     // candidates/not type\n        typename Visitor>\n    void extend_clique(const Graph& g,\n                        Clique& clique,\n                        Container& cands,\n                        Container& nots,\n                        Visitor vis,\n                        std::size_t min)\n    {\n        function_requires< GraphConcept<Graph> >();\n        function_requires< CliqueVisitorConcept<Visitor,Clique,Graph> >();\n        typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\n\n        // Is there vertex in nots that is connected to all vertices\n        // in the candidate set? If so, no clique can ever be found.\n        // This could be broken out into a separate function.\n        {\n            typename Container::iterator ni, nend = nots.end();\n            typename Container::iterator ci, cend = cands.end();\n            for(ni = nots.begin(); ni != nend; ++ni) {\n                for(ci = cands.begin(); ci != cend; ++ci) {\n                    // if we don't find an edge, then we're okay.\n                    if(!lookup_edge(*ni, *ci, g).second) break;\n                }\n                // if we iterated all the way to the end, then *ni\n                // is connected to all *ci\n                if(ci == cend) break;\n            }\n            // if we broke early, we found *ni connected to all *ci\n            if(ni != nend) return;\n        }\n\n        // TODO: the original algorithm 457 describes an alternative\n        // (albeit really complicated) mechanism for selecting candidates.\n        // The given optimizaiton seeks to bring about the above\n        // condition sooner (i.e., there is a vertex in the not set\n        // that is connected to all candidates). unfortunately, the\n        // method they give for doing this is fairly unclear.\n\n        // basically, for every vertex in not, we should know how many\n        // vertices it is disconnected from in the candidate set. if\n        // we fix some vertex in the not set, then we want to keep\n        // choosing vertices that are not connected to that fixed vertex.\n        // apparently, by selecting fix point with the minimum number\n        // of disconnections (i.e., the maximum number of connections\n        // within the candidate set), then the previous condition wil\n        // be reached sooner.\n\n        // there's some other stuff about using the number of disconnects\n        // as a counter, but i'm jot really sure i followed it.\n\n        // TODO: If we min-sized cliques to visit, then theoretically, we\n        // should be able to stop recursing if the clique falls below that\n        // size - maybe?\n\n        // otherwise, iterate over candidates and and test\n        // for maxmimal cliquiness.\n        typename Container::iterator i, j, end = cands.end();\n        for(i = cands.begin(); i != cands.end(); ) {\n            Vertex candidate = *i;\n\n            // add the candidate to the clique (keeping the iterator!)\n            // typename Clique::iterator ci = clique.insert(clique.end(), candidate);\n            clique.push_back(candidate);\n\n            // remove it from the candidate set\n            i = cands.erase(i);\n\n            // build new candidate and not sets by removing all vertices\n            // that are not connected to the current candidate vertex.\n            // these actually invert the operation, adding them to the new\n            // sets if the vertices are connected. its semantically the same.\n            Container new_cands, new_nots;\n            filter_unconnected_vertices(g, candidate, cands, new_cands);\n            filter_unconnected_vertices(g, candidate, nots, new_nots);\n\n            if(new_cands.empty() && new_nots.empty()) {\n                // our current clique is maximal since there's nothing\n                // that's connected that we haven't already visited. If\n                // the clique is below our radar, then we won't visit it.\n                if(clique.size() >= min) {\n                    vis.clique(clique, g);\n                }\n            }\n            else {\n                // recurse to explore the new candidates\n                extend_clique(g, clique, new_cands, new_nots, vis, min);\n            }\n\n            // we're done with this vertex, so we need to move it\n            // to the nots, and remove the candidate from the clique.\n            nots.push_back(candidate);\n            clique.pop_back();\n        }\n    }\n} /* namespace detail */\n\ntemplate <typename Graph, typename Visitor>\ninline void\nbron_kerbosch_all_cliques(const Graph& g, Visitor vis, std::size_t min)\n{\n    function_requires< IncidenceGraphConcept<Graph> >();\n    function_requires< VertexListGraphConcept<Graph> >();\n    function_requires< VertexIndexGraphConcept<Graph> >();\n    function_requires< AdjacencyMatrixConcept<Graph> >(); // Structural requirement only\n    typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\n    typedef typename graph_traits<Graph>::vertex_iterator VertexIterator;\n    typedef std::vector<Vertex> VertexSet;\n    typedef std::deque<Vertex> Clique;\n    function_requires< CliqueVisitorConcept<Visitor,Clique,Graph> >();\n\n    // NOTE: We're using a deque to implement the clique, because it provides\n    // constant inserts and removals at the end and also a constant size.\n\n    VertexIterator i, end;\n    tie(i, end) = vertices(g);\n    VertexSet cands(i, end);    // start with all vertices as candidates\n    VertexSet nots;             // start with no vertices visited\n\n    Clique clique;              // the first clique is an empty vertex set\n    detail::extend_clique(g, clique, cands, nots, vis, min);\n}\n\n// NOTE: By default the minimum number of vertices per clique is set at 2\n// because singleton cliques aren't really very interesting.\ntemplate <typename Graph, typename Visitor>\ninline void\nbron_kerbosch_all_cliques(const Graph& g, Visitor vis)\n{ bron_kerbosch_all_cliques(g, vis, 2); }\n\ntemplate <typename Graph>\ninline std::size_t\nbron_kerbosch_clique_number(const Graph& g)\n{\n    std::size_t ret = 0;\n    bron_kerbosch_all_cliques(g, find_max_clique(ret));\n    return ret;\n}\n\n} /* namespace boost */\n\n#endif\n", "meta": {"hexsha": "f6d253b1a26684d685ed5953e65da541cabc7baf", "size": 11997, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/graph/bron_kerbosch_all_cliques.hpp", "max_stars_repo_name": "oudream/boost_1_42_0", "max_stars_repo_head_hexsha": "e92227bf374e478030e89876ec353de6eecaeac0", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2017-04-08T10:44:28.000Z", "max_stars_repo_stars_event_max_datetime": "2017-04-08T10:44:28.000Z", "max_issues_repo_path": "boost/graph/bron_kerbosch_all_cliques.hpp", "max_issues_repo_name": "jonstewart/boost-svn", "max_issues_repo_head_hexsha": "7f6dc0c0cb807b28072c7bdd3d77bb01ab290c59", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "boost/graph/bron_kerbosch_all_cliques.hpp", "max_forks_repo_name": "jonstewart/boost-svn", "max_forks_repo_head_hexsha": "7f6dc0c0cb807b28072c7bdd3d77bb01ab290c59", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7, "max_line_length": 118, "alphanum_fraction": 0.6229057264, "num_tokens": 2672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4960938294709195, "lm_q2_score": 0.13117321187415154, "lm_q1q2_score": 0.06507422100264813}}
{"text": "/*! \\file demo_1d_simple.cpp\n    \\brief Example of a simple 1D plot of two vectors of data.\n    \\details Creates file demo_1d_simple.svg\n    \\author Jacob Voytko and Paul A. Bristow\n    \\date 2007\n  */\n\n// Copyright Jacob Voytko 2007\n// Copyright Paul A. Bristow 2009\n\n// Distributed under the Boost Software License, Version 1.0.\n// For more information, see http://www.boost.org\n\n// An example to demonstrate very simple 1D settings.\n// See also demo_1d_plot.cpp for a wider range of use.\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[demo_1d_simple_1\n\n/*`First we need a few includes to use Boost.Plot, and an STL 1D container vector.\n*/\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\nusing namespace boost::svg;\n\n#include <vector>\nusing std::vector;\n\nint main()\n{ // Construct two STL containers for the two data series to plot.\n  vector<double> dan_times;\n  vector<double> elaine_times;\n\n  // Fill the two containers with some data:\n  dan_times.push_back(3.1);\n  dan_times.push_back(4.2);\n  elaine_times.push_back(2.1);\n  elaine_times.push_back(7.8);\n\n  svg_1d_plot my_plot; // Construct a plot.\n\n  my_plot.legend_on(true) // Set title and legend, and X-axis range and label.\n         .title(\"Race Times\")\n         .x_label(\"time (sec)\")\n         .x_range(-1, 11);\n  // There are hundreds of other possible options here!\n\n  // Add the two containers of data to the plot, choosing two different colors.\n  my_plot.plot(dan_times, \"Dan\").stroke_color(blue);\n  my_plot.plot(elaine_times, \"Elaine\").stroke_color(orange);\n\n  my_plot.write(\"./demo_1d_simple.svg\"); // Finally write the plot to a file.\n\n  return 0;\n} // int main()\n\n//] [/demo_1d_simple_1]\n\n\n", "meta": {"hexsha": "552f061067b28e55231f9720792f7865f2b653cf", "size": 1949, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_1d_simple.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_1d_simple.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_1d_simple.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 29.5303030303, "max_line_length": 82, "alphanum_fraction": 0.7147255003, "num_tokens": 526, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4111108836623764, "lm_q2_score": 0.15817435671676675, "lm_q1q2_score": 0.06502719956255792}}
{"text": "// Copyright (c) 2018-2019, University of Bremen, M. Farzalipour Tabriz\r\n// Copyrights licensed under the 2-Clause BSD License.\r\n// See the accompanying LICENSE.txt file for terms.\r\n\r\n#pragma once\r\n#include <armadillo>\r\n#include <iomanip>\r\n#include <iostream>\r\n\r\nusing namespace std;\r\nusing namespace arma;\r\n\r\n\r\n//single-line output for vec\r\ntemplate<typename T>\r\nostream &operator << (ostream &o, const Row<T> &vec) {\r\n\tfor (uword elem = 0; elem < vec.n_elem; ++elem) {\r\n\t\to << vec(elem);\r\n\t\tif (elem != vec.n_elem - 1) {\r\n\t\t\to << \" \";\r\n\t\t}\r\n\t}\r\n\treturn o;\r\n}\r\n\r\ntemplate<typename T>\r\nostream &operator << (ostream &o, const subview<T> &vec) {\r\n\tfor (uword elem = 0; elem < vec.n_elem; ++elem) {\r\n\t\to << vec(elem);\r\n\t\tif (elem != vec.n_elem - 1) {\r\n\t\t\to  << \" \";\r\n\t\t}\r\n\t}\r\n\r\n\treturn o;\r\n}\r\n\r\n//single-line output for mat\r\ntemplate<typename T>\r\nostream &operator << (ostream &o, const Mat<T> &mat) {\r\n\tmat.each_row([&o](const Row<T> &row) { o << row << \"; \"; });\r\n\treturn o;\r\n}\r\n\r\ntemplate<typename T>\r\nistream &operator >> (istream &o, Row<T> &vec) {\r\n\tvec.for_each([&o](T &elem) { o >> elem; });\r\n\treturn o;\r\n}\r\n\r\ntemplate<typename T>\r\nistream &operator >> (istream &o, subview_row<T> vec) {\r\n\tvec.for_each([&o](T &elem) { o >> elem; });\r\n\treturn o;\r\n}\r\n\r\ntemplate<typename T>\r\nistream &operator >> (istream &o, Cube<T> &c) {\r\n\tc.for_each([&o](T &elem) { o >> elem; });\r\n\treturn o;\r\n}\r\n\r\ntemplate<typename T>\r\nistream &operator >> (istream &o, Mat<T> &m) {\r\n\tm.for_each([&o](T &elem) { o >> elem; });\r\n\treturn o;\r\n}\r\n\r\ntemplate <typename T>\r\nstring to_string(T input) {\r\n\tostringstream output;\r\n\toutput << setprecision(15);\r\n\toutput << input;\r\n\treturn output.str();\r\n}\r\n\r\n\r\n", "meta": {"hexsha": "bda4573dccad64418b5eb6b57eb0ed8414982bcb", "size": 1676, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/arma_io.hpp", "max_stars_repo_name": "Anower120/slabcc", "max_stars_repo_head_hexsha": "8b8d17224314ad4c37c6c57d3c613592572870f8", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-09-02T01:11:56.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-02T01:11:56.000Z", "max_issues_repo_path": "src/arma_io.hpp", "max_issues_repo_name": "Anower120/slabcc", "max_issues_repo_head_hexsha": "8b8d17224314ad4c37c6c57d3c613592572870f8", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/arma_io.hpp", "max_forks_repo_name": "Anower120/slabcc", "max_forks_repo_head_hexsha": "8b8d17224314ad4c37c6c57d3c613592572870f8", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.4871794872, "max_line_length": 72, "alphanum_fraction": 0.5954653938, "num_tokens": 475, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4571367168274948, "lm_q2_score": 0.1422318986458388, "lm_q1q2_score": 0.06501942317509975}}
{"text": "\n\n/* --------------------------------------------------------------------- \n * \n * Copyright (C) 2013 - 2021 by the deal.II authors \n * \n * This file is part of the deal.II library. \n * \n * The deal.II library is free software; you can use it, redistribute \n * it, and/or modify it under the terms of the GNU Lesser General \n * Public License as published by the Free Software Foundation; either \n * version 2.1 of the License, or (at your option) any later version. \n * The full text of the license can be found in the file LICENSE.md at \n * the top level directory of deal.II. \n * \n * --------------------------------------------------------------------- \n * \n * Author: Timo Heister, Texas A&M University, 2013 \n */ \n\n\n\n// \u8fd9\u4e2a\u6559\u7a0b\u7a0b\u5e8f\u5f88\u5947\u602a\uff0c\u4e0e\u5176\u4ed6\u5927\u591a\u6570\u6b65\u9aa4\u4e0d\u540c\uff0c\u4ecb\u7ecd\u4e2d\u5df2\u7ecf\u63d0\u4f9b\u4e86\u5173\u4e8e\u5982\u4f55\u4f7f\u7528\u5404\u79cd\u7b56\u7565\u6765\u751f\u6210\u7f51\u683c\u7684\u5927\u90e8\u5206\u4fe1\u606f\u3002\u56e0\u6b64\uff0c\u8fd9\u91cc\u6ca1\u6709\u4ec0\u4e48\u9700\u8981\u8bc4\u8bba\u7684\uff0c\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u7a7f\u63d2\u4e86\u76f8\u5bf9\u8f83\u5c11\u7684\u6587\u5b57\u3002\u4ece\u672c\u8d28\u4e0a\u8bb2\uff0c\u8fd9\u91cc\u7684\u4ee3\u7801\u53ea\u662f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5728\u4ecb\u7ecd\u4e2d\u5df2\u7ecf\u63cf\u8ff0\u8fc7\u7684\u5185\u5bb9\u7684\u53c2\u8003\u5b9e\u73b0\u3002\n\n//  @sect3{Include files}  \n#include <deal.II/grid/tria.h> \n#include <deal.II/grid/grid_generator.h> \n#include <deal.II/grid/grid_tools.h> \n#include <deal.II/grid/manifold_lib.h> \n#include <deal.II/grid/grid_out.h> \n#include <deal.II/grid/grid_in.h> \n\n#include <iostream> \n#include <fstream> \n\n#include <map> \n\nusing namespace dealii; \n// @sect3{Generating output for a given mesh}  \n\n// \u4e0b\u9762\u7684\u51fd\u6570\u4e3a\u6211\u4eec\u5c06\u5728\u672c\u7a0b\u5e8f\u7684\u5269\u4f59\u90e8\u5206\u4e2d\u751f\u6210\u7684\u4efb\u4f55\u7f51\u683c\u751f\u6210\u4e00\u4e9b\u8f93\u51fa\u3002\u7279\u522b\u662f\uff0c\u5b83\u751f\u6210\u4e86\u4ee5\u4e0b\u4fe1\u606f\u3002\n\n\n\n// - \u4e00\u4e9b\u5173\u4e8e\u8fd9\u4e2a\u7f51\u683c\u6240\u5904\u7684\u7a7a\u95f4\u7ef4\u6570\u548c\u5b83\u7684\u5355\u5143\u6570\u7684\u4e00\u822c\u4fe1\u606f\u3002\n\n// - \u4f7f\u7528\u6bcf\u4e2a\u8fb9\u754c\u6307\u6807\u7684\u8fb9\u754c\u9762\u7684\u6570\u91cf\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u548c\u6211\u4eec\u9884\u671f\u7684\u60c5\u51b5\u8fdb\u884c\u6bd4\u8f83\u3002\n\n// \u6700\u540e\uff0c\u8be5\u51fd\u6570\u5c06\u7f51\u683c\u8f93\u51fa\u4e3aVTU\u683c\u5f0f\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728Paraview\u6216VisIt\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u3002\n\ntemplate <int dim> \nvoid print_mesh_info(const Triangulation<dim> &triangulation, \n                     const std::string &       filename) \n{ \n  std::cout << \"Mesh info:\" << std::endl \n            << \" dimension: \" << dim << std::endl \n            << \" no. of cells: \" << triangulation.n_active_cells() << std::endl; \n\n// \u63a5\u4e0b\u6765\u5faa\u73af\u6240\u6709\u5355\u5143\u683c\u7684\u6240\u6709\u9762\uff0c\u627e\u51fa\u6bcf\u4e2a\u8fb9\u754c\u6307\u6807\u7684\u4f7f\u7528\u9891\u7387\uff08\u8bf7\u8bb0\u4f4f\uff0c\u5982\u679c\u4f60\u8bbf\u95ee\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684 std::map \u5bf9\u8c61\u7684\u5143\u7d20\uff0c\u5b83\u5c06\u88ab\u9690\u5f0f\u521b\u5efa\u5e76\u9ed8\u8ba4\u521d\u59cb\u5316--\u5728\u5f53\u524d\u60c5\u51b5\u4e0b\u4e3a\u96f6--\u7136\u540e\u6211\u4eec\u518d\u5c06\u5176\u589e\u52a0\uff09\u3002\n\n  { \n    std::map<types::boundary_id, unsigned int> boundary_count; \n    for (const auto &face : triangulation.active_face_iterators()) \n      if (face->at_boundary()) \n        boundary_count[face->boundary_id()]++; \n\n    std::cout << \" boundary indicators: \"; \n    for (const std::pair<const types::boundary_id, unsigned int> &pair : \n         boundary_count) \n      { \n        std::cout << pair.first << \"(\" << pair.second << \" times) \"; \n      } \n    std::cout << std::endl; \n  } \n\n// \u6700\u540e\uff0c\u4ea7\u751f\u4e00\u4e2a\u7f51\u683c\u7684\u56fe\u5f62\u8868\u793a\u5230\u4e00\u4e2a\u8f93\u51fa\u6587\u4ef6\u3002\n\n  std::ofstream out(filename); \n  GridOut       grid_out; \n  grid_out.write_vtu(triangulation, out); \n  std::cout << \" written to \" << filename << std::endl << std::endl; \n} \n// @sect3{Main routines}  \n// @sect4{grid_1: Loading a mesh generated by gmsh}  \n\n// \u5728\u8fd9\u7b2c\u4e00\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c55\u793a\u4e86\u5982\u4f55\u52a0\u8f7d\u6211\u4eec\u5728\u4ecb\u7ecd\u4e2d\u8ba8\u8bba\u8fc7\u7684\u5982\u4f55\u751f\u6210\u7684\u7f51\u683c\u3002\u8fd9\u4e0e step-5 \u4e2d\u52a0\u8f7d\u7f51\u683c\u7684\u6a21\u5f0f\u76f8\u540c\uff0c\u5c3d\u7ba1\u90a3\u91cc\u662f\u4ee5\u4e0d\u540c\u7684\u6587\u4ef6\u683c\u5f0f\uff08UCD\u800c\u4e0d\u662fMSH\uff09\u7f16\u5199\u3002\n\nvoid grid_1() \n{ \n  Triangulation<2> triangulation; \n\n  GridIn<2> gridin; \n  gridin.attach_triangulation(triangulation); \n  std::ifstream f(\"example.msh\"); \n  gridin.read_msh(f); \n\n  print_mesh_info(triangulation, \"grid-1.vtu\"); \n} \n// @sect4{grid_2: Merging triangulations}  \n\n// \u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e24\u4e2a\u4e09\u89d2\u5f62\uff0c\u7136\u540e\u5c06\u5b83\u4eec\u5408\u5e76\u6210\u4e00\u4e2a\u3002 \u6b63\u5982\u4ecb\u7ecd\u4e2d\u6240\u8ba8\u8bba\u7684\uff0c\u5fc5\u987b\u786e\u4fdd\u5171\u540c\u754c\u9762\u7684\u9876\u70b9\u4f4d\u4e8e\u76f8\u540c\u7684\u5750\u6807\u4e0a\u3002\n\nvoid grid_2() \n{ \n  Triangulation<2> tria1; \n  GridGenerator::hyper_cube_with_cylindrical_hole(tria1, 0.25, 1.0); \n\n  Triangulation<2>          tria2; \n  std::vector<unsigned int> repetitions(2); \n  repetitions[0] = 3; \n  repetitions[1] = 2; \n  GridGenerator::subdivided_hyper_rectangle(tria2, \n                                            repetitions, \n                                            Point<2>(1.0, -1.0), \n                                            Point<2>(4.0, 1.0)); \n\n  Triangulation<2> triangulation; \n  GridGenerator::merge_triangulations(tria1, tria2, triangulation); \n\n  print_mesh_info(triangulation, \"grid-2.vtu\"); \n} \n// @sect4{grid_3: Moving vertices}  \n\n// \u5728\u8fd9\u4e2a\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u79fb\u52a8\u4e00\u4e2a\u7f51\u683c\u7684\u9876\u70b9\u3002\u8fd9\u6bd4\u4eba\u4eec\u901a\u5e38\u60f3\u8c61\u7684\u8981\u7b80\u5355\uff1a\u5982\u679c\u4f60\u7528 <code>cell-@>vertex(i)</code> \u8be2\u95ee\u4e00\u4e2a\u5355\u5143\u683c\u7684 <code>i</code> \u7684\u9876\u70b9\u7684\u5750\u6807\uff0c\u5b83\u4e0d\u53ea\u662f\u63d0\u4f9b\u8fd9\u4e2a\u9876\u70b9\u7684\u4f4d\u7f6e\uff0c\u5b9e\u9645\u4e0a\u662f\u5bf9\u5b58\u50a8\u8fd9\u4e9b\u5750\u6807\u7684\u4f4d\u7f6e\u7684\u5f15\u7528\u3002\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u4fee\u6539\u5b58\u50a8\u5728\u90a3\u91cc\u7684\u503c\u3002\n\n// \u6240\u4ee5\u8fd9\u5c31\u662f\u6211\u4eec\u5728\u8fd9\u4e2a\u51fd\u6570\u7684\u7b2c\u4e00\u90e8\u5206\u6240\u505a\u7684\u3002\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u51e0\u4f55\u5f62\u72b6\u4e3a $[-1,1]^2$ \u7684\u6b63\u65b9\u5f62\uff0c\u5728\u539f\u70b9\u5904\u6709\u4e00\u4e2a\u534a\u5f84\u4e3a0.25\u7684\u5706\u5b54\u3002\u7136\u540e\u6211\u4eec\u5728\u6240\u6709\u5355\u5143\u683c\u548c\u6240\u6709\u9876\u70b9\u4e0a\u5faa\u73af\uff0c\u5982\u679c\u4e00\u4e2a\u9876\u70b9\u7684 $y$ \u5750\u6807\u7b49\u4e8e1\uff0c\u6211\u4eec\u5c31\u628a\u5b83\u5411\u4e0a\u79fb\u52a80.5\u3002\n\n// \u6ce8\u610f\uff0c\u8fd9\u79cd\u7a0b\u5e8f\u901a\u5e38\u4e0d\u662f\u8fd9\u6837\u5de5\u4f5c\u7684\uff0c\u56e0\u4e3a\u901a\u5e38\u4f1a\u591a\u6b21\u9047\u5230\u76f8\u540c\u7684\u9876\u70b9\uff0c\u5e76\u4e14\u53ef\u80fd\u4f1a\u591a\u6b21\u79fb\u52a8\u5b83\u4eec\u3002\u5b83\u5728\u8fd9\u91cc\u8d77\u4f5c\u7528\u662f\u56e0\u4e3a\u6211\u4eec\u6839\u636e\u9876\u70b9\u7684\u51e0\u4f55\u4f4d\u7f6e\u6765\u9009\u62e9\u8981\u4f7f\u7528\u7684\u9876\u70b9\uff0c\u800c\u79fb\u52a8\u8fc7\u4e00\u6b21\u7684\u9876\u70b9\u5728\u672a\u6765\u5c06\u65e0\u6cd5\u901a\u8fc7\u8fd9\u4e2a\u6d4b\u8bd5\u3002\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u4e00\u4e2a\u66f4\u666e\u904d\u7684\u65b9\u6cd5\u662f\u4fdd\u7559\u4e00\u4e2a std::set \uff0c\u5373\u90a3\u4e9b\u6211\u4eec\u5df2\u7ecf\u79fb\u52a8\u8fc7\u7684\u9876\u70b9\u7d22\u5f15\uff08\u6211\u4eec\u53ef\u4ee5\u7528 <code>cell-@>vertex_index(i)</code> \u83b7\u5f97\uff0c\u5e76\u4e14\u53ea\u79fb\u52a8\u90a3\u4e9b\u7d22\u5f15\u8fd8\u4e0d\u5728\u8fd9\u4e2a\u96c6\u5408\u4e2d\u7684\u9876\u70b9\u3002\n\nvoid grid_3() \n{ \n  Triangulation<2> triangulation; \n  GridGenerator::hyper_cube_with_cylindrical_hole(triangulation, 0.25, 1.0); \n\n  for (const auto &cell : triangulation.active_cell_iterators()) \n    { \n      for (const auto i : cell->vertex_indices()) \n        { \n          Point<2> &v = cell->vertex(i); \n          if (std::abs(v(1) - 1.0) < 1e-5) \n            v(1) += 0.5; \n        } \n    } \n\n// \u5728\u7b2c\u4e8c\u6b65\uff0c\u6211\u4eec\u5c06\u5bf9\u7f51\u683c\u8fdb\u884c\u4e24\u6b21\u7ec6\u5316\u3002\u4e3a\u4e86\u6b63\u786e\u505a\u5230\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u5e94\u8be5\u6cbf\u7740\u4ee5\u539f\u70b9\u4e3a\u4e2d\u5fc3\u7684\u5706\u7684\u8868\u9762\u5728\u5185\u90e8\u8fb9\u754c\u4e0a\u653e\u7f6e\u65b0\u7684\u70b9\u3002\u5e78\u8fd0\u7684\u662f\uff0c GridGenerator::hyper_cube_with_cylindrical_hole \u5df2\u7ecf\u5728\u5185\u90e8\u8fb9\u754c\u4e0a\u9644\u52a0\u4e86\u4e00\u4e2aManifold\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u9700\u8981\u505a\u4efb\u4f55\u4e8b\u60c5\uff0c\u53ea\u9700\u8981\u7ec6\u5316\u7f51\u683c\uff08\u53c2\u89c1<a href=\"#Results\">results section</a>\u4e2d\u4e00\u4e2a\u5b8c\u5168\u53ef\u884c\u7684\u4f8b\u5b50\uff0c\u6211\u4eec <em> \u505a </em> \u9644\u52a0\u4e00\u4e2aManifold\u5bf9\u8c61\uff09\u3002\n\n  triangulation.refine_global(2); \n  print_mesh_info(triangulation, \"grid-3.vtu\"); \n} \n\n// \u5982\u4e0a\u56fe\u6240\u793a\uff0c\u505a\u4e8b\u6709\u4e00\u4e2a\u969c\u788d\u3002\u5982\u679c\u50cf\u8fd9\u91cc\u6240\u793a\u7684\u90a3\u6837\u79fb\u52a8\u8fb9\u754c\u4e0a\u7684\u8282\u70b9\uff0c\u7531\u4e8e\u5185\u90e8\u7684\u8282\u70b9\u6ca1\u6709\u88ab\u79fb\u52a8\uff0c\u6240\u4ee5\u7ecf\u5e38\u4f1a\u51fa\u73b0\u5185\u90e8\u7684\u5355\u5143\u88ab\u4e25\u91cd\u626d\u66f2\u7684\u60c5\u51b5\u3002\u5728\u76ee\u524d\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u5e76\u4e0d\u662f\u4e00\u4e2a\u5f88\u5927\u7684\u95ee\u9898\uff0c\u56e0\u4e3a\u5f53\u8282\u70b9\u88ab\u79fb\u52a8\u65f6\uff0c\u7f51\u683c\u5e76\u4e0d\u5305\u542b\u4efb\u4f55\u5185\u90e8\u8282\u70b9--\u5b83\u662f\u7c97\u7565\u7684\u7f51\u683c\uff0c\u800c\u4e14\u6070\u597d\u6240\u6709\u7684\u9876\u70b9\u90fd\u5728\u8fb9\u754c\u4e0a\u3002\u8fd8\u6709\u4e00\u79cd\u60c5\u51b5\u662f\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u7684\u79fb\u52a8\uff0c\u4e0e\u5e73\u5747\u5355\u5143\u7684\u5927\u5c0f\u76f8\u6bd4\uff0c\u5e76\u6ca1\u6709\u592a\u5927\u5f71\u54cd\u3002\u7136\u800c\uff0c\u6709\u65f6\u6211\u4eec\u786e\u5b9e\u60f3\u628a\u9876\u70b9\u79fb\u52a8\u4e00\u6bb5\u8ddd\u79bb\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4e5f\u9700\u8981\u79fb\u52a8\u5185\u90e8\u8282\u70b9\u3002\u4e00\u4e2a\u81ea\u52a8\u5b8c\u6210\u7684\u65b9\u6cd5\u662f\u8c03\u7528\u51fd\u6570 GridTools::laplace_transform \uff0c\u8be5\u51fd\u6570\u63a5\u6536\u4e00\u7ec4\u8f6c\u6362\u540e\u7684\u9876\u70b9\u5750\u6807\u5e76\u79fb\u52a8\u6240\u6709\u5176\u4ed6\u7684\u9876\u70b9\uff0c\u4f7f\u4ea7\u751f\u7684\u7f51\u683c\u5728\u67d0\u79cd\u610f\u4e49\u4e0a\u6709\u4e00\u4e2a\u5c0f\u7684\u53d8\u5f62\u3002\n\n//  @sect4{grid_4: Demonstrating extrude_triangulation}  \n\n// \u8fd9\u4e2a\u4f8b\u5b50\u4ece\u524d\u9762\u7684\u51fd\u6570\u4e2d\u83b7\u53d6\u521d\u59cb\u7f51\u683c\uff0c\u5e76\u7b80\u5355\u5730\u5c06\u5176\u6324\u538b\u5230\u7b2c\u4e09\u7a7a\u95f4\u7ef4\u5ea6\u3002\n\nvoid grid_4() \n{ \n  Triangulation<2> triangulation; \n  Triangulation<3> out; \n  GridGenerator::hyper_cube_with_cylindrical_hole(triangulation, 0.25, 1.0); \n\n  GridGenerator::extrude_triangulation(triangulation, 3, 2.0, out); \n  print_mesh_info(out, \"grid-4.vtu\"); \n} \n// @sect4{grid_5: Demonstrating GridTools::transform, part 1}  \n\n// \u8fd9\u4e2a\u4f8b\u5b50\u548c\u4e0b\u4e00\u4e2a\u4f8b\u5b50\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u7f51\u683c\uff0c\u7136\u540e\u6839\u636e\u4e00\u4e2a\u51fd\u6570\u79fb\u52a8\u7f51\u683c\u7684\u6bcf\u4e2a\u8282\u70b9\uff0c\u8fd9\u4e2a\u51fd\u6570\u63a5\u6536\u4e00\u4e2a\u70b9\u5e76\u8fd4\u56de\u4e00\u4e2a\u6620\u5c04\u7684\u70b9\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u8f6c\u6362  $(x,y) \\mapsto (x,y+\\sin(\\pi x/5))$  \u3002\n\n//  GridTools::transform()  \u9700\u8981\u4e00\u4e2a\u4e09\u89d2\u5f62\u548c\u4e00\u4e2a\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u50cf\u4e00\u4e2a\u51fd\u6570\u4e00\u6837\u88ab\u8c03\u7528\uff0c\u63a5\u6536\u4e00\u4e2a\u70b9\u5e76\u8fd4\u56de\u4e00\u4e2a\u70b9\u3002\u6709\u4e0d\u540c\u7684\u65b9\u5f0f\u6765\u63d0\u4f9b\u8fd9\u6837\u4e00\u4e2a\u53c2\u6570\u3002\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2a\u51fd\u6570\u7684\u6307\u9488\uff1b\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2a\u5177\u6709`operator()`\u7684\u7c7b\u7684\u5bf9\u8c61\uff1b\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2alambda\u51fd\u6570\uff1b\u6216\u8005\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u901a\u8fc7 <code>std::function@<Point@<2@>(const Point@<2@>)@></code> \u5bf9\u8c61\u63cf\u8ff0\u7684\u4e1c\u897f\u3002\n\n// \u66f4\u73b0\u4ee3\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u4e00\u4e2a\u63a5\u53d7\u4e00\u4e2a\u70b9\u5e76\u8fd4\u56de\u4e00\u4e2a\u70b9\u7684lambda\u51fd\u6570\uff0c\u8fd9\u5c31\u662f\u6211\u4eec\u5728\u4e0b\u9762\u6240\u505a\u7684\u3002\n\nvoid grid_5() \n{ \n  Triangulation<2>          triangulation; \n  std::vector<unsigned int> repetitions(2); \n  repetitions[0] = 14; \n  repetitions[1] = 2; \n  GridGenerator::subdivided_hyper_rectangle(triangulation, \n                                            repetitions, \n                                            Point<2>(0.0, 0.0), \n                                            Point<2>(10.0, 1.0)); \n\n  GridTools::transform( \n    [](const Point<2> &in) { \n      return Point<2>(in[0], in[1] + std::sin(numbers::PI * in[0] / 5.0)); \n    }, \n    triangulation); \n  print_mesh_info(triangulation, \"grid-5.vtu\"); \n} \n\n//  @sect4{grid_6: Demonstrating GridTools::transform, part 2}  \n\n// \u5728\u7b2c\u4e8c\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u6620\u5c04  $(x,y) \\mapsto (x,\\tanh(2y)/\\tanh(2))$  \u5c06\u539f\u59cb\u7f51\u683c\u4e2d\u7684\u70b9\u8f6c\u6362\u4e3a\u65b0\u7684\u7f51\u683c\u3002\u4e3a\u4e86\u4f7f\u4e8b\u60c5\u66f4\u6709\u8da3\uff0c\u800c\u4e0d\u662f\u50cf\u524d\u9762\u7684\u4f8b\u5b50\u90a3\u6837\u5728\u4e00\u4e2a\u5355\u4e00\u7684\u51fd\u6570\u4e2d\u5b8c\u6210\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u521b\u5efa\u4e00\u4e2a\u5177\u6709  <code>operator()</code>  \u7684\u5bf9\u8c61\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u5c06\u88ab  GridTools::transform.  \u6240\u8c03\u7528\u3002\u5f53\u7136\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u5b9e\u9645\u4e0a\u53ef\u80fd\u8981\u590d\u6742\u5f97\u591a\uff1a\u8fd9\u4e2a\u5bf9\u8c61\u53ef\u80fd\u6709\u6210\u5458\u53d8\u91cf\uff0c\u5728\u8ba1\u7b97\u9876\u70b9\u7684\u65b0\u4f4d\u7f6e\u65f6\u8d77\u4f5c\u7528\u3002\n\nstruct Grid6Func \n{ \n  double trans(const double y) const \n  { \n    return std::tanh(2 * y) / tanh(2); \n  } \n\n  Point<2> operator()(const Point<2> &in) const \n  { \n    return {in(0), trans(in(1))}; \n  } \n}; \n\nvoid grid_6() \n{ \n  Triangulation<2>          triangulation; \n  std::vector<unsigned int> repetitions(2); \n  repetitions[0] = repetitions[1] = 40; \n  GridGenerator::subdivided_hyper_rectangle(triangulation, \n                                            repetitions, \n                                            Point<2>(0.0, 0.0), \n                                            Point<2>(1.0, 1.0)); \n\n  GridTools::transform(Grid6Func(), triangulation); \n  print_mesh_info(triangulation, \"grid-6.vtu\"); \n} \n// @sect4{grid_7: Demonstrating distort_random}  \n\n// \u5728\u8fd9\u6700\u540e\u4e00\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u7f51\u683c\uff0c\u7136\u540e\u901a\u8fc7\u968f\u673a\u6270\u52a8\u4f7f\u5176\uff08\u5185\u90e8\uff09\u9876\u70b9\u53d8\u5f62\u3002\u8fd9\u4e0d\u662f\u4f60\u60f3\u5728\u751f\u4ea7\u8ba1\u7b97\u4e2d\u505a\u7684\u4e8b\u60c5\uff08\u56e0\u4e3a\u5728\u5177\u6709 \"\u826f\u597d\u5f62\u72b6 \"\u5355\u5143\u7684\u7f51\u683c\u4e0a\u7684\u7ed3\u679c\u901a\u5e38\u6bd4\u5728 GridTools::distort_random()), \u4ea7\u751f\u7684\u53d8\u5f62\u5355\u5143\u4e0a\u7684\u7ed3\u679c\u8981\u597d\uff0c\u4f46\u8fd9\u662f\u4e00\u4e2a\u6709\u7528\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u6d4b\u8bd5\u79bb\u6563\u5316\u548c\u4ee3\u7801\uff0c\u786e\u4fdd\u5b83\u4eec\u4e0d\u4f1a\u56e0\u4e3a\u7f51\u683c\u6070\u597d\u662f\u5747\u5300\u7ed3\u6784\u548c\u652f\u6301\u8d85\u7ea7\u6536\u655b\u7279\u6027\u800c\u610f\u5916\u5730\u5de5\u4f5c\u3002\n\nvoid grid_7() \n{ \n  Triangulation<2>          triangulation; \n  std::vector<unsigned int> repetitions(2); \n  repetitions[0] = repetitions[1] = 16; \n  GridGenerator::subdivided_hyper_rectangle(triangulation, \n                                            repetitions, \n                                            Point<2>(0.0, 0.0), \n                                            Point<2>(1.0, 1.0)); \n\n  GridTools::distort_random(0.3, triangulation, true); \n  print_mesh_info(triangulation, \"grid-7.vtu\"); \n} \n// @sect3{The main function}  \n\n// \u6700\u540e\u662f\u4e3b\u51fd\u6570\u3002\u8fd9\u91cc\u6ca1\u6709\u4ec0\u4e48\u53ef\u505a\u7684\uff0c\u53ea\u662f\u8c03\u7528\u6211\u4eec\u4e0a\u9762\u5199\u7684\u6240\u6709\u5404\u79cd\u51fd\u6570\u3002\n\nint main() \n{ \n  try \n    { \n      grid_1(); \n      grid_2(); \n      grid_3(); \n      grid_4(); \n      grid_5(); \n      grid_6(); \n      grid_7(); \n    } \n  catch (std::exception &exc) \n    { \n      std::cerr << std::endl \n                << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n      std::cerr << \"Exception on processing: \" << std::endl \n                << exc.what() << std::endl \n                << \"Aborting!\" << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n\n      return 1; \n    } \n  catch (...) \n    { \n      std::cerr << std::endl \n                << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n      std::cerr << \"Unknown exception!\" << std::endl \n                << \"Aborting!\" << std::endl \n                << \"----------------------------------------------------\" \n                << std::endl; \n      return 1; \n    } \n} \n\n\n", "meta": {"hexsha": "71d2645522b7afd85f445d695bf1bf653b8a5bea", "size": 9548, "ext": "cc", "lang": "C++", "max_stars_repo_path": "Translator_file/examples/step-49/step-49.cc", "max_stars_repo_name": "jiaqiwang969/deal.ii-course-practice", "max_stars_repo_head_hexsha": "0da5ad1537d8152549d8a0e4de5872efe7619c8a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Translator_file/examples/step-49/step-49.cc", "max_issues_repo_name": "jiaqiwang969/deal.ii-course-practice", "max_issues_repo_head_hexsha": "0da5ad1537d8152549d8a0e4de5872efe7619c8a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Translator_file/examples/step-49/step-49.cc", "max_forks_repo_name": "jiaqiwang969/deal.ii-course-practice", "max_forks_repo_head_hexsha": "0da5ad1537d8152549d8a0e4de5872efe7619c8a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.501754386, "max_line_length": 303, "alphanum_fraction": 0.6045245078, "num_tokens": 3974, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3998116407397951, "lm_q2_score": 0.1623800386934589, "lm_q1q2_score": 0.06492142969342321}}
{"text": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#include \"main.h\"\n\n#include <Eigen/Core>\n#include \"AnnoyingScalar.h\"\n\nusing namespace Eigen;\n\ntemplate <typename Scalar, int Storage>\nvoid run_matrix_tests()\n{\n  typedef Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Storage> MatrixType;\n\n  MatrixType m, n;\n\n  // boundary cases ...\n  m = n = MatrixType::Random(50,50);\n  m.conservativeResize(1,50);\n  VERIFY_IS_APPROX(m, n.block(0,0,1,50));\n\n  m = n = MatrixType::Random(50,50);\n  m.conservativeResize(50,1);\n  VERIFY_IS_APPROX(m, n.block(0,0,50,1));\n\n  m = n = MatrixType::Random(50,50);\n  m.conservativeResize(50,50);\n  VERIFY_IS_APPROX(m, n.block(0,0,50,50));\n\n  // random shrinking ...\n  for (int i=0; i<25; ++i)\n  {\n    const Index rows = internal::random<Index>(1,50);\n    const Index cols = internal::random<Index>(1,50);\n    m = n = MatrixType::Random(50,50);\n    m.conservativeResize(rows,cols);\n    VERIFY_IS_APPROX(m, n.block(0,0,rows,cols));\n  }\n\n  // random growing with zeroing ...\n  for (int i=0; i<25; ++i)\n  {\n    const Index rows = internal::random<Index>(50,75);\n    const Index cols = internal::random<Index>(50,75);\n    m = n = MatrixType::Random(50,50);\n    m.conservativeResizeLike(MatrixType::Zero(rows,cols));\n    VERIFY_IS_APPROX(m.block(0,0,n.rows(),n.cols()), n);\n    VERIFY( rows<=50 || m.block(50,0,rows-50,cols).sum() == Scalar(0) );\n    VERIFY( cols<=50 || m.block(0,50,rows,cols-50).sum() == Scalar(0) );\n  }\n}\n\ntemplate <typename Scalar>\nvoid run_vector_tests()\n{\n  typedef Matrix<Scalar, 1, Eigen::Dynamic> VectorType;\n\n  VectorType m, n;\n\n  // boundary cases ...\n  m = n = VectorType::Random(50);\n  m.conservativeResize(1);\n  VERIFY_IS_APPROX(m, n.segment(0,1));\n\n  m = n = VectorType::Random(50);\n  m.conservativeResize(50);\n  VERIFY_IS_APPROX(m, n.segment(0,50));\n  \n  m = n = VectorType::Random(50);\n  m.conservativeResize(m.rows(),1);\n  VERIFY_IS_APPROX(m, n.segment(0,1));\n\n  m = n = VectorType::Random(50);\n  m.conservativeResize(m.rows(),50);\n  VERIFY_IS_APPROX(m, n.segment(0,50));\n\n  // random shrinking ...\n  for (int i=0; i<50; ++i)\n  {\n    const int size = internal::random<int>(1,50);\n    m = n = VectorType::Random(50);\n    m.conservativeResize(size);\n    VERIFY_IS_APPROX(m, n.segment(0,size));\n    \n    m = n = VectorType::Random(50);\n    m.conservativeResize(m.rows(), size);\n    VERIFY_IS_APPROX(m, n.segment(0,size));\n  }\n\n  // random growing with zeroing ...\n  for (int i=0; i<50; ++i)\n  {\n    const int size = internal::random<int>(50,100);\n    m = n = VectorType::Random(50);\n    m.conservativeResizeLike(VectorType::Zero(size));\n    VERIFY_IS_APPROX(m.segment(0,50), n);\n    VERIFY( size<=50 || m.segment(50,size-50).sum() == Scalar(0) );\n    \n    m = n = VectorType::Random(50);\n    m.conservativeResizeLike(Matrix<Scalar,Dynamic,Dynamic>::Zero(1,size));\n    VERIFY_IS_APPROX(m.segment(0,50), n);\n    VERIFY( size<=50 || m.segment(50,size-50).sum() == Scalar(0) );\n  }\n}\n\n// Basic memory leak check with a non-copyable scalar type\ntemplate<int> void noncopyable()\n{\n  typedef Eigen::Matrix<AnnoyingScalar,Dynamic,1> VectorType;\n  typedef Eigen::Matrix<AnnoyingScalar,Dynamic,Dynamic> MatrixType;\n  \n  {\n    AnnoyingScalar::dont_throw = true;\n    int n = 50;\n    VectorType v0(n), v1(n);\n    MatrixType m0(n,n), m1(n,n), m2(n,n);\n    v0.setOnes(); v1.setOnes();\n    m0.setOnes(); m1.setOnes(); m2.setOnes();\n    VERIFY(m0==m1);\n    m0.conservativeResize(2*n,2*n);\n    VERIFY(m0.topLeftCorner(n,n) == m1);\n    \n    VERIFY(v0.head(n) == v1);\n    v0.conservativeResize(2*n);\n    VERIFY(v0.head(n) == v1);\n  }\n  VERIFY(AnnoyingScalar::instances==0 && \"global memory leak detected in noncopyable\");\n}\n\nEIGEN_DECLARE_TEST(conservative_resize)\n{\n  for(int i=0; i<g_repeat; ++i)\n  {\n    CALL_SUBTEST_1((run_matrix_tests<int, Eigen::RowMajor>()));\n    CALL_SUBTEST_1((run_matrix_tests<int, Eigen::ColMajor>()));\n    CALL_SUBTEST_2((run_matrix_tests<float, Eigen::RowMajor>()));\n    CALL_SUBTEST_2((run_matrix_tests<float, Eigen::ColMajor>()));\n    CALL_SUBTEST_3((run_matrix_tests<double, Eigen::RowMajor>()));\n    CALL_SUBTEST_3((run_matrix_tests<double, Eigen::ColMajor>()));\n    CALL_SUBTEST_4((run_matrix_tests<std::complex<float>, Eigen::RowMajor>()));\n    CALL_SUBTEST_4((run_matrix_tests<std::complex<float>, Eigen::ColMajor>()));\n    CALL_SUBTEST_5((run_matrix_tests<std::complex<double>, Eigen::RowMajor>()));\n    CALL_SUBTEST_5((run_matrix_tests<std::complex<double>, Eigen::ColMajor>()));\n    CALL_SUBTEST_1((run_matrix_tests<int, Eigen::RowMajor | Eigen::DontAlign>()));\n\n    CALL_SUBTEST_1((run_vector_tests<int>()));\n    CALL_SUBTEST_2((run_vector_tests<float>()));\n    CALL_SUBTEST_3((run_vector_tests<double>()));\n    CALL_SUBTEST_4((run_vector_tests<std::complex<float> >()));\n    CALL_SUBTEST_5((run_vector_tests<std::complex<double> >()));\n\n    AnnoyingScalar::dont_throw = true;\n    CALL_SUBTEST_6(( run_vector_tests<AnnoyingScalar>() ));\n    CALL_SUBTEST_6(( noncopyable<0>() ));\n  }\n}\n", "meta": {"hexsha": "d709e33461774e7d2b2a4a32fdf93d0385b0e5a2", "size": 5265, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "external/eigen/test/conservative_resize.cpp", "max_stars_repo_name": "francescozoccheddu/cinolib", "max_stars_repo_head_hexsha": "6d6f7d359db673aca1c203a208f50e0a7a362b76", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "external/eigen/test/conservative_resize.cpp", "max_issues_repo_name": "francescozoccheddu/cinolib", "max_issues_repo_head_hexsha": "6d6f7d359db673aca1c203a208f50e0a7a362b76", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "external/eigen/test/conservative_resize.cpp", "max_forks_repo_name": "francescozoccheddu/cinolib", "max_forks_repo_head_hexsha": "6d6f7d359db673aca1c203a208f50e0a7a362b76", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1036585366, "max_line_length": 87, "alphanum_fraction": 0.6640075973, "num_tokens": 1606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48047867804790706, "lm_q2_score": 0.1347759174229568, "lm_q1q2_score": 0.06475695463607617}}
{"text": "/*    This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.\n *    See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.\n *    Author(s):       Vincent Rouvreau\n *\n *    Copyright (C) 2014 Inria\n *\n *    Modification(s):\n *      - YYYY/MM Author: Description of the modification\n */\n\n#include <iostream>\n#include <vector>\n#include <string>\n\n#define BOOST_TEST_DYN_LINK\n#define BOOST_TEST_MODULE \"simplex_tree_constructor_and_move\"\n#include <boost/test/unit_test.hpp>\n#include <boost/mpl/list.hpp>\n\n//  ^\n// /!\\ Nothing else from Simplex_tree shall be included to test includes are well defined.\n#include \"gudhi/Simplex_tree.h\"\n\nusing namespace Gudhi;\n\ntypedef boost::mpl::list<Simplex_tree<>, Simplex_tree<Simplex_tree_options_fast_persistence>> list_of_tested_variants;\n\ntemplate<typename Simplex_tree>\nvoid print_simplex_filtration(Simplex_tree& st, const std::string& msg) {\n  // Required before browsing through filtration values\n  st.initialize_filtration();\n\n  std::cout << \"********************************************************************\\n\";\n  std::cout << \"* \" << msg << \"\\n\";\n  std::cout << \"* The complex contains \" << st.num_simplices() << \" simplices\";\n  std::cout << \"   - dimension \" << st.dimension() << \"\\n\";\n  std::cout << \"* Iterator on Simplices in the filtration, with [filtration value]:\\n\";\n  for (auto f_simplex : st.filtration_simplex_range()) {\n    std::cout << \"   \"\n              << \"[\" << st.filtration(f_simplex) << \"] \";\n    for (auto vertex : st.simplex_vertex_range(f_simplex)) std::cout << \"(\" << vertex << \")\";\n    std::cout << std::endl;\n  }\n\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_copy_constructor, Simplex_tree, list_of_tested_variants) {\n  Simplex_tree st;\n\n  st.insert_simplex_and_subfaces({2, 1, 0}, 3.0);\n  st.insert_simplex_and_subfaces({0, 1, 6, 7}, 4.0);\n  st.insert_simplex_and_subfaces({3, 0}, 2.0);\n  st.insert_simplex_and_subfaces({3, 4, 5}, 3.0);\n  st.insert_simplex_and_subfaces({8}, 1.0);\n  /* Inserted simplex:        */\n  /*    1   6                 */\n  /*    o---o                 */\n  /*   /X\\7/                  */\n  /*  o---o---o---o   o       */\n  /*  2   0   3\\X/4   8       */\n  /*            o             */\n  /*            5             */\n  /*                          */\n  /* In other words:          */\n  /*   A facet  [2,1,0]       */\n  /*   An edge  [0,3]         */\n  /*   A facet  [3,4,5]       */\n  /*   A cell   [0,1,6,7]     */\n  /*   A vertex [8]           */\n\n  print_simplex_filtration(st, \"Default Simplex_tree is initialized\");\n\n  std::cout << \"********************************************************************\" << std::endl;\n  std::cout << \"TEST OF COPY CONSTRUCTOR\" << std::endl;\n\n  Simplex_tree st1(st);\n  Simplex_tree st2(st);\n  print_simplex_filtration(st1, \"First copy constructor from the default Simplex_tree\");\n  print_simplex_filtration(st2, \"Second copy constructor from the default Simplex_tree\");\n  // Cross check\n  BOOST_CHECK(st1 == st2);\n  BOOST_CHECK(st == st2);\n  BOOST_CHECK(st1 == st);\n\n  std::cout << \"********************************************************************\" << std::endl;\n  std::cout << \"TEST OF COPY ASSIGNMENT\" << std::endl;\n  Simplex_tree st3;\n  // To check there is no memory leak\n  st3.insert_simplex_and_subfaces({9, 10, 11}, 200.0);\n  st3 = st;\n  print_simplex_filtration(st3, \"First copy assignment from the default Simplex_tree\");\n  Simplex_tree st4;\n  st4 = st;\n  print_simplex_filtration(st4, \"Second copy assignment from the default Simplex_tree\");\n\n  // Cross check\n  BOOST_CHECK(st3 == st4);\n  BOOST_CHECK(st == st4);\n  BOOST_CHECK(st3 == st);\n\n  st = st;\n  print_simplex_filtration(st4, \"Third self copy assignment from the default Simplex_tree\");\n\n  BOOST_CHECK(st3 == st);\n\n  std::cout << \"********************************************************************\" << std::endl;\n  std::cout << \"TEST OF MOVE CONSTRUCTOR\" << std::endl;\n  Simplex_tree st5(std::move(st1));\n  print_simplex_filtration(st5, \"First move constructor from the default Simplex_tree\");\n  print_simplex_filtration(st1, \"First moved Simplex_tree shall be empty\");\n  Simplex_tree st6(std::move(st2));\n  print_simplex_filtration(st6, \"Second move constructor from the default Simplex_tree\");\n  print_simplex_filtration(st2, \"Second moved Simplex_tree shall be empty\");\n\n  // Cross check\n  BOOST_CHECK(st5 == st6);\n  BOOST_CHECK(st == st6);\n  BOOST_CHECK(st5 == st);\n\n  Simplex_tree empty_st;\n  BOOST_CHECK(st1 == st2);\n  BOOST_CHECK(empty_st == st2);\n  BOOST_CHECK(st1 == empty_st);\n\n  std::cout << \"********************************************************************\" << std::endl;\n  std::cout << \"TEST OF MOVE ASSIGNMENT\" << std::endl;\n\n  Simplex_tree st7;\n  // To check there is no memory leak\n  st7.insert_simplex_and_subfaces({9, 10, 11}, 200.0);\n  st7 = std::move(st3);\n  print_simplex_filtration(st7, \"First move assignment from the default Simplex_tree\");\n  Simplex_tree st8;\n  st8 = std::move(st4);\n  print_simplex_filtration(st8, \"Second move assignment from the default Simplex_tree\");\n\n  // Cross check\n  BOOST_CHECK(st7 == st8);\n  BOOST_CHECK(st == st8);\n  BOOST_CHECK(st7 == st);\n\n  st = std::move(st);\n  print_simplex_filtration(st, \"Third self move assignment from the default Simplex_tree\");\n\n  BOOST_CHECK(st7 == st);\n\n}\n", "meta": {"hexsha": "c0615b1253f15afb159affb3199a20c952238db3", "size": 5319, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp", "max_stars_repo_name": "jmarino/gudhi-devel", "max_stars_repo_head_hexsha": "b1824e4de6fd1d037af3c1341c3065731472ffc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2020-01-27T03:32:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-14T21:14:14.000Z", "max_issues_repo_path": "src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp", "max_issues_repo_name": "jmarino/gudhi-devel", "max_issues_repo_head_hexsha": "b1824e4de6fd1d037af3c1341c3065731472ffc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2020-08-25T16:03:23.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-28T07:36:21.000Z", "max_forks_repo_path": "src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp", "max_forks_repo_name": "jmarino/gudhi-devel", "max_forks_repo_head_hexsha": "b1824e4de6fd1d037af3c1341c3065731472ffc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2.0, "max_forks_repo_forks_event_min_datetime": "2019-11-06T12:36:23.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-25T14:53:13.000Z", "avg_line_length": 35.9391891892, "max_line_length": 118, "alphanum_fraction": 0.6048129348, "num_tokens": 1461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4610167941228964, "lm_q2_score": 0.14033624589467186, "lm_q1q2_score": 0.06469736618160411}}
{"text": "//\n// Copyright (c) 2002--2010\n// Toon Knapen, Karl Meerbergen, Kresimir Fresl,\n// Thomas Klimpel and Rutger ter Borg\n//\n// Distributed under the Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt or copy at\n// http://www.boost.org/LICENSE_1_0.txt)\n//\n// THIS FILE IS AUTOMATICALLY GENERATED\n// PLEASE DO NOT EDIT!\n//\n\n#ifndef BOOST_NUMERIC_BINDINGS_BLAS_LEVEL2_TRMV_HPP\n#define BOOST_NUMERIC_BINDINGS_BLAS_LEVEL2_TRMV_HPP\n\n#include <boost/assert.hpp>\n#include <boost/numeric/bindings/begin.hpp>\n#include <boost/numeric/bindings/blas/detail/default_order.hpp>\n#include <boost/numeric/bindings/diag_tag.hpp>\n#include <boost/numeric/bindings/has_linear_array.hpp>\n#include <boost/numeric/bindings/is_mutable.hpp>\n#include <boost/numeric/bindings/remove_imaginary.hpp>\n#include <boost/numeric/bindings/size.hpp>\n#include <boost/numeric/bindings/stride.hpp>\n#include <boost/numeric/bindings/trans_tag.hpp>\n#include <boost/numeric/bindings/uplo_tag.hpp>\n#include <boost/numeric/bindings/value_type.hpp>\n#include <boost/static_assert.hpp>\n#include <boost/type_traits/is_same.hpp>\n#include <boost/type_traits/remove_const.hpp>\n\n//\n// The BLAS-backend is selected by defining a pre-processor variable,\n//  which can be one of\n// * for CBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CBLAS\n// * for CUBLAS, define BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS\n// * netlib-compatible BLAS is the default\n//\n#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS\n#include <boost/numeric/bindings/blas/detail/cblas.h>\n#include <boost/numeric/bindings/blas/detail/cblas_option.hpp>\n#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS\n#include <boost/numeric/bindings/blas/detail/cublas.h>\n#include <boost/numeric/bindings/blas/detail/blas_option.hpp>\n#else\n#include <boost/numeric/bindings/blas/detail/blas.h>\n#include <boost/numeric/bindings/blas/detail/blas_option.hpp>\n#endif\n\nnamespace boost {\nnamespace numeric {\nnamespace bindings {\nnamespace blas {\n\n//\n// The detail namespace contains value-type-overloaded functions that\n// dispatch to the appropriate back-end BLAS-routine.\n//\nnamespace detail {\n\n#if defined BOOST_NUMERIC_BINDINGS_BLAS_CBLAS\n//\n// Overloaded function for dispatching to\n// * CBLAS backend, and\n// * float value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const float* a, const int lda, float* x,\n        const int incx ) {\n    cblas_strmv( cblas_option< Order >::value, cblas_option< UpLo >::value,\n            cblas_option< Trans >::value, cblas_option< Diag >::value, n, a,\n            lda, x, incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * CBLAS backend, and\n// * double value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const double* a, const int lda, double* x,\n        const int incx ) {\n    cblas_dtrmv( cblas_option< Order >::value, cblas_option< UpLo >::value,\n            cblas_option< Trans >::value, cblas_option< Diag >::value, n, a,\n            lda, x, incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * CBLAS backend, and\n// * complex<float> value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const std::complex<float>* a, const int lda,\n        std::complex<float>* x, const int incx ) {\n    cblas_ctrmv( cblas_option< Order >::value, cblas_option< UpLo >::value,\n            cblas_option< Trans >::value, cblas_option< Diag >::value, n, a,\n            lda, x, incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * CBLAS backend, and\n// * complex<double> value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const std::complex<double>* a, const int lda,\n        std::complex<double>* x, const int incx ) {\n    cblas_ztrmv( cblas_option< Order >::value, cblas_option< UpLo >::value,\n            cblas_option< Trans >::value, cblas_option< Diag >::value, n, a,\n            lda, x, incx );\n}\n\n#elif defined BOOST_NUMERIC_BINDINGS_BLAS_CUBLAS\n//\n// Overloaded function for dispatching to\n// * CUBLAS backend, and\n// * float value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const float* a, const int lda, float* x,\n        const int incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    cublasStrmv( blas_option< UpLo >::value, blas_option< Trans >::value,\n            blas_option< Diag >::value, n, a, lda, x, incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * CUBLAS backend, and\n// * double value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const double* a, const int lda, double* x,\n        const int incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    cublasDtrmv( blas_option< UpLo >::value, blas_option< Trans >::value,\n            blas_option< Diag >::value, n, a, lda, x, incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * CUBLAS backend, and\n// * complex<float> value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const std::complex<float>* a, const int lda,\n        std::complex<float>* x, const int incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    cublasCtrmv( blas_option< UpLo >::value, blas_option< Trans >::value,\n            blas_option< Diag >::value, n, a, lda, x, incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * CUBLAS backend, and\n// * complex<double> value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const int n, const std::complex<double>* a, const int lda,\n        std::complex<double>* x, const int incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    cublasZtrmv( blas_option< UpLo >::value, blas_option< Trans >::value,\n            blas_option< Diag >::value, n, a, lda, x, incx );\n}\n\n#else\n//\n// Overloaded function for dispatching to\n// * netlib-compatible BLAS backend (the default), and\n// * float value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const fortran_int_t n, const float* a, const fortran_int_t lda,\n        float* x, const fortran_int_t incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    BLAS_STRMV( &blas_option< UpLo >::value, &blas_option< Trans >::value,\n            &blas_option< Diag >::value, &n, a, &lda, x, &incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible BLAS backend (the default), and\n// * double value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const fortran_int_t n, const double* a, const fortran_int_t lda,\n        double* x, const fortran_int_t incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    BLAS_DTRMV( &blas_option< UpLo >::value, &blas_option< Trans >::value,\n            &blas_option< Diag >::value, &n, a, &lda, x, &incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible BLAS backend (the default), and\n// * complex<float> value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const fortran_int_t n, const std::complex<float>* a,\n        const fortran_int_t lda, std::complex<float>* x,\n        const fortran_int_t incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    BLAS_CTRMV( &blas_option< UpLo >::value, &blas_option< Trans >::value,\n            &blas_option< Diag >::value, &n, a, &lda, x, &incx );\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible BLAS backend (the default), and\n// * complex<double> value-type.\n//\ntemplate< typename Order, typename UpLo, typename Trans, typename Diag >\ninline void trmv( const Order, const UpLo, const Trans, const Diag,\n        const fortran_int_t n, const std::complex<double>* a,\n        const fortran_int_t lda, std::complex<double>* x,\n        const fortran_int_t incx ) {\n    BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );\n    BLAS_ZTRMV( &blas_option< UpLo >::value, &blas_option< Trans >::value,\n            &blas_option< Diag >::value, &n, a, &lda, x, &incx );\n}\n\n#endif\n\n} // namespace detail\n\n//\n// Value-type based template class. Use this class if you need a type\n// for dispatching to trmv.\n//\ntemplate< typename Value >\nstruct trmv_impl {\n\n    typedef Value value_type;\n    typedef typename remove_imaginary< Value >::type real_type;\n    typedef void result_type;\n\n    //\n    // Static member function that\n    // * Deduces the required arguments for dispatching to BLAS, and\n    // * Asserts that most arguments make sense.\n    //\n    template< typename MatrixA, typename VectorX >\n    static result_type invoke( const MatrixA& a, VectorX& x ) {\n        namespace bindings = ::boost::numeric::bindings;\n        typedef typename detail::default_order< MatrixA >::type order;\n        typedef typename result_of::trans_tag< MatrixA, order >::type trans;\n        typedef typename result_of::uplo_tag< MatrixA, trans >::type uplo;\n        typedef typename result_of::diag_tag< MatrixA >::type diag;\n        BOOST_STATIC_ASSERT( (is_same< typename remove_const<\n                typename bindings::value_type< MatrixA >::type >::type,\n                typename remove_const< typename bindings::value_type<\n                VectorX >::type >::type >::value) );\n        BOOST_STATIC_ASSERT( (bindings::has_linear_array< MatrixA >::value) );\n        BOOST_STATIC_ASSERT( (bindings::has_linear_array< VectorX >::value) );\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorX >::value) );\n        BOOST_ASSERT( bindings::size_minor(a) == 1 ||\n                bindings::stride_minor(a) == 1 );\n        detail::trmv( order(), uplo(), trans(), diag(),\n                bindings::size_column_op(a, trans()),\n                bindings::begin_value(a), bindings::stride_major(a),\n                bindings::begin_value(x), bindings::stride(x) );\n    }\n};\n\n//\n// Functions for direct use. These functions are overloaded for temporaries,\n// so that wrapped types can still be passed and used for write-access. Calls\n// to these functions are passed to the trmv_impl classes. In the \n// documentation, the const-overloads are collapsed to avoid a large number of\n// prototypes which are very similar.\n//\n\n//\n// Overloaded function for trmv. Its overload differs for\n//\ntemplate< typename MatrixA, typename VectorX >\ninline typename trmv_impl< typename bindings::value_type<\n        MatrixA >::type >::result_type\ntrmv( const MatrixA& a, VectorX& x ) {\n    trmv_impl< typename bindings::value_type<\n            MatrixA >::type >::invoke( a, x );\n}\n\n} // namespace blas\n} // namespace bindings\n} // namespace numeric\n} // namespace boost\n\n#endif\n", "meta": {"hexsha": "2950aa7b4521a0af4c91bcfa2f56593c44c321ef", "size": 11602, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "externals/numeric_bindings/boost/numeric/bindings/blas/level2/trmv.hpp", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137.0, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "externals/numeric_bindings/boost/numeric/bindings/blas/level2/trmv.hpp", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381.0, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "externals/numeric_bindings/boost/numeric/bindings/blas/level2/trmv.hpp", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 38.2904290429, "max_line_length": 78, "alphanum_fraction": 0.6916048957, "num_tokens": 2984, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583464, "lm_q2_score": 0.13117323564948066, "lm_q1q2_score": 0.06404971287486903}}
{"text": "// Copyright 2008 Gunter Winkler <guwi17@gmx.de>\r\n// Distributed under the Boost Software License, Version 1.0. (See\r\n// accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n\r\n#ifndef _HPP_TESTHELPER_\r\n#define _HPP_TESTHELPER_\r\n\r\n#include <utility>\r\n#include <iostream>\r\n#include <boost/numeric/ublas/vector_expression.hpp>\r\n#include <boost/numeric/ublas/matrix_expression.hpp>\r\n\r\nstatic unsigned _success_counter = 0;\r\nstatic unsigned _fail_counter    = 0;\r\n\r\nstatic inline\r\nvoid assertTrue(const char* message, bool condition) {\r\n#ifndef NOMESSAGES\r\n  std::cout << message;\r\n#endif\r\n  if ( condition ) {\r\n    ++ _success_counter;\r\n    std::cout << \"1\\n\"; // success\r\n  } else {\r\n    ++ _fail_counter;\r\n    std::cout << \"0\\n\"; // failed\r\n  }\r\n}\r\n\r\ntemplate < class T >\r\nvoid assertEquals(const char* message, T expected, T actual) {\r\n#ifndef NOMESSAGES\r\n  std::cout << message;\r\n#endif\r\n  if ( expected == actual ) {\r\n    ++ _success_counter;\r\n    std::cout << \"1\\n\"; // success\r\n  } else {\r\n    #ifndef NOMESSAGES\r\n      std::cout << \" expected \" << expected << \" actual \" << actual << \" \";\r\n    #endif\r\n    ++ _fail_counter;\r\n    std::cout << \"0\\n\"; // failed\r\n  }\r\n}\r\n\r\ninline static\r\nstd::pair<unsigned, unsigned> getResults() {\r\n  return std::make_pair(_success_counter, _fail_counter);\r\n}\r\n\r\ntemplate < class M1, class M2 >\r\nbool compare( const boost::numeric::ublas::matrix_expression<M1> & m1, \r\n              const boost::numeric::ublas::matrix_expression<M2> & m2 ) {\r\n  if ((m1().size1() != m2().size1()) ||\r\n      (m1().size2() != m2().size2())) {\r\n    return false;\r\n  }\r\n\r\n  size_t size1 = m1().size1();\r\n  size_t size2 = m1().size2();\r\n  for (size_t i=0; i < size1; ++i) {\r\n    for (size_t j=0; j < size2; ++j) {\r\n      if ( m1()(i,j) != m2()(i,j) ) return false;\r\n    }\r\n  }\r\n  return true;\r\n}\r\n\r\ntemplate < class M1, class M2 >\r\nbool compare( const boost::numeric::ublas::vector_expression<M1> & m1, \r\n              const boost::numeric::ublas::vector_expression<M2> & m2 ) {\r\n  if (m1().size() != m2().size()) {\r\n    return false;\r\n  }\r\n\r\n  size_t size = m1().size();\r\n  for (size_t i=0; i < size; ++i) {\r\n    if ( m1()(i) != m2()(i) ) return false;\r\n  }\r\n  return true;\r\n}\r\n\r\n// Compare if two matrices or vectors are equals based on distance.\r\n\r\ntemplate <class AE>\r\ntypename AE::value_type mean_square(const boost::numeric::ublas::matrix_expression<AE> &me) {\r\n    typename AE::value_type s(0);\r\n    typename AE::size_type i, j;\r\n    for (i=0; i!= me().size1(); i++) {\r\n        for (j=0; j!= me().size2(); j++) {\r\n            s += boost::numeric::ublas::scalar_traits<typename AE::value_type>::type_abs(me()(i,j));\r\n        }\r\n    }\r\n    return s / (me().size1() * me().size2());\r\n}\r\n\r\ntemplate <class AE>\r\ntypename AE::value_type mean_square(const boost::numeric::ublas::vector_expression<AE> &ve) {\r\n    // We could have use norm2 here, but ublas' ABS does not support unsigned types.\r\n    typename AE::value_type s(0);\r\n    typename AE::size_type i;\r\n    for (i=0; i!= ve().size(); i++) {\r\n        s += boost::numeric::ublas::scalar_traits<typename AE::value_type>::type_abs(ve()(i));\r\n    }\r\n    return s / ve().size();\r\n}\r\n\r\ntemplate < class M1, class M2 >\r\nbool compare_to( const boost::numeric::ublas::matrix_expression<M1> & m1,\r\n               const boost::numeric::ublas::matrix_expression<M2> & m2,\r\n               double tolerance = 0.0 ) {\r\n    if ((m1().size1() != m2().size1()) ||\r\n        (m1().size2() != m2().size2())) {\r\n        return false;\r\n    }\r\n\r\n    return mean_square(m2() - m1()) <= tolerance;\r\n}\r\n\r\ntemplate < class M1, class M2 >\r\nbool compare_to( const boost::numeric::ublas::vector_expression<M1> & m1,\r\n               const boost::numeric::ublas::vector_expression<M2> & m2,\r\n               double tolerance = 0.0 ) {\r\n    if (m1().size() != m2().size()) {\r\n        return false;\r\n    }\r\n\r\n    return mean_square(m2() - m1()) <= tolerance;\r\n}\r\n\r\n\r\n#endif\r\n", "meta": {"hexsha": "ed7509505992eb81c66ecc1266fd12e4658b1cef", "size": 3948, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/ublas/test/common/testhelper.hpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/ublas/test/common/testhelper.hpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/ublas/test/common/testhelper.hpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 29.0294117647, "max_line_length": 101, "alphanum_fraction": 0.587639311, "num_tokens": 1119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.41489884579676883, "lm_q2_score": 0.15405756074950905, "lm_q1q2_score": 0.0639183041412369}}
{"text": "/**\n * \\file dcs/disjoint_sets.hpp\n *\n * \\brief Implementation of the disjoint-sets (union-find) data structure.\n *\n * \\author Marco Guazzone (marco.guazzone@gmail.com)\n *\n * <hr/>\n *\n * Copyright 2009 Marco Guazzone (marco.guazzone@gmail.com)\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef DCS_DISJOINT_SETS_HPP\n#define DCS_DISJOINT_SETS_HPP\n\n\n#include <boost/function.hpp>\n#include <cstddef>\n#include <map>\n#include <vector>\n\n\nnamespace dcs {\n\nnamespace detail { namespace /*<unnamed>*/ {\n\ntemplate <typename T,typename ValueT>\nstruct identity_hasher\n{\n\tValueT operator()(T const& t) { return t; }\n}; // identity\n\n\ntemplate <class ParentPA, class Vertex>\nVertex find_representative_with_path_halving(ParentPA p, Vertex v)\n{\n  Vertex parent = p[v];\n  Vertex grandparent = p[parent];\n  while (parent != grandparent) {\n    p[v] = grandparent;\n    v =  grandparent;\n    parent = p[v];\n    grandparent = p[parent];\n  }\n  return parent;\n}\n\n\ntemplate <class ParentPA, class Vertex>\nVertex find_representative_with_full_compression(ParentPA parent, Vertex v)\n{\n  Vertex old = v;\n  Vertex ancestor = parent[v];\n  while (ancestor != v) {\n    v = ancestor;\n    ancestor = parent[v];\n  }\n  v = parent[old];\n  while (ancestor != v) {\n    parent[old] = ancestor;\n    old = v;\n    v = parent[old];\n  }\n  return ancestor;\n}\n\n}} // Namespace detail::<unnamed>\n\n\nstruct find_with_path_halving\n{\n\ttemplate <class ParentPA, class Vertex>\n\tVertex operator()(ParentPA p, Vertex v) const\n\t{\n\t\treturn detail::find_representative_with_path_halving(p, v);\n\t}\n};\n\nstruct find_with_full_path_compression\n{\n\ttemplate <class ParentPA, class Vertex>\n\tVertex operator()(ParentPA p, Vertex v) const\n\t{\n\t\treturn detail::find_representative_with_full_compression(p, v);\n\t}\n};\n\n\ntemplate <typename ElementT, typename FinderT = find_with_full_path_compression>\nclass disjoint_sets\n{\n\tpublic: typedef ElementT element_type;\n\tpublic: typedef ::std::size_t size_type;\n\tpublic: typedef size_type (*hash_function_type)(element_type const&);\n\tpublic: typedef FinderT finder_type;\n\n\n\tpublic: disjoint_sets()\n\t: hash_(detail::identity_hasher<element_type,size_type>())\n\t{\n\t}\n\n\tpublic: void make_set(element_type const& e)\n\t{\n\t\tsize_type sid(id_map_.size());\n\t\tid_map_[hash_(e)] = sid;\n\t\tinv_id_map_[sid] = e;\n\t\tranks_.push_back(0);\n\t\tparents_.push_back(sid);\n\n\t}\n\n\tpublic: size_type find_set(element_type const& e) const\n\t{\n\t\treturn finder_(parents_, id_map_.at(hash_(e)));\n\t}\n\n\tpublic: void link_sets(element_type const& e1, element_type const& e2)\n\t{\n\t\tsize_type sid1 = find_set(e1);\n\t\tsize_type sid2 = find_set(e2);\n\t\tif (sid1 == sid2)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\t// e1 and e1 are not already in same set. Merge them.\n\t\tif (ranks_[sid1] > ranks_[sid2])\n\t\t{\n\t\t\tparents_[sid2] = sid1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tparents_[sid1] = sid2;\n\t\t\tif (ranks_[sid1] == ranks_[sid2])\n\t\t\t{\n\t\t\t\tranks_[sid2] += 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic: void union_sets(element_type const& e1, element_type const& e2)\n\t{\n\t\tlink_sets(find_set(e1), find_set(e2));\n\t}\n\n\n\tprivate: ::std::vector<size_type> ranks_;\n\tprivate: ::std::vector<size_type> parents_;\n\tprivate: ::std::map<size_type,size_type> id_map_;\n\tprivate: ::std::map<size_type,element_type> inv_id_map_;\n\tprivate: ::boost::function<size_type(element_type const&)> hash_;\n\tprivate: finder_type finder_;\n}; // disjoint_sets\n\n} // Namespace dcs\n\n#endif // DCS_DISJOINT_SETS_HPP\n", "meta": {"hexsha": "19d6719e8c776974c04ba8306814c27e45e44efe", "size": 3870, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "inc/dcs/disjoint_sets.hpp", "max_stars_repo_name": "sguazt/dcsxx-commons", "max_stars_repo_head_hexsha": "0fc1fd8a38b7c412941b401c00a9293bc5df8b21", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "inc/dcs/disjoint_sets.hpp", "max_issues_repo_name": "sguazt/dcsxx-commons", "max_issues_repo_head_hexsha": "0fc1fd8a38b7c412941b401c00a9293bc5df8b21", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "inc/dcs/disjoint_sets.hpp", "max_forks_repo_name": "sguazt/dcsxx-commons", "max_forks_repo_head_hexsha": "0fc1fd8a38b7c412941b401c00a9293bc5df8b21", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.6315789474, "max_line_length": 80, "alphanum_fraction": 0.7062015504, "num_tokens": 1057, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.12765261702501562, "lm_q1q2_score": 0.06382630851250781}}
{"text": "//==============================================================================\n//         Copyright 2003 - 2012   LASMEA UMR 6602 CNRS/Univ. Clermont II\n//         Copyright 2009 - 2012   LRI    UMR 8623 CNRS/Univ Paris Sud XI\n//\n//          Distributed under the Boost Software License, Version 1.0.\n//                 See accompanying file LICENSE.txt or copy at\n//                     http://www.boost.org/LICENSE_1_0.txt\n//==============================================================================\n#define NT2_UNIT_MODULE \"nt2 arithmetic toolbox - iround/scalar Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// unit test behavior of arithmetic components in scalar mode\n//////////////////////////////////////////////////////////////////////////////\n/// created by jt the 01/12/2010\n///\n#include <nt2/arithmetic/include/functions/iround.hpp>\n#include <boost/simd/sdk/simd/io.hpp>\n#include <nt2/sdk/meta/as_integer.hpp>\n#include <nt2/sdk/unit/tests.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/unit/tests/type_expr.hpp>\n\n#include <nt2/constant/constant.hpp>\n#include <nt2/include/constants/one.hpp>\n#include <nt2/include/constants/inf.hpp>\n#include <nt2/include/constants/zero.hpp>\n#include <nt2/include/constants/minf.hpp>\n#include <nt2/include/constants/mone.hpp>\n#include <nt2/include/constants/nan.hpp>\n\n\n\nNT2_TEST_CASE_TPL ( iround_real__1_0,  NT2_REAL_TYPES)\n{\n\n  using nt2::iround;\n  using nt2::tag::iround_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<iround_(T)>::type r_t;\n  typedef iT wished_r_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(iround(T(1.4)), 1, 0);\n  NT2_TEST_ULP_EQUAL(iround(T(1.5)), 2, 0);\n  NT2_TEST_ULP_EQUAL(iround(T(1.6)), 2, 0);\n  NT2_TEST_ULP_EQUAL(iround(T(2.5)), 3, 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Half<T>()), nt2::One<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Inf<T>()), nt2::Inf<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Mhalf<T>()), nt2::Mone<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Minf<T>()), nt2::Minf<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Mone<T>()), nt2::Mone<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Nan<T>()), nt2::Zero<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::One<T>()), nt2::One<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Zero<T>()), nt2::Zero<r_t>(), 0);\n} // end of test for floating_\n\nNT2_TEST_CASE_TPL ( iround_unsigned_int__1_0,  NT2_UNSIGNED_TYPES)\n{\n\n  using nt2::iround;\n  using nt2::tag::iround_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<iround_(T)>::type r_t;\n  typedef iT wished_r_t;\n\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n\n\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(iround(nt2::One<T>()), nt2::One<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Zero<T>()), nt2::Zero<r_t>(), 0);\n} // end of test for unsigned_int_\n\nNT2_TEST_CASE_TPL ( iround_signed_int__1_0,  NT2_INTEGRAL_SIGNED_TYPES)\n{\n\n  using nt2::iround;\n  using nt2::tag::iround_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<iround_(T)>::type r_t;\n  typedef iT wished_r_t;\n\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(iround(nt2::Mone<T>()), nt2::Mone<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::One<T>()), nt2::One<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(iround(nt2::Zero<T>()), nt2::Zero<T>(), 0);\n} // end of test for signed_int_\n", "meta": {"hexsha": "572bd7a31247539a82c7033e1997cf571bf7258e", "size": 3574, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/core/base/unit/arithmetic/scalar/iround.cpp", "max_stars_repo_name": "psiha/nt2", "max_stars_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 34.0, "max_stars_repo_stars_event_min_datetime": "2017-05-19T18:10:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T02:18:13.000Z", "max_issues_repo_path": "modules/core/base/unit/arithmetic/scalar/iround.cpp", "max_issues_repo_name": "psiha/nt2", "max_issues_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/core/base/unit/arithmetic/scalar/iround.cpp", "max_forks_repo_name": "psiha/nt2", "max_forks_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 7.0, "max_forks_repo_forks_event_min_datetime": "2017-12-02T12:59:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-31T12:46:14.000Z", "avg_line_length": 36.101010101, "max_line_length": 80, "alphanum_fraction": 0.6323447118, "num_tokens": 1070, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4532618627863438, "lm_q2_score": 0.14033625308549463, "lm_q1q2_score": 0.06360907148998708}}
{"text": "//  (C) Copyright Gennadiy Rozental 2011-2015.\r\n//  Distributed under the Boost Software License, Version 1.0.\r\n//  (See accompanying file LICENSE_1_0.txt or copy at\r\n//  http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n//  See http://www.boost.org/libs/test for the library home page.\r\n\r\n//[example_code\r\n#define BOOST_TEST_MODULE example\r\n#include <boost/test/included/unit_test.hpp>\r\n\r\nbool is_even( int i )\r\n{\r\n  return i%2 == 0;\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( test_is_even )\r\n{\r\n  BOOST_CHECK_PREDICATE( is_even, (14) );\r\n\r\n  int i = 17;\r\n  BOOST_CHECK_PREDICATE( is_even, (i) );\r\n}\r\n//]\r\n", "meta": {"hexsha": "a1724a0368cb0b3167236600dd8258a2955fd7ce", "size": 583, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/example30.run-fail.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/example30.run-fail.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/example30.run-fail.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 23.32, "max_line_length": 66, "alphanum_fraction": 0.6826758148, "num_tokens": 166, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.48438008427698437, "lm_q2_score": 0.13117322546005344, "lm_q1q2_score": 0.06353769800322456}}
{"text": "// (C) Copyright 2007-2009 Andrew Sutton\r\n//\r\n// Use, modification and distribution are subject to the\r\n// Boost Software License, Version 1.0 (See accompanying file\r\n// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n#ifndef BOOST_GRAPH_CYCLE_HPP\r\n#define BOOST_GRAPH_CYCLE_HPP\r\n\r\n#include <vector>\r\n\r\n#include <boost/config.hpp>\r\n#include <boost/graph/graph_concepts.hpp>\r\n#include <boost/graph/graph_traits.hpp>\r\n#include <boost/graph/properties.hpp>\r\n\r\n#include <boost/concept/detail/concept_def.hpp>\r\nnamespace boost {\r\n    namespace concepts {\r\n        BOOST_concept(CycleVisitor,(Visitor)(Path)(Graph))\r\n        {\r\n            BOOST_CONCEPT_USAGE(CycleVisitor)\r\n            {\r\n                vis.cycle(p, g);\r\n            }\r\n        private:\r\n            Visitor vis;\r\n            Graph g;\r\n            Path p;\r\n        };\r\n    } /* namespace concepts */\r\nusing concepts::CycleVisitorConcept;\r\n} /* namespace boost */\r\n#include <boost/concept/detail/concept_undef.hpp>\r\n\r\n\r\nnamespace boost\r\n{\r\n\r\n// The implementation of this algorithm is a reproduction of the Teirnan\r\n// approach for directed graphs: bibtex follows\r\n//\r\n//     @article{362819,\r\n//         author = {James C. Tiernan},\r\n//         title = {An efficient search algorithm to find the elementary circuits of a graph},\r\n//         journal = {Commun. ACM},\r\n//         volume = {13},\r\n//         number = {12},\r\n//         year = {1970},\r\n//         issn = {0001-0782},\r\n//         pages = {722--726},\r\n//         doi = {http://doi.acm.org/10.1145/362814.362819},\r\n//             publisher = {ACM Press},\r\n//             address = {New York, NY, USA},\r\n//         }\r\n//\r\n// It should be pointed out that the author does not provide a complete analysis for\r\n// either time or space. This is in part, due to the fact that it's a fairly input\r\n// sensitive problem related to the density and construction of the graph, not just\r\n// its size.\r\n//\r\n// I've also taken some liberties with the interpretation of the algorithm - I've\r\n// basically modernized it to use real data structures (no more arrays and matrices).\r\n// Oh... and there's explicit control structures - not just gotos.\r\n//\r\n// The problem is definitely NP-complete, an an unbounded implementation of this\r\n// will probably run for quite a while on a large graph. The conclusions\r\n// of this paper also reference a Paton algorithm for undirected graphs as being\r\n// much more efficient (apparently based on spanning trees). Although not implemented,\r\n// it can be found here:\r\n//\r\n//     @article{363232,\r\n//         author = {Keith Paton},\r\n//         title = {An algorithm for finding a fundamental set of cycles of a graph},\r\n//         journal = {Commun. ACM},\r\n//         volume = {12},\r\n//         number = {9},\r\n//         year = {1969},\r\n//         issn = {0001-0782},\r\n//         pages = {514--518},\r\n//         doi = {http://doi.acm.org/10.1145/363219.363232},\r\n//             publisher = {ACM Press},\r\n//             address = {New York, NY, USA},\r\n//         }\r\n\r\n/**\r\n * The default cycle visitor providse an empty visit function for cycle\r\n * visitors.\r\n */\r\nstruct cycle_visitor\r\n{\r\n    template <typename Path, typename Graph>\r\n    inline void cycle(const Path& p, const Graph& g)\r\n    { }\r\n};\r\n\r\n/**\r\n * The min_max_cycle_visitor simultaneously records the minimum and maximum\r\n * cycles in a graph.\r\n */\r\nstruct min_max_cycle_visitor\r\n{\r\n    min_max_cycle_visitor(std::size_t& min_, std::size_t& max_)\r\n        : minimum(min_), maximum(max_)\r\n    { }\r\n\r\n    template <typename Path, typename Graph>\r\n    inline void cycle(const Path& p, const Graph& g)\r\n    {\r\n        BOOST_USING_STD_MIN();\r\n        BOOST_USING_STD_MAX();\r\n        std::size_t len = p.size();\r\n        minimum = min BOOST_PREVENT_MACRO_SUBSTITUTION (minimum, len);\r\n        maximum = max BOOST_PREVENT_MACRO_SUBSTITUTION (maximum, len);\r\n    }\r\n    std::size_t& minimum;\r\n    std::size_t& maximum;\r\n};\r\n\r\ninline min_max_cycle_visitor\r\nfind_min_max_cycle(std::size_t& min_, std::size_t& max_)\r\n{ return min_max_cycle_visitor(min_, max_); }\r\n\r\nnamespace detail\r\n{\r\n    template <typename Graph, typename Path>\r\n    inline bool\r\n    is_vertex_in_path(const Graph&,\r\n                        typename graph_traits<Graph>::vertex_descriptor v,\r\n                        const Path& p)\r\n    {\r\n        return (std::find(p.begin(), p.end(), v) != p.end());\r\n    }\r\n\r\n    template <typename Graph, typename ClosedMatrix>\r\n    inline bool\r\n    is_path_closed(const Graph& g,\r\n                    typename graph_traits<Graph>::vertex_descriptor u,\r\n                    typename graph_traits<Graph>::vertex_descriptor v,\r\n                    const ClosedMatrix& closed)\r\n    {\r\n        // the path from u to v is closed if v can be found in the list\r\n        // of closed vertices associated with u.\r\n        typedef typename ClosedMatrix::const_reference Row;\r\n        Row r = closed[get(vertex_index, g, u)];\r\n        if(find(r.begin(), r.end(), v) != r.end()) {\r\n            return true;\r\n        }\r\n        return false;\r\n    }\r\n\r\n    template <typename Graph, typename Path, typename ClosedMatrix>\r\n    inline bool\r\n    can_extend_path(const Graph& g,\r\n                    typename graph_traits<Graph>::edge_descriptor e,\r\n                    const Path& p,\r\n                    const ClosedMatrix& m)\r\n    {\r\n        function_requires< IncidenceGraphConcept<Graph> >();\r\n        function_requires< VertexIndexGraphConcept<Graph> >();\r\n        typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\r\n\r\n        // get the vertices in question\r\n        Vertex\r\n            u = source(e, g),\r\n            v = target(e, g);\r\n\r\n        // conditions for allowing a traversal along this edge are:\r\n        // 1. the index of v must be greater than that at which the\r\n        //    the path is rooted (p.front()).\r\n        // 2. the vertex v cannot already be in the path\r\n        // 3. the vertex v cannot be closed to the vertex u\r\n\r\n        bool indices = get(vertex_index, g, p.front()) < get(vertex_index, g, v);\r\n        bool path = !is_vertex_in_path(g, v, p);\r\n        bool closed = !is_path_closed(g, u, v, m);\r\n        return indices && path && closed;\r\n    }\r\n\r\n    template <typename Graph, typename Path>\r\n    inline bool\r\n    can_wrap_path(const Graph& g, const Path& p)\r\n    {\r\n        function_requires< IncidenceGraphConcept<Graph> >();\r\n        typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\r\n        typedef typename graph_traits<Graph>::out_edge_iterator OutIterator;\r\n\r\n        // iterate over the out-edges of the back, looking for the\r\n        // front of the path. also, we can't travel along the same\r\n        // edge that we did on the way here, but we don't quite have the\r\n        // stringent requirements that we do in can_extend_path().\r\n        Vertex\r\n            u = p.back(),\r\n            v = p.front();\r\n        OutIterator i, end;\r\n        for(boost::tie(i, end) = out_edges(u, g); i != end; ++i) {\r\n            if((target(*i, g) == v)) {\r\n                return true;\r\n            }\r\n        }\r\n        return false;\r\n    }\r\n\r\n    template <typename Graph,\r\n        typename Path,\r\n        typename ClosedMatrix>\r\n    inline typename graph_traits<Graph>::vertex_descriptor\r\n    extend_path(const Graph& g,\r\n                Path& p,\r\n                ClosedMatrix& closed)\r\n    {\r\n        function_requires< IncidenceGraphConcept<Graph> >();\r\n        typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\r\n        typedef typename graph_traits<Graph>::edge_descriptor Edge;\r\n        typedef typename graph_traits<Graph>::out_edge_iterator OutIterator;\r\n\r\n        // get the current vertex\r\n        Vertex u = p.back();\r\n        Vertex ret = graph_traits<Graph>::null_vertex();\r\n\r\n        // AdjacencyIterator i, end;\r\n        OutIterator i, end;\r\n        for(boost::tie(i, end) = out_edges(u, g); i != end; ++i) {\r\n            Vertex v = target(*i, g);\r\n\r\n            // if we can actually extend along this edge,\r\n            // then that's what we want to do\r\n            if(can_extend_path(g, *i, p, closed)) {\r\n                p.push_back(v);         // add the vertex to the path\r\n                ret = v;\r\n                break;\r\n            }\r\n        }\r\n        return ret;\r\n    }\r\n\r\n    template <typename Graph, typename Path, typename ClosedMatrix>\r\n    inline bool\r\n    exhaust_paths(const Graph& g, Path& p, ClosedMatrix& closed)\r\n    {\r\n        function_requires< GraphConcept<Graph> >();\r\n        typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\r\n\r\n        // if there's more than one vertex in the path, this closes\r\n        // of some possible routes and returns true. otherwise, if there's\r\n        // only one vertex left, the vertex has been used up\r\n        if(p.size() > 1) {\r\n            // get the last and second to last vertices, popping the last\r\n            // vertex off the path\r\n            Vertex last, prev;\r\n            last = p.back();\r\n            p.pop_back();\r\n            prev = p.back();\r\n\r\n            // reset the closure for the last vertex of the path and\r\n            // indicate that the last vertex in p is now closed to\r\n            // the next-to-last vertex in p\r\n            closed[get(vertex_index, g, last)].clear();\r\n            closed[get(vertex_index, g, prev)].push_back(last);\r\n            return true;\r\n        }\r\n        else {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    template <typename Graph, typename Visitor>\r\n    inline void\r\n    all_cycles_from_vertex(const Graph& g,\r\n                            typename graph_traits<Graph>::vertex_descriptor v,\r\n                            Visitor vis,\r\n                            std::size_t minlen,\r\n                            std::size_t maxlen)\r\n    {\r\n        function_requires< VertexListGraphConcept<Graph> >();\r\n        typedef typename graph_traits<Graph>::vertex_descriptor Vertex;\r\n        typedef std::vector<Vertex> Path;\r\n        function_requires< CycleVisitorConcept<Visitor,Path,Graph> >();\r\n        typedef std::vector<Vertex> VertexList;\r\n        typedef std::vector<VertexList> ClosedMatrix;\r\n\r\n        Path p;\r\n        ClosedMatrix closed(num_vertices(g), VertexList());\r\n        Vertex null = graph_traits<Graph>::null_vertex();\r\n\r\n        // each path investigation starts at the ith vertex\r\n        p.push_back(v);\r\n\r\n        while(1) {\r\n            // extend the path until we've reached the end or the\r\n            // maxlen-sized cycle\r\n            Vertex j = null;\r\n            while(((j = detail::extend_path(g, p, closed)) != null)\r\n                    && (p.size() < maxlen))\r\n                ; // empty loop\r\n\r\n            // if we're done extending the path and there's an edge\r\n            // connecting the back to the front, then we should have\r\n            // a cycle.\r\n            if(detail::can_wrap_path(g, p) && p.size() >= minlen) {\r\n                vis.cycle(p, g);\r\n            }\r\n\r\n            if(!detail::exhaust_paths(g, p, closed)) {\r\n                break;\r\n            }\r\n        }\r\n    }\r\n\r\n    // Select the minimum allowable length of a cycle based on the directedness\r\n    // of the graph - 2 for directed, 3 for undirected.\r\n    template <typename D> struct min_cycles { enum { value = 2 }; };\r\n    template <> struct min_cycles<undirected_tag> { enum { value = 3 }; };\r\n} /* namespace detail */\r\n\r\ntemplate <typename Graph, typename Visitor>\r\ninline void\r\ntiernan_all_cycles(const Graph& g,\r\n                    Visitor vis,\r\n                    std::size_t minlen,\r\n                    std::size_t maxlen)\r\n{\r\n    function_requires< VertexListGraphConcept<Graph> >();\r\n    typedef typename graph_traits<Graph>::vertex_iterator VertexIterator;\r\n\r\n    VertexIterator i, end;\r\n    for(boost::tie(i, end) = vertices(g); i != end; ++i) {\r\n        detail::all_cycles_from_vertex(g, *i, vis, minlen, maxlen);\r\n    }\r\n}\r\n\r\ntemplate <typename Graph, typename Visitor>\r\ninline void\r\ntiernan_all_cycles(const Graph& g, Visitor vis, std::size_t maxlen)\r\n{\r\n    typedef typename graph_traits<Graph>::directed_category Dir;\r\n    tiernan_all_cycles(g, vis, detail::min_cycles<Dir>::value, maxlen);\r\n}\r\n\r\ntemplate <typename Graph, typename Visitor>\r\ninline void\r\ntiernan_all_cycles(const Graph& g, Visitor vis)\r\n{\r\n    typedef typename graph_traits<Graph>::directed_category Dir;\r\n    tiernan_all_cycles(g, vis, detail::min_cycles<Dir>::value,\r\n                       (std::numeric_limits<std::size_t>::max)());\r\n}\r\n\r\ntemplate <typename Graph>\r\ninline std::pair<std::size_t, std::size_t>\r\ntiernan_girth_and_circumference(const Graph& g)\r\n{\r\n    std::size_t\r\n        min_ = (std::numeric_limits<std::size_t>::max)(),\r\n        max_ = 0;\r\n    tiernan_all_cycles(g, find_min_max_cycle(min_, max_));\r\n\r\n    // if this is the case, the graph is acyclic...\r\n    if(max_ == 0) max_ = min_;\r\n\r\n    return std::make_pair(min_, max_);\r\n}\r\n\r\ntemplate <typename Graph>\r\ninline std::size_t\r\ntiernan_girth(const Graph& g)\r\n{ return tiernan_girth_and_circumference(g).first; }\r\n\r\ntemplate <typename Graph>\r\ninline std::size_t\r\ntiernan_circumference(const Graph& g)\r\n{ return tiernan_girth_and_circumference(g).second; }\r\n\r\n} /* namespace boost */\r\n\r\n#endif\r\n", "meta": {"hexsha": "a80d547195525ed4ae789bf5dcd35b3f743c25c1", "size": 13202, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/graph/tiernan_all_cycles.hpp", "max_stars_repo_name": "Ron2014/boost_1_48_0", "max_stars_repo_head_hexsha": "19673f69677ffcba7c7bd6e08ec07ee3962f161c", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-01-30T18:41:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-30T18:41:39.000Z", "max_issues_repo_path": "boost/graph/tiernan_all_cycles.hpp", "max_issues_repo_name": "Ron2014/boost_1_48_0", "max_issues_repo_head_hexsha": "19673f69677ffcba7c7bd6e08ec07ee3962f161c", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "boost/graph/tiernan_all_cycles.hpp", "max_forks_repo_name": "Ron2014/boost_1_48_0", "max_forks_repo_head_hexsha": "19673f69677ffcba7c7bd6e08ec07ee3962f161c", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0185676393, "max_line_length": 95, "alphanum_fraction": 0.590971065, "num_tokens": 2946, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46490155654565424, "lm_q2_score": 0.13660838651113866, "lm_q1q2_score": 0.06350945152621872}}
{"text": "#define BOOST_TEST_MODULE \"test_read_clementi_dihedral_potential\"\n\n#ifdef BOOST_TEST_DYN_LINK\n#include <boost/test/unit_test.hpp>\n#else\n#include <boost/test/included/unit_test.hpp>\n#endif\n\n#include <mjolnir/input/read_local_potential.hpp>\n#include <tuple>\n\nusing test_types = std::tuple<double, float>;\n\nconstexpr inline float  tolerance_value(float)  noexcept {return 1e-4;}\nconstexpr inline double tolerance_value(double) noexcept {return 1e-8;}\n\ntemplate<typename Real>\ndecltype(boost::test_tools::tolerance(std::declval<Real>()))\ntolerance() {return boost::test_tools::tolerance(tolerance_value(Real()));}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(read_clementi_dihedral_noenv, T, test_types)\n{\n    mjolnir::LoggerManager::set_default_logger(\"test_read_clementi_dihedral.log\");\n\n    using real_type = T;\n    {\n        using namespace toml::literals;\n        const toml::value env;\n        const toml::value v = u8R\"(\n            indices = [1, 2, 3, 4]\n            k1 = 3.14\n            k3 = 0.577\n            v0 = 2.71\n        )\"_toml;\n\n        const auto g = mjolnir::read_clementi_dihedral_potential<real_type>(v, env);\n        BOOST_TEST(g.k1() == real_type(3.14),  tolerance<real_type>());\n        BOOST_TEST(g.k3() == real_type(0.577), tolerance<real_type>());\n        BOOST_TEST(g.v0() == real_type(2.71),  tolerance<real_type>());\n    }\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(read_clementi_dihedral_env, T, test_types)\n{\n    mjolnir::LoggerManager::set_default_logger(\"test_read_clementi_dihedral.log\");\n\n    using real_type = T;\n    {\n        using namespace toml::literals;\n        const auto env = u8R\"(\n            indices = [1, 2, 3, 4]\n            k1 = 3.14\n            k3 = 0.577\n            v0 = 2.71\n        )\"_toml;\n        const auto v = u8R\"(\n            indices = \"indices\"\n            k1 = \"k1\"\n            k3 = \"k3\"\n            v0 = \"v0\"\n        )\"_toml;\n\n        const auto g = mjolnir::read_clementi_dihedral_potential<real_type>(v, env);\n        BOOST_TEST(g.k1() == real_type(3.14),  tolerance<real_type>());\n        BOOST_TEST(g.k3() == real_type(0.577), tolerance<real_type>());\n        BOOST_TEST(g.v0() == real_type(2.71),  tolerance<real_type>());\n    }\n}\n\n// ---------------------------------------------------------------------------\n// read_local_potential\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(read_local_potential_clementi_dihedral_noenv, T, test_types)\n{\n    mjolnir::LoggerManager::set_default_logger(\"test_read_clementi_dihedral.log\");\n\n    using real_type = T;\n    {\n        using namespace toml::literals;\n        const toml::value v = u8R\"(\n            parameters = [\n                {indices = [1, 2, 3, 4], k1 = 3.14, k3 = 0.577, v0 = 2.71}\n            ]\n        )\"_toml;\n\n        const auto g = mjolnir::read_local_potential<4,\n              mjolnir::ClementiDihedralPotential<real_type>>(v);\n\n        const std::array<std::size_t, 4> ref_idx{{1, 2, 3, 4}};\n\n        BOOST_TEST(g.size() == 1u);\n        BOOST_TEST(g.at(0).first == ref_idx);\n        BOOST_TEST(g.at(0).second.k1() == real_type(3.14),  tolerance<real_type>());\n        BOOST_TEST(g.at(0).second.k3() == real_type(0.577), tolerance<real_type>());\n        BOOST_TEST(g.at(0).second.v0() == real_type(2.71),  tolerance<real_type>());\n    }\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(read_local_potential_clementi_dihedral_env, T, test_types)\n{\n    mjolnir::LoggerManager::set_default_logger(\"test_read_clementi_dihedral.log\");\n\n    using real_type = T;\n    {\n        using namespace toml::literals;\n        const toml::value v = u8R\"(\n            env.pi    = 3.14\n            env.gamma = 0.577\n            env.e     = 2.71\n            parameters = [\n                {indices = [1, 2, 3, 4], k1 = \"pi\", k3 = \"gamma\", v0 = \"e\"}\n            ]\n        )\"_toml;\n\n        const auto g = mjolnir::read_local_potential<4,\n              mjolnir::ClementiDihedralPotential<real_type>>(v);\n\n        const std::array<std::size_t, 4> ref_idx{{1, 2, 3, 4}};\n\n        BOOST_TEST(g.size() == 1u);\n        BOOST_TEST(g.at(0).first == ref_idx);\n        BOOST_TEST(g.at(0).second.k1() == real_type(3.14),  tolerance<real_type>());\n        BOOST_TEST(g.at(0).second.k3() == real_type(0.577), tolerance<real_type>());\n        BOOST_TEST(g.at(0).second.v0() == real_type(2.71),  tolerance<real_type>());\n    }\n}\n", "meta": {"hexsha": "d16577e2c409780516db65e581196d6d5eda947f", "size": 4267, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/core/test_read_clementi_dihedral_potential.cpp", "max_stars_repo_name": "yutakasi634/Mjolnir", "max_stars_repo_head_hexsha": "ab7a29a47f994111e8b889311c44487463f02116", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12.0, "max_stars_repo_stars_event_min_datetime": "2017-02-01T08:28:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-25T15:47:51.000Z", "max_issues_repo_path": "test/core/test_read_clementi_dihedral_potential.cpp", "max_issues_repo_name": "Mjolnir-MD/Mjolnir", "max_issues_repo_head_hexsha": "043df4080720837042c6b67a5495ecae198bc2b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 60.0, "max_issues_repo_issues_event_min_datetime": "2019-01-14T08:11:33.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-29T08:26:36.000Z", "max_forks_repo_path": "test/core/test_read_clementi_dihedral_potential.cpp", "max_forks_repo_name": "yutakasi634/Mjolnir", "max_forks_repo_head_hexsha": "ab7a29a47f994111e8b889311c44487463f02116", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8.0, "max_forks_repo_forks_event_min_datetime": "2019-01-13T11:03:31.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-01T11:38:00.000Z", "avg_line_length": 33.5984251969, "max_line_length": 90, "alphanum_fraction": 0.5990157019, "num_tokens": 1254, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091957, "lm_q2_score": 0.12765262366243563, "lm_q1q2_score": 0.06332767891470781}}
{"text": "#include \"leap.h\"\n#define BOOST_TEST_MAIN\n#include <boost/test/unit_test.hpp>\n\nBOOST_AUTO_TEST_CASE(a_known_leap_year)\n{\n    BOOST_REQUIRE(leap::is_leap_year(1996));\n}\n\nBOOST_AUTO_TEST_CASE(any_old_year)\n{\n    BOOST_REQUIRE(!leap::is_leap_year(1997));\n}\n\nBOOST_AUTO_TEST_CASE(turn_of_the_20th_century)\n{\n    BOOST_REQUIRE(!leap::is_leap_year(1900));\n}\n\nBOOST_AUTO_TEST_CASE(turn_of_the_21st_century)\n{\n    BOOST_REQUIRE(leap::is_leap_year(2000));\n}\n\nBOOST_AUTO_TEST_CASE(turn_of_the_25th_century)\n{\n    BOOST_REQUIRE(leap::is_leap_year(2400));\n}\n#if defined(EXERCISM_RUN_ALL_TESTS)\n#endif\n", "meta": {"hexsha": "cd8f9b46b7d99af3d90d97719b860dbbedfd02b5", "size": 589, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "leap/leap_test.cpp", "max_stars_repo_name": "mapa17/Exercism-cpp", "max_stars_repo_head_hexsha": "6f61c33dbe96c1e580d5b98bfc36ca2f59adea60", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "leap/leap_test.cpp", "max_issues_repo_name": "mapa17/Exercism-cpp", "max_issues_repo_head_hexsha": "6f61c33dbe96c1e580d5b98bfc36ca2f59adea60", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "leap/leap_test.cpp", "max_forks_repo_name": "mapa17/Exercism-cpp", "max_forks_repo_head_hexsha": "6f61c33dbe96c1e580d5b98bfc36ca2f59adea60", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.0, "max_line_length": 46, "alphanum_fraction": 0.7860780985, "num_tokens": 169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.45713671682749485, "lm_q2_score": 0.13846179590164853, "lm_q1q2_score": 0.06329597078451829}}
{"text": "/*    This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.\n *    See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.\n *    Author(s):       Vincent Rouvreau\n *\n *    Copyright (C) 2014 Inria\n *\n *    Modification(s):\n *      - YYYY/MM Author: Description of the modification\n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <algorithm>\n#include <utility>  // std::pair, std::make_pair\n#include <cmath>  // float comparison\n#include <limits>\n#include <functional>  // greater\n#include <tuple>  // std::tie\n#include <iterator>  // for std::distance\n#include <cstddef>  // for std::size_t\n\n#define BOOST_TEST_DYN_LINK\n#define BOOST_TEST_MODULE \"simplex_tree\"\n#include <boost/test/unit_test.hpp>\n#include <boost/mpl/list.hpp>\n\n//  ^\n// /!\\ Nothing else from Simplex_tree shall be included to test includes are well defined.\n#include \"gudhi/Simplex_tree.h\"\n\nusing namespace Gudhi;\n\ntypedef boost::mpl::list<Simplex_tree<>, Simplex_tree<Simplex_tree_options_fast_persistence>> list_of_tested_variants;\n\n\ntemplate<class typeST>\nvoid test_empty_simplex_tree(typeST& tst) {\n  typedef typename typeST::Vertex_handle Vertex_handle;\n  const Vertex_handle DEFAULT_VERTEX_VALUE = Vertex_handle(- 1);\n  BOOST_CHECK(tst.null_vertex() == DEFAULT_VERTEX_VALUE);\n  BOOST_CHECK(tst.num_vertices() == (size_t) 0);\n  BOOST_CHECK(tst.num_simplices() == (size_t) 0);\n  typename typeST::Siblings* STRoot = tst.root();\n  BOOST_CHECK(STRoot != nullptr);\n  BOOST_CHECK(STRoot->oncles() == nullptr);\n  BOOST_CHECK(STRoot->parent() == DEFAULT_VERTEX_VALUE);\n  BOOST_CHECK(tst.dimension() == -1);\n}\n\ntemplate<class typeST>\nvoid test_iterators_on_empty_simplex_tree(typeST& tst) {\n  std::clog << \"Iterator on vertices: \" << std::endl;\n  for (auto vertex : tst.complex_vertex_range()) {\n    std::clog << \"vertice:\" << vertex << std::endl;\n    BOOST_CHECK(false); // shall be empty\n  }\n  std::clog << \"Iterator on simplices: \" << std::endl;\n  for (auto simplex : tst.complex_simplex_range()) {\n    BOOST_CHECK(simplex != simplex); // shall be empty - to remove warning of non-used simplex\n  }\n\n  std::clog\n      << \"Iterator on Simplices in the filtration, with [filtration value]:\"\n      << std::endl;\n  for (auto f_simplex : tst.filtration_simplex_range()) {\n    BOOST_CHECK(false); // shall be empty\n    std::clog << \"test_iterators_on_empty_simplex_tree - filtration=\"\n        << tst.filtration(f_simplex) << std::endl;\n  }\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_when_empty, typeST, list_of_tested_variants) {\n  typedef std::pair<typename typeST::Simplex_handle, bool> typePairSimplexBool;\n  typedef std::vector<typename typeST::Vertex_handle> typeVectorVertex;\n\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST OF DEFAULT CONSTRUCTOR\" << std::endl;\n  typeST st;\n\n  test_empty_simplex_tree(st);\n\n  test_iterators_on_empty_simplex_tree(st);\n  // TEST OF EMPTY INSERTION\n  std::clog << \"TEST OF EMPTY INSERTION\" << std::endl;\n  typeVectorVertex simplexVectorEmpty;\n  BOOST_CHECK(simplexVectorEmpty.empty() == true);\n  typePairSimplexBool returnEmptyValue = st.insert_simplex(simplexVectorEmpty, 0.0);\n  BOOST_CHECK(returnEmptyValue.first == typename typeST::Simplex_handle(nullptr));\n  BOOST_CHECK(returnEmptyValue.second == true);\n\n  test_empty_simplex_tree(st);\n\n  test_iterators_on_empty_simplex_tree(st);\n}\n\nbool AreAlmostTheSame(float a, float b) {\n  return std::fabs(a - b) < std::numeric_limits<float>::epsilon();\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_from_file, typeST, list_of_tested_variants) {\n  // TEST OF INSERTION\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST OF SIMPLEX TREE FROM A FILE\" << std::endl;\n  typeST st;\n\n  std::string inputFile(\"simplex_tree_for_unit_test.txt\");\n  std::ifstream simplex_tree_stream(inputFile.c_str());\n  simplex_tree_stream >> st;\n\n  // Display the Simplex_tree\n  std::clog << \"The complex contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  std::clog << \"   - dimension \" << st.dimension() << std::endl;\n\n  // Check\n  BOOST_CHECK(st.num_simplices() == 143353);\n  BOOST_CHECK(st.dimension() == 3);\n\n  int previous_size = 0;\n  for (auto f_simplex : st.filtration_simplex_range()) {\n    // Size of simplex\n    int size = 0;\n    for (auto vertex : st.simplex_vertex_range(f_simplex)) {\n      // Remove warning\n      (void) vertex;\n      size++;\n    }\n    BOOST_CHECK(AreAlmostTheSame(st.filtration(f_simplex), (0.1 * size))); // Specific test: filtration = 0.1 * simplex_size\n    BOOST_CHECK(previous_size <= size); // Check list is sorted (because of sorted filtrations in simplex_tree.txt)\n    previous_size = size;\n  }\n  simplex_tree_stream.close();\n}\n\ntemplate<class typeST, class typeSimplex>\nvoid test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int pos) {\n  auto f_simplex = simplexTree.filtration_simplex_range().begin() + pos;\n\n  std::clog << \"test_simplex_tree_contains - filtration=\" << simplexTree.filtration(*f_simplex) << \"||\" << simplex.second << std::endl;\n  BOOST_CHECK(AreAlmostTheSame(simplexTree.filtration(*f_simplex), simplex.second));\n\n  int simplexIndex = simplex.first.size() - 1;\n  std::sort(simplex.first.begin(), simplex.first.end()); // if the simplex wasn't sorted, the next test could fail\n  for (auto vertex : simplexTree.simplex_vertex_range(*f_simplex)) {\n    std::clog << \"test_simplex_tree_contains - vertex=\" << vertex << \"||\" << simplex.first.at(simplexIndex) << std::endl;\n    BOOST_CHECK(vertex == simplex.first.at(simplexIndex));\n    BOOST_CHECK(simplexIndex >= 0);\n    simplexIndex--;\n  }\n}\n\ntemplate<class typeST, class typePairSimplexBool>\nvoid test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValue) {\n  BOOST_CHECK(returnValue.second == true);\n  // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator\n  typename typeST::Simplex_handle shReturned = returnValue.first;\n  BOOST_CHECK(shReturned != typename typeST::Simplex_handle(nullptr));\n}\n\n// Global variables\nint dim_max = -1;\n\ntemplate<class typeST, class Filtration_value>\nvoid set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, const Filtration_value& fil) {\n  if (vectorSize > dim_max + 1) {\n    dim_max = vectorSize - 1;\n    simplexTree.set_dimension(dim_max);\n    std::clog << \"   set_and_test_simplex_tree_dim_fil - dim_max=\" << dim_max\n        << std::endl;\n  }\n\n  BOOST_CHECK(simplexTree.dimension() == dim_max);\n\n  // Another way to count simplices:\n  size_t num_simp = 0;\n  for (auto f_simplex : simplexTree.complex_simplex_range()) {\n    // Remove warning\n    (void) f_simplex;\n    num_simp++;\n  }\n\n  BOOST_CHECK(simplexTree.num_simplices() == num_simp);\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_variants) {\n  typedef typename typeST::Filtration_value Filtration_value;\n  typedef std::pair<typename typeST::Simplex_handle, bool> typePairSimplexBool;\n  typedef std::vector<typename typeST::Vertex_handle> typeVectorVertex;\n  typedef std::pair<typeVectorVertex, Filtration_value> typeSimplex;\n  const Filtration_value FIRST_FILTRATION_VALUE = 0.1;\n  const Filtration_value SECOND_FILTRATION_VALUE = 0.2;\n  const Filtration_value THIRD_FILTRATION_VALUE = 0.3;\n  const Filtration_value FOURTH_FILTRATION_VALUE = 0.4;\n  // reset since we run the test several times\n  dim_max = -1;\n\n  // TEST OF INSERTION\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST OF INSERTION\" << std::endl;\n  typeST st;\n\n  // ++ FIRST\n  std::clog << \"   - INSERT 0\" << std::endl;\n  typeVectorVertex firstSimplexVector{0};\n  BOOST_CHECK(firstSimplexVector.size() == 1);\n  typeSimplex firstSimplex = std::make_pair(firstSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));\n  typePairSimplexBool returnValue = st.insert_simplex(firstSimplex.first, firstSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, firstSimplexVector.size(), firstSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 1);\n\n  // ++ SECOND\n  std::clog << \"   - INSERT 1\" << std::endl;\n  typeVectorVertex secondSimplexVector{1};\n  BOOST_CHECK(secondSimplexVector.size() == 1);\n  typeSimplex secondSimplex = std::make_pair(secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(secondSimplex.first, secondSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, secondSimplexVector.size(), secondSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 2);\n\n  // ++ THIRD\n  std::clog << \"   - INSERT (0,1)\" << std::endl;\n  typeVectorVertex thirdSimplexVector{0, 1};\n  BOOST_CHECK(thirdSimplexVector.size() == 2);\n  typeSimplex thirdSimplex = std::make_pair(thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(thirdSimplex.first, thirdSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, thirdSimplexVector.size(), thirdSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 2); // Not incremented !!\n\n  // ++ FOURTH\n  std::clog << \"   - INSERT 2\" << std::endl;\n  typeVectorVertex fourthSimplexVector{2};\n  BOOST_CHECK(fourthSimplexVector.size() == 1);\n  typeSimplex fourthSimplex = std::make_pair(fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(fourthSimplex.first, fourthSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, fourthSimplexVector.size(), fourthSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 3);\n\n  // ++ FIFTH\n  std::clog << \"   - INSERT (2,0)\" << std::endl;\n  typeVectorVertex fifthSimplexVector{2, 0};\n  BOOST_CHECK(fifthSimplexVector.size() == 2);\n  typeSimplex fifthSimplex = std::make_pair(fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(fifthSimplex.first, fifthSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, fifthSimplexVector.size(), fifthSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !!\n\n  // ++ SIXTH\n  std::clog << \"   - INSERT (2,1)\" << std::endl;\n  typeVectorVertex sixthSimplexVector{2, 1};\n  BOOST_CHECK(sixthSimplexVector.size() == 2);\n  typeSimplex sixthSimplex = std::make_pair(sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(sixthSimplex.first, sixthSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, sixthSimplexVector.size(), sixthSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !!\n\n  // ++ SEVENTH\n  std::clog << \"   - INSERT (2,1,0)\" << std::endl;\n  typeVectorVertex seventhSimplexVector{2, 1, 0};\n  BOOST_CHECK(seventhSimplexVector.size() == 3);\n  typeSimplex seventhSimplex = std::make_pair(seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(seventhSimplex.first, seventhSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, seventhSimplexVector.size(), seventhSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !!\n\n  // ++ EIGHTH\n  std::clog << \"   - INSERT 3\" << std::endl;\n  typeVectorVertex eighthSimplexVector{3};\n  BOOST_CHECK(eighthSimplexVector.size() == 1);\n  typeSimplex eighthSimplex = std::make_pair(eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(eighthSimplex.first, eighthSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, eighthSimplexVector.size(), eighthSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 4);\n\n  // ++ NINETH\n  std::clog << \"   - INSERT (3,0)\" << std::endl;\n  typeVectorVertex ninethSimplexVector{3, 0};\n  BOOST_CHECK(ninethSimplexVector.size() == 2);\n  typeSimplex ninethSimplex = std::make_pair(ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(ninethSimplex.first, ninethSimplex.second);\n\n  test_simplex_tree_insert_returns_true<typeST>(returnValue);\n  set_and_test_simplex_tree_dim_fil(st, ninethSimplexVector.size(), ninethSimplex.second);\n  BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !!\n\n  // ++ TENTH\n  std::clog << \"   - INSERT 0 (already inserted)\" << std::endl;\n  typeVectorVertex tenthSimplexVector{0};\n  BOOST_CHECK(tenthSimplexVector.size() == 1);\n  // With a different filtration value\n  typeSimplex tenthSimplex = std::make_pair(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(tenthSimplex.first, tenthSimplex.second);\n\n  BOOST_CHECK(returnValue.second == false);\n  // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator\n  typename typeST::Simplex_handle shReturned = returnValue.first;\n  BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr));\n  std::clog << \"st.num_vertices()=\" << st.num_vertices() << std::endl;\n  BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !!\n  BOOST_CHECK(st.dimension() == dim_max);\n\n  // ++ ELEVENTH\n  std::clog << \"   - INSERT (2,1,0) (already inserted)\" << std::endl;\n  typeVectorVertex eleventhSimplexVector{2, 1, 0};\n  BOOST_CHECK(eleventhSimplexVector.size() == 3);\n  typeSimplex eleventhSimplex = std::make_pair(eleventhSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE));\n  returnValue = st.insert_simplex(eleventhSimplex.first, eleventhSimplex.second);\n\n  BOOST_CHECK(returnValue.second == false);\n  // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator\n  shReturned = returnValue.first;\n  BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr));\n  BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !!\n  BOOST_CHECK(st.dimension() == dim_max);\n\n  /* Inserted simplex:        */\n  /*    1                     */\n  /*    o                     */\n  /*   /X\\                    */\n  /*  o---o---o               */\n  /*  2   0   3               */\n\n  //   [0.1] 0\n  //   [0.1] 1\n  //   [0.1] 2\n  //   [0.1] 3\n  //   [0.2] 1 0\n  //   [0.2] 2 0\n  //   [0.2] 2 1\n  //   [0.2] 3 0\n  //   [0.3] 2 1 0\n  //  !! Be careful, simplex are sorted by filtration value on insertion !!\n  std::clog << \"simplex_tree_insertion - first - 0\" << std::endl;\n  test_simplex_tree_contains(st, firstSimplex, 0); // (0) -> 0\n  std::clog << \"simplex_tree_insertion - second - 1\" << std::endl;\n  test_simplex_tree_contains(st, secondSimplex, 1); // (1) -> 1\n  std::clog << \"simplex_tree_insertion - third - 4\" << std::endl;\n  test_simplex_tree_contains(st, thirdSimplex, 4); // (0,1) -> 4\n  std::clog << \"simplex_tree_insertion - fourth - 2\" << std::endl;\n  test_simplex_tree_contains(st, fourthSimplex, 2); // (2) -> 2\n  std::clog << \"simplex_tree_insertion - fifth - 5\" << std::endl;\n  test_simplex_tree_contains(st, fifthSimplex, 5); // (2,0) -> 5\n  std::clog << \"simplex_tree_insertion - sixth - 6\" << std::endl;\n  test_simplex_tree_contains(st, sixthSimplex, 6); //(2,1) -> 6\n  std::clog << \"simplex_tree_insertion - seventh - 8\" << std::endl;\n  test_simplex_tree_contains(st, seventhSimplex, 8); // (2,1,0) -> 8\n  std::clog << \"simplex_tree_insertion - eighth - 3\" << std::endl;\n  test_simplex_tree_contains(st, eighthSimplex, 3); // (3) -> 3\n  std::clog << \"simplex_tree_insertion - nineth - 7\" << std::endl;\n  test_simplex_tree_contains(st, ninethSimplex, 7); // (3,0) -> 7\n\n  // Display the Simplex_tree - Can not be done in the middle of 2 inserts\n  std::clog << \"The complex contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  std::clog << \"   - dimension \" << st.dimension() << std::endl;\n  std::clog << std::endl << std::endl << \"Iterator on Simplices in the filtration, with [filtration value]:\" << std::endl;\n  for (auto f_simplex : st.filtration_simplex_range()) {\n    std::clog << \"   \" << \"[\" << st.filtration(f_simplex) << \"] \";\n    for (auto vertex : st.simplex_vertex_range(f_simplex)) {\n      std::clog << (int) vertex << \" \";\n    }\n    std::clog << std::endl;\n  }\n\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_of_tested_variants) {\n  typedef std::pair<typename typeST::Simplex_handle, bool> typePairSimplexBool;\n  typedef std::vector<typename typeST::Vertex_handle> typeVectorVertex;\n  typedef std::pair<typeVectorVertex, typename typeST::Filtration_value> typeSimplex;\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST OF RECURSIVE INSERTION\" << std::endl;\n  typeST st;\n  typePairSimplexBool returnValue;\n  int position = 0;\n\n  // ++ FIRST\n  std::clog << \"   - INSERT (2,1,0)\" << std::endl;\n  typeVectorVertex SimplexVector1{2, 1, 0};\n  BOOST_CHECK(SimplexVector1.size() == 3);\n  returnValue = st.insert_simplex_and_subfaces(SimplexVector1);\n\n  BOOST_CHECK(st.num_vertices() == (size_t) 3); // +3 (2, 1 and 0 are not existing)\n\n  // Check it is well inserted\n  BOOST_CHECK(true == returnValue.second);\n  position = 0;\n  std::sort(SimplexVector1.begin(), SimplexVector1.end(), std::greater<typename typeST::Vertex_handle>());\n  for (auto vertex : st.simplex_vertex_range(returnValue.first)) {\n    // Check returned Simplex_handle\n    std::clog << \"vertex = \" << vertex << \" | vector[\" << position << \"] = \" << SimplexVector1[position] << std::endl;\n    BOOST_CHECK(vertex == SimplexVector1[position]);\n    position++;\n  }\n\n  // ++ SECOND\n  std::clog << \"   - INSERT 3\" << std::endl;\n  typeVectorVertex SimplexVector2{3};\n  BOOST_CHECK(SimplexVector2.size() == 1);\n  returnValue = st.insert_simplex_and_subfaces(SimplexVector2);\n\n  BOOST_CHECK(st.num_vertices() == (size_t) 4); // +1 (3 is not existing)\n\n  // Check it is well inserted\n  BOOST_CHECK(true == returnValue.second);\n  position = 0;\n  std::sort(SimplexVector2.begin(), SimplexVector2.end(), std::greater<typename typeST::Vertex_handle>());\n  for (auto vertex : st.simplex_vertex_range(returnValue.first)) {\n    // Check returned Simplex_handle\n    std::clog << \"vertex = \" << vertex << \" | vector[\" << position << \"] = \" << SimplexVector2[position] << std::endl;\n    BOOST_CHECK(vertex == SimplexVector2[position]);\n    position++;\n  }\n\n  // ++ THIRD\n  std::clog << \"   - INSERT (0,3)\" << std::endl;\n  typeVectorVertex SimplexVector3{3, 0};\n  BOOST_CHECK(SimplexVector3.size() == 2);\n  returnValue = st.insert_simplex_and_subfaces(SimplexVector3);\n\n  BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented (all are existing)\n\n  // Check it is well inserted\n  BOOST_CHECK(true == returnValue.second);\n  position = 0;\n  std::sort(SimplexVector3.begin(), SimplexVector3.end(), std::greater<typename typeST::Vertex_handle>());\n  for (auto vertex : st.simplex_vertex_range(returnValue.first)) {\n    // Check returned Simplex_handle\n    std::clog << \"vertex = \" << vertex << \" | vector[\" << position << \"] = \" << SimplexVector3[position] << std::endl;\n    BOOST_CHECK(vertex == SimplexVector3[position]);\n    position++;\n  }\n\n  // ++ FOURTH\n  std::clog << \"   - INSERT (1,0) (already inserted)\" << std::endl;\n  typeVectorVertex SimplexVector4{1, 0};\n  BOOST_CHECK(SimplexVector4.size() == 2);\n  returnValue = st.insert_simplex_and_subfaces(SimplexVector4);\n\n  BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented (all are existing)\n\n  // Check it was not inserted (already there from {2,1,0} insertion)\n  BOOST_CHECK(false == returnValue.second);\n\n  // ++ FIFTH\n  std::clog << \"   - INSERT (3,4,5)\" << std::endl;\n  typeVectorVertex SimplexVector5{3, 4, 5};\n  BOOST_CHECK(SimplexVector5.size() == 3);\n  returnValue = st.insert_simplex_and_subfaces(SimplexVector5);\n\n  BOOST_CHECK(st.num_vertices() == (size_t) 6);\n\n  // Check it is well inserted\n  BOOST_CHECK(true == returnValue.second);\n  position = 0;\n  std::sort(SimplexVector5.begin(), SimplexVector5.end(), std::greater<typename typeST::Vertex_handle>());\n  for (auto vertex : st.simplex_vertex_range(returnValue.first)) {\n    // Check returned Simplex_handle\n    std::clog << \"vertex = \" << vertex << \" | vector[\" << position << \"] = \" << SimplexVector5[position] << std::endl;\n    BOOST_CHECK(vertex == SimplexVector5[position]);\n    position++;\n  }\n\n  // ++ SIXTH\n  std::clog << \"   - INSERT (0,1,6,7)\" << std::endl;\n  typeVectorVertex SimplexVector6{0, 1, 6, 7};\n  BOOST_CHECK(SimplexVector6.size() == 4);\n  returnValue = st.insert_simplex_and_subfaces(SimplexVector6);\n\n  BOOST_CHECK(st.num_vertices() == (size_t) 8); // +2 (6 and 7 are not existing - 0 and 1 are already existing)\n\n  // Check it is well inserted\n  BOOST_CHECK(true == returnValue.second);\n  position = 0;\n  std::sort(SimplexVector6.begin(), SimplexVector6.end(), std::greater<typename typeST::Vertex_handle>());\n  for (auto vertex : st.simplex_vertex_range(returnValue.first)) {\n    // Check returned Simplex_handle\n    std::clog << \"vertex = \" << vertex << \" | vector[\" << position << \"] = \" << SimplexVector6[position] << std::endl;\n    BOOST_CHECK(vertex == SimplexVector6[position]);\n    position++;\n  }\n  \n  /* Inserted simplex:        */\n  /*    1   6                 */\n  /*    o---o                 */\n  /*   /X\\7/                  */\n  /*  o---o---o---o           */\n  /*  2   0   3\\X/4           */\n  /*            o             */\n  /*            5             */\n  /*                          */\n  /* In other words:          */\n  /*   A facet [2,1,0]        */\n  /*   An edge [0,3]          */\n  /*   A facet [3,4,5]        */\n  /*   A cell  [0,1,6,7]      */\n\n  typeSimplex simplexPair1 = std::make_pair(SimplexVector1, 0.0);\n  typeSimplex simplexPair2 = std::make_pair(SimplexVector2, 0.0);\n  typeSimplex simplexPair3 = std::make_pair(SimplexVector3, 0.0);\n  typeSimplex simplexPair4 = std::make_pair(SimplexVector4, 0.0);\n  typeSimplex simplexPair5 = std::make_pair(SimplexVector5, 0.0);\n  typeSimplex simplexPair6 = std::make_pair(SimplexVector6, 0.0);\n  test_simplex_tree_contains(st, simplexPair1, 6); // (2,1,0) is in position 6\n  test_simplex_tree_contains(st, simplexPair2, 7); // (3) is in position 7\n  test_simplex_tree_contains(st, simplexPair3, 8); // (3,0) is in position 8\n  test_simplex_tree_contains(st, simplexPair4, 2); // (1,0) is in position 2\n  test_simplex_tree_contains(st, simplexPair5, 14); // (3,4,5) is in position 14\n  test_simplex_tree_contains(st, simplexPair6, 26); // (7,6,1,0) is in position 26\n\n  // ------------------------------------------------------------------------------------------------------------------\n  // Find in the simplex_tree\n  // ------------------------------------------------------------------------------------------------------------------\n  typeVectorVertex simpleSimplexVector{1};\n  typename typeST::Simplex_handle simplexFound = st.find(simpleSimplexVector);\n  std::clog << \"**************IS THE SIMPLEX {1} IN THE SIMPLEX TREE ?\\n\";\n  if (simplexFound != st.null_simplex())\n    std::clog << \"***+ YES IT IS!\\n\";\n  else\n    std::clog << \"***- NO IT ISN'T\\n\";\n  // Check it is found\n  BOOST_CHECK(simplexFound != st.null_simplex());\n\n  typeVectorVertex unknownSimplexVector{15};\n  simplexFound = st.find(unknownSimplexVector);\n  std::clog << \"**************IS THE SIMPLEX {15} IN THE SIMPLEX TREE ?\\n\";\n  if (simplexFound != st.null_simplex())\n    std::clog << \"***+ YES IT IS!\\n\";\n  else\n    std::clog << \"***- NO IT ISN'T\\n\";\n  // Check it is NOT found\n  BOOST_CHECK(simplexFound == st.null_simplex());\n\n  simplexFound = st.find(SimplexVector6);\n  std::clog << \"**************IS THE SIMPLEX {0,1,6,7} IN THE SIMPLEX TREE ?\\n\";\n  if (simplexFound != st.null_simplex())\n    std::clog << \"***+ YES IT IS!\\n\";\n  else\n    std::clog << \"***- NO IT ISN'T\\n\";\n  // Check it is found\n  BOOST_CHECK(simplexFound != st.null_simplex());\n\n  typeVectorVertex otherSimplexVector{1, 15};\n  simplexFound = st.find(otherSimplexVector);\n  std::clog << \"**************IS THE SIMPLEX {15,1} IN THE SIMPLEX TREE ?\\n\";\n  if (simplexFound != st.null_simplex())\n    std::clog << \"***+ YES IT IS!\\n\";\n  else\n    std::clog << \"***- NO IT ISN'T\\n\";\n  // Check it is NOT found\n  BOOST_CHECK(simplexFound == st.null_simplex());\n\n  typeVectorVertex invSimplexVector{1, 2, 0};\n  simplexFound = st.find(invSimplexVector);\n  std::clog << \"**************IS THE SIMPLEX {1,2,0} IN THE SIMPLEX TREE ?\\n\";\n  if (simplexFound != st.null_simplex())\n    std::clog << \"***+ YES IT IS!\\n\";\n  else\n    std::clog << \"***- NO IT ISN'T\\n\";\n  // Check it is found\n  BOOST_CHECK(simplexFound != st.null_simplex());\n\n  // Display the Simplex_tree - Can not be done in the middle of 2 inserts\n  std::clog << \"The complex contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  std::clog << \"   - dimension \" << st.dimension() << std::endl;\n  std::clog << std::endl << std::endl << \"Iterator on Simplices in the filtration, with [filtration value]:\" << std::endl;\n  for (auto f_simplex : st.filtration_simplex_range()) {\n    std::clog << \"   \" << \"[\" << st.filtration(f_simplex) << \"] \";\n    for (auto vertex : st.simplex_vertex_range(f_simplex)) {\n      std::clog << (int) vertex << \" \";\n    }\n    std::clog << std::endl;\n  }\n}\n\ntemplate<class typeST, class Vertex_handle>\nvoid test_cofaces(typeST& st, const std::vector<Vertex_handle>& expected, int dim, const std::vector<typename typeST::Simplex_handle>& res) {\n  typename typeST::Cofaces_simplex_range cofaces;\n  if (dim == 0)\n    cofaces = st.star_simplex_range(st.find(expected));\n  else\n    cofaces = st.cofaces_simplex_range(st.find(expected), dim);\n  for (auto simplex = cofaces.begin(); simplex != cofaces.end(); ++simplex) {\n    typename typeST::Simplex_vertex_range rg = st.simplex_vertex_range(*simplex);\n    for (auto vertex = rg.begin(); vertex != rg.end(); ++vertex) {\n      std::clog << \"(\" << *vertex << \")\";\n    }\n    std::clog << std::endl;\n    BOOST_CHECK(std::find(res.begin(), res.end(), *simplex) != res.end());\n  }\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_variants) {\n  typedef std::vector<typename typeST::Vertex_handle> typeVectorVertex;\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST COFACE ALGORITHM\" << std::endl;\n  typeST st;\n\n  typeVectorVertex SimplexVector{2, 1, 0};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  SimplexVector = {3, 0};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  SimplexVector = {3, 4, 5};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  SimplexVector = {0, 1, 6, 7};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  /* Inserted simplex:        */\n  /*    1   6                 */\n  /*    o---o                 */\n  /*   /X\\7/                  */\n  /*  o---o---o---o           */\n  /*  2   0   3\\X/4           */\n  /*            o             */\n  /*            5             */\n\n  std::vector<typename typeST::Vertex_handle> simplex_result;\n  std::vector<typename typeST::Simplex_handle> result;\n  std::clog << \"First test - Star of (3):\" << std::endl;\n\n  simplex_result = {3};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {3, 0};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {4, 3};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {5, 4, 3};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {5, 3};\n  result.push_back(st.find(simplex_result));\n  simplex_result.clear();\n\n  std::vector<typename typeST::Vertex_handle> vertex = {3};\n  test_cofaces(st, vertex, 0, result);\n  vertex.clear();\n  result.clear();\n\n  vertex.push_back(1);\n  vertex.push_back(7);\n  std::clog << \"Second test - Star of (1,7): \" << std::endl;\n\n  simplex_result = {7, 1};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {7, 6, 1, 0};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {7, 1, 0};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {7, 6, 1};\n  result.push_back(st.find(simplex_result));\n\n  test_cofaces(st, vertex, 0, result);\n  result.clear();\n\n  std::clog << \"Third test - 2-dimension Cofaces of simplex(1,7) : \" << std::endl;\n\n  simplex_result = {7, 1, 0};\n  result.push_back(st.find(simplex_result));\n\n  simplex_result = {7, 6, 1};\n  result.push_back(st.find(simplex_result));\n\n  test_cofaces(st, vertex, 1, result);\n  result.clear();\n\n  std::clog << \"Cofaces with a codimension too high (codimension + vetices > tree.dimension) :\" << std::endl;\n  test_cofaces(st, vertex, 5, result);\n\n  //std::clog << \"Cofaces with an empty codimension\" << std::endl;\n  //test_cofaces(st, vertex, -1, result);\n  //    std::clog << \"Cofaces in an empty simplex tree\" << std::endl;\n  //   typeST empty_tree;\n  //    test_cofaces(empty_tree, vertex, 1, result);\n  //std::clog << \"Cofaces of an empty simplex\" << std::endl;\n  //vertex.clear();\n  // test_cofaces(st, vertex, 1, result);\n\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(copy_move_on_simplex_tree, typeST, list_of_tested_variants) {\n  typedef std::vector<typename typeST::Vertex_handle> typeVectorVertex;\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST COPY MOVE CONSTRUCTORS\" << std::endl;\n  typeST st;\n\n  typeVectorVertex SimplexVector{2, 1, 0};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  SimplexVector = {3, 0};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  SimplexVector = {3, 4, 5};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  SimplexVector = {0, 1, 6, 7};\n  st.insert_simplex_and_subfaces(SimplexVector);\n\n  /* Inserted simplex:        */\n  /*    1   6                 */\n  /*    o---o                 */\n  /*   /X\\7/                  */\n  /*  o---o---o---o           */\n  /*  2   0   3\\X/4           */\n  /*            o             */\n  /*            5             */\n\n  std::clog << \"Printing st - address = \" << &st << std::endl;\n\n  // Copy constructor  \n  typeST st_copy = st;\n  std::clog << \"Printing a copy of st - address = \" << &st_copy << std::endl;\n\n  // Check the data are the same\n  BOOST_CHECK(st == st_copy);\n  // Check there is a new simplex tree reference\n  BOOST_CHECK(&st != &st_copy);\n\n  // Move constructor  \n  typeST st_move = std::move(st);\n  std::clog << \"Printing a move of st - address = \" << &st_move << std::endl;\n\n  // Check the data are the same\n  BOOST_CHECK(st_move == st_copy);\n  // Check there is a new simplex tree reference\n  BOOST_CHECK(&st_move != &st_copy);\n  BOOST_CHECK(&st_move != &st);\n  \n  typeST st_empty;\n  // Check st has been emptied by the move\n  BOOST_CHECK(st == st_empty);\n  BOOST_CHECK(st.dimension() == -1);\n  BOOST_CHECK(st.num_simplices() == 0);\n  BOOST_CHECK(st.num_vertices() == (size_t)0);\n  \n  std::clog << \"Printing st once again- address = \" << &st << std::endl;\n}\n\ntemplate<class typeST>\nvoid test_simplex_is_vertex(typeST& st, typename typeST::Simplex_handle sh, typename typeST::Vertex_handle v) {\n  BOOST_CHECK(st.dimension(sh) == 0);\n  auto&& r = st.simplex_vertex_range(sh);\n  auto i = std::begin(r);\n  BOOST_CHECK(*i == v);\n  BOOST_CHECK(++i == std::end(r));\n}\n\nBOOST_AUTO_TEST_CASE(non_contiguous) {\n  typedef Simplex_tree<> typeST;\n  typedef typeST::Simplex_handle Simplex_handle;\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST NON-CONTIGUOUS VERTICES\" << std::endl;\n  typeST st;\n  typeST::Vertex_handle e[] = {3,-7};\n  std::clog << \"Insert\" << std::endl;\n  st.insert_simplex_and_subfaces(e);\n  BOOST_CHECK(st.num_vertices() == 2);\n  BOOST_CHECK(st.num_simplices() == 3);\n  std::clog << \"Find\" << std::endl;\n  Simplex_handle sh = st.find(e);\n  BOOST_CHECK(sh != st.null_simplex());\n  std::clog << \"Endpoints\" << std::endl;\n  auto p = st.endpoints(sh);\n  test_simplex_is_vertex(st, p.first, 3);\n  test_simplex_is_vertex(st, p.second, -7);\n  std::clog << \"Boundary\" << std::endl;\n  auto&& b = st.boundary_simplex_range(sh);\n  auto i = std::begin(b);\n  test_simplex_is_vertex(st, *i, -7);\n  test_simplex_is_vertex(st, *++i, 3);\n  BOOST_CHECK(++i == std::end(b));\n}\n\n\ntypedef boost::mpl::list<boost::adjacency_list<boost::setS, boost::vecS, boost::directedS,\n                                               boost::property<vertex_filtration_t, double>,\n                                               boost::property<edge_filtration_t, double>>,\n                         boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS,\n                                               boost::property<vertex_filtration_t, double>,\n                                               boost::property<edge_filtration_t, double>>,\n                         boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS,\n                                               boost::property<vertex_filtration_t, double>,\n                                               boost::property<edge_filtration_t, double>>,\n                         boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,\n                                               boost::property<vertex_filtration_t, double>,\n                                               boost::property<edge_filtration_t, double>>,\n                         boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,\n                                               boost::property<vertex_filtration_t, double>,\n                                               boost::property<edge_filtration_t, double>>,\n                         boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,\n                                               boost::property<vertex_filtration_t, double>,\n                                               boost::property<edge_filtration_t, double>>> list_of_graph_variants;\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insert_graph, Graph, list_of_graph_variants) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"INSERT GRAPH\" << std::endl;\n\n  Graph g(3);\n  // filtration value 0 everywhere\n  put(Gudhi::vertex_filtration_t(), g, 0, 0);\n  put(Gudhi::vertex_filtration_t(), g, 1, 0);\n  put(Gudhi::vertex_filtration_t(), g, 2, 0);\n  // vertices don't always occur in sorted order\n  add_edge(0, 1, 1.1, g);\n  add_edge(2, 0, 2.2, g);\n  add_edge(2, 1, 3.3, g);\n\n  Simplex_tree<> st1;\n  st1.insert_graph(g);\n  BOOST_CHECK(st1.num_simplices() == 6);\n\n  // edges can have multiplicity in the graph unless we replace the first vecS with (hash_)setS\n  add_edge(1, 0, 1.1, g);\n  add_edge(1, 2, 3.3, g);\n  add_edge(0, 2, 2.2, g);\n  add_edge(0, 1, 1.1, g);\n  add_edge(2, 1, 3.3, g);\n  add_edge(2, 0, 2.2, g);\n  Simplex_tree<> st2;\n  st2.insert_graph(g);\n  BOOST_CHECK(st2.num_simplices() == 6);\n\n  std::clog << \"st1 is\" << std::endl;\n  std::clog << st1 << std::endl;\n\n  std::clog << \"st2 is\" << std::endl;\n  std::clog << st2 << std::endl;\n\n  BOOST_CHECK(st1 == st2);\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(insert_duplicated_vertices, typeST, list_of_tested_variants) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST INSERT DUPLICATED VERTICES\" << std::endl;\n  typeST st;\n\n  typename typeST::Simplex_handle sh;\n  bool success = false;\n  std::tie(sh, success) = st.insert_simplex_and_subfaces({1});\n  BOOST_CHECK(success);\n  BOOST_CHECK(sh != st.null_simplex());\n  std::clog << \"st.dimension(sh)= \" << st.dimension(sh) << std::endl;\n  BOOST_CHECK(st.dimension(sh) == 0);\n  std::tie(sh, success) = st.insert_simplex_and_subfaces({2, 2});\n  BOOST_CHECK(success);\n  BOOST_CHECK(sh != st.null_simplex());\n  std::clog << \"st.dimension(sh)= \" << st.dimension(sh) << std::endl;\n  BOOST_CHECK(st.dimension(sh) == 0);\n  std::tie(sh, success) = st.insert_simplex_and_subfaces({3, 3, 3});\n  BOOST_CHECK(success);\n  BOOST_CHECK(sh != st.null_simplex());\n  std::clog << \"st.dimension(sh)= \" << st.dimension(sh) << std::endl;\n  BOOST_CHECK(st.dimension(sh) == 0);\n  std::tie(sh, success) = st.insert_simplex_and_subfaces({4, 4, 4, 4});\n  BOOST_CHECK(success);\n  BOOST_CHECK(sh != st.null_simplex());\n  std::clog << \"st.dimension(sh)= \" << st.dimension(sh) << std::endl;\n  BOOST_CHECK(st.dimension(sh) == 0);\n\n  std::clog << \"dimension =\" << st.dimension() << \" - num_vertices = \" << st.num_vertices()\n            << \" - num_simplices = \" << st.num_simplices() << std::endl;\n  BOOST_CHECK(st.dimension() == 0);\n  BOOST_CHECK(st.num_simplices() == st.num_vertices());\n\n  std::tie(sh, success) = st.insert_simplex_and_subfaces({2, 1, 1, 2});\n  BOOST_CHECK(success);\n  BOOST_CHECK(sh != st.null_simplex());\n  std::clog << \"st.dimension(sh)= \" << st.dimension(sh) << std::endl;\n  BOOST_CHECK(st.dimension(sh) == 1);\n\n  std::clog << \"dimension =\" << st.dimension() << \" - num_vertices = \" << st.num_vertices()\n            << \" - num_simplices = \" << st.num_simplices() << std::endl;\n  BOOST_CHECK(st.dimension() == 1);\n  BOOST_CHECK(st.num_simplices() == st.num_vertices() + 1);\n\n  // Already inserted\n  std::tie(sh, success) = st.insert_simplex_and_subfaces({1, 2, 2, 1});\n  BOOST_CHECK(!success);\n  BOOST_CHECK(sh == st.null_simplex());\n\n  std::clog << \"dimension =\" << st.dimension() << \" - num_vertices = \" << st.num_vertices()\n            << \" - num_simplices = \" << st.num_simplices() << std::endl;\n  BOOST_CHECK(st.dimension() == 1);\n  BOOST_CHECK(st.num_simplices() == st.num_vertices() + 1);\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(generators, typeST, list_of_tested_variants) {\n  std::cout << \"********************************************************************\" << std::endl;\n  std::cout << \"TEST FIND GENERATORS\" << std::endl;\n  {\n    typeST st;\n    st.insert_simplex_and_subfaces({0,1,2,3,4,5,6},0);\n    st.assign_filtration(st.find({0,2,4}), 10);\n    st.assign_filtration(st.find({1,5}), 20);\n    st.assign_filtration(st.find({1,2,4}), 30);\n    st.assign_filtration(st.find({3}), 5);\n    st.make_filtration_non_decreasing();\n    BOOST_CHECK(st.filtration(st.find({1,2}))==0);\n    BOOST_CHECK(st.filtration(st.find({0,1,2,3,4}))==30);\n    BOOST_CHECK(st.minimal_simplex_with_same_filtration(st.find({0,1,2,3,4,5}))==st.find({1,2,4}));\n    BOOST_CHECK(st.minimal_simplex_with_same_filtration(st.find({0,2,3}))==st.find({3}));\n    auto s=st.minimal_simplex_with_same_filtration(st.find({0,2,6}));\n    BOOST_CHECK(s==st.find({0})||s==st.find({2})||s==st.find({6}));\n    BOOST_CHECK(st.vertex_with_same_filtration(st.find({2}))==2);\n    BOOST_CHECK(st.vertex_with_same_filtration(st.find({1,5}))==st.null_vertex());\n    BOOST_CHECK(st.vertex_with_same_filtration(st.find({5,6}))>=5);\n  }\n  {\n    typeST st;\n    st.insert_simplex_and_subfaces({0,1}, 8);\n    st.insert_simplex_and_subfaces({0,2}, 10);\n    st.insert_simplex_and_subfaces({3,4}, 6);\n    st.insert_simplex_and_subfaces({1,2}, 5);\n    st.insert_simplex_and_subfaces({1,5}, 4);\n    st.insert_simplex_and_subfaces({0,5}, 3);\n    st.insert_simplex_and_subfaces({2,5}, 2);\n    st.insert_simplex_and_subfaces({1,3}, 9);\n    st.expansion(50);\n    BOOST_CHECK(st.edge_with_same_filtration(st.find({0,1,2,5}))==st.find({0,2}));\n    BOOST_CHECK(st.edge_with_same_filtration(st.find({1,5}))==st.find({1,5}));\n  }\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_reset_filtration, typeST, list_of_tested_variants) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST RESET FILTRATION\" << std::endl;\n  typeST st;\n\n  st.insert_simplex_and_subfaces({2, 1, 0}, 3.);\n  st.insert_simplex_and_subfaces({3, 0}, 2.);\n  st.insert_simplex_and_subfaces({3, 4, 5}, 3.);\n  st.insert_simplex_and_subfaces({0, 1, 6, 7}, 4.);\n\n  /* Inserted simplex:        */\n  /*    1   6                 */\n  /*    o---o                 */\n  /*   /X\\7/                  */\n  /*  o---o---o---o           */\n  /*  2   0   3\\X/4           */\n  /*            o             */\n  /*            5             */\n\n  for (auto f_simplex : st.skeleton_simplex_range(3)) {\n    std::clog << \"vertex = (\";\n    for (auto vertex : st.simplex_vertex_range(f_simplex)) {\n      std::clog << vertex << \",\";\n    }\n    std::clog << \") - filtration = \" << st.filtration(f_simplex);\n    std::clog << \" - dimension = \" << st.dimension(f_simplex) << std::endl;\n    // Guaranteed by construction\n    BOOST_CHECK(st.filtration(f_simplex) >= 2.);\n  }\n\n  // dimension until 5 even if simplex tree is of dimension 3 to test the limits\n  for(int dimension = 5; dimension >= 0; dimension --) {\n    std::clog << \"### reset_filtration - dimension = \" << dimension << \"\\n\";\n    st.reset_filtration(0., dimension);\n    for (auto f_simplex : st.skeleton_simplex_range(3)) {\n      std::clog << \"vertex = (\";\n      for (auto vertex : st.simplex_vertex_range(f_simplex)) {\n        std::clog << vertex << \",\";\n      }\n      std::clog << \") - filtration = \" << st.filtration(f_simplex);\n      std::clog << \" - dimension = \" << st.dimension(f_simplex) << std::endl;\n      if (st.dimension(f_simplex) < dimension)\n        BOOST_CHECK(st.filtration(f_simplex) >= 2.);\n      else\n        BOOST_CHECK(st.filtration(f_simplex) == 0.);\n    }\n  }\n\n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_boundaries_and_opposite_vertex_iterator, typeST, list_of_tested_variants) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"TEST OF BOUNDARIES AND OPPOSITE VERTEX ITERATORS\" << std::endl;\n  typeST st;\n\n  st.insert_simplex_and_subfaces({2, 1, 0}, 3.);\n  st.insert_simplex_and_subfaces({3, 0}, 2.);\n  st.insert_simplex_and_subfaces({3, 4, 5}, 3.);\n  st.insert_simplex_and_subfaces({0, 1, 6, 7}, 4.);\n\n  /* Inserted simplex:        */\n  /*    1   6                 */\n  /*    o---o                 */\n  /*   /X\\7/                  */\n  /*  o---o---o---o           */\n  /*  2   0   3\\X/4           */\n  /*            o             */\n  /*            5             */\n  using Simplex = std::vector<typename typeST::Vertex_handle>;\n  // simplices must be kept sorted by vertex number for std::vector to use operator== - cf. last BOOST_CHECK\n  std::vector<Simplex> simplices = {{0, 1, 2}, {0, 3}, {0, 1, 6, 7}, {3, 4, 5}, {3, 5}, {2}};\n  for (auto simplex : simplices) {\n    Simplex opposite_vertices;\n    for(auto boundary_and_opposite_vertex : st.boundary_opposite_vertex_simplex_range(st.find(simplex))) {\n      Simplex output;\n      for (auto vertex : st.simplex_vertex_range(boundary_and_opposite_vertex.first)) {\n        std::clog << vertex << \" \";\n        output.emplace_back(vertex);\n      }\n      std::clog << \" - opposite vertex = \" << boundary_and_opposite_vertex.second << std::endl;\n      // Check that boundary simplex + opposite vertex = simplex given as input\n      output.emplace_back(boundary_and_opposite_vertex.second);\n      std::sort(output.begin(), output.end());\n      BOOST_CHECK(simplex == output);\n      opposite_vertices.emplace_back(boundary_and_opposite_vertex.second);\n    }\n    // Check that the list of all opposite vertices = simplex given as input\n    // no opposite vertices if simplex given as input is of dimension 1\n    std::sort(opposite_vertices.begin(), opposite_vertices.end());\n    if (simplex.size() > 1)\n      BOOST_CHECK(simplex == opposite_vertices);\n    else\n      BOOST_CHECK(opposite_vertices.size() == 0);\n  }\n}\n", "meta": {"hexsha": "b18e2ec4429a7188867410ce2c3666e98a374a34", "size": 43564, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/Simplex_tree/test/simplex_tree_unit_test.cpp", "max_stars_repo_name": "MathieuCarriere/gudhi-devel", "max_stars_repo_head_hexsha": "1631c51ef9aaecbdb8f2230ab17cfc9626a4a5b3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-06-21T14:00:27.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-21T14:00:27.000Z", "max_issues_repo_path": "src/Simplex_tree/test/simplex_tree_unit_test.cpp", "max_issues_repo_name": "MathieuCarriere/gudhi-devel", "max_issues_repo_head_hexsha": "1631c51ef9aaecbdb8f2230ab17cfc9626a4a5b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Simplex_tree/test/simplex_tree_unit_test.cpp", "max_forks_repo_name": "MathieuCarriere/gudhi-devel", "max_forks_repo_head_hexsha": "1631c51ef9aaecbdb8f2230ab17cfc9626a4a5b3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.8482228626, "max_line_length": 141, "alphanum_fraction": 0.6412404738, "num_tokens": 12435, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4035668680822513, "lm_q2_score": 0.15610489351941398, "lm_q1q2_score": 0.06299876296994322}}
{"text": "/*    This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.\n *    See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.\n *    Author(s):       Vincent Rouvreau\n *\n *    Copyright (C) 2014 Inria\n *\n *    Modification(s):\n *      - YYYY/MM Author: Description of the modification\n */\n\n#include <iostream>\n\n#define BOOST_TEST_DYN_LINK\n#define BOOST_TEST_MODULE \"simplex_tree_remove\"\n#include <boost/test/unit_test.hpp>\n\n//  ^\n// /!\\ Nothing else from Simplex_tree shall be included to test includes are well defined.\n#include \"gudhi/Simplex_tree.h\"\n\nusing namespace Gudhi;\n\nstruct MyOptions : Simplex_tree_options_full_featured {\n  // Not doing persistence, so we don't need those\n  static const bool store_key = false;\n  static const bool store_filtration = false;\n  // I have few vertices\n  typedef short Vertex_handle;\n};\n\nusing Mini_stree = Simplex_tree<MyOptions>;\nusing Stree = Simplex_tree<>;\n\nBOOST_AUTO_TEST_CASE(remove_maximal_simplex) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"REMOVE MAXIMAL SIMPLEX\" << std::endl;\n\n  Mini_stree st;\n\n  st.insert_simplex_and_subfaces({0, 1, 6, 7});\n  st.insert_simplex_and_subfaces({3, 4, 5});\n\n  // Constructs a copy at this state for further test purpose\n  Mini_stree st_pruned = st;\n\n  st.insert_simplex_and_subfaces({3, 0});\n  st.insert_simplex_and_subfaces({2, 1, 0});\n\n  // Constructs a copy at this state for further test purpose\n  Mini_stree st_complete = st;\n  // st_complete and st:\n  //    1   6\n  //    o---o\n  //   /X\\7/\n  //  o---o---o---o\n  //  2   0   3\\X/4\n  //            o\n  //            5\n  // st_pruned:\n  //    1   6\n  //    o---o\n  //     \\7/\n  //      o   o---o\n  //      0   3\\X/4\n  //            o\n  //            5\n\n#ifdef GUDHI_DEBUG\n  std::clog << \"Check exception throw in debug mode\" << std::endl;\n  // throw excpt because sh has children\n  BOOST_CHECK_THROW (st.remove_maximal_simplex(st.find({0, 1, 6})), std::invalid_argument);\n  BOOST_CHECK_THROW (st.remove_maximal_simplex(st.find({3})), std::invalid_argument);\n  BOOST_CHECK(st == st_complete);\n#endif\n  std::clog << \"st.remove_maximal_simplex({0, 2})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 2}));\n  std::clog << \"st.remove_maximal_simplex({0, 1, 2})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 1, 2}));\n  std::clog << \"st.remove_maximal_simplex({1, 2})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 2}));\n  std::clog << \"st.remove_maximal_simplex({2})\" << std::endl;\n  st.remove_maximal_simplex(st.find({2}));\n  std::clog << \"st.remove_maximal_simplex({3})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 3}));\n  \n  BOOST_CHECK(st == st_pruned);\n  // Remove all, but as the simplex tree is not storing filtration, there is no modification\n  st.prune_above_filtration(0.0);\n  BOOST_CHECK(st == st_pruned);\n  \n  Mini_stree st_wo_seven;\n\n  st_wo_seven.insert_simplex_and_subfaces({0, 1, 6});\n  st_wo_seven.insert_simplex_and_subfaces({3, 4, 5});\n  // st_wo_seven:\n  //    1   6\n  //    o---o\n  //     \\X/\n  //      o   o---o\n  //      0   3\\X/4\n  //            o\n  //            5\n\n  // Remove all 7 to test the both remove_maximal_simplex cases (when _members is empty or not)\n  std::clog << \"st.remove_maximal_simplex({0, 1, 6, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 1, 6, 7}));\n  std::clog << \"st.remove_maximal_simplex({0, 1, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 1, 7}));\n  std::clog << \"st.remove_maximal_simplex({0, 6, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 6, 7}));\n  std::clog << \"st.remove_maximal_simplex({0, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 7}));\n  std::clog << \"st.remove_maximal_simplex({1, 6, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 6, 7}));\n  std::clog << \"st.remove_maximal_simplex({1, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 7}));\n  std::clog << \"st.remove_maximal_simplex({6, 7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({6, 7}));\n  std::clog << \"st.remove_maximal_simplex({7})\" << std::endl;\n  st.remove_maximal_simplex(st.find({7}));\n\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n\n  // Check dimension calls lower_upper_bound_dimension to recompute dimension\n  BOOST_CHECK(st.dimension() == 2);\n  BOOST_CHECK(st.upper_bound_dimension() == 2);\n\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension()\n            << \" | st_wo_seven.upper_bound_dimension()=\" << st_wo_seven.upper_bound_dimension() << std::endl;\n  std::clog << \"st.dimension()=\" << st.dimension() << \" | st_wo_seven.dimension()=\" << st_wo_seven.dimension() << std::endl;\n  BOOST_CHECK(st == st_wo_seven);\n}\n\nBOOST_AUTO_TEST_CASE(auto_dimension_set) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"DIMENSION ON REMOVE MAXIMAL SIMPLEX\" << std::endl;\n\n  Mini_stree st;\n\n  st.insert_simplex_and_subfaces({0, 1, 2});\n  st.insert_simplex_and_subfaces({0, 1, 3});\n  st.insert_simplex_and_subfaces({1, 2, 3, 4});\n  st.insert_simplex_and_subfaces({1, 2, 3, 5});\n  st.insert_simplex_and_subfaces({6, 7, 8, 9});\n  st.insert_simplex_and_subfaces({6, 7, 8, 10});\n\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.remove_maximal_simplex({6, 7, 8, 10})\" << std::endl;\n  st.remove_maximal_simplex(st.find({6, 7, 8, 10}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.remove_maximal_simplex({6, 7, 8, 9})\" << std::endl;\n  st.remove_maximal_simplex(st.find({6, 7, 8, 9}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.remove_maximal_simplex({1, 2, 3, 4})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 2, 3, 4}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.remove_maximal_simplex({1, 2, 3, 5})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 2, 3, 5}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 2);\n  std::clog << \"st.dimension()=\" << st.dimension() << std::endl;\n\n  std::clog << \"st.insert_simplex_and_subfaces({1, 2, 3, 5})\" << std::endl;\n  st.insert_simplex_and_subfaces({1, 2, 3, 5});\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.insert_simplex_and_subfaces({1, 2, 3, 4})\" << std::endl;\n  st.insert_simplex_and_subfaces({1, 2, 3, 4});\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n\n  std::clog << \"st.remove_maximal_simplex({1, 2, 3, 5})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 2, 3, 5}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n\n  std::clog << \"st.remove_maximal_simplex({1, 2, 3, 4})\" << std::endl;\n  st.remove_maximal_simplex(st.find({1, 2, 3, 4}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 2);\n  std::clog << \"st.dimension()=\" << st.dimension() << std::endl;\n\n  std::clog << \"st.insert_simplex_and_subfaces({0, 1, 3, 4})\" << std::endl;\n  st.insert_simplex_and_subfaces({0, 1, 3, 4});\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.remove_maximal_simplex({0, 1, 3, 4})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 1, 3, 4}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 2);\n  std::clog << \"st.dimension()=\" << st.dimension() << std::endl;\n\n  std::clog << \"st.insert_simplex_and_subfaces({1, 2, 3, 5})\" << std::endl;\n  st.insert_simplex_and_subfaces({1, 2, 3, 5});\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.insert_simplex_and_subfaces({1, 2, 3, 4})\" << std::endl;\n  st.insert_simplex_and_subfaces({1, 2, 3, 4});\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n\n  // Check you can override the dimension\n  // This is a limit test case - shall not happen\n  st.set_dimension(1);\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 1);\n  // check dimension() and lower_upper_bound_dimension() is not giving the right answer because dimension is too low\n  BOOST_CHECK(st.dimension() == 1);\n\n\n  // Check you can override the dimension\n  // This is a limit test case - shall not happen\n  st.set_dimension(6);\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 6);\n  // check dimension() do not launch lower_upper_bound_dimension()\n  BOOST_CHECK(st.dimension() == 6);\n\n\n  // Reset with the correct value\n  st.set_dimension(3);\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n  BOOST_CHECK(st.dimension() == 3);\n\n  std::clog << \"st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6})\" << std::endl;\n  st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6});\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 6);\n  BOOST_CHECK(st.dimension() == 6);\n\n  std::clog << \"st.remove_maximal_simplex({0, 1, 2, 3, 4, 5, 6})\" << std::endl;\n  st.remove_maximal_simplex(st.find({0, 1, 2, 3, 4, 5, 6}));\n  std::clog << \"st.upper_bound_dimension()=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 6);\n  BOOST_CHECK(st.dimension() == 5);\n\n}\n\nBOOST_AUTO_TEST_CASE(prune_above_filtration) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"PRUNE ABOVE FILTRATION\" << std::endl;\n\n  Stree st;\n\n  st.insert_simplex_and_subfaces({0, 1, 6, 7}, 1.0);\n  st.insert_simplex_and_subfaces({3, 4, 5}, 2.0);\n\n  // Constructs a copy at this state for further test purpose\n  Stree st_pruned = st;\n  st_pruned.initialize_filtration();  // reset\n\n  st.insert_simplex_and_subfaces({3, 0}, 3.0);\n  st.insert_simplex_and_subfaces({2, 1, 0}, 4.0);\n\n  // Constructs a copy at this state for further test purpose\n  Stree st_complete = st;\n  // st_complete and st:\n  //    1   6\n  //    o---o\n  //   /X\\7/\n  //  o---o---o---o\n  //  2   0   3\\X/4\n  //            o\n  //            5\n  // st_pruned:\n  //    1   6\n  //    o---o\n  //     \\7/\n  //      o   o---o\n  //      0   3\\X/4\n  //            o\n  //            5\n\n  bool simplex_is_changed = false;\n  // Check the no action cases\n  // greater than initial filtration value\n  simplex_is_changed = st.prune_above_filtration(10.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  BOOST_CHECK(st == st_complete);\n  BOOST_CHECK(!simplex_is_changed);\n  // equal to initial filtration value\n  simplex_is_changed = st.prune_above_filtration(6.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  BOOST_CHECK(st == st_complete);\n  BOOST_CHECK(!simplex_is_changed);\n  // lower than initial filtration value, but still greater than the maximum filtration value\n  simplex_is_changed = st.prune_above_filtration(5.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  BOOST_CHECK(st == st_complete);\n  BOOST_CHECK(!simplex_is_changed);\n\n  // Display the Simplex_tree\n  std::clog << \"The complex contains \" << st.num_simplices() << \" simplices\";\n  std::clog << \" - dimension \" << st.dimension() << std::endl;\n  std::clog << \"Iterator on Simplices in the filtration, with [filtration value]:\" << std::endl;\n  for (auto f_simplex : st.filtration_simplex_range()) {\n    std::clog << \"   \" << \"[\" << st.filtration(f_simplex) << \"] \";\n    for (auto vertex : st.simplex_vertex_range(f_simplex)) {\n      std::clog << (int) vertex << \" \";\n    }\n    std::clog << std::endl;\n  }\n\n  // Check the pruned cases\n  simplex_is_changed = st.prune_above_filtration(2.5);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  BOOST_CHECK(st == st_pruned);\n  BOOST_CHECK(simplex_is_changed);\n\n  // Display the Simplex_tree\n  std::clog << \"The complex pruned at 2.5 contains \" << st.num_simplices() << \" simplices\";\n  std::clog << \" - dimension \" << st.dimension() << std::endl;\n\n  simplex_is_changed = st.prune_above_filtration(2.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  \n  std::clog << \"The complex pruned at 2.0 contains \" << st.num_simplices() << \" simplices\";\n  std::clog << \" - dimension \" << st.dimension() << std::endl;\n\n  BOOST_CHECK(st == st_pruned);\n  BOOST_CHECK(!simplex_is_changed);\n\n  Stree st_empty;\n  simplex_is_changed = st.prune_above_filtration(0.0);\n  BOOST_CHECK(simplex_is_changed == true);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n\n  // Display the Simplex_tree\n  std::clog << \"The complex pruned at 0.0 contains \" << st.num_simplices() << \" simplices\";\n  std::clog << \" - upper_bound_dimension \" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == 3);\n\n  BOOST_CHECK(st.dimension() == -1);\n  std::clog << \"upper_bound_dimension=\" << st.upper_bound_dimension() << std::endl;\n  BOOST_CHECK(st.upper_bound_dimension() == -1);\n\n  BOOST_CHECK(st == st_empty);\n  BOOST_CHECK(simplex_is_changed);\n\n  // Test case to the limit\n  simplex_is_changed = st.prune_above_filtration(-1.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  BOOST_CHECK(st == st_empty);\n  BOOST_CHECK(!simplex_is_changed);\n}\n\nBOOST_AUTO_TEST_CASE(mini_prune_above_filtration) {\n  std::clog << \"********************************************************************\" << std::endl;\n  std::clog << \"MINI PRUNE ABOVE FILTRATION\" << std::endl;\n\n  Mini_stree st;\n\n  st.insert_simplex_and_subfaces({0, 1, 6, 7});\n  st.insert_simplex_and_subfaces({3, 4, 5});\n  st.insert_simplex_and_subfaces({3, 0});\n  st.insert_simplex_and_subfaces({2, 1, 0});\n\n  // st:\n  //    1   6\n  //    o---o\n  //   /X\\7/\n  //  o---o---o---o\n  //  2   0   3\\X/4\n  //            o\n  //            5\n\n  st.initialize_filtration();\n  \n  // Display the Simplex_tree\n  std::clog << \"The complex contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  BOOST_CHECK(st.num_simplices() == 27);\n\n  // Test case to the limit - With these options, there is no filtration, which means filtration is 0\n  bool simplex_is_changed = st.prune_above_filtration(1.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  // Display the Simplex_tree\n  std::clog << \"The complex pruned at 1.0 contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  BOOST_CHECK(!simplex_is_changed);\n  BOOST_CHECK(st.num_simplices() == 27);\n\n  simplex_is_changed = st.prune_above_filtration(0.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  // Display the Simplex_tree\n  std::clog << \"The complex pruned at 0.0 contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  BOOST_CHECK(!simplex_is_changed);\n  BOOST_CHECK(st.num_simplices() == 27);\n\n  // Test case to the limit\n  simplex_is_changed = st.prune_above_filtration(-1.0);\n  if (simplex_is_changed)\n    st.initialize_filtration();\n  // Display the Simplex_tree\n  std::clog << \"The complex pruned at -1.0 contains \" << st.num_simplices() << \" simplices\" << std::endl;\n  BOOST_CHECK(simplex_is_changed);\n  BOOST_CHECK(st.num_simplices() == 0);\n\n  // Display the Simplex_tree\n  std::clog << \"The complex contains \" << st.num_simplices() << \" simplices\" << std::endl;\n\n}\n", "meta": {"hexsha": "36b8b3c6d151af9aaaad8a009faf177aff1d2d5b", "size": 16684, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp", "max_stars_repo_name": "m0baxter/gudhi-devel", "max_stars_repo_head_hexsha": "6e14ef1f31e09f3875316440303450ff870d9881", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 146.0, "max_stars_repo_stars_event_min_datetime": "2019-03-15T14:10:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T21:14:52.000Z", "max_issues_repo_path": "src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp", "max_issues_repo_name": "m0baxter/gudhi-devel", "max_issues_repo_head_hexsha": "6e14ef1f31e09f3875316440303450ff870d9881", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 398.0, "max_issues_repo_issues_event_min_datetime": "2019-03-07T14:55:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T14:50:40.000Z", "max_forks_repo_path": "src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp", "max_forks_repo_name": "m0baxter/gudhi-devel", "max_forks_repo_head_hexsha": "6e14ef1f31e09f3875316440303450ff870d9881", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 51.0, "max_forks_repo_forks_event_min_datetime": "2019-03-08T15:58:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T10:23:23.000Z", "avg_line_length": 38.0913242009, "max_line_length": 124, "alphanum_fraction": 0.6475065931, "num_tokens": 5175, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46879062662624377, "lm_q2_score": 0.13296422989056966, "lm_q1q2_score": 0.06233238464927608}}
{"text": "//  Copyright Paul A. Bristow 2015.\n//  Copyright Christopher Kormanyos 2015.\n//  Distributed under the Boost Software License,\n//  Version 1.0. (See accompanying file LICENSE_1_0.txt\n//  or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//! \\file\n//!\\brief Test numeric_limits lowest for a list of negatable fixed_point types.\n\n//! \\sa http://www.boost.org/doc/libs/1_59_0/libs/test/doc/html/boost_test/tests_organization/test_cases/test_organization_templates.html#ref_BOOST_AUTO_TEST_CASE_TEMPLATE\n\n#define BOOST_TEST_MODULE test_negatable_basic_limits\n#define BOOST_LIB_DIAGNOSTIC\n//#define ENABLE_LOCAL_TEST_DEBUG_MESSAGES\n\n#include <boost/test/included/unit_test.hpp>\n#include <boost/mpl/list.hpp> // for mpl::list\n#include <boost/fixed_point/fixed_point.hpp>\n\n#include <limits>\n#include <iostream>\n#include <type_traits>\n\nusing namespace boost::fixed_point;\n\n// List of fixed_point types to use in testing (with rationale).\n// All have default rounding and default overflow undefined.\n// Split are chosen to be as close as possible to analogous IEEE floating-point layout,\n// but can't match exactly because that format has an implicit hidden bit for fraction part,\n// and exponent part has a sign bit, so use one less than the exponent bits.\n// For a start, cover the edge case of all resolution bits, zero range, \n// so can only represent a fraction -1..0 .. 0.999....\ntypedef boost::fixed_point::negatable<0, -7> fixed_point_type_0m7; // 8-bit Fraction only.\ntypedef boost::fixed_point::negatable<2, -5> fixed_point_type_2m5; // 8-bit split, -4 to +3.999\n// 8-bit types.\ntypedef boost::fixed_point::negatable<0, -15> fixed_point_type_0m15; // 16-bit Fraction only.\ntypedef boost::fixed_point::negatable<4, -11> fixed_point_type_4m11; // 16-bit split (as IEEE binary16).\n// 32-bit types.\ntypedef boost::fixed_point::negatable<0, -31> fixed_point_type_0m31; // 32-bit Fraction only.\ntypedef boost::fixed_point::negatable<7, -24> fixed_point_type_7m24; // 32-bit split (as IEEE binary32 float).\n// 64-bit types.\ntypedef boost::fixed_point::negatable<0, -63> fixed_point_type_0m63; // 64-bit Fraction only.\ntypedef boost::fixed_point::negatable<10, -53> fixed_point_type_10m53; // 64-bit split (as IEEE binary64 double).\n\n// 80-bit type\ntypedef boost::fixed_point::negatable<15, -64> fixed_point_type_15m64; // 80-bit split (as IEEE X86 extended long double).\n// Can't match exactly here as 64th bit is used to show that value is denormal).\n\n// 128-bit types that will use float128 where available, else Boost.Multiprecision.\ntypedef boost::fixed_point::negatable<0, -127> fixed_point_type_0m127; // 128-bit Fraction only.\ntypedef boost::fixed_point::negatable<14, -113> fixed_point_type_14m113; // 128-bit split (as IEEE binary128).\n\n// 256-bit types that must use Boost.Multiprecision.\ntypedef boost::fixed_point::negatable<0, -255> fixed_point_type_0m255; // 128-bit Fraction only.\ntypedef boost::fixed_point::negatable<15, -240> fixed_point_type_15m240; // 128-bit split (as IEEE binary128).\n\n\ntypedef boost::mpl::list<\n  fixed_point_type_0m7,  fixed_point_type_2m5,  // 8-bit types.\n  fixed_point_type_0m15, fixed_point_type_4m11, // 16-bit types.\n  fixed_point_type_0m31, fixed_point_type_7m24, // 32-bit types.\n  fixed_point_type_0m63, fixed_point_type_10m53, // 64-bit types.\n  fixed_point_type_15m64, // 80-bit type.\n  fixed_point_type_0m127, fixed_point_type_14m113, // 128-bit types.\n  fixed_point_type_0m255, fixed_point_type_15m240 // 256-bit types.\n  > test_types;\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(lowest_test, T, test_types)\n{\n  T x = (std::numeric_limits<T>::lowest)();\n  T mm = -(std::numeric_limits<T>::max)();\n\n  BOOST_CHECK(x < mm);\n  BOOST_CHECK(mm > x);\n} // BOOST_AUTO_TEST_CASE_TEMPLATE(lowest_test, T, test_types)\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(min_test, T, test_types)\n{\n  T z; // Default constructor.\n  BOOST_CHECK_EQUAL(z, T(0)); // Check that initial value is zero.\n\n  T m((std::numeric_limits<T>::min)()); // Constructor.\n  T x = m; // Use assignment operator.\n\n  std::string s = m.bit_pattern(); // \"00...001\"\n  std::size_t d = s.find('1');\n  BOOST_CHECK_EQUAL(d, x.all_bits-1);\n} // BOOST_AUTO_TEST_CASE_TEMPLATE(mintest_test, T, test_types)\n\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(max_test, T, test_types)\n{\n  T z; // Default constructor.\n  BOOST_CHECK_EQUAL(z, T(0)); // Check that initial value is zero.\n\n  T m((std::numeric_limits<T>::max)()); // Constructor.\n  T x = m; // Use assignment operator.\n  BOOST_CHECK_EQUAL(x, m); // Check assignment operator.\n  // This and many other tests should be elsewhere.\n\n  std::string s = m.bit_pattern(); // \"00...001\" \n  std::string e(\"0\");\n  e.append(m.all_bits - 1, '1');  // Expected string \"011...111.\n  BOOST_CHECK_EQUAL(s, e); // Not sign bit.\n} // BOOST_AUTO_TEST_CASE_TEMPLATE(maxtest_test, T, test_types)\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(radix_test, T, test_types)\n{ // radix always 2 for all fixed_point types.\n  BOOST_CHECK_EQUAL(std::numeric_limits<T>::radix, 2);\n} // \n\n\n/*\n1>  test_fixed_point_types_limits.cpp\n1>  test_fixed_point_types_limits.vcxproj -> J:\\Cpp\\fixed_point\\Debug\\test_fixed_point_types_limits.exe\n1>\n1>  Running 39 test cases...\n1>  *** No errors detected\n\n*/", "meta": {"hexsha": "e040393e7943b8c56ba7d86b1ab60cd94e402f71", "size": 5161, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/test_fixed_point_types_limits.cpp", "max_stars_repo_name": "BoostGSoC15/fixed-point", "max_stars_repo_head_hexsha": "d71b4a622ded821a2429d8d857097441c2a10246", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/test_fixed_point_types_limits.cpp", "max_issues_repo_name": "BoostGSoC15/fixed-point", "max_issues_repo_head_hexsha": "d71b4a622ded821a2429d8d857097441c2a10246", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/test_fixed_point_types_limits.cpp", "max_forks_repo_name": "BoostGSoC15/fixed-point", "max_forks_repo_head_hexsha": "d71b4a622ded821a2429d8d857097441c2a10246", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0083333333, "max_line_length": 171, "alphanum_fraction": 0.7467545049, "num_tokens": 1447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44939263446475963, "lm_q2_score": 0.13846179056896438, "lm_q1q2_score": 0.06222370883649471}}
{"text": "/* vim: set tabstop=4 expandtab shiftwidth=4 softtabstop=4: */\n\n/**\n * \\file libs/numeric/ublasx/test/reshape.cpp\n *\n * \\brief Test suite for the \\c reshape operation.\n *\n * \\author Marco Guazzone (marco.guazzone@gmail.com)\n *\n * <hr/>\n *\n * Copyright (c) 2011, Marco Guazzone\n *\n * Distributed under the Boost Software License, Version 1.0. (See\n * accompanying file LICENSE_1_0.txt or copy at\n * http://www.boost.org/LICENSE_1_0.txt)\n */\n\n#include <boost/numeric/ublas/io.hpp>\n#include <boost/numeric/ublas/matrix.hpp>\n#include <boost/numeric/ublas/traits.hpp>\n#include <boost/numeric/ublasx/detail/debug.hpp>\n#include <boost/numeric/ublasx/operation/num_columns.hpp>\n#include <boost/numeric/ublasx/operation/num_rows.hpp>\n#include <boost/numeric/ublasx/operation/reshape.hpp>\n#include <boost/numeric/ublasx/tags.hpp>\n#include \"libs/numeric/ublasx/test/utils.hpp\"\n\n\nnamespace ublas = ::boost::numeric::ublas;\nnamespace ublasx = ::boost::numeric::ublasx;\n\n\nstatic const double tol = 1e-5;\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_dim1_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<1>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<1>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_dim1_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<1>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<1>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_dim2_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<2>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<2>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_dim2_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<2>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<2>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( inplace_reshape_by_dim1_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X(A);\n    ublasx::reshape_inplace<1>(X, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<1>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( inplace_reshape_by_dim1_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X(A);\n    ublasx::reshape_inplace<1>(X, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<1>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( inplace_reshape_by_dim2_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n    matrix_type X(A);\n    ublasx::reshape_inplace<2>(X, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<2>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( inplace_reshape_by_dim2_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n    matrix_type X(A);\n    ublasx::reshape_inplace<2>(X, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<2>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\n/*\n * BEGIN FIXME: Does Not Work!\n *\nBOOST_UBLASX_TEST_DEF( reshape_by_tag_major_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<ublas::tag::major>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<major>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_tag_major_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<ublas::tag::major>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<major>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_tag_minor_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n\n    matrix_type X;\n    X = ublasx::reshape<ublas::tag::minor>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<minor>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_tag_minor_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<ublas::tag::minor>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<minor>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_tag_leading_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n\n    matrix_type X;\n    X = ublasx::reshape<ublas::tag::leading>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<leading>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_by_tag_leading_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) =  7; E(0,2) = 2; E(0,3) =  8; E(0,4) = 3; E(0,5) =  9;\n    E(1,0) =  4; E(1,1) = 10; E(1,2) = 5; E(1,3) = 11; E(1,4) = 6; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape<ublas::tag::leading>(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape<leading>(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n * BEGIN FIXME: Does Not Work!\n *\n */\n\n\nBOOST_UBLASX_TEST_DEF( reshape_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X;\n    X = ublasx::reshape(A, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( inplace_reshape_col_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::column_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X(A);\n    ublasx::reshape_inplace(X, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( inplace_reshape_row_major )\n{\n    typedef double value_type;\n    typedef ublas::matrix<value_type,ublas::row_major> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type nr(3);\n    const size_type nc(4);\n    const size_type new_nr(2);\n    const size_type new_nc(6);\n\n    matrix_type A(nr,nc);\n\n    A(0,0) =  1; A(0,1) =  4; A(0,2) =  7; A(0,3) = 10;\n    A(1,0) =  2; A(1,1) =  5; A(1,2) =  8; A(1,3) = 11;\n    A(2,0) =  3; A(2,1) =  6; A(2,2) =  9; A(2,3) = 12;\n\n    matrix_type E(new_nr,new_nc);\n\n    E(0,0) =  1; E(0,1) = 3; E(0,2) = 5; E(0,3) = 7; E(0,4) =  9; E(0,5) = 11;\n    E(1,0) =  2; E(1,1) = 4; E(1,2) = 6; E(1,3) = 8; E(1,4) = 10; E(1,5) = 12;\n\n    matrix_type X(A);\n    ublasx::reshape_inplace(X, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"A=\" << A);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(A,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nBOOST_UBLASX_TEST_DEF( reshape_vec )\n{\n    BOOST_UBLASX_DEBUG_TRACE(\"Test Case: Reshape Vector\");\n\n    typedef double value_type;\n    typedef ublas::vector<value_type> vector_type;\n    typedef ublas::matrix<value_type> matrix_type;\n    typedef typename ublas::matrix_traits<matrix_type>::size_type size_type;\n\n    const size_type n(6);\n\n    vector_type v(n);\n\n    v(0) =  1;\n    v(1) =  2;\n    v(2) =  3;\n    v(3) =  4;\n    v(4) =  5;\n    v(5) =  6;\n\n    size_type new_nr;\n    size_type new_nc;\n    matrix_type E;\n    matrix_type X;\n\n\n    // vector(n) => matrix(n,1)\n    new_nr = 6;\n    new_nc = 1;\n    E = matrix_type(new_nr,new_nc);\n    E(0,0) =  1;\n    E(1,0) =  2;\n    E(2,0) =  3;\n    E(3,0) =  4;\n    E(4,0) =  5;\n    E(5,0) =  6;\n    X = ublasx::reshape(v, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"v=\" << v);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n\n\n    // vector(n) => matrix(1,n)\n    new_nr = 1;\n    new_nc = 6;\n    E = matrix_type(new_nr,new_nc);\n    E(0,0) =  1; E(0,1) =  2; E(0,2) =  3; E(0,3) =  4; E(0,4) =  5; E(0,5) = 6;\n    X = ublasx::reshape(v, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"v=\" << v);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n\n\n    // vector(n) => matrix(n1,n2)\n    new_nr = 3;\n    new_nc = 2;\n    E = matrix_type(new_nr,new_nc);\n    E(0,0) = 1; E(0,1) = 4;\n    E(1,0) = 2; E(1,1) = 5;\n    E(2,0) = 3; E(2,1) = 6;\n    X = ublasx::reshape(v, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"v=\" << v);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n\n\n    // vector(n) => matrix(n1,n2)\n    new_nr = 2;\n    new_nc = 3;\n    E = matrix_type(new_nr,new_nc);\n    E(0,0) = 1; E(0,1) = 3; E(0,2) = 5;\n    E(1,0) = 2; E(1,1) = 4; E(1,2) = 6;\n    X = ublasx::reshape(v, new_nr, new_nc);\n    BOOST_UBLASX_DEBUG_TRACE(\"v=\" << v);\n    BOOST_UBLASX_DEBUG_TRACE(\"reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << X);\n    BOOST_UBLASX_DEBUG_TRACE(\"Expected reshape(v,\" << new_nr << \",\" << new_nc << \")=\" << E);\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_rows(X) == new_nr );\n    BOOST_UBLASX_TEST_CHECK( ublasx::num_columns(X) == new_nc );\n    BOOST_UBLASX_TEST_CHECK_MATRIX_CLOSE( X, E, new_nr, new_nc, tol );\n}\n\n\nint main()\n{\n    BOOST_UBLASX_TEST_BEGIN();\n\n    BOOST_UBLASX_TEST_DO( reshape_by_dim1_col_major );\n    BOOST_UBLASX_TEST_DO( reshape_by_dim1_row_major );\n    BOOST_UBLASX_TEST_DO( reshape_by_dim2_col_major );\n    BOOST_UBLASX_TEST_DO( reshape_by_dim2_row_major );\n    BOOST_UBLASX_TEST_DO( inplace_reshape_by_dim1_col_major );\n    BOOST_UBLASX_TEST_DO( inplace_reshape_by_dim1_row_major );\n    BOOST_UBLASX_TEST_DO( inplace_reshape_by_dim2_col_major );\n    BOOST_UBLASX_TEST_DO( inplace_reshape_by_dim2_row_major );\n\n\n//FIXME: does not work\n//  BOOST_UBLASX_TEST_DO( reshape_by_tag_major_col_major );\n//  BOOST_UBLASX_TEST_DO( reshape_by_tag_major_row_major );\n//  BOOST_UBLASX_TEST_DO( reshape_by_tag_minor_col_major );\n//  BOOST_UBLASX_TEST_DO( reshape_by_tag_minor_row_major );\n//  BOOST_UBLASX_TEST_DO( reshape_by_tag_leading_col_major );\n//  BOOST_UBLASX_TEST_DO( reshape_by_tag_leading_row_major );\n\n    BOOST_UBLASX_TEST_DO( reshape_col_major );\n    BOOST_UBLASX_TEST_DO( reshape_row_major );\n    BOOST_UBLASX_TEST_DO( inplace_reshape_col_major );\n    BOOST_UBLASX_TEST_DO( inplace_reshape_row_major );\n\n    BOOST_UBLASX_TEST_DO( reshape_vec );\n\n    BOOST_UBLASX_TEST_END();\n}\n", "meta": {"hexsha": "4848fd43c4ffe124a0882b5452d6a55265985267", "size": 27697, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/numeric/ublasx/test/reshape.cpp", "max_stars_repo_name": "sguazt/boost-ublasx", "max_stars_repo_head_hexsha": "21c9b393d33a6ec2a8071ba8d48680073d766409", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 7.0, "max_stars_repo_stars_event_min_datetime": "2016-05-14T11:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T14:22:20.000Z", "max_issues_repo_path": "libs/numeric/ublasx/test/reshape.cpp", "max_issues_repo_name": "sguazt/boost-ublasx", "max_issues_repo_head_hexsha": "21c9b393d33a6ec2a8071ba8d48680073d766409", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2020-12-28T18:36:04.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-06T11:28:51.000Z", "max_forks_repo_path": "libs/numeric/ublasx/test/reshape.cpp", "max_forks_repo_name": "sguazt/boost-ublasx", "max_forks_repo_head_hexsha": "21c9b393d33a6ec2a8071ba8d48680073d766409", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-12-23T02:53:27.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-23T02:53:27.000Z", "avg_line_length": 36.3955321945, "max_line_length": 92, "alphanum_fraction": 0.5987291042, "num_tokens": 11317, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4610167793123159, "lm_q2_score": 0.13477592958647094, "lm_q1q2_score": 0.0621339649867783}}
{"text": "#include \"test_helpers/test_assertions.hpp\"\n\n#include <vector>\n\n#include <deal.II/base/mpi.h>\n#include <deal.II/dofs/dof_tools.h>\n#include <deal.II/dofs/dof_handler.h>\n#include <deal.II/distributed/tria.h>\n#include <deal.II/fe/fe_q.h>\n#include <deal.II/grid/grid_generator.h>\n#include <deal.II/grid/grid_tools.h>\n#include <deal.II/lac/dynamic_sparsity_pattern.h>\n#include <deal.II/lac/petsc_sparse_matrix.h>\n#include <deal.II/base/tensor.h>\n\n#include \"test_helpers/dealii_test_domain.h\"\n#include \"test_helpers/test_helper_functions.h\"\n#include \"test_helpers/gmock_wrapper.h\"\n\nnamespace  {\n\nnamespace test_helpers = bart::test_helpers;\n\nusing ::testing::AssertionResult, ::testing::AssertionFailure, ::testing::AssertionSuccess;\n\nclass TestAssertionsTest : public ::testing::Test {\n protected:\n  std::vector<double> vector_1, vector_2;\n  dealii::Vector<double> dealii_vector_1, dealii_vector_2;\n  void SetUp() override;\n};\n\nvoid TestAssertionsTest::SetUp() {\n  const auto vector_size = test_helpers::RandomInt(5, 10);\n  vector_1 = test_helpers::RandomVector(vector_size, 0, 1.0);\n  vector_2 = test_helpers::RandomVector(vector_size, 1.0, 2.0);\n  dealii_vector_1.reinit(vector_size);\n  dealii_vector_2.reinit(vector_size);\n\n  for (int i = 0; i < vector_size; ++i) {\n    dealii_vector_1[i] = vector_1[i];\n    dealii_vector_2[i] = vector_2[i];\n  }\n}\n\nTEST_F(TestAssertionsTest, GoodComparisonStdVector) {\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(vector_1, vector_1));\n}\n\nTEST_F(TestAssertionsTest, BadComparisonStdVector) {\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(vector_1, vector_2));\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(vector_2, vector_1));\n}\n\nTEST_F(TestAssertionsTest, GoodComparisonDealiiVector) {\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(dealii_vector_1, dealii_vector_1));\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(dealii_vector_2, dealii_vector_2));\n}\n\nTEST_F(TestAssertionsTest, BadComparisonDealiiVector) {\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(dealii_vector_1, dealii_vector_2));\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(dealii_vector_2, dealii_vector_1));\n}\n\nclass TestAssertionsMatrixTests : public ::testing::Test {\n public:\n  dealii::FullMatrix<double> matrix_1, matrix_2, matrix_bad_columns, matrix_bad_rows;\n  void SetUp() override;\n};\n\nvoid TestAssertionsMatrixTests::SetUp() {\n  const auto matrix_rows{ test_helpers::RandomInt(5, 10) }, matrix_cols{ matrix_rows + 1 };\n  matrix_1.reinit(matrix_rows, matrix_cols);\n  matrix_2.reinit(matrix_rows, matrix_cols);\n  matrix_bad_columns.reinit(matrix_rows, matrix_rows);\n  matrix_bad_rows.reinit(matrix_cols, matrix_cols);\n\n  for (int i = 0; i < matrix_rows; ++i) {\n    for (int j = 0; j < matrix_cols; ++j) {\n      matrix_1.set(i, j, test_helpers::RandomDouble(-100, 100));\n      matrix_2.set(i, j, test_helpers::RandomDouble(-100, 100));\n    }\n  }\n\n  for (int i = 0; i < matrix_rows; ++i) {\n    for (int j = 0; j < matrix_rows; ++j) {\n      matrix_bad_columns.set(i, j, test_helpers::RandomDouble(-100, 100));\n    }\n  }\n\n  for (int i = 0; i < matrix_cols; ++i) {\n    for (int j = 0; j < matrix_cols; ++j) {\n      matrix_bad_rows.set(i, j, test_helpers::RandomDouble(-100, 100));\n    }\n  }\n}\n\nTEST_F(TestAssertionsMatrixTests, GoodComparison) {\n  EXPECT_TRUE(test_helpers::AreEqual(matrix_1, matrix_1));\n  EXPECT_TRUE(test_helpers::AreEqual(matrix_2, matrix_2));\n  EXPECT_TRUE(test_helpers::AreEqual(matrix_bad_columns, matrix_bad_columns));\n  EXPECT_TRUE(test_helpers::AreEqual(matrix_bad_rows, matrix_bad_rows));\n}\n\nTEST_F(TestAssertionsMatrixTests, BadComparison) {\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_1, matrix_2));\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_2, matrix_1));\n}\n\nTEST_F(TestAssertionsMatrixTests, BadSizeComparison) {\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_1, matrix_bad_columns));\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_2, matrix_bad_columns));\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_1, matrix_bad_rows));\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_2, matrix_bad_rows));\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_bad_rows, matrix_bad_columns));\n}\n\nTEST_F(TestAssertionsMatrixTests, GoodComparisonWithinTolerance) {\n  auto matrix_3 = matrix_1;\n  for (auto entry : matrix_3) {\n    entry += test_helpers::RandomDouble(1e-6, 1e-5);\n  }\n  EXPECT_FALSE(test_helpers::AreEqual(matrix_1, matrix_3));\n  EXPECT_TRUE(test_helpers::AreEqual(matrix_1, matrix_3, 1e-4));\n}\n\ntemplate <typename DimensionWrapper>\nclass TestAssertionsTensorsAreEqual : public ::testing::Test {\n public:\n  static constexpr int dim = DimensionWrapper::value;\n  dealii::Tensor<1, dim> tensor_1_, tensor_2_;\n\n  auto SetUp() -> void override;\n};\n\ntemplate <typename DimensionWrapper>\nauto TestAssertionsTensorsAreEqual<DimensionWrapper>::SetUp() -> void {\n  for (int i = 0; i < dim; ++i) {\n    tensor_1_[i] = test_helpers::RandomDouble(-100, 100);\n    tensor_2_[i] = test_helpers::RandomDouble(-100, 100);\n  }\n}\n\nTYPED_TEST_SUITE(TestAssertionsTensorsAreEqual, bart::testing::AllDimensions);\n\nTYPED_TEST(TestAssertionsTensorsAreEqual, GoodComparison) {\n  EXPECT_TRUE(test_helpers::AreEqual(this->tensor_1_, this->tensor_1_));\n  EXPECT_TRUE(test_helpers::AreEqual(this->tensor_2_, this->tensor_2_));\n}\n\nTYPED_TEST(TestAssertionsTensorsAreEqual, BadComparison) {\n  EXPECT_FALSE(test_helpers::AreEqual(this->tensor_1_, this->tensor_2_));\n  EXPECT_FALSE(test_helpers::AreEqual(this->tensor_2_, this->tensor_1_));\n}\n\nTYPED_TEST(TestAssertionsTensorsAreEqual, Tolerance) {\n  auto tensor_3 = this->tensor_1_;\n  tensor_3 *= (1 + 1e-8);\n  EXPECT_TRUE(test_helpers::AreEqual(this->tensor_1_, tensor_3));\n  tensor_3 *= (1 + 1e-5);\n  EXPECT_FALSE(test_helpers::AreEqual(this->tensor_1_, tensor_3));\n}\n\n\nclass TestAssertionsMPIMatricesTests : public ::testing::Test, public bart::testing::DealiiTestDomain<2> {\n protected:\n  void SetUp() override;\n};\n\nvoid TestAssertionsMPIMatricesTests::SetUp() {\n  SetUpDealii();\n  std::vector<dealii::types::global_dof_index> local_dof_indices(fe_.dofs_per_cell);\n\n  for (const auto cell : cells_) {\n    cell->get_dof_indices(local_dof_indices);\n    for (const auto index_i : local_dof_indices) {\n      for (const auto index_j : local_dof_indices) {\n        matrix_1.add(index_i, index_j, 1);\n        matrix_2.add(index_i, index_j, 2);\n        matrix_3.add(index_i, index_j, 1);\n      }\n    }\n  }\n\n  matrix_1.compress(dealii::VectorOperation::add);\n  matrix_2.compress(dealii::VectorOperation::add);\n  matrix_3.compress(dealii::VectorOperation::add);\n}\n\nTEST_F(TestAssertionsMPIMatricesTests, CompareMPIMatrices) {\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(matrix_2, matrix_2));\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(matrix_1, matrix_3));\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(matrix_1, matrix_2));\n\n  const int random_cell = test_helpers::RandomInt(0, cells_.size());\n  std::vector<dealii::types::global_dof_index> local_dof_indices(fe_.dofs_per_cell);\n  cells_[random_cell]->get_dof_indices(local_dof_indices);\n\n  for (const auto index_i : local_dof_indices) {\n    for (const auto index_j : local_dof_indices) {\n      matrix_3.add(index_i, index_j, 1);\n    }\n  }\n  matrix_3.compress(dealii::VectorOperation::add);\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(matrix_1, matrix_3));\n}\n\nclass TestAssertionsMPIVectorTests : public ::testing::Test, public bart::testing::DealiiTestDomain<2> {\n protected:\n  void SetUp() override;\n};\n\nvoid TestAssertionsMPIVectorTests::SetUp() {\n  SetUpDealii();\n  std::vector<dealii::types::global_dof_index> local_dof_indices(fe_.dofs_per_cell);\n\n  for (const auto cell : cells_) {\n    cell->get_dof_indices(local_dof_indices);\n    for (const auto index_i : local_dof_indices) {\n      vector_1(index_i) += 1;\n      vector_2(index_i) += 2;\n      vector_3(index_i) += 1;\n    }\n  }\n\n  vector_1.compress(dealii::VectorOperation::add);\n  vector_2.compress(dealii::VectorOperation::add);\n  vector_3.compress(dealii::VectorOperation::add);\n}\n\nTEST_F(TestAssertionsMPIVectorTests, CompareMPIVectors) {\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(vector_1, vector_1));\n  EXPECT_EQ(AssertionSuccess(), bart::test_helpers::AreEqual(vector_1, vector_3));\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(vector_1, vector_2));\n\n  const int random_cell = test_helpers::RandomInt(0, cells_.size());\n  std::vector<dealii::types::global_dof_index> local_dof_indices(fe_.dofs_per_cell);\n  cells_[random_cell]->get_dof_indices(local_dof_indices);\n\n  for (auto index_i : local_dof_indices) {\n    vector_3(index_i) += 1;\n  }\n\n  EXPECT_EQ(AssertionFailure(), bart::test_helpers::AreEqual(vector_1, vector_3));\n}\n\n} // namespace\n\n", "meta": {"hexsha": "8a60057025fc2f84a2525cd848d452382977ce3c", "size": 8796, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/test_helpers/tests/test_assertions_test.cpp", "max_stars_repo_name": "SlaybaughLab/Transport", "max_stars_repo_head_hexsha": "8eb32cb8ae50c92875526a7540350ef9a85bc050", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12.0, "max_stars_repo_stars_event_min_datetime": "2018-03-14T12:30:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T14:46:44.000Z", "max_issues_repo_path": "src/test_helpers/tests/test_assertions_test.cpp", "max_issues_repo_name": "SlaybaughLab/Transport", "max_issues_repo_head_hexsha": "8eb32cb8ae50c92875526a7540350ef9a85bc050", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 194.0, "max_issues_repo_issues_event_min_datetime": "2017-07-07T01:38:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-19T18:21:19.000Z", "max_forks_repo_path": "src/test_helpers/tests/test_assertions_test.cpp", "max_forks_repo_name": "SlaybaughLab/Transport", "max_forks_repo_head_hexsha": "8eb32cb8ae50c92875526a7540350ef9a85bc050", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2017-07-06T22:58:59.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-15T07:01:21.000Z", "avg_line_length": 35.3253012048, "max_line_length": 106, "alphanum_fraction": 0.7494315598, "num_tokens": 2470, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091946, "lm_q2_score": 0.12421301321508336, "lm_q1q2_score": 0.061621309395992634}}
{"text": "//------------------------------------------------------------------------------\n/// \\file FunctionObject_test.cpp\n/// \\ref Vandevoorde, Josuttis, Gregor. C++ Templates: The Complete Guide.\n/// Addison-Wesley Professional; 2nd edition. 2017\n//------------------------------------------------------------------------------\n\n#include <boost/test/unit_test.hpp>\n//#include <functional> // std::functional\n#include <vector>\n\nusing std::vector;\n\nBOOST_AUTO_TEST_SUITE(Cpp)\nBOOST_AUTO_TEST_SUITE(Utilities)\nBOOST_AUTO_TEST_SUITE(FunctionObject_tests)\n\n//------------------------------------------------------------------------------\n/// \\ref Vandevoorde, Josuttis, Gregor (2017). pp. 517, 22.1\n/// \\brief Demonstrate Function template that enumerates integer values from 0\n/// up to some value, providing each value to given function object f.\n/// bridge/forupto3.hpp from Vandevoorde, Josuttis, Gregor (2017)\n//------------------------------------------------------------------------------\ntemplate <typename F>\nvoid for_up_to(const int n, F f)\n{\n  for (int i {0}; i < n; ++i)\n  {\n    f(i); // call passed function f for i\n  }\n}\n\nvoid for_up_to_3(const int n, std::function<void(int)> f)\n{\n  for (int i {0}; i < n; ++i)\n  {\n    f(i); // call passed function f for i\n  }\n}\n\nclass TestOutputStringStream\n{\n  private:\n\n\n};\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(FunctionTemplateForStaticPolymorphism)\n{\n  constexpr int n {5};\n\n  vector<int> values;\n  for_up_to(n, [&values](int i) { values.push_back(i); });\n\n  for (int i {0}; i < n; ++i)\n  {\n    BOOST_TEST(values.at(i) == i);\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(StdFunctionForTypeErasure)\n{\n  constexpr int n {5};\n\n  vector<int> values;\n  for_up_to_3(n, [&values](int i) { values.push_back(i); });\n\n  for (int i {0}; i < n; ++i)\n  {\n    BOOST_TEST(values.at(i) == i);\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(StdFunctionTypesMatchOnArgumentsNotOnReturnType)\n{\n  std::function<void(double)> f = [](double x) -> double { return x*x; };\n  f(2);\n  // Void has incomplete type.\n  //auto result = f(2);\n  BOOST_TEST(true);\n}\n\nBOOST_AUTO_TEST_SUITE_END() // FunctionObject_tests\nBOOST_AUTO_TEST_SUITE_END() // Utilities\nBOOST_AUTO_TEST_SUITE_END() // Cpp\n", "meta": {"hexsha": "4bdff45ab0105b046715e430f1014b4c38d71720", "size": 2640, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Cpp/Utilities/FunctionObject_test.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Cpp/Utilities/FunctionObject_test.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Cpp/Utilities/FunctionObject_test.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.010989011, "max_line_length": 80, "alphanum_fraction": 0.4765151515, "num_tokens": 546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4687906266262437, "lm_q2_score": 0.13117323225300484, "lm_q1q2_score": 0.06149278174447594}}
{"text": "//! c/c++ system headers\n//! other headers\n#include <class_def.hpp>\n#include <boost/python.hpp>\n\n// create class that will wrap our c++ code into python using boost\nstruct BoostPyWrapper {\n    // we can expose either constructor from class_def, as well\n    // as both.  Let's expose both.  This just means that we can init\n    // python version using either an input argument or not.\n    BoostPyWrapper() : e_(new Exponentiate()) {}\n    BoostPyWrapper(double base) : e_(new Exponentiate(base)) {}\n\n    // create a python-callable method to raise base to an input power\n    double raise_to_power(double in) {\n        return e_->RaiseToPower(in);\n    }\n\n    // create a shared pointer to our Exponentiate instance\n    boost::shared_ptr<Exponentiate> e_;\n};\n\n\n// define boost python module\nBOOST_PYTHON_MODULE(pyRTP) {\n    using namespace boost::python;\n    // this is where the magic happens\n    // here is where we define what is actually exposed to python\n    // and how to reference it\n    class_<BoostPyWrapper>(\"Exponentiate\", init<>())  // default constructor\n        .def(init<double>())  // constructor that takes a single argument\n        .def(\"raise_to_power\", &BoostPyWrapper::raise_to_power, \"perform the computation\");  // ref to our single method\n\n}\n", "meta": {"hexsha": "b42aa189ac338cf2d8541e4a3775061c2df14527", "size": 1262, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/boost_wrapper.cpp", "max_stars_repo_name": "jwdinius/call_cpp_from_python_with_boost", "max_stars_repo_head_hexsha": "79f6b2ab08b798217130237203cd12cb718bc0fa", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2020-01-26T10:06:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-12T10:16:58.000Z", "max_issues_repo_path": "src/boost_wrapper.cpp", "max_issues_repo_name": "jwdinius/call_cpp_from_python_with_boost", "max_issues_repo_head_hexsha": "79f6b2ab08b798217130237203cd12cb718bc0fa", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/boost_wrapper.cpp", "max_forks_repo_name": "jwdinius/call_cpp_from_python_with_boost", "max_forks_repo_head_hexsha": "79f6b2ab08b798217130237203cd12cb718bc0fa", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.0571428571, "max_line_length": 120, "alphanum_fraction": 0.6973058637, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828341018881344, "lm_q2_score": 0.12592276647524683, "lm_q1q2_score": 0.061485997834943115}}
{"text": "/// @file\r\n/// @brief\r\n\n\r\n#include <ostream>\r\n#include <vector>\r\n#include <boost/bind/bind.hpp>\r\n#include <boost/lexical_cast.hpp>\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/test/data/test_case.hpp>\r\n#include <boost/test/data/monomorphic.hpp>\r\n#include <boost/algorithm/string/join.hpp>\r\n#include <boost/range/adaptor/transformed.hpp>\r\n\r\n\r\ntemplate< typename T >\r\nauto makeSequence( std::initializer_list< T >&& il )\r\n{\r\n     return std::vector< T, std::allocator< T > >{ il.begin(), il.end() };\r\n}\r\n\r\n\r\nnamespace std {\r\ntemplate< typename T >\r\nostream& boost_test_print_type( ostream& os, const vector< T, allocator< T > >& v )\r\n{\r\n     const char* sep = \"\";\r\n     os << '{';\r\n     for( auto&& el: v )\r\n     {\r\n          os << sep << el;\r\n          sep = \",\";\r\n     }\r\n     os << '}';\r\n     return os;\r\n}\r\n} // namespace std\r\n\r\n\r\nstruct InfiniteSequence\r\n{\r\n     enum { arity = 1 };\r\n\r\n     struct iterator\r\n     {\r\n          iterator() {}\r\n\r\n          int operator*() const { return current_; }\r\n          void operator++() { ++current_; }\r\n     private:\r\n          unsigned current_ = 0u;\r\n     };\r\n\r\n     InfiniteSequence() {}\r\n\r\n     boost::unit_test::data::size_t size() const\r\n     {\r\n          return boost::unit_test::data::BOOST_TEST_DS_INFINITE_SIZE;\r\n     }\r\n\r\n     iterator begin() const\r\n     {\r\n          return iterator{};\r\n     }\r\n};\r\n\r\n\r\nnamespace boost {\r\nnamespace unit_test {\r\nnamespace data {\r\nnamespace monomorphic {\r\n\r\ntemplate<> struct is_dataset< InfiniteSequence > : mpl::true_ {};\r\n\r\n} // namespace monomorphic\r\n} // namespace data\r\n} // namespace unit_test\r\n} // namespace boost\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE(\r\n     DatasetTestExamples,\r\n     * boost::unit_test::label( \"dataset\" )\r\n     * boost::unit_test::description( \"Tests with datasets for example\" )\r\n     )\r\nBOOST_DATA_TEST_CASE(\r\n     TestInfiniteSequence\r\n     , InfiniteSequence() ^ boost::unit_test::data::make({ 0,1,2,3,4,5,6,7,8,9,10,11,12 })\r\n     , generatedValue\r\n     , expectedValue\r\n     )\r\n{\r\n     BOOST_TEST( expectedValue == generatedValue );\r\n}\r\n\r\n\r\nstatic constexpr int INTEGERS[] = {\r\n     0,1,2,3,4,5,6,7,8,9\r\n};\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestInfiniteSequenceUsingArray\r\n     , InfiniteSequence() ^ boost::unit_test::data::make( INTEGERS )\r\n     , generatedValue\r\n     , expectedValue\r\n     )\r\n{\r\n     BOOST_TEST( expectedValue == generatedValue );\r\n}\r\n\r\n\r\nstatic constexpr int XRANGE_5 = 5;\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestUsingXrange\r\n     , boost::unit_test::data::xrange( XRANGE_5 )\r\n     , value\r\n     )\r\n{\r\n     BOOST_TEST( ((0 <= value) && (value < XRANGE_5)) );\r\n}\r\n\r\n\r\nstatic constexpr int XRANGE_3 = 3;\r\nstatic const char* const CSTRS_3[] = { \"zero\", \"one\", \"two\" };\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestUsingZip\r\n     , boost::unit_test::data::xrange( XRANGE_3 ) ^ boost::unit_test::data::make( CSTRS_3 )\r\n     , index\r\n     , text\r\n     )\r\n{\r\n     BOOST_TEST( (0 <= index && index < XRANGE_3 ) );\r\n     BOOST_TEST( std::string{ CSTRS_3[ index ] } == text );\r\n}\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestUsingJoin\r\n     , boost::unit_test::data::xrange( XRANGE_3 ) + boost::unit_test::data::make({ 66, 55, 44, 99, 12 })\r\n     , value\r\n     )\r\n{\r\n     BOOST_TEST((\r\n          value == 0\r\n          || value == 1\r\n          || value == 2\r\n          || value == 66\r\n          || value == 55\r\n          || value == 44\r\n          || value == 99\r\n          || value == 12\r\n          ));\r\n}\r\n\r\n\r\nstatic const char* CSTRS_4[] = { \"cake\", \"owl\", \"radio\", \"top\" };\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestUsingCartesianProduct\r\n     , boost::unit_test::data::xrange( 3 ) * boost::unit_test::data::make( CSTRS_4 )\r\n     , first\r\n     , second\r\n     )\r\n{\r\n     static const auto isPresent =\r\n          []( const std::string& str )\r\n          {\r\n               static constexpr auto end = CSTRS_4 + 4;\r\n               return end != std::find( CSTRS_4, end, str );\r\n          };\r\n\r\n     switch( first )\r\n     {\r\n          case 0:\r\n               BOOST_TEST( isPresent( second ) );\r\n               break;\r\n          case 1:\r\n               BOOST_TEST( isPresent( second ) );\r\n               break;\r\n          case 2:\r\n               BOOST_TEST( isPresent( second ) );\r\n               break;\r\n          default:\r\n               BOOST_TEST( false );\r\n     }\r\n}\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestDatasetSingleton\r\n     , boost::unit_test::data::make( 2 )\r\n     , singleton\r\n     )\r\n{\r\n     BOOST_TEST( (singleton == 2) );\r\n}\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestDatasetSingletonZip\r\n     , boost::unit_test::data::xrange( 3 ) ^ boost::unit_test::data::make( 2 )\r\n     , value\r\n     , singleton\r\n     )\r\n{\r\n     BOOST_TEST( ((0 <= value && value < 3) && (singleton == 2)) );\r\n}\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestDatasetOneToManyMapping\r\n     , boost::unit_test::data::xrange( 3 )\r\n          ^ boost::unit_test::data::make({\r\n               makeSequence({ 1,2,3 })\r\n               , makeSequence({ 9,7,3,5 })\r\n               , makeSequence({ 4,0 })\r\n          })\r\n     , index\r\n     , value\r\n     )\r\n{\r\n     boost::ignore_unused( index, value );\r\n     BOOST_TEST( true );\r\n}\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestDatasetRandomReal\r\n     , boost::unit_test::data::xrange( 3 ) ^ boost::unit_test::data::random()\r\n     , index\r\n     , random\r\n     )\r\n{\r\n     BOOST_TEST( (0 <= index && index < 3) );\r\n     BOOST_TEST( (random != 0.538256) ); /// I feel lucky!\r\n}\r\n\r\n\r\nBOOST_DATA_TEST_CASE(\r\n     TestDatasetRandomDiceRoll\r\n     , boost::unit_test::data::xrange( 5 ) ^ boost::unit_test::data::random( 1, 6 )\r\n     , step\r\n     , dice\r\n     )\r\n{\r\n     BOOST_TEST( (0 <= step && step < 5) );\r\n     BOOST_TEST( (1 <= dice && dice <= 6) );\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "d93f3e72afe4e16c2d6c9880cdf5dd36a21299f4", "size": 5681, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "testing/dataset_test.cpp", "max_stars_repo_name": "alexen/using_boost", "max_stars_repo_head_hexsha": "3573c90ba7b170e4232064ff1455b1a5c565d927", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "testing/dataset_test.cpp", "max_issues_repo_name": "alexen/using_boost", "max_issues_repo_head_hexsha": "3573c90ba7b170e4232064ff1455b1a5c565d927", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 18.0, "max_issues_repo_issues_event_min_datetime": "2021-11-24T13:59:42.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-02T19:42:33.000Z", "max_forks_repo_path": "testing/dataset_test.cpp", "max_forks_repo_name": "alexen/using_boost", "max_forks_repo_head_hexsha": "3573c90ba7b170e4232064ff1455b1a5c565d927", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1050583658, "max_line_length": 105, "alphanum_fraction": 0.5381094878, "num_tokens": 1495, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3886180408675583, "lm_q2_score": 0.15817435870093427, "lm_q1q2_score": 0.0614694093938395}}
{"text": "/**\n * @file lecture111.cpp\n * @brief Code demonstrating the program_options library and the chrono library\n * \n * @author Henry Chronowski\n * @assignment Lab 11.2\n * @date 19/11/2020\n * @credits Lecture 11.2\n * https://www.boost.org/doc/libs/1_71_0/doc/html/chrono.html\n * https://www.boost.org/doc/libs/1_71_0/doc/html/program_options.html\n * \n **/\n\n#include <boost/program_options.hpp>\n#include <boost/chrono/include.hpp>\n#include <iostream>\n#include <iomanip>\n#include <chrono>\n\nusing namespace boost::program_options;\n\nconst double NUMBER = 289.7773;\nconst double TO_SECONDS = 0.000000001;\n\nint main(int argc, const char *argv[])\n{\n  try\n  {\n    options_description desc{\"Options\"};\n    desc.add_options()\n      (\"help,h\", \"Help screen\")\n      (\"it\", value<long>()->default_value(100), \"Iterations\");\n\n    variables_map vm;\n    store(parse_command_line(argc, argv, desc), vm);\n    notify(vm);\n\n    if (vm.count(\"help\"))\n      std::cout << desc << '\\n';\n    else if (vm.count(\"it\"))\n    {\n      long i;\n\n      // Run a for loop and time it with the stl timer\n      auto startTime = std::chrono::high_resolution_clock::now();\n      for( i = 0; i < vm[\"it\"].as<long>(); i++)\n      {\n        std::sqrt(NUMBER);\n      }\n      auto secondsPassed = std::chrono::high_resolution_clock::now() - startTime;\n\n      // Run a for loop and time it with the chrono timer\n      boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();\n      for( i = 0; i < vm[\"it\"].as<long>(); i++)\n      {\n        std::sqrt(NUMBER);\n      }\n      boost::chrono::duration<double> dt = boost::chrono::system_clock::now() - start;\n\n      // Output results\n      std::cout << \"Iterations: \" << vm[\"it\"].as<long>() << '\\n';\n      std::cout << \"Boost timer: \" << dt << std::endl;\n      std::cout << \"STL timer: \" << std::fixed << std::setprecision(5) << secondsPassed.count() * TO_SECONDS << \" seconds\\n\";\n    }\n      \n  }\n  catch (const error &ex)\n  {\n    std::cerr << ex.what() << '\\n';\n  }\n}", "meta": {"hexsha": "807a7294b5414042d6d800313bfe4450346cab87", "size": 1989, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Lab11.2/src/lecture111.cpp", "max_stars_repo_name": "henrychronowski/CSI230-Demo", "max_stars_repo_head_hexsha": "1f18ad676655e9ccf084be703711b4ea39c73320", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lab11.2/src/lecture111.cpp", "max_issues_repo_name": "henrychronowski/CSI230-Demo", "max_issues_repo_head_hexsha": "1f18ad676655e9ccf084be703711b4ea39c73320", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lab11.2/src/lecture111.cpp", "max_forks_repo_name": "henrychronowski/CSI230-Demo", "max_forks_repo_head_hexsha": "1f18ad676655e9ccf084be703711b4ea39c73320", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.014084507, "max_line_length": 125, "alphanum_fraction": 0.6053293112, "num_tokens": 541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4301473485858429, "lm_q2_score": 0.1422318986458388, "lm_q1q2_score": 0.061180674086837895}}
{"text": "/*! \\file auto_boxplot.cpp\n\n   \\brief An example to demonstrate boxplot settings, including auto-scaling.\n   \\details See also:\n     example @c auto_1d_containers.cpp for an example autoscaling with multiple data-series.\n     example @c demo_boxplot.cpp for a wider range of use.\n\n// Copyright Jacob Voytko 2007\n// Copyright Paul A Bristow 2008, 2020\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// This file is written to be included from a Quickbook .qbk document.\n// It can be compiled by the C++ compiler, and run. Any output can\n// also be added here as comment or included or pasted in elsewhere.\n\n// Caution: this file contains Quickbook markup as well as code\n// and comments: don't change any of the special comment markups!\n\n//[auto_boxplot_1\n\n//!`First we need a few includes to use Boost.Plot\n//! (and some others only needed for this example).\n*/\n\n#include <boost/quan/meas.hpp> // measurement class\n#include <boost/quan/unc.hpp> // uncertain class\n\n#include <boost/svg_plot/svg_boxplot.hpp>\n  using boost::svg::svg_boxplot;\n\n#include <boost/svg_plot/detail/pair.hpp>\n// (Provides operator<< for std::pair).\n\n#include <boost/algorithm/minmax.hpp>\n using boost::minmax;\n#include <boost/algorithm/minmax_element.hpp>\n using boost::minmax_element;\n\n#include <boost/svg_plot/detail/auto_axes.hpp>\n  using boost::svg::show; // A single STL container.\n  using boost::svg::show_all; // Multiple STL containers.\n // using boost::svg::range; // Find min and max of a STL container.\n  using boost::svg::range_all;// Find min and max of multipler STL containers.\n\n#include <iostream> // for debugging.\n  using std::cout;\n  using std::endl;\n  using std::boolalpha;\n\n#include <limits>\n  using std::numeric_limits;\n\n#include <vector>\n  using std::vector;\n#include <set>\n  using std::multiset;\n\n#include <utility>\n  using std::pair;\n\n//] [/auto_boxplot_1]\n\nvoid scale_axis(double min_value, double max_value, // input\n               double* axis_min_value,  double* axis_max_value, double* axis_tick_increment, // updated.\n               bool origin, double tight, int min_ticks, int steps); \n\nconstexpr double tol100eps = 1000 * numeric_limits<double>::epsilon(); // Suitable tight value.\n\nint main()\n{\n  using namespace boost::svg; // Especially convenient for SVG colors.\n\n  //[auto_boxplot_2\n  /*`\n  This example uses containers to demonstrate autoscaling.\n  Autoscaling must inspect the container in order to find axis ranges that will be suitable.\n  First we create a container and fill with some fictional data.\n  */\n  vector<double> my_data;\n  // Initialize my_data with some entirely fictional data.\n  my_data.push_back(0.2); // [0]\n  my_data.push_back(1.1); // [1]\n  my_data.push_back(4.2); // [2]\n  my_data.push_back(3.3); // [3]\n  my_data.push_back(5.4); // [4]\n  my_data.push_back(6.5); // [5]\n  my_data.push_back(6.8); // [6]\n  my_data.push_back(6.9); // [7]\n  my_data.push_back(7.2); // [8]\n  my_data.push_back(7.3); // [9]\n  my_data.push_back(8.1); // [10]\n  my_data.push_back(8.5); // [11]\n\n  /*`Not included is an 'at limit' value that could confuse autoscaling.\n  Obviously we do not want the plot range to include infinity.\n  // my_data.push_back(numeric_limits<double>::infinity()); // [12]\n  */\n  try\n  { // Ensure error, warning and information messages from svg_plot are displayed by the catch block.\n    \n    double mn; // Ready to be updated by mnmx;\n    double mx;\n    int good = mnmx(my_data.begin(), my_data.end(), &mn, &mx);\n    cout << good << \" good values, \" << my_data.size() - good << \" limit values.\"\n      << \" min value = \" << mn << \", max = \" << mx << std::endl;\n    // 12 good values, 0 limit values. min value = 0.2, max = 8.5\n\n    svg_boxplot my_boxplot; // Construct a plot with all the default constructor values.\n    my_boxplot.title(\"Auto boxplot\");\n    my_boxplot.y_label(\"Values\");\n    my_boxplot.y_autoscale(my_data);  // Compute autoscale values for the plot.\n    //my_boxplot.y_autoscale(my_data.begin(), my_data.end());  // Compute autoscale values for the plot.\n    // my_boxplot.y_autoscale(std::make_pair(0., 10.));\n    //my_boxplot.y_autoscale(0., 9.);  // Compute autoscale values for the plot.\n    cout << boolalpha << \"Use y autoscale \" << my_boxplot.y_autoscale() << \".\"<< std::endl;\n    my_boxplot.plot(my_data, \"Auto boxplot\"); // Add the one data-series, and give it a title.\n    my_boxplot.write(\"auto_boxplot.svg\"); // Write the plot to file.\n\n    /*`It may be useful to display that range chosen by autoscaling. */\n    using boost::svg::detail::operator<<; // For displaying std::pair.\n    cout << \"y_range() \" << my_boxplot.y_range() << std::endl; // x_range() \n  }\n  catch(const std::exception& e)\n  { // Error, warning and information messages are displayed by the catch block.\n    std::cout <<\n      \"\\n\"\"Message from thrown exception was:\\n   \" << e.what() << std::endl;\n  }\n  //] [/auto_boxplot_2]\n\n  return 0;\n} // int main()\n\n/*\n\n//[auto_boxplot_output\n\nCompiling...\nauto_boxplot.cpp\nLinking...\nEmbedding manifest...\nAutorun \"j:\\Cpp\\SVG\\debug\\auto_boxplot.exe\"\n12 good values, 0 limit values. min value = 0.2, max = 8.5\nUse y autoscale true.\nMin outlier fences <-1.7 or >12.6333\nMin extreme fences <-7.075 or >18.0083\ny_range() 0, 9\nBuild Time 0:02\nBuild log was saved at \"file://j:\\Cpp\\SVG\\auto_boxplot\\Debug\\BuildLog.htm\"\n\n//] [auto_boxplot_output]\n\n*/\n\n", "meta": {"hexsha": "7515393b050fa1780d39ea896473408f02e8e0ff", "size": 5476, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/auto_boxplot.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/auto_boxplot.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/auto_boxplot.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 34.6582278481, "max_line_length": 104, "alphanum_fraction": 0.6901022644, "num_tokens": 1502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.12940274502147983, "lm_q1q2_score": 0.0611665394009805}}
{"text": "/**\n * \\file boost/numeric/ublasx/operation/for_each.hpp\n *\n * The \\c for_each operation.\n *\n * Copyright (c) 2010, Marco Guazzone\n *\n * Distributed under the Boost Software License, Version 1.0. (See\n * accompanying file LICENSE_1_0.txt or copy at\n * http://www.boost.org/LICENSE_1_0.txt)\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\n\n#ifndef BOOST_NUMERIC_UBLASX_OPERATION_FOR_EACH_HPP\n#define BOOST_NUMERIC_UBLASX_OPERATION_FOR_EACH_HPP\n\n\n#include <boost/numeric/ublas/fwd.hpp>\n#include <boost/numeric/ublas/traits.hpp>\n#include <boost/numeric/ublasx/operation/num_columns.hpp>\n#include <boost/numeric/ublasx/operation/num_rows.hpp>\n#include <boost/numeric/ublasx/operation/size.hpp>\n#include <boost/numeric/ublasx/tags.hpp>\n#include <cstddef>\n\n\nnamespace boost { namespace numeric { namespace ublasx {\n\nusing namespace ::boost::numeric::ublas;\n\n\nnamespace detail {\n\ntemplate <std::size_t Dim>\nstruct for_each_by_dim_impl;\n\ntemplate <>\nstruct for_each_by_dim_impl<1>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t{\n\t\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\ntemplate <>\nstruct for_each_by_dim_impl<2>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\n\ntemplate <typename TagT, typename OrientationT>\nstruct for_each_by_tag_impl;\n\ntemplate <>\nstruct for_each_by_tag_impl<tag::major, row_major_tag>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t{\n\t\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\ntemplate <>\nstruct for_each_by_tag_impl<tag::major, column_major_tag>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\ntemplate <>\nstruct for_each_by_tag_impl<tag::minor, row_major_tag>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\ntemplate <>\nstruct for_each_by_tag_impl<tag::minor, column_major_tag>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t{\n\t\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\ntemplate <>\nstruct for_each_by_tag_impl<tag::leading, row_major_tag>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\ntemplate <>\nstruct for_each_by_tag_impl<tag::leading, column_major_tag>\n{\n\ttemplate <typename MatrixExprT, typename UnaryFunctorT>\n\tstatic void apply(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n\t{\n\t\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\t\tsize_type nr = num_rows(me);\n\t\tsize_type nc = num_columns(me);\n\t\tfor (size_type r = 0; r < nr; ++r)\n\t\t{\n\t\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t\t{\n\t\t\t\tf(me()(r,c));\n\t\t\t}\n\t\t}\n\t}\n};\n\n\n} // Namespace detail\n\n\n/**\n * \\brief Apply a function to a vector expression.\n *\n * \\tparam VectorExprT The type of input vector expression.\n * \\tparam UnaryFunctorT The type of the function to be applied.\n *\n * \\param ve The input vector expression.\n * \\param f The unary function to be applied to the vector expression.\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\ntemplate <typename VectorExprT, typename UnaryFunctorT>\nvoid for_each(vector_expression<VectorExprT> const& ve, UnaryFunctorT f)\n{\n\ttypedef typename vector_traits<VectorExprT>::size_type size_type;\n\n\tsize_type n = size(ve);\n\tfor (size_type i = 0; i < n; ++i)\n\t{\n\t\tf(ve()(i));\n\t}\n}\n\n\n/**\n * \\brief Apply a function to a matrix expression.\n *\n * \\tparam MatrixExprT The type of input matrix expression.\n * \\tparam UnaryFunctorT The type of the function to be applied.\n *\n * \\param me The input matrix expression.\n * \\param f The unary function to be applied to the matrix expression.\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\ntemplate <typename MatrixExprT, typename UnaryFunctorT>\nvoid for_each(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n{\n\ttypedef typename matrix_traits<MatrixExprT>::size_type size_type;\n\n\tsize_type nr = num_rows(me);\n\tsize_type nc = num_columns(me);\n\tfor (size_type r = 0; r < nr; ++r)\n\t{\n\t\tfor (size_type c = 0; c < nc; ++c)\n\t\t{\n\t\t\tf(me()(r,c));\n\t\t}\n\t}\n}\n\n\n/**\n * \\brief Apply a function to a matrix expression along the given dimension.\n *\n * \\tparam Dim The dimension to follow when applying the function.\n *  Valid values are: 1 (by rows), and 2 (by columns).\n * \\tparam MatrixExprT The type of input matrix expression.\n * \\tparam UnaryFunctorT The type of the function to be applied.\n *\n * \\param me The input matrix expression.\n * \\param f The unary function to be applied to the matrix expression.\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\ntemplate <std::size_t Dim, typename MatrixExprT, typename UnaryFunctorT>\nvoid for_each(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n{\n\tdetail::for_each_by_dim_impl<Dim>::template apply(me, f);\n}\n\n\n/**\n * \\brief Apply a function to a matrix expression along the given dimension.\n *\n * \\tparam TagT The dimension to follow when applying the function.\n *  Valid values are \\c tag::major, \\c tag::minor, and \\c tag::leading.\n * \\tparam MatrixExprT The type of input matrix expression.\n * \\tparam UnaryFunctorT The type of the function to be applied.\n *\n * \\param me The input matrix expression.\n * \\param f The unary function to be applied to the matrix expression.\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\ntemplate <typename TagT, typename MatrixExprT, typename UnaryFunctorT>\nvoid for_each_by_tag(matrix_expression<MatrixExprT> const& me, UnaryFunctorT f)\n{\n\tdetail::for_each_by_tag_impl<TagT, typename matrix_traits<MatrixExprT>::orientation_category>::template apply(me, f);\n}\n\n\n}}} // Namespace boost::numeric::ublasx\n\n\n#endif // BOOST_NUMERIC_UBLASX_OPERATION_FOR_EACH_HPP\n", "meta": {"hexsha": "41752272f37b301ee69e52b961d6e5cbba8f8063", "size": 7664, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/numeric/ublasx/operation/for_each.hpp", "max_stars_repo_name": "comcon1/boost-ublasx", "max_stars_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "boost/numeric/ublasx/operation/for_each.hpp", "max_issues_repo_name": "comcon1/boost-ublasx", "max_issues_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "boost/numeric/ublasx/operation/for_each.hpp", "max_forks_repo_name": "comcon1/boost-ublasx", "max_forks_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3774834437, "max_line_length": 118, "alphanum_fraction": 0.7112473904, "num_tokens": 2169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.12421302132013365, "lm_q1q2_score": 0.061136175395804015}}
{"text": "/*!\n  \\file gpp_random_test.cpp\n  \\rst\n  This file contains functions for testing the functions and classes in gpp_random.hpp.  There are also a number of simple\n  supporting routines.  See header for comments on the general layout of these tests.\n\\endrst*/\n\n#include \"gpp_random_test.hpp\"\n\n#include <algorithm>\n#include <limits>\n#include <unordered_set>\n#include <vector>\n\n#include <boost/random/uniform_int.hpp>  // NOLINT(build/include_order)\n#include <boost/random/uniform_real.hpp>  // NOLINT(build/include_order)\n\n#include \"gpp_common.hpp\"\n#include \"gpp_exception.hpp\"\n#include \"gpp_geometry.hpp\"\n#include \"gpp_logging.hpp\"\n#include \"gpp_random.hpp\"\n#include \"gpp_test_utils.hpp\"\n\nnamespace optimal_learning {\n\nnamespace {\n\n/*!\\rst\n  Randomly generates points in a domain and ensures that the results are valid.  ComputeRandomPointInDomain guarantees\n  nothing further about the distribution of its outputs.\n\n  \\return\n    number of randomly generated points that were not inside the domain\n\\endrst*/\nOL_WARN_UNUSED_RESULT int RandomPointInDomainTest() {\n  static const int kDim = 5;\n  const int num_tests = 50;\n  ClosedInterval domain[kDim];\n  double random_point[kDim];\n  int total_errors = 0;\n\n  UniformRandomGenerator uniform_generator(314);\n  boost::uniform_real<double> uniform_double_domain_lower_bound(-5.0, -0.01);\n  boost::uniform_real<double> uniform_double_domain_upper_bound(0.02, 4.0);\n\n  // domain w/min edge length 0.03 and max edge length 9\n  for (int i = 0; i < kDim; ++i) {\n    domain[i].min = uniform_double_domain_lower_bound(uniform_generator.engine);\n    domain[i].max = uniform_double_domain_upper_bound(uniform_generator.engine);\n  }\n\n  for (int i = 0; i < num_tests; ++i) {\n    ComputeRandomPointInDomain(domain, kDim, &uniform_generator, random_point);\n\n    if (!CheckPointInHypercube(domain, random_point, kDim)) {\n      ++total_errors;\n    }\n  }\n\n  if (total_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"random_point_in_domain generated points outside the domain\\n\");\n  }\n\n  return total_errors;\n}\n\n/*!\\rst\n  Just your basic bubble sort.\n\n  Need the ability to sort matrices ``A_{ij}`` in blocks of ``A_{i*}``, doing comparisons only on\n  ``j``-th entries.  This is (as far as I know) awkward with STL vectors/sort.\n\\endrst*/\nOL_NONNULL_POINTERS void bubble_sort(int dim_to_sort, int dim, int num_points, double * restrict points) noexcept {\n  int newi;\n\n  for (int i = num_points - 1; i > 0; --i) {\n    newi = 0;\n    for (int j = 1; j <= i; ++j) {\n      if (points[(j-1)*dim + dim_to_sort] > points[j*dim + dim_to_sort]) {\n        double * restrict point_one = points + (j-1)*dim;\n        double * restrict point_two = points + j*dim;\n        std::swap_ranges(point_one, point_one + dim, point_two);\n        newi = j;\n      }\n    }\n    // after a given pass (loop over j), all elements after the most recent swap are\n    // already sorted.  skip over them.\n    i = newi;\n  }\n}\n\n/*!\\rst\n  Check that the latin hypercube point generation routine generates points in that are:\n\n  1. in the domain\n  2. properly distributed\n\n  Latin hypercube sampling with N points divides a d-dimensional domain into N subranges in\n  each ordinate direction.  For example, in the 2D domain [0,1]x[0,1], with N=8, the square\n  is divided up like a chess board.\n\n  Then lathin hypercube sampling guarantees that there can only be ONE point per row and per column.  In\n  the chess analogy, this sampling places N rooks so that no 2 attack each other.  Since placing each point\n  eliminates 1 row and 1 column, this is always possible (let the rooks be pidgeons).\n\n  So the test is as follows:\n\n  1. use latin hypercube sampling to sample N points\n  2. for each spatial dimension d\n  3. sort the points along their d-th coordinate\n  4. check that each subrange only contains 1 point\n\n  \\return\n    number of LHC points that were improperly distributed\n\\endrst*/\nOL_WARN_UNUSED_RESULT int HypercubePointInDomainTest() {\n  static const int kDim = 5;\n  const int num_tests = 50;\n  static const int kNumberOfSamples = 30;\n  ClosedInterval domain[kDim];\n  double random_points[kDim*kNumberOfSamples];\n  double subcube_edge_length, min_val, max_val;\n  int errors_this_iteration;\n  int total_errors = 0;\n\n  UniformRandomGenerator uniform_generator(314);\n  boost::uniform_real<double> uniform_double_domain_lower_bound(-5.0, -0.01);\n  boost::uniform_real<double> uniform_double_domain_upper_bound(0.02, 4.0);\n\n  // domain w/min edge length 0.03 and max edge length 9\n  for (int i = 0; i < kDim; ++i) {\n    domain[i].min = uniform_double_domain_lower_bound(uniform_generator.engine);\n    domain[i].max = uniform_double_domain_upper_bound(uniform_generator.engine);\n  }\n\n  for (int i = 0; i < num_tests; ++i) {\n    ComputeLatinHypercubePointsInDomain(domain, kDim, kNumberOfSamples, &uniform_generator, random_points);\n\n    for (int j = 0; j < kNumberOfSamples; ++j) {\n      if (!CheckPointInHypercube(domain, random_points + j*kDim, kDim)) {\n        ++total_errors;\n      }\n    }\n\n    for (int k = 0; k < kDim; ++k) {\n      subcube_edge_length = (domain[k].Length())/static_cast<double>(kNumberOfSamples);\n      bubble_sort(k, kDim, kNumberOfSamples, random_points);\n\n      // i-th point (sorted) must fall somewhere in the i-th slice of the hypercube\n      for (int j = 0; j < kNumberOfSamples; ++j) {\n        min_val = domain[k].min + subcube_edge_length*j;\n        max_val = min_val + subcube_edge_length;\n\n        errors_this_iteration = 0;\n        if (random_points[j*kDim + k] > max_val) {\n          ++errors_this_iteration;\n        }\n        if (random_points[j*kDim + k] < min_val) {\n          ++errors_this_iteration;\n        }\n        total_errors += errors_this_iteration;\n      }\n    }\n  }\n\n  if (total_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"hypercube_point_in_domain generated invalid point distributions\\n\");\n  }\n\n  return total_errors;\n}\n\n/*!\\rst\n  Test random point generation in a unit simplex.\n\n  \\return\n    number of randomly generated points that were not in the unit simplex\n\\endrst*/\nOL_WARN_UNUSED_RESULT int RandomPointInUnitSimplexTest() {\n  static const int kDim = 5;\n  const int num_tests = 50;\n  static const int kNumberOfSamples = 30;\n  double random_points[kDim*kNumberOfSamples];\n  int total_errors = 0;\n\n  UniformRandomGenerator uniform_generator(314);\n\n  for (int i = 0; i < num_tests; ++i) {\n    ComputeUniformPointsInUnitSimplex(kDim, kNumberOfSamples, &uniform_generator, random_points);\n\n    for (int j = 0; j < kNumberOfSamples; ++j) {\n      if (!CheckPointInUnitSimplex(random_points + j*kDim, kDim)) {\n        ++total_errors;\n      }\n    }\n  }\n\n  if (total_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"RandomPointInUnitSimplex generated invalid point distributions\\n\");\n  }\n\n  return total_errors;\n}\n\n}  // end unnamed namespace\n\nint RunRandomPointGeneratorTests() {\n  int current_errors;\n  int total_errors = 0;\n\n  current_errors = RandomPointInDomainTest();\n  total_errors += current_errors;\n  if (current_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"Random Point in Domain errors = %d\\n\", current_errors);\n  }\n\n  current_errors = HypercubePointInDomainTest();\n  total_errors += current_errors;\n  if (current_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"Latin Hypercube Points in Domain errors = %d\\n\", current_errors);\n  }\n\n  current_errors = RandomPointInUnitSimplexTest();\n  total_errors += current_errors;\n  if (current_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"Random Point in Unit Simplex errors = %d\\n\", current_errors);\n  }\n\n  return total_errors;\n}\n\nnamespace {\n\n/*!\\rst\n  Checks that all elements of a vector are unique.\n\n  Modifies the vector (by sorting).\n\n  \\input\n    :input_vector: vector to be checked\n  \\return\n    true if all elements are distinct\n\\endrst*/\ntemplate <typename T>\nOL_WARN_UNUSED_RESULT bool CheckAllElementsUnique(const std::vector<T>& input_vector) {\n  return std::unordered_set<T>(input_vector.begin(), input_vector.end()).size() == input_vector.size();\n}\n\n/*!\\rst\n  Fill a vector with all unique random elements.  Random elements are meant\n  to potentially be fake process IDs for non-system processes.  I'm assuming\n  those probably lie in ``(100, 2^32)`` or so.\n\n  \\input\n    :thread_ids[1]: allocated vector of thread ids, already set to desired size\n  \\output\n    :thread_ids[1]: overwrites all thread_ids entries with unique values\n\\endrst*/\nvoid GenerateUniqueRandomVector(std::vector<int> * thread_ids) {\n  UniformRandomGenerator uniform_generator(314, 0);  // single instance, so thread_id = 0\n  boost::uniform_int<int> uniform_int_distribution(100, std::numeric_limits<int>::max());\n\n  // generate seeds\n  for (auto& entry : (*thread_ids)) {\n    entry = uniform_int_distribution(uniform_generator.engine);\n  }\n\n  while (false == CheckAllElementsUnique(*thread_ids)) {\n    // could be smarter about this and only regen non-unique elements\n    for (auto& entry : (*thread_ids)) {\n      entry = uniform_int_distribution(uniform_generator.engine);\n    }\n  }\n\n  // re-randomize ordering\n  std::shuffle((*thread_ids).begin(), (*thread_ids).end(), uniform_generator.engine);\n}\n\n/*!\\rst\n  Test the features of random number generator containers.\n\n  1. Check that explicitly setting the seed works and sets \"last_seed\" properly\n  2. Verify that the reset functionality properly resets to the last seed\n  3. verify that with different input thread ids, container will generate will\n     generate a unique seed per thread\n\n  \\return\n    number of test failures\n\\endrst*/\ntemplate <typename RNGContainer>\nOL_WARN_UNUSED_RESULT int RandomNumberGeneratorContainerTestCore() {\n  int total_errors = 0;\n  int current_errors = 0;\n\n  // set seed manually; verify that last seed is set appropriately\n  {\n    current_errors = 0;\n    const typename RNGContainer::EngineType::result_type seed1 = 31415;\n    const typename RNGContainer::EngineType::result_type seed2 = 27182;\n    RNGContainer test_rng(seed1);\n    if (!CheckIntEquals(test_rng.last_seed(), seed1)) {\n      ++current_errors;\n    }\n\n    test_rng.SetExplicitSeed(seed2);\n    if (!CheckIntEquals(test_rng.last_seed(), seed2)) {\n      ++current_errors;\n    }\n    total_errors += current_errors;\n  }\n\n  // verify last seed reset: set seed and save off PRNG state.  Generate a few randoms\n  // and check that state changed; then reset to last seed and verify against the original state\n  {\n    current_errors = 0;\n    RNGContainer rng;\n\n    typename RNGContainer::EngineType original_engine(rng.GetEngine());  // copy ctor\n    rng.GetEngine().discard(13);\n    if (rng.GetEngine() == original_engine) {\n      ++current_errors;  // engine state should have changed\n    }\n\n    rng.ResetToMostRecentSeed();\n    if (rng.GetEngine() != original_engine) {\n      ++current_errors;  // engine state should have been reset\n    }\n\n    total_errors += current_errors;\n  }\n\n  // multi-threaded seeding check\n  // build several RNGContainer objects w/different thread ids (ensure ids are all different)\n  // verify that objects' last_seed() values are all different\n  {\n    current_errors = 0;\n    const int max_num_threads = 11;\n\n    std::vector<RNGContainer> normal_rng_vec(max_num_threads);\n    std::vector<typename RNGContainer::EngineType::result_type> seed_values(max_num_threads);\n    std::vector<int> thread_ids(max_num_threads);\n    GenerateUniqueRandomVector(&thread_ids);\n\n    for (int i = 0; i < max_num_threads; ++i) {\n      normal_rng_vec[i].SetRandomizedSeed(38970, thread_ids[i]);\n      seed_values[i] = normal_rng_vec[i].last_seed();\n    }\n\n    bool all_seeds_different = CheckAllElementsUnique(seed_values);\n\n    if (all_seeds_different == false) {\n      OL_PARTIAL_FAILURE_PRINTF(\"seed values are not all different!\\n\");\n      for (const auto& value : seed_values) {\n        OL_ERROR_PRINTF(\"%d \", value);\n      }\n      OL_ERROR_PRINTF(\"\\n\");\n    }\n\n    if (!all_seeds_different) {\n      ++current_errors;\n    }\n    total_errors += current_errors;\n  }\n\n  return total_errors;\n}\n\n/*!\\rst\n  Checks that NormalRNGSimulator is behaving correctly:\n\n  * Tests index increments as expected\n  * Tests ResetToMostRecentSeed reset index to 0\n  * Tests exception handling when number of queries of random numbers exceeds\n  * size of the random table\n\n  \\return\n    number of test failures: 0 if NormalRNGSimulator behaving correctly\n\\endrst*/\nint NormalRNGSimulatorTest() {\n  int total_errors = 0;\n  int random_table_size = 500;\n  std::vector<double> random_table(random_table_size);\n  for (int i = 0; i < random_table_size; ++i) {\n    random_table[i] = static_cast<double>(i);\n  }\n  NormalRNGSimulator rng_simulator(random_table);\n\n  for (int n = 0; n < 40; ++n) {\n    int current_idx = rng_simulator.index();\n    rng_simulator();\n    int next_idx = rng_simulator.index();\n    total_errors = ((next_idx - current_idx) == 1) ? total_errors : (total_errors+1);\n  }\n\n  rng_simulator.ResetToMostRecentSeed();\n  total_errors = (rng_simulator.index() == 0) ? total_errors : (total_errors+1);\n\n  for (int n = 0; n < random_table_size; ++n) {\n    rng_simulator();\n  }\n\n  ++total_errors;\n\n  try {\n    rng_simulator();\n  } catch (const InvalidValueException<int>& exception) {\n    if ((exception.value() == random_table_size) && (exception.truth() == random_table_size)) {\n      --total_errors;\n    }\n  }\n\n  return total_errors;\n}\n\n}  // end unnamed namespace\n\n/*!\\rst\n  .. Note:: only NormalRNG is meant to be used multi-threaded, so UniformRandomGenerator\n      is not tested for generating unique seeds in a multi-threaded environment\n\\endrst*/\nint RandomNumberGeneratorContainerTest() {\n  int total_errors = 0;\n  int current_errors = 0;\n\n  current_errors = RandomNumberGeneratorContainerTestCore<UniformRandomGenerator>();\n  if (current_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"UniformRandomGenerator failed with %d errors\\n\", current_errors);\n  } else {\n    OL_PARTIAL_SUCCESS_PRINTF(\"UniformRandomGenerator passed all tests\\n\");\n  }\n  total_errors += current_errors;\n\n  current_errors = RandomNumberGeneratorContainerTestCore<NormalRNG>();\n  if (current_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"NormalRNG failed with %d errors\\n\", current_errors);\n  } else {\n    OL_PARTIAL_SUCCESS_PRINTF(\"NormalRNG passed all tests\\n\");\n  }\n  total_errors += current_errors;\n\n  current_errors = NormalRNGSimulatorTest();\n  if (current_errors != 0) {\n    OL_PARTIAL_FAILURE_PRINTF(\"NormalRNGSimulator failed with %d errors\\n\", current_errors);\n  } else {\n    OL_PARTIAL_SUCCESS_PRINTF(\"NormalRNGSimulator passed all tests\\n\");\n  }\n  total_errors += current_errors;\n\n  return total_errors;\n}\n\n}  // end namespace optimal_learning\n", "meta": {"hexsha": "92e88856eac85f6e3a212d1a9018d8d1563e4b48", "size": 14557, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "moe/optimal_learning/cpp/gpp_random_test.cpp", "max_stars_repo_name": "dstoeckel/MOE", "max_stars_repo_head_hexsha": "5b5a6a2c6c3cf47320126f7f5894e2a83e347f5c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 966.0, "max_stars_repo_stars_event_min_datetime": "2015-01-10T05:27:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:04:36.000Z", "max_issues_repo_path": "moe/optimal_learning/cpp/gpp_random_test.cpp", "max_issues_repo_name": "dstoeckel/MOE", "max_issues_repo_head_hexsha": "5b5a6a2c6c3cf47320126f7f5894e2a83e347f5c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 46.0, "max_issues_repo_issues_event_min_datetime": "2015-01-16T22:33:08.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-04T16:33:27.000Z", "max_forks_repo_path": "moe/optimal_learning/cpp/gpp_random_test.cpp", "max_forks_repo_name": "dstoeckel/MOE", "max_forks_repo_head_hexsha": "5b5a6a2c6c3cf47320126f7f5894e2a83e347f5c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 143.0, "max_forks_repo_forks_event_min_datetime": "2015-01-07T03:57:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-28T01:10:45.000Z", "avg_line_length": 32.063876652, "max_line_length": 122, "alphanum_fraction": 0.7130590094, "num_tokens": 3700, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46101677931231594, "lm_q2_score": 0.13117322715829127, "lm_q1q2_score": 0.06047305871651826}}
{"text": "// Copyright Louis Dionne 2013-2017\r\n// Distributed under the Boost Software License, Version 1.0.\r\n// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)\r\n\r\n#include <boost/hana/functional/iterate.hpp>\r\n\r\n#include <boost/hana/assert.hpp>\r\n#include <boost/hana/equal.hpp>\r\n\r\n#include <laws/base.hpp>\r\n\r\n#include <vector>\r\nnamespace hana = boost::hana;\r\nusing hana::test::ct_eq;\r\n\r\n\r\nstruct undefined { };\r\n\r\nconstexpr int incr(int i) { return i + 1; }\r\n\r\nint main() {\r\n    hana::test::_injection<0> f{};\r\n\r\n    // \"real usage\" tests\r\n    static_assert(hana::iterate<3>(incr, 0) == 3, \"\");\r\n    {\r\n        std::vector<int> vec;\r\n        hana::iterate<10>([&](int i) { vec.push_back(i); return i + 1; }, 0);\r\n        BOOST_HANA_RUNTIME_CHECK(\r\n            vec == std::vector<int>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}\r\n        );\r\n    }\r\n\r\n    // equivalence between iterate<n>(f, x) and iterate<n>(f)(x)\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<0>(undefined{})(ct_eq<0>{}),\r\n        hana::iterate<0>(undefined{}, ct_eq<0>{})\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<4>(f)(ct_eq<0>{}),\r\n        hana::iterate<4>(f, ct_eq<0>{})\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<10>(f)(ct_eq<0>{}),\r\n        hana::iterate<10>(f, ct_eq<0>{})\r\n    ));\r\n\r\n    // systematic tests\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<0>(undefined{}, ct_eq<0>{}),\r\n        ct_eq<0>{}\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<1>(f, ct_eq<0>{}),\r\n        f(ct_eq<0>{})\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<2>(f, ct_eq<0>{}),\r\n        f(f(ct_eq<0>{}))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<3>(f, ct_eq<0>{}),\r\n        f(f(f(ct_eq<0>{})))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<4>(f, ct_eq<0>{}),\r\n        f(f(f(f(ct_eq<0>{}))))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<5>(f, ct_eq<0>{}),\r\n        f(f(f(f(f(ct_eq<0>{})))))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<6>(f, ct_eq<0>{}),\r\n        f(f(f(f(f(f(ct_eq<0>{}))))))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<7>(f, ct_eq<0>{}),\r\n        f(f(f(f(f(f(f(ct_eq<0>{})))))))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<11>(f, ct_eq<0>{}),\r\n        f(f(f(f(f(f(f(f(f(f(f(ct_eq<0>{})))))))))))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<12>(f, ct_eq<0>{}),\r\n        f(f(f(f(f(f(f(f(f(f(f(f(ct_eq<0>{}))))))))))))\r\n    ));\r\n\r\n    BOOST_HANA_CONSTANT_CHECK(hana::equal(\r\n        hana::iterate<13>(f, ct_eq<0>{}),\r\n        f(f(f(f(f(f(f(f(f(f(f(f(f(ct_eq<0>{})))))))))))))\r\n    ));\r\n\r\n    // We can't nest too many calls to f, because that uses a hana::tuple\r\n    // internally and some implementation (libstdc++) have trouble with\r\n    // deeply-nested calls to `std::is_constructible`, which is required by\r\n    // hana::tuple. Hence, we use an homogeneous function for the remaining\r\n    // tests.\r\n    static_assert(hana::iterate<23>(incr, 0) == 23, \"\");\r\n    static_assert(hana::iterate<24>(incr, 0) == 24, \"\");\r\n    static_assert(hana::iterate<25>(incr, 0) == 25, \"\");\r\n    static_assert(hana::iterate<26>(incr, 0) == 26, \"\");\r\n    static_assert(hana::iterate<27>(incr, 0) == 27, \"\");\r\n    static_assert(hana::iterate<28>(incr, 0) == 28, \"\");\r\n    static_assert(hana::iterate<29>(incr, 0) == 29, \"\");\r\n\r\n    static_assert(hana::iterate<30>(incr, 0) == 30, \"\");\r\n    static_assert(hana::iterate<31>(incr, 0) == 31, \"\");\r\n    static_assert(hana::iterate<32>(incr, 0) == 32, \"\");\r\n    static_assert(hana::iterate<33>(incr, 0) == 33, \"\");\r\n    static_assert(hana::iterate<34>(incr, 0) == 34, \"\");\r\n    static_assert(hana::iterate<35>(incr, 0) == 35, \"\");\r\n    static_assert(hana::iterate<36>(incr, 0) == 36, \"\");\r\n    static_assert(hana::iterate<37>(incr, 0) == 37, \"\");\r\n    static_assert(hana::iterate<38>(incr, 0) == 38, \"\");\r\n    static_assert(hana::iterate<39>(incr, 0) == 39, \"\");\r\n\r\n    static_assert(hana::iterate<40>(incr, 0) == 40, \"\");\r\n    static_assert(hana::iterate<41>(incr, 0) == 41, \"\");\r\n    static_assert(hana::iterate<42>(incr, 0) == 42, \"\");\r\n    static_assert(hana::iterate<43>(incr, 0) == 43, \"\");\r\n    static_assert(hana::iterate<44>(incr, 0) == 44, \"\");\r\n    static_assert(hana::iterate<45>(incr, 0) == 45, \"\");\r\n    static_assert(hana::iterate<46>(incr, 0) == 46, \"\");\r\n    static_assert(hana::iterate<47>(incr, 0) == 47, \"\");\r\n    static_assert(hana::iterate<48>(incr, 0) == 48, \"\");\r\n    static_assert(hana::iterate<49>(incr, 0) == 49, \"\");\r\n\r\n    static_assert(hana::iterate<50>(incr, 0) == 50, \"\");\r\n    static_assert(hana::iterate<51>(incr, 0) == 51, \"\");\r\n    static_assert(hana::iterate<52>(incr, 0) == 52, \"\");\r\n    static_assert(hana::iterate<53>(incr, 0) == 53, \"\");\r\n    static_assert(hana::iterate<54>(incr, 0) == 54, \"\");\r\n    static_assert(hana::iterate<55>(incr, 0) == 55, \"\");\r\n    static_assert(hana::iterate<56>(incr, 0) == 56, \"\");\r\n    static_assert(hana::iterate<57>(incr, 0) == 57, \"\");\r\n    static_assert(hana::iterate<58>(incr, 0) == 58, \"\");\r\n    static_assert(hana::iterate<59>(incr, 0) == 59, \"\");\r\n}\r\n", "meta": {"hexsha": "1707f85cb06c997240bd386377c77e390120b7a1", "size": 5348, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/hana/test/functional/iterate.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/hana/test/functional/iterate.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/hana/test/functional/iterate.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 35.1842105263, "max_line_length": 82, "alphanum_fraction": 0.5544128646, "num_tokens": 1748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.12085323565689977, "lm_q1q2_score": 0.06042661782844989}}
{"text": "// Group B - Perpetual American Options\r\n//\r\n// by Scott Sidoli\r\n//\r\n// 6-10-19\r\n//\r\n// Types.hpp\r\n//\r\n// Create new type names for parameters in option data.\r\n\r\n#ifndef Types_hpp\r\n#define Types_hpp\r\n\r\n#include <boost/serialization/strong_typedef.hpp>\r\n\r\nBOOST_STRONG_TYPEDEF(double, Strike_Price);\r\nBOOST_STRONG_TYPEDEF(double, Volatility);\r\nBOOST_STRONG_TYPEDEF(double, rate);\r\nBOOST_STRONG_TYPEDEF(double, cost_of_carry);\r\nBOOST_STRONG_TYPEDEF(double, curr_stock_price);\r\n\r\n\r\n#endif", "meta": {"hexsha": "f83a428772c919425dfeca40328d7050bb38c27d", "size": 485, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "Group B/Group B/Types.hpp", "max_stars_repo_name": "scottsidoli/C-for-Financial-Engineering---Baruch-Pre-MFE-Certificate", "max_stars_repo_head_hexsha": "79c2fb297a85c914d5f0b8671bb17636801e3ce7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2021-11-05T08:14:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-05T08:14:37.000Z", "max_issues_repo_path": "Group B/Group B/Types.hpp", "max_issues_repo_name": "scottsidoli/C-for-Financial-Engineering---Baruch-Pre-MFE-Certificate", "max_issues_repo_head_hexsha": "79c2fb297a85c914d5f0b8671bb17636801e3ce7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Group B/Group B/Types.hpp", "max_forks_repo_name": "scottsidoli/C-for-Financial-Engineering---Baruch-Pre-MFE-Certificate", "max_forks_repo_head_hexsha": "79c2fb297a85c914d5f0b8671bb17636801e3ce7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0869565217, "max_line_length": 56, "alphanum_fraction": 0.7443298969, "num_tokens": 110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.5, "lm_q2_score": 0.12085322932404166, "lm_q1q2_score": 0.06042661466202083}}
{"text": "#include \"testsuite.h\"\n\n#include <blitz/array.h>\n\nBZ_USING_NAMESPACE(blitz)\n\nArray< double, 1> a(100); \n\nint main(){\n\n  BZTEST(a.size() == 100);\n  return 0;\n}\n\n", "meta": {"hexsha": "df54e798044e092a55ab7541c274e71711f4b774", "size": 160, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "depspawn-blitz-0.10/testsuite/gary-huber-1.cpp", "max_stars_repo_name": "fraguela/depspawn", "max_stars_repo_head_hexsha": "b5760f4c0d38a1b245ee5274e2ccc5c5fe2d3d45", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8.0, "max_stars_repo_stars_event_min_datetime": "2017-04-12T11:05:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:10:27.000Z", "max_issues_repo_path": "ibtk/third_party/blitz-0.10/testsuite/gary-huber-1.cpp", "max_issues_repo_name": "MSV-Project/IBAMR", "max_issues_repo_head_hexsha": "3cf614c31bb3c94e2620f165ba967cba719c45ea", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ibtk/third_party/blitz-0.10/testsuite/gary-huber-1.cpp", "max_forks_repo_name": "MSV-Project/IBAMR", "max_forks_repo_head_hexsha": "3cf614c31bb3c94e2620f165ba967cba719c45ea", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 10.6666666667, "max_line_length": 26, "alphanum_fraction": 0.6375, "num_tokens": 53, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.48438008427698437, "lm_q2_score": 0.12421301969912354, "lm_q1q2_score": 0.06016631295016018}}
{"text": "//==================================================================================================\n/*!\n  @file\n\n  @copyright 2016 NumScale SAS\n\n  Distributed under the Boost Software License, Version 1.0.\n  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)\n*/\n//==================================================================================================\n#ifndef BOOST_SIMD_CONSTANT_ZERO_HPP_INCLUDED\n#define BOOST_SIMD_CONSTANT_ZERO_HPP_INCLUDED\n\n#if defined(DOXYGEN_ONLY)\nnamespace boost { namespace simd\n{\n  /*!\n    @ingroup group-constant\n\n    Generate  value 0\n\n\n    @par Header <boost/simd/constant/zero.hpp>\n\n    @par Semantic:\n\n    @code\n    T r = Zero<T>();\n    @endcode\n\n    is similar to:\n\n    @code\n    T r = T(0);\n    @endcode\n\n    @return The Zero constant for the proper type\n  **/\n  template<typename T> T Zero();\n\n  namespace functional\n  {\n    /*!\n      @ingroup group-callable-constant\n      Generate the  constant zero.\n\n      @return The Zero constant for the proper type\n    **/\n    Value Zero();\n  }\n} }\n#endif\n\n#include <boost/simd/constant/scalar/zero.hpp>\n#include <boost/simd/constant/simd/zero.hpp>\n\n#endif\n", "meta": {"hexsha": "c8876eeecbfc2706dd90ae31e37ba4453dc6aeb1", "size": 1172, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "include/boost/simd/constant/zero.hpp", "max_stars_repo_name": "TobiasLudwig/boost.simd", "max_stars_repo_head_hexsha": "c04d0cc56747188ddb9a128ccb5715dd3608dbc1", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "include/boost/simd/constant/zero.hpp", "max_issues_repo_name": "TobiasLudwig/boost.simd", "max_issues_repo_head_hexsha": "c04d0cc56747188ddb9a128ccb5715dd3608dbc1", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/boost/simd/constant/zero.hpp", "max_forks_repo_name": "TobiasLudwig/boost.simd", "max_forks_repo_head_hexsha": "c04d0cc56747188ddb9a128ccb5715dd3608dbc1", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 3.0, "max_forks_repo_forks_event_min_datetime": "2018-02-16T09:58:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-10T14:22:43.000Z", "avg_line_length": 20.2068965517, "max_line_length": 100, "alphanum_fraction": 0.5554607509, "num_tokens": 257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4843800842769844, "lm_q2_score": 0.12421299862599396, "lm_q1q2_score": 0.0601663027427559}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Serial Unit Tests for the LinearSolverPETSc Class\n */\n\n#define BOOST_TEST_MODULE LinearSolverPETScSerial\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n#include <stdexcept>\n\n#include \"LinearSolverPETScSerial.h\"\n#include \"Error.h\"\n#include \"SparseMatrixCOO.h\"\n#include <iostream>\n\nusing namespace cupcfd::linearsolvers;\n\n// Setup\nBOOST_AUTO_TEST_CASE(setup)\n{\n    int argc = boost::unit_test::framework::master_test_suite().argc;\n    char ** argv = boost::unit_test::framework::master_test_suite().argv;\n\tPetscInitialize(&argc, &argv, NULL, NULL);\n}\n\n// ============== Constructors ===================\n// Test 1: Check values are probably defaulted to their null states\nBOOST_AUTO_TEST_CASE(constructor_test1)\n{\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.a != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.mLocal, 0);\n\tBOOST_CHECK_EQUAL(solver.nLocal, 0);\n\tBOOST_CHECK_EQUAL(solver.mGlobal, 0);\n\tBOOST_CHECK_EQUAL(solver.nGlobal, 0);\n\n\tBOOST_CHECK_EQUAL(solver.xRanges, static_cast<decltype(solver.xRanges)>(nullptr));\n\tBOOST_CHECK_EQUAL(solver.bRanges, static_cast<decltype(solver.bRanges)>(nullptr));\n\tBOOST_CHECK_EQUAL(solver.aRanges, static_cast<decltype(solver.aRanges)>(nullptr));\n}\n\n// ============== setupVectorX ===================\n// Test 1: Check Vector is created if a suitable row size is set\nBOOST_AUTO_TEST_CASE(setupVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 20;\n\tsolver.mGlobal = 20;\n\n\t// Test and Check\n\tstatus = solver.setupVectorX();\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.x == PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tPetscInt cmp[2] = {0, 20};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, solver.xRanges, solver.xRanges + 2);\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// Test 2: Check error if a suitable row size is not set - e.g. 0\nBOOST_AUTO_TEST_CASE(setupVectorX_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 0;\n\tsolver.mGlobal = 0;\n\n\t// Test and Check\n\tstatus = solver.setupVectorX();\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Check error if the communicator is not set to PETSC_COMM_SELF\n// ToDo\nBOOST_AUTO_TEST_CASE(setupVectorX_test3)\n{\n\n}\n\n// ============== resetVectorX ===================\n// Test 1: Test the successful reset of a existing vector\nBOOST_AUTO_TEST_CASE(resetVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t//Setup\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 20;\n\tsolver.mGlobal = 20;\n\n\t// Create the vector\n\tstatus = solver.setupVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.resetVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.xRanges, static_cast<decltype(solver.xRanges)>(nullptr));\n}\n\n// Test 2: Test the successful reset of a non-existing vector (i.e. no\n// change, but no error either).\nBOOST_AUTO_TEST_CASE(resetVectorX_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Check it is unset for the test\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// === Test and Check ===\n\tstatus = solver.resetVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n}\n\n// ============== setupVectorB ===================\n// Test 1: Check Vector is created if a suitable row size is set\nBOOST_AUTO_TEST_CASE(setupVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 20;\n\tsolver.mGlobal = 20;\n\n\t// Test and Check\n\tstatus = solver.setupVectorB();\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.b == PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.bRanges, static_cast<decltype(solver.bRanges)>(nullptr));\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// Test 2: Check error if a suitable row size is not set - e.g. 0\nBOOST_AUTO_TEST_CASE(setupVectorB_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 0;\n\tsolver.mGlobal = 0;\n\n\t// Test and Check\n\tstatus = solver.setupVectorB();\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Check error if the correct communicator is not set to PETSC_COMM_SELF\n// ToDo\nBOOST_AUTO_TEST_CASE(setupVectorB_test3)\n{\n\n}\n\n\n// ============== resetVectorB ===================\n// Test 1: Test the successful reset of a existing vector\nBOOST_AUTO_TEST_CASE(resetVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t//Setup\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 20;\n\tsolver.mGlobal = 20;\n\n\t// Create the vector\n\tstatus = solver.setupVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.resetVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.bRanges, static_cast<decltype(solver.bRanges)>(nullptr));\n}\n\n// Test 2: Test the successful reset of a non-existing vector (i.e. no\n// change, but no error either).\nBOOST_AUTO_TEST_CASE(resetVectorB_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Check it is unset for the test\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// === Test and Check ===\n\tstatus = solver.resetVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n}\n\n// ============== setupMatrixA ===================\n// Test 1: Test setup of PETSc matrix from a SparseCOO matrix\nBOOST_AUTO_TEST_CASE(setupMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tPetscInt cmp[2] = {0, 8};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, solver.aRanges, solver.aRanges + 2);\n\n\t// ToDo: Ideally would like to check PETSc internal nnz structure of matrix\n}\n\n// ============== resetMatrixA ===================\n//Test 1: Check the matrix is correctly reset after being setup\nBOOST_AUTO_TEST_CASE(resetMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Setup Matrix\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check Reset\n\tstatus = solver.resetMatrixA();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check range array has been reset\n\tBOOST_CHECK_EQUAL(solver.aRanges, static_cast<decltype(solver.aRanges)>(nullptr));\n}\n\n// Test 2: Check the matrix reset function does not error when\n// no matrix is yet setup\nBOOST_AUTO_TEST_CASE(resetMatrixA_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Test and Check Reset\n\tstatus = solver.resetMatrixA();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// ToDo\n// Test 3: There should be an error code for PETSc errors\nBOOST_AUTO_TEST_CASE(resetMatrixA_test3)\n{\n\n}\n\n// ============== setup ===========\n// Test 1: Test the successful setup of the object from a matrix\nBOOST_AUTO_TEST_CASE(setup_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// ============== reset ===========\n// Test 1: Test a successful reset after the object has been setup\nBOOST_AUTO_TEST_CASE(reset_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = solver.reset();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// Test 2: Test a successful reset if the object is still in an unset state\nBOOST_AUTO_TEST_CASE(reset_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tstatus = solver.reset();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// ============== setValuesVectorX(T scalar) ===========\n// Test 1: Test setting the entire vector to a specific scalar\n// Ideally want to check value using getter, but will\n// use PETSc function directly to keep function tests separate\nBOOST_AUTO_TEST_CASE(setValuesVectorX_scalar_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorX(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Any position should hold the value 2.4\n\tPetscInt pos = 5;\n\tPetscScalar result;\n\tVecGetValues(solver.x, 1, &pos, &result);\n\tBOOST_CHECK_EQUAL(result, 2.4);\n\n\t// Second check in different position to ensure more than one was updated\n\tpos = 7;\n\tresult = 0.0;\n\tVecGetValues(solver.x, 1, &pos, &result);\n\tBOOST_CHECK_EQUAL(result, 2.4);\n}\n\n// Test 2: Check for error when vector does not exist\nBOOST_AUTO_TEST_CASE(setValuesVectorX_scalar_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorX(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// ============== setValuesVectorX(T * scalars, int nScalars) ===========\n// Test 1: Test setting values at specific locations\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Any position should hold the value 2.4\n\tPetscInt pos[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\tPetscScalar result[8];\n\tVecGetValues(solver.x, 8, pos, result);\n\n\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7, 0.0, 0.0, 0.0, 0.3};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n}\n\n// Test 2: Check Error for arrays of mismatched sizes\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 7};\n\tdouble values[2] = {0.5, 0.7};\n\tstatus = solver.setValuesVectorX(values, 2, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_ARRAY_MISMATCH_SIZE);\n}\n\n// Test 3: Check error for vector X not being setup\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// Test 4: Check error for unset row size\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test4)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 5: Check error for an index lower than minimum of global range\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test5)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Test and Check\n\tint indices[3] = {-1, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// Test 6: Check error for an index higher than maximum of global range\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test6)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 8};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// ============== setValuesVectorB(T scalar) ===========\n// Test 1: Test setting the entire vector to a specific scalar\n// Ideally want to check value using getter, but will\n// use PETSc function directly to keep function tests separate\nBOOST_AUTO_TEST_CASE(setValuesVectorB_scalar_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorB(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Any position should hold the value 2.4\n\tPetscInt pos = 5;\n\tPetscScalar result;\n\tVecGetValues(solver.b, 1, &pos, &result);\n\tBOOST_CHECK_EQUAL(result, 2.4);\n\n\t// Second check in different position to ensure more than one was updated\n\tpos = 7;\n\tresult = 0.0;\n\tVecGetValues(solver.b, 1, &pos, &result);\n\tBOOST_CHECK_EQUAL(result, 2.4);\n}\n\n// Test 2: Check for error when vector does not exist\nBOOST_AUTO_TEST_CASE(setValuesVectorB_scalar_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorB(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// ============== setValuesVectorB(T * scalars, int nScalars) ===========\n// Test 1: Test setting values at specific locations\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Any position should hold the value 2.4\n\tPetscInt pos[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\tPetscScalar result[8];\n\tVecGetValues(solver.b, 8, pos, result);\n\n\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7, 0.0, 0.0, 0.0, 0.3};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n}\n\n// Test 2: Check Error for arrays of mismatched sizes\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 7};\n\tdouble values[2] = {0.5, 0.7};\n\tstatus = solver.setValuesVectorB(values, 2, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_ARRAY_MISMATCH_SIZE);\n}\n\n// Test 3: Check error for vector B not being setup\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// Test 4: Check error for unset row size\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test4)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 5: Check error for an index lower than minimum of global range\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test5)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Test and Check\n\tint indices[3] = {-1, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// Test 6: Check error for an index higher than maximum of global range\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test6)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Test and Check\n\tint indices[3] = {0, 3, 8};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// ============== setValuesMatrixA ===========\n// Test 1: Successfully set the matrix values from a Sparse Matrix\nBOOST_AUTO_TEST_CASE(setValuesMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Setup the Matrix\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check the values are correct - use PETSc function directly since we haven't tested\n\t// the get function yet\n\tPetscInt rowResult = 3;\n\tPetscInt colResult[2] = {3, 4};\n\tPetscScalar valResult[2];\n\n\tMatGetValues(solver.a, 1, &rowResult, 2, colResult, valResult);\n\tBOOST_CHECK_EQUAL(valResult[0], 0.06);\n\tBOOST_CHECK_EQUAL(valResult[1], 0.1);\n}\n\n// Test 2: Error: Check the row sizes are set\nBOOST_AUTO_TEST_CASE(setValuesMatrixA_test2)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nLocal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Setup the Matrix\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check: Don't use solver setup/set the solver matrix row sizes\n\tsolver.mLocal = 0;\n\tsolver.mGlobal = 0;\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Error: Check the column sizes are set\nBOOST_AUTO_TEST_CASE(setValuesMatrixA_test3)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nLocal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Setup the Matrix\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check: Don't use solver setup/set the solver matrix col sizes\n\tsolver.nLocal = 0;\n\tsolver.nGlobal = 0;\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_COL_SIZE_UNSET);\n}\n\n// Test 4: Error: Check the Matrix has been setup\nBOOST_AUTO_TEST_CASE(setValuesMatrixA_test4)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check: Matrix has not been setup\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_MATRIX);\n}\n\n// ============== getValuesVectorX ===========\n// Test 1: Check all values are the same when\n// set to all same value.\nBOOST_AUTO_TEST_CASE(getValuesVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes, else we will get error\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Set the values\n\tstatus = solver.setValuesVectorX(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tdouble cmp[8] = {2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 8, cmp, cmp + 8);\n\n\tfree(result);\n}\n\n// Test 2: Check all values are different when\n// set to different values\nBOOST_AUTO_TEST_CASE(getValuesVectorX_test2)\n{\n\n}\n\n// Test 3: Check error when row size unset\nBOOST_AUTO_TEST_CASE(getValuesVectorX_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n\n\t// Since error, nothing to free\n}\n\n// Test 4: Check error when vector not set\nBOOST_AUTO_TEST_CASE(getValuesVectorX_test4)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n\n\t// Since error, nothing to free\n}\n\n// ============== getValuesVectorXIndexes ===========\n// Test 1: Retrieve specific indexes\nBOOST_AUTO_TEST_CASE(getValuesVectorX_indexes_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Setup\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint getIndices[4] = {7, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tPetscScalar cmp[4] = {0.3, 0.0, 0.5, 0.0};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 4, result, result + 4);\n\n\tfree(result);\n}\n\n// Test 2: Error Check for unset global row size\nBOOST_AUTO_TEST_CASE(getValuesVectorX_indexes_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Test and Check\n\tint getIndices[4] = {7, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Error Check for unset vector\nBOOST_AUTO_TEST_CASE(getValuesVectorX_indexes_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tint getIndices[4] = {7, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// Test 4: Error Check for invalid lower bound index\nBOOST_AUTO_TEST_CASE(getValuesVectorX_indexes_test4)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Setup\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint getIndices[4] = {-1, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// Test 5: Error Check for invalid upper bound index\nBOOST_AUTO_TEST_CASE(getValuesVectorX_indexes_test5)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Setup\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorX(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint getIndices[4] = {0, 4, 0, 8};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// ============== getValuesVectorB ===========\n// Test 1: Check all values are the same when\n// set to all same value.\nBOOST_AUTO_TEST_CASE(getValuesVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes, else we will get error\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Set the values\n\tstatus = solver.setValuesVectorB(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tdouble cmp[8] = {2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 8, cmp, cmp + 8);\n\n\tfree(result);\n}\n\n// Test 2: Check all values are different when\n// set to all same value.\nBOOST_AUTO_TEST_CASE(getValuesVectorB_test2)\n{\n\n}\n\n// Test 3: Check error when row size unset\nBOOST_AUTO_TEST_CASE(getValuesVectorB_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n\n\t// Since error, nothing to free\n}\n\n// Test 4: Check error when vector not set\nBOOST_AUTO_TEST_CASE(getValuesVectorB_test4)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n\n\t// Since error, nothing to free\n}\n\n\n\n// ============== getValuesVectorBIndexes ===========\n// Test 1: Retrieve specific indexes\nBOOST_AUTO_TEST_CASE(getValuesVectorB_indexes_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Setup\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint getIndices[4] = {7, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tPetscScalar cmp[4] = {0.3, 0.0, 0.5, 0.0};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 4, result, result + 4);\n\n\tfree(result);\n}\n\n// Test 2: Error Check for unset global row size\nBOOST_AUTO_TEST_CASE(getValuesVectorB_indexes_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Test and Check\n\tint getIndices[4] = {7, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Error Check for unset vector\nBOOST_AUTO_TEST_CASE(getValuesVectorB_indexes_test3)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tint getIndices[4] = {7, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// Test 4: Error Check for invalid lower bound index\nBOOST_AUTO_TEST_CASE(getValuesVectorB_indexes_test4)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Setup\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint getIndices[4] = {-1, 4, 0, 6};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n// Test 5: Error Check for invalid upper bound index\nBOOST_AUTO_TEST_CASE(getValuesVectorB_indexes_test5)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Setup\n\tint indices[3] = {0, 3, 7};\n\tdouble values[3] = {0.5, 0.7, 0.3};\n\tstatus = solver.setValuesVectorB(values, 3, indices, 3, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint getIndices[4] = {0, 4, 0, 8};\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult, getIndices, 4, 0);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_INVALID_INDEX);\n}\n\n\n\n// ============== getValuesMatrixA ===========\n// Test 1: Check we can retrieve values correctly from the matrix\nBOOST_AUTO_TEST_CASE(getValuesMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] =    {0,   0,   1,   1,    2,    2,    3,    3,   4,    4,    5,    6,    7};\n\tint cols[13] =    {0,   1,   1,   2,    2,    3,    3,    4,   4,    5,    5,    6,    7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> resultMatrix(8, 8, 0);\n\n\tint resultRows[9] = {0, 1, 2, 2, 4, 4, 5, 6, 6};\n\tint resultCols[9] = {1, 1, 2, 3, 4, 5, 5, 6, 7};\n\tdouble resultVals[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tresultMatrix.setElement(resultRows[i], resultCols[i], resultVals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Setup the Matrix\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Set the values inside the matrix\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\t// Retrieve values via the function and check they are what we expect\n\tstatus = solver.getValuesMatrixA(resultMatrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check contents of SparseMatrixCOO nnz to verify it has been updated correctly\n\tdouble cmp[9] = {0.2, 0.1, 0.07, 0.09, 0.15, 0.23, 0.11, 0.13, 0.0};\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 9, &resultMatrix.val[0], &resultMatrix.val[0] + 9);\n}\n\n// Not Done\n// Test 2: Error Check: Check PETSc matrix is setup\nBOOST_AUTO_TEST_CASE(getValuesMatrixA_test2)\n{\n\tcupcfd::error::eCodes status;\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> resultMatrix(8, 8, 0);\n\n\tint resultRows[9] = {0, 1, 2, 2, 4, 4, 5, 6, 6};\n\tint resultCols[9] = {1, 1, 2, 3, 4, 5, 5, 6, 7};\n\tdouble resultVals[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tresultMatrix.setElement(resultRows[i], resultCols[i], resultVals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Skip setting up the matrix\n\n\t// Test and Check\n\t// Should be an error since the matrix is not setup\n\tstatus = solver.getValuesMatrixA(resultMatrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_MATRIX);\n}\n\n// Test 3: Error Check: Check that the maximum indices of the matrix object are within the bounds\n// of the PETSc matrix object\nBOOST_AUTO_TEST_CASE(getValuesMatrixA_test3)\n{\n\n}\n\n// ============== clearVectorX ===========\n// Test 1: Check value is set to 0\nBOOST_AUTO_TEST_CASE(clearVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes, else we will get error\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorX();\n\n\t// Set the values\n\t// Will need to use setValueVector, but this should have been\n\t// tested by this point\n\tstatus = solver.setValuesVectorX(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.clearVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Get value to check\n\t// Will need to use getValuesVectorX, but should be tested by this point\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorX(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tdouble cmp[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 8, cmp, cmp + 8);\n\n\tfree(result);\n}\n\n// Test 2: Check for error when vector X is not setup\nBOOST_AUTO_TEST_CASE(clearVectorX_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes, else we will get error\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// === Test and Check ===\n\tstatus = solver.clearVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// ============== clearVectorB ===========\nBOOST_AUTO_TEST_CASE(clearVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes, else we will get error\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Create Vector\n\tsolver.setupVectorB();\n\n\t// Set the values\n\t// Will need to use setValueVector, but this should have been\n\t// tested by this point\n\tstatus = solver.setValuesVectorB(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.clearVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Get value to check\n\t// Will need to use getValuesVectorB, but should be tested by this point\n\tdouble * result;\n\tint nResult;\n\tstatus = solver.getValuesVectorB(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tdouble cmp[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 8, cmp, cmp + 8);\n\n\tfree(result);\n}\n\nBOOST_AUTO_TEST_CASE(clearVectorB_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes, else we will get error\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// === Test and Check ===\n\tstatus = solver.clearVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// ============== clearMatrixA ===========\nBOOST_AUTO_TEST_CASE(clearMatrixA_test1)\n{\n\n}\n\n// ============== resetSolverSelection ===========\nBOOST_AUTO_TEST_CASE(resetSolverSelection_test1)\n{\n\n}\n\n// ============== setSolverSelection ===========\nBOOST_AUTO_TEST_CASE(setSolverSelection_test1)\n{\n\n}\n\n// ============== resetTolerances ===========\nBOOST_AUTO_TEST_CASE(resetTolerances_test1)\n{\n\n}\n\n// ============== resetPETScSolver ===========\n// Test 1: Test that we can reset when the KSP solver is not setup\nBOOST_AUTO_TEST_CASE(resetPETScSolver_test1)\n{\n\n}\n\n// Test 2: Test that we can reset when the KSP Solver is setup\nBOOST_AUTO_TEST_CASE(resetPETScSolver_test2)\n{\n\n}\n\n// ============== setupPETScSolver ===========\n// Test 1: Test that we can setup the CG/AMG solver\nBOOST_AUTO_TEST_CASE(setupPETScSolver_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tfor(int i = 0; i < 13; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 8;\n\tsolver.nLocal = 8;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tsolver.petscSolverSelection = PETSC_SOLVER_CGAMG;\n\n\t// Test and Check\n\tstatus = solver.setupPETScSolver();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n\n// ============== solveMatrixA ===========\nBOOST_AUTO_TEST_CASE(solveMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScSerial<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\t//int rows[21] = {0, 1, 2, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};\n\t//int cols[21] = {1, 2, 3, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7};\n\t//double vals[21] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09, 0.4, 0.2, 0.6, 0.8, 0.7, 0.4, 0.3, 0.2};\n\tint rows[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\tint cols[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\tdouble vals[8] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8};\n\n\tfor(int i = 0; i < 8; i++)\n\t{\n\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t}\n\n\t// Setup the data structures of the solver\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Set some suitable values for a very small test solve\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Set a suitable value for the B Vector\n\t//double tmp[8] = {0.23, 0.598, 0.46, 0.345, 0.644, 0.414, 0.506, 0.207};\n\t//int tmp2[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\n\t//status = solver.setValuesVectorB(tmp, 8, tmp2, 8, 0);\n\tstatus = solver.setValuesVectorB(0.1);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Clear the X Vector\n\tstatus = solver.clearVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Set the solver type\n\tstatus = solver.setSolverSelection(PETSC_SOLVER_CGAMG);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tsolver.setTolerances(0.0, 0.0);\n\n\t// Test and Check\n\t// Run the solve\n\tstatus = solver.solve();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Get the contents of Vector X\n\tdouble * vecX;\n\tint nVecX;\n\n\tstatus = solver.getValuesVectorX(&vecX, &nVecX);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tdouble cmp[8] = {1, 0.5, 0.33333333333333337, 0.25, 0.2, 0.16666666666666669, 0.14285714285714288, 0.125};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, vecX, vecX + 8);\n}\n\nBOOST_AUTO_TEST_CASE(cleanup)\n{\n\tPetscFinalize();\n}\n", "meta": {"hexsha": "6fa492976139b5b0804f376d3052d0fb463b94a2", "size": 45749, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/linearsolvers/classes/LinearSolverPETScSerialTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/linearsolvers/classes/LinearSolverPETScSerialTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/linearsolvers/classes/LinearSolverPETScSerialTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 25.6153415454, "max_line_length": 136, "alphanum_fraction": 0.6878401714, "num_tokens": 15134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.42250463481418826, "lm_q2_score": 0.14223188773801163, "lm_q1q2_score": 0.06009363178768122}}
{"text": "/**\n * @file numpdesetup.cc\n * @brief NPDE homework NumPDESetup code\n * @author Oliver Rietmann, Erick Schulz\n * @date 01.01.2020\n * @copyright Developed at ETH Zurich\n */\n\n#include \"numpdesetup.h\"\n\n#include <Eigen/Core>\n#include <iostream>\n\nnamespace NumPDESetup {\n\n/* SAM_LISTING_BEGIN_1 */\nEigen::VectorXd dummyFunction(double x, int n) {\n  // Appears only in mastersolution\n  std::cout << \"NumPDESetup: master solution code\" << std::endl;\n  return Eigen::VectorXd::Constant(n, x);\n}\n/* SAM_LISTING_END_1 */\n\n}  // namespace NumPDESetup\n", "meta": {"hexsha": "0549703701642582cb79f8305321f3bfd89b9581", "size": 540, "ext": "cc", "lang": "C++", "max_stars_repo_path": "homeworks/NumPDESetup/mastersolution/numpdesetup.cc", "max_stars_repo_name": "kryo4096/NPDECODES", "max_stars_repo_head_hexsha": "3498c0e4abec6ba21447849ba2ddc9286c068ea1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15.0, "max_stars_repo_stars_event_min_datetime": "2019-04-29T11:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T05:10:58.000Z", "max_issues_repo_path": "homeworks/NumPDESetup/mastersolution/numpdesetup.cc", "max_issues_repo_name": "kryo4096/NPDECODES", "max_issues_repo_head_hexsha": "3498c0e4abec6ba21447849ba2ddc9286c068ea1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12.0, "max_issues_repo_issues_event_min_datetime": "2020-02-29T15:05:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T13:51:07.000Z", "max_forks_repo_path": "homeworks/NumPDESetup/mastersolution/numpdesetup.cc", "max_forks_repo_name": "kryo4096/NPDECODES", "max_forks_repo_head_hexsha": "3498c0e4abec6ba21447849ba2ddc9286c068ea1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 26.0, "max_forks_repo_forks_event_min_datetime": "2020-01-09T15:59:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T16:27:33.000Z", "avg_line_length": 21.6, "max_line_length": 64, "alphanum_fraction": 0.7092592593, "num_tokens": 156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.38491213037224875, "lm_q2_score": 0.1561048974454574, "lm_q1q2_score": 0.060086668637272425}}
{"text": "// Copyright Andr\u00e1s Vukics 2006\u20132020. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)\n#include \"BlitzArray.h\"\n#include \"SliceIterator.tcc\"\n\n// #include \"Random.h\"\n\n#define BOOST_TEST_MODULE BlitzArraySliceIterator test\n#include <boost/test/unit_test.hpp>\n\n#include <boost/fusion/sequence/io.hpp>\n#include <boost/fusion/sequence/comparison.hpp>\n#include <boost/fusion/functional/invocation/invoke.hpp>\n#include <boost/fusion/sequence/intrinsic/at_c.hpp>\nnamespace mpl=boost::mpl;\n\n#include <sstream>\n\nusing namespace cppqedutils::sliceiterator;\nusing namespace std;\n\nusing V=tmptools::Vector<3,6,1,9,7>;\n\nconst int RANK=11;\n\nusing TM=details::TransposerMeta_t<RANK,V>;\n\nusing FullIdx=details::IndexerBase<RANK,V>::Idx; // This contains Range types at the appropriate locations\n\n\nconst IdxTiny<RANK> idx(21,2,4,10,11,3,5,9,23,22,7);\n\n\nconst VecIdxTiny<RANK,V> filteredIdx(filterOut<RANK,V>(idx));\n\nusing DArray11=DArray<11>;\n\n\nnamespace {\n\nusing mpl::at_c, mpl::equal;\n\nstatic_assert(at_c<TM,0>::type::value==0);\nstatic_assert(at_c<TM,1>::type::value==3);\nstatic_assert(at_c<TM,2>::type::value==2);\nstatic_assert(at_c<TM,3>::type::value==6);\nstatic_assert(at_c<TM,4>::type::value==4);\nstatic_assert(at_c<TM,5>::type::value==5);\nstatic_assert(at_c<TM,6>::type::value==1);\nstatic_assert(at_c<TM,7>::type::value==9);\nstatic_assert(at_c<TM,8>::type::value==8);\nstatic_assert(at_c<TM,9>::type::value==7);\nstatic_assert(at_c<TM,10>::type::value==10);\n\nstatic_assert(equal<TM,     mpl::vector_c<int,0,3,2,6,4,5,1,9,8,7,10> >::value);\nstatic_assert(equal<TM,tmptools::Vector  <    0,3,2,6,4,5,1,9,8,7,10> >::value);\n\n\nusing blitz::Range;\n\nstatic_assert(equal<FullIdx,mpl::vector<int,Range,int,Range,int,int,Range,Range,int,Range,int> >::value);\n\n\n}\n\n\nBOOST_AUTO_TEST_CASE( FilterOutTest )\n{\n  BOOST_CHECK(all(filteredIdx==VecIdxTiny<RANK,V>(21,4,11,3,23,7)));\n}\n\n\nBOOST_AUTO_TEST_CASE( IdxValueTest )\n{\n  using namespace std;\n\n  const blitz::Range a(blitz::Range::all());\n\n  const FullIdx v(21,a,4,a,11,3,a,a,23,a,7);\n\n  // The following strange solution is needed because there is no comparison operation for Ranges\n  stringstream s1(stringstream::out), s2(stringstream::out);\n\n  s1<<v; s2<<details::IndexerBase<RANK,V>::fillIdxValues(filteredIdx);\n\n  BOOST_CHECK(s1.str()==s2.str());\n\n}\n\n\nBOOST_AUTO_TEST_CASE( ArraySlicingTest )\n{\n  const auto a{blitz::Range::all()};\n\n  DArray11 array11{22,2,5,1,12,4,4,3,24,2,8};\n\n  FullIdx v{21,a,4,a,11,3,a,a,23,a,7};\n\n  using boost::fusion::at_c;\n\n  BOOST_CHECK(\n    all(DArray<5>{array11(at_c<0>(v),at_c<1>(v),at_c<2>(v),at_c<3>(v),at_c<4>(v),at_c<5>(v),at_c<6>(v),at_c<7>(v),at_c<8>(v),at_c<9>(v),at_c<10>(v))}.extent()\n        ==\n        ExtTiny<5>(2,1,4,3,2)));\n\n}\n\n\nBOOST_AUTO_TEST_CASE( ExampleFromManual )\n{\n  void actWithA(CArray<5>&);\n\n  CArray<RANK> psi;\n\n  for (auto p : fullRange<V>(psi) ) actWithA(p);\n}\n\nvoid actWithA(CArray<5>&) {}\n\n\n\n// The following test comes from the old version of this file, and is intended to demonstrate the performance as a function of the arity of slices\n/*\nnamespace basi_performance {\n\nconst int nRepetition=1;\n\nCArray<11> array1(5,4,5,4,5,4,5,4,5,4,5), array2(array1.shape()), arrayRes(array1.shape()), arrayOrig(array1.shape());\n\nstruct Helper\n{\n  template<typename V> void operator()(V)\n  {\n    PROGRESS_TIMER_IN_POINT(cout);\n    for (int i=nRepetition; i; --i) cppqedutils::for_each(fullRange<V>(array1),basi::begin<V>(array2),bll::_1*=bll::_2); \n    cout<<\"Arity \"<<11-mpl::size<V>::value<<\": \";\n    PROGRESS_TIMER_OUT_POINT(\"\");\n\n    BOOST_CHECK(all(array1==arrayRes)); array1=arrayOrig;\n\n    PROGRESS_TIMER_IN_POINT(cout);\n    SlicesData<11,V> slicesData(array1);\n    for (int i=nRepetition; i; --i) cppqedutils::for_each(basi_fast::fullRange(array1,slicesData),basi_fast::begin(array2,slicesData),bll::_1*=bll::_2); \n    cout<<\"Fast. Arity \"<<11-mpl::size<V>::value;\n    PROGRESS_TIMER_OUT_POINT(\"\");\n\n    BOOST_CHECK(all(array1==arrayRes)); array1=arrayOrig;\n  }\n\n};\n\n} // basi_performance\n\n\nBOOST_AUTO_TEST_CASE( BASI_Performance )\n{\n\n  using namespace randomized; using namespace basi_performance;\n\n  fillWithRandom(array2,fillWithRandom(array1));\n\n  arrayRes=arrayOrig=array1;\n\n  PROGRESS_TIMER_IN_POINT(cout);\n  for (int i=nRepetition; i; --i) arrayRes*=array2;\n  PROGRESS_TIMER_OUT_POINT(\"\\nBlitz internal multiplication\");\n\n  mpl::for_each<mpl::vector<\n    tmptools::Vector<9,3,6,0,10,4,7,8,1,5,2>,\n    tmptools::Vector<9,3,6,0,10,4,7,8,1,5>,\n    tmptools::Vector<9,3,6,0,10,4,7,8,1>,\n    tmptools::Vector<9,3,6,0,10,4,7,8>,\n    tmptools::Vector<9,3,6,0,10,4,7>,\n    tmptools::Vector<9,3,6,0,10,4>,\n    tmptools::Vector<9,3,6,0,10>,\n    tmptools::Vector<9,3,6,0>,\n    tmptools::Vector<9,3,6>,\n    tmptools::Vector<9,3>,\n    tmptools::Vector<9>\n      > >(Helper());\n\n}\n\n\n\n\n\nnamespace basi_monitor {\n\nCArray<6> array1(3,2,3,2,3,2), array2(array1.shape());\n\n\ntemplate<int RANK>\nvoid helper(const CArray<RANK>& a1, const CArray<RANK>& a2, const dcomp* dc1, const dcomp* dc2)\n{\n  cout<<a1.zeroOffset()<<' '<<a1.shape()<<' '<<a1.stride()<<' '<<a1.ordering()<<' '<<a1.data()-dc1<<endl<<a2.zeroOffset()<<' '<<a2.shape()<<' '<<a2.stride()<<' '<<a2.ordering()<<' '<<a2.data()-dc2<<endl;\n  BOOST_CHECK(all(a1==a2));\n}\n\n\nstruct Helper\n{\n  \n  template<typename V> void operator()(V)\n  {\n    SlicesData<6,V> slicesData(array1);\n\n    cout<<endl<<\n      \"****************\\n\"<<\n      \"*** Slice Arity: \"<<mpl::size<V>::value<<endl<<\n      \"****************\\n\";\n    cppqedutils::for_each(fullRange<V>(array1),basi_fast::begin(array2,slicesData),boost::bind(helper<mpl::size<V>::value>,_1,_2,array1.data(),array2.data())); \n  }\n\n};\n\n} // basi_monitor\n\n\n\nBOOST_AUTO_TEST_CASE( BASI_Monitor )\n{\n\n  using namespace basi_monitor;\n\n  randomized::fillWithRandom(array1);\n\n  array2=array1;\n\n  mpl::for_each<mpl::vector<\n  tmptools::Vector<3,0,4,1,5>,\n  tmptools::Vector<3,0,4,1>,\n  tmptools::Vector<3,0,4>,\n  tmptools::Vector<3,0>,\n  tmptools::Vector<3>\n    > > (Helper());\n\n  \n  // SlicesData<6,tmptools::Vector<3,0,4,1,5> > data(array1);\n  // basi_fast::Iterator<6,tmptools::Vector<3,0,4,1,5>,true> iter(data,array2,mpl::false_());\n\n}\n*/\n\n\n// BlitzArraySliceIteratorFast assumes: all storage ascending, all bases zero\n", "meta": {"hexsha": "296a91bcfe03b4d4082da54657bb3099ed043ecf", "size": 6231, "ext": "cc", "lang": "C++", "max_stars_repo_path": "CPPQEDutils/Testing/SliceIterator.cc", "max_stars_repo_name": "vukics/cppqed", "max_stars_repo_head_hexsha": "a933375f53b982b14cebf7cb63de300996ddd00b", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 5.0, "max_stars_repo_stars_event_min_datetime": "2021-02-21T14:00:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-29T15:12:11.000Z", "max_issues_repo_path": "CPPQEDutils/Testing/SliceIterator.cc", "max_issues_repo_name": "vukics/cppqed", "max_issues_repo_head_hexsha": "a933375f53b982b14cebf7cb63de300996ddd00b", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 10.0, "max_issues_repo_issues_event_min_datetime": "2020-04-14T11:18:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-04T20:11:23.000Z", "max_forks_repo_path": "CPPQEDutils/Testing/SliceIterator.cc", "max_forks_repo_name": "vukics/cppqed", "max_forks_repo_head_hexsha": "a933375f53b982b14cebf7cb63de300996ddd00b", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 2.0, "max_forks_repo_forks_event_min_datetime": "2021-01-25T10:16:35.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-28T18:29:01.000Z", "avg_line_length": 25.3292682927, "max_line_length": 203, "alphanum_fraction": 0.677258867, "num_tokens": 2098, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44552953503957277, "lm_q2_score": 0.13477592089824644, "lm_q1q2_score": 0.060046653372325974}}
{"text": "\n#include <boost/test/unit_test.hpp>\n\n#include <stdexcept>\n\n#include \"xmlparser.h\"\n#include \"logs.h\"\n#include \"route.h\"\n\nusing namespace GPS;\n\n/*////////////////////////////////////////Design//////////////////////////////////////////////////////////////\n\nIt's important to know that this test suit assumes correct implimentation of the route class.\nAs such it dose not attempt to check for null vectors and invalid arguments.\n\n\n1: Testing one value\n\n2: Test suit for data patterns\n    1:Ascending\n    2:Descending\n    3:Staggered\n\n3: Test suit for different values\n    1:Positive\n    2:Negative\n    3:Positive and Negative\n\n4: Large data set\n\n5: Test suit for Ivalid input\n    1: >=90\n    2: <=-90\n\nTest 1 is needed as the start as a failure would produce a failure for tests 2,3 and 4.\n\nTest 2 comes before 3 but only uses positive values. I origionally had Test 3 before 2,\nhowever they would need a pattern or to be staggered which gives the data patterns test no purpose.\nAs a result test 2 now only uses positive values - positive values test in different values is\nstill needed as tests can be run in any order.\n\nTest 3 now uses only staggered values.\n\nTest 5 is placed at the end to encourage correct code before handling exceptions.\n*/\n\n/*\n    using tolerance as 0.1 as test data is widely spead +- ~10 however if there is manipulation of data\n    maybe in a for loop that uses ++ then using 0.1 will distinguish between the values.\n*/\nBOOST_AUTO_TEST_SUITE(n0682255)\n\n\n/*\n The check single value test case holds the smallest route possible of one position.\n If this test is failed it means the implimentation of the function is severly wrong.\n This is to catch functions that either manipulate the data, or return the wrong value.\n For the test data: the longditude is 1 and elevation 2 to distinguish between them if they are returned.\n*/\nBOOST_AUTO_TEST_CASE(checkSingleValue)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"singleValueN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , 0 , 1);\n\n}\n\n/*\n    This test suit checks for hard coded return values e.g returning Position[0],\n    these would pass tests where the smallest latitudes were at the begining.\n    By testing descending, ascending and staggered values we can eliminate hard coded return values.\n */\nBOOST_AUTO_TEST_SUITE(DataSetPatterns)\n\nBOOST_AUTO_TEST_CASE(checkAscending)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"posAscendN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , 1 , 1);\n\n}\n\nBOOST_AUTO_TEST_CASE(checkDescending)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"posDescendN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , 60 , 1);\n\n}\n\nBOOST_AUTO_TEST_CASE(checkPosativeStaggered)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"posStaggeredN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , 20 , 1);\n\n}\nBOOST_AUTO_TEST_SUITE_END()\n\n\n/*\n    This test suit tests if the function can handle positive , negative and a mixture of the both.\n */\nBOOST_AUTO_TEST_SUITE(ValueHandling)\nBOOST_AUTO_TEST_CASE(checkPositive)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"posStaggeredN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , 20 , 1);\n\n}\n\nBOOST_AUTO_TEST_CASE(checkNegative)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"negStaggeredN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , -40 , 1);\n\n}\n\nBOOST_AUTO_TEST_CASE(checkPosativeandNegative)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"posNegStaggeredN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , -19.9869 , 1);\n\n}\nBOOST_AUTO_TEST_SUITE_END()\n\n\n/*\n    This test case uses large data sets. It also uses values with very similar numbers\nso the tolerance has to be of greater precision. Otherwise the test may be passed.\n */\nBOOST_AUTO_TEST_CASE(checkLargeData)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"NorthYorkMoors.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_CLOSE(route.minLatitude() , 54.40526783466339  , 0.001);\n\n}\nBOOST_AUTO_TEST_SUITE(InvalidData)\n\n\n/*\n    These test cases check if there are any invalid values as latitude cannot be greater than 90 deg or less than -90 deg\n*/\nBOOST_AUTO_TEST_CASE(checkGreaterThan90)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"posOutOfBoundsN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_THROW(route.minLatitude() , std::invalid_argument);\n\n}\n\nBOOST_AUTO_TEST_CASE(checkLessThanMinus90)\n{\n    const bool isFileName = true;\n    const std::string filePath = LogFiles::GPXRoutesDir + \"negOutOfBoundsN0682255.gpx\";\n\n    Route route = Route(filePath, isFileName);\n\n    BOOST_CHECK_THROW(route.minLatitude() , std::invalid_argument);\n\n}\nBOOST_AUTO_TEST_SUITE_END()\nBOOST_AUTO_TEST_SUITE_END()\n\n\n\n", "meta": {"hexsha": "c9158e787653bee8f321fd03eff6dd620cf8e5f5", "size": 5486, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/gpx-tests/N0682255_MinLAtitude.cpp", "max_stars_repo_name": "EdwinLangley/GPX-Route-and-Track", "max_stars_repo_head_hexsha": "e4de303c62c7e9dc92724e8f257f7960ff77c992", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/gpx-tests/N0682255_MinLAtitude.cpp", "max_issues_repo_name": "EdwinLangley/GPX-Route-and-Track", "max_issues_repo_head_hexsha": "e4de303c62c7e9dc92724e8f257f7960ff77c992", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/gpx-tests/N0682255_MinLAtitude.cpp", "max_forks_repo_name": "EdwinLangley/GPX-Route-and-Track", "max_forks_repo_head_hexsha": "e4de303c62c7e9dc92724e8f257f7960ff77c992", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.567839196, "max_line_length": 121, "alphanum_fraction": 0.7307692308, "num_tokens": 1319, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4765796659321433, "lm_q2_score": 0.1259227615549033, "lm_q1q2_score": 0.060012227635088754}}
{"text": "//  Copyright John Maddock 2006.\r\n//  Use, modification and distribution are subject to the\r\n//  Boost Software License, Version 1.0. (See accompanying file\r\n//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n// distributions.hpp provides definitions of the concept of a distribution\r\n// and non-member accessor functions that must be implemented by all distributions.\r\n// This is used to verify that\r\n// all the features of a distributions have been fully implemented.\r\n\r\n#ifndef BOOST_MATH_DISTRIBUTION_CONCEPT_HPP\r\n#define BOOST_MATH_DISTRIBUTION_CONCEPT_HPP\r\n\r\n#include <boost/math/distributions/complement.hpp>\r\n#ifdef BOOST_MSVC\r\n#pragma warning(push)\r\n#pragma warning(disable: 4100)\r\n#pragma warning(disable: 4510)\r\n#pragma warning(disable: 4610)\r\n#endif\r\n#include <boost/concept_check.hpp>\r\n#ifdef BOOST_MSVC\r\n#pragma warning(pop)\r\n#endif\r\n#include <utility>\r\n\r\nnamespace boost{\r\nnamespace math{\r\n\r\nnamespace concepts\r\n{\r\n// Begin by defining a concept archetype\r\n// for a distribution class:\r\n//\r\ntemplate <class RealType>\r\nclass distribution_archetype\r\n{\r\npublic:\r\n   typedef RealType value_type;\r\n\r\n   distribution_archetype(const distribution_archetype&); // Copy constructible.\r\n   distribution_archetype& operator=(const distribution_archetype&); // Assignable.\r\n\r\n   // There is no default constructor,\r\n   // but we need a way to instantiate the archetype:\r\n   static distribution_archetype& get_object()\r\n   {\r\n      // will never get caled:\r\n      return *reinterpret_cast<distribution_archetype*>(0);\r\n   }\r\n}; // template <class RealType>class distribution_archetype\r\n\r\n// Non-member accessor functions:\r\n// (This list defines the functions that must be implemented by all distributions).\r\n\r\ntemplate <class RealType>\r\nRealType pdf(const distribution_archetype<RealType>& dist, const RealType& x);\r\n\r\ntemplate <class RealType>\r\nRealType cdf(const distribution_archetype<RealType>& dist, const RealType& x);\r\n\r\ntemplate <class RealType>\r\nRealType quantile(const distribution_archetype<RealType>& dist, const RealType& p);\r\n\r\ntemplate <class RealType>\r\nRealType cdf(const complemented2_type<distribution_archetype<RealType>, RealType>& c);\r\n\r\ntemplate <class RealType>\r\nRealType quantile(const complemented2_type<distribution_archetype<RealType>, RealType>& c);\r\n\r\ntemplate <class RealType>\r\nRealType mean(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType standard_deviation(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType variance(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType hazard(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType chf(const distribution_archetype<RealType>& dist);\r\n// http://en.wikipedia.org/wiki/Characteristic_function_%28probability_theory%29\r\n\r\ntemplate <class RealType>\r\nRealType coefficient_of_variation(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType mode(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType skewness(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType kurtosis_excess(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType kurtosis(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nRealType median(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nstd::pair<RealType, RealType> range(const distribution_archetype<RealType>& dist);\r\n\r\ntemplate <class RealType>\r\nstd::pair<RealType, RealType> support(const distribution_archetype<RealType>& dist);\r\n\r\n//\r\n// Next comes the concept checks for verifying that a class\r\n// fullfils the requirements of a Distribution:\r\n//\r\ntemplate <class Distribution>\r\nstruct DistributionConcept\r\n{\r\n   void constraints()\r\n   {\r\n      function_requires<CopyConstructibleConcept<Distribution> >();\r\n      function_requires<AssignableConcept<Distribution> >();\r\n\r\n      typedef typename Distribution::value_type value_type;\r\n\r\n      const Distribution& dist = DistributionConcept<Distribution>::get_object();\r\n\r\n      value_type x = 0;\r\n       // The result values are ignored in all these checks.\r\n       value_type v = cdf(dist, x);\r\n      v = cdf(complement(dist, x));\r\n      v = pdf(dist, x);\r\n      v = quantile(dist, x);\r\n      v = quantile(complement(dist, x));\r\n      v = mean(dist);\r\n      v = mode(dist);\r\n      v = standard_deviation(dist);\r\n      v = variance(dist);\r\n      v = hazard(dist, x);\r\n      v = chf(dist, x);\r\n      v = coefficient_of_variation(dist);\r\n      v = skewness(dist);\r\n      v = kurtosis(dist);\r\n      v = kurtosis_excess(dist);\r\n      v = median(dist);\r\n      std::pair<value_type, value_type> pv;\r\n      pv = range(dist);\r\n      pv = support(dist);\r\n\r\n      float f = 1;\r\n      v = cdf(dist, f);\r\n      v = cdf(complement(dist, f));\r\n      v = pdf(dist, f);\r\n      v = quantile(dist, f);\r\n      v = quantile(complement(dist, f));\r\n      v = hazard(dist, f);\r\n      v = chf(dist, f);\r\n      double d = 1;\r\n      v = cdf(dist, d);\r\n      v = cdf(complement(dist, d));\r\n      v = pdf(dist, d);\r\n      v = quantile(dist, d);\r\n      v = quantile(complement(dist, d));\r\n      v = hazard(dist, d);\r\n      v = chf(dist, d);\r\n#ifndef TEST_MPFR\r\n      long double ld = 1;\r\n      v = cdf(dist, ld);\r\n      v = cdf(complement(dist, ld));\r\n      v = pdf(dist, ld);\r\n      v = quantile(dist, ld);\r\n      v = quantile(complement(dist, ld));\r\n      v = hazard(dist, ld);\r\n      v = chf(dist, ld);\r\n#endif\r\n      int i = 1;\r\n      v = cdf(dist, i);\r\n      v = cdf(complement(dist, i));\r\n      v = pdf(dist, i);\r\n      v = quantile(dist, i);\r\n      v = quantile(complement(dist, i));\r\n      v = hazard(dist, i);\r\n      v = chf(dist, i);\r\n      unsigned long li = 1;\r\n      v = cdf(dist, li);\r\n      v = cdf(complement(dist, li));\r\n      v = pdf(dist, li);\r\n      v = quantile(dist, li);\r\n      v = quantile(complement(dist, li));\r\n      v = hazard(dist, li);\r\n      v = chf(dist, li);\r\n   }\r\nprivate:\r\n   static Distribution& get_object()\r\n   {\r\n      // will never get called:\r\n      static char buf[sizeof(Distribution)];\r\n      return * reinterpret_cast<Distribution*>(buf);\r\n   }\r\n}; // struct DistributionConcept\r\n\r\n} // namespace concepts\r\n} // namespace math\r\n} // namespace boost\r\n\r\n#endif // BOOST_MATH_DISTRIBUTION_CONCEPT_HPP\r\n\r\n", "meta": {"hexsha": "610c9d58de21e7ee815acbc4d776eda120eb8bde", "size": 6411, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "Compiler/boost/boost/math/concepts/distributions.hpp", "max_stars_repo_name": "davidov541/MiniC", "max_stars_repo_head_hexsha": "d3b16a1568b97a4d801880b110a8be04fe848adb", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2015-04-16T01:05:53.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-26T07:38:43.000Z", "max_issues_repo_path": "LibsExternes/Includes/boost/math/concepts/distributions.hpp", "max_issues_repo_name": "benkaraban/anima-games-engine", "max_issues_repo_head_hexsha": "8aa7a5368933f1b82c90f24814f1447119346c3b", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2017-04-05T01:56:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-05T01:56:28.000Z", "max_forks_repo_path": "LibsExternes/Includes/boost/math/concepts/distributions.hpp", "max_forks_repo_name": "benkaraban/anima-games-engine", "max_forks_repo_head_hexsha": "8aa7a5368933f1b82c90f24814f1447119346c3b", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.9710144928, "max_line_length": 92, "alphanum_fraction": 0.6788332553, "num_tokens": 1477, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091946, "lm_q2_score": 0.12085323090725615, "lm_q1q2_score": 0.05995454212471399}}
{"text": "//------------------------------------------------------------------------------\n/// \\file Max_tests.cpp\n/// \\ref Vandevoorde, Josuttis, Gregor. C++ Templates: The Complete Guide. 2nd\n/// Ed. Addison-Wesley Professional. 2017.\n//------------------------------------------------------------------------------\n#include \"Cpp/Templates/FunctionT/MoreMax.h\"\n\n#include <boost/test/unit_test.hpp>\n#include <complex>\n#include <string>\n#include <type_traits> // std::decay\n\nusing namespace Cpp::Templates::FunctionTemplates;\n\nBOOST_AUTO_TEST_SUITE(Cpp)\nBOOST_AUTO_TEST_SUITE(Templates)\nBOOST_AUTO_TEST_SUITE(FunctionTemplates)\nBOOST_AUTO_TEST_SUITE(MoreMax_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ShowHowToUseFunctionTemplateDefinition)\n{\n  // Templates aren't compiled into single entities that can handle any type.\n  // Instead, different entities are generated from the template for every type\n  // for which template is used.\n  // Process of replacing template parameters by concrete types is called\n  // instantiations. Results in an instance of a template.\n  // Note mere use of a function template can trigger such an instantiation\n  // process.\n  constexpr int i {42};\n  BOOST_TEST(max1::max(7, i) == i);\n\n  constexpr double f1 {3.4};\n  constexpr double f2 {-6.7};\n  BOOST_TEST(max1::max(f1, f2) == f1);\n\n  const std::string s1 {\"mathematics\"};\n  const std::string s2 {\"math\"};\n  BOOST_TEST(max1::max(s1, s2) == s1);\n}\n\n// cf. Ch. 3.1 Function Templates, Gottschling. Discovering Modern C++.\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(FunctionTemplateDoesFunctionOverloading)\n{\n  BOOST_TEST(max1::max(3, 5) == 5);\n  BOOST_TEST(max1::max(3l, 5l) == 5l);\n  BOOST_TEST(max1::max(3.0, 5.0) == 5.0);\n\n  unsigned u1 {2}, u2 {8};\n  BOOST_TEST(max1::max(u1, u2) == u2);\n  BOOST_TEST(max1::max(u1 * u2, u1 + u2) == u1 * u2);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TemplateArgumentDeducedAsPartOfConstReference)\n{\n  {\n    int c {42};\n    int i {7};\n\n    BOOST_TEST(max_with_const_refs::max(i, c) == c);\n  }\n\n  {\n    BOOST_TEST(max_with_const_refs::max(2, 3) == 3);\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(CompilerDeducesReturnTypeWithAuto)\n{\n  {\n    const int c {42};\n    const double i {7.0};\n\n    BOOST_TEST(max_auto::max(i, c) == c);\n  }\n\n  {\n    BOOST_TEST(max_auto::max(2.0, 3) == 3);\n  }\n}\n\n// Trailing return type is ->\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(Cpp11UsesTrailingReturnType)\n{\n  {\n    const int c {42};\n    const double i {7.0};\n\n    BOOST_TEST(max_decltype::max(i, c) == c);\n  }\n\n  {\n    BOOST_TEST(max_decltype::max(2.0, 3) == 3);\n  }\n}\n\n// https://en.cppreference.com/w/cpp/types/decay\n// Applies lvalue-to-rvalue, array-to-pointer, function-to-pointer implicit\n// conversions to type T, removes cv-qualifiers, defines resulting type as\n// member typedef type.\ntemplate <typename T, typename U>\nstruct DecayEquivalent : \n  std::is_same<typename std::decay_t<T>, U>::type\n{};\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(StdDecay)\n{\n  BOOST_TEST((DecayEquivalent<int, int>::value));\n  BOOST_TEST((DecayEquivalent<int&, int>::value));\n  BOOST_TEST((DecayEquivalent<int&&, int>::value));\n  BOOST_TEST((DecayEquivalent<const int&, int>::value));\n  BOOST_TEST((DecayEquivalent<int[2], int*>::value));\n  BOOST_TEST((DecayEquivalent<int(int), int(*)(int)>::value));\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(MaxDecltypeDecayAppliesLvalueToRvalueDecay)\n{\n  {\n    int a {42};\n    int b {7};\n\n    int& a_ref {a};\n    int&& b_r_value {std::move(b)};\n\n    auto result = max_decltype_decay::max(a_ref, b_r_value);\n    BOOST_TEST(result == 42);\n  }\n\n}\n\n/*\n\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(TypeDeductionForDefaultTemplateArgument)\n{\n  f1(); // OK\n  BOOST_TEST(true);\n}\n\n// pp. 15, Sec. 1.5 Overloaindg Function Templates\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(OverloadingFunctionTemplates)\n{\n  BOOST_TEST(max(7, 42) == 42); // calls nontemplate for 2 ints.\n  BOOST_TEST(max(7.0, 42.0) == 42.0); // call max <double> (by argument\n    //deduction)\n  BOOST_TEST(max('a', 'b') == 'b'); // calls max<char> (by argument deduction)\n  BOOST_TEST(max<>(7, 42) == 42); // call max<int> (by argument deduction)\n  BOOST_TEST(max<double>(7, 42) == 42.0); // calls max<double> (no argument\n  // deduction)\n  BOOST_TEST(max('a', 42.7) == 97); // call the nontemplate for two ints \n}\n*/\n\nBOOST_AUTO_TEST_SUITE_END() // MoreMax_tests\n\nBOOST_AUTO_TEST_SUITE_END() // FunctionTemplates\nBOOST_AUTO_TEST_SUITE_END() // Templates\nBOOST_AUTO_TEST_SUITE_END() // Cpp", "meta": {"hexsha": "4ed0cb760fffb5b1d21317acf14335cc5dc745b1", "size": 5750, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Cpp/Templates/FunctionT/MoreMax_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Cpp/Templates/FunctionT/MoreMax_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Cpp/Templates/FunctionT/MoreMax_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8571428571, "max_line_length": 80, "alphanum_fraction": 0.4982608696, "num_tokens": 1242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3775406828054583, "lm_q2_score": 0.15817435473259922, "lm_q1q2_score": 0.05971725388805829}}
{"text": "<<<<<<< HEAD\n/*    Copyright (c) 2010-2018, Delft University of Technology\n=======\n/*    Copyright (c) 2010-2019, Delft University of Technology\n>>>>>>> origin/master\n *    All rigths reserved\n *\n *    This file is part of the Tudat. Redistribution and use in source and\n *    binary forms, with or without modification, are permitted exclusively\n *    under the terms of the Modified BSD license. You should have received\n *    a copy of the license with this file. If not, please or visit:\n *    http://tudat.tudelft.nl/LICENSE.\n *\n *    References\n *      HORIZONS Web-Interface, http://ssd.jpl.nasa.gov/horizons.cgi, last accessed: 5 April, 2011.\n *\n *    Notes\n *      It is noted during the 120513 check that this is not a very extensive and/or precise unit\n *      test. Given that the ephemeris class will soon be updated, this is not deemed a big issue.\n *      However the unit test will have to be improved a lot in the next update. Some code was\n *      outcommented when boostifying the unit test. It is attached in commented version at the\n *      bottom of this file.\n *\n *      Also the test of the approximate planet positions (3D) was changed. It used to check the\n *      only the spherical position coordinates. It was changed to check the cartesian elements in\n *      total. The accuracy with which this is possible is very low though.\n *\n */\n\n#define BOOST_TEST_MAIN\n\n#include <boost/test/unit_test.hpp>\n\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/orbitalElementConversions.h\"\n#include \"Tudat/Basics/testMacros.h\"\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/unitConversions.h\"\n\n#include \"Tudat/Astrodynamics/Ephemerides/approximatePlanetPositions.h\"\n#include \"Tudat/Astrodynamics/Ephemerides/approximatePlanetPositionsCircularCoplanar.h\"\n\nnamespace tudat\n{\nnamespace unit_tests\n{\n\n//! Test the functionality of the approximate planet position functions\nBOOST_AUTO_TEST_SUITE( test_approximate_planet_positions )\n\n//! Test the orbital elements function against the orbital elements of Mars at JD 2455626.5.\nBOOST_AUTO_TEST_CASE( testOrbitalElements )\n{\n    using unit_conversions::convertDegreesToRadians;\n    using namespace ephemerides;\n\n    // Set tolerance.\n    const double tolerance = 2.0e-2;\n\n    // Expected result.\n    Eigen::Matrix< double, 6, 1 > expectedKeplerianElements;\n    expectedKeplerianElements[ 0 ] = 2.279361944126564e11;\n    expectedKeplerianElements[ 1 ] = 9.338126166083623e-2;\n    expectedKeplerianElements[ 2 ] = convertDegreesToRadians( 1.848907897011101 );\n    expectedKeplerianElements[ 3 ] = convertDegreesToRadians( 2.866464026954701e2 );\n    expectedKeplerianElements[ 4 ] = convertDegreesToRadians( 4.952419052428279e1 );\n    expectedKeplerianElements[ 5 ] = convertDegreesToRadians( 3.577219707986779e2 );\n\n    // Create Mars ephemeris.\n    ApproximatePlanetPositions marsEphemeris( ApproximatePlanetPositions::mars );\n\n    // Convert the expected Keplerian elements to Cartesian elements.\n    Eigen::Vector6d expectedEphemeris;\n    expectedEphemeris = orbital_element_conversions::\n            convertKeplerianToCartesianElements(\n            expectedKeplerianElements,\n            marsEphemeris.getSunGravitationalParameter( ) );\n\n    // Retrieve state of Mars in Cartesian elements at Julian date 2455626.5.\n    Eigen::Vector6d marsState = marsEphemeris.getCartesianState(\n                ( 2455626.5 - basic_astrodynamics::JULIAN_DAY_ON_J2000 ) * physical_constants::JULIAN_DAY );\n\n    // Test if the computed ephemeris matches the expected ephemeris within the tolerance set.\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( expectedEphemeris, marsState, tolerance );\n\n    // Check that the reference frame properties are as expected.\n    BOOST_CHECK_EQUAL( marsEphemeris.getReferenceFrameOrientation( ), \"ECLIPJ2000\" );\n    BOOST_CHECK_EQUAL( marsEphemeris.getReferenceFrameOrigin( ), \"Sun\" );\n}\n\n//! Test the cicular coplanar function against orbital elements of Mars at JD 2455626.5.\nBOOST_AUTO_TEST_CASE( testCircularCoplannar )\n{\n    using namespace ephemerides;\n\n    ApproximatePlanetPositionsCircularCoplanar marsEphemeris(\n                ApproximatePlanetPositionsBase::mars );\n\n    Eigen::Vector6d marsStateCircularCoplanar\n            = marsEphemeris.getCartesianState(\n                ( 2455626.5 - basic_astrodynamics::JULIAN_DAY_ON_J2000 ) * physical_constants::JULIAN_DAY );\n\n    // Compute the Keplerian elements from this ephemeris.\n    Eigen::Vector6d keplerianElementsCircularCoplanar;\n    keplerianElementsCircularCoplanar = orbital_element_conversions::\n            convertCartesianToKeplerianElements( marsStateCircularCoplanar,\n                    marsEphemeris.getSunGravitationalParameter( ) + marsEphemeris.getPlanetGravitationalParameter( ) );\n\n    // Check the eccentricity, inclination and z-component of velocity and position are 0.\n    BOOST_CHECK_SMALL( keplerianElementsCircularCoplanar( 1 ), 1e-15 );\n    BOOST_CHECK_SMALL( keplerianElementsCircularCoplanar( 2 ),\n                       std::numeric_limits< double >::min( ) );\n    BOOST_CHECK_SMALL( marsStateCircularCoplanar( 2 ), 2.0e-5 );\n    BOOST_CHECK_SMALL( marsStateCircularCoplanar( 5 ),\n                       std::numeric_limits< double >::min( ) );\n\n    // Check that the reference frame properties are as expected.\n    BOOST_CHECK_EQUAL( marsEphemeris.getReferenceFrameOrientation( ), \"ECLIPJ2000\" );\n    BOOST_CHECK_EQUAL( marsEphemeris.getReferenceFrameOrigin( ), \"Sun\" );\n}\n\nBOOST_AUTO_TEST_SUITE_END( )\n\n} // namespace unit_tests\n} // namespace tudat\n\n//    // Compute the difference in semi-major axis between Test 2 and\n//    // the external EphemerisData \"p_elem_t2.txt\".\n//    double errorSemiMajorAxis = fabs( positionMars.norm( )\n//                                      - convertAstronomicalUnitsToMeters( 1.52371243 ) )\n//            / convertAstronomicalUnitsToMeters( 1.52371243 );\n\n//    if ( errorSemiMajorAxis > errorTolerance_ )\n//    {\n//        isApproximatePlanetPositionsErroneous = true;\n\n//        // Generate error statements.\n//        cerr << \"The computed relative error in position of the  \" << endl;\n//        cerr << \"coplanar circular position of Mars ( \" << errorSemiMajorAxis << \" )\" << endl;\n//        cerr << \"using the ApproximatePlanetPositionsCircularCoplanar class, exceeds \"\n//             << \"the maximum expected error \" << endl;\n//        cerr << \"( \" << errorTolerance_ << \" ).\" << endl;\n//    }\n\n//    // Check orientation of position vector by comparison of separate components.\n//    // Error in position should be smaller than maximum expected offset with respect to\n//    // elliptical and inclined orbits.\n//    double maximumErrorPosition =   keplerianElementsTest3D.getSemiMajorAxis( ) * (\n//                keplerianElementsTest3D.getEccentricity( ) + 1.0\n//                - cos( keplerianElementsTest3D.getInclination( ) ) );\n//    Vector3d errorPositionVector = positionMars - marsEphemeris.getPosition( );\n\n//    if ( fabs( errorPositionVector( 0 ) ) > maximumErrorPosition\n//         || fabs( errorPositionVector( 1 ) ) > maximumErrorPosition )\n//    {\n//        isApproximatePlanetPositionsErroneous = true;\n\n//        // Generate error statements.\n//        cerr << \"The computed error in position vector of the  \" << endl;\n//        cerr << \"coplanar circular position of Mars ( \"\n//             << errorPositionVector << \" meters )\" << endl;\n//        cerr << \"using the ApproximatePlanetPositionsCircularCoplanar class, exceeds \"\n//             << \"the expected error (\" << endl;\n//        cerr << \"( \" << maximumErrorPosition << \" meters ).\" << endl;\n//    }\n\n    /* FIX THIS TEST!!!\n    // Check size of velocity.\n    Eigen::Vector3d errorVelocity = velocityMars - marsEphemeris.segment( 3, 3 );\n\n    // Error in scalar velocity should be smaller than maximum expected offset with respect to\n    // ellipitical and inclined orbits.\n    double expectedErrorVelocity = fabs(\n                sqrt( predefinedSun.getGravitationalParameter( )\n                      / marsEphemeris.segment( 0, 3 ).norm( ) ) *\n                ( ( 1.0 - cos( keplerianElementsTest3D.getInclination( ) )\n                    + sqrt( ( 1.0 - keplerianElementsTest3D.getEccentricity( ) ) /\n                            ( 1.0 + keplerianElementsTest3D.getEccentricity( ) ) ) - 1.0 ) ) );\n\n\n    if ( errorVelocity.norm( ) > expectedErrorVelocity )\n    {\n        isApproximatePlanetPositionsErroneous = true;\n\n        // Generate error statements.\n        cerr << \"The computed error in velocity of the \" << endl;\n        cerr << \"coplanar circular position of Mars \"\n             << \"( \" << errorVelocity.norm( ) << \" meters per second )\" << endl;\n        cerr << \"using the ApproximatePlanetPositionsCircularCoplanar class, exceeds \"\n             << \"the expected error \" << endl;\n        cerr << \"( \" << expectedErrorVelocity << \" meters per second ).\" << endl;\n        cerr << \"The computed error exceeds the expected error by: \"\n             << fabs( errorVelocity.norm( ) - expectedErrorVelocity )\n             << \" meters per second.\" << endl;\n    }\n    */\n", "meta": {"hexsha": "dc3703b1e4037851cdbc97240903ac8cd2370903", "size": 9058, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestApproximatePlanetPositions.cpp", "max_stars_repo_name": "ViktorJordanov/tudat", "max_stars_repo_head_hexsha": "069ceeab8f12405c356e19f50d6df037914df85c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestApproximatePlanetPositions.cpp", "max_issues_repo_name": "ViktorJordanov/tudat", "max_issues_repo_head_hexsha": "069ceeab8f12405c356e19f50d6df037914df85c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestApproximatePlanetPositions.cpp", "max_forks_repo_name": "ViktorJordanov/tudat", "max_forks_repo_head_hexsha": "069ceeab8f12405c356e19f50d6df037914df85c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.4512820513, "max_line_length": 119, "alphanum_fraction": 0.6897769927, "num_tokens": 2265, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.11920292358664389, "lm_q1q2_score": 0.059601461793321944}}
{"text": "#pragma once\n\n/* =========================================================================\n      Copyright (c) 2015-2017, COE of Peking University, Shaoqiang Tang.\n\n                         -----------------\n            cuarma - COE of Peking University, Shaoqiang Tang.\n                         -----------------\n\n                  Author Email    yangxianpku@pku.edu.cn\n\n         Code Repo   https://github.com/yangxianpku/cuarma\n\n                      License:    MIT (X11) License\n============================================================================= */\n\n\n/** @file tag_of.hpp\n    @brief Dispatch facility for distinguishing between ublas, STL and cuarma types\n*/\n\n#include <vector>\n#include <map>\n\n#include \"cuarma/forwards.h\"\n\n#ifdef CUARMA_WITH_UBLAS\n#include <boost/numeric/ublas/matrix_sparse.hpp>\n#include <boost/numeric/ublas/matrix.hpp>\n#include <boost/numeric/ublas/vector.hpp>\n#endif\n\nnamespace cuarma\n{\n\n// ----------------------------------------------------\n// TAGS\n//\n/** @brief A tag class for identifying 'unknown' types. */\nstruct tag_none     {};\n\n/** @brief A tag class for identifying types from uBLAS. */\nstruct tag_ublas    {};\n\n/** @brief A tag class for identifying types from the C++ STL. */\nstruct tag_stl      {};\n\n/** @brief A tag class for identifying types from cuarma. */\nstruct tag_cuarma {};\n\nnamespace traits\n{\n  // ----------------------------------------------------\n  // GENERIC BASE\n  //\n  /** @brief Generic base for wrapping other linear algebra packages\n  *\n  *  Maps types to tags, e.g. cuarma::vector to tag_cuarma, ublas::vector to tag_ublas\n  *  if the matrix type is unknown, tag_none is returned\n  *\n  *  This is an internal function only, there is no need for a library user of cuarma to care about it any further\n  *\n  * @tparam T   The type to be inspected\n  */\n  template< typename T, typename Active = void >\n  struct tag_of;\n\n  /** \\cond */\n  template< typename Sequence, typename Active >\n  struct tag_of\n  {\n    typedef cuarma::tag_none  type;\n  };\n\n\n#ifdef CUARMA_WITH_UBLAS\n  // ----------------------------------------------------\n  // UBLAS\n  //\n  template< typename T >\n  struct tag_of< boost::numeric::ublas::vector<T> >\n  {\n    typedef cuarma::tag_ublas  type;\n  };\n\n  template< typename T >\n  struct tag_of< boost::numeric::ublas::matrix<T> >\n  {\n    typedef cuarma::tag_ublas  type;\n  };\n\n  template< typename T1, typename T2 >\n  struct tag_of< boost::numeric::ublas::matrix_unary2<T1,T2> >\n  {\n    typedef cuarma::tag_ublas  type;\n  };\n\n  template< typename T1, typename T2 >\n  struct tag_of< boost::numeric::ublas::compressed_matrix<T1,T2> >\n  {\n    typedef cuarma::tag_ublas  type;\n  };\n\n#endif\n\n  // ----------------------------------------------------\n  // STL types\n  //\n\n  //vector\n  template< typename T, typename A >\n  struct tag_of< std::vector<T, A> >\n  {\n    typedef cuarma::tag_stl  type;\n  };\n\n  //dense matrix\n  template< typename T, typename A >\n  struct tag_of< std::vector<std::vector<T, A>, A> >\n  {\n    typedef cuarma::tag_stl  type;\n  };\n\n  //sparse matrix (vector of maps)\n  template< typename KEY, typename DATA, typename COMPARE, typename AMAP, typename AVEC>\n  struct tag_of< std::vector<std::map<KEY, DATA, COMPARE, AMAP>, AVEC> >\n  {\n    typedef cuarma::tag_stl  type;\n  };\n\n\n  // ----------------------------------------------------\n  // CUARMA\n  //\n  template< typename T, unsigned int alignment >\n  struct tag_of< cuarma::vector<T, alignment> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  template< typename T, typename F, unsigned int alignment >\n  struct tag_of< cuarma::matrix<T, F, alignment> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  template< typename T1, typename T2, typename OP >\n  struct tag_of< cuarma::matrix_expression<T1,T2,OP> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  template< typename T >\n  struct tag_of< cuarma::matrix_range<T> >\n  {\n    typedef cuarma::tag_cuarma  type;\n\n  };\n\n  template< typename T, unsigned int I>\n  struct tag_of< cuarma::compressed_matrix<T,I> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  template< typename T, unsigned int I>\n  struct tag_of< cuarma::coordinate_matrix<T,I> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  template< typename T, unsigned int I>\n  struct tag_of< cuarma::ell_matrix<T,I> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  template< typename T, typename I>\n  struct tag_of< cuarma::sliced_ell_matrix<T,I> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n\n  template< typename T, unsigned int I>\n  struct tag_of< cuarma::hyb_matrix<T,I> >\n  {\n    typedef cuarma::tag_cuarma  type;\n  };\n\n  // ----------------------------------------------------\n} // end namespace traits\n\n\n/** @brief Meta function which checks whether a tag is tag_ublas\n*\n*  This is an internal function only, there is no need for a library user of cuarma to care about it any further\n*/\ntemplate<typename Tag>\nstruct is_ublas\n{\n  enum { value = false };\n};\n\n/** \\cond */\ntemplate<>\nstruct is_ublas< cuarma::tag_ublas >\n{\n  enum { value = true };\n};\n/** \\endcond */\n\n/** @brief Meta function which checks whether a tag is tag_ublas\n*\n*  This is an internal function only, there is no need for a library user of cuarma to care about it any further\n*/\ntemplate<typename Tag>\nstruct is_stl\n{\n  enum { value = false };\n};\n\n/** \\cond */\ntemplate<>\nstruct is_stl< cuarma::tag_stl >\n{\n  enum { value = true };\n};\n/** \\endcond */\n\n\n/** @brief Meta function which checks whether a tag is tag_cuarma\n*\n*  This is an internal function only, there is no need for a library user of cuarma to care about it any further\n*/\ntemplate<typename Tag>\nstruct is_cuarma\n{\n  enum { value = false };\n};\n\n/** \\cond */\ntemplate<>\nstruct is_cuarma< cuarma::tag_cuarma >\n{\n  enum { value = true };\n};\n/** \\endcond */\n\n} // end namespace cuarma", "meta": {"hexsha": "d3adbbeda2b2ce08cb26cd3861d0a4edf6108acd", "size": 5800, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "cuarma/meta/tag_of.hpp", "max_stars_repo_name": "yangxianpku/cuarma", "max_stars_repo_head_hexsha": "404f20b5b3fa74e5e27338e89343450f8853024c", "max_stars_repo_licenses": ["X11", "MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cuarma/meta/tag_of.hpp", "max_issues_repo_name": "yangxianpku/cuarma", "max_issues_repo_head_hexsha": "404f20b5b3fa74e5e27338e89343450f8853024c", "max_issues_repo_licenses": ["X11", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cuarma/meta/tag_of.hpp", "max_forks_repo_name": "yangxianpku/cuarma", "max_forks_repo_head_hexsha": "404f20b5b3fa74e5e27338e89343450f8853024c", "max_forks_repo_licenses": ["X11", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.2, "max_line_length": 114, "alphanum_fraction": 0.5984482759, "num_tokens": 1502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4455295350395727, "lm_q2_score": 0.13117322206357787, "lm_q1q2_score": 0.05844154463562847}}
{"text": "// Author: b1tank\n// Email: b1tank@outlook.com\n//=================================\n\n// cpp essentials playground\n\n#include <iostream>\n\n#include <sstream> // stringstream, istringstream, ostringstream\n#include <string> // to_string(), stoi()\n\n#include <cctype> // isalnum, isalpha, isdigit, islower, isupper, isspace; toupper, tolower\n#include <climits> // INT_MAX 2147483647\n#include <cmath> // pow(3.0, 4.0); abs(-3.0)\n#include <cstdlib> // rand() % 100 + 1; abs(-3)\n\n#include <vector>\n#include <forward_list> // singly-linked list\n#include <list> // doubly-linked list\n#include <stack>\n#include <queue>\n#include <deque>\n\n#include <unordered_set> // unordered_set, unordered_multiset\n#include <set> // set, multiset\n#include <bitset> // bitset\n#include <unordered_map> // unordered_map, unordered_multimap\n#include <map> // map, multimap\n\n#include <utility> // pair<>\n#include <tuple> // tuple<>\n\n#include <algorithm> // reverse, sort, transform, find, remove, count, count_if\n\n#include <memory> // shared_ptr<>, make_shared<>\n\n#include <stdexcept> // invalid_argument\n\nusing namespace std;\n\nint main() {\n\n    // cpp style ref: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es23-prefer-the--initializer-syntax\n\n    // char and string\n    char c = 'c';\n    isalnum('2'); // #include<cctype>\n    isalpha('a');\n    isdigit('4');\n    islower('z');\n    isupper('Z');\n    isspace(' ');\n    char C = toupper(c);\n    int d = 'c' - 'a';\n    char e = 'c' + 2; \n    \n    string a(\"str\");\n    string b(\"str2\");\n\n    long i = 28;\n    to_string(i); // \"28\"\n    stoi(\"28\"); // 28\n    string str_dec = \"2001, A Space Odyssey\";\n    string str_hex = \"40c3\";\n    string str_bin = \"-10010110001\";\n    string str_auto = \"0x7f\";\n    int i_dec = stoi (str_dec, &sz);\n    int i_hex = stoi (str_hex, nullptr, 16);\n    int i_bin = stoi (str_bin, nullptr, 2);\n    int i_auto = stoi (str_auto, nullptr, 0);\n\n    auto c = a.at(2);\n    a.front() = 'B';\n    a.back() = 'E';\n\n    a.substr(4, 2); // 2 is len\n    auto pos = a.find(\"tr\");\n    a.substr(pos); // from pos to the end\n    string token = s.substr(0, s.find(delimiter)); // split string\n\n    a += \"suffix\";\n    a.append(b);\n    a.append(b, 3, 2);\n    a.append(\"string\", 3);\n    a.append(\"string\");\n    a.append(10u, '.');\n    a.append(b.begin()+5, b.end());\n\n    a.insert(2, \"string\", 3); // just add a \"size_t pos\" upon append method\n    a.erase(10,9); // only apply to string (not to vector!!!)\n    a.erase(a.begin()+7);\n    a.erase(a.begin()+7, a.end());\n    a.replace(10, 8, b, 7, 6); // just add a \"size_t pos\" and \"size_t len\" upon append method\n\n    a.swap(b);\n\n    a.push_back('c');\n    a.pop_back();\n\n    auto it = a.begin();\n    auto it = a.end();\n    auto it = a.rbegin();\n    auto it = a.rend();\n    if (a.empty()) {}\n\n    int s = a.length();\n    int ss = a.size();\n\n    a.find(\"tr\") == string::npos; // find or not\n    a.find(\"tr\");\n    a.find(\"tr\", 4);\n    a.find(\"tr\", 4, 1); // starting pos, len\n    a.rfind(\"tr\"); // last appearance\n    a.rfind(\"tr\", 4);\n    a.rfind(\"tr\", 4, 1);\n\n    a.compare(6, 5, \"apple\", 4, 5); // <0, ==0, >0\n\n    // number, power and random\n    int ma = INT_MAX; // #include <climits> -2147483648, 2147483647\n    int mi = INT_MIN;\n    int p = pow(3.0, 4.0); // #include <cmath> 81\n    int a = abs(-3); // #include <cstdlib> integral\n    int a = abs(-3.0); // #include <cmath> double/float\n    int r = rand() % 100; // #include <cstdlib> 0-99\n    int r = rand() % 100 + 1; // #include <cstdlib> 1-100\n\n    // bool and condition\n    bool t = true;\n    bool f = false;\n\n    // loop\n    for (auto c : a) {}\n    for (auto it = a.begin(); it != a.end(); it++) {}\n    for (auto it = a.rbegin(); it != a.rend(); it++) {}\n\n    // vector\n    vector<int> v{2, 3, 4};\n    vector<int> v(3);\n    vector<int> v(3, 8);\n    vector<vector<int>> v(3, vector<int>(8));\n    vector<int> v(v1.begin()+1, v1.end());\n    vector<pair<int, int>> vp;\n\n    v = v1; // copy another vector\n    v = vector<int>(); // const vector<>&\n    v = {2, 3}; // initializer list\n\n    // return {}; // return empty vector\n    // return vector<int>();\n\n    v.push_back(4);\n    v.pop_back();\n    vp.emplace_back(3, 5); // implicit constructor \n    auto it = v.insert(v.end(), v2.begin(), v2.end());\n    auto it = v.insert(v.begin()+2, 7);\n    auto it = v.insert(v.begin(), 2, 7); // insert 2 \"7\"s\n    auto it = v.erase(v.begin()+1);\n    auto it = v.erase(v.begin()+1, v.end());\n    v.swap(v2);\n    v.clear();\n\n    int vf = v.front();\n    int vf = v.back();\n    auto it = v.begin();\n    auto it = v.end();\n    auto it = v.rbegin();\n    auto it = v.rend();\n\n    if (v.empty()) {}\n\n    // stack (by default underlying container is <deque>)\n    // * Queue, Stack, and Priority_queue has no begin()/end(). Can't do loop. Can't modify elements by clear(), reverse().\n    stack<int> st;\n    stack<int> st1;\n    stack<pair<int, int>> st2;\n\n    int s = st.size();\n    if (st.empty()) {}\n\n    st.push(3); // st.push_back() of underlying container\n    st2.emplace(2, 3);\n    st.pop(); // st.pop_back() of underlying container\n\n    st.top(); // st.back() of underlying container\n\n    st.swap(st1); // cannot swap with st2 !!!\n\n    // queue (by default underlying container is <deque>)\n    queue<int> q;\n    queue<int> q1;\n    queue<pair<int, int>> q2;\n\n    int s = q.size();\n    if (q.empty()) {}\n\n    q.push(3);\n    q2.emplace(2, 3);\n\n    q.front();\n    q.back();\n\n    q.pop(); // pop_front() of underlying container\n\n    q.swap(q1); // cannot swap with q2 !!!\n\n    // deque \n    deque<int> dq;\n    deque<int> dq1;\n    deque<pair<int, int>> q2;\n\n    int s = dq.size();\n    if (dq.empty()) {}\n\n    dq.push_front(3);\n    dq.push_back(3);\n    dq1.emplace(dq.begin()+2, 8, 3); // pos (1st arg)\n    dq1.emplace_front(8, 3);\n    dq1.emplace_back(8, 3);\n\n    dq.front();\n    dq.back();\n\n    dq.begin();\n    dq.end();\n    dq.rbegin();\n    dq.rend();\n\n    dq.pop_front();\n    dq.pop_back();\n\n    dq.swap(q1); // cannot swap with q2 !!!\n\n    // priority_queue (by default: Max-Heap; <vector> as the underlying container)\n    priority_queue<int> pq;\n    priority_queue<int, vector<int>, greater<int>> pq1; // Min-Heap\n    priority_queue<pair<int, int>> pq2;\n\n    int s = pq.size();\n    if (pq.empty()) {}\n\n    pq.push(3);\n    pq2.emplace(2, 3);\n\n    int t = pq.top();\n\n    pq.pop();\n\n    pq.swap(pq1); // cannot swap with pq2\n\n    class point{\n    public:\n        int x;\n        int y;\n        point(int x, int y):x(x),y(y) {}\n    };\n\n    class pointCompLessThan {\n    public:\n        bool operator()(point& a, point& b) {  // operator()!!!\n            return a.x < b.x;\n        }\n    };\n\n    priority_queue<point, vector<point>, pointCompLessThan> Q;\n    Q.emplace(1, 2);\n\n    // bitset (index 0 from the right end !!!!!)\n    vector<bitset<26>> dp;\n    bitset<26> set_i(0);\n    bitset<26> set_j(string(\"10101001\"));\n    set_i[1] = 1;\n    int n = set_i.size(); // 26\n    if (set_i.count() == 1) {}\n    if ((set_i & set_j).none()) {}\n    if ((set_i | set_j).any()) {}\n    if ((set_i ^ set_j).all()) {}\n    set_i.set(c - 'a');\n    set_i.set(); // apply to all bits\n    set_i.reset(c - 'a');\n    set_i.reset();\n    set_i.flip(c - 'a');\n    set_i.flip();\n\n    // unordered set and multiset; map and multimap\n    // * Can be looped through using iterators from begin() to end()\n    // * Array/vector are not hashable. One way to work around is to convert it to strings.\n    unordered_set<int> s;\n    unordered_set<int> s1{\"red\", \"blue\", \"green\"}; // {} is list initialization for containers, which is preferred !!!\n    // unordered_set<int> s1( {\"red\", \"blue\", \"green\"} ); // also correct but allows parsing ambiguities !!!\n    unordered_map<string, int> m;\n    unordered_map<string, int> m1{{\"red\", 1}, {\"blue\", 2}, {\"green\", 3}}; // {} is list initialization for containers, which is preferred !!!\n    // unordered_map<string, int> m1( {{\"red\", 1}, {\"blue\", 2}, {\"green\", 3}} ); // also correct but allows parsing ambiguities !!!\n\n    int ss = s.size();\n    if (s.empty()) {}\n\n    auto it = s.begin();\n    auto it = s.end();\n\n    if (s.find(5) != s.end() || s.count(5) == 1) {}\n\n    s.insert(\"orange\");\n    s.insert(v.begin(), v.end());\n    s.insert( {\"orange\", \"purple\"} ); // initializer list\n    s.erase(\"blue\");\n    s.erase(s.begin()+2);\n    s.erase(s.begin()+2, s.end());\n\n    pair<string, int> mypair (\"baking powder\", 3);\n    m.insert (mypair);                        // copy insertion\n    m.insert (make_pair<string, int>(\"eggs\", 6)); // move insertion\n    m.insert (m1.begin(), m2.end());  // range insertion\n    m.insert ( {{\"sugar\", 8}, {\"salt\", 1}} );    // initializer list insertion\n\n    s.swap(s2);\n\n    unordered_multiset<int> ms( { 2, 3, 2, 4, 2} );\n    int count = ms.count(2); // 3\n    auto myrange = ms.equal_range(2);\n    while (myrange.first != myrange.second) {\n        cout << *myrange.first++ << endl;\n    }\n\n    // (ordered) set and multiset; (map and multimap)\n    set<int> s;\n    set<int> s1{\"red\", \"blue\", \"green\"}; // {} is list initialization for containers, which is preferred !!!\n    // set<int> s1( {\"red\", \"blue\", \"green\"} ); // also correct but allows parsing ambiguities !!!\n\n    int ss = s.size();\n    if (s.empty()) {}\n\n    auto it = s.begin();\n    auto it = s.end();\n    auto it = s.rbegin();\n    auto it = s.rend();\n\n    if (s.find(5) != s.end() || s.count(5) == 1) {}\n\n    s.insert(\"orange\");\n    s.insert(v.begin(), v.end());\n    s.insert( {\"orange\", \"purple\"} ); // initializer list\n    s.erase(\"blue\");\n    s.erase(s.begin()+2);\n    s.erase(s.begin()+2, s.end());\n\n    s.swap(s2);\n\n    unordered_multiset<int> ms( { 2, 3, 2, 4, 2} );\n    int count = ms.count(2);\n    auto it = ms.lower_bound(3);\n    auto it = ms.upper_bound(4);\n    auto myrange = ms.equal_range(2);\n    while (myrange.first != myrange.second) {\n        cout << *myrange.first++ << endl;\n    }\n\n    // pair (<utility>) and tuple (<tuple>)\n    pair <string, double> p1 (\"tomatoes\", 2.30);\n    p1.first;\n    p1.second;\n\n    tuple<int,char> foo (10, 'x');\n    auto bar = make_tuple (\"test\", 3.1, 14, 'y');\n\n    get<2>(bar) = 100;                          // access element\n\n    int myint; char mychar;\n    tie (myint, mychar) = foo;                  // unpack elements\n    tie (ignore, ignore, myint, mychar) = bar;  // unpack (with ignore)\n\n    //// data structure\n    // tree\n    struct TreeNode {\n        int val;\n        TreeNode* left;\n        TreeNode* right;\n        TreeNode (int v) : val(v), left(nullptr), right(nullptr) {}\n    };\n\n    // trie\n    class TrieNode {\n    public:\n        // vector<TrieNode*> next;\n        bool isEnd;\n        vector<shared_ptr<TrieNode>> next;\n        \n        TrieNode() : isEnd(false), next(26, nullptr) {}\n    };\n    class Trie {\n        // TrieNode* root;\n        shared_ptr<TrieNode> root;\n    public:\n        /** Initialize your data structure here. */\n        Trie() {\n            // root = new TrieNode();\n            root = make_shared<TrieNode>();\n        }\n        \n        /** Inserts a word into the trie. */\n        void insert(string word) {\n            // TrieNode* cur = root;\n            shared_ptr<TrieNode> cur = root;\n            for (char c: word) {\n                if (cur->next[c - 'a'] == nullptr) {\n                    // cur->next[c - 'a'] = new TrieNode();\n                    cur->next[c - 'a'] = make_shared<TrieNode>();\n                }\n                cur = cur->next[c - 'a'];\n            }\n            cur->isEnd = true;\n            return;\n        }\n        \n        /** Returns if the word is in the trie. */\n        bool search(string word) {\n            // TrieNode* cur = root;\n            shared_ptr<TrieNode> cur = root;\n            for (char c : word) {\n                if (cur->next[c - 'a'] == nullptr) {\n                    return false;\n                } else {\n                    cur = cur->next[c - 'a'];\n                }\n            }\n            return cur->isEnd;\n        }\n        \n        /** Returns if there is any word in the trie that starts with the given prefix. */\n        bool startsWith(string prefix) {\n            // TrieNode* cur = root;\n            shared_ptr<TrieNode> cur = root;\n            for (char c : prefix) {\n                if (cur->next[c - 'a'] == nullptr) {\n                    return false;\n                } else {\n                    cur = cur->next[c - 'a'];\n                }\n            }\n            return true;\n        }\n    };\n\n    // single-linked list\n    struct ListNode {\n        int val;\n        ListNode* next;\n        ListNode (int v) : val(v), next(nullptr) {};\n    };\n\n    // double-linked list\n    struct ListNode {\n        int val;\n        ListNode* prev;\n        ListNode* next;\n        ListNode (int v) : val(v), prev(nullptr), next(nullptr) {};\n    };\n\n    // graph node and graph (adjacency list)\n    struct GraphNode {\n\n        int val;\n        // string str;\n        vector<GraphNode*> neighbors;\n        // vector<int> neighbors;\n        // vector<string> neighbors;\n        // vector<pair<string, int>> neighbors; // weighted edges\n        // unordered_set<int> neighbors;\n        // unordered_set<string> neighbors;\n        // unordered_set<pair<string, int>> neighbors; // weighted edges\n\n        GraphNode() {\n            val = 0;\n            neighbors = vector<GraphNode*>();\n        }\n\n        GraphNode(int _v) {\n            val = _v;\n            neighbors = vector<GraphNode*>();\n        }\n\n        GraphNode(int _v, vector<GraphNode*> _ns) {\n            val = _v;\n            neighbors = _ns;\n        }\n    };\n\n    // ref: https://www.redblobgames.com/pathfinding/a-star/implementation.cpp\n    struct Graph {\n        unordered_map<char, vector<char>> edges;\n        // unordered_map<int, vector<int>> edges;\n        // ... other types\n        vector<char> neighbors (char val) {\n            return edges[val];\n        }\n    };\n    Graph g {\n        {\n            { 'A', {'B'} },\n            { 'B', {'C', 'D'} },\n            { 'C', {'A'} },\n            { 'D', {'B'} }\n        }\n    }; // {} gives direct initialization with explicit constructor; whereas ={} gives copy initialization !!!!!\n    \n    //// algorithm\n\n    // STL\n    transform(a.begin(), a.end(), a.begin(), toupper); // #include<algorithm>\n    auto it = find(a.begin(), a.end(), \"str\"); // #include<algorithm>\n    reverse(v.begin(), v.end()); // #include<algorithm>\n    sort(v.begin(), v.end()); // #include<algorithm>\n    sort(v.begin(), v.end(), boolFuncLessThan); // #include<algorithm> asc\n    sort(v.begin(), v.end(), [](point& a, point& b) {return a.y < b.y;});\n    sort(v.begin(), v.end(), boolFuncGreaterThan); // #include<algorithm> desc\n    auto it = remove(v.begin(), v.end(), 13); // #include<algorithm>\n    int count = count(v.begin(), v.end(), 13); // #include<algorithm>\n    int count_if = count_if(v.begin(), v.end(), boolFunc); // #include<algorithm>\n\n    // split string\n    // ref: https://doc.bccnsoft.com/docs/cppreference_en/cppsstream/all.html\n\n    // #include <boost/algorithm/string.hpp>\n    // string s = \"hello world\";\n    // vector<string> res;\n    // boost::split(res, s, [](char c){return c == ' ';});\n\n    istringstream iss(s); // or stringstream\n    // or ss << s;\n    // or ss.str(s);\n    vector<string> res;\n    string token;\n    char delimiter = ' ';\n    while(getline(ss, token, delimiter)) {\n        res.push_back(token);\n    }\n\n    // join strings\n    ostringstream oss;\n    if (begin != end) ss << *begin++;\n    while (begin != end) {\n        ss << delimiter;\n        ss << *begin++;\n    }\n    ss << concluder;\n    string joined_str = ss.str();\n\n    // stringstream peek and EOF (empty stringstream is a special case!!!)\n    stringstream ss(\"\");\n    ss.peek(); // make empty ss reach EOF !!!\n    if (ss.eof()) {} // true; false without peek() call above\n\n    // binary search\n    int target = 4;\n    vector<int> arr{1, 2, 3, 4, 5};\n    int l = 0;\n    int r = arr.size()-1;\n    while (l < r) { // or l <= r\n        int mid = l + (r-l) / 2;\n        if (target == arr[mid]) {\n            return mid;\n        } else if (target > arr[mid]) {\n            l = mid + 1;\n        } else {\n            r = mid; // or r = mid - 1\n        }\n    }\n\n    // Depth first seach (DFS)\n    void dfs_iterative (vector<vector<int>> graph, int start) {\n        stack<int> st{start};\n        unordered_set<int> visited{start};\n        while (!st.empty()) {\n            int cur = st.top();\n            st.pop();\n            for (auto& n : graph[cur]) {\n                if (visited.find(n) == visited.end()) {\n                    visited.insert(n);\n                    st.push(n);\n                }\n            }\n        }\n    }\n    void dfs_recursive (vector<vector<int>> graph, int start, unordered_set<int> visited) {\n        visited.insert(start);\n        for (auto& n : graph[cur]) {\n            if (visited.find(n) == visited.end()) {\n                dfs_recursive(graph, n, visited);\n            }\n        }\n    }\n\n    // Breadth first seach (BFS)\n    void bfs (vector<vector<int>> graph, int start, int target) {\n        queue<pair<int, int>> q; // depth (cost), node_val\n        q.emplace(0, start);  \n        unordered_set<int> visited{start};\n        while (!q.empty()) {\n            int cur_depth = q.front().first;\n            int cur = q.front().second;\n            q.pop();\n            if (cur == target) return cur_depth; // shortest path to target\n            for (auto& n : graph[cur]) {\n                if (visited.find(n) == visited.end()) {\n                    visited.insert(n);\n                    q.emplace(cur_depth + 1, n);\n                }\n            }\n        }\n    }\n\n    // Dijkstra's algorithm\n    void dijksta (vector<vector<pair<int, int>>> graph, int start, int target) {\n        // Min-Heap\n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; // cost, node\n        pq.emplace(0, start);\n        while (!pq.empty()) {\n            int cur_cost = pq.top().first;\n            int cur = pq.top().second;\n            pq.pop();\n            if (cur == target) return cur_cost; // shortest path to target\n            for (auto& n : graph[cur]) {\n                int n_weight = n.first;\n                int n_node = n.second;\n                pq.emplace(cur_cost + n_weight, n_node);\n            }\n        }\n    }\n\n    // A* algorithm\n    inline int heuristic (int& a, int& b) {\n        return abs(a - b);\n    }\n    void a_star (vector<vector<pair<int, int>>> graph, int start, int target) {\n        // Min-Heap\n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; // cost, node\n        pq.emplace(0, start);\n        \n        unordered_map<int, int> prev; // node, node (prev)\n        unordered_map<int, int> cost; // node, cost\n\n        while (!pq.empty()) {\n            int cur_cost = pq.top().first;\n            int cur = pq.top().second;\n            pq.pop();\n            if (cur == target) return cur_cost; // shortest path to target\n            for (auto& n : graph[cur]) {\n                int n_weight = n.first;\n                int n_node = n.second;\n                int new_cost = cur_cost + n_weight;\n                if (cost.find(n_node) == cost.end() || new_cost < cost[n_node]) {\n                    cost[n_node] = new_cost;\n                    pq.emplace(new_cost + heuristics(n_node, target), n_node);\n                    prev[n_node] = cur;\n                }\n            }\n        }\n    }\n\n    // Topological sort (In-degree; Adjacency matrix - Adjacency list)\n    int n = 10;\n    vector<pair<int, int>> prerequisites;\n    vector<vector<int>> graph(n); // adjacency list\n    vector<int> in_degree(n, 0);\n    vector<int> res;\n\n    // construct graph from edges (adjacency matrix) and compute in-degrees\n    for (auto &p: prerequisites) {\n        graph[p.second].push_back(p.first);\n        in_degree[p.first]++; \n    }\n\n    queue<int> q;\n    for (int i = 0; i < n; i++) {\n        if (in_degree[i] == 0) {\n            q.push(i); \n            res.push_back(i);\n        }\n    }\n\n    while (!q.empty()) {\n        int cur = q.front(); \n        q.pop();\n        for (auto& n: graph[cur]) {\n            in_degree[n]--;\n            if (in_degree[n] == 0) {\n                q.push(n); \n                res.push_back(n);\n            }\n        }\n    }\n\n    // union-find\n    // - canonical implementation of Weighted Union-Find with path compression\n    //     - weighted: size of each component\n    //     - path compression: update nodes' direct parent as root\n    // - Complexity\n    //     - UnionFind(): O(N)\n    //     - find_root(): nearly 1 (amortized)\n    //     - union_weighted(): nearly 1 (amortized)\n    //     - connected(): nearly 1 (amortized)\n    //     - count(): O(1)\n    // - ref\n    //     - https://algs4.cs.princeton.edu/15uf/WeightedQuickUnionPathCompressionUF.java.html\n    //     - https://www.hackerearth.com/practice/notes/disjoint-set-union-union-find/\n    class UnionFind {\n        int count;\n        vector<int> parent;\n        vector<int> size;\n    public:\n        UnionFind(int N) : count(N), parent(N), size(N, 1) {\n            for (int i=0; i < N; i++) {\n                parent[i] = i;\n            }\n        }\n        void union(int p, int q) {\n            int rp = find_root(p);\n            int rq = find_root(q);\n            if (rp == rq) return;\n\n            if (size[p] < size[q]) {\n                parent[p] = rq;\n                size[q] += size[p];\n            } else {\n                parent[q] = rp;\n                size[p] += size[q];\n            }\n            count--;\n        }\n\n        int find_root(int p) {\n            int root = p;\n            while(parent[p] != p) {\n                p = parent[parent[p]]; // log(N)\n            }\n            // update all parents with root value\n            while(p != root) {\n                int tmp = parent[p];\n                parent[p] = root;\n                p = tmp;\n            }\n            return root;\n        }\n\n        bool connected(int p, int q) {\n            return find_root(p) == find_root(q);\n        }\n\n        int count() {\n            return count;\n        }\n    };\n\n\n    // copy and move (lvalue, rvalue)\n    // ref: https://www.cprogramming.com/c++11/rvalue-references-and-move-semantics-in-c++11.html\n    // lvalue: provides a (semi)permanent piece of memory\n    // rvalue: a temporary object\n    // copy (without std::move()) is more time-expensive\n    std::move(lvalue); // return rvalue\n\n    // smart pointers\n    shared_ptr<int> sp; // increment counter when sp1 = sp\n    unique_ptr<int> up; // always do std::move() when up1 = up\n\n    // inline function\n    // compiler will insert the body of the function in that location as opposed to making a function call\n    // only for small functions that are used frequently, not for large functions\n    inline void swap(int & a, int & b) // inline is a compiler directive\n    {\n        // code needs to be recompiled when the function is changed\n        int temp = a;\n        a = b;\n        b = temp;\n    }\n\n    // lambda function\n    // ref: https://lospi.net/c++/developing/software/visual%20studio/2015/03/11/lambdas-and-cpp11.html\n    std::transform(\n        words.begin(), words.end(), \n        result.begin(),\n        [&](int x){ return x + a - b; } // all passed by reference\n        //[=](int x){ return x + a - b; } // all passed by value\n        //[a, &b](int x){ return x + a - b; } // a passed by value, b passed by reference\n    );\n\n    // exception handling\n    // * Common exceptions: http://stdcxx.apache.org/doc/stdlibref/2-3.html\n    try {\n        bitset<5> bs(string(\"01234\")); // \"234\" are invalid\n        // throw invalid_argument( \"Invalid argument!\" );\n    } catch( const invalid_argument& e ) {\n        cerr << \"Invalid Argument: \" << e.what() << endl;\n    }\n}", "meta": {"hexsha": "8e41008b92a25230cfc7ff116ce26654887841bc", "size": 23726, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "_essentials/cpp_essentials.cpp", "max_stars_repo_name": "b1tank/leetcode", "max_stars_repo_head_hexsha": "0b71eb7a4f52291ff072b1280d6b76e68f7adfee", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_essentials/cpp_essentials.cpp", "max_issues_repo_name": "b1tank/leetcode", "max_issues_repo_head_hexsha": "0b71eb7a4f52291ff072b1280d6b76e68f7adfee", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_essentials/cpp_essentials.cpp", "max_forks_repo_name": "b1tank/leetcode", "max_forks_repo_head_hexsha": "0b71eb7a4f52291ff072b1280d6b76e68f7adfee", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.8440251572, "max_line_length": 141, "alphanum_fraction": 0.5179549861, "num_tokens": 6448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828338040285596, "lm_q2_score": 0.11920291419948607, "lm_q1q2_score": 0.05820480189919666}}
{"text": "/** lexical_cast_nonfinite_facets.cpp\n*\n* Copyright (c) 2011 Paul A. Bristow\n*\n* Distributed under the Boost Software License, Version 1.0.\n* (See accompanying file LICENSE_1_0.txt\n* or copy at http://www.boost.org/LICENSE_1_0.txt)\n*\n* This very simple program illustrates how to use the\n* `boost/math/nonfinite_num_facets.hpp' with lexical cast\n* to obtain C99 representation of infinity and NaN.\n* This example is from the original Floating Point  Utilities contribution by Johan Rade.\n* Floating Point Utility library has been accepted into Boost,\n* but the utilities are incorporated into Boost.Math library.\n*\n\\file\n\n\\brief A very simple example of using lexical cast with\nnon_finite_num facet for C99 standard output of infinity and NaN.\n\n\\detail This example shows how to create a C99 non-finite locale,\nand imbue input and output streams with the non_finite_num put and get facets.\nThis allows lexical_cast output and input of infinity and NaN in a Standard portable way,\nThis permits 'loop-back' of output back into input (and portably across different system too).\n\n*/\n\n#include <boost/math/special_functions/nonfinite_num_facets.hpp>\nusing boost::math::nonfinite_num_get;\nusing boost::math::nonfinite_num_put;\n\n#include <boost/lexical_cast.hpp>\nusing boost::lexical_cast;\n\n#include <iostream>\nusing std::cout;\nusing std::endl;\nusing std::cerr;\n\n#include <iomanip>\nusing std::setw;\nusing std::left;\nusing std::right;\nusing std::internal;\n\n#include <string>\nusing std::string;\n\n#include <sstream>\nusing std::istringstream;\n\n#include <limits>\nusing std::numeric_limits;\n\n#include <locale>\nusing std::locale;\n\n#include <boost/assert.hpp>\n\nint main ()\n{\n  std::cout << \"lexical_cast example (NOT using finite_num_facet).\" << std::endl;\n\n  if((std::numeric_limits<double>::has_infinity == false) || (std::numeric_limits<double>::infinity() == 0))\n  {\n    std::cout << \"Infinity not supported on this platform.\" << std::endl;\n    return 0;\n  }\n\n  if((std::numeric_limits<double>::has_quiet_NaN == false) || (std::numeric_limits<double>::quiet_NaN() == 0))\n  {\n    std::cout << \"NaN not supported on this platform.\" << std::endl;\n    return 0;\n  }\n\n  // Some tests that are expected to fail on some platforms.\n  // (But these tests are expected to pass using non_finite num_put and num_get facets).\n\n  // Use the current 'native' default locale.\n  std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale.\n\n  // Create plus and minus infinity.\n  double plus_infinity = +std::numeric_limits<double>::infinity();\n  double minus_infinity = -std::numeric_limits<double>::infinity();\n\n  // and create a NaN (NotANumber).\n  double NaN = +std::numeric_limits<double>::quiet_NaN ();\n\n  // Output the nonfinite values using the current (default C) locale.\n  // The default representations differ from system to system,\n  // for example, using Microsoft compilers, 1.#INF, -1.#INF, and 1.#QNAN.\n  cout << \"Using default locale\" << endl;\n  cout << \"+std::numeric_limits<double>::infinity() = \" << plus_infinity << endl;\n  cout << \"-std::numeric_limits<double>::infinity() = \" << minus_infinity << endl;\n  cout << \"+std::numeric_limits<double>::quiet_NaN () = \" << NaN << endl;\n\n  // Checks below are expected to fail on some platforms!\n\n  // Now try some 'round-tripping', 'reading' \"inf\"\n  double x = boost::lexical_cast<double>(\"inf\");\n  // and check we get a floating-point infinity.\n  BOOST_ASSERT(x == std::numeric_limits<double>::infinity());\n\n  // Check we can convert the other way from floating-point infinity,\n  string s = boost::lexical_cast<string>(numeric_limits<double>::infinity());\n  // to a C99 string representation as \"inf\".\n  BOOST_ASSERT(s == \"inf\");\n\n  // Finally try full 'round-tripping' (in both directions):\n  BOOST_ASSERT(lexical_cast<double>(lexical_cast<string>(numeric_limits<double>::infinity()))\n    == numeric_limits<double>::infinity());\n  BOOST_ASSERT(lexical_cast<string>(lexical_cast<double>(\"inf\")) == \"inf\");\n\n  return 0;\n} // int main()\n\n/*\n\nOutput:\n\nfrom MSVC 10, fails (as expected)\n\n  lexical_cast_native.vcxproj -> J:\\Cpp\\fp_facet\\fp_facet\\Debug\\lexical_cast_native.exe\n  lexical_cast example (NOT using finite_num_facet).\n  Using default locale\n  +std::numeric_limits<double>::infinity() = 1.#INF\n  -std::numeric_limits<double>::infinity() = -1.#INF\n  +std::numeric_limits<double>::quiet_NaN () = 1.#QNAN\nC:\\Program Files\\MSBuild\\Microsoft.Cpp\\v4.0\\Microsoft.CppCommon.targets(183,5): error MSB3073: The command \"\"J:\\Cpp\\fp_facet\\fp_facet\\Debug\\lexical_cast_native.exe\"\nC:\\Program Files\\MSBuild\\Microsoft.Cpp\\v4.0\\Microsoft.CppCommon.targets(183,5): error MSB3073: :VCEnd\" exited with code 3.\n\n\n*/\n", "meta": {"hexsha": "a39a0983a67a5b649fca76292519557b1a0ce0ef", "size": 4672, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/external/boost/boost_1_68_0/libs/math/example/lexical_cast_native.cpp", "max_stars_repo_name": "Bpowers4/turicreate", "max_stars_repo_head_hexsha": "73dad213cc1c4f74337b905baea2b3a1e5a0266c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11356.0, "max_stars_repo_stars_event_min_datetime": "2017-12-08T19:42:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T16:55:25.000Z", "max_issues_repo_path": "src/external/boost/boost_1_68_0/libs/math/example/lexical_cast_native.cpp", "max_issues_repo_name": "Bpowers4/turicreate", "max_issues_repo_head_hexsha": "73dad213cc1c4f74337b905baea2b3a1e5a0266c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2402.0, "max_issues_repo_issues_event_min_datetime": "2017-12-08T22:31:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T19:25:52.000Z", "max_forks_repo_path": "src/external/boost/boost_1_68_0/libs/math/example/lexical_cast_native.cpp", "max_forks_repo_name": "Bpowers4/turicreate", "max_forks_repo_head_hexsha": "73dad213cc1c4f74337b905baea2b3a1e5a0266c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1343.0, "max_forks_repo_forks_event_min_datetime": "2017-12-08T19:47:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T11:31:36.000Z", "avg_line_length": 34.8656716418, "max_line_length": 164, "alphanum_fraction": 0.7258133562, "num_tokens": 1174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44939263446475963, "lm_q2_score": 0.1294027265554491, "lm_q1q2_score": 0.05815263219367618}}
{"text": "/**\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Tests for the MeshHDF5Source Class\n */\n\n#define BOOST_TEST_MODULE MeshHDF5Source\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n\n#include <stdexcept>\n#include <string>\n\n#include \"MeshHDF5Source.h\"\n#include \"EuclideanPoint.h\"\n#include \"EuclideanVector.h\"\n\nusing namespace cupcfd::geometry::mesh;\n\nnamespace utf = boost::unit_test;\n\n// Setup\nBOOST_AUTO_TEST_CASE(setup)\n{\n    int argc = boost::unit_test::framework::master_test_suite().argc;\n    char ** argv = boost::unit_test::framework::master_test_suite().argv;\n\n    MPI_Init(&argc, &argv);\n}\n\n// === Constructors ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(constructor_test1)\n{\n\n}\n\n// === getAttribute int ===\n\n// === getAttribute float ===\n\n// === getAttribute double ===\n\n// === getCellLabels ===\nBOOST_AUTO_TEST_CASE(getCellLabels)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint indices[4] = {0, 1, 2, 3};\n\n\tint cellLabels[4];\n\tint cellLabelsCmp[4] = {1, 2, 3, 4};\n\n\tstatus = file.getCellLabels(cellLabels, 4, indices, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cellLabels, cellLabels + 4, cellLabelsCmp, cellLabelsCmp + 4);\n}\n\n// === getFaceLabels ===\n\n// === getVertexLabels ===\n\n// === getBoundaryLabels ===\n\n// === getRegionLabels ===\n\n// === getFaceArea ===\n\n// === getFaceNVertices ===\nBOOST_AUTO_TEST_CASE(getFaceNVertices_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};\n\n\tint nFaceVertices[15];\n\tint nFaceVerticesCmp[15] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4};\n\n\tstatus = file.getFaceNVertices(nFaceVertices, 15, faceLabels, 15);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(nFaceVertices, nFaceVertices + 15, nFaceVerticesCmp, nFaceVerticesCmp + 15);\n}\n\n// === getFaceVerticesLabelsCSR ===\n// Test 1: Partial Read 1\nBOOST_AUTO_TEST_CASE(getFaceVerticesLabelsCSR_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};\n\n\tint csrIndices[16];\n\tint csrData[58];\n\n\tint csrIndicesCmp[16] = {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 39, 43, 46, 50, 54, 58};\n\n\tint csrDataCmp[58] = {1, 5, 14, 11,\n\t\t\t\t\t  1, 2, 6, 5,\n\t\t\t\t\t  1, 2, 12, 11,\n\t\t\t\t\t  5, 6, 15, 14,\n\t\t\t\t\t  11, 12, 15, 14,\n\t\t\t\t\t  2, 3, 7, 6,\n\t\t\t\t\t  2, 3, 13, 12,\n\t\t\t\t\t  12, 13, 16, 15,\n\t\t\t\t\t  3, 4, 8, 7,\n\t\t\t\t\t  3, 4, 13,\n\t\t\t\t\t  4, 8, 16, 13,\n\t\t\t\t\t  7, 8, 16,\n\t\t\t\t\t  7, 10, 18, 16,\n\t\t\t\t\t  9, 10, 18, 17,\n\t\t\t\t\t  6, 9, 17, 15\n\t};\n\n\tstatus = file.getFaceVerticesLabelsCSR(csrIndices, 16, csrData, 58, faceLabels, 15);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(csrIndices, csrIndices + 16, csrIndicesCmp, csrIndicesCmp + 16);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(csrData, csrData + 58, csrDataCmp, csrDataCmp + 58);\n}\n\n// Test 2: Partial Read 2\nBOOST_AUTO_TEST_CASE(getFaceVerticesLabelsCSR_test2)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[12] = {15, 1, 2, 4, 5, 6, 8, 10, 11, 13, 14, 7};\n\n\tint csrIndices[13];\n\tint csrData[47];\n\n\tint csrIndicesCmp[16] = {0, 4, 8, 12, 16, 20, 24, 28, 31, 35, 39, 43, 47};\n\n\tint csrDataCmp[47] = { 6, 9, 17, 15,\n\t\t\t\t\t  1, 5, 14, 11,\n\t\t\t\t\t  1, 2, 6, 5,\n\t\t\t\t\t  5, 6, 15, 14,\n\t\t\t\t\t  11, 12, 15, 14,\n\t\t\t\t\t  2, 3, 7, 6,\n\t\t\t\t\t  12, 13, 16, 15,\n\t\t\t\t\t  3, 4, 13,\n\t\t\t\t\t  4, 8, 16, 13,\n\t\t\t\t\t  7, 10, 18, 16,\n\t\t\t\t\t  9, 10, 18, 17,\n\t\t\t\t\t  2, 3, 13, 12\n\t};\n\n\tstatus = file.getFaceVerticesLabelsCSR(csrIndices, 13, csrData, 48, faceLabels, 12);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(csrIndices, csrIndices + 13, csrIndicesCmp, csrIndicesCmp + 13);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(csrData, csrData + 47, csrDataCmp, csrDataCmp + 47);\n}\n\n// === getBoundaryVerticesLabelsCSR ===\n// Partial Read 1\nBOOST_AUTO_TEST_CASE(getBoundaryVerticesLabelsCSR_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint boundaryLabels[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};\n\n\tint csrIndices[16];\n\tint csrData[58];\n\n\tint csrIndicesCmp[16] = {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 39, 43, 47, 50, 54, 58};\n\n\tint csrDataCmp[58] = {1, 5, 14, 11,\n\t\t\t\t\t  1, 2, 6, 5,\n\t\t\t\t\t  1, 2, 12, 11,\n\t\t\t\t\t  5, 6, 15, 14,\n\t\t\t\t\t  11, 12, 15, 14,\n\t\t\t\t\t  2, 3, 7, 6,\n\t\t\t\t\t  2, 3, 13, 12,\n\t\t\t\t\t  12, 13, 16, 15,\n\t\t\t\t\t  3, 4, 8, 7,\n\t\t\t\t\t  3, 4, 13,\n\t\t\t\t\t  4, 8, 16, 13,\n\t\t\t\t\t  7, 10, 18, 16,\n\t\t\t\t\t  7, 8, 16,\n\t\t\t\t\t  9, 10, 18, 17,\n\t\t\t\t\t  15, 16, 18, 17\n\t};\n\n\tstatus = file.getBoundaryVerticesLabelsCSR(csrIndices, 16, csrData, 58, boundaryLabels, 15);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(csrIndices, csrIndices + 16, csrIndicesCmp, csrIndicesCmp + 16);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(csrData, csrData + 58, csrDataCmp, csrDataCmp + 58);\n}\n\n// === getCellCount ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getCellCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint cells;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getCellCount(&cells);\n\tBOOST_CHECK_EQUAL(cells, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getFaceCount ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getFaceCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint faces;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getFaceCount(&faces);\n\tBOOST_CHECK_EQUAL(faces, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getBoundaryCount ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getBoundaryCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint boundaries;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getBoundaryCount(&boundaries);\n\tBOOST_CHECK_EQUAL(boundaries, 17);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getRegionCount ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getRegionCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint regions;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getRegionCount(&regions);\n\tBOOST_CHECK_EQUAL(regions, 1);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getVertexCount ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getVertexCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint vertices;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getVertexCount(&vertices);\n\tBOOST_CHECK_EQUAL(vertices, 18);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getMaxFaceCount ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getMaxFaceCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint maxFaceCount;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getMaxFaceCount(&maxFaceCount);\n\tBOOST_CHECK_EQUAL(maxFaceCount, 6);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getMaxVertexCount ===\nBOOST_AUTO_TEST_CASE(getMaxVertexCount_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tint maxVertexCount;\n\tcupcfd::error::eCodes status;\n\n\tstatus = file.getMaxVertexCount(&maxVertexCount);\n\tBOOST_CHECK_EQUAL(maxVertexCount, 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getCellNFaces ===\nBOOST_AUTO_TEST_CASE(getCellNFaces_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\t// Cell Labels - Indexed from base of 1 for this format\n\tint nLabels[3] = {1,3,4};\n\n\tint nFaces[3];\n\tint nFacesCmp[3] = {6, 5, 6};\n\n\tstatus = file.getCellNFaces(nFaces, 3, nLabels, 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(nFaces, nFaces + 3, nFacesCmp, nFacesCmp + 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getCellVolume ===\nBOOST_AUTO_TEST_CASE(getCellVolume_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint nLabels[3] = {1,3,4};\n\n\tdouble vol[3];\n\tint nVol = 3;\n\tdouble volCmp[4] = {1.0, 3.0, 4.0};\n\n\tstatus = file.getCellVolume(vol, nVol, nLabels, 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(vol, vol + 4, volCmp, volCmp + 4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getCellCenter ===\nBOOST_AUTO_TEST_CASE(getCellCenter_test1)\n{\n\n}\n\n// === getCellFaceLabels ===\nBOOST_AUTO_TEST_CASE(getCellFaceLabels_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint cellLabels[3] = {1, 3, 4};\n\n\tint faceLabelsInd[4];\n\tint faceLabelsIndCmp[4] = {0, 6, 11, 17};\n\n\tint faceLabelsData[17];\n\tint faceLabelsDataCmp[17] = {1, 2, 3, 4, 5, 18, 9, 10, 11, 12, 19, 13, 14, 15, 16, 17, 20};\n\n\tstatus = file.getCellFaceLabels(faceLabelsInd, 4, faceLabelsData, 17, cellLabels, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(faceLabelsInd, faceLabelsInd + 4, faceLabelsIndCmp, faceLabelsIndCmp + 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(faceLabelsData, faceLabelsData + 17, faceLabelsDataCmp, faceLabelsDataCmp + 17);\n}\n\n// === getFaceIsBoundary ===\nBOOST_AUTO_TEST_CASE(getFaceIsBoundary_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};\n\tbool isBoundary[20];\n\tbool isBoundaryCmp[20] = {true, true, true, true, true, true, true, true, true, true,\n\t\t\t\t\t\t\t true, true, true, true, true, true, true, false, false, false};\n\n\tstatus = file.getFaceIsBoundary(isBoundary, 20, faceLabels, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(isBoundary, isBoundary + 20, isBoundaryCmp, isBoundaryCmp + 20);\n}\n\n// === getFaceBoundaryLabels ===\n// Test 1: Get Correct Boundary Labels for all valid faces\nBOOST_AUTO_TEST_CASE(getFaceBoundaryLabels_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[17] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};\n\n\tint boundaryLabels[17];\n\tint boundaryLabelsCmp[17] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 12, 14, 17, 16, 15};\n\n\tstatus = file.getFaceBoundaryLabels(boundaryLabels, 17, faceLabels, 17);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(boundaryLabels, boundaryLabels + 17, boundaryLabelsCmp, boundaryLabelsCmp + 17);\n}\n\n// Test 2: Error: One or more faces are not boundary faces\nBOOST_AUTO_TEST_CASE(getFaceBoundaryLabels_test2)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};\n\tint boundaryLabels[20];\n\n\tstatus = file.getFaceBoundaryLabels(boundaryLabels, 20, faceLabels, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_ERROR);\n}\n\n// === getFaceCell1Labels ===\nBOOST_AUTO_TEST_CASE(getFaceCell1Labels_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};\n\tint cellLabels[20];\n\tint cellLabelsCmp[20] = {1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 1, 2, 2};\n\n\tstatus = file.getFaceCell1Labels(cellLabels, 20, faceLabels, 20);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cellLabels, cellLabels + 20, cellLabelsCmp, cellLabelsCmp + 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getFaceCell2Labels ===\nBOOST_AUTO_TEST_CASE(getFaceCell2Labels_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tint faceLabels[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};\n\tint cellLabels[20];\n\tint cellLabelsCmp[20] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4};\n\n\tstatus = file.getFaceCell2Labels(cellLabels, 20, faceLabels, 20);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cellLabels, cellLabels + 20, cellLabelsCmp, cellLabelsCmp + 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// === getFaceLambda ===\nBOOST_AUTO_TEST_CASE(getFaceLambda2_test1)\n{\n\t/*\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tdouble faceLambda[20];\n\tdouble faceLambdaCmp[20] = {12.0, 3.2, 0.53, 634.0, -431.3, 23.351, 54.6352, 4246.2,\n\t\t\t\t\t\t\t 421.4, 2.53, 351.4, 23.0, 41.0, 0.0, 426.2, 42111.5, 2462.2,\n\t\t\t\t\t\t\t 14.3, 15.0, -252.2};\n\n\tstatus = file.getFaceLambda(faceLambda, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\t// Allow some leeway for floating point tolerance\n\t\tBOOST_TEST(faceLambda[i] == faceLambdaCmp[i]);\n\t}\n\t*/\n}\n\n// === getFaceNormal ===\nBOOST_AUTO_TEST_CASE(getFaceNormal_test1)\n{\n\t/*\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> normal[20];\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> normalCmp[20];\n\tdouble normalCmpX[20] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0};\n\tdouble normalCmpY[20] = {100.0, 101.0, 102.0, 103.0, 104.0, 105.5, 106.0, 107.0, 108.0, 109.0, 110.0, 111.0, 112.3, 113.0, 114.0, 115.0, 116.0, 117.0, 118.0, 119.0};\n\tdouble normalCmpZ[20] = {200.8, 201.0, 202.0, 203.0, 204.5, 205.0, 206.0, 207.0, 208.0, 209.0, 210.0, 211.1, 212.0, 213.0, 214.0, 215.0, 216.0, 217.0, 218.9, 219.0};\n\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\tnormalCmp[i] = cupcfd::geometry::euclidean::EuclideanVector<double,3>(normalCmpX[i], normalCmpY[i], normalCmpZ[i]);\n\t}\n\n\tstatus = file.getFaceNormal(normal, 20);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\t// Boost does not handle comparing EuclieanPoints in it's macro\n\t\tBOOST_TEST(normal[i].cmp[0] == normalCmp[i].cmp[0]);\n\t\tBOOST_TEST(normal[i].cmp[1] == normalCmp[i].cmp[1]);\n\t\tBOOST_TEST(normal[i].cmp[2] == normalCmp[i].cmp[2]);\n\t}\n\t*/\n}\n\n// === getFaceCenter ===\nBOOST_AUTO_TEST_CASE(getFaceCenter_test1)\n{\n\n}\n\n// === getVertexCoords ===\nBOOST_AUTO_TEST_CASE(getVertexCoords_test1)\n{\n\n}\n\n// === getBoundaryFaceLabels ===\nBOOST_AUTO_TEST_CASE(getBoundaryFaceLabels_test1)\n{\n\n}\n\n// === getBoundaryNVertices ===\nBOOST_AUTO_TEST_CASE(getBoundaryNVertices_test1)\n{\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\tstd::string filePath = \"../tests/geometry/mesh/data/MeshHDF5.hdf5\";\n\tMeshHDF5Source<int, double> file(filePath);\n\tcupcfd::error::eCodes status;\n\n\t// Note: Face 13 - > Boundary 12 and Face 12 -> Boundary 13.\n\t// This is to test that it is boundary labels being used to do lookup rather\n\t// than face labels since this will give values in different order\n\tint boundaryLabels[17] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};\n\n\tint nVertices[17];\n\tint nVerticesCmp[17] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 3, 4, 4, 4, 4};\n\n\tstatus = file.getBoundaryNVertices(nVertices, 15, boundaryLabels, 15);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(nVertices, nVertices + 15, nVerticesCmp, nVerticesCmp + 15);\n}\n\n// === getBoundaryRegionLabels ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getBoundaryRegionLabels_test1)\n{\n\n}\n\n// === getBoundaryDistance ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getBoundaryDistance_test1)\n{\n\n}\n\n// === getRegionName ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getRegionName_test1)\n{\n\n}\n\n\n// === buildDistributedAdjacencyList1 ===\n// Test: Build a arbitrary graph based on manually assigned cells\nBOOST_AUTO_TEST_CASE(buildDistributedAdjacencyList1_test1)\n{\n\n}\n\n// === buildDistributedAdjacencyList2 ===\n// Test: Build a graph that has a naive cell allocation\nBOOST_AUTO_TEST_CASE(buildDistributedAdjacencyList2_test1)\n{\n\n}\n\nBOOST_AUTO_TEST_CASE(cleanup)\n{\n    MPI_Finalize();\n}\n", "meta": {"hexsha": "91c675123bfe862043b9a365499e4d4fae53b952", "size": 18172, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/geometry/mesh/implementation/source/MeshHDF5SourceTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/geometry/mesh/implementation/source/MeshHDF5SourceTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/geometry/mesh/implementation/source/MeshHDF5SourceTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 29.0752, "max_line_length": 166, "alphanum_fraction": 0.6926590359, "num_tokens": 6431, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4493926197162523, "lm_q2_score": 0.1294027265554491, "lm_q1q2_score": 0.05815263028517911}}
{"text": "//==============================================================================\n//         Copyright 2003 - 2012   LASMEA UMR 6602 CNRS/Univ. Clermont II\n//         Copyright 2009 - 2012   LRI    UMR 8623 CNRS/Univ Paris Sud XI\n//\n//          Distributed under the Boost Software License, Version 1.0.\n//                 See accompanying file LICENSE.txt or copy at\n//                     http://www.boost.org/LICENSE_1_0.txt\n//==============================================================================\n#define NT2_UNIT_MODULE \"nt2 complex.arithmetic toolbox - arg/simd Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// unit test behavior of boost.simd.arithmetic components in simd mode\n//////////////////////////////////////////////////////////////////////////////\n/// created by jt the 28/11/2010\n///\n\n#include <nt2/include/functions/unary_minus.hpp>\n#include <nt2/include/functions/splat.hpp>\n#include <boost/simd/include/native.hpp>\n#include <nt2/sdk/functor/meta/call.hpp>\n#include <nt2/sdk/meta/scalar_of.hpp>\n#include <nt2/include/constants/inf.hpp>\n#include <nt2/include/constants/minf.hpp>\n#include <nt2/include/constants/nan.hpp>\n#include <nt2/include/constants/one.hpp>\n#include <nt2/include/constants/mone.hpp>\n#include <nt2/include/constants/zero.hpp>\n#include <nt2/sdk/complex/complex.hpp>\n#include <nt2/sdk/complex/dry.hpp>\n#include <nt2/sdk/complex/imaginary.hpp>\n#include <nt2/sdk/complex/meta/as_imaginary.hpp>\n#include <nt2/sdk/complex/meta/as_dry.hpp>\n\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/unit/tests/relation.hpp>\n\nNT2_TEST_CASE_TPL ( abs_cplx__1_0,  BOOST_SIMD_SIMD_REAL_TYPES)\n{\n  using boost::simd::native;\n  typedef NT2_SIMD_DEFAULT_EXTENSION  ext_t;\n  typedef std::complex<T>                              cT;\n  typedef native<T ,ext_t>                             vT;\n  typedef native<cT ,ext_t>                           vcT;\n  typedef typename nt2::meta::as_imaginary<T>::type   ciT;\n  typedef native<ciT ,ext_t>                         vciT;\n  typedef typename nt2::meta::as_dry<T>::type          dT;\n  typedef native<dT ,ext_t>                           vdT;\n\n  // specific values tests\n  {\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::splat<vcT>(cT(T(1.1),T(1.6))))[0], cT(T(-1.1),T(-1.6)));\n  }\n  {\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Inf<vcT>())[0], nt2::Minf<vcT>()[0]);\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Minf<vcT>())[0], nt2::Inf<vcT>()[0]);\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Mone<vcT>())[0], nt2::One<vcT>()[0]);\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Nan<vcT>())[0], nt2::Nan<vcT>()[0]);\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::One<vcT>())[0], nt2::Mone<vcT>()[0]);\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Zero<vcT>())[0], nt2::Zero<vcT>()[0]);\n  }\n  {\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::splat<vciT>(ciT(T(-1.1))))[0], ciT(T( 1.1)) );\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::splat<vciT>(ciT(T(1.1))))[0],ciT(T(-1.1)));\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Inf<vciT>())[0], nt2::Minf<ciT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Minf<vciT>())[0],nt2::Inf<ciT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Mone<vciT>())[0],nt2::One<ciT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Nan<vciT>())[0], nt2::Nan<ciT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::One<vciT>())[0], nt2::Mone<ciT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Zero<vciT>())[0], nt2::Zero<ciT>());\n  }\n  {\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::splat<vdT>(dT(T(-1.1))))[0], dT(T(1.1)));\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::splat<vdT>(dT(T(1.1))))[0],  dT(T(-1.1)));\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Inf<vdT>())[0], nt2::Minf<dT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Minf<vdT>())[0], nt2::Inf<dT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Mone<vdT>())[0], nt2::One<dT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Nan<vdT>())[0], nt2::Nan<dT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::One<vdT>())[0], nt2::Mone<dT>());\n    NT2_TEST_EQUAL(nt2::unary_minus(nt2::Zero<vdT>())[0], nt2::Zero<dT>());\n  }\n} // end of test for floating_\n", "meta": {"hexsha": "e552187098167445e3657bf43960751f9de24248", "size": 4063, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/type/complex/operator/unit/simd/unary_minus.cpp", "max_stars_repo_name": "pbrunet/nt2", "max_stars_repo_head_hexsha": "2aeca0f6a315725b335efd5d9dc95d72e10a7fb7", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modules/type/complex/operator/unit/simd/unary_minus.cpp", "max_issues_repo_name": "pbrunet/nt2", "max_issues_repo_head_hexsha": "2aeca0f6a315725b335efd5d9dc95d72e10a7fb7", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/type/complex/operator/unit/simd/unary_minus.cpp", "max_forks_repo_name": "pbrunet/nt2", "max_forks_repo_head_hexsha": "2aeca0f6a315725b335efd5d9dc95d72e10a7fb7", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.5487804878, "max_line_length": 97, "alphanum_fraction": 0.5906965297, "num_tokens": 1299, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.11596072130911701, "lm_q1q2_score": 0.057980360654558506}}
{"text": "/*!\r\n\t@brief Tests the Array class\r\n */\r\n\r\n#include \"StdAfx.h\"\r\n#include \"Array.h\"\r\n\r\n#include <boost/test/unit_test.hpp>\r\n\r\n#ifdef UNIT_TEST\r\n\r\nBOOST_AUTO_TEST_SUITE( ArrayTests )\r\n\r\n\t/** @test begin() method of class Array.\r\n\t */\r\n\tBOOST_AUTO_TEST_CASE( begin )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a ;\r\n\t\tBOOST_CHECK_EQUAL ( a.begin() , a.end() ) ; \r\n\t\ta.resize( 10 ) ;\r\n\t\tstd::fill(a.begin(), a.end(), 0) ;\r\n\t\ta(0) = 5 ;\r\n\t\ta(1) = 25 ;\r\n\t\tBOOST_CHECK ( a.begin() != a.end() ) ;\r\n\r\n\t\tarray_type::iterator pos = a.begin() ;\r\n\t\tBOOST_CHECK_EQUAL( 5 , *pos ) ; \r\n\r\n\t\tarray_type::const_iterator cpos = a.begin() ;\r\n\r\n\t\tstd::advance( cpos, 1 ) ;\r\n\t\tBOOST_CHECK_EQUAL( cpos , ++pos ) ;\r\n\t\tBOOST_CHECK_EQUAL( *cpos , *pos ) ;\r\n\t\tBOOST_CHECK_EQUAL( 25, *cpos) ;\r\n\r\n\t\tcpos = a.begin() ;\r\n\t\tstd::advance( cpos, a.size() ) ;\r\n\t\tBOOST_CHECK_EQUAL( cpos , a.end() ) ;\r\n\r\n\t}\r\n\r\n\t/** @test end() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( end )\r\n\t{\r\n\t\ttypedef Array< double > array_type ;\r\n\r\n\t\tarray_type a ;\r\n\t\tBOOST_CHECK_EQUAL ( a.begin() , a.end() ) ; \r\n\t\ta.resize( 10 ) ;\r\n\t\ta.init(0.0) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.begin() + 10 , a.end() ) ;\r\n\r\n\t\ta(8) = 5.f ;\r\n\t\ta(9) = 4.f ;\r\n\r\n\t\tarray_type::iterator pos = a.end() ;\r\n\t\t--pos ;\r\n\t\tBOOST_CHECK( FLOAT_EQ( *pos, a[9] ) ) ;\r\n\t\t--pos ;\r\n\t\tBOOST_CHECK( FLOAT_EQ( *pos, a[8] )) ;\r\n\t\t*pos = 25.f ;\r\n\t\tBOOST_CHECK( FLOAT_EQ( 25.f, a[8] ) ) ;\r\n\r\n\t\tarray_type::const_iterator cpos = a.end() ;\r\n\r\n\t\t--cpos ;\r\n\t\tBOOST_CHECK( FLOAT_EQ( *cpos, a[9] ) ) ;\r\n\t\t--cpos ;\r\n\t\tBOOST_CHECK( FLOAT_EQ( *cpos, a[8] )) ;\r\n\t\t*pos = 25.f ;\r\n\t\tcpos = pos ;\r\n\t\tBOOST_CHECK( FLOAT_EQ( 25.f, *cpos ) ) ;\r\n\t }\r\n\r\n\r\n\t/** @test size() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( size )\r\n\t{\r\n\t\tArray< double > a ;\r\n\t\tBOOST_CHECK_EQUAL ( a.size() , 0u ) ; \r\n\t\ta.resize( 5 ) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.size() , 5u ) ;\r\n\t}\r\n\r\n\t/** @test max_size() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( max_size )\r\n\t{\r\n\t\tArray< double > a ;\r\n\t\tBOOST_CHECK_EQUAL ( a.max_size() , 0u ) ; \r\n\t\ta.resize( 10 ) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.max_size() , 10u ) ; \r\n\t\ta.resize( 5 ) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.max_size() , 10u ) ; \r\n\t}\r\n\r\n\t/** @test clear() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( clear )\r\n\t{\r\n\t\tArray< double > a ;\r\n\r\n\t\ta.resize( 10 ) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.size() , 10u ) ; \r\n\t\tBOOST_CHECK_EQUAL ( a.max_size() , 10u ) ; \r\n\r\n\t\ta.clear( ) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.size() , 0u ) ; \r\n\t\tBOOST_CHECK_EQUAL ( a.max_size() , 0u ) ; \r\n\t\tBOOST_CHECK_EQUAL ( a.empty() , true ) ;\r\n\t\tBOOST_CHECK_EQUAL ( a.begin() , a.end() ) ; \r\n\t}\r\n\r\n\t/** @test resize() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( resize )\r\n\t{\r\n\t\tArray< long > a(10) ;\r\n\r\n\t\tstd::fill(a.begin(), a.end(), 5) ;\r\n\t\ta.resize( 5 ) ;\r\n\t\tBOOST_CHECK_EQUAL( 5, (int)a.size()) ; \r\n\t\tBOOST_CHECK_EQUAL( 10, (int)a.max_size()) ; \r\n\t\tBOOST_CHECK_EQUAL( a[3] , 5 ) ; \r\n\t\r\n\t\ta.resize( 20 ) ;\r\n\t\tBOOST_CHECK_EQUAL( 20, (int)a.size()) ; \r\n\t\tBOOST_CHECK_EQUAL( 20, (int)a.max_size()) ; \r\n\t\tBOOST_CHECK_EQUAL( a[0] , 5 ) ; \r\n\r\n\t}\r\n\r\n\t/** @test ParensOperator of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( ParensOperator )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a ;\r\n\r\n\t\tBOOST_CHECK_EQUAL( 0u, a.max_size()) ;\r\n\t\ta.resize( 10 ) ;\r\n\r\n\t\ta(0) = 3 ;\r\n\t\tBOOST_CHECK_EQUAL( a(0) , 3 ) ;\r\n\r\n\t\ta(1) = 10 ;\r\n\t\tBOOST_CHECK_EQUAL( a(1) , 10 ) ;\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( ParensOperator_throws_on_oob )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a ;\r\n\r\n\t\tBOOST_CHECK_EQUAL( 0u, a.max_size()) ;\r\n\r\n\t\ttry\r\n\t\t{\r\n\t\t\ta(2) = 4 ;\r\n\t\t\tBOOST_FAIL( \"Should have thrown when referencing out of bounds index\" ) ;\r\n\t\t}\r\n\t\tcatch( std::out_of_range& )\r\n\t\t{\r\n\t\t\tBOOST_CHECK_EQUAL( 0u, a.max_size()) ;\r\n\t\t}\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( BracketOperator_throws_on_oob )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a ;\r\n\r\n\t\tBOOST_CHECK_EQUAL( 0u, a.max_size()) ;\r\n\t\ta.resize( 2 ) ;\r\n\r\n\t\ttry\r\n\t\t{\r\n\t\t\tconst short i = a[2] ;\r\n\t\t\ti ;\r\n\t\t\tBOOST_FAIL( \"Should have thrown when referencing out of bounds index\" ) ;\r\n\t\t}\r\n\t\tcatch( std::out_of_range& )\r\n\t\t{\r\n\t\t\tBOOST_CHECK_EQUAL( 2u, a.max_size()) ;\r\n\t\t}\r\n\t}\r\n\r\n\t/** @test init() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( init )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a ;\r\n\r\n\t\ta.resize( 15 ) ;\r\n\t\ta.init(35) ;\r\n\r\n\t\tFOREACH(short i, a)\r\n\t\t{\r\n\t\t\tBOOST_CHECK_EQUAL(35, i) ;\r\n\t\t}\r\n\t}\r\n\r\n\t/** @test OperatorEqual method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( OperatorEqual )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type array1, array2 ;\r\n\r\n\t\tarray1.resize( 15 ) ;\r\n\t\tarray1.init(35) ;\r\n\r\n\t\tarray2 = array1 ;\r\n\r\n\t\tBOOST_CHECK_EQUAL( array1.size() , array2.size() ) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.max_size() , array2.max_size() ) ;\r\n\r\n\t\tfor ( size_t i = 0u ; i < array1.size() ; ++i )\r\n\t\t{\r\n\t\t\tBOOST_CHECK_EQUAL( array2[i] , array1[i] ) ;\r\n\t\t}\r\n\t\tBOOST_CHECK( array1.val_identity(array2) ) ;\r\n\t}\r\n\r\n\t/** @test implementation of black-box test for clone. */\r\n\tBOOST_AUTO_TEST_CASE( clone )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a, b ;\r\n\r\n\t\ta.resize( 15 ) ;\r\n\t\ta.init(35) ;\r\n\r\n\t\ta.clone( b ) ;\r\n\r\n\t\tBOOST_CHECK(a.val_identity(b)) ;\r\n\t}\r\n\r\n\r\n\t/** @test implementation of black-box test for val_identity. */\r\n\tBOOST_AUTO_TEST_CASE( val_identity )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type array1, array2 ;\r\n\r\n\t\tarray1.resize( 15 ) ;\r\n\t\tarray1.init(35) ;\r\n\r\n\t\tarray2 = array1 ;\r\n\r\n\t\tBOOST_CHECK_EQUAL( (int)array1.size() , (int)array2.size() ) ;\r\n\t\tBOOST_CHECK_EQUAL( (int)array1.max_size() , (int)array2.max_size() ) ;\r\n\r\n\t\tBOOST_CHECK( array1.val_identity(array2) ) ;\r\n\t\tBOOST_CHECK( array2.val_identity(array1) ) ;\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( val_identity_self )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a(5) ;\r\n\r\n\t\ta.init(3) ;\r\n\r\n\t\tBOOST_CHECK(a.val_identity(a)) ;\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( val_identity_false_val )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a(5), b(5) ;\r\n\r\n\t\ta.init(3) ;\r\n\t\tb.init(4) ;\r\n\r\n\t\tBOOST_CHECK(! a.val_identity(b)) ;\r\n\t\tBOOST_CHECK(! b.val_identity(a)) ;\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( val_identity_false_size )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a(5), b(7) ;\r\n\r\n\t\ta.init(0) ;\r\n\t\tb.init(0) ;\r\n\r\n\t\tBOOST_CHECK(! a.val_identity(b)) ;\r\n\t\tBOOST_CHECK(! b.val_identity(a)) ;\r\n\t}\r\n\r\n\r\n\t/** @test swap() method of class Array.\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( swap )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type a, b ;\r\n\r\n\t\ta.resize(5) ;\r\n\t\ta.init(10) ;\r\n\r\n\t\tb.swap(a) ;\r\n\r\n\t\tBOOST_CHECK_EQUAL(0u, a.size()) ;\r\n\t\tBOOST_CHECK_EQUAL(5, (int)b.size()) ;\r\n\r\n\t\tBOOST_CHECK_EQUAL(0u, a.max_size()) ;\r\n\t\tBOOST_CHECK_EQUAL(5, (int)b.max_size()) ;\r\n\r\n\t\tFOREACH(short i, b)\r\n\t\t{\r\n\t\t\tBOOST_CHECK_EQUAL(10, i) ;\r\n\t\t}\r\n\t}\r\n\r\n\t/** @test implementation of black-box test for Array.\r\n\tno requirement for number of elements to be greater than 0.\t\r\n\t*/\r\n\tBOOST_AUTO_TEST_CASE( Constructor )\r\n\t{\r\n\t\ttypedef Array< short > array_type ;\r\n\t\tarray_type array1(10) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.size() , 10u ) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.max_size() , 10u ) ;\r\n\r\n\t\tarray1.init(10) ;\r\n\r\n\t\tarray_type array2( array1 ) ;\r\n\t\tBOOST_CHECK( array1.val_identity(array2) ) ;\r\n\t\tBOOST_CHECK( array2.val_identity(array1) ) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.size() , array2.size() ) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.max_size() , array2.max_size() ) ;\r\n\r\n\t\tarray1.resize(5) ;\r\n\r\n\t\tarray_type array3( array1 ) ;\r\n\t\tBOOST_CHECK( array1.val_identity(array3) ) ;\r\n\t\tBOOST_CHECK( array3.val_identity(array1) ) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.size() , array3.size() ) ;\r\n\t\tBOOST_CHECK_EQUAL( array1.max_size() , array3.max_size() ) ;\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( assignment_to_self )\r\n\t{\r\n\t\ttypedef Array< int > array_type ;\r\n\t\tarray_type a(5) ;\r\n\t\ta.init(10) ;\r\n\r\n\t\ta = a ;\r\n\t\tFOREACH(int i, a)\r\n\t\t{\r\n\t\t\tBOOST_CHECK_EQUAL(10, i) ;\r\n\t\t}\r\n\t}\r\n\tBOOST_AUTO_TEST_CASE( assignment_to_other)\r\n\t{\r\n\t\ttypedef Array< int > array_type ;\r\n\t\tarray_type a ;\r\n\t\tarray_type b(10) ;\r\n\t\tb.init(10) ;\r\n\r\n\t\ta = b ;\r\n\t\tBOOST_CHECK(b.val_identity(a)) ;\r\n\t}\r\nBOOST_AUTO_TEST_SUITE_END()\r\n\r\n#endif\r\n", "meta": {"hexsha": "7f09941a250f29cf19de7c1404d2372f2987a8f1", "size": 8047, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "common/array_test.cpp", "max_stars_repo_name": "ultimatezen/felix", "max_stars_repo_head_hexsha": "5a7ad298ca4dcd5f1def05c60ae3c84519ec54c4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "common/array_test.cpp", "max_issues_repo_name": "ultimatezen/felix", "max_issues_repo_head_hexsha": "5a7ad298ca4dcd5f1def05c60ae3c84519ec54c4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "common/array_test.cpp", "max_forks_repo_name": "ultimatezen/felix", "max_forks_repo_head_hexsha": "5a7ad298ca4dcd5f1def05c60ae3c84519ec54c4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9264305177, "max_line_length": 77, "alphanum_fraction": 0.6003479558, "num_tokens": 2488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4186969238628498, "lm_q2_score": 0.13846179056896438, "lm_q1q2_score": 0.05797352578376753}}
{"text": "\n//          Copyright Maksym V. Bilinets 2015 - 2019.\n// Distributed under the Boost Software License, Version 1.0.\n//      (See accompanying file LICENSE.txt or copy at\n//          http://www.boost.org/LICENSE_1_0.txt )\n\n#include <dst/binary_tree/algorithm.h>\n#include <dst/binary_tree/tree.h>\n\n#include <boost/test/unit_test.hpp>\n\nnamespace\n{\n// $      |    $\n// $      0    $\n// $    /   \\  $\n// $   1     2 $\n// $  / \\   /  $\n// $ 3   4 5   $\nconst dst::binary_tree::initializer_tree<int>\n  init_tree({{3, 1, 4}, 0, {5, 2, {}}});\n\nconst dst::binary_tree::tree<int> tree(init_tree);\n}\n\nBOOST_AUTO_TEST_SUITE(test_binary_tree_algorithm)\n\nBOOST_AUTO_TEST_CASE(test_leaf)\n{\n  BOOST_TEST(!leaf(init_tree.root()));\n  BOOST_TEST(!leaf(right(init_tree.root())));\n  BOOST_TEST(leaf(left(right(init_tree.root()))));\n}\n\nBOOST_AUTO_TEST_CASE(test_maximum)\n{\n  BOOST_TEST(*maximum(init_tree.root()) == 2);\n}\n\nBOOST_AUTO_TEST_CASE(test_minimum)\n{\n  BOOST_TEST(*minimum(init_tree.root()) == 3);\n}\n\nBOOST_AUTO_TEST_CASE(test_parent)\n{\n  BOOST_TEST(*parent(left(tree.root())) == 0);\n  BOOST_TEST(*parent(right(tree.root())) == 0);\n  BOOST_TEST(!parent(tree.root()));\n}\n\nBOOST_AUTO_TEST_CASE(test_roll_down_left)\n{\n  BOOST_TEST(*roll_down_left(init_tree.root()) == 3);\n}\n\nBOOST_AUTO_TEST_CASE(test_roll_down_right)\n{\n  BOOST_TEST(*roll_down_right(init_tree.root()) == 5);\n}\n\nBOOST_AUTO_TEST_CASE(test_root)\n{\n  for (auto it = tree.begin(); it != tree.end(); ++it)\n  {\n    BOOST_TEST((root(it.base()) == tree.root()));\n  }\n}\n\nBOOST_AUTO_TEST_CASE(test_sibling)\n{\n  BOOST_TEST(*sibling(left(tree.root())) == 2);\n  BOOST_TEST(*sibling(right(tree.root())) == 1);\n  BOOST_TEST(!sibling(left(right(tree.root()))));\n}\n\nBOOST_AUTO_TEST_CASE(test_topologically_equal)\n{\n  // $      |    $\n  // $      0    $\n  // $    /   \\  $\n  // $   1     2 $\n  // $  / \\   /  $\n  // $ 3   4 5   $\n  dst::binary_tree::initializer_tree<int> a({{3, 1, 4}, 0, {5, 2, {}}});\n\n  BOOST_TEST(topologically_equal(init_tree.root(), a.root()));\n\n  // $    |      $\n  // $    4      $\n  // $  /   \\    $\n  // $ 3     5   $\n  // $  \\   / \\  $\n  // $   1 0   2 $\n  dst::binary_tree::initializer_tree<int> b({{{}, 3, 1}, 4, {0, 5, 2}});\n\n  BOOST_TEST(!topologically_equal(init_tree.root(), b.root()));\n\n  // $   | $\n  // $   4 $\n  // $  /  $\n  // $ 3   $\n  // $  \\  $\n  // $   1 $\n  dst::binary_tree::initializer_tree<int> c({{{}, 3, 1}, 4, {}});\n\n  BOOST_TEST(!topologically_equal(init_tree.root(), c.root()));\n\n  // $ | $\n  dst::binary_tree::initializer_tree<int> d;\n\n  BOOST_TEST(!topologically_equal(init_tree.root(), d.root()));\n\n  // $ | $\n  dst::binary_tree::initializer_tree<int> e;\n\n  BOOST_TEST(topologically_equal(d.root(), e.root()));\n}\n\nBOOST_AUTO_TEST_CASE(test_successor)\n{\n  auto it = left(left(tree.root()));\n\n  BOOST_TEST(*it == 3);\n\n  it = successor(it);\n\n  BOOST_TEST(*it == 1);\n\n  it = successor(it);\n\n  BOOST_TEST(*it == 4);\n\n  it = successor(it);\n\n  BOOST_TEST(*it == 0);\n\n  it = successor(it);\n\n  BOOST_TEST(*it == 5);\n\n  it = successor(it);\n\n  BOOST_TEST(*it == 2);\n\n  BOOST_TEST(!successor(it));\n}\n\nBOOST_AUTO_TEST_CASE(test_predecessor)\n{\n  auto it = right(tree.root());\n\n  BOOST_TEST(*it == 2);\n\n  it = predecessor(it);\n\n  BOOST_TEST(*it == 5);\n\n  it = predecessor(it);\n\n  BOOST_TEST(*it == 0);\n\n  it = predecessor(it);\n\n  BOOST_TEST(*it == 4);\n\n  it = predecessor(it);\n\n  BOOST_TEST(*it == 1);\n\n  it = predecessor(it);\n\n  BOOST_TEST(*it == 3);\n\n  BOOST_TEST(!predecessor(it));\n}\n\nBOOST_AUTO_TEST_CASE(test_order)\n{\n  const auto it_0 = tree.root();\n  const auto it_1 = left(it_0);\n  const auto it_2 = right(it_0);\n  const auto it_3 = left(it_1);\n  const auto it_4 = right(it_1);\n  const auto it_5 = left(it_2);\n\n  BOOST_TEST(order(it_4, it_5));\n  BOOST_TEST(order(it_5, it_4) == false);\n\n  BOOST_TEST(order(it_3, it_4));\n  BOOST_TEST(order(it_4, it_3) == false);\n\n  BOOST_TEST(order(it_3, it_0));\n  BOOST_TEST(order(it_0, it_3) == false);\n\n  BOOST_TEST(order(it_5, it_5) == false);\n}\n\nBOOST_AUTO_TEST_CASE(test_inorder_depth_first_search)\n{\n  std::vector<int> sequence(begin_inorder_depth_first_search(tree.root()),\n                            end_inorder_depth_first_search(tree.nil()));\n\n  BOOST_TEST(sequence == std::vector<int>({3, 1, 4, 0, 5, 2}),\n             boost::test_tools::per_element());\n}\n\nBOOST_AUTO_TEST_CASE(test_postorder_depth_first_search)\n{\n  std::vector<int> sequence(begin_postorder_depth_first_search(tree.root()),\n                            end_postorder_depth_first_search(tree.nil()));\n\n  BOOST_TEST(sequence == std::vector<int>({3, 4, 1, 5, 2, 0}),\n             boost::test_tools::per_element());\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "96b416783b1c768e19fcbc23d7f59b46fddb074c", "size": 4635, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/binary_tree/test_algorithm.cpp", "max_stars_repo_name": "bi-ts/dst", "max_stars_repo_head_hexsha": "d68d4cfb7509a2f65c8120d88cbc198874343f30", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/binary_tree/test_algorithm.cpp", "max_issues_repo_name": "bi-ts/dst", "max_issues_repo_head_hexsha": "d68d4cfb7509a2f65c8120d88cbc198874343f30", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/binary_tree/test_algorithm.cpp", "max_forks_repo_name": "bi-ts/dst", "max_forks_repo_head_hexsha": "d68d4cfb7509a2f65c8120d88cbc198874343f30", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-09-03T10:48:56.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-03T10:48:56.000Z", "avg_line_length": 21.2614678899, "max_line_length": 76, "alphanum_fraction": 0.6105717368, "num_tokens": 1379, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.1225232237324595, "lm_q1q2_score": 0.05791470336060208}}
{"text": "#include \"quadrature/calculators/spherical_harmonic_zeroth_moment.h\"\n\n#include <memory>\n\n#include <deal.II/base/mpi.h>\n#include <deal.II/lac/petsc_vector.h>\n\n#include \"system/system_types.h\"\n#include \"system/moments/spherical_harmonic_types.h\"\n#include \"quadrature/utility/quadrature_utilities.h\"\n#include \"quadrature/tests/quadrature_set_mock.hpp\"\n#include \"quadrature/tests/quadrature_point_mock.hpp\"\n#include \"system/solution/tests/mpi_group_angular_solution_mock.h\"\n#include \"test_helpers/gmock_wrapper.h\"\n\nnamespace {\n\nusing namespace bart;\n\nusing ::testing::Ref, ::testing::Return, ::testing::ReturnRef;\n\nvoid SetVector(system::MPIVector& to_set, double value) {\n  auto [first_row, last_row] = to_set.local_range();\n  for (unsigned int i = first_row; i < last_row; ++i)\n    to_set[i] = value;\n  to_set.compress(dealii::VectorOperation::insert);\n}\n\n/* Tests for the SphericalHarmonicMomentsZerothMoment class. Mock quadrature set\n * is required.\n *\n * Test initial conditions: test object is constructed with mock quadrature set,\n * observation pointer is provided to set call expectations. Three mpi vectors\n * are provided with values 1, 10, and 100.\n */\ntemplate <typename DimensionWrapper>\nclass QuadCalcSphericalHarmonicMomentsOnlyScalar : public ::testing::Test {\n protected:\n  static constexpr int dim = DimensionWrapper::value;\n  // Aliases\n  using QuadratureSetType = quadrature::QuadratureSetMock<dim>;\n  using MomentCalculatorType = quadrature::calculators::SphericalHarmonicZerothMoment<dim>;\n\n  // Pointer to tested object\n  std::unique_ptr<MomentCalculatorType> test_calculator;\n\n  // Supporting objects\n  system::solution::MPIGroupAngularSolutionMock mock_solution_;\n  std::array<system::MPIVector, 3> mpi_vectors_;\n\n  // Test object dependency\n  std::shared_ptr<QuadratureSetType> mock_quadrature_set_ptr_;\n\n  // Observing pointers\n  QuadratureSetType* quadrature_set_obs_ptr_;\n\n  // Test parameters\n  const int n_processes = dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);\n  const int n_entries_per_proc = 10;\n\n  void SetUp() override;\n};\n\ntemplate <typename DimensionWrapper>\nvoid QuadCalcSphericalHarmonicMomentsOnlyScalar<DimensionWrapper>::SetUp() {\n\n  // Instantiate mock objects\n  mock_quadrature_set_ptr_ = std::make_shared<QuadratureSetType>();\n\n  // Instantiate object to be tested\n  test_calculator = std::make_unique<MomentCalculatorType>(\n      mock_quadrature_set_ptr_);\n\n  // Set up observation pointers\n  quadrature_set_obs_ptr_ = dynamic_cast<QuadratureSetType*>(\n      test_calculator->quadrature_set_ptr());\n\n  for (auto& mpi_vector : mpi_vectors_) {\n    mpi_vector.reinit(MPI_COMM_WORLD,\n                      n_processes * n_entries_per_proc,\n                      n_entries_per_proc);\n  }\n\n  SetVector(mpi_vectors_[0], 1);\n  SetVector(mpi_vectors_[1], 10);\n  SetVector(mpi_vectors_[2], 100);\n}\n\nTYPED_TEST_CASE(QuadCalcSphericalHarmonicMomentsOnlyScalar,\n                bart::testing::AllDimensions);\n\n// Constructor should have set quadrature_set_ptr properly.\nTYPED_TEST(QuadCalcSphericalHarmonicMomentsOnlyScalar, Constructor) {\n\n  auto quadrature_set_ptr = this->test_calculator->quadrature_set_ptr();\n  ASSERT_NE(nullptr, quadrature_set_ptr);\n}\n\n/* An error should be thrown if there is a mismatch between the total angles\n * reported by the solution and the size of the quadrature set */\nTYPED_TEST(QuadCalcSphericalHarmonicMomentsOnlyScalar, CalculateBadAngleNumber) {\n  auto& quadrature_set_mock = *this->quadrature_set_obs_ptr_;\n  auto& test_calculator = this->test_calculator;\n  auto mock_solution_ptr = &this->mock_solution_;\n\n  EXPECT_CALL(quadrature_set_mock, size())\n      .WillOnce(Return(4));\n  EXPECT_CALL(*mock_solution_ptr, total_angles())\n      .WillOnce(Return(3));\n  EXPECT_ANY_THROW(test_calculator->CalculateMoment(mock_solution_ptr, 0, 0, 0));\n}\n\n/* Moments should be calculated properly.\n *\n * To accomplish this test we will fill a set with mock points with weights\n * given by 2.2 + i*1.1 where i is an index value. These index values will\n * identify one of the mpi_vectors provided by the test, which are equal to 1,\n * 10, and 100, sequentiall. Therefore we expect the final moment to be equal to\n * 2.2 + 3.3*10 + 4.4*100\n */\nTYPED_TEST(QuadCalcSphericalHarmonicMomentsOnlyScalar, CalculateMomentsMPI) {\n  auto& quadrature_set_mock = *this->quadrature_set_obs_ptr_;\n  auto& test_calculator = this->test_calculator;\n  auto mock_solution_ptr = &this->mock_solution_;\n  constexpr int dim = this->dim;\n\n  const int n_angles = 3;\n  const int group = 0;\n\n  EXPECT_CALL(quadrature_set_mock, size())\n      .WillOnce(Return(n_angles));\n  EXPECT_CALL(*mock_solution_ptr, total_angles())\n      .WillOnce(Return(n_angles));\n\n  std::set<std::shared_ptr<quadrature::QuadraturePointI<dim>>,\n           quadrature::utility::quadrature_point_compare<dim>>\n      mock_quadrature_point_set;\n\n  for (int angle = 0; angle < n_angles; ++angle) {\n    // Solutions are identified by angle index, so we expect a request for\n    // the solution for each angle to be called.\n    EXPECT_CALL(*mock_solution_ptr, GetSolution(angle))\n        .WillOnce(ReturnRef(this->mpi_vectors_[angle]));\n\n    // We make our mock quadrature point and set the weight and position\n    auto mock_quadrature_point =\n        std::make_shared<::testing::NiceMock<quadrature::QuadraturePointMock<dim>>>();\n    EXPECT_CALL(*mock_quadrature_point, weight())\n        .WillOnce(Return(2.2 + angle*1.1));\n    // Position is only added for ordering in the set, value doesn't matter as\n    // long as each processor orders them equally (by position)\n    std::array<double, dim> position;\n    position.fill(angle*1.1);\n    ON_CALL(*mock_quadrature_point, cartesian_position())\n        .WillByDefault(Return(position));\n\n    // Insert into our mock set, get an insert pair that includes an interator\n    // to the newly inserted object\n    auto insert_pair = mock_quadrature_point_set.insert(mock_quadrature_point);\n\n    // We expect the function to retrieve the index of the point. This is what\n    // links THIS point to the correct solution.\n    EXPECT_CALL(quadrature_set_mock,\n        GetQuadraturePointIndex(*insert_pair.first))\n        .WillOnce(Return(angle));\n  }\n\n  EXPECT_CALL(quadrature_set_mock, begin())\n      .WillOnce(Return(mock_quadrature_point_set.begin()));\n  EXPECT_CALL(quadrature_set_mock, end())\n      .WillOnce(Return(mock_quadrature_point_set.end()));\n\n  system::moments::MomentVector expected_result(\n      this->n_entries_per_proc*this->n_processes);\n\n  expected_result = 4.4*100 + 3.3*10 + 2.2;\n\n  auto result = test_calculator->CalculateMoment(mock_solution_ptr, group, 0, 0);\n  ASSERT_NE(result.size(), 0); // Make sure it isn't empty\n  EXPECT_EQ(result, expected_result);\n}\n\n\n} // namespace\n", "meta": {"hexsha": "f5aa57e730b0159600a2ae308172e6913932937e", "size": 6748, "ext": "cc", "lang": "C++", "max_stars_repo_path": "src/quadrature/calculators/tests/spherical_harmonic_zeroth_moment_test.cc", "max_stars_repo_name": "SlaybaughLab/Transport", "max_stars_repo_head_hexsha": "8eb32cb8ae50c92875526a7540350ef9a85bc050", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12.0, "max_stars_repo_stars_event_min_datetime": "2018-03-14T12:30:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T14:46:44.000Z", "max_issues_repo_path": "src/quadrature/calculators/tests/spherical_harmonic_zeroth_moment_test.cc", "max_issues_repo_name": "SlaybaughLab/Transport", "max_issues_repo_head_hexsha": "8eb32cb8ae50c92875526a7540350ef9a85bc050", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 194.0, "max_issues_repo_issues_event_min_datetime": "2017-07-07T01:38:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-19T18:21:19.000Z", "max_forks_repo_path": "src/quadrature/calculators/tests/spherical_harmonic_zeroth_moment_test.cc", "max_forks_repo_name": "SlaybaughLab/Transport", "max_forks_repo_head_hexsha": "8eb32cb8ae50c92875526a7540350ef9a85bc050", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2017-07-06T22:58:59.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-15T07:01:21.000Z", "avg_line_length": 36.4756756757, "max_line_length": 91, "alphanum_fraction": 0.7495554238, "num_tokens": 1691, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.45326184801538616, "lm_q2_score": 0.12765262532179067, "lm_q1q2_score": 0.05786006485737052}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Unit Tests for the concrete methods of the CupCfdAoSMesh class\n */\n\n#define BOOST_TEST_MODULE CupCfdAoSMesh\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n#include <stdexcept>\n#include <string>\n\n#include \"CupCfdAoSMesh.h\"\n#include \"Error.h\"\n#include \"EuclideanPoint.h\"\n#include \"EuclideanVector.h\"\n\n#include \"EuclideanPoint.h\"\n#include \"PartitionerConfig.h\"\n#include \"PartitionerNaiveConfig.h\"\n#include \"MeshSourceStructGenConfig.h\"\n#include \"MeshConfig.h\"\n\nusing namespace cupcfd::geometry::mesh;\nnamespace utf = boost::unit_test;\nnamespace euc = cupcfd::geometry::euclidean;\n\n// Setup\nBOOST_AUTO_TEST_CASE(setup)\n{\n    int argc = boost::unit_test::framework::master_test_suite().argc;\n    char ** argv = boost::unit_test::framework::master_test_suite().argv;\n\n    MPI_Init(&argc, &argv);\n}\n\n// ToDo: A lot of these tests check the internals (which is OK for now), but really should be\n// more akin to black-box tests\n\n// ToDo: Unit Tests for getters and setters\n\n// === Constructors ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(constructor_test1)\n{\n\n}\n\n// === addVertex + Vertex getters + Vertex Setters ===\n// Test 1: Add Vertex and retrieve correct points\nBOOST_AUTO_TEST_CASE(addVertex_test1)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Vertices\n\tint vertLabel[18] = {180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10};\n\tdouble vertX[18] = {0.0, 0.5, 1.0, 1.5, 0.0, 0.5, 1.0, 1.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 1.0};\n\tdouble vertY[18] = {0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0};\n\tdouble vertZ[18] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};\n\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Test getters functions without error codes\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tint localID = mesh.getVertexID(vertLabel[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point = mesh.getVertexPos(localID);\n\t\tBOOST_CHECK_EQUAL(point.cmp[0], vertX[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[1], vertY[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[2], vertZ[i]);\n\t}\n\n\t// Test getter functions with error codes\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tint localID;\n\t\tmesh.getVertexID(vertLabel[i], &localID);\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point;\n\t\tmesh.getVertexPos(localID, point);\n\t\tBOOST_CHECK_EQUAL(point.cmp[0], vertX[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[1], vertY[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[2], vertZ[i]);\n\t}\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 18);\n}\n\n// Test 2: Test overwriting values\nBOOST_AUTO_TEST_CASE(addVertex_test2)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Vertices\n\tint vertLabel[18] = {180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10};\n\tdouble vertX[18] = {0.0, 0.5, 1.0, 1.5, 0.0, 0.5, 1.0, 1.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 1.0};\n\tdouble vertY[18] = {0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0};\n\tdouble vertZ[18] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};\n\n\tdouble vertXNew[18] = {10.0, 10.5, 11.0, 11.5, 10.0, 10.5, 11.0, 11.5, 10.5, 11.0, 10.0, 10.5, 11.0, 10.0, 10.5, 11.0, 10.5, 11.0};\n\tdouble vertYNew[18] = {10.0, 10.0, 10.0, 10.0, 10.5, 10.5, 10.5, 10.5, 11.0, 11.0, 10.0, 10.0, 10.0, 10.5, 10.5, 10.5, 11.0, 11.0};\n\tdouble vertZNew[18] = {10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5};\n\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tint localID = mesh.getVertexID(vertLabel[i]);\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point = mesh.getVertexPos(localID);\n\t\tBOOST_CHECK_EQUAL(point.cmp[0], vertX[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[1], vertY[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[2], vertZ[i]);\n\t}\n\n\t// Overwrite values\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tint localID = mesh.getVertexID(vertLabel[i]);\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertXNew[i], vertYNew[i], vertZNew[i]);\n\t\tmesh.setVertexPos(localID, point);\n\t}\n\n\t// Test values correct\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tint localID = mesh.getVertexID(vertLabel[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point = mesh.getVertexPos(localID);\n\t\tBOOST_CHECK_EQUAL(point.cmp[0], vertXNew[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[1], vertYNew[i]);\n\t\tBOOST_CHECK_EQUAL(point.cmp[2], vertZNew[i]);\n\t}\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 18);\n}\n\n// Test 3: Error Check: Add a vertex label that already exists on this rank\nBOOST_AUTO_TEST_CASE(addVertex_test3)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Vertices\n\tint vertLabel[18] = {180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 200};\n\tdouble vertX[18] = {0.0, 0.5, 1.0, 1.5, 0.0, 0.5, 1.0, 1.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 1.0};\n\tdouble vertY[18] = {0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0};\n\tdouble vertZ[18] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[0], vertY[0], vertZ[0]);\n\tstatus = mesh.addVertex(vertLabel[0], point);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tfor(int i = 1; i < 17; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_EXISTING_VERTEX);\n\t}\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point2(vertX[17], vertY[17], vertZ[17]);\n\tstatus = mesh.addVertex(vertLabel[17], point2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 2);\n}\n\n\n// === addRegion + Region getters + Region Setters ===\n// Test 1: Add Region and get correct values\nBOOST_AUTO_TEST_CASE(addRegion_test1)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Regions\n\t// First 7 have set values, last two are default comparisons\n\tint rLabel[9] = {90, 80, 70, 60, 50, 30, 40, 10, 20};\n\tRType rTypes[9] = {RTYPE_DEFAULT, RTYPE_WALL, RTYPE_OUTLET, RTYPE_INLET, RTYPE_OUTLET, RTYPE_DEFAULT, RTYPE_SYMP, RTYPE_DEFAULT, RTYPE_DEFAULT};\n\tstd::string rName[9] = {\"Region1\", \"Region2\", \"Region3\", \"Test4\", \"Name5\", \"Region6\", \"Region7\", \"Default1\", \"Default2\"};\n\tbool std[9] = {true, false, false, false, true, true, false, false, false};\n\tbool flux[9] = {false, false, true, true, false, false, true, false, false};\n\tbool adiab[9] = {false, true, true, true, false, false, false, false, false};\n\tdouble ylog[9] = {0.7, 9.8, 2.6, 6.9, 10.2, 12.8, 5.6, 0.0, 0.0};\n\tdouble elog[9] = {-1.2, 3.5, 10.9, 4.5, 3.5, 1.7, 8.6, 0.0, 0.0};\n\tdouble density[9] = {0.0, 3.6, 2.4, 100.3, 102.3, -6.7, -10.5, 0.0, 0.0};\n\tdouble turbKE[9] = {6.7, 2.4, -1.6, 23.5, 2.5, 2.6, 2.7, 0.0, 0.0};\n\tdouble turbDiss[9] = {1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 0.0, 0.0};\n\tdouble splvl[9] = {8.9, 8.8, 8.7, 8.6, 8.5, 8.4, 8.3, 0.0, 0.0};\n\tdouble den[9] = {10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 0.0, 0.0};\n\tdouble r[9] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 0.0, 0.0};\n\tdouble t[9] = {90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 0.0, 0.0};\n\tdouble forceTanX[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0, 0.0};\n\tdouble forceTanY[9] = {9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 0.0, 0.0};\n\tdouble forceTanZ[9] = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 0.0, 0.0};\n\tdouble uvwX[9] = {9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 0.0, 0.0};\n\tdouble uvwY[9] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 0.0, 0.0};\n\tdouble uvwZ[9] = {9.9, 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 0.0, 0.0};\n\n\t// Add Regions with values\n\tfor(int i = 0; i < 7; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent(forceTanX[i], forceTanY[i], forceTanZ[i]);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw(uvwX[i], uvwY[i], uvwZ[i]);\n\n\t\tstatus = mesh.addRegion(rLabel[i], rTypes[i], std[i], flux[i], adiab[i], ylog[i], elog[i],\n\t\t\t\t\t   density[i], turbKE[i], turbDiss[i], splvl[i], den[i], r[i], t[i],\n\t\t\t\t\t   forceTangent, uvw, rName[i]);\n\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Regions that are defaults\n\tfor(int i = 7; i < 9; i++)\n\t{\n\t\tstatus = mesh.addRegion(rLabel[i], rName[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Test getters without error codes\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tint localID = mesh.getRegionID(rLabel[i]);\n\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionType(localID), rTypes[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionStd(localID), std[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionYLog(localID), ylog[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionELog(localID), elog[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionDensity(localID), density[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionTurbKE(localID), turbKE[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionTurbDiss(localID), turbDiss[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionSplvl(localID), splvl[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionDen(localID), den[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionName(localID), rName[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionFlux(localID), flux[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionAdiab(localID), adiab[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionR(localID), r[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionT(localID), t[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent = mesh.getRegionForceTangent(localID);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw = mesh.getRegionUVW(localID);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[0], forceTanX[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[1], forceTanY[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[2], forceTanZ[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[0], uvwX[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[1], uvwY[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[2], uvwZ[i]);\n\t}\n\n\t// Test getters with error codes\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tint localID = mesh.getRegionID(rLabel[i]);\n\n\t\tbool bTmp;\n\t\tdouble dTmp;\n\t\tRType typeTmp;\n\t\tstd::string sTmp;\n\n\t\tmesh.getRegionType(localID, &typeTmp);\n\t\tBOOST_CHECK_EQUAL(typeTmp, rTypes[i]);\n\n\t\tmesh.getRegionStd(localID, &bTmp);\n\t\tBOOST_CHECK_EQUAL(bTmp, std[i]);\n\n\t\tmesh.getRegionFlux(localID, &bTmp);\n\t\tBOOST_CHECK_EQUAL(bTmp, flux[i]);\n\n\t\tmesh.getRegionAdiab(localID, &bTmp);\n\t\tBOOST_CHECK_EQUAL(bTmp, adiab[i]);\n\n\t\tmesh.getRegionYLog(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, ylog[i]);\n\n\t\tmesh.getRegionELog(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, elog[i]);\n\n\t\tmesh.getRegionDensity(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, density[i]);\n\n\t\tmesh.getRegionTurbKE(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, turbKE[i]);\n\n\t\tmesh.getRegionTurbDiss(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, turbDiss[i]);\n\n\t\tmesh.getRegionSplvl(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, splvl[i]);\n\n\t\tmesh.getRegionDen(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, den[i]);\n\n\t\t//mesh.getRegionName(localID, sTmp);\n\t\t//BOOST_CHECK_EQUAL(dTmp, rName[i]);\n\n\t\tmesh.getRegionR(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, r[i]);\n\n\t\tmesh.getRegionT(localID, &dTmp);\n\t\tBOOST_CHECK_EQUAL(dTmp, t[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent;\n\t\tmesh.getRegionForceTangent(localID, forceTangent);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[0], forceTanX[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[1], forceTanY[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[2], forceTanZ[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw;\n\t\tmesh.getRegionUVW(localID, uvw);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[0], uvwX[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[1], uvwY[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[2], uvwZ[i]);\n\t}\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lRegions, 9);\n}\n\n// Test 2: Test overwriting values\nBOOST_AUTO_TEST_CASE(addRegion_test2)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Regions\n\t// First 7 have set values, last two are default comparisons\n\tint rLabel[9] = {90, 80, 70, 60, 50, 30, 40, 10, 20};\n\tRType rTypes[9] = {RTYPE_DEFAULT, RTYPE_WALL, RTYPE_OUTLET, RTYPE_INLET, RTYPE_OUTLET, RTYPE_DEFAULT, RTYPE_SYMP, RTYPE_DEFAULT, RTYPE_DEFAULT};\n\tstd::string rName[9] = {\"Region1\", \"Region2\", \"Region3\", \"Test4\", \"Name5\", \"Region6\", \"Region7\", \"Default1\", \"Default2\"};\n\tbool std[9] = {true, false, false, false, true, true, false, false, false};\n\tbool flux[9] = {false, false, true, true, false, false, true, false, false};\n\tbool adiab[9] = {false, true, true, true, false, false, false, false, false};\n\tdouble ylog[9] = {0.7, 9.8, 2.6, 6.9, 10.2, 12.8, 5.6, 0.0, 0.0};\n\tdouble elog[9] = {-1.2, 3.5, 10.9, 4.5, 3.5, 1.7, 8.6, 0.0, 0.0};\n\tdouble density[9] = {0.0, 3.6, 2.4, 100.3, 102.3, -6.7, -10.5, 0.0, 0.0};\n\tdouble turbKE[9] = {6.7, 2.4, -1.6, 23.5, 2.5, 2.6, 2.7, 0.0, 0.0};\n\tdouble turbDiss[9] = {1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 0.0, 0.0};\n\tdouble splvl[9] = {8.9, 8.8, 8.7, 8.6, 8.5, 8.4, 8.3, 0.0, 0.0};\n\tdouble den[9] = {10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 0.0, 0.0};\n\tdouble r[9] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 0.0, 0.0};\n\tdouble t[9] = {90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 0.0, 0.0};\n\tdouble forceTanX[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0, 0.0};\n\tdouble forceTanY[9] = {9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 0.0, 0.0};\n\tdouble forceTanZ[9] = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 0.0, 0.0};\n\tdouble uvwX[9] = {9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 0.0, 0.0};\n\tdouble uvwY[9] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 0.0, 0.0};\n\tdouble uvwZ[9] = {9.9, 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 0.0, 0.0};\n\n\tRType rTypesNew[9] = {RTYPE_DEFAULT, RTYPE_WALL, RTYPE_OUTLET, RTYPE_INLET, RTYPE_OUTLET, RTYPE_DEFAULT, RTYPE_SYMP, RTYPE_DEFAULT, RTYPE_DEFAULT};\n\tstd::string rNameNew[9] = {\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\"};\n\tbool stdNew[9] = {false, false, false, false, true, false, false, false, false};\n\tbool fluxNew[9] = {true, true, true, true, false, true, true, true, true};\n\tbool adiabNew[9] = {true, false, true, false, true, false, true, false, true};\n\tdouble ylogNew[9] = {-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0};\n\tdouble elogNew[9] = {-9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0};\n\tdouble densityNew[9] = {0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0};\n\tdouble turbKENew[9] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};\n\tdouble turbDissNew[9] = {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0};\n\tdouble splvlNew[9] = {-1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0};\n\tdouble denNew[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 4.0, 3.0, 2.0, 1.0};\n\tdouble rNew[9] = {5.0, 4.0, 3.0, 2.0, 1.0, 2.0, 3.0, 4.0, 5.0};\n\tdouble tNew[9] = {10.0, 9.0, 8.0, 7.0, 6.0, 7.0, 8.0, 9.0, 10.0};\n\tdouble forceTanXNew[9] = {6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0};\n\tdouble forceTanYNew[9] = {1.2, 1.3, 1.4, 1.4, 1.5, 1.6, 1.6, 1.7, 1.7};\n\tdouble forceTanZNew[9] = {2.0, 3.0, 2.0, 4.0, 2.0, 2.0, 2.0, 2.0, 2.0};\n\tdouble uvwXNew[9] = {9.9, 8.8, 7.7, 6.6, 7.7, 8.8, 9.9, 8.8, 7.7};\n\tdouble uvwYNew[9] = {9.9, 8.8, 7.7, 6.6, 7.7, 8.8, 6.8, 8.8, 7.7};\n\tdouble uvwZNew[9] = {9.9, 8.8, 7.7, 6.6, 7.7, 8.8, 9.9, 7.8, 7.7};\n\n\t// Add Regions with values\n\tfor(int i = 0; i < 7; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent(forceTanX[i], forceTanY[i], forceTanZ[i]);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw(uvwX[i], uvwY[i], uvwZ[i]);\n\n\t\tstatus = mesh.addRegion(rLabel[i], rTypes[i], std[i], flux[i], adiab[i], ylog[i], elog[i],\n\t\t\t\t\t   density[i], turbKE[i], turbDiss[i], splvl[i], den[i], r[i], t[i],\n\t\t\t\t\t   forceTangent, uvw, rName[i]);\n\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Regions that are defaults\n\tfor(int i = 7; i < 9; i++)\n\t{\n\t\tstatus = mesh.addRegion(rLabel[i], rName[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tint localID = mesh.getRegionID(rLabel[i]);\n\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionType(localID), rTypes[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionStd(localID), std[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionYLog(localID), ylog[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionELog(localID), elog[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionDensity(localID), density[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionTurbKE(localID), turbKE[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionTurbDiss(localID), turbDiss[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionSplvl(localID), splvl[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionDen(localID), den[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionName(localID), rName[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionFlux(localID), flux[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionAdiab(localID), adiab[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionR(localID), r[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionT(localID), t[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent = mesh.getRegionForceTangent(localID);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw = mesh.getRegionUVW(localID);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[0], forceTanX[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[1], forceTanY[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[2], forceTanZ[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[0], uvwX[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[1], uvwY[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[2], uvwZ[i]);\n\t}\n\n\t// Overwrite Values\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tint localID = mesh.getRegionID(rLabel[i]);\n\n\t\tmesh.setRegionType(localID, rTypesNew[i]);\n\t\tmesh.setRegionStd(localID, stdNew[i]);\n\t\tmesh.setRegionYLog(localID, ylogNew[i]);\n\t\tmesh.setRegionELog(localID, elogNew[i]);\n\t\tmesh.setRegionDensity(localID, densityNew[i]);\n\t\tmesh.setRegionTurbKE(localID, turbKENew[i]);\n\t\tmesh.setRegionTurbDiss(localID, turbDissNew[i]);\n\t\tmesh.setRegionSplvl(localID, splvlNew[i]);\n\t\tmesh.setRegionDen(localID, denNew[i]);\n\t\tmesh.setRegionName(localID, rNameNew[i]);\n\t\tmesh.setRegionFlux(localID, fluxNew[i]);\n\t\tmesh.setRegionAdiab(localID, adiabNew[i]);\n\t\tmesh.setRegionR(localID, rNew[i]);\n\t\tmesh.setRegionT(localID, tNew[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent(forceTanXNew[i], forceTanYNew[i], forceTanZNew[i]);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw(uvwXNew[i], uvwYNew[i], uvwZNew[i]);\n\n\t\tmesh.setRegionForceTangent(localID, forceTangent);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tmesh.setRegionUVW(localID, uvw);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Check Values Correctly Overwritten\n\tfor(int i = 0; i < 9; i++)\n\t{\n\t\tint localID = mesh.getRegionID(rLabel[i]);\n\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionType(localID), rTypesNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionStd(localID), stdNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionYLog(localID), ylogNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionELog(localID), elogNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionDensity(localID), densityNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionTurbKE(localID), turbKENew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionTurbDiss(localID), turbDissNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionSplvl(localID), splvlNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionDen(localID), denNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionName(localID), rNameNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionFlux(localID), fluxNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionAdiab(localID), adiabNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionR(localID), rNew[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getRegionT(localID), tNew[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent = mesh.getRegionForceTangent(localID);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw = mesh.getRegionUVW(localID);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[0], forceTanXNew[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[1], forceTanYNew[i]);\n\t\tBOOST_CHECK_EQUAL(forceTangent.cmp[2], forceTanZNew[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[0], uvwXNew[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[1], uvwYNew[i]);\n\t\tBOOST_CHECK_EQUAL(uvw.cmp[2], uvwZNew[i]);\n\t}\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lRegions, 9);\n}\n\n// Test 3: Error Check: Add a region label that already exists on this rank\nBOOST_AUTO_TEST_CASE(addRegion_test3)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Regions\n\t// First 7 have set values, last two are default comparisons\n\tint rLabel[9] = {90, 90, 90, 90, 90, 90, 90, 90, 90};\n\tRType rTypes[9] = {RTYPE_DEFAULT, RTYPE_WALL, RTYPE_OUTLET, RTYPE_INLET, RTYPE_OUTLET, RTYPE_DEFAULT, RTYPE_SYMP, RTYPE_DEFAULT, RTYPE_DEFAULT};\n\tstd::string rName[9] = {\"Region1\", \"Region2\", \"Region3\", \"Test4\", \"Name5\", \"Region6\", \"Region7\", \"Default1\", \"Default2\"};\n\tbool std[9] = {true, false, false, false, true, true, false, false, false};\n\tbool flux[9] = {false, false, true, true, false, false, true, false, false};\n\tbool adiab[9] = {false, true, true, true, false, false, false, false, false};\n\tdouble ylog[9] = {0.7, 9.8, 2.6, 6.9, 10.2, 12.8, 5.6, 0.0, 0.0};\n\tdouble elog[9] = {-1.2, 3.5, 10.9, 4.5, 3.5, 1.7, 8.6, 0.0, 0.0};\n\tdouble density[9] = {0.0, 3.6, 2.4, 100.3, 102.3, -6.7, -10.5, 0.0, 0.0};\n\tdouble turbKE[9] = {6.7, 2.4, -1.6, 23.5, 2.5, 2.6, 2.7, 0.0, 0.0};\n\tdouble turbDiss[9] = {1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 0.0, 0.0};\n\tdouble splvl[9] = {8.9, 8.8, 8.7, 8.6, 8.5, 8.4, 8.3, 0.0, 0.0};\n\tdouble den[9] = {10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 0.0, 0.0};\n\tdouble r[9] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 0.0, 0.0};\n\tdouble t[9] = {90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 0.0, 0.0};\n\tdouble forceTanX[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0, 0.0};\n\tdouble forceTanY[9] = {9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 0.0, 0.0};\n\tdouble forceTanZ[9] = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 0.0, 0.0};\n\tdouble uvwX[9] = {9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 0.0, 0.0};\n\tdouble uvwY[9] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 0.0, 0.0};\n\tdouble uvwZ[9] = {9.9, 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 0.0, 0.0};\n\n\t// Add Regions with values\n\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent(forceTanX[0], forceTanY[0], forceTanZ[0]);\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw(uvwX[0], uvwY[0], uvwZ[0]);\n\n\tstatus = mesh.addRegion(rLabel[0], rTypes[0], std[0], flux[0], adiab[0], ylog[0], elog[0],\n\t\t\t\t   density[0], turbKE[0], turbDiss[0], splvl[0], den[0], r[0], t[0],\n\t\t\t\t   forceTangent, uvw, rName[0]);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tfor(int i = 1; i < 9; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> forceTangent(forceTanX[i], forceTanY[i], forceTanZ[i]);\n\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> uvw(uvwX[i], uvwY[i], uvwZ[i]);\n\n\t\tstatus = mesh.addRegion(rLabel[i], rTypes[i], std[i], flux[i], adiab[i], ylog[i], elog[i],\n\t\t\t\t\t   density[i], turbKE[i], turbDiss[i], splvl[i], den[i], r[i], t[i],\n\t\t\t\t\t   forceTangent, uvw, rName[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_EXISTING_REGION);\n\t}\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lRegions, 1);\n}\n\n/*\n// === addBoundary ===\n// Test 1: Add two boundaries\nBOOST_AUTO_TEST_CASE(addBoundary_test1)\n{\n\t// Setup\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tstd::string name;\n\n\t// Add Regions\n\tname = \"Default Region\";\n\tstatus = mesh.addRegion(65, RTYPE_DEFAULT, name);\n\tname = \"Region2\";\n\tstatus = mesh.addRegion(101, RTYPE_SYMP, name);\n\n\t// Add Vertices\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point1(1.0, 2.0, 3.0);\n\tstatus = mesh.addVertex(41, point1);\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point2(2.0, 3.0, 4.0);\n\tstatus = mesh.addVertex(42, point2);\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point3(12.0, 13.0, 14.0);\n\tstatus = mesh.addVertex(15, point3);\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point4(13.0, 14.0, 15.0);\n\tstatus = mesh.addVertex(65, point4);\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point5(14.0, 15.0, 16.0);\n\tstatus = mesh.addVertex(101, point5);\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point6(3.0, 4.0, 5.0);\n\tstatus = mesh.addVertex(43, point6);\n\n\tint vertexIDs1[3] = {41, 43, 42};\n\tint vertexIDs2[4] = {43, 15, 65, 101};\n\n\tstatus = mesh.addBoundary(17, 101, vertexIDs1, 3, 3.7);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].faceID, -1);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].verticesID[0], 0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].verticesID[1], 5);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].verticesID[2], 1);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].verticesID[3], -1);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].regionID, 1);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].distance, 3.7);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].yplus, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].uplus, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].shear.cmp[0], 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].shear.cmp[1], 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].shear.cmp[2], 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].q, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].h, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[0].t, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries.size(), 1);\n\tBOOST_CHECK_EQUAL(mesh.properties.lBoundaries, 1);\n\n\tstatus = mesh.addBoundary(201, 65, vertexIDs2, 4, 2.1);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].faceID, -1);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].verticesID[0], 5);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].verticesID[1], 2);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].verticesID[2], 3);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].verticesID[3], 4);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].regionID, 0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].distance, 2.1);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].yplus, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].uplus, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].shear.cmp[0], 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].shear.cmp[1], 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].shear.cmp[2], 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].q, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].h, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries[1].t, 0.0);\n\tBOOST_CHECK_EQUAL(mesh.boundaries.size(), 2);\n\tBOOST_CHECK_EQUAL(mesh.properties.lBoundaries, 2);\n}\n\n*/\n\n// === addBoundary + boundary getters + boundary setters ===\n// Test 1: Add Boundaries and retrieve correct points\n\n\n// === addCell + cell getters + cell setters ===\n// Test 2: Test overwriting boundary values\n\n// Test 3: Add a boundary with a non-existant region\nBOOST_AUTO_TEST_CASE(addBoundary_test3)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tstd::string name;\n\n\t// Add a Region\n\tname = \"Default Region\";\n\tstatus = mesh.addRegion(65, name);\n\n\t// Add Vertices\n\tdouble vertX[3] = {1.0, 2.0, 3.0};\n\tdouble vertY[3] = {2.0, 3.0, 4.0};\n\tdouble vertZ[3] = {3.0, 4.0, 5.0};\n\tdouble vertLabels[3] = {41, 42, 43};\n\n\tfor(int i = 0; i < 3; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabels[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint vertexIDs1[3] = {41, 43, 42};\n\n\t// Test and Check\n\tstatus = mesh.addBoundary(17, 57, vertexIDs1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_REGION_LABEL);\n}\n\n// Test 4: Add a boundary with a non-existant vertex\nBOOST_AUTO_TEST_CASE(addBoundary_test4)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tstd::string name;\n\n\t// Add a Region\n\tname = \"Default Region\";\n\tstatus = mesh.addRegion(65, name);\n\n\t// Add Vertices\n\tdouble vertX[3] = {1.0, 2.0, 3.0};\n\tdouble vertY[3] = {2.0, 3.0, 4.0};\n\tdouble vertZ[3] = {3.0, 4.0, 5.0};\n\tdouble vertLabels[3] = {41, 42, 43};\n\n\tfor(int i = 0; i < 3; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabels[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// One Vertex ID has not been used during an add\n\tint vertexIDs1[3] = {41, 43, 109};\n\n\t// Test and Check\n\tstatus = mesh.addBoundary(17, 65, vertexIDs1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_VERTEX_LABEL);\n}\n\n// Test 5: Add a boundary with too few vertexes\nBOOST_AUTO_TEST_CASE(addBoundary_test5)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tstd::string name;\n\n\tname = \"Default Region\";\n\tstatus = mesh.addRegion(65, name);\n\n\t// Add Vertices\n\tdouble vertX[3] = {1.0, 2.0, 3.0};\n\tdouble vertY[3] = {2.0, 3.0, 4.0};\n\tdouble vertZ[3] = {3.0, 4.0, 5.0};\n\tdouble vertLabels[3] = {41, 42, 43};\n\n\tfor(int i = 0; i < 3; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabels[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// 2 is insufficient number of vertices\n\tint vertexIDs1[2] = {41, 43};\n\n\t// Test and Check\n\tstatus = mesh.addBoundary(17, 65, vertexIDs1, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_VERTEX_COUNT);\n}\n\n// Test 6: Add a boundary with too many vertices (currently capped at 4)\nBOOST_AUTO_TEST_CASE(addBoundary_test6)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tstd::string name;\n\n\tname = \"Default Region\";\n\tstatus = mesh.addRegion(65, name);\n\n\t// Add Vertices\n\tdouble vertX[5] = {1.0, 2.0, 3.0, 4.0, 5.0};\n\tdouble vertY[5] = {2.0, 3.0, 4.0, 5.0, 6.0};\n\tdouble vertZ[5] = {3.0, 4.0, 5.0, 6.0, 7.0};\n\tdouble vertLabels[5] = {41, 42, 43, 44, 45};\n\n\tfor(int i = 0; i < 3; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabels[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint vertexIDs1[5] = {41, 43, 42, 44, 45};\n\n\t// Test and Check\n\tstatus = mesh.addBoundary(17, 65, vertexIDs1, 5);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_VERTEX_COUNT);\n}\n\n// Test 7: Error Test - Add a boundary that already exists\nBOOST_AUTO_TEST_CASE(addBoundary_test7)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tstd::string name;\n\n\t// Add Regions\n\tname = \"Default Region\";\n\tstatus = mesh.addRegion(65, name);\n\n\t// Add Vertices\n\tdouble vertX[3] = {1.0, 2.0, 3.0};\n\tdouble vertY[3] = {2.0, 3.0, 4.0};\n\tdouble vertZ[3] = {3.0, 4.0, 5.0};\n\tdouble vertLabels[3] = {41, 42, 43};\n\n\tfor(int i = 0; i < 3; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabels[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint vertexIDs1[3] = {41, 43, 42};\n\n\t// Add boundary 1\n\tstatus = mesh.addBoundary(17, 65, vertexIDs1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Reuse boundary label\n\tstatus = mesh.addBoundary(17, 65, vertexIDs1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_EXISTING_BOUNDARY);\n}\n\n// === addCell + cell getters + cell setters ===\n// Test 1: Add Cells and retrieve correct points\nBOOST_AUTO_TEST_CASE(addCell_test1)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm;\n\n\t// Add Cells\n\tdouble cellLabel[5] = {10, 20, 30, 40, 50};\n\tdouble cellVol[5] = {1.0, 2.0, 3.0, 4.0, 0.0};\n\tdouble cellCenterX[5] = {5.0, 10.0, 15.0, 25.0, 0.0};\n\tdouble cellCenterY[5] = {15.0, 110.0, 115.0, 125.0, 0.0};\n\tdouble cellCenterZ[5] = {25.0, 210.0, 215.0, 225.0, 0.0};\n\tdouble cellLocal[5] = {false, false, false, false, false};\n\tdouble cellGhost[5] = {true, true, true, true, true};\n\n\t// Set 1 cell for each rank to be local\n\tcellLocal[comm.rank] = true;\n\tcellGhost[comm.rank] = false;\n\n\t// Rank 1 can have cell 5 (the 'default' cell)\n\tif(comm.rank == 0)\n\t{\n\t\tcellLocal[4] = true;\n\t\tcellGhost[4] = false;\n\t}\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(cellCenterX[i], cellCenterY[i], cellCenterZ[i]);\n\t\tstatus = mesh.addCell(cellLabel[i], center, cellVol[i], cellLocal[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add 'default' cell\n\tstatus = mesh.addCell(cellLabel[4], cellLocal[4]);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test getters functions without error codes\n\tfor(int i = 0; i < 5; i++)\n\t{\n\t\tint localID = mesh.getCellID(cellLabel[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\t\tcenter = mesh.getCellCenter(localID);\n\n\t\tBOOST_CHECK_EQUAL(center.cmp[0], cellCenterX[i]);\n\t\tBOOST_CHECK_EQUAL(center.cmp[1], cellCenterY[i]);\n\t\tBOOST_CHECK_EQUAL(center.cmp[2], cellCenterZ[i]);\n\t\tBOOST_CHECK_EQUAL(mesh.getCellVolume(localID), cellVol[i]);\n\t}\n\n\t// Test getters functions with error codes\n\tfor(int i = 0; i < 5; i++)\n\t{\n\t\tint localID = mesh.getCellID(cellLabel[i]);\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\t\tmesh.getCellCenter(localID, center);\n\t\tBOOST_CHECK_EQUAL(center.cmp[0], cellCenterX[i]);\n\t\tBOOST_CHECK_EQUAL(center.cmp[1], cellCenterY[i]);\n\t\tBOOST_CHECK_EQUAL(center.cmp[2], cellCenterZ[i]);\n\n\t\tdouble tTmp;\n\t\tmesh.getCellVolume(localID, &tTmp);\n\t\tBOOST_CHECK_EQUAL(tTmp, cellVol[i]);\n\n\t\t// Check the ghost/local status of the cells is correct - done by cell label\n\t\tbool local, ghost;\n\n\t\tlocal = mesh.cellConnGraph->existsLocalNode(cellLabel[i]);\n\t\tBOOST_CHECK_EQUAL(local, cellLocal[i]);\n\n\t\tghost = mesh.cellConnGraph->existsGhostNode(cellLabel[i]);\n\t\tBOOST_CHECK_EQUAL(ghost, cellGhost[i]);\n\t}\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tBOOST_CHECK_EQUAL(mesh.properties.lTCells, 5);\n\n\tif(comm.rank == 0)\n\t{\n\t\tBOOST_CHECK_EQUAL(mesh.properties.lOCells, 2);\n\t\tBOOST_CHECK_EQUAL(mesh.properties.lGhCells, 3);\n\t}\n\telse\n\t{\n\t\tBOOST_CHECK_EQUAL(mesh.properties.lOCells, 1);\n\t\tBOOST_CHECK_EQUAL(mesh.properties.lGhCells, 4);\n\t}\n}\n\n// Test 2: Test overwriting values\nBOOST_AUTO_TEST_CASE(addCell_test2)\n{\n\n}\n\n// Test 3: Test adding a duplicate cell label on this rank\nBOOST_AUTO_TEST_CASE(addCell_test3)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Cells\n\tdouble cellLabel[5] = {50, 50, 50, 50, 50};\n\tdouble cellVol[5] = {1.0, 2.0, 3.0, 4.0, 0.0};\n\tdouble cellCenterX[5] = {5.0, 10.0, 15.0, 25.0, 0.0};\n\tdouble cellCenterY[5] = {15.0, 110.0, 115.0, 125.0, 0.0};\n\tdouble cellCenterZ[5] = {25.0, 210.0, 215.0, 225.0, 0.0};\n\tdouble cellLocal[5] = {false, false, false, false, false};\n\tdouble cellGhost[5] = {true, true, true, true, true};\n\n\t// Set 1 cell for each rank to be local\n\tcellLocal[comm.rank] = true;\n\tcellGhost[comm.rank] = false;\n\n\t// Rank 1 can have cell 5 (the 'default' cell)\n\tif(comm.rank == 0)\n\t{\n\t\tcellLocal[4] = true;\n\t\tcellGhost[4] = false;\n\t}\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center1(cellCenterX[0], cellCenterY[0], cellCenterZ[0]);\n\tstatus = mesh.addCell(cellLabel[0], center1, cellVol[0], cellLocal[0]);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tfor(int i = 1; i < 5; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(cellCenterX[i], cellCenterY[i], cellCenterZ[i]);\n\t\tstatus = mesh.addCell(cellLabel[i], center, cellVol[i], cellLocal[i]);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_EXISTING_CELL);\n\t}\n}\n\n// === addFace + face getters + face setters ===\n// Test 1: Add Face and retrieve correct points\nBOOST_AUTO_TEST_CASE(addFace_test1)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Regions\n\tstd::string name = \"Default\";\n\tstatus = mesh.addRegion(0, name);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// ToDo: Strictly speaking, not all vertices and boundaries are needed on all ranks for this test.\n\t// We can whittle them down.\n\n\t// Add Vertices\n\tint vertLabel[18] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90};\n\tdouble vertX[18] = {0.0, 0.5, 1.0, 1.5, 0.0, 0.5, 1.0, 1.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 1.0};\n\tdouble vertY[18] = {0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0};\n\tdouble vertZ[18] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};\n\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Boundaries\n\tint bndLabel[17] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};\n\tint bndVert1[17] = {0,  0, 0,  4,  10, 1, 1,  11, 2, 2,  3,  6,  6,  8,  5,  5, 14};\n\tint bndVert2[17] = {4,  1, 1,  5,  11, 2, 2,  12, 3, 3,  7,  7,  9,  9,  8,  6, 15};\n\tint bndVert3[17] = {10, 4, 10, 13, 13, 5, 11, 14, 6, 12, 12, 15, 15, 16, 14, 8, 16};\n\tint bndVert4[17] = {13, 5, 11, 14, 14, 6, 12, 15, 7, -1, 15, -1, 17, 17, 16, 9, 17};\n\n\tfor(int i = 0; i < 17; i++)\n\t{\n\t\t// Use region 0 for all\n\t\tint vert[4] = {vertLabel[bndVert1[i]], vertLabel[bndVert2[i]], vertLabel[bndVert3[i]], -1};\n\t\tint count = 3;\n\n\t\t// add the 4th vertex if it exists\n\t\tif(bndVert4[i] != - 1)\n\t\t{\n\t\t\tcount = 4;\n\t\t\tvert[3] = vertLabel[bndVert4[i]];\n\t\t}\n\n\t\tstatus = mesh.addBoundary(bndLabel[i], 0, vert, count);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\tint cellLabel[4] = {100, 200, 300, 400};\n\n\t// Add Cells\n\t// Each Rank gets 1 local cell\n\tif(comm.rank == 0)\n\t{\n\t\tstatus = mesh.addCell(cellLabel[0], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tstatus = mesh.addCell(cellLabel[1], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tstatus = mesh.addCell(cellLabel[0], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tstatus = mesh.addCell(cellLabel[1], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tstatus = mesh.addCell(cellLabel[2], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tstatus = mesh.addCell(cellLabel[3], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tstatus = mesh.addCell(cellLabel[2], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tstatus = mesh.addCell(cellLabel[1], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tstatus = mesh.addCell(cellLabel[1], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tstatus = mesh.addCell(cellLabel[3], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Faces\n\t// For convienience, same order as boundaries + 3 non-boundary faces at end\n\t// This means face index = boundary index where applicable\n\tint faceLabel[20] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};\n\tint faceVert1[20] = {0,  0, 0,  4,  10, 1, 1,  11, 2, 2,  3,  6,  6,  8,  5,  5, 14, 1,  2,  5};\n\tint faceVert2[20] = {4,  1, 1,  5,  11, 2, 2,  12, 3, 3,  7,  7,  9,  9,  8,  6, 15, 5,  6,  6};\n\tint faceVert3[20] = {10, 4, 10, 13, 13, 5, 11, 14, 6, 12, 12, 15, 15, 16, 14, 8, 16, 11, 12, 14};\n\tint faceVert4[20] = {13, 5, 11, 14, 14, 6, 12, 15, 7, -1, 15, -1, 17, 17, 16, 9, 17, 14, 15, 15};\n\tint faceNVertices[20] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4};\n\tint faceCell1[20] = {0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 1, 1};\n\tint faceCell2OrBoundary[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3};\n\tint isBoundary[20] = {true, true, true, true, true, true, true, true, true, true, true, true, true,\n\t\t\t\t\t\t  true, true, true, true, false, false, false};\n\n\tint keepFace[20] = {false, false, false, false, false, false, false, false, false, false,\n\t\t\t\t\t\tfalse, false, false, false, false, false, false, false, false, false};\n\n\t// Leave the last face as a default value face\n\tdouble faceLambda[20] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 0.0};\n\tdouble faceRLencos[20] = {20.0, 19.0, 18.0, 17.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 0.0};\n\tdouble faceArea[20] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.0};\n\tdouble faceCenterX[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceCenterY[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 2.87, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceCenterZ[20] = {4.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 7.8, 1.9, 2.0, 2.1, 2.2, 2.3, 4.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceNormX[20] = {1.0, 6.3, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 15.7, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceNormY[20] = {1.0, 1.1, 9.8, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceNormZ[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 10.54, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXnacX[20] = {1.0, 1.1, 1.2, 7.6, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXnacY[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 5.9, 2.8, 0.0};\n\tdouble faceXnacZ[20] = {1.0, 1.1, 1.2, 1.3, 180.9, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXpacX[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 180.7, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXpacY[20] = {1.0, 1.1, 1.2, 1.3, 14.6, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXpacZ[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 17.89, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\n\tif(comm.rank == 0)\n\t{\n\t\tkeepFace[0] = true;\n\t\tkeepFace[1] = true;\n\t\tkeepFace[2] = true;\n\t\tkeepFace[3] = true;\n\t\tkeepFace[4] = true;\n\t\tkeepFace[17] = true;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tkeepFace[5] = true;\n\t\tkeepFace[6] = true;\n\t\tkeepFace[7] = true;\n\t\tkeepFace[17] = true;\n\t\tkeepFace[18] = true;\n\t\tkeepFace[19] = true;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tkeepFace[18] = true;\n\t\tkeepFace[8] = true;\n\t\tkeepFace[9] = true;\n\t\tkeepFace[10] = true;\n\t\tkeepFace[11] = true;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tkeepFace[19] = true;\n\t\tkeepFace[12] = true;\n\t\tkeepFace[13] = true;\n\t\tkeepFace[14] = true;\n\t\tkeepFace[15] = true;\n\t\tkeepFace[16] = true;\n\t}\n\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\tif(keepFace[i] == true)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[faceVert1[i]], vertLabel[faceVert2[i]], vertLabel[faceVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(faceVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[faceVert4[i]];\n\t\t\t}\n\n\t\t\tif(i == 19)\n\t\t\t{\n\t\t\t\t// Default add\n\t\t\t\tif(isBoundary[i])\n\t\t\t\t{\n\t\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(isBoundary[i])\n\t\t\t\t{\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm(faceNormX[i], faceNormY[i], faceNormZ[i]);\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(faceCenterX[i], faceCenterY[i], faceCenterZ[i]);\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xpac(faceXpacX[i], faceXpacY[i], faceXpacZ[i]);\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xnac(faceXnacX[i], faceXnacY[i], faceXnacZ[i]);\n\n\t\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i],\n\t\t\t\t\t\t\t\t\t\t  faceLambda[i], norm, vert, count, center, xpac, xnac, faceRLencos[i], faceArea[i]);\n\t\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm(faceNormX[i], faceNormY[i], faceNormZ[i]);\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(faceCenterX[i], faceCenterY[i], faceCenterZ[i]);\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xpac(faceXpacX[i], faceXpacY[i], faceXpacZ[i]);\n\t\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xnac(faceXnacX[i], faceXnacY[i], faceXnacZ[i]);\n\n\t\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i],\n\t\t\t\t\t\t\t\t\t\t  faceLambda[i], norm, vert, count, center, xpac, xnac, faceRLencos[i], faceArea[i]);\n\t\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Test getters functions without error codes\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\tif(keepFace[i])\n\t\t{\n\t\t\tint localID = mesh.getFaceID(faceLabel[i]);\n\n\t\t\t// (1) Test Face Values\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceLambda(localID), faceLambda[i]);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceRLencos(localID), faceRLencos[i]);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceArea(localID), faceArea[i]);\n\n\t\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm = mesh.getFaceNorm(localID);\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center = mesh.getFaceCenter(localID);\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xpac = mesh.getFaceXpac(localID);\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xnac = mesh.getFaceXnac(localID);\n\t\t\tint nVertices = mesh.getFaceNVertices(localID);\n\n\t\t\tBOOST_CHECK_EQUAL(norm.cmp[0], faceNormX[i]);\n\t\t\tBOOST_CHECK_EQUAL(norm.cmp[1], faceNormY[i]);\n\t\t\tBOOST_CHECK_EQUAL(norm.cmp[2], faceNormZ[i]);\n\n\t\t\tBOOST_CHECK_EQUAL(center.cmp[0], faceCenterX[i]);\n\t\t\tBOOST_CHECK_EQUAL(center.cmp[1], faceCenterY[i]);\n\t\t\tBOOST_CHECK_EQUAL(center.cmp[2], faceCenterZ[i]);\n\n\t\t\tBOOST_CHECK_EQUAL(xpac.cmp[0], faceXpacX[i]);\n\t\t\tBOOST_CHECK_EQUAL(xpac.cmp[1], faceXpacY[i]);\n\t\t\tBOOST_CHECK_EQUAL(xpac.cmp[2], faceXpacZ[i]);\n\n\t\t\tBOOST_CHECK_EQUAL(xnac.cmp[0], faceXnacX[i]);\n\t\t\tBOOST_CHECK_EQUAL(xnac.cmp[1], faceXnacY[i]);\n\t\t\tBOOST_CHECK_EQUAL(xnac.cmp[2], faceXnacZ[i]);\n\n\t\t\tBOOST_CHECK_EQUAL(nVertices, faceNVertices[i]);\n\n\t\t\t// (2) Test Face References - the internal references should be the same as the label->id mapping for a component\n\t\t\t// This will be face->cell1, face->boundary and face->cell2\n\n\t\t\t// Check the stored local cell ID is the same as the local ID for tcupcfd::geometry::euclidean::EuclideanPoint<T,3>(T(0), T(0), T(0));he cell label\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceCell1ID(localID), mesh.getCellID(cellLabel[faceCell1[i]]));\n\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceCell2ID(localID), -1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceBoundaryID(localID), mesh.getBoundaryID(bndLabel[faceCell2OrBoundary[i]]));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceCell2ID(localID), mesh.getCellID(cellLabel[faceCell2OrBoundary[i]]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceBoundaryID(localID), -1);\n\t\t\t}\n\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(localID,0), mesh.getVertexID(vertLabel[faceVert1[i]]));\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(localID,1), mesh.getVertexID(vertLabel[faceVert2[i]]));\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(localID,2), mesh.getVertexID(vertLabel[faceVert3[i]]));\n\n\t\t\tif(faceVert4[i] != -1)\n\t\t\t{\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(localID,3), mesh.getVertexID(vertLabel[faceVert4[i]]));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(localID,3), -1);\n\t\t\t}\n\t\t}\n\t}\n\n\t// ToDo - Test getters functions with error codes\n\n\t// Check Mesh Local Properties are Updated - Global can only be updated at finalize\n\tswitch(comm.rank)\n\t{\n\t\tcase 0:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\t\t\t\tbreak;\n\n\t\tcase 1:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\t\t\t\tbreak;\n\n\t\tcase 2:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 5);\n\t\t\t\tbreak;\n\n\t\tcase 3:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\t\t\t\tbreak;\n\t}\n}\n\n// Test 2: Test overwriting values\nBOOST_AUTO_TEST_CASE(addFace_test2)\n{\n\n}\n\n// Test 3: Test adding a duplicate face label on this rank\nBOOST_AUTO_TEST_CASE(addFace_test3)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[4] = {0, 1, 2, 3};\n\tdouble vertX[4] = {0.0, 0.5, 1.0, 1.5};\n\tdouble vertY[4] = {0.0, 0.0, 0.0, 0.0};\n\tdouble vertZ[4] = {0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Three Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(2, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and cell 1\n\tint vert1[3] = {0, 1, 2};\n\tstatus = mesh.addFace(0, 0, 1, false, vert1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 1 and cell2, but with same face label, use different vert set\n\tint vert2[3] = {0, 1, 3};\n\tstatus = mesh.addFace(0, 1, 2, false, vert2, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_EXISTING_FACE);\n}\n\n// Test 4: Error Check: Using a non-existing cell build ID\nBOOST_AUTO_TEST_CASE(addFace_test4)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[4] = {0, 1, 2, 3};\n\tdouble vertX[4] = {0.0, 0.5, 1.0, 1.5};\n\tdouble vertY[4] = {0.0, 0.0, 0.0, 0.0};\n\tdouble vertZ[4] = {0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Two Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and non-existant cell 4\n\tint vert1[3] = {0, 1, 2};\n\tstatus = mesh.addFace(0, 0, 4, false, vert1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_CELL_LABEL);\n}\n\n// Test 5: Error Check: Using a non-existing boundary build ID\nBOOST_AUTO_TEST_CASE(addFace_test5)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[4] = {0, 1, 2, 3};\n\tdouble vertX[4] = {0.0, 0.5, 1.0, 1.5};\n\tdouble vertY[4] = {0.0, 0.0, 0.0, 0.0};\n\tdouble vertZ[4] = {0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Two Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and non-existant boundary 5\n\tint vert1[3] = {0, 1, 2};\n\tstatus = mesh.addFace(0, 0, 5, true, vert1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_BOUNDARY_LABEL);\n}\n\n// Test 6: Error Check: Using a non-existing vertex build ID\nBOOST_AUTO_TEST_CASE(addFace_test6)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[4] = {0, 1, 2, 3};\n\tdouble vertX[4] = {0.0, 0.5, 1.0, 1.5};\n\tdouble vertY[4] = {0.0, 0.0, 0.0, 0.0};\n\tdouble vertZ[4] = {0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Two Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and cell 1, but with a non-existant vertex label  8\n\tint vert1[3] = {0, 1, 8};\n\tstatus = mesh.addFace(0, 0, 1, false, vert1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_VERTEX_LABEL);\n}\n\n// Test 7: Too few vertices\nBOOST_AUTO_TEST_CASE(addFace_test7)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[4] = {0, 1, 2, 3};\n\tdouble vertX[4] = {0.0, 0.5, 1.0, 1.5};\n\tdouble vertY[4] = {0.0, 0.0, 0.0, 0.0};\n\tdouble vertZ[4] = {0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Two Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and cell 1, but with only two vertices\n\tint vert1[2] = {0, 1};\n\tstatus = mesh.addFace(0, 0, 1, false, vert1, 2);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_VERTEX_COUNT);\n}\n\n// Test 8: Too many vertices\nBOOST_AUTO_TEST_CASE(addFace_test8)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[5] = {0, 1, 2, 3, 4};\n\tdouble vertX[5] = {0.0, 0.5, 1.0, 1.5, 10.0};\n\tdouble vertY[5] = {0.0, 0.0, 0.0, 0.0, 20.0};\n\tdouble vertZ[5] = {0.0, 0.0, 0.0, 0.0, 30.0};\n\n\tfor(int i = 0; i < 5; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Two Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and cell 1, but with only two vertices\n\tint vert1[5] = {0, 1, 2, 3, 4};\n\tstatus = mesh.addFace(0, 0, 1, false, vert1, 5);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_INVALID_VERTEX_COUNT);\n}\n\n// Test 9: Error Case: Edge/Face Already Exists (i.e. cell1, cell2 combo exists)\nBOOST_AUTO_TEST_CASE(addFace_test9)\n{\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Vertices\n\tint vertLabel[4] = {0, 1, 2, 3};\n\tdouble vertX[4] = {0.0, 0.5, 1.0, 1.5};\n\tdouble vertY[4] = {0.0, 0.0, 0.0, 0.0};\n\tdouble vertZ[4] = {0.0, 0.0, 0.0, 0.0};\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Three Cells\n\tstatus = mesh.addCell(0, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(1, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = mesh.addCell(2, true);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and cell 1\n\tint vert1[3] = {0, 1, 2};\n\tstatus = mesh.addFace(0, 0, 1, false, vert1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Add Face between cell 0 and cell 1 again, different face label but same edge\n\tstatus = mesh.addFace(1, 0, 1, false, vert1, 3);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_MESH_FACE_EDGE_EXISTS);\n}\n\n// === Finalize ===\n// Test 1: Test successful build, check properties are correct, check we can build cell Polyhedron types\nBOOST_AUTO_TEST_CASE(finalize_test1)\n{\n\t// Setup - Create a very simple mesh for 4 cells\n\t// Properties of components - volume, norm, center etc can be arbitrary - we are only testing these for\n\t// positioning by checking they are attached to the correct components before and after reordering.\n\t// The only things that must be correct are the component relationships - i.e. face->boundary mappings,\n\t// face-> vertex etc etc.\n\n\t// Setup\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\t// Add Regions\n\tstd::string name = \"Default\";\n\tstatus = mesh.addRegion(0, name);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// ToDo: Strictly speaking, not all vertices and boundaries are needed on all ranks for this test.\n\t// We can whittle them down.\n\n\t// Add Vertices\n\tint vertLabel[18] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90};\n\tdouble vertX[18] = {0.0, 0.5, 1.0, 1.5, 0.0, 0.5, 1.0, 1.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 1.0};\n\tdouble vertY[18] = {0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0};\n\tdouble vertZ[18] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};\n\n\tfor(int i = 0; i < 18; i++)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Add Boundaries\n\tint bndLabel[17] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};\n\tint bndVert1[17] = {0,  0, 0,  4,  10, 1, 1,  11, 2, 2,  3,  6,  6,  8,  5,  5, 14};\n\tint bndVert2[17] = {4,  1, 1,  5,  11, 2, 2,  12, 3, 3,  7,  7,  9,  9,  8,  6, 15};\n\tint bndVert3[17] = {10, 4, 10, 13, 13, 5, 11, 14, 6, 12, 12, 15, 15, 16, 14, 8, 16};\n\tint bndVert4[17] = {13, 5, 11, 14, 14, 6, 12, 15, 7, -1, 15, -1, 17, 17, 16, 9, 17};\n\tint bndFace[17] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};\n\n\tint keepBnd[17] = {false, false, false, false, false, false, false, false, false, false,\n\t\t\t\t\t\tfalse, false, false, false, false, false, false};\n\n\tif(comm.rank == 0)\n\t{\n\t\tkeepBnd[0] = true;\n\t\tkeepBnd[1] = true;\n\t\tkeepBnd[2] = true;\n\t\tkeepBnd[3] = true;\n\t\tkeepBnd[4] = true;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tkeepBnd[5] = true;\n\t\tkeepBnd[6] = true;\n\t\tkeepBnd[7] = true;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tkeepBnd[8] = true;\n\t\tkeepBnd[9] = true;\n\t\tkeepBnd[10] = true;\n\t\tkeepBnd[11] = true;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tkeepBnd[12] = true;\n\t\tkeepBnd[13] = true;\n\t\tkeepBnd[14] = true;\n\t\tkeepBnd[15] = true;\n\t\tkeepBnd[16] = true;\n\t}\n\n\tfor(int i = 0; i < 17; i++)\n\t{\n\t\tif(keepBnd[i])\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[bndVert1[i]], vertLabel[bndVert2[i]], vertLabel[bndVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(bndVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[bndVert4[i]];\n\t\t\t}\n\n\t\t\tstatus = mesh.addBoundary(bndLabel[i], 0, vert, count);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\t}\n\n\tint cellLabel[4] = {100, 200, 300, 400};\n\tdouble cellVol[4] = {1.0, 2.0, 3.0, 4.0};\n\tdouble cellCenterX[4] = {5.0, 10.0, 15.0, 25.0};\n\tdouble cellCenterY[4] = {15.0, 110.0, 115.0, 125.0};\n\tdouble cellCenterZ[4] = {25.0, 210.0, 215.0, 225.0};\n\tdouble keepCell[4] = {false, false, false, false};\n\n\t// Add Cells\n\t// Each Rank gets 1 local cell\n\tif(comm.rank == 0)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[0], cellCenterY[0], cellCenterZ[0]);\n\t\tstatus = mesh.addCell(cellLabel[0], center, cellVol[0], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[0] = true;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[1], cellCenterY[1], cellCenterZ[1]);\n\t\tstatus = mesh.addCell(cellLabel[1], center, cellVol[1], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[1] = true;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[0], cellCenterY[0], cellCenterZ[0]);\n\t\tstatus = mesh.addCell(cellLabel[0], center, cellVol[0], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[0] = true;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[3], cellCenterY[3], cellCenterZ[3]);\n\t\tstatus = mesh.addCell(cellLabel[3], center, cellVol[3], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[1] = true;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[1], cellCenterY[1], cellCenterZ[1]);\n\t\tstatus = mesh.addCell(cellLabel[1], center, cellVol[1], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[2] = true;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[2], cellCenterY[2], cellCenterZ[2]);\n\t\tstatus = mesh.addCell(cellLabel[2], center, cellVol[2], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[3] = true;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[2], cellCenterY[2], cellCenterZ[2]);\n\t\tstatus = mesh.addCell(cellLabel[2], center, cellVol[2], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[2] = true;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[1], cellCenterY[1], cellCenterZ[1]);\n\t\tstatus = mesh.addCell(cellLabel[1], center, cellVol[1], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[1] = true;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\n\t\t// Add ghost cell first so we can check reordering after finalize.\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[1], cellCenterY[1], cellCenterZ[1]);\n\t\tstatus = mesh.addCell(cellLabel[1], center, cellVol[1], false);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[1] = true;\n\n\t\tcenter = cupcfd::geometry::euclidean::EuclideanPoint<double,3>(cellCenterX[3], cellCenterY[3], cellCenterZ[3]);\n\t\tstatus = mesh.addCell(cellLabel[3], center, cellVol[3], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\tkeepCell[3] = true;\n\t}\n\n\t// Add Faces\n\t// For convienience, same order as boundaries + 3 non-boundary faces at end\n\t// This means face index = boundary index where applicable\n\tint faceLabel[20] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};\n\tint faceVert1[20] = {0,  0, 0,  4,  10, 1, 1,  11, 2, 2,  3,  6,  6,  8,  5,  5, 14, 1,  2,  5};\n\tint faceVert2[20] = {4,  1, 1,  5,  11, 2, 2,  12, 3, 3,  7,  7,  9,  9,  8,  6, 15, 5,  6,  6};\n\tint faceVert3[20] = {10, 4, 10, 13, 13, 5, 11, 14, 6, 12, 12, 15, 15, 16, 14, 8, 16, 11, 12, 14};\n\tint faceVert4[20] = {13, 5, 11, 14, 14, 6, 12, 15, 7, -1, 15, -1, 17, 17, 16, 9, 17, 14, 15, 15};\n\tint faceCell1[20] = {0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 1, 1};\n\tint faceCell2OrBoundary[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3};\n\tint isBoundary[20] = {true, true, true, true, true, true, true, true, true, true, true, true, true,\n\t\t\t\t\t\t  true, true, true, true, false, false, false};\n\n\tint keepFace[20] = {false, false, false, false, false, false, false, false, false, false,\n\t\t\t\t\t\tfalse, false, false, false, false, false, false, false, false, false};\n\n\t// Leave the last face as a default value face\n\tdouble faceLambda[20] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 0.0};\n\tdouble faceRLencos[20] = {20.0, 19.0, 18.0, 17.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 0.0};\n\tdouble faceArea[20] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 0.0};\n\tdouble faceCenterX[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceCenterY[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 2.87, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceCenterZ[20] = {4.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 7.8, 1.9, 2.0, 2.1, 2.2, 2.3, 4.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceNormX[20] = {1.0, 6.3, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 15.7, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceNormY[20] = {1.0, 1.1, 9.8, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceNormZ[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 10.54, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXnacX[20] = {1.0, 1.1, 1.2, 7.6, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXnacY[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 5.9, 2.8, 0.0};\n\tdouble faceXnacZ[20] = {1.0, 1.1, 1.2, 1.3, 180.9, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXpacX[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 180.7, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXpacY[20] = {1.0, 1.1, 1.2, 1.3, 14.6, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\tdouble faceXpacZ[20] = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 17.89, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 0.0};\n\n\tif(comm.rank == 0)\n\t{\n\t\tkeepFace[0] = true;\n\t\tkeepFace[1] = true;\n\t\tkeepFace[2] = true;\n\t\tkeepFace[3] = true;\n\t\tkeepFace[4] = true;\n\t\tkeepFace[17] = true;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tkeepFace[5] = true;\n\t\tkeepFace[6] = true;\n\t\tkeepFace[7] = true;\n\t\tkeepFace[17] = true;\n\t\tkeepFace[18] = true;\n\t\tkeepFace[19] = true;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tkeepFace[18] = true;\n\t\tkeepFace[8] = true;\n\t\tkeepFace[9] = true;\n\t\tkeepFace[10] = true;\n\t\tkeepFace[11] = true;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tkeepFace[19] = true;\n\t\tkeepFace[12] = true;\n\t\tkeepFace[13] = true;\n\t\tkeepFace[14] = true;\n\t\tkeepFace[15] = true;\n\t\tkeepFace[16] = true;\n\t}\n\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\tif(keepFace[i] == true)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[faceVert1[i]], vertLabel[faceVert2[i]], vertLabel[faceVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(faceVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[faceVert4[i]];\n\t\t\t}\n\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm(faceNormX[i], faceNormY[i], faceNormZ[i]);\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(faceCenterX[i], faceCenterY[i], faceCenterZ[i]);\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xpac(faceXpacX[i], faceXpacY[i], faceXpacZ[i]);\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xnac(faceXnacX[i], faceXnacY[i], faceXnacZ[i]);\n\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i],\n\t\t\t\t\t\t\t\t\t  faceLambda[i], norm, vert, count, center, xpac, xnac, faceRLencos[i], faceArea[i]);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanVector<double,3> norm(faceNormX[i], faceNormY[i], faceNormZ[i]);\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(faceCenterX[i], faceCenterY[i], faceCenterZ[i]);\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xpac(faceXpacX[i], faceXpacY[i], faceXpacZ[i]);\n\t\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> xnac(faceXnacX[i], faceXnacY[i], faceXnacZ[i]);\n\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i],\n\t\t\t\t\t\t\t\t\t  faceLambda[i], norm, vert, count, center, xpac, xnac, faceRLencos[i], faceArea[i]);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus = mesh.finalize();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\treturn;\n\n\t// === Checks ===\n\n\t// === Check Mesh Properties are Updated - Global is only updated at finalize ===\n\tswitch(comm.rank)\n\t{\n\t\tcase 0:\tBOOST_CHECK_EQUAL(mesh.properties.lTCells, 2);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lOCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lGhCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lBoundaries, 5);\n\n\t\t\t\t// Note: For this test we haven't bothered to filter out unused vertices\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 18);\n\t\t\t\tbreak;\n\n\t\tcase 1:\tBOOST_CHECK_EQUAL(mesh.properties.lTCells, 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lOCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lGhCells, 3);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lBoundaries, 3);\n\n\t\t\t\t// Note: For this test we haven't bothered to filter out unused vertices\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 18);\n\t\t\t\tbreak;\n\n\t\tcase 2:\tBOOST_CHECK_EQUAL(mesh.properties.lTCells, 2);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lOCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lGhCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 5);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lBoundaries, 4);\n\n\t\t\t\t// Note: For this test we haven't bothered to filter out unused vertices\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 18);\n\t\t\t\tbreak;\n\n\t\tcase 3:\tBOOST_CHECK_EQUAL(mesh.properties.lTCells, 2);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lOCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lGhCells, 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lBoundaries, 5);\n\n\t\t\t\t// Note: For this test we haven't bothered to filter out unused vertices\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.properties.lVertices, 18);\n\t\t\t\tbreak;\n\t}\n\n\t// === Check Cell Local IDs in Mesh match the local IDs in the connectivity graph ===\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tif(keepCell[i])\n\t\t{\n\t\t\tint meshLocalID;\n\t\t\tint graphLocalID;\n\n\t\t\tmeshLocalID = mesh.getCellID(cellLabel[i]);\n\t\t\tstatus = mesh.cellConnGraph->connGraph.getNodeLocalIndex(cellLabel[i], &graphLocalID);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\tBOOST_CHECK_EQUAL(meshLocalID, graphLocalID);\n\t\t}\n\t}\n\n\t// === Check that the cell data still matches up correctly for each cell label (i.e. it was reordered correctly) ===\n\n\tfor(int i = 0; i < 4; i++)\n\t{\n\t\tif(keepCell[i])\n\t\t{\n\t\t\t// Cell is on this rank, check the values\n\t\t\t// Check Cell Data\n\t\t\tint localID = mesh.getCellID(cellLabel[i]);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getCellVolume(localID), cellVol[i]);\n\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center;\n\t\t\tcenter = mesh.getCellCenter(localID);\n\n\t\t\tBOOST_CHECK_EQUAL(center.cmp[0], cellCenterX[i]);\n\t\t\tBOOST_CHECK_EQUAL(center.cmp[1], cellCenterY[i]);\n\t\t\tBOOST_CHECK_EQUAL(center.cmp[2], cellCenterZ[i]);\n\t\t}\n\t}\n\n\t// === Check each boundary still maps to the correct face and vertices ===\n\n\tfor(int i = 0; i < 17; i++)\n\t{\n\t\tif(keepBnd[i] && comm.rank == 3)\n\t\t{\n\t\t\tint bndID = mesh.getBoundaryID(bndLabel[i]);\n\t\t\tint faceID = mesh.getFaceID(faceLabel[bndFace[i]]);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getBoundaryFaceID(bndID), faceID);\n\n\t\t\tint vert1ID = mesh.getVertexID(vertLabel[bndVert1[i]]);\n\t\t\tint vert2ID = mesh.getVertexID(vertLabel[bndVert2[i]]);\n\t\t\tint vert3ID = mesh.getVertexID(vertLabel[bndVert3[i]]);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getBoundaryVertex(bndID, 0), vert1ID);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getBoundaryVertex(bndID, 1), vert2ID);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getBoundaryVertex(bndID, 2), vert3ID);\n\n\t\t\tif(bndVert4[i] != -1)\n\t\t\t{\n\t\t\t\tint vert4ID = mesh.getVertexID(vertLabel[bndVert4[i]]);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getBoundaryVertex(bndID, 3), vert4ID);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getBoundaryVertex(bndID, 3), -1);\n\t\t\t}\n\t\t}\n\t}\n\n\t// === Check each face still maps to the correct cells, boundaries and vertices ===\n\n\tfor(int i = 0; i < 20; i++)\n\t{\n\t\tif(keepFace[i] && comm.rank == 3)\n\t\t{\n\t\t\tint faceID = mesh.getFaceID(faceLabel[i]);\n\t\t\tint cell1ID = mesh.getCellID(cellLabel[faceCell1[i]]);\n\n\t\t\t// Check Cell 1 Mapping is to same cell ID as expected from source data\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceCell1ID(faceID), cell1ID);\n\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\t// Check Boundary Mapping (should be same as before)\n\t\t\t\tint bndID = mesh.getBoundaryID(bndLabel[faceCell2OrBoundary[i]]);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceBoundaryID(faceID), bndID);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceCell2ID(faceID), -1);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Check Cell 2 Mapping\n\t\t\t\tint cell2ID = mesh.getCellID(cellLabel[faceCell2OrBoundary[i]]);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceCell2ID(faceID), cell2ID);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceBoundaryID(faceID), -1);\n\t\t\t}\n\n\t\t\tint vert1ID = mesh.getVertexID(vertLabel[faceVert1[i]]);\n\t\t\tint vert2ID = mesh.getVertexID(vertLabel[faceVert2[i]]);\n\t\t\tint vert3ID = mesh.getVertexID(vertLabel[faceVert3[i]]);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(faceID, 0), vert1ID);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(faceID, 1), vert2ID);\n\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(faceID, 2), vert3ID);\n\n\t\t\tif(faceVert4[i] != -1)\n\t\t\t{\n\t\t\t\tint vert4ID = mesh.getVertexID(vertLabel[faceVert4[i]]);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(faceID, 3), vert4ID);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getFaceVertex(faceID, 3), -1);\n\t\t\t}\n\n\t\t}\n\t}\n\n\t// === Check each cell has mappings to the correct faces ===\n\t// Also check that each cell tracks the correct number of faces, vertices\n\t// both locally and globally (will be different for ghost cells)\n\n\tswitch(comm.rank)\n\t{\n\t\tint localID;\n\n\t\tcase 0:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\n\t\t\t\t// Cell 0\n\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[0]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[0]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 1), mesh.getFaceID(faceLabel[1]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 2), mesh.getFaceID(faceLabel[2]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 3), mesh.getFaceID(faceLabel[3]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 4), mesh.getFaceID(faceLabel[4]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 5), mesh.getFaceID(faceLabel[17]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 8);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\t// Cell 1\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[1]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[17]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\tbreak;\n\n\t\tcase 1:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\n\t\t\t\t// Test getter for cell->number of locally attached faces\n\n\t\t\t\t// Cell 0\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[0]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[17]));\n\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\t// Cell 1\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[1]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\t// Should technically sort getFaceID(faceLabel...) to ensure they are in correct order\n\t\t\t\t// For now ensure they are in order of that which they were added, but this could be prone to\n\t\t\t\t// breaking if internals of class change.\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[5]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 1), mesh.getFaceID(faceLabel[6]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 2), mesh.getFaceID(faceLabel[7]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 3), mesh.getFaceID(faceLabel[17]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 4), mesh.getFaceID(faceLabel[18]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 5), mesh.getFaceID(faceLabel[19]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 8);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\t// Cell 2\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[2]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[18]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 5);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 6);\n\n\t\t\t\t// Cell 3\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[3]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[19]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\tbreak;\n\n\t\tcase 2:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 5);\n\n\t\t\t\t// Cell 1\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[1]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[18]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\t// Cell 2\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[2]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\t// Should technically sort getFaceID(faceLabel...) to ensure they are in correct order\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[8]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 1), mesh.getFaceID(faceLabel[9]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 2), mesh.getFaceID(faceLabel[10]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 3), mesh.getFaceID(faceLabel[11]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 4), mesh.getFaceID(faceLabel[18]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 5);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 5);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 6);\n\n\t\t\t\tbreak;\n\n\t\tcase 3:\tBOOST_CHECK_EQUAL(mesh.properties.lFaces, 6);\n\n\t\t\t\t// Cell 1\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[1]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[19]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 1);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 4);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\t\t\t\t// Cell 3\n\t\t\t\tlocalID = mesh.getCellID(cellLabel[3]);\n\n\t\t\t\t// Check Cell Face Mappings are correct\n\t\t\t\t// Should technically sort getFaceID(faceLabel...) to ensure they are in correct order\n\t\t\t\t// For now ensure they are in order of that which they were added, but this could be prone to\n\t\t\t\t// breaking if internals of class change.\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 0), mesh.getFaceID(faceLabel[12]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 1), mesh.getFaceID(faceLabel[13]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 2), mesh.getFaceID(faceLabel[14]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 3), mesh.getFaceID(faceLabel[15]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 4), mesh.getFaceID(faceLabel[16]));\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellFaceID(localID, 5), mesh.getFaceID(faceLabel[19]));\n\n\t\t\t\t// Check Cell Properties Counts are correct\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNFaces(localID), 6);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellStoredNVertices(localID), 8);\n\t\t\t\tBOOST_CHECK_EQUAL(mesh.getCellNVertices(localID), 8);\n\n\n\t\t\t\tbreak;\n\t}\n}\n/*\n// === buildPolyhedron + getCellPolyhedronType===\n// Test 1: TriPrism\nBOOST_AUTO_TEST_CASE(buildPolyhedron_test1, * utf::tolerance(0.00001))\n{\n\t// For simplicity, build a very simple mesh on one process with only one cell\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Add Regions\n\t\tstd::string name = \"Default\";\n\t\tstatus = mesh.addRegion(0, name);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Vertices\n\t\tint vertLabel[6] = {0, 1, 2, 3, 4, 5};\n\t\tdouble vertX[6] = {0.0, 5.0, 2.5, 0.0, 5.0, 2.5};\n\t\tdouble vertY[6] = {0.0, 0.0, 5.0, 0.0, 0.0, 5.0};\n\t\tdouble vertZ[6] = {0.0, 0.0, 0.0, 5.0, 5.0, 5.0};\n\n\t\tfor(int i = 0; i < 6; i++)\n\t\t{\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\t// Add Boundaries\n\t\tint bndLabel[5] = {0, 1, 2, 3, 4};\n\t\tint bndVert1[5] = {0,  3, 0, 1, 0};\n\t\tint bndVert2[5] = {1,  4, 1, 2, 2};\n\t\tint bndVert3[5] = {2,  5, 3, 4, 3};\n\t\tint bndVert4[5] = {-1, -1, 4, 5, 5};\n\n\t\tfor(int i = 0; i < 5; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[bndVert1[i]], vertLabel[bndVert2[i]], vertLabel[bndVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(bndVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[bndVert4[i]];\n\t\t\t}\n\n\t\t\tstatus = mesh.addBoundary(bndLabel[i], 0, vert, count);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\tint cellLabel[1] = {0};\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(2.1428571, 1.42857142, 2.1428571);\n\t\tdouble vol = 62.5;\n\n\t\tstatus = mesh.addCell(cellLabel[0], center, vol, true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Faces\n\t\t// For convienience, same order as boundaries + 3 non-boundary faces at end\n\t\t// This means face index = boundary index where applicable\n\t\tint faceLabel[5] = {0, 1, 2, 3, 4};\n\t\tint faceVert1[5] = {0, 3, 0, 1, 0};\n\t\tint faceVert2[5] = {1, 4, 3, 2, 2};\n\t\tint faceVert3[5] = {2, 5, 4, 5, 5};\n\t\tint faceVert4[5] = {-1, -1, 1, 4, 3};\n\t\tint faceNVertices[5] = {3, 3, 4, 4, 4};\n\t\tint faceCell1[5] = {0 ,0 ,0 ,0, 0};\n\t\tint faceCell2OrBoundary[5] = {0, 1, 2, 3, 4};\n\t\tint isBoundary[5] = {true, true, true, true, true};\n\n\t\tfor(int i = 0; i < 5; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[faceVert1[i]], vertLabel[faceVert2[i]], vertLabel[faceVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(faceVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[faceVert4[i]];\n\t\t\t}\n\n\t\t\t// Default add\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus = mesh.finalize();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Test getPolyhedronType\n\t\tcupcfd::geometry::shapes::PolyhedronType type = mesh.getCellPolyhedronType(0);\n\t\tBOOST_CHECK_EQUAL(type, cupcfd::geometry::shapes::POLYHEDRON_TRIPRISM);\n\n\t\t// Test Building the polyhedron\n\t\tcupcfd::geometry::shapes::TriPrism<double> * shape;\n\t\tstatus = mesh.buildPolyhedron(0, &shape);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Check Polyhedron Values to ensure it is correct\n\t\tBOOST_TEST(shape->top.vertices[0].cmp[0] == 0.0);\n\t\tBOOST_TEST(shape->top.vertices[0].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->top.vertices[0].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->top.vertices[1].cmp[0] == 2.5);\n\t\tBOOST_TEST(shape->top.vertices[1].cmp[1] == 5.0);\n\t\tBOOST_TEST(shape->top.vertices[1].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->top.vertices[2].cmp[0] == 5.0);\n\t\tBOOST_TEST(shape->top.vertices[2].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->top.vertices[2].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->bottom.vertices[0].cmp[0] == 0.0);\n\t\tBOOST_TEST(shape->bottom.vertices[0].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->bottom.vertices[0].cmp[2] == 5.0);\n\n\t\tBOOST_TEST(shape->bottom.vertices[1].cmp[0] == 2.5);\n\t\tBOOST_TEST(shape->bottom.vertices[1].cmp[1] == 5.0);\n\t\tBOOST_TEST(shape->bottom.vertices[1].cmp[2] == 5.0);\n\n\t\tBOOST_TEST(shape->bottom.vertices[5].cmp[0] == 5.0);\n\t\tBOOST_TEST(shape->bottom.vertices[5].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->bottom.vertices[5].cmp[2] == 5.0);\n\n\t\tBOOST_TEST(shape->getVolume() == 62.5);\n\t\tBOOST_TEST(shape->getCentroid().cmp[0] == 2.1428571);\n\t\tBOOST_TEST(shape->getCentroid().cmp[1] == 1.42857142);\n\t\tBOOST_TEST(shape->getCentroid().cmp[2] == 2.1428571);\n\t}\n}\n\n// Test 2: QuadPyramid\nBOOST_AUTO_TEST_CASE(buildPolyhedron_test2, * utf::tolerance(0.00001))\n{\n\t// For simplicity, buila very simple mesh on one process with only one cell\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Add Regions\n\t\tstd::string name = \"Default\";\n\t\tstatus = mesh.addRegion(0, name);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Vertices\n\t\tint vertLabel[5] = {0, 1, 2, 3, 4};\n\t\tdouble vertX[5] = {0.0, 5.0, 5.0, 0.0, 2.5};\n\t\tdouble vertY[5] = {0.0, 0.0, 5.0, 5.0, 2.5};\n\t\tdouble vertZ[5] = {0.0, 0.0, 0.0, 0.0, 5.0};\n\n\t\tfor(int i = 0; i < 5; i++)\n\t\t{\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\t// Add Boundaries\n\t\tint bndLabel[5] = {0, 1, 2, 3, 4};\n\t\tint bndVert1[5] = {0, 0, 1, 2, 3};\n\t\tint bndVert2[5] = {1, 1, 2, 3, 1};\n\t\tint bndVert3[5] = {2, 4, 4, 4, 4};\n\t\tint bndVert4[5] = {3, -1, -1, -1, -1};\n\n\t\tfor(int i = 0; i < 5; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[bndVert1[i]], vertLabel[bndVert2[i]], vertLabel[bndVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(bndVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[bndVert4[i]];\n\t\t\t}\n\n\t\t\tstatus = mesh.addBoundary(bndLabel[i], 0, vert, count);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\tint cellLabel[1] = {0};\n\n\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> center(2.5, 2.5, 1.25);\n\t\tdouble vol = 41.6666667;\n\n\t\tstatus = mesh.addCell(cellLabel[0], center, vol, true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Faces\n\t\t// For convienience, same order as boundaries + 3 non-boundary faces at end\n\t\t// This means face index = boundary index where applicable\n\t\tint faceLabel[5] = {0, 1, 2, 3, 4};\n\t\tint faceVert1[5] = {0, 0, 1, 2, 3};\n\t\tint faceVert2[5] = {1, 1, 2, 3, 0};\n\t\tint faceVert3[5] = {2, 4, 4, 4, 4};\n\t\tint faceVert4[5] = {3, -1, -1, -1, -1};\n\t\tint faceNVertices[5] = {4, 3, 3, 3, 3};\n\t\tint faceCell1[5] = {0 ,0 ,0 ,0, 0};\n\t\tint faceCell2OrBoundary[5] = {0, 1, 2, 3, 4};\n\t\tint isBoundary[5] = {true, true, true, true, true};\n\n\t\tfor(int i = 0; i < 5; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[faceVert1[i]], vertLabel[faceVert2[i]], vertLabel[faceVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(faceVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[faceVert4[i]];\n\t\t\t}\n\n\t\t\t// Default add\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus = mesh.finalize();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Test getPolyhedronType\n\t\tcupcfd::geometry::shapes::PolyhedronType type = mesh.getCellPolyhedronType(0);\n\t\tBOOST_CHECK_EQUAL(type, cupcfd::geometry::shapes::POLYHEDRON_QUADPYRAMID);\n\n\t\t// Test Building the polyhedron\n\t\tcupcfd::geometry::shapes::QuadPyramid<double> * shape;\n\t\tstatus = mesh.buildPolyhedron(0, &shape);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tBOOST_TEST(shape->base.vertices[0].cmp[0] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[0].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[0].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->base.vertices[1].cmp[0] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[1].cmp[1] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[1].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->base.vertices[2].cmp[0] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[2].cmp[1] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[2].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->base.vertices[3].cmp[0] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[3].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[3].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->apex.cmp[0] == 2.5);\n\t\tBOOST_TEST(shape->apex.cmp[1] == 2.5);\n\t\tBOOST_TEST(shape->apex.cmp[2] == 5.0);\n\n\t\tBOOST_TEST(shape->getVolume() == 41.6666667);\n\t\tBOOST_TEST(shape->getCentroid().cmp[0] == 2.5);\n\t\tBOOST_TEST(shape->getCentroid().cmp[1] == 2.5);\n\t\tBOOST_TEST(shape->getCentroid().cmp[2] == 1.25);\n\t}\n}\n\n// Test 3: Tetrahedron\nBOOST_AUTO_TEST_CASE(buildPolyhedron_test3, * utf::tolerance(0.00001))\n{\n\t// For simplicity, buila very simple mesh on one process with only one cell\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Add Regions\n\t\tstd::string name = \"Default\";\n\t\tstatus = mesh.addRegion(0, name);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Vertices\n\t\tint vertLabel[4] = {0, 1, 2, 3};\n\t\tdouble vertX[4] = {0.0, 5.0, 5.0, 2.5};\n\t\tdouble vertY[4] = {0.0, 0.0, 5.0, 2.5};\n\t\tdouble vertZ[4] = {0.0, 0.0, 0.0, 5.0};\n\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\t// Add Boundaries\n\t\tint bndLabel[4] = {0, 1, 2, 3};\n\t\tint bndVert1[4] = {0, 0, 1, 2};\n\t\tint bndVert2[4] = {1, 1, 2, 3};\n\t\tint bndVert3[4] = {2, 3, 3, 3};\n\t\tint bndVert4[4] = {3, -1, -1, -1};\n\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[bndVert1[i]], vertLabel[bndVert2[i]], vertLabel[bndVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(bndVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[bndVert4[i]];\n\t\t\t}\n\n\t\t\tstatus = mesh.addBoundary(bndLabel[i], 0, vert, count);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\tint cellLabel[1] = {0};\n\n\t\tstatus = mesh.addCell(cellLabel[0], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Faces\n\t\t// For convienience, same order as boundaries + 3 non-boundary faces at end\n\t\t// This means face index = boundary index where applicable\n\t\tint faceLabel[4] = {0, 1, 2, 3};\n\t\tint faceVert1[4] = {0, 0, 1, 2};\n\t\tint faceVert2[4] = {1, 1, 2, 3};\n\t\tint faceVert3[4] = {2, 3, 3, 3};\n\t\tint faceVert4[4] = {3, -1, -1, -1};\n\t\tint faceNVertices[4] = {4, 3, 3, 3};\n\t\tint faceCell1[4] = {0 ,0 ,0 ,0};\n\t\tint faceCell2OrBoundary[4] = {0, 1, 2, 3};\n\t\tint isBoundary[4] = {true, true, true, true};\n\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[faceVert1[i]], vertLabel[faceVert2[i]], vertLabel[faceVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(faceVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[faceVert4[i]];\n\t\t\t}\n\n\t\t\t// Default add\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus = mesh.finalize();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Test getPolyhedronType\n\t\tcupcfd::geometry::shapes::PolyhedronType type = mesh.getCellPolyhedronType(0);\n\t\tBOOST_CHECK_EQUAL(type, cupcfd::geometry::shapes::POLYHEDRON_TETRAHEDRON);\n\n\t\t// Test Building the polyhedron\n\t\tcupcfd::geometry::shapes::Tetrahedron<double> * shape;\n\t\tstatus = mesh.buildPolyhedron(0, &shape);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tBOOST_TEST(shape->base.vertices[0].cmp[0] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[0].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[0].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->base.vertices[1].cmp[0] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[1].cmp[1] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[1].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->base.vertices[2].cmp[0] == 5.0);\n\t\tBOOST_TEST(shape->base.vertices[2].cmp[1] == 0.0);\n\t\tBOOST_TEST(shape->base.vertices[2].cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->apex.cmp[0] == 2.5);\n\t\tBOOST_TEST(shape->apex.cmp[1] == 2.5);\n\t\tBOOST_TEST(shape->apex.cmp[2] == 5.0);\n\n\t\tBOOST_TEST(shape->getVolume() == 20.83333);\n\t\tBOOST_TEST(shape->getCentroid().cmp[0] == 3.125);\n\t\tBOOST_TEST(shape->getCentroid().cmp[1] == 1.875);\n\t\tBOOST_TEST(shape->getCentroid().cmp[2] == 1.25);\n\t}\n}\n\n// Test 4: Hexahedral\nBOOST_AUTO_TEST_CASE(buildPolyhedron_test4, * utf::tolerance(0.00001))\n{\n\t// For simplicity, buila very simple mesh on one process with only one cell\n\tcupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\tCupCfdAoSMesh<int,double,int> mesh(comm);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Add Regions\n\t\tstd::string name = \"Default\";\n\t\tstatus = mesh.addRegion(0, name);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Vertices\n\t\tint vertLabel[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\t\tdouble vertX[8] = {0.0, 5.0, 5.0, 0.0, 0.0, 5.0, 5.0, 0.0};\n\t\tdouble vertY[8] = {0.0, 0.0, 5.0, 5.0, 0.0, 0.0, 5.0, 5.0};\n\t\tdouble vertZ[8] = {0.0, 0.0, 0.0, 0.0, 5.0, 5.0, 5.0, 5.0};\n\n\t\tfor(int i = 0; i < 8; i++)\n\t\t{\n\t\t\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point(vertX[i], vertY[i], vertZ[i]);\n\t\t\tstatus = mesh.addVertex(vertLabel[i], point);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\t// Add Boundaries\n\t\tint bndLabel[6] = {0, 1, 2, 3, 4, 5};\n\t\tint bndVert1[6] = {0, 4, 0, 1, 2, 0};\n\t\tint bndVert2[6] = {1, 5, 1, 2, 3, 3};\n\t\tint bndVert3[6] = {2, 6, 5, 6, 7, 7};\n\t\tint bndVert4[6] = {3, 7, 4, 5, 6, 4};\n\n\t\tfor(int i = 0; i < 6; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[bndVert1[i]], vertLabel[bndVert2[i]], vertLabel[bndVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(bndVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[bndVert4[i]];\n\t\t\t}\n\n\t\t\tstatus = mesh.addBoundary(bndLabel[i], 0, vert, count);\n\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t}\n\n\t\tint cellLabel[1] = {0};\n\n\t\tstatus = mesh.addCell(cellLabel[0], true);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Add Faces\n\t\t// For convienience, same order as boundaries + 3 non-boundary faces at end\n\t\t// This means face index = boundary index where applicable\n\t\tint faceLabel[6] = {0, 1, 2, 3, 4, 5};\n\t\tint faceVert1[6] = {0, 4, 0, 1, 2, 0};\n\t\tint faceVert2[6] = {1, 5, 1, 2, 3, 3};\n\t\tint faceVert3[6] = {2, 6, 5, 6, 7, 7};\n\t\tint faceVert4[6] = {3, 7, 4, 5, 6, 4};\n\t\tint faceNVertices[6] = {4, 4, 4, 4, 4, 4};\n\t\tint faceCell1[6] = {0 ,0 ,0 ,0, 0, 0};\n\t\tint faceCell2OrBoundary[6] = {0, 1, 2, 3, 4, 5};\n\t\tint isBoundary[6] = {true, true, true, true, true, true};\n\n\t\tfor(int i = 0; i < 6; i++)\n\t\t{\n\t\t\t// Use region 0 for all\n\t\t\tint vert[4] = {vertLabel[faceVert1[i]], vertLabel[faceVert2[i]], vertLabel[faceVert3[i]], -1};\n\t\t\tint count = 3;\n\n\t\t\t// add the 4th vertex if it exists\n\t\t\tif(faceVert4[i] != - 1)\n\t\t\t{\n\t\t\t\tcount = 4;\n\t\t\t\tvert[3] = vertLabel[faceVert4[i]];\n\t\t\t}\n\n\t\t\t// Default add\n\t\t\tif(isBoundary[i])\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], bndLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstatus = mesh.addFace(faceLabel[i], cellLabel[faceCell1[i]], cellLabel[faceCell2OrBoundary[i]], isBoundary[i], vert, count);\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus = mesh.finalize();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Test getPolyhedronType\n\t\tcupcfd::geometry::shapes::PolyhedronType type = mesh.getCellPolyhedronType(0);\n\t\tBOOST_CHECK_EQUAL(type, cupcfd::geometry::shapes::POLYHEDRON_HEXAHEDRON);\n\n\t\t// Test Building the polyhedron\n\t\tcupcfd::geometry::shapes::Hexahedron<double> * shape;\n\t\tstatus = mesh.buildPolyhedron(0, &shape);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// BOOST_TEST(shape->tlf.cmp[0] == 0.0);\n\t\t// BOOST_TEST(shape->tlf.cmp[1] == 0.0);\n\t\t// BOOST_TEST(shape->tlf.cmp[2] == 5.0);\n\n\t\t// BOOST_TEST(shape->trf.cmp[0] == 0.0);\n\t\t// BOOST_TEST(shape->trf.cmp[1] == 5.0);\n\t\t// BOOST_TEST(shape->trf.cmp[2] == 5.0);\n\n\t\t// BOOST_TEST(shape->blf.cmp[0] == 0.0);\n\t\t// BOOST_TEST(shape->blf.cmp[1] == 0.0);\n\t\t// BOOST_TEST(shape->blf.cmp[2] == 0.0);\n\n\t\t// BOOST_TEST(shape->brf.cmp[0] == 0.0);\n\t\t// BOOST_TEST(shape->brf.cmp[1] == 5.0);\n\t\t// BOOST_TEST(shape->brf.cmp[2] == 0.0);\n\n\t\t// BOOST_TEST(shape->tlb.cmp[0] == 5.0);\n\t\t// BOOST_TEST(shape->tlb.cmp[1] == 0.0);\n\t\t// BOOST_TEST(shape->tlb.cmp[2] == 5.0);\n\n\t\t// BOOST_TEST(shape->trb.cmp[0] == 5.0);\n\t\t// BOOST_TEST(shape->trb.cmp[1] == 5.0);\n\t\t// BOOST_TEST(shape->trb.cmp[2] == 5.0);\n\n\t\t// BOOST_TEST(shape->blb.cmp[0] == 5.0);\n\t\t// BOOST_TEST(shape->blb.cmp[1] == 0.0);\n\t\t// BOOST_TEST(shape->blb.cmp[2] == 0.0);\n\n\t\t// BOOST_TEST(shape->brb.cmp[0] == 5.0);\n\t\t// BOOST_TEST(shape->brb.cmp[1] == 5.0);\n\t\t// BOOST_TEST(shape->brb.cmp[2] == 0.0);\n\n\t\tBOOST_TEST(shape->getVolume() == 125.0);\n\t\tBOOST_TEST(shape->getCentroid().cmp[0] == 2.5);\n\t\tBOOST_TEST(shape->getCentroid().cmp[1] == 2.5);\n\t\tBOOST_TEST(shape->getCentroid().cmp[2] == 2.5);\n\t}\n}\n\n// === findCellID ===\n// Test 1: Test arbitrary point\nBOOST_AUTO_TEST_CASE(findCellID_test1)\n{\n\tcupcfd::error::eCodes status;\n    cupcfd::comm::Communicator comm(MPI_COMM_WORLD);\n\n\t// === Create a small test mesh ===\n\t// Setup the configurations\n    cupcfd::partitioner::PartitionerNaiveConfig<int,int> partConfig;\n    MeshSourceStructGenConfig<int, double> meshSourceConfig(5, 5, 5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0);\n    MeshConfig<int,double,int> meshConfig(partConfig, meshSourceConfig);\n\n    // Build the mesh\n    CupCfdAoSMesh<int,double,int> * mesh;\n\tstatus = meshConfig.buildUnstructuredMesh(&mesh, comm);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tcupcfd::geometry::euclidean::EuclideanPoint<double,3> point1(0.56, 0.24, 0.3);\n\n\tint localCellID;\n\tint globalCellID;\n\tstatus = mesh->findCellID(point1, &localCellID, &globalCellID);\n\n\t// Naive Partitioner splits each rank into 32, 31, 31, 31\n\t// Expected cell is Cell 32 (Zero-indexed)\n\n\tswitch(comm.rank)\n\t{\n\t\tcase 0:\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_GEOMETRY_NO_VALID_CELL);\n\t\t\t\tbreak;\n\t\tcase 1:\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t\t\t\tBOOST_CHECK_EQUAL(localCellID, 0);\n\t\t\t\tBOOST_CHECK_EQUAL(globalCellID, 32);\n\t\t\t\tbreak;\n\t\tcase 2:\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_GEOMETRY_NO_VALID_CELL);\n\t\t\t\tbreak;\n\t\tcase 3:\n\t\t\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_GEOMETRY_NO_VALID_CELL);\n\t\t\t\tbreak;\n\t}\n\n\tdelete mesh;\n}\n\nBOOST_AUTO_TEST_CASE(cleanup)\n{\n    MPI_Finalize();\n}\n*/\n", "meta": {"hexsha": "42f9561624730e144808c9217dc46510aab7788e", "size": 103223, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/geometry/mesh/implementation/component/CupCfdAoSMeshTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/geometry/mesh/implementation/component/CupCfdAoSMeshTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/geometry/mesh/implementation/component/CupCfdAoSMeshTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 36.812767475, "max_line_length": 150, "alphanum_fraction": 0.6618001802, "num_tokens": 40182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46490157137338844, "lm_q2_score": 0.12421301807811347, "lm_q1q2_score": 0.05774682728954606}}
{"text": "/*\n Copyright (C) 2020 Quaternion Risk Management Ltd\n All rights reserved.\n\n This file is part of ORE, a free-software/open-source library\n for transparent pricing and risk analysis - http://opensourcerisk.org\n\n ORE is free software: you can redistribute it and/or modify it\n under the terms of the Modified BSD License.  You should have received a\n copy of the license along with this program.\n The license is also available online at <http://opensourcerisk.org>\n\n This program is distributed on the basis that it will form a useful\n contribution to risk analytics and model standardisation, but WITHOUT\n ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.\n*/\n\n// clang-format off\n#include <boost/test/unit_test.hpp>\n#include <boost/test/data/test_case.hpp>\n// clang-format on\n#include <oret/datapaths.hpp>\n#include <oret/toplevelfixture.hpp>\n\n#include <boost/make_shared.hpp>\n\n#include <ored/configuration/curveconfigurations.hpp>\n#include <ored/marketdata/csvloader.hpp>\n#include <ored/marketdata/todaysmarket.hpp>\n#include <ored/utilities/csvfilereader.hpp>\n#include <ored/utilities/parsers.hpp>\n\nusing namespace std;\nusing namespace boost::unit_test_framework;\nusing namespace QuantLib;\nusing namespace QuantExt;\nusing namespace ore::data;\n\nnamespace bdata = boost::unit_test::data;\n\nnamespace {\n\nboost::shared_ptr<TodaysMarket> createTodaysMarket(const Date& asof, const string& inputDir) {\n\n    auto conventions = boost::make_shared<Conventions>();\n    // conventions->fromFile(TEST_INPUT_FILE(string(inputDir + \"/conventions.xml\")));\n\n    auto curveConfigs = boost::make_shared<CurveConfigurations>();\n    curveConfigs->fromFile(TEST_INPUT_FILE(string(inputDir + \"/curveconfig.xml\")));\n\n    auto todaysMarketParameters = boost::make_shared<TodaysMarketParameters>();\n    todaysMarketParameters->fromFile(TEST_INPUT_FILE(string(inputDir + \"/todaysmarket.xml\")));\n\n    auto loader = boost::make_shared<CSVLoader>(TEST_INPUT_FILE(string(inputDir + \"/market.txt\")),\n                                                TEST_INPUT_FILE(string(inputDir + \"/fixings.txt\")), false);\n\n    return boost::make_shared<TodaysMarket>(asof, todaysMarketParameters, loader, curveConfigs, conventions);\n}\n\n}\n\nBOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)\n\nBOOST_AUTO_TEST_SUITE(BaseCorrelationCurveTests)\n\n// Sub-directories containing input data to test various base correlation curve and market data set-ups\nvector<string> setups{\n    \"exp_terms_exp_dps_curve\",\n    \"exp_terms_exp_dps_surface\",\n    \"exp_terms_wc_dps_curve\",\n    \"exp_terms_wc_dps_surface\",\n    \"wc_terms_exp_dps_curve\",\n    \"wc_terms_exp_dps_surface\",\n    \"wc_terms_wc_dps_curve\",\n    \"wc_terms_wc_dps_surface\"\n};\n\nBOOST_DATA_TEST_CASE(testBaseCorrelationStructureBuilding, bdata::make(setups), setup) {\n\n    BOOST_TEST_MESSAGE(\"Testing base correlation structure building using setup in \" << setup);\n\n    Date asof(19, Oct, 2020);\n    Settings::instance().evaluationDate() = asof;\n\n    auto todaysMarket = createTodaysMarket(asof, setup);\n\n    // Get the built base correlation structure.\n    auto bc = todaysMarket->baseCorrelation(\"BASE_CORR_TEST\");\n\n    // These are the values used in the test configurations.\n    Calendar calendar = parseCalendar(\"US settlement\");\n    BusinessDayConvention bdc = Following;\n\n    // Tolerance for comparison.\n    Real tol = 1e-12;\n\n    // Read in the expected results.\n    string filename = setup + \"/expected.csv\";\n    CSVFileReader reader(TEST_INPUT_FILE(filename), true, \",\");\n    BOOST_REQUIRE_EQUAL(reader.numberOfColumns(), 3);\n\n    BOOST_TEST_MESSAGE(\"term,detachment,expected_bc,calculated_bc,difference\");\n    while (reader.next()) {\n\n        // Get the term, detachment point and expected base correlation\n        Period term = parsePeriod(reader.get(0));\n        Real dp = parseReal(reader.get(1));\n        Real expBc = parseReal(reader.get(2));\n\n        // Check\n        Date d = calendar.advance(asof, term, bdc);\n        Real calcBc = bc->correlation(d, dp);\n        Real difference = expBc - calcBc;\n        BOOST_TEST_MESSAGE(term << \",\" << fixed << setprecision(12) << dp << \",\" <<\n            expBc << \",\" << calcBc << \",\" << difference);\n        BOOST_CHECK_SMALL(difference, tol);\n    }\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "351523b8e43ee0dc03170b6c0f2c8162f55baa7b", "size": 4374, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "OREData/test/basecorrelationcurve.cpp", "max_stars_repo_name": "mrslezak/Engine", "max_stars_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 335.0, "max_stars_repo_stars_event_min_datetime": "2016-10-07T16:31:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-02T07:12:03.000Z", "max_issues_repo_path": "OREData/test/basecorrelationcurve.cpp", "max_issues_repo_name": "mrslezak/Engine", "max_issues_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 59.0, "max_issues_repo_issues_event_min_datetime": "2016-10-31T04:20:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T16:39:57.000Z", "max_forks_repo_path": "OREData/test/basecorrelationcurve.cpp", "max_forks_repo_name": "mrslezak/Engine", "max_forks_repo_head_hexsha": "c46ff278a2c5f4162db91a7ab500a0bb8cef7657", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 180.0, "max_forks_repo_forks_event_min_datetime": "2016-10-08T14:23:50.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T10:43:05.000Z", "avg_line_length": 35.2741935484, "max_line_length": 109, "alphanum_fraction": 0.7309099223, "num_tokens": 993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46879062662624377, "lm_q2_score": 0.12252322533450248, "lm_q1q2_score": 0.057437739580829886}}
{"text": "#include <boost/test/unit_test.hpp>\n#include \"algorithms/data_structures/bt/bt_inorder_traversal.hpp\"\n\nBOOST_AUTO_TEST_SUITE(BTInorderTraversal)\n\nBOOST_AUTO_TEST_CASE(empty_bt)\n{\n    Types::DS::NodeBT<int>* bt = nullptr;\n    const std::vector<int> expected;\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderRecursive(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterative(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterativeMorris(bt));\n\n    Types::DS::DeleteBT(&bt);\n}\n\nBOOST_AUTO_TEST_CASE(only_one_node)\n{\n    Types::DS::NodeBT<int>* bt = Types::DS::CreateBST<int>({10});\n    const std::vector<int> expected = {10};\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderRecursive(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterative(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterativeMorris(bt));\n\n    Types::DS::DeleteBT(&bt);\n}\n\nBOOST_AUTO_TEST_CASE(valid_bt)\n{\n    Types::DS::NodeBT<int>* bt = Types::DS::CreateBST<int>({2, 1, 2, 3});\n    const std::vector<int> expected = {1, 2, 2, 3};\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderRecursive(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterative(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterativeMorris(bt));\n\n    Types::DS::DeleteBT(&bt);\n}\n\nBOOST_AUTO_TEST_CASE(valid_v_shape_bt)\n{\n    Types::DS::NodeBT<int>* bt = Types::DS::CreateBST<int>({10, 5, 3, 20, 30});\n    const std::vector<int> expected = {3, 5, 10, 20, 30};\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderRecursive(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterative(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterativeMorris(bt));\n\n    Types::DS::DeleteBT(&bt);\n}\n\nBOOST_AUTO_TEST_CASE(valid_full_bt)\n{\n    Types::DS::NodeBT<int>* bt = Types::DS::CreateBST<int>({10, 5, 4, 6, 20, 15, 30});\n    const std::vector<int> expected = {4, 5, 6, 10, 15, 20, 30};\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderRecursive(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterative(bt));\n\n    BOOST_CHECK(expected ==\n                Algo::DS::BT::InorderTraversal::InorderIterativeMorris(bt));\n\n    Types::DS::DeleteBT(&bt);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "603fe1d4d3fade52873d279fbcc8defa270aa74c", "size": 2657, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/algorithms/data_structures/bt/test_bt_inorder_traversal.cpp", "max_stars_repo_name": "iamantony/CppNotes", "max_stars_repo_head_hexsha": "2707db6560ad80b0e5e286a04b2d46e5c0280b3f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2020-07-31T14:13:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-03T09:51:43.000Z", "max_issues_repo_path": "test/algorithms/data_structures/bt/test_bt_inorder_traversal.cpp", "max_issues_repo_name": "iamantony/CppNotes", "max_issues_repo_head_hexsha": "2707db6560ad80b0e5e286a04b2d46e5c0280b3f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 28.0, "max_issues_repo_issues_event_min_datetime": "2015-09-22T07:38:21.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-02T11:00:58.000Z", "max_forks_repo_path": "test/algorithms/data_structures/bt/test_bt_inorder_traversal.cpp", "max_forks_repo_name": "iamantony/CppNotes", "max_forks_repo_head_hexsha": "2707db6560ad80b0e5e286a04b2d46e5c0280b3f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2.0, "max_forks_repo_forks_event_min_datetime": "2018-10-11T14:10:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-27T08:53:50.000Z", "avg_line_length": 30.5402298851, "max_line_length": 86, "alphanum_fraction": 0.6341738803, "num_tokens": 723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4416730056646256, "lm_q2_score": 0.1294027231979892, "lm_q1q2_score": 0.05715368969604346}}
{"text": "// Boost.Polygon library polygon_segment_test.cpp file\r\n\r\n//          Copyright Andrii Sydorchuk 2012.\r\n// Distributed under the Boost Software License, Version 1.0.\r\n//    (See accompanying file LICENSE_1_0.txt or copy at\r\n//          http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n// See http://www.boost.org for updates, documentation, and revision history.\r\n\r\n#include <algorithm>\r\n#include <list>\r\n\r\n#define BOOST_TEST_MODULE POLYGON_SEGMENT_TEST\r\n#include <boost/mpl/list.hpp>\r\n#include <boost/test/test_case_template.hpp>\r\n\r\n#include \"boost/polygon/polygon.hpp\"\r\nusing namespace boost::polygon;\r\n\r\ntypedef boost::mpl::list<int> test_types;\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_data_test, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef segment_data<T> segment_type;\r\n  point_type point1(1, 2);\r\n  point_type point2(3, 4);\r\n  segment_type segment1(point1, point2);\r\n  segment_type segment2 = segment1;\r\n\r\n  BOOST_CHECK(segment1.low() == point1);\r\n  BOOST_CHECK(segment1.high() == point2);\r\n  BOOST_CHECK(segment1.get(LOW) == point1);\r\n  BOOST_CHECK(segment1.get(HIGH) == point2);\r\n  BOOST_CHECK(segment1 == segment2);\r\n  BOOST_CHECK(!(segment1 != segment2));\r\n  BOOST_CHECK(!(segment1 < segment2));\r\n  BOOST_CHECK(!(segment1 > segment1));\r\n  BOOST_CHECK(segment1 <= segment2);\r\n  BOOST_CHECK(segment1 >= segment2);\r\n\r\n  segment1.low(point2);\r\n  segment1.high(point1);\r\n  BOOST_CHECK(segment1.low() == point2);\r\n  BOOST_CHECK(segment1.high() == point1);\r\n  BOOST_CHECK(!(segment1 == segment2));\r\n  BOOST_CHECK(segment1 != segment2);\r\n\r\n  segment2.set(LOW, point2);\r\n  segment2.set(HIGH, point1);\r\n  BOOST_CHECK(segment1 == segment2);\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_traits_test, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef segment_data<T> segment_type;\r\n\r\n  point_type point1(1, 2);\r\n  point_type point2(3, 4);\r\n  segment_type segment = segment_mutable_traits<segment_type>::construct(point1, point2);\r\n\r\n  BOOST_CHECK(segment_traits<segment_type>::get(segment, LOW) == point1);\r\n  BOOST_CHECK(segment_traits<segment_type>::get(segment, HIGH) == point2);\r\n\r\n  segment_mutable_traits<segment_type>::set(segment, LOW, point2);\r\n  segment_mutable_traits<segment_type>::set(segment, HIGH, point1);\r\n\r\n  BOOST_CHECK(segment_traits<segment_type>::get(segment, LOW) == point2);\r\n  BOOST_CHECK(segment_traits<segment_type>::get(segment, HIGH) == point1);\r\n}\r\n\r\ntemplate <typename T>\r\nstruct Segment {\r\n  point_data<T> p0;\r\n  point_data<T> p1;\r\n};\r\n\r\nnamespace boost {\r\nnamespace polygon {\r\n  template <typename T>\r\n  struct geometry_concept< Segment<T> > {\r\n    typedef segment_concept type;\r\n  };\r\n\r\n  template <typename T>\r\n  struct segment_traits< Segment<T> > {\r\n    typedef T coordinate_type;\r\n    typedef point_data<T> point_type;\r\n\r\n    static point_type get(const Segment<T>& segment, direction_1d dir) {\r\n      return dir.to_int() ? segment.p1 : segment.p0;\r\n    }\r\n  };\r\n\r\n  template <typename T>\r\n  struct segment_mutable_traits< Segment<T> > {\r\n    typedef point_data<T> point_type;\r\n\r\n    static inline void set(Segment<T>& segment, direction_1d dir, const point_type& point) {\r\n      if (dir.to_int()) {\r\n        segment.p1 = point;\r\n      } else {\r\n        segment.p0 = point;\r\n      }\r\n    }\r\n\r\n    static inline Segment<T> construct(const point_type& point1, const point_type& point2) {\r\n      Segment<T> segment;\r\n      segment.p0 = point1;\r\n      segment.p1 = point2;\r\n      return segment;\r\n    }\r\n  };\r\n}\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test1, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(1, 2);\r\n  point_type point2(3, 4);\r\n  point_type point3(2, 3);\r\n  segment_type segment1 = construct<segment_type>(point1, point2);\r\n  BOOST_CHECK(segment1.p0 == point1);\r\n  BOOST_CHECK(segment1.p1 == point2);\r\n  BOOST_CHECK(get(segment1, LOW) == point1);\r\n  BOOST_CHECK(low(segment1) == point1);\r\n  BOOST_CHECK(get(segment1, HIGH) == point2);\r\n  BOOST_CHECK(high(segment1) == point2);\r\n  BOOST_CHECK(center(segment1) == point3);\r\n\r\n  set(segment1, LOW, point2);\r\n  set(segment1, HIGH, point1);\r\n  BOOST_CHECK(segment1.p0 == point2);\r\n  BOOST_CHECK(segment1.p1 == point1);\r\n  BOOST_CHECK(get(segment1, LOW) == point2);\r\n  BOOST_CHECK(get(segment1, HIGH) == point1);\r\n  low(segment1, point1);\r\n  high(segment1, point2);\r\n  BOOST_CHECK(segment1.p0 == point1);\r\n  BOOST_CHECK(segment1.p1 == point2);\r\n\r\n  segment_data<T> segment2 = copy_construct< segment_data<T> >(segment1);\r\n  BOOST_CHECK(segment1.p0 == segment2.low());\r\n  BOOST_CHECK(segment1.p1 == segment2.high());\r\n  BOOST_CHECK(equivalence(segment1, segment2));\r\n\r\n  segment_data<T> segment3 = construct< segment_data<T> >(point2, point1);\r\n  assign(segment1, segment3);\r\n  BOOST_CHECK(segment1.p0 == point2);\r\n  BOOST_CHECK(segment1.p1 == point1);\r\n  BOOST_CHECK(!equivalence(segment1, segment2));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test2, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(1, 2);\r\n  point_type point2(2, 4);\r\n  point_type point3(0, 0);\r\n  point_type point4(5, 10);\r\n  point_type point5(1, 3);\r\n  point_type point6(2, 3);\r\n  point_type point7(100, 201);\r\n  point_type point8(100, 200);\r\n  point_type point9(100, 199);\r\n  segment_type segment1 = construct<segment_type>(point1, point2);\r\n  segment_type segment2 = construct<segment_type>(point2, point1);\r\n  segment_type segment3 = construct<segment_type>(point1, point5);\r\n\r\n  BOOST_CHECK(orientation(segment1, point1) == 0);\r\n  BOOST_CHECK(orientation(segment1, point2) == 0);\r\n  BOOST_CHECK(orientation(segment1, point3) == 0);\r\n  BOOST_CHECK(orientation(segment1, point4) == 0);\r\n  BOOST_CHECK(orientation(segment1, point5) == 1);\r\n  BOOST_CHECK(orientation(segment2, point5) == -1);\r\n  BOOST_CHECK(orientation(segment1, point6) == -1);\r\n  BOOST_CHECK(orientation(segment2, point6) == 1);\r\n  BOOST_CHECK(orientation(segment1, point7) == 1);\r\n  BOOST_CHECK(orientation(segment2, point7) == -1);\r\n  BOOST_CHECK(orientation(segment1, point8) == 0);\r\n  BOOST_CHECK(orientation(segment1, point9) == -1);\r\n  BOOST_CHECK(orientation(segment2, point9) == 1);\r\n  BOOST_CHECK(orientation(segment3, point6) == -1);\r\n  BOOST_CHECK(orientation(segment3, point3) == 1);\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test3, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(1, 2));\r\n  segment_type segment2 = construct<segment_type>(point_type(0, 0), point_type(2, 4));\r\n  segment_type segment3 = construct<segment_type>(point_type(0, 0), point_type(2, 3));\r\n  segment_type segment4 = construct<segment_type>(point_type(0, 0), point_type(2, 5));\r\n  segment_type segment5 = construct<segment_type>(point_type(0, 2), point_type(2, 0));\r\n\r\n  BOOST_CHECK(orientation(segment1, segment2) == 0);\r\n  BOOST_CHECK(orientation(segment1, segment3) == -1);\r\n  BOOST_CHECK(orientation(segment3, segment1) == 1);\r\n  BOOST_CHECK(orientation(segment1, segment4) == 1);\r\n  BOOST_CHECK(orientation(segment4, segment1) == -1);\r\n  BOOST_CHECK(orientation(segment1, segment5) == -1);\r\n  BOOST_CHECK(orientation(segment5, segment1) == 1);\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test4, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(1, 2);\r\n  point_type point2(3, 6);\r\n  point_type point3(2, 4);\r\n  point_type point4(4, 8);\r\n  point_type point5(0, 0);\r\n  segment_type segment = construct<segment_type>(point1, point2);\r\n\r\n  BOOST_CHECK(contains(segment, point1, true));\r\n  BOOST_CHECK(contains(segment, point2, true));\r\n  BOOST_CHECK(!contains(segment, point1, false));\r\n  BOOST_CHECK(!contains(segment, point2, false));\r\n  BOOST_CHECK(contains(segment, point3, false));\r\n  BOOST_CHECK(!contains(segment, point4, true));\r\n  BOOST_CHECK(!contains(segment, point5, true));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test5, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(0, 0);\r\n  point_type point2(10, 0);\r\n  point_type point3(5, 0);\r\n  point_type point4(-1, 0);\r\n  point_type point5(11, 0);\r\n  segment_type segment = construct<segment_type>(point1, point2);\r\n\r\n  BOOST_CHECK(contains(segment, point1, true));\r\n  BOOST_CHECK(contains(segment, point2, true));\r\n  BOOST_CHECK(!contains(segment, point1, false));\r\n  BOOST_CHECK(!contains(segment, point2, false));\r\n  BOOST_CHECK(contains(segment, point3, false));\r\n  BOOST_CHECK(!contains(segment, point4, true));\r\n  BOOST_CHECK(!contains(segment, point5, true));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test6, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(0, 0);\r\n  point_type point2(1, 2);\r\n  point_type point3(2, 4);\r\n  point_type point4(3, 6);\r\n  point_type point5(4, 8);\r\n  point_type point6(5, 10);\r\n  segment_type segment1 = construct<segment_type>(point2, point5);\r\n  segment_type segment2 = construct<segment_type>(point3, point4);\r\n  segment_type segment3 = construct<segment_type>(point1, point3);\r\n  segment_type segment4 = construct<segment_type>(point4, point6);\r\n\r\n  BOOST_CHECK(contains(segment1, segment2, false));\r\n  BOOST_CHECK(!contains(segment2, segment1, true));\r\n  BOOST_CHECK(!contains(segment1, segment3, true));\r\n  BOOST_CHECK(!contains(segment1, segment4, true));\r\n  BOOST_CHECK(contains(segment1, segment1, true));\r\n  BOOST_CHECK(!contains(segment1, segment1, false));\r\n}\r\n\r\ntemplate<typename T>\r\nstruct Transformer {\r\n  void scale(T& x, T& y) const {\r\n    x *= 2;\r\n    y *= 2;\r\n  }\r\n\r\n  void transform(T& x, T& y) const {\r\n    T tmp = x;\r\n    x = y;\r\n    y = tmp;\r\n  }\r\n};\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test7, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(1, 2);\r\n  point_type point2(4, 6);\r\n  segment_type segment1 = construct<segment_type>(point1, point2);\r\n\r\n  scale_up(segment1, 3);\r\n  BOOST_CHECK(low(segment1) == point_type(3, 6));\r\n  BOOST_CHECK(high(segment1) == point_type(12, 18));\r\n\r\n  scale_down(segment1, 3);\r\n  BOOST_CHECK(low(segment1) == point1);\r\n  BOOST_CHECK(high(segment1) == point2);\r\n  BOOST_CHECK(length(segment1) == 5);\r\n\r\n  move(segment1, HORIZONTAL, 1);\r\n  move(segment1, VERTICAL, 2);\r\n  BOOST_CHECK(low(segment1) == point_type(2, 4));\r\n  BOOST_CHECK(high(segment1) == point_type(5, 8));\r\n  BOOST_CHECK(length(segment1) == 5);\r\n\r\n  convolve(segment1, point_type(1, 2));\r\n  BOOST_CHECK(low(segment1) == point_type(3, 6));\r\n  BOOST_CHECK(high(segment1) == point_type(6, 10));\r\n\r\n  deconvolve(segment1, point_type(2, 4));\r\n  BOOST_CHECK(low(segment1) == point1);\r\n  BOOST_CHECK(high(segment1) == point2);\r\n\r\n  scale(segment1, Transformer<T>());\r\n  BOOST_CHECK(low(segment1) == point_type(2, 4));\r\n  BOOST_CHECK(high(segment1) == point_type(8, 12));\r\n  transform(segment1, Transformer<T>());\r\n  BOOST_CHECK(low(segment1) == point_type(4, 2));\r\n  BOOST_CHECK(high(segment1) == point_type(12, 8));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test8, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(1, 2));\r\n  segment_type segment2 = construct<segment_type>(point_type(1, 2), point_type(2, 4));\r\n  segment_type segment3 = construct<segment_type>(point_type(2, 4), point_type(0, 4));\r\n  segment_type segment4 = construct<segment_type>(point_type(0, 4), point_type(0, 0));\r\n\r\n  BOOST_CHECK(abuts(segment1, segment2, HIGH));\r\n  BOOST_CHECK(abuts(segment2, segment3, HIGH));\r\n  BOOST_CHECK(abuts(segment3, segment4, HIGH));\r\n  BOOST_CHECK(abuts(segment4, segment1, HIGH));\r\n\r\n  BOOST_CHECK(!abuts(segment1, segment2, LOW));\r\n  BOOST_CHECK(!abuts(segment2, segment3, LOW));\r\n  BOOST_CHECK(!abuts(segment3, segment4, LOW));\r\n  BOOST_CHECK(!abuts(segment4, segment1, LOW));\r\n\r\n  BOOST_CHECK(abuts(segment2, segment1));\r\n  BOOST_CHECK(abuts(segment3, segment2));\r\n  BOOST_CHECK(abuts(segment4, segment3));\r\n  BOOST_CHECK(abuts(segment1, segment4));\r\n\r\n  BOOST_CHECK(!abuts(segment1, segment3));\r\n  BOOST_CHECK(!abuts(segment2, segment4));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test9, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(2, 2));\r\n  segment_type segment2 = construct<segment_type>(point_type(1, 1), point_type(3, 3));\r\n  segment_type segment3 = construct<segment_type>(point_type(2, 2), point_type(-1, -1));\r\n  segment_type segment4 = construct<segment_type>(point_type(1, 3), point_type(3, 1));\r\n  segment_type segment5 = construct<segment_type>(point_type(2, 2), point_type(1, 3));\r\n\r\n  BOOST_CHECK(intersects(segment1, segment2, false));\r\n  BOOST_CHECK(intersects(segment1, segment2, true));\r\n  BOOST_CHECK(intersects(segment1, segment3, false));\r\n  BOOST_CHECK(intersects(segment1, segment3, true));\r\n  BOOST_CHECK(intersects(segment2, segment3, false));\r\n  BOOST_CHECK(intersects(segment2, segment3, true));\r\n  BOOST_CHECK(intersects(segment4, segment3, false));\r\n  BOOST_CHECK(intersects(segment4, segment3, true));\r\n  BOOST_CHECK(intersects(segment4, segment2, false));\r\n  BOOST_CHECK(intersects(segment4, segment2, true));\r\n  BOOST_CHECK(!intersects(segment3, segment5, false));\r\n  BOOST_CHECK(intersects(segment3, segment5, true));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test10, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(0, 2));\r\n  segment_type segment2 = construct<segment_type>(point_type(0, 1), point_type(0, 3));\r\n  segment_type segment3 = construct<segment_type>(point_type(0, 1), point_type(0, 2));\r\n  segment_type segment4 = construct<segment_type>(point_type(0, 2), point_type(0, 3));\r\n  segment_type segment5 = construct<segment_type>(point_type(0, 2), point_type(2, 2));\r\n  segment_type segment6 = construct<segment_type>(point_type(0, 1), point_type(1, 1));\r\n\r\n  BOOST_CHECK(intersects(segment1, segment1, false));\r\n  BOOST_CHECK(intersects(segment1, segment1, true));\r\n  BOOST_CHECK(intersects(segment1, segment2, false));\r\n  BOOST_CHECK(intersects(segment1, segment2, true));\r\n  BOOST_CHECK(intersects(segment1, segment3, false));\r\n  BOOST_CHECK(intersects(segment1, segment3, true));\r\n  BOOST_CHECK(intersects(segment2, segment3, false));\r\n  BOOST_CHECK(intersects(segment2, segment3, true));\r\n  BOOST_CHECK(!intersects(segment1, segment4, false));\r\n  BOOST_CHECK(intersects(segment1, segment4, true));\r\n  BOOST_CHECK(!intersects(segment1, segment5, false));\r\n  BOOST_CHECK(intersects(segment1, segment5, true));\r\n  BOOST_CHECK(intersects(segment1, segment6, false));\r\n  BOOST_CHECK(intersects(segment1, segment6, true));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test11, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  point_type point1(1, 2);\r\n  point_type point2(7, 10);\r\n  segment_type segment1 = construct<segment_type>(point1, point2);\r\n\r\n  BOOST_CHECK(euclidean_distance(segment1, point1) == 0.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, point2) == 0.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, point_type(10, 14)) == 5.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, point_type(-3, -1)) == 5.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, point_type(0, 9)) == 5.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, point_type(8, 3)) == 5.0);\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test12, T, test_types) {\r\n  typedef point_data<T> point_type;\r\n  typedef Segment<T> segment_type;\r\n\r\n  segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(3, 4));\r\n  segment_type segment2 = construct<segment_type>(point_type(2, 0), point_type(0, 2));\r\n  segment_type segment3 = construct<segment_type>(point_type(1, -7), point_type(10, 5));\r\n  segment_type segment4 = construct<segment_type>(point_type(7, 7), point_type(10, 11));\r\n\r\n  BOOST_CHECK(euclidean_distance(segment1, segment2) == 0.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, segment3) == 5.0);\r\n  BOOST_CHECK(euclidean_distance(segment1, segment4) == 5.0);\r\n}\r\n", "meta": {"hexsha": "141dc7b8a191ed108a159e59989b492e5f3d2fb4", "size": 16402, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/polygon/test/polygon_segment_test.cpp", "max_stars_repo_name": "jmuskaan72/Boost", "max_stars_repo_head_hexsha": "047e36c01841a8cd6a5c74d4e3034da46e327bc1", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 198.0, "max_stars_repo_stars_event_min_datetime": "2015-01-13T05:47:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T04:46:46.000Z", "max_issues_repo_path": "libs/polygon/test/polygon_segment_test.cpp", "max_issues_repo_name": "xiaoliang2121/Boost", "max_issues_repo_head_hexsha": "fc90c3fde129c62565c023f091eddc4a7ed9902b", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 4.0, "max_issues_repo_issues_event_min_datetime": "2015-03-19T08:23:23.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-24T07:48:47.000Z", "max_forks_repo_path": "libs/polygon/test/polygon_segment_test.cpp", "max_forks_repo_name": "xiaoliang2121/Boost", "max_forks_repo_head_hexsha": "fc90c3fde129c62565c023f091eddc4a7ed9902b", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 139.0, "max_forks_repo_forks_event_min_datetime": "2015-01-15T20:09:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-31T15:21:16.000Z", "avg_line_length": 37.9675925926, "max_line_length": 93, "alphanum_fraction": 0.7151566882, "num_tokens": 4442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.11596070908851644, "lm_q1q2_score": 0.05707448522313842}}
{"text": "/**\n * @file ipdgfem.cc\n * @brief NPDE homework IPDGFEM code\n * @author Philippe Peter\n * @date 22.11.2019\n * @copyright Developed at ETH Zurich\n */\n\n#include \"ipdgfem.h\"\n\n#include <Eigen/Core>\n\nnamespace IPDGFEM {\n\n/* SAM_LISTING_BEGIN_1 */\nEigen::VectorXd dummyFunction(double x, int n) {\n#if SOLUTION\n  // Appears only in mastersolution\n  return Eigen::Vector2d::Constant(1.0);\n#else\n  // Appears only in mysolution and templates\n  return Eigen::Vector2d::Zero();\n#endif\n}\n/* SAM_LISTING_END_1 */\n\n}  // namespace IPDGFEM\n", "meta": {"hexsha": "c03ade95c7e68728ff74a6133f7b8aae8934b297", "size": 525, "ext": "cc", "lang": "C++", "max_stars_repo_path": "developers/IPDGFEM/mastersolution/ipdgfem.cc", "max_stars_repo_name": "padomu/NPDECODES", "max_stars_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15.0, "max_stars_repo_stars_event_min_datetime": "2019-04-29T11:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T05:10:58.000Z", "max_issues_repo_path": "developers/IPDGFEM/mastersolution/ipdgfem.cc", "max_issues_repo_name": "padomu/NPDECODES", "max_issues_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12.0, "max_issues_repo_issues_event_min_datetime": "2020-02-29T15:05:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T13:51:07.000Z", "max_forks_repo_path": "developers/IPDGFEM/mastersolution/ipdgfem.cc", "max_forks_repo_name": "padomu/NPDECODES", "max_forks_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 26.0, "max_forks_repo_forks_event_min_datetime": "2020-01-09T15:59:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T16:27:33.000Z", "avg_line_length": 18.75, "max_line_length": 48, "alphanum_fraction": 0.7047619048, "num_tokens": 154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.399811640739795, "lm_q2_score": 0.1422318931919251, "lm_q1q2_score": 0.05686596658259086}}
{"text": "/*\r\n [auto_generated]\r\n boost/numeric/odeint/util/ublas_wrapper.hpp\r\n\r\n [begin_description]\r\n Resizing for ublas::vector and ublas::matrix\r\n [end_description]\r\n\r\n Copyright 2009-2011 Karsten Ahnert\r\n Copyright 2009-2011 Mario Mulansky\r\n\r\n Distributed under the Boost Software License, Version 1.0.\r\n (See accompanying file LICENSE_1_0.txt or\r\n copy at http://www.boost.org/LICENSE_1_0.txt)\r\n */\r\n\r\n\r\n#ifndef BOOST_NUMERIC_ODEINT_UTIL_UBLAS_WRAPPER_HPP_INCLUDED\r\n#define BOOST_NUMERIC_ODEINT_UTIL_UBLAS_WRAPPER_HPP_INCLUDED\r\n\r\n\r\n#include <boost/type_traits/integral_constant.hpp>\r\n#include <boost/numeric/ublas/vector.hpp>\r\n#include <boost/numeric/ublas/matrix.hpp>\r\n#include <boost/numeric/ublas/lu.hpp>\r\n\r\n#include <boost/numeric/odeint/util/is_resizeable.hpp>\r\n#include <boost/numeric/odeint/util/state_wrapper.hpp>\r\n\r\nnamespace boost {\r\nnamespace numeric {\r\nnamespace odeint {\r\n\r\n/*\r\n * resizeable specialization for boost::numeric::ublas::vector\r\n */\r\ntemplate< class T , class A >\r\nstruct is_resizeable< boost::numeric::ublas::vector< T , A > >\r\n{\r\n    typedef boost::true_type type;\r\n    const static bool value = type::value;\r\n};\r\n\r\n\r\n/*\r\n * resizeable specialization for boost::numeric::ublas::matrix\r\n */\r\ntemplate< class T , class L , class A >\r\nstruct is_resizeable< boost::numeric::ublas::matrix< T , L , A > >\r\n{\r\n    typedef boost::true_type type;\r\n    const static bool value = type::value;\r\n};\r\n\r\n\r\n/*\r\n * resizeable specialization for boost::numeric::ublas::permutation_matrix\r\n */\r\ntemplate< class T , class A >\r\nstruct is_resizeable< boost::numeric::ublas::permutation_matrix< T , A > >\r\n{\r\n    typedef boost::true_type type;\r\n    const static bool value = type::value;\r\n};\r\n\r\n\r\n// specialization for ublas::matrix\r\n// same size and resize specialization for matrix-matrix resizing\r\ntemplate< class T , class L , class A , class T2 , class L2 , class A2 >\r\nstruct same_size_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::matrix< T2 , L2 , A2 > >\r\n{\r\n    static bool same_size( const boost::numeric::ublas::matrix< T , L , A > &m1 ,\r\n                           const boost::numeric::ublas::matrix< T2 , L2 , A2 > &m2 )\r\n    {\r\n        return ( ( m1.size1() == m2.size1() ) && ( m1.size2() == m2.size2() ) );\r\n    }\r\n};\r\n\r\ntemplate< class T , class L , class A , class T2 , class L2 , class A2 >\r\nstruct resize_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::matrix< T2 , L2 , A2 > >\r\n{\r\n    static void resize( boost::numeric::ublas::matrix< T , L , A > &m1 ,\r\n                        const boost::numeric::ublas::matrix< T2 , L2 , A2 > &m2 )\r\n    {\r\n        m1.resize( m2.size1() , m2.size2() );\r\n    }\r\n};\r\n\r\n\r\n\r\n// same size and resize specialization for matrix-vector resizing\r\ntemplate< class T , class L , class A , class T_V , class A_V >\r\nstruct same_size_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::vector< T_V , A_V > >\r\n{\r\n    static bool same_size( const boost::numeric::ublas::matrix< T , L , A > &m ,\r\n                           const boost::numeric::ublas::vector< T_V , A_V > &v )\r\n    {\r\n        return ( ( m.size1() == v.size() ) && ( m.size2() == v.size() ) );\r\n    }\r\n};\r\n\r\ntemplate< class T , class L , class A , class T_V , class A_V >\r\nstruct resize_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::vector< T_V , A_V > >\r\n{\r\n    static void resize( boost::numeric::ublas::matrix< T , L , A > &m ,\r\n                        const boost::numeric::ublas::vector< T_V , A_V > &v )\r\n    {\r\n        m.resize( v.size() , v.size() );\r\n    }\r\n};\r\n\r\n\r\n\r\n// specialization for ublas::permutation_matrix\r\n// same size and resize specialization for matrix-vector resizing\r\ntemplate< class T , class A , class T_V , class A_V >\r\nstruct same_size_impl< boost::numeric::ublas::permutation_matrix< T , A > , boost::numeric::ublas::vector< T_V , A_V > >\r\n{\r\n    static bool same_size( const boost::numeric::ublas::permutation_matrix< T , A > &m ,\r\n                           const boost::numeric::ublas::vector< T_V , A_V > &v )\r\n    {\r\n        return ( m.size() == v.size() ); // && ( m.size2() == v.size() ) );\r\n    }\r\n};\r\n\r\ntemplate< class T , class A , class T_V , class A_V >\r\nstruct resize_impl< boost::numeric::ublas::vector< T_V , A_V > , boost::numeric::ublas::permutation_matrix< T , A > >\r\n{\r\n    static void resize( const boost::numeric::ublas::vector< T_V , A_V > &v,\r\n                        boost::numeric::ublas::permutation_matrix< T , A > &m )\r\n    {\r\n        m.resize( v.size() , v.size() );\r\n    }\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\ntemplate< class T , class A >\r\nstruct state_wrapper< boost::numeric::ublas::permutation_matrix< T , A > > // with resizing\r\n{\r\n    typedef boost::numeric::ublas::permutation_matrix< T , A > state_type;\r\n    typedef state_wrapper< state_type > state_wrapper_type;\r\n\r\n    state_type m_v;\r\n\r\n    state_wrapper() : m_v( 1 ) // permutation matrix constructor requires a size, choose 1 as default\r\n    { }\r\n\r\n};\r\n\r\n\r\n\r\n\r\n} } }\r\n\r\n//// all specializations done, ready to include state_wrapper\r\n//\r\n//#include <boost/numeric/odeint/util/state_wrapper.hpp>\r\n//\r\n//namespace boost {\r\n//namespace numeric {\r\n//namespace odeint {\r\n//\r\n///* specialization for permutation matrices wrapper because we need to change the construction */\r\n//template< class T , class A >\r\n//struct state_wrapper< boost::numeric::ublas::permutation_matrix< T , A > , true > // with resizing\r\n//{\r\n//    typedef boost::numeric::ublas::permutation_matrix< T , A > state_type;\r\n//    typedef state_wrapper< state_type > state_wrapper_type;\r\n//    //typedef typename V::value_type value_type;\r\n//    typedef boost::true_type is_resizeable;\r\n//\r\n//    state_type m_v;\r\n//\r\n//    state_wrapper() : m_v( 1 ) // permutation matrix constructor requires a size, choose 1 as default\r\n//    { }\r\n//\r\n//    template< class T_V , class A_V >\r\n//    bool same_size( const boost::numeric::ublas::vector< T_V , A_V > &x )\r\n//    {\r\n//        return boost::numeric::odeint::same_size( m_v , x );\r\n//    }\r\n//\r\n//    template< class T_V , class A_V >\r\n//    bool resize( const boost::numeric::ublas::vector< T_V , A_V > &x )\r\n//    {\r\n//        //standard resizing done like for std::vector\r\n//        if( !same_size( x ) )\r\n//        {\r\n//            boost::numeric::odeint::resize( m_v , x );\r\n//            return true;\r\n//        } else\r\n//            return false;\r\n//    }\r\n//};\r\n//\r\n//}\r\n//}\r\n//}\r\n\r\n\r\n/*\r\n * preparing ublas::matrix for boost::range, such that ublas::matrix can be used in all steppers with the range algebra\r\n */\r\n\r\nnamespace boost\r\n{\r\ntemplate< class T , class L , class A >\r\nstruct range_mutable_iterator< boost::numeric::ublas::matrix< T , L , A > >\r\n{\r\n    typedef typename boost::numeric::ublas::matrix< T , L , A >::array_type::iterator type;\r\n};\r\n\r\ntemplate< class T , class L , class A >\r\nstruct range_const_iterator< boost::numeric::ublas::matrix< T , L , A > >\r\n{\r\n    typedef typename boost::numeric::ublas::matrix< T , L , A >::array_type::const_iterator type;\r\n};\r\n\r\n} // namespace boost\r\n\r\n\r\nnamespace boost { namespace numeric { namespace ublas {\r\n\r\ntemplate< class T , class L , class A >\r\ninline typename matrix< T , L , A >::array_type::iterator\r\nrange_begin( matrix< T , L , A > &x )\r\n{\r\n    return x.data().begin();\r\n}\r\n\r\ntemplate< class T , class L , class A >\r\ninline typename matrix< T , L , A >::array_type::const_iterator\r\nrange_begin( const matrix< T , L , A > &x )\r\n{\r\n    return x.data().begin();\r\n}\r\n\r\ntemplate< class T , class L , class A >\r\ninline typename matrix< T , L , A >::array_type::iterator\r\nrange_end( matrix< T , L , A > &x )\r\n{\r\n    return x.data().end();\r\n}\r\n\r\ntemplate< class T , class L , class A >\r\ninline typename matrix< T , L , A >::array_type::const_iterator\r\nrange_end( const matrix< T , L , A > &x )\r\n{\r\n    return x.data().end();\r\n}\r\n\r\n} } } // namespace boost::numeric::ublas\r\n\r\n\r\n#endif // BOOST_NUMERIC_ODEINT_UTIL_UBLAS_WRAPPER_HPP_INCLUDED\r\n", "meta": {"hexsha": "a9a7706b5fb1b7b1a912920e509fdaef48bf712b", "size": 7938, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "third_party/boost/numeric/odeint/util/ublas_wrapper.hpp", "max_stars_repo_name": "PXLVision/opengv", "max_stars_repo_head_hexsha": "e48f77da4db7b8cee36ec677ed4ff5c5354571bb", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4.0, "max_stars_repo_stars_event_min_datetime": "2018-08-22T03:43:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-11T18:20:27.000Z", "max_issues_repo_path": "third_party/boost/numeric/odeint/util/ublas_wrapper.hpp", "max_issues_repo_name": "PXLVision/opengv", "max_issues_repo_head_hexsha": "e48f77da4db7b8cee36ec677ed4ff5c5354571bb", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 7.0, "max_issues_repo_issues_event_min_datetime": "2020-10-06T16:34:12.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-06T17:29:22.000Z", "max_forks_repo_path": "third_party/boost/numeric/odeint/util/ublas_wrapper.hpp", "max_forks_repo_name": "PXLVision/opengv", "max_forks_repo_head_hexsha": "e48f77da4db7b8cee36ec677ed4ff5c5354571bb", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 71.0, "max_forks_repo_forks_event_min_datetime": "2015-03-26T10:28:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-07T10:09:12.000Z", "avg_line_length": 30.4137931034, "max_line_length": 121, "alphanum_fraction": 0.6199294533, "num_tokens": 2101, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4960938294709195, "lm_q2_score": 0.11436853523769842, "lm_q1q2_score": 0.05673752461704961}}
{"text": "#define BOOST_TEST_MODULE factorial header only test\n#include <boost/test/included/unit_test.hpp>\n#include \"../factorial.cpp\"\n\nBOOST_AUTO_TEST_CASE(Factorials_for_zero) {\n    BOOST_TEST( Factorial(0) == 1 );\n}\n\nBOOST_AUTO_TEST_CASE(Factorials_for_positive_numbers) {\n    BOOST_CHECK( Factorial(1) == 1 );\n    BOOST_CHECK( Factorial(2) == 2 );\n    BOOST_CHECK( Factorial(3) == 6 );\n    BOOST_CHECK( Factorial(10) == 3628800 );\n}", "meta": {"hexsha": "c0bbe115327a854084ac12f3e5fe8b981e7d17be", "size": 427, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/boost-header-test-factorial.cpp", "max_stars_repo_name": "mekyas/Unit-Test-in-Cpp", "max_stars_repo_head_hexsha": "dabfc7f83380c2c056c421bbf9f71f54acca8a0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2021-11-18T05:42:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T05:43:59.000Z", "max_issues_repo_path": "test/boost-header-test-factorial.cpp", "max_issues_repo_name": "mekyas/Unit-Test-in-Cpp", "max_issues_repo_head_hexsha": "dabfc7f83380c2c056c421bbf9f71f54acca8a0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/boost-header-test-factorial.cpp", "max_forks_repo_name": "mekyas/Unit-Test-in-Cpp", "max_forks_repo_head_hexsha": "dabfc7f83380c2c056c421bbf9f71f54acca8a0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5, "max_line_length": 55, "alphanum_fraction": 0.718969555, "num_tokens": 117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4960938294709195, "lm_q2_score": 0.11436852467249821, "lm_q1q2_score": 0.05673751937571898}}
{"text": "// Copyright 2014, Max Planck Society.\r\n// Distributed under the BSD 3-Clause license.\r\n// (See accompanying file LICENSE.txt or copy at\r\n// http://opensource.org/licenses/BSD-3-Clause)\r\n\r\n#ifndef BOOST_UBLAS_MATRIX_HELPER_GRASSMANN_AVERAGES_PCA_HPP__\r\n#define BOOST_UBLAS_MATRIX_HELPER_GRASSMANN_AVERAGES_PCA_HPP__\r\n\r\n/*!@file\r\n * Contains utility classes around uBlas matrices(mainly an iterator on matrix rows).\r\n */\r\n\r\n#include <boost/numeric/ublas/matrix_proxy.hpp>\r\n#include <boost/iterator/iterator_adaptor.hpp>\r\n\r\n\r\n\r\nnamespace grassmann_averages_pca\r\n{\r\n  namespace details\r\n  {\r\n    namespace ublas_helpers\r\n    {\r\n\r\n\r\n      /*!@brief Iterator on rows of a matrix.\r\n       *\r\n       * This iterator is an adaptor that iterates over the rows of an ublas matrix. The returned element\r\n       * is a matrix proxy that provides an ublas vector semantic. \r\n       * @author Raffi Enficiaud\r\n       */\r\n      template <class matrix_t>\r\n      class row_iter : \r\n        public boost::iterator_facade<\r\n          row_iter<matrix_t>                            // Derived\r\n        , boost::numeric::ublas::matrix_row<matrix_t>   // Value\r\n        , std::random_access_iterator_tag               // CategoryOrTraversal\r\n        , boost::numeric::ublas::matrix_row<matrix_t>   // reference\r\n        >\r\n      {\r\n      private:\r\n        typedef row_iter<matrix_t> this_type;\r\n\r\n        // this is a nice technic for SFNIAE, taken from the examples of boost.iterator.\r\n        struct enabler {};\r\n\r\n        size_t index;\r\n        matrix_t *matrix;\r\n\r\n        typedef boost::numeric::ublas::matrix_row<matrix_t> return_t;\r\n\r\n      public:\r\n\r\n        //! Default constructor\r\n        row_iter() : index(std::numeric_limits<size_t>::max()), matrix(0)\r\n        {}\r\n\r\n        /*! Constructs an iterator on the nth rows of the given matrix\r\n         *\r\n         * @param[in] matrix_ the matrix from which the rows will be extracted\r\n         * @param[in] index_ the index of the row of the matrix on which the iterator starts.\r\n         *\r\n         * @pre the provided index is lower than the total number of rows of the matrix.\r\n         */\r\n        row_iter(matrix_t &matrix_, size_t index_) : index(index_), matrix(&matrix_)\r\n        {\r\n          // below the <= is correct since it should be possible to give an index one passed the end\r\n          assert(index_ <= matrix->size1());\r\n        }\r\n\r\n\r\n        /*! Constructor from an iterator \r\n         *\r\n         * This constructor is selected when the row_iter is instanciated from a row_iter on another type, and\r\n         * type are convertible from the other matrix type to the current type (example non-const to const). Otherwise\r\n         * the SFNIAE does reveal this constructor in the set of available constructor for this class.\r\n         */\r\n        template <class other_matrix_t>\r\n        row_iter(\r\n          row_iter<other_matrix_t> const& other, \r\n          typename boost::enable_if<\r\n            boost::is_convertible<typename other_matrix_t::iterator1, typename matrix_t::iterator1>, \r\n            enabler>::type = enabler()) \r\n          : \r\n          index(other.index), matrix(other.matrix)\r\n        {}\r\n\r\n      private:\r\n        friend class boost::iterator_core_access;\r\n\r\n        //!@name boost::iterator_facade interface\r\n        //!@{\r\n\r\n        void increment()\r\n        {\r\n          assert(matrix);\r\n          assert(index < matrix->size1());\r\n          index++;\r\n        }\r\n\r\n        bool equal(this_type const& other) const\r\n        {\r\n          assert(matrix == other.matrix);\r\n          return this->index == other.index;\r\n        }\r\n\r\n        return_t dereference() const\r\n        {\r\n          assert(matrix);\r\n          return return_t(*matrix, index);\r\n        }\r\n\r\n        typename this_type::difference_type distance_to(this_type const& r) const\r\n        {\r\n          assert((matrix != 0) && (r.matrix == matrix));\r\n          return typename this_type::difference_type(r.index) - typename this_type::difference_type(index); // sign promotion\r\n        }\r\n\r\n        void advance(typename this_type::difference_type n)\r\n        {\r\n          if(n < 0)\r\n          {\r\n            assert((-n) <= static_cast<typename this_type::difference_type>(index));\r\n            index -= n;\r\n          }\r\n          else\r\n          {\r\n            assert(n + index <= matrix->size1());\r\n            index += n;\r\n          }\r\n          \r\n        }\r\n\r\n        //!@}\r\n\r\n      };\r\n\r\n    }\r\n  }\r\n}\r\n\r\n#endif\r\n", "meta": {"hexsha": "faa65d216a1c68d02ede07c2c0309f45a8df9209", "size": 4463, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "include/private/boost_ublas_row_iterator.hpp", "max_stars_repo_name": "MPI-Intelligent-Systems-Tuebingen/-Grassmann-Averages-PCA", "max_stars_repo_head_hexsha": "247ed7c8125057b55fc7ef3f26e8c106e09b8ad0", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 26.0, "max_stars_repo_stars_event_min_datetime": "2015-07-15T11:14:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T01:47:55.000Z", "max_issues_repo_path": "include/private/boost_ublas_row_iterator.hpp", "max_issues_repo_name": "MPI-Intelligent-Systems-Tuebingen/-Grassmann-Averages-PCA", "max_issues_repo_head_hexsha": "247ed7c8125057b55fc7ef3f26e8c106e09b8ad0", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2015-11-20T11:08:11.000Z", "max_issues_repo_issues_event_max_datetime": "2016-01-01T17:40:30.000Z", "max_forks_repo_path": "include/private/boost_ublas_row_iterator.hpp", "max_forks_repo_name": "MPI-Intelligent-Systems-Tuebingen/-Grassmann-Averages-PCA", "max_forks_repo_head_hexsha": "247ed7c8125057b55fc7ef3f26e8c106e09b8ad0", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4.0, "max_forks_repo_forks_event_min_datetime": "2018-07-11T12:33:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T12:51:49.000Z", "avg_line_length": 31.2097902098, "max_line_length": 126, "alphanum_fraction": 0.5796549406, "num_tokens": 952, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583464, "lm_q2_score": 0.11596072283669216, "lm_q1q2_score": 0.05662169546765928}}
{"text": "//==============================================================================\n//         Copyright 2003 - 2012   LASMEA UMR 6602 CNRS/Univ. Clermont II\n//         Copyright 2009 - 2012   LRI    UMR 8623 CNRS/Univ Paris Sud XI\n//\n//          Distributed under the Boost Software License, Version 1.0.\n//                 See accompanying file LICENSE.txt or copy at\n//                     http://www.boost.org/LICENSE_1_0.txt\n//==============================================================================\n#define NT2_UNIT_MODULE \"nt2 boost.simd.arithmetic toolbox - fma/scalar Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// unit test behavior of boost.simd.arithmetic components in scalar mode\n//////////////////////////////////////////////////////////////////////////////\n/// created by jt the 01/12/2010\n///\n#include <nt2/arithmetic/include/functions/fma.hpp>\n#include <boost/dispatch/functor/meta/call.hpp>\n#include <nt2/sdk/unit/tests/relation.hpp>\n#include <nt2/sdk/unit/tests/type_expr.hpp>\n#include <nt2/sdk/unit/tests/ulp.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/include/constants/inf.hpp>\n#include <nt2/include/constants/minf.hpp>\n#include <nt2/include/constants/one.hpp>\n#include <nt2/include/constants/mone.hpp>\n#include <nt2/include/constants/zero.hpp>\n#include <nt2/include/constants/two.hpp>\n#include <nt2/include/constants/nan.hpp>\n#include <nt2/include/constants/minf.hpp>\n\n\nNT2_TEST_CASE_TPL ( fma_real__3_0, BOOST_SIMD_REAL_TYPES)\n{\n\n  using nt2::fma;\n  using nt2::tag::fma_;\n  typedef std::complex<T> cT;\n  typedef typename boost::dispatch::meta::call<fma_(cT,cT,cT)>::type r_t;\n  typedef typename nt2::meta::scalar_of<r_t>::type sr_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( typename boost::dispatch::meta::call<fma_(cT,cT,cT)>::type, cT );\n\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(fma(cT(nt2::Inf<T>()), cT(nt2::Inf<T>()), cT(nt2::Inf<T>())), cT(nt2::Inf<T>()), 0);\n  NT2_TEST_EQUAL(fma(cT(nt2::Minf<T>()), cT(nt2::Minf<T>()), cT(nt2::Minf<T>())), cT(nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(cT(nt2::Mone<T>()), cT(nt2::Mone<T>()), cT(nt2::Mone<T>())), cT(nt2::Zero<T>()));\n  NT2_TEST_EQUAL(fma(cT(nt2::Nan<T>()), cT(nt2::Nan<T>()), cT(nt2::Nan<T>())), cT(nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(cT(nt2::One<T>()), cT(nt2::One<T>()), cT(nt2::One<T>())), cT(nt2::Two<T>()));\n  NT2_TEST_EQUAL(fma(cT(nt2::Zero<T>()), cT(nt2::Zero<T>()), cT(nt2::Zero<T>())), cT(nt2::Zero<T>()));\n} // end of test for floating_\n\n\n\nNT2_TEST_CASE_TPL ( fma_various,  BOOST_SIMD_REAL_TYPES)\n{\n\n  using nt2::fma;\n  using nt2::tag::fma_;\n  typedef std::complex<T> cT;\n  typedef typename nt2::meta::as_imaginary<T>::type iT;\n\n  std::cout << \"0\\n\";\n  NT2_TEST_EQUAL(fma(T(2), T(3), T(4)), T(10));\n  NT2_TEST_EQUAL(fma(cT(2), cT(3), cT(4)), cT(10));\n  NT2_TEST_EQUAL(    cT(2)*cT(3)+cT(4), cT(10));\n  std::cout << \"1\\n\";\n  NT2_TEST_EQUAL(fma(cT(2), cT(3), iT(4)), cT(6, 4));\n  NT2_TEST_EQUAL(fma(cT(2), cT(3), cT(0, 4)), cT(6, 4));\n  NT2_TEST_EQUAL(    cT(2)*cT(3)+cT(0, 4), cT(6, 4));\n  std::cout << \"2\\n\";\n  NT2_TEST_EQUAL(fma(cT(2), iT(3), cT(4)), cT(4, 6));\n  NT2_TEST_EQUAL(fma(cT(2), cT(0, 3), cT(4)), cT(4, 6));\n  NT2_TEST_EQUAL((cT(2)*cT(0, 3)+cT(4)), cT(4, 6));\n  std::cout << \"3\\n\";\n  NT2_TEST_EQUAL(fma(iT(2), cT(3), cT(4)), cT(4, 6));\n  NT2_TEST_EQUAL(fma(cT(0, 2), cT(3), cT(4)), cT(4, 6));\n  NT2_TEST_EQUAL((cT(0, 2)* cT(3)+cT(4)), cT(4, 6));\n  std::cout << \"4\\n\";\n  NT2_TEST_EQUAL(fma(cT(2), iT(3), iT(4)), cT(0, 10));\n  NT2_TEST_EQUAL(fma(cT(2), cT(0, 3), cT(0, 4)), cT(0, 10));\n  NT2_TEST_EQUAL((cT(2)* cT(0, 3)+ cT(0, 4)), cT(0, 10));\n  std::cout << \"5\\n\";\n  NT2_TEST_EQUAL(fma(iT(2), iT(3), cT(4, 5)), cT(-2, 5));\n  NT2_TEST_EQUAL(fma(cT(0, 2), cT(0, 3), cT(4, 5)), cT(-2, 5));\n  NT2_TEST_EQUAL((cT(0, 2)* cT(0, 3)+ cT(4, 5)), cT(-2, 5));\n  std::cout << \"6\\n\";\n  NT2_TEST_EQUAL(fma(iT(2), cT(3, 5), iT(4)), cT(-10, 10));\n  NT2_TEST_EQUAL(fma(cT(0, 2), cT(3, 5), cT(0, 4)), cT(-10, 10));\n  NT2_TEST_EQUAL((cT(0, 2)* cT(3, 5)+ cT(0, 4)), cT(-10, 10));\n  std::cout << \"7\\n\";\n  NT2_TEST_EQUAL(fma(iT(2), iT(3),iT(4)), cT(-6, 4));\n  NT2_TEST_EQUAL(fma(cT(0, 2), cT(0, 3), cT(0, 4)), cT(-6, 4));\n  NT2_TEST_EQUAL((cT(0, 2)*cT(0, 3)+cT(0, 4)), cT(-6, 4));\n  std::cout << \"8\\n\";\n  NT2_TEST_EQUAL(fma(T(2), cT(5, 3),cT(6, 4)), cT(16, 10));\n  NT2_TEST_EQUAL(fma(cT(2), cT(5, 3), cT(6, 4)), cT(16, 10));\n  NT2_TEST_EQUAL((cT(2)*cT(5, 3)+cT(6, 4)), cT(16, 10));\n  std::cout << \"9\\n\";\n  NT2_TEST_EQUAL(fma(T(2), cT(5, 3),cT(6, 4)), cT(16, 10));\n  NT2_TEST_EQUAL(fma(cT(2), cT(5, 3), cT(6, 4)), cT(16, 10));\n  NT2_TEST_EQUAL((cT(2)*cT(5, 3)+cT(6, 4)), cT(16, 10));\n  std::cout << \"10\\n\";\n  NT2_TEST_EQUAL(fma(cT(2, 3), cT(5, 3),T(6)), cT(7, 21));\n  NT2_TEST_EQUAL(fma(cT(2, 3), cT(5, 3), cT(6)), cT(7, 21));\n  NT2_TEST_EQUAL((cT(2, 3)*cT(5, 3)+cT(6)), cT(7, 21));\n  std::cout << \"11\\n\";\n  NT2_TEST_EQUAL(fma(cT(2, 3), T(5),T(6)), cT(16, 15));\n  NT2_TEST_EQUAL(fma(cT(2, 3), cT(5), cT(6)), cT(16, 15));\n  NT2_TEST_EQUAL((cT(2, 3)*cT(5)+cT(6)), cT(16, 15));\n  std::cout << \"12\\n\";\n  NT2_TEST_EQUAL(fma(T(2), cT(5, 3),T(6)), cT(16, 6));\n  NT2_TEST_EQUAL(fma(cT(2), cT(5, 3), cT(6)), cT(16, 6));\n  NT2_TEST_EQUAL((cT(2)*cT(5, 3)+cT(6)), cT(16, 6));\n  std::cout << \"13\\n\";\n  NT2_TEST_EQUAL(fma(T(2), T(5),cT(6, 2)), cT(16, 2));\n  NT2_TEST_EQUAL(fma(cT(2), cT(5), cT(6, 2)), cT(16, 2));\n  NT2_TEST_EQUAL((cT(2)*cT(5)+cT(6, 2)), cT(16, 2));\n  std::cout << \"14\\n\";\n  NT2_TEST_EQUAL(fma(T(2), iT(5),cT(6, 2)), cT(6, 12));\n  NT2_TEST_EQUAL(fma(cT(2), cT(0, 5), cT(6, 2)), cT(6, 12));\n  NT2_TEST_EQUAL((cT(2)*cT(0, 5)+cT(6, 2)), cT(6, 12));\n  std::cout << \"15\\n\";\n  NT2_TEST_EQUAL(fma(T(2), cT(2, 5),iT(2)), cT(4, 12));\n  NT2_TEST_EQUAL(fma(cT(2), cT(2, 5), cT(0, 2)), cT(4, 12));\n  NT2_TEST_EQUAL((cT(2)*cT(2, 5)+cT(0, 2)), cT(4, 12));\n  std::cout << \"16\\n\";\n  NT2_TEST_EQUAL(fma(cT(2, 5), iT(5),T(2)), cT(-23, 10));\n  NT2_TEST_EQUAL(fma(cT(2, 5), cT(0, 5), cT(2)), cT(-23, 10));\n  NT2_TEST_EQUAL((cT(2, 5)*cT(0, 5)+cT(2)), cT(-23, 10));\n  std::cout << \"17\\n\";\n  NT2_TEST_EQUAL(fma(iT(5), cT(2, 5),T(2)), cT(-23, 10));\n  NT2_TEST_EQUAL(fma(cT(0, 5), cT(2, 5), cT(2)), cT(-23, 10));\n  NT2_TEST_EQUAL((cT(0, 5)*cT(2, 5)+cT(2)), cT(-23, 10));\n  std::cout << \"18\\n\";\n  NT2_TEST_EQUAL(fma(cT(2, 5), T(3),iT(2)), cT(6, 17));\n  NT2_TEST_EQUAL(fma(cT(2, 5), cT(3, 0), cT(0, 2)), cT(6, 17));\n  NT2_TEST_EQUAL((cT(2, 5)*cT(3, 0)+cT(0, 2)), cT(6, 17));\n  std::cout << \"19\\n\";\n  NT2_TEST_EQUAL(fma(iT(5), T(3),cT(6, 2)), cT(6, 17));\n  NT2_TEST_EQUAL(fma(cT(0, 5), cT(3), cT(6, 2)), cT(6, 17));\n  NT2_TEST_EQUAL((cT(0, 5)*cT(3, 0)+cT(6, 2)), cT(6, 17));\n\n\n\n} // end of test for floating_\n\nNT2_TEST_CASE_TPL ( fma_various_invalid, (float))//BOOST_SIMD_REAL_TYPES)\n{\n\n  using nt2::fma;\n  using nt2::tag::fma_;\n  typedef std::complex<T> cT;\n  typedef typename nt2::meta::as_imaginary<T>::type iT;\n\n  // specific values tests\n\n  std::cout << \"0 ccc \\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(3), cT(4)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(3), cT(4)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(cT(2), cT(3), cT(4)), cT(10));\n  NT2_TEST_EQUAL(fma(cT(2, 3), cT(3, 1), cT(2, 4)), cT(5, 15));\n\n  NT2_TEST_EQUAL(fma(cT(0, nt2::Inf<T>()), cT(0), cT(3, 4)), cT(3, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(cT(0),cT(0, nt2::Inf<T>()), cT(4)), cT(4, nt2::Nan<T>()));\n\n  NT2_TEST_EQUAL(fma(cT(1, nt2::Inf<T>()), cT(0), cT(3, nt2::Minf<T>())), cT(3, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(cT(0),cT(1, nt2::Inf<T>()), cT(4)), cT(4, nt2::Nan<T>()));\n\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(), T(3), T(4)), nt2::Inf<T>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(3), cT(nt2::Minf<T>())), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(1),nt2::Inf<cT>(), cT(nt2::Minf<T>())), cT(nt2::Nan<T>(), 0));\n  NT2_TEST_EQUAL(fma(cT(1),cT(0, nt2::Inf<T>()), cT(nt2::Minf<T>())), cT(nt2::Minf<T>(), nt2::Inf<T>()));\n\n  NT2_TEST_EQUAL(   nt2::multiplies(nt2::Inf<cT>(), cT(3))+cT(4), nt2::Inf<cT>());\n\n  std::cout << \"1 cci\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(3), iT(0)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(cT(2), cT(3), cT(0, 4)), cT(6, 4));\n  NT2_TEST_EQUAL(    nt2::plus(nt2::multiplies(nt2::Inf<cT>(), cT(3)), iT(0)), nt2::Inf<cT>());\n\n  std::cout << \"2 cic \\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(), T(0), cT(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), iT(0), cT(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0), cT(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(nt2::Inf<cT>(), iT(0)), cT(4)), nt2::Nan<cT>());\n  std::cout << \"3 icc\\n\";\n  NT2_TEST_EQUAL(fma(iT(0), nt2::Inf<cT>(), cT(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(0), nt2::Inf<cT>(), cT(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(iT(0), nt2::Inf<cT>()), cT(4)), nt2::Nan<cT>());\n\n  std::cout << \"4 cii\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), iT(0), cT(0, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), iT(1), iT(4)), cT(0, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0, 1), iT(4)), cT(0, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0), cT(0, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(cT(0), cT(0), nt2::Inf<cT>()),  nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0), nt2::Inf<cT>()),  nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Minf<cT>(), cT(1), nt2::Inf<cT>()),  nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(1), nt2::Inf<cT>()),  nt2::Nan<cT>());\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(nt2::Inf<cT>(), cT(0)), cT(0, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(nt2::Inf<cT>(), iT(0)), cT(0, 4)), cT(nt2::Nan<T>(), 4));\n\n  std::cout << \"5 iic\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0), cT(4, 5)), cT(nt2::Nan<T>(), 5));\n  NT2_TEST_EQUAL(fma(cT(0), nt2::Inf<cT>(), cT(4, 5)), cT(nt2::Nan<T>(), 5));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(nt2::Inf<cT>(), cT(0)), cT(4, 5)), cT(nt2::Nan<T>(), 5));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(nt2::Inf<cT>(), iT(0)), cT(4, 5)), cT(nt2::Nan<T>(), 5));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(0), cT(4, 4)), cT(4, nt2::Nan<T>()));\n\n\n  std::cout << \"6 ici\\n\";\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), cT(0), iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(cT(0), iT(nt2::Inf<T>()), iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(0), cT(3, 4)), cT(3, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(iT(0), iT(nt2::Inf<T>()), cT(3, 4)), cT(3, nt2::Nan<T>()));\n\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(0), iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma( iT(0),iT(nt2::Inf<T>()),iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(1), iT(4)), cT(nt2::Minf<T>(), 4));\n  NT2_TEST_EQUAL(fma( iT(1),iT(nt2::Inf<T>()),iT(4)), cT(nt2::Minf<T>(), 4));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(cT(0,nt2::Inf<T>()), cT(0)), cT(0, 4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(iT(nt2::Inf<T>()), cT(0)), cT(0, 4)), cT(0, nt2::Nan<T>()));\n\n  std::cout << \"7 iii\\n\";\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(3),iT(4)), cT(nt2::Minf<T>(), 4));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(0),iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(iT(nt2::Inf<T>()), iT(0)), iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(iT(nt2::Inf<T>()), iT(3)), iT(4)), cT(nt2::Minf<T>(), 4));\n\n  std::cout << \"8\\n acc\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(), cT(0),cT(6, 4)),     cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(), iT(0), cT(6, 4)),    cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(), cT(0, 3),cT(6, 4)),  cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(), iT(3), cT(6, 4)),    cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(T(0),          nt2::Inf<cT>(),      cT(6, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(0),          iT(nt2::Inf<T>()),   cT(6, 4)), cT(6, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  cT(1), cT( 3, 4)), cT(nt2::Inf<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(1), cT(nt2::Inf<T>()),  cT(4, 4)), cT(nt2::Inf<T>(), 4));\n\n  std::cout << \"9 cac\\n\";\n  NT2_TEST_EQUAL(fma( cT(0)                ,nt2::Inf<T>(),cT(6, 4)),     cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( iT(0)                ,nt2::Inf<T>(),cT(6, 4)),    cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( iT(0)                ,nt2::Inf<cT>(),cT(6, 4)),    cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( cT(0, 3)             ,nt2::Inf<T>(),cT(6, 4)),  cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma( iT(3)                ,nt2::Inf<T>(),cT(6, 4)),    cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma( nt2::Inf<cT>(),       T(0),         cT(6, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( iT(nt2::Inf<T>()),    T(0),         cT(6, 4)), cT(6, nt2::Nan<T>()));\n\n  std::cout << \"10 cca\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(3), T(4)),                     nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(cT(3),                     nt2::Inf<cT>(), T(4)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(cT(4),                     nt2::Inf<cT>(), cT(3)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), T(4), cT(3)),                     nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0), T(4)),                     nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(0),                     nt2::Inf<cT>(), T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(0),                     nt2::Inf<cT>(), cT(3)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), T(4), cT(3)),                     nt2::Inf<cT>());\n\n  std::cout << \"11 caa\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), T(3),           T(4)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(cT(3, 4),        nt2::Inf<T>(), T(4)), cT(nt2::Inf<T>(), nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(cT(4),           nt2::Inf<T>(), T(3)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(),  T(0),          T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(0),           nt2::Inf<T>(), T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(),  T(4),          T(3)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(cT(0, nt2::Inf<T>()), T(4),     T(3)), cT(3, nt2::Inf<T>()));\n\n\n  std::cout << \"12 aca\\n\";\n  NT2_TEST_EQUAL(fma(T(3),         nt2::Inf<cT>(),   T(4)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),cT(3, 4),         T(4)), cT(nt2::Inf<T>(), nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),cT(4),            T(3)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(T(0),         nt2::Inf<cT>(),   T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),cT(0),            T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(T(4),         nt2::Inf<cT>(),   T(3)), nt2::Inf<cT>());\n  NT2_TEST_EQUAL(fma(T(4), cT(0, nt2::Inf<T>()), T(3)), cT(3, nt2::Inf<T>()));\n\n  std::cout << \"13 aac\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  T(0), cT(6, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(0), nt2::Inf<T>(),  cT(6, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  T(1), cT(6, 4)), cT(nt2::Inf<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(1), nt2::Inf<T>(),  cT(6, 4)), cT(nt2::Inf<T>(), 4));\n\n\n  std::cout << \"14\\n aic\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(0), cT(6, 4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(0), iT(nt2::Inf<T>()),  cT(6, 4)), cT(6, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(1), cT(6, 4)), cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(T(1), iT(nt2::Inf<T>()),  cT(6, 4)), cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(0), cT(6)), cT(nt2::Nan<T>(), 0));\n  NT2_TEST_EQUAL(fma(T(0), iT(nt2::Inf<T>()),  cT(6)), cT(6, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(1), cT(6)), cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(T(1), iT(nt2::Inf<T>()),  cT(6)), cT(6, nt2::Inf<T>()));\n\n\n  std::cout << \"15 aci\\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  cT(0), iT(4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(0), cT(nt2::Inf<T>()),  iT(4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  cT(1), iT(4)), cT(nt2::Inf<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(1), cT(nt2::Inf<T>()),  iT(4)), cT(nt2::Inf<T>(), 4));\n\n  std::cout << \"16 cia \\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), iT(0), T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(nt2::Inf<cT>(), cT(0), T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(0), iT(nt2::Inf<T>()), T(4)), cT(4, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(cT(0), cT(0, nt2::Inf<T>()), T(4)),cT(4, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(nt2::Inf<cT>(), iT(0)), T(4)), nt2::Nan<cT>());\n\n\n\n  std::cout << \"17 ica \\n\";\n  NT2_TEST_EQUAL(fma(iT(0), nt2::Inf<cT>(), T(4)), nt2::Nan<cT>());\n  NT2_TEST_EQUAL(fma(cT(0), nt2::Inf<cT>(), T(4)), nt2::Nan<cT>());\n\n\n  std::cout << \"18 cai \\n\";\n  NT2_TEST_EQUAL(fma( cT(0),              nt2::Inf<T>(), iT(4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( cT(nt2::Inf<T>()),  T(0),          iT(4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( cT(1),              nt2::Inf<T>(), iT(4)), cT(nt2::Inf<T>(), 4));\n  NT2_TEST_EQUAL(fma( cT(nt2::Inf<T>()),  T(1),          iT(4)), cT(nt2::Inf<T>(), 4));\n\n\n\n  std::cout << \"19 iac \\n\";\n  NT2_TEST_EQUAL(fma( iT(0),              nt2::Inf<T>(), cT(6, 4)),   cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma( iT(nt2::Inf<T>()),  T(0),          cT(6, 4)), cT(6, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma( iT(1),   nt2::Inf<T>(), cT(6, 4)), cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma( iT(nt2::Inf<T>()),  T(1),          cT(6, 4)), cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma( iT(0),              nt2::Inf<T>(), cT(6)),      cT(nt2::Nan<T>(), 0));\n  NT2_TEST_EQUAL(fma( iT(nt2::Inf<T>()),  T(0),          cT(6)), cT(6, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma( iT(1),              nt2::Inf<T>(), cT(6)),      cT(6, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma( iT(nt2::Inf<T>()),  T(1),          cT(6)), cT(6, nt2::Inf<T>()));\n\n  std::cout << \"20 aai \\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  T(0), iT(4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(0), nt2::Inf<T>(),  iT(4)), cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  T(1), iT(4)), cT(nt2::Inf<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(1), nt2::Inf<T>(),  iT(4)), cT(nt2::Inf<T>(), 4));\n\n  std::cout << \"21 aia \\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(0), T(4)),    cT(nt2::Nan<T>(), 0));\n  NT2_TEST_EQUAL(fma(T(0), iT(nt2::Inf<T>()),  T(4)), cT(4, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(1), T(4)),    cT(4, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(T(1), iT(nt2::Inf<T>()),  T(4)), cT(4, nt2::Inf<T>()));\n\n  std::cout << \"22 iaa \\n\";\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()),  T(0), T(4)),    cT(4, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(iT(0), nt2::Inf<T>(),  T(4)),       cT(nt2::Nan<T>(), 0));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()),  T(1), T(4)),    cT(4, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(iT(1), T(nt2::Inf<T>()),  T(4)),    cT(4, nt2::Inf<T>()));\n\n  std::cout << \"23 aii \\n\";\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(0), iT(4)),    cT(nt2::Nan<T>(), 4));\n  NT2_TEST_EQUAL(fma(T(0), iT(nt2::Inf<T>()),  iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(nt2::Inf<T>(),  iT(1), iT(4)),    cT(0, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(T(1), iT(nt2::Inf<T>()),  iT(4)), cT(0, nt2::Inf<T>()));\n\n  std::cout << \"24 iia \\n\";\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(3),T(4)), cT(nt2::Minf<T>(), 0));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), iT(0),T(4)), cT(4, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(iT(nt2::Inf<T>()), iT(0)), T(4)), cT(4, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(nt2::plus(nt2::multiplies(iT(nt2::Inf<T>()), iT(3)), T(4)), cT(nt2::Minf<T>(), 0));\n\n  std::cout << \"25 iai \\n\";\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), T(3),iT(4)), cT(0, nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(iT(nt2::Inf<T>()), T(0),iT(4)), cT(0, nt2::Nan<T>()));\n  NT2_TEST_EQUAL(fma(iT(3), nt2::Inf<T>(),iT(4)),     cT(0,  nt2::Inf<T>()));\n  NT2_TEST_EQUAL(fma(iT(0), nt2::Inf<T>(),iT(4)),     cT(nt2::Nan<T>(), 4));\n} // end of test for floating_\n", "meta": {"hexsha": "904b172efeae9323cf888c21f2cb98bacc7ea549", "size": 19744, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/type/complex/arithmetic/unit/scalar/fma.cpp", "max_stars_repo_name": "pbrunet/nt2", "max_stars_repo_head_hexsha": "2aeca0f6a315725b335efd5d9dc95d72e10a7fb7", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modules/type/complex/arithmetic/unit/scalar/fma.cpp", "max_issues_repo_name": "pbrunet/nt2", "max_issues_repo_head_hexsha": "2aeca0f6a315725b335efd5d9dc95d72e10a7fb7", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/type/complex/arithmetic/unit/scalar/fma.cpp", "max_forks_repo_name": "pbrunet/nt2", "max_forks_repo_head_hexsha": "2aeca0f6a315725b335efd5d9dc95d72e10a7fb7", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.218328841, "max_line_length": 105, "alphanum_fraction": 0.5294266613, "num_tokens": 8864, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48047867804790706, "lm_q2_score": 0.11757213818344736, "lm_q1q2_score": 0.056490905529648645}}
{"text": "//------------------------------------------------------------------------------\n// \\file ToBytes_test.cpp\n//------------------------------------------------------------------------------\n#include \"Utilities/ToBytes.h\"\n\n#include <boost/test/unit_test.hpp>\n#include <cstddef> // std::byte\n#include <cstdio> // printf\n#include <iostream>\n#include <limits>\n#include <string>\n\nusing Utilities::ToBytes;\n\nBOOST_AUTO_TEST_SUITE(Utilities)\nBOOST_AUTO_TEST_SUITE(ToBytes_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ReinterpretCastAndHexadecimalPrintExamples)\n{\n  std::cout << \"\\n ReinterpretCastAndHexadecimalPrintExamples begins \\n\";\n\n\n  constexpr unsigned short x_0 {15213};\n  constexpr short x_1 {15213};\n  constexpr short y {-15213};\n\n  auto x = reinterpret_cast<const std::byte*>(&x_0);\n  auto xa = reinterpret_cast<const unsigned char*>(&x_0);\n\n  //std::cout << std::to_integer(x[0]) << '\\n'; // didn't work\n  //std::cout << std::to_integer(*x) << '\\n'; // didn't work\n  // std::cout << x << '\\n'; // worked\n\n  //std::cout << xa[0] << '\\n'; // m\n  //std::cout << xa[1] << '\\n'; // ;\n  //std::cout << xa[2] << '\\n'; \n  //std::cout << xa[3] << '\\n';\n  //printf(\"%x \\n\", xa); // 178892be\n  //printf(\"%01x \\n\", xa[0]);\n  //printf(\"%01x \\n\", xa[1]);\n  //printf(\"%01x \\n\", xa[2]);\n  //printf(\"%001x \\n\", xa[3]);\n  //printf(\"%001x \\n\", xa[4]);\n\n  BOOST_TEST_REQUIRE(sizeof(unsigned short) == 2);\n  BOOST_TEST_REQUIRE(sizeof(short) == 2);\n\n  BOOST_TEST(true);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ToBytesWorks)\n{\n  constexpr unsigned short x_0 {15213};\n  constexpr short x_1 {15213};\n  constexpr short y {-15213};\n\n  const ToBytes to_bytes_x_0 {x_0};\n\n  std::cout << \"\\n Print 15213 with increasing addresses \\n\";\n  to_bytes_x_0.increasing_addresses_print(); // WORKS\n  //to_bytes_x_0.decreasing_addresses_print(); // WORKS\n  std::cout << \"\\n END OF Print 15213 with increasing addresses \\n\";\n\n  ToBytes to_bytes_x_1 {x_1};\n\n  to_bytes_x_1.increasing_addresses_print(); // WORKS 93\n  to_bytes_x_1.decreasing_addresses_print(); // WORKS c4\n\n  const ToBytes to_bytes_y {y};\n\n  to_bytes_y.increasing_addresses_print(); // WORKS c4\n  to_bytes_y.decreasing_addresses_print(); // WORKS 93\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(IncreasingAddressesHexWorks)\n{\n  constexpr unsigned short x_0 {15213};\n  constexpr short x_1 {15213};\n  constexpr short y {-15213};\n\n  const ToBytes to_bytes_x_0 {x_0};\n\n  ToBytes to_bytes_x_1 {x_1};\n\n  const ToBytes to_bytes_y {y};\n\n  const std::string x_0_str {to_bytes_x_0.increasing_addresses_hex()};\n  BOOST_TEST(x_0_str == \"6d3b\");\n\n  const std::string x_1_str {to_bytes_x_1.increasing_addresses_hex()};\n  BOOST_TEST(x_1_str == \"6d3b\");\n\n  const std::string y_str {to_bytes_y.increasing_addresses_hex()};\n  BOOST_TEST(y_str == \"93c4\");\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(IncreasingAddressesHexWorksByInduction)\n{\n  {\n    BOOST_TEST(sizeof(unsigned int) == 4);\n    const unsigned int x {0};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"0000\");\n  }\n  {\n    const unsigned int x {1};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"1000\");\n  }\n  {\n    const unsigned int x {2};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"2000\");\n  }\n  {\n    const unsigned int x {15};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"f000\");\n  }\n  {\n    const unsigned int x {16};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"10000\");\n  }\n  {\n    const unsigned int x {17};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"11000\");\n  }\n  {\n    const unsigned int x {std::numeric_limits<unsigned int>::max() - 1};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"feffffff\");\n  }\n  {\n    const unsigned int x {std::numeric_limits<unsigned int>::max()};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"ffffffff\");\n  }\n  {\n    const unsigned int x {std::numeric_limits<unsigned int>::min()};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.increasing_addresses_hex() == \"0000\");\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DecreasingAddressesHexWorksByInduction)\n{\n  {\n    BOOST_TEST(sizeof(unsigned int) == 4);\n    const unsigned int x {0};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"0000\");\n  }\n  {\n    const unsigned int x {1};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"0001\");\n  }\n  {\n    const unsigned int x {2};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"0002\");\n  }\n  {\n    const unsigned int x {15};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"000f\");\n  }\n  {\n    const unsigned int x {16};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"00010\");\n  }\n  {\n    const unsigned int x {17};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"00011\");\n  }\n  {\n    const unsigned int x {std::numeric_limits<unsigned int>::max() - 1};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"fffffffe\");\n  }\n  {\n    const unsigned int x {std::numeric_limits<unsigned int>::max()};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"ffffffff\");\n  }\n  {\n    const unsigned int x {std::numeric_limits<unsigned int>::min()};\n    const ToBytes to_bytes_x {x};\n    BOOST_TEST(to_bytes_x.decreasing_addresses_hex() == \"0000\");\n  }\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DecreasingAddressesHexWorks)\n{\n  constexpr unsigned short x_0 {15213};\n  constexpr short x_1 {15213};\n  constexpr short y {-15213};\n\n  const ToBytes to_bytes_x_0 {x_0};\n\n  ToBytes to_bytes_x_1 {x_1};\n\n  const ToBytes to_bytes_y {y};\n\n  const std::string x_0_str {to_bytes_x_0.decreasing_addresses_hex()};\n  BOOST_TEST(x_0_str == \"3b6d\");\n\n  const std::string x_1_str {to_bytes_x_1.decreasing_addresses_hex()};\n  BOOST_TEST(x_1_str == \"3b6d\");\n\n  const std::string y_str {to_bytes_y.decreasing_addresses_hex()};\n  BOOST_TEST(y_str == \"c493\");\n}\n\nBOOST_AUTO_TEST_SUITE(RepresentingStrings_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(StringToByteGetsPointer)\n{\n  const std::string input {\"12345\"};\n  const ToBytes input_in_bytes {input};\n\n  //BOOST_TEST(input_in_bytes.decreasing_addresses_hex() ==\n  //  \"0000040ad14000353433323100000005007ffdc68e6e10 \");\n\n  const ToBytes input_as_char_in_bytes {input.data()};\n\n  //BOOST_TEST(input_as_char_in_bytes.decreasing_addresses_hex() ==\n  //  \"007ffd70befdb0 \");\n\n  //const ToBytes r_input {\"12345\"};\n\n  BOOST_TEST(true);\n}\n\nBOOST_AUTO_TEST_SUITE_END() // RepresentingStrings_tests\n\nBOOST_AUTO_TEST_SUITE_END() // ToBytes_tests\nBOOST_AUTO_TEST_SUITE_END() // Utilities", "meta": {"hexsha": "1cbae91ea87354b7d8ed136caaaddae42cbc286a", "size": 8016, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Utilities/ToBytes_test.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Utilities/ToBytes_test.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Utilities/ToBytes_test.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3125, "max_line_length": 80, "alphanum_fraction": 0.5805888224, "num_tokens": 1920, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4804786631694601, "lm_q2_score": 0.11757212272365287, "lm_q1q2_score": 0.05649089635225643}}
{"text": "//  (C) Copyright Raffi Enficiaud 2014.\r\n//  Distributed under the Boost Software License, Version 1.0.\r\n//  (See accompanying file LICENSE_1_0.txt or copy at\r\n//  http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n//  See http://www.boost.org/libs/test for the library home page.\r\n\r\n//[example_code\r\n#define BOOST_TEST_MODULE boost_test_sequence\r\n#include <boost/test/included/unit_test.hpp>\r\n#include <vector>\r\n\r\nBOOST_AUTO_TEST_CASE( test_collections_vectors )\r\n{\r\n  std::vector<int> a{1,2,3}, c{1,5,3,4};\r\n  std::vector<long> b{1,5,3};\r\n  \r\n  // the following does not compile\r\n  //BOOST_TEST(a == b);\r\n  //BOOST_TEST(a <= b);\r\n  \r\n  // stl defaults to lexicographical comparison\r\n  BOOST_TEST(a < c);\r\n  BOOST_TEST(a >= c);\r\n  BOOST_TEST(a != c);\r\n}\r\n//]\r\n", "meta": {"hexsha": "2bea89f41e419b54fc4a0a4f71e28d6865deb9f5", "size": 751, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/boost_test_container_default.run-fail.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/boost_test_container_default.run-fail.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-03-04T11:21:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-24T01:36:31.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/boost_test_container_default.run-fail.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 26.8214285714, "max_line_length": 66, "alphanum_fraction": 0.6684420772, "num_tokens": 213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.1127954077740912, "lm_q1q2_score": 0.0563977038870456}}
{"text": "/*    Copyright (c) 2010-2015, Delft University of Technology\n *    All rights reserved.\n *\n *    Redistribution and use in source and binary forms, with or without modification, are\n *    permitted provided that the following conditions are met:\n *      - Redistributions of source code must retain the above copyright notice, this list of\n *        conditions and the following disclaimer.\n *      - Redistributions in binary form must reproduce the above copyright notice, this list of\n *        conditions and the following disclaimer in the documentation and/or other materials\n *        provided with the distribution.\n *      - Neither the name of the Delft University of Technology nor the names of its contributors\n *        may be used to endorse or promote products derived from this software without specific\n *        prior written permission.\n *\n *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS\n *    OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n *    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n *    COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n *    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n *    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n *    AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n *    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n *    OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n *    Changelog\n *      YYMMDD    Author            Comment\n *      130218    D. Dirkx          File created from personal application.\n *      130301    K. Kumar          Split and refactored unit tests.\n *\n *    References\n *\n *    Notes\n *\n */\n\n#define BOOST_TEST_MAIN\n\n#include <limits>\n\n#include <boost/test/floating_point_comparison.hpp>\n#include <boost/test/unit_test.hpp>\n#include <boost/date_time/gregorian/gregorian.hpp>\n\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/physicalConstants.h\"\n\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/timeConversions.h\"\n\nnamespace tudat\n{\nnamespace unit_tests\n{\n\nusing namespace basic_astrodynamics;\n\n//! Test the functionality of the time conversion functions.\nBOOST_AUTO_TEST_SUITE( test_Time_Conversions )\n\n//! Unit test for Julian day to seconds conversion function.\nBOOST_AUTO_TEST_CASE( testJulianDayToSecondsConversions )\n{\n    // Test conversion from Julian day to seconds since epoch at 0 MJD.\n    {\n        // Set reference epoch and Julian day for tests.\n        const double referenceEpoch = JULIAN_DAY_AT_0_MJD;\n        const double julianDay = JULIAN_DAY_AT_0_MJD + 1.0e6 / 86400.0;\n\n        // Set expected seconds since epoch result.\n        const double expectedSecondsSinceEpoch = 1.0e6;\n\n        // Compute seconds since epoch given Julian day and reference epoch.\n        const double computedSecondsSinceEpoch = convertJulianDayToSecondsSinceEpoch(\n                    julianDay, referenceEpoch );\n\n        // Test that computed result matches expected result.\n        // Test is run at reduced tolerance, because the final digits of the seconds were lost\n        // when converting to Julian day.\n        BOOST_CHECK_CLOSE_FRACTION( computedSecondsSinceEpoch, expectedSecondsSinceEpoch,\n                                    1.0e-11 );\n    }\n\n    // Test conversion from Julian day to seconds since J2000 epoch.\n    {\n        // Set reference epoch and Julian day for tests.\n        const double referenceEpoch = JULIAN_DAY_ON_J2000;\n        const double julianDay = JULIAN_DAY_ON_J2000 + 0.5;\n\n        // Set expected seconds since epoch result.\n        double expectedSecondsSinceEpoch\n                = physical_constants::JULIAN_DAY / 2.0;\n\n        // Compute seconds since epoch given Julian day and reference epoch.\n        const double computedSecondsSinceEpoch = convertJulianDayToSecondsSinceEpoch(\n                    julianDay, referenceEpoch );\n\n        // Test that computed result matches expected result.\n        // Test is run at reduced tolerance, because the final digits of the seconds were lost\n        // when converting to Julian day.\n        BOOST_CHECK_CLOSE_FRACTION( computedSecondsSinceEpoch, expectedSecondsSinceEpoch,\n                                    std::numeric_limits< double >::epsilon( ) );\n    }\n}\n\n//! Unit test for seconds to Julian day conversion function.\nBOOST_AUTO_TEST_CASE( testSecondsSinceEpochToJulianDayConversions )\n{\n    // Test conversion from seconds since epoch to Julian day.\n\n    // Set reference epoch and seconds since epoch for tests.\n    const double referenceEpoch = JULIAN_DAY_AT_0_MJD;\n    const double secondsSinceEpoch = 1.0e6;\n\n    // Set expected Julian day result.\n    const double expectedJulianDay = JULIAN_DAY_AT_0_MJD + 1.0e6 / 86400.0;\n\n    // Compute Julian day with seconds since reference epoch specified.\n    const double computedJulianDay = convertSecondsSinceEpochToJulianDay(\n                secondsSinceEpoch, referenceEpoch );\n\n    // Test that computed result matches expected result.\n    BOOST_CHECK_CLOSE_FRACTION( computedJulianDay, expectedJulianDay,\n                                std::numeric_limits< double >::epsilon( ) );\n}\n\n//! Unit test for calendar date to Julian day conversion function.\nBOOST_AUTO_TEST_CASE( testConversionCalendarDateToJulianDay )\n{\n    // Compute the Julian day of the calendar date: January 1st, 2000, at 12h0m0s.\n    {\n        //Use the function to compute the Julian day.\n        const double computedJulianDay = convertCalendarDateToJulianDay ( 2000, 1, 1, 12, 0, 0 );\n\n        //Known Julian day at this calendar date.\n        const double expectedJulianDay = basic_astrodynamics::JULIAN_DAY_ON_J2000;\n\n        // Test that computed result matches expected result.\n        BOOST_CHECK_CLOSE_FRACTION( computedJulianDay, expectedJulianDay,\n                                std::numeric_limits< double >::epsilon( ) );\n    }\n\n    //Compute the Julian day of the calendar date: November 17th, 1858, At 0h0m0s.\n    {\n        //Use the function to compute the Julian day.\n        const double computedJulianDay = convertCalendarDateToJulianDay( 1858, 11, 17, 0, 0, 0 );\n\n        //Known Julian day at this calendar date\n        const double expectedJulianDay = basic_astrodynamics::JULIAN_DAY_AT_0_MJD;\n\n        // Test that computed result matches expected result.\n        BOOST_CHECK_CLOSE_FRACTION( computedJulianDay, expectedJulianDay,\n                                std::numeric_limits< double >::epsilon( ) );\n    }\n\n    //Test conversion wrapper against boost result.\n    {\n        const int year = 1749;\n        const int month = 3;\n        const int day = 30;\n\n        BOOST_CHECK_CLOSE_FRACTION( boost::gregorian::date( year, month, day ).julian_day( ) - 0.5,\n                                    convertCalendarDateToJulianDay( year, month, day, 0, 0, 0.0 ),\n                                    std::numeric_limits< double >::epsilon( ) );\n        const int hour = 4;\n        BOOST_CHECK_CLOSE_FRACTION( boost::gregorian::date( year, month, day ).julian_day( ) - 0.5 +\n                                    static_cast< double >( hour ) / 24.0,\n                                    convertCalendarDateToJulianDay( year, month, day, hour, 0, 0.0 ),\n                                    std::numeric_limits< double >::epsilon( ) );\n\n        const int minute = 36;\n        BOOST_CHECK_CLOSE_FRACTION( boost::gregorian::date( year, month, day ).julian_day( ) - 0.5 +\n                                    static_cast< double >( hour ) / 24.0 + static_cast< double >( minute ) / ( 24.0 * 60.0 ),\n                                    convertCalendarDateToJulianDay( year, month, day, hour, minute, 0.0 ),\n                                    std::numeric_limits< double >::epsilon( ) );\n\n        const double second = 21.36474854836359;\n        BOOST_CHECK_CLOSE_FRACTION( boost::gregorian::date( year, month, day ).julian_day( ) - 0.5 +\n                                    static_cast< double >( hour ) / 24.0 + static_cast< double >( minute ) / ( 24.0 * 60.0 ) +\n                                    second / ( 24.0 * 60.0 * 60.0 ),\n                                    convertCalendarDateToJulianDay( year, month, day, hour, minute, second ),\n                                    std::numeric_limits< double >::epsilon( ) );\n\n    }\n}\n\nBOOST_AUTO_TEST_SUITE_END( )\n\n} // namespace unit_tests\n} // namespace tudat\n", "meta": {"hexsha": "03b0d06fa10b2fed230be19b838c56c7afb31bad", "size": 8569, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestTimeConversions.cpp", "max_stars_repo_name": "JPelamatti/ThesisTUDAT", "max_stars_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestTimeConversions.cpp", "max_issues_repo_name": "JPelamatti/ThesisTUDAT", "max_issues_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestTimeConversions.cpp", "max_forks_repo_name": "JPelamatti/ThesisTUDAT", "max_forks_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-05-30T03:42:22.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-30T03:42:22.000Z", "avg_line_length": 45.579787234, "max_line_length": 126, "alphanum_fraction": 0.6604037811, "num_tokens": 1935, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.11279540330049728, "lm_q1q2_score": 0.05639770165024864}}
{"text": "#define BOOST_TEST_MAIN\r\n\r\n#include <boost/format.hpp>\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/make_shared.hpp>\r\n\r\n#include \"Tudat/Basics/testMacros.h\"\r\n\r\n#include \"Tudat/External/SpiceInterface/spiceInterface.h\"\r\n#include \"Tudat/InputOutput/basicInputOutput.h\"\r\n\r\n#include \"Tudat/Astrodynamics/Ephemerides/frameManager.h\"\r\n#include \"Tudat/Astrodynamics/Ephemerides/constantEphemeris.h\"\r\n\r\nnamespace tudat\r\n{\r\nnamespace unit_tests\r\n{\r\n\r\nusing namespace tudat::ephemerides;\r\nusing namespace tudat::spice_interface;\r\n\r\nBOOST_AUTO_TEST_SUITE( test_frame_manager )\r\n\r\nBOOST_AUTO_TEST_CASE( test_FrameManager )\r\n{\r\n\r\n    std::string kernelsPath = input_output::getSpiceKernelPath( );\r\n\r\n    //Load spice kernels.\r\n    spice_interface::loadSpiceKernelInTudat( kernelsPath + \"naif0009.tls\");\r\n    spice_interface::loadSpiceKernelInTudat( kernelsPath + \"pck00009.tpc\");\r\n    spice_interface::loadSpiceKernelInTudat( kernelsPath + \"de-403-masses.tpc\");\r\n    spice_interface::loadSpiceKernelInTudat( kernelsPath + \"de421.bsp\");\r\n\r\n    std::map< std::string, boost::shared_ptr< Ephemeris > > ephemerisList;\r\n\r\n    basic_mathematics::Vector6d barycentricSunState = getBodyCartesianStateAtEpoch( \"Sun\", getBaseFrameName( ), \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Sun\" ] = boost::make_shared< ConstantEphemeris >( barycentricSunState, getBaseFrameName( ), \"ECLIPJ2000\" );\r\n\r\n    basic_mathematics::Vector6d sunCentricEarthState = getBodyCartesianStateAtEpoch( \"Earth\", \"Sun\", \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Earth\" ] = boost::make_shared< ConstantEphemeris >( sunCentricEarthState, \"Sun\", \"ECLIPJ2000\" );\r\n\r\n    basic_mathematics::Vector6d earthCentricMoonState = getBodyCartesianStateAtEpoch( \"Moon\", \"Earth\", \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Moon\" ] = boost::make_shared< ConstantEphemeris >( earthCentricMoonState, \"Earth\", \"ECLIPJ2000\" );\r\n\r\n    basic_mathematics::Vector6d earthCentricLageosState = basic_mathematics::Vector6d::Zero( );\r\n    earthCentricLageosState( 1 ) = 2.5E6;\r\n    earthCentricLageosState( 2 ) = 4.0E6;\r\n    ephemerisList[ \"LAGEOS\" ] = boost::make_shared< ConstantEphemeris >( earthCentricLageosState, \"Earth\", \"ECLIPJ2000\" );\r\n\r\n    basic_mathematics::Vector6d moonCentricLroState = basic_mathematics::Vector6d::Zero( );\r\n    moonCentricLroState( 0 ) = 1.0E6;\r\n    moonCentricLroState( 1 ) = 2.0E6;\r\n\r\n    ephemerisList[ \"LRO\" ] = boost::make_shared< ConstantEphemeris >( moonCentricLroState, \"Moon\", \"ECLIPJ2000\" );\r\n\r\n    basic_mathematics::Vector6d sunCentricMarsState = getBodyCartesianStateAtEpoch( \"Mars\", \"Sun\", \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Mars\" ] = boost::make_shared< ConstantEphemeris >( sunCentricMarsState, \"Sun\", \"ECLIPJ2000\" );\r\n\r\n    basic_mathematics::Vector6d marsCentricPhobosState = basic_mathematics::Vector6d::Zero( );\r\n    marsCentricPhobosState( 0 ) = 2.3E5;\r\n    marsCentricPhobosState( 1 ) = 2.9E4;\r\n    marsCentricPhobosState( 2 ) = 600;\r\n\r\n    ephemerisList[ \"Phobos\" ] = boost::make_shared< ConstantEphemeris >( marsCentricPhobosState, \"Mars\", \"ECLIPJ2000\" );\r\n\r\n    boost::shared_ptr< ReferenceFrameManager > frameManager = boost::make_shared< ReferenceFrameManager >( ephemerisList );\r\n\r\n    std::map< std::string, int > expectedFrameLevel;\r\n    expectedFrameLevel[ \"Sun\" ] = 0;\r\n    expectedFrameLevel[ \"Earth\" ] = 1;\r\n    expectedFrameLevel[ \"Mars\" ] = 1;\r\n    expectedFrameLevel[ \"LAGEOS\" ] = 2;\r\n    expectedFrameLevel[ \"Moon\" ] = 2;\r\n    expectedFrameLevel[ \"Phobos\" ] = 2;\r\n    expectedFrameLevel[ \"LRO\" ] = 3;\r\n\r\n    for( std::map< std::string, int >::iterator it = expectedFrameLevel.begin( ); it != expectedFrameLevel.end( ); it++ )\r\n    {\r\n        if( frameManager->getFrameLevel( it->first ).first != it->second )\r\n        {\r\n            throw std::runtime_error(\r\n                        \"Error when identifying frame level of \" + it->first + \" found \" +\r\n                        boost::lexical_cast< std::string >( frameManager->getFrameLevel( it->first ).first ) + \" expected\" +\r\n                        boost::lexical_cast< std::string >( it->second ) );\r\n        }\r\n    }\r\n\r\n    std::vector< std::string > frames;\r\n    frames.push_back( \"Earth\" );\r\n    frames.push_back( \"Mars\" );\r\n    std::pair< std::string, int > commonFrame = frameManager->getNearestCommonFrame( frames );\r\n    BOOST_CHECK_EQUAL( commonFrame.first, \"Sun\" );\r\n    BOOST_CHECK_EQUAL( commonFrame.second, 0 );\r\n\r\n    frames.clear( );\r\n    frames.push_back( \"Moon\" );\r\n    frames.push_back( \"Sun\" );\r\n\r\n    commonFrame = frameManager->getNearestCommonFrame( frames );\r\n\r\n    BOOST_CHECK_EQUAL( commonFrame.first, \"Sun\" );\r\n    BOOST_CHECK_EQUAL( commonFrame.second, 0 );\r\n\r\n    frames.clear( );\r\n    frames.push_back( \"Earth\" );\r\n    frames.push_back( \"LRO\" );\r\n\r\n    commonFrame = frameManager->getNearestCommonFrame( frames );\r\n\r\n    BOOST_CHECK_EQUAL( commonFrame.first, \"Earth\" );\r\n    BOOST_CHECK_EQUAL( commonFrame.second, 1 );\r\n\r\n    basic_mathematics::Vector6d testState = frameManager->getEphemeris< >( \"Moon\", \"LAGEOS\" )->getCartesianStateFromEphemeris( 0.0 );\r\n    basic_mathematics::Vector6d expectedState = earthCentricLageosState - earthCentricMoonState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Phobos\", \"Sun\" )->getCartesianStateFromEphemeris( 0.0 );\r\n    expectedState = sunCentricMarsState + marsCentricPhobosState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, ( -1.0 * expectedState ), std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Sun\", \"Phobos\" )->getCartesianStateFromEphemeris( 0.0 );\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Sun\", \"Earth\" )->getCartesianStateFromEphemeris( 0.0 );\r\n    expectedState = sunCentricEarthState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( getBaseFrameName( ), \"Earth\" )->getCartesianStateFromEphemeris( 0.0 );\r\n    expectedState = barycentricSunState + sunCentricEarthState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Earth\", getBaseFrameName( ) )->getCartesianStateFromEphemeris( 0.0 );\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, ( -1.0 * expectedState ), std::numeric_limits< double >::epsilon( ) );\r\n\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END( )\r\n\r\n}\r\n\r\n}\r\n", "meta": {"hexsha": "e070013c28ee670e1735b7fb8b6e88bc12d9d9d1", "size": 6637, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestFrameManager.cpp", "max_stars_repo_name": "JPelamatti/ThesisTUDAT", "max_stars_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestFrameManager.cpp", "max_issues_repo_name": "JPelamatti/ThesisTUDAT", "max_issues_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestFrameManager.cpp", "max_forks_repo_name": "JPelamatti/ThesisTUDAT", "max_forks_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-05-30T03:42:22.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-30T03:42:22.000Z", "avg_line_length": 46.0902777778, "max_line_length": 141, "alphanum_fraction": 0.7004670785, "num_tokens": 1962, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4726834766204328, "lm_q2_score": 0.1192029314092759, "lm_q1q2_score": 0.05634525604188352}}
{"text": "//////////////////////////////////////////////////////////////////////////////\n///   Copyright 2003 and onward LASMEA UMR 6602 CNRS/U.B.P Clermont-Ferrand\n///   Copyright 2009 and onward LRI    UMR 8623 CNRS/Univ Paris Sud XI\n///\n///          Distributed under the Boost Software License, Version 1.0\n///                 See accompanying file LICENSE.txt or copy at\n///                     http://www.boost.org/LICENSE_1_0.txt\n//////////////////////////////////////////////////////////////////////////////\n#define NT2_UNIT_MODULE \"nt2 bitwise toolbox - hi/scalar Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// Test behavior of bitwise components in scalar mode\n//////////////////////////////////////////////////////////////////////////////\n/// created  by jt the 18/02/2011\n/// modified by jt the 16/03/2011\n#include <boost/type_traits/is_same.hpp>\n#include <nt2/sdk/functor/meta/call.hpp>\n#include <nt2/sdk/unit/tests.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/memory/buffer.hpp>\n#include <nt2/sdk/constant/real.hpp>\n#include <nt2/sdk/constant/infinites.hpp>\n#include <nt2/include/functions/ulpdist.hpp>\n#include <nt2/toolbox/bitwise/include/hi.hpp>\n// specific includes for arity 1 tests\n#include<nt2/sdk/meta/downgrade.hpp>\n\nNT2_TEST_CASE_TPL ( hi_real__1,  NT2_REAL_TYPES)\n{\n  \n  using nt2::hi;\n  using nt2::tag::hi_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<hi_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(hi(nt2::Nan<T>()), nt2::Mone<r_t>());\n  NT2_TEST_EQUAL(hi(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for real_\n\nNT2_TEST_CASE_TPL ( hi_int64__1,  (int64_t)(uint64_t))\n{\n  \n  using nt2::hi;\n  using nt2::tag::hi_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<hi_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(hi(nt2::One<T>()), nt2::Zero<r_t>());\n  NT2_TEST_EQUAL(hi(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for int64_\n\nNT2_TEST_CASE_TPL ( hi_int32__1,  (int32_t)(uint32_t))\n{\n  \n  using nt2::hi;\n  using nt2::tag::hi_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<hi_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(hi(nt2::One<T>()), nt2::Zero<r_t>());\n  NT2_TEST_EQUAL(hi(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for int32_\n\nNT2_TEST_CASE_TPL ( hi_int16__1,  (int16_t)(uint16_t))\n{\n  \n  using nt2::hi;\n  using nt2::tag::hi_;\n  typedef typename nt2::meta::as_integer<T,unsigned>::type ir_t;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<hi_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::downgrade<ir_t>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(hi(nt2::One<T>()), nt2::Zero<r_t>());\n  NT2_TEST_EQUAL(hi(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for int16_\n", "meta": {"hexsha": "766e559b4b2515a68a28996268b4a408020bbf18", "size": 4105, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/bitwise/unit/scalar/hi.cpp", "max_stars_repo_name": "brycelelbach/nt2", "max_stars_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-03-24T03:35:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T03:35:10.000Z", "max_issues_repo_path": "modules/bitwise/unit/scalar/hi.cpp", "max_issues_repo_name": "brycelelbach/nt2", "max_issues_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/bitwise/unit/scalar/hi.cpp", "max_forks_repo_name": "brycelelbach/nt2", "max_forks_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3739837398, "max_line_length": 78, "alphanum_fraction": 0.6302070646, "num_tokens": 1202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.39606818053136394, "lm_q2_score": 0.14223189319192514, "lm_q1q2_score": 0.05633352715005708}}
{"text": "/*\nThe library Boost.NumericConversion can be used to convert numbers of one \ntype to numbers of a different type. In C++, such a conversion can also \ntake place implicitly as shown in the following example.\n*/\n\n//#include <iostream> \n//\n//int main() \n//{ \n//  int i = 0x10000; \n//  short s = i; \n//  std::cout << s << std::endl; \n//}\n\n/*\nThe example is compiled without any error since the type conversion from \nint to short takes place automatically. Even though the application can be \nexecuted, the result of the conversion cannot be predicted but rather \ndepends on the actual compiler and its implementation. The number 0x10000 \nin the variable i is too big to be stored in a variable of type short. Per \nthe C++ standard, the result of this operation is \"implementation defined\".\nCompiled with Visual C++ 2008, the application displays 0. The value of s \ncertainly differs from the value in i.\n*/\n\n/*\nTo avoid these kind of errors while converting numbers, the cast operator \nboost::numeric_cast can be used.\n*/\n\n#include <boost/numeric/conversion/cast.hpp> \n#include <iostream> \n\nint main() \n{ \n  try \n  { \n    int i = -0x10000; \n    short s = boost::numeric_cast<short>(i); \n    std::cout << s << std::endl; \n  } \n  catch (boost::numeric::bad_numeric_cast &e) \n  { \n    std::cerr << e.what() << std::endl; \n  } \n}\n\n/*\nboost::numeric_cast is used exactly like the known C++ cast operators. The \ncorrect header file must certainly be included though; in this case \nboost/numeric/conversion/cast.hpp.\n\nboost::numeric_cast executes the same conversion than C++ does implicitly. \nHowever, boost::numeric_cast actually verifies whether or not the \nconversion can take place without changing the value of the number to be \nconverted. Given the example application, a conversion would not take \nplace. Instead, an exception of type boost::numeric::bad_numeric_cast is \nthrown since 0x10000 is too big to be placed in a variable of type short.\n*/\n\n/*\nStrictly speaking, an exception of type boost::numeric::positive_overflow is\nthrown. This type specifies a so-called overflow - in this case for \npositive numbers. There also exists a type boost::numeric::negative_overflow \nwhich specifies an overflow for negative numbers instead.\n*/\n\n//#include <boost/numeric/conversion/cast.hpp> \n//#include <iostream> \n//\n//int main() \n//{ \n//  try \n//  { \n//    int i = -0x10000; \n//    short s = boost::numeric_cast<short>(i); \n//    std::cout << s << std::endl; \n//  } \n//  catch (boost::numeric::negative_overflow &e) \n//  { \n//    std::cerr << e.what() << std::endl; \n//  } \n//}\n\n/*\nBoost.NumericConversion defines additional exception types, all derived \nfrom boost::numeric::bad_numeric_cast. Since boost::numeric::bad_numeric_cast\nis derived from std::bad_cast itself, a catch handler can also catch \nexceptions of this type.\n*/\n", "meta": {"hexsha": "bb3b9a0033762990d1061b94357163b8bd822cfe", "size": 2826, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Boost/Boost/castOperators/boostNumericConv.cpp", "max_stars_repo_name": "goodspeed24e/Programming", "max_stars_repo_head_hexsha": "ae73fad022396ea03105aad83293facaeea561ae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2021-03-12T19:29:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-12T19:29:33.000Z", "max_issues_repo_path": "Boost/Boost/castOperators/boostNumericConv.cpp", "max_issues_repo_name": "goodspeed24e/Programming", "max_issues_repo_head_hexsha": "ae73fad022396ea03105aad83293facaeea561ae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-03-13T01:36:12.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-13T01:36:12.000Z", "max_forks_repo_path": "Boost/Boost/castOperators/boostNumericConv.cpp", "max_forks_repo_name": "goodspeed24e/Programming", "max_forks_repo_head_hexsha": "ae73fad022396ea03105aad83293facaeea561ae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7173913043, "max_line_length": 77, "alphanum_fraction": 0.7144373673, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583464, "lm_q2_score": 0.11436853523769842, "lm_q1q2_score": 0.05584425670087469}}
{"text": "// fp_traits.hpp\n\n#ifndef BOOST_MATH_FP_TRAITS_HPP\n#define BOOST_MATH_FP_TRAITS_HPP\n\n// Copyright (c) 2006 Johan Rade\n\n// Distributed under the Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n/*\nTo support old compilers, care has been taken to avoid partial template\nspecialization and meta function forwarding.\nWith these techniques, the code could be simplified.\n*/\n\n#if defined(__vms) && defined(__DECCXX) && !__IEEE_FLOAT\n// The VAX floating point formats are used (for float and double)\n#   define BOOST_FPCLASSIFY_VAX_FORMAT\n#endif\n\n#include <cstring>\n\n#include <boost/assert.hpp>\n#include <boost/cstdint.hpp>\n#include <boost/detail/endian.hpp>\n#include <boost/static_assert.hpp>\n#include <boost/type_traits/is_floating_point.hpp>\n\n#ifdef BOOST_NO_STDC_NAMESPACE\n  namespace std{ using ::memcpy; }\n#endif\n\n#ifndef FP_NORMAL\n\n#define FP_ZERO        0\n#define FP_NORMAL      1\n#define FP_INFINITE    2\n#define FP_NAN         3\n#define FP_SUBNORMAL   4\n\n#else\n\n#define BOOST_HAS_FPCLASSIFY\n\n#ifndef fpclassify\n#  if (defined(__GLIBCPP__) || defined(__GLIBCXX__)) \\\n         && defined(_GLIBCXX_USE_C99_MATH) \\\n         && !(defined(_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) \\\n         && (_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC != 0))\n#     ifdef _STLP_VENDOR_CSTD \n#        define BOOST_FPCLASSIFY_PREFIX ::_STLP_VENDOR_CSTD:: \n#     else \n#        define BOOST_FPCLASSIFY_PREFIX ::std::\n#     endif\n#  else\n#     undef BOOST_HAS_FPCLASSIFY\n#     define BOOST_FPCLASSIFY_PREFIX\n#  endif\n#elif (defined(__HP_aCC) && !defined(__hppa))\n// aCC 6 appears to do \"#define fpclassify fpclassify\" which messes us up a bit!\n#  define BOOST_FPCLASSIFY_PREFIX ::\n#else\n#  define BOOST_FPCLASSIFY_PREFIX\n#endif\n\n#ifdef __MINGW32__\n#  undef BOOST_HAS_FPCLASSIFY\n#endif\n\n#endif\n\n\n//------------------------------------------------------------------------------\n\nnamespace boost {\nnamespace math {\nnamespace detail {\n\n//------------------------------------------------------------------------------\n\n/* \nThe following classes are used to tag the different methods that are used\nfor floating point classification\n*/\n\nstruct native_tag {};\ntemplate <bool has_limits>\nstruct generic_tag {};\nstruct ieee_tag {};\nstruct ieee_copy_all_bits_tag : public ieee_tag {};\nstruct ieee_copy_leading_bits_tag : public ieee_tag {};\n\n#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS\n//\n// These helper functions are used only when numeric_limits<>\n// members are not compile time constants:\n//\ninline bool is_generic_tag_false(const generic_tag<false>&)\n{\n   return true;\n}\ninline bool is_generic_tag_false(...)\n{\n   return false;\n}\n#endif\n\n//------------------------------------------------------------------------------\n\n/*\nMost processors support three different floating point precisions:\nsingle precision (32 bits), double precision (64 bits)\nand extended double precision (80 - 128 bits, depending on the processor)\n\nNote that the C++ type long double can be implemented\nboth as double precision and extended double precision.\n*/\n\nstruct unknown_precision{};\nstruct single_precision {};\nstruct double_precision {};\nstruct extended_double_precision {};\n\n// native_tag version --------------------------------------------------------------\n\ntemplate<class T> struct fp_traits_native\n{\n    typedef native_tag method;\n};\n\n// generic_tag version -------------------------------------------------------------\n\ntemplate<class T, class U> struct fp_traits_non_native\n{\n#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS\n   typedef generic_tag<std::numeric_limits<T>::is_specialized> method;\n#else\n   typedef generic_tag<false> method;\n#endif\n};\n\n// ieee_tag versions ---------------------------------------------------------------\n\n/*\nThese specializations of fp_traits_non_native contain information needed\nto \"parse\" the binary representation of a floating point number.\n\nTypedef members:\n\n  bits -- the target type when copying the leading bytes of a floating\n      point number. It is a typedef for uint32_t or uint64_t.\n\n  method -- tells us whether all bytes are copied or not.\n      It is a typedef for ieee_copy_all_bits_tag or ieee_copy_leading_bits_tag.\n\nStatic data members:\n\n  sign, exponent, flag, significand -- bit masks that give the meaning of the\n  bits in the leading bytes.\n\nStatic function members:\n\n  get_bits(), set_bits() -- provide access to the leading bytes.\n\n*/\n\n// ieee_tag version, float (32 bits) -----------------------------------------------\n\n#ifndef BOOST_FPCLASSIFY_VAX_FORMAT\n\ntemplate<> struct fp_traits_non_native<float, single_precision>\n{\n    typedef ieee_copy_all_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7f800000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0x00000000);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x007fffff);\n\n    typedef uint32_t bits;\n    static void get_bits(float x, uint32_t& a) { std::memcpy(&a, &x, 4); }\n    static void set_bits(float& x, uint32_t a) { std::memcpy(&x, &a, 4); }\n};\n\n// ieee_tag version, double (64 bits) ----------------------------------------------\n\n#if defined(BOOST_NO_INT64_T) || defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) \\\n   || defined(__BORLANDC__) || defined(__CODEGEAR__)\n\ntemplate<> struct fp_traits_non_native<double, double_precision>\n{\n    typedef ieee_copy_leading_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7ff00000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x000fffff);\n\n    typedef uint32_t bits;\n\n    static void get_bits(double x, uint32_t& a)\n    {\n        std::memcpy(&a, reinterpret_cast<const unsigned char*>(&x) + offset_, 4);\n    }\n\n    static void set_bits(double& x, uint32_t a)\n    {\n        std::memcpy(reinterpret_cast<unsigned char*>(&x) + offset_, &a, 4);\n    }\n\nprivate:\n\n#if defined(BOOST_BIG_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 0);\n#elif defined(BOOST_LITTLE_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 4);\n#else\n    BOOST_STATIC_ASSERT(false);\n#endif\n};\n\n//..............................................................................\n\n#else\n\ntemplate<> struct fp_traits_non_native<double, double_precision>\n{\n    typedef ieee_copy_all_bits_tag method;\n\n    static const uint64_t sign     = ((uint64_t)0x80000000u) << 32;\n    static const uint64_t exponent = ((uint64_t)0x7ff00000) << 32;\n    static const uint64_t flag     = 0;\n    static const uint64_t significand\n        = (((uint64_t)0x000fffff) << 32) + ((uint64_t)0xffffffffu);\n\n    typedef uint64_t bits;\n    static void get_bits(double x, uint64_t& a) { std::memcpy(&a, &x, 8); }\n    static void set_bits(double& x, uint64_t a) { std::memcpy(&x, &a, 8); }\n};\n\n#endif\n\n#endif\t// #ifndef BOOST_FPCLASSIFY_VAX_FORMAT\n\n// long double (64 bits) -------------------------------------------------------\n\n#if defined(BOOST_NO_INT64_T) || defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)\\\n   || defined(__BORLANDC__) || defined(__CODEGEAR__)\n\ntemplate<> struct fp_traits_non_native<long double, double_precision>\n{\n    typedef ieee_copy_leading_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7ff00000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x000fffff);\n\n    typedef uint32_t bits;\n\n    static void get_bits(long double x, uint32_t& a)\n    {\n        std::memcpy(&a, reinterpret_cast<const unsigned char*>(&x) + offset_, 4);\n    }\n\n    static void set_bits(long double& x, uint32_t a)\n    {\n        std::memcpy(reinterpret_cast<unsigned char*>(&x) + offset_, &a, 4);\n    }\n\nprivate:\n\n#if defined(BOOST_BIG_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 0);\n#elif defined(BOOST_LITTLE_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 4);\n#else\n    BOOST_STATIC_ASSERT(false);\n#endif\n};\n\n//..............................................................................\n\n#else\n\ntemplate<> struct fp_traits_non_native<long double, double_precision>\n{\n    typedef ieee_copy_all_bits_tag method;\n\n    static const uint64_t sign     = (uint64_t)0x80000000u << 32;\n    static const uint64_t exponent = (uint64_t)0x7ff00000 << 32;\n    static const uint64_t flag     = 0;\n    static const uint64_t significand\n        = ((uint64_t)0x000fffff << 32) + (uint64_t)0xffffffffu;\n\n    typedef uint64_t bits;\n    static void get_bits(long double x, uint64_t& a) { std::memcpy(&a, &x, 8); }\n    static void set_bits(long double& x, uint64_t a) { std::memcpy(&x, &a, 8); }\n};\n\n#endif\n\n\n// long double (>64 bits), x86 and x64 -----------------------------------------\n\n#if defined(__i386) || defined(__i386__) || defined(_M_IX86) \\\n    || defined(__amd64) || defined(__amd64__)  || defined(_M_AMD64) \\\n    || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)\n\n// Intel extended double precision format (80 bits)\n\ntemplate<>\nstruct fp_traits_non_native<long double, extended_double_precision>\n{\n    typedef ieee_copy_leading_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7fff0000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0x00008000);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x00007fff);\n\n    typedef uint32_t bits;\n\n    static void get_bits(long double x, uint32_t& a)\n    {\n        std::memcpy(&a, reinterpret_cast<const unsigned char*>(&x) + 6, 4);\n    }\n\n    static void set_bits(long double& x, uint32_t a)\n    {\n        std::memcpy(reinterpret_cast<unsigned char*>(&x) + 6, &a, 4);\n    }\n};\n\n\n// long double (>64 bits), Itanium ---------------------------------------------\n\n#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)\n\n// The floating point format is unknown at compile time\n// No template specialization is provided.\n// The generic_tag definition is used.\n\n// The Itanium supports both\n// the Intel extended double precision format (80 bits) and\n// the IEEE extended double precision format with 15 exponent bits (128 bits).\n\n\n// long double (>64 bits), PowerPC ---------------------------------------------\n\n#elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) \\\n    || defined(__ppc) || defined(__ppc__) || defined(__PPC__)\n\n// PowerPC extended double precision format (128 bits)\n\ntemplate<>\nstruct fp_traits_non_native<long double, extended_double_precision>\n{\n    typedef ieee_copy_leading_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7ff00000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0x00000000);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x000fffff);\n\n    typedef uint32_t bits;\n\n    static void get_bits(long double x, uint32_t& a)\n    {\n        std::memcpy(&a, reinterpret_cast<const unsigned char*>(&x) + offset_, 4);\n    }\n\n    static void set_bits(long double& x, uint32_t a)\n    {\n        std::memcpy(reinterpret_cast<unsigned char*>(&x) + offset_, &a, 4);\n    }\n\nprivate:\n\n#if defined(BOOST_BIG_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 0);\n#elif defined(BOOST_LITTLE_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 12);\n#else\n    BOOST_STATIC_ASSERT(false);\n#endif\n};\n\n\n// long double (>64 bits), Motorola 68K ----------------------------------------\n\n#elif defined(__m68k) || defined(__m68k__) \\\n    || defined(__mc68000) || defined(__mc68000__) \\\n\n// Motorola extended double precision format (96 bits)\n\n// It is the same format as the Intel extended double precision format,\n// except that 1) it is big-endian, 2) the 3rd and 4th byte are padding, and\n// 3) the flag bit is not set for infinity\n\ntemplate<>\nstruct fp_traits_non_native<long double, extended_double_precision>\n{\n    typedef ieee_copy_leading_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7fff0000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0x00008000);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x00007fff);\n\n    // copy 1st, 2nd, 5th and 6th byte. 3rd and 4th byte are padding.\n\n    typedef uint32_t bits;\n\n    static void get_bits(long double x, uint32_t& a)\n    {\n        std::memcpy(&a, &x, 2);\n        std::memcpy(reinterpret_cast<unsigned char*>(&a) + 2,\n               reinterpret_cast<const unsigned char*>(&x) + 4, 2);\n    }\n\n    static void set_bits(long double& x, uint32_t a)\n    {\n        std::memcpy(&x, &a, 2);\n        std::memcpy(reinterpret_cast<unsigned char*>(&x) + 4,\n               reinterpret_cast<const unsigned char*>(&a) + 2, 2);\n    }\n};\n\n\n// long double (>64 bits), All other processors --------------------------------\n\n#else\n\n// IEEE extended double precision format with 15 exponent bits (128 bits)\n\ntemplate<>\nstruct fp_traits_non_native<long double, extended_double_precision>\n{\n    typedef ieee_copy_leading_bits_tag method;\n\n    BOOST_STATIC_CONSTANT(uint32_t, sign        = 0x80000000u);\n    BOOST_STATIC_CONSTANT(uint32_t, exponent    = 0x7fff0000);\n    BOOST_STATIC_CONSTANT(uint32_t, flag        = 0x00000000);\n    BOOST_STATIC_CONSTANT(uint32_t, significand = 0x0000ffff);\n\n    typedef uint32_t bits;\n\n    static void get_bits(long double x, uint32_t& a)\n    {\n        std::memcpy(&a, reinterpret_cast<const unsigned char*>(&x) + offset_, 4);\n    }\n\n    static void set_bits(long double& x, uint32_t a)\n    {\n        std::memcpy(reinterpret_cast<unsigned char*>(&x) + offset_, &a, 4);\n    }\n\nprivate:\n\n#if defined(BOOST_BIG_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 0);\n#elif defined(BOOST_LITTLE_ENDIAN)\n    BOOST_STATIC_CONSTANT(int, offset_ = 12);\n#else\n    BOOST_STATIC_ASSERT(false);\n#endif\n};\n\n#endif\n\n//------------------------------------------------------------------------------\n\n// size_to_precision is a type switch for converting a C++ floating point type\n// to the corresponding precision type.\n\ntemplate<int n, bool fp> struct size_to_precision\n{\n   typedef unknown_precision type;\n};\n\ntemplate<> struct size_to_precision<4, true>\n{\n    typedef single_precision type;\n};\n\ntemplate<> struct size_to_precision<8, true>\n{\n    typedef double_precision type;\n};\n\ntemplate<> struct size_to_precision<10, true>\n{\n    typedef extended_double_precision type;\n};\n\ntemplate<> struct size_to_precision<12, true>\n{\n    typedef extended_double_precision type;\n};\n\ntemplate<> struct size_to_precision<16, true>\n{\n    typedef extended_double_precision type;\n};\n\n//------------------------------------------------------------------------------\n//\n// Figure out whether to use native classification functions based on\n// whether T is a built in floating point type or not:\n//\ntemplate <class T>\nstruct select_native\n{\n    typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::boost::is_floating_point<T>::value>::type precision;\n    typedef fp_traits_non_native<T, precision> type;\n};\ntemplate<>\nstruct select_native<float>\n{\n    typedef fp_traits_native<float> type;\n};\ntemplate<>\nstruct select_native<double>\n{\n    typedef fp_traits_native<double> type;\n};\ntemplate<>\nstruct select_native<long double>\n{\n    typedef fp_traits_native<long double> type;\n};\n\n//------------------------------------------------------------------------------\n\n// fp_traits is a type switch that selects the right fp_traits_non_native\n\n#if (defined(BOOST_MATH_USE_C99) && !(defined(__GNUC__) && (__GNUC__ < 4))) \\\n   && !defined(__hpux) \\\n   && !defined(__DECCXX)\\\n   && !defined(__osf__)\n#  define BOOST_MATH_USE_STD_FPCLASSIFY\n#endif\n\ntemplate<class T> struct fp_traits\n{\n#ifdef BOOST_MATH_USE_STD_FPCLASSIFY\n    typedef typename select_native<T>::type type;\n#else\n    typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::boost::is_floating_point<T>::value>::type precision;\n    typedef fp_traits_non_native<T, precision> type;\n#endif\n};\n\n//------------------------------------------------------------------------------\n\n}   // namespace detail\n}   // namespace math\n}   // namespace boost\n\n#endif\n", "meta": {"hexsha": "60fca11e45a09dd7794eb65af40a1845678640b0", "size": 16135, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/math/special_functions/detail/fp_traits.hpp", "max_stars_repo_name": "mike-code/boost_1_38_0", "max_stars_repo_head_hexsha": "7ff8b2069344ea6b0b757aa1f0778dfb8526df3c", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 21.0, "max_stars_repo_stars_event_min_datetime": "2015-05-22T09:22:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-06T18:54:07.000Z", "max_issues_repo_path": "lshkit/trunk/3rd-party/boost/boost/math/special_functions/detail/fp_traits.hpp", "max_issues_repo_name": "mrfarhadi/BinClone", "max_issues_repo_head_hexsha": "035c20ab27ec00935c12ce54fe9c52bba4aaeff2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2020-05-21T08:43:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-21T08:43:19.000Z", "max_forks_repo_path": "lshkit/trunk/3rd-party/boost/boost/math/special_functions/detail/fp_traits.hpp", "max_forks_repo_name": "mrfarhadi/BinClone", "max_forks_repo_head_hexsha": "035c20ab27ec00935c12ce54fe9c52bba4aaeff2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 11.0, "max_forks_repo_forks_event_min_datetime": "2015-09-08T20:56:14.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-22T12:52:45.000Z", "avg_line_length": 28.6081560284, "max_line_length": 118, "alphanum_fraction": 0.6619770685, "num_tokens": 3839, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583475, "lm_q2_score": 0.11436852618181248, "lm_q1q2_score": 0.05584425227903597}}
{"text": "#include <iostream>\n#include <boost/date_time/gregorian/gregorian.hpp>\n\nusing namespace std;\nusing namespace boost::gregorian;\n\nint main(){\n    // There's three ways to print date:\n    //      1. to_simple_string(date);          YYYY-mm-DD\n    //      2. to_iso_string(date);             YYYYMMDD\n    //      3. to_iso_extended_string(date);    YYYY-MM-DD\n    date d(2008,11,20);\n    cout << \" Standard output format : \" << d << endl;\n    cout << \"to_simple_string format : \" << to_simple_string(d) << endl;\n    cout << \"   to_iso_string format : \" << to_iso_string(d) << endl;\n    cout << \"to_iso_extended_string  : \" << to_iso_extended_string(d) << endl;\n    return 0;\n}\n", "meta": {"hexsha": "257c848a6d0791c16c8e1680b80d286cbf746933", "size": 673, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "cpp/boost/date_time/gregorian_date/03_print_date_example.cpp", "max_stars_repo_name": "Trickness/pl_learning", "max_stars_repo_head_hexsha": "53c10490aed1ba4a02b14aae4890321ad099cc60", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cpp/boost/date_time/gregorian_date/03_print_date_example.cpp", "max_issues_repo_name": "Trickness/pl_learning", "max_issues_repo_head_hexsha": "53c10490aed1ba4a02b14aae4890321ad099cc60", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cpp/boost/date_time/gregorian_date/03_print_date_example.cpp", "max_forks_repo_name": "Trickness/pl_learning", "max_forks_repo_head_hexsha": "53c10490aed1ba4a02b14aae4890321ad099cc60", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.4210526316, "max_line_length": 78, "alphanum_fraction": 0.6166419019, "num_tokens": 181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.480478678047907, "lm_q2_score": 0.11596071367124153, "lm_q1q2_score": 0.055716650410249986}}
{"text": "/*\n//@HEADER\n// ************************************************************************\n//\n// tutorial1.cc\n//                     \t\t  Pressio\n//                             Copyright 2019\n//    National Technology & Engineering Solutions of Sandia, LLC (NTESS)\n//\n// Under the terms of Contract DE-NA0003525 with NTESS, the\n// U.S. Government retains certain rights in this software.\n//\n// Pressio is licensed under BSD-3-Clause terms of use:\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions\n// are met:\n//\n// 1. Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n//\n// 3. Neither the name of the copyright holder nor the names of its\n// contributors may be used to endorse or promote products derived\n// from this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n// POSSIBILITY OF SUCH DAMAGE.\n//\n// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov)\n//\n// ************************************************************************\n//@HEADER\n*/\n\n#include \"pressio_containers.hpp\"\n#include <Eigen/Core>\n\nint main(int argc, char *argv[])\n{\n  std::cout << \"Running tutorial 1\\n\";\n\n  /*\n    Pressio makes use of container wrappers to wrap arbitrary data types.\n    These wrappers are thin layers.\n\n    Pressio has predefined knowledge about data structures\n    from specific libraries, e.g. Trilinos, Eigen, Kokkos.\n    Over time, this support will be extended.\n    If your application uses vector/matrix/multivector classes of one\n    of these libraries, you can easily use pressio as follows.\n\n    Suppose that you have an application that is based on Eigen.\n    Therefore, a (dynamic) vector object \"a\" in your application looks like:\n\n    Eigen::VectorXd a;\n\n    Now, suppose now that you need to use some functionality in pressio.\n    To do so, you need to wrap your object with a pressio container.\n    e.g. ::pressio::containers::Vector<Eigen::VectorXd> aW(a);\n\n    If the type you are wrapping is one of the already supported by pressio,\n    then you have seamless access to all pressio functionalities, since pressio\n    behind the scenes knows how to do algebra with these objects and in fact\n    leverages the native algebra functionalities of the target library.\n    If the type you are wrapping is NOT already known to pressio,\n    then you can still wrap it, but in order to instantiate and use pressio\n    functionalities you need to provide functionalities to tell pressio\n    how to do operations with your data types.\n    See tutorials{3,5} for examples showing using arbitrary types.\n  */\n\n  // this is dynamic double array in Eigen\n  Eigen::VectorXd a(5);\n  a.setConstant(2.2);\n\n  // the corresponding pressio wrapper can be created as follows\n  // Note that here pressio makes a deep copy of the object.\n  // This is because the target ROM algorithms are all implemented\n  // such that pressio owns the data and queries the full-order application\n  // to computed things.\n  ::pressio::containers::Vector<Eigen::VectorXd> aW(a);\n\n  // we can verify that a deep copy is made\n  for (auto i=0; i<aW.extent(0); ++i)\n    std::cout << \"aW(i) = \" << aW(i)\n\t      << \" expected = \" << 2.2\n\t      << std::endl;\n\n  // note that above we used the \"extent\" method\n  // extent(k) works for all pressio container wrappers\n  // - extent(k1) for 1d objects,\n  // - extent(k1,k2) for 2d objects\n\n  return 0;\n}\n", "meta": {"hexsha": "2ae7167a00e77e7bc836a224b0355f4e68c79e54", "size": 4470, "ext": "cc", "lang": "C++", "max_stars_repo_path": "tutorials/wip/tutorial1.cc", "max_stars_repo_name": "Pressio/pressio-tutorials", "max_stars_repo_head_hexsha": "5762d17a8cd2990d84ccc80e1f5ba9759b55b5b9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-03-06T12:06:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-06T12:06:19.000Z", "max_issues_repo_path": "tutorials/wip/tutorial1.cc", "max_issues_repo_name": "Pressio/pressio-tutorials", "max_issues_repo_head_hexsha": "5762d17a8cd2990d84ccc80e1f5ba9759b55b5b9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 16.0, "max_issues_repo_issues_event_min_datetime": "2019-09-30T11:34:49.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-17T20:58:46.000Z", "max_forks_repo_path": "tutorials/wip/tutorial1.cc", "max_forks_repo_name": "Pressio/pressio-tutorials", "max_forks_repo_head_hexsha": "5762d17a8cd2990d84ccc80e1f5ba9759b55b5b9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.6363636364, "max_line_length": 79, "alphanum_fraction": 0.6995525727, "num_tokens": 996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.37022539259558657, "lm_q2_score": 0.15002883004302128, "lm_q1q2_score": 0.05554448250333409}}
{"text": "//---------------------------------------------------------------------------//\r\n// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>\r\n//\r\n// Distributed under the Boost Software License, Version 1.0\r\n// See accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt\r\n//\r\n// See http://boostorg.github.com/compute for more information.\r\n//---------------------------------------------------------------------------//\r\n\r\n#define BOOST_TEST_MODULE TestPermutationIterator\r\n#include <boost/test/unit_test.hpp>\r\n\r\n#include <iterator>\r\n\r\n#include <boost/type_traits.hpp>\r\n#include <boost/static_assert.hpp>\r\n\r\n#include <boost/compute/types.hpp>\r\n#include <boost/compute/algorithm/copy.hpp>\r\n#include <boost/compute/container/vector.hpp>\r\n#include <boost/compute/iterator/buffer_iterator.hpp>\r\n#include <boost/compute/iterator/permutation_iterator.hpp>\r\n\r\n#include \"check_macros.hpp\"\r\n#include \"context_setup.hpp\"\r\n\r\nBOOST_AUTO_TEST_CASE(value_type)\r\n{\r\n    using boost::compute::float4_;\r\n\r\n    BOOST_STATIC_ASSERT((\r\n        boost::is_same<\r\n            boost::compute::permutation_iterator<\r\n                boost::compute::buffer_iterator<float>,\r\n                boost::compute::buffer_iterator<int>\r\n            >::value_type,\r\n            float\r\n        >::value\r\n    ));\r\n    BOOST_STATIC_ASSERT((\r\n        boost::is_same<\r\n            boost::compute::permutation_iterator<\r\n                boost::compute::buffer_iterator<float4_>,\r\n                boost::compute::buffer_iterator<short>\r\n            >::value_type,\r\n            float4_\r\n        >::value\r\n    ));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(base_type)\r\n{\r\n    BOOST_STATIC_ASSERT((\r\n        boost::is_same<\r\n            boost::compute::permutation_iterator<\r\n                boost::compute::buffer_iterator<int>,\r\n                boost::compute::buffer_iterator<int>\r\n            >::base_type,\r\n            boost::compute::buffer_iterator<int>\r\n        >::value\r\n    ));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(copy)\r\n{\r\n    int input_data[] = { 3, 4, 2, 1, 5 };\r\n    boost::compute::vector<int> input(input_data, input_data + 5, queue);\r\n\r\n    int map_data[] = { 3, 2, 0, 1, 4 };\r\n    boost::compute::vector<int> map(map_data, map_data + 5, queue);\r\n\r\n    boost::compute::vector<int> output(5, context);\r\n    boost::compute::copy(\r\n        boost::compute::make_permutation_iterator(input.begin(), map.begin()),\r\n        boost::compute::make_permutation_iterator(input.end(), map.end()),\r\n        output.begin(),\r\n        queue\r\n    );\r\n    CHECK_RANGE_EQUAL(int, 5, output, (1, 2, 3, 4, 5));\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(reverse_range_doctest)\r\n{\r\n    int values_data[] = { 10, 20, 30, 40 };\r\n    int indices_data[] = { 3, 2, 1, 0 };\r\n\r\n    boost::compute::vector<int> values(values_data, values_data + 4, queue);\r\n    boost::compute::vector<int> indices(indices_data, indices_data + 4, queue);\r\n\r\n    boost::compute::vector<int> result(4, context);\r\n\r\n//! [reverse_range]\r\n// values =  { 10, 20, 30, 40 }\r\n// indices = { 3, 2, 1, 0 }\r\n\r\nboost::compute::copy(\r\n    boost::compute::make_permutation_iterator(values.begin(), indices.begin()),\r\n    boost::compute::make_permutation_iterator(values.end(), indices.end()),\r\n    result.begin(),\r\n    queue\r\n);\r\n\r\n// result == { 40, 30, 20, 10 }\r\n//! [reverse_range]\r\n\r\n    CHECK_RANGE_EQUAL(int, 4, result, (40, 30, 20, 10));\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "fda4e399852f46239faf856652e2a95d489a4080", "size": 3374, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/compute/test/test_permutation_iterator.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/compute/test/test_permutation_iterator.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-03-04T11:21:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-24T01:36:31.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/compute/test/test_permutation_iterator.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 30.3963963964, "max_line_length": 80, "alphanum_fraction": 0.5921754594, "num_tokens": 804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.11279541373888335, "lm_q1q2_score": 0.05551656440599681}}
{"text": "//=======================================================================\r\n// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, \r\n//\r\n// This file is part of the Boost Graph Library\r\n//\r\n// You should have received a copy of the License Agreement for the\r\n// Boost Graph Library along with the software; see the file LICENSE.\r\n// If not, contact Office of Research, Indiana University,\r\n// Bloomington, IN 47405.\r\n//\r\n// Permission to modify the code and to distribute the code is\r\n// granted, provided the text of this NOTICE is retained, a notice if\r\n// the code was modified is included with the above COPYRIGHT NOTICE\r\n// and with the COPYRIGHT NOTICE in the LICENSE file, and that the\r\n// LICENSE file is distributed with the modified code.\r\n//\r\n// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.\r\n// By way of example, but not limitation, Licensor MAKES NO\r\n// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY\r\n// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS\r\n// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS\r\n// OR OTHER RIGHTS.\r\n//=======================================================================\r\n#include <boost/config.hpp>\r\n#include <iostream>\r\n#include <fstream>\r\n#include <boost/graph/adjacency_list.hpp>\r\n#include <boost/graph/breadth_first_search.hpp>\r\nusing namespace boost;\r\n\r\ntemplate < typename Graph, typename VertexNameMap, typename TransDelayMap > void\r\nbuild_router_network(Graph & g, VertexNameMap name_map,\r\n                     TransDelayMap delay_map)\r\n{\r\n  typename graph_traits < Graph >::vertex_descriptor a, b, c, d, e;\r\n  a = add_vertex(g);\r\n  name_map[a] = 'a';\r\n  b = add_vertex(g);\r\n  name_map[b] = 'b';\r\n  c = add_vertex(g);\r\n  name_map[c] = 'c';\r\n  d = add_vertex(g);\r\n  name_map[d] = 'd';\r\n  e = add_vertex(g);\r\n  name_map[e] = 'e';\r\n\r\n  typename graph_traits < Graph >::edge_descriptor ed;\r\n  bool inserted;\r\n\r\n  tie(ed, inserted) = add_edge(a, b, g);\r\n  delay_map[ed] = 1.2;\r\n  tie(ed, inserted) = add_edge(a, d, g);\r\n  delay_map[ed] = 4.5;\r\n  tie(ed, inserted) = add_edge(b, d, g);\r\n  delay_map[ed] = 1.8;\r\n  tie(ed, inserted) = add_edge(c, a, g);\r\n  delay_map[ed] = 2.6;\r\n  tie(ed, inserted) = add_edge(c, e, g);\r\n  delay_map[ed] = 5.2;\r\n  tie(ed, inserted) = add_edge(d, c, g);\r\n  delay_map[ed] = 0.4;\r\n  tie(ed, inserted) = add_edge(d, e, g);\r\n  delay_map[ed] = 3.3;\r\n\r\n}\r\n\r\n\r\ntemplate < typename VertexNameMap > class bfs_name_printer:public default_bfs_visitor {\r\n                                // inherit default (empty) event point actions\r\npublic:\r\nbfs_name_printer(VertexNameMap n_map):m_name_map(n_map) {\r\n  }\r\n  template < typename Vertex, typename Graph >\r\n    void discover_vertex(Vertex u, const Graph &) const\r\n  {\r\n    std::cout << get(m_name_map, u) << ' ';\r\n  }\r\nprivate:\r\n    VertexNameMap m_name_map;\r\n};\r\n\r\n\r\nint\r\nmain()\r\n{\r\n  typedef adjacency_list < listS, vecS, directedS,\r\n    property < vertex_name_t, char >,\r\n    property < edge_weight_t, double > > graph_t;\r\n  graph_t g;\r\n\r\n  property_map < graph_t, vertex_name_t >::type name_map =\r\n    get(vertex_name, g);\r\n  property_map < graph_t, edge_weight_t >::type delay_map =\r\n    get(edge_weight, g);\r\n\r\n  build_router_network(g, name_map, delay_map);\r\n\r\n  typedef property_map < graph_t, vertex_name_t >::type VertexNameMap;\r\n  graph_traits < graph_t >::vertex_descriptor a = *vertices(g).first;\r\n  bfs_name_printer < VertexNameMap > vis(name_map);\r\n  std::cout << \"BFS vertex discover order: \";\r\n  breadth_first_search(g, a, visitor(vis));\r\n  std::cout << std::endl;\r\n\r\n}\r\n", "meta": {"hexsha": "a5106c986a363440dba3a8f0c55a68d16077232c", "size": 3602, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "sdk/boost_1_30_0/libs/graph/example/bfs-name-printer.cpp", "max_stars_repo_name": "acidicMercury8/xray-1.0", "max_stars_repo_head_hexsha": "65e85c0e31e82d612c793d980dc4b73fa186c76c", "max_stars_repo_licenses": ["Linux-OpenIB"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2020-01-30T12:51:49.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-31T08:36:49.000Z", "max_issues_repo_path": "sdk/boost_1_30_0/libs/graph/example/bfs-name-printer.cpp", "max_issues_repo_name": "acidicMercury8/xray-1.0", "max_issues_repo_head_hexsha": "65e85c0e31e82d612c793d980dc4b73fa186c76c", "max_issues_repo_licenses": ["Linux-OpenIB"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sdk/boost_1_30_0/libs/graph/example/bfs-name-printer.cpp", "max_forks_repo_name": "acidicMercury8/xray-1.0", "max_forks_repo_head_hexsha": "65e85c0e31e82d612c793d980dc4b73fa186c76c", "max_forks_repo_licenses": ["Linux-OpenIB"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.9811320755, "max_line_length": 88, "alphanum_fraction": 0.6482509717, "num_tokens": 910, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4649015713733885, "lm_q2_score": 0.11920291263495983, "lm_q1q2_score": 0.055417621396277573}}
{"text": "\r\n// Copyright (C) 2008-2018 Lorenzo Caminiti\r\n// Distributed under the Boost Software License, Version 1.0 (see accompanying\r\n// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).\r\n// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html\r\n\r\n//[n1962_sum\r\n#include <boost/contract.hpp>\r\n#include <cassert>\r\n\r\nint sum(int count, int* array) {\r\n    int result;\r\n    boost::contract::check c = boost::contract::function()\r\n        .precondition([&] {\r\n            BOOST_CONTRACT_ASSERT(count % 4 == 0);\r\n        })\r\n    ;\r\n\r\n    result = 0;\r\n    for(int i = 0; i < count; ++i) result += array[i];\r\n    return result;\r\n}\r\n\r\nint main() {\r\n    int a[4] = {1, 2, 3, 4};\r\n    assert(sum(4, a) == 10);\r\n    return 0;\r\n}\r\n//]\r\n\r\n", "meta": {"hexsha": "1b6d05564d5bfc782c4f9641648a45b4838956b4", "size": 764, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/contract/example/n1962/sum.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/contract/example/n1962/sum.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/contract/example/n1962/sum.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 24.6451612903, "max_line_length": 80, "alphanum_fraction": 0.5903141361, "num_tokens": 220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4339814648038985, "lm_q2_score": 0.12765263859663167, "lm_q1q2_score": 0.055398879084248884}}
{"text": "/* test_constructors.cpp - Test Adept's selection of constructors in a range of scenarios\n\n    Copyright (C) 2017 European Centre for Medium-Range Weather Forecasts\n\n    Author: Robin Hogan <r.j.hogan@ecmwf.int>\n\n  Copying and distribution of this file, with or without modification,\n  are permitted in any medium without royalty provided the copyright\n  notice and this notice are preserved.  This file is offered as-is,\n  without any warranty.\n*/\n\n#include <iostream>\n\n#define ADEPT_BOUNDS_CHECKING 1\n#define ADEPT_VERBOSE_FUNCTIONS\n#define ADEPT_NO_ALIAS_CHECKING\n\n#include <adept_arrays.h>\n\nusing namespace adept;\n\nVector square(const Vector& v) {\n  std::cout << \"  inside function\\n\";\n  return v*v;\n}\n\nvoid square_in_place(Vector& v) {\n  std::cout << \"  inside function\\n\";\n  v *= v;\n}\n\nVector square_copy(Vector v) {\n  std::cout << \"  inside function\\n\";\n  v *= -1.0;\n  return v*v;\n}\n\n#define COMMA ,\n\n#define EVAL_CONSTRUCT(MSG,X,COMMAND) std::cout << \"--------------------------------------------------------------------\\n\" \\\n  << MSG << \"\\n\" \\\n  << #COMMAND << \"\\n\"; \\\n  COMMAND; \\\n  std::cout << #X << \" = \" << X << \"\\n\"\n\n#define EVAL(MSG,X,COMMAND) std::cout << \"--------------------------------------------------------------------\\n\" \\\n  << MSG << \"\\n\" \\\n  << #X << \" = \" << X << \"\\n\" \\\n  << #COMMAND << \"\\n\"; \\\n  COMMAND; \\\n  std::cout << #X << \" = \" << X << \"\\n\"\n\n #define EVAL2(MSG,X,COMMAND,Y) std::cout << \"--------------------------------------------------------------------\\n\" \\\n  << MSG << \"\\n\" \\\n  << #X << \" = \" << X << \"\\n\" \\\n  << #COMMAND << \"\\n\"; \\\n  COMMAND;\t\t\t\t\t\\\n  std::cout << #X << \" = \" << X << \"\\n\" \\\n            << #Y << \" = \" << Y << \"\\n\"\n\n#define EVAL_FAIL(MSG,X,COMMAND) std::cout << \"--------------------------------------------------------------------\\n\" \\\n  << MSG << \"\\n\" \\\n  << #COMMAND << \"\\n\" \\\n  << \"DOES NOT COMPILE (INCORRECT BEHAVIOUR)\\n\"\n\n#define EVAL2_FAIL(MSG,X,COMMAND,Y) std::cout << \"--------------------------------------------------------------------\\n\" \\\n  << MSG << \"\\n\" \\\n  << #COMMAND << \"\\n\" \\\n  << \"DOES NOT COMPILE (INCORRECT BEHAVIOUR)\\n\"\n\n#define VERDICT98(MSG) std::cout << \"Verdict for C++98: \" << MSG << \"\\n\"\n#define VERDICT11(MSG) std::cout << \"Verdict for C++11: \" << MSG << \"\\n\"\n\n#define HEADING(MSG) std::cout << \"####################################################################\\n\" \\\n  << MSG << \"\\n\"\n\n\nint\nmain() {\n\n  Vector v(2), w(2), v_data(2), v_const_data(2);\n  v_data << 2, 3;\n  v_const_data << 5, 7;\n  v = v_data;\n  const Vector v_const = v_const_data;\n\n  adept::Stack stack;\n  stack.new_recording();\n\n  {\n  HEADING(\"COPY CONSTRUCTORS\");\n  EVAL2(\"Passing Vector as argument to Vector copy constructor\",\n\tv, const Vector v2(v), v2);\n  VERDICT98(\"correct\");\n  VERDICT11(\"should perform deep copy\");\n\n  EVAL2(\"Passing Vector as argument to const Vector copy constructor\",\n\tv, const Vector v_const(v), v_const);\n  VERDICT98(\"correct\");\n  VERDICT11(\"should perform deep copy\");\n\n  EVAL2(\"Passing const Vector as argument to const Vector copy constructor\",\n\tv_const, const Vector v_const2(v_const), v_const2);\n  VERDICT98(\"correct\");\n  VERDICT11(\"should perform deep copy\");\n\n  EVAL2(\"Passing const Vector as argument to Vector copy constructor\",\n\tv_const, Vector v3(v_const), v3);\n  VERDICT98(\"should not compile\");\n  VERDICT11(\"should perform deep copy\");\n  }\n\n#ifdef ADEPT_CXX11_FEATURES\n  HEADING(\"INITIALIZER LISTS\");\n  EVAL_CONSTRUCT(\"Construct Vector from initializer list of ints\",\n\tv1, Vector v1 = {1 COMMA 2 COMMA 3});\n  EVAL_CONSTRUCT(\"Construct Vector from initializer list of doubles\",\n\tv1d, Vector v1d = {1.0 COMMA 2.0 COMMA 3.0});\n  EVAL_CONSTRUCT(\"Construct Matrix from initializer list\",\n\t\t M, Matrix M = { {1 COMMA 2} COMMA {3} } );\n  EVAL_CONSTRUCT(\"Construct Array3D from initializer list\",\n\t\t A3, Array3D A3 = { { {1 COMMA 2} COMMA {3} } COMMA { { 4 } } } );\n  EVAL_CONSTRUCT(\"Construct FixedVector from initializer list\",\n\t\t fv1, Vector3 fv1 = {1 COMMA 2});\n  EVAL_CONSTRUCT(\"Construct FixedMatrix from initializer list\",\n\t\t fM, Matrix33 fM = { {1 COMMA 2} COMMA {3} } );\n  EVAL_CONSTRUCT(\"Construct FixedArray3D from initializer list\",\n\t\t fA3, FixedArray<double COMMA false COMMA 3 COMMA 3 COMMA 3> fA3 = { { {1 COMMA 2} COMMA {3} } COMMA { { 4 } } } );\n#endif\n\n  HEADING(\"ASSIGNMENT OPERATOR\");\n  EVAL2(\"Passing Vector to assignment operator\",\n\tv, w = v, w);\n  EVAL2(\"Passing const Vector to assignment operator\",\n\tv_const, w = v_const, w);\n  EVAL2(\"Passing Vector rvalue to assignment operator\",\n\tv, w = v(stride(1,0,-1)), w);\n  EVAL2(\"Passing const-Vector rvalue to assignment operator\",\n\tv_const, w = v_const(stride(1,0,-1)), w);\n  EVAL2(\"Passing Expression to assignment operator\",\n\tv, w = v+v, w);\n\n  HEADING(\"PASSING Vector TO FUNCTIONS\");\n  EVAL2(\"Passing Vector as argument to function taking const Vector&\",\n       v, w = square(v), w);\n  VERDICT98(\"too many copies\");\n  VERDICT11(\"could replace last copy with a move\");\n  EVAL(\"Passing Vector as argument to function taking Vector&\",\n       v, square_in_place(v));\n  VERDICT98(\"correct\");\n\n  v = v_data;\n  EVAL2(\"Passing Vector as argument to function taking Vector\",\n       v, w = square_copy(v), w);\n  VERDICT98(\"too many copies, unexpected change of argument\");\n  VERDICT11(\"should do deep copy on input, replace last copy with a move\");\n\n  /*\n\n    // Behaves same as passing non-const Vector, which is correct\n\n  // Passing const Vector\n  EVAL2(\"Passing const Vector as argument to function taking const Vector&\",\n       v_const, w = square(v_const), w);\n  // The following should not compile:\n  //  EVAL(\"Passing const Vector as argument to function taking Vector&\",\n  //       v_const, square_in_place(v_const));\n  EVAL2(\"Passing const Vector as argument to function taking Vector\",\n       v_const, w = square_copy(v_const), w);\n\n  */\n\n\n  HEADING(\"LINKING\");\n  w.clear();\n  EVAL2(\"Linking to Vector\",\n\tv, w >>= v, w);\n\n  /*\n  w.clear();\n  // This should not compile\n  EVAL2(\"Linking to const Vector\",\n\tv_const, w >>= v_const, w);\n  */\n  w.clear();\n  EVAL2(\"Linking to Vector rvalue\",\n\tv, w >>= v(stride(1,0,-1)), w);\n\n  /*\n  // This should not compile\n  w.clear();\n  EVAL2(\"Linking to const-Vector rvalue\",\n\tv_const, w >>= v_const(stride(1,0,-1)), w);\n  */\n  /*\n    // This should not compile\n  w.clear();\n  EVAL2(\"Linking to Expression\",\n\tv, w >>= v+v, w);\n  VERDICT98(\"this doesn't make much sense\");\n  */\n\n  HEADING(\"PASSING Vector TO FUNCTIONS\");\n  EVAL2(\"Passing Vector as argument to function taking const Vector&\",\n       v, w = square(v), w);\n  VERDICT98(\"too many copies\");\n  VERDICT11(\"could replace last copy with a move\");\n  EVAL(\"Passing Vector as argument to function taking Vector&\",\n       v, square_in_place(v));\n  VERDICT98(\"correct\");\n\n  v = v_data;\n  EVAL2(\"Passing Vector as argument to function taking Vector\",\n       v, w = square_copy(v), w);\n  VERDICT98(\"too many copies, unexpected change of argument\");\n  VERDICT11(\"should do deep copy on input, replace last copy with a move\");\n\n\n  HEADING(\"PASSING Vector RVALUE TO FUNCTIONS\");\n  EVAL2(\"Passing Vector rvalue as argument to function taking const Vector&\",\n\tv, w = square(v(stride(1,0,-1))), w);\n  VERDICT98(\"correct\");\n  EVAL_FAIL(\"Passing Vector rvalue as argument to function taking Vector&\",\n       v, square_in_place(v(stride(1,0,-1))));\n  VERDICT98(\"Vector subset functions could return references?\");\n\n  v = v_data;\n  EVAL2(\"Passing Vector rvalue as argument to function taking Vector\",\n\t     v, w = square_copy(v(stride(1,0,-1))), w);\n  VERDICT98(\"Vector subset functions could return references?\");\n  VERDICT11(\"Should use move function\");\n\n  HEADING(\"PASSING const Vector RVALUES TO FUNCTIONS\");\n  EVAL2(\"Passing const-Vector rvalue as argument to function taking const Vector&\",\n\tv_const, w = square(v_const(stride(1,0,-1))), w);\n  VERDICT98(\"correct\");\n  // This should not compile\n  //  EVAL(\"Passing const-Vector rvalue as argument to function taking Vector&\",\n  //       v_const, square_in_place(v_const(stride(1,0,-1))));\n  //  VERDICT98(\"Vector subset functions could return references?\");\n  EVAL2(\"Passing const-Vector rvalue as argument to function taking Vector\",\n\t     v_const, w = square_copy(v_const(stride(1,0,-1))), w);\n  VERDICT98(\"correct\");\n  //  VERDICT11(\"Should use move function\");\n\n  HEADING(\"PASSING Expression TO FUNCTIONS\");\n  EVAL2(\"Passing Expression as argument to function taking const Vector&\",\n       v, w = square(v+v), w);\n  VERDICT98(\"Unclear why copy-assignment + constructor needed\");\n  // This should not compile:\n  //  EVAL(\"Passing Expression as argument to function taking Vector&\",\n  //       v, square_in_place(v+v));\n  v = v_data;\n  EVAL2(\"Passing Expression as argument to function taking Vector\",\n       v, w = square_copy(v+v), w);\n  VERDICT98(\"Unclear why copy-assignment + constructor needed\");\n\n  return 0;\n}\n", "meta": {"hexsha": "2d5db018195eeb489b0f95ce197e0450f598996c", "size": 8814, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/test_constructors.cpp", "max_stars_repo_name": "yairchu/Adept-2", "max_stars_repo_head_hexsha": "3b4f898c74139618464ccd8e8df0934aed9ed6a2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 131.0, "max_stars_repo_stars_event_min_datetime": "2016-07-06T04:06:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T22:34:47.000Z", "max_issues_repo_path": "test/test_constructors.cpp", "max_issues_repo_name": "yairchu/Adept-2", "max_issues_repo_head_hexsha": "3b4f898c74139618464ccd8e8df0934aed9ed6a2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 19.0, "max_issues_repo_issues_event_min_datetime": "2016-06-20T20:20:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T14:55:01.000Z", "max_forks_repo_path": "test/test_constructors.cpp", "max_forks_repo_name": "yairchu/Adept-2", "max_forks_repo_head_hexsha": "3b4f898c74139618464ccd8e8df0934aed9ed6a2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 31.0, "max_forks_repo_forks_event_min_datetime": "2017-10-07T00:07:49.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-05T17:51:17.000Z", "avg_line_length": 33.7701149425, "max_line_length": 125, "alphanum_fraction": 0.6266167461, "num_tokens": 2456, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4610167793123159, "lm_q2_score": 0.11920292984474949, "lm_q1q2_score": 0.054954550801618346}}
{"text": "// This file is part of Eigen, a lightweight C++ template library\r\n// for linear algebra.\r\n//\r\n// Copyright (C) 20015 Gael Guennebaud <gael.guennebaud@inria.fr>\r\n//\r\n// This Source Code Form is subject to the terms of the Mozilla\r\n// Public License v. 2.0. If a copy of the MPL was not distributed\r\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\r\n\r\n// This unit test cannot be easily written to work with EIGEN_DEFAULT_TO_ROW_MAJOR\r\n#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR\r\n#undef EIGEN_DEFAULT_TO_ROW_MAJOR\r\n#endif\r\n\r\nstatic long int nb_temporaries;\r\n\r\ninline void on_temporary_creation() {\r\n  // here's a great place to set a breakpoint when debugging failures in this test!\r\n  nb_temporaries++;\r\n}\r\n\r\n#define EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN { on_temporary_creation(); }\r\n\r\n#include \"main.h\"\r\n#include <Eigen/SparseCore>\r\n\r\n#define VERIFY_EVALUATION_COUNT(XPR,N) {\\\r\n    nb_temporaries = 0; \\\r\n    CALL_SUBTEST( XPR ); \\\r\n    if(nb_temporaries!=N) std::cerr << \"nb_temporaries == \" << nb_temporaries << \"\\n\"; \\\r\n    VERIFY( (#XPR) && nb_temporaries==N ); \\\r\n  }\r\n\r\ntemplate<typename PlainObjectType> void check_const_correctness(const PlainObjectType&)\r\n{\r\n  // verify that ref-to-const don't have LvalueBit\r\n  typedef typename internal::add_const<PlainObjectType>::type ConstPlainObjectType;\r\n  VERIFY( !(internal::traits<Ref<ConstPlainObjectType> >::Flags & LvalueBit) );\r\n  VERIFY( !(internal::traits<Ref<ConstPlainObjectType, Aligned> >::Flags & LvalueBit) );\r\n  VERIFY( !(Ref<ConstPlainObjectType>::Flags & LvalueBit) );\r\n  VERIFY( !(Ref<ConstPlainObjectType, Aligned>::Flags & LvalueBit) );\r\n}\r\n\r\ntemplate<typename B>\r\nEIGEN_DONT_INLINE void call_ref_1(Ref<SparseMatrix<float> > a, const B &b) { VERIFY_IS_EQUAL(a.toDense(),b.toDense()); }\r\n\r\ntemplate<typename B>\r\nEIGEN_DONT_INLINE void call_ref_2(const Ref<const SparseMatrix<float> >& a, const B &b) { VERIFY_IS_EQUAL(a.toDense(),b.toDense()); }\r\n\r\ntemplate<typename B>\r\nEIGEN_DONT_INLINE void call_ref_3(const Ref<const SparseMatrix<float>, StandardCompressedFormat>& a, const B &b) {\r\n  VERIFY(a.isCompressed());\r\n  VERIFY_IS_EQUAL(a.toDense(),b.toDense());\r\n}\r\n\r\ntemplate<typename B>\r\nEIGEN_DONT_INLINE void call_ref_4(Ref<SparseVector<float> > a, const B &b) { VERIFY_IS_EQUAL(a.toDense(),b.toDense()); }\r\n\r\ntemplate<typename B>\r\nEIGEN_DONT_INLINE void call_ref_5(const Ref<const SparseVector<float> >& a, const B &b) { VERIFY_IS_EQUAL(a.toDense(),b.toDense()); }\r\n\r\nvoid call_ref()\r\n{\r\n  SparseMatrix<float>               A = MatrixXf::Random(10,10).sparseView(0.5,1);\r\n  SparseMatrix<float,RowMajor>      B = MatrixXf::Random(10,10).sparseView(0.5,1);\r\n  SparseMatrix<float>               C = MatrixXf::Random(10,10).sparseView(0.5,1);\r\n  C.reserve(VectorXi::Constant(C.outerSize(), 2));\r\n  const SparseMatrix<float>&        Ac(A);\r\n  Block<SparseMatrix<float> >       Ab(A,0,1, 3,3);\r\n  const Block<SparseMatrix<float> > Abc(A,0,1,3,3);\r\n  SparseVector<float>               vc =  VectorXf::Random(10).sparseView(0.5,1);\r\n  SparseVector<float,RowMajor>      vr =  VectorXf::Random(10).sparseView(0.5,1);\r\n  SparseMatrix<float> AA = A*A;\r\n  \r\n\r\n  VERIFY_EVALUATION_COUNT( call_ref_1(A, A),  0);\r\n//   VERIFY_EVALUATION_COUNT( call_ref_1(Ac, Ac),  0); // does not compile on purpose\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A, A),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(A, A),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A.transpose(), A.transpose()),  1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(A.transpose(), A.transpose()),  1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(Ac,Ac), 0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(Ac,Ac), 0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A+A,2*Ac), 1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(A+A,2*Ac), 1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(B, B),  1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(B, B),  1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(B.transpose(), B.transpose()),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(B.transpose(), B.transpose()),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A*A, AA),  3);\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(A*A, AA),  3);\r\n  \r\n  VERIFY(!C.isCompressed());\r\n  VERIFY_EVALUATION_COUNT( call_ref_3(C, C),  1);\r\n  \r\n  Ref<SparseMatrix<float> > Ar(A);\r\n  VERIFY_IS_APPROX(Ar+Ar, A+A);\r\n  VERIFY_EVALUATION_COUNT( call_ref_1(Ar, A),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(Ar, A),  0);\r\n  \r\n  Ref<SparseMatrix<float,RowMajor> > Br(B);\r\n  VERIFY_EVALUATION_COUNT( call_ref_1(Br.transpose(), Br.transpose()),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(Br, Br),  1);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(Br.transpose(), Br.transpose()),  0);\r\n  \r\n  Ref<const SparseMatrix<float> > Arc(A);\r\n//   VERIFY_EVALUATION_COUNT( call_ref_1(Arc, Arc),  0); // does not compile on purpose\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(Arc, Arc),  0);\r\n  \r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A.middleCols(1,3), A.middleCols(1,3)),  0);\r\n  \r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A.col(2), A.col(2)),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(vc, vc),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(vr.transpose(), vr.transpose()),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_2(vr, vr.transpose()),  0);\r\n  \r\n  VERIFY_EVALUATION_COUNT( call_ref_2(A.block(1,1,3,3), A.block(1,1,3,3)),  1); // should be 0 (allocate starts/nnz only)\r\n\r\n  VERIFY_EVALUATION_COUNT( call_ref_4(vc, vc),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_4(vr, vr.transpose()),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_5(vc, vc),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_5(vr, vr.transpose()),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_4(A.col(2), A.col(2)),  0);\r\n  VERIFY_EVALUATION_COUNT( call_ref_5(A.col(2), A.col(2)),  0);\r\n  // VERIFY_EVALUATION_COUNT( call_ref_4(A.row(2), A.row(2).transpose()),  1); // does not compile on purpose\r\n  VERIFY_EVALUATION_COUNT( call_ref_5(A.row(2), A.row(2).transpose()),  1);\r\n}\r\n\r\nvoid test_sparse_ref()\r\n{\r\n  for(int i = 0; i < g_repeat; i++) {\r\n    CALL_SUBTEST_1( check_const_correctness(SparseMatrix<float>()) );\r\n    CALL_SUBTEST_1( check_const_correctness(SparseMatrix<double,RowMajor>()) );\r\n    CALL_SUBTEST_2( call_ref() );\r\n\r\n    CALL_SUBTEST_3( check_const_correctness(SparseVector<float>()) );\r\n    CALL_SUBTEST_3( check_const_correctness(SparseVector<double,RowMajor>()) );\r\n  }\r\n}\r\n", "meta": {"hexsha": "59369fcbce15da8a7c98b73006755ff6ef991768", "size": 6256, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "packages/eigen-eigen-323c052e1731/test/sparse_ref.cpp", "max_stars_repo_name": "k4rth33k/dnnc-operators", "max_stars_repo_head_hexsha": "a7fe3f1240c12b3438558def71fbfcd4520446c3", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5.0, "max_stars_repo_stars_event_min_datetime": "2019-08-16T14:35:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-11T23:59:22.000Z", "max_issues_repo_path": "packages/eigen-eigen-323c052e1731/test/sparse_ref.cpp", "max_issues_repo_name": "k4rth33k/dnnc-operators", "max_issues_repo_head_hexsha": "a7fe3f1240c12b3438558def71fbfcd4520446c3", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 6.0, "max_issues_repo_issues_event_min_datetime": "2019-08-12T04:38:14.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-04T16:32:13.000Z", "max_forks_repo_path": "packages/eigen-eigen-323c052e1731/test/sparse_ref.cpp", "max_forks_repo_name": "k4rth33k/dnnc-operators", "max_forks_repo_head_hexsha": "a7fe3f1240c12b3438558def71fbfcd4520446c3", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 7.0, "max_forks_repo_forks_event_min_datetime": "2019-08-15T13:29:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-09T17:08:04.000Z", "avg_line_length": 44.6857142857, "max_line_length": 134, "alphanum_fraction": 0.6993286445, "num_tokens": 1915, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46101677931231594, "lm_q2_score": 0.11920291419948607, "lm_q1q2_score": 0.054954543588889404}}
{"text": "//  Copyright (c) 2010 Peter Schueller\r\n//  Copyright (c) 2001-2010 Hartmut Kaiser\r\n// \r\n//  Distributed under the Boost Software License, Version 1.0. (See accompanying \r\n//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n#include <boost/config/warning_disable.hpp>\r\n#include <boost/detail/lightweight_test.hpp>\r\n\r\n#include <vector>\r\n#include <istream>\r\n#include <sstream>\r\n#include <iostream>\r\n\r\n#include <boost/spirit/include/qi.hpp>\r\n#include <boost/spirit/include/support_multi_pass.hpp>\r\n\r\nnamespace qi = boost::spirit::qi;\r\nnamespace ascii = boost::spirit::ascii;\r\n\r\nstd::vector<double> parse(std::istream& input)\r\n{\r\n  // iterate over stream input\r\n  typedef std::istreambuf_iterator<char> base_iterator_type;\r\n  base_iterator_type in_begin(input);\r\n\r\n  // convert input iterator to forward iterator, usable by spirit parser\r\n  typedef boost::spirit::multi_pass<base_iterator_type> forward_iterator_type;\r\n  forward_iterator_type fwd_begin = boost::spirit::make_default_multi_pass(in_begin);\r\n  forward_iterator_type fwd_end;\r\n\r\n  // prepare output\r\n  std::vector<double> output;\r\n\r\n  // parse\r\n  bool r = qi::phrase_parse(\r\n    fwd_begin, fwd_end,                          // iterators over input\r\n    qi::double_ >> *(',' >> qi::double_) >> qi::eoi,    // recognize list of doubles\r\n    ascii::space | '#' >> *(ascii::char_ - qi::eol) >> qi::eol, // comment skipper\r\n    output);                              // doubles are stored into this object\r\n\r\n  // error detection\r\n  if( !r || fwd_begin != fwd_end )\r\n    throw std::runtime_error(\"parse error\");\r\n\r\n  // return result\r\n  return output;\r\n}\r\n\r\nint main()\r\n{\r\n  try {\r\n    std::stringstream str(\"1.0,2.0\\n\");\r\n    std::vector<double> values = parse(str);\r\n    BOOST_TEST(values.size() == 2 && values[0] == 1.0 && values[1] == 2.0);\r\n  }\r\n  catch(std::exception const&) {\r\n    BOOST_TEST(false);\r\n  }\r\n  return boost::report_errors();\r\n}\r\n", "meta": {"hexsha": "022ce57692f4072972b19e69ece47eda418dfd6f", "size": 1929, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/spirit/test/support/multi_pass_regression003.cpp", "max_stars_repo_name": "zyiacas/boost-doc-zh", "max_stars_repo_head_hexsha": "689e5a3a0a4dbead1a960f7b039e3decda54aa2c", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 198.0, "max_stars_repo_stars_event_min_datetime": "2015-01-13T05:47:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T04:46:46.000Z", "max_issues_repo_path": "libs/spirit/test/support/multi_pass_regression003.cpp", "max_issues_repo_name": "sdfict/boost-doc-zh", "max_issues_repo_head_hexsha": "689e5a3a0a4dbead1a960f7b039e3decda54aa2c", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 9.0, "max_issues_repo_issues_event_min_datetime": "2015-01-28T16:33:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T23:03:28.000Z", "max_forks_repo_path": "libs/spirit/test/support/multi_pass_regression003.cpp", "max_forks_repo_name": "sdfict/boost-doc-zh", "max_forks_repo_head_hexsha": "689e5a3a0a4dbead1a960f7b039e3decda54aa2c", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 139.0, "max_forks_repo_forks_event_min_datetime": "2015-01-15T20:09:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-31T15:21:16.000Z", "avg_line_length": 31.1129032258, "max_line_length": 86, "alphanum_fraction": 0.6562986003, "num_tokens": 476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4416730056646256, "lm_q2_score": 0.12421301483609339, "lm_q1q2_score": 0.054861535605322094}}
{"text": "/*    This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.\n *    See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.\n *    Author(s):       Vincent Rouvreau\n *\n *    Copyright (C) 2020 Inria\n *\n *    Modification(s):\n *      - YYYY/MM Author: Description of the modification\n */\n\n#include <iostream>\n#include <limits>  // for NaN\n#include <cmath>  // for isNaN\n\n#define BOOST_TEST_DYN_LINK\n#define BOOST_TEST_MODULE \"simplex_tree_make_filtration_non_decreasing\"\n#include <boost/test/unit_test.hpp>\n#include <boost/mpl/list.hpp>\n\n//  ^\n// /!\\ Nothing else from Simplex_tree shall be included to test includes are well defined.\n#include \"gudhi/Simplex_tree.h\"\n\nusing namespace Gudhi;\n\ntypedef boost::mpl::list<Simplex_tree<>, Simplex_tree<Simplex_tree_options_fast_persistence>> list_of_tested_variants;\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(make_filtration_non_decreasing, typeST, list_of_tested_variants) {\n  typeST st;\n\n  st.insert_simplex_and_subfaces({2, 1, 0}, 2.0);\n  st.insert_simplex_and_subfaces({3, 0}, 2.0);\n  st.insert_simplex_and_subfaces({3, 4, 5}, 2.0);\n  \n  /* Inserted simplex:     */\n  /*    1                  */\n  /*    o                  */\n  /*   /X\\                 */\n  /*  o---o---o---o        */\n  /*  2   0   3\\X/4        */\n  /*            o          */\n  /*            5          */\n\n  std::clog << \"Check default insertion ensures the filtration values are non decreasing\" << std::endl;\n  BOOST_CHECK(!st.make_filtration_non_decreasing());\n\n  // Because of non decreasing property of simplex tree, { 0 } , { 1 } and { 0, 1 } are going to be set from value 2.0\n  // to 1.0\n  st.insert_simplex_and_subfaces({0, 1, 6, 7}, 1.0);\n  \n  // Inserted simplex:\n  //    1   6\n  //    o---o\n  //   /X\\7/\n  //  o---o---o---o\n  //  2   0   3\\X/4\n  //            o\n  //            5\n  \n  std::clog << \"Check default second insertion ensures the filtration values are non decreasing\" << std::endl;\n  BOOST_CHECK(!st.make_filtration_non_decreasing());\n  \n  // Copy original simplex tree\n  typeST st_copy = st;\n\n  // Modify specific values for st to become like st_copy thanks to make_filtration_non_decreasing\n  st.assign_filtration(st.find({0,1,6,7}), 0.8);\n  st.assign_filtration(st.find({0,1,6}), 0.9);\n  st.assign_filtration(st.find({0,6}), 0.6);\n  st.assign_filtration(st.find({3,4,5}), 1.2);\n  st.assign_filtration(st.find({3,4}), 1.1);\n  st.assign_filtration(st.find({4,5}), 1.99);\n  \n  std::clog << \"Check the simplex_tree is rolled back in case of decreasing filtration values\" << std::endl;\n  BOOST_CHECK(st.make_filtration_non_decreasing());\n  BOOST_CHECK(st == st_copy);\n\n  // Other simplex tree\n  typeST st_other;\n  st_other.insert_simplex_and_subfaces({2, 1, 0}, 3.0);  // This one is different from st\n  st_other.insert_simplex_and_subfaces({3, 0}, 2.0);\n  st_other.insert_simplex_and_subfaces({3, 4, 5}, 2.0);\n  st_other.insert_simplex_and_subfaces({0, 1, 6, 7}, 1.0);\n\n  // Modify specific values for st to become like st_other thanks to make_filtration_non_decreasing\n  st.assign_filtration(st.find({2}), 3.0);\n  // By modifying just the simplex {2}\n  // {0,1,2}, {1,2} and {0,2} will be modified\n  \n  std::clog << \"Check the simplex_tree is repaired in case of decreasing filtration values\" << std::endl;\n  BOOST_CHECK(st.make_filtration_non_decreasing());\n  BOOST_CHECK(st == st_other);\n\n  // Modify specific values for st still to be non-decreasing\n  st.assign_filtration(st.find({0,1,2}), 10.0);\n  st.assign_filtration(st.find({0,2}), 9.0);\n  st.assign_filtration(st.find({0,1,6,7}), 50.0);\n  st.assign_filtration(st.find({0,1,6}), 49.0);\n  st.assign_filtration(st.find({0,1,7}), 48.0);\n  // Other copy simplex tree\n  typeST st_other_copy = st;\n  \n  std::clog << \"Check the simplex_tree is not modified in case of non-decreasing filtration values\" << std::endl;\n  BOOST_CHECK(!st.make_filtration_non_decreasing());\n  BOOST_CHECK(st == st_other_copy);\n  \n}\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(make_filtration_non_decreasing_on_nan_values, typeST, list_of_tested_variants) {\n  typeST st;\n\n  st.insert_simplex_and_subfaces({2, 1, 0}, std::numeric_limits<double>::quiet_NaN());\n  st.insert_simplex_and_subfaces({3, 0},    std::numeric_limits<double>::quiet_NaN());\n  st.insert_simplex_and_subfaces({3, 4, 5}, std::numeric_limits<double>::quiet_NaN());\n  \n  /* Inserted simplex:     */\n  /*    1                  */\n  /*    o                  */\n  /*   /X\\                 */\n  /*  o---o---o---o        */\n  /*  2   0   3\\X/4        */\n  /*            o          */\n  /*            5          */\n\n  std::clog << \"SPECIFIC CASE:\" << std::endl;\n  std::clog << \"Insertion with NaN values does not ensure the filtration values are non decreasing\" << std::endl;\n  st.make_filtration_non_decreasing();\n\n  std::clog << \"Check all filtration values are NaN\" << std::endl;\n  for (auto f_simplex : st.complex_simplex_range()) {\n    BOOST_CHECK(std::isnan(st.filtration(f_simplex)));\n  }\n\n  st.assign_filtration(st.find({0}), 0.);\n  st.assign_filtration(st.find({1}), 0.);\n  st.assign_filtration(st.find({2}), 0.);\n  st.assign_filtration(st.find({3}), 0.);\n  st.assign_filtration(st.find({4}), 0.);\n  st.assign_filtration(st.find({5}), 0.);\n\n  std::clog << \"Check make_filtration_non_decreasing is modifying the simplicial complex\" << std::endl;\n  BOOST_CHECK(st.make_filtration_non_decreasing());\n  \n  std::clog << \"Check all filtration values are now defined\" << std::endl;\n  for (auto f_simplex : st.complex_simplex_range()) {\n    BOOST_CHECK(!std::isnan(st.filtration(f_simplex)));\n  }\n}\n", "meta": {"hexsha": "e0e7cadf7e7733dbc4af019dfb595bc0e04f71af", "size": 5575, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/Simplex_tree/test/simplex_tree_make_filtration_non_decreasing_unit_test.cpp", "max_stars_repo_name": "m0baxter/gudhi-devel", "max_stars_repo_head_hexsha": "6e14ef1f31e09f3875316440303450ff870d9881", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 146.0, "max_stars_repo_stars_event_min_datetime": "2019-03-15T14:10:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T21:14:52.000Z", "max_issues_repo_path": "src/Simplex_tree/test/simplex_tree_make_filtration_non_decreasing_unit_test.cpp", "max_issues_repo_name": "m0baxter/gudhi-devel", "max_issues_repo_head_hexsha": "6e14ef1f31e09f3875316440303450ff870d9881", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 398.0, "max_issues_repo_issues_event_min_datetime": "2019-03-07T14:55:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T14:50:40.000Z", "max_forks_repo_path": "src/Simplex_tree/test/simplex_tree_make_filtration_non_decreasing_unit_test.cpp", "max_forks_repo_name": "m0baxter/gudhi-devel", "max_forks_repo_head_hexsha": "6e14ef1f31e09f3875316440303450ff870d9881", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 51.0, "max_forks_repo_forks_event_min_datetime": "2019-03-08T15:58:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T10:23:23.000Z", "avg_line_length": 37.4161073826, "max_line_length": 118, "alphanum_fraction": 0.6505829596, "num_tokens": 1687, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3557749071749625, "lm_q2_score": 0.15405756269148543, "lm_q1q2_score": 0.0548098150661642}}
{"text": "//------------------------------------------------------------------------------\n/// \\file SingleNode_tests.cpp\n//------------------------------------------------------------------------------\n#include \"DataStructures/Lists/SingleNode.h\"\n\n#include <boost/test/unit_test.hpp>\n\nusing DataStructures::Lists::Nodes::SingleNode;\n// Alternatively,\n//template <typename T>\n//using SingleNode = DataStructures::Lists::SingleNode::SingleNode<T>;\n\nBOOST_AUTO_TEST_SUITE(DataStructures)\nBOOST_AUTO_TEST_SUITE(Lists)\nBOOST_AUTO_TEST_SUITE(Nodes)\nBOOST_AUTO_TEST_SUITE(SingleNode_tests)\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(DefaultConstructs)\n{\n\tSingleNode<int> node {};\n\n\tBOOST_TEST(node.retrieve() == 0);\n\tBOOST_TEST(node.next() == nullptr);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(ConstructsWithElementValueOnly)\n{\n\tSingleNode<int> node {42};\n\n\tBOOST_TEST(node.retrieve() == 42);\n\tBOOST_TEST(node.next() == nullptr);\t\t\n}\n\nBOOST_AUTO_TEST_SUITE_END() // SingleNode_tests\nBOOST_AUTO_TEST_SUITE_END() // Nodes\nBOOST_AUTO_TEST_SUITE_END() // Lists\nBOOST_AUTO_TEST_SUITE_END() // DataStructures", "meta": {"hexsha": "a4687e46e0b669fd763c3bf4722e0b1512884f86", "size": 1372, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/DataStructures/Lists/SingleNode_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/DataStructures/Lists/SingleNode_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/DataStructures/Lists/SingleNode_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.4634146341, "max_line_length": 80, "alphanum_fraction": 0.5072886297, "num_tokens": 213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4532618480153861, "lm_q2_score": 0.12085323249047068, "lm_q1q2_score": 0.05477815949726384}}
{"text": "/**\n * @license  this file is a part of libchef. more info see https://github.com/q191201771/libchef\n * @tag      v1.10.17\n * @file     chef_crypto_hmac_sha256.hpp\n * @deps     chef_crypto_sha256_op.hpp\n * @platform linux | macos | xxx\n *\n * @author\n *   chef <191201771@qq.com>\n *     -initial release xxxx-xx-xx\n *\n * @brief\n *   - hmac sha256\u52a0\u5bc6\n *   - @NOTICE \u5b9e\u73b0\u90e8\u5206\u62f7\u8d1d\u81eahttps://github.com/lyokato/cpp-cryptlite/blob/master/include/cryptlite/hmac.h\n *\n     ```\n     // \u793a\u4f8b\n     uint8_t key[] = {\n  \t  0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,\n  \t  0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,\n  \t  0x0b, 0x0b, 0x0b, 0x0b\n     };\n     std::size_t key_len = 20;\n     const char *buf = \"Hi There\";\n     std::size_t len = 8;\n\n     chef::crypto_hmac_sha256 ctx(key, 20);\n     ctx.update((const uint8_t *)buf, 8);\n     uint8_t digest[32];\n     ctx.final(digest);\n     uint8_t result[] = {\n       0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,\n       0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,\n       0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7,\n       0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7\n     };\n     assert(memcmp(digest, result, 32) == 0);\n\n     ```\n *\n */\n\n#ifndef _CHEF_BASE_CRYPTO_HMAC_SHA256_HPP_\n#define _CHEF_BASE_CRYPTO_HMAC_SHA256_HPP_\n#pragma once\n\n#include \"chef_crypto_sha256_op.hpp\"\n#include <string>\n\nnamespace chef {\n\n  namespace cryptlite__ {\n    class sha256;\n    template <typename T> class hmac;\n  }\n\n  class crypto_hmac_sha256 {\n    public:\n      crypto_hmac_sha256(const uint8_t *key, std::size_t key_len);\n      ~crypto_hmac_sha256();\n      void update(const uint8_t *buf, std::size_t len);\n      void final(uint8_t dst[32] /* out */);\n\n    private:\n      crypto_hmac_sha256(const crypto_hmac_sha256 &);\n      crypto_hmac_sha256 &operator=(const crypto_hmac_sha256 &);\n\n    private:\n      cryptlite__::hmac<cryptlite__::sha256> *ctx_;\n\n  }; // class crypto_hmac_sha256\n\n} // namespace chef\n\n\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n// @NOTICE \u8be5\u5206\u9694\u7ebf\u4ee5\u4e0a\u90e8\u5206\u4e3a\u8be5\u6a21\u5757\u7684\u63a5\u53e3\uff0c\u5206\u5272\u7ebf\u4ee5\u4e0b\u90e8\u5206\u4e3a\u5bf9\u5e94\u7684\u5b9e\u73b0\n\n\n\n\n\n/*\nThe MIT License\n\nCopyright (c) 2011 lyo.kato@gmail.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\n//#ifndef _CRYPTLITE_HMAC_H_\n//#define _CRYPTLITE_HMAC_H_\n\n#include <string>\n#include <sstream>\n#include <cstring>\n#include <cassert>\n#include <iomanip>\n//#include <boost/cstdint.hpp>\n\nnamespace chef {\n\nnamespace cryptlite__ {\n\ntemplate <typename T>\nclass hmac {\n\npublic:\n\n    static const unsigned int BLOCK_SIZE = T::BLOCK_SIZE;\n    static const unsigned int HASH_SIZE  = T::HASH_SIZE;\n\n    static void calc(\n            const char* text, int text_len,\n            const char* key,  int key_len,\n            uint8_t digest[HASH_SIZE]) {\n        assert(digest);\n        calc(reinterpret_cast<const uint8_t*>(text), text_len,\n             reinterpret_cast<const uint8_t*>(key), key_len, digest);\n    }\n\n    static void calc(\n            const uint8_t* text, int text_len,\n            const uint8_t* key,  int key_len,\n            uint8_t digest[HASH_SIZE]) {\n        assert(digest);\n        hmac<T> ctx(key, key_len);\n        ctx.input(text, text_len);\n        ctx.result(digest);\n    }\n\n    inline static void calc(\n            const std::string& text,\n            const std::string& key,\n            uint8_t digest[HASH_SIZE]) {\n        assert(digest);\n        calc(reinterpret_cast<const char*>(text.c_str()), text.size(),\n             reinterpret_cast<const char*>(key.c_str()), key.size(), digest);\n    }\n\n    inline static std::string calc_hex(\n            const std::string& text,\n            const std::string& key ) {\n        return calc_hex(reinterpret_cast<const uint8_t*>(text.c_str()), text.size(),\n                reinterpret_cast<const uint8_t*>(key.c_str()), key.size());\n    }\n\n    static std::string calc_hex(\n            const uint8_t* text, int text_len,\n            const uint8_t* key,  int key_len ) {\n        int i;\n        uint8_t digest[HASH_SIZE];\n        assert(key);\n        assert(text);\n        std::ostringstream oss;\n        oss << std::hex << std::setfill('0');\n        hmac<T> ctx(key, key_len);\n        ctx.input(text, text_len);\n        ctx.result(digest);\n        for (i = 0; i < HASH_SIZE; i++)\n            oss << std::setw(2) << (digest[i] & 0xff);\n        oss << std::dec;\n        return oss.str();\n    }\n\n    hmac(const uint8_t* key, int key_len) : hasher_(T()) {\n        assert(key);\n        reset(key, key_len);\n    }\n\n    hmac(const std::string& key) : hasher_(T()) {\n        reset(reinterpret_cast<const uint8_t*>(key.c_str()), key.size());\n    }\n\n    ~hmac() { }\n\n    inline void reset(const std::string& key) {\n        reset(reinterpret_cast<const uint8_t*>(key.c_str()), key.size());\n    }\n\n    void reset(const uint8_t* key, int key_len) {\n\n        int i;\n        uint8_t k_ipad[BLOCK_SIZE];\n        uint8_t tempkey[HASH_SIZE];\n\n        assert(key);\n\n        if (key_len > static_cast<int>(BLOCK_SIZE)) {\n            T sha;\n            sha.input(key, key_len);\n            sha.result(tempkey);\n            key = tempkey;\n            key_len = HASH_SIZE;\n        }\n\n        for (i=0; i < key_len; i++) {\n            k_ipad[i]  = key[i] ^ 0x36;\n            k_opad_[i] = key[i] ^ 0x5c;\n        }\n\n        for (; i < static_cast<int>(BLOCK_SIZE); i++) {\n            k_ipad[i]  = 0x36;\n            k_opad_[i] = 0x5c;\n        }\n\n        hasher_.reset();\n        hasher_.input(k_ipad, static_cast<int>(BLOCK_SIZE));\n    }\n\n    inline void input(const std::string& text) {\n        input(reinterpret_cast<const uint8_t*>(text.c_str()), text.size());\n    }\n\n    void input(const uint8_t* text, int text_len) {\n        assert(text);\n        hasher_.input(text, text_len);\n    }\n\n    void final_bits(const uint8_t bits, unsigned int bitcount) {\n        hasher_.final_bits(bits, bitcount);\n    }\n\n    void result(uint8_t digest[HASH_SIZE]) {\n        assert(digest);\n        hasher_.result(digest);\n        hasher_.reset();\n        hasher_.input(k_opad_, BLOCK_SIZE);\n        hasher_.input(digest, HASH_SIZE);\n        hasher_.result(digest);\n    }\n\nprivate:\n    uint8_t k_opad_[BLOCK_SIZE];\n    T hasher_;\n}; // end of class\n\n}  // end of namespace\n\ninline crypto_hmac_sha256::crypto_hmac_sha256(const uint8_t *key, std::size_t key_len) {\n  ctx_ = new cryptlite__::hmac<cryptlite__::sha256>(key, key_len);\n}\n\ninline crypto_hmac_sha256::~crypto_hmac_sha256() {\n  delete ctx_;\n}\n\ninline void crypto_hmac_sha256::update(const uint8_t *buf, std::size_t len) {\n  ctx_->input(buf, len);\n}\n\ninline void crypto_hmac_sha256::final(uint8_t dst[32] /* out */) {\n  ctx_->result(dst);\n}\n\n} // namespace chef\n\n#endif\n", "meta": {"hexsha": "08038ea74b22de1804a2f486d2adac34e60d903e", "size": 7629, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "include/chef_base/chef_crypto_hmac_sha256.hpp", "max_stars_repo_name": "q191201771/libchef", "max_stars_repo_head_hexsha": "678a5d92611aa15783ac86f6db362884cf211582", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 123.0, "max_stars_repo_stars_event_min_datetime": "2018-12-28T02:18:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T12:04:58.000Z", "max_issues_repo_path": "yet/chef_base/chef_crypto_hmac_sha256.hpp", "max_issues_repo_name": "zeusseo/yet", "max_issues_repo_head_hexsha": "901a2d8f6e54b9b76d6bb9b5b6a1d9c0938ca665", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2022-03-05T08:49:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-06T12:52:46.000Z", "max_forks_repo_path": "yet/chef_base/chef_crypto_hmac_sha256.hpp", "max_forks_repo_name": "zeusseo/yet", "max_forks_repo_head_hexsha": "901a2d8f6e54b9b76d6bb9b5b6a1d9c0938ca665", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2019-01-02T10:51:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T12:04:40.000Z", "avg_line_length": 27.4424460432, "max_line_length": 119, "alphanum_fraction": 0.6175121248, "num_tokens": 2164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.11124120650754304, "lm_q1q2_score": 0.05475160204627964}}
{"text": "//  (C) Copyright Raffi Enficiaud 2014.\r\n//  Distributed under the Boost Software License, Version 1.0.\r\n//  (See accompanying file LICENSE_1_0.txt or copy at\r\n//  http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n//  See http://www.boost.org/libs/test for the library home page.\r\n\r\n//[example_code\r\n#define BOOST_TEST_MODULE dataset_example65\r\n#include <boost/test/included/unit_test.hpp>\r\n#include <boost/test/data/test_case.hpp>\r\n#include <boost/test/data/monomorphic.hpp>\r\n\r\nnamespace bdata = boost::unit_test::data;\r\n\r\n\r\nBOOST_DATA_TEST_CASE( \r\n  test1, \r\n  bdata::make(2),\r\n  singleton)\r\n{\r\n  std::cout \r\n    << \"test 1: \" \r\n    << singleton << std::endl;\r\n  BOOST_TEST(singleton == 2);\r\n}\r\n\r\nBOOST_DATA_TEST_CASE( \r\n  test2, \r\n  bdata::xrange(3) ^ bdata::make(2),\r\n  xr, singleton)\r\n{\r\n  std::cout \r\n    << \"test 2: \" \r\n    << xr << \", \" << singleton << std::endl;\r\n  BOOST_TEST(singleton == 2);\r\n}\r\n//]\r\n", "meta": {"hexsha": "9da6aace2988e4a71ce959f12e7086a6a13880d1", "size": 903, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/dataset_example65.run.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/dataset_example65.run.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/test/doc/examples/dataset_example65.run.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 23.1538461538, "max_line_length": 66, "alphanum_fraction": 0.6411960133, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47657965106367595, "lm_q2_score": 0.1143685322190697, "lm_q1q2_score": 0.05450571517762902}}
{"text": "// Date Last Altered: $Date: 2008-08-04 22:55:41 -0600 (Mon, 04 Aug 2008) $\n// Revision Number: $Revision: 344 $\n//--------------------------------------------*-C++-*------------------------------------//\n/*! \\file MeshConcept.hh\n *  \\author Greg Davidson\n *  \\date November 6, 2006\n *  \n *  \\brief Provides the \\c CartesianMeshConcept concept class.\n * \n *  This file provides the \\c CartesianMeshConcept concept class.  This is provided to \n *  require that all \\c CartesianMesh types provide certain minimal functionality. */\n\n#ifndef MESHCONCEPT_HH\n#define MESHCONCEPT_HH\n\n#include <boost/concept_check.hpp>\n\n#include \"Types.hh\"\n#include \"Dimension.hh\"\n\nusing boost::function_requires;\nusing boost::ConvertibleConcept;\nusing boost::UnsignedIntegerConcept;\n\n/*! \\addtogroup MeshMod Mesh Module\n *  @{  */\n\n/*! \\brief Depicts the functionality that all \\c CartesianMesh types must implement.\n *\n *  The \\c CartesianMeshConcept class template dictates what functionality\n *  all \\c CartesianMesh types must implement.\n *  \\par Template Parameters: \n *     <dl> <dt> \\e mesh_type </dt> \n *          <dd> The mesh type to check for concept conformity. </dd> </dl> \n *  \\par Concept Requirements:\n *       The following types must be provided by the \\c mesh_type type:\n *       <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n *          <TR>  <TD> \\arg \\c DimensionType </TD> \n *                <TD> The \\c mesh_type type must provide a \\c DimensionType. </TD> </TR>\n *          <TR>  <TD> \\arg \\c LengthType </TD> \n *                <TD> All \\c mesh_type types must provide a \\c LengthType. </TD> </TR>\n *          <TR>  <TD> \\arg \\c SizeType </TD> \n *                <TD> All \\c mesh_type types must provide a \\c SizeType. </TD> </TR>\n *          <TR>  <TD> \\arg \\c Zone </TD> \n *                <TD> All \\c mesh_type types must provide a \\c Zone. </TD> </TR>\n *          <TR>  <TD> \\arg \\c Node </TD> \n *                <TD> All \\c mesh_type types must provide a \\c Node. </TD> </TR>\n *          <TR>  <TD> \\arg \\c Corner </TD> \n *                <TD> All \\c mesh_type types must provide a \\c Corner. </TD> </TR>\n *          <TR>  <TD> \\arg \\c const_ZoneIterator </TD> \n *                <TD> All \\c mesh_type types must provide a \\c const_ZoneIterator \n *                                                                            type. </TD> </TR>\n *          <TR>  <TD> \\arg \\c const_NodeIterator </TD> \n *                <TD> All \\c mesh_type types must provide a \\c const_NodeIterator \n *                                                                            type. </TD> </TR>\n *          <TR>  <TD> \\arg \\c const_CornerIterator </TD> \n *                <TD> All \\c mesh_type types must provide a \\c const_CornerIterator \n *                                                                             type. </TD> </TR>\n *          <TR>  <TD> \\arg \\c SweepIterator </TD> \n *                <TD> All \\c mesh_type types must provide a \\c SweepIterator \n *                                                                             type. </TD> </TR>\n *       </TABLE>\n *       The following functionality must be provided by the \\c mesh_type type:\n *       \\arg The \\c DimensionType must satisfy the \\c DimensionConcept concept.\n *       \\arg The \\c LengthType type must be convertible to a \\c Real8 type.\n *       \\arg The \\c SizeType type must satisfy the UnsignedIntegerConcept concept.\n *       \\arg The \\c mesh_type must provide a \\c length() accessor.\n *       \\arg The \\c mesh_type must provide a \\c area() accessor. \n *       \\arg The \\c mesh_type must provide a \\c volume() accessor.\n *       \\arg The \\c mesh_type must provide a \\c numZones() accessor.\n *       \\arg The \\c mesh_type must provide a \\c numNodes() accessor. \n *       \\arg The \\c mesh_type must provide a \\c numCorners() accessor. \n *       \\arg The \\c mesh_type must provide a \\c getZone(Zone::Id) method.\n *       \\arg The \\c mesh_type must provide a \\c getNode(Node::Id) method.\n *       \\arg The \\c mesh_type must provide a \\c getCorner(Corner::Id) method.\n *       \\arg The \\c mesh_type must provide a \\c zoneBegin() method.\n *       \\arg The \\c mesh_type must provide a \\c zoneEnd() method.\n *       \\arg The \\c mesh_type must provide a \\c nodeBegin() method.\n *       \\arg The \\c mesh_type must provide a \\c nodeEnd() method.\n *       \\arg The \\c mesh_type must provide a \\c cornerBegin() method.\n *       \\arg The \\c mesh_type must provide a \\c cornerEnd() method.\n *       \\arg The \\c mesh_type must provide a \\c sweepBegin(<tt>Angle</tt><\\c DimensionType>) method.\n *       \\arg The \\c mesh_type must provide a \\c sweepEnd(<tt>Angle</tt>< \\c DimensionType>) method.\n *  \\remarks  It should be noted that this class is compiled but never executed, so concept\n *            checking does not imply any runtime overhead. */\ntemplate<typename mesh_type>\nclass CartesianMeshConcept\n{\npublic:\n   // ****** Defines the required mesh types ******\n   /// The \\c mesh_type must provide a \\c DimensionType type.\n   typedef typename mesh_type::DimensionType          DimensionType;\n   /// The \\c mesh_type must provide a \\c LengthType type.\n   typedef typename mesh_type::LengthType             LengthType;\n   /// The \\c mesh_type must provide a \\c SizeType type.\n   typedef typename mesh_type::SizeType               SizeType;\n   /// The \\c mesh_type must provide a \\c Zone type.\n   typedef typename mesh_type::Zone                   Zone;\n   /// The \\c mesh_type must provide a \\c Node type.\n   typedef typename mesh_type::Node                   Node;\n   /// The \\c mesh_type must provide a \\c Corner type.\n   typedef typename mesh_type::Corner                 Corner;\n   /// The \\c mesh_type must provide a \\c const_ZoneIterator type.\n   typedef typename mesh_type::const_ZoneIterator     const_ZoneIterator;\n   /// The \\c mesh_type must provide a \\c const_NodeIterator type.\n   typedef typename mesh_type::const_NodeIterator     const_NodeIterator;\n   /// The \\c mesh_type must provide a \\c const_CornerIterator type.\n   typedef typename mesh_type::const_CornerIterator   const_CornerIterator;\n   /// The \\c mesh_type must provide a \\c SweepIterator type.\n   typedef typename mesh_type::SweepIterator          SweepIterator;\n\n   // ****** Tests the required mesh functionality ******\n   /*! \\brief The constraints method tests that the \\c mesh_type \n    *         provides certain functionality. */\n   void constraints()\n   {\n      function_requires< DimensionConcept<DimensionType> >();\n      function_requires< ConvertibleConcept<LengthType, Real8> >();\n      function_requires< UnsignedIntegerConcept<SizeType> >();\n   \n      // Basic mesh sizes\n      LengthType length = mMesh->length();\n      LengthType area   = mMesh->area();\n      LengthType volume = mMesh->volume();\n\n      // Meshes must have a way to number the geometric elements      \n      SizeType num_zones   = mMesh->numZones();\n      SizeType num_nodes   = mMesh->numNodes();\n      SizeType num_corners = mMesh->numCorners();\n      \n      // Meshes must have a way to access particular elements\n      const Zone& zone     = mMesh->getZone( mZoneId );\n      const Node& node     = mMesh->getNode( mNodeId );\n      const Corner& corner = mMesh->getCorner( mCornerId );\n      \n      // Meshes must support at least forward iterators over each element\n      mZoneIterator   = mMesh.zoneBegin();\n      mZoneIterator   = mMesh.zoneEnd();\n      mNodeIterator   = mMesh.nodeBegin();\n      mNodeIterator   = mMesh.nodeEnd();\n      mCornerIterator = mMesh.cornerBegin();\n      mCornerIterator = mMesh.cornerEnd();\n      \n      // Meshes must support sweep iterators\n      mSweepIterator = mMesh.sweepBegin(mAngle);\n      mSweepIterator = mMesh.sweepEnd(mAngle);\n   }\n   \nprivate:\n   /// The \\c mesh_type to use for the tests.\n   mesh_type            mMesh;\n   /// Used to test that the \\c length() method returns a \\c LengthType.\n   LengthType           mLength;\n   /// Used to test that the \\c area() method returns a \\c LengthType.\n   LengthType           mArea;\n   /// Used to test that the \\c volume() method returns a \\c LengthType.\n   LengthType           mVolume;\n   /// Used to test that the \\c numZones() method returns a \\c SizeType.\n   SizeType             mNumZones;\n   /// Used to test that the \\c numNodes() method returns a \\c SizeType.\n   SizeType             mNumNodes;\n   /// Used to test that the \\c numCorners() method returns a \\c SizeType.\n   SizeType             mNumCorners;\n   /// Used to test the \\c getZone(Zone::Id) method.\n   typename Zone::Id    mZoneId;\n   /// Used to test the \\c getNode(Node::Id) method.\n   typename Node::Id    mNodeId;\n   /// Used to test the \\c getCorner(Corner::Id) method.\n   typename Corner::Id  mCornerId;\n   /*! \\brief Used to test that the \\c zoneBegin() and \\c zoneEnd() methods\n    *         return a \\c const_ZoneIterator. */\n   const_ZoneIterator   mZoneIterator;\n   /*! \\brief Used to test that the \\c nodeBegin() and \\c nodeEnd() methods\n    *         return a \\c const_NodeIterator. */\n   const_NodeIterator   mNodeIterator;\n   /*! \\brief Used to test that the \\c cornerBegin() and \\c cornerEnd() methods\n    *         return a \\c const_CornerIterator. */\n   const_CornerIterator mCornerIterator;\n   /*! \\brief Used to test that the \\c sweepBegin(angle) and \\c sweepEnd(angle)\n    *         methods return a \\c SweepIterator. */\n   SweepIterator        mSweepIterator;\n   /// Used as a parameter for the \\c sweepBegin(angle) and \\c sweepEnd(angle) methods.\n   Angle<DimensionType> mAngle;\n};\n\n#endif\n\n", "meta": {"hexsha": "117a1d5a611b72960aacc3e4ff11f1e82426d195", "size": 9527, "ext": "hh", "lang": "C++", "max_stars_repo_path": "Code/trunk/cpp/Geometry/CartesianMesh/MeshConcept.hh", "max_stars_repo_name": "jlconlin/PhDThesis", "max_stars_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Code/trunk/cpp/Geometry/CartesianMesh/MeshConcept.hh", "max_issues_repo_name": "jlconlin/PhDThesis", "max_issues_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Code/trunk/cpp/Geometry/CartesianMesh/MeshConcept.hh", "max_forks_repo_name": "jlconlin/PhDThesis", "max_forks_repo_head_hexsha": "8e704613721a800ce1c59576e94f40fa6f7cd986", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.6755319149, "max_line_length": 101, "alphanum_fraction": 0.6114201742, "num_tokens": 2416, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4571367168274948, "lm_q2_score": 0.11920293297380237, "lm_q1q2_score": 0.054492037415851936}}
{"text": "/**\n * @file\n * @brief UNITESTS for NPDE homework OutputImpedanceBVP\n * @author Erick Schulz\n * @date 28/03/2019\n * @copyright Developed at ETH Zurich\n */\n\n#include <gtest/gtest.h>\n\n#include <string>\n\n#include <Eigen/Core>\n\n#include <lf/assemble/assemble.h>\n#include <lf/io/io.h>\n#include <lf/mesh/hybrid2d/hybrid2d.h>\n#include <lf/uscalfe/uscalfe.h>\n\n#include \"../evalclass.h\"\n#include \"../outputimpedancebvp.h\"\n\nnamespace OutputImpedanceBVP::test {\n\nTEST(OutputImpedanceBVP, computeApproxSolDirichlet) {\n  // Load mesh into a Lehrfem++ object\n  auto mesh_factory = std::make_unique<lf::mesh::hybrid2d::MeshFactory>(2);\n  const lf::io::GmshReader reader(std::move(mesh_factory), CURRENT_SOURCE_DIR\n                                  \"/../../meshes/unitsquare.msh\");\n  auto mesh_p = reader.mesh();  // type shared_ptr< const lf::mesh::Mesh>\n\n  // Finite element space\n  auto fe_space_p =\n      std::make_shared<lf::uscalfe::FeSpaceLagrangeO1<double>>(mesh_p);\n  // Obtain local->global index mapping for current finite element space\n  const lf::assemble::DofHandler &dofh{fe_space_p->LocGlobMap()};\n  // Dimension of finite element space\n  const lf::uscalfe::size_type N_dofs(dofh.NumDofs());\n\n  // Exact solution and Dirichlet boundary conditions\n  Eigen::Vector2d g;\n  g << 1.0, 3.0;\n  auto uExact = [&g](Eigen::Vector2d x) -> double { return g.dot(x); };\n  auto uExact_vec = interpolateData<std::function<double(Eigen::Vector2d)>>(\n      fe_space_p, std::move(uExact));\n\n  // Solve BVP\n  Eigen::VectorXd uApprox_vec = solveImpedanceBVP(fe_space_p, g);\n\n  ASSERT_TRUE(uApprox_vec.isApprox(uExact_vec));\n}\n\n}  // namespace OutputImpedanceBVP::test\n", "meta": {"hexsha": "dc1e2a78915e4dd1c31d1fdc25a3b064476c5bbe", "size": 1648, "ext": "cc", "lang": "C++", "max_stars_repo_path": "homeworks/OutputImpedanceBVP/templates/test/outputimpedancebvp_test.cc", "max_stars_repo_name": "padomu/NPDECODES", "max_stars_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "homeworks/OutputImpedanceBVP/templates/test/outputimpedancebvp_test.cc", "max_issues_repo_name": "padomu/NPDECODES", "max_issues_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "homeworks/OutputImpedanceBVP/templates/test/outputimpedancebvp_test.cc", "max_forks_repo_name": "padomu/NPDECODES", "max_forks_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5185185185, "max_line_length": 77, "alphanum_fraction": 0.7026699029, "num_tokens": 477, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.43782348444346736, "lm_q2_score": 0.1242130164571034, "lm_q1q2_score": 0.05438337567848277}}
{"text": "/* Copyright (C) 2012-2020 IBM Corp.\n * This program is Licensed under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *   http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License. See accompanying LICENSE file.\n */\n#include <cassert>\n#include <cstring>\n#include <fstream>\n#include <utility>\n#include <unistd.h>\n\n#include <NTL/ZZX.h>\n#include <NTL/vector.h>\n\n#include <helib/helib.h>\n#include <helib/ArgMap.h>\n\n#include <helib/debugging.h>\n\nNTL_CLIENT\nusing namespace helib;\n\nbool isLittleEndian()\n{\n    int i=1;\n    return static_cast<bool>(*reinterpret_cast<char *>(&i));\n}\n\nvoid cleanupFiles(const char* file){\n  if(unlink(file)) cerr<< \"Delete of \"<< file <<\" failed.\"<<endl; \n}\n\ntemplate<class... Files>\nvoid cleanupFiles(const char * file, Files... files){\n  cleanupFiles(file);\n  cleanupFiles(files...);\n}\n\n// Compare two binary files, return 0 if they are equal, -1 if they\n// have different length, and 1 if they have the same length but\n// different content.\nlong compareFiles(string filename1, string filename2)\n{\n\n  ifstream file1(filename1);\n  ifstream file2(filename2);\n \n  if(!file1.is_open() && !file2.is_open()){\n    cerr << \"Could not open one of the following files:\" << endl;\n    cerr << filename1 << \" and/or \" << filename2 << endl;\n    exit(EXIT_FAILURE);\n  }\n \n  fstream::pos_type file1size, file2size;\n\n  file1size = file1.seekg(0, ifstream::end).tellg();\n  file1.seekg(0, ifstream::beg);\n\n  file2size = file2.seekg(0, ifstream::end).tellg();\n  file2.seekg(0, ifstream::beg);\n\n  // Quick compare sizes.\n  if(file1size != file2size){ \n    file1.close();\n    file2.close();\n    cerr << \"Files \"<<filename1<<\" and \"<<filename2<<\" not the same size :(\"<< endl;\n    return -1;\n  }\n\n  // Now compare byte blocks at a time.\n  const size_t BLOCKSIZE = 4096; // 4 kB\n\n  char buffer1[BLOCKSIZE];\n  char buffer2[BLOCKSIZE];\n  size_t curBlckSz = 0;\n\n  for(size_t i=file1size, cnt=0; i > 0; i-=curBlckSz, cnt++) {\n\n    curBlckSz = std::min(BLOCKSIZE, i);\n\n    file1.read(buffer1, curBlckSz);\n    file2.read(buffer2, curBlckSz);\n\n    if(memcmp(buffer1, buffer2, curBlckSz)) {\n      cerr << \"Block \"\n           <<cnt<<\" (block size: \"<<BLOCKSIZE<<\" bytes) \"\n           <<cnt<<\" does not match :(\"<<endl;\n      return 1; \n    }\n  }  \n  return 0; // Files are the same!\n}\n\n\nint main(int argc, char *argv[])\n{ \n  ArgMap amap;\n\n  bool noPrint=true;\n  long m=7;\n  long r=1;\n  long p=2;\n  long c=2;\n  long w=64;\n  long L=300;\n  long cleanup=1;\n  string sampleFilePrefix; \n \n  amap.arg(\"m\", m, \"order of cyclotomic polynomial\");\n  amap.arg(\"p\", p, \"plaintext base\");\n  amap.arg(\"r\", r, \"lifting\");\n  amap.arg(\"c\", c, \"number of columns in the key-switching matrices\");\n  amap.arg(\"L\", L, \"number of levels wanted\");\n  amap.arg(\"sample\", sampleFilePrefix, \"sample file prefix e.g. <prefix>_BE.txt\");\n  amap.arg(\"cleanup\", cleanup, \"cleanup files created\");\n  amap.arg(\"noPrint\", noPrint, \"suppress printouts\");\n  amap.parse(argc, argv);\n\n  // FIXME: this is wrong!\n  const char* asciiFile1 = \"../misc/iotest_ascii1.txt\"; \n  const char* asciiFile2 = \"../misc/iotest_ascii2.txt\"; \n  const char* binFile1 = \"../misc/iotest_bin.bin\"; \n  const char* otherEndianFileOut = \"../misc/iotest_ascii3.txt\";  \n\n  { // 1. Write ASCII and bin files. \n    ofstream asciiFile(asciiFile1);\n    ofstream binFile(binFile1, ios::binary);\n    assert(asciiFile.is_open());  \n\n    std::unique_ptr<Context> context(new Context(m, p, r));\n    buildModChain(*context, L, c);  // Set the modulus chain\n\n    if (!noPrint) {\n      cout << \"Test to write out ASCII and Binary Files.\\n\";\n      context->zMStar.printout(); // Printout context params\n      cout << \"\\tSecurity Level: \" << context->securityLevel() << endl;\n    }\n    std::unique_ptr<SecKey> secKey(new SecKey(*context));\n    PubKey* pubKey = (PubKey*) secKey.get();\n    secKey->GenSecKey(w);\n    addSome1DMatrices(*secKey);\n    addFrbMatrices(*secKey);\n\n#ifdef DEBUG_PRINTOUT\n        dbgEa = context->ea;\n        dbgKey = secKey.get();\n#endif\n\n    // ASCII \n    if (!noPrint)\n      cout << \"\\tWriting ASCII1 file \" << asciiFile1 << endl;\n    writeContextBase(asciiFile, *context);\n    asciiFile << *context << endl << endl;\n    asciiFile << *pubKey << endl << endl;\n    asciiFile << *secKey << endl << endl;\n\n    // Bin\n    if (!noPrint)\n      cout << \"\\tWriting Binary file \" << binFile1<< endl;\n    writeContextBaseBinary(binFile, *context);\n    writeContextBinary(binFile, *context);\n    writePubKeyBinary(binFile, *pubKey);\n    writeSecKeyBinary(binFile, *secKey);\n\n    asciiFile.close();\n    binFile.close();\n    cout << \"GOOD\\n\";\n  }\n  { // 2. Read in bin files and write out ASCII.\n    if (!noPrint)\n      cout << \"Test to read binary file and write it out as ASCII\" << endl;\n  \n    ifstream inFile(binFile1, ios::binary);\n    ofstream outFile(asciiFile2);\n  \n    // Read in context,\n    std::unique_ptr<Context> context = buildContextFromBinary(inFile);  \n    readContextBinary(inFile, *context);  \n\n    // Read in SecKey and PubKey.\n    std::unique_ptr<SecKey> secKey(new SecKey(*context));\n\n#ifdef DEBUG_PRINTOUT\n        dbgEa = context->ea;\n        dbgKey = secKey.get();\n#endif\n\n    PubKey* pubKey = (PubKey*) secKey.get();\n  \n    readPubKeyBinary(inFile, *pubKey);\n    readSecKeyBinary(inFile, *secKey);\n \n    // ASCII \n    if (!noPrint)\n      cout << \"\\tWriting ASCII2 file.\" << endl;\n    writeContextBase(outFile, *context);\n    outFile << *context << endl << endl;\n    outFile << *pubKey << endl << endl;\n    outFile << *secKey << endl << endl;\n\n    inFile.close();\n    outFile.close();\n\n    cout << \"GOOD\\n\";\n  }\n  { // 3. Compare byte-wise the two ASCII files\n    if (!noPrint)\n      cout << \"Comparing the two ASCII files\\n\"; \n  \n    long differ = compareFiles(asciiFile1, asciiFile2); \n\n    if(differ != 0){\n      cout << \"BAD\\n\";\n      if (!noPrint)\n        cout << \"\\tFAIL - Files differ. Return Code: \" << differ << endl;\n      exit(EXIT_FAILURE);\n    }\n    cout << \"GOOD\\n\";\n  }\n  { // 4. Read in binary and perform operation.\n    if (!noPrint)\n      cout << \"Test reading in Binary files and performing an operation between two ctxts\\n\";  \n\n    ifstream inFile(binFile1, ios::binary);\n\n    // Read in context,\n    std::unique_ptr<Context> context = buildContextFromBinary(inFile);\n    readContextBinary(inFile, *context);  \n\n    // Read in PubKey.\n    std::unique_ptr<SecKey> secKey(new SecKey(*context));\n    PubKey* pubKey = (PubKey*) secKey.get();\n\n#ifdef DEBUG_PRINTOUT\n        dbgEa = context->ea;\n        dbgKey = secKey.get();\n#endif\n\n        readPubKeyBinary(inFile, *pubKey);\n    readSecKeyBinary(inFile, *secKey);\n    inFile.close(); \n\n    // Get the ea\n    const EncryptedArray& ea = *context->ea;\n \n    // Setup some ptxts and ctxts.\n    Ctxt c1(*pubKey), c2(*pubKey);\n    PlaintextArray p1(ea),  p2(ea);\n\n    random(ea, p1);\n    random(ea, p2);\n\n    ea.encrypt(c1, *pubKey, p1);\n    ea.encrypt(c2, *pubKey, p2);\n\n    // Operation multiply and add.\n    mul(ea, p1, p2);\n    c1.multiplyBy(c2);\n    //c1 *= c2;\n\n    // Decrypt and Compare.\n    PlaintextArray pp1(ea);\n    ea.decrypt(c1, *secKey, pp1);     \n\t\n    if(!equals(ea, p1, pp1)) {\n      cout << \"BAD\\n\";\n      exit(EXIT_FAILURE);\n    }\n    cout << \"GOOD\\n\";\n\n    if(cleanup) {\n      if (!noPrint)\n        cout << \"Clean up. Deleting created files.\" << endl;\n      cleanupFiles(asciiFile1, asciiFile2, binFile1);     \n    }\n  }\n  { // 5. Read in binary from opposite little endian and print ASCII and compare\n    bool littleEndian = isLittleEndian(); \n\n    string otherEndianFileIn\n      = sampleFilePrefix + (littleEndian? \"_BE.bin\" : \"_LE.bin\");\n    string otherEndianASCII\n      = sampleFilePrefix + (littleEndian? \"_BE.txt\" : \"_LE.txt\");\n\n    if (!noPrint)\n      cout << \"Test to read in\" << (littleEndian? \" BE \":\" LE \") \n           << \"binary file and write it out as ASCII\" << endl;\n\n    if(sampleFilePrefix.empty()) {\n      if (!noPrint)\n        cout << \"\\tSample prefix not provided, test not done.\" << endl;\n    } else {\n      if (!noPrint)\n        cout << \"\\tSample file used: \" << otherEndianFileIn << endl;\n\n      ifstream inFile(otherEndianFileIn, ios::binary);\n\n      if(!inFile.is_open()) {\n        cout << \"BAD boo!\\n\";\n        if (!noPrint)\n          cout << \"  file \" << otherEndianFileIn \n               << \" could not be opened.\\n\";\n        exit(EXIT_FAILURE);\n      }\n      ofstream outFile(otherEndianFileOut);\n    \n      // Read in context,\n      std::unique_ptr<Context> context = buildContextFromBinary(inFile);\n      readContextBinary(inFile, *context);  \n\n      // Read in SecKey and PubKey.\n      std::unique_ptr<SecKey> secKey(new SecKey(*context));\n      PubKey* pubKey = (PubKey*) secKey.get();\n\n#ifdef DEBUG_PRINTOUT\n        dbgEa = context->ea;\n        dbgKey = secKey.get();\n#endif\n\n        readPubKeyBinary(inFile, *pubKey);\n      readSecKeyBinary(inFile, *secKey);\n      inFile.close();\n   \n      // ASCII\n      if (!noPrint)\n        cout << \"\\tWriting other endian file.\" << endl;\n      writeContextBase(outFile, *context);\n      outFile << *context << endl << endl;\n      outFile << *pubKey << endl << endl;\n      outFile << *secKey << endl << endl;\n      outFile.close();\n\n      // Compare byte-wise the two ASCII files\n      if (!noPrint)\n        cout << \"Comparing the two ASCII files\\n\"; \n    \n      long differ = compareFiles(otherEndianASCII, otherEndianFileOut); \n\n      if(differ != 0) {\n        cout << \"BAD\\n\";\n        exit(EXIT_FAILURE);\n      }\n      cout << \"GOOD\\n\";\n\n      if(cleanup) {\n        if (!noPrint)\n          cout << \"Clean up. Deleting created files.\" << endl;\n        cleanupFiles(otherEndianFileOut); \n      }\n    }\n  }\n  return 0;\n}\n", "meta": {"hexsha": "f3e219958c98ae9af913229c3a5e1156bb061c41", "size": 10046, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/Test_Bin_IO.cpp", "max_stars_repo_name": "Souhail-MEFTAH/HElib", "max_stars_repo_head_hexsha": "5f97813b99407d6f9a6251cee920b4e419edc028", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Test_Bin_IO.cpp", "max_issues_repo_name": "Souhail-MEFTAH/HElib", "max_issues_repo_head_hexsha": "5f97813b99407d6f9a6251cee920b4e419edc028", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Test_Bin_IO.cpp", "max_forks_repo_name": "Souhail-MEFTAH/HElib", "max_forks_repo_head_hexsha": "5f97813b99407d6f9a6251cee920b4e419edc028", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.9055555556, "max_line_length": 95, "alphanum_fraction": 0.6190523591, "num_tokens": 2792, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4610167793123159, "lm_q2_score": 0.11757212890757046, "lm_q1q2_score": 0.054202724205860565}}
{"text": "//==============================================================================\n//         Copyright 2003 - 2012   LASMEA UMR 6602 CNRS/Univ. Clermont II\n//         Copyright 2009 - 2012   LRI    UMR 8623 CNRS/Univ Paris Sud XI\n//\n//          Distributed under the Boost Software License, Version 1.0.\n//                 See accompanying file LICENSE.txt or copy at\n//                     http://www.boost.org/LICENSE_1_0.txt\n//==============================================================================\n#define NT2_UNIT_MODULE \"nt2 complex.arithmetic toolbox - cmplx_testing/simd Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// unit test behavior of complex.arithmetic components in simd  mode\n//////////////////////////////////////////////////////////////////////////////\n/// created by jt the 13/01/2012\n///\n#include <nt2/include/functions/abs.hpp>\n#include <boost/simd/sdk/simd/io.hpp>\n#include <boost/simd/sdk/simd/native.hpp>\n#include <nt2/include/functions/splat.hpp>\n#include <nt2/include/functions/real.hpp>\n#include <boost/type_traits/is_same.hpp>\n#include <nt2/sdk/functor/meta/call.hpp>\n#include <nt2/sdk/meta/as_integer.hpp>\n#include <nt2/sdk/meta/as_floating.hpp>\n#include <nt2/sdk/meta/as_signed.hpp>\n#include <nt2/sdk/meta/upgrade.hpp>\n#include <nt2/sdk/meta/downgrade.hpp>\n#include <nt2/sdk/meta/scalar_of.hpp>\n#include <boost/dispatch/meta/as_floating.hpp>\n#include <boost/type_traits/common_type.hpp>\n#include <nt2/sdk/unit/tests.hpp>\n#include <nt2/sdk/unit/module.hpp>\n\n#include <nt2/toolbox/constant/constant.hpp>\n#include <nt2/sdk/meta/cardinal_of.hpp>\n#include <nt2/include/functions/splat.hpp>\n\n#include <nt2/include/functions/load.hpp>\n#include <nt2/sdk/complex/complex.hpp>\n#include <nt2/sdk/complex/dry.hpp>\n#include <nt2/sdk/complex/imaginary.hpp>\n#include <nt2/sdk/complex/meta/as_complex.hpp>\n#include <nt2/sdk/complex/meta/as_imaginary.hpp>\n#include <nt2/sdk/complex/meta/as_dry.hpp>\n\nNT2_TEST_CASE_TPL ( abs_cplx__1_0,   BOOST_SIMD_SIMD_REAL_TYPES)\n{\n  using boost::simd::native;\n  typedef NT2_SIMD_DEFAULT_EXTENSION  ext_t;\n  typedef std::complex<T>                              cT;\n  typedef native<T ,ext_t>                             vT;\n  typedef native<cT ,ext_t>                           vcT;\n  typedef typename nt2::meta::as_imaginary<T>::type   ciT;\n  typedef native<ciT ,ext_t>                         vciT;\n  typedef typename nt2::meta::as_dry<T>::type          dT;\n  typedef native<dT ,ext_t>                           vdT;\n\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Inf<vT>(),nt2::Nan<vT>())), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Inf<vT>(), nt2::Zero<vT>())), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Minf<vT>(), nt2::Zero<vT>())), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Mone<vT>(), nt2::Zero<vT>())), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Nan<vT>(), nt2::Zero<vT>())), nt2::Nan<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::One<vT>(), nt2::Zero<vT>())), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Valmax<vT>(), nt2::Zero<vT>())), nt2::Valmax<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Valmin<vT>(), nt2::Zero<vT>())), nt2::Valmax<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Zero<vT>(), nt2::Zero<vT>())), nt2::Zero<vT>());\n  NT2_TEST_ULP_EQUAL(nt2::abs(vcT(nt2::One<vT>(), nt2::One<vT>()))[0], nt2::Sqrt_2<T>(), 1);\n  NT2_TEST_EQUAL(nt2::abs(vcT(nt2::Four<vT>(), nt2::Three<vT>())), nt2::Five<vT>());\n\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Inf<vciT>())), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Inf<vciT>())   ), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Minf<vciT>())  ), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Mone<vciT>())  ), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Nan<vciT>())   ), nt2::Nan<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::One<vciT>())   ), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Valmax<vciT>())), nt2::Valmax<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Valmin<vciT>())), nt2::Valmax<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Zero<vciT>() ) ), nt2::Zero<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::One<vciT>()   )), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vciT(nt2::Four<vciT>() ) ), nt2::Four<vT>());\n\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Inf<vdT>())   ), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Inf<vdT>())   ), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Minf<vdT>())  ), nt2::Inf<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Mone<vdT>())  ), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Nan<vdT>())   ), nt2::Nan<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::One<vdT>())   ), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Valmax<vdT>())), nt2::Valmax<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Valmin<vdT>())), nt2::Valmax<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Zero<vdT>())  ), nt2::Zero<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::One<vdT>())   ), nt2::One<vT>());\n  NT2_TEST_EQUAL(nt2::abs(vdT(nt2::Four<vdT>())  ), nt2::Four<vT>());\n\n} // end of test for floating_\n\n\n", "meta": {"hexsha": "fe62055366f4803f9b2b173e4b72d783e914e345", "size": 5035, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/type/complex/arithmetic/unit/simd/abs.cpp", "max_stars_repo_name": "timblechmann/nt2", "max_stars_repo_head_hexsha": "6c71f7063ca4e5975c9c019877e6b2fe07c9e4ce", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2016-09-14T00:23:53.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-14T12:51:18.000Z", "max_issues_repo_path": "modules/type/complex/arithmetic/unit/simd/abs.cpp", "max_issues_repo_name": "timblechmann/nt2", "max_issues_repo_head_hexsha": "6c71f7063ca4e5975c9c019877e6b2fe07c9e4ce", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/type/complex/arithmetic/unit/simd/abs.cpp", "max_forks_repo_name": "timblechmann/nt2", "max_forks_repo_head_hexsha": "6c71f7063ca4e5975c9c019877e6b2fe07c9e4ce", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.9072164948, "max_line_length": 92, "alphanum_fraction": 0.6003972195, "num_tokens": 1616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.1097057753333734, "lm_q1q2_score": 0.053995881039137494}}
{"text": "//\n//                              libieeep1788\n//\n//   An implementation of the preliminary IEEE P1788 standard for\n//   interval arithmetic\n//\n//\n//   Copyright 2013 - 2015\n//\n//   Marco Nehmeier (nehmeier@informatik.uni-wuerzburg.de)\n//   Department of Computer Science,\n//   University of Wuerzburg, Germany\n//\n//   Licensed under the Apache License, Version 2.0 (the \"License\");\n//   you may not use this file except in compliance with the License.\n//   You may obtain a copy of the License at\n//\n//       http://www.apache.org/licenses/LICENSE-2.0\n//\n//   UnF<double>::less required by applicable law or agreed to in writing, software\n//   distributed under the License is distributed on an \"AS IS\" BASIS,\n//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//   See the License for the specific language governing permissions and\n//   limitations under the License.\n\n#define BOOST_TEST_MODULE \"Decorations [p1788/decoration/decoration]\"\n#include \"test/util/boost_test_wrapper.hpp\"\n\n#include <sstream>\n\n#include <boost/test/output_test_stream.hpp>\n\n#include \"p1788/decoration/decoration.hpp\"\n#include \"p1788/io/io_manip.hpp\"\n\n\ntypedef p1788::decoration::decoration DEC;\n\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_equal_test)\n{\n    BOOST_CHECK( (DEC::trv == DEC::trv) );\n    BOOST_CHECK( !(DEC::trv == DEC::def) );\n    BOOST_CHECK( !(DEC::trv == DEC::dac) );\n    BOOST_CHECK( !(DEC::trv == DEC::com) );\n    BOOST_CHECK( !(DEC::trv == DEC::ill) );\n\n    BOOST_CHECK( !(DEC::def == DEC::trv) );\n    BOOST_CHECK( (DEC::def == DEC::def) );\n    BOOST_CHECK( !(DEC::def == DEC::dac) );\n    BOOST_CHECK( !(DEC::def == DEC::com) );\n    BOOST_CHECK( !(DEC::def == DEC::ill) );\n\n    BOOST_CHECK( !(DEC::dac == DEC::trv) );\n    BOOST_CHECK( !(DEC::dac == DEC::def) );\n    BOOST_CHECK( (DEC::dac == DEC::dac) );\n    BOOST_CHECK( !(DEC::dac == DEC::com) );\n    BOOST_CHECK( !(DEC::dac == DEC::ill) );\n\n    BOOST_CHECK( !(DEC::com == DEC::trv) );\n    BOOST_CHECK( !(DEC::com == DEC::def) );\n    BOOST_CHECK( !(DEC::com == DEC::dac) );\n    BOOST_CHECK( (DEC::com == DEC::com) );\n    BOOST_CHECK( !(DEC::com == DEC::ill) );\n\n    BOOST_CHECK( !(DEC::ill == DEC::trv) );\n    BOOST_CHECK( !(DEC::ill == DEC::def) );\n    BOOST_CHECK( !(DEC::ill == DEC::dac) );\n    BOOST_CHECK( !(DEC::ill == DEC::com) );\n    BOOST_CHECK( (DEC::ill == DEC::ill) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_not_equal_test)\n{\n    BOOST_CHECK( !(DEC::trv != DEC::trv) );\n    BOOST_CHECK( (DEC::trv != DEC::def) );\n    BOOST_CHECK( (DEC::trv != DEC::dac) );\n    BOOST_CHECK( (DEC::trv != DEC::com) );\n    BOOST_CHECK( (DEC::trv != DEC::ill) );\n\n    BOOST_CHECK( (DEC::def != DEC::trv) );\n    BOOST_CHECK( !(DEC::def != DEC::def) );\n    BOOST_CHECK( (DEC::def != DEC::dac) );\n    BOOST_CHECK( (DEC::def != DEC::com) );\n    BOOST_CHECK( (DEC::def != DEC::ill) );\n\n    BOOST_CHECK( (DEC::dac != DEC::trv) );\n    BOOST_CHECK( (DEC::dac != DEC::def) );\n    BOOST_CHECK( !(DEC::dac != DEC::dac) );\n    BOOST_CHECK( (DEC::dac != DEC::com) );\n    BOOST_CHECK( (DEC::dac != DEC::ill) );\n\n    BOOST_CHECK( (DEC::com != DEC::trv) );\n    BOOST_CHECK( (DEC::com != DEC::def) );\n    BOOST_CHECK( (DEC::com != DEC::dac) );\n    BOOST_CHECK( !(DEC::com != DEC::com) );\n    BOOST_CHECK( (DEC::com != DEC::ill) );\n\n    BOOST_CHECK( (DEC::ill != DEC::trv) );\n    BOOST_CHECK( (DEC::ill != DEC::def) );\n    BOOST_CHECK( (DEC::ill != DEC::dac) );\n    BOOST_CHECK( (DEC::ill != DEC::com) );\n    BOOST_CHECK( !(DEC::ill != DEC::ill) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_lower_test)\n{\n    BOOST_CHECK( !(DEC::trv < DEC::trv) );\n    BOOST_CHECK( (DEC::trv < DEC::def) );\n    BOOST_CHECK( (DEC::trv < DEC::dac) );\n    BOOST_CHECK( (DEC::trv < DEC::com) );\n    BOOST_CHECK( !(DEC::trv < DEC::ill) );\n\n    BOOST_CHECK( !(DEC::def < DEC::trv) );\n    BOOST_CHECK( !(DEC::def < DEC::def) );\n    BOOST_CHECK( (DEC::def < DEC::dac) );\n    BOOST_CHECK( (DEC::def < DEC::com) );\n    BOOST_CHECK( !(DEC::def < DEC::ill) );\n\n    BOOST_CHECK( !(DEC::dac < DEC::trv) );\n    BOOST_CHECK( !(DEC::dac < DEC::def) );\n    BOOST_CHECK( !(DEC::dac < DEC::dac) );\n    BOOST_CHECK( (DEC::dac < DEC::com) );\n    BOOST_CHECK( !(DEC::dac < DEC::ill) );\n\n    BOOST_CHECK( !(DEC::com < DEC::trv) );\n    BOOST_CHECK( !(DEC::com < DEC::def) );\n    BOOST_CHECK( !(DEC::com < DEC::dac) );\n    BOOST_CHECK( !(DEC::com < DEC::com) );\n    BOOST_CHECK( !(DEC::com < DEC::ill) );\n\n    BOOST_CHECK( (DEC::ill < DEC::trv) );\n    BOOST_CHECK( (DEC::ill < DEC::def) );\n    BOOST_CHECK( (DEC::ill < DEC::dac) );\n    BOOST_CHECK( (DEC::ill < DEC::com) );\n    BOOST_CHECK( !(DEC::ill < DEC::ill) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_lower_equal_test)\n{\n    BOOST_CHECK( (DEC::trv <= DEC::trv) );\n    BOOST_CHECK( (DEC::trv <= DEC::def) );\n    BOOST_CHECK( (DEC::trv <= DEC::dac) );\n    BOOST_CHECK( (DEC::trv <= DEC::com) );\n    BOOST_CHECK( !(DEC::trv <= DEC::ill) );\n\n    BOOST_CHECK( !(DEC::def <= DEC::trv) );\n    BOOST_CHECK( (DEC::def <= DEC::def) );\n    BOOST_CHECK( (DEC::def <= DEC::dac) );\n    BOOST_CHECK( (DEC::def <= DEC::com) );\n    BOOST_CHECK( !(DEC::def <= DEC::ill) );\n\n    BOOST_CHECK( !(DEC::dac <= DEC::trv) );\n    BOOST_CHECK( !(DEC::dac <= DEC::def) );\n    BOOST_CHECK( (DEC::dac <= DEC::dac) );\n    BOOST_CHECK( (DEC::dac <= DEC::com) );\n    BOOST_CHECK( !(DEC::dac <= DEC::ill) );\n\n    BOOST_CHECK( !(DEC::com <= DEC::trv) );\n    BOOST_CHECK( !(DEC::com <= DEC::def) );\n    BOOST_CHECK( !(DEC::com <= DEC::dac) );\n    BOOST_CHECK( (DEC::com <= DEC::com) );\n    BOOST_CHECK( !(DEC::com <= DEC::ill) );\n\n    BOOST_CHECK( (DEC::ill <= DEC::trv) );\n    BOOST_CHECK( (DEC::ill <= DEC::def) );\n    BOOST_CHECK( (DEC::ill <= DEC::dac) );\n    BOOST_CHECK( (DEC::ill <= DEC::com) );\n    BOOST_CHECK( (DEC::ill <= DEC::ill) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_greater_test)\n{\n    BOOST_CHECK( !(DEC::trv > DEC::trv) );\n    BOOST_CHECK( !(DEC::trv > DEC::def) );\n    BOOST_CHECK( !(DEC::trv > DEC::dac) );\n    BOOST_CHECK( !(DEC::trv > DEC::com) );\n    BOOST_CHECK( (DEC::trv > DEC::ill) );\n\n    BOOST_CHECK( (DEC::def > DEC::trv) );\n    BOOST_CHECK( !(DEC::def > DEC::def) );\n    BOOST_CHECK( !(DEC::def > DEC::dac) );\n    BOOST_CHECK( !(DEC::def > DEC::com) );\n    BOOST_CHECK( (DEC::def > DEC::ill) );\n\n    BOOST_CHECK( (DEC::dac > DEC::trv) );\n    BOOST_CHECK( (DEC::dac > DEC::def) );\n    BOOST_CHECK( !(DEC::dac > DEC::dac) );\n    BOOST_CHECK( !(DEC::dac > DEC::com) );\n    BOOST_CHECK( (DEC::dac > DEC::ill) );\n\n    BOOST_CHECK( (DEC::com > DEC::trv) );\n    BOOST_CHECK( (DEC::com > DEC::def) );\n    BOOST_CHECK( (DEC::com > DEC::dac) );\n    BOOST_CHECK( !(DEC::com > DEC::com) );\n    BOOST_CHECK( (DEC::com > DEC::ill) );\n\n    BOOST_CHECK( !(DEC::ill > DEC::trv) );\n    BOOST_CHECK( !(DEC::ill > DEC::def) );\n    BOOST_CHECK( !(DEC::ill > DEC::dac) );\n    BOOST_CHECK( !(DEC::ill > DEC::com) );\n    BOOST_CHECK( !(DEC::ill > DEC::ill) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_greater_equal_test)\n{\n    BOOST_CHECK( (DEC::trv >= DEC::trv) );\n    BOOST_CHECK( !(DEC::trv >= DEC::def) );\n    BOOST_CHECK( !(DEC::trv >= DEC::dac) );\n    BOOST_CHECK( !(DEC::trv >= DEC::com) );\n    BOOST_CHECK( (DEC::trv >= DEC::ill) );\n\n    BOOST_CHECK( (DEC::def >= DEC::trv) );\n    BOOST_CHECK( (DEC::def >= DEC::def) );\n    BOOST_CHECK( !(DEC::def >= DEC::dac) );\n    BOOST_CHECK( !(DEC::def >= DEC::com) );\n    BOOST_CHECK( (DEC::def >= DEC::ill) );\n\n    BOOST_CHECK( (DEC::dac >= DEC::trv) );\n    BOOST_CHECK( (DEC::dac >= DEC::def) );\n    BOOST_CHECK( (DEC::dac >= DEC::dac) );\n    BOOST_CHECK( !(DEC::dac >= DEC::com) );\n    BOOST_CHECK( (DEC::dac >= DEC::ill) );\n\n    BOOST_CHECK( (DEC::com >= DEC::trv) );\n    BOOST_CHECK( (DEC::com >= DEC::def) );\n    BOOST_CHECK( (DEC::com >= DEC::dac) );\n    BOOST_CHECK( (DEC::com >= DEC::com) );\n    BOOST_CHECK( (DEC::com >= DEC::ill) );\n\n    BOOST_CHECK( !(DEC::ill >= DEC::trv) );\n    BOOST_CHECK( !(DEC::ill >= DEC::def) );\n    BOOST_CHECK( !(DEC::ill >= DEC::dac) );\n    BOOST_CHECK( !(DEC::ill >= DEC::com) );\n    BOOST_CHECK( (DEC::ill >= DEC::ill) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_is_valid_test)\n{\n    p1788::exception::clear();\n\n    BOOST_CHECK( p1788::decoration::is_valid(DEC::ill) );\n    BOOST_CHECK( p1788::decoration::is_valid(DEC::trv) );\n    BOOST_CHECK( p1788::decoration::is_valid(DEC::def) );\n    BOOST_CHECK( p1788::decoration::is_valid(DEC::dac) );\n    BOOST_CHECK( p1788::decoration::is_valid(DEC::com) );\n\n    BOOST_CHECK(!p1788::exception::invalid_operand());\n\n    DEC bad_dec = static_cast<p1788::decoration::decoration>(13);\n\n    BOOST_CHECK( !p1788::decoration::is_valid(bad_dec) );\n    BOOST_CHECK(p1788::exception::invalid_operand());\n    p1788::exception::clear();\n\n    p1788::exception::set_throw_exception_cwd(p1788::exception::invalid_operand_bit);\n    BOOST_CHECK_THROW(p1788::decoration::is_valid(bad_dec), p1788::exception::invalid_operand_exception);\n    BOOST_CHECK(p1788::exception::invalid_operand());\n    p1788::exception::clear();\n    p1788::exception::set_throw_exception_cwd(p1788::exception::none_bit);\n}\n\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_output_test)\n{\n    boost::test_tools::output_test_stream output;\n\n\n    output << DEC::trv;\n    BOOST_CHECK( output.is_equal( \"trv\" ) );\n\n    output << DEC::def;\n    BOOST_CHECK( output.is_equal( \"def\" ) );\n\n    output << DEC::dac;\n    BOOST_CHECK( output.is_equal( \"dac\" ) );\n\n    output << DEC::com;\n    BOOST_CHECK( output.is_equal( \"com\" ) );\n\n    output << DEC::ill;\n    BOOST_CHECK( output.is_equal( \"ill\" ) );\n\n\n    output << p1788::io::dec_numeric;\n\n    output << DEC::trv;\n    BOOST_CHECK( output.is_equal( \"4\" ) );\n\n    output << DEC::def;\n    BOOST_CHECK( output.is_equal( \"8\" ) );\n\n    output << DEC::dac;\n    BOOST_CHECK( output.is_equal( \"12\" ) );\n\n    output << DEC::com;\n    BOOST_CHECK( output.is_equal( \"16\" ) );\n\n    output << DEC::ill;\n    BOOST_CHECK( output.is_equal( \"0\" ) );\n\n\n    output << p1788::io::dec_alpha;\n    output << p1788::io::upper_case;\n\n    output << DEC::com;\n    BOOST_CHECK( output.is_equal( \"COM\" ) );\n\n    output << DEC::ill;\n    BOOST_CHECK( output.is_equal( \"ILL\" ) );\n\n    output << DEC::trv;\n    BOOST_CHECK( output.is_equal( \"TRV\" ) );\n\n    output << DEC::def;\n    BOOST_CHECK( output.is_equal( \"DEF\" ) );\n\n    output << DEC::dac;\n    BOOST_CHECK( output.is_equal( \"DAC\" ) );\n\n    output << p1788::io::lower_case;\n    output << DEC::com;\n    BOOST_CHECK( output.is_equal( \"com\" ) );\n\n    output << DEC::ill;\n    BOOST_CHECK( output.is_equal( \"ill\" ) );\n}\n\nBOOST_AUTO_TEST_CASE(minimal_decoration_input_test)\n{\n    {\n        DEC dec;\n        std::istringstream is(\"ill\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::ill);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"0\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::ill);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"trv\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"4\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"def\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::def);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"8\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::def);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"dac\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::dac);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"12\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::dac);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"com\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::com);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"16\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::com);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec;\n        std::istringstream is(\"dac4\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::dac);\n        BOOST_CHECK(is);\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is);\n    }\n\n    {\n        DEC dec;\n        std::istringstream is(\"8 dac 4\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::def);\n        BOOST_CHECK(is);\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::dac);\n        BOOST_CHECK(is);\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is);\n    }\n\n    {\n        DEC dec;\n        std::istringstream is(\"  DAC  16\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::dac);\n        BOOST_CHECK(is);\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::com);\n        BOOST_CHECK(is);\n    }\n\n\n    {\n        DEC dec = DEC::com;\n        std::istringstream is(\"  def\");\n        is >> std::noskipws;\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::com);\n        BOOST_CHECK(is.fail());\n    }\n\n    {\n        DEC dec = DEC::trv;\n        std::istringstream is(\"  12\");\n        is >> std::noskipws;\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is.fail());\n    }\n\n    {\n        DEC dec;\n        std::istringstream is(\"\\n 4 \\t DEF \\n\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is);\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::def);\n        BOOST_CHECK(is);\n    }\n\n    {\n        DEC dec = DEC::trv;\n        std::istringstream is(\"foo com\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::trv);\n        BOOST_CHECK(is.fail());\n    }\n\n\n    {\n        DEC dec = DEC::dac;\n        std::istringstream is(\" \\t \\n \\t \");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::dac);\n        BOOST_CHECK(is.fail());\n    }\n\n\n    {\n        DEC dec = DEC::com;\n        std::istringstream is(\"7\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::com);\n        BOOST_CHECK(is.fail());\n    }\n\n    {\n        DEC dec = DEC::def;\n        std::istringstream is(\"-2\");\n        is >> dec;\n        BOOST_CHECK_EQUAL(dec, DEC::def);\n        BOOST_CHECK(is.fail());\n    }\n}\n", "meta": {"hexsha": "d582e5cc81b20851d4f664925df9d4bc9219e704", "size": 14280, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/p1788/decoration/test_decoration.cpp", "max_stars_repo_name": "nehmeier/libieeep1788", "max_stars_repo_head_hexsha": "1f10b896ff532e95818856614ab3073189e81199", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 41.0, "max_stars_repo_stars_event_min_datetime": "2015-01-23T07:52:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T03:15:21.000Z", "max_issues_repo_path": "test/p1788/decoration/test_decoration.cpp", "max_issues_repo_name": "nehmeier/libieeep1788", "max_issues_repo_head_hexsha": "1f10b896ff532e95818856614ab3073189e81199", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 25.0, "max_issues_repo_issues_event_min_datetime": "2015-01-25T16:13:35.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T12:05:08.000Z", "max_forks_repo_path": "test/p1788/decoration/test_decoration.cpp", "max_forks_repo_name": "nehmeier/libieeep1788", "max_forks_repo_head_hexsha": "1f10b896ff532e95818856614ab3073189e81199", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 8.0, "max_forks_repo_forks_event_min_datetime": "2015-02-22T11:06:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-23T09:57:32.000Z", "avg_line_length": 27.4088291747, "max_line_length": 105, "alphanum_fraction": 0.5593137255, "num_tokens": 4141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44552953503957277, "lm_q2_score": 0.12085324357297285, "lm_q1q2_score": 0.05384368941709083}}
{"text": "#include <any>\n#include <string>\n#include <vector>\n\n#include <boost/test/unit_test.hpp>\n\n#include \"BinarySearchTree.hpp\"\n#include \"Traversal.hpp\"\n\nusing namespace CppSampleCode;\n\n// Test data to build a tree\nconst std::vector<std::pair<int32_t, std::string>> TEST_DATA{\n    {23, \"23\"}, {4, \"4\"},   {30, \"30\"}, {11, \"11\"}, {7, \"7\"}, {34, \"34\"},\n    {20, \"20\"}, {24, \"24\"}, {22, \"22\"}, {15, \"15\"}, {1, \"1\"}};\n\nBOOST_AUTO_TEST_SUITE(BinarySearchTreeTestsSuite)\n\nBOOST_AUTO_TEST_CASE(BasicTest)\n{\n    BinarySearchTree tree;\n\n    for (const auto &item : TEST_DATA)\n    {\n        tree.insertNode(item.first, std::make_any<std::string>(item.second));\n    }\n\n    BOOST_CHECK(!tree.empty()); // NOLINT\n\n    BOOST_CHECK_EQUAL(tree.getLeftmost(tree.getRoot())->key, 1);\n    BOOST_CHECK_EQUAL(\n        std::any_cast<std::string>(tree.getLeftmost(tree.getRoot())->data), \"1\");\n\n    BOOST_CHECK_EQUAL(tree.getRightmost(tree.getRoot())->key, 34);\n    BOOST_CHECK_EQUAL(\n        std::any_cast<std::string>(tree.getRightmost(tree.getRoot())->data), \"34\");\n\n    BOOST_CHECK_EQUAL(std::any_cast<std::string>(tree.search(24)->data), \"24\");\n\n    BOOST_CHECK_EQUAL(tree.getPredecessor(tree.getRoot())->key, 22);\n    BOOST_CHECK_EQUAL(tree.getSuccessor(tree.getRoot())->key, 24);\n\n    tree.deleteNode(15); // NOLINT\n    tree.deleteNode(22); // NOLINT\n    tree.deleteNode(7);  // NOLINT\n    tree.deleteNode(20); // NOLINT\n\n    BOOST_CHECK(!tree.search(15)); // NOLINT\n}\n\nBOOST_AUTO_TEST_CASE(DeletionTest)\n{\n    BinarySearchTree_p tree{std::make_shared<BinarySearchTree>()};\n\n    for (const auto &item : TEST_DATA)\n    {\n        tree->insertNode(item.first, std::make_any<std::string>(item.second));\n    }\n\n    // No child\n    tree->deleteNode(15); // NOLINT\n    {\n        const std::vector<std::pair<int32_t, std::string>> expectedData{\n            {23, \"23\"}, {4, \"4\"},   {30, \"30\"}, {1, \"1\"},   {11, \"11\"},\n            {24, \"24\"}, {34, \"34\"}, {7, \"7\"},   {20, \"20\"}, {22, \"22\"}};\n\n        TraversalOutput output = levelOrderTraverse(tree);\n\n        for (size_t index = 0; index < output.size(); ++index)\n        {\n            BOOST_CHECK(output.at(index).first == expectedData.at(index).first); // NOLINT\n            BOOST_CHECK(std::any_cast<std::string>(output.at(index).second) ==   // NOLINT\n                        expectedData.at(index).second);\n        }\n    }\n\n    // One right child\n    tree->deleteNode(20); // NOLINT\n    {\n        const std::vector<std::pair<int32_t, std::string>> expectedData{\n            {23, \"23\"}, {4, \"4\"},   {30, \"30\"}, {1, \"1\"},  {11, \"11\"},\n            {24, \"24\"}, {34, \"34\"}, {7, \"7\"},   {22, \"22\"}};\n        TraversalOutput output = levelOrderTraverse(tree);\n\n        for (size_t index = 0; index < output.size(); ++index)\n        {\n            BOOST_CHECK(output.at(index).first == expectedData.at(index).first); // NOLINT\n            BOOST_CHECK(std::any_cast<std::string>(output.at(index).second) ==   // NOLINT\n                        expectedData.at(index).second);\n        }\n    }\n\n    // One left child\n    tree->insertNode(17, std::make_any<std::string>(\"17\")); // NOLINT\n    tree->deleteNode(22); // NOLINT\n    {\n        const std::vector<std::pair<int32_t, std::string>> expectedData{\n            {23, \"23\"}, {4, \"4\"},   {30, \"30\"}, {1, \"1\"},  {11, \"11\"},\n            {24, \"24\"}, {34, \"34\"}, {7, \"7\"},   {17, \"17\"}};\n        TraversalOutput output = levelOrderTraverse(tree);\n\n        for (size_t index = 0; index < output.size(); ++index)\n        {\n            BOOST_CHECK(output.at(index).first == expectedData.at(index).first); // NOLINT\n\n            BOOST_CHECK(std::any_cast<std::string>(output.at(index).second) ==   // NOLINT\n                        expectedData.at(index).second);\n        }\n    }\n\n    // Two children\n    tree->deleteNode(11); // NOLINT\n    {\n        const std::vector<std::pair<int32_t, std::string>> expectedData{\n            {23, \"23\"}, {4, \"4\"},   {30, \"30\"}, {1, \"1\"},\n            {17, \"17\"}, {24, \"24\"}, {34, \"34\"}, {7, \"7\"}};\n        TraversalOutput output = levelOrderTraverse(tree);\n\n        for (size_t index = 0; index < output.size(); ++index)\n        {\n            BOOST_CHECK(output.at(index).first == expectedData.at(index).first); // NOLINT\n            BOOST_CHECK(std::any_cast<std::string>(output.at(index).second) ==   // NOLINT\n                        expectedData.at(index).second);\n        }\n    }\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "1b93400f93fb0e8270c8811c0174222e61f1ef7c", "size": 4404, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/BinarySearchTreeTests.cpp", "max_stars_repo_name": "shunsvineyard/cpp-sample-code", "max_stars_repo_head_hexsha": "b407423729b44b15c6d2f07a9cfdeacffb3e13ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/BinarySearchTreeTests.cpp", "max_issues_repo_name": "shunsvineyard/cpp-sample-code", "max_issues_repo_head_hexsha": "b407423729b44b15c6d2f07a9cfdeacffb3e13ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2021-01-18T07:22:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-02T07:56:09.000Z", "max_forks_repo_path": "test/BinarySearchTreeTests.cpp", "max_forks_repo_name": "shunsvineyard/cpp-sample-code", "max_forks_repo_head_hexsha": "b407423729b44b15c6d2f07a9cfdeacffb3e13ca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1395348837, "max_line_length": 90, "alphanum_fraction": 0.5665304269, "num_tokens": 1242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.45713673161914675, "lm_q2_score": 0.11757212736159103, "lm_q1q2_score": 0.05374653803158778}}
{"text": "/*! \\file demo_1d_x_external.cpp\n  \\brief 1D plot from two vectors of doubles, showing axis label variation.\n  \\author Jacob Voytko and Paul A. Bristow\n  \\date 2009\n*/\n\n// Copyright Jacob Voytko 2007\n// Copyright Paul A. Bristow 2009\n\n// Distributed under the Boost Software License, Version 1.0.\n// For more information, see http://www.boost.org\n\n#include <boost/svg_plot/svg_1d_plot.hpp>\n#include <vector>\n\nusing std::vector;\nusing namespace boost::svg;\n\n//enum x_axis_intersect\n//{ //! \\enum x_axis_intersect If and how the X axes intersects Y axis.\n//  bottom = -1, //!< X-axis free below bottom of end of Y-axis (case of all Y definitely < 0).\n//  x_intersects_y = 0, //!< x_intersects_y when Y values include zero, so X intersects the Y axis.\n//  top = +1 //!< X-axis free above top of X-axis (case of all Y definitely > 0).\n//  };\n\nint main()\n{\n//[demo_1d_x_external_1\n\n/*`Following previous examples, we set up two containers for two data series.\n*/\n  vector<double> dan_times;\n  vector<double> elaine_times;\n\n  dan_times.push_back(3.1);\n  dan_times.push_back(4.2);\n  elaine_times.push_back(2.1);\n  elaine_times.push_back(7.8);\n\n  svg_1d_plot my_plot;\n\n  // Adding some generic settings.\n  my_plot.background_border_color(black)\n         .legend_on(true)\n         .plot_window_on(true)\n         .title(\"Race Times\")\n         .x_range(-1, 10);\n\n/*`We add tastelessly color the grids for both major and minor ticks, and switch both grids on.\n*/\n  my_plot.x_major_grid_color(pink)\n         .x_minor_grid_color(lightgray);\n\n  my_plot.x_major_grid_on(true)\n         .x_minor_grid_on(true);\n\n/*`Also we specify the position of the labelling of the X-axis.\nIt can be controlled using values in the `enum x_axis_intersect`.\n``\n  enum x_axis_intersect\n  { //! \\enum x_axis_intersect\n    bottom = -1, // On the bottom of the plot window.\n    x_intersects_y = 0, // On the Y axis (in the middle of the plot window).\n    top = +1 // On the top of the plot window.\n  };\n``\nFor this example, we choose to show the X axis and tick value labels at the top of the plot window.\n*/\n  my_plot.x_ticks_on_window_or_axis(top); // on top, not on axis.\n\n  // Write to plot.\n  my_plot.plot(dan_times, \"Dan\").stroke_color(blue);\n  my_plot.plot(elaine_times, \"Elaine\").stroke_color(orange);\n\n  // Write to file.\n  my_plot.write(\"./demo_1d_x_external.svg\");\n  return 0;\n} // int main()\n//] [/demo_1d_x_external_1]\n\n/*\nOutput:\n\nCompiling...\ndemo_1d_x_external.cpp\nLinking...\nEmbedding manifest...\nAutorun \"j:\\Cpp\\SVG\\debug\\demo_1d_x_external.exe\"\n*/\n\n", "meta": {"hexsha": "b4ea332faec26d487c2f2e0c7e80297877e2408b", "size": 2530, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/demo_1d_x_external.cpp", "max_stars_repo_name": "pabristow/svg_plot", "max_stars_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2016-03-09T03:23:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T14:02:07.000Z", "max_issues_repo_path": "example/demo_1d_x_external.cpp", "max_issues_repo_name": "pabristow/svg_plot", "max_issues_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 11.0, "max_issues_repo_issues_event_min_datetime": "2018-03-05T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-22T09:00:33.000Z", "max_forks_repo_path": "example/demo_1d_x_external.cpp", "max_forks_repo_name": "pabristow/svg_plot", "max_forks_repo_head_hexsha": "59e06b752acc252498e0ddff560b01fb951cb909", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2016-11-04T14:36:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-17T08:12:03.000Z", "avg_line_length": 27.8021978022, "max_line_length": 99, "alphanum_fraction": 0.7003952569, "num_tokens": 702, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.37754065479083276, "lm_q2_score": 0.14223190046381007, "lm_q1q2_score": 0.053698324833251404}}
{"text": "/**\n * \\file boost/numeric/ublasx/operation/num_rows.hpp\n *\n * \\brief The \\c num_rows operation.\n *\n * Copyright (c) 2009, Marco Guazzone\n *\n * Distributed under the Boost Software License, Version 1.0. (See\n * accompanying file LICENSE_1_0.txt or copy at\n * http://www.boost.org/LICENSE_1_0.txt)\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\n\n#ifndef BOOST_NUMERIC_UBLASX_OPERATION_NUM_ROWS_HPP\n#define BOOST_NUMERIC_UBLASX_OPERATION_NUM_ROWS_HPP\n\n\n/*\n#include <boost/version.hpp>\n\n\n#if BOOST_VERSION > 105100L\n\n\n#include <boost/numeric/ublas/operation/num_rows.hpp>\n\n\nnamespace boost { namespace numeric { namespace ublasx {\n\nusing ::boost::numeric::ublas::num_rows;\n\n}}} // Namespace boost::numeric::ublasx\n\n\n#else // BOOST_VERSION\n\n\n#include <boost/numeric/ublas/detail/config.hpp>\n#include <boost/numeric/ublas/expression_types.hpp>\n#include <boost/numeric/ublas/traits.hpp>\n\n\nnamespace boost { namespace numeric { namespace ublasx {\n\ntemplate <typename MatrixExprT>\nBOOST_UBLAS_INLINE\ntypename matrix_traits<MatrixExprT>::size_type num_rows(matrix_expression<MatrixExprT> const& me)\n{\n\treturn me().size1();\n}\n\n}}} // Namespace boost::numeric::ublasx\n\n\n#endif // BOOST_VERSION\n*/\n#include <boost/numeric/ublas/operation/num_rows.hpp>\n\n\nnamespace boost { namespace numeric { namespace ublasx {\n\nusing ::boost::numeric::ublas::num_rows;\n\n}}} // Namespace boost::numeric::ublasx\n\n\n#endif // BOOST_NUMERIC_UBLASX_OPERATION_NUM_ROWS_HPP\n", "meta": {"hexsha": "8090732390e6731112d71ad999bcb282613db50a", "size": 1450, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/numeric/ublasx/operation/num_rows.hpp", "max_stars_repo_name": "comcon1/boost-ublasx", "max_stars_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "boost/numeric/ublasx/operation/num_rows.hpp", "max_issues_repo_name": "comcon1/boost-ublasx", "max_issues_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "boost/numeric/ublasx/operation/num_rows.hpp", "max_forks_repo_name": "comcon1/boost-ublasx", "max_forks_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0144927536, "max_line_length": 97, "alphanum_fraction": 0.7579310345, "num_tokens": 372, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4960938294709195, "lm_q2_score": 0.1081889574375208, "lm_q1q2_score": 0.053671874201646014}}
{"text": "/* Copyright (C) 2020 IBM Corp.\n * This program is Licensed under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *   http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License. See accompanying LICENSE file.\n */\n\n/**\n * @file matmul.h\n * @brief some matrix / linear algebra stuff\n */\n\n#include <numeric>\n\n#include <NTL/BasicThreadPool.h>\n\n#include <helib/matmul.h>\n#include <helib/fhe_stats.h>\n#include <helib/debugging.h>\n\n#if (defined(__unix__) || defined(__unix) || defined(unix))\n#include <sys/time.h>\n#include <sys/resource.h>\n#endif\n\n#include \"gtest/gtest.h\"\n#include \"test_common.h\"\n\nnamespace {\n\nstruct Parameters\n{\n  Parameters(long m,\n             long r,\n             long bits,\n             long nt,\n             int force_bsgs,\n             int force_hoist,\n             int ks_strategy) :\n      m(m),\n      r(r),\n      bits(bits),\n      nt(nt),\n      force_bsgs(force_bsgs),\n      force_hoist(force_hoist),\n      ks_strategy(ks_strategy){};\n\n  const long m;          // defines the cyclotomic polynomial Phi_m(X)\n  const long r;          // Bit precision\n  const long bits;       // # bits in the modulus chain\n  const long nt;         // # threads\n  const int force_bsgs;  // 1 to force on, -1 to force off\n  const int force_hoist; // -1 to force off\n  const int ks_strategy; // 0: default, 1: full, 2: bsgs, 3: minimal\n\n  friend std::ostream& operator<<(std::ostream& os, const Parameters& params)\n  {\n    return os << \"{\"\n              << \"m=\" << params.m << \",\"\n              << \"r=\" << params.r << \",\"\n              << \"bits=\" << params.bits << \",\"\n              << \"nt=\" << params.nt << \",\"\n              << \"force_bsgs=\" << params.force_bsgs << \",\"\n              << \"force_hoist=\" << params.force_hoist << \",\"\n              << \"ks_strategy=\" << params.ks_strategy << \"}\";\n  }\n};\n\nclass TestMatmulCKKS : public ::testing::TestWithParam<Parameters>\n{\nprotected:\n  static void setGlobals(long force_bsgs, long force_hoist)\n  {\n    helib::fhe_test_force_bsgs = force_bsgs;\n    helib::fhe_test_force_hoist = force_hoist;\n  }\n\n  const long m;\n  const long r;\n  const long bits;\n  const long nt;\n\n  helib::Context context;\n  helib::SecKey secretKey;\n  const helib::PubKey publicKey;\n  const helib::EncryptedArray& ea;\n\n  TestMatmulCKKS() :\n      m(GetParam().m),\n      r(GetParam().r),\n      bits(GetParam().bits),\n      nt(GetParam().nt),\n      context(m, /*p=*/-1, r),\n      secretKey((buildModChain(context, bits), context)),\n      publicKey(keySetup(secretKey, GetParam().ks_strategy)),\n      ea(*(context.ea))\n  {}\n\n  static helib::SecKey& keySetup(helib::SecKey& secretKey, int ks_strategy)\n  {\n    secretKey.GenSecKey();\n    // We call addSomeFrbMatrices for all strategies except minimal\n    switch (ks_strategy) {\n    case 0:\n      addSome1DMatrices(secretKey);\n      addSomeFrbMatrices(secretKey);\n      break;\n    case 1:\n      add1DMatrices(secretKey);\n      addSomeFrbMatrices(secretKey);\n      break;\n    case 2:\n      addBSGS1DMatrices(secretKey);\n      addSomeFrbMatrices(secretKey);\n      break;\n    case 3:\n      addMinimal1DMatrices(secretKey);\n      addMinimalFrbMatrices(secretKey);\n      break;\n\n    default:\n      NTL::Error(\"bad ks_strategy\");\n    }\n    return secretKey;\n  }\n\n  virtual void SetUp() override\n  {\n    if (helib_test::verbose) {\n      context.zMStar.printout();\n      std::cout << \"# small primes = \" << context.smallPrimes.card() << \"\\n\"\n                << \"# ctxt primes = \" << context.ctxtPrimes.card() << \"\\n\"\n                << \"# bits in ctxt primes = \"\n                << long(context.logOfProduct(context.ctxtPrimes) / log(2.0) +\n                        0.5)\n                << \"\\n\"\n                << \"# special primes = \" << context.specialPrimes.card() << \"\\n\"\n                << \"# bits in special primes = \"\n                << long(context.logOfProduct(context.specialPrimes) / log(2.0) +\n                        0.5)\n                << \"\\n\";\n\n      helib::fhe_stats = true;\n    }\n    helib::setupDebugGlobals(&secretKey, context.ea);\n  }\n\n  virtual void TearDown() override\n  {\n    if (helib_test::verbose) {\n      helib::printAllTimers();\n#if (defined(__unix__) || defined(__unix) || defined(unix))\n      struct rusage rusage;\n      getrusage(RUSAGE_SELF, &rusage);\n      std::cout << \"  rusage.ru_maxrss=\" << rusage.ru_maxrss << std::endl;\n#endif\n      helib::print_stats(std::cout);\n    }\n    helib::cleanupDebugGlobals();\n  }\n};\n\nTEST_P(TestMatmulCKKS, vectorToMatrixMultiplication)\n{\n  std::vector<double> v(ea.size());\n  std::iota(v.begin(), v.end(), 1);\n\n  helib::MatMul_CKKS_Complex mat(context, [&v](long i, long j) {\n    return ((i + j) % v.size()) / double(v.size());\n  });\n  // Note the use of a \"lambda\": this allows for quite\n  // general ways to describe a matrix with minimal fuss\n\n  helib::Ctxt ctxt(publicKey);\n  // Initialize ptxt with the vector v\n  helib::PtxtArray ptxt(context, v);\n\n  // Encrypt ptxt. We have to supply *some* upper bound on the magnitude\n  // of the slots.\n  ptxt.encrypt(ctxt);\n\n  // Perform the linear transformation on the encrypted data\n  helib::EncodedMatMul_CKKS emat(mat);\n  // emat.upgrade();\n  ctxt *= emat;\n\n  // We can also do it this way:\n  // ctxt *= mat;\n\n  // Perform the linear transformation on the plaintext data\n  ptxt *= mat;\n\n  helib::PtxtArray ptxt1(context);\n  ptxt1.decrypt(ctxt, secretKey);\n\n  // w1 is the result of performing the transformation on\n  // the encrypted data\n  std::vector<double> w1;\n  ptxt1.store(w1);\n\n  // w is the result of performing the transformation on\n  // the encrypted data\n  std::vector<double> w;\n  ptxt.store(w);\n\n  for (long i = 0; i < ea.size(); ++i) {\n    EXPECT_NEAR(w[i], w1[i], 0.01);\n  }\n}\n\n// clang-format off\nINSTANTIATE_TEST_SUITE_P(typicalParameters, TestMatmulCKKS, ::testing::Values(\n      Parameters(/*m=*/16, /*r=*/10, /*bits=*/200, /*nt=*/1, /*force_bsgs=*/0, /*force_hoist=*/0, /*ks_strategy=*/0)\n      ));\n// clang-format on\n\n} // namespace\n", "meta": {"hexsha": "1b23dcac0433ae89b9d44be70af17e372bb6e7f2", "size": 6340, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/TestMatmulCKKS.cpp", "max_stars_repo_name": "jatanloya/HElib-PSI", "max_stars_repo_head_hexsha": "b5ec2844216ac87f1e20542e31ebb98363c14a6f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/TestMatmulCKKS.cpp", "max_issues_repo_name": "jatanloya/HElib-PSI", "max_issues_repo_head_hexsha": "b5ec2844216ac87f1e20542e31ebb98363c14a6f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2020-11-05T10:55:33.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-05T12:59:21.000Z", "max_forks_repo_path": "tests/TestMatmulCKKS.cpp", "max_forks_repo_name": "jatanloya/HElib-PSI", "max_forks_repo_head_hexsha": "b5ec2844216ac87f1e20542e31ebb98363c14a6f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4304932735, "max_line_length": 116, "alphanum_fraction": 0.6121451104, "num_tokens": 1721, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091957, "lm_q2_score": 0.10818895024889486, "lm_q1q2_score": 0.053671870635413045}}
{"text": "<<<<<<< HEAD\r\n/*    Copyright (c) 2010-2018, Delft University of Technology\r\n=======\r\n/*    Copyright (c) 2010-2019, Delft University of Technology\r\n>>>>>>> origin/master\r\n *    All rigths reserved\r\n *\r\n *    This file is part of the Tudat. Redistribution and use in source and\r\n *    binary forms, with or without modification, are permitted exclusively\r\n *    under the terms of the Modified BSD license. You should have received\r\n *    a copy of the license with this file. If not, please or visit:\r\n *    http://tudat.tudelft.nl/LICENSE.\r\n */\r\n\r\n#define BOOST_TEST_MAIN\r\n\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/make_shared.hpp>\r\n\r\n#include \"Tudat/Basics/testMacros.h\"\r\n\r\n#include \"Tudat/External/SpiceInterface/spiceInterface.h\"\r\n#include \"Tudat/InputOutput/basicInputOutput.h\"\r\n\r\n#include \"Tudat/Astrodynamics/Ephemerides/frameManager.h\"\r\n#include \"Tudat/Astrodynamics/Ephemerides/constantEphemeris.h\"\r\n\r\nnamespace tudat\r\n{\r\nnamespace unit_tests\r\n{\r\n\r\nusing namespace tudat::ephemerides;\r\nusing namespace tudat::spice_interface;\r\n\r\nBOOST_AUTO_TEST_SUITE( test_frame_manager )\r\n\r\nBOOST_AUTO_TEST_CASE( test_FrameManager )\r\n{\r\n\r\n    //Load spice kernels.\r\n    spice_interface::loadStandardSpiceKernels( );\r\n\r\n    std::map< std::string, std::shared_ptr< Ephemeris > > ephemerisList;\r\n\r\n    Eigen::Vector6d barycentricSunState = getBodyCartesianStateAtEpoch( \"Sun\", getBaseFrameName( ), \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Sun\" ] = std::make_shared< ConstantEphemeris >( barycentricSunState, getBaseFrameName( ), \"ECLIPJ2000\" );\r\n\r\n    Eigen::Vector6d sunCentricEarthState = getBodyCartesianStateAtEpoch( \"Earth\", \"Sun\", \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Earth\" ] = std::make_shared< ConstantEphemeris >( sunCentricEarthState, \"Sun\", \"ECLIPJ2000\" );\r\n\r\n    Eigen::Vector6d earthCentricMoonState = getBodyCartesianStateAtEpoch( \"Moon\", \"Earth\", \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Moon\" ] = std::make_shared< ConstantEphemeris >( earthCentricMoonState, \"Earth\", \"ECLIPJ2000\" );\r\n\r\n    Eigen::Vector6d earthCentricLageosState = Eigen::Vector6d::Zero( );\r\n    earthCentricLageosState( 1 ) = 2.5E6;\r\n    earthCentricLageosState( 2 ) = 4.0E6;\r\n    ephemerisList[ \"LAGEOS\" ] = std::make_shared< ConstantEphemeris >( earthCentricLageosState, \"Earth\", \"ECLIPJ2000\" );\r\n\r\n    Eigen::Vector6d moonCentricLroState = Eigen::Vector6d::Zero( );\r\n    moonCentricLroState( 0 ) = 1.0E6;\r\n    moonCentricLroState( 1 ) = 2.0E6;\r\n\r\n    ephemerisList[ \"LRO\" ] = std::make_shared< ConstantEphemeris >( moonCentricLroState, \"Moon\", \"ECLIPJ2000\" );\r\n\r\n    Eigen::Vector6d sunCentricMarsState = getBodyCartesianStateAtEpoch( \"Mars\", \"Sun\", \"ECLIPJ2000\", \"NONE\", 0.0 );\r\n    ephemerisList[ \"Mars\" ] = std::make_shared< ConstantEphemeris >( sunCentricMarsState, \"Sun\", \"ECLIPJ2000\" );\r\n\r\n    Eigen::Vector6d marsCentricPhobosState = Eigen::Vector6d::Zero( );\r\n    marsCentricPhobosState( 0 ) = 2.3E5;\r\n    marsCentricPhobosState( 1 ) = 2.9E4;\r\n    marsCentricPhobosState( 2 ) = 600;\r\n\r\n    ephemerisList[ \"Phobos\" ] = std::make_shared< ConstantEphemeris >( marsCentricPhobosState, \"Mars\", \"ECLIPJ2000\" );\r\n\r\n    std::shared_ptr< ReferenceFrameManager > frameManager = std::make_shared< ReferenceFrameManager >( ephemerisList );\r\n\r\n    std::map< std::string, int > expectedFrameLevel;\r\n    expectedFrameLevel[ \"Sun\" ] = 0;\r\n    expectedFrameLevel[ \"Earth\" ] = 1;\r\n    expectedFrameLevel[ \"Mars\" ] = 1;\r\n    expectedFrameLevel[ \"LAGEOS\" ] = 2;\r\n    expectedFrameLevel[ \"Moon\" ] = 2;\r\n    expectedFrameLevel[ \"Phobos\" ] = 2;\r\n    expectedFrameLevel[ \"LRO\" ] = 3;\r\n\r\n    for( std::map< std::string, int >::iterator it = expectedFrameLevel.begin( ); it != expectedFrameLevel.end( ); it++ )\r\n    {\r\n        if( frameManager->getFrameLevel( it->first ).first != it->second )\r\n        {\r\n            throw std::runtime_error(\r\n                        \"Error when identifying frame level of \" + it->first + \" found \" +\r\n                        std::to_string( frameManager->getFrameLevel( it->first ).first ) + \" expected\" +\r\n                        std::to_string( it->second ) );\r\n        }\r\n    }\r\n\r\n    std::vector< std::string > frames;\r\n    frames.push_back( \"Earth\" );\r\n    frames.push_back( \"Mars\" );\r\n    std::pair< std::string, int > commonFrame = frameManager->getNearestCommonFrame( frames );\r\n    BOOST_CHECK_EQUAL( commonFrame.first, \"Sun\" );\r\n    BOOST_CHECK_EQUAL( commonFrame.second, 0 );\r\n\r\n    frames.clear( );\r\n    frames.push_back( \"Moon\" );\r\n    frames.push_back( \"Sun\" );\r\n\r\n    commonFrame = frameManager->getNearestCommonFrame( frames );\r\n\r\n    BOOST_CHECK_EQUAL( commonFrame.first, \"Sun\" );\r\n    BOOST_CHECK_EQUAL( commonFrame.second, 0 );\r\n\r\n    frames.clear( );\r\n    frames.push_back( \"Earth\" );\r\n    frames.push_back( \"LRO\" );\r\n\r\n    commonFrame = frameManager->getNearestCommonFrame( frames );\r\n\r\n    BOOST_CHECK_EQUAL( commonFrame.first, \"Earth\" );\r\n    BOOST_CHECK_EQUAL( commonFrame.second, 1 );\r\n\r\n    Eigen::Vector6d testState = frameManager->getEphemeris< >( \"Moon\", \"LAGEOS\" )->getCartesianState( 0.0 );\r\n    Eigen::Vector6d expectedState = earthCentricLageosState - earthCentricMoonState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Phobos\", \"Sun\" )->getCartesianState( 0.0 );\r\n    expectedState = sunCentricMarsState + marsCentricPhobosState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, ( -1.0 * expectedState ), std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Sun\", \"Phobos\" )->getCartesianState( 0.0 );\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Sun\", \"Earth\" )->getCartesianState( 0.0 );\r\n    expectedState = sunCentricEarthState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( getBaseFrameName( ), \"Earth\" )->getCartesianState( 0.0 );\r\n    expectedState = barycentricSunState + sunCentricEarthState;\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, expectedState, std::numeric_limits< double >::epsilon( ) );\r\n\r\n    testState = frameManager->getEphemeris( \"Earth\", getBaseFrameName( ) )->getCartesianState( 0.0 );\r\n    TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testState, ( -1.0 * expectedState ), std::numeric_limits< double >::epsilon( ) );\r\n\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END( )\r\n\r\n}\r\n\r\n}\r\n", "meta": {"hexsha": "c8ccd9dcf42989cd994cf0acd5713b9b0cdf0602", "size": 6547, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestFrameManager.cpp", "max_stars_repo_name": "ViktorJordanov/tudat", "max_stars_repo_head_hexsha": "069ceeab8f12405c356e19f50d6df037914df85c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestFrameManager.cpp", "max_issues_repo_name": "ViktorJordanov/tudat", "max_issues_repo_head_hexsha": "069ceeab8f12405c356e19f50d6df037914df85c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/Astrodynamics/Ephemerides/UnitTests/unitTestFrameManager.cpp", "max_forks_repo_name": "ViktorJordanov/tudat", "max_forks_repo_head_hexsha": "069ceeab8f12405c356e19f50d6df037914df85c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0723684211, "max_line_length": 129, "alphanum_fraction": 0.6838246525, "num_tokens": 1932, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.32423541204073586, "lm_q2_score": 0.1645164628965632, "lm_q1q2_score": 0.0533420631347516}}
{"text": "/* Daniel R. Reynolds\n   SMU Mathematics\n   6 August 2020 */\n\n// Inclusions\n#include <stdlib.h>\n#include <stdio.h>\n#include <iostream>\n#include <iomanip>\n#include <fstream>\n#include <armadillo>\nusing namespace std;\n\n// prototypes of other functions\nint GramSchmidt(arma::mat& X);\n\n\n// Example routine to test the Mat class\nint main(int argc, char* argv[]) {\n\n  // create a row vector of length 5\n  arma::rowvec a(5);\n  a.fill(0.0);\n\n  // create a row vec with an existing data array\n  double dat1[5] = {0.1, 0.2, 0.3, 0.4, 0.5};\n  arma::rowvec b(dat1, 5);\n\n  // create a column vec with an existing vector\n  double dat2[5] = {0.1, 0.2, 0.3, 0.4, 0.5};\n  arma::vec b2(dat2, 5);\n\n  // create a row vector using linspace\n  arma::rowvec c = arma::linspace<arma::rowvec>(1.0, 5.0, 5);\n\n  // create a column vector using the single integer constructor\n  arma::vec h(7);\n\n  // output vectors above to screen\n  cout << \"writing array of zeros:\\n\";\n  cout << a << endl;\n  cout << \"writing array of 0.1,0.2,0.3,0.4,0.5:\\n\";\n  cout << b << endl;\n  cout << \"writing (column) array of 0.1,0.2,0.3,0.4,0.5:\\n\";\n  cout << b2 << endl;\n  cout << \"writing array of 1,2,3,4,5:\\n\";\n  cout << c << endl;\n  cout << \"writing a column vector of 7 zeros:\\n\";\n  cout << h << endl;\n\n  // verify that b has size 5\n  if (b.n_elem != 5)\n    cerr << \"error: incorrect matrix size\\n\";\n  if (b.n_cols != 5)\n    cerr << \"error: incorrect matrix columns\\n\";\n  if (b.n_rows != 1)\n    cerr << \"error: incorrect matrix rows\\n\";\n\n  // edit entries of a in both matrix forms, and write each entry of a to screen\n  a(0)  = 10.0;\n  a(1)  = 15.0;\n  a[2] = 20.0;\n  a(0,3) = 25.0;\n  a.at(4) = 30.0;\n  cout << \"entries of a, one at a time: should give 10, 15, 20, 25, 30\\n\";\n  for (size_t i=0; i<a.n_elem; i++)\n    cout << \"  \" << a[i] << endl;\n\n  // write the values to file\n  cout << \"writing this same vector to the file 'a_data':\\n\";\n  a.save(\"a_data\", arma::raw_ascii);\n\n  // Testing MatrixRead() constructor\n  double tol = 2.0e-15;\n  arma::mat read_test1a = arma::randu(3,4);\n  read_test1a.save(\"tmp.txt\", arma::raw_ascii);\n  arma::mat read_test1b;\n  read_test1b.load(\"tmp.txt\");\n  arma::mat read_test1_error = read_test1a - read_test1b;\n  if (norm(read_test1_error,\"inf\") < tol)\n    cout << \"save/load test 1 passed\\n\";\n  else {\n    cout << \"save/load test 1 failed, ||error|| = \" << norm(read_test1_error,\"inf\") << endl;\n    cout << \"  read_test1a = \\n\" << read_test1a << endl;\n    cout << \"  read_test1b = \\n\" << read_test1b << endl;\n  }\n\n  arma::mat read_test2a = arma::randu(12,1);\n  read_test2a.save(\"tmp.txt\", arma::raw_ascii);\n  arma::mat read_test2b;\n  read_test2b.load(\"tmp.txt\");\n  arma::mat read_test2_error = read_test2a - read_test2b;\n  if (norm(read_test2_error,\"inf\") < tol)\n    cout << \"save/load test 2 passed\\n\";\n  else {\n    cout << \"save/load test 2 failed, ||error|| = \" << norm(read_test2_error,\"inf\") << endl;\n    cout << \"  read_test2a = \\n\" << read_test2a << endl;\n    cout << \"  read_test2b = \\n\" << read_test2b << endl;\n  }\n\n  arma::mat read_test3a = arma::randu(1,7);\n  read_test3a.save(\"tmp.txt\", arma::raw_ascii);\n  arma::mat read_test3b;\n  read_test3b.load(\"tmp.txt\");\n  arma::mat read_test3_error = read_test3a - read_test3b;\n  if (norm(read_test3_error,\"inf\") < tol)\n    cout << \"save/load test 3 passed\\n\";\n  else {\n    cout << \"save/load test 3 failed, ||error|| = \" << norm(read_test3_error,\"inf\") << endl;\n    cout << \"  read_test3a = \\n\" << read_test3a << endl;\n    cout << \"  read_test3b = \\n\" << read_test3b << endl;\n  }\n\n  // Testing copy constructor\n  arma::mat B = a;\n  cout << \"arma::mat B = a uses copy constructor, should give 10, 15, 20, 25, 30\\n\";\n  cout << B << endl;\n  // update one entry of a\n  cout << \"updating the 5th entry of a to be 31:\\n\";\n  a(4) = 31.0;\n  cout << \"   a = \" << a << endl;\n\n  cout << \"B should not have changed\" << endl;\n  cout << \"   B = \" << B << endl;\n  a(4) = 30.0;  // reset to original\n\n  // Testing submatrix copy constructor\n  arma::mat B2 = a.submat(0,1,0,3);  // B2 = a(0:0,1:3)\n  cout << \"arma::mat B2 = a.submat(0,1,0,3) uses submatrix copy constructor\" << endl;\n  cout << B2 << endl;\n  // update entries of B2\n  B2(0) = 4.0;\n  B2(1) = 3.0;\n  B2(2) = 2.0;\n  // copy B2 back into a using submatrix copy\n  a(0,arma::span(1,3)) = B2;  // a(0,1:3) = B2\n  cout << \"span copy back into a, should have entries 10 4 3 2 30\" << endl;\n  cout << a << endl;\n  a(1) = 15.0;  // reset to original\n  a(2) = 20.0;\n  a(3) = 25.0;\n\n  // Test arithmetic operators\n  cout << \"Testing vector add, should give 1.1, 2.2, 3.3, 4.4, 5.5\\n\";\n  b += c;  // b = b + c\n  cout << b << endl;\n\n  cout << \"Testing scalar add, should give 2, 3, 4, 5, 6\\n\";\n  c += 1.0;  // c = c + 1\n  cout << c << endl;\n\n  cout << \"Testing vector subtract, should be 8, 12, 16, 20, 24\\n\";\n  a -= c;  // a = a - c\n  cout << a << endl;\n\n  cout << \"Testing scalar subtract, should be 0, 1, 2, 3, 4\\n\";\n  c -= 2.0;  // c = c - 2\n  cout << c << endl;\n\n  cout << \"Testing vector fill, should all be -1\\n\";\n  b.fill(-1.0);  // b = -1*ones(size(b))\n  cout << b << endl;\n\n  cout << \"Testing vector copy, should be 0, 1, 2, 3, 4\\n\";\n  a = c;\n  cout << a << endl;\n\n  cout << \"Testing scalar multiply, should be 0, 5, 10, 15, 20\\n\";\n  c *= 5.0;  // c = c * 5\n  cout << c << endl;\n\n  cout << \"Testing deep copy, should be 0, 1, 2, 3, 4\\n\";\n  cout << a << endl;\n\n  cout << \"Testing vector multiply, should be 0, -1, -2, -3, -4\\n\";\n  b %= a;   // b = b.*a\n  cout << b << endl;\n\n  cout << \"Testing vector divide, should be 0, -2.5, -3.3333, -3.75, -4\\n\";\n  arma::mat j(c);  // j = c\n  b += -1.0;\n  j /= b;   // j = j ./ b\n  b += 1.0;\n  cout << j << endl;\n\n  cout << \"Testing vector +=, should be 0, 4, 8, 12, 16\\n\";\n  b += c;\n  cout << b << endl;\n\n  cout << \"Testing scalar +=, should be 1, 6, 11, 16, 21\\n\";\n  c += 1.0;\n  cout << c << endl;\n\n  cout << \"Testing vector -=, should be 1, 2, 3, 4, 5\\n\";\n  c -= b;\n  cout << c << endl;\n\n  cout << \"Testing scalar -=, should be -2, -1, 0, 1, 2\\n\";\n  a -= 2.0;\n  cout << a << endl;\n\n  cout << \"Testing vector %=, should be 0, -4, 0, 12, 32\\n\";\n  a %= b;\n  cout << a << endl;\n\n  cout << \"Testing scalar *=, should be 2, 4, 6, 8, 10\\n\";\n  c *= 2.0;\n  cout << c << endl;\n\n  cout << \"Testing vector /=, should be 0, -1, 0, 1.5, 3.2\\n\";\n  j = a;\n  j /= c;\n  cout << j << endl;\n\n  cout << \"Testing scalar /=, should be 1, 2, 3, 4, 5\\n\";\n  j = c;\n  j /= 2.0;\n  cout << j << endl;\n\n  cout << \"Testing vector =, should be 2, 4, 6, 8, 10\\n\";\n  b = c;\n  cout << b << endl;\n\n  cout << \"Testing scalar fill, should be 3, 3, 3, 3, 3\\n\";\n  a.fill(3.0);\n  cout << a << endl;\n\n  cout << \"Testing vector norm, should be 14.8324\\n\";\n  cout << \"  \" << arma::norm(b) << endl;\n\n  cout << \"Testing vector infinity norm, should be 10\\n\";\n  cout << \"  \" << arma::norm(b,\"inf\") << endl;\n\n  cout << \"Testing vector one norm, should be 30\\n\";\n  cout << \"  \" << arma::norm(b,1) << endl;\n\n  cout << \"Testing vector min, should be 2\\n\";\n  cout << \"  \" << b.min() << endl;\n\n  cout << \"Testing vector max, should be 10\\n\";\n  cout << \"  \" << b.max() << endl;\n\n  B = arma::mat(2,5);\n  B(0,arma::span(0,4)) = c;   // B(0,:) = c\n  B(1,arma::span(0,4)) = a;   // B(1,:) = a\n  B += 2.0;\n\n  cout << \"Testing matrix infinity norm, should be 40\\n\";\n  cout << \"  \" << arma::norm(B,\"inf\") << endl;\n\n  cout << \"Testing matrix one norm, should be 17\\n\";\n  cout << \"  \" << arma::norm(B,1) << endl;\n\n  cout << \"Testing matrix two norm, should be 21.7821\\n\";\n  cout << \"  \" << arma::norm(B,2) << endl;\n\n  cout << \"Testing matrix min, should be 4\\n\";\n  cout << \"  \" << B.min() << endl;\n\n  cout << \"Testing matrix max, should be 12\\n\";\n  cout << \"  \" << B.max() << endl;\n\n  cout << \"Testing dot, should be 90\\n\";\n  cout << \"  \" << dot(a, c) << endl;\n\n  cout << \"Testing logspace, should be 0.01 0.1 1 10 100\\n\";\n  arma::mat e = arma::logspace<arma::rowvec>(-2.0, 2.0, 5);\n  cout << e << endl;\n\n  ofstream out;\n  out.open(\"e.txt\");\n  if(out.is_open())\n  {\n    out << e;\n    cout << \"Wrote to file e.txt:\\n\" << e;\n  }\n  out.close();\n\n  cout << \"Testing randu\\n\";\n  arma::mat f = arma::randu(3,3);\n  cout << \"f = \" << f << endl;\n  cout << \"Testing write with a temporary result\" << endl;\n  cout << (f*f+f) << endl;\n  cout << \"f should be unchanged from above\" << endl;\n  cout << \"f = \" << f << endl;\n  cout << \"Testing f==f, should be 3x3 matrix of ones\\n\" << (f==f) << endl;\n  b.fill(1.0);\n  cout << \"Testing e==b, should be 0 0 1 0 0\\n  \" << (e==b) << endl;\n\n  // create and fill in a 10x5 matrix\n  arma::mat Y(10,5);\n  for (size_t i=0; i<10; i++) {\n    Y(i,0) = 1.0*i;\n    Y(i,1) = -5.0 + 1.0*i;\n    Y(i,2) = 2.0 + 2.0*i;\n    Y(i,3) = 20.0 - 1.0*i;\n    Y(i,4) = -20.0 + 1.0*i;\n  }\n\n  // extract columns from matrix (both ways)\n  arma::vec Y0 = Y.col(0);\n  arma::mat Y1(Y.col(1));\n  arma::vec Y2(Y(arma::span(0,9),2));\n  arma::vec Y3 = Y.col(3);\n  arma::vec Y4 = Y(arma::span(0,9),4);\n\n  // check the LinearSum routine\n  Y4 += Y3;\n  cout << \"Testing column extraction, should be all zeros:\\n\";\n  cout << Y4 << endl;\n\n  // check linear sum \n  arma::mat d = arma::linspace<arma::rowvec>(0.0, 4.0, 5);\n  cout << \"Testing LinearSum, should be 0.02 1.2 4 23 204:\\n\";\n  arma::mat g = 1.0*d + 2.0*e;\n  cout << g << endl;\n\n  // check the pow routine\n  d = arma::pow(d,2.0);   // d = d.^2\n  cout << \"Testing pow, should be 0 1 4 9 16:\\n\";\n  cout << d << endl;\n  d = arma::pow(d,0.5);   // d = sqrt(d)\n  cout << \"Testing pow, should be 0 1 2 3 4:\\n\";\n  cout << d << endl;\n\n  // check the abs routine\n  Y1 = arma::abs(Y1);\n  cout << \"Testing abs, should be the column 5 4 3 2 1 0 1 2 3 4:\\n\";\n  cout << Y1 << endl;\n\n  // check the inplace_trans routine\n  cout << \"Testing inplace_trans, should be the row 5 4 3 2 1 0 1 2 3 4:\\n\";\n  inplace_trans(Y1);\n  cout << Y1 << endl;\n\n  // check the copy-based transpose routine\n  cout << \"Testing copy-based transpose, should be the column 5 4 3 2 1 0 1 2 3 4:\\n\";\n  Y2 = Y1.t();\n  cout << Y2 << endl;\n\n  cout << \"Testing GramSchmidt, should work\\n\";\n  arma::mat X = arma::randu(20,3);\n  int iret = GramSchmidt(X);\n  cout << \"  GramSchmidt returned \" << iret << \", dot-products are:\\n\";\n  cout << \"     <X0,X0> = \" << arma::dot(X.col(0),X.col(0)) << endl;\n  cout << \"     <X0,X1> = \" << arma::dot(X.col(0),X.col(1)) << endl;\n  cout << \"     <X0,X2> = \" << arma::dot(X.col(0),X.col(2)) << endl;\n  cout << \"     <X1,X1> = \" << arma::dot(X.col(1),X.col(1)) << endl;\n  cout << \"     <X1,X2> = \" << arma::dot(X.col(1),X.col(2)) << endl;\n  cout << \"     <X2,X2> = \" << arma::dot(X.col(2),X.col(2)) << endl << endl;\n\n  cout << \"Testing GramSchmidt, should fail\\n\";\n  arma::mat V = arma::randu(20,3);\n  V.col(2) = 2.0*V.col(1);\n  iret = GramSchmidt(V);\n  cout << \"  GramSchmidt returned \" << iret << \", dot-products are:\\n\";\n  cout << \"     <V0,V0> = \" << arma::dot(V.col(0),V.col(0)) << endl;\n  cout << \"     <V0,V1> = \" << arma::dot(V.col(0),V.col(1)) << endl;\n  cout << \"     <V0,V2> = \" << arma::dot(V.col(0),V.col(2)) << endl;\n  cout << \"     <V1,V1> = \" << arma::dot(V.col(1),V.col(1)) << endl;\n  cout << \"     <V1,V2> = \" << arma::dot(V.col(1),V.col(2)) << endl;\n  cout << \"     <V2,V2> = \" << arma::dot(V.col(2),V.col(2)) << endl << endl;\n\n  cout << \"Testing matrix product, should be: 9 -1 9 -8 11 6\\n\";\n  arma::mat A_ = arma::eye(6,6);\n  A_(0,3) = 2.0;\n  A_(1,2) = -1.0;\n  A_(2,5) = 1.0;\n  A_(3,5) = -2.0;\n  A_(4,5) = 1.0;\n  arma::mat xtrue_ = arma::linspace(1.0, 6.0, 6);\n  arma::mat b_ = A_*xtrue_;\n  cout << b_ << endl;\n\n  cout << \"Testing backwards substitution solve with provided solution array:\\n\";\n  arma::vec x_(6);\n  if (arma::solve(x_, A_, b_)) {\n    cout << \"  solve succeeded\\n\";\n  } else {\n    cout << \"  solve failed\\n\";\n  }\n  cout << \"  ||x - xtrue|| = \" << arma::norm(x_ - xtrue_, \"inf\") << \"\\n\\n\";\n\n  cout << \"Testing forwards substitution with provided solution array:\\n\";\n  A_.eye();\n  A_(3,0) = 2.0;\n  A_(2,1) = -1.0;\n  A_(5,2) = 1.0;\n  A_(5,3) = -2.0;\n  A_(5,4) = 1.0;\n  b_ = A_*xtrue_;\n  x_ = 0.0;\n  if (arma::solve(x_, A_, b_)) {\n    cout << \"  solve succeeded\\n\";\n  } else {\n    cout << \"  solve failed\\n\";\n  }\n  cout << \"  ||x - xtrue|| = \" << arma::norm(x_ - xtrue_, \"inf\") << \"\\n\\n\";\n\n  cout << \"Testing general solver:\\n\";\n  arma::mat C_ = 100.0*arma::eye(9,9) + arma::randu(9,9);\n  arma::vec z_ = arma::logspace(-4.0, 4.0, 9);\n  arma::mat f_ = C_*z_;\n  arma::mat g_ = arma::solve(C_, f_);\n  cout << \"  ||x - xtrue|| = \" << arma::norm(g_ - z_, \"inf\") << \"\\n\\n\";\n\n  cout << \"Testing copy-into-col, should be: \\n\";\n  cout << \"    0.01   0.02   0.04   0.08\\n\";\n  cout << \"    0.1    0.2    0.4    0.8\\n\";\n  cout << \"    1      2      4      8\\n\";\n  cout << \"   10     20     40     80\\n\";\n  cout << \" Actually is:\\n\";\n  arma::mat z2_ = arma::logspace(-2.0, 1.0, 4);\n  arma::mat B_(4,4);\n  B_.col(0) = z2_;\n  z2_ *= 2.0;\n  B_.col(1) = z2_;\n  z2_ *= 2.0;\n  B_.col(2) = z2_;\n  z2_ *= 2.0;\n  B_.col(3) = z2_;\n  cout << B_ << endl;\n\n  cout << \"Testing general solver with matrix-valued rhs:\\n\";\n  arma::mat E_ = 100.0*arma::eye(4,4) + arma::randu(4,4);\n  arma::mat F_ = E_*B_;\n  arma::mat X_ = arma::solve(E_, F_);\n  cout << \"  ||X - Xtrue|| = \" << arma::norm(X_ - B_,\"inf\") << \"\\n\\n\";\n\n  cout << \"Testing matrix inverse:\\n\";\n  arma::mat D_ = 10.0*arma::eye(8,8) + arma::randu(8,8);\n  arma::mat DDinv_(D_);\n  arma::mat Dinv_ = D_.i();\n  DDinv_ = D_*Dinv_;\n  cout << \"  ||I - D*Dinv|| = \" << arma::norm(arma::eye(8,8) - DDinv_,\"inf\") << endl;\n  DDinv_ = Dinv_*D_;\n  cout << \"  ||I - Dinv*D|| = \" << arma::norm(arma::eye(8,8) - DDinv_,\"inf\") << endl;\n\n  return 0;\n} // end main\n", "meta": {"hexsha": "b55d4e166b1e35326114dfa4c9305eff7a33d3a0", "size": 13500, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "armadillo/armadillo_test.cpp", "max_stars_repo_name": "drreynolds/Math6321-codes", "max_stars_repo_head_hexsha": "3cce53bbe70bdd00220b5d8888b00b20b4fd521b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "armadillo/armadillo_test.cpp", "max_issues_repo_name": "drreynolds/Math6321-codes", "max_issues_repo_head_hexsha": "3cce53bbe70bdd00220b5d8888b00b20b4fd521b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "armadillo/armadillo_test.cpp", "max_forks_repo_name": "drreynolds/Math6321-codes", "max_forks_repo_head_hexsha": "3cce53bbe70bdd00220b5d8888b00b20b4fd521b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2020-08-31T18:04:07.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-31T18:04:07.000Z", "avg_line_length": 30.612244898, "max_line_length": 92, "alphanum_fraction": 0.5384444444, "num_tokens": 5329, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.11279541373888333, "lm_q1q2_score": 0.053316528312935506}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Tests for the array driver functions from the utility operations\n *\n */\n\n#define BOOST_TEST_MODULE ArrayDrivers\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n\n#include <stdexcept>\n#include \"ArrayDrivers.h\"\n#include \"ArrayKernels.h\"\n\nusing namespace cupcfd::utility::drivers;\n\n// ======================= Array Copy Tests ==================================\n// Test 1: Successful copy\nBOOST_AUTO_TEST_CASE(copy_test1)\n{\n\tint source[6] = {1, 4, 3, 2, 6, 1};\n\tint result[6] = {0 ,0 ,0 ,0 ,0 ,0};\n\tint resultCmp[6] = {1, 4, 3, 2, 6, 1};\n\n\tcupcfd::error::eCodes err = copy(source, 6, result, 6);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 5, resultCmp, resultCmp + 5);\n}\n\n// Test 2: Undersized destination array\nBOOST_AUTO_TEST_CASE(copy_test2)\n{\n\tint source[6] = {1, 4, 3, 2, 6, 1};\n\tint result[4] = {0 ,0 ,0 ,0};\n\n\tcupcfd::error::eCodes err = copy(source, 6, result, 4);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_ARRAY_SIZE_UNDERSIZED);\n}\n\n// ======================= Array Zero Tests ==================================\n// Test 1: Zero the array\nBOOST_AUTO_TEST_CASE(zero_test1)\n{\n\tint source[6] = {1, 4, 3, 2, 6, 1};\n\tint resultCmp[6] = {0, 0, 0, 0, 0, 0};\n\n\tcupcfd::error::eCodes err = zero(source, 6);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source, source + 5, resultCmp, resultCmp + 5);\n}\n\n// ==================== UniqueCount ==========================\n// Test 1: Count the number of unique elements in an array\nBOOST_AUTO_TEST_CASE(uniqueCount_test1)\n{\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 11, & count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 2: Count zero unique elements in an array with only duplicates\nBOOST_AUTO_TEST_CASE(uniqueCount_test2)\n{\n\tint source[14] = {1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 14, & count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 0);\n}\n\n// Test 3: Count the number of unique elements in an array that is unsorted\nBOOST_AUTO_TEST_CASE(uniqueCount_test3)\n{\n\tint source[11] = {7, 5, 3, 2, 15, 2, 7, 21, 100, 200, 150};\n\tint sourceCmp[11] = {7, 5, 3, 2, 15, 2, 7, 21, 100, 200, 150};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 11, & count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t// Source should remain unmodified (non-destructive)\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source, source + 11, sourceCmp, sourceCmp + 11);\n\tBOOST_CHECK_EQUAL(count, 7);\n}\n\n// Test 4: Count the number of unique elements when all elements are unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test4)\n{\n\tint source[6] = {1, 2, 3, 4, 7, 325};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 6, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 6);\n}\n\n// Test 5: Count the number of unique elements when only the first is unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test5)\n{\n\tint source[11] = {1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 11, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 1);\n}\n\n// Test 6: Count the number of unique elements when only the last is unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test6)\n{\n\tint source[11] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 11, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 1);\n}\n\n// Test 7: Count the number of unique elements when only the last two are unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test7)\n{\n\tint source[10] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 325};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = uniqueCount(source, 10, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// ================= Unique Array =======================\n// Test 1: Find the unique elements in an arbitrary array\nBOOST_AUTO_TEST_CASE(uniqueArray_test1)\n{\n\t// The kernel expects sorted arrays only\n\t// Isn't this tested already in the kernels tests?\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 3);\n\n\tint result[3];\n\tint result_cmp[3] = {2, 7, 325};\n\n\tcupcfd::error::eCodes err = uniqueArray(source, 11, result, 3);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, result_cmp, result_cmp + 3);\n}\n\n// Test 2: Find the unique elements in an unsorted array\nBOOST_AUTO_TEST_CASE(uniqueArray_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 3);\n\n\tint result[3];\n\tint result_cmp[3] = {2, 7, 325};\n\n\tcupcfd::error::eCodes err = uniqueArray(source, 11, result, 3);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, result_cmp, result_cmp + 3);\n}\n\n// Test 3: Check that the method runs without error when there are no unique elements\nBOOST_AUTO_TEST_CASE(uniqueArray_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[14] = {1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 14);\n\tBOOST_CHECK_EQUAL(count, 0);\n\n\tint result[0];\n\t// Theoretically, it should never copy. If it does, it will go out of bounds in memory.\n\tcupcfd::error::eCodes err = uniqueArray(source, 14, result, 0);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n}\n\n// Test 4: Test when all elements are unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[6] = {1, 2, 3, 4, 7, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 6);\n\tBOOST_CHECK_EQUAL(count, 6);\n\n\tint result[6];\n\tint result_cmp[6] = {1, 2, 3, 4, 7, 325};\n\tcupcfd::error::eCodes err = uniqueArray(source, 6, result, 6);\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 6, result_cmp, result_cmp + 6);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n}\n\n// Test 5: Test when only the first element is unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 1);\n\n\tint result[1];\n\tint result_cmp[1] = {1};\n\tcupcfd::error::eCodes err = uniqueArray(source, 11, result, 1);\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 1, result_cmp, result_cmp + 1);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n}\n\n// Test 6: Test when the last element is unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 1);\n\n\tint result[1];\n\tint result_cmp[1] = {325};\n\tcupcfd::error::eCodes err = uniqueArray(source, 11, result, 1);\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 1, result_cmp, result_cmp + 1);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n}\n\n// Test 7: Test when the last two elements are unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test7)\n{\n\t// The kernel expects sorted arrays only\n\tint source[10] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 325};\n\tint count = cupcfd::utility::kernels::uniqueCount(source, 10);\n\tBOOST_CHECK_EQUAL(count, 2);\n\n\tint result[2];\n\tint result_cmp[2] = {7, 325};\n\tcupcfd::error::eCodes err = uniqueArray(source, 10, result, 2);\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 2, result_cmp, result_cmp + 2);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n}\n\n// ================= Unique Array + Array Creation =======================\n\n// Test 8: Test creating an array automatically when finding unique elements\nBOOST_AUTO_TEST_CASE(uniqueArray_test8)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count;\n\tint * result;\n\n\tint result_cmp[3] = {2, 7, 325};\n\n\tcupcfd::error::eCodes err = uniqueArray(source, 11, &result, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, result_cmp, result_cmp + 3);\n\n\t// Cleanup\n\tfree(result);\n}\n\n// ======================= Array Add Tests ===================================\n// Test 1: Test adding with destructive storage in source1\nBOOST_AUTO_TEST_CASE(add_test1)\n{\n\tint source1[5] = {1,2,3,4,5};\n\tint source2[5] = {1,2,18,4,7};\n\tint resultCmp[5] = {2, 4, 21, 8, 12};\n\tint source2Cmp[5] = {1,2,18,4,7};\n\n\tcupcfd::error::eCodes err = add(source1, 5, source2, 5);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source1, source1 + 5, resultCmp, resultCmp + 5);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source2, source2 + 5, source2Cmp, source2Cmp + 5);\n}\n\n// ======================= Array Add Non-Destructive Tests ===================================\n// Test 2: Test adding with non-destructive storage\nBOOST_AUTO_TEST_CASE(add_test2)\n{\n\tint dest[5];\n\n\tint source1[5] = {1,2,3,4,5};\n\tint source2[5] = {1,2,18,4,7};\n\n\tint source1Cmp[5] = {1,2,3,4,5};\n\tint source2Cmp[5] = {1,2,18,4,7};\n\tint resultCmp[5] = {2, 4, 21, 8, 12};\n\n\tcupcfd::error::eCodes err = add(source1, 5, source2, 5, dest, 5);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 5, resultCmp, resultCmp + 5);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source1, source1 + 5, source1Cmp, source1Cmp + 5);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source2, source2 + 5, source2Cmp, source2Cmp + 5);\n}\n\n// ================= Distinct Count ===========================\n// Test 1: Test counting distinct elements in arbitrary array\nBOOST_AUTO_TEST_CASE(distinctCount_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 6);\n}\n\n// Test 2: Test counting distinct elements with duplicates\nBOOST_AUTO_TEST_CASE(distinctCount_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n// Test 3: Test counting with all elements being distinct\nBOOST_AUTO_TEST_CASE(distinctCount_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 11);\n}\n\n// Test 4: Test counting where only first element is non-duplicate\nBOOST_AUTO_TEST_CASE(distinctCount_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// Test 5: Test counting where only last element is non-duplicate\nBOOST_AUTO_TEST_CASE(distinctCount_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// Test 6: Test counting where only first two elements are non-duplicate\nBOOST_AUTO_TEST_CASE(distinctCount_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 7: Test counting where only last two elements are non-duplicate\nBOOST_AUTO_TEST_CASE(distinctCount_test7)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3};\n\tint count;\n\tcupcfd::error::eCodes err = distinctCount(source, 11, &count);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// ================= Distinct Array  ===========================\n// Test 1: Test finding distinct elements in arbitrary array\nBOOST_AUTO_TEST_CASE(distinctArray_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint * dest = (int *) malloc(sizeof(int) * 6);\n\tint resultCmp[6] = {1,2,3,4,7,325};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 6);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 6, resultCmp, resultCmp + 6);\n}\n\n// Test 2: Test finding distinct elements in arbitrary unsorted array\nBOOST_AUTO_TEST_CASE(distinctArray_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {325, 1, 4, 1, 2, 7, 3, 1, 4, 3, 1};\n\tint * dest = (int *) malloc(sizeof(int) * 6);\n\tint resultCmp[6] = {1,2,3,4,7,325};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 6);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 6, resultCmp, resultCmp + 6);\n}\n\n// Test 3: Test finding distinct elements where all elements have duplicates\nBOOST_AUTO_TEST_CASE(distinctArray_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4};\n\tint * dest = (int *) malloc(sizeof(int) * 4);\n\tint resultCmp[4] = {1,2,3,4};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 4);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 4, resultCmp, resultCmp + 4);\n}\n\n// Test 4: Test finding distinct elements when no element has a duplicate\nBOOST_AUTO_TEST_CASE(distinctArray_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint * dest = (int *) malloc(sizeof(int) * 11);\n\tint resultCmp[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 11);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 11, resultCmp, resultCmp + 11);\n}\n\n// Test 5: Test finding distinct elements when only first element has no duplicate\nBOOST_AUTO_TEST_CASE(distinctArray_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint resultCmp[2] = {1, 2};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 2);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n}\n\n// Test 6: Test finding distinct elements when only last element has no duplicate\nBOOST_AUTO_TEST_CASE(distinctArray_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint resultCmp[2] = {1, 2};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 2);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n}\n\n// Test 7: Test finding distinct elements when only first two elements have no duplicate\nBOOST_AUTO_TEST_CASE(distinctArray_test7)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint resultCmp[6] = {1, 2, 3};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 3);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n}\n\n// Test 8: Test finding distinct elements when only last two elements have no duplicate\nBOOST_AUTO_TEST_CASE(distinctArray_test8)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 7};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint resultCmp[3] = {1, 2, 7};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 3);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n}\n\n// ================= Distinct Array + Array Creation ===========================\n\n// ================= Distinct Array + Count ===========================\n// Test 1: Test finding distinct elements with count also in arbitrary array\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint * dest = (int *) malloc(sizeof(int) * 6);\n\tint * count = (int *) malloc(sizeof(int) * 6);\n\n\tint resultCmp[6] = {1,2,3,4,7,325};\n\tint countCmp[6] = {4,1,2,2,1,1};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 6, count, 6);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 6, resultCmp, resultCmp + 6);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 6, countCmp, countCmp + 6);\n}\n\n// Test 2: Test finding distinct elements with count also in arbitrary array where all elements have duplicates\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4};\n\tint * dest = (int *) malloc(sizeof(int) * 4);\n\tint * count = (int *) malloc(sizeof(int) * 4);\n\n\tint resultCmp[4] = {1,2,3,4};\n\tint countCmp[4] = {2, 3, 2, 4};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 4, count, 4);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 4, resultCmp, resultCmp + 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 4, countCmp, countCmp + 4);\n}\n\n// Test 3: Test finding distinct elements with count also in arbitrary array where no elements has a duplicate\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint * dest = (int *) malloc(sizeof(int) * 11);\n\tint * count = (int *) malloc(sizeof(int) * 11);\n\n\tint resultCmp[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint countCmp[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 11, count, 11);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 11, resultCmp, resultCmp + 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 11, countCmp, countCmp + 11);\n}\n\n// Test 4: Test finding distinct elements with count where first element only has no duplicate\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint * count = (int *) malloc(sizeof(int) * 2);\n\n\tint resultCmp[2] = {1, 2};\n\tint countCmp[2] = {1, 10};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 2, count, 2);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 2, countCmp, countCmp + 2);\n}\n\n// Test 5: Test finding distinct elements with count where last element only has no duplicate\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint * count = (int *) malloc(sizeof(int) * 2);\n\n\tint resultCmp[2] = {1, 2};\n\tint countCmp[2] = {10, 1};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 2, count, 2);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 2, countCmp, countCmp + 2);\n}\n\n// Test 6: Test finding distinct elements with count where first two elements only have no duplicate\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint * count = (int *) malloc(sizeof(int) * 3);\n\n\tint resultCmp[6] = {1, 2, 3};\n\tint countCmp[3] = {1, 1, 9};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 3, count, 3);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 3, countCmp, countCmp + 3);\n}\n\n// Test 7: Test finding distinct elements with count where last two elements only have no duplicate\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test7)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 7};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint * count = (int *) malloc(sizeof(int) * 3);\n\n\tint resultCmp[3] = {1, 2, 7};\n\tint countCmp[3] = {9, 1, 1};\n\n\tcupcfd::error::eCodes err = distinctArray(source, 11, dest, 3, count, 3);\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 3, countCmp, countCmp + 3);\n}\n\n// ================= Distinct Array + Count + Array Creation ===========================\n\n\n//====================== Minus Count ===========================\n// Test 1: Test MinusCount when array1 is larger than array2\nBOOST_AUTO_TEST_CASE(minusCount_test1)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\n\tminusCount(source1, 7, source2, 4, &count);\n\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n// Test 2: Test MinusCount when array2 is larger than array1\nBOOST_AUTO_TEST_CASE(minusCount_test2)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\tint count;\n\n\tminusCount(source1, 7, source2, 8, &count);\n\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n// Test 3: Test MinusCount when array1 is all the same element\nBOOST_AUTO_TEST_CASE(minusCount_test3)\n{\n\tint source1[7] = {1, 1, 1, 1, 1, 1, 1};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\n\tminusCount(source1, 7, source2, 4, &count);\n\n\tBOOST_CHECK_EQUAL(count, 7);\n}\n\n// Test 4: Test MinusCount when arrays have the same contents\nBOOST_AUTO_TEST_CASE(minusCount_test4)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\n\tminusCount(source1, 4, source2, 4, &count);\n\n\tBOOST_CHECK_EQUAL(count, 0);\n}\n\n//====================== Minus Array ===========================\n// Test 1: Test MinusArray when array1 is larger than array2\nBOOST_AUTO_TEST_CASE(minusArray_test1)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\tint * result;\n\tint nResult;\n\tint resultCmp[4] = {1, 4, 10, 12};\n\n\tcupcfd::error::eCodes err = minusArray(source1, 7, source2, 4, &result, &nResult);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, resultCmp, resultCmp + 4);\n}\n\n// Test 2: Test MinusArray when array2 is larger than array1\nBOOST_AUTO_TEST_CASE(minusArray_test2)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\tint * result;\n\tint nResult;\n\tint resultCmp[4] = {1, 4, 10, 12};\n\n\tcupcfd::error::eCodes err = minusArray(source1, 7, source2, 8, &result, &nResult);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, resultCmp, resultCmp + 4);\n}\n\n// Test 3: Test MinusArray when array1 is unsorted\nBOOST_AUTO_TEST_CASE(minusArray_test3)\n{\n\tint source1[7] = {12, 2, 4, 1, 8, 2, 10};\n\tint source2[4] = {2, 8, 21, 22};\n\tint * result;\n\tint nResult;\n\tint resultCmp[4] = {1, 4, 10, 12};\n\n\tcupcfd::error::eCodes err = minusArray(source1, 7, source2, 4, &result, &nResult);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, resultCmp, resultCmp + 4);\n}\n\n// Test 4: Test MinusArray when array1 is all the same element\nBOOST_AUTO_TEST_CASE(minusArray_test4)\n{\n\tint source1[7] = {1, 1, 1, 1, 1, 1, 1};\n\tint source2[4] = {2, 8, 21, 22};\n\tint * result;\n\tint nResult;\n\tint resultCmp[7] = {1, 1, 1, 1, 1, 1, 1};\n\n\tcupcfd::error::eCodes err = minusArray(source1, 7, source2, 4, &result, &nResult);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 7);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 7, resultCmp, resultCmp + 7);\n}\n\n// Test 5: Test MinusArray when the arrays have the same contents\nBOOST_AUTO_TEST_CASE(minusArray_test5)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\tint * result;\n\tint nResult;\n\tint resultCmp[0];\n\n\tcupcfd::error::eCodes err = minusArray(source1, 4, source2, 4, &result, &nResult);\n\n\tBOOST_CHECK_EQUAL(err, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 0);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 0, resultCmp, resultCmp + 0);\n}\n\n//====================== Intersect Count ===========================\n// Test 1: Test Intersect Count with array\nBOOST_AUTO_TEST_CASE(intersectCount_test1)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = intersectCount(source1, 6, source2, 4, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t// Duplicates should not count, so only 2 and 8 are in both.\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// Test 2: Test Intersect Count with array\nBOOST_AUTO_TEST_CASE(intersectCount_test2)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = intersectCount(source1, 6, source2, 4, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t// Duplicates should not count, so only 2 and 8 are in both.\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 3: Test Intersect Count with array2 larger\nBOOST_AUTO_TEST_CASE(intersectCount_test3)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 200};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = intersectCount(source1, 7, source2, 8, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t// Duplicates should not count, so only 2, 8 and 200 are in both.\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 4: Test Intersect Count with no intersection elements\nBOOST_AUTO_TEST_CASE(intersectCount_test4)\n{\n\tint source1[1] = {1};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = intersectCount(source1, 1, source2, 4, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(count, 0);\n}\n\n// Test 5: Test Intersect Count with same array contents\nBOOST_AUTO_TEST_CASE(intersectCount_test5)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\tint count;\n\tcupcfd::error::eCodes status;\n\tstatus = intersectCount(source1, 4, source2, 4, &count);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t// Arrays are same, so all elements are in intersect\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n//====================== Intersect Array ===========================\n// Test 1: Test Intersect Count with array\nBOOST_AUTO_TEST_CASE(intersectArray_test1)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint * result;\n\tint nResult;\n\tint cmp[2] = {2, 8};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 6, source2, 4, &result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 2, cmp, cmp + 2);\n}\n\n// Test 2: Test Intersect Count with array\nBOOST_AUTO_TEST_CASE(intersectArray_test2)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint * result;\n\tint nResult;\n\tint cmp[3] = {2, 8, 22};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 6, source2, 4, &result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, cmp, cmp + 3);\n}\n\n// Test 3: Test Intersect Count with array2 larger\nBOOST_AUTO_TEST_CASE(intersectArray_test3)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 200};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\n\tint * result;\n\tint nResult;\n\tint cmp[3] = {2, 8, 200};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 7, source2, 8, &result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, cmp, cmp + 3);\n}\n\n// Test 4: Test Intersect Count with no intersection elements\nBOOST_AUTO_TEST_CASE(intersectArray_test4)\n{\n\tint source1[1] = {1};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint * result;\n\tint nResult;\n\tint cmp[0];\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 1, source2, 4, &result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 0);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 0, cmp, cmp + 0);\n}\n\n// Test 5: Test Intersect Count with same array contents\nBOOST_AUTO_TEST_CASE(intersectArray_test5)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint * result;\n\tint nResult;\n\tint cmp[4] = {2, 8, 21, 22};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 4, source2, 4, &result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, cmp, cmp + 4);\n}\n\n// === randomUniform ===\n// ToDo: Is it possible to generate a suitable test for this?\n", "meta": {"hexsha": "fc9787731392be5ad15c6d777bfb57545e7bd33b", "size": 30089, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/utility/interface/component/ArrayDriverTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/utility/interface/component/ArrayDriverTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/utility/interface/component/ArrayDriverTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 32.5991332611, "max_line_length": 111, "alphanum_fraction": 0.6812124032, "num_tokens": 10096, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.35936414516010196, "lm_q2_score": 0.14804720179063333, "lm_q1q2_score": 0.053202856114836064}}
{"text": "#include <stdexcept>\n#include <boost/test/unit_test.hpp>\n#include <initializer_list>\n#include \"composite-shape.hpp\"\n#include \"circle.hpp\"\n#include \"rectangle.hpp\"\n#include \"base-types.hpp\"\n\nconst double epsilon = 0.0000001;\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeConstructor)\n\nBOOST_AUTO_TEST_CASE(ValidParameters_ValidShapeConstructed)\n{\n  const double radius = 34;\n  const gadzhiev::point_t point{ 1, 5 };\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(radius, point));\n  BOOST_CHECK_EQUAL(cmpShape.getSize(), 1);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().x, point.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().y, point.y, epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(ValidInitialisationListParameters_ValidShapeConstructed)\n{\n  const double radius = 34;\n  const gadzhiev::point_t point{ 1, 5 };\n  gadzhiev::CompositeShape cmpShape{ std::make_shared<gadzhiev::Circle>(12, gadzhiev::point_t{ -67, 5 }),\n      std::make_shared<gadzhiev::Circle>(32, gadzhiev::point_t { 24, 5 }),\n      std::make_shared<gadzhiev::Circle>(radius, point),\n      std::make_shared<gadzhiev::Circle>(1, gadzhiev::point_t { 33, 54 }) };\n\n  BOOST_CHECK_EQUAL(cmpShape.getSize(), 4);\n  BOOST_CHECK_CLOSE(cmpShape[2]->getCenter().x, point.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[2]->getCenter().y, point.y, epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(InValidInitialisationListParameters_ThrownInvalidArgument)\n{\n  gadzhiev::Shape::ShapePtr nullptrShape{ nullptr };\n  const double radius = 34;\n  const gadzhiev::point_t point{ 1, 5 };\n\n  BOOST_CHECK_THROW(gadzhiev::CompositeShape cmpShape({ std::make_shared<gadzhiev::Circle>(radius, point),\n      std::make_shared<gadzhiev::Circle>(radius, point),\n      std::make_shared<gadzhiev::Circle>(radius, point),\n      nullptrShape }),\n      std::invalid_argument);\n}\n\nBOOST_AUTO_TEST_CASE(InvalidParameters_ThrownInvalidArument)\n{\n  BOOST_CHECK_THROW(gadzhiev::CompositeShape(nullptr), std::invalid_argument);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeAdd)\n\nBOOST_AUTO_TEST_CASE(AddFigure_FiguresInCmpShape)\n{\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(4, 9, gadzhiev::point_t { 3, 7 });\n\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(32, gadzhiev::point_t { 1, 76 }));\n\n  cmpShape.add(std::make_shared<gadzhiev::Circle>(1, gadzhiev::point_t { -2, 7 }));\n  cmpShape.add(rectangle);\n\n  BOOST_CHECK_EQUAL(cmpShape.getSize(), 3);\n  BOOST_CHECK_EQUAL(cmpShape[2], rectangle);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeRemove)\n\nBOOST_AUTO_TEST_CASE(ValidRemoveFigure_ThereIsNoFigureInCmpShape)\n{\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(11, 13, gadzhiev::point_t { 3, 7 });\n\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(32, gadzhiev::point_t { 1, 76 }));\n\n  cmpShape.add(std::make_shared<gadzhiev::Circle>(1, gadzhiev::point_t{ -2, 7 }));\n  cmpShape.add(rectangle);\n  cmpShape.remove(0);\n  BOOST_CHECK_EQUAL(cmpShape[1], rectangle);\n  BOOST_CHECK_EQUAL(cmpShape.getSize(), 2);\n}\n\nBOOST_AUTO_TEST_CASE(RemoveLastFigure_ThrownLengthError)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(32, gadzhiev::point_t { 1, 76 }));\n  BOOST_CHECK_THROW(cmpShape.remove(0), std::length_error);\n}\n\nBOOST_AUTO_TEST_CASE(InvalidIndexToRemove_ThrownOutOfRange)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(32, gadzhiev::point_t{ 1, 76 }));\n  BOOST_CHECK_THROW(cmpShape.remove(3), std::out_of_range);\n}\nBOOST_AUTO_TEST_SUITE_END()\n\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeIndex)\n\nBOOST_AUTO_TEST_CASE(ValidIndex_ValidGetFigureFromCmpShape)\n{\n  gadzhiev::point_t point{ 3, 7 };\n\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(32, point));\n\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(11, 13, gadzhiev::point_t { 3, 45 });\n  cmpShape.add(rectangle);\n\n  BOOST_CHECK_CLOSE(cmpShape[0]->getCenter().x, point.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[0]->getCenter().y, point.y, epsilon);\n  BOOST_CHECK_EQUAL(cmpShape[1], rectangle);\n}\n\nBOOST_AUTO_TEST_CASE(InvalidIndex_ThrownOutOfRange)\n{\n  gadzhiev::point_t point{ 3, 7 };\n\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(32, gadzhiev::point_t { 1, 76 }));\n\n  std::shared_ptr<gadzhiev::Shape> rectangle = std::make_shared<gadzhiev::Rectangle>(11, 13, point);\n  cmpShape.add(rectangle);\n\n  BOOST_CHECK_THROW(cmpShape[-1], std::out_of_range);\n  BOOST_CHECK_THROW(cmpShape[2], std::out_of_range);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeMove)\n\nBOOST_AUTO_TEST_CASE(ValidMoveDxDy_CmpShapeCenterValidMoved)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(23, gadzhiev::point_t { -3, 8 }));\n  const int dx = 4;\n  const int dy = 9;\n  cmpShape.move(dx, dy);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().x, -3 + dx, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().y, 8 + dy, epsilon);\n\n  const int dxZero = 0;\n  const int dyZero = 0;\n  const gadzhiev::point_t previousCenter = cmpShape.getCenter();\n  cmpShape.move(dxZero, dyZero);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().x, previousCenter.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().y, previousCenter.y, epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(ValidMoveToPoint_CmpShapeCenterValidMoved)\n{\n  const gadzhiev::point_t center{ 2, 2 };\n  const gadzhiev::point_t secondCenter{ 4, 4 };\n\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(2, center));\n  cmpShape.add(std::make_shared<gadzhiev::Circle>(2, secondCenter));\n\n  gadzhiev::point_t previousCenter{ cmpShape.getCenter() };\n  gadzhiev::point_t newCenter{ 7, 5 };\n\n  cmpShape.move(newCenter);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().x, newCenter.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().y, newCenter.y, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[0]->getCenter().x, center.x + cmpShape.getCenter().x - previousCenter.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[0]->getCenter().y, center.y + cmpShape.getCenter().y - previousCenter.y, epsilon);\n\n  gadzhiev::point_t newCenterInZero{ 0, 0 };\n  cmpShape.move(newCenterInZero);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().x, newCenterInZero.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getCenter().y, newCenterInZero.y, epsilon);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeFrameRectangle)\n\nBOOST_AUTO_TEST_CASE(FrameRectangle_ValidWidthHeightCenterOfRectangle)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(10, gadzhiev::point_t { 1, 20 }));\n\n  gadzhiev::rectangle_t rectangleStruct = cmpShape.getFrameRect();\n  BOOST_CHECK_CLOSE(rectangleStruct.height, 20, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.width, 20, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.pos.x, 1, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.pos.y, 20, epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(FrameRectangleAfterAdd_ValidWidthHeightCenterOfRectangle)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(2, gadzhiev::point_t { 4, 6 }));\n  cmpShape.add(std::make_shared<gadzhiev::Rectangle>(7, 5, gadzhiev::point_t { -1, 2 }));\n\n  gadzhiev::rectangle_t rectangleStruct = cmpShape.getFrameRect();\n  BOOST_CHECK_CLOSE(rectangleStruct.height, 8.5, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.width, 10.5, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.pos.x, 0.75, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.pos.y, 3.75, epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(FrameRectangleAfterScale_ValidWidthHeightCenterOfRectangle)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Circle>(10, gadzhiev::point_t { 1, 32 }));\n\n  const double scaleCoef = 3.7;\n  cmpShape.scale(scaleCoef);\n  gadzhiev::rectangle_t rectangleStruct = cmpShape.getFrameRect();\n\n  BOOST_CHECK_CLOSE(rectangleStruct.height, 20 * scaleCoef, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.width, 20 * scaleCoef, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.pos.x, 1, epsilon);\n  BOOST_CHECK_CLOSE(rectangleStruct.pos.y, 32, epsilon);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeScale)\n\nBOOST_AUTO_TEST_CASE(InvalidScale_CoefLessThanZeroOrZero_ThrownInvalidArgument)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Rectangle>(13, 34, gadzhiev::point_t { -5, 18 }));\n  BOOST_CHECK_THROW(cmpShape.scale(0), std::invalid_argument);\n  BOOST_CHECK_THROW(cmpShape.scale(-12), std::invalid_argument);\n}\n\nBOOST_AUTO_TEST_CASE(ValidScale_CoefMoreThanZero_CmpShapeValidScaled)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Rectangle>(2, 2, gadzhiev::point_t { 1, 3 }));\n  cmpShape.add(std::make_shared<gadzhiev::Rectangle>(4, 4, gadzhiev::point_t{ 3.5, 0.5 }));\n\n  gadzhiev::rectangle_t rectangleStruct = cmpShape.getFrameRect();\n\n  const double scaleCoef = 0.65;\n  cmpShape.scale(scaleCoef);\n\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().height, rectangleStruct.height * scaleCoef, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().width, rectangleStruct.width * scaleCoef, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().pos.x, rectangleStruct.pos.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().pos.y, rectangleStruct.pos.y, epsilon);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeArea)\n\nBOOST_AUTO_TEST_CASE(DefaultArea_ValidGetArea)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Rectangle>(13, 34, gadzhiev::point_t{ -5, 18 }));\n  BOOST_CHECK_CLOSE(cmpShape.getArea(), 13 * 34, 0.0000001);\n}\n\nBOOST_AUTO_TEST_CASE(AreaAfterAddingFigures_ValidGetArea)\n{\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(21, 4, gadzhiev::point_t{ -5, 18 });\n  gadzhiev::Shape::ShapePtr circle = std::make_shared<gadzhiev::Circle>(12, gadzhiev::point_t{ 1, 6 });\n  gadzhiev::Shape::ShapePtr secondCircle = std::make_shared<gadzhiev::Circle>(10, gadzhiev::point_t{ -1, 3 });\n\n  gadzhiev::CompositeShape cmpShape(rectangle);\n  cmpShape.add(circle);\n  cmpShape.add(secondCircle);\n\n  const double areaOfFirstFigure = rectangle->getArea();\n  const double areaOfSecondFigure = circle->getArea();\n  const double areaOfThirdFigure = secondCircle->getArea();\n\n  BOOST_CHECK_CLOSE(cmpShape.getArea(), areaOfFirstFigure + areaOfSecondFigure + areaOfThirdFigure, 0.0000001);\n}\n\nBOOST_AUTO_TEST_CASE(AreaAfterMoving_AreaNotChanged)\n{\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(21, 4, gadzhiev::point_t{ -5, 18 });\n  gadzhiev::CompositeShape cmpShape(rectangle);\n\n  const gadzhiev::point_t newCenter{ 12, -33 };\n  const double dx = 6;\n  const double dy = -34;\n  const double area = cmpShape.getArea();\n\n  cmpShape.move(dx, dy);\n\n  BOOST_CHECK_CLOSE(cmpShape.getArea(), area, epsilon);\n\n  cmpShape.move(newCenter);\n\n  BOOST_CHECK_CLOSE(cmpShape.getArea(), area, epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(AreaAfterScale_AreaChangedToSquaredCoef)\n{\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(21, 4, gadzhiev::point_t{ -5, 18 });\n  gadzhiev::Shape::ShapePtr circle = std::make_shared<gadzhiev::Circle>(12, gadzhiev::point_t{ 1, 6 });\n  gadzhiev::Shape::ShapePtr secondCircle = std::make_shared<gadzhiev::Circle>(10, gadzhiev::point_t{ -1, 3 });\n\n  gadzhiev::CompositeShape cmpShape(rectangle);\n  cmpShape.add(circle);\n  cmpShape.add(secondCircle);\n\n  const double FirstShapeArea = rectangle->getArea();\n  const double SecondShapeArea = circle->getArea();\n  const double ThirdShapeArea = secondCircle->getArea();\n\n  const double scaleCoef = 1.4;\n  cmpShape.scale(scaleCoef);\n  BOOST_CHECK_CLOSE(cmpShape.getArea(), scaleCoef * scaleCoef * (FirstShapeArea + SecondShapeArea + ThirdShapeArea), epsilon);\n}\n\nBOOST_AUTO_TEST_CASE(AreaAfterRotate_AreaNotChanged)\n{\n  gadzhiev::Shape::ShapePtr rectangle = std::make_shared<gadzhiev::Rectangle>(21, 4, gadzhiev::point_t{ -5, 18 });\n  gadzhiev::CompositeShape cmpShape(rectangle);\n\n  const double rotateCoef = 45;\n  const double area = cmpShape.getArea();\n\n  cmpShape.rotate(rotateCoef);\n\n  BOOST_CHECK_CLOSE(cmpShape.getArea(), area, epsilon);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\n\nBOOST_AUTO_TEST_SUITE(CompositeShapeRotate)\n\nBOOST_AUTO_TEST_CASE(CmpShapeRotate_ValidParametersOfFiguresAndValidFrameRect)\n{\n  gadzhiev::CompositeShape cmpShape(std::make_shared<gadzhiev::Rectangle>(4, 4, gadzhiev::point_t{ 2, 7 }));\n  cmpShape.add(std::make_shared<gadzhiev::Rectangle>(2, 6, gadzhiev::point_t{ 3, 3 }));\n\n  gadzhiev::rectangle_t rectangleStruct = cmpShape.getFrameRect();\n\n  const double rotateCoef = 90;\n  cmpShape.rotate(rotateCoef);\n\n  BOOST_CHECK_CLOSE(cmpShape[0]->getCenter().x, -0.5, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[0]->getCenter().y, 4.5, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[1]->getCenter().x, 3.5, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape[1]->getCenter().y, 5.5, epsilon);\n\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().width, 9, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().height, 4, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().width, 9, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().pos.x, rectangleStruct.pos.x, epsilon);\n  BOOST_CHECK_CLOSE(cmpShape.getFrameRect().pos.y, rectangleStruct.pos.y, epsilon);\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "6c07879857882022fbf403883ffa20b69b5c3c2e", "size": 13173, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "508 - A4-spbspu-labs-2020-904-3/2/common/test-composite-shape.cpp", "max_stars_repo_name": "NekoSilverFox/CPP", "max_stars_repo_head_hexsha": "c6797264fceda4a65ac3452acca496e468d1365a", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5.0, "max_stars_repo_stars_event_min_datetime": "2020-02-08T20:57:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-23T06:24:41.000Z", "max_issues_repo_path": "508 - A4-spbspu-labs-2020-904-3/2/common/test-composite-shape.cpp", "max_issues_repo_name": "NekoSilverFox/CPP", "max_issues_repo_head_hexsha": "c6797264fceda4a65ac3452acca496e468d1365a", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2020-03-02T14:44:55.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-11T16:25:33.000Z", "max_forks_repo_path": "508 - A4-spbspu-labs-2020-904-3/2/common/test-composite-shape.cpp", "max_forks_repo_name": "NekoSilverFox/CPP", "max_forks_repo_head_hexsha": "c6797264fceda4a65ac3452acca496e468d1365a", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4.0, "max_forks_repo_forks_event_min_datetime": "2020-09-27T17:30:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-16T09:48:23.000Z", "avg_line_length": 37.3172804533, "max_line_length": 126, "alphanum_fraction": 0.7663402414, "num_tokens": 3715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4843800842769844, "lm_q2_score": 0.10970578406578958, "lm_q1q2_score": 0.053139296931459815}}
{"text": "#include \"testsuite.h\"\n#include <blitz/array.h>\n\nBZ_USING_NAMESPACE(blitz)\n\nint main()\n{\n    Array<int,1> A(1);\n    A(0) = 5;\n    Array<int,1> B(1);\n    B = A;\n}\n\n", "meta": {"hexsha": "adfa2bf1cf65cb4f1b8dac99a2eb2ffcbeb95133", "size": 163, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "depspawn-blitz-0.10/testsuite/copy.cpp", "max_stars_repo_name": "fraguela/depspawn", "max_stars_repo_head_hexsha": "b5760f4c0d38a1b245ee5274e2ccc5c5fe2d3d45", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8.0, "max_stars_repo_stars_event_min_datetime": "2017-04-12T11:05:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:10:27.000Z", "max_issues_repo_path": "ibtk/third_party/blitz-0.10/testsuite/copy.cpp", "max_issues_repo_name": "MSV-Project/IBAMR", "max_issues_repo_head_hexsha": "3cf614c31bb3c94e2620f165ba967cba719c45ea", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ibtk/third_party/blitz-0.10/testsuite/copy.cpp", "max_forks_repo_name": "MSV-Project/IBAMR", "max_forks_repo_head_hexsha": "3cf614c31bb3c94e2620f165ba967cba719c45ea", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 11.6428571429, "max_line_length": 25, "alphanum_fraction": 0.5644171779, "num_tokens": 60, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.48438008427698437, "lm_q2_score": 0.10970577096716554, "lm_q1q2_score": 0.053139290586747184}}
{"text": "/**\n * \\file libs/numeric/ublasx/hold.cpp\n *\n * \\brief Test the \\c hold operation.\n *\n * Copyright (c) 2010, Marco Guazzone\n *\n * Distributed under the Boost Software License, Version 1.0. (See\n * accompwhiching file LICENSE_1_0.txt or copy at\n * http://www.boost.org/LICENSE_1_0.txt)\n *\n * \\author Marco Guazzone, marco.guazzone@gmail.com\n */\n\n#include <boost/numeric/ublas/fwd.hpp>\n#include <boost/numeric/ublas/io.hpp>\n#include <boost/numeric/ublas/matrix.hpp>\n#include <boost/numeric/ublas/matrix_expression.hpp>\n#include <boost/numeric/ublas/vector.hpp>\n#include <boost/numeric/ublas/vector_expression.hpp>\n#include <boost/numeric/ublasx/detail/debug.hpp>\n#include <boost/numeric/ublasx/operation/hold.hpp>\n#include <boost/numeric/ublasx/tags.hpp>\n#include <cstddef>\n#include <functional>\n#include <iostream>\n#include \"libs/numeric/ublasx/test/utils.hpp\"\n\n\nstatic const double tol = 1.0e-5;\n\n\nnamespace ublas = ::boost::numeric::ublas;\nnamespace ublasx = ::boost::numeric::ublasx;\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_container )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Vector Container\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\ttypedef ublas::zero_vector<value_type> zero_vector_type;\n\ttypedef ublas::vector<bool> out_vector_type;\n\n\tconst std::size_t n = 5;\n\n\tvector_type v(n);\n\n\tv(0) = 0.0;\n\tv(1) = 0.108929;\n\tv(2) = 0.0;\n\tv(3) = 0.0;\n\tv(4) = 1.023787;\n\n\tzero_vector_type z(n);\n\n\tvalue_type val(0);\n\tout_vector_type expect;\n\tout_vector_type res;\n\n\n\t// hold(z)\n\tBOOST_UBLASX_DEBUG_TRACE( \"NOTE: Expect to fail cause ublas::vector_assign assume the value type is a floating point\" );\n\texpect = out_vector_type(n, false);\n\tres = ublasx::hold(z);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << z << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n\n\tBOOST_UBLASX_DEBUG_TRACE( \"HERE.2\" );\n\t// hold(v)\n\texpect = out_vector_type(n);\n\tfor (std::size_t i = 0; i < n; ++i)\n\t{\n\t\texpect(i) = v(i) != 0;\n\t}\n\tres = ublasx::hold(v);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << v << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n\n\tBOOST_UBLASX_DEBUG_TRACE( \"HERE.3\" );\n\t// hold(v, > .5)\n\tval = 0.5;\n\texpect = out_vector_type(n);\n\tfor (std::size_t i = 0; i < n; ++i)\n\t{\n\t\texpect(i) = v(i) > val;\n\t}\n\tres = ublasx::hold(v, ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << v << \", > \" << val << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_expression )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Vector Expression\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\ttypedef ublas::vector<bool> out_vector_type;\n\n\tconst std::size_t n = 5;\n\n\tvector_type v(n);\n\n\tv(0) = 0.0;\n\tv(1) = 0.108929;\n\tv(2) = 0.0;\n\tv(3) = 0.0;\n\tv(4) = 1.023787;\n\n\tvalue_type val(0);\n\tout_vector_type expect;\n\tout_vector_type res;\n\n\n\t// hold(-v)\n\texpect = out_vector_type(n);\n\tfor (std::size_t i = 0; i < n; ++i)\n\t{\n\t\texpect(i) = (-v(i)) != 0;\n\t}\n\tres = ublasx::hold(-v);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << -v << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n\n\t// hold(-v, > -.5)\n\tval = -0.5;\n\texpect = out_vector_type(n);\n\tfor (std::size_t i = 0; i < n; ++i)\n\t{\n\t\texpect(i) = (-v(i)) > val;\n\t}\n\tres = ublasx::hold(-v, ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << -v << \", > \" << val << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_vector_reference )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Vector Reference\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::vector<value_type> vector_type;\n\ttypedef ublas::vector_reference<vector_type> vector_reference_type;\n\ttypedef ublas::vector<bool> out_vector_type;\n\n\tconst std::size_t n = 5;\n\n\tvector_type v(n);\n\n\tv(0) = 0.0;\n\tv(1) = 0.108929;\n\tv(2) = 0.0;\n\tv(3) = 0.0;\n\tv(4) = 1.023787;\n\n\n\tvalue_type val(0);\n\tout_vector_type expect;\n\tout_vector_type res;\n\n\t// hold(ref(v))\n\texpect = out_vector_type(n);\n\tfor (std::size_t i = 0; i < n; ++i)\n\t{\n\t\texpect(i) = v(i) != 0;\n\t}\n\tres = ublasx::hold(vector_reference_type(v));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << vector_reference_type(v) << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n\n\t// which(ref(v), > .5)\n\tval = 0.5;\n\texpect = out_vector_type(n);\n\tfor (std::size_t i = 0; i < n; ++i)\n\t{\n\t\texpect(i) = v(i) > val;\n\t}\n\tres = ublasx::hold(vector_reference_type(v), ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << vector_reference_type(v) << \", > \" << val << \") = \" << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_VECTOR_EQ( res, expect, n );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_row_major_matrix_container )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Row-major Matrix Container\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type, ublas::row_major> matrix_type;\n\ttypedef ublas::zero_matrix<value_type, ublas::row_major> zero_matrix_type;\n\ttypedef ublas::matrix<bool, ublas::row_major> out_matrix_type;\n\n\tconst std::size_t nr(5);\n\tconst std::size_t nc(4);\n\n\tmatrix_type A(nr,nc);\n\n\tA(0,0) = 0.0;      A(0,1) = 0.274690; A(0,2) = 0.0;      A(0,3) = 0.798938;\n\tA(1,0) = 0.108929; A(1,1) = 0.0;      A(1,2) = 0.891726; A(1,3) = 0.0;\n\tA(2,0) = 0.0;      A(2,1) = 0.0;      A(2,2) = 0.0;      A(2,3) = 0.0;\n\tA(3,0) = 0.0;      A(3,1) = 0.675382; A(3,2) = 0.0;      A(3,3) = 0.450332;\n\tA(4,0) = 1.023787; A(4,1) = 1.0;      A(4,2) = 1.231751; A(4,3) = 1.0;\n\n\tzero_matrix_type Z(nr, nc);\n\n\tvalue_type val(0);\n\tout_matrix_type expect;\n\tout_matrix_type res;\n\n\n\t// hold(Z)\n\texpect = out_matrix_type(nr, nc, false);\n\tres = ublasx::hold(Z);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << Z << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n\n\t// hold(A)\n\texpect = out_matrix_type(nr, nc);\n\tfor (std::size_t r = 0; r < nr; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(r,c) != 0;\n\t\t}\n\t}\n\tres = ublasx::hold(A);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << A << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n\n\t// hold(A, > .5)\n\tval = 0.5;\n\texpect = out_matrix_type(nr, nc);\n\tfor (std::size_t r = 0; r < nr; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(r,c) > val;\n\t\t}\n\t}\n\tres = ublasx::hold(A, ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << A << \", > \" << val << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_column_major_matrix_container )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Column-major Matrix Container\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type, ublas::column_major> matrix_type;\n\ttypedef ublas::zero_matrix<value_type, ublas::column_major> zero_matrix_type;\n\ttypedef ublas::matrix<bool, ublas::column_major> out_matrix_type;\n\n\tconst std::size_t nr(5);\n\tconst std::size_t nc(4);\n\n\tmatrix_type A(nr,nc);\n\n\tA(0,0) = 0.0;      A(0,1) = 0.274690; A(0,2) = 0.0;      A(0,3) = 0.798938;\n\tA(1,0) = 0.108929; A(1,1) = 0.0;      A(1,2) = 0.891726; A(1,3) = 0.0;\n\tA(2,0) = 0.0;      A(2,1) = 0.0;      A(2,2) = 0.0;      A(2,3) = 0.0;\n\tA(3,0) = 0.0;      A(3,1) = 0.675382; A(3,2) = 0.0;      A(3,3) = 0.450332;\n\tA(4,0) = 1.023787; A(4,1) = 1.0;      A(4,2) = 1.231751; A(4,3) = 1.0;\n\n\tzero_matrix_type Z(nr, nc);\n\n\tvalue_type val(0);\n\tout_matrix_type expect;\n\tout_matrix_type res;\n\n\n\t// hold(Z)\n\texpect = out_matrix_type(nr, nc, false);\n\tres = ublasx::hold(Z);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << Z << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n\n\t// hold(A)\n\texpect = out_matrix_type(nr, nc);\n\tfor (std::size_t r = 0; r < nr; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(r,c) != 0;\n\t\t}\n\t}\n\tres = ublasx::hold(A);\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << A << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n\n\t// hold(A, > .5)\n\tval = 0.5;\n\texpect = out_matrix_type(nr, nc);\n\tfor (std::size_t r = 0; r < nr; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(r,c) > val;\n\t\t}\n\t}\n\tres = ublasx::hold(A, ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << A << \", > \" << val << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_expression )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Matrix Expression\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\ttypedef ublas::matrix<bool, ublas::column_major> out_matrix_type;\n\n\tconst std::size_t nr(5);\n\tconst std::size_t nc(4);\n\n\tmatrix_type A(nr,nc);\n\n\tA(0,0) = 0.0;      A(0,1) = 0.274690; A(0,2) = 0.0;      A(0,3) = 0.798938;\n\tA(1,0) = 0.108929; A(1,1) = 0.0;      A(1,2) = 0.891726; A(1,3) = 0.0;\n\tA(2,0) = 0.0;      A(2,1) = 0.0;      A(2,2) = 0.0;      A(2,3) = 0.0;\n\tA(3,0) = 0.0;      A(3,1) = 0.675382; A(3,2) = 0.0;      A(3,3) = 0.450332;\n\tA(4,0) = 1.023787; A(4,1) = 1.0;      A(4,2) = 1.231751; A(4,3) = 1.0;\n\n\tvalue_type val(0);\n\tout_matrix_type expect;\n\tout_matrix_type res;\n\n\n\t// all(A')\n\texpect = out_matrix_type(nc, nr);\n\tfor (std::size_t r = 0; r < nc; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nr; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(c,r) != 0;\n\t\t}\n\t}\n\tres = ublasx::hold(ublas::trans(A));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << A << \"') = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nc, nr );\n\n\t// hold(A', > .5)\n\tval = 0.5;\n\texpect = out_matrix_type(nc, nr);\n\tfor (std::size_t r = 0; r < nc; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nr; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(c,r) > val;\n\t\t}\n\t}\n\tres = ublasx::hold(ublas::trans(A), ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(\" << A << \"', > \" << val << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nc, nr );\n}\n\n\nBOOST_UBLASX_TEST_DEF( test_matrix_reference )\n{\n\tBOOST_UBLASX_DEBUG_TRACE( \"TEST Matrix Reference\" );\n\n\ttypedef double value_type;\n\ttypedef ublas::matrix<value_type> matrix_type;\n\ttypedef ublas::matrix_reference<matrix_type> matrix_reference_type;\n\ttypedef ublas::matrix<bool, ublas::column_major> out_matrix_type;\n\n\tconst std::size_t nr(5);\n\tconst std::size_t nc(4);\n\n\tmatrix_type A(nr,nc);\n\n\tA(0,0) = 0.0;      A(0,1) = 0.274690; A(0,2) = 0.0;      A(0,3) = 0.798938;\n\tA(1,0) = 0.108929; A(1,1) = 0.0;      A(1,2) = 0.891726; A(1,3) = 0.0;\n\tA(2,0) = 0.0;      A(2,1) = 0.0;      A(2,2) = 0.0;      A(2,3) = 0.0;\n\tA(3,0) = 0.0;      A(3,1) = 0.675382; A(3,2) = 0.0;      A(3,3) = 0.450332;\n\tA(4,0) = 1.023787; A(4,1) = 1.0;      A(4,2) = 1.231751; A(4,3) = 1.0;\n\n\tvalue_type val(0);\n\tout_matrix_type expect;\n\tout_matrix_type res;\n\n\n\t// hold(ref(A))\n\texpect = out_matrix_type(nr, nc);\n\tfor (std::size_t r = 0; r < nr; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(r,c) != 0;\n\t\t}\n\t}\n\tres = ublasx::hold(matrix_reference_type(A));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(reference(\" << A << \")) = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n\n\t// hold(ref(A), > .5)\n\tval = 0.5;\n\texpect = out_matrix_type(nr, nc);\n\tfor (std::size_t r = 0; r < nr; ++r)\n\t{\n\t\tfor (std::size_t c = 0; c < nc; ++c)\n\t\t{\n\t\t\texpect(r,c) = A(r,c) > val;\n\t\t}\n\t}\n\tres = ublasx::hold(matrix_reference_type(A), ::std::bind2nd(::std::greater<value_type>(), val));\n\tBOOST_UBLASX_DEBUG_TRACE( \"hold(reference(\" << A << \"), > \" << val << \") = \" << ::std::boolalpha << res << \" ==> \" << expect );\n\tBOOST_UBLASX_TEST_CHECK_MATRIX_EQ( res, expect, nr, nc );\n}\n\n\nint main()\n{\n\tBOOST_UBLASX_DEBUG_TRACE(\"Test Suite: 'hold' operation\");\n\n\tBOOST_UBLASX_TEST_BEGIN();\n\n\tBOOST_UBLASX_TEST_DO( test_vector_container );\n\tBOOST_UBLASX_TEST_DO( test_vector_expression );\n\tBOOST_UBLASX_TEST_DO( test_vector_reference );\n\tBOOST_UBLASX_TEST_DO( test_row_major_matrix_container );\n\tBOOST_UBLASX_TEST_DO( test_column_major_matrix_container );\n\tBOOST_UBLASX_TEST_DO( test_matrix_expression );\n\tBOOST_UBLASX_TEST_DO( test_matrix_reference );\n\n\tBOOST_UBLASX_TEST_END();\n}\n", "meta": {"hexsha": "c8b494724283f2f24db81c4494a3294c5c4d918f", "size": 12506, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/numeric/ublasx/test/hold.cpp", "max_stars_repo_name": "comcon1/boost-ublasx", "max_stars_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "libs/numeric/ublasx/test/hold.cpp", "max_issues_repo_name": "comcon1/boost-ublasx", "max_issues_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/numeric/ublasx/test/hold.cpp", "max_forks_repo_name": "comcon1/boost-ublasx", "max_forks_repo_head_hexsha": "290b92b643a944825df99bece3468a4f81518056", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7494252874, "max_line_length": 128, "alphanum_fraction": 0.6153046538, "num_tokens": 4585, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.45713671682749485, "lm_q2_score": 0.11596072894699293, "lm_q1q2_score": 0.05300990691175139}}
{"text": "// Boost.Geometry (aka GGL, Generic Geometry Library)\r\n// Unit Test\r\n\r\n// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.\r\n// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.\r\n// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.\r\n\r\n// Use, modification and distribution is subject to the Boost Software License,\r\n// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n\r\n#include <sstream>\r\n\r\n#include <geometry_test_common.hpp>\r\n\r\n#include <boost/geometry/geometries/geometries.hpp>\r\n#include <boost/geometry/multi/io/dsv/write.hpp>\r\n#include <boost/geometry/multi/geometries/multi_geometries.hpp>\r\n#include <boost/geometry/multi/io/wkt/read.hpp>\r\n\r\ntemplate <typename Geometry>\r\nvoid test_dsv(std::string const& wkt, std::string const& expected, bool json = false)\r\n{\r\n    Geometry geometry;\r\n    bg::read_wkt(wkt, geometry);\r\n    std::ostringstream out;\r\n    if (json)\r\n    {\r\n        out << bg::dsv(geometry, \", \", \"[\", \"]\", \", \", \"[ \", \" ]\", \", \");\r\n    }\r\n    else\r\n    {\r\n        out << bg::dsv(geometry);\r\n    }\r\n    BOOST_CHECK_EQUAL(out.str(), expected);\r\n}\r\n\r\n\r\ntemplate <typename T>\r\nvoid test_all()\r\n{\r\n    using namespace boost::geometry;\r\n    typedef model::point<T, 2, cs::cartesian> point_type;\r\n    typedef model::multi_point<point_type> mpoint;\r\n    typedef model::multi_linestring<model::linestring<point_type> > mline;\r\n    typedef model::multi_polygon<model::polygon<point_type> > mpoly;\r\n\r\n    test_dsv<mpoint>\r\n        (\r\n            \"multipoint((1 2),(3 4))\",\r\n            \"((1, 2), (3, 4))\"\r\n        );\r\n    test_dsv<mline>\r\n        (\r\n            \"multilinestring((1 1,2 2,3 3),(4 4,5 5,6 6))\",\r\n            \"(((1, 1), (2, 2), (3, 3)), ((4, 4), (5, 5), (6, 6)))\"\r\n        );\r\n    test_dsv<mpoly>\r\n        (\r\n            // Multi with 2 poly's, first has hole, second is triangle\r\n            \"multipolygon(((0 0,0 4,4 4,4 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((5 5,6 5,5 6,5 5)))\",\r\n            \"((((0, 0), (0, 4), (4, 4), (4, 0), (0, 0)), ((1, 1), (1, 2), (2, 2), (2, 1), (1, 1))), (((5, 5), (6, 5), (5, 6), (5, 5))))\"\r\n        );\r\n\r\n    // http://geojson.org/geojson-spec.html#id5\r\n    test_dsv<mpoint>\r\n        (\r\n            \"multipoint((1 2),(3 4))\",\r\n            \"[ [1, 2], [3, 4] ]\",\r\n            true\r\n        );\r\n\r\n    // http://geojson.org/geojson-spec.html#id6\r\n    test_dsv<mline>\r\n        (\r\n            \"multilinestring((1 1,2 2,3 3),(4 4,5 5,6 6))\",\r\n            \"[ [ [1, 1], [2, 2], [3, 3] ], [ [4, 4], [5, 5], [6, 6] ] ]\",\r\n            true\r\n        );\r\n\r\n    // http://geojson.org/geojson-spec.html#id7\r\n    test_dsv<mpoly>\r\n        (\r\n            \"multipolygon(((0 0,0 4,4 4,4 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((5 5,6 5,5 6,5 5)))\",\r\n            \"[ [ [ [0, 0], [0, 4], [4, 4], [4, 0], [0, 0] ], [ [1, 1], [1, 2], [2, 2], [2, 1], [1, 1] ] ], [ [ [5, 5], [6, 5], [5, 6], [5, 5] ] ] ]\",\r\n            true\r\n        );\r\n\r\n}\r\n\r\n\r\nint test_main(int, char* [])\r\n{\r\n    test_all<double>();\r\n    test_all<int>();\r\n\r\n    return 0;\r\n}\r\n\r\n", "meta": {"hexsha": "8b3382cb29c047ba7297645b844584e28b52e9bd", "size": 3044, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "libs/geometry/test/io/dsv/multi_dsv.cpp", "max_stars_repo_name": "Abce/boost", "max_stars_repo_head_hexsha": "2d7491a27211aa5defab113f8e2d657c3d85ca93", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 85.0, "max_stars_repo_stars_event_min_datetime": "2015-02-08T20:36:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T20:38:31.000Z", "max_issues_repo_path": "libs/boost/libs/geometry/test/multi/io/dsv/multi_dsv.cpp", "max_issues_repo_name": "flingone/frameworks_base_cmds_remoted", "max_issues_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 9.0, "max_issues_repo_issues_event_min_datetime": "2015-01-28T16:33:19.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-12T23:03:28.000Z", "max_forks_repo_path": "libs/boost/libs/geometry/test/multi/io/dsv/multi_dsv.cpp", "max_forks_repo_name": "flingone/frameworks_base_cmds_remoted", "max_forks_repo_head_hexsha": "4509d9f0468137ed7fd8d100179160d167e7d943", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 27.0, "max_forks_repo_forks_event_min_datetime": "2015-01-28T16:33:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-12T05:04:39.000Z", "avg_line_length": 30.1386138614, "max_line_length": 150, "alphanum_fraction": 0.5045992116, "num_tokens": 1079, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4571367168274948, "lm_q2_score": 0.11596071214366648, "lm_q1q2_score": 0.0530098992303339}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n */\n\n#define BOOST_TEST_MODULE SparseMatrixHDF5File\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n#include \"mpi.h\"\n\n#include \"SparseMatrixHDF5File.h\"\n#include \"Error.h\"\n#include \"Communicator.h\"\n#include \"SparseMatrixCOO.h\"\n\nusing namespace cupcfd::fileformats::matrices;\n\n// These tests require MPI\nBOOST_AUTO_TEST_CASE(setup)\n{\n    int argc = boost::unit_test::framework::master_test_suite().argc;\n    char ** argv = boost::unit_test::framework::master_test_suite().argv;\n    MPI_Init(&argc, &argv);\n}\n\n// === Constructor ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(constructor_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int ,double> file(fileName);\n\t}\n}\n\n// === getNNZ ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getNNZ_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\tint nnz;\n\t\tstatus = file.getNNZ(&nnz);\n\t\tBOOST_CHECK_EQUAL(nnz, 24);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n}\n\n// === getNRows ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getNRows_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\tint nRows;\n\t\tstatus = file.getNRows(&nRows);\n\t\tBOOST_CHECK_EQUAL(nRows, 8);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n}\n\n// === getNCols ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getNCols_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\tint nCols;\n\t\tstatus = file.getNCols(&nCols);\n\t\tBOOST_CHECK_EQUAL(nCols, 8);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n}\n\n// === getMatrixIndicesBase ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getMatrixIndicesBase_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\tint base;\n\t\tstatus = file.getMatrixIndicesBase(&base);\n\t\tBOOST_CHECK_EQUAL(base, 1);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n}\n\n// === getNNZRows ===\n// Test 1:\nBOOST_AUTO_TEST_CASE(getNNZRows_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\t// This test file is known in advance to have 8 rows\n\t\tint * nnzRows = (int *) malloc(sizeof(int) * 8);\n\t\tstatus = file.getNNZRows(nnzRows, 8);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\tint cmp[8] = {3, 3, 3, 3, 3, 3, 4, 2};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, nnzRows, nnzRows + 8);\n\t}\n}\n\n// === getSparseMatrix (All) ===\n// Test 1: Test we can read into a matrix with the correct values for a base 0 Sparsematrix object\nBOOST_AUTO_TEST_CASE(getSparseMatrix_full_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\t\t// Test and Check\n\t\tstatus = file.getSparseMatrix(matrix);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Should probably use the matrix functions for this test, but can just check on\n\t\t// internal data structures for now\n\t\tint rowCmp[24] = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7};\n\t\tint colCmp[24] = {0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 4, 5, 6, 7, 6, 7};\n\t\tdouble valCmp[24] = {0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4};\n\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(rowCmp, rowCmp + 24, &matrix.row[0], &matrix.row[0] + 24);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(colCmp, colCmp + 24, &matrix.col[0], &matrix.col[0] + 24);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(valCmp, valCmp + 24, &matrix.val[0], &matrix.val[0] + 24);\n\t}\n}\n\n// Test 1: Test we can read into a matrix with the correct values for a base 4 SparseMatrix object\nBOOST_AUTO_TEST_CASE(getSparseMatrix_full_test2)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\n\t\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 4);\n\n\t\t// Test and Check\n\t\tstatus = file.getSparseMatrix(matrix);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Should probably use the matrix functions for this test, but can just check on\n\t\t// internal data structures for now\n\t\tint rowCmp[24] = {4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11};\n\t\tint colCmp[24] = {4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10, 9, 10, 11, 8, 9, 10, 11, 10, 11};\n\t\tdouble valCmp[24] = {0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4};\n\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(rowCmp, rowCmp + 24, &matrix.row[0], &matrix.row[0] + 24);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(colCmp, colCmp + 24, &matrix.col[0], &matrix.col[0] + 24);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(valCmp, valCmp + 24, &matrix.val[0], &matrix.val[0] + 24);\n\t}\n}\n\n// === getSparseMatrix (Partial) ===\n//ToDo: The multile pranges aspect has the potential for a lot of edge cases.\n// This will probably need more expansive testing - this one test tries too many things at once\n// Test 1:\nBOOST_AUTO_TEST_CASE(getSparseMatrix_partial_test1)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\t// === Setup ===\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\t\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 4);\n\n\t\t// Speciy which rows we want\n\t\tint desiredRows[4] = {2, 3, 5, 7};\n\n\t\t// === Test and Check ===\n\t\tstatus = file.getSparseMatrix(matrix, desiredRows, 4, 1);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Should probably use the matrix functions for this test, but can just check on\n\t\t// internal data structures for now\n\t\tint rowCmp[13] = {5, 5, 5, 6, 6, 6, 8, 8, 8, 10, 10, 10, 10};\n\t\tint colCmp[13] = {5, 6, 7, 6, 7, 8, 8, 9, 10, 8, 9, 10, 11};\n\t\tdouble valCmp[13] = {0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.1, 0.2, 0.3, 0.3, 0.4, 0.1, 0.2};\n\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(rowCmp, rowCmp + 13, &matrix.row[0], &matrix.row[0] + 13);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(colCmp, colCmp + 13, &matrix.col[0], &matrix.col[0] + 13);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(valCmp, valCmp + 13, &matrix.val[0], &matrix.val[0] + 13);\n\t}\n}\n\n// Test 2: Single row\nBOOST_AUTO_TEST_CASE(getSparseMatrix_partial_test2)\n{\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\tcupcfd::error::eCodes status;\n\n\tif(comm.rank == 0)\n\t{\n\t\t// === Setup ===\n\t\tstd::string fileName = \"../tests/testdata/Matrix1SparseCOO.h5\";\n\t\tSparseMatrixHDF5File<int, double> file(fileName);\n\t\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 4);\n\n\t\t// Speciy which rows we want\n\t\tint desiredRows[1] = {5};\n\n\t\t// === Test and Check ===\n\t\tstatus = file.getSparseMatrix(matrix, desiredRows, 1, 2);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t\t// Should probably use the matrix functions for this test, but can just check on\n\t\t// internal data structures for now\n\t\tint rowCmp[3] = {7, 7, 7};\n\t\tint colCmp[3] = {7, 8, 9};\n\t\tdouble valCmp[3] = {0.2, 0.3, 0.4};\n\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(rowCmp, rowCmp + 3, &matrix.row[0], &matrix.row[0] + 3);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(colCmp, colCmp + 3, &matrix.col[0], &matrix.col[0] + 3);\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(valCmp, valCmp + 3, &matrix.val[0], &matrix.val[0] + 3);\n\t}\n}\n\n// Finalize MPI\nBOOST_AUTO_TEST_CASE(cleanup)\n{\n    // Cleanup MPI Environment\n    MPI_Finalize();\n}\n", "meta": {"hexsha": "35d7f5acccd48d38b28d7abe79ab241fcd3f7305", "size": 8966, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/data/file_formats/matrix/HDF5/SparseMatrixHDF5FileTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/data/file_formats/matrix/HDF5/SparseMatrixHDF5FileTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/data/file_formats/matrix/HDF5/SparseMatrixHDF5FileTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 31.4596491228, "max_line_length": 143, "alphanum_fraction": 0.6833593576, "num_tokens": 3275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3486451217982255, "lm_q2_score": 0.15203224546424315, "lm_q1q2_score": 0.05300530073713877}}
{"text": "#include <vector>\r\n#include <list>\r\n#include <set>\r\n#include <map>\r\n#include <unordered_map>\r\n#include <unordered_set>\r\n#include <deque>\r\n#include <forward_list>\r\n#include <iostream>\r\n#include <boost/tti/tti.hpp>\r\n\r\ntemplate< typename T, typename ... Types> struct IsMap{\r\n static constexpr bool value = false;\r\n};\r\n\r\ntemplate< typename ... Types> struct IsMap<std::map<Types ...>>{\r\n  static constexpr bool value = true;\r\n};\r\n\r\ntemplate< typename ... Types> struct IsMap<std::unordered_map<Types ...>>{\r\n  static constexpr bool value = true;\r\n};\r\n\r\n\r\nint main(){\r\n\r\n  std::set<int> s;  std::map<int,int> m;  std::unordered_map<int,int> um;\r\n\r\n  bool b1 =  IsMap<decltype(s)>::value;\r\n  bool b2 =  IsMap<decltype(m)>::value;\r\n  bool b3 =  IsMap<decltype(um)>::value;\r\n\r\n\r\n  return 0;\r\n  }\r\n", "meta": {"hexsha": "f9f7047e0063228376501bbf95d53b22187cd3ee", "size": 790, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "diff/is_map3.cpp", "max_stars_repo_name": "IgorHersht/proxygen_ih", "max_stars_repo_head_hexsha": "616a8eb899196d2a130e14c0fabcae1944e34b7d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7.0, "max_stars_repo_stars_event_min_datetime": "2017-11-10T05:18:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-29T15:38:25.000Z", "max_issues_repo_path": "diff/is_map3.cpp", "max_issues_repo_name": "IgorHersht/proxygen_ih", "max_issues_repo_head_hexsha": "616a8eb899196d2a130e14c0fabcae1944e34b7d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "diff/is_map3.cpp", "max_forks_repo_name": "IgorHersht/proxygen_ih", "max_forks_repo_head_hexsha": "616a8eb899196d2a130e14c0fabcae1944e34b7d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.9444444444, "max_line_length": 75, "alphanum_fraction": 0.6455696203, "num_tokens": 202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4882833952958346, "lm_q2_score": 0.10818895528093296, "lm_q1q2_score": 0.05282687041808316}}
{"text": "// https://launchpad.net/libmct\n\n//#define GOOGLE_HASH_MAPS\n\n#include \"details/io_details.h\"\n#include \"details/fp_details.h\"\n\n#include <gtest/gtest.h>\n\n//#include <ext/hash_set>\n#include <boost/unordered_set.hpp>\n#include <boost/unordered_map.hpp>\n#ifdef GOOGLE_HASH_MAPS\n// DANGER: \u041a\u0430\u0436\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c. \u0427\u0442\u043e \u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u0438 \u043f\u0440\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043b\u044b\u0448\u0430\u043b, \u043a\u0430\u0436\u0435\u0442\u0441\u044f.\n// Exsist depend on K and V type\n#  include <google/dense_hash_map>\n#endif\n#include <boost/foreach.hpp>\n\n#include <cassert>\n#include <vector>\n#include <iostream>\n#include <fstream>\n#include <algorithm>\n#include <stdexcept>\n#include <unordered_map>\n\nusing namespace std;\n\nusing std::hash;  // C++11\n//using boost::hash;  // \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u0447\u0435\u0447\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c\n\nnamespace {\nstruct TaskId {\n  TaskId() : v(0), w(0) {}\n  TaskId(int _v, int _w) : v(_v), w(_w) {}\n  \n  int v;\n  int w;\n};\n\nstruct KeyHash {\n std::size_t operator()(const TaskId& k) const\n {\n   // Watch \"Eff. Java.\"  \n   // \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\n   return boost::hash<int>()(k.v) ^ (boost::hash<int>()(k.w) << 1);\n }\n};\n \nstruct KeyEqual {\n bool operator()(const TaskId& lhs, const TaskId& rhs) const\n {\n    return lhs.v == rhs.v && lhs.w == rhs.w;\n }\n};\n\n}\n\n/// HashTables\n// TODO: \u0430 \u0435\u0441\u0442\u044c \u043b\u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b?\n//\n// \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u043d\u043e \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043a\u0430\u0442\u044c?\n//\n// \u0441\u043c. effective Java - \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u043f\u0440\u043e \u0445\u044d\u0448 \u043a\u043e\u0434\u044b - \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043e\u0440\u043f. equal then \u043f\u0435\u0440\u0435\u043e\u0440\u043f. hashCode!\n// \u0420\u0430\u0432\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0432\u043d\u044b\u0435 \u0445\u044d\u0448\u0438.\n//\n// DANGER: Good hashtable:\n// - good hash functon - \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0437\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0431\u0430\u043a\u0435\u0442\u0430\u043c\n//   && good load factor - n/(count_buckets) - \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 (\u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433) \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u0440\u043e\u0447\u0435\n//   && O(1) calc hash value\n// \n// Pro:\n// \n//\n// Cons:\n//   - \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445?\n//   - O(1) \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u044d\u0442\u043e \u0434\u0430, \u043d\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438\n//   - \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438\n//\n// Java:\n//  http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html\n//\n// C++:\n// TODO: \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0445\u044d\u0448 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443? \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443?\n//   \u041f\u043e\u0445\u043e\u0436\u0435 \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0445\u044d\u0448.\n//\n// Benchmarks:\n//   http://research.neustar.biz/tag/unordered_map/\n//   http://preshing.com/20110603/hash-table-performance-tests/\n//\n// Hash functions:\n//   http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed\n//\nTEST(DataStructures, HashTables) {\n  // http://stackoverflow.com/questions/2179946/i-would-like-to-see-a-hash-map-example-in-c\n  //\n  // http://msdn.microsoft.com/en-us/library/1s1byw77.aspx\n  // \u0415\u0441\u043b\u0438 \u0443\u0442\u043e\u0447\u043d\u044f\u0442\u044c \u043a\u043b\u044e\u0447, \u0442\u043e \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0441 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f\u043c\u0438 - \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c.\n  // \u0425\u043e\u0442\u044f... \u0412\u043e\u043e\u0431\u0449\u0435 \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0440\u0430\u0432\u043d\u044b\u043c\u0438 \u043a\u0435\u0448\u0430\u043c\u0438 \u043e\u0447\u0435\u043d\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b. \u0415\u0449\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u0442\u043d\u043e\u0441\u0442\u0438.\n  //\n  //\n  //unordered_map<TaskId, int> table;  // not compiled - \u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438\n  unordered_map<int, int> table;\n  \n  boost::unordered_map<TaskId, int, KeyHash, KeyEqual> htbl;\n\n#ifdef GOOGLE_HASH_MAPS\n  google::dense_hash_map<TaskId, int, KeyHash, KeyEqual> g_tbl;\n  g_tbl.set_empty_key(TaskId(0, 0));\n  g_tbl[TaskId(1, 5)] = 9;\n  \n  cout << g_tbl[TaskId(1, 5)] << endl;\n  assert(g_tbl.end() != g_tbl.find(TaskId(1, 5)));\n#endif\n  \n}\n\nTEST(DataStructures, BloomFilter) {\n  // Bloom filter:\n  //   http://code.google.com/p/bloom/\n  //\n  // Pro:\n  //   - more then hashtable space efficient - DANGER: \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043b\u043e\u0436\u043d\u043e\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435\n  // Cons:\n  //   - can't store value\n  //   - can't delete\n  //   - \u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f\n}\n\n// \u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u0437\u043d\u043e\u0431\u043e\u0439\n// http://preshing.com/20130107/this-hash-table-is-faster-than-a-judy-array/\n// TODO: See sparese arrays, skeep list\nTEST(DataStructures, JudyArrays) {\n  // http://judy.sourceforge.net/\n  // Cons:\n  //   - \u043f\u043e\u0445\u043e\u0436\u0435 \u0437\u0430\u043f\u0430\u0442\u0435\u043d\u0442\u043e\u0432\u0430\u043d\u043e\n}\n\n", "meta": {"hexsha": "c88c2be3064ff884d909dd5e17ec6c8e1c3a03ac", "size": 3825, "ext": "cc", "lang": "C++", "max_stars_repo_path": "my-cs/projects/try/choose_hash_tables_test.cc", "max_stars_repo_name": "zaqwes8811/cs-courses", "max_stars_repo_head_hexsha": "aa9cf5ad109c9cfcacaadc11bf2defb2188ddce2", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "my-cs/projects/try/choose_hash_tables_test.cc", "max_issues_repo_name": "zaqwes8811/cs-courses", "max_issues_repo_head_hexsha": "aa9cf5ad109c9cfcacaadc11bf2defb2188ddce2", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "my-cs/projects/try/choose_hash_tables_test.cc", "max_forks_repo_name": "zaqwes8811/cs-courses", "max_forks_repo_head_hexsha": "aa9cf5ad109c9cfcacaadc11bf2defb2188ddce2", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3214285714, "max_line_length": 119, "alphanum_fraction": 0.6912418301, "num_tokens": 1263, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.38121955219593834, "lm_q2_score": 0.13846178168115783, "lm_q1q2_score": 0.05278433840874277}}
{"text": "//==============================================================================\n//         Copyright 2003 - 2012   LASMEA UMR 6602 CNRS/Univ. Clermont II\n//         Copyright 2009 - 2012   LRI    UMR 8623 CNRS/Univ Paris Sud XI\n//\n//          Distributed under the Boost Software License, Version 1.0.\n//                 See accompanying file LICENSE.txt or copy at\n//                     http://www.boost.org/LICENSE_1_0.txt\n//==============================================================================\n#define NT2_UNIT_MODULE \"nt2 boost.simd.arithmetic toolbox - idivround2even/simd Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// unit test behavior of boost.simd.arithmetic components in simd mode\n//////////////////////////////////////////////////////////////////////////////\n/// created by jt the 01/12/2010\n///\n#include <boost/simd/arithmetic/include/functions/idivround2even.hpp>\n#include <boost/simd/sdk/simd/io.hpp>\n#include <boost/dispatch/meta/as_integer.hpp>\n#include <nt2/sdk/unit/tests.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/unit/tests/type_expr.hpp>\n#include <boost/simd/sdk/simd/native.hpp>\n#include <boost/simd/constant/constant.hpp>\n#include <boost/simd/include/constants/one.hpp>\n#include <boost/simd/include/constants/inf.hpp>\n#include <boost/simd/include/constants/zero.hpp>\n#include <boost/simd/include/constants/minf.hpp>\n#include <boost/simd/include/constants/mone.hpp>\n#include <boost/simd/include/constants/nan.hpp>\n\nNT2_TEST_CASE_TPL ( idivround2even_real__2_0,  BOOST_SIMD_SIMD_REAL_TYPES)\n{\n  using boost::simd::idivround2even;\n  using boost::simd::tag::idivround2even_;\n  using boost::simd::native;\n  typedef BOOST_SIMD_DEFAULT_EXTENSION  ext_t;\n  typedef native<T,ext_t>                  vT;\n  typedef typename boost::dispatch::meta::as_integer<T>::type iT;\n  typedef native<iT,ext_t>                                   ivT;\n  typedef typename boost::dispatch::meta::call<idivround2even_(vT,vT)>::type r_t;\n  typedef ivT wished_r_t;\n\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::Inf<vT>(), boost::simd::Inf<vT>()), boost::simd::Zero<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::Minf<vT>(), boost::simd::Minf<vT>()), boost::simd::Zero<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::Mone<vT>(), boost::simd::Mone<vT>()), boost::simd::One<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::Nan<vT>(), boost::simd::Nan<vT>()), boost::simd::Zero<r_t>(), 0);\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::One<vT>(), boost::simd::One<vT>()), boost::simd::One<r_t>(), 0);\n} // end of test for floating_\n\n\nNT2_TEST_CASE_TPL ( idivround2even_unsigned_int__2_0,  BOOST_SIMD_SIMD_UNSIGNED_TYPES)\n{\n\n  using boost::simd::idivround2even;\n  using boost::simd::tag::idivround2even_;\n  using boost::simd::native;\n  typedef BOOST_SIMD_DEFAULT_EXTENSION  ext_t;\n  typedef native<T,ext_t>                  vT;\n  typedef typename boost::dispatch::meta::as_integer<T>::type iT;\n  typedef native<iT,ext_t>                                   ivT;\n  typedef typename boost::dispatch::meta::call<idivround2even_(vT,vT)>::type r_t;\n  typedef ivT wished_r_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::One<vT>(), boost::simd::One<vT>()), boost::simd::One<ivT>(), 0);\n} // end of test for unsigned_int_\n\nNT2_TEST_CASE_TPL ( idivround2even_signed_int__2_0,  BOOST_SIMD_SIMD_INTEGRAL_SIGNED_TYPES)\n{\n\n  using boost::simd::idivround2even;\n  using boost::simd::tag::idivround2even_;\n  using boost::simd::native;\n  typedef BOOST_SIMD_DEFAULT_EXTENSION  ext_t;\n  typedef native<T,ext_t>                  vT;\n  typedef typename boost::dispatch::meta::as_integer<T>::type iT;\n  typedef native<iT,ext_t>                                   ivT;\n  typedef typename boost::dispatch::meta::call<idivround2even_(vT,vT)>::type r_t;\n  typedef ivT wished_r_t;\n\n  // return type conformity test\n  NT2_TEST_TYPE_IS( r_t, wished_r_t );\n\n  // specific values tests\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::Mone<vT>(), boost::simd::Mone<vT>()), boost::simd::One<ivT>(), 0);\n  NT2_TEST_ULP_EQUAL(idivround2even(boost::simd::One<vT>(), boost::simd::One<vT>()), boost::simd::One<ivT>(), 0);\n} // end of test for signed_int_\n", "meta": {"hexsha": "ba3673e469aa4d8b160b433166257c355b47077a", "size": 4390, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/boost/simd/base/unit/arithmetic/simd/idivround2even.cpp", "max_stars_repo_name": "psiha/nt2", "max_stars_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 34.0, "max_stars_repo_stars_event_min_datetime": "2017-05-19T18:10:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T02:18:13.000Z", "max_issues_repo_path": "modules/boost/simd/base/unit/arithmetic/simd/idivround2even.cpp", "max_issues_repo_name": "psiha/nt2", "max_issues_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/boost/simd/base/unit/arithmetic/simd/idivround2even.cpp", "max_forks_repo_name": "psiha/nt2", "max_forks_repo_head_hexsha": "5e829807f6b57b339ca1be918a6b60a2507c54d0", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 7.0, "max_forks_repo_forks_event_min_datetime": "2017-12-02T12:59:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-31T12:46:14.000Z", "avg_line_length": 47.2043010753, "max_line_length": 116, "alphanum_fraction": 0.6510250569, "num_tokens": 1197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48047869292635403, "lm_q2_score": 0.10970577096716554, "lm_q1q2_score": 0.05271128544078166}}
{"text": "//------------------------------------------------------------------------------\n// \\file ErrorHandling_tests.cpp\n//------------------------------------------------------------------------------\n#include \"Utilities/ErrorHandling/ErrorHandling.h\"\n\n#include \"Cpp/Utilities/TypeSupport/UnderlyingTypes.h\"\n\n#include <boost/test/unit_test.hpp>\n#include <cmath>\n\nusing Cpp::Utilities::TypeSupport::get_underlying_value;\nusing Utilities::ErrorHandling::ErrorCodeNumber;\nusing Utilities::ErrorHandling::HandleReturnValuePassively;\nusing OptionalErrorNumber =\n\tUtilities::ErrorHandling::HandleReturnValuePassively::OptionalErrorNumber;\n\nBOOST_AUTO_TEST_SUITE(Utilities)\nBOOST_AUTO_TEST_SUITE(ErrorHandling_tests)\n\n// cf. https://en.cppreference.com/w/cpp/error/errno\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nBOOST_AUTO_TEST_CASE(HandleReturnValuePassivelyGetsLatestErrno)\n{\n  double not_a_number {std::log(-1.0)};\n\n\tconst OptionalErrorNumber result {HandleReturnValuePassively()(-1)};\n\n\tBOOST_TEST(static_cast<bool>(result));\n\tBOOST_TEST((*result).error_number() ==\n\t\tget_underlying_value(ErrorCodeNumber::argument_out_of_domain));\n}\n\nBOOST_AUTO_TEST_SUITE_END() // ErrorHandling_tests\nBOOST_AUTO_TEST_SUITE_END() // Utilities", "meta": {"hexsha": "56377f65dd38fc8d517c5b6c46885b0772771b52", "size": 1338, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Voltron/Source/UnitTests/Utilities/ErrorHandling/ErrorHandling_tests.cpp", "max_stars_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_stars_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2018-02-09T19:44:51.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-09T19:44:51.000Z", "max_issues_repo_path": "Voltron/Source/UnitTests/Utilities/ErrorHandling/ErrorHandling_tests.cpp", "max_issues_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_issues_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Voltron/Source/UnitTests/Utilities/ErrorHandling/ErrorHandling_tests.cpp", "max_forks_repo_name": "ernestyalumni/HrdwCCppCUDA", "max_forks_repo_head_hexsha": "17ed937dea06431a4d5ca103f993ea69a6918734", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2285714286, "max_line_length": 80, "alphanum_fraction": 0.6240657698, "num_tokens": 226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4416730056646256, "lm_q2_score": 0.11920292828022305, "lm_q1q2_score": 0.05264871561755091}}
{"text": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n/*                                                                           */\n/*  This file is part of the library KASKADE 7                               */\n/*    see http://www.zib.de/projects/kaskade7-finite-element-toolbox         */\n/*                                                                           */\n/*  Copyright (C) 2002-2016 Zuse Institute Berlin                            */\n/*                                                                           */\n/*  KASKADE 7 is distributed under the terms of the ZIB Academic License.    */\n/*    see $KASKADE/academic.txt                                              */\n/*                                                                           */\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n#include <iostream>\n\n#ifndef GRIDTYPE\n#define GRIDTYPE 1 // UGGrid\n#endif\n\n#if ( GRIDTYPE < 1 ) || ( GRIDTYPE > 4 )\n#error \"GRIDTYPE must be 1 (UGGrid), 2 (ALUSImplexGrid), 3 (ALUConformGrid) or 4 (AlbertaGrid)\"\n#endif\n\n#if GRIDTYPE==1\n#define CHARGRIDTYPE \"UGGrid\"\n#elif  GRIDTYPE==2\n#define CHARGRIDTYPE \"ALUSimplexGrid\"\n#elif  GRIDTYPE==3\n#define CHARGRIDTYPE \"ALUConformGrid\"\n#elif  GRIDTYPE==4\n#define CHARGRIDTYPE \"AlbertaGrid\"\n#endif\n\n#include <boost/timer/timer.hpp>\n\n#include \"dune/grid/config.h\"\n#include \"dune/grid/uggrid.hh\"\n\n#ifndef SPACEDIM\n#define SPACEDIM 2\n#endif\n\n#if ( SPACEDIM < 2 ) || ( SPACEDIM > 3 )\n#error 'Dimension SPACEDIM must be 2 or 3'\n#endif\n\n#if ( GRIDTYPE==2 ) || ( GRIDTYPE==3 )\n#define HAVE_DUNE_ALUGRID 1\n#define ENABLE_DUNE_ALUGRID 1\n#if SPACEDIM==2\n#include \"dune/alugrid/2d/alu2dinclude.hh\"\n#include \"dune/alugrid/2d/alugrid.hh\"\n#include \"dune/alugrid/2d/gridfactory.hh\"\n#else\n#include \"dune/alugrid/3d/alu3dinclude.hh\"\n#include \"dune/alugrid/3d/alugrid.hh\"\n#include \"dune/alugrid/3d/gridfactory.hh\"\n#endif\n#endif\n\n#if GRIDTYPE==4\n#define ENABLE_ALBERTA 1\n#define ALBERTA_DIM SPACEDIM\n#include \"dune/grid/albertagrid/agrid.hh\"\n#include \"dune/grid/albertagrid/gridfactory.hh\"\n#endif\n\n#include \"utilities/enums.hh\"\n\n#include \"fem/assemble.hh\"\n#include \"fem/norms.hh\"\n#include \"fem/lagrangespace.hh\"\n//#include \"fem/hierarchicspace.hh\"   // ContinuousHierarchicMapper\n#include \"linalg/direct.hh\"\n#include \"linalg/trivialpreconditioner.hh\"\n//#include \"linalg/partialDirectPreconditioner.hh\"\n#include \"linalg/additiveschwarz.hh\"\n#include \"linalg/iluprecond.hh\"      // ILUT, ILUK, ARMS\n#include \"linalg/iccprecond.hh\"\n#include \"linalg/icc0precond.hh\"\n#include \"linalg/hyprecond.hh\"       // BoomerAMG, Euclid\n#include \"linalg/jacobiPreconditioner.hh\"\n#include \"linalg/cg.hh\"\n#include \"mg/hb.hh\"\n#include \"io/vtk.hh\"\n//#include \"io/amira.hh\"\n#include \"utilities/kaskopt.hh\"\n\nusing namespace Kaskade;\n#include \"ht.hh\"\n\n#if SPACEDIM==3\n#include \"cubus.hh\"\n#endif\n\n#if GRIDTYPE==4\n#define DEFAULT_REFINEMENTS 14\n#else\n#if GRIDTYPE==3\n#define DEFAULT_REFINEMENTS 7\n#else\n#if SPACEDIM==2\n#define DEFAULT_REFINEMENTS 5\n#endif\n#if SPACEDIM==3\n#define DEFAULT_REFINEMENTS 3\n#endif\n#endif\n#endif\n\nint main(int argc, char *argv[])\n{\n  using namespace boost::fusion;\n\n  std::cout << \"Start heat transfer tutorial program (with GridType=\" << CHARGRIDTYPE <<\n              \" and SpaceDimension=\" << SPACEDIM << \")\" << std::endl;\n\n  boost::timer::cpu_timer totalTimer;\n\n  int verbosityOpt = 1;\n  bool dump = true; \n  std::unique_ptr<boost::property_tree::ptree> pt = getKaskadeOptions(argc, argv, verbosityOpt, dump);\n\n  int  refinements = getParameter(pt, \"refinements\", DEFAULT_REFINEMENTS),\n       order       =  getParameter(pt, \"order\", 2),\n       verbosity   = getParameter(pt, \"verbosity\", 1);\n  std::cout << \"original mesh shall be refined : \" << refinements << \" times\" << std::endl;\n  std::cout << \"discretization order           : \" << order << std::endl;\n  std::cout << \"output level (verbosity)       : \" << verbosity << std::endl;\n\n  int  direct, onlyLowerTriangle = false;\n    \n  DirectType directType;\n//  IterateType iterateType = IterateType::CG;\n  MatrixProperties property = MatrixProperties::SYMMETRIC;\n  PrecondType precondType = PrecondType::NONE;\n  std::string empty;\n\n  std::string s(\"names.type.\");\n  s += getParameter(pt, \"solver.type\", empty);\n  direct = getParameter(pt, s, 0);\n    \n  s = \"names.direct.\" + getParameter(pt, \"solver.direct\", empty);\n  directType = static_cast<DirectType>(getParameter(pt, s, 0));\n\n//  s = \"names.iterate.\" + getParameter(pt, \"solver.iterate\", empty);\n//  iterateType = static_cast<IterateType>(getParameter(pt, s, 0));\n  s = \"names.preconditioner.\" + getParameter(pt, \"solver.preconditioner\", empty);\n  precondType = static_cast<PrecondType>(getParameter(pt, s, 0));\n  \n  int blocks = getParameter(pt,\"blocks\",40);\n  int nthreads = getParameter(pt,\"threads\",4);\n  double rowBlockFactor = getParameter(pt,\"rowBlockFactor\",2.0);\n\n  property = MatrixProperties::SYMMETRIC;\n\n  if ( (directType == DirectType::MUMPS)||(directType == DirectType::PARDISO) || ( (precondType == PrecondType::ICC) && !direct ) )\n  {\n    onlyLowerTriangle = true;\n    std::cout << \n      \"Note: direct solver MUMPS/PARADISO or PrecondType::ICC preconditioner ===> onlyLowerTriangle is set to true!\" \n      << std::endl;\n  }\n\n  boost::timer::cpu_timer gridTimer;\n#if SPACEDIM==2\n  //   two-dimensional space: dim=2\n  constexpr int dim=2;        \n#if GRIDTYPE==1\n  using Grid = Dune::UGGrid<dim>;\n#endif\n  // There are alternatives to UGGrid: ALUSimplexGrid (red refinement), ALUConformGrid (bisection)\n  // and AlbertaGrid\n#if GRIDTYPE==2\n  using Grid = Dune::ALUGrid<dim,dim,Dune::ALUGridElementType::simplex,Dune::ALUGridRefinementType::nonconforming>;\n#endif\n#if GRIDTYPE==3\n  using Grid = Dune::ALUGrid<dim,dim,Dune::ALUGridElementType::simplex,Dune::ALUGridRefinementType::conforming>;\n#endif\n#if GRIDTYPE==4\n  using Grid = Dune::AlbertaGrid<dim,dim>;\n#endif\n  Dune::GridFactory<Grid> factory;\n\n  // vertex coordinates v[0], v[1]\n  Dune::FieldVector<double,dim> v;    \n  v[0]=0; v[1]=0; factory.insertVertex(v);\n  v[0]=1; v[1]=0; factory.insertVertex(v);\n  v[0]=1; v[1]=1; factory.insertVertex(v);\n  v[0]=0; v[1]=1; factory.insertVertex(v);\n  // triangle defined by 3 vertex indices\n  std::vector<unsigned int> vid(3);\n  Dune::GeometryType gt(Dune::GeometryType::simplex,2);\n  vid[0]=0; vid[1]=1; vid[2]=2; factory.insertElement(gt,vid);\n  vid[0]=0; vid[1]=2; vid[2]=3; factory.insertElement(gt,vid);\n  std::unique_ptr<Grid> grid( factory.createGrid() ) ;\n  // the coarse grid will be refined three times\n  grid->globalRefine(refinements);\n  // some information on the refined mesh\n  std::cout << std::endl << \"Grid: \" << grid->size(0) << \" triangles, \" << std::endl;\n  std::cout << \"      \" << grid->size(1) << \" edges, \" << std::endl;\n  std::cout << \"      \" << grid->size(2) << \" points\" << std::endl;\n\n  // a gridmanager is constructed \n  // as connector between geometric and algebraic information\n  GridManager<Grid> gridManager(std::move(grid));\n#else\n  //  three-dimensional space: dim=3\n  //  we offer 2 geometries:\n  //  - very simple:  1 tetrahedron defined by 4 vertices\n  //  - more complex: 1 cube defined by 48 tetrahedra, provided in cubus.hh\n  constexpr int dim=3;\n    \n  //    \n  //definition of 1 tetrahedron by 4 vertices\n#if GRIDTYPE==4\n  using Grid = Dune::AlbertaGrid<dim,dim>;\n  Dune::GridFactory<Grid> factory;\n  // vertex coordinates v[0], v[1]\n  Dune::FieldVector<double,dim> v;    \n  v[0]=0; v[1]=0; v[2]=0; factory.insertVertex(v);\n  v[0]=1; v[1]=0; v[2]=0; factory.insertVertex(v);\n  v[0]=0; v[1]=1; v[2]=0; factory.insertVertex(v);\n  v[0]=0; v[1]=0; v[2]=1; factory.insertVertex(v);\n  // tetrahedron defined by 4 vertex indices\n  std::vector<unsigned int> vid(4);\n  Dune::GeometryType gt(Dune::GeometryType::simplex,dim);\n  vid[0]=0; vid[1]=1; vid[2]=2; vid[3]=3; factory.insertElement(gt,vid);\n  std::unique_ptr<Grid> grid( factory.createGrid() ) ;\n  // the coarse grid will be refined three times\n  grid->globalRefine(refinements);\n  //\n#else \n  // definition of a more complex mesh using cubus.hh\n  // note: trying to use the following code with AlbertaGrid will lead to a crash\n  // during runtime due to a bug in the AlbertaGrid refinement routine\n  int heapSize=1024;\n#if GRIDTYPE==1\n  using Grid = Dune::UGGrid<dim>;\n#endif\n  // There are alternatives to UGGrid: ALUSimplexGrid (red refinement)\n#if GRIDTYPE==2\n  using Grid = Dune::ALUGrid<dim,dim,Dune::ALUGridElementType::simplex,Dune::ALUGridRefinementType::nonconforming>;\n#endif\n#if GRIDTYPE==3\n#error ALUCONFORM GridType not supported by DUNE for Dimension=3\n#endif\n  std::unique_ptr<Grid> grid( RefineGrid<Grid>(refinements, heapSize) );\n#endif\n\n  // some information on the refined mesh\n  std::cout << std::endl << \"Grid: \" << grid->size(0) << \" tetrahedra, \" << std::endl;\n  std::cout << \"      \" << grid->size(1) << \" triangles, \" << std::endl;\n  std::cout << \"      \" << grid->size(dim-1) << \" edges, \" << std::endl;\n  std::cout << \"      \" << grid->size(dim) << \" points\" << std::endl;\n  // a gridmanager is constructed \n  // as connector between geometric and algebraic information\n  GridManager<Grid> gridManager(std::move(grid));\n#endif\n  std::cout << \"computing time for generation of initial mesh: \" << boost::timer::format(gridTimer.elapsed()) << \"\\n\";\n    \n  using LeafView = Grid::LeafGridView;\n    \n  // construction of finite element space for the scalar solution T.\n  using H1Space = FEFunctionSpace<ContinuousLagrangeMapper<double,LeafView> >;\n  // using H1Space = FEFunctionSpace<ContinuousHierarchicMapper<double,LeafView> >;\n  using Spaces = boost::fusion::vector<H1Space const*>;\n  using VariableDescriptions = boost::fusion::vector<Variable<SpaceIndex<0>,Components<1>,VariableId<0> > >;\n  using VariableSet = VariableSetDescription<Spaces,VariableDescriptions>;\n  using Functional = HeatFunctional<double,VariableSet>;\n  using Assembler = VariationalFunctionalAssembler<LinearizationAt<Functional> >;\n  constexpr int neq = Functional::TestVars::noOfVariables;\n  using CoefficientVectors = VariableSet::CoefficientVectorRepresentation<0,neq>::type;\n  using LinearSpace = VariableSet::CoefficientVectorRepresentation<0,neq>::type;\n  // avoid collision of reference to the Kaskade CG with an equal named enum value in the Alberta headers\n  using CG = Kaskade::CG<LinearSpace,LinearSpace>;\n    \n  // construction of finite element space for the scalar solution T.\n  H1Space temperatureSpace(gridManager,gridManager.grid().leafGridView(),order);\n    \n  Spaces spaces(&temperatureSpace);\n    \n  // construct variable list.\n  // VariableDescription<int spaceId, int components, int Id>\n  // spaceId: number of associated FEFunctionSpace\n  // components: number of components in this variable\n  // Id: number of this variable\n        \n  std::string varNames[1] = { \"u\" };\n    \n  VariableSet variableSet(spaces,varNames);\n\n  // construct variational functional\n    \n  double kappa = 1.0;\n  double q = 1.0;\n  Functional F(kappa,q);\n  constexpr int nvars = Functional::AnsatzVars::noOfVariables;\n  std::cout << std::endl << \"no of variables = \" << nvars << std::endl;\n  std::cout << \"no of equations = \" << neq   << std::endl;\n  size_t dofs = variableSet.degreesOfFreedom(0,nvars);\n  std::cout << \"number of degrees of freedom = \" << dofs   << std::endl;\n\n  //construct Galerkin representation\n  Assembler assembler(gridManager,spaces);\n  VariableSet::VariableSet u(variableSet);\n  VariableSet::VariableSet du(variableSet);\n\n  size_t nnz = assembler.nnz(0,neq,0,nvars,onlyLowerTriangle);\n  std::cout << \"number of nonzero elements in the stiffness matrix: \" << nnz << std::endl << std::endl;\n  \n  boost::timer::cpu_timer assembTimer;\n  CoefficientVectors solution(VariableSet::CoefficientVectorRepresentation<0,neq>::init(spaces));\n  solution = 0;\n  \n  // UG seems to admit concurrent reads while claiming not to be thread safe. In this case we enforce multithreading during assembly.\n  gridManager.enforceConcurrentReads(std::is_same<Grid,Dune::UGGrid<dim> >::value);\n  assembler.setNSimultaneousBlocks(blocks);\n  assembler.setRowBlockFactor(rowBlockFactor);\n  assembler.assemble(linearization(F,u),assembler.MATRIX|assembler.RHS|assembler.VALUE,nthreads,verbosity);\n  std::cout << \"computing time for assemble: \" << boost::timer::format(assembTimer.elapsed()) << \"\\n\";\n  \n  CoefficientVectors rhs(assembler.rhs());\n  AssembledGalerkinOperator<Assembler,0,neq,0,nvars> A(assembler, onlyLowerTriangle);\n  \n  // matrix may be used in triplet format, e.g.,\n  // MatrixAsTriplet<double> tri = A.get<MatrixAsTriplet<double> >();\n  //     for (k=0; k< nnz; k++)\n  //       {\n  //         printf(\"%3d %3d %e\\n\", tri.ridx[k], tri.cidx[k], tri.data[k]);\n  //       }\n\n  if (direct)\n  {\n    boost::timer::cpu_timer directTimer;\n    directInverseOperator(A,directType,property).applyscaleadd(-1.0,rhs,solution);\n    u.data = solution.data;\n    std::cout << \"computing time for direct solve: \" << boost::timer::format(directTimer.elapsed()) << \"\\n\";\n  }\n  else\n  {\n    boost::timer::cpu_timer iteTimer;\n    Dune::InverseOperatorResult res;\n    const DefaultDualPairing<LinearSpace,LinearSpace> defaultScalarProduct{};\n    int iteSteps = getParameter(pt, \"solver.iteMax\", 2000);\n    double iteEps = getParameter(pt, \"solver.iteEps\", 1.0e-10);\n    StrakosTichyPTerminationCriterion<double> termination(iteEps,iteSteps);\n    int lookAhead;\n    switch (precondType)\n    {\n      case PrecondType::NONE:\n      case PrecondType::HB:   lookAhead=50; break;\n      default:                lookAhead=3; break;\n    }\n    lookAhead = getParameter(pt, \"solver.lookAhead\", lookAhead);\n    termination.setLookAhead(lookAhead);\n\n    switch (precondType)\n    {\n      case PrecondType::NONE:\n      {\n        std::cout << \"selected preconditioner: NONE\" << std::endl;\n        TrivialPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > trivial;\n        CG cg(A,trivial,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::ADDITIVESCHWARZ:\n      {\n        std::cout << \"selected preconditioner: ADDITIVESCHWARZ\" << std::endl;\n        std::pair<size_t,size_t> idx = temperatureSpace.mapper().globalIndexRange(gridManager.grid().leafIndexSet().geomTypes(dim)[0]);\n        AdditiveSchwarzPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > addschwarz(A,idx.first,idx.second,verbosity);\n        CG cg(A,addschwarz,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::ILUT:\n      {\n        std::cout << \"selected preconditioner: ILUT\" << std::endl;\n//        std::cout << \"Note that this preconditioner combined with the BICGSTAB solver\" << std::endl;\n        std::cout << \"needs matrix.property = GENERAL\" << std::endl;\n        int lfil = getParameter(pt, \"solver.ILUT.lfil\", 140);\n        double dropTol = getParameter(pt, \"solver.ILUT.dropTol\", 0.01);\n        ILUTPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > ilut(A,lfil,dropTol,verbosity);\n        CG cg(A,ilut,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n//         Dune::BiCGSTABSolver<LinearSpace> cg(A,ilut,iteEps,iteSteps,verbosity);\n//         cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::ILUK:\n      {\n        std::cout << \"selected preconditioner: ILUK\" << std::endl;\n//        std::cout << \"Note that this preconditioner combined with the BICGSTAB solver\" << std::endl;\n        std::cout << \"needs matrix.property = GENERAL\" << std::endl;\n        int fill_lev = getParameter(pt, \"solver.ILUK.fill_lev\", 3);\n        ILUKPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > iluk(A,fill_lev,verbosity);\n        CG cg(A,iluk,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n//         Dune::BiCGSTABSolver<LinearSpace> cg(A,iluk,iteEps,iteSteps,verbosity);\n//         cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::ARMS:\n      {\n        int lfil = getParameter(pt, \"solver.ARMS.lfil\", 140);\n        int lev_reord = getParameter(pt, \"solver.ARMS.lev_reord\", 1);\n        double dropTol = getParameter(pt, \"solver.ARMS.dropTol\", 0.01);\n        double tolind = getParameter(pt, \"solver.ARMS.tolind\", 0.2);\n        ARMSPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > iluk(A,lfil,dropTol,lev_reord,tolind,verbosity);\n        CG cg(A,iluk,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::ICC:\n      {\n        std::cout << \"selected preconditioner: ICC\" << std::endl;\n        if (property != MatrixProperties::SYMMETRIC) \n        {\n          std::cout << \"PrecondType::ICC preconditioner of TAUCS lib has to be used with matrix.property==MatrixProperties::SYMMETRIC\\n\";\n          std::cout << \"i.e., call the executable with option --solver.property MatrixProperties::SYMMETRIC\\n\\n\";\n        }\n        double dropTol = getParameter(pt, \"solver.ICC.dropTol\", 0.01);;\n        ICCPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > icc(A,dropTol);\n        CG cg(A,icc,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::ICC0:\n      {\n        std::cout << \"selected preconditioner: ICC0\" << std::endl;\n        ICC_0Preconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > icc0(A);\n        CG cg(A,icc0,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::HB:\n      {\n        std::cout << \"selected preconditioner: HB\" << std::endl;\n        HierarchicalBasisPreconditioner<Grid,AssembledGalerkinOperator<Assembler,0,neq,0,nvars>::range_type, AssembledGalerkinOperator<Assembler,0,neq,0,nvars>::range_type > hb(gridManager.grid());\n        CG cg(A,hb,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::BOOMERAMG:\n      {\n        int steps = getParameter(pt, \"solver.BOOMERAMG.steps\", iteSteps);\n        int coarsentype = getParameter(pt, \"solver.BOOMERAMG.coarsentype\", 21);\n        int interpoltype = getParameter(pt, \"solver.BOOMERAMG.interpoltype\", 0);\n        int cycleType = getParameter(pt, \"solver.BOOMERAMG.cycleType\", 1);\n        int relaxType = getParameter(pt, \"solver.BOOMERAMG.relaxType\", 3);\n        int variant = getParameter(pt, \"solver.BOOMERAMG.variant\", 0);\n        int overlap = getParameter(pt, \"solver.BOOMERAMG.overlap\", 1);\n        double tol = getParameter(pt, \"solver.BOOMERAMG.tol\", iteEps);\n        double strongThreshold = getParameter(pt, \"solver.BOOMERAMG.strongThreshold\", (dim==2)?0.25:0.6);\n        BoomerAMG<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> >\n                  boomerAMGPrecon(A,steps,coarsentype,interpoltype,tol,cycleType,relaxType,\n                  strongThreshold,variant,overlap,1,verbosity);\n        CG cg(A,boomerAMGPrecon,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n//         Dune::LoopSolver<LinearSpace> cg(A,boomerAMGPrecon,iteEps,iteSteps,verbosity);\n//         cg.apply(solution,rhs,res);\n      }\n      break;\n      case PrecondType::EUCLID:\n      {\n        std::cout << \"selected preconditioner: EUCLID\" << std::endl;\n        int level      = getParameter(pt, \"solver.EUCLID.level\",1);\n        double droptol = getParameter(pt, \"solver.EUCLID.droptol\",0.01);\n        int printlevel = 0;\n        if (verbosity>2) printlevel=verbosity-2;\n        printlevel = getParameter(pt,\"solver.EUCLID.printlevel\",printlevel);\n        int bj = getParameter(pt, \"solver.EUCLID.bj\",0);\n        Euclid<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > EuclidPrecon(A,level,droptol,printlevel,bj,verbosity);\n        CG cg(A,EuclidPrecon,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n     }\n      break;\n      case PrecondType::JACOBI:\n      default:\n      {\n        std::cout << \"selected preconditioner: JACOBI\" << std::endl;\n        JacobiPreconditioner<AssembledGalerkinOperator<Assembler,0,neq,0,nvars> > jacobi(A,1.0);\n        CG cg(A,jacobi,defaultScalarProduct,termination,verbosity);\n        cg.apply(solution,rhs,res);\n      }\n      break;\n    }\n    solution *= -1.0;\n    u.data = solution.data;\n    \n    std::cout << \"iterative solve eps= \" << iteEps << \": \" \n              << (res.converged?\"converged\":\"failed\") << \" after \"\n              << res.iterations << \" steps, rate=\"\n              << res.conv_rate << \", computing time=\" << (double)(iteTimer.elapsed().user)/1e9 << \"s\\n\";\n  }\n  \n    \n  \n  // compute L2 norm of the solution\n  boost::timer::cpu_timer outputTimer;\n  L2Norm l2Norm;\n  std::cout << \"L2norm(solution) = \" << l2Norm(boost::fusion::at_c<0>(u.data)) << std::endl;\n    \n    \n\n  // output of solution in VTK format for visualization,\n  // the data are written as ascii stream into file temperature.vtu,\n  // possible is also binary\n  writeVTKFile(u,\"temperature\",IoOptions().setOrder(order).setPrecision(7));\n\n  std::cout << \"graphical output finished, data in VTK format is written into file temperature.vtu \\n\";\n    \n  // output of solution for Amira visualization,\n  // the data are written in binary format into file temperature.am,\n  // possible is also ascii\n  // IoOptions options;\n  // options.outputType = IoOptions::ascii;\n  // LeafView leafGridView = gridManager.grid().leafGridView();\n  // writeAMIRAFile(leafGridView,variableSet,u,\"temperature\",options);\n\n  std::cout << \"computing time for output: \" << boost::timer::format(outputTimer.elapsed()) << \"\\n\";\n\n  std::cout << \"total computing time: \" << boost::timer::format(totalTimer.elapsed()) << \"\\n\";\n  std::cout << \"End heat transfer tutorial program\" << std::endl;\n}\n", "meta": {"hexsha": "8ca051c18ac60345374192e966d512bc332859c9", "size": 21825, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Kaskade/tutorial/stationary_heattransfer/ht_advanced.cpp", "max_stars_repo_name": "chenzongxiong/streambox", "max_stars_repo_head_hexsha": "76f95780d1bf6c02731e39d8ac73937cea352b95", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2019-07-03T14:03:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T10:18:49.000Z", "max_issues_repo_path": "Kaskade/tutorial/stationary_heattransfer/ht_advanced.cpp", "max_issues_repo_name": "chenzongxiong/streambox", "max_issues_repo_head_hexsha": "76f95780d1bf6c02731e39d8ac73937cea352b95", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 6.0, "max_issues_repo_issues_event_min_datetime": "2020-02-17T12:01:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-09T22:02:36.000Z", "max_forks_repo_path": "Kaskade/tutorial/stationary_heattransfer/ht_advanced.cpp", "max_forks_repo_name": "chenzongxiong/streambox", "max_forks_repo_head_hexsha": "76f95780d1bf6c02731e39d8ac73937cea352b95", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2.0, "max_forks_repo_forks_event_min_datetime": "2020-12-03T04:41:18.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-11T21:44:42.000Z", "avg_line_length": 41.4923954373, "max_line_length": 197, "alphanum_fraction": 0.6629553265, "num_tokens": 6201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.5, "lm_q2_score": 0.10521053950871516, "lm_q1q2_score": 0.05260526975435758}}
{"text": "/*!\n * @file right_hand_side.hpp\n * @brief Contains implementation of right-hand side.\n * @author Konrad Simon\n * @date August 2019\n */\n\n#ifndef INCLUDE_RIGHT_HAND_SIDE_HPP_\n#define INCLUDE_RIGHT_HAND_SIDE_HPP_\n\n// Deal.ii\n#include <deal.II/base/function.h>\n\n// STL\n#include <cmath>\n#include <fstream>\n\n// My Headers\n#include \"coefficients.h\"\n\nnamespace Coefficients\n{\nusing namespace dealii;\n\n/*!\n * @class RightHandSide\n * @brief Class implements scalar right-hand side function.\n *\n * The right-hand side represents some external forcing parameter.\n */\ntemplate <int dim>\nclass RightHandSide : public Function<dim>\n{\npublic:\n\tRightHandSide() : Function<dim>() {}\n\n\tvirtual double value(const Point<dim> &p,\n\t\t\t\t\t\tconst unsigned int component = 0) const override;\n\tvirtual void value_list(const std::vector<Point<dim>> &points,\n\t\t\t\t\t\t\tstd::vector<double>  &values,\n\t\t\t\t\t\t\tconst unsigned int component = 0) const override;\n};\n\n\ntemplate <int dim>\ndouble\nRightHandSide<dim>::value(const Point<dim>& /*p*/,\n\t\t\t\t\t\t\t   const unsigned int /*component*/) const\n{\n\tdouble return_value = 2.0;\n\n\treturn return_value;\n}\n\ntemplate <int dim>\nvoid\nRightHandSide<dim>::value_list(const std::vector<Point<dim>> &points,\n\t\t\t\t\t\t\t\tstd::vector<double>  &values,\n\t\t\t\t\t\t\t\tconst unsigned int /*component = 0*/) const\n{\n\tAssert (points.size() == values.size(),\n\t\t\tExcDimensionMismatch (points.size(), values.size()) );\n\n\tfor ( unsigned int p=0; p<points.size(); ++p)\n\t{\n\t\tvalues[p] = 2.0;\n\t} // end ++p\n}\n\n} // end namespace Coefficients\n\n#endif /* INCLUDE_RIGHT_HAND_SIDE_HPP_ */\n", "meta": {"hexsha": "04f6622a489a4b17324b1415cc47532f18dfd4b1", "size": 1559, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "include/right_hand_side.hpp", "max_stars_repo_name": "konsim83/deal.ii-9.1.1_SS19_demo_elliptic_multiscale_fem", "max_stars_repo_head_hexsha": "cde9eabcbdee1271f4d36ce67d9168b65251ad32", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "include/right_hand_side.hpp", "max_issues_repo_name": "konsim83/deal.ii-9.1.1_SS19_demo_elliptic_multiscale_fem", "max_issues_repo_head_hexsha": "cde9eabcbdee1271f4d36ce67d9168b65251ad32", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/right_hand_side.hpp", "max_forks_repo_name": "konsim83/deal.ii-9.1.1_SS19_demo_elliptic_multiscale_fem", "max_forks_repo_head_hexsha": "cde9eabcbdee1271f4d36ce67d9168b65251ad32", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-10-19T15:42:43.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-19T15:42:43.000Z", "avg_line_length": 21.3561643836, "max_line_length": 69, "alphanum_fraction": 0.6946760744, "num_tokens": 379, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.11124120650754304, "lm_q1q2_score": 0.052581880235436966}}
{"text": "/***\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements.  See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership.  The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.  You may obtain a copy of the License at\n\n *   http://www.apache.org/licenses/LICENSE-2.0\n\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\n#include <boost/ut.hpp>\n\n#include <mpp/mat.hpp>\n\n#include \"../include/utils.hpp\"\n\n#include <initializer_list>\n#include <vector>\n\nusing namespace boost::ut;\nusing namespace boost::ut::bdd;\nusing namespace mpp;\n\nnamespace\n{\n\ttemplate<typename Mats, bool Move>\n\tvoid test_assign_rng(std::string_view test_name)\n\t{\n\t\ttest(test_name.data()) = [test_name]<typename Mat, typename Mat2>(\n\t\t\t\t\t\t\t\t\t std::tuple<std::type_identity<Mat>, std::type_identity<Mat2>>) {\n\t\t\tauto [mat, vec2d, expected_mat] =\n\t\t\t\tparse_test(test_name, parse_mat<Mat>, parse_rng2d<typename Mat::value_type>, parse_mat<Mat2>);\n\n\t\t\tif constexpr (Move)\n\t\t\t{\n\t\t\t\tmat = std::move(vec2d);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmat = vec2d;\n\t\t\t}\n\n\t\t\tcmp_mat_to_expr_like(mat, expected_mat);\n\t\t} | Mats{};\n\t}\n\n\ttemplate<typename Mats, bool Move>\n\tvoid test_assign_mat(std::string_view test_name)\n\t{\n\t\ttest(test_name.data()) =\n\t\t\t[test_name]<typename Mat, typename Mat2, typename Mat3>(\n\t\t\t\tstd::tuple<std::type_identity<Mat>, std::type_identity<Mat2>, std::type_identity<Mat3>>) {\n\t\t\t\tauto [mat, mat2, expected_mat] =\n\t\t\t\t\tparse_test(test_name, parse_mat<Mat>, parse_mat<Mat2>, parse_mat<Mat3>);\n\n\t\t\t\tif constexpr (Move)\n\t\t\t\t{\n\t\t\t\t\tmat = std::move(mat2);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmat = mat2;\n\t\t\t\t}\n\n\t\t\t\tcmp_mat_to_expr_like(mat, expected_mat);\n\t\t\t} |\n\t\t\tMats{};\n\t}\n} // namespace\n\n\nint main()\n{\n\t// @NOTE: This covers copy and move assignment from rule of five (2/5)\n\n\tfeature(\"Assigning a 2D range with same dimensions\") = []() {\n\t\tusing mats = join_mats<all_mats<int, 2, 3>, all_mats<int, 2, 3>>;\n\n\t\ttest_assign_rng<mats, false>(\"assign/2x3_same_dims.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/2x3_same_dims.txt\");\n\t};\n\n\tfeature(\"Assigning a matrix with same dimensions\") = []() {\n\t\tusing mats = join_mats<all_mats<int, 2, 3>, all_mats<int, 2, 3>, all_mats<int, 2, 3>>;\n\n\t\ttest_assign_mat<mats, false>(\"assign/2x3_same_dims.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/2x3_same_dims.txt\");\n\t};\n\n\tfeature(\"Assigning a matrix with same dimensions but different types\") = []() {\n\t\tusing mats = join_mats<all_mats<int, 2, 3>, all_mats_reverse<int, 2, 3>, all_mats<int, 2, 3>>;\n\n\t\ttest_assign_mat<mats, false>(\"assign/2x3_same_dims.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/2x3_same_dims.txt\");\n\t};\n\n\tfeature(\"Expanding dynamic matrices by 2D range (dynamic matrices only)\") = []() {\n\t\tusing mats = join_mats<dyn_mat<int>, dyn_mat<int>>;\n\n\t\ttest_assign_rng<mats, false>(\"assign/2x3_10x10_expand.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/2x3_10x10_expand.txt\");\n\t\ttest_assign_rng<mats, false>(\"assign/2x3_10x3_expand.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/2x3_10x3_expand.txt\");\n\t\ttest_assign_rng<mats, false>(\"assign/2x3_2x10_expand.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/2x3_2x10_expand.txt\");\n\t};\n\n\tfeature(\"Shrinking dynamic matrices by 2D range (dynamic matrices only)\") = []() {\n\t\tusing mats = join_mats<dyn_mat<int>, dyn_mat<int>>;\n\n\t\ttest_assign_rng<mats, false>(\"assign/10x10_2x3_shrink.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/10x10_2x3_shrink.txt\");\n\t\ttest_assign_rng<mats, false>(\"assign/10x3_2x3_shrink.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/10x3_2x3_shrink.txt\");\n\t\ttest_assign_rng<mats, false>(\"assign/2x10_2x3_shrink.txt\");\n\t\ttest_assign_rng<mats, true>(\"assign/2x10_2x3_shrink.txt\");\n\t};\n\n\tfeature(\"Expanding dynamic matrices by another matrix (dynamic matrices only)\") = []() {\n\t\tusing mats = join_mats<dyn_mat<int>, dyn_mat<int>, dyn_mat<int>>;\n\n\t\ttest_assign_mat<mats, false>(\"assign/2x3_10x10_expand.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/2x3_10x10_expand.txt\");\n\t\ttest_assign_mat<mats, false>(\"assign/2x3_10x3_expand.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/2x3_10x3_expand.txt\");\n\t\ttest_assign_mat<mats, false>(\"assign/2x3_2x10_expand.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/2x3_2x10_expand.txt\");\n\t};\n\n\tfeature(\"Shrinking dynamic matrices by another matrix (dynamic matrices only)\") = []() {\n\t\tusing mats = join_mats<dyn_mat<int>, dyn_mat<int>, dyn_mat<int>>;\n\n\t\ttest_assign_mat<mats, false>(\"assign/10x10_2x3_shrink.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/10x10_2x3_shrink.txt\");\n\t\ttest_assign_mat<mats, false>(\"assign/10x3_2x3_shrink.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/10x3_2x3_shrink.txt\");\n\t\ttest_assign_mat<mats, false>(\"assign/2x10_2x3_shrink.txt\");\n\t\ttest_assign_mat<mats, true>(\"assign/2x10_2x3_shrink.txt\");\n\t};\n\n\treturn 0;\n}\n", "meta": {"hexsha": "4f5607bba845f202f044884f7b599eb8fc7a2437", "size": 5164, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/src/assign.cpp", "max_stars_repo_name": "sam20908/mpp", "max_stars_repo_head_hexsha": "60450a1573e326015428e9320d9750ec9b937fbb", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 5.0, "max_stars_repo_stars_event_min_datetime": "2021-05-08T10:14:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-25T18:33:53.000Z", "max_issues_repo_path": "tests/src/assign.cpp", "max_issues_repo_name": "sam20908/mpp", "max_issues_repo_head_hexsha": "60450a1573e326015428e9320d9750ec9b937fbb", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 210.0, "max_issues_repo_issues_event_min_datetime": "2021-02-07T00:24:16.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T04:35:24.000Z", "max_forks_repo_path": "tests/src/assign.cpp", "max_forks_repo_name": "sam20908/mpp", "max_forks_repo_head_hexsha": "60450a1573e326015428e9320d9750ec9b937fbb", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.9736842105, "max_line_length": 98, "alphanum_fraction": 0.7155305964, "num_tokens": 1539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.1112411961949534, "lm_q1q2_score": 0.05258187536084624}}
{"text": "// Copyright (C) 2009  Davis E. King (davis@dlib.net)\r\n// License: Boost Software License   See LICENSE.txt for the full license.\r\n\r\n#include \"../tester.h\"\r\n#include <dlib/matrix.h>\r\n\r\n#ifndef DLIB_USE_BLAS\r\n#error \"BLAS bindings must be used for this test to make any sense\"\r\n#endif\r\n\r\nnamespace dlib\r\n{\r\n    namespace blas_bindings\r\n    {\r\n        // This is a little screwy.  This function is used inside the BLAS\r\n        // bindings to count how many times each of the BLAS functions get called.\r\n#ifdef DLIB_TEST_BLAS_BINDINGS\r\n        int& counter_gemv() { static int counter = 0; return counter; }\r\n#endif\r\n\r\n    }\r\n}\r\n\r\nnamespace  \r\n{\r\n    using namespace test;\r\n    using namespace std;\r\n    // Declare the logger we will use in this test.  The name of the logger \r\n    // should start with \"test.\"\r\n    dlib::logger dlog(\"test.gemv\");\r\n\r\n\r\n    class blas_bindings_gemv_tester : public tester\r\n    {\r\n    public:\r\n        blas_bindings_gemv_tester (\r\n        ) :\r\n            tester (\r\n                \"test_gemv\", // the command line argument name for this test\r\n                \"Run tests for GEMV routines.\", // the command line argument description\r\n                0                     // the number of command line arguments for this test\r\n            )\r\n        {}\r\n\r\n        template <typename matrix_type, typename rv_type, typename cv_type>\r\n        void test_gemv_stuff(\r\n            matrix_type& m,\r\n            cv_type& cv,\r\n            rv_type& rv\r\n        ) const\r\n        {\r\n            using namespace dlib;\r\n            using namespace dlib::blas_bindings;\r\n\r\n            cv_type cv2;\r\n            rv_type rv2;\r\n            typedef typename matrix_type::type scalar_type;\r\n            scalar_type val;\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = m*cv;\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = m*2*cv;\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = m*2*trans(rv);\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            rv2 = trans(m*2*cv);\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            rv2 = rv*m;\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            rv2 = (rv + rv)*m;\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            rv2 = trans(cv)*m;\r\n            DLIB_TEST(counter_gemv() == 1);\r\n            dlog << dlib::LTRACE << 1;\r\n\r\n            counter_gemv() = 0;\r\n            rv2 = trans(cv)*trans(m) + rv*trans(m);\r\n            DLIB_TEST(counter_gemv() == 2);\r\n            dlog << dlib::LTRACE << 2;\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = m*trans(trans(cv)*trans(m) + 3*rv*trans(m));\r\n            DLIB_TEST(counter_gemv() == 3);\r\n\r\n            // This does one dot and one gemv\r\n            counter_gemv() = 0;\r\n            val = trans(cv)*m*trans(rv);\r\n            DLIB_TEST_MSG(counter_gemv() == 1, counter_gemv());\r\n\r\n            // This does one dot and two gemv \r\n            counter_gemv() = 0;\r\n            val = (trans(cv)*m)*(m*trans(rv));\r\n            DLIB_TEST_MSG(counter_gemv() == 2, counter_gemv());\r\n\r\n            // This does one dot and two gemv \r\n            counter_gemv() = 0;\r\n            val = trans(cv)*m*trans(m)*trans(rv);\r\n            DLIB_TEST_MSG(counter_gemv() == 2, counter_gemv());\r\n        }\r\n\r\n\r\n        template <typename matrix_type, typename rv_type, typename cv_type>\r\n        void test_gemv_stuff_conj(\r\n            matrix_type& m,\r\n            cv_type& cv,\r\n            rv_type& rv\r\n        ) const\r\n        {\r\n            using namespace dlib;\r\n            using namespace dlib::blas_bindings;\r\n\r\n            cv_type cv2;\r\n            rv_type rv2;\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = trans(cv)*conj(m);\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = conj(trans(m))*rv;\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = conj(trans(m))*trans(cv);\r\n            DLIB_TEST(counter_gemv() == 1);\r\n\r\n            counter_gemv() = 0;\r\n            cv2 = trans(trans(cv)*conj(2*m) + conj(3*trans(m))*rv + conj(trans(m)*3)*trans(cv));\r\n            DLIB_TEST(counter_gemv() == 3);\r\n\r\n        }\r\n\r\n        void perform_test (\r\n        )\r\n        {\r\n            using namespace dlib;\r\n            typedef dlib::memory_manager<char>::kernel_1a mm;\r\n\r\n            dlog << dlib::LINFO << \"test double\";\r\n            {\r\n                matrix<double> m = randm(4,4);\r\n                matrix<double,0,1> cv = randm(4,1);\r\n                matrix<double,1,0> rv = randm(1,4);\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n            dlog << dlib::LINFO << \"test float\";\r\n            {\r\n                matrix<float> m = matrix_cast<float>(randm(4,4));\r\n                matrix<float,0,1> cv = matrix_cast<float>(randm(4,1));\r\n                matrix<float,1,0> rv = matrix_cast<float>(randm(1,4));\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n            dlog << dlib::LINFO << \"test complex<double>\";\r\n            {\r\n                matrix<complex<double> > m = complex_matrix(randm(4,4), randm(4,4));\r\n                matrix<complex<double>,0,1> cv = complex_matrix(randm(4,1), randm(4,1));\r\n                matrix<complex<double>,1,0> rv = complex_matrix(randm(1,4), randm(1,4));\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n            dlog << dlib::LINFO << \"test complex<float>\";\r\n            {\r\n                matrix<complex<float> > m = matrix_cast<complex<float> >(complex_matrix(randm(4,4), randm(4,4)));\r\n                matrix<complex<float>,0,1> cv = matrix_cast<complex<float> >(complex_matrix(randm(4,1), randm(4,1)));\r\n                matrix<complex<float>,1,0> rv = matrix_cast<complex<float> >(complex_matrix(randm(1,4), randm(1,4)));\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n\r\n            dlog << dlib::LINFO << \"test double\";\r\n            {\r\n                matrix<double,0,0,mm,column_major_layout> m = randm(4,4);\r\n                matrix<double,0,1,mm,column_major_layout> cv = randm(4,1);\r\n                matrix<double,1,0,mm,column_major_layout> rv = randm(1,4);\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n            dlog << dlib::LINFO << \"test float\";\r\n            {\r\n                matrix<float,0,0,mm,column_major_layout> m = matrix_cast<float>(randm(4,4));\r\n                matrix<float,0,1,mm,column_major_layout> cv = matrix_cast<float>(randm(4,1));\r\n                matrix<float,1,0,mm,column_major_layout> rv = matrix_cast<float>(randm(1,4));\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n            dlog << dlib::LINFO << \"test complex<double>\";\r\n            {\r\n                matrix<complex<double>,0,0,mm,column_major_layout > m = complex_matrix(randm(4,4), randm(4,4));\r\n                matrix<complex<double>,0,1,mm,column_major_layout> cv = complex_matrix(randm(4,1), randm(4,1));\r\n                matrix<complex<double>,1,0,mm,column_major_layout> rv = complex_matrix(randm(1,4), randm(1,4));\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n            dlog << dlib::LINFO << \"test complex<float>\";\r\n            {\r\n                matrix<complex<float>,0,0,mm,column_major_layout > m = matrix_cast<complex<float> >(complex_matrix(randm(4,4), randm(4,4)));\r\n                matrix<complex<float>,0,1,mm,column_major_layout> cv = matrix_cast<complex<float> >(complex_matrix(randm(4,1), randm(4,1)));\r\n                matrix<complex<float>,1,0,mm,column_major_layout> rv = matrix_cast<complex<float> >(complex_matrix(randm(1,4), randm(1,4)));\r\n                test_gemv_stuff(m,cv,rv);\r\n            }\r\n\r\n\r\n            print_spinner();\r\n        }\r\n    };\r\n\r\n    blas_bindings_gemv_tester a;\r\n\r\n}\r\n\r\n\r\n", "meta": {"hexsha": "170fa3408ad2d8a61d3d18a829b53272186b7d7b", "size": 7920, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "dlib/test/blas_bindings/blas_bindings_gemv.cpp", "max_stars_repo_name": "ckproc/dlib-19.7", "max_stars_repo_head_hexsha": "0ca40f5e85de2436e557bee9a805d3987d2d9507", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2016-10-11T18:37:52.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-11T18:37:52.000Z", "max_issues_repo_path": "dlib/test/blas_bindings/blas_bindings_gemv.cpp", "max_issues_repo_name": "ckproc/dlib-19.7", "max_issues_repo_head_hexsha": "0ca40f5e85de2436e557bee9a805d3987d2d9507", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 4.0, "max_issues_repo_issues_event_min_datetime": "2018-02-27T15:44:25.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-28T01:26:03.000Z", "max_forks_repo_path": "dlib/test/blas_bindings/blas_bindings_gemv.cpp", "max_forks_repo_name": "ckproc/dlib-19.7", "max_forks_repo_head_hexsha": "0ca40f5e85de2436e557bee9a805d3987d2d9507", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 4.0, "max_forks_repo_forks_event_min_datetime": "2016-04-19T06:15:01.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-02T11:11:57.000Z", "avg_line_length": 34.8898678414, "max_line_length": 141, "alphanum_fraction": 0.5077020202, "num_tokens": 2003, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.45326184801538616, "lm_q2_score": 0.11596072589184252, "lm_q1q2_score": 0.05256057291494218}}
{"text": "// Boost.Geometry (aka GGL, Generic Geometry Library)\r\n// QuickBook Example\r\n\r\n// Copyright (c) 2015, Oracle and/or its affiliates\r\n\r\n// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle\r\n\r\n// Licensed under the Boost Software License version 1.0.\r\n// http://www.boost.org/users/license.html\r\n\r\n//[is_empty\r\n//` Check if a geometry is the empty set\r\n\r\n#include <iostream>\r\n\r\n#include <boost/geometry.hpp>\r\n#include <boost/geometry/geometries/point_xy.hpp>\r\n\r\n\r\nint main()\r\n{\r\n    boost::geometry::model::multi_linestring\r\n        <\r\n            boost::geometry::model::linestring\r\n                <\r\n                    boost::geometry::model::d2::point_xy<double>\r\n                >\r\n        > mls;\r\n    boost::geometry::read_wkt(\"MULTILINESTRING((0 0,0 10,10 0),(1 1,8 1,1 8))\", mls);\r\n    std::cout << \"Is empty? \" << (boost::geometry::is_empty(mls) ? \"yes\" : \"no\") << std::endl;\r\n    boost::geometry::clear(mls);\r\n    std::cout << \"Is empty (after clearing)? \" << (boost::geometry::is_empty(mls) ? \"yes\" : \"no\") << std::endl;\r\n    return 0;\r\n}\r\n\r\n//]\r\n\r\n\r\n//[is_empty_output\r\n/*`\r\nOutput:\r\n[pre\r\nIs empty? no\r\nIs empty (after clearing)? yes\r\n]\r\n*/\r\n//]\r\n", "meta": {"hexsha": "ee56be18cd11c4a6e2a3e4b4b39d85bda06f481a", "size": 1179, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/doc/src/examples/algorithms/is_empty.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/doc/src/examples/algorithms/is_empty.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/doc/src/examples/algorithms/is_empty.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 24.5625, "max_line_length": 112, "alphanum_fraction": 0.5954198473, "num_tokens": 324, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.10669060033653141, "lm_q1q2_score": 0.05251184767856988}}
{"text": "/**\r\n *\r\n * Copyright (C) 2021 Mohammad Javad Dousti, Qing Xie, Mahdi Nazemi,\r\n * and Massoud Pedram. All rights reserved.\r\n *\r\n * Please refer to the LICENSE file for terms of use.\r\n *\r\n */\r\n\r\n#pragma once\r\n\r\n#include <Eigen/SparseCore>\r\n#include <Eigen/Core>\r\n\r\n#include \"general.hpp\"\r\n\r\n// OpenMP header file\r\n#include <omp.h>\r\n\r\n#define NEGLIGIBLE_EPSILON 1e-5\r\n\r\nnamespace utils {\r\nVALUE KtoC(VALUE temp);\r\n\r\nvoid dumpMatrix(const Eigen::SparseMatrix<VALUE>& matrix, const string& file_output);\r\nvoid dumpVector(const Eigen::Matrix<VALUE, Eigen::Dynamic, 1>& vec, const string& file_output);\r\n\r\nbool fileExists(const std::string &name);\r\n\r\nVALUE calcElapsedTime(\r\n    const std::chrono::high_resolution_clock::time_point &start,\r\n    const std::chrono::high_resolution_clock::time_point &end);\r\n\r\n// Inline function for speed up.\r\ninline bool eq(VALUE a, VALUE b) { return fabs(a - b) < NEGLIGIBLE_EPSILON; }\r\ninline bool neq(VALUE a, VALUE b) { return !eq(a, b); }\r\ninline bool less(VALUE a, VALUE b) { return (b - a) > NEGLIGIBLE_EPSILON; }\r\ninline bool le(VALUE a, VALUE b) { return ((a < b) || eq(a, b)); }\r\ninline bool ge(VALUE a, VALUE b) { return ((a > b) || eq(a, b)); }\r\ninline bool greater(VALUE a, VALUE b) { return (a - b) > NEGLIGIBLE_EPSILON; }\r\n\r\n}; // namespace utils\r\n", "meta": {"hexsha": "1edc5bf5fbf39fdfe732606ac8bdc9b0280ff28a", "size": 1290, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/headers/utils.hpp", "max_stars_repo_name": "mjdousti/therminator", "max_stars_repo_head_hexsha": "d706ab43ac97a4266ce19618b1e35d4e0245cd5b", "max_stars_repo_licenses": ["Xnet", "X11", "RSA-MD"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2019-09-26T00:09:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-09T03:19:38.000Z", "max_issues_repo_path": "src/headers/utils.hpp", "max_issues_repo_name": "mjdousti/therminator", "max_issues_repo_head_hexsha": "d706ab43ac97a4266ce19618b1e35d4e0245cd5b", "max_issues_repo_licenses": ["Xnet", "X11", "RSA-MD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/headers/utils.hpp", "max_forks_repo_name": "mjdousti/therminator", "max_forks_repo_head_hexsha": "d706ab43ac97a4266ce19618b1e35d4e0245cd5b", "max_forks_repo_licenses": ["Xnet", "X11", "RSA-MD"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2015-08-03T01:41:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-06T18:14:11.000Z", "avg_line_length": 30.0, "max_line_length": 96, "alphanum_fraction": 0.676744186, "num_tokens": 345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49218813572079556, "lm_q2_score": 0.10669058968506455, "lm_q1q2_score": 0.05251184243604426}}
{"text": "/*\n * @file\n *\n *  Created on: Oct 8, 2018\n *      Author: koldar\n */\n\n#ifndef XYLOC_H_\n#define XYLOC_H_\n\n#include <boost/functional/hash.hpp>\n#include <cstdint>\n#include <iostream>\n#include \"types.hpp\"\n\nnamespace pathfinding {\n\n\t/**\n\t * A direction of a movement within the grid\n\t */\n\tenum class Direction {\n\t\tNORTH,\n\t\tSOUTH,\n\t\tEAST,\n\t\tWEST,\n\t\tNORTHWEST,\n\t\tNORTHEAST,\n\t\tSOUTHWEST,\n\t\tSOUTHEAST\n\t};\n\n\tnamespace DirectionMethods {\n\n\t\t/**\n\t\t * @brief \n\t\t * \n\t\t * @param dir  the direction involved\n\t\t * @return true if dir is either north, south, east or west\n\t\t * @return false otherwise\n\t\t */\n\t\tbool isStraight(Direction dir);\n\n\t\t/**\n\t\t * @brief \n\t\t * \n\t\t * @param dir the direction involved\n\t\t * @return true if dir is not straight\n\t\t * @return false otherwise\n\t\t */\n\t\tbool isDiagonal(Direction dir);\n\n\n\t\t/**\n\t\t * @param[in] dir a direction\n\t\t * @return the label associated\n\t\t * ted to a direction\n\t\t */\n\t\tconst char* getLabel(const Direction& dir);\n\n\t}\n\n\tstd::ostream& operator <<(std::ostream& ss, const Direction& dir);\n\n\t/**\n\t * represent a position in the grid.\n\t *\n\t * Inside the grid, \"x\" is the column while \"y\" is the row.\n\t * \n\t */\n\tstruct xyLoc {\n\t\t///x coordinate\n\t\tucood_t x;\n\t\t///y coordinate\n\t\tucood_t y;\n\n\t\txyLoc(ucood_t x, ucood_t y) : x{x}, y{y} {\n\n\t\t}\n\n\t\txyLoc(ucood_t t): x{t}, y{t} {\n\n\t\t}\n\n\t\txyLoc(): x{0}, y{0} {\n\n\t\t}\n\n\t\txyLoc(const xyLoc& other): x{other.x}, y{other.y} {\n\n\t\t}\n\n\t\txyLoc(xyLoc&& other): x{other.x}, y{other.y} {\n\n\t\t}\n\n\t\txyLoc& operator =(const xyLoc& other) {\n\t\t\tthis->x = other.x;\n\t\t\tthis->y = other.y;\n\t\t\treturn *this;\n\t\t};\n\t\txyLoc& operator =(xyLoc&& other) {\n\t\t\tthis->x = other.x;\n\t\t\tthis->y = other.y;\n\t\t\treturn *this;\n\t\t};\n\t\txyLoc& operator +=(const xyLoc& other) = delete;\n\t\txyLoc& operator -=(const xyLoc& other) = delete;\n\t\txyLoc& operator *=(const xyLoc& other) = delete;\n\t\txyLoc& operator /=(const xyLoc& other) = delete;\n\n\t\t/**\n\t\t * The direction a cell is relative to another one\n\t\t *\n\t\t * for example if the current location is <tt>5,5</tt> and @c to is <tt>5,4</tt> the direction will be @c west because\n\t\t * the second cell is on the west of the first one.\n\t\t *\n\t\t * @param[in] to the cell (other than this one) where we need to look at\n\t\t * @return the direction between this cell and @c\n\t\t */\n\t\tDirection getDirectionTo(const xyLoc& to) const;\n\n\t\t/**\n\t\t * like ::xyLoc::getDirectionTo but we can specific 2 location, not just one\n\t\t *\n\t\t * @param[in] from the first cell to consider\n\t\t * @param[in] to the second cell to consider\n\t\t * @return the direction @c to is relative to @c from\n\t\t */\n\t\tstatic Direction getDirection(const xyLoc& from, const xyLoc& to);\n\n\t\t/**\n\t\t *\n\t\t * 2 locations are immediately adjacent one to the other iff they shares a side or a point.\n\t\t *\n\t\t * for example \\f$(4,5)\\f$ is adjacent with \\f$(4,6)\\f$ or \\f$(3,4)\\f$ but is not adjacent with \\f$(100, 400)\\f$.\n\t\t *\n\t\t * If @c US represents this xyLoc location, \"OK\" stands for location immediately adjacent while \"KO\" stands for location not immediately adjacent.\n\t\t *\n\t\t *\n\t\t * |--|--|--|--|\n\t\t * |OK|OK|OK|KO|\n\t\t * |OK|US|OK|KO|\n\t\t * |OK|OK|OK|KO|\n\t\t *\n\t\t * @note\n\t\t * This definition does not take into consideration if the underlying map is traversable or not in the involved locations\n\t\t *\n\t\t *\n\t\t * @param[in] other the location to test against\n\t\t * @return\n\t\t *  @li true if this location is immediately adjacent to @c other;\n\t\t *  @li false otherwise\n\t\t */\n\t\tbool isAdjacentTo(const xyLoc& other) const;\n\n\t\t/**\n\t\t * @brief check if, starting from this, we can go in a particular direction\n\t\t * \n\t\t * @code\n\t\t * \t{5,3}.isThereLocationInDirectionOf(LEFT, {5,5}); //yes\n\t\t *  {5,3}.isThereLocationInDirectionOf(RIGHT, {5,5}); //no\n\t\t * @endcode\n\t\t * \n\t\t * @param dir the direction we should follow to check if there is another xyLoc.\n\t\t * @param maxPoint coordinates representing the bottom right corner of an invisible rectangle we cannot escape from. You can have a location set to this point\n\t\t * @param minPoint coordinates representing the top left corner of an invisible rectangle we cannot escape from. You can have a location set to this point\n\t\t * @return true if there is a clocation adjacent to self by following @c dir\n\t\t * @return false \n\t\t */\n\t\tbool isThereLocationInDirectionOf(Direction dir, xyLoc maxPoint, xyLoc minPoint = {0, 0}) const;\n\n\t\t/**\n\t\t * @brief Get the Nearby Diagonale Cells object\n\t\t * \n\t\t * If `loc1` and `loc2` are marked as `1` and `2` the out locations will be \"a\" and \"b\"\n\t\t * @code\n\t\t * 1|a\n\t\t * -|-\n\t\t * b|2\n\t\t * @endcode\n\t\t * \n\t\t * @pre\n\t\t *  @li loc1 adjacent to loc2\n\t\t * \n\t\t * @param loc1 first location\n\t\t * @param loc2 second location\n\t\t * @return a pair representing the adjacent cells\n\t\t */\n\t\tstatic std::pair<xyLoc, xyLoc> getNearbyDiagonalCells(const xyLoc& loc1, const xyLoc& loc2);\n\n\t\t/**\n\t\t * The coordiante system is in the topLeft corner (0,0) while the infinity is in the bottomRight\n\t\t *\n\t\t * locationns within the border of the rectangle are considered as well\n\t\t *\n\t\t * @param[in] topLeft the point representing a point of the rectangle\n\t\t * @param[in] bottomRight the point representing a point of the rectangle\n\t\t * @return\n\t\t *  @li true if the point is inside the rectangle generated by @c topLeft and @c bottomRight\n\t\t */\n\t\tbool isInside(const xyLoc& topLeft, const xyLoc& bottomRight) const {\n\t\t\treturn (topLeft.x <= this->x)&&(this->x <= bottomRight.x) &&\n\t\t\t\t\t(topLeft.y <= this->y)&&(this->y <= bottomRight.y);\n\t\t}\n\n\t\t/**\n\t\t * @brief return the distance between 2 points, ignoring sign\n\t\t * \n\t\t * For example here:\n\t\t * \n\t\t * ```\n\t\t * | |B| | |\n\t\t * | | | | |\n\t\t * | | | | |\n\t\t * | | | |A|\n\t\t * ```\n\t\t * \n\t\t * it would be `<-2, -3>` but with this method it will return `<2, 3>`\n\t\t * \n\t\t * @param other the other point\n\t\t * @return xyLoc \n\t\t */\n\t\txyLoc getDistance(const xyLoc& other) const {\n\t\t\tcood_t ax = static_cast<cood_t>(this->x);\n\t\t\tcood_t ay = static_cast<cood_t>(this->y);\n\t\t\tcood_t bx = static_cast<cood_t>(other.x);\n\t\t\tcood_t by = static_cast<cood_t>(other.y);\n\n\t\t\treturn xyLoc{\n\t\t\t\tstatic_cast<ucood_t>(std::abs(ax - bx)), \n\t\t\t\tstatic_cast<ucood_t>(std::abs(ay - by))\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * @brief get the adjacent cell of self by following a direction\n\t\t * \n\t\t * @note\n\t\t * UB if you don't check with ::isThereLocationInDirectionOf if the direction might generate a result\n\t\t * \n\t\t * @param dir ther direction to follow to obtain a new location\n\t\t * @return xyLoc the adjacent location by following a particular direction\n\t\t */\n\t\txyLoc getAdjacent(Direction dir) const;\n\n\t\t/**\n\t\t * @brief Get the Min Coordinate object\n\t\t * \n\t\t * @return ucood_t the coordinate which has the least value between x and y\n\t\t */\n\t\tucood_t getMinCoordinate() const {\n\t\t\treturn this->x < this->y ? this->x : this->y;\n\t\t}\n\n\t\t/**\n\t\t * @brief Get the Max Coordinate object\n\t\t * \n\t\t * @return ucood_t the coordinate which has the greatest value between x and y\n\t\t */\n\t\tucood_t getMaxCoordinate() const {\n\t\t\treturn this->x > this->y ? this->x : this->y;\n\t\t}\n\n\t\tfriend std::size_t hash_value(const xyLoc& p) {\n\t\t\tstd::size_t seed = 0;\n\t\t\tboost::hash_combine(seed, p.x);\n\t\t\tboost::hash_combine(seed, p.y);\n\n\t\t\treturn seed;\n\t\t}\n\t};\n\n\tstd::ostream& operator<<(std::ostream& str, const xyLoc& v);\n\tbool operator==(const xyLoc& a, const xyLoc& b);\n\tbool operator!=(const xyLoc& a, const xyLoc& b);\n\txyLoc operator +(const xyLoc& a, const xyLoc& b);\n\txyLoc operator +(const xyLoc& a, int value);\n\txyLoc operator -(const xyLoc& a, const xyLoc& b);\n\txyLoc operator -(const xyLoc& a, int value);\n\n\t/**\n\t * @brief anew xyLoc containing the minimum of the coordinates of 2 xyLoc\n\t * \n\t * @code\n\t * \tmin.x = min(a.x, b.x);\n\t *  min.y = min(a.y, b.y);\n\t * @endcode\n\t * \n\t * @param a first location\n\t * @param b second location\n\t * @return xyLoc minimum of coordinates\n\t */\n\txyLoc min(const xyLoc& a, const xyLoc& b);\n\t/**\n\t * @brief a new xyLoc containing the maximum of the coordinates of 2 xyLoc\n\t * \n\t * @code\n\t * \tmax.x = max(a.x, b.x);\n\t *  max.y = max(a.y, b.y);\n\t * @endcode\n\t * \n\t * @param a first location\n\t * @param b second location\n\t * @return xyLoc maximum of coordinates\n\t */\n\txyLoc max(const xyLoc& a, const xyLoc& b);\n\n}\n\nnamespace std {\n\n\ttemplate <>\n\tstruct hash<pathfinding::xyLoc> {\n\tpublic:\n\t\tsize_t operator()(const pathfinding::xyLoc& l) const {\n\t\t\tsize_t seed = 0;\n\t\t\tboost::hash_combine(seed, l.x);\n\t\t\tboost::hash_combine(seed, l.y);\n\t\t\treturn seed;\n\t\t}\n\t};\n\n}\n\n#endif /* XYLOC_H_ */\n", "meta": {"hexsha": "f2941cf17afd5e2124f970273553d3b93ad967cc", "size": 8387, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/main/include/xyLoc.hpp", "max_stars_repo_name": "Koldar/pathfinding-utils", "max_stars_repo_head_hexsha": "e1c67bbb9eb0dca9f9f748f2f929310a7ab319f8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2020-10-04T00:52:20.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-19T06:46:04.000Z", "max_issues_repo_path": "src/main/include/xyLoc.hpp", "max_issues_repo_name": "Koldar/pathfinding-utils", "max_issues_repo_head_hexsha": "e1c67bbb9eb0dca9f9f748f2f929310a7ab319f8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/main/include/xyLoc.hpp", "max_forks_repo_name": "Koldar/pathfinding-utils", "max_forks_repo_head_hexsha": "e1c67bbb9eb0dca9f9f748f2f929310a7ab319f8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.726993865, "max_line_length": 160, "alphanum_fraction": 0.6358650292, "num_tokens": 2576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091946, "lm_q2_score": 0.10521054371715848, "lm_q1q2_score": 0.052194301533362734}}
{"text": "/* vim: set tabstop=4 expandtab shiftwidth=4 softtabstop=4: */\n\n/**\n * \\file boost/numeric/ublasx/operation/which.hpp\n *\n * \\brief Find the positions of the elments of a given container which satisfy\n *  a given unary predicate.\n *\n * \\author Marco Guazzone (marco.guazzone@gmail.com)\n *\n * <hr/>\n *\n * Copyright (c) 2010, Marco Guazzone\n *\n * Distributed under the Boost Software License, Version 1.0. (See\n * accompwhiching file LICENSE_1_0.txt or copy at\n * http://www.boost.org/LICENSE_1_0.txt)\n */\n\n#ifndef BOOST_NUMERIC_UBLASX_OPERATION_WHICH_HPP\n#define BOOST_NUMERIC_UBLASX_OPERATION_WHICH_HPP\n\n\n#include <boost/numeric/ublas/detail/config.hpp>\n#include <boost/numeric/ublas/expression_types.hpp>\n#include <boost/numeric/ublas/traits.hpp>\n#include <boost/numeric/ublas/vector.hpp>\n#include <boost/numeric/ublasx/operation/num_columns.hpp>\n#include <boost/numeric/ublasx/operation/num_rows.hpp>\n#include <boost/numeric/ublasx/operation/size.hpp>\n#include <functional>\n\n\n//TODO: implement the 'which' operation for matrix expressions\n\nnamespace boost { namespace numeric { namespace ublasx {\n\nusing namespace ::boost::numeric::ublas;\n\n\n//@{ Declarations\n\n/**\n * \\brief Find the positions of the elments of the given vector expression\n *  which satisfy the given unary predicate.\n * \\tparam VectorExprT The type of the vector expression.\n * \\tparam UnaryPredicateT The type of the unary predicate functor.\n * \\param ve The vector expression over which check for the predicate.\n * \\param p The unary predicate functor: must accept one argument and return\n *  a boolean value.\n * \\return A vector of positions of the elements of the given vector\n *  expression which satisfy the given predicate; an empty vector, if no element\n *  satisfies the given predicate.\n *\n * \\author Marco Guazzone, &lt;marco.guazzone@gmail.com&gt;\n */\ntemplate <typename VectorExprT, typename UnaryPredicateT>\nvector<typename vector_traits<VectorExprT>::size_type> which(vector_expression<VectorExprT> const& ve, UnaryPredicateT p);\n\n/**\n * \\brief Find the positions of the non-zero elments of the given vector\n *  expression.\n * \\tparam VectorExprT The type of the vector expression.\n * \\param ve The vector expression over which check for existence of non-zero\n *  elements.\n * \\return A vector of positions of the non-zero elements of the given vector\n *  expression; an empty vector, if no non-zero element is found.\n *\n * \\note The test for zero equality is done in the strong sense, that is by not\n *  using which tolerance.\n *  For checking for \"weak\" zero equality between a given tolerance use the\n *  two-argument version of this function with an appropriate predicate.\n *\n * \\author Marco Guazzone, &lt;marco.guazzone@gmail.com&gt;\n */\ntemplate <typename VectorExprT>\nvector<typename vector_traits<VectorExprT>::size_type> which(vector_expression<VectorExprT> const& ve);\n\n//@} Declarations\n\n\n//@{ Definitions\n\ntemplate <typename VectorExprT, typename UnaryPredicateT>\nBOOST_UBLAS_INLINE\nvector<typename vector_traits<VectorExprT>::size_type> which(vector_expression<VectorExprT> const& ve, UnaryPredicateT p)\n{\n    typedef typename vector_traits<VectorExprT>::size_type size_type;\n\n    vector<size_type> res;\n    size_type n = size(ve);\n    size_type j = 0;\n    for (size_type i = 0; i < n; ++i)\n    {\n        if (p(ve()(i)))\n        {\n            res.resize(res.size()+1);\n            res(j++) = i;\n        }\n    }\n\n    return res;\n}\n\n\ntemplate <typename VectorExprT>\nBOOST_UBLAS_INLINE\nvector<typename vector_traits<VectorExprT>::size_type> which(vector_expression<VectorExprT> const& ve)\n{\n    typedef typename vector_traits<VectorExprT>::value_type value_type;\n\n    return which(ve, ::std::bind2nd(::std::not_equal_to<value_type>(), 0));\n}\n\n//@} Definitions\n\n}}} // Namespace boost::numeric::ublasx\n\n\n#endif // BOOST_NUMERIC_UBLASX_OPERATION_WHICH_HPP\n", "meta": {"hexsha": "6d2b0bf79429e254390064b25f66d9c437026555", "size": 3848, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/numeric/ublasx/operation/which.hpp", "max_stars_repo_name": "sguazt/boost-ublasx", "max_stars_repo_head_hexsha": "21c9b393d33a6ec2a8071ba8d48680073d766409", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 7.0, "max_stars_repo_stars_event_min_datetime": "2016-05-14T11:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T14:22:20.000Z", "max_issues_repo_path": "boost/numeric/ublasx/operation/which.hpp", "max_issues_repo_name": "sguazt/boost-ublasx", "max_issues_repo_head_hexsha": "21c9b393d33a6ec2a8071ba8d48680073d766409", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2020-12-28T18:36:04.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-06T11:28:51.000Z", "max_forks_repo_path": "boost/numeric/ublasx/operation/which.hpp", "max_forks_repo_name": "sguazt/boost-ublasx", "max_forks_repo_head_hexsha": "21c9b393d33a6ec2a8071ba8d48680073d766409", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-12-23T02:53:27.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-23T02:53:27.000Z", "avg_line_length": 31.8016528926, "max_line_length": 122, "alphanum_fraction": 0.7424636175, "num_tokens": 947, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4960938294709195, "lm_q2_score": 0.10521052688338609, "lm_q1q2_score": 0.05219429318223213}}
{"text": "/*\n*   back up Eigen vector of matrix to CSV file\n*   by R. Falque\n*   30/07/2019\n*/\n\n#ifndef EIGEN_WRITE_TO_CSV_HPP\n#define EIGEN_WRITE_TO_CSV_HPP\n\n#include <Eigen/Core>\n#include <iostream>\n#include <fstream>\n#include <string>\n\nconst static Eigen::IOFormat CSVFormat(Eigen::StreamPrecision, Eigen::DontAlignCols, \", \", \"\\n\");\n\ntemplate <typename T>\ninline bool EigenWriteToCSVfile(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> matrix, std::string name)\n{\n    std::ofstream file(name.c_str());\n    file << matrix.format(CSVFormat);\n    file.close();\n\n    return true;\n};\n\n\ninline bool EigenWriteToCSVfile(Eigen::VectorXi matrix, std::string name)\n{\n    std::ofstream file(name.c_str());\n    file << matrix.format(CSVFormat);\n    file.close();\n\n    return true;\n};\n\n#endif\n", "meta": {"hexsha": "c28f486b376f504ace1732f203de23c32253577f", "size": 775, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "utils/EigenTools/writeToCSV.hpp", "max_stars_repo_name": "rFalque/normals_transfer", "max_stars_repo_head_hexsha": "c0c27fb6e3bce32123489442f3b606f9be00b56e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "utils/EigenTools/writeToCSV.hpp", "max_issues_repo_name": "rFalque/normals_transfer", "max_issues_repo_head_hexsha": "c0c27fb6e3bce32123489442f3b606f9be00b56e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "utils/EigenTools/writeToCSV.hpp", "max_forks_repo_name": "rFalque/normals_transfer", "max_forks_repo_head_hexsha": "c0c27fb6e3bce32123489442f3b606f9be00b56e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.3947368421, "max_line_length": 106, "alphanum_fraction": 0.6967741935, "num_tokens": 203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4687906266262437, "lm_q2_score": 0.11124120061463458, "lm_q1q2_score": 0.05214883214279023}}
{"text": "//\n// Copyright (c) 2009 Rutger ter Borg\n//\n// Distributed under the Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt or copy at\n// http://www.boost.org/LICENSE_1_0.txt)\n//\n\n#ifndef BOOST_NUMERIC_BINDINGS_STD_VALARRAY_HPP\n#define BOOST_NUMERIC_BINDINGS_STD_VALARRAY_HPP\n\n#include <boost/numeric/bindings/detail/adaptor.hpp>\n#include <valarray>\n\nnamespace boost {\nnamespace numeric {\nnamespace bindings {\nnamespace detail {\n\ntemplate< typename T, typename Id, typename Enable >\nstruct adaptor< std::valarray< T >, Id, Enable > {\n\n    typedef typename copy_const< Id, T >::type value_type;\n    typedef mpl::map<\n        mpl::pair< tag::value_type, value_type >,\n        mpl::pair< tag::entity, tag::vector >,\n        mpl::pair< tag::size_type<1>, std::ptrdiff_t >,\n        mpl::pair< tag::data_structure, tag::linear_array >,\n        mpl::pair< tag::stride_type<1>, tag::contiguous >\n    > property_map;\n\n    static std::ptrdiff_t size1( const Id& id ) {\n        return id.size();\n    }\n\n    static value_type* begin_value( Id& id ) {\n        return &const_cast< std::valarray< T >& >( id )[0];\n    }\n\n    static value_type* end_value( Id& id ) {\n        return &const_cast< std::valarray< T >& >( id )[0] + id.size();\n    }\n\n};\n\n} // namespace detail\n} // namespace bindings\n} // namespace numeric\n} // namespace boost\n\n#endif\n", "meta": {"hexsha": "e919db3b9e76f9a884e4f8343f2d485925f25b1a", "size": 1356, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "externals/numeric_bindings/boost/numeric/bindings/std/valarray.hpp", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137.0, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "externals/numeric_bindings/boost/numeric/bindings/std/valarray.hpp", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381.0, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "externals/numeric_bindings/boost/numeric/bindings/std/valarray.hpp", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 26.0769230769, "max_line_length": 71, "alphanum_fraction": 0.6607669617, "num_tokens": 353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4610167793123159, "lm_q2_score": 0.11279539584450776, "lm_q1q2_score": 0.052000570113492746}}
{"text": "/*    Copyright (c) 2010-2019, Delft University of Technology\n *    All rigths reserved\n *\n *    This file is part of the Tudat. Redistribution and use in source and\n *    binary forms, with or without modification, are permitted exclusively\n *    under the terms of the Modified BSD license. You should have received\n *    a copy of the license with this file. If not, please or visit:\n *    http://tudat.tudelft.nl/LICENSE.\n *\n *    Notes\n *      If tabs are used as spaces, it doesn't work. The seperator should also be tabs then.\n *\n */\n\n#define BOOST_TEST_MAIN\n\n#include <cmath>\n#include <limits>\n#include <stdexcept>\n#include <iostream>\n\n#include <boost/test/floating_point_comparison.hpp>\n#include <boost/test/unit_test.hpp>\n\n#include <Eigen/Core>\n\n#include \"Tudat/Basics/testMacros.h\"\n#include \"Tudat/InputOutput/basicInputOutput.h\"\n#include \"Tudat/InputOutput/mapTextFileReader.h\"\n\nnamespace tudat\n{\n\nnamespace unit_tests\n{\n\n// Test if matrix text file reader is working correctly.\nBOOST_AUTO_TEST_CASE( testMatrixTextFileReader )\n{\n\n    // Test 1\n    {\n        // Set expected matrix.\n        std::map< int, std::vector< int > > expectedMap = {\n            { 1, { 1, 2 } },\n            { 2, { 1, 2, 4 } },\n            { 3, { 1, 2, 4, 8 } },\n            { 4, { 1, 2, 4, 8, 16 } }\n        };\n\n        // Read input file and store data in matrix.\n        auto inputFileMap = input_output::readStlVectorMapFromFile< int, int >(\n                    input_output::getTudatRootPath( ) + \"/InputOutput/UnitTests/testMap1.txt\" );\n\n        bool allEqual = true;\n        // Check if data input file matrix matches expected matrix.\n        try\n        {\n            for ( auto ent: inputFileMap )\n            {\n                auto key = ent.first;\n                auto values = ent.second;\n                for ( unsigned int i = 0; i < values.size(); i++ )\n                {\n                    if ( inputFileMap[ key ][ i ] != expectedMap[ key ][ i ] )\n                    {\n                        std::cout << \"Element at \" << i << \" for key \" << key << \" (\"\n                                  << inputFileMap[ key ][ i ] << \") does not match expected value of \"\n                                  << \"(\" << expectedMap[ key ][ i ] << \").\" << std::endl;\n                        allEqual = false;\n                        break;\n                    }\n                }\n                if ( ! allEqual )\n                {\n                    break;\n                }\n            }\n        }\n        catch( std::runtime_error &inconsistentSizes )\n        {\n            std::cout << \"Maps have different keys or inconsistent sizes.\" << std::endl;\n            allEqual = false;\n        }\n\n        BOOST_CHECK( allEqual );\n\n    }\n\n\n    // Test 2\n    {\n        // Set expected matrix.\n        std::map< double, std::vector< float > > expectedMap = {\n            { 0.0, {  0.5, 0.8 } },\n            { 0.1, { -0.5, 1.0 } },\n            { 0.2, {  0.5 } },\n            { 0.3, {  1e6, 1.0, 1.0 } }\n        };\n\n        // Read input file and store data in matrix.\n        auto inputFileMap = input_output::readStlVectorMapFromFile< double, float >(\n                    input_output::getTudatRootPath( ) + \"/InputOutput/UnitTests/testMap2.txt\" );\n\n        bool allEqual = true;\n        // Check if data input file matrix matches expected matrix.\n        try\n        {\n            for ( auto ent: inputFileMap )\n            {\n                auto key = ent.first;\n                auto values = ent.second;\n                for ( unsigned int i = 0; i < values.size(); i++ )\n                {\n                    if ( inputFileMap[ key ][ i ] != expectedMap[ key ][ i ] )\n                    {\n                        std::cout << \"Element at \" << i << \" for key \" << key << \" (\"\n                                  << inputFileMap[ key ][ i ] << \") does not match expected value of \"\n                                  << \"(\" << expectedMap[ key ][ i ] << \").\" << std::endl;\n                        allEqual = false;\n                        break;\n                    }\n                }\n                if ( ! allEqual )\n                {\n                    break;\n                }\n            }\n        }\n        catch( std::runtime_error &inconsistentSizes )\n        {\n            std::cout << \"Maps have different keys or inconsistent sizes.\" << std::endl;\n            allEqual = false;\n        }\n\n        BOOST_CHECK( allEqual );\n\n    }\n\n\n    // Test 1\n    {\n        // Set expected matrix.\n        std::map< std::string, std::vector< std::string > > expectedMap = {\n            { \"x\", { \"one\", \"two\" } },\n            { \"y\", { \"three\", \"four\", \"five\" } },\n            { \"z\", { \"six\" } }\n        };\n\n        // Read input file and store data in matrix.\n        auto inputFileMap = input_output::readStlVectorMapFromFile< std::string, std::string >(\n                    input_output::getTudatRootPath( ) + \"/InputOutput/UnitTests/testMap3.txt\" );\n\n        bool allEqual = true;\n        // Check if data input file matrix matches expected matrix.\n        try\n        {\n            for ( auto ent: inputFileMap )\n            {\n                auto key = ent.first;\n                auto values = ent.second;\n                for ( unsigned int i = 0; i < values.size(); i++ )\n                {\n                    if ( inputFileMap[ key ][ i ] != expectedMap[ key ][ i ] )\n                    {\n                        std::cout << \"Element at \" << i << \" for key \" << key << \" (\"\n                                  << inputFileMap[ key ][ i ] << \") does not match expected value of \"\n                                  << \"(\" << expectedMap[ key ][ i ] << \").\" << std::endl;\n                        allEqual = false;\n                        break;\n                    }\n                }\n                if ( ! allEqual )\n                {\n                    break;\n                }\n            }\n        }\n        catch( std::runtime_error &inconsistentSizes )\n        {\n            std::cout << \"Maps have different keys or inconsistent sizes.\" << std::endl;\n            allEqual = false;\n        }\n\n        BOOST_CHECK( allEqual );\n\n    }\n\n\n\n}\n\n} // namespace unit_tests\n\n} // namespace tudat\n", "meta": {"hexsha": "b4c0a9a1df1e15ad4e57d47e1a5075062c3e884c", "size": 6178, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/InputOutput/UnitTests/unitTestMapTextFileReader.cpp", "max_stars_repo_name": "sebranchett/tudat", "max_stars_repo_head_hexsha": "24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/InputOutput/UnitTests/unitTestMapTextFileReader.cpp", "max_issues_repo_name": "sebranchett/tudat", "max_issues_repo_head_hexsha": "24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/InputOutput/UnitTests/unitTestMapTextFileReader.cpp", "max_forks_repo_name": "sebranchett/tudat", "max_forks_repo_head_hexsha": "24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.5204081633, "max_line_length": 102, "alphanum_fraction": 0.4551634833, "num_tokens": 1424, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4301473485858429, "lm_q2_score": 0.12085322140796938, "lm_q1q2_score": 0.05198469275669586}}
{"text": "#define BOOST_TEST_MODULE factorial shared library test\n#define BOOST_TEST_DYN_LINK\n#include <boost/test/unit_test.hpp>\n\n#include \"factorial.cpp\"\n\nBOOST_AUTO_TEST_CASE(Factorials_for_zero) {\n    BOOST_TEST( Factorial(0) == 1 );\n}\n\nBOOST_AUTO_TEST_CASE(Factorials_for_positive_numbers) {\n    BOOST_TEST( Factorial(1) == 1 );\n    BOOST_TEST( Factorial(2) == 2 );\n    BOOST_TEST( Factorial(3) == 6 );\n    BOOST_TEST( Factorial(10) == 3628800 );\n}", "meta": {"hexsha": "e4ed5c12385d59036c93c79299f573b3d9a8ccdc", "size": 443, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/boost-shared-tests-factorial.cpp", "max_stars_repo_name": "mekyas/Unit-Test-in-Cpp", "max_stars_repo_head_hexsha": "dabfc7f83380c2c056c421bbf9f71f54acca8a0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2.0, "max_stars_repo_stars_event_min_datetime": "2021-11-18T05:42:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T05:43:59.000Z", "max_issues_repo_path": "test/boost-shared-tests-factorial.cpp", "max_issues_repo_name": "mekyas/Unit-Test-in-Cpp", "max_issues_repo_head_hexsha": "dabfc7f83380c2c056c421bbf9f71f54acca8a0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/boost-shared-tests-factorial.cpp", "max_forks_repo_name": "mekyas/Unit-Test-in-Cpp", "max_forks_repo_head_hexsha": "dabfc7f83380c2c056c421bbf9f71f54acca8a0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6875, "max_line_length": 55, "alphanum_fraction": 0.7291196388, "num_tokens": 122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.480478678047907, "lm_q2_score": 0.10818896462614715, "lm_q1q2_score": 0.05198249070294295}}
{"text": "/**\n * @file laxwendroffscheme_main.cc\n * @brief NPDE homework \"LaxWendroffScheme\" code\n * @author Oliver Rietmann\n * @date 29.04.2019\n * @copyright Developed at ETH Zurich\n */\n\n#include <Eigen/Core>\n#include <fstream>\n#include <iostream>\n\n#include \"laxwendroffscheme.h\"\n\nusing namespace LaxWendroffScheme;\n\nconst static Eigen::IOFormat CSVFormat(Eigen::FullPrecision,\n                                       Eigen::DontAlignCols, \", \", \"\\n\");\n\nint main() {\n  Eigen::VectorXi M(6);\n  M << 20, 40, 80, 160, 320, 640;\n\n  Eigen::VectorXd error_LaxWendroffRP = numexpLaxWendroffRP(M);\n  Eigen::VectorXd error_LaxWendroffSmoothU0 = numexpLaxWendroffSmoothU0(M);\n  Eigen::VectorXd error_GodunovSmoothU0 = numexpGodunovSmoothU0(M);\n\n  std::ofstream file;\n  file.open(\"convergence.csv\");\n  file << M.transpose().format(CSVFormat) << std::endl;\n  file << error_LaxWendroffRP.transpose().format(CSVFormat) << std::endl;\n  file << error_LaxWendroffSmoothU0.transpose().format(CSVFormat) << std::endl;\n  file << error_GodunovSmoothU0.transpose().format(CSVFormat) << std::endl;\n  file.close();\n  std::cout << \"Generated \" CURRENT_BINARY_DIR \"/convergence.csv\" << std::endl;\n\n  // To plot from convergence.csv uncomment this:\n  // std::system(\"python3 \" CURRENT_SOURCE_DIR \"/plot.py \" CURRENT_BINARY_DIR\n  // \"/convergence.csv \" CURRENT_BINARY_DIR \"/convergence.eps\");\n\n  return 0;\n}\n", "meta": {"hexsha": "fffd78b9b74de4e598f56016a1069deed192ca2c", "size": 1370, "ext": "cc", "lang": "C++", "max_stars_repo_path": "homeworks/LaxWendroffScheme/templates/laxwendroffscheme_main.cc", "max_stars_repo_name": "padomu/NPDECODES", "max_stars_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15.0, "max_stars_repo_stars_event_min_datetime": "2019-04-29T11:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T05:10:58.000Z", "max_issues_repo_path": "homeworks/LaxWendroffScheme/templates/laxwendroffscheme_main.cc", "max_issues_repo_name": "padomu/NPDECODES", "max_issues_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12.0, "max_issues_repo_issues_event_min_datetime": "2020-02-29T15:05:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T13:51:07.000Z", "max_forks_repo_path": "homeworks/LaxWendroffScheme/templates/laxwendroffscheme_main.cc", "max_forks_repo_name": "padomu/NPDECODES", "max_forks_repo_head_hexsha": "d2bc5b0d2d5e76e4d5b8ab6948c82f902211182e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 26.0, "max_forks_repo_forks_event_min_datetime": "2020-01-09T15:59:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T16:27:33.000Z", "avg_line_length": 31.8604651163, "max_line_length": 79, "alphanum_fraction": 0.702919708, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.34158248603300034, "lm_q2_score": 0.152032235859071, "lm_q1q2_score": 0.051931549081896934}}
{"text": "#include <frovedis.hpp>\n\n#define BOOST_TEST_MODULE FrovedisTest\n#include <boost/test/unit_test.hpp>\n\nusing namespace frovedis;\nusing namespace std;\n\nint sum(int a, int b) {return a + b;}\n\nBOOST_AUTO_TEST_CASE( frovedis_test )\n{\n  int argc = 1;\n  char** argv = NULL;\n  use_frovedis use(argc, argv);\n\n  // filling sample input vector and computing expected output\n  std::vector<int> v;\n  int ref_out = 0;\n  for(size_t i = 1; i <= 8; i++) { \n    v.push_back(i);\n    ref_out += i;\n  }\n\n  // testing on dvector::reduce\n  auto d1 = frovedis::make_dvector_scatter(v);\n  auto r = d1.reduce(sum);\n\n  // confirming whether reduced result matched with expected output\n  BOOST_CHECK(r == ref_out);\n}\n", "meta": {"hexsha": "5870d5dc64f338479a88a0a07e43016651228eda", "size": 688, "ext": "cc", "lang": "C++", "max_stars_repo_path": "test/core/test2.4.5/test.cc", "max_stars_repo_name": "XpressAI/frovedis", "max_stars_repo_head_hexsha": "bda0f2c688fb832671c5b542dd8df1c9657642ff", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 63.0, "max_stars_repo_stars_event_min_datetime": "2018-06-21T14:11:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T11:24:36.000Z", "max_issues_repo_path": "test/core/test2.4.5/test.cc", "max_issues_repo_name": "XpressAI/frovedis", "max_issues_repo_head_hexsha": "bda0f2c688fb832671c5b542dd8df1c9657642ff", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 5.0, "max_issues_repo_issues_event_min_datetime": "2018-09-22T14:01:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-27T16:11:05.000Z", "max_forks_repo_path": "test/core/test2.4.5/test.cc", "max_forks_repo_name": "XpressAI/frovedis", "max_forks_repo_head_hexsha": "bda0f2c688fb832671c5b542dd8df1c9657642ff", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 12.0, "max_forks_repo_forks_event_min_datetime": "2018-08-23T15:59:44.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T06:47:22.000Z", "avg_line_length": 21.5, "max_line_length": 67, "alphanum_fraction": 0.6860465116, "num_tokens": 198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.4649015713733885, "lm_q2_score": 0.11124121387367901, "lm_q1q2_score": 0.05171621513135656}}
{"text": "\ufeff/*! \\file parallelquicksort.cpp\n    \\brief \u30b9\u30ec\u30c3\u30c9\u4e26\u5217\u5316\u3057\u305f\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\n\n    Copyright \u00a9 2017-2020 @dc1394 All Rights Reserved.\n    This software is released under the BSD 2-Clause License.\n*/\n\n#include <algorithm>                // for std::partition, std::sort\n#include <array>                    // for std::array\n#include <chrono>                   // for std::chrono\n#include <cstdint>                  // for std::int32_t\n#include <cstdio>                   // for std::fclose, std::fopen, std::fread, std::rewind\n#include <execution>                // for std::execution\n#include <fstream>                  // for std::ofstream\n#include <iostream>                 // for std::cerr, std::cout, std::endl\n#include <iterator>                 // for std::distance\n#include <numeric>                  // for std::iota\n#include <stack>                    // for std::stack\n#include <stdexcept>                // for std::runtime_error\n#include <thread>                   // for std::thread\n#include <utility>                  // for std::pair\n#include <vector>                   // for std::vector\n\n#if defined(_MSC_VER) && defined(__llvm__)\n    #include <string_view>          // for std::string_view_literals\n    #include <system_error>         // for std::system_error \n\n    #define WIN32_LEAN_AND_MEAN\n    #include <Windows.h>            // for GetLastError, MultiByteToWideChar\n#endif\n\n#ifndef _MSC_VER\n    #include <parallel/algorithm>   // for __gnu_parallel::sort\n#else\n    #include <ppl.h>                // for concurrency::parallel_sort, concurrency::parallel_buffered_sort\n#endif\n\n#include <pstl/algorithm>\n#include <pstl/execution>           // for pstl::execution\n\n#include <boost/assert.hpp>         // for boost::assert\n#include <boost/format.hpp>         // for boost::format\n#include <boost/process.hpp>        // for boost::process\n#include <boost/thread.hpp>         // for boost::thread\n\n#include <tbb/parallel_invoke.h>    // for tbb::parallel_invoke\n#include <tbb/parallel_sort.h>      // for tbb::parallel_sort\n\nnamespace {\n    //! A enumerated type\n    /*!\n        \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u969b\u306e\u5bfe\u8c61\u914d\u5217\u306e\u7a2e\u985e\u3092\u5b9a\u7fa9\u3057\u305f\u5217\u6319\u578b\n    */\n    enum class Checktype : std::int32_t {\n        // \u5b8c\u5168\u306b\u30e9\u30f3\u30c0\u30e0\u306a\u30c7\u30fc\u30bf\n        RANDOM = 0,\n\n        // \u3042\u3089\u304b\u3058\u3081\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\n        SORT = 1,\n\n        // \u6700\u521d\u306e1/4\u3060\u3051\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\n        QUARTERSORT = 2\n    };\n\n    //! A global variable (constant expression).\n    /*!\n        \u8a08\u6e2c\u3059\u308b\u56de\u6570\n    */\n    static auto constexpr CHECKLOOP = 10;\n\n    //! A global variable (constant expression).\n    /*!\n        \u30bd\u30fc\u30c8\u3059\u308b\u914d\u5217\u306e\u8981\u7d20\u6570\u306e\u6700\u521d\u306e\u6570\n    */\n    static auto constexpr N = 500;\n\n    //! A global variable (constant).\n    /*!\n        \u5b9f\u884c\u3059\u308bCPU\u306e\u7269\u7406\u30b3\u30a2\u6570\n    */\n    static std::int32_t const NUMPHYSICALCORE = boost::thread::physical_concurrency();\n\n    //! A global variable (constant expression).\n    /*!\n        \u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3092std::thread\u3067\u4e26\u5217\u5316\u3059\u308b\u969b\u306e\u518d\u5e30\u6570\u306e\u4e0a\u9650\n    */\n    static auto constexpr STDTHREADRECMAX = 7;\n\n    //! A global variable (constant).\n    /*!\n        \u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306b\u304a\u3051\u308b\u95be\u5024\n    */\n    static auto constexpr THRESHOLD = 500;\n\n    //! A function.\n    /*!\n        \u4e26\u5217\u5316\u3055\u308c\u305f\u30bd\u30fc\u30c8\u95a2\u6570\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\n        \\param checktype \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u969b\u306e\u5bfe\u8c61\u914d\u5217\u306e\u7a2e\u985e\n        \\param ofs \u51fa\u529b\u7528\u306e\u30d5\u30a1\u30a4\u30eb\u30b9\u30c8\u30ea\u30fc\u30e0\n\t\t\\return \u6210\u529f\u3057\u305f\u304b\u3069\u3046\u304b\n    */\n    bool check_performance(Checktype checktype, std::ofstream & ofs);\n\n    //! A function.\n    /*!\n        \u5f15\u6570\u3067\u4e0e\u3048\u3089\u308c\u305fstd::function\u306e\u5b9f\u884c\u6642\u9593\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u51fa\u529b\u3059\u308b\n        \\param checktype \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u969b\u306e\u5bfe\u8c61\u914d\u5217\u306e\u7a2e\u985e\n        \\param func \u5b9f\u884c\u3059\u308bstd::function\n        \\param n \u914d\u5217\u306e\u30b5\u30a4\u30ba\n        \\param ofs \u51fa\u529b\u7528\u306e\u30d5\u30a1\u30a4\u30eb\u30b9\u30c8\u30ea\u30fc\u30e0\n        \\return func\u306e\u5b9f\u884c\u7d50\u679c\u306estd::vector\n    */\n    std::vector<std::int32_t> elapsed_time(Checktype checktype, std::function<void(std::vector<std::int32_t> &)> const & func, std::int32_t n, std::ofstream & ofs);\n\n#if defined(_MSC_VER) && defined(__llvm__)\n    //! A function.\n    /*!\n        UTF-8\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u6587\u5b57\u5217\u3092Shift-JIS\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b\n        \\param u8str UTF-8\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u6587\u5b57\u5217\n        \\return Shift-JIS\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u6587\u5b57\u5217\n    */\n    std::string myutf8tosjis(std::string_view const & u8str);\n#endif\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n    */\n    void quick_sort(RandomIter first, RandomIter last)\n    {\n        using mypair = std::pair< RandomIter, RandomIter >;\n\n        // \u7bc4\u56f2\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u30b9\u30bf\u30c3\u30af\n        std::stack< mypair, std::vector< mypair > > stack;\n\n        // \u7bc4\u56f2\u306e\u4e0a\u9650\u3068\u4e0b\u9650\u3092\u30b9\u30bf\u30c3\u30af\u3078\u7a4d\u3080\n        stack.push(std::make_pair(first, last - 1));\n\n        // \u30b9\u30bf\u30c3\u30af\u304c\u7a7a\u306b\u306a\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059\n        while (!stack.empty()) {\n            // \u7bc4\u56f2\u306e\u60c5\u5831\u3092\u30b9\u30bf\u30c3\u30af\u304b\u3089\u53d6\u308a\u51fa\u3059\n            // C++17\u306e\u69cb\u9020\u5316\u675f\u7e1b\u3092\u4f7f\u3046\n            auto const [left, right] = stack.top();\n            stack.pop();\n\n            auto i = left;\n            auto j = right;\n            auto const pivot = (*left + *right) / 2;\n\n            // \u5de6\u53f3\u304b\u3089\u9032\u3081\u3066\u304d\u305fi\u3068j\u304c\u3076\u3064\u304b\u308b\u307e\u3067\u30eb\u30fc\u30d7\n            while (i <= j) {\n                // \u57fa\u6e96\u5024\u4ee5\u4e0a\u306e\u5024\u304c\u898b\u3064\u304b\u308b\u307e\u3067\u53f3\u65b9\u5411\u3078\u9032\u3081\u3066\u3044\u304f\n                while (*i < pivot) {\n                    ++i;\n                }\n\n                // \u57fa\u6e96\u5024\u4ee5\u4e0b\u306e\u5024\u304c\u898b\u3064\u304b\u308b\u307e\u3067\u5de6\u65b9\u5411\u3078\u9032\u3081\u3066\u3044\u304f \n                while (*j > pivot) {\n                    --j;\n                }\n\n                // \u5de6\u53f3\u304b\u3089\u9032\u3081\u3066\u304d\u305fi\u3068j\u304c\u3076\u3064\u304b\u3063\u305f\u3089\n                if (i <= j) {\n                    // \u57fa\u6e96\u5024\u4f4d\u7f6e\u3088\u308a\u3082\u5de6\u5074\u306b\u3042\u308a\u3001\u57fa\u6e96\u5024\u3088\u308a\u3082\u5927\u304d\u3044\u5024\u3068\u3001\n                    // \u57fa\u6e96\u5024\u4f4d\u7f6e\u3088\u308a\u3082\u53f3\u5074\u306b\u3042\u308a\u3001\u57fa\u6e96\u5024\u3088\u308a\u3082\u5c0f\u3055\u3044\u5024\u306e\n                    // \u4f4d\u7f6e\u95a2\u4fc2\u3092\u4ea4\u63db\u3059\u308b\u3002\n                    std::iter_swap(i, j);\n\n                    // \u6b21\u56de\u306b\u5099\u3048\u3066\u3001\u6ce8\u76ee\u70b9\u3092\u305a\u3089\u3059\n                    ++i;\n\n                    // \u5883\u754c\u30c1\u30a7\u30c3\u30af\n                    if (j != first) {\n                        // \u6b21\u56de\u306b\u5099\u3048\u3066\u3001\u6ce8\u76ee\u70b9\u3092\u305a\u3089\u3059\n                        --j;\n                    }\n                }\n            }\n\n            // \u5de6\u53f3\u306e\u914d\u5217\u306e\u3046\u3061\u3001\u8981\u7d20\u6570\u304c\u5c11\u306a\u3044\u65b9\u3092\u5148\u306b\u51e6\u7406\u3059\u308b\n            // \u5f8c\u3067\u51e6\u7406\u3059\u308b\u5074\u306f\u3001\u305d\u306e\u7bc4\u56f2\u3092\u30b9\u30bf\u30c3\u30af\u3078\u7a4d\u3093\u3067\u304a\u304f\n            if (left < j) {\n                // \u53f3\u5074\u306e\u914d\u5217\u3092\u6b21\u306e\u30bd\u30fc\u30c8\u51e6\u7406\u306e\u5bfe\u8c61\u306b\u3059\u308b\n                stack.push(std::make_pair(left, j));\n            }\n\n            if (i < right) {\n                // \u5de6\u5074\u306e\u914d\u5217\u3092\u6b21\u306e\u30bd\u30fc\u30c8\u51e6\u7406\u306e\u5bfe\u8c61\u306b\u3059\u308b\n                stack.push(std::make_pair(i, right));\n            }\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08oneTBB\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param reci \u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\n    */\n    void quick_sort_onetbb(RandomIter first, RandomIter last, std::int32_t reci)\n    {\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\n        auto const num = std::distance(first, last);\n\n        if (num <= 1) {\n            // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c1\u500b\u4ee5\u4e0b\u306a\u3089\u4f55\u3082\u3059\u308b\u3053\u3068\u306f\u306a\u3044\n            return;\n        }\n\n        // \u518d\u5e30\u306e\u6df1\u3055 + 1\n        reci++;\n\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u304f\u306a\u308a\u3059\u304e\u308b\u3068\u30b7\u30ea\u30a2\u30eb\u5b9f\u884c\u306e\u307b\u3046\u304c\u52b9\u7387\u304c\u826f\u304f\u306a\u308b\u305f\u3081\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c\u95be\u5024\u4ee5\u4e0a\u306e\u6642\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        // \u304b\u3064\u3001\u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\u304c\u7269\u7406\u30b3\u30a2\u6570\u4ee5\u4e0b\u306e\u3068\u304d\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        if (num >= THRESHOLD && reci <= NUMPHYSICALCORE) {\n            // \u4ea4\u70b9\u307e\u3067\u5de6\u53f3\u304b\u3089\u5165\u308c\u66ff\u3048\u3057\u3066\u4ea4\u70b9\u3092\u63a2\u3059\n            auto const middle = std::partition(first + 1, last, [first](auto n) { return n < *first; });\n\n            // \u4ea4\u70b9 - 1\u306e\u4f4d\u7f6e\n            auto const mid = middle - 1;\n\n            // \u4ea4\u70b9\u3092\u79fb\u52d5\n            std::iter_swap(first, mid);\n\n            // \u4e8c\u3064\u306e\u30e9\u30e0\u30c0\u5f0f\u3092\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\n            tbb::parallel_invoke(\n                // \u4e0b\u90e8\u3092\u30bd\u30fc\u30c8\n                [first, mid, reci]() { quick_sort_onetbb(first, mid, reci); },\n                // \u4e0a\u90e8\u3092\u30bd\u30fc\u30c8\n                [middle, last, reci]() { quick_sort_onetbb(middle, last, reci); });\n        }\n        else {\n            // \u518d\u5e30\u306a\u3057\u306e\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n            quick_sort(first, last);\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08oneTBB\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n    */\n    inline void quick_sort_onetbb(RandomIter first, RandomIter last)\n    {\n        // \u518d\u5e30\u3042\u308a\u306e\u4e26\u5217\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n        quick_sort_onetbb(first, last, 0);\n    }\n\n#if _OPENMP >= 200805\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08OpenMP\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param reci \u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\n    */\n    void quick_sort_openmp(RandomIter first, RandomIter last, std::int32_t reci)\n    {\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\n        auto const num = std::distance(first, last);\n\n        if (num <= 1) {\n            // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c1\u500b\u4ee5\u4e0b\u306a\u3089\u4f55\u3082\u3059\u308b\u3053\u3068\u306f\u306a\u3044\n            return;\n        }\n\n        // \u518d\u5e30\u306e\u6df1\u3055 + 1\n        reci++;\n\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u304f\u306a\u308a\u3059\u304e\u308b\u3068\u30b7\u30ea\u30a2\u30eb\u5b9f\u884c\u306e\u307b\u3046\u304c\u52b9\u7387\u304c\u826f\u304f\u306a\u308b\u305f\u3081\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c\u95be\u5024\u4ee5\u4e0a\u306e\u6642\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        // \u304b\u3064\u3001\u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\u304c\u7269\u7406\u30b3\u30a2\u6570\u4ee5\u4e0b\u306e\u3068\u304d\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        if (num >= THRESHOLD && reci <= NUMPHYSICALCORE) {\n            // \u4ea4\u70b9\u307e\u3067\u5de6\u53f3\u304b\u3089\u5165\u308c\u66ff\u3048\u3057\u3066\u4ea4\u70b9\u3092\u63a2\u3059\n            auto const middle = std::partition(first + 1, last, [first](auto n) { return n < *first; });\n\n            // \u4ea4\u70b9 - 1\u306e\u4f4d\u7f6e\n            auto const mid = middle - 1;\n\n            // \u4ea4\u70b9\u3092\u79fb\u52d5\n            std::iter_swap(first, mid);\n\n            // \u6b21\u306e\u95a2\u6570\u3092\u30bf\u30b9\u30af\u3068\u3057\u3066\u5b9f\u884c\n#pragma omp task\n            // \u4e0b\u90e8\u3092\u30bd\u30fc\u30c8\n            quick_sort_openmp(first, mid, reci);\n\n            // \u6b21\u306e\u95a2\u6570\u3092\u30bf\u30b9\u30af\u3068\u3057\u3066\u5b9f\u884c\n#pragma omp task\n            // \u4e0a\u90e8\u3092\u30bd\u30fc\u30c8\n            quick_sort_openmp(middle, last, reci);\n\n            // \u4e8c\u3064\u306e\u30bf\u30b9\u30af\u306e\u7d42\u4e86\u3092\u5f85\u6a5f\n#pragma omp taskwait\n        }\n        else {\n            // \u518d\u5e30\u306a\u3057\u306e\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n            quick_sort(first, last);\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08OpenMP\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n    */\n    inline void quick_sort_openmp(RandomIter first, RandomIter last)\n    {\n#pragma omp parallel    // OpenMP\u4e26\u5217\u9818\u57df\u306e\u59cb\u307e\u308a\n#pragma omp single      // task\u53e5\u306fsingle\u9818\u57df\u3067\u5b9f\u884c\n        // \u518d\u5e30\u3042\u308a\u306e\u4e26\u5217\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3092\u547c\u3073\u51fa\u3059\n        quick_sort_openmp(first, last, 0);\n    }\n#endif\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08std::thread\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param reci \u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\n    */\n    void quick_sort_thread(RandomIter first, RandomIter last, std::int32_t reci)\n    {\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\n        auto const num = std::distance(first, last);\n\n        if (num <= 1) {\n            // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c1\u500b\u4ee5\u4e0b\u306a\u3089\u4f55\u3082\u3059\u308b\u3053\u3068\u306f\u306a\u3044\n            return;\n        }\n\n        // \u518d\u5e30\u306e\u6df1\u3055 + 1\n        reci++;\n\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u304f\u306a\u308a\u3059\u304e\u308b\u3068\u30b7\u30ea\u30a2\u30eb\u5b9f\u884c\u306e\u307b\u3046\u304c\u52b9\u7387\u304c\u826f\u304f\u306a\u308b\u305f\u3081\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c\u95be\u5024\u4ee5\u4e0a\u306e\u6642\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        // \u304b\u3064\u3001\u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\u304cSTDTHREADRECMAX( = 7)\u4ee5\u4e0b\u306e\u3068\u304d\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        if (num >= THRESHOLD && reci <= STDTHREADRECMAX) {\n            // \u4ea4\u70b9\u307e\u3067\u5de6\u53f3\u304b\u3089\u5165\u308c\u66ff\u3048\u3057\u3066\u4ea4\u70b9\u3092\u63a2\u3059\n            auto const middle = std::partition(first + 1, last, [first](auto n) { return n < *first; });\n\n            // \u4ea4\u70b9 - 1\u306e\u4f4d\u7f6e\n            auto const mid = middle - 1;\n\n            // \u4ea4\u70b9\u3092\u79fb\u52d5\n            std::iter_swap(first, mid);\n\n            // \u4e0b\u90e8\u3092\u30bd\u30fc\u30c8\uff08\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\uff09\n            auto th1 = std::thread([first, mid, reci]() { quick_sort_thread(first, mid, reci); });\n\n            // \u4e0a\u90e8\u3092\u30bd\u30fc\u30c8\uff08\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\uff09\n            auto th2 = std::thread([middle, last, reci]() { quick_sort_thread(middle, last, reci); });\n\n            // \u4e8c\u3064\u306e\u30b9\u30ec\u30c3\u30c9\u306e\u7d42\u4e86\u3092\u5f85\u6a5f\n            th1.join();\n            th2.join();\n        }\n        else {\n            // \u518d\u5e30\u306a\u3057\u306e\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n            quick_sort(first, last);\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08std::thread\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n    */\n    inline void quick_sort_thread(RandomIter first, RandomIter last)\n    {\n        // \u518d\u5e30\u3042\u308a\u306e\u4e26\u5217\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n        quick_sort_thread(first, last, 0);\n    }\n\n#ifdef DEBUG_CHECK_RECUL\n    //! A function.\n    /*!\n        \u518d\u5e30\u6570\u306e\u4e0a\u9650\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u3069\u3046\u5909\u5316\u3059\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\n        \\param ofs \u51fa\u529b\u7528\u306e\u30d5\u30a1\u30a4\u30eb\u30b9\u30c8\u30ea\u30fc\u30e0\n    */\n    void check_performance_recul(std::ofstream & ofs);\n\n    //! A function.\n    /*!\n        \u5f15\u6570\u3067\u4e0e\u3048\u3089\u308c\u305fstd::function\u306e\u5b9f\u884c\u6642\u9593\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u51fa\u529b\u3059\u308b\n        \\param func \u5b9f\u884c\u3059\u308bstd::function\n        \\param n \u914d\u5217\u306e\u30b5\u30a4\u30ba\n        \\param ofs \u51fa\u529b\u7528\u306e\u30d5\u30a1\u30a4\u30eb\u30b9\u30c8\u30ea\u30fc\u30e0\n    */\n    void elapsed_time_recul(std::function<void(std::vector<std::int32_t> &)> const & func, std::int32_t n, std::ofstream & ofs);\n\n#if _OPENMP >= 200805\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08OpenMP\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param reci \u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\n        \\param recul \u518d\u5e30\u6570\u306e\u4e0a\u9650\n    */\n    void quick_sort_openmp_recul(RandomIter first, RandomIter last, std::int32_t reci, std::int32_t recul)\n    {\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\n        auto const num = std::distance(first, last);\n\n        if (num <= 1) {\n            // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c1\u500b\u4ee5\u4e0b\u306a\u3089\u4f55\u3082\u3059\u308b\u3053\u3068\u306f\u306a\u3044\n            return;\n        }\n\n        // \u518d\u5e30\u306e\u6df1\u3055 + 1\n        reci++;\n\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u304f\u306a\u308a\u3059\u304e\u308b\u3068\u30b7\u30ea\u30a2\u30eb\u5b9f\u884c\u306e\u307b\u3046\u304c\u52b9\u7387\u304c\u826f\u304f\u306a\u308b\u305f\u3081\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c\u95be\u5024\u4ee5\u4e0a\u306e\u6642\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        // \u304b\u3064\u3001\u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\u304c\u7269\u7406\u30b3\u30a2\u6570\u4ee5\u4e0b\u306e\u3068\u304d\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        if (num >= THRESHOLD && reci <= recul) {\n            // \u4ea4\u70b9\u307e\u3067\u5de6\u53f3\u304b\u3089\u5165\u308c\u66ff\u3048\u3057\u3066\u4ea4\u70b9\u3092\u63a2\u3059\n            auto const middle = std::partition(first + 1, last, [first](auto n) { return n < *first; });\n\n            // \u4ea4\u70b9 - 1\u306e\u4f4d\u7f6e\n            auto const mid = middle - 1;\n\n            // \u4ea4\u70b9\u3092\u79fb\u52d5\n            std::iter_swap(first, mid);\n\n            // \u6b21\u306e\u95a2\u6570\u3092\u30bf\u30b9\u30af\u3068\u3057\u3066\u5b9f\u884c\n#pragma omp task\n            // \u4e0b\u90e8\u3092\u30bd\u30fc\u30c8\n            quick_sort_openmp_recul(first, mid, reci, recul);\n\n            // \u6b21\u306e\u95a2\u6570\u3092\u30bf\u30b9\u30af\u3068\u3057\u3066\u5b9f\u884c\n#pragma omp task\n            // \u4e0a\u90e8\u3092\u30bd\u30fc\u30c8\n            quick_sort_openmp_recul(middle, last, reci, recul);\n\n            // \u4e8c\u3064\u306e\u30bf\u30b9\u30af\u306e\u7d42\u4e86\u3092\u5f85\u6a5f\n#pragma omp taskwait\n        }\n        else {\n            // \u518d\u5e30\u306a\u3057\u306e\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n            quick_sort(first, last);\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08OpenMP\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param recul \u518d\u5e30\u6570\u306e\u4e0a\u9650\n    */\n    inline void quick_sort_openmp_recul(RandomIter first, RandomIter last, std::int32_t recul)\n    {\n#pragma omp parallel    // OpenMP\u4e26\u5217\u9818\u57df\u306e\u59cb\u307e\u308a\n#pragma omp single      // task\u53e5\u306fsingle\u9818\u57df\u3067\u5b9f\u884c\n        // \u518d\u5e30\u3042\u308a\u306e\u4e26\u5217\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3092\u547c\u3073\u51fa\u3059\n        quick_sort_openmp_recul(first, last, 0, recul);\n    }\n#endif\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08oneTBB\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param reci \u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\n        \\param recul \u518d\u5e30\u6570\u306e\u4e0a\u9650\n    */\n    void quick_sort_tbb_recul(RandomIter first, RandomIter last, std::int32_t reci, std::int32_t recul)\n    {\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\n        auto const num = std::distance(first, last);\n\n        if (num <= 1) {\n            // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c1\u500b\u4ee5\u4e0b\u306a\u3089\u4f55\u3082\u3059\u308b\u3053\u3068\u306f\u306a\u3044\n            return;\n        }\n\n        // \u518d\u5e30\u306e\u6df1\u3055 + 1\n        reci++;\n\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u304f\u306a\u308a\u3059\u304e\u308b\u3068\u30b7\u30ea\u30a2\u30eb\u5b9f\u884c\u306e\u307b\u3046\u304c\u52b9\u7387\u304c\u826f\u304f\u306a\u308b\u305f\u3081\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c\u95be\u5024\u4ee5\u4e0a\u306e\u6642\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        // \u304b\u3064\u3001\u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\u304c\u7269\u7406\u30b3\u30a2\u6570\u4ee5\u4e0b\u306e\u3068\u304d\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        if (num >= THRESHOLD && reci <= recul) {\n            // \u4ea4\u70b9\u307e\u3067\u5de6\u53f3\u304b\u3089\u5165\u308c\u66ff\u3048\u3057\u3066\u4ea4\u70b9\u3092\u63a2\u3059\n            auto const middle = std::partition(first + 1, last, [first](auto n) { return n < *first; });\n\n            // \u4ea4\u70b9 - 1\u306e\u4f4d\u7f6e\n            auto const mid = middle - 1;\n\n            // \u4ea4\u70b9\u3092\u79fb\u52d5\n            std::iter_swap(first, mid);\n\n            // \u4e8c\u3064\u306e\u30e9\u30e0\u30c0\u5f0f\u3092\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\n            tbb::parallel_invoke(\n                // \u4e0b\u90e8\u3092\u30bd\u30fc\u30c8\n                [first, mid, reci, recul]() { quick_sort_tbb_recul(first, mid, reci, recul); },\n                // \u4e0a\u90e8\u3092\u30bd\u30fc\u30c8\n                [middle, last, reci, recul]() { quick_sort_tbb_recul(middle, last, reci, recul); });\n        }\n        else {\n            // \u518d\u5e30\u306a\u3057\u306e\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n            quick_sort(first, last);\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08oneTBB\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param recul \u518d\u5e30\u6570\u306e\u4e0a\u9650\n    */\n    inline void quick_sort_tbb_recul(RandomIter first, RandomIter last, std::int32_t recul)\n    {\n        // \u518d\u5e30\u3042\u308a\u306e\u4e26\u5217\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n        quick_sort_tbb_recul(first, last, 0, recul);\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08std::thread\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n        \\param reci \u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\n        \\param recul \u518d\u5e30\u6570\u306e\u4e0a\u9650\n    */\n    void quick_sort_thread_recul(RandomIter first, RandomIter last, std::int32_t reci, std::int32_t recul)\n    {\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\n        auto const num = std::distance(first, last);\n\n        if (num <= 1) {\n            // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c1\u500b\u4ee5\u4e0b\u306a\u3089\u4f55\u3082\u3059\u308b\u3053\u3068\u306f\u306a\u3044\n            return;\n        }\n\n        // \u518d\u5e30\u306e\u6df1\u3055 + 1\n        reci++;\n\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u304f\u306a\u308a\u3059\u304e\u308b\u3068\u30b7\u30ea\u30a2\u30eb\u5b9f\u884c\u306e\u307b\u3046\u304c\u52b9\u7387\u304c\u826f\u304f\u306a\u308b\u305f\u3081\n        // \u90e8\u5206\u30bd\u30fc\u30c8\u306e\u8981\u7d20\u6570\u304c\u95be\u5024\u4ee5\u4e0a\u306e\u6642\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        // \u304b\u3064\u3001\u73fe\u5728\u306e\u518d\u5e30\u306e\u6df1\u3055\u304c\u7269\u7406\u30b3\u30a2\u6570\u4ee5\u4e0b\u306e\u3068\u304d\u3060\u3051\u518d\u5e30\u3055\u305b\u308b\n        if (num >= THRESHOLD && reci <= recul) {\n            // \u4ea4\u70b9\u307e\u3067\u5de6\u53f3\u304b\u3089\u5165\u308c\u66ff\u3048\u3057\u3066\u4ea4\u70b9\u3092\u63a2\u3059\n            auto const middle = std::partition(first + 1, last, [first](auto n) { return n < *first; });\n\n            // \u4ea4\u70b9 - 1\u306e\u4f4d\u7f6e\n            auto const mid = middle - 1;\n\n            // \u4ea4\u70b9\u3092\u79fb\u52d5\n            std::iter_swap(first, mid);\n\n            // \u4e0b\u90e8\u3092\u30bd\u30fc\u30c8\uff08\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\uff09\n            auto th1 = std::thread([first, mid, reci, recul]() { quick_sort_thread_recul(first, mid, reci, recul); });\n\n            // \u4e0a\u90e8\u3092\u30bd\u30fc\u30c8\uff08\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\uff09\n            auto th2 = std::thread([middle, last, reci, recul]() { quick_sort_thread_recul(middle, last, reci, recul); });\n\n            // \u4e8c\u3064\u306e\u30b9\u30ec\u30c3\u30c9\u306e\u7d42\u4e86\u3092\u5f85\u6a5f\n            th1.join();\n            th2.join();\n        }\n        else {\n            // \u518d\u5e30\u306a\u3057\u306e\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n            quick_sort(first, last);\n        }\n    }\n\n    template < class RandomIter >\n    //! A template function.\n    /*!\n        \u6307\u5b9a\u3055\u308c\u305f\u7bc4\u56f2\u306e\u8981\u7d20\u3092\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3067\u30bd\u30fc\u30c8\u3059\u308b\uff08std::thread\u3067\u4e26\u5217\u5316\uff09\n        \\param first \u7bc4\u56f2\u306e\u4e0b\u9650\n        \\param last \u7bc4\u56f2\u306e\u4e0a\u9650\n    */\n    inline void quick_sort_thread_recul(RandomIter first, RandomIter last, std::int32_t recul)\n    {\n        // \u518d\u5e30\u3042\u308a\u306e\u4e26\u5217\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\n        quick_sort_thread_recul(first, last, 0, recul);\n    }\n#endif\n\n#ifdef DEBUG\n    //! A template function.\n    /*!\n        \u4e0e\u3048\u3089\u308c\u305f\u4e8c\u3064\u306estd::vector\u306e\u3059\u3079\u3066\u306e\u8981\u7d20\u304c\u540c\u3058\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\n        \\param v1 \u4e00\u3064\u76ee\u306estd::vector\n        \\param v2 \u4e8c\u3064\u3081\u306estd::vector\n        \\return \u4e0e\u3048\u3089\u308c\u305f\u4e8c\u3064\u306estd::vector\u306e\u3059\u3079\u3066\u306e\u8981\u7d20\u304c\u540c\u3058\u306a\u3089true\u3001\u305d\u3046\u3067\u306a\u3044\u306a\u3089false\n    */\n    bool vec_check(std::vector<std::int32_t> const & v1, std::vector<std::int32_t> const & v2);\n#endif\n}\n\nint main()\n{\n#if defined(_MSC_VER) && defined(__llvm__)\n    using namespace std::string_view_literals;\n\n    std::cout << myutf8tosjis(u8R\"(\u7269\u7406\u30b3\u30a2\u6570: )\"sv) << boost::thread::physical_concurrency();\n    std::cout << myutf8tosjis(u8R\"(, \u8ad6\u7406\u30b3\u30a2\u6570: )\"sv) << boost::thread::hardware_concurrency() << std::endl;\n\n#ifdef DEBUG_CHECK_RECUL\n    std::ofstream ofsrec(myutf8tosjis(u8R\"(\u5b8c\u5168\u306b\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u305f\u30c7\u30fc\u30bf_\u518d\u5e30\u6570\u30c1\u30a7\u30c3\u30af.csv)\"sv));\n    check_performance_recul(ofsrec);\n#else\n    std::ofstream ofsrandom(myutf8tosjis(u8R\"(\u5b8c\u5168\u306b\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u305f\u30c7\u30fc\u30bf.csv)\"sv));\n    std::ofstream ofssort(myutf8tosjis(u8R\"(\u3042\u3089\u304b\u3058\u3081\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf.csv)\"sv));\n    std::ofstream ofsquartersort(myutf8tosjis(u8R\"(\u6700\u521d\u306e1_4\u3060\u3051\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf.csv)\"sv));\n\n    std::cout << myutf8tosjis(u8R\"(\u5b8c\u5168\u306b\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8a08\u6e2c\u4e2d...)\"sv) << '\\n';\n    if (!check_performance(Checktype::RANDOM, ofsrandom)) {\n        return -1;\n    }\n\n    std::cout << '\\n' << myutf8tosjis(u8R\"(\u3042\u3089\u304b\u3058\u3081\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8a08\u6e2c\u4e2d...)\"sv) << '\\n';\n    if (!check_performance(Checktype::SORT, ofssort)) {\n        return -1;\n    }\n\n    std::cout << '\\n' << myutf8tosjis(u8R\"(\u6700\u521d\u306e1/4\u3060\u3051\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8a08\u6e2c\u4e2d...)\"sv) << '\\n';\n    if (!check_performance(Checktype::QUARTERSORT, ofsquartersort)) {\n        return -1;\n    }\n#endif\n\n#else\n    std::cout << \"\u7269\u7406\u30b3\u30a2\u6570: \" << boost::thread::physical_concurrency();\n    std::cout << \", \u8ad6\u7406\u30b3\u30a2\u6570: \" << boost::thread::hardware_concurrency() << std::endl;\n\n#ifdef DEBUG_CHECK_RECUL\n    std::ofstream ofsrec(\"\u5b8c\u5168\u306b\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u305f\u30c7\u30fc\u30bf_\u518d\u5e30\u6570\u30c1\u30a7\u30c3\u30af.csv\");\n    check_performance_recul(ofsrec);\n#else\n    std::ofstream ofsrandom(\"\u5b8c\u5168\u306b\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u305f\u30c7\u30fc\u30bf.csv\");\n    std::ofstream ofssort(\"\u3042\u3089\u304b\u3058\u3081\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf.csv\");\n    std::ofstream ofsquartersort(\"\u6700\u521d\u306e1_4\u3060\u3051\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf.csv\");\n\n    std::cout << \"\u5b8c\u5168\u306b\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8a08\u6e2c\u4e2d...\\n\";\n    if (!check_performance(Checktype::RANDOM, ofsrandom)) {\n        return -1;\n    }\n\n    std::cout << \"\\n\u3042\u3089\u304b\u3058\u3081\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8a08\u6e2c\u4e2d...\\n\";\n    if (!check_performance(Checktype::SORT, ofssort)) {\n        return -1;\n    }\n\n    std::cout << \"\\n\u6700\u521d\u306e1/4\u3060\u3051\u30bd\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8a08\u6e2c\u4e2d...\\n\";\n    if (!check_performance(Checktype::QUARTERSORT, ofsquartersort)) {\n        return -1;\n    }\n#endif\n#endif\n\n    return 0;\n}\n\nnamespace {\n    bool check_performance(Checktype checktype, std::ofstream & ofs)\n    {\n#ifndef _MSC_VER\n        std::array< std::uint8_t, 3 > const bom = { 0xEF, 0xBB, 0xBF };\n        ofs.write(reinterpret_cast<char const *>(bom.data()), sizeof(bom));\n#endif\n\n#if defined(_MSC_VER) && _OPENMP < 200805\n        ofs << \"\u914d\u5217\u306e\u8981\u7d20\u6570,std::sort,\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8,std::thread,oneTBB,concurrency::parallel_sort,concurrency::parallel_buffered_sort,tbb::parallel_sort,std::sort (MSVC\u5185\u8535\u306eParallelism TS),std::sort (Parallel STL\u306eParallelism TS)\\n\";\n#elif defined(_MSC_VER) && defined(__llvm__)\n        using namespace std::string_view_literals;\n        \n        ofs << myutf8tosjis(u8R\"(\u914d\u5217\u306e\u8981\u7d20\u6570,std::sort,\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8,std::thread,OpenMP,oneTBB,concurrency::parallel_sort,concurrency::parallel_buffered_sort,tbb::parallel_sort,std::sort (MSVC\u5185\u8535\u306eParallelism TS),std::sort (Parallel STL\u306eParallelism TS))\"sv) << '\\n';\n#else\n        ofs << u8R\"(\u914d\u5217\u306e\u8981\u7d20\u6570,std::sort,\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8,std::thread,OpenMP,oneTBB,__gnu_parallel::sort,tbb::parallel_sort,std::sort (Parallelism TS),std::sort (Parallel STL\u306eParallelism TS))\" << '\\n';\n#endif\n        \n        auto issuccess = true;\n\n        auto n = N;\n        for (auto i = 0; i < 6; i++) {\n            for (auto j = 0; j < 2; j++) {\n#if defined(_MSC_VER) && defined(__llvm__)\n                std::cout << n << myutf8tosjis(u8R\"(\u500b\u3092\u8a08\u6e2c\u4e2d...)\"sv) << '\\n';\n#else\n                std::cout << n << \"\u500b\u3092\u8a08\u6e2c\u4e2d...\\n\";\n#endif\n                std::vector<std::int32_t> vec(n);\n                std::iota(vec.begin(), vec.end(), 1);\n\n                std::array< std::vector<std::int32_t>, 10 > vecar;\n\n                ofs << n << ',';\n\n                try {\n                    vecar[0] = elapsed_time(checktype, [](auto && vec) { std::sort(vec.begin(), vec.end()); }, n, ofs);\n                    vecar[1] = elapsed_time(checktype, [](auto && vec) { quick_sort(vec.begin(), vec.end()); }, n, ofs);\n                    vecar[2] = elapsed_time(checktype, [](auto && vec) { quick_sort_thread(vec.begin(), vec.end()); }, n, ofs);\n                \n#if _OPENMP >= 200805\n                    vecar[3] = elapsed_time(checktype, [](auto && vec) { quick_sort_openmp(vec.begin(), vec.end()); }, n, ofs);\n#endif\n                    vecar[4] = elapsed_time(checktype, [](auto && vec) { quick_sort_onetbb(vec.begin(), vec.end()); }, n, ofs);\n\n#ifndef _MSC_VER\n                    vecar[5] = elapsed_time(checktype, [](auto && vec) { __gnu_parallel::sort(vec.begin(), vec.end()); }, n, ofs);\n#else\n                    vecar[5] = elapsed_time(checktype, [](auto && vec) { concurrency::parallel_sort(vec.begin(), vec.end()); }, n, ofs);\n\n                    vecar[6] = elapsed_time(checktype, [](auto && vec) { concurrency::parallel_buffered_sort(vec.begin(), vec.end()); }, n, ofs);\n#endif\n\n\n                    vecar[7] = elapsed_time(checktype, [](auto && vec) { tbb::parallel_sort(vec); }, n, ofs);\n\n                    vecar[8] = elapsed_time(checktype, [](auto && vec) { std::sort(std::execution::par, vec.begin(), vec.end()); }, n, ofs);\n\n#ifdef _MSC_VER\n                    vecar[9] = elapsed_time(checktype, [](auto && vec) { std::sort(pstl::execution::par, vec.begin(), vec.end()); }, n, ofs);\n#else\n                    vecar[9] = elapsed_time(checktype, [](auto && vec) { std::sort(__pstl::execution::par, vec.begin(), vec.end()); }, n, ofs);\n#endif\n\n                }\n                catch (std::runtime_error const & e) {\n                    std::cerr << e.what() << std::endl;\n                    return false;\n                }\n\n                ofs << std::endl;\n\n#ifdef DEBUG\n                for (auto k = 0U; k < vecar.size(); k++) {\n#if _OPENMP < 200805\n                    if (k == 3) {\n                        continue;\n                    }\n#endif\n\n                    if (!k || k == 6 || k == 7 || k == 8) {\n                        continue;\n                    }\n\n                    if (static_cast<std::int32_t>(vecar[k].size()) != n) {\n                        issuccess = false;\n                        continue;\n                    }\n\n                    if (!vec_check(vec, vecar[k])) {\n                        std::cerr << \"Error! vecar[\" << k << ']' << std::endl;\n                        issuccess = false;\n                    }\n                }\n#endif\n                if (!j) {\n                    n *= 2;\n                }\n            }\n\n            n *= 5;\n        }\n\n        return issuccess;\n    }\n\n    std::vector<std::int32_t> elapsed_time(Checktype checktype, std::function<void(std::vector<std::int32_t> &)> const & func, std::int32_t n, std::ofstream & ofs)\n    {\n        using namespace std::chrono;\n\n        std::vector<std::int32_t> vec(n);\n        std::unique_ptr< FILE, decltype(&std::fclose) > fp(nullptr, fclose);\n\n        auto const program_name = \"makequicksortdata\";\n\n        switch (checktype) {\n        case Checktype::RANDOM:\n            {\n                auto const filename = (boost::format(\"sortdata_%d_rand.dat\") % n).str();\n                fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n                if (!fp) {\n                    boost::process::child(program_name + (boost::format(\" 0 %d\") % n).str()).wait();\n                    fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n                }\n            }\n            break;\n\n        case Checktype::SORT:\n            {\n                auto const filename = (boost::format(\"sortdata_%d_already.dat\") % n).str();\n                fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n                if (!fp) {\n                    boost::process::child(program_name + (boost::format(\" 1 %d\") % n).str()).wait();\n                    fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n                }\n            }\n            break;\n\n        case Checktype::QUARTERSORT:\n            {\n                auto const filename = (boost::format(\"sortdata_%d_quartersort.dat\") % n).str();\n                fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n                if (!fp) {\n                    boost::process::child(program_name + (boost::format(\" 2 %d\") % n).str()).wait();\n                    fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n                }\n            }\n            break;\n\n        default:\n            BOOST_ASSERT(!\"switch\u6587\u306edefault\u306b\u6765\u3066\u3057\u307e\u3063\u305f\uff01\");\n            break;\n        }\n\n        auto const readsize = vec.size();        \n        if (readsize != std::fread(vec.data(), sizeof(std::int32_t), readsize, fp.get())) {\n            throw std::runtime_error(\"std::fread\u306b\u5931\u6557\");\n        }\n\n        auto elapsed_time = 0.0;\n        \n        for (auto i = 1; i <= CHECKLOOP; i++) {\n            auto const beg = high_resolution_clock::now();\n            func(vec);\n            auto const end = high_resolution_clock::now();\n\n            elapsed_time += (duration_cast<duration<double>>(end - beg)).count();\n            \n            if (i != CHECKLOOP) {\n                std::rewind(fp.get());\n                if (readsize != std::fread(vec.data(), sizeof(std::int32_t), readsize, fp.get())) {\n                    throw std::runtime_error(\"std::fread\u306b\u5931\u6557\");\n                }\n            }\n        }\n\n        ofs << boost::format(\"%.10f\") % (elapsed_time / static_cast<double>(CHECKLOOP)) << ',';\n\n        return vec;\n    }\n\n#ifdef DEBUG_CHECK_RECUL\n    void check_performance_recul(std::ofstream& ofs)\n    {\n        using namespace std::string_view_literals;\n\n#if _OPENMP < 200805\n        ofs << \"\u518d\u5e30\u6570,std::thread,oneTBB\\n\";\n#else\n        ofs << myutf8tosjis(u8R\"(\u518d\u5e30\u6570,std::thread,OpenMP,oneTBB)\"sv) << '\\n';\n#endif\n\n        for (auto recul = 0U; recul <= boost::thread::hardware_concurrency(); recul++) {\n#if defined(_MSC_VER) && defined(__llvm__)\n            std::cout << myutf8tosjis(u8R\"(\u518d\u5e30\u6570: )\"sv) << recul << myutf8tosjis(u8R\"(\u3092\u8a08\u6e2c\u4e2d...)\"sv) << '\\n';\n#else\n            std::cout << \"\u518d\u5e30\u6570: \" << recul << \"\u3092\u8a08\u6e2c\u4e2d...\\n\";\n#endif\n\n            ofs << recul << ',';\n            elapsed_time_recul([recul](auto && vec) { quick_sort_thread_recul(vec.begin(), vec.end(), recul); }, 5000000, ofs);\n#if _OPENMP >= 200805\n            elapsed_time_recul([recul](auto && vec) { quick_sort_openmp_recul(vec.begin(), vec.end(), recul); }, 5000000, ofs);\n#endif\n            elapsed_time_recul([recul](auto && vec) { quick_sort_tbb_recul(vec.begin(), vec.end(), recul); }, 5000000, ofs);\n            ofs << std::endl;\n        }\n    }\n\n    void elapsed_time_recul(std::function<void(std::vector<std::int32_t>&)> const& func, std::int32_t n, std::ofstream& ofs)\n    {\n        using namespace std::chrono;\n\n        std::vector<std::int32_t> vec(n);\n        std::unique_ptr< FILE, decltype(&std::fclose) > fp(nullptr, fclose);\n\n        auto const program_name = \"makequicksortdata\";\n\n        auto const filename = (boost::format(\"sortdata_%d_rand.dat\") % n).str();\n        fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n        if (!fp) {\n            boost::process::child(program_name + (boost::format(\" 0 %d\") % n).str()).wait();\n            fp = std::unique_ptr< FILE, decltype(&std::fclose) >(std::fopen(filename.c_str(), \"rb\"), std::fclose);\n        }\n\n        auto const readsize = vec.size();\n        if (readsize != std::fread(vec.data(), sizeof(std::int32_t), readsize, fp.get())) {\n            throw std::runtime_error(\"std::fread\u306b\u5931\u6557\");\n        }\n\n        auto elapsed_time = 0.0;\n\n        for (auto i = 1; i <= CHECKLOOP; i++) {\n            auto const beg = high_resolution_clock::now();\n            func(vec);\n            auto const end = high_resolution_clock::now();\n\n            elapsed_time += (duration_cast<duration<double>>(end - beg)).count();\n\n            if (i != CHECKLOOP) {\n                std::rewind(fp.get());\n                if (readsize != std::fread(vec.data(), sizeof(std::int32_t), readsize, fp.get())) {\n                    throw std::runtime_error(\"std::fread\u306b\u5931\u6557\");\n                }\n            }\n        }\n\n        ofs << boost::format(\"%.10f\") % (elapsed_time / static_cast<double>(CHECKLOOP)) << ',';\n    }\n#endif\n\n#if defined(_MSC_VER) && defined(__llvm__)\n    std::string myutf8tosjis(std::string_view const & u8str)\n    {\n        // UTF-8 -> UTF-16\n        auto length = ::MultiByteToWideChar(\n            CP_UTF8,\n            0,\n            reinterpret_cast<const char*>(u8str.data()),\n            static_cast<int>(u8str.length()),\n            nullptr,\n            0);\n        if (!length) {\n            throw std::system_error(std::error_code(GetLastError(), std::system_category()));\n        }\n\n        std::wstring temp(length, '\\0');\n\n        auto res = ::MultiByteToWideChar(\n            CP_UTF8,\n            0,\n            reinterpret_cast<const char*>(u8str.data()),\n            static_cast<int>(u8str.length()),\n            temp.data(), temp.length());\n        if (!res) {\n            throw std::system_error(std::error_code(GetLastError(), std::system_category()));\n        }\n\n        // UTF-16 -> Shift-JIS\n        length = ::WideCharToMultiByte(CP_ACP, 0,\n            temp.data(), static_cast<int>(temp.length()),\n            nullptr, 0,\n            nullptr, nullptr);\n\n        std::string result(length, '\\0');\n\n        res = ::WideCharToMultiByte(CP_ACP, 0,\n            temp.data(), static_cast<int>(temp.length()),\n            result.data(), static_cast<int>(result.length()),\n            nullptr, nullptr);\n        if (!res) {\n            throw std::system_error(std::error_code(GetLastError(), std::system_category()));\n        }\n\n        return result;\n    }\n#endif\n\n#ifdef DEBUG\n    bool vec_check(std::vector<std::int32_t> const & v1, std::vector<std::int32_t> const & v2)\n    {\n        auto const size = v1.size();\n        BOOST_ASSERT(size == v2.size());\n\n        for (auto i = 0UL; i < size; i++) {\n            if (v1[i] != v2[i]) {\n                std::cerr << \"Error! i = \" << i << '\\n';\n                return false;\n            }\n        }\n\n        return true;\n    }\n#endif\n}\n", "meta": {"hexsha": "a839bf933a0ab79ad5997b06ab3d521fd92191ab", "size": 31879, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/parallelquicksort/parallelquicksort.cpp", "max_stars_repo_name": "dc1394/parallelquicksort", "max_stars_repo_head_hexsha": "f3293bc8672bc1c952a5db527ac747b78ecc9728", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 5.0, "max_stars_repo_stars_event_min_datetime": "2017-12-16T13:22:18.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-23T09:05:34.000Z", "max_issues_repo_path": "src/parallelquicksort/parallelquicksort.cpp", "max_issues_repo_name": "dc1394/parallelquicksort", "max_issues_repo_head_hexsha": "f3293bc8672bc1c952a5db527ac747b78ecc9728", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/parallelquicksort/parallelquicksort.cpp", "max_forks_repo_name": "dc1394/parallelquicksort", "max_forks_repo_head_hexsha": "f3293bc8672bc1c952a5db527ac747b78ecc9728", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2018-07-22T02:40:29.000Z", "max_forks_repo_forks_event_max_datetime": "2018-07-22T02:40:29.000Z", "avg_line_length": 31.9749247743, "max_line_length": 253, "alphanum_fraction": 0.5439317419, "num_tokens": 10909, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46490157137338844, "lm_q2_score": 0.11124120650754304, "lm_q1q2_score": 0.051716211706828365}}
{"text": "// Copyright Paul A. Bristow 2013\n\n// Use, modification and distribution are subject to the\n// Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt\n// or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n// Program to list all numeric_limits items for any type to a file in Quickbook format.\n\n// C standard http://www.open-std.org/jtc1/sc22/wg11/docs/n507.pdf\n// SC22/WG11 N507 DRAFT INTERNATIONAL ISO/IEC STANDARD WD 10967-1\n// Information technology Language independent arithmetic Part 1: Integer and Floating point arithmetic\n\n/* E.3 C++\nThe programming language C++ is defined by ISO/IEC 14882:1998, Programming languages C++ [18].\nAn implementation should follow all the requirements of LIA-1 unless otherwise specified by\nthis language binding.\n*/\n\n// https://doi.org/10.1109/IEEESTD.1985.82928\n\n// http://www.cesura17.net/~will/Professional/Research/Papers/retrospective.pdf\n\n// http://www.exploringbinary.com/using-integers-to-check-a-floating-point-approximation/\n\n// http://stackoverflow.com/questions/12466745/how-to-convert-float-to-doubleboth-stored-in-ieee-754-representation-without-loss\n\n\n#ifdef _MSC_VER\n#  pragma warning (disable : 4127)  // conditional expression is constant.\n#  pragma warning (disable : 4100)  // unreferenced formal parameter.\n#endif\n\n\n#include <iostream>\n#include <iomanip>\n#include <string>\n#include <sstream>\n#include <fstream>\n#include <limits> // numeric_limits\n\n#include <typeinfo>\n\n#include <boost/version.hpp>\n#include <boost/config.hpp>\n\n// May need extra includes for other types, for example:\n#include <nil/crypto3/multiprecision/cpp_dec_float.hpp> // is decimal.\n#include <nil/crypto3/multiprecision/cpp_bin_float.hpp> // is binary.\n\n\n// Assume that this will be run on MSVC to get the 32 or 64 bit info.\n#ifdef _WIN32\n  std::string bits32_64 = \"32\";\nstd::string filename = \"numeric_limits_32_tables.qbk\";\n#else\n  std::string bits32_64 = \"64\";\nstd::string filename = \"numeric_limits_64_tables.qbk\";\n#endif\n\n#ifdef INT32_T_MAX\n  int i = INT256_T_MAX;\n#endif\n\nstd::array<std::string, 16> integer_type_names =\n{\n\"bool\",\n\"char\",\n\"unsigned char\",\n\"char16_t\",\n\"char32_t\",\n\"short\",\n\"unsigned short\",\n\"int\",\n\"unsigned int\",\n\"long\",\n\"unsigned long\",\n\"long long\",\n\"unsigned long long\",\n\"int32_t\",\n//\"uint32_t\",\n\"int64_t\",\n//\"uint64_t\",\n\"int128_t\",\n//\"uint128_t\" // Too big?\n//\"int256_t\",\n//\"uint256_t\"\n//\"int512_t\"\n};\n\nstd::array<std::string, 6> float_type_names =\n{\n  \"function\", \"float\", \"double\", \"long double\", \"cpp_dec_50\", \"cpp_bin_128\"\n};\n\n// Table headings for integer constants.\nstd::array<std::string, 8> integer_constant_heads =\n{\n    \"type\", \"signed\", \"bound\", \"modulo\", \"round\", \"radix\", \"digits\", \"digits10\", // \"max_digits10\"\n};\n\n// Table headings for integer functions.\nstd::array<std::string, 2> integer_function_heads =\n{\n  \"max\", // \"lowest\",  assumes is same for all integer types, so not worth listing.\n  \"min\"\n};\n\n// Table headings for float constants.\nstd::array<std::string, 12> float_constant_heads =\n{\n    \"type\", // \"signed\", \"exact\", \"bound\", // \"modulo\",\n    \"round\", \"radix\", \"digits\", \"digits10\", \"max_digits10\", \"min_exp\", \"min_exp10\", \"max_exp\", \"max_exp10\", \"tiny\", \"trap\"\n};\n\n// Table headings for float functions.\nstd::array<std::string, 10> float_function_heads =\n{\n  \"function\", \"max\", \"lowest\", \"min\", \"eps\", \"round\", \"infinity\", \"NaN\", \"sig_NaN\", \"denorm_min\"\n};\n\nstd::string versions()\n{ // Build a string of info about Boost, platform, STL, etc.\n  std::stringstream mess;\n  //mess << \"\\n\" << \"Program:\\n\\\" \" __FILE__  << \"\\\"\\n\"; // \\n is mis-interpreted!\n  mess << \"\\n\" << \"Program:\\n numeric_limits_qbk.cpp \\n\";\n#ifdef __TIMESTAMP__\n  mess << __TIMESTAMP__;\n#endif\n  mess << \"\\nBuildInfo:\\n\" \"  Platform \" << BOOST_PLATFORM;\n  mess << \"\\n  Compiler \" BOOST_COMPILER;\n#ifdef _MSC_FULL_VER\n  mess << \"\\n  MSVC version \"<< BOOST_STRINGIZE(_MSC_FULL_VER) << \".\";\n#endif\n  mess << \"\\n  STL \" BOOST_STDLIB;\n  mess << \"\\n  Boost version \" << BOOST_VERSION/100000 << \".\" << BOOST_VERSION/100 % 1000 << \".\" << BOOST_VERSION % 100 << std::endl;\n  return mess.str();\n} // std::string versions()\n\ntemplate <typename T>\nvoid out_round_style(std::ostream& os)\n{ //! Send short string describing STD::round_style to stream os.\n    // os << \"Round style is \";\n    if (std::numeric_limits<T>::round_style == std::round_indeterminate)\n    {\n     os << \"indeterminate\" ;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_toward_zero)\n    {\n      os << \"to zero\" ;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_to_nearest)\n    {\n      os << \"to nearest\" ;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_toward_infinity)\n    {\n      os << \"to infin[]\"; // Or << \"to \\u221E\"  << \"to infinity\" ;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_toward_neg_infinity)\n    {\n      os << \"to -infin[]\" ;\n    }\n    else\n    {\n      os << \"undefined!\";\n      std::cout << \"std::numeric_limits<T>::round_style is undefined value!\" << std::endl;\n    }\n    return;\n} // out_round_style(std::ostream& os);\n\ntemplate<typename T>\nvoid integer_constants(std::string type_name, std::ostream& os)\n{ //! Output a line of table integer constant values to ostream os.\n    os << \"\\n[\"\n          \"[\" << type_name << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::is_signed ? \"signed\" : \"unsigned\") << \"]\" ;\n    // Is always exact for integer types, so removed:\n    // os << \"[\" << (std::numeric_limits<T>::is_exact ? \"exact\" : \"inexact\") << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::is_bounded ? \"bound\" : \"unbounded\") << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::is_modulo ? \"modulo\" : \"no\") << \"]\" ;\n    os << \"[\" ; out_round_style<T>(os); os << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::radix << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::digits << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::digits10 << \"]\" ;\n    // Undefined for integers, so removed:\n   // os << \"[\" << std::numeric_limits<T>::max_digits10 << \"]\"\n     os << \"]\";\n} // void integer_constants\n\n\ntemplate<typename T>\nvoid float_constants(std::string type_name, std::ostream& os)\n{ //! Output a row of table values to `ostream` os.\n    os << \"\\n[\"\n          \"[\" << type_name << \"]\" ;\n    //os << \"[\" << (std::numeric_limits<T>::is_signed ? \"signed\" : \"unsigned\") << \"]\" ;\n    //os << \"[\" << (std::numeric_limits<T>::is_exact ? \"exact\" : \"inexact\") << \"]\" ;\n    //os << \"[\" << (std::numeric_limits<T>::is_bounded ? \"bound\" : \"no\") << \"]\" ;\n    // os << \"[\" << (std::numeric_limits<T>::is_modulo ? \"modulo\" : \"no\") << \"]\" ;\n    os << \"[\" ; out_round_style<T>(os); os << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::radix << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::digits << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::digits10 << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::max_digits10 << \"]\";\n    os << \"[\" << std::numeric_limits<T>::min_exponent << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::min_exponent10 << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::max_exponent << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::max_exponent10  << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::tinyness_before ? \"tiny\" : \"no\") << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::traps ? \"traps\" : \"no\") << \"]\" ;\n    os << \"]\" \"\\n\"; // end of row.\n} // void float_constants\n\n/* Types across and two functions down.\n\ntemplate<typename T>\nvoid integer_functions(std::string type_name, std::ostream& os)\n{ //! Output a line of table integer function values to `ostream` os.\n    os << \"\\n[\"\n          \"[\" << type_name << \"]\" ;\n    os << \"[\" << std::numeric_limits<T>::max() << \"]\" ;\n    //os << \"[\" << std::numeric_limits<T>::lowest() << \"]\" ;  always == min for integer types,\n    // so removed to save space.\n    os << \"[\" << std::numeric_limits<T>::min() << \"]\"\n      \"]\";\n} // void integer_functions\n\n*/\n\n// Types down and two (or three) functions across.\ntemplate<typename T>\nvoid integer_functions(std::string type_name, std::ostream& os)\n{ //! Output a line of table integer function values to `ostream` os.\n    os << \"\\n[\" // start of row.\n          \"[\" << type_name << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::max)() << \"]\" ;\n   // os << \"[\" << std::numeric_limits<T>::lowest() << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::min)() << \"]\" ;\n    os <<  \"]\"; // end of row.\n} // void integer_functions\n\n\ntemplate<typename T>\nvoid float_functions(std::string type_name, std::ostream& os)\n{ //! Output a line of table float-point function values to `ostream` os.\n    os << \"\\n[\" // start of row.\n          \"[\" << type_name << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::max)() << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::lowest)() << \"]\" ;\n    os << \"[\" << (std::numeric_limits<T>::min)() << \"]\"\n    os << \"[\" << std::numeric_limits<T>::epsilon() << \"]\"\n    os << \"[\" << std::numeric_limits<T>::round_error() << \"]\"\n    os << \"[\" << std::numeric_limits<T>::infinity() << \"]\"\n    os << \"[\" << std::numeric_limits<T>::quiet_NaN() << \"]\"\n    os << \"[\" << std::numeric_limits<T>::signaling_NaN() << \"]\"\n    os << \"[\" << std::numeric_limits<T>::denorm_min() << \"]\"\n      \"]\"; // end of row.\n} // void float_functions\n\ntemplate<typename T>\nint numeric_limits_list(std::string description)\n{//!  Output numeric_limits for numeric_limits<T>, for example `numeric_limits_list<bool>()`.\n  // This is not used for Quickbook format.\n  // std::cout << versions()  << std::endl;\n\n  std::cout << \"\\n\" << description << \"\\n\"  << std::endl; // int, int64_t rather than full long typeid(T).name().\n\n  std::cout << \"Type \" << typeid(T).name() << \" std::numeric_limits::<\" << typeid(T).name() << \">\\n\"  << std::endl;\n  // ull long typeid(T).name()\n\n  if (std::numeric_limits<T>::is_specialized == false)\n  {\n    std::cout << \"type \" << typeid(T).name()  << \" is not specialized for std::numeric_limits!\" << std::endl;\n    //return -1;\n  }\n\n  // Member constants.\n\n  std::cout << (std::numeric_limits<T>::is_signed ? \"is signed.\" : \"unsigned.\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::is_integer ? \"is integer.\" : \"not integer (fixed or float-point).\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::is_exact ? \"is exact.\" : \"not exact.\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::has_infinity ? \"has infinity.\" : \"no infinity.\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::has_quiet_NaN ? \"has quiet NaN.\" : \"no quiet NaN.\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::has_signaling_NaN ? \"has signaling NaN.\" : \"no signaling NaN.\")  << std::endl;\n  if (!std::numeric_limits<T>::is_integer)\n  { // is floating_point\n    std::cout << \"Denorm style is \" ;\n    if (std::numeric_limits<T>::has_denorm == std::denorm_absent)\n    {\n      std::cout << \"denorm_absent.\" << std::endl;\n    }\n    else if (std::numeric_limits<T>::has_denorm == std::denorm_present)\n    {\n      std::cout << \"denorm_present.\" << std::endl;\n    }\n    else if (std::numeric_limits<T>::has_denorm == std::denorm_indeterminate)\n    {\n      std::cout << \"denorm_indeterminate.\" << std::endl;\n    }\n    else\n    {\n      std::cout << \"std::numeric_limits<T>::has_denorm unexpected value!\" << std::endl;\n    }\n\n    std::cout << (std::numeric_limits<T>::has_denorm_loss ? \"has denorm loss.\" : \"no denorm loss.\")  << std::endl;\n    // true if a loss of accuracy is detected as a denormalization loss, rather than an inexact result.\n\n    std::cout << \"Round style is \";\n    if (std::numeric_limits<T>::round_style == std::round_indeterminate)\n    {\n      std::cout << \"round_indeterminate!\" << std::endl;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_toward_zero)\n    {\n      std::cout << \"round_toward_zero.\" << std::endl;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_to_nearest)\n    {\n      std::cout << \"round_to_nearest.\" << std::endl;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_toward_infinity)\n    {\n      std::cout << \"round_toward_infinity.\" << std::endl;\n    }\n    else if (std::numeric_limits<T>::round_style == std::round_toward_neg_infinity)\n    {\n      std::cout << \"round_toward_neg_infinity.\" << std::endl;\n    }\n    else\n    {\n      std::cout << \"undefined value!\" << std::endl;\n    }\n\n  } // is floating_point\n\n  std::cout << (std::numeric_limits<T>::is_iec559 ? \"is IEC599.\" : \"not IEC599.\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::is_bounded ? \"is bound.\" : \"unbounded.\")  << std::endl;\n  std::cout << (std::numeric_limits<T>::is_modulo ? \"is modulo.\" : \"no modulo.\")  << std::endl;\n  std::cout << std::dec << \"radix \" << std::numeric_limits<T>::radix  << std::endl;\n  std::cout << \"digits \" << std::numeric_limits<T>::digits  << std::endl;\n  std::cout << \"digits10 \" << std::numeric_limits<T>::digits10  << std::endl;\n\n  std::cout.precision(std::numeric_limits<T>::max_digits10); // Full precision for floating-point values like max, min ...\n\n  std::cout << \"max_digits10 \" << std::numeric_limits<T>::max_digits10  << std::endl;\n  std::cout << \"min_exponent \" << std::numeric_limits<T>::min_exponent  << std::endl;\n  std::cout << \"min_exponent10 \" << std::numeric_limits<T>::min_exponent10  << std::endl;\n  std::cout << \"max_exponent \" << std::numeric_limits<T>::max_exponent  << std::endl;\n  std::cout << \"max_exponent10 \" << std::numeric_limits<T>::max_exponent10  << std::endl;\n\n  std::cout << (std::numeric_limits<T>::tinyness_before ? \"Can tiny values before rounding.\" : \"no tinyness_before.\")  << std::endl;\n  // true if the type can detect tiny values before rounding; false if it cannot.\n  std::cout << (std::numeric_limits<T>::traps ? \"traps\" : \"no trapping.\")  << std::endl;\n  // Whether trapping that reports on arithmetic exceptions is implemented for a type.\n\n  std::cout << \"Member functions.\" << std::endl;\n  // (assumes operator<< for type T is available).\n  // If floating-point then hex format may not be available.\n\n  std::cout << \"max = \" << (std::numeric_limits<T>::max)() << std::endl;\n  //if (std::numeric_limits<T>::is_integer)\n  //{\n  //  std::cout << \"    = \" << std::hex << std::numeric_limits<T>::max() << std::endl;\n  //}\n\n  std::cout << \"lowest = \" << std::dec << std::numeric_limits<T>::lowest() << std::endl;\n  //if (std::numeric_limits<T>::is_integer)\n  //{\n  //   std::cout << \"       = \" << std::hex << std::numeric_limits<T>::lowest() << std::endl;\n  //}\n\n  std::cout << \"min = \" << (std::dec << std::numeric_limits<T>::min)() << std::endl;\n  //if (std::numeric_limits<T>::is_integer)\n  //{\n  //  std::cout << \"    = \" << std::hex << std::numeric_limits<T>::min() << std::endl;\n  //}\n\n  std::cout << \"epsilon = \" << std::dec << std::numeric_limits<T>::epsilon() << std::endl;\n  //if (std::numeric_limits<T>::is_integer)\n  //{\n  //  std::cout << \"        = \" << std::hex << std::numeric_limits<T>::epsilon() << std::endl;\n  //}\n  // round_error is always zero for integer types.\n  // round_error is usually 1/2 = (T)0.5 for floating-point types.\n  // round_error is ? for fixed-point.\n  std::cout << \"round_error = \" << std::numeric_limits<T>::round_error() << \" ULP.\" << std::endl;\n\n  std::cout << \"infinity = \" << std::dec << std::numeric_limits<T>::infinity() << std::endl;\n  std::cout << \"         = \" << std::hex << std::numeric_limits<T>::infinity() << std::endl;\n\n  std::cout << \"quiet_NaN = \" << std::dec << std::numeric_limits<T>::quiet_NaN() << std::endl;\n  std::cout << \"          = \" << std::hex << std::numeric_limits<T>::quiet_NaN() << std::endl;\n\n  std::cout << \"signaling_NaN = \" << std::dec << std::numeric_limits<T>::signaling_NaN() << std::endl;\n  std::cout << \"              = \" << std::hex << std::numeric_limits<T>::signaling_NaN() << std::endl;\n\n  //  Only meaningful if (std::numeric_limits<T>::has_denorm == std::denorm_present)\n  // so might not bother to show if absent?\n  std::cout << \"denorm_min = \" << std::numeric_limits<T>::denorm_min()  << std::endl;\n  std::cout << \"           = \" << std::numeric_limits<T>::denorm_min()  << std::endl;\n  return 0;\n}\n\nint main()\n{\n\n\n\n  try\n  {\n    using namespace nil::crypto3::multiprecision;\n\n    std::cout << versions() << std::endl;\n\n    std::ofstream fout(filename, std::ios_base::out);\n    if (!fout.is_open())\n    {\n      std::cout << \"Unable to open file \" << filename << \" for output.\\n\" << std::endl;\n      return -1; // boost::EXIT_FAILURE;\n    }\n    fout <<\n      \"[/\"\"\\n\"\n      \"Copyright 2013 Paul A. Bristow.\"\"\\n\"\n      \"Copyright 2013 John Maddock.\"\"\\n\"\n      \"Distributed under the Boost Software License, Version 1.0.\"\"\\n\"\n      \"(See accompanying file LICENSE_1_0.txt or copy at\"\"\\n\"\n      \"http://www.boost.org/LICENSE_1_0.txt).\"\"\\n\"\n      \"]\"\"\\n\"\n    << std::endl;\n\n    fout << \"[section:limits\"<< bits32_64 << \" Numeric limits for \" << bits32_64 << \"-bit platform]\" << std::endl;\n\n    // Output platform version info (32 or 64).\n    fout << \"These tables were generated using the following program and options:\\n\\n\"\n      \"[pre\"\"\\n\"\n      << versions()\n      << \"]\"\"\\n\"\n      << std::endl;\n\n    fout << \"[table:integral_constants Integer types constants (`std::numeric_limits<T>::is_integer == true` && is_exact == true)\" \"\\n\"\n      \"[\";\n\n    for (size_t i = 0; i < integer_constant_heads.size(); i++)\n    { // signed, bound, modulo ...\n      fout << \"[\" << integer_constant_heads[i] << \"]\" ;\n    }\n    fout << \"]\";\n\n    integer_constants<bool>(\"bool\", fout);\n    integer_constants<char>(\"char\", fout);\n    integer_constants<unsigned char>(\"unsigned char\", fout);\n    integer_constants<char16_t>(\"char16_t\", fout);\n    integer_constants<char32_t>(\"char32_t\", fout);\n    integer_constants<short>(\"short\", fout);\n    integer_constants<unsigned short>(\"unsigned short\", fout);\n    integer_constants<int>(\"int\", fout);\n    integer_constants<unsigned int>(\"unsigned\", fout);\n    integer_constants<long>(\"long\", fout);\n    integer_constants<unsigned long>(\"unsigned long\", fout);\n    integer_constants<long long>(\"long long\", fout);\n    integer_constants<unsigned long long>(\"unsigned long long\", fout);\n    integer_constants<int32_t>(\"int32_t\", fout);\n    integer_constants<uint32_t>(\"uint32_t\", fout);\n    integer_constants<int64_t>(\"int64_t\", fout);\n    integer_constants<uint64_t>(\"uint64_t\", fout);\n    integer_constants<int128_t>(\"int128_t\", fout);\n    integer_constants<uint128_t>(\"uint128_t\", fout);\n    integer_constants<int256_t>(\"int256_t\", fout);\n    integer_constants<uint256_t>(\"uint256_t\", fout);\n   // integer_constants<int512_t>(\"int512_t\", fout);\n    //integer_constants<uint512_t>(\"uint512_t\", fout); // Too big?\n    integer_constants<cpp_int>(\"cpp_int\", fout);\n\n    fout << \"\\n]\\n\\n\";\n\n\n    fout << \"[table:integral_functions Integer types functions (`std::numeric_limits<T>::is_integer == true && std::numeric_limits<T>::min() == std::numeric_limits<T>::lowest()` )\" \"\\n\"\n      \"[\";\n    // Display types across the page, and 2 (or 3) functions as rows.\n\n    fout << \"[function]\";\n    for (size_t i = 0; i < integer_function_heads.size(); i++)\n    {\n      fout << \"[\" << integer_function_heads[i] << \"]\" ;\n    }\n    fout << \"]\"; // end of headings.\n    integer_functions<bool>(\"bool\", fout);\n    //integer_functions<char>(\"char\", fout); // Need int value not char.\n    fout << \"\\n[\" // start of row.\n       \"[\" << \"char\"<< \"]\" ;\n    fout << \"[\" << static_cast<int>(std::numeric_limits<char>::max)() << \"]\" ;\n   // fout << \"[\" << (std::numeric_limits<T>::lowest)() << \"]\" ;\n    fout << \"[\" << static_cast<int>(std::numeric_limits<char>::min)() << \"]\" ;\n    fout <<  \"]\"; // end of row.\n    //integer_functions<unsigned char>(\"unsigned char\", fout); // Need int value not char.\n    fout << \"\\n[\" // start of row.\n       \"[\" << \"unsigned char\"<< \"]\" ;\n    fout << \"[\" << static_cast<int>(std::numeric_limits<unsigned char>::max)() << \"]\" ;\n   // fout << \"[\" << std::numeric_limits<unsigned char>::lowest() << \"]\" ;\n    fout << \"[\" << static_cast<int>(std::numeric_limits<unsigned char>::min)() << \"]\" ;\n    fout <<  \"]\"; // end of row.\n\n    integer_functions<char16_t>(\"char16_t\", fout);\n    integer_functions<char32_t>(\"char32_t\", fout);\n    integer_functions<short>(\"short\", fout);\n    integer_functions<unsigned short>(\"unsigned short\", fout);\n    integer_functions<int>(\"int\", fout);\n    integer_functions<unsigned int>(\"unsigned int\", fout);\n    integer_functions<long>(\"long\", fout);\n    integer_functions<unsigned long>(\"unsigned long\", fout);\n    integer_functions<long long>(\"long long\", fout);\n    integer_functions<unsigned long long>(\"unsigned long long\", fout);\n    integer_functions<int32_t>(\"int32_t\", fout);\n    integer_functions<int64_t>(\"int64_t\", fout);\n    integer_functions<int128_t>(\"int128_t\", fout);\n    fout << \"]\" \"\\n\";  // end of table;\n\n\n    //fout << \"[[max]\"\n    //  << \"[\" << std::numeric_limits<bool>::max() << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<char>::max()) << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<unsigned char>::max()) << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<char16_t>::max()) << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<char32_t>::max()) << \"]\"\n    //  << \"[\" << std::numeric_limits<short>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned short>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<int>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned int>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<long>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned long>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<long long>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned long long>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<int32_t>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<int64_t>::max() << \"]\"\n    //  << \"[\" << std::numeric_limits<int128_t>::max() << \"]\"\n    //  //<< \"[\" << std::numeric_limits<int256_t>::max() << \"]\"  // too big?\n    //  //<< \"[\" << std::numeric_limits<int512_t>::max() << \"]\" // too big?\n    //  << \"]\" \"\\n\";\n    ///*  Assume lowest() is not useful as == min for all integer types.\n    // */\n\n    //fout << \"[[min]\"\n    //  << \"[\" << std::numeric_limits<bool>::min() << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<char>::min()) << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<unsigned char>::min()) << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<char16_t>::min()) << \"]\"\n    //  << \"[\" << static_cast<int>(std::numeric_limits<char32_t>::min()) << \"]\"\n    //  << \"[\" << std::numeric_limits<short>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned short>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<int>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned int>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<long>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned long>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<long long>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<unsigned long long>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<int32_t>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<int64_t>::min() << \"]\"\n    //  << \"[\" << std::numeric_limits<int128_t>::min() << \"]\"\n    //  // << \"[\" << std::numeric_limits<int256_t>::min() << \"]\"  // too big?\n    //  // << \"[\" << std::numeric_limits<int512_t>::min() << \"]\"  // too big?\n    //  << \"]\"\"\\n\";\n\n\n\n  // Floating-point\n\n    typedef number<cpp_dec_float<50> > cpp_dec_float_50; // 50 decimal digits.\n    typedef number<cpp_bin_float<113> > bin_128bit_double_type; // == Binary rare long double.\n\n    fout <<\n      //\"[table:float_functions Floating-point types constants (`std::numeric_limits<T>::is_integer == false && std::numeric_limits<T>::is_modulo == false` )\" \"\\n\"\n      \"[table:float_functions Floating-point types constants (`std::numeric_limits<T>::is_integer==false && is_signed==true && is_modulo==false && is_exact==false && is_bound==true`)\" \"\\n\"\n      \"[\";\n    for (size_t i = 0; i < float_constant_heads.size(); i++)\n    {\n      fout << \"[\" << float_constant_heads[i] << \"]\" ;\n    }\n    fout << \"]\"; // end of headings.\n\n    float_constants<float>(\"float\", fout);\n    float_constants<double>(\"double\", fout);\n    float_constants<long double>(\"long double\", fout);\n    float_constants<cpp_dec_float_50>(\"cpp_dec_float_50\", fout);\n    float_constants<bin_128bit_double_type>(\"bin_128bit_double_type\", fout);\n    fout << \"]\" \"\\n\";  // end of table;\n\n    fout <<\n      \"[table:float_functions Floating-point types functions (`std::numeric_limits<T>::is_integer == false`)\" \"\\n\"\n      \"[\";\n\n    for (size_t i = 0; i < float_type_names.size(); i++)\n    {\n      fout << \"[\" << float_type_names[i] << \"]\" ;\n    }\n    fout << \"]\"; // end of headings.\n\n    fout << \"[[max]\"\n      << \"[\" << (std::numeric_limits<float>::max)() << \"]\"\n      << \"[\" << (std::numeric_limits<double>::max)() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Perhaps to test Long double is not just a duplication of double (but need change is headings too).\n      << \"[\" << (std::numeric_limits<long double>::max)() << \"]\"\n//#endif\n      << \"[\" << (std::numeric_limits<cpp_dec_float_50>::max)() << \"]\"\n      << \"[\" << (std::numeric_limits<bin_128bit_double_type >::max)() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[min]\"\n      << \"[\" << (std::numeric_limits<float>::min)() << \"]\"\n      << \"[\" << (std::numeric_limits<double>::min)() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << (std::numeric_limits<long double>::min)() << \"]\"\n//#endif\n      << \"[\" << (std::numeric_limits<cpp_dec_float_50 >::min)() << \"]\"\n      << \"[\" << (std::numeric_limits<bin_128bit_double_type >::min)() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[epsilon]\"\n      << \"[\" << std::numeric_limits<float>::epsilon() << \"]\"\n      << \"[\" << std::numeric_limits<double>::epsilon() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << std::numeric_limits<long double>::epsilon() << \"]\"\n//#endif\n      << \"[\" << std::numeric_limits<cpp_dec_float_50 >::epsilon() << \"]\"\n      << \"[\" << std::numeric_limits<bin_128bit_double_type >::epsilon() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[round_error]\"\n      << \"[\" << std::numeric_limits<float>::round_error() << \"]\"\n      << \"[\" << std::numeric_limits<double>::round_error() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << std::numeric_limits<long double>::round_error() << \"]\"\n//#endif\n      << \"[\" << std::numeric_limits<cpp_dec_float_50 >::round_error() << \"]\"\n      << \"[\" << std::numeric_limits<bin_128bit_double_type >::round_error() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[infinity]\"\n      << \"[\" << std::numeric_limits<float>::infinity() << \"]\"\n      << \"[\" << std::numeric_limits<double>::infinity() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << std::numeric_limits<long double>::infinity() << \"]\"\n//#endif\n      << \"[\" << std::numeric_limits<cpp_dec_float_50 >::infinity() << \"]\"\n      << \"[\" << std::numeric_limits<bin_128bit_double_type >::infinity() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[quiet_NaN]\"\n      << \"[\" << std::numeric_limits<float>::quiet_NaN() << \"]\"\n      << \"[\" << std::numeric_limits<double>::quiet_NaN() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << std::numeric_limits<long double>::quiet_NaN() << \"]\"\n//#endif\n      << \"[\" << std::numeric_limits<cpp_dec_float_50 >::quiet_NaN() << \"]\"\n      << \"[\" << std::numeric_limits<bin_128bit_double_type >::quiet_NaN() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[signaling_NaN]\"\n      << \"[\" << std::numeric_limits<float>::signaling_NaN() << \"]\"\n      << \"[\" << std::numeric_limits<double>::signaling_NaN() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << std::numeric_limits<long double>::signaling_NaN() << \"]\"\n//#endif\n      << \"[\" << std::numeric_limits<cpp_dec_float_50 >::signaling_NaN() << \"]\"\n      << \"[\" << std::numeric_limits<bin_128bit_double_type >::signaling_NaN() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n    fout << \"[[denorm_min]\"\n      << \"[\" << std::numeric_limits<float>::denorm_min() << \"]\"\n      << \"[\" << std::numeric_limits<double>::denorm_min() << \"]\"\n//#if LDBL_MANT_DIG > DBL_MANT_DIG\n    // Long double is not just a duplication of double.\n      << \"[\" << std::numeric_limits<long double>::denorm_min() << \"]\"\n//#endif\n      << \"[\" << std::numeric_limits<cpp_dec_float_50 >::denorm_min() << \"]\"\n      << \"[\" << std::numeric_limits<bin_128bit_double_type >::denorm_min() << \"]\"\n      << \"]\" \"\\n\"; // end of row.\n\n\n\n     fout << \"]\" \"\\n\";  // end of table;\n\n\n       fout <<  \"\\n\\n\"\n    \"[endsect] [/section:limits32  Numeric limits for 32-bit platform]\" \"\\n\" << std::endl;\n\n\n\n    fout.close();\n  }\n  catch(std::exception ex)\n  {\n    std::cout << \"exception thrown: \" << ex.what() << std::endl;\n  }\n\n\n} // int main()\n\n/*\n  Description: Autorun \"J:\\Cpp\\Misc\\Debug\\numeric_limits_qbk.exe\"\n\n  Program: I:\\boost-sandbox\\multiprecision.cpp_bin_float\\libs\\multiprecision\\doc\\numeric_limits_qbk.cpp\n  Wed Aug 28 14:17:21 2013\n  BuildInfo:\n    Platform Win32\n    Compiler Microsoft Visual C++ version 10.0\n    MSVC version 160040219.\n    STL Dinkumware standard library version 520\n    Boost version 1.55.0\n\n  */\n\n", "meta": {"hexsha": "4f6425b220e3274b95a522c79207236682293045", "size": 29497, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "snark-logic/libs-source/multiprecision/doc/numeric_limits_qbk.cpp", "max_stars_repo_name": "podlodkin/podlodkin-freeton-year-control", "max_stars_repo_head_hexsha": "e394c11f2414804d2fbde93a092ae589d4359739", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2021-09-14T18:09:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-14T18:09:38.000Z", "max_issues_repo_path": "snark-logic/libs-source/multiprecision/doc/numeric_limits_qbk.cpp", "max_issues_repo_name": "podlodkin/podlodkin-freeton-year-control", "max_issues_repo_head_hexsha": "e394c11f2414804d2fbde93a092ae589d4359739", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "snark-logic/libs-source/multiprecision/doc/numeric_limits_qbk.cpp", "max_forks_repo_name": "podlodkin/podlodkin-freeton-year-control", "max_forks_repo_head_hexsha": "e394c11f2414804d2fbde93a092ae589d4359739", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-08-31T06:27:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-31T06:27:19.000Z", "avg_line_length": 40.9680555556, "max_line_length": 188, "alphanum_fraction": 0.5875173746, "num_tokens": 8197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4571367020358429, "lm_q2_score": 0.11279539882690352, "lm_q1q2_score": 0.05156291662454826}}
{"text": "//==================================================================================================\n/*!\n  @file\n\n  @copyright 2016 NumScale SAS\n\n  Distributed under the Boost Software License, Version 1.0.\n  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)\n\n**/\n//==================================================================================================\n#ifndef BOOST_SIMD_OPERATOR_HPP_INCLUDED\n#define BOOST_SIMD_OPERATOR_HPP_INCLUDED\n\nnamespace boost { namespace simd\n{\n  /*!\n    @ingroup group-functions\n    @defgroup group-operator Operators\n\n    These functions provide scalar and SIMD version of the native C and C++ operators.\n\n    Operators are provided in infix and prefix notations, except for scalar floating types\n    as C++ does not allow overloading of operators for these types. Operators &, |, ~,  % and\n    the ternary operator ?: are also not defined for floating types in C++.\n    In these seldomly used cases, prefix bitwise_and, bitwise_or, complement\n    and if_else are required.\n\n    @warningbox{Note that && and || overloaded on simd packs do not make short circuitry}\n\n    Here is the list of of operators and their infix associated notation.\n    These remarks are only valid if the prefix notation is used and at least one parameter is a pack:\n    otherwise infix operators on scalars are regulated by usual C++ langage rules.\n\n    All operators are included as soon as <boost/simd/pack.hpp> is included.\n\n    <center>\n    | Name                    | op  | arity |   types      |  precondition/result                          |\n    |-------------------------|-----|-------|--------------|-----------------------------------------------|\n    | @ref bitwise_and        | &   |  2    |  T1, T2      |  same bit size for T1 and T2    (1)           |\n    | @ref bitwise_or         | \\|  |  2    |  T1, T2      |  same bit size for T1 and T2    (1)           |\n    | @ref bitwise_xor        | ^   |  2    |  T1, T2      |  same bit size for T1 and T2    (1)           |\n    | @ref complement         | ~   |  1    |  T1          |                                               |\n    | @ref divides            | /   |  2    |  T1, T1      |  arithmetic types               (2)           |\n    | @ref div                | /   |  2    |  T1, T1      |  arithmetic types               (2)           |\n    | @ref if_else            | NA  |  3    |  T1, T2, T2  |                                               |\n    | @ref is_equal           | ==  |  2    |  T1, T1      |                                               |\n    | @ref is_greater         | >   |  2    |  T1, T1      |                                               |\n    | @ref is_greater_equal   | >=  |  2    |  T1, T1      |                                               |\n    | @ref is_less            | <   |  2    |  T1, T1      |                                               |\n    | @ref is_less_equal      | <=  |  2    |  T1, T1      |                                               |\n    | @ref is_not_equal       | !=  |  2    |  T1, T1      |                                               |\n    | @ref logical_and        | &&  |  2    |  T1, T1      |  returns a @ref logical                       |\n    | @ref logical_not        | !   |  1    |  T1, T1      |  returns a @ref logical                       |\n    | @ref logical_or         | \\|\\||  2    |  T1, T1      |  returns a @ref logical                      |\n    | @ref minus              | -   |  2    |  T1, T1      |  arithmetic types                (2)          |\n    | @ref rem                | %   |  2    |  T1, T2      |  T2 is integral scalar or associated to T1 (3)|\n    | @ref multiplies         | *   |  2    |  T1, T1      |  arithmetic types                (2)          |\n    | @ref plus               | +   |  2    |  T1, T1      |  arithmetic types                (2)          |\n    | @ref shift_left         | <<  |  2    |  T1, T2      |  T2 is integral scalar or associated to T1 (3)|\n    | @ref shift_right        | >>  |  2    |  T1, T2      |  T2 is integral scalar or associated to T1 (3)|\n    | @ref shr (logical shift)|     |  2    |  T1, T2      |  T2 is integral scalar or associated to T1 (3)|\n    | @ref unary_minus        | -   |  1    |  T1          |  signed arithmetic types         (2)          |\n    | @ref unary_plus         | +   |  1    |  T1          |  arithmetic types                (2)          |\n    </center>\n\n\n    Notes:\n     - (1)  This precisely means sizeof(T1) == sizeof(T2) or one is scalar and its size in bits is the same as\n           the element of the other (which is a pack).\n\n     - (2)  arithmetic types are defined as std::int8_t, std::int16_t, std::int32_t, std::int64_t,\n           std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, float, double and packs of these.\n\n           The use of implementation dependent types as char, int, long, long long and their unsigned conterpart\n           is discouraged and even may lead to inconsistent behaviour.\n\n           Also it must be noted that \"arithmetic\" operators cannot mix types. This is to ensure correct SIMD\n           performance if the operation is supported by hardware.\n\n     - (3)  This precisely means T2 is both scalar and of integral type or T2 is as_integer_t<T1>. Note that if T2 scalar\n           is always simd hardware supported, the other case is often emulated.\n\n   Extensions:\n\n      @ref div \"division\"  and @ref rem \"remainder\" operators have extensions to be seen following the links.\n\n  **/\n} }\n\n#include <boost/simd/function/bitwise_and.hpp>\n#include <boost/simd/function/bitwise_or.hpp>\n#include <boost/simd/function/bitwise_xor.hpp>\n#include <boost/simd/function/complement.hpp>\n#include <boost/simd/function/div.hpp>\n#include <boost/simd/function/divides.hpp>\n#include <boost/simd/function/minus.hpp>\n#include <boost/simd/function/multiplies.hpp>\n#include <boost/simd/function/plus.hpp>\n#include <boost/simd/function/shift_left.hpp>\n#include <boost/simd/function/shift_right.hpp>\n#include <boost/simd/function/shl.hpp>\n#include <boost/simd/function/unary_minus.hpp>\n#include <boost/simd/function/unary_plus.hpp>\n#include <boost/simd/function/if_else.hpp>\n#include <boost/simd/function/is_equal.hpp>\n#include <boost/simd/function/is_greater.hpp>\n#include <boost/simd/function/is_greater_equal.hpp>\n#include <boost/simd/function/is_less.hpp>\n#include <boost/simd/function/is_less_equal.hpp>\n#include <boost/simd/function/is_not_equal.hpp>\n#include <boost/simd/function/logical_and.hpp>\n#include <boost/simd/function/logical_not.hpp>\n#include <boost/simd/function/logical_or.hpp>\n#include <boost/simd/function/minus.hpp>\n#include <boost/simd/function/rem.hpp>\n#include <boost/simd/function/multiplies.hpp>\n#include <boost/simd/function/plus.hpp>\n#include <boost/simd/function/shift_left.hpp>\n#include <boost/simd/function/shift_right.hpp>\n#include <boost/simd/function/shl.hpp>\n#include <boost/simd/function/unary_minus.hpp>\n#include <boost/simd/function/unary_plus.hpp>\n\n#endif\n", "meta": {"hexsha": "e764aa6795e9f692651ab35a4ca4680401ffd2ca", "size": 7013, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "include/boost/simd/operator.hpp", "max_stars_repo_name": "TobiasLudwig/boost.simd", "max_stars_repo_head_hexsha": "c04d0cc56747188ddb9a128ccb5715dd3608dbc1", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "include/boost/simd/operator.hpp", "max_issues_repo_name": "TobiasLudwig/boost.simd", "max_issues_repo_head_hexsha": "c04d0cc56747188ddb9a128ccb5715dd3608dbc1", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "include/boost/simd/operator.hpp", "max_forks_repo_name": "TobiasLudwig/boost.simd", "max_forks_repo_head_hexsha": "c04d0cc56747188ddb9a128ccb5715dd3608dbc1", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 3.0, "max_forks_repo_forks_event_min_datetime": "2018-02-16T09:58:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-10T14:22:43.000Z", "avg_line_length": 55.6587301587, "max_line_length": 121, "alphanum_fraction": 0.5321545701, "num_tokens": 1744, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.476579651063676, "lm_q2_score": 0.10818896318842185, "lm_q1q2_score": 0.05156065832527897}}
{"text": "// normalEqn.hpp\n#ifndef COURSERA_NORMALEQN_HPP\n#define COURSERA_NORMALEQN_HPP\n\n#include <memory>\n#include <armadillo>\n\nvoid normalEqn(std::shared_ptr<arma::fvec> &theta,\n               const std::shared_ptr<arma::fmat> &X, const std::shared_ptr<arma::fvec> &y);\n\n#endif // COURSERA_NORMALEQN_HPP\n", "meta": {"hexsha": "780f14820e49776851741f5e281e880300a62c5b", "size": 297, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "ex1/normalEqn.hpp", "max_stars_repo_name": "kolbma/coursera-ml", "max_stars_repo_head_hexsha": "a8473829138804cf6a46cc60e076d9851b55ae25", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-11-15T21:08:21.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-15T21:08:21.000Z", "max_issues_repo_path": "ex1/normalEqn.hpp", "max_issues_repo_name": "kolbma/coursera-ml", "max_issues_repo_head_hexsha": "a8473829138804cf6a46cc60e076d9851b55ae25", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ex1/normalEqn.hpp", "max_forks_repo_name": "kolbma/coursera-ml", "max_forks_repo_head_hexsha": "a8473829138804cf6a46cc60e076d9851b55ae25", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.75, "max_line_length": 91, "alphanum_fraction": 0.7306397306, "num_tokens": 93, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.42632159254749036, "lm_q2_score": 0.12085322299118381, "lm_q1q2_score": 0.051522338490098456}}
{"text": "/*\n@copyright Louis Dionne 2015\nDistributed under the Boost Software License, Version 1.0.\n(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)\n */\n\n#ifndef BOOST_HANA_TEST_LAWS_SEQUENCE_HPP\n#define BOOST_HANA_TEST_LAWS_SEQUENCE_HPP\n\n#include <boost/hana/assert.hpp>\n#include <boost/hana/config.hpp>\n#include <boost/hana/core/datatype.hpp>\n#include <boost/hana/functional/compose.hpp>\n#include <boost/hana/functional/id.hpp>\n#include <boost/hana/functional/partial.hpp>\n#include <boost/hana/integral_constant.hpp>\n#include <boost/hana/maybe.hpp>\n#include <boost/hana/sequence.hpp>\n\n#include <laws/base.hpp>\n\n#include <test/equivalence_class.hpp>\n#include <test/identity.hpp>\n#include <test/minimal_product.hpp>\n#include <test/numeric.hpp>\n#include <test/seq.hpp>\n\n#include <type_traits>\n#include <vector>\n\n\nnamespace boost { namespace hana { namespace test {\n    template <typename S, typename = when<true>>\n    struct TestSequence : TestSequence<S, laws> {\n        using TestSequence<S, laws>::TestSequence;\n    };\n\n    template <typename S>\n    struct TestSequence<S, laws> {\n        static_assert(_models<Sequence, S>{}, \"\");\n\n        template <int i>\n        using eq = integer<i,\n              Policy::Comparable\n            | Policy::Constant\n        >;\n\n        template <int i>\n        using cx_eq = integer<i,\n              Policy::Comparable\n            | Policy::Constexpr\n        >;\n\n        template <int i>\n        using ord = integer<i,\n              Policy::Orderable\n            | Policy::Constant\n        >;\n\n        struct undefined { };\n\n        TestSequence() {\n            constexpr auto list = make<S>;\n\n            //////////////////////////////////////////////////////////////////\n            // Check for basic data type consistency\n            //////////////////////////////////////////////////////////////////\n            struct Random;\n            static_assert(std::is_same<datatype_t<decltype(list())>, S>{}, \"\");\n            static_assert(std::is_same<datatype_t<decltype(list(1))>, S>{}, \"\");\n            static_assert(std::is_same<datatype_t<decltype(list(1, '2'))>, S>{}, \"\");\n            static_assert(std::is_same<datatype_t<decltype(list(1, '2', 3.3))>, S>{}, \"\");\n            static_assert(!std::is_same<datatype_t<Random>, S>{}, \"\");\n\n            //////////////////////////////////////////////////////////////////\n            // Foldable -> Sequence conversion\n            //////////////////////////////////////////////////////////////////\n            {\n            auto foldable = seq;\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                to<S>(foldable()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                to<S>(foldable(eq<0>{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                to<S>(foldable(eq<0>{}, eq<1>{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                to<S>(foldable(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                to<S>(foldable(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // make (tautological given our definition of `list`)\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                make<S>(),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                make<S>(eq<0>{}),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                make<S>(eq<0>{}, eq<1>{}),\n                list(eq<0>{}, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                make<S>(eq<0>{}, eq<1>{}, eq<2>{}),\n                list(eq<0>{}, eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                make<S>(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}),\n                list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // init\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                init(list(undefined{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                init(list(eq<0>{}, undefined{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                init(list(eq<0>{}, eq<1>{}, undefined{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                init(list(eq<0>{}, eq<1>{}, eq<2>{}, undefined{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{})\n            ));\n\n\n            BOOST_HANA_CONSTEXPR_CHECK(equal(\n                init(list(cx_eq<1>{}, cx_eq<2>{})),\n                list(cx_eq<1>{})\n            ));\n            BOOST_HANA_CONSTEXPR_CHECK(equal(\n                init(list(cx_eq<1>{}, cx_eq<2>{}, cx_eq<3>{})),\n                list(cx_eq<1>{}, cx_eq<2>{})\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // intersperse\n            //////////////////////////////////////////////////////////////////\n            {\n            auto z = eq<999>{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(), undefined{}),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(eq<0>{}), undefined{}),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(eq<0>{}, eq<1>{}), z),\n                list(eq<0>{}, z, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(eq<0>{}, eq<1>{}, eq<2>{}), z),\n                list(eq<0>{}, z, eq<1>{}, z, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}), z),\n                list(eq<0>{}, z, eq<1>{}, z, eq<2>{}, z, eq<3>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}), z),\n                list(eq<0>{}, z, eq<1>{}, z, eq<2>{}, z, eq<3>{}, z, eq<4>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                intersperse(list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}, eq<5>{}), z),\n                list(eq<0>{}, z, eq<1>{}, z, eq<2>{}, z, eq<3>{}, z, eq<4>{}, z, eq<5>{})\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // slice\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(), size_t<0>, size_t<0>),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(undefined{}), size_t<0>, size_t<0>),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(undefined{}, undefined{}), size_t<0>, size_t<0>),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(eq<0>{}), size_t<0>, size_t<1>),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(eq<0>{}, undefined{}), size_t<0>, size_t<1>),\n                list(eq<0>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(undefined{}, eq<1>{}), size_t<1>, size_t<2>),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(undefined{}, eq<1>{}, undefined{}), size_t<1>, size_t<2>),\n                list(eq<1>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(eq<0>{}, eq<1>{}), size_t<0>, size_t<2>),\n                list(eq<0>{}, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(eq<0>{}, eq<1>{}, undefined{}), size_t<0>, size_t<2>),\n                list(eq<0>{}, eq<1>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                slice(list(undefined{}, eq<1>{}, eq<2>{}), size_t<1>, size_t<3>),\n                list(eq<1>{}, eq<2>{})\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // take.at_most\n            //////////////////////////////////////////////////////////////////\n            {\n            auto take = hana::take.at_most;\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<0>, list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<1>, list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<2>, list()),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<0>, list(eq<0>{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<1>, list(eq<0>{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<2>, list(eq<0>{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<3>, list(eq<0>{})),\n                list(eq<0>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<0>, list(eq<0>{}, eq<1>{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<1>, list(eq<0>{}, eq<1>{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<2>, list(eq<0>{}, eq<1>{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<3>, list(eq<0>{}, eq<1>{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<10>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{},  eq<4>{},  eq<5>{},  eq<6>{},\n                                      eq<7>{}, eq<8>{}, eq<9>{}, eq<10>{}, eq<11>{}, eq<12>{}, eq<13>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}, eq<5>{}, eq<6>{}, eq<7>{}, eq<8>{}, eq<9>{})\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // take.exactly\n            //////////////////////////////////////////////////////////////////\n            {\n            auto take = hana::take.exactly;\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<0>, list()),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<0>, list(eq<0>{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<1>, list(eq<0>{})),\n                list(eq<0>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<0>, list(eq<0>{}, eq<1>{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<1>, list(eq<0>{}, eq<1>{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<2>, list(eq<0>{}, eq<1>{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take(size_t<10>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{},  eq<4>{},  eq<5>{},  eq<6>{},\n                                      eq<7>{}, eq<8>{}, eq<9>{}, eq<10>{}, eq<11>{}, eq<12>{}, eq<13>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}, eq<5>{}, eq<6>{}, eq<7>{}, eq<8>{}, eq<9>{})\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // remove_at\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<0>, list(eq<0>{})),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<0>, list(eq<0>{}, eq<1>{})),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<1>, list(eq<0>{}, eq<1>{})),\n                list(eq<0>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<0>, list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<1>, list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<0>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<2>, list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<0>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})),\n                list(eq<1>{}, eq<2>{}, eq<3>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<1>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})),\n                list(eq<0>{}, eq<2>{}, eq<3>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<2>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})),\n                list(eq<0>{}, eq<1>{}, eq<3>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<3>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<0>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{})),\n                list(eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<1>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{})),\n                list(eq<0>{}, eq<2>{}, eq<3>{}, eq<4>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<2>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{})),\n                list(eq<0>{}, eq<1>{}, eq<3>{}, eq<4>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<3>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{}, eq<4>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at(size_t<4>, list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{})),\n                list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // remove_at_c\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at_c<0>(list(eq<0>{})),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at_c<0>(list(eq<0>{}, eq<1>{})),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at_c<1>(list(eq<0>{}, eq<1>{})),\n                list(eq<0>{})\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at_c<0>(list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at_c<1>(list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<0>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                remove_at_c<2>(list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<0>{}, eq<1>{})\n            ));\n\n\n            //////////////////////////////////////////////////////////////////\n            // reverse\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                reverse(list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                reverse(list(eq<0>{})),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                reverse(list(eq<0>{}, eq<1>{})),\n                list(eq<1>{}, eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                reverse(list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(eq<2>{}, eq<1>{}, eq<0>{})\n            ));\n\n\n            BOOST_HANA_CONSTEXPR_CHECK(equal(\n                reverse(list(cx_eq<1>{})),\n                list(cx_eq<1>{})\n            ));\n            BOOST_HANA_CONSTEXPR_CHECK(equal(\n                reverse(list(cx_eq<1>{}, cx_eq<2>{})),\n                list(cx_eq<2>{}, cx_eq<1>{})\n            ));\n            BOOST_HANA_CONSTEXPR_CHECK(equal(\n                reverse(list(cx_eq<1>{}, cx_eq<2>{}, cx_eq<3>{})),\n                list(cx_eq<3>{}, cx_eq<2>{}, cx_eq<1>{})\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // sort\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort(list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort(list(ord<0>{})),\n                list(ord<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort(list(ord<0>{}, ord<1>{})),\n                list(ord<0>{}, ord<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort(list(ord<1>{}, ord<0>{})),\n                list(ord<0>{}, ord<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort(list(ord<1>{}, ord<0>{}, ord<4>{}, ord<2>{})),\n                list(ord<0>{}, ord<1>{}, ord<2>{}, ord<4>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort(list(ord<1>{}, ord<0>{}, ord<-4>{}, ord<2>{})),\n                list(ord<-4>{}, ord<0>{}, ord<1>{}, ord<2>{})\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // unzip\n            //////////////////////////////////////////////////////////////////\n            {\n            auto t = list; // tests are unreadable otherwise. mnemonic: tuple\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t())),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(), t())),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(eq<0>{}, eq<2>{}), t(eq<1>{}, eq<3>{}, eq<4>{}))),\n                list(t(eq<0>{}, eq<1>{}), t(eq<2>{}, eq<3>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(),     t(),     t()))    ,\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(eq<0>{}), t(),     t()))    ,\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(),     t(eq<1>{}), t()))    ,\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(),     t(),     t(eq<2>{}))),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(eq<0>{}), t(eq<1>{}), t()))    ,\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(),     t(eq<1>{}), t(eq<2>{}))),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(eq<0>{}), t(),     t(eq<2>{}))),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(eq<0>{}), t(eq<1>{}), t(eq<2>{}))),\n                list(t(eq<0>{}, eq<1>{}, eq<2>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unzip(list(t(eq<0>{}, eq<3>{}), t(eq<1>{}, eq<4>{}), t(eq<2>{}, eq<5>{}))),\n                list(t(eq<0>{}, eq<1>{}, eq<2>{}), t(eq<3>{}, eq<4>{}, eq<5>{}))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // span\n            //////////////////////////////////////////////////////////////////\n            {\n            auto z = eq<999>{};\n            auto prod = minimal_product;\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(), equal.to(z)),\n                prod(list(), list())\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(eq<0>{}), equal.to(z)),\n                prod(list(), list(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(z), equal.to(z)),\n                prod(list(z), list())\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(eq<0>{}, z), equal.to(z)),\n                prod(list(), list(eq<0>{}, z))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(z, eq<0>{}), equal.to(z)),\n                prod(list(z), list(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(eq<0>{}, eq<1>{}), equal.to(z)),\n                prod(list(), list(eq<0>{}, eq<1>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(eq<0>{}, eq<1>{}, eq<2>{}), equal.to(z)),\n                prod(list(), list(eq<0>{}, eq<1>{}, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(z, eq<1>{}, eq<2>{}), equal.to(z)),\n                prod(list(z), list(eq<1>{}, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(eq<0>{}, z, eq<2>{}), equal.to(z)),\n                prod(list(), list(eq<0>{}, z, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(z, z, eq<2>{}), equal.to(z)),\n                prod(list(z, z), list(eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                span(list(z, z, z), equal.to(z)),\n                prod(list(z, z, z), list())\n            ));\n            }\n\n\n            //////////////////////////////////////////////////////////////////\n            // take_while\n            //////////////////////////////////////////////////////////////////\n            {\n            auto z = eq<999>{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(), not_equal.to(z)),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(eq<1>{}), not_equal.to(z)),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(z), not_equal.to(z)),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(eq<1>{}, eq<2>{}), not_equal.to(z)),\n                list(eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(eq<1>{}, z), not_equal.to(z)),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(z, eq<2>{}), not_equal.to(z)),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(eq<1>{}, eq<2>{}, eq<3>{}), not_equal.to(z)),\n                list(eq<1>{}, eq<2>{}, eq<3>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(eq<1>{}, eq<2>{}, z), not_equal.to(z)),\n                list(eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(eq<1>{}, z, eq<3>{}), not_equal.to(z)),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_while(list(z, eq<2>{}, eq<3>{}), not_equal.to(z)),\n                list()\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // take_until\n            //////////////////////////////////////////////////////////////////\n            {\n            auto z = eq<999>{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(), equal.to(z)),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(eq<1>{}), equal.to(z)),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(z), equal.to(z)),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(eq<1>{}, eq<2>{}), equal.to(z)),\n                list(eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(eq<1>{}, z), equal.to(z)),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(z, eq<2>{}), equal.to(z)),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(eq<1>{}, eq<2>{}, eq<3>{}), equal.to(z)),\n                list(eq<1>{}, eq<2>{}, eq<3>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(eq<1>{}, eq<2>{}, z), equal.to(z)),\n                list(eq<1>{}, eq<2>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(eq<1>{}, z, eq<3>{}), equal.to(z)),\n                list(eq<1>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                take_until(list(z, eq<2>{}, eq<3>{}), equal.to(z)),\n                list()\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // permutations\n            //////////////////////////////////////////////////////////////////\n            {\n            auto permute = [=](auto xs) {\n                return [=](auto ...expected_) {\n                    auto actual = permutations(xs);\n                    auto expected = list(expected_...);\n\n                    BOOST_HANA_CONSTANT_CHECK(and_(\n                        equal(length(expected), length(actual)),\n                        all_of(actual, [=](auto x) { return elem(expected, x); })\n                    ));\n                };\n            };\n\n            BOOST_HANA_CONSTANT_CHECK(equal(permutations(list()), list(list())));\n\n            permute(list(eq<0>{}))(list(eq<0>{}));\n            permute(list(eq<0>{}, eq<1>{}))(\n                list(eq<0>{}, eq<1>{}),\n                list(eq<1>{}, eq<0>{})\n            );\n            permute(list(eq<0>{}, eq<1>{}, eq<2>{}))(\n                list(eq<0>{}, eq<1>{}, eq<2>{}),\n                list(eq<0>{}, eq<2>{}, eq<1>{}),\n                list(eq<1>{}, eq<0>{}, eq<2>{}),\n                list(eq<1>{}, eq<2>{}, eq<0>{}),\n                list(eq<2>{}, eq<0>{}, eq<1>{}),\n                list(eq<2>{}, eq<1>{}, eq<0>{})\n            );\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // group\n            //////////////////////////////////////////////////////////////////\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list()),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{})),\n                list(list(eq<0>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<0>{})),\n                list(list(eq<0>{}, eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<1>{})),\n                list(list(eq<0>{}), list(eq<1>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<0>{}, eq<0>{})),\n                list(list(eq<0>{}, eq<0>{}, eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<0>{}, eq<1>{})),\n                list(list(eq<0>{}, eq<0>{}), list(eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<1>{}, eq<0>{})),\n                list(list(eq<0>{}),\n                     list(eq<1>{}),\n                     list(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<1>{}, eq<0>{}, eq<0>{})),\n                list(list(eq<1>{}),\n                     list(eq<0>{}, eq<0>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<0>{}, eq<1>{}, eq<1>{})),\n                list(list(eq<0>{}, eq<0>{}),\n                     list(eq<1>{}, eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group(list(eq<0>{}, eq<0>{}, eq<1>{}, eq<1>{}, eq<2>{}, eq<2>{}, eq<2>{})),\n                list(list(eq<0>{}, eq<0>{}),\n                     list(eq<1>{}, eq<1>{}),\n                     list(eq<2>{}, eq<2>{}, eq<2>{}))\n            ));\n\n            //////////////////////////////////////////////////////////////////\n            // partition\n            //////////////////////////////////////////////////////////////////\n            {\n            auto prod = minimal_product;\n            auto pred = in ^ list(eq<-1>{}, eq<-2>{}, eq<-3>{}, eq<-4>{}, eq<-5>{});\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(), pred),\n                prod(list(), list())\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(eq<0>{}), pred),\n                prod(list(),\n                     list(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(eq<0>{}, eq<1>{}), pred),\n                prod(list(),\n                     list(eq<0>{}, eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(eq<-1>{}), pred),\n                prod(list(eq<-1>{}),\n                     list())\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(eq<-1>{}, eq<0>{}, eq<2>{}), pred),\n                prod(list(eq<-1>{}),\n                     list(eq<0>{}, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(eq<0>{}, eq<-3>{}, eq<2>{}, eq<-5>{}, eq<6>{}), pred),\n                prod(list(eq<-3>{}, eq<-5>{}),\n                     list(eq<0>{}, eq<2>{}, eq<6>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                partition(list(eq<-1>{}, eq<2>{}, eq<-3>{}, eq<0>{}, eq<-3>{}, eq<4>{}), pred),\n                prod(list(eq<-1>{}, eq<-3>{}, eq<-3>{}),\n                     list(eq<2>{}, eq<0>{}, eq<4>{}))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // scanl\n            //////////////////////////////////////////////////////////////////\n            {\n            _injection<0> f{};\n            auto s = eq<999>{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl(list(), s, f),\n                list(s)\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl(list(eq<0>{}), s, f),\n                list(s, f(s, eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl(list(eq<0>{}, eq<1>{}), s, f),\n                list(s, f(s, eq<0>{}), f(f(s, eq<0>{}), eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl(list(eq<0>{}, eq<1>{}, eq<2>{}), s, f),\n                list(\n                    s,\n                    f(s, eq<0>{}),\n                    f(f(s, eq<0>{}), eq<1>{}),\n                    f(f(f(s, eq<0>{}), eq<1>{}), eq<2>{})\n                )\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // scanr\n            //////////////////////////////////////////////////////////////////\n            {\n            _injection<0> f{};\n            auto s = eq<999>{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr(list(), s, f),\n                list(s)\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr(list(eq<0>{}), s, f),\n                list(\n                    f(eq<0>{}, s),\n                    s\n                )\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr(list(eq<0>{}, eq<1>{}), s, f),\n                list(\n                    f(eq<0>{}, f(eq<1>{}, s)),\n                    f(eq<1>{}, s),\n                    s\n                )\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr(list(eq<0>{}, eq<1>{}, eq<2>{}), s, f),\n                list(\n                    f(eq<0>{}, f(eq<1>{}, f(eq<2>{}, s))),\n                    f(eq<1>{}, f(eq<2>{}, s)),\n                    f(eq<2>{}, s),\n                    s\n                )\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // scanl1\n            //////////////////////////////////////////////////////////////////\n            {\n            _injection<0> f{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl1(list(), f),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl1(list(eq<0>{}), f),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl1(list(eq<0>{}, eq<1>{}), f),\n                list(eq<0>{}, f(eq<0>{}, eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl1(list(eq<0>{}, eq<1>{}, eq<2>{}), f),\n                list(\n                    eq<0>{},\n                    f(eq<0>{}, eq<1>{}),\n                    f(f(eq<0>{}, eq<1>{}), eq<2>{})\n                )\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanl1(list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}), f),\n                list(\n                    eq<0>{},\n                    f(eq<0>{}, eq<1>{}),\n                    f(f(eq<0>{}, eq<1>{}), eq<2>{}),\n                    f(f(f(eq<0>{}, eq<1>{}), eq<2>{}), eq<3>{})\n                )\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // scanr1\n            //////////////////////////////////////////////////////////////////\n            {\n            _injection<0> f{};\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr1(list(), f),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr1(list(eq<0>{}), f),\n                list(eq<0>{})\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr1(list(eq<0>{}, eq<1>{}), f),\n                list(\n                    f(eq<0>{}, eq<1>{}),\n                    eq<1>{}\n                )\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                scanr1(list(eq<0>{}, eq<1>{}, eq<2>{}), f),\n                list(\n                    f(eq<0>{}, f(eq<1>{}, eq<2>{})),\n                    f(eq<1>{}, eq<2>{}),\n                    eq<2>{}\n                )\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // unfoldl\n            //////////////////////////////////////////////////////////////////\n            {\n            auto prod = minimal_product;\n            _injection<0> f{};\n            auto stop_at = [=](auto stop) {\n                return [=](auto x) {\n                    return hana::if_(hana::equal(stop, x),\n                        hana::nothing,\n                        hana::just(prod(hana::succ(x), f(x)))\n                    );\n                };\n            };\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unfoldl<S>(stop_at(int_<0>), int_<0>),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unfoldl<S>(stop_at(int_<1>), int_<0>),\n                list(f(int_<0>))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unfoldl<S>(stop_at(int_<2>), int_<0>),\n                list(f(int_<1>), f(int_<0>))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unfoldl<S>(stop_at(int_<3>), int_<0>),\n                list(f(int_<2>), f(int_<1>), f(int_<0>))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                unfoldl<S>(stop_at(int_<4>), int_<0>),\n                list(f(int_<3>), f(int_<2>), f(int_<1>), f(int_<0>))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // unfoldr\n            //////////////////////////////////////////////////////////////////\n            {\n            auto prod = minimal_product;\n            _injection<0> f{};\n            auto stop_at = [=](auto stop) {\n                return [=](auto x) {\n                    return hana::if_(hana::equal(stop, x),\n                        nothing,\n                        hana::just(prod(f(x), hana::succ(x)))\n                    );\n                };\n            };\n\n            BOOST_HANA_CONSTANT_CHECK(hana::equal(\n                unfoldr<S>(stop_at(int_<0>), int_<0>),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(hana::equal(\n                unfoldr<S>(stop_at(int_<1>), int_<0>),\n                list(f(int_<0>))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(hana::equal(\n                unfoldr<S>(stop_at(int_<2>), int_<0>),\n                list(f(int_<0>), f(int_<1>))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(hana::equal(\n                unfoldr<S>(stop_at(int_<3>), int_<0>),\n                list(f(int_<0>), f(int_<1>), f(int_<2>))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(hana::equal(\n                unfoldr<S>(stop_at(int_<4>), int_<0>),\n                list(f(int_<0>), f(int_<1>), f(int_<2>), f(int_<3>))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // Make sure unfold{r,l} can be reversed under certain conditions.\n            //////////////////////////////////////////////////////////////////\n            {\n            auto prod = minimal_product;\n            auto z = eq<999>{};\n            auto f = prod;\n            auto g = [=](auto k) {\n                return if_(equal(k, z), nothing, just(k));\n            };\n\n            // Make sure the special conditions are met\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                g(z),\n                nothing\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                g(f(eq<0>{}, z)),\n                just(prod(eq<0>{}, z))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                g(f(z, eq<0>{})),\n                just(prod(z, eq<0>{}))\n            ));\n\n            // Make sure the reversing works\n            auto lists = list(\n                list(),\n                list(eq<0>{}),\n                list(eq<0>{}, eq<1>{}),\n                list(eq<0>{}, eq<1>{}, eq<2>{})\n            );\n            for_each(lists, [=](auto xs) {\n                BOOST_HANA_CONSTANT_CHECK(equal(\n                    unfoldl<S>(g, foldl(xs, z, f)),\n                    xs\n                ));\n                BOOST_HANA_CONSTANT_CHECK(equal(\n                    unfoldr<S>(g, foldr(xs, z, f)),\n                    xs\n                ));\n            });\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // sort_by\n            //////////////////////////////////////////////////////////////////\n            {\n            auto pred = [](auto x, auto y) {\n                return less(x.unwrap, y.unwrap);\n            };\n            auto a = [](auto z) { return test::tag(eq<999>{}, z); };\n            auto b = [](auto z) { return test::tag(eq<888>{}, z); };\n\n            auto check = [=](auto ...sorted) {\n                auto perms = transform(\n                    permutations(list(a(sorted)...)),\n                    partial(sort_by, pred)\n                );\n                BOOST_HANA_CONSTANT_CHECK(all_of(perms, [=](auto xs) {\n                    return equal(xs, list(a(sorted)...));\n                }));\n            };\n\n            check();\n            check(ord<1>{});\n            check(ord<1>{}, ord<2>{});\n            check(ord<1>{}, ord<2>{}, ord<3>{});\n\n            // check stability\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(a(ord<1>{}), b(ord<1>{}))),\n                list(a(ord<1>{}), b(ord<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(b(ord<1>{}), a(ord<1>{}))),\n                list(b(ord<1>{}), a(ord<1>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(a(ord<1>{}), b(ord<1>{}), a(ord<2>{}), b(ord<2>{}))),\n                list(a(ord<1>{}), b(ord<1>{}), a(ord<2>{}), b(ord<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(a(ord<1>{}), a(ord<2>{}), b(ord<1>{}), b(ord<2>{}))),\n                list(a(ord<1>{}), b(ord<1>{}), a(ord<2>{}), b(ord<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(b(ord<1>{}), a(ord<1>{}), a(ord<2>{}), b(ord<2>{}))),\n                list(b(ord<1>{}), a(ord<1>{}), a(ord<2>{}), b(ord<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(a(ord<2>{}), b(ord<1>{}), b(ord<2>{}), a(ord<1>{}))),\n                list(b(ord<1>{}), a(ord<1>{}), a(ord<2>{}), b(ord<2>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                sort_by(pred, list(a(ord<1>{}), a(ord<3>{}), b(ord<1>{}), a(ord<2>{}), b(ord<3>{}))),\n                list(a(ord<1>{}), b(ord<1>{}), a(ord<2>{}), a(ord<3>{}), b(ord<3>{}))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // group_by\n            //////////////////////////////////////////////////////////////////\n            {\n            auto a = [](auto z) { return test::tag(eq<999>{}, z); };\n            auto b = [](auto z) { return test::tag(eq<888>{}, z); };\n\n            BOOST_HANA_CONSTEXPR_LAMBDA auto pred = [](auto x, auto y) {\n                return equal(x.unwrap, y.unwrap);\n            };\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group_by(pred, list()),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group_by(pred, list(a(eq<0>{}))),\n                list(list(a(eq<0>{})))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group_by(pred, list(a(eq<0>{}), b(eq<0>{}))),\n                list(list(a(eq<0>{}), b(eq<0>{})))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group_by(pred, list(a(eq<0>{}), b(eq<0>{}), a(eq<1>{}))),\n                list(list(a(eq<0>{}), b(eq<0>{})), list(a(eq<1>{})))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group_by(pred, list(a(eq<0>{}), b(eq<0>{}), a(eq<1>{}), b(eq<1>{}))),\n                list(list(a(eq<0>{}), b(eq<0>{})), list(a(eq<1>{}), b(eq<1>{})))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                group_by(pred, list(a(eq<0>{}), b(eq<0>{}), a(eq<1>{}), b(eq<1>{}), b(eq<0>{}))),\n                list(list(a(eq<0>{}), b(eq<0>{})), list(a(eq<1>{}), b(eq<1>{})), list(b(eq<0>{})))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // zip.shortest\n            //////////////////////////////////////////////////////////////////\n            {\n            auto zip = hana::zip.shortest;\n            auto t = list; // tests are unreadable otherwise. mnemonic: tuple\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{})),\n                list(t(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}, eq<1>{})),\n                list(t(eq<0>{}), t(eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(t(eq<0>{}), t(eq<1>{}), t(eq<2>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}), list(eq<1>{})),\n                list(t(eq<0>{}, eq<1>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}), list(eq<1>{}), list(eq<2>{})),\n                list(t(eq<0>{}, eq<1>{}, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}, eq<3>{}), list(eq<1>{}, eq<4>{}), list(eq<2>{}, eq<5>{}, eq<8>{})),\n                list(t(eq<0>{}, eq<1>{}, eq<2>{}), t(eq<3>{}, eq<4>{}, eq<5>{}))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // zip.unsafe\n            //////////////////////////////////////////////////////////////////\n            {\n            auto zip = hana::zip.unsafe;\n            auto t = list; // tests are unreadable otherwise. mnemonic: tuple\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{})),\n                list(t(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}, eq<1>{})),\n                list(t(eq<0>{}), t(eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(t(eq<0>{}), t(eq<1>{}), t(eq<2>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}), list(eq<1>{})),\n                list(t(eq<0>{}, eq<1>{}))\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}), list(eq<1>{}), list(eq<2>{})),\n                list(t(eq<0>{}, eq<1>{}, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(list(eq<0>{}, eq<3>{}), list(eq<1>{}, eq<4>{}), list(eq<2>{}, eq<5>{})),\n                list(t(eq<0>{}, eq<1>{}, eq<2>{}), t(eq<3>{}, eq<4>{}, eq<5>{}))\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // zip.unsafe.with\n            //////////////////////////////////////////////////////////////////\n            {\n            _injection<0> f{};\n            auto zip = hana::zip.unsafe.with;\n\n            // zip 1\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{})),\n                list(f(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}, eq<1>{})),\n                list(f(eq<0>{}), f(eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(f(eq<0>{}), f(eq<1>{}), f(eq<2>{}))\n            ));\n\n            // zip 2\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}), list(eq<-1>{})),\n                list(f(eq<1>{}, eq<-1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}, eq<2>{}), list(eq<-1>{}, eq<-2>{})),\n                list(f(eq<1>{}, eq<-1>{}), f(eq<2>{}, eq<-2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}, eq<2>{}, eq<3>{}), list(eq<-1>{}, eq<-2>{}, eq<-3>{})),\n                list(f(eq<1>{}, eq<-1>{}), f(eq<2>{}, eq<-2>{}), f(eq<3>{}, eq<-3>{}))\n            ));\n\n            // zip 3\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(),          list(),          list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}), list(eq<1>{}), list(eq<2>{})),\n                list(f(eq<0>{}, eq<1>{}, eq<2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}, eq<1>{}), list(eq<2>{}, eq<3>{}), list(eq<4>{}, eq<5>{})),\n                list(f(eq<0>{}, eq<2>{}, eq<4>{}), f(eq<1>{}, eq<3>{}, eq<5>{}))\n            ));\n\n            // zip 4\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f,\n                    list(eq<11>{}, eq<12>{}, eq<13>{}),\n                    list(eq<21>{}, eq<22>{}, eq<23>{}),\n                    list(eq<31>{}, eq<32>{}, eq<33>{}),\n                    list(eq<41>{}, eq<42>{}, eq<43>{})\n                ),\n                list(\n                    f(eq<11>{}, eq<21>{}, eq<31>{}, eq<41>{}),\n                    f(eq<12>{}, eq<22>{}, eq<32>{}, eq<42>{}),\n                    f(eq<13>{}, eq<23>{}, eq<33>{}, eq<43>{})\n                )\n            ));\n\n            // zip 5\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f,\n                    list(eq<11>{}, eq<12>{}, eq<13>{}, eq<14>{}),\n                    list(eq<21>{}, eq<22>{}, eq<23>{}, eq<24>{}),\n                    list(eq<31>{}, eq<32>{}, eq<33>{}, eq<34>{}),\n                    list(eq<41>{}, eq<42>{}, eq<43>{}, eq<44>{}),\n                    list(eq<51>{}, eq<52>{}, eq<53>{}, eq<54>{})\n                ),\n                list(\n                    f(eq<11>{}, eq<21>{}, eq<31>{}, eq<41>{}, eq<51>{}),\n                    f(eq<12>{}, eq<22>{}, eq<32>{}, eq<42>{}, eq<52>{}),\n                    f(eq<13>{}, eq<23>{}, eq<33>{}, eq<43>{}, eq<53>{}),\n                    f(eq<14>{}, eq<24>{}, eq<34>{}, eq<44>{}, eq<54>{})\n                )\n            ));\n            }\n\n            //////////////////////////////////////////////////////////////////\n            // zip.shortest.with\n            //////////////////////////////////////////////////////////////////\n            {\n            _injection<0> f{};\n            auto zip = hana::zip.shortest.with;\n\n            // zip 1\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{})),\n                list(f(eq<0>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}, eq<1>{})),\n                list(f(eq<0>{}), f(eq<1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}, eq<1>{}, eq<2>{})),\n                list(f(eq<0>{}), f(eq<1>{}), f(eq<2>{}))\n            ));\n\n            // zip 2\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(undefined{}), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list(undefined{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}), list(eq<-1>{})),\n                list(f(eq<1>{}, eq<-1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}, eq<2>{}), list(eq<-1>{})),\n                list(f(eq<1>{}, eq<-1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}), list(eq<-1>{}, eq<-2>{})),\n                list(f(eq<1>{}, eq<-1>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}, eq<2>{}), list(eq<-1>{}, eq<-2>{})),\n                list(f(eq<1>{}, eq<-1>{}), f(eq<2>{}, eq<-2>{}))\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}), list(eq<-1>{}, eq<-2>{}, eq<-3>{})),\n                list(f(eq<1>{}, eq<-1>{}), f(eq<2>{}, eq<-2>{}), f(eq<3>{}, eq<-3>{}))\n            ));\n\n            // zip 3\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list(), list()),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(undefined{}), list(), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list(undefined{}), list()),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list(), list(undefined{})),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(), list(undefined{}), list(undefined{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(undefined{}), list(), list(undefined{})),\n                list()\n            ));\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(undefined{}, list(undefined{}), list(undefined{}), list()),\n                list()\n            ));\n\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f, list(eq<0>{}), list(eq<1>{}), list(eq<2>{})),\n                list(f(eq<0>{}, eq<1>{}, eq<2>{}))\n            ));\n\n            // zip 4\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f,\n                    list(eq<11>{}, eq<12>{}, eq<13>{}, eq<14>{}),\n                    list(eq<21>{}, eq<22>{}, eq<23>{}),\n                    list(eq<31>{}, eq<32>{}, eq<33>{}, eq<34>{}),\n                    list(eq<41>{}, eq<42>{}, eq<43>{}, eq<44>{}, eq<45>{})\n                ),\n                list(\n                    f(eq<11>{}, eq<21>{}, eq<31>{}, eq<41>{}),\n                    f(eq<12>{}, eq<22>{}, eq<32>{}, eq<42>{}),\n                    f(eq<13>{}, eq<23>{}, eq<33>{}, eq<43>{})\n                )\n            ));\n\n            // zip 5\n            BOOST_HANA_CONSTANT_CHECK(equal(\n                zip(f,\n                    list(eq<11>{}, eq<12>{}, eq<13>{}, eq<14>{}),\n                    list(eq<21>{}, eq<22>{}, eq<23>{}, eq<24>{}, eq<25>{}),\n                    list(eq<31>{}, eq<32>{}, eq<33>{}, eq<34>{}),\n                    list(eq<41>{}, eq<42>{}, eq<43>{}, eq<44>{}, eq<45>{}, eq<46>{}),\n                    list(eq<51>{}, eq<52>{}, eq<53>{}, eq<54>{}, eq<55>{})\n                ),\n                list(\n                    f(eq<11>{}, eq<21>{}, eq<31>{}, eq<41>{}, eq<51>{}),\n                    f(eq<12>{}, eq<22>{}, eq<32>{}, eq<42>{}, eq<52>{}),\n                    f(eq<13>{}, eq<23>{}, eq<33>{}, eq<43>{}, eq<53>{}),\n                    f(eq<14>{}, eq<24>{}, eq<34>{}, eq<44>{}, eq<54>{})\n                )\n            ));\n            }\n        }\n    };\n}}} // end namespace boost::hana::test\n\n#endif // !BOOST_HANA_TEST_LAWS_SEQUENCE_HPP\n", "meta": {"hexsha": "b93a124e803409f74785033f0ea92f7e03e2e7e7", "size": 56567, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "test/laws/sequence.hpp", "max_stars_repo_name": "josephwinston/hana", "max_stars_repo_head_hexsha": "a8586ec1812e14e43dfd6867209412aa1d254e1a", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/laws/sequence.hpp", "max_issues_repo_name": "josephwinston/hana", "max_issues_repo_head_hexsha": "a8586ec1812e14e43dfd6867209412aa1d254e1a", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/laws/sequence.hpp", "max_forks_repo_name": "josephwinston/hana", "max_forks_repo_head_hexsha": "a8586ec1812e14e43dfd6867209412aa1d254e1a", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5361645654, "max_line_length": 110, "alphanum_fraction": 0.3504870331, "num_tokens": 13332, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4687906266262437, "lm_q2_score": 0.10970577096716555, "lm_q1q2_score": 0.05142903711621271}}
{"text": "// Software License for MTL\n// \n// Copyright (c) 2007 The Trustees of Indiana University.\n//               2008 Dresden University of Technology and the Trustees of Indiana University.\n//               2010 SimuNova UG (haftungsbeschr\u00e4nkt), www.simunova.com.\n// All rights reserved.\n// Authors: Peter Gottschling and Andrew Lumsdaine\n// \n// This file is part of the Matrix Template Library\n// \n// See also license.mtl.txt in the distribution.\n\n#ifndef MTL_PRINT_MATRIX_INCLUDE\n#define MTL_PRINT_MATRIX_INCLUDE\n\n#include <cstddef>\n#include <iostream>\n#include <sstream>\n#include <boost/numeric/mtl/mtl_fwd.hpp>\n#include <boost/numeric/mtl/concept/collection.hpp>\n#include <boost/numeric/mtl/utility/tag.hpp>\n#include <boost/numeric/mtl/utility/category.hpp>\n#include <boost/numeric/mtl/utility/range_generator.hpp>\n\nnamespace mtl { namespace mat {\n\ntemplate <typename Matrix>\nstd::ostream& print_matrix(Matrix const& matrix, std::ostream& out= std::cout, std::size_t width= 3, std::size_t precision= 2)\n{\n    // typedef typename Collection<Matrix>::size_type size_type;\n    // all indices will start from 0; otherwise wrong\n    for (std::size_t r= 0, nr= num_rows(matrix); r < nr; ++r) {\n\tout << '[';\n\tfor (std::size_t c= 0, nc= num_cols(matrix); c < nc; ++c) {\n\t    if (precision)\n\t\tout.precision(precision); \n\t    out.fill (' '); out.width (width); \n#ifdef MTL_PRINT_STRING_TMP // probably very slow but looks better for certain types\n\t    std::ostringstream st;\n\t    st << matrix(r, c) << (c + 1 < nc ? \" \" : \"]\\n\");\n\t    out << std::right << st.str();\n#else\n\t    out << matrix(r, c) << (c + 1 < nc ? \" \" : \"]\\n\");\n#endif\n\t}\n    }\n    return out;\n}\n\n}} // namespace mtl::matrix\n\n#endif // MTL_PRINT_MATRIX_INCLUDE\n", "meta": {"hexsha": "e043bf29ca79db9e00e4d84c76c6bee87eec54b7", "size": 1716, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "boost/numeric/mtl/operation/print_matrix.hpp", "max_stars_repo_name": "lit-uriy/mtl4-mirror", "max_stars_repo_head_hexsha": "37cf7c2847165d3537cbc3400cb5fde6f80e3d8b", "max_stars_repo_licenses": ["MTLL"], "max_stars_count": 24.0, "max_stars_repo_stars_event_min_datetime": "2019-03-26T15:25:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T10:00:45.000Z", "max_issues_repo_path": "boost/numeric/mtl/operation/print_matrix.hpp", "max_issues_repo_name": "lit-uriy/mtl4-mirror", "max_issues_repo_head_hexsha": "37cf7c2847165d3537cbc3400cb5fde6f80e3d8b", "max_issues_repo_licenses": ["MTLL"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2020-04-17T12:35:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-03T15:46:25.000Z", "max_forks_repo_path": "boost/numeric/mtl/operation/print_matrix.hpp", "max_forks_repo_name": "lit-uriy/mtl4-mirror", "max_forks_repo_head_hexsha": "37cf7c2847165d3537cbc3400cb5fde6f80e3d8b", "max_forks_repo_licenses": ["MTLL"], "max_forks_count": 10.0, "max_forks_repo_forks_event_min_datetime": "2019-12-01T13:40:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-14T08:39:54.000Z", "avg_line_length": 32.3773584906, "max_line_length": 126, "alphanum_fraction": 0.675990676, "num_tokens": 467, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4493926344647596, "lm_q2_score": 0.11436852316318395, "lm_q1q2_score": 0.051396371924147116}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Tests for the array kernel functions from the utility operations\n *\n */\n\n#define BOOST_TEST_MODULE ArrayKernel\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n\n#include <stdexcept>\n#include \"ArrayKernels.h\"\n\n// ============================================================\n// ==================== Kernel Tests ==========================\n// ============================================================\nusing namespace cupcfd::utility::kernels;\n\n// ==================== add ============================\n// Test 1: Test correction addition of two arrays\nBOOST_AUTO_TEST_CASE(add_test1)\n{\n\tint dest[5];\n\n\tint source1[5] = {1,2,3,4,5};\n\tint source2[5] = {1,2,18,4,7};\n\n\tint source1Cmp[5] = {1,2,3,4,5};\n\tint source2Cmp[5] = {1,2,18,4,7};\n\tint resultCmp[5] = {2, 4, 21, 8, 12};\n\n\tadd(source1, source2, dest, 5);\n\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 5, resultCmp, resultCmp + 5);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source1, source1 + 5, source1Cmp, source1Cmp + 5);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(source2, source2 + 5, source2Cmp, source2Cmp + 5);\n}\n\n// ==================== uniqueCount ==========================\n// Test 1: Test correct count of unique elements in arbitrary array\nBOOST_AUTO_TEST_CASE(uniqueCount_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count = uniqueCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 2: Test correct count of zero in array with no unique elements\nBOOST_AUTO_TEST_CASE(uniqueCount_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[14] = {1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\n\tint count = uniqueCount(source, 14);\n\n\tBOOST_CHECK_EQUAL(count, 0);\n}\n\n// Test 3: Test correct count of unique elements when all elements are unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[6] = {1, 2, 3, 4, 7, 325};\n\n\tint count = uniqueCount(source, 6);\n\n\tBOOST_CHECK_EQUAL(count, 6);\n}\n\n// Test 4: Test correct count when only first element is unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\n\tint count = uniqueCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 1);\n}\n\n// Test 5: Test correct count when only last element is unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325};\n\n\tint count = uniqueCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 1);\n}\n\n// Test 6: Test correct count when last two elements are unique\nBOOST_AUTO_TEST_CASE(uniqueCount_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[10] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 325};\n\n\tint count = uniqueCount(source, 10);\n\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// ================= uniqueArray ===========================\n\n// Test 1: Find the unique elements for an arbitrary array\nBOOST_AUTO_TEST_CASE(uniqueArray_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count = uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 3);\n\n\tint result[3];\n\tint result_cmp[3] = {2, 7, 325};\n\n\tuniqueArray(source, result, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, result_cmp, result_cmp + 3);\n}\n\n// Test 2: Check that the function runs to completion without error when there are\n// no unique elements\nBOOST_AUTO_TEST_CASE(uniqueArray_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[14] = {1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\tint count = uniqueCount(source, 14);\n\tBOOST_CHECK_EQUAL(count, 0);\n\n\tint result[0];\n\t// Theoretically, it should never copy. If it does, it will go out of bounds in memory.\n\tuniqueArray(source, result, 14);\n}\n\n// Test 3: Check that the result is correct when the entire source is unique elements\nBOOST_AUTO_TEST_CASE(uniqueArray_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[6] = {1, 2, 3, 4, 7, 325};\n\tint count = uniqueCount(source, 6);\n\tBOOST_CHECK_EQUAL(count, 6);\n\n\tint result[6];\n\tint result_cmp[6] = {1, 2, 3, 4, 7, 325};\n\tuniqueArray(source, result, 6);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 6, result_cmp, result_cmp + 6);\n}\n\n// Test 4: Check that the result is correct when only the first element is unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 3, 3, 4, 4, 7, 7, 325, 325};\n\tint count = uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 1);\n\n\tint result[1];\n\tint result_cmp[1] = {1};\n\tuniqueArray(source, result, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 1, result_cmp, result_cmp + 1);\n}\n\n// Test 5: Check that the result is correct when only the last element is unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 325};\n\tint count = uniqueCount(source, 11);\n\tBOOST_CHECK_EQUAL(count, 1);\n\n\tint result[1];\n\tint result_cmp[1] = {325};\n\tuniqueArray(source, result, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 1, result_cmp, result_cmp + 1);\n}\n\n// Test 6: Check that the result is correct when the last two elements are unique\nBOOST_AUTO_TEST_CASE(uniqueArray_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[10] = {1, 1, 2, 2, 3, 3, 4, 4, 7, 325};\n\tint count = uniqueCount(source, 10);\n\tBOOST_CHECK_EQUAL(count, 2);\n\n\tint result[2];\n\tint result_cmp[2] = {7, 325};\n\tuniqueArray(source, result, 10);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 2, result_cmp, result_cmp + 2);\n}\n\n\n// ==================== distinctCount ==========================\n\n// Test 1: Find the correct number of distinct elements\nBOOST_AUTO_TEST_CASE(distinctCount_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 6);\n}\n\n// Test 2: Find correct number of distinct elements with no unique elements\nBOOST_AUTO_TEST_CASE(distinctCount_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n// Test 3: Find correct number of distinct elements with all unique elements\nBOOST_AUTO_TEST_CASE(distinctCount_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 11);\n}\n\n// Test 4: Find correct number of distinct elements when only first is unique\nBOOST_AUTO_TEST_CASE(distinctCount_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// Test 5: Find correct number of distinct elements when only last is distinct\nBOOST_AUTO_TEST_CASE(distinctCount_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// Test 6: Find correct number of distinct elements when first two are unique\nBOOST_AUTO_TEST_CASE(distinctCount_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 7: Find correct number of distinct elements when last two are unique\nBOOST_AUTO_TEST_CASE(distinctCount_int_lastTwoDistinct)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3};\n\tint count = distinctCount(source, 11);\n\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// ==================== DistinctArray ==========================\n\n// Test 1: Find Array of Distinct Elements\nBOOST_AUTO_TEST_CASE(distinctArray_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint * dest = (int *) malloc(sizeof(int) * 6);\n\tint resultCmp[6] = {1,2,3,4,7,325};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 6, resultCmp, resultCmp + 6);\n}\n\n// Test 2: Find Array of Distinct Elements when no unique elements\nBOOST_AUTO_TEST_CASE(distinctArray_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4};\n\tint * dest = (int *) malloc(sizeof(int) * 4);\n\tint resultCmp[4] = {1,2,3,4};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 4, resultCmp, resultCmp + 4);\n\n}\n\n// Test 3: Find Array of Distinct Elements when all are unique\nBOOST_AUTO_TEST_CASE(distinctArray_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint * dest = (int *) malloc(sizeof(int) * 11);\n\tint resultCmp[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 11, resultCmp, resultCmp + 11);\n}\n\n// Test 4: Find array of distinct elements when only first is unique\nBOOST_AUTO_TEST_CASE(distinctArray_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint resultCmp[2] = {1, 2};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n}\n\n// Test 5: Find array of distinct elements when only last is unique\nBOOST_AUTO_TEST_CASE(distinctArray_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint resultCmp[2] = {1, 2};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n}\n\n// Test 6: Find array of distinct elements when only first two are unique\nBOOST_AUTO_TEST_CASE(distinctArray_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint resultCmp[6] = {1, 2, 3};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n}\n\n// Test 7: Find array of distinct elements when only last two are unique\nBOOST_AUTO_TEST_CASE(distinctArray_test7)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 7};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint resultCmp[3] = {1, 2, 7};\n\n\tdistinctArray(source, dest, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n}\n\n\n// ==================== DistinctWithCount ======================\n\n// Test 1: Find Array of Distinct Elements with correct number of instances of each element\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test1)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 2, 3, 3, 4, 4, 7, 325};\n\tint * dest = (int *) malloc(sizeof(int) * 6);\n\tint * count = (int *) malloc(sizeof(int) * 6);\n\n\tint resultCmp[6] = {1,2,3,4,7,325};\n\tint countCmp[6] = {4,1,2,2,1,1};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 6, resultCmp, resultCmp + 6);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 6, countCmp, countCmp + 6);\n}\n\n// Test 2: Find Array of Distinct Elements with correct number of instances of each element with no unique elements\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test2)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4};\n\tint * dest = (int *) malloc(sizeof(int) * 4);\n\tint * count = (int *) malloc(sizeof(int) * 4);\n\n\tint resultCmp[4] = {1,2,3,4};\n\tint countCmp[4] = {2, 3, 2, 4};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 4, resultCmp, resultCmp + 4);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 4, countCmp, countCmp + 4);\n}\n\n// Test 3: Find Array of Distinct Elements with correct number of instances of each element with all unique elements\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test3)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint * dest = (int *) malloc(sizeof(int) * 11);\n\tint * count = (int *) malloc(sizeof(int) * 11);\n\n\tint resultCmp[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15};\n\tint countCmp[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 11, resultCmp, resultCmp + 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 11, countCmp, countCmp + 11);\n}\n\n// Test 4: Find Array of Distinct Elements with correct number of instances of each element when only first is unique\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test4)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint * count = (int *) malloc(sizeof(int) * 2);\n\n\tint resultCmp[2] = {1, 2};\n\tint countCmp[2] = {1, 10};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 2, countCmp, countCmp + 2);\n}\n\n// Test 5: Find Array of Distinct Elements with correct number of instances of each element when only last is unique\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test5)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};\n\tint * dest = (int *) malloc(sizeof(int) * 2);\n\tint * count = (int *) malloc(sizeof(int) * 2);\n\n\tint resultCmp[2] = {1, 2};\n\tint countCmp[2] = {10, 1};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 2, resultCmp, resultCmp + 2);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 2, countCmp, countCmp + 2);\n}\n\n// Test 6: Find Array of Distinct Elements with correct number of instances of each element when only first two are unique\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test6)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint * count = (int *) malloc(sizeof(int) * 3);\n\n\tint resultCmp[6] = {1, 2, 3};\n\tint countCmp[3] = {1, 1, 9};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 3, countCmp, countCmp + 3);\n}\n\n// Test 7: Find Array of Distinct Elements with correct number of instances of each element when only last tow are unique\nBOOST_AUTO_TEST_CASE(distinctArrayWithCount_test7)\n{\n\t// The kernel expects sorted arrays only\n\tint source[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 7};\n\tint * dest = (int *) malloc(sizeof(int) * 3);\n\tint * count = (int *) malloc(sizeof(int) * 3);\n\n\tint resultCmp[3] = {1, 2, 7};\n\tint countCmp[3] = {9, 1, 1};\n\n\tdistinctArray(source, dest, count, 11);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(dest, dest + 3, resultCmp, resultCmp + 3);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(count, count + 3, countCmp, countCmp + 3);\n}\n\n//====================== Minus Count ===========================\n\n// Test 1: Get correct number of elements left in minus array when first array is larger\nBOOST_AUTO_TEST_CASE(minusCount_test1)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = minusCount(source1, 7, source2, 4);\n\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n// Test 2: Get correct number of elements left in minus array when second array is larger\nBOOST_AUTO_TEST_CASE(minusCount_test2)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\n\tint count = minusCount(source1, 7, source2, 8);\n\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n// Test 3: Get correct number of elements left in minus array when first array is all same element\nBOOST_AUTO_TEST_CASE(minusCount_test3)\n{\n\tint source1[7] = {1, 1, 1, 1, 1, 1, 1};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = minusCount(source1, 7, source2, 4);\n\n\tBOOST_CHECK_EQUAL(count, 7);\n}\n\n// Test 4: Get correct number of elements left in minus array when arrays are the same\nBOOST_AUTO_TEST_CASE(minusCount_test4)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = minusCount(source1, 4, source2, 4);\n\n\tBOOST_CHECK_EQUAL(count, 0);\n}\n\n//====================== Minus Array ===========================\n\n// Test 1: Get correct set minus array when first array is larger\nBOOST_AUTO_TEST_CASE(minusArray_test1)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\tint result[4];\n\tint resultCmp[4] = {1, 4, 10, 12};\n\tcupcfd::error::eCodes status;\n\n\tstatus = minusArray(source1, 7, source2, 4, result, 4);\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, resultCmp, resultCmp + 4);\n}\n\n// Test 2: Get correct set minus array when second array is larger\nBOOST_AUTO_TEST_CASE(minusArray_test2)\n{\n\tint source1[7] = {1, 2, 2, 4, 8, 10, 12};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\tint result[4];\n\tint resultCmp[4] = {1, 4, 10, 12};\n\tcupcfd::error::eCodes status;\n\n\tstatus = minusArray(source1, 7, source2, 8, result, 4);\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, resultCmp, resultCmp + 4);\n}\n\n// Test 3: Get correct set minus array when first array is all same element\nBOOST_AUTO_TEST_CASE(minusArray_test3)\n{\n\tint source1[7] = {1, 1, 1, 1, 1, 1, 1};\n\tint source2[4] = {2, 8, 21, 22};\n\tint result[7];\n\tint resultCmp[7] = {1, 1, 1, 1, 1, 1, 1};\n\tcupcfd::error::eCodes status;\n\n\tstatus = minusArray(source1, 7, source2, 4, result, 7);\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 7, resultCmp, resultCmp + 7);\n}\n\n// Test 4: Get correct set minus array when arrays have same contents\nBOOST_AUTO_TEST_CASE(minusArray_test4)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\tint result[0];\n\tint resultCmp[0];\n\tcupcfd::error::eCodes status;\n\n\tstatus = minusArray(source1, 4, source2, 4, result, 0);\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 0, resultCmp, resultCmp + 0);\n}\n\n\n//====================== Intersect Count ===========================\n\n// Test 1: Get correct set intersect count when first array is larger and\n// first + last elements to be discarded\nBOOST_AUTO_TEST_CASE(intersectCount_test1)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = intersectCount(source1, 6, source2, 4);\n\n\t// Duplicates should not count, so only 2 and 8 are in both.\n\tBOOST_CHECK_EQUAL(count, 2);\n}\n\n// Test 2: Get correct set intersect count when first array is larger and\n// first to be discarded\nBOOST_AUTO_TEST_CASE(intersectCount_test2)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = intersectCount(source1, 6, source2, 4);\n\n\t// Duplicates should not count, so only 2 and 8 are in both.\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 3: Get correct set intersect count when second array is larger\nBOOST_AUTO_TEST_CASE(intersectCount_test3)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 200};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\n\tint count = intersectCount(source1, 7, source2, 8);\n\n\t// Duplicates should not count, so only 2, 8 and 200 are in both.\n\tBOOST_CHECK_EQUAL(count, 3);\n}\n\n// Test 4: Get correct set intersect count when no elements are in both arrays\nBOOST_AUTO_TEST_CASE(intersectCount_test4)\n{\n\tint source1[1] = {1};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = intersectCount(source1, 1, source2, 4);\n\n\tBOOST_CHECK_EQUAL(count, 0);\n}\n\n// Test 5: Get correct set intersect count when all elements are in both arrays\nBOOST_AUTO_TEST_CASE(intersectCount_test5)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint count = intersectCount(source1, 4, source2, 4);\n\n\t// Arrays are same, so all elements are in intersect\n\tBOOST_CHECK_EQUAL(count, 4);\n}\n\n\n//====================== Intersect Array ===========================\n\n// Test 1: Get correct set intersect array when first array is larger and\n// first + last elements to be discarded\nBOOST_AUTO_TEST_CASE(intersectArray_test1)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 12};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint result[2];\n\tint nResult = 2;\n\tint cmp[2] = {2, 8};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 6, source2, 4, result, nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 2, cmp, cmp + 2);\n}\n\n// Test 2: Get correct set intersect array when first array is larger and\n// first to be discarded\nBOOST_AUTO_TEST_CASE(intersectArray_test2)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint result[3];\n\tint nResult = 3;\n\tint cmp[3] = {2, 8, 22};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 6, source2, 4, result, nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, cmp, cmp + 3);\n}\n\n// Test 3: Get correct set intersect array when second array is larger\nBOOST_AUTO_TEST_CASE(intersectArray_test3)\n{\n\tint source1[6] = {1, 2, 4, 8, 10, 200};\n\tint source2[8] = {2, 8, 21, 22, 100, 102, 200, 400};\n\n\tint result[3];\n\tint nResult = 3;\n\tint cmp[3] = {2, 8, 200};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 7, source2, 8, result, nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 3, cmp, cmp + 3);\n}\n\n// Test 4: Get correct set intersect array when no elements are in both arrays\nBOOST_AUTO_TEST_CASE(intersectArray_test4)\n{\n\tint source1[1] = {1};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint result[0];\n\tint nResult = 0;\n\tint cmp[0];\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 1, source2, 4, result, nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 0, cmp, cmp + 0);\n}\n\n// Test 5: Get correct set intersect array when all elements are in both arrays\nBOOST_AUTO_TEST_CASE(intersectArray_test5)\n{\n\tint source1[4] = {2, 8, 21, 22};\n\tint source2[4] = {2, 8, 21, 22};\n\n\tint result[4];\n\tint nResult = 4;\n\tint cmp[4] = {2, 8, 21, 22};\n\n\tcupcfd::error::eCodes status;\n\tstatus = intersectArray(source1, 4, source2, 4, result, nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL_COLLECTIONS(result, result + 4, cmp, cmp + 4);\n}\n\n// === randomUniform ===\n// ToDo: Is it possible to generate a suitable test for this?\n", "meta": {"hexsha": "35534a12e73329f9b2d8635c18f961cbff034ba0", "size": 22644, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/utility/implementation/component/ArrayKernelTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/utility/implementation/component/ArrayKernelTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/utility/implementation/component/ArrayKernelTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 30.8922237381, "max_line_length": 122, "alphanum_fraction": 0.6743508214, "num_tokens": 7493, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3812195803163617, "lm_q2_score": 0.13477591568531197, "lm_q1q2_score": 0.05137921801430798}}
{"text": "/*    Copyright (c) 2010-2015, Delft University of Technology\r\n *    All rights reserved.\r\n *\r\n *    Redistribution and use in source and binary forms, with or without modification, are\r\n *    permitted provided that the following conditions are met:\r\n *      - Redistributions of source code must retain the above copyright notice, this list of\r\n *        conditions and the following disclaimer.\r\n *      - Redistributions in binary form must reproduce the above copyright notice, this list of\r\n *        conditions and the following disclaimer in the documentation and/or other materials\r\n *        provided with the distribution.\r\n *      - Neither the name of the Delft University of Technology nor the names of its contributors\r\n *        may be used to endorse or promote products derived from this software without specific\r\n *        prior written permission.\r\n *\r\n *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS\r\n *    OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r\n *    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r\n *    COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r\n *    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\r\n *    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r\n *    AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r\n *    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r\n *    OF THE POSSIBILITY OF SUCH DAMAGE.\r\n *\r\n *    Changelog\r\n *      YYMMDD    Author            Comment\r\n *      120720    A. Ronse          First creation of the unit test.\r\n *      120724    K. Kumar          Addition of extensive comments and tests for\r\n *                                  updateAndGetAcceleration functions.\r\n *      120821    K. Kumar          Rewrote tests to make use of updated DerivedAccelerationModel\r\n *                                  class, AnotherDerivedAccelerationModel class, and new TestBody\r\n *                                  class.\r\n *      121123    S. Billemont      Changed boost::assign usage to push_back(), to ensure\r\n *                                  compatibility with MSVC.\r\n *\r\n *    References\r\n *\r\n *    Notes:\r\n *      Test tolerance was set at 5.0e-15 (or 5.0e-7 for floats) instead of epsilon due to\r\n *      rounding errors in Eigen types with entries over a number of orders of magnitude,\r\n *      presumably causing the observed larger than epsilon relative differences between\r\n *      expected and computed values.\r\n *\r\n */\r\n\r\n#define BOOST_TEST_MAIN\r\n\r\n#include <vector>\r\n\r\n#include <boost/assign/list_of.hpp>\r\n#include <boost/bind.hpp>\r\n#include <boost/make_shared.hpp>\r\n#include <boost/shared_ptr.hpp>\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/test/floating_point_comparison.hpp>\r\n\r\n#include <Eigen/Core>\r\n\r\n#include \"Tudat/Basics/testMacros.h\"\r\n\r\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/accelerationModel.h\"\r\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/testAccelerationModels.h\"\r\n#include \"Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/testBody.h\"\r\n#include \"Tudat/Mathematics/BasicMathematics/linearAlgebraTypes.h\"\r\n\r\nnamespace tudat\r\n{\r\nnamespace unit_tests\r\n{\r\n\r\nusing basic_astrodynamics::AccelerationModel;\r\nusing basic_astrodynamics::updateAndGetAcceleration;\r\nusing boost::assign::list_of;\r\n\r\nBOOST_AUTO_TEST_SUITE( test_accelerationModel )\r\n\r\n//! Test whether DerivedAccelerationModel (acceleration data type=Eigen::Vector3d) functions\r\n//! correctly.\r\nBOOST_AUTO_TEST_CASE( test_derived3dAccelerationModel )\r\n{\r\n    using basic_astrodynamics::AccelerationModel3dPointer;\r\n\r\n    // Shortcuts.\r\n    typedef TestBody< 3, double > TestBody3d;\r\n    typedef boost::shared_ptr< TestBody3d > TestBody3dPointer;\r\n    typedef DerivedAccelerationModel< > DerivedAccelerationModel3d;\r\n\r\n    // Create body with initial state and time.\r\n    TestBody3dPointer body = boost::make_shared< TestBody3d >(\r\n                ( basic_mathematics::Vector6d( ) << 1.1, 2.2, 3.3, -0.1, 0.2, 0.3 ).finished( ), 2.0 );\r\n\r\n    // Create acceleration model using DerivedAccelerationModel class, and pass pointers to\r\n    // functions in body.\r\n    AccelerationModel3dPointer accelerationModel3d\r\n            = boost::make_shared< DerivedAccelerationModel3d >(\r\n                boost::bind( &TestBody3d::getCurrentPosition, body ),\r\n                boost::bind( &TestBody3d::getCurrentTime, body ) );\r\n\r\n    // Declare container of computed accelerations.\r\n    std::vector< Eigen::Vector3d > computedAccelerations( 3 );\r\n\r\n    // Get acceleration vector before members are updated.\r\n    computedAccelerations.at( 0 ) = accelerationModel3d->getAcceleration( );\r\n\r\n    // Update time and state.\r\n    body->setCurrentTimeAndState(\r\n                -1.1, ( basic_mathematics::Vector6d( )\r\n                        << -0.45, 10.63, -9.81, 0.11, 0.22, 0.33 ).finished( ) );\r\n\r\n    // Update acceleration model members.\r\n    accelerationModel3d->updateMembers( );\r\n\r\n    // Get acceleration vector, now after members have been updated.\r\n    computedAccelerations.at( 1 ) = accelerationModel3d->getAcceleration( );\r\n\r\n    // Update time and state.\r\n    body->setCurrentTimeAndState(\r\n                4.6, ( basic_mathematics::Vector6d( )\r\n                       << -87.685, 101.44, -1.38, -0.12, 0.23, -0.34 ).finished( ) );\r\n\r\n    // Update and get acceleration with single function.\r\n    computedAccelerations.at( 2 ) = updateAndGetAcceleration( accelerationModel3d );\r\n\r\n    // Set expected accelerations.\r\n    std::vector< Eigen::Vector3d > expectedAccelerations;\r\n    expectedAccelerations.push_back( Eigen::Vector3d(   1.1,     2.2,   3.3  ) / (  2.0 *  2.0 ) );\r\n    expectedAccelerations.push_back( Eigen::Vector3d(  -0.45,   10.63, -9.81 ) / ( -1.1 * -1.1 ) );\r\n    expectedAccelerations.push_back( Eigen::Vector3d( -87.685, 101.44, -1.38 ) / (  4.6 *  4.6 ) );\r\n\r\n    // Check that the acceleration vectors before and after the update match expected values.\r\n    for ( unsigned int i = 0; i < computedAccelerations.size( ); i++ )\r\n    {\r\n        TUDAT_CHECK_MATRIX_BASE( computedAccelerations.at( i ), expectedAccelerations.at( i ) )\r\n                BOOST_CHECK_CLOSE_FRACTION( computedAccelerations.at( i ).coeff( row, col ),\r\n                                   expectedAccelerations.at( i ).coeff( row, col ), 5.0e-15 );\r\n    }\r\n}\r\n\r\n//! Test whether AnotherDerivedAccelerationModel (acceleration data type=Eigen::Vector2f) functions\r\n//! correctly.\r\nBOOST_AUTO_TEST_CASE( test_derived2fAccelerationModel )\r\n{\r\n    // NOTE: For this test, it is imperative that the float values are given with the \"f\"\r\n    // suffix, to ensure that their precision is indeed of float-type.\r\n\r\n    // Shortcuts.\r\n    typedef TestBody< 2, float > TestBody2f;\r\n    typedef boost::shared_ptr< TestBody2f > TestBody2fPointer;\r\n    typedef AccelerationModel< Eigen::Vector2f > AccelerationModel2f;\r\n    typedef boost::shared_ptr< AccelerationModel2f > AccelerationModel2fPointer;\r\n    typedef AnotherDerivedAccelerationModel< Eigen::Vector2f, Eigen::Vector2f,\r\n            Eigen::Vector2f, float > AnotherDerivedAccelerationModel2f;\r\n\r\n    // Create body with initial state and time.\r\n    TestBody2fPointer body = boost::make_shared< TestBody2f >(\r\n                ( Eigen::VectorXf( 4 ) << -0.3f, 4.5f, 0.1f, 0.2f ).finished( ), -2.3f );\r\n\r\n    // Create acceleration model using AnotherDerivedAccelerationModel class, and pass pointers to\r\n    // functions in body.\r\n    AccelerationModel2fPointer accelerationModel2f\r\n            = boost::make_shared< AnotherDerivedAccelerationModel2f >(\r\n                boost::bind( &TestBody2f::getCurrentPosition, body ),\r\n                boost::bind( &TestBody2f::getCurrentVelocity, body ),\r\n                boost::bind( &TestBody2f::getCurrentTime, body ) );\r\n\r\n    // Declare container of computed accelerations.\r\n    std::vector< Eigen::Vector2f > computedAccelerations( 3 );\r\n\r\n    // Get acceleration vector before members are updated.\r\n    computedAccelerations.at( 0 ) = accelerationModel2f->getAcceleration( );\r\n\r\n    // Update time and state.\r\n    body->setCurrentTimeAndState(\r\n                0.33f, ( Eigen::VectorXf( 4 ) << 1.34f, 2.65f, -0.23f, 0.1f ).finished( ) );\r\n\r\n    // Update acceleration model members.\r\n    accelerationModel2f->updateMembers( );\r\n\r\n    // Get acceleration vector, now after members have been updated.\r\n    computedAccelerations.at( 1 ) = accelerationModel2f->getAcceleration( );\r\n\r\n    // Update time and state.\r\n    body->setCurrentTimeAndState(\r\n                -10.3f, ( Eigen::VectorXf( 4 ) << -98.99f, 1.53f, 1.23f, -0.11f ).finished( ) );\r\n\r\n    // Update and get acceleration with single function.\r\n    computedAccelerations.at( 2 ) = updateAndGetAcceleration( accelerationModel2f );\r\n\r\n    // Set expected accelerations.\r\n    std::vector< Eigen::Vector2f > expectedAccelerations;\r\n    expectedAccelerations.push_back( 0.5 * Eigen::Vector2f( -0.3f, 4.5f )\r\n                                     / ( 3.2 * ( -2.3f + 3.4 ) * -2.3f )\r\n                                     + Eigen::Vector2f( 0.1f, 0.2f ) / -2.3f );\r\n    expectedAccelerations.push_back( 0.5 * Eigen::Vector2f( 1.34f, 2.65f )\r\n                                     / ( 3.2 * ( 0.33f + 3.4 ) * 0.33f )\r\n                                     + Eigen::Vector2f( -0.23f, 0.1f ) / 0.33f );\r\n    expectedAccelerations.push_back( 0.5 * Eigen::Vector2f( -98.99f, 1.53f )\r\n                                     / ( 3.2 * ( -10.3f + 3.4 ) * -10.3f )\r\n                                     + Eigen::Vector2f( 1.23f, -0.11f ) / -10.3f );\r\n\r\n    // Check that the acceleration vectors before and after the update match expected values.\r\n    for ( unsigned int i = 0; i < computedAccelerations.size( ); i++ )\r\n    {\r\n        TUDAT_CHECK_MATRIX_BASE( computedAccelerations.at( i ), expectedAccelerations.at( i ) )\r\n                BOOST_CHECK_CLOSE_FRACTION( computedAccelerations.at( i ).coeff( row, col ),\r\n                                   expectedAccelerations.at( i ).coeff( row, col ), 5.0e-7 );\r\n    }\r\n}\r\n\r\n//! Test whether DerivedAccelerationModel (acceleration data type=Eigen::Vector1i) functions\r\n//! correctly.\r\nBOOST_AUTO_TEST_CASE( test_derived1iAccelerationModel )\r\n{\r\n    // Shortcuts.\r\n    typedef TestBody< 1, int > TestBody1i;\r\n    typedef boost::shared_ptr< TestBody1i > TestBody1iPointer;\r\n    typedef AccelerationModel< int > AccelerationModel1i;\r\n    typedef boost::shared_ptr< AccelerationModel1i > AccelerationModel1iPointer;\r\n    typedef DerivedAccelerationModel< int, int, int > DerivedAccelerationModel1i;\r\n\r\n    // Create body with initial state and time.\r\n    TestBody1iPointer body = boost::make_shared< TestBody1i >( Eigen::Vector2i( 20, 1 ), 2 );\r\n\r\n    // Create acceleration model using DerivedAccelerationModel class, and pass pointers to\r\n    // functions in body.\r\n    AccelerationModel1iPointer accelerationModeli1\r\n            = boost::make_shared< DerivedAccelerationModel1i >(\r\n                boost::bind( ( &TestBody1i::getCurrentPosition ), body ),\r\n                boost::bind( ( &TestBody1i::getCurrentTime ), body ) );\r\n\r\n    // Declare container of computed accelerations.\r\n    std::vector< int > computedAccelerations( 3 );\r\n\r\n    // Get scalar acceleration before members are updated.\r\n    computedAccelerations.at( 0 ) = accelerationModeli1->getAcceleration( );\r\n\r\n    // Update time and state.\r\n    body->setCurrentTimeAndState( -3, Eigen::Vector2i( 90, 3 ) );\r\n\r\n    // Update acceleration model members.\r\n    accelerationModeli1->updateMembers( );\r\n\r\n    // Get scalar acceleration, now after members have been updated.\r\n    computedAccelerations.at( 1 ) = accelerationModeli1->getAcceleration( );\r\n\r\n    // Update time and state.\r\n    body->setCurrentTimeAndState( 4, Eigen::Vector2i( 16, -4 ) );\r\n\r\n    // Update and get scalar acceleration with single function.\r\n    computedAccelerations.at( 2 ) = updateAndGetAcceleration( accelerationModeli1 );\r\n\r\n    // Set expected accelerations.\r\n    const std::vector< int > expectedAccelerations\r\n            = list_of( 20 / ( 2 * 2 ) )( 90 / ( -3 * -3 ) )( 16 / ( 4 * 4 ) );\r\n\r\n    // Check that the acceleration vectors before and after the update match expected values.\r\n    for ( unsigned int i = 0; i < computedAccelerations.size( ); i++ )\r\n    {\r\n        BOOST_CHECK_EQUAL( computedAccelerations.at( i ), expectedAccelerations.at( i ) );\r\n    }\r\n}\r\n\r\nBOOST_AUTO_TEST_SUITE_END( )\r\n\r\n} // namespace unit_tests\r\n} // namespace tudat\r\n", "meta": {"hexsha": "8fee30c76191f8ff3ae9f54e03aed86228c852cf", "size": 12692, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestAccelerationModel.cpp", "max_stars_repo_name": "JPelamatti/ThesisTUDAT", "max_stars_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestAccelerationModel.cpp", "max_issues_repo_name": "JPelamatti/ThesisTUDAT", "max_issues_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestAccelerationModel.cpp", "max_forks_repo_name": "JPelamatti/ThesisTUDAT", "max_forks_repo_head_hexsha": "b94ce35fb7c8fa44ae83238e296a979dfa3adfe8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-05-30T03:42:22.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-30T03:42:22.000Z", "avg_line_length": 47.5355805243, "max_line_length": 104, "alphanum_fraction": 0.6581311062, "num_tokens": 3124, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.48828339529583464, "lm_q2_score": 0.10521054511997295, "lm_q1q2_score": 0.051372562192106}}
{"text": "//\n// Copyright (c) 2002--2010\n// Toon Knapen, Karl Meerbergen, Kresimir Fresl,\n// Thomas Klimpel and Rutger ter Borg\n//\n// Distributed under the Boost Software License, Version 1.0.\n// (See accompanying file LICENSE_1_0.txt or copy at\n// http://www.boost.org/LICENSE_1_0.txt)\n//\n// THIS FILE IS AUTOMATICALLY GENERATED\n// PLEASE DO NOT EDIT!\n//\n\n#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_COMPUTATIONAL_TPTRI_HPP\n#define BOOST_NUMERIC_BINDINGS_LAPACK_COMPUTATIONAL_TPTRI_HPP\n\n#include <boost/assert.hpp>\n#include <boost/numeric/bindings/begin.hpp>\n#include <boost/numeric/bindings/diag_tag.hpp>\n#include <boost/numeric/bindings/is_mutable.hpp>\n#include <boost/numeric/bindings/remove_imaginary.hpp>\n#include <boost/numeric/bindings/size.hpp>\n#include <boost/numeric/bindings/stride.hpp>\n#include <boost/numeric/bindings/uplo_tag.hpp>\n#include <boost/numeric/bindings/value_type.hpp>\n#include <boost/static_assert.hpp>\n#include <boost/type_traits/is_same.hpp>\n#include <boost/type_traits/remove_const.hpp>\n\n//\n// The LAPACK-backend for tptri is the netlib-compatible backend.\n//\n#include <boost/numeric/bindings/lapack/detail/lapack.h>\n#include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>\n\nnamespace boost {\nnamespace numeric {\nnamespace bindings {\nnamespace lapack {\n\n//\n// The detail namespace contains value-type-overloaded functions that\n// dispatch to the appropriate back-end LAPACK-routine.\n//\nnamespace detail {\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * float value-type.\n//\ntemplate< typename UpLo, typename Diag >\ninline std::ptrdiff_t tptri( const UpLo, const Diag, const fortran_int_t n,\n        float* ap ) {\n    fortran_int_t info(0);\n    LAPACK_STPTRI( &lapack_option< UpLo >::value, &lapack_option<\n            Diag >::value, &n, ap, &info );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * double value-type.\n//\ntemplate< typename UpLo, typename Diag >\ninline std::ptrdiff_t tptri( const UpLo, const Diag, const fortran_int_t n,\n        double* ap ) {\n    fortran_int_t info(0);\n    LAPACK_DTPTRI( &lapack_option< UpLo >::value, &lapack_option<\n            Diag >::value, &n, ap, &info );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * complex<float> value-type.\n//\ntemplate< typename UpLo, typename Diag >\ninline std::ptrdiff_t tptri( const UpLo, const Diag, const fortran_int_t n,\n        std::complex<float>* ap ) {\n    fortran_int_t info(0);\n    LAPACK_CTPTRI( &lapack_option< UpLo >::value, &lapack_option<\n            Diag >::value, &n, ap, &info );\n    return info;\n}\n\n//\n// Overloaded function for dispatching to\n// * netlib-compatible LAPACK backend (the default), and\n// * complex<double> value-type.\n//\ntemplate< typename UpLo, typename Diag >\ninline std::ptrdiff_t tptri( const UpLo, const Diag, const fortran_int_t n,\n        std::complex<double>* ap ) {\n    fortran_int_t info(0);\n    LAPACK_ZTPTRI( &lapack_option< UpLo >::value, &lapack_option<\n            Diag >::value, &n, ap, &info );\n    return info;\n}\n\n} // namespace detail\n\n//\n// Value-type based template class. Use this class if you need a type\n// for dispatching to tptri.\n//\ntemplate< typename Value >\nstruct tptri_impl {\n\n    typedef Value value_type;\n    typedef typename remove_imaginary< Value >::type real_type;\n\n    //\n    // Static member function, that\n    // * Deduces the required arguments for dispatching to LAPACK, and\n    // * Asserts that most arguments make sense.\n    //\n    template< typename MatrixAP >\n    static std::ptrdiff_t invoke( MatrixAP& ap ) {\n        namespace bindings = ::boost::numeric::bindings;\n        typedef typename result_of::uplo_tag< MatrixAP >::type uplo;\n        typedef typename result_of::diag_tag< MatrixAP >::type diag;\n        BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixAP >::value) );\n        BOOST_ASSERT( bindings::size_column(ap) >= 0 );\n        return detail::tptri( uplo(), diag(), bindings::size_column(ap),\n                bindings::begin_value(ap) );\n    }\n\n};\n\n\n//\n// Functions for direct use. These functions are overloaded for temporaries,\n// so that wrapped types can still be passed and used for write-access. In\n// addition, if applicable, they are overloaded for user-defined workspaces.\n// Calls to these functions are passed to the tptri_impl classes. In the \n// documentation, most overloads are collapsed to avoid a large number of\n// prototypes which are very similar.\n//\n\n//\n// Overloaded function for tptri. Its overload differs for\n//\ntemplate< typename MatrixAP >\ninline std::ptrdiff_t tptri( MatrixAP& ap ) {\n    return tptri_impl< typename bindings::value_type<\n            MatrixAP >::type >::invoke( ap );\n}\n\n} // namespace lapack\n} // namespace bindings\n} // namespace numeric\n} // namespace boost\n\n#endif\n", "meta": {"hexsha": "4fa7f2f1a94feb7637c45493d97fcaa7c4f4d127", "size": 4920, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/computational/tptri.hpp", "max_stars_repo_name": "ljktest/siconos", "max_stars_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 137.0, "max_stars_repo_stars_event_min_datetime": "2015-06-16T15:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T06:01:59.000Z", "max_issues_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/computational/tptri.hpp", "max_issues_repo_name": "ljktest/siconos", "max_issues_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 381.0, "max_issues_repo_issues_event_min_datetime": "2015-09-22T15:31:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T09:05:23.000Z", "max_forks_repo_path": "externals/numeric_bindings/boost/numeric/bindings/lapack/computational/tptri.hpp", "max_forks_repo_name": "ljktest/siconos", "max_forks_repo_head_hexsha": "85b60e62beca46e6bf06bfbd65670089e86607c7", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 30.0, "max_forks_repo_forks_event_min_datetime": "2015-08-06T22:57:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-02T20:30:20.000Z", "avg_line_length": 31.1392405063, "max_line_length": 76, "alphanum_fraction": 0.7101626016, "num_tokens": 1247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4339814648038986, "lm_q2_score": 0.11757214591334528, "lm_q1q2_score": 0.051024132103611286}}
{"text": "/*\n@copyright Louis Dionne 2015\nDistributed under the Boost Software License, Version 1.0.\n(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)\n */\n\n#include <boost/hana/assert.hpp>\n#include <boost/hana/ext/std/integral_constant.hpp>\n#include <boost/hana/tuple.hpp>\n#include <boost/hana/type.hpp>\n\n#include <cassert>\n#include <iostream>\n#include <string>\n#include <tuple>\n#include <type_traits>\n\n#include <boost/mpl/if.hpp>\n#include <boost/mpl/quote.hpp>\n#include <boost/mpl/transform.hpp>\n#include <boost/mpl/vector.hpp>\n#include <boost/mpl/equal.hpp>\nusing namespace boost::hana;\n\n\nint main() {\n\n{\n\n//! [type]\n// We \"lift\" the `int` type to a value, and the `std::add_pointer` metafunction\n// to a regular function. Then, we can call that metafunction with a regular\n// function call syntax.\nconstexpr auto t = type<int>;\nconstexpr auto add_pointer = metafunction<std::add_pointer>;\nstatic_assert(add_pointer(t) == type<int*>, \"\");\n//! [type]\n\n//! [type_as_nullary_metafunction]\nusing T = decltype(t)::type;\nstatic_assert(std::is_same<T, int>{}, \"\");\n//! [type_as_nullary_metafunction]\n\n}{\n\n//! [type_sequence]\nconstexpr auto types = make<Tuple>(type<int>, type<char const>, type<void>);\nstatic_assert(\n    transform(types, metafunction<std::add_pointer>) ==\n    make<Tuple>(type<int*>, type<char const*>, type<void*>)\n, \"\");\n//! [type_sequence]\n\n}{\n\n//! [tuple_t]\nconstexpr auto types = tuple_t<int, char const, void>;\nstatic_assert(types == make<Tuple>(type<int>, type<char const>, type<void>), \"\");\n\nstatic_assert(\n    transform(types, metafunction<std::add_pointer>) ==\n    tuple_t<int*, char const*, void*>\n, \"\");\n//! [tuple_t]\n\n}{\n\n//! [type_three_step_cumbersome]\nstatic_assert(std::is_same<\n    decltype(metafunction<std::add_pointer>(type<int>))::type,\n    int*\n>{}, \"\");\n//! [type_three_step_cumbersome]\n\n//! [type_three_step_alternative]\nstatic_assert(std::is_same<\n    std::add_pointer<int>::type,\n    int*\n>{}, \"\");\n//! [type_three_step_alternative]\n\n}{\n\n//! [apply_to_all]\nauto apply_to_all = [](auto sequences, auto f) {\n    return transform(sequences, [=](auto sequence) {\n        return transform(sequence, f);\n    });\n};\n\nconstexpr auto types = make<Tuple>(\n    tuple_t<int, char>,\n    tuple_t<void, std::string, double>\n);\n\nBOOST_HANA_CONSTANT_CHECK(\n    apply_to_all(types, metafunction<std::add_pointer>) ==\n    make<Tuple>(\n        tuple_t<int*, char*>,\n        tuple_t<void*, std::string*, double*>\n    )\n);\n//! [apply_to_all]\n\n}\n\n}\n\nnamespace mpl = boost::mpl;\n//! [apply_to_all_mpl]\ntemplate <typename Sequences, typename F>\nstruct apply_to_all\n    : mpl::transform<\n        Sequences,\n        mpl::transform<mpl::_1, F>\n    >\n{ };\n\nusing types = mpl::vector<\n    mpl::vector<int, char>,\n    mpl::vector<void, std::string, double>\n>;\n\nstatic_assert(mpl::equal<\n    apply_to_all<types, mpl::quote1<std::add_pointer>>::type,\n    mpl::vector<\n        mpl::vector<int*, char*>,\n        mpl::vector<void*, std::string*, double*>\n    >,\n\n    // mpl::equal was seemingly not designed for deep comparisons, so we\n    // need this tricky line for it to do what we want.\n    mpl::equal<mpl::_1, mpl::_2, mpl::quote2<std::is_same>>\n>{}, \"\");\n//! [apply_to_all_mpl]\n", "meta": {"hexsha": "0bfa1d1bb2290ba6f2f19087f014b71e60fcbb0a", "size": 3207, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "example/tutorial/type.cpp", "max_stars_repo_name": "josephwinston/hana", "max_stars_repo_head_hexsha": "a8586ec1812e14e43dfd6867209412aa1d254e1a", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "example/tutorial/type.cpp", "max_issues_repo_name": "josephwinston/hana", "max_issues_repo_head_hexsha": "a8586ec1812e14e43dfd6867209412aa1d254e1a", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "example/tutorial/type.cpp", "max_forks_repo_name": "josephwinston/hana", "max_forks_repo_head_hexsha": "a8586ec1812e14e43dfd6867209412aa1d254e1a", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5808823529, "max_line_length": 81, "alphanum_fraction": 0.6694730278, "num_tokens": 826, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4649015713733885, "lm_q2_score": 0.10970577096716554, "lm_q1q2_score": 0.05100238531136432}}
{"text": "/* -*- Mode:C++; c-file-style:\"gnu\"; indent-tabs-mode:nil; -*- */\n/*\n * Copyright (c) 2013-2018 Regents of the University of California.\n *\n * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).\n *\n * ndn-cxx library is free software: you can redistribute it and/or modify it under the\n * terms of the GNU Lesser General Public License as published by the Free Software\n * Foundation, either version 3 of the License, or (at your option) any later version.\n *\n * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY\n * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.\n *\n * You should have received copies of the GNU General Public License and GNU Lesser\n * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * See AUTHORS.md for complete list of ndn-cxx authors and contributors.\n */\n\n#include \"util/random.hpp\"\n#include \"security/detail/openssl.hpp\"\n\n#include \"boost-test.hpp\"\n\n#include <boost/mpl/vector.hpp>\n#include <cmath>\n\nnamespace ndn {\nnamespace tests {\n\nBOOST_AUTO_TEST_SUITE(Util)\nBOOST_AUTO_TEST_SUITE(TestRandom)\n\nclass PseudoRandomWord32\n{\npublic:\n  static uint32_t\n  generate()\n  {\n    return random::generateWord32();\n  }\n};\n\nclass PseudoRandomWord64\n{\npublic:\n  static uint64_t\n  generate()\n  {\n    return random::generateWord64();\n  }\n};\n\nclass SecureRandomWord32\n{\npublic:\n  static uint32_t\n  generate()\n  {\n    return random::generateSecureWord32();\n  }\n};\n\nclass SecureRandomWord64\n{\npublic:\n  static uint64_t\n  generate()\n  {\n    return random::generateSecureWord64();\n  }\n};\n\ntypedef boost::mpl::vector<PseudoRandomWord32,\n                           PseudoRandomWord64,\n                           SecureRandomWord32,\n                           SecureRandomWord64> RandomGenerators;\n\n\nstatic double\ngetDeviation(const std::vector<uint32_t>& counts, size_t size)\n{\n  // Kolmogorov-Smirnov Goodness-of-Fit Test\n  // http://www.itl.nist.gov/div898/handbook/eda/section3/eda35g.htm\n\n  std::vector<double> edf(counts.size(), 0.0);\n  double probability = 0.0;\n  for (size_t i = 0; i < counts.size(); i++) {\n    probability += 1.0 * counts[i] / size;\n    edf[i] = probability;\n  }\n\n  double t = 0.0;\n  for (size_t i = 0; i < counts.size(); i++) {\n    t = std::max(t, std::abs(edf[i] - (i * 1.0 / counts.size())));\n  }\n\n  return t;\n}\n\n\nBOOST_AUTO_TEST_CASE_TEMPLATE(GoodnessOfFit, RandomGenerator, RandomGenerators)\n{\n  const size_t MAX_BINS = 32;\n  const uint32_t MAX_ITERATIONS = 35;\n\n  std::vector<uint32_t> counts(MAX_BINS, 0);\n\n  for (uint32_t i = 0; i < MAX_ITERATIONS; i++) {\n    counts[RandomGenerator::generate() % MAX_BINS]++;\n  }\n\n  // Check if it is uniform distribution with confidence 0.95\n  // http://dlc.erieri.com/onlinetextbook/index.cfm?fuseaction=textbook.appendix&FileName=Table7\n  BOOST_WARN_LE(getDeviation(counts, MAX_ITERATIONS), 0.230);\n}\n\nBOOST_AUTO_TEST_CASE(GenerateRandomBytes)\n{\n  // Kolmogorov-Smirnov Goodness-of-Fit Test\n  // http://www.itl.nist.gov/div898/handbook/eda/section3/eda35g.htm\n\n  uint8_t buf[1024] = {0};\n  random::generateSecureBytes(buf, sizeof(buf));\n\n  std::vector<uint32_t> counts(256, 0);\n\n  for (size_t i = 0; i < sizeof(buf); i++) {\n    counts[buf[i]]++;\n  }\n\n  // Check if it is uniform distribution with confidence 0.95\n  // http://dlc.erieri.com/onlinetextbook/index.cfm?fuseaction=textbook.appendix&FileName=Table7\n  BOOST_WARN_LE(getDeviation(counts, sizeof(buf)), 0.230);\n}\n\n// This fixture uses OpenSSL routines to set a dummy random generator that always fails\nclass FailRandMethodFixture\n{\npublic:\n  FailRandMethodFixture()\n    : m_dummyRandMethod{&FailRandMethodFixture::seed,\n                        &FailRandMethodFixture::bytes,\n                        &FailRandMethodFixture::cleanup,\n                        &FailRandMethodFixture::add,\n                        &FailRandMethodFixture::pseudorand,\n                        &FailRandMethodFixture::status}\n  {\n    m_origRandMethod = RAND_get_rand_method();\n    RAND_set_rand_method(&m_dummyRandMethod);\n  }\n\n  ~FailRandMethodFixture()\n  {\n    RAND_set_rand_method(m_origRandMethod);\n  }\n\nprivate: // RAND_METHOD callbacks\n#if OPENSSL_VERSION_NUMBER < 0x1010000fL\n  static void\n  seed(const void* buf, int num)\n  {\n  }\n#else\n  static int\n  seed(const void* buf, int num)\n  {\n    return 0;\n  }\n#endif // OPENSSL_VERSION_NUMBER < 0x1010000fL\n\n  static int\n  bytes(unsigned char* buf, int num)\n  {\n    return 0;\n  }\n\n  static void\n  cleanup()\n  {\n  }\n\n#if OPENSSL_VERSION_NUMBER < 0x1010000fL\n  static void\n  add(const void* buf, int num, double entropy)\n  {\n  }\n#else\n  static int\n  add(const void* buf, int num, double entropy)\n  {\n    return 0;\n  }\n#endif // OPENSSL_VERSION_NUMBER < 0x1010000fL\n\n  static int\n  pseudorand(unsigned char* buf, int num)\n  {\n    return 0;\n  }\n\n  static int\n  status()\n  {\n    return 0;\n  }\n\nprivate:\n  const RAND_METHOD* m_origRandMethod;\n  RAND_METHOD m_dummyRandMethod;\n};\n\nBOOST_FIXTURE_TEST_CASE(Error, FailRandMethodFixture)\n{\n  uint8_t buf[1024] = {0};\n  BOOST_CHECK_THROW(random::generateSecureBytes(buf, sizeof(buf)), std::runtime_error);\n}\n\nBOOST_AUTO_TEST_SUITE_END() // TestRandom\nBOOST_AUTO_TEST_SUITE_END() // Util\n\n} // namespace tests\n} // namespace ndn\n", "meta": {"hexsha": "e830f7baa9a013b6c31c5eca8fb6cd02f0332030", "size": 5379, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/unit/util/random.t.cpp", "max_stars_repo_name": "mkrdnz02/ndnCXXMain", "max_stars_repo_head_hexsha": "cf8a3684c21910164c80173e676f3c42271ade69", "max_stars_repo_licenses": ["OpenSSL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/unit/util/random.t.cpp", "max_issues_repo_name": "mkrdnz02/ndnCXXMain", "max_issues_repo_head_hexsha": "cf8a3684c21910164c80173e676f3c42271ade69", "max_issues_repo_licenses": ["OpenSSL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/unit/util/random.t.cpp", "max_forks_repo_name": "mkrdnz02/ndnCXXMain", "max_forks_repo_head_hexsha": "cf8a3684c21910164c80173e676f3c42271ade69", "max_forks_repo_licenses": ["OpenSSL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.8008849558, "max_line_length": 96, "alphanum_fraction": 0.6873024726, "num_tokens": 1468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44552953503957277, "lm_q2_score": 0.11436852165386974, "lm_q1q2_score": 0.050954554275611894}}
{"text": "// Boost.Geometry\r\n// QuickBook Example\r\n\r\n// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.\r\n// Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.\r\n\r\n// Use, modification and distribution is subject to the Boost Software License,\r\n// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n//[multi_linestring\r\n//` Declaration and use of the Boost.Geometry model::multi_linestring, modelling the MultiLinestring Concept\r\n\r\n#include <iostream>\r\n#include <boost/geometry.hpp>\r\n#include <boost/geometry/geometries/geometries.hpp>\r\n\r\nnamespace bg = boost::geometry;\r\n\r\nint main()\r\n{\r\n    typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;\r\n    typedef bg::model::linestring<point_t> linestring_t;\r\n    typedef bg::model::multi_linestring<linestring_t> mlinestring_t;\r\n\r\n    mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/\r\n\r\n#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \\\r\n && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)\r\n\r\n    mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}},\r\n                       {{1.0, 0.0}, {2.0, 0.0}}}; /*< Construct a multi_linestring containing two linestrings, using C++11 unified initialization syntax. >*/\r\n\r\n#endif\r\n\r\n    mls1.resize(2); /*< Resize a multi_linestring, store two linestrings. >*/\r\n\r\n    bg::append(mls1[0], point_t(0.0, 0.0)); /*< Append point to the first linestring. >*/\r\n    bg::append(mls1[0], point_t(0.0, 1.0));\r\n    bg::append(mls1[0], point_t(2.0, 1.0));\r\n\r\n    bg::append(mls1[1], point_t(1.0, 0.0)); /*< Append point to the second linestring. >*/\r\n    bg::append(mls1[1], point_t(2.0, 0.0));\r\n\r\n    double l = bg::length(mls1);\r\n\r\n    std::cout << l << std::endl;\r\n\r\n    return 0;\r\n}\r\n\r\n//]\r\n\r\n\r\n//[multi_linestring_output\r\n/*`\r\nOutput:\r\n[pre\r\n4\r\n]\r\n*/\r\n//]\r\n", "meta": {"hexsha": "a1279b7adc05799cabed6655c10842052a7f469c", "size": 1840, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/doc/src/examples/geometries/multi_linestring.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/doc/src/examples/geometries/multi_linestring.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/doc/src/examples/geometries/multi_linestring.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 29.2063492063, "max_line_length": 158, "alphanum_fraction": 0.6565217391, "num_tokens": 561, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4765796510636759, "lm_q2_score": 0.10669060317692272, "lm_q1q2_score": 0.050846570433830944}}
{"text": "// Boost.Geometry (aka GGL, Generic Geometry Library)\r\n// Unit Test\r\n\r\n// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.\r\n// Use, modification and distribution is subject to the Boost Software License,\r\n// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\r\n// http://www.boost.org/LICENSE_1_0.txt)\r\n\r\n#ifndef BOOST_GEOMETRY_TEST_SIMPLIFY_HPP\r\n#define BOOST_GEOMETRY_TEST_SIMPLIFY_HPP\r\n\r\n// Test-functionality, shared between single and multi tests\r\n\r\n#include <iomanip>\r\n#include <sstream>\r\n#include <geometry_test_common.hpp>\r\n#include <boost/geometry/algorithms/correct_closure.hpp>\r\n#include <boost/geometry/algorithms/equals.hpp>\r\n#include <boost/geometry/algorithms/simplify.hpp>\r\n#include <boost/geometry/algorithms/distance.hpp>\r\n#include <boost/geometry/strategies/strategies.hpp>\r\n#include <boost/geometry/io/wkt/wkt.hpp>\r\n#include <boost/variant/variant.hpp>\r\n\r\n\r\ntemplate\r\n<\r\n    typename GeometryForTag,\r\n    typename Tag = typename bg::tag<GeometryForTag>::type\r\n>\r\nstruct test_equality\r\n{\r\n    template <typename Geometry, typename Expected>\r\n    static void apply(Geometry const& geometry, Expected const& expected)\r\n    {\r\n        // Verify both spatially equal AND number of points, because several\r\n        // of the tests only check explicitly on collinear points being\r\n        // simplified away\r\n        bool const result\r\n                = bg::equals(geometry, expected)\r\n                && bg::num_points(geometry) == bg::num_points(expected);\r\n\r\n        BOOST_CHECK_MESSAGE(result,\r\n                            \" result: \" << bg::wkt(geometry) << \" \" << bg::area(geometry)\r\n                            << \" expected: \" << bg::wkt(expected) << \" \" << bg::area(expected));\r\n\r\n    }\r\n};\r\n\r\n// Linestring does NOT yet have \"geometry::equals\" implemented\r\n// Until then, WKT's are compared (which is acceptable for linestrings, but not\r\n// for polygons, because simplify might rotate them)\r\ntemplate <typename GeometryForTag>\r\nstruct test_equality<GeometryForTag, bg::linestring_tag>\r\n{\r\n    template <typename Geometry, typename Expected>\r\n    static void apply(Geometry const& geometry, Expected const& expected)\r\n    {\r\n        std::ostringstream out1, out2;\r\n        out1 << bg::wkt(geometry);\r\n        out2 << bg::wkt(expected);\r\n        BOOST_CHECK_EQUAL(out1.str(), out2.str());\r\n    }\r\n};\r\n\r\n\r\ntemplate <typename Tag>\r\nstruct test_inserter\r\n{\r\n    template <typename Geometry, typename Expected>\r\n    static void apply(Geometry& , Expected const& , double )\r\n    {}\r\n};\r\n\r\ntemplate <>\r\nstruct test_inserter<bg::linestring_tag>\r\n{\r\n    template <typename Geometry, typename Expected, typename DistanceMeasure>\r\n    static void apply(Geometry& geometry,\r\n            Expected const& expected,\r\n            DistanceMeasure const& distance)\r\n    {\r\n        {\r\n            Geometry simplified;\r\n            bg::detail::simplify::simplify_insert(geometry,\r\n                std::back_inserter(simplified), distance);\r\n\r\n            test_equality<Geometry>::apply(simplified, expected);\r\n        }\r\n\r\n#ifdef TEST_PULL89\r\n        {\r\n            typedef typename bg::point_type<Geometry>::type point_type;\r\n            typedef typename bg::strategy::distance::detail::projected_point_ax<>::template result_type<point_type, point_type>::type distance_type;\r\n            typedef bg::strategy::distance::detail::projected_point_ax_less<distance_type> less_comparator;\r\n\r\n            distance_type max_distance(distance);\r\n            less_comparator less(max_distance);\r\n\r\n            bg::strategy::simplify::detail::douglas_peucker\r\n                <\r\n                    point_type,\r\n                    bg::strategy::distance::detail::projected_point_ax<>,\r\n                    less_comparator\r\n                > strategy(less);\r\n\r\n            Geometry simplified;\r\n            bg::detail::simplify::simplify_insert(geometry,\r\n                std::back_inserter(simplified), max_distance, strategy);\r\n\r\n            test_equality<Geometry>::apply(simplified, expected);\r\n        }\r\n#endif\r\n    }\r\n};\r\n\r\ntemplate <typename Geometry, typename Expected, typename DistanceMeasure>\r\nvoid check_geometry(Geometry const& geometry,\r\n                    Expected const& expected,\r\n                    DistanceMeasure const& distance)\r\n{\r\n    Geometry simplified;\r\n    bg::simplify(geometry, simplified, distance);\r\n    test_equality<Expected>::apply(simplified, expected);\r\n}\r\n\r\ntemplate <typename Geometry, typename Expected, typename Strategy, typename DistanceMeasure>\r\nvoid check_geometry(Geometry const& geometry,\r\n                    Expected const& expected,\r\n                    DistanceMeasure const& distance,\r\n                    Strategy const& strategy)\r\n{\r\n    Geometry simplified;\r\n    bg::simplify(geometry, simplified, distance, strategy);\r\n    test_equality<Expected>::apply(simplified, expected);\r\n}\r\n\r\ntemplate <typename Geometry, typename DistanceMeasure>\r\nvoid check_geometry_with_area(Geometry const& geometry,\r\n                    double expected_area,\r\n                    DistanceMeasure const& distance)\r\n{\r\n    Geometry simplified;\r\n    bg::simplify(geometry, simplified, distance);\r\n    BOOST_CHECK_CLOSE(bg::area(simplified), expected_area, 0.01);\r\n}\r\n\r\n\r\ntemplate <typename Geometry, typename DistanceMeasure>\r\nvoid test_geometry(std::string const& wkt,\r\n        std::string const& expected_wkt,\r\n        DistanceMeasure distance)\r\n{\r\n    typedef typename bg::point_type<Geometry>::type point_type;\r\n\r\n    Geometry geometry, expected;\r\n\r\n    bg::read_wkt(wkt, geometry);\r\n    bg::read_wkt(expected_wkt, expected);\r\n\r\n    boost::variant<Geometry> v(geometry);\r\n\r\n    // Define default strategy for testing\r\n    typedef bg::strategy::simplify::douglas_peucker\r\n        <\r\n            typename bg::point_type<Geometry>::type,\r\n            bg::strategy::distance::projected_point<double>\r\n        > dp;\r\n\r\n    check_geometry(geometry, expected, distance);\r\n    check_geometry(v, expected, distance);\r\n\r\n\r\n    BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy<dp, point_type>) );\r\n\r\n    check_geometry(geometry, expected, distance, dp());\r\n    check_geometry(v, expected, distance, dp());\r\n\r\n    // Check inserter (if applicable)\r\n    test_inserter\r\n        <\r\n            typename bg::tag<Geometry>::type\r\n        >::apply(geometry, expected, distance);\r\n\r\n#ifdef TEST_PULL89\r\n    // Check using non-default less comparator in douglass_peucker\r\n    typedef typename bg::strategy::distance::detail::projected_point_ax<>::template result_type<point_type, point_type>::type distance_type;\r\n    typedef bg::strategy::distance::detail::projected_point_ax_less<distance_type> less_comparator;\r\n\r\n    distance_type const max_distance(distance);\r\n    less_comparator const less(max_distance);\r\n\r\n    typedef bg::strategy::simplify::detail::douglas_peucker\r\n        <\r\n            point_type,\r\n            bg::strategy::distance::detail::projected_point_ax<>,\r\n            less_comparator\r\n        > douglass_peucker_with_less;\r\n\r\n    BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy<douglass_peucker_with_less, point_type>) );\r\n\r\n    check_geometry(geometry, expected, distance, douglass_peucker_with_less(less));\r\n    check_geometry(v, expected, distance, douglass_peucker_with_less(less));\r\n#endif\r\n}\r\n\r\ntemplate <typename Geometry, typename Strategy, typename DistanceMeasure>\r\nvoid test_geometry(std::string const& wkt,\r\n        std::string const& expected_wkt,\r\n        DistanceMeasure const& distance,\r\n        Strategy const& strategy)\r\n{\r\n    Geometry geometry, expected;\r\n\r\n    bg::read_wkt(wkt, geometry);\r\n    bg::read_wkt(expected_wkt, expected);\r\n    bg::correct_closure(geometry);\r\n    bg::correct_closure(expected);\r\n\r\n    boost::variant<Geometry> v(geometry);\r\n\r\n    BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy<Strategy,\r\n                           typename bg::point_type<Geometry>::type>) );\r\n\r\n    check_geometry(geometry, expected, distance, strategy);\r\n    check_geometry(v, expected, distance, strategy);\r\n}\r\n\r\ntemplate <typename Geometry, typename DistanceMeasure>\r\nvoid test_geometry(std::string const& wkt,\r\n        double expected_area,\r\n        DistanceMeasure const& distance)\r\n{\r\n    Geometry geometry;\r\n    bg::read_wkt(wkt, geometry);\r\n    bg::correct_closure(geometry);\r\n\r\n    check_geometry_with_area(geometry, expected_area, distance);\r\n}\r\n\r\n#endif\r\n", "meta": {"hexsha": "88cfe973b276d2653e2d8431afbd1f216300b541", "size": 8364, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/test/algorithms/test_simplify.hpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/test/algorithms/test_simplify.hpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-03-04T11:21:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-24T01:36:31.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/geometry/test/algorithms/test_simplify.hpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 34.5619834711, "max_line_length": 149, "alphanum_fraction": 0.6667862267, "num_tokens": 1732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.49609382947091946, "lm_q2_score": 0.10230471541940117, "lm_q1q2_score": 0.050752738045343346}}
{"text": "// Exercise 5.1.3 - Variant\r\n//\r\n// by Scott Sidoli\r\n//\r\n// 5-29-19\r\n//\r\n// Main.cpp\r\n//\r\n// In this exercise, we experiment with boost::variant. This is similar to tuple, but can only store one value.\r\n// We create a function that asks the user for a kind of shape to create and then returns that shape. Instead of\r\n// returning a Shape*, we return a boost::variant. We create a typedef 'ShapeType' that can contain a Point, Line,\r\n// or Circle. In the main function we call the function and print the result. Next, we try to assign the variant \r\n// to a Line variable by using the global boost::get<T>() function. We expect an exception to get thrown. Finally,\r\n// we experiment with 'visitors'. We create a variant visitor that moves shapes, apply it, and print the shape\r\n// afterwords to see if the shape's coordinates actually changed.\r\n\r\n#include <boost\\variant.hpp>\r\n#include <iostream>\r\n#include \"Line.hpp\"\r\n#include \"Circle.hpp\"\r\n#include \"Visitor.hpp\"\r\n#include \"Point.hpp\"\r\n#include <string>\r\n\r\nusing namespace std;\r\nusing namespace ssidoli::CAD;\r\n\r\ntypedef boost::variant<Point, Line, Circle> ShapeType;\r\n\r\nShapeType Create_Shape()\r\n{\r\n\tShapeType shape;\r\n\r\n\tcout << \"Please choose a shape: \" << endl << \"a) Point\" << endl << \"b) Line\" << endl << \"c) Circle\" << endl;\r\n\tchar choice;\r\n\tcin >> choice;\r\n\r\n\tswitch (choice)\r\n\t{\r\n\tcase 'a':\r\n\t\tshape = Point();\r\n\t\tbreak;\r\n\r\n\tcase 'b':\r\n\t\tshape = Line();\r\n\t\tbreak;\r\n\r\n\tcase 'c':\r\n\t\tshape = Circle();\r\n\t\tbreak;\r\n\r\n\tdefault:\r\n\t\tbreak;\r\n\t}\r\n\r\n\treturn shape;\r\n}\r\n\r\nint main()\r\n{\r\n\tusing boost::variant;\r\n\r\n\t// Creating a shape\r\n\tShapeType user_Shape = Create_Shape();\r\n\tcout << \"before visiting: \" << user_Shape << endl;\r\n\r\n\t// Trying to catch an exception\r\n\ttry\r\n\t{\r\n\t\tLine l = boost::get<Line>(user_Shape);\r\n\t}\r\n\r\n\tcatch (boost::bad_get& ex)\r\n\t{\r\n\t\tcout << \"Error: \" << ex.what() << endl;\r\n\t}\r\n\r\n\t// Using Visitor\r\n\tVisitor visitor(5.0, 7.0);\r\n\tboost::apply_visitor(visitor, user_Shape);\r\n\r\n\tcout << \"After visiting: \" << user_Shape << endl;\r\n\treturn 0;\r\n}\r\n\r\n\r\n", "meta": {"hexsha": "9884b386fd5de8efe2d02dcf450e7fc1c19bd4bb", "size": 2016, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Scott_Sidoli Level 8 HW Submission/Section 5.1/Exercise513/Exercise513/Main.cpp", "max_stars_repo_name": "scottsidoli/C-for-Financial-Engineering---Baruch-Pre-MFE-Certificate", "max_stars_repo_head_hexsha": "79c2fb297a85c914d5f0b8671bb17636801e3ce7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2021-11-05T08:14:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-05T08:14:37.000Z", "max_issues_repo_path": "Scott_Sidoli Level 8 HW Submission/Section 5.1/Exercise513/Exercise513/Main.cpp", "max_issues_repo_name": "scottsidoli/C-for-Financial-Engineering---Baruch-Pre-MFE-Certificate", "max_issues_repo_head_hexsha": "79c2fb297a85c914d5f0b8671bb17636801e3ce7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Scott_Sidoli Level 8 HW Submission/Section 5.1/Exercise513/Exercise513/Main.cpp", "max_forks_repo_name": "scottsidoli/C-for-Financial-Engineering---Baruch-Pre-MFE-Certificate", "max_forks_repo_head_hexsha": "79c2fb297a85c914d5f0b8671bb17636801e3ce7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1724137931, "max_line_length": 115, "alphanum_fraction": 0.6473214286, "num_tokens": 514, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.41869690935568665, "lm_q2_score": 0.12085322774082716, "lm_q1q2_score": 0.050600872940743266}}
{"text": "//C++ implementation code of finding the product of large numbers using Boost Lib.\n//The Boost.Multiprecision library can be used for computations requiring precision exceeding that of standard built-in types such as float, double and long double.\n//For extended-precision calculations, Boost.Multiprecision supplies a template data type called cpp_dec_float.\n\n#include <boost/multiprecision/cpp_int.hpp> \nusing namespace boost::multiprecision; //here we are using boost as namespace that includes boost libarary\nusing namespace std; \n \n//the below line is the function where the product of two numbers will take place. \nint128_t boost_product(long long A, long long B) \n{ \n    int128_t ans = (int128_t) A * B; \n    return ans; \n} \n  \n//in main function we tooked two long data type numbers and then called our boost_product() function.\nint main() \n{ \n    long long first = 98745636214564698; \n    long long second=7459874565236544789; \n    cout << \"Product of \"<< first << \" * \"\n         << second << \" = \\n\"\n         << boost_product(first,second) ; \n    return 0; \n} \n", "meta": {"hexsha": "f9319a76ee31d29597b3e6a24d7332b52a20b7da", "size": 1071, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "C++boost/LarNumBoost.cpp", "max_stars_repo_name": "soumilk/Inheritance-", "max_stars_repo_head_hexsha": "8aa19aef0f4d739db71124af1616ec8f6ddd8375", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 12.0, "max_stars_repo_stars_event_min_datetime": "2019-07-04T19:35:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-28T15:10:19.000Z", "max_issues_repo_path": "C++boost/LarNumBoost.cpp", "max_issues_repo_name": "soumilk/Inheritance-", "max_issues_repo_head_hexsha": "8aa19aef0f4d739db71124af1616ec8f6ddd8375", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": 13.0, "max_issues_repo_issues_event_min_datetime": "2019-07-16T17:15:27.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-25T09:07:12.000Z", "max_forks_repo_path": "C++boost/LarNumBoost.cpp", "max_forks_repo_name": "soumilk/Inheritance-", "max_forks_repo_head_hexsha": "8aa19aef0f4d739db71124af1616ec8f6ddd8375", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": 16.0, "max_forks_repo_forks_event_min_datetime": "2019-08-16T00:52:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-29T15:03:32.000Z", "avg_line_length": 41.1923076923, "max_line_length": 164, "alphanum_fraction": 0.7264239029, "num_tokens": 256, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.47268347662043286, "lm_q2_score": 0.10669058471438035, "lm_q1q2_score": 0.05043087650546012}}
{"text": "/**\n * MIT License\n *\n * Copyright (c) 2020 Thibaut Goetghebuer-Planchon <tessil@gmx.com>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n#define BOOST_TEST_DYN_LINK\n\n#include <boost/test/unit_test.hpp>\n\n#include \"utils.h\"\n#include \"tsl/uint_n.h\"\n\ntemplate <size_t BITS_COUNT>\nusing uint_n = tsl::uint_n<BITS_COUNT, uint8_t>;\n\nBOOST_AUTO_TEST_SUITE(test_bitset)\n\nnamespace {\n\ntemplate <size_t N>\nstd::string to_string(uint_n<N> const& x) {\n    std::ostringstream oss;\n    oss << x;\n    return oss.str();\n}\n\n} // namespace\n\nBOOST_AUTO_TEST_CASE(test_constructor_from_int) {\n    uint_n<2> x(1);\n    BOOST_CHECK_EQUAL(to_string(x), \"01\");\n}\n\nBOOST_AUTO_TEST_CASE(test_constructor_from_multiple_int) {\n    uint_n<9> x(1_b, 101_b);\n    BOOST_CHECK_EQUAL(to_string(x), \"1'00000101\");\n}\n\nBOOST_AUTO_TEST_CASE(test_shift_left_operator) {\n    {\n        uint_n<1> x(1);\n        x <<= 1;\n        BOOST_CHECK_EQUAL(to_string(x), \"0\");\n    }\n\n    {\n        uint_n<2> x(01_b);\n        x <<= 1;\n        BOOST_CHECK_EQUAL(to_string(x), \"10\");\n    }\n\n    {\n        uint_n<10> x(00000000_b, 10101001_b);\n        x <<= 3;\n        BOOST_CHECK_EQUAL(to_string(x), \"01'01001000\");\n    }\n\n    {\n        uint_n<10> x(00000000_b, 10101001_b);\n        x <<= 3;\n        BOOST_CHECK_EQUAL(to_string(x), \"01'01001000\");\n    }\n\n    {\n        uint_n<32> x(00000000_b, 10101001_b, 00001000_b, 00000100_b);\n        x <<= 9;\n        BOOST_CHECK_EQUAL(to_string(x), \"01010010'00010000'00001000'00000000\");\n    }\n}\n\nBOOST_AUTO_TEST_CASE(test_operator_pre_decrement) {\n    {\n        uint_n<1> x(1_b);\n        --x;\n        BOOST_CHECK_EQUAL(to_string(x), \"0\");\n        --x;\n        BOOST_CHECK_EQUAL(to_string(x), \"1\");\n    }\n\n    {\n        uint_n<10> x(1_b, 1_b);\n        --x;\n        BOOST_CHECK_EQUAL(to_string(x), \"01'00000000\");\n        --x;\n        BOOST_CHECK_EQUAL(to_string(x), \"00'11111111\");\n    }\n\n    {\n        uint_n<9> x(0_b, 0_b);\n        --x;\n        BOOST_CHECK_EQUAL(to_string(x), \"1'11111111\");\n    }\n}\n\nBOOST_AUTO_TEST_CASE(test_popcount) {\n    BOOST_CHECK_EQUAL(popcount(uint_n<1>(0_b)), 0);\n    BOOST_CHECK_EQUAL(popcount(uint_n<1>(1_b)), 1);\n    BOOST_CHECK_EQUAL(popcount(uint_n<2>(11_b)), 2);\n    BOOST_CHECK_EQUAL(popcount(uint_n<2>(111_b)), 2);\n    BOOST_CHECK_EQUAL(popcount(uint_n<9>(1_b, 1_b)), 2);\n}\n\nBOOST_AUTO_TEST_CASE(test_operator_bitwise_and) {\n    {\n        uint_n<1> x(1_b);\n        const uint_n<1> y(1_b);\n        BOOST_CHECK_EQUAL(to_string(x &= y), \"1\");\n    }\n\n    {\n        uint_n<1> x(0_b);\n        const uint_n<1> y(1_b);\n        BOOST_CHECK_EQUAL(to_string(x &= y), \"0\");\n    }\n\n    {\n        uint_n<10> x(10_b, 111_b);\n        const uint_n<10> y(11_b, 101_b);\n        BOOST_CHECK_EQUAL(to_string(x &= y), \"10'00000101\");\n    }\n\n}\n\nBOOST_AUTO_TEST_CASE(test_test) {\n    {\n        const uint_n<1> x(1_b);\n        BOOST_CHECK(x.test(0));\n    }\n\n    {\n        const uint_n<1> x(0_b);\n        BOOST_CHECK(!x.test(0));\n    }\n\n    {\n        const uint_n<11> x(101_b, 10010000_b);\n        BOOST_CHECK(x.test(10));\n        BOOST_CHECK(!x.test(9));\n        BOOST_CHECK(x.test(8));\n        BOOST_CHECK(x.test(7));\n        BOOST_CHECK(!x.test(6));\n        BOOST_CHECK(x.test(4));\n        BOOST_CHECK(!x.test(3));\n    }\n}\n\nBOOST_AUTO_TEST_CASE(test_set) {\n    uint_n<11> x{};\n    x.set(1);\n    x.set(3);\n    x.set(7);\n    x.set(10);\n    x.set(10);\n    BOOST_CHECK_EQUAL(to_string(x), \"100'10001010\");\n}\n\nBOOST_AUTO_TEST_CASE(test_unset) {\n    uint_n<11> x(101_b, 10001010_b);\n    x.unset(0);\n    x.unset(1);\n    x.unset(8);\n    BOOST_CHECK_EQUAL(to_string(x), \"100'10001000\");\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n", "meta": {"hexsha": "4b872b2f0d058d925197611630d8c55f8228c315", "size": 4637, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/uint_n_tests.cpp", "max_stars_repo_name": "nicktrandafil/hat-trie", "max_stars_repo_head_hexsha": "a62a4832c4fbc78a72630c4d3e2a3b9a79c36e8e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/uint_n_tests.cpp", "max_issues_repo_name": "nicktrandafil/hat-trie", "max_issues_repo_head_hexsha": "a62a4832c4fbc78a72630c4d3e2a3b9a79c36e8e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/uint_n_tests.cpp", "max_forks_repo_name": "nicktrandafil/hat-trie", "max_forks_repo_head_hexsha": "a62a4832c4fbc78a72630c4d3e2a3b9a79c36e8e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2010869565, "max_line_length": 81, "alphanum_fraction": 0.6299331464, "num_tokens": 1325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.43398145016252115, "lm_q2_score": 0.11596071519881658, "lm_q1q2_score": 0.05032479934386553}}
{"text": "/** @file cpp_int_util.hpp Supports the use of Boost cpp_int. */\n\n#ifndef INCLUDED_CPP_INT_UTIL\n#define INCLUDED_CPP_INT_UTIL\n\n/// @cond\n#include <boost/multiprecision/cpp_int.hpp> // cpp_int\n\n// TODO cassert\n#include <algorithm>                        // count\n#include <climits>                          // CHAR_MAX\n#include <cstdlib>                          // size_t\n#include <string>                           // string\n/// @endcond\n\nnamespace cpp_int_util {\n\nusing boost::multiprecision::cpp_int;\n\n/** STL-compatible hash functor for use with unordered containers. */\nstruct hash {\n    std::size_t operator()(cpp_int const& n) const;\n};\n\nint sum_digits(cpp_int const& n);\n\n}\n\ninline\nstd::size_t cpp_int_util::hash::operator()(cpp_int const& n) const {\n    return n.convert_to<std::size_t>();\n}\n\ntemplate<>\nstruct std::hash<boost::multiprecision::cpp_int>: cpp_int_util::hash { };\n\n#endif\n", "meta": {"hexsha": "c80998fe50a1edc090732131014b49e7c40bff24", "size": 895, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/cpp_int_util.hpp", "max_stars_repo_name": "jeffs/cpp-euler", "max_stars_repo_head_hexsha": "b42a8a70fad782569a699a028968bc1a60bd5c44", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/cpp_int_util.hpp", "max_issues_repo_name": "jeffs/cpp-euler", "max_issues_repo_head_hexsha": "b42a8a70fad782569a699a028968bc1a60bd5c44", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/cpp_int_util.hpp", "max_forks_repo_name": "jeffs/cpp-euler", "max_forks_repo_head_hexsha": "b42a8a70fad782569a699a028968bc1a60bd5c44", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5526315789, "max_line_length": 73, "alphanum_fraction": 0.6424581006, "num_tokens": 203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.46490157137338844, "lm_q2_score": 0.10818896031297129, "lm_q1q2_score": 0.050297217654753514}}
{"text": "/*\r\n [auto_generated]\r\n libs/numeric/odeint/test/adaptive_iterator.cpp\r\n\r\n [begin_description]\r\n This file tests the adaptive iterators.\r\n [end_description]\r\n\r\n Copyright 2012-2013 Karsten Ahnert\r\n Copyright 2012-2013 Mario Mulansky\r\n\r\n Distributed under the Boost Software License, Version 1.0.\r\n (See accompanying file LICENSE_1_0.txt or\r\n copy at http://www.boost.org/LICENSE_1_0.txt)\r\n */\r\n\r\n\r\n#define BOOST_TEST_MODULE odeint_adaptive_iterator\r\n\r\n#include <iterator>\r\n#include <algorithm>\r\n#include <vector>\r\n\r\n#include <boost/numeric/odeint/config.hpp>\r\n#include <boost/array.hpp>\r\n#include <boost/range/algorithm/copy.hpp>\r\n#include <boost/range/algorithm/for_each.hpp>\r\n#include <boost/mpl/vector.hpp>\r\n\r\n#include <boost/test/unit_test.hpp>\r\n#include <boost/test/floating_point_comparison.hpp>\r\n\r\n#include <boost/numeric/odeint/iterator/adaptive_iterator.hpp>\r\n#include \"dummy_steppers.hpp\"\r\n#include \"dummy_odes.hpp\"\r\n#include \"dummy_observers.hpp\"\r\n\r\nnamespace mpl = boost::mpl;\r\nusing namespace boost::numeric::odeint;\r\n\r\ntypedef dummy_stepper::state_type state_type;\r\ntypedef dummy_stepper::value_type value_type;\r\n\r\nBOOST_AUTO_TEST_SUITE( adaptive_iterator_test )\r\n\r\ntypedef mpl::vector<\r\n    dummy_controlled_stepper\r\n    , dummy_dense_output_stepper\r\n    > dummy_steppers;\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( copy_controlled_stepper_iterator )\r\n{\r\n    typedef adaptive_iterator< dummy_controlled_stepper , empty_system , state_type > iterator_type;\r\n\r\n    state_type x = {{ 1.0 }};\r\n    iterator_type iter1( dummy_controlled_stepper() , empty_system() , x );\r\n    iterator_type iter2( iter1 );\r\n\r\n    BOOST_CHECK_EQUAL( &( *iter1 ) , &x );\r\n    BOOST_CHECK_EQUAL( &( *iter2 ) , &x );\r\n    BOOST_CHECK_EQUAL( &( *iter1 ) , &( *iter2 ) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n\r\n    ++iter1;\r\n    ++iter2;\r\n\r\n    BOOST_CHECK_EQUAL( &( *iter1 ) , &x );\r\n    BOOST_CHECK_EQUAL( &( *iter2 ) , &x );\r\n    BOOST_CHECK_EQUAL( &( *iter1 ) , &( *iter2 ) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator )\r\n{\r\n    typedef adaptive_iterator< dummy_dense_output_stepper , empty_system , state_type > iterator_type;\r\n\r\n    state_type x = {{ 1.0 }};\r\n    // fix by mario: do not dereference iterators at the end - made iter1 start iterator\r\n    iterator_type iter1( dummy_dense_output_stepper() , empty_system() , x , 0.0 , 1.0 , 0.1 );\r\n    iterator_type iter2( iter1 );\r\n\r\n    // fix by mario: iterator dereference now always gives internal state also for dense output, consistent with other iterator implementations\r\n    // changed: iterators with dense output stepper do not have an internal state now to avoid a copy\r\n    BOOST_CHECK_NE( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n\r\n    ++iter1;\r\n    ++iter2;\r\n\r\n    BOOST_CHECK_NE( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper )\r\n{\r\n    // bad use case, the same stepper is iterated twice\r\n    typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system , state_type > iterator_type;\r\n\r\n    state_type x = {{ 1.0 }};\r\n    dummy_dense_output_stepper stepper;\r\n    iterator_type iter1( boost::ref( stepper ) , empty_system() , x , 0.0 , 0.9 , 0.1 );\r\n    iterator_type iter2( iter1 );\r\n\r\n    BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n    \r\n    ++iter1;\r\n    ++iter2;\r\n    \r\n    BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( !iter1.same( iter2 ) );         // they point to the same stepper, there the times will be different\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator )\r\n{\r\n    typedef adaptive_iterator< dummy_controlled_stepper , empty_system , state_type > iterator_type;\r\n    state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};\r\n    iterator_type iter1 = iterator_type( dummy_controlled_stepper() , empty_system() , x1 , 0.0 , 1.0 , 0.1 );\r\n    iterator_type iter2 = iterator_type( dummy_controlled_stepper() , empty_system() , x2 , 0.0 , 1.0 , 0.2 );\r\n    BOOST_CHECK_EQUAL( &(*iter1) , &x1 );\r\n    BOOST_CHECK_EQUAL( &(*iter2) , &x2 );\r\n    // the iterators are indeed the same as this only checks the time values\r\n    BOOST_CHECK( !iter1.same( iter2 ) );\r\n    iter2 = iter1;\r\n    BOOST_CHECK_EQUAL( &(*iter1) , &x1 );\r\n    BOOST_CHECK_EQUAL( &(*iter2) , &x1 );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator )\r\n{\r\n    typedef adaptive_iterator< dummy_dense_output_stepper , empty_system , state_type > iterator_type;\r\n    state_type x1 = {{ 1.0 }};\r\n    iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 1.0 , 0.1 );\r\n    iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 1.0 , 0.2 );\r\n\r\n    BOOST_CHECK_NE( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( !iter1.same( iter2 ) );\r\n\r\n    iter2 = iter1;\r\n    // fix by mario: iterator dereference now always gives internal state also for dense output, consistent with other iterator implementations\r\n    // changed: iterators with dense output stepper do not have an internal state now to avoid a copy\r\n    BOOST_CHECK_NE( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper )\r\n{\r\n    typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system , state_type > iterator_type;\r\n    state_type x1 = {{ 1.0 }};\r\n\r\n    dummy_dense_output_stepper stepper;\r\n    iterator_type iter1 = iterator_type( boost::ref( stepper )  , empty_system() , x1 , 0.0 , 1.0 , 0.1 );\r\n    iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 1.0 , 0.2 );\r\n\r\n    BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( !iter1.same( iter2 ) );\r\n\r\n    iter2 = iter1;\r\n\r\n    BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );\r\n    BOOST_CHECK( iter1.same( iter2 ) );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory )\r\n{\r\n    dummy_controlled_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    std::for_each(\r\n         make_adaptive_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n         make_adaptive_iterator_end( stepper , boost::ref( system ) , x ) ,\r\n         dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );\r\n}\r\n\r\n// just test if it compiles\r\nBOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory )\r\n{\r\n    dummy_dense_output_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    std::for_each(\r\n         make_adaptive_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n         make_adaptive_iterator_end( stepper , boost::ref( system ) , x ) ,\r\n         dummy_observer() );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( controlled_stepper_range )\r\n{\r\n    dummy_controlled_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    boost::for_each( make_adaptive_range( stepper , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n                     dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );\r\n}\r\n\r\n// just test if it compiles\r\nBOOST_AUTO_TEST_CASE( dense_output_stepper_range )\r\n{\r\n    dummy_dense_output_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    boost::for_each( make_adaptive_range( stepper , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n                     dummy_observer() );\r\n}\r\n\r\n\r\nBOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory )\r\n{\r\n    dummy_controlled_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    std::for_each(\r\n        make_adaptive_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n        make_adaptive_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,\r\n        dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );\r\n}\r\n\r\n// just test if it compiles\r\nBOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory )\r\n{\r\n    dummy_dense_output_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    std::for_each(\r\n        make_adaptive_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n        make_adaptive_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,\r\n        dummy_observer() );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper )\r\n{\r\n    dummy_controlled_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    boost::for_each( make_adaptive_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n                     dummy_observer() );\r\n\r\n    BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );\r\n}\r\n\r\n// just test if it compiles\r\nBOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper )\r\n{\r\n    dummy_dense_output_stepper stepper;\r\n    empty_system system;\r\n    state_type x = {{ 1.0 }};\r\n\r\n    boost::for_each( make_adaptive_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 1.0 , 0.1 ) ,\r\n                     dummy_observer() );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )\r\n{\r\n    typedef adaptive_iterator< Stepper , empty_system , state_type > stepper_iterator;\r\n\r\n    state_type x = {{ 1.0 }};\r\n    stepper_iterator first1( Stepper() , empty_system() , x , 2.5 , 2.0 , 0.1 );\r\n    stepper_iterator last1( Stepper() , empty_system() , x );\r\n    stepper_iterator last2( Stepper() , empty_system() , x );\r\n\r\n    BOOST_CHECK( first1 == last1 );\r\n    BOOST_CHECK( first1 == last2 );\r\n    BOOST_CHECK( last1 == last2 );\r\n}\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )\r\n{\r\n    typedef adaptive_iterator< Stepper , empty_system , state_type > stepper_iterator;\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    stepper_iterator first( Stepper() , empty_system() , x , 0.0 , 0.35 , 0.1 );\r\n    stepper_iterator last( Stepper() , empty_system() , x );\r\n\r\n    std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 5 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[4][0] , 2.0 , 1.0e-14 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )\r\n{\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    std::copy( make_adaptive_iterator_begin( Stepper() , empty_system() , x , 0.0 , 0.35 , 0.1 ) ,\r\n               make_adaptive_iterator_end( Stepper() , empty_system() , x ) ,\r\n               std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 5 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[4][0] , 2.0 , 1.0e-14 );\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )\r\n{\r\n    state_type x = {{ 1.0 }};\r\n    std::vector< state_type > res;\r\n    boost::range::copy( make_adaptive_range( Stepper() , empty_system() , x , 0.0 , 0.35 , 0.1 ) ,\r\n                        std::back_insert_iterator< std::vector< state_type > >( res ) );\r\n\r\n    BOOST_CHECK_EQUAL( res.size() , size_t( 5 ) );\r\n    BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );\r\n    BOOST_CHECK_CLOSE( res[4][0] , 2.0 , 1.0e-14 );\r\n}\r\n\r\n\r\n\r\n\r\nBOOST_AUTO_TEST_SUITE_END()\r\n", "meta": {"hexsha": "80ebb69d9266c80b9029a90eaeae636130098f67", "size": 12166, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/adaptive_iterator.cpp", "max_stars_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_stars_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 32.0, "max_stars_repo_stars_event_min_datetime": "2019-02-27T06:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-29T10:56:19.000Z", "max_issues_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/adaptive_iterator.cpp", "max_issues_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_issues_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2019-04-04T18:00:00.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T18:00:00.000Z", "max_forks_repo_path": "REDSI_1160929_1161573/boost_1_67_0/libs/numeric/odeint/test/adaptive_iterator.cpp", "max_forks_repo_name": "Wultyc/ISEP_1718_2A2S_REDSI_TrabalhoGrupo", "max_forks_repo_head_hexsha": "eb0f7ef64e188fe871f47c2ef9cdef36d8a66bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2019-08-20T13:45:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-01T18:23:49.000Z", "avg_line_length": 35.060518732, "max_line_length": 144, "alphanum_fraction": 0.6493506494, "num_tokens": 3419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.3886180267058489, "lm_q2_score": 0.1294027383065593, "lm_q1q2_score": 0.05028823681102843}}
{"text": "//\n// Created by przemek on 01.04.2020.\n//\n#include <AST/expression/base_math_expr.h>\n#include <AST/expression/realtion_expr.h>\n#include <AST/statement/assign_stmt.h>\n#include <AST/statement/if_stmt.h>\n#include <AST/statement/return_stmt.h>\n#include <boost/test/unit_test.hpp>\n#include <mock_expr.h>\n#include <mock_stmt.h>\n\nusing namespace vecc;\nusing namespace vecc::ast;\nusing namespace vecc::test;\n\nBOOST_AUTO_TEST_SUITE(AST_Test_Suite)\n\nBOOST_AUTO_TEST_SUITE(If_Stmt_Test_Suite)\n\nBOOST_AUTO_TEST_CASE(IfTest_NoThrow) {\n  auto cond = std::make_unique<BaseMathExpr>(Variable());\n\n  IfStatement ifStmt(std::move(cond));\n\n  Return temp;\n  BOOST_CHECK_NO_THROW(temp = ifStmt.run());\n}\n\nBOOST_AUTO_TEST_CASE(IfTrueTest_TrueBlockRun) {\n  auto var1 = Variable({1});\n  auto var2 = Variable({10});\n  auto cond = std::make_unique<RelationExpr>(\n      std::make_unique<BaseMathExpr>(&var1), RelationExpr::OperatorType::Less,\n      std::make_unique<BaseMathExpr>(&var2));\n\n  IfStatement ifStmt(std::move(cond));\n\n  ifStmt.falseBlock().addInstruction(std::make_unique<AssignStatement>(\n      var2, std::make_unique<BaseMathExpr>(Variable({99}))));\n\n  ifStmt.trueBlock().addInstruction(std::make_unique<AssignStatement>(\n      var1, std::make_unique<BaseMathExpr>(Variable({99}))));\n\n  BOOST_CHECK_EQUAL(true, ifStmt.run().type_ == Return::Type::Noting);\n  BOOST_CHECK_EQUAL(var1, Variable({99}));\n  BOOST_CHECK_EQUAL(var2, Variable({10}));\n}\n\nBOOST_AUTO_TEST_CASE(IfFalseTest_FalseBlockRun) {\n  auto var1 = Variable({1});\n  auto var2 = Variable({10});\n  auto cond =\n      std::make_unique<RelationExpr>(std::make_unique<BaseMathExpr>(&var1),\n                                     RelationExpr::OperatorType::GreaterOrEqual,\n                                     std::make_unique<BaseMathExpr>(&var2));\n\n  IfStatement ifStmt(std::move(cond));\n\n  ifStmt.falseBlock().addInstruction(std::make_unique<AssignStatement>(\n      var2, std::make_unique<BaseMathExpr>(Variable({99}))));\n\n  ifStmt.trueBlock().addInstruction(std::make_unique<AssignStatement>(\n      var1, std::make_unique<BaseMathExpr>(Variable({99}))));\n\n  BOOST_CHECK_EQUAL(true, ifStmt.run().type_ == Return::Type::Noting);\n  BOOST_CHECK_EQUAL(var1, Variable({1}));\n  BOOST_CHECK_EQUAL(var2, Variable({99}));\n}\n\nBOOST_AUTO_TEST_CASE(IfTrueTest_TrueBlockReturn) {\n  auto cond = std::make_unique<BaseMathExpr>(Variable({1}));\n\n  BOOST_REQUIRE_EQUAL(true, cond->calculate());\n\n  IfStatement ifStmt(std::move(cond));\n\n  ifStmt.trueBlock().addInstruction(std::make_unique<ReturnStatement>(\n      std::make_unique<BaseMathExpr>(Variable({99}))));\n\n  ifStmt.falseBlock().addInstruction(std::make_unique<ReturnStatement>(\n      std::make_unique<BaseMathExpr>(Variable({22}))));\n\n  BOOST_CHECK_EQUAL(true, ifStmt.run().type_ == Return::Type::Value);\n  BOOST_CHECK_EQUAL(ifStmt.run().variable_, Variable({99}));\n}\n\nBOOST_AUTO_TEST_CASE(IfFalseTest_FalseBlockReturn) {\n  auto cond = std::make_unique<BaseMathExpr>(Variable({0}));\n\n  BOOST_REQUIRE_EQUAL(false, cond->calculate());\n\n  IfStatement ifStmt(std::move(cond));\n\n  ifStmt.trueBlock().addInstruction(std::make_unique<ReturnStatement>(\n      std::make_unique<BaseMathExpr>(Variable({99}))));\n\n  ifStmt.falseBlock().addInstruction(std::make_unique<ReturnStatement>(\n      std::make_unique<BaseMathExpr>(Variable({22}))));\n\n  BOOST_CHECK_EQUAL(true, ifStmt.run().type_ == Return::Type::Value);\n  BOOST_CHECK_EQUAL(ifStmt.run().variable_, Variable({22}));\n}\n\nBOOST_AUTO_TEST_CASE(If_ToStringWorks) {\n  IfStatement ifStmt(std::make_unique<MockExpr>(\"condition\"));\n\n  ifStmt.trueBlock().addInstruction(std::make_unique<MockStmt>(\"true block\"));\n\n  ifStmt.falseBlock().addInstruction(std::make_unique<MockStmt>(\"false block\"));\n\n  BOOST_CHECK_EQUAL(ifStmt.toString(),\n                    \"if(condition){\\ntrue block;\\n}else{\\nfalse block;\\n}\");\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\nBOOST_AUTO_TEST_SUITE_END()", "meta": {"hexsha": "c5da870d4d6d0a42b4c40fb0f24c843dd52a6ba8", "size": 3890, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "test/AST/statement/if_stmt_test.cpp", "max_stars_repo_name": "przestaw/vecc_SimpleLanguage", "max_stars_repo_head_hexsha": "a48bb8c0e53cc5f256c926cdb28cf39b107d66ee", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/AST/statement/if_stmt_test.cpp", "max_issues_repo_name": "przestaw/vecc_SimpleLanguage", "max_issues_repo_head_hexsha": "a48bb8c0e53cc5f256c926cdb28cf39b107d66ee", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/AST/statement/if_stmt_test.cpp", "max_forks_repo_name": "przestaw/vecc_SimpleLanguage", "max_forks_repo_head_hexsha": "a48bb8c0e53cc5f256c926cdb28cf39b107d66ee", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9661016949, "max_line_length": 80, "alphanum_fraction": 0.7241645244, "num_tokens": 962, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4843800842769843, "lm_q2_score": 0.10374862755917083, "lm_q1q2_score": 0.05025376896073262}}
{"text": "//////////////////////////////////////////////////////////////////////////////\n///   Copyright 2003 and onward LASMEA UMR 6602 CNRS/U.B.P Clermont-Ferrand\n///   Copyright 2009 and onward LRI    UMR 8623 CNRS/Univ Paris Sud XI\n///\n///          Distributed under the Boost Software License, Version 1.0\n///                 See accompanying file LICENSE.txt or copy at\n///                     http://www.boost.org/LICENSE_1_0.txt\n//////////////////////////////////////////////////////////////////////////////\n#define NT2_UNIT_MODULE \"nt2 bitwise toolbox - ffs/scalar Mode\"\n\n//////////////////////////////////////////////////////////////////////////////\n// Test behavior of bitwise components in scalar mode\n//////////////////////////////////////////////////////////////////////////////\n/// created  by jt the 18/02/2011\n/// modified by jt the 16/03/2011\n#include <boost/type_traits/is_same.hpp>\n#include <nt2/sdk/functor/meta/call.hpp>\n#include <nt2/sdk/unit/tests.hpp>\n#include <nt2/sdk/unit/module.hpp>\n#include <nt2/sdk/memory/buffer.hpp>\n#include <nt2/sdk/constant/real.hpp>\n#include <nt2/sdk/constant/infinites.hpp>\n#include <nt2/include/functions/ulpdist.hpp>\n#include <nt2/toolbox/bitwise/include/ffs.hpp>\n\nNT2_TEST_CASE_TPL ( ffs_float_1,  (float))\n{\n  \n  using nt2::ffs;\n  using nt2::tag::ffs_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<ffs_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::as_integer<T, unsigned>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(ffs(nt2::Inf<T>()), 24u);\n  NT2_TEST_EQUAL(ffs(nt2::Minf<T>()), 24u);\n  NT2_TEST_EQUAL(ffs(nt2::Nan<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(ffs(nt2::Signmask<T>()), sizeof(T)*8);\n  NT2_TEST_EQUAL(ffs(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for float\n\nNT2_TEST_CASE_TPL ( ffs_double_1,  (double))\n{\n  \n  using nt2::ffs;\n  using nt2::tag::ffs_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<ffs_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::as_integer<T, unsigned>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(ffs(nt2::Inf<T>()), 53u);\n  NT2_TEST_EQUAL(ffs(nt2::Minf<T>()), 53u);\n  NT2_TEST_EQUAL(ffs(nt2::Nan<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(ffs(nt2::Signmask<T>()), sizeof(T)*8);\n  NT2_TEST_EQUAL(ffs(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for double\n\nNT2_TEST_CASE_TPL ( ffs_signed_int__1,  NT2_INTEGRAL_SIGNED_TYPES)\n{\n  \n  using nt2::ffs;\n  using nt2::tag::ffs_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<ffs_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::as_integer<T, unsigned>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(ffs(nt2::One<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(ffs(nt2::Signmask<T>()), sizeof(T)*8);\n  NT2_TEST_EQUAL(ffs(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for signed_int_\n\nNT2_TEST_CASE_TPL ( ffs_unsigned_int__1,  NT2_UNSIGNED_TYPES)\n{\n  \n  using nt2::ffs;\n  using nt2::tag::ffs_;\n  typedef typename nt2::meta::as_integer<T>::type iT;\n  typedef typename nt2::meta::call<ffs_(T)>::type r_t;\n  typedef typename nt2::meta::upgrade<T>::type u_t;\n  typedef typename nt2::meta::as_integer<T, unsigned>::type wished_r_t;\n\n\n  // return type conformity test \n  NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) );\n  std::cout << std::endl; \n  double ulpd;\n  ulpd=0.0;\n\n\n  // specific values tests\n  NT2_TEST_EQUAL(ffs(nt2::One<T>()), nt2::One<r_t>());\n  NT2_TEST_EQUAL(ffs(nt2::Zero<T>()), nt2::Zero<r_t>());\n} // end of test for unsigned_int_\n", "meta": {"hexsha": "69fa7046a586d01c0f7240cbdec0770c306df851", "size": 4176, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "modules/bitwise/unit/scalar/ffs.cpp", "max_stars_repo_name": "brycelelbach/nt2", "max_stars_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2022-03-24T03:35:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T03:35:10.000Z", "max_issues_repo_path": "modules/bitwise/unit/scalar/ffs.cpp", "max_issues_repo_name": "brycelelbach/nt2", "max_issues_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/bitwise/unit/scalar/ffs.cpp", "max_forks_repo_name": "brycelelbach/nt2", "max_forks_repo_head_hexsha": "73d7e8dd390fa4c8d251c6451acdae65def70e0b", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.6774193548, "max_line_length": 78, "alphanum_fraction": 0.6269157088, "num_tokens": 1253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.44552953503957266, "lm_q2_score": 0.11279540926528923, "lm_q1q2_score": 0.05025368624456262}}
{"text": "//  Copyright (c) 2015 Hartmut Kaiser\n//\n//  Distributed under the Boost Software License, Version 1.0. (See accompanying\n//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n#include <hpx/hpx_init.hpp>\n#include <hpx/hpx.hpp>\n#include <hpx/include/parallel_set_operations.hpp>\n#include <hpx/util/lightweight_test.hpp>\n\n#include <boost/range/functions.hpp>\n\n#include \"test_utils.hpp\"\n\n///////////////////////////////////////////////////////////////////////////////\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference1(ExPolicy const& policy, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::test_iterator<base_iterator, IteratorTag> iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    std::sort(boost::begin(c1), boost::end(c1));\n    std::sort(boost::begin(c2), boost::end(c2));\n\n    std::vector<std::size_t> c3(2*c1.size()), c4(2*c1.size());\n\n    hpx::parallel::set_symmetric_difference(policy,\n        iterator(boost::begin(c1)), iterator(boost::end(c1)),\n        boost::begin(c2), boost::end(c2), boost::begin(c3));\n\n    std::set_symmetric_difference(boost::begin(c1), boost::end(c1),\n        boost::begin(c2), boost::end(c2), boost::begin(c4));\n\n    // verify values\n    HPX_TEST(std::equal(boost::begin(c3), boost::end(c3), boost::begin(c4)));\n}\n\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference1_async(ExPolicy const& p, IteratorTag)\n{\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::test_iterator<base_iterator, IteratorTag> iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    std::sort(boost::begin(c1), boost::end(c1));\n    std::sort(boost::begin(c2), boost::end(c2));\n\n    std::vector<std::size_t> c3(2*c1.size()), c4(2*c1.size());\n\n    hpx::future<void> result =\n        hpx::parallel::set_symmetric_difference(p,\n            iterator(boost::begin(c1)), iterator(boost::end(c1)),\n            boost::begin(c2), boost::end(c2), boost::begin(c3));\n    result.wait();\n\n    std::set_symmetric_difference(boost::begin(c1), boost::end(c1),\n        boost::begin(c2), boost::end(c2), boost::begin(c4));\n\n    // verify values\n    HPX_TEST(std::equal(boost::begin(c3), boost::end(c3), boost::begin(c4)));\n}\n\ntemplate <typename IteratorTag>\nvoid test_set_symmetric_difference1()\n{\n    using namespace hpx::parallel;\n\n    test_set_symmetric_difference1(seq, IteratorTag());\n    test_set_symmetric_difference1(par, IteratorTag());\n    test_set_symmetric_difference1(par_vec, IteratorTag());\n\n    test_set_symmetric_difference1_async(seq(task), IteratorTag());\n    test_set_symmetric_difference1_async(par(task), IteratorTag());\n\n    test_set_symmetric_difference1(execution_policy(seq), IteratorTag());\n    test_set_symmetric_difference1(execution_policy(par), IteratorTag());\n    test_set_symmetric_difference1(execution_policy(par_vec), IteratorTag());\n\n    test_set_symmetric_difference1(execution_policy(seq(task)), IteratorTag());\n    test_set_symmetric_difference1(execution_policy(par(task)), IteratorTag());\n}\n\nvoid set_symmetric_difference_test1()\n{\n    test_set_symmetric_difference1<std::random_access_iterator_tag>();\n    test_set_symmetric_difference1<std::forward_iterator_tag>();\n    test_set_symmetric_difference1<std::input_iterator_tag>();\n}\n\n///////////////////////////////////////////////////////////////////////////////\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference2(ExPolicy const& policy, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::test_iterator<base_iterator, IteratorTag> iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    auto comp = [](std::size_t l, std::size_t r) { return l > r; };\n\n    std::sort(boost::begin(c1), boost::end(c1), comp);\n    std::sort(boost::begin(c2), boost::end(c2), comp);\n\n    std::vector<std::size_t> c3(2*c1.size()), c4(2*c1.size());\n\n    hpx::parallel::set_symmetric_difference(policy,\n        iterator(boost::begin(c1)), iterator(boost::end(c1)),\n        boost::begin(c2), boost::end(c2), boost::begin(c3), comp);\n\n    std::set_symmetric_difference(boost::begin(c1), boost::end(c1),\n        boost::begin(c2), boost::end(c2), boost::begin(c4), comp);\n\n    // verify values\n    HPX_TEST(std::equal(boost::begin(c3), boost::end(c3), boost::begin(c4)));\n}\n\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference2_async(ExPolicy const& p, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::test_iterator<base_iterator, IteratorTag> iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    auto comp = [](std::size_t l, std::size_t r) { return l > r; };\n\n    std::sort(boost::begin(c1), boost::end(c1), comp);\n    std::sort(boost::begin(c2), boost::end(c2), comp);\n\n    std::vector<std::size_t> c3(2*c1.size()), c4(2*c1.size());\n\n    hpx::future<void> result =\n        hpx::parallel::set_symmetric_difference(p,\n            iterator(boost::begin(c1)), iterator(boost::end(c1)),\n            boost::begin(c2), boost::end(c2), boost::begin(c3), comp);\n    result.wait();\n\n    std::set_symmetric_difference(boost::begin(c1), boost::end(c1),\n        boost::begin(c2), boost::end(c2), boost::begin(c4), comp);\n\n    // verify values\n    HPX_TEST(std::equal(boost::begin(c3), boost::end(c3), boost::begin(c4)));\n}\n\ntemplate <typename IteratorTag>\nvoid test_set_symmetric_difference2()\n{\n    using namespace hpx::parallel;\n\n    test_set_symmetric_difference2(seq, IteratorTag());\n    test_set_symmetric_difference2(par, IteratorTag());\n    test_set_symmetric_difference2(par_vec, IteratorTag());\n\n    test_set_symmetric_difference2_async(seq(task), IteratorTag());\n    test_set_symmetric_difference2_async(par(task), IteratorTag());\n\n    test_set_symmetric_difference2(execution_policy(seq), IteratorTag());\n    test_set_symmetric_difference2(execution_policy(par), IteratorTag());\n    test_set_symmetric_difference2(execution_policy(par_vec), IteratorTag());\n\n    test_set_symmetric_difference2(execution_policy(seq(task)), IteratorTag());\n    test_set_symmetric_difference2(execution_policy(par(task)), IteratorTag());\n}\n\nvoid set_symmetric_difference_test2()\n{\n    test_set_symmetric_difference2<std::random_access_iterator_tag>();\n    test_set_symmetric_difference2<std::forward_iterator_tag>();\n    test_set_symmetric_difference2<std::input_iterator_tag>();\n}\n\n///////////////////////////////////////////////////////////////////////////////\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference_exception(ExPolicy const& policy, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::decorated_iterator<base_iterator, IteratorTag>\n        decorated_iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    std::sort(boost::begin(c1), boost::end(c1));\n    std::sort(boost::begin(c2), boost::end(c2));\n\n    std::vector<std::size_t> c3(2*c1.size());\n\n    bool caught_exception = false;\n    try {\n        hpx::parallel::set_symmetric_difference(policy,\n            decorated_iterator(\n                boost::begin(c1),\n                [](){ throw std::runtime_error(\"test\"); }),\n            decorated_iterator(boost::end(c1)),\n            boost::begin(c2), boost::end(c2),\n            boost::begin(c3));\n\n        HPX_TEST(false);\n    }\n    catch(hpx::exception_list const& e) {\n        caught_exception = true;\n        test::test_num_exceptions<ExPolicy, IteratorTag>::call(policy, e);\n    }\n    catch(...) {\n        HPX_TEST(false);\n    }\n\n    HPX_TEST(caught_exception);\n}\n\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference_exception_async(ExPolicy const& p, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::decorated_iterator<base_iterator, IteratorTag>\n        decorated_iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    std::sort(boost::begin(c1), boost::end(c1));\n    std::sort(boost::begin(c2), boost::end(c2));\n\n    std::vector<std::size_t> c3(2*c1.size());\n\n    bool caught_exception = false;\n    bool returned_from_algorithm = false;\n    try {\n        hpx::future<void> f =\n            hpx::parallel::set_symmetric_difference(p,\n                decorated_iterator(\n                    boost::begin(c1),\n                    [](){ throw std::runtime_error(\"test\"); }),\n                decorated_iterator(boost::end(c1)),\n                boost::begin(c2), boost::end(c2),\n                boost::begin(c3));\n\n        returned_from_algorithm = true;\n        f.get();\n\n        HPX_TEST(false);\n    }\n    catch(hpx::exception_list const& e) {\n        caught_exception = true;\n        test::test_num_exceptions<ExPolicy, IteratorTag>::call(p, e);\n    }\n    catch(...) {\n        HPX_TEST(false);\n    }\n\n    HPX_TEST(caught_exception);\n    HPX_TEST(returned_from_algorithm);\n}\n\ntemplate <typename IteratorTag>\nvoid test_set_symmetric_difference_exception()\n{\n    using namespace hpx::parallel;\n\n    // If the execution policy object is of type vector_execution_policy,\n    // std::terminate shall be called. therefore we do not test exceptions\n    // with a vector execution policy\n    test_set_symmetric_difference_exception(seq, IteratorTag());\n    test_set_symmetric_difference_exception(par, IteratorTag());\n\n    test_set_symmetric_difference_exception_async(seq(task), IteratorTag());\n    test_set_symmetric_difference_exception_async(par(task), IteratorTag());\n\n    test_set_symmetric_difference_exception(execution_policy(seq), IteratorTag());\n    test_set_symmetric_difference_exception(execution_policy(par), IteratorTag());\n\n    test_set_symmetric_difference_exception(execution_policy(seq(task)), IteratorTag());\n    test_set_symmetric_difference_exception(execution_policy(par(task)), IteratorTag());\n}\n\nvoid set_symmetric_difference_exception_test()\n{\n    test_set_symmetric_difference_exception<std::random_access_iterator_tag>();\n    test_set_symmetric_difference_exception<std::forward_iterator_tag>();\n    test_set_symmetric_difference_exception<std::input_iterator_tag>();\n}\n\n///////////////////////////////////////////////////////////////////////////////\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference_bad_alloc(ExPolicy const& policy, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::decorated_iterator<base_iterator, IteratorTag>\n        decorated_iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    std::sort(boost::begin(c1), boost::end(c1));\n    std::sort(boost::begin(c2), boost::end(c2));\n\n    std::vector<std::size_t> c3(2*c1.size());\n\n    bool caught_bad_alloc = false;\n    try {\n        hpx::parallel::set_symmetric_difference(policy,\n            decorated_iterator(\n                boost::begin(c1),\n                [](){ throw std::bad_alloc(); }),\n            decorated_iterator(boost::end(c1)),\n            boost::begin(c2), boost::end(c2),\n            boost::begin(c3));\n\n        HPX_TEST(false);\n    }\n    catch(std::bad_alloc const&) {\n        caught_bad_alloc = true;\n    }\n    catch(...) {\n        HPX_TEST(false);\n    }\n\n    HPX_TEST(caught_bad_alloc);\n}\n\ntemplate <typename ExPolicy, typename IteratorTag>\nvoid test_set_symmetric_difference_bad_alloc_async(ExPolicy const& p, IteratorTag)\n{\n    BOOST_STATIC_ASSERT(hpx::parallel::is_execution_policy<ExPolicy>::value);\n\n    typedef std::vector<std::size_t>::iterator base_iterator;\n    typedef test::decorated_iterator<base_iterator, IteratorTag>\n        decorated_iterator;\n\n    std::vector<std::size_t> c1 = test::random_fill(10007);\n    std::vector<std::size_t> c2 = test::random_fill(c1.size());\n\n    std::sort(boost::begin(c1), boost::end(c1));\n    std::sort(boost::begin(c2), boost::end(c2));\n\n    std::vector<std::size_t> c3(2*c1.size());\n\n    bool caught_bad_alloc = false;\n    bool returned_from_algorithm = false;\n    try {\n        hpx::future<void> f =\n            hpx::parallel::set_symmetric_difference(p,\n                decorated_iterator(\n                    boost::begin(c1),\n                    [](){ throw std::bad_alloc(); }),\n                decorated_iterator(boost::end(c1)),\n                boost::begin(c2), boost::end(c2),\n                boost::begin(c3));\n\n        returned_from_algorithm = true;\n        f.get();\n\n        HPX_TEST(false);\n    }\n    catch(std::bad_alloc const&) {\n        caught_bad_alloc = true;\n    }\n    catch(...) {\n        HPX_TEST(false);\n    }\n\n    HPX_TEST(caught_bad_alloc);\n    HPX_TEST(returned_from_algorithm);\n}\n\ntemplate <typename IteratorTag>\nvoid test_set_symmetric_difference_bad_alloc()\n{\n    using namespace hpx::parallel;\n\n    // If the execution policy object is of type vector_execution_policy,\n    // std::terminate shall be called. therefore we do not test exceptions\n    // with a vector execution policy\n    test_set_symmetric_difference_bad_alloc(seq, IteratorTag());\n    test_set_symmetric_difference_bad_alloc(par, IteratorTag());\n\n    test_set_symmetric_difference_bad_alloc_async(seq(task), IteratorTag());\n    test_set_symmetric_difference_bad_alloc_async(par(task), IteratorTag());\n\n    test_set_symmetric_difference_bad_alloc(execution_policy(seq), IteratorTag());\n    test_set_symmetric_difference_bad_alloc(execution_policy(par), IteratorTag());\n\n    test_set_symmetric_difference_bad_alloc(execution_policy(seq(task)), IteratorTag());\n    test_set_symmetric_difference_bad_alloc(execution_policy(par(task)), IteratorTag());\n}\n\nvoid set_symmetric_difference_bad_alloc_test()\n{\n    test_set_symmetric_difference_bad_alloc<std::random_access_iterator_tag>();\n    test_set_symmetric_difference_bad_alloc<std::forward_iterator_tag>();\n    test_set_symmetric_difference_bad_alloc<std::input_iterator_tag>();\n}\n\n///////////////////////////////////////////////////////////////////////////////\nint hpx_main(boost::program_options::variables_map& vm)\n{\n    unsigned int seed = (unsigned int)std::time(0);\n    if (vm.count(\"seed\"))\n        seed = vm[\"seed\"].as<unsigned int>();\n\n    std::cout << \"using seed: \" << seed << std::endl;\n    std::srand(seed);\n\n    set_symmetric_difference_test1();\n    set_symmetric_difference_test2();\n    set_symmetric_difference_exception_test();\n    set_symmetric_difference_bad_alloc_test();\n    return hpx::finalize();\n}\n\nint main(int argc, char* argv[])\n{\n    // add command line option which controls the random number generator seed\n    using namespace boost::program_options;\n    options_description desc_commandline(\n        \"Usage: \" HPX_APPLICATION_STRING \" [options]\");\n\n    desc_commandline.add_options()\n        (\"seed,s\", value<unsigned int>(),\n        \"the random number generator seed to use for this run\")\n        ;\n\n    // By default this test should run on all available cores\n    std::vector<std::string> cfg;\n    cfg.push_back(\"hpx.os_threads=\" +\n        boost::lexical_cast<std::string>(hpx::threads::hardware_concurrency()));\n\n    // Initialize and run HPX\n    HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0,\n        \"HPX main exited with non-zero status\");\n\n    return hpx::util::report_errors();\n}\n\n\n", "meta": {"hexsha": "67adf59b0fbbf51d4cd85208977a5565c943aa56", "size": 16232, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/unit/parallel/set_symmetric_difference.cpp", "max_stars_repo_name": "akemp/hpx", "max_stars_repo_head_hexsha": "1ddf7282e322c30d82f2be044071aed14807ebe1", "max_stars_repo_licenses": ["BSL-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/unit/parallel/set_symmetric_difference.cpp", "max_issues_repo_name": "akemp/hpx", "max_issues_repo_head_hexsha": "1ddf7282e322c30d82f2be044071aed14807ebe1", "max_issues_repo_licenses": ["BSL-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/unit/parallel/set_symmetric_difference.cpp", "max_forks_repo_name": "akemp/hpx", "max_forks_repo_head_hexsha": "1ddf7282e322c30d82f2be044071aed14807ebe1", "max_forks_repo_licenses": ["BSL-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6747252747, "max_line_length": 88, "alphanum_fraction": 0.6774889108, "num_tokens": 3808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.4455295350395727, "lm_q2_score": 0.1127954092652892, "lm_q1q2_score": 0.05025368624456261}}
{"text": "#include \"series.h\"\n#define BOOST_TEST_MAIN\n#include <boost/test/unit_test.hpp>\n#include <stdexcept>\n\nusing namespace std;\nnamespace tt = boost::test_tools;\n\nBOOST_AUTO_TEST_CASE(short_digits)\n{\n    const vector<int> expected{0, 1, 2, 3, 4, 5};\n\n    const vector<int> actual{series::digits(\"012345\")};\n\n    BOOST_TEST(expected == actual, tt::per_element());\n}\n\nBOOST_AUTO_TEST_CASE(long_digits)\n{\n    const vector<int> expected{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n\n    const vector<int> actual{series::digits(\"0123456789\")};\n\n    BOOST_TEST(expected == actual, tt::per_element());\n}\n\nBOOST_AUTO_TEST_CASE(keeps_the_digit_order_if_reversed)\n{\n    const vector<int> expected{9, 8, 7, 6, 5, 4, 3, 2, 1, 0};\n\n    const vector<int> actual{series::digits(\"9876543210\")};\n\n    BOOST_TEST(expected == actual, tt::per_element());\n}\n\nBOOST_AUTO_TEST_CASE(keeps_arbitrary_digit_order)\n{\n    const vector<int> expected{9, 3, 6, 9, 2, 3, 4, 6, 8};\n\n    const vector<int> actual{series::digits(\"936923468\")};\n\n    BOOST_TEST(expected == actual, tt::per_element());\n}\n\nBOOST_AUTO_TEST_CASE(can_slice_by_1)\n{\n    const vector<vector<int>> expected{{0}, {1}, {2}, {3}, {4}};\n\n    const vector<vector<int>> actual{series::slice(\"01234\", 1)};\n\n    BOOST_TEST(expected == actual);\n}\n\nBOOST_AUTO_TEST_CASE(can_slice_by_2)\n{\n    const vector<vector<int>> expected{{9, 8}, {8, 2}, {2, 7}, {7, 3}, {3, 4}, {4, 6}, {6, 3}};\n\n    const vector<vector<int>> actual{series::slice(\"98273463\", 2)};\n\n    BOOST_TEST(expected == actual);\n}\n\nBOOST_AUTO_TEST_CASE(can_slice_by_3)\n{\n    const vector<vector<int>> expected{{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};\n\n    const vector<vector<int>> actual{series::slice(\"01234\", 3)};\n\n    BOOST_TEST(expected == actual);\n}\n\nBOOST_AUTO_TEST_CASE(can_slice_by_3_with_duplicate_digits)\n{\n    const vector<vector<int>> expected{{3, 1, 0}, {1, 0, 0}, {0, 0, 1}};\n\n    const vector<vector<int>> actual{series::slice(\"31001\", 3)};\n\n    BOOST_TEST(expected == actual);\n}\n\nBOOST_AUTO_TEST_CASE(can_slice_by_4)\n{\n    const vector<vector<int>> expected{{3, 1, 0}, {1, 0, 0}, {0, 0, 1}};\n\n    const vector<vector<int>> actual{series::slice(\"31001\", 3)};\n\n    BOOST_TEST(expected == actual);\n}\n\nBOOST_AUTO_TEST_CASE(can_slice_by_5)\n{\n    const vector<vector<int>> expected{{8, 1, 2, 2, 8}};\n\n    const vector<vector<int>> actual{series::slice(\"81228\", 5)};\n\n    BOOST_TEST(expected == actual);\n}\n\nBOOST_AUTO_TEST_CASE(domain_error_if_not_enough_digits_to_slice)\n{\n    BOOST_REQUIRE_THROW(series::slice(\"01032987583\", 12), domain_error);\n}\n#if defined(EXERCISM_RUN_ALL_TESTS)\n#endif\n", "meta": {"hexsha": "82bb43579c29fc2af6331143983e4c93098eac8d", "size": 2566, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "series/series_test.cpp", "max_stars_repo_name": "cmccandless/ExercismSolutions-cpp", "max_stars_repo_head_hexsha": "1a97e2a68513a34883b29ed047443b6602e77d3b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "series/series_test.cpp", "max_issues_repo_name": "cmccandless/ExercismSolutions-cpp", "max_issues_repo_head_hexsha": "1a97e2a68513a34883b29ed047443b6602e77d3b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "series/series_test.cpp", "max_forks_repo_name": "cmccandless/ExercismSolutions-cpp", "max_forks_repo_head_hexsha": "1a97e2a68513a34883b29ed047443b6602e77d3b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4380952381, "max_line_length": 95, "alphanum_fraction": 0.6710833983, "num_tokens": 803, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.33458945452352534, "lm_q2_score": 0.15002882624262381, "lm_q1q2_score": 0.05019806313532427}}
{"text": "// featureNormalize.hpp\n#ifndef COURSERA_FEATURENORMALIZE_HPP\n#define COURSERA_FEATURENORMALIZE_HPP\n\n#include <memory>\n#include <armadillo>\n\nvoid featureNormalize(std::shared_ptr<arma::fmat> &X_norm, std::shared_ptr<arma::frowvec> &mu,\n                      std::shared_ptr<arma::frowvec> &sigma, const arma::fmat &X);\n\n#endif // COURSERA_FEATURENORMALIZE_HPP\n", "meta": {"hexsha": "1691fa2aa3c7464fa64183545fe230bb87254311", "size": 360, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "ex1/featureNormalize.hpp", "max_stars_repo_name": "kolbma/coursera-ml", "max_stars_repo_head_hexsha": "a8473829138804cf6a46cc60e076d9851b55ae25", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-11-15T21:08:21.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-15T21:08:21.000Z", "max_issues_repo_path": "ex1/featureNormalize.hpp", "max_issues_repo_name": "kolbma/coursera-ml", "max_issues_repo_head_hexsha": "a8473829138804cf6a46cc60e076d9851b55ae25", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ex1/featureNormalize.hpp", "max_forks_repo_name": "kolbma/coursera-ml", "max_forks_repo_head_hexsha": "a8473829138804cf6a46cc60e076d9851b55ae25", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0, "max_line_length": 94, "alphanum_fraction": 0.7444444444, "num_tokens": 97, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO\n\n", "lm_q1_score": 0.476579651063676, "lm_q2_score": 0.10521054511997295, "lm_q1q2_score": 0.05014120488149585}}
{"text": "/* ----------------------------------------------------------------------------\n\n * GTSAM Copyright 2010, Georgia Tech Research Corporation,\n * Atlanta, Georgia 30332-0415\n * All Rights Reserved\n * Authors: Frank Dellaert, et al. (see THANKS for the full author list)\n\n * See LICENSE for the license information\n\n * -------------------------------------------------------------------------- */\n\n/**\n *  @file   testCameraSet.cpp\n *  @brief  Unit tests for testCameraSet Class\n *  @author Frank Dellaert\n *  @date   Feb 19, 2015\n */\n\n#include <gtsam/geometry/CameraSet.h>\n#include <gtsam/geometry/Pose3.h>\n#include <gtsam/base/numericalDerivative.h>\n#include <CppUnitLite/TestHarness.h>\n#include <boost/bind.hpp>\n\nusing namespace std;\nusing namespace gtsam;\n\n/* ************************************************************************* */\n// Cal3Bundler test\n#include <gtsam/geometry/PinholeCamera.h>\n#include <gtsam/geometry/Cal3Bundler.h>\nTEST(CameraSet, Pinhole) {\n  typedef PinholeCamera<Cal3Bundler> Camera;\n  typedef CameraSet<Camera> Set;\n  typedef Point2Vector ZZ;\n  Set set;\n  Camera camera;\n  set.push_back(camera);\n  set.push_back(camera);\n  Point3 p(0, 0, 1);\n  EXPECT(assert_equal(set, set));\n  Set set2 = set;\n  set2.push_back(camera);\n  EXPECT(!set.equals(set2));\n\n  // Check measurements\n  Point2 expected(0,0);\n  ZZ z = set.project2(p);\n  EXPECT(assert_equal(expected, z[0]));\n  EXPECT(assert_equal(expected, z[1]));\n\n  // Calculate expected derivatives using Pinhole\n  Matrix actualE;\n  Matrix29 F1;\n  {\n    Matrix23 E1;\n    camera.project2(p, F1, E1);\n    actualE.resize(4,3);\n    actualE << E1, E1;\n  }\n\n  // Check computed derivatives\n  Set::FBlocks Fs;\n  Matrix E;\n  set.project2(p, Fs, E);\n  LONGS_EQUAL(2, Fs.size());\n  EXPECT(assert_equal(F1, Fs[0]));\n  EXPECT(assert_equal(F1, Fs[1]));\n  EXPECT(assert_equal(actualE, E));\n\n  // Check errors\n  ZZ measured;\n  measured.push_back(Point2(1, 2));\n  measured.push_back(Point2(3, 4));\n  Vector4 expectedV;\n\n  // reprojectionError\n  expectedV << -1, -2, -3, -4;\n  Vector actualV = set.reprojectionError(p, measured);\n  EXPECT(assert_equal(expectedV, actualV));\n\n  // Check Schur complement\n  Matrix F(4, 18);\n  F << F1, Matrix29::Zero(), Matrix29::Zero(), F1;\n  Matrix Ft = F.transpose();\n  Matrix34 Et = E.transpose();\n  Matrix3 P = Et * E;\n  Matrix schur(19, 19);\n  Vector4 b = actualV;\n  Vector v = Ft * (b - E * P * Et * b);\n  schur << Ft * F - Ft * E * P * Et * F, v, v.transpose(), 30;\n  SymmetricBlockMatrix actualReduced = Set::SchurComplement<3>(Fs, E, P, b);\n  EXPECT(assert_equal(schur, actualReduced.selfadjointView()));\n\n  // Check Schur complement update, same order, should just double\n  KeyVector allKeys {1, 2}, keys {1, 2};\n  Set::UpdateSchurComplement<3>(Fs, E, P, b, allKeys, keys, actualReduced);\n  EXPECT(assert_equal((Matrix )(2.0 * schur), actualReduced.selfadjointView()));\n\n  // Check Schur complement update, keys reversed\n  KeyVector keys2 {2, 1};\n  Set::UpdateSchurComplement<3>(Fs, E, P, b, allKeys, keys2, actualReduced);\n  Vector4 reverse_b;\n  reverse_b << b.tail<2>(), b.head<2>();\n  Vector reverse_v = Ft * (reverse_b - E * P * Et * reverse_b);\n  Matrix A(19, 19);\n  A << Ft * F - Ft * E * P * Et * F, reverse_v, reverse_v.transpose(), 30;\n  EXPECT(assert_equal((Matrix )(2.0 * schur + A), actualReduced.selfadjointView()));\n\n  // reprojectionErrorAtInfinity\n  Unit3 pointAtInfinity(0, 0, 1000);\n  EXPECT(\n      assert_equal(pointAtInfinity,\n          camera.backprojectPointAtInfinity(Point2(0,0))));\n  actualV = set.reprojectionError(pointAtInfinity, measured, Fs, E);\n  EXPECT(assert_equal(expectedV, actualV));\n  LONGS_EQUAL(2, Fs.size());\n  {\n    Matrix22 E1;\n    camera.project2(pointAtInfinity, F1, E1);\n    actualE.resize(4,2);\n    actualE << E1, E1;\n  }\n  EXPECT(assert_equal(F1, Fs[0]));\n  EXPECT(assert_equal(F1, Fs[1]));\n  EXPECT(assert_equal(actualE, E));\n}\n\n/* ************************************************************************* */\n#include <gtsam/geometry/StereoCamera.h>\nTEST(CameraSet, Stereo) {\n  CameraSet<StereoCamera> set;\n  typedef StereoCamera::MeasurementVector ZZ;\n  StereoCamera camera;\n  set.push_back(camera);\n  set.push_back(camera);\n  Point3 p(0, 0, 1);\n  EXPECT_LONGS_EQUAL(6, traits<StereoCamera>::dimension);\n\n  // Check measurements\n  StereoPoint2 expected(0, -1, 0);\n  ZZ z = set.project2(p);\n  EXPECT(assert_equal(expected, z[0]));\n  EXPECT(assert_equal(expected, z[1]));\n\n  // Calculate expected derivatives using Pinhole\n  Matrix63 actualE;\n  Matrix F1;\n  {\n    Matrix33 E1;\n    camera.project2(p, F1, E1);\n    actualE << E1, E1;\n  }\n\n  // Check computed derivatives\n  CameraSet<StereoCamera>::FBlocks Fs;\n  Matrix E;\n  set.project2(p, Fs, E);\n  LONGS_EQUAL(2, Fs.size());\n  EXPECT(assert_equal(F1, Fs[0]));\n  EXPECT(assert_equal(F1, Fs[1]));\n  EXPECT(assert_equal(actualE, E));\n}\n\n/* ************************************************************************* */\nint main() {\n  TestResult tr;\n  return TestRegistry::runAllTests(tr);\n}\n/* ************************************************************************* */\n\n", "meta": {"hexsha": "60cee59ee1a215d88c161b674a25c9c1fc224101", "size": 5060, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "gtsam/geometry/tests/testCameraSet.cpp", "max_stars_repo_name": "kvmanohar22/gtsam", "max_stars_repo_head_hexsha": "8194b931fe07fb1bd346cdcf116a35f9c4e208ba", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 14.0, "max_stars_repo_stars_event_min_datetime": "2019-12-11T18:33:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T04:52:45.000Z", "max_issues_repo_path": "gtsam/geometry/tests/testCameraSet.cpp", "max_issues_repo_name": "kvmanohar22/gtsam", "max_issues_repo_head_hexsha": "8194b931fe07fb1bd346cdcf116a35f9c4e208ba", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6.0, "max_issues_repo_issues_event_min_datetime": "2019-10-30T21:17:33.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-18T18:47:40.000Z", "max_forks_repo_path": "gtsam/geometry/tests/testCameraSet.cpp", "max_forks_repo_name": "kvmanohar22/gtsam", "max_forks_repo_head_hexsha": "8194b931fe07fb1bd346cdcf116a35f9c4e208ba", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 5.0, "max_forks_repo_forks_event_min_datetime": "2020-01-09T16:24:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-24T11:10:49.000Z", "avg_line_length": 29.4186046512, "max_line_length": 84, "alphanum_fraction": 0.616798419, "num_tokens": 1417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.476579651063676, "lm_q2_score": 0.10521054371715848, "lm_q1q2_score": 0.05014120421294301}}
{"text": "/*\n * @file\n * @author University of Warwick\n * @version 1.0\n *\n * @section LICENSE\n *\n * @section DESCRIPTION\n *\n * Serial Unit Tests for the LinearSolverPETSc Class\n */\n\n#define BOOST_TEST_MODULE LinearSolverPETScParallel\n#include <boost/test/unit_test.hpp>\n#include <boost/test/output_test_stream.hpp>\n#include <stdexcept>\n\n#include \"LinearSolverPETScParallel.h\"\n#include \"Error.h\"\n#include \"SparseMatrixCOO.h\"\n#include <iostream>\n\nusing namespace cupcfd::linearsolvers;\n\n// Setup\nBOOST_AUTO_TEST_CASE(setup)\n{\n    int argc = boost::unit_test::framework::master_test_suite().argc;\n    char ** argv = boost::unit_test::framework::master_test_suite().argv;\n\n    MPI_Init(&argc, &argv);\n\tPetscInitialize(&argc, &argv, NULL, NULL);\n}\n\n// ============== Constructors ===================\n// Test 1: Check values are probably defaulted to their null states\nBOOST_AUTO_TEST_CASE(constructor_test1)\n{\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.a != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.mLocal, 0);\n\tBOOST_CHECK_EQUAL(solver.nLocal, 0);\n\tBOOST_CHECK_EQUAL(solver.mGlobal, 0);\n\tBOOST_CHECK_EQUAL(solver.nGlobal, 0);\n\n\tBOOST_CHECK_EQUAL(solver.xRanges, static_cast<decltype(solver.xRanges)>(nullptr));\n\tBOOST_CHECK_EQUAL(solver.bRanges, static_cast<decltype(solver.bRanges)>(nullptr));\n\tBOOST_CHECK_EQUAL(solver.aRanges, static_cast<decltype(solver.aRanges)>(nullptr));\n}\n\n// ============== setupVectorX ===================\n// Test 1: Check Vector is created if a suitable row size is set\nBOOST_AUTO_TEST_CASE(setupVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorX();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorX();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorX();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorX();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.x == PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tPetscInt cmp[5] = {0, 5, 10, 15, 20};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 5, solver.xRanges, solver.xRanges + 5);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// Test 2: Check error if a suitable row size is not set - e.g. 0\nBOOST_AUTO_TEST_CASE(setupVectorX_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 0;\n\tsolver.mGlobal = 0;\n\n\t// Test and Check\n\tstatus = solver.setupVectorX();\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Check error if the communicator is not set to PETSC_COMM_SELF\n// ToDo\nBOOST_AUTO_TEST_CASE(setupVectorX_test3)\n{\n\n}\n\n// ============== resetVectorX ===================\n// Test 1: Test the successful reset of a existing vector\nBOOST_AUTO_TEST_CASE(resetVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\t//Setup\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 5;\n\tsolver.mGlobal = 20;\n\n\t// Create the vector\n\tstatus = solver.setupVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.resetVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.xRanges, static_cast<decltype(solver.xRanges)>(nullptr));\n}\n\n// Test 2: Test the successful reset of a non-existing vector (i.e. no\n// change, but no error either).\nBOOST_AUTO_TEST_CASE(resetVectorX_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\t// === Setup ===\n\n\t// Check it is unset for the test\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// === Test and Check ===\n\tstatus = solver.resetVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.x != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n}\n\n\n// ============== setupVectorB ===================\n// Test 1: Check Vector is created if a suitable row size is set\nBOOST_AUTO_TEST_CASE(setupVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\tif(comm.rank == 0)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorB();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorB();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorB();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\t// Manually set row size so it is valid\n\t\tsolver.mLocal = 5;\n\t\tsolver.mGlobal = 20;\n\n\t\t// Test and Check\n\t\tstatus = solver.setupVectorB();\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Workaround - seems OK to compare these in C++,\n\t// but BOOST doesn't like making the comparison\n\tif(solver.b == PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tPetscInt cmp[5] = {0, 5, 10, 15, 20};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 5, solver.bRanges, solver.bRanges + 5);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// Test 2: Check error if a suitable row size is not set - e.g. 0\nBOOST_AUTO_TEST_CASE(setupVectorB_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 0;\n\tsolver.mGlobal = 0;\n\n\t// Test and Check\n\tstatus = solver.setupVectorB();\n\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_ROW_SIZE_UNSET);\n}\n\n// Test 3: Check error if the communicator is not set to PETSC_COMM_SELF\n// ToDo\nBOOST_AUTO_TEST_CASE(setupVectorB_test3)\n{\n\n}\n\n// ============== resetVectorB ===================\n// Test 1: Test the successful reset of a existing vector\nBOOST_AUTO_TEST_CASE(resetVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\t//Setup\n\n\t// Manually set row size so it is valid\n\tsolver.mLocal = 5;\n\tsolver.mGlobal = 20;\n\n\t// Create the vector\n\tstatus = solver.setupVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.resetVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\tBOOST_CHECK_EQUAL(solver.bRanges, static_cast<decltype(solver.bRanges)>(nullptr));\n}\n\n// Test 2: Test the successful reset of a non-existing vector (i.e. no\n// change, but no error either).\nBOOST_AUTO_TEST_CASE(resetVectorB_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Since we are not using setup, manually set the petsc communicator for now\n\tcupcfd::mpi::drivers::set_comm(solver.comm, MPI_COMM_WORLD);\n\n\t// === Setup ===\n\n\t// Check it is unset for the test\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n\n\t// === Test and Check ===\n\tstatus = solver.resetVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tif(solver.b != PETSC_NULL)\n\t{\n\t\tBOOST_CHECK_EQUAL(true, false);\n\t}\n}\n\n// ============== setupMatrixA ===================\n// Test 1: Test setup of PETSc matrix from a SparseCOO matrix\nBOOST_AUTO_TEST_CASE(setupMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix, with data distributed across the four ranks\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 4; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 8; i < 10; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 11; i < 13; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// ToDo: Technically, we let PETSc decide this so it could change.....\n\t// We're just assuming that 2 is a fair distribution\n\t//PetscInt cmp[5] = {0, 2, 4, 6, 8};\n\t//BOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 5, solver.aRanges, solver.aRanges + 5);\n\n\t// ToDo: Ideally would like to check PETSc internal nnz structure of matrix\n}\n\n// ============== resetMatrixA ===================\n//Test 1: Check the matrix is correctly reset after being setup\nBOOST_AUTO_TEST_CASE(resetMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 4; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 8; i < 10; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 11; i < 13; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Setup Matrix\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check Reset\n\tstatus = solver.resetMatrixA();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Check range array has been reset\n\tBOOST_CHECK_EQUAL(solver.aRanges, static_cast<decltype(solver.aRanges)>(nullptr));\n}\n\n// Test 2: Check the matrix reset function does not error when\n// no matrix is yet setup\nBOOST_AUTO_TEST_CASE(resetMatrixA_test2)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Test and Check Reset\n\tstatus = solver.resetMatrixA();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// ToDo\n// Test 3: There should be an error code for PETSc errors\nBOOST_AUTO_TEST_CASE(resetMatrixA_test3)\n{\n\n}\n\n// ============== setup ===========\n// Test 1: Test the successful setup of the object from a matrix\nBOOST_AUTO_TEST_CASE(setup_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 4; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 8; i < 10; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 11; i < 13; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// ============== reset ===========\n// Test 1: Test a successful reset after the object has been setup\nBOOST_AUTO_TEST_CASE(reset_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 4; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 8; i < 10; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 11; i < 13; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = solver.reset();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// Test 2: Test a successful reset if the object is still in an unset state\nBOOST_AUTO_TEST_CASE(reset_test2)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\tstatus = solver.reset();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n// ============== setValuesVectorX(T scalar) ===========\n// Test 1: Test setting the entire vector to a specific scalar\n// Ideally want to check value using getter, but will\n// use PETSc function directly to keep function tests separate\nBOOST_AUTO_TEST_CASE(setValuesVectorX_scalar_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 2;\n\tsolver.nLocal = 2;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\tsolver.comm = comm;\n\n\t// Create Vector\n\tstatus = solver.setupVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorX(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Any position should hold the value 2.4\n\tif(comm.rank == 2)\n\t{\n\t\tPetscInt pos = 5;\n\t\tPetscScalar result;\n\t\tVecGetValues(solver.x, 1, &pos, &result);\n\t\tBOOST_CHECK_EQUAL(result, 2.4);\n\t}\n\n\t// Second check in different position to ensure more than one was updated\n\tif(comm.rank == 3)\n\t{\n\t\tPetscInt pos = 7;\n\t\tPetscScalar result = 0.0;\n\t\tVecGetValues(solver.x, 1, &pos, &result);\n\t\tBOOST_CHECK_EQUAL(result, 2.4);\n\t}\n}\n\n// Test 2: Check for error when vector does not exist\nBOOST_AUTO_TEST_CASE(setValuesVectorX_scalar_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorX(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n// ============== setValuesVectorX(T * scalars, int nScalars) ===========\n// Test 1: Test setting values at specific locations, across different processors\nBOOST_AUTO_TEST_CASE(setValuesVectorX_indexedscalars_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 2;\n\tsolver.nLocal = 2;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\tsolver.comm = comm;\n\n\t// Create Vector\n\tstatus = solver.setupVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint indices[4] = {0, 3, 4, 7};\n\tdouble values[4] = {0.5, 0.7, 0.2, 0.3};\n\n\tif(comm.rank == 0)\n\t{\n\t\tstatus = solver.setValuesVectorX(values, 1, indices, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tstatus = solver.setValuesVectorX(values + 1, 1, indices + 1, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tstatus = solver.setValuesVectorX(values + 2, 1, indices + 2, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tstatus = solver.setValuesVectorX(values + 3, 1, indices + 3, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Assuming each process is allocated two rows each here...\n\tif(comm.rank == 0)\n\t{\n\t\tPetscInt pos[2] = {0, 1};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.x, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.5, 0.0};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tPetscInt pos[2] = {2, 3};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.x, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.0, 0.7};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tPetscInt pos[2] = {4, 5};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.x, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.2, 0.0};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tPetscInt pos[2] = {6, 7};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.x, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n}\n\n// ============== setValuesVectorB(T scalar) ===========\n// Test 1: Test setting the entire vector to a specific scalar\n// Ideally want to check value using getter, but will\n// use PETSc function directly to keep function tests separate\nBOOST_AUTO_TEST_CASE(setValuesVectorB_scalar_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 2;\n\tsolver.nLocal = 2;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\tsolver.comm = comm;\n\n\t// Create Vector\n\tstatus = solver.setupVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorB(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Any position should hold the value 2.4\n\tif(comm.rank == 2)\n\t{\n\t\tPetscInt pos = 5;\n\t\tPetscScalar result;\n\t\tVecGetValues(solver.b, 1, &pos, &result);\n\t\tBOOST_CHECK_EQUAL(result, 2.4);\n\t}\n\n\t// Second check in different position to ensure more than one was updated\n\tif(comm.rank == 3)\n\t{\n\t\tPetscInt pos = 7;\n\t\tPetscScalar result = 0.0;\n\t\tVecGetValues(solver.b, 1, &pos, &result);\n\t\tBOOST_CHECK_EQUAL(result, 2.4);\n\t}\n}\n\n// Test 2: Check for error when vector does not exist\nBOOST_AUTO_TEST_CASE(setValuesVectorB_scalar_test2)\n{\n\tcupcfd::error::eCodes status;\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// Test and Check\n\tstatus = solver.setValuesVectorB(2.4);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_LINEARSOLVER_INVALID_VECTOR);\n}\n\n\n// ============== setValuesVectorB(T * scalars, int nScalars) ===========\n// Test 1: Test setting values at specific locations, across different processors\nBOOST_AUTO_TEST_CASE(setValuesVectorB_indexedscalars_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 2;\n\tsolver.nLocal = 2;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\tsolver.comm = comm;\n\n\t// Create Vector\n\tstatus = solver.setupVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint indices[4] = {0, 3, 4, 7};\n\tdouble values[4] = {0.5, 0.7, 0.2, 0.3};\n\n\tif(comm.rank == 0)\n\t{\n\t\tstatus = solver.setValuesVectorB(values, 1, indices, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tstatus = solver.setValuesVectorB(values + 1, 1, indices + 1, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tstatus = solver.setValuesVectorB(values + 2, 1, indices + 2, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tstatus = solver.setValuesVectorB(values + 3, 1, indices + 3, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Assuming each process is allocated two rows each here...\n\tif(comm.rank == 0)\n\t{\n\t\tPetscInt pos[2] = {0, 1};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.b, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.5, 0.0};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tPetscInt pos[2] = {2, 3};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.b, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.0, 0.7};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tPetscInt pos[2] = {4, 5};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.b, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.2, 0.0};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tPetscInt pos[2] = {6, 7};\n\t\tPetscScalar result[2];\n\t\tVecGetValues(solver.b, 2, pos, result);\n\n\t\tPetscScalar cmp[2] = {0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 2, result, result + 2);\n\t}\n}\n\n// ============== setValuesMatrixA ===========\n// Test 1: Test the successful setup of the object from a matrix\nBOOST_AUTO_TEST_CASE(setValuesMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 4; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 8; i < 10; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 11; i < 13; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// ToDo: Best way to check contents of matrix in PETSc?\n\t// Could get local matrix contents for each rank\n}\n\n\n\n// ============== getValuesVectorX ===========\nBOOST_AUTO_TEST_CASE(getValuesVectorX_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 2;\n\tsolver.nLocal = 2;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\tsolver.comm = comm;\n\n\t// Create Vector\n\tstatus = solver.setupVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint indices[4] = {0, 3, 4, 7};\n\tdouble values[4] = {0.5, 0.7, 0.2, 0.3};\n\n\tif(comm.rank == 0)\n\t{\n\t\tstatus = solver.setValuesVectorX(values, 1, indices, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tstatus = solver.setValuesVectorX(values + 1, 1, indices + 1, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tstatus = solver.setValuesVectorX(values + 2, 1, indices + 2, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tstatus = solver.setValuesVectorX(values + 3, 1, indices + 3, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Test and Check\n\t// Everyone get's a copy of the entire vector\n\tdouble * result;\n\tint nResult;\n\n\tstatus = solver.getValuesVectorX(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 8);\n\n\t// Assuming each process is allocated two rows each here...\n\tif(comm.rank == 0)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n}\n\n\n// ============== getValuesVectorXIndexes ===========\n// ToDo\n\n// ============== getValuesVectorB ===========\nBOOST_AUTO_TEST_CASE(getValuesVectorB_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\n\t// Set the row and col sizes\n\tsolver.mLocal = 2;\n\tsolver.nLocal = 2;\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\tsolver.comm = comm;\n\n\t// Create Vector\n\tstatus = solver.setupVectorB();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Test and Check\n\tint indices[4] = {0, 3, 4, 7};\n\tdouble values[4] = {0.5, 0.7, 0.2, 0.3};\n\n\tif(comm.rank == 0)\n\t{\n\t\tstatus = solver.setValuesVectorB(values, 1, indices, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tstatus = solver.setValuesVectorB(values + 1, 1, indices + 1, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tstatus = solver.setValuesVectorB(values + 2, 1, indices + 2, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tstatus = solver.setValuesVectorB(values + 3, 1, indices + 3, 1, 0);\n\t\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\t}\n\n\t// Test and Check\n\t// Everyone get's a copy of the entire vector\n\tdouble * result;\n\tint nResult;\n\n\tstatus = solver.getValuesVectorB(&result, &nResult);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\tBOOST_CHECK_EQUAL(nResult, 8);\n\n\t// Assuming each process is allocated two rows each here...\n\tif(comm.rank == 0)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tPetscScalar cmp[8] = {0.5, 0.0, 0.0, 0.7,0.2, 0.0, 0.0, 0.3};\n\t\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, result, result + 8);\n\t}\n}\n\n// ============== getValuesVectorBIndexes ===========\n// ToDo\n\n// ============== getValuesMatrixA ===========\n// ToDo\n\n// ============== clearVectorX ===========\n// ToDo\n\n// ============== clearVectorB ===========\n// ToDo\n\n// ============== clearMatrixA ===========\nBOOST_AUTO_TEST_CASE(clearMatrixA_test1)\n{\n\t// ToDo\n}\n\n// ============== resetSolverSelection ===========\nBOOST_AUTO_TEST_CASE(resetSolverSelection_test1)\n{\n\t// ToDo\n}\n\n// ============== setSolverSelection ===========\nBOOST_AUTO_TEST_CASE(setSolverSelection_test1)\n{\n\t// ToDo\n}\n\n// ============== resetTolerances ===========\nBOOST_AUTO_TEST_CASE(resetTolerances_test1)\n{\n\t// ToDo\n}\n\n// ============== resetPETScSolver ===========\n// Test 1: Test that we can reset when the KSP solver is not setup\nBOOST_AUTO_TEST_CASE(resetPETScSolver_test1)\n{\n\t// ToDo\n}\n\n// Test 2: Test that we can reset when the KSP Solver is setup\nBOOST_AUTO_TEST_CASE(resetPETScSolver_test2)\n{\n\t// ToDo\n}\n\n// ============== setupPETScSolver ===========\nBOOST_AUTO_TEST_CASE(setupPETScSolver_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[13] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7};\n\tint cols[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7};\n\tdouble vals[13] = {0.1, 0.2, 0.1, 0.05, 0.07, 0.09, 0.06, 0.1, 0.15, 0.23, 0.11, 0.13, 0.09};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 4; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 8; i < 10; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 11; i < 13; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\n\t\tsolver.mLocal = 2;\n\t\tsolver.nLocal = 2;\n\t}\n\n\tsolver.mGlobal = 8;\n\tsolver.nGlobal = 8;\n\n\t// Test and Check\n\tstatus = solver.setupMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tsolver.petscSolverSelection = PETSC_SOLVER_CGAMG;\n\n\t// Test and Check\n\tstatus = solver.setupPETScSolver();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n}\n\n\n// ============== solveMatrixA ===========\nBOOST_AUTO_TEST_CASE(solveMatrixA_test1)\n{\n\tcupcfd::error::eCodes status;\n\tcupcfd::mpi::Communicator comm;\n\tcupcfd::mpi::drivers::set_comm(comm, MPI_COMM_WORLD);\n\n\tLinearSolverPETScParallel<double> solver;\n\n\t// === Setup ===\n\t// Create a simple SparseMatrix\n\tcupcfd::data_structures::matrices::SparseMatrixCOO<int, double> matrix(8, 8, 0);\n\n\tint rows[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\tint cols[8] = {0, 1, 2, 3, 4, 5, 6, 7};\n\tdouble vals[8] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8};\n\n\tif(comm.rank == 0)\n\t{\n\t\tfor(int i = 0; i < 2; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 1)\n\t{\n\t\tfor(int i = 2; i < 4; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 2)\n\t{\n\t\tfor(int i = 4; i < 6; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\telse if(comm.rank == 3)\n\t{\n\t\tfor(int i = 6; i < 8; i++)\n\t\t{\n\t\t\tmatrix.setElement(rows[i], cols[i], vals[i]);\n\t\t}\n\t}\n\n\t// Setup the data structures of the solver\n\tstatus = solver.setup(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Set some suitable values for a very small test solve\n\tstatus = solver.setValuesMatrixA(matrix);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tstatus = solver.setValuesVectorB(0.1);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Clear the X Vector\n\tstatus = solver.clearVectorX();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Set the solver type\n\tstatus = solver.setSolverSelection(PETSC_SOLVER_CGAMG);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tsolver.setTolerances(0.0, 0.0);\n\n\t// Test and Check\n\t// Run the solve\n\tstatus = solver.solve();\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\t// Get the contents of Vector X\n\tdouble * vecX;\n\tint nVecX;\n\n\tstatus = solver.getValuesVectorX(&vecX, &nVecX);\n\tBOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);\n\n\tdouble cmp[8] = {1, 0.5, 0.33333333333333337, 0.25, 0.2, 0.16666666666666669, 0.14285714285714288, 0.125};\n\tBOOST_CHECK_EQUAL_COLLECTIONS(cmp, cmp + 8, vecX, vecX + 8);\n}\n\n\nBOOST_AUTO_TEST_CASE(cleanup)\n{\n\tPetscFinalize();\n    MPI_Finalize();\n}\n", "meta": {"hexsha": "c7d50d99cbd64e703899d76218b58cc61e4c9a14", "size": 35371, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "tests/linearsolvers/classes/LinearSolverPETScParallelTests.cpp", "max_stars_repo_name": "thorbenlouw/CUP-CFD", "max_stars_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3.0, "max_stars_repo_stars_event_min_datetime": "2021-06-24T10:20:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-18T14:43:19.000Z", "max_issues_repo_path": "tests/linearsolvers/classes/LinearSolverPETScParallelTests.cpp", "max_issues_repo_name": "thorbenlouw/CUP-CFD", "max_issues_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2.0, "max_issues_repo_issues_event_min_datetime": "2021-07-22T15:31:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-28T14:27:28.000Z", "max_forks_repo_path": "tests/linearsolvers/classes/LinearSolverPETScParallelTests.cpp", "max_forks_repo_name": "thorbenlouw/CUP-CFD", "max_forks_repo_head_hexsha": "d06f7673a1ed12bef24de4f1b828ef864fa45958", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2021-07-22T15:24:24.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-22T15:24:24.000Z", "avg_line_length": 24.9442877292, "max_line_length": 107, "alphanum_fraction": 0.6637641005, "num_tokens": 11772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. NO\n2. NO", "lm_q1_score": 0.43782349911420193, "lm_q2_score": 0.11436853221906972, "lm_q1q2_score": 0.05007323096470844}}
