diff --git a/.github/workflows/R-CMD-check-macOS.yml b/.github/workflows/R-CMD-check-macOS.yml index 23ac6d616..b1ac281c3 100644 --- a/.github/workflows/R-CMD-check-macOS.yml +++ b/.github/workflows/R-CMD-check-macOS.yml @@ -41,12 +41,17 @@ jobs: - name: Install dependencies run: Rscript -e "install.packages(c('devtools', dependencies=TRUE))" -e "install.packages(c('rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'testthat', 'downloader', 'xfun'))"; + - name: Checkout Rvolesti repository + run: git clone https://github.com/GeomScale/Rvolesti.git; + + - name: Upgrade with current develop of volesti + run: cp -rf include Rvolesti/src/volesti; + cp -rf external Rvolesti/src; + - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: cd cran_gen/; - Rscript genCRANpkg.R; - cd cran_package; + run: cd Rvolesti/; Rscript -e "library(rcmdcheck)" -e "rcmdcheck::rcmdcheck(args = c('--no-manual'), error_on = 'warning', check_dir = 'check')" - name: Upload check results diff --git a/.github/workflows/R-CMD-check-ubuntu.yml b/.github/workflows/R-CMD-check-ubuntu.yml index 645396120..753ee114a 100644 --- a/.github/workflows/R-CMD-check-ubuntu.yml +++ b/.github/workflows/R-CMD-check-ubuntu.yml @@ -22,8 +22,8 @@ jobs: config: - {os: ubuntu-latest, r: 'devel'} - {os: ubuntu-latest, r: 'release'} - - {os: ubuntu-18.04, r: 'devel'} - - {os: ubuntu-18.04, r: 'release'} + - {os: ubuntu-20.04, r: 'devel'} + - {os: ubuntu-20.04, r: 'release'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true @@ -44,12 +44,17 @@ jobs: - name: Install dependencies run: Rscript -e "install.packages(c('testthat', 'pkgload', 'rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'downloader', 'xfun', dependencies=TRUE))"; + - name: Checkout Rvolesti repository + run: git clone https://github.com/GeomScale/Rvolesti.git; + + - name: Upgrade with current develop of volesti + run: cp -rf include Rvolesti/src/volesti; + cp -rf external Rvolesti/src; + - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: cd cran_gen/; - Rscript genCRANpkg.R; - cd cran_package; + run: cd Rvolesti/; Rscript -e "library(rcmdcheck)" -e "rcmdcheck::rcmdcheck(args = c('--no-manual'), error_on = 'warning', check_dir = 'check')" - name: Upload check results diff --git a/.github/workflows/R-CMD-check-windows.yml b/.github/workflows/R-CMD-check-windows.yml index ad56a7170..97e725aa0 100644 --- a/.github/workflows/R-CMD-check-windows.yml +++ b/.github/workflows/R-CMD-check-windows.yml @@ -40,12 +40,17 @@ jobs: - name: Install dependencies run: Rscript -e "install.packages(c('devtools', dependencies=TRUE))" -e "install.packages(c('rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'testthat', 'downloader', 'xfun'))" + - name: Checkout Rvolesti repository + run: git clone https://github.com/GeomScale/Rvolesti.git; + + - name: Upgrade with current develop of volesti + run: cp -r -fo include Rvolesti/src/volesti; + cp -r -fo external Rvolesti/src; + - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: cd cran_gen/; - Rscript genCRANpkg.R; - cd cran_package; + run: cd Rvolesti/; Rscript -e "library(rcmdcheck)" -e "rcmdcheck::rcmdcheck(args = c('--no-manual'), error_on = 'warning', check_dir = 'check')" - name: Upload check results diff --git a/.github/workflows/cmake-clang.yml b/.github/workflows/cmake-clang.yml index caa22fff2..520b33159 100644 --- a/.github/workflows/cmake-clang.yml +++ b/.github/workflows/cmake-clang.yml @@ -30,7 +30,7 @@ jobs: steps: - uses: actions/checkout@v1 - run: sudo apt-get update || true; - sudo apt-get install ${{ matrix.config.compiler_pkg }} lp-solve; + sudo apt-get install ${{ matrix.config.compiler_pkg }} lp-solve libopenblas-dev; rm -rf build; mkdir build; cd build; diff --git a/.github/workflows/cmake-gcc.yml b/.github/workflows/cmake-gcc.yml index e42805492..f18e358ac 100644 --- a/.github/workflows/cmake-gcc.yml +++ b/.github/workflows/cmake-gcc.yml @@ -29,7 +29,7 @@ jobs: steps: - uses: actions/checkout@v1 - run: sudo apt-get update || true; - sudo apt-get install ${{ matrix.config.compiler }} lp-solve; + sudo apt-get install ${{ matrix.config.compiler }} lp-solve libopenblas-dev; rm -rf build; mkdir build; cd build; diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 09827eb16..272634eb9 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at . All +reported by contacting the project team at geomscale@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/R-proj/DESCRIPTION b/R-proj/DESCRIPTION deleted file mode 100644 index ce188ad22..000000000 --- a/R-proj/DESCRIPTION +++ /dev/null @@ -1,23 +0,0 @@ -Package: volesti -Type: Package -License: LGPL-3 -Title: Volume Approximation and Sampling of Convex Polytopes -Author: Vissarion Fisikopoulos [aut, cph, cre], - Apostolos Chalkis [cph, aut], - contributors in file inst/AUTHORS -Copyright: file inst/COPYRIGHTS -Description: Provides an R interface for 'volesti' C++ package. 'volesti' computes estimations of volume - of polytopes given by (i) a set of points, (ii) linear inequalities or (iii) Minkowski sum of segments - (a.k.a. zonotopes). There are three algorithms for volume estimation as well as algorithms - for sampling, rounding and rotating polytopes. Moreover, 'volesti' provides algorithms for - estimating copulas useful in computational finance. -Version: 1.1.2 -Date: 2020-10-24 -Maintainer: Vissarion Fisikopoulos -Depends: Rcpp (>= 0.12.17) -Imports: methods, stats -LinkingTo: Rcpp, RcppEigen, BH -Suggests: testthat -Encoding: UTF-8 -RoxygenNote: 7.1.1 -BugReports: https://github.com/GeomScale/volume_approximation/issues diff --git a/R-proj/NAMESPACE b/R-proj/NAMESPACE deleted file mode 100644 index 085d9ed9f..000000000 --- a/R-proj/NAMESPACE +++ /dev/null @@ -1,42 +0,0 @@ -# Generated by roxygen2: do not edit by hand - -export(compute_indicators) -export(copula) -export(dinvweibull_with_loc) -export(direct_sampling) -export(ess) -export(estimtate_lipschitz_constant) -export(exact_vol) -export(file_to_polytope) -export(frustum_of_simplex) -export(gen_birkhoff) -export(gen_cross) -export(gen_cube) -export(gen_prod_simplex) -export(gen_rand_hpoly) -export(gen_rand_vpoly) -export(gen_rand_zonotope) -export(gen_simplex) -export(gen_skinny_cube) -export(geweke) -export(inner_ball) -export(loadSdpaFormatFile) -export(ode_solve) -export(pinvweibull_with_loc) -export(psrf_multivariate) -export(psrf_univariate) -export(raftery) -export(readSdpaFormatFile) -export(rotate_polytope) -export(round_polytope) -export(sample_points) -export(volume) -export(writeSdpaFormatFile) -export(zonotope_approximation) -exportPattern("^[[:alpha:]]+") -importFrom("methods","new") -importFrom("stats","cov") -importFrom("utils","read.csv") -importFrom(Rcpp,evalCpp) -importFrom(Rcpp,loadModule) -useDynLib(volesti, .registration=TRUE) diff --git a/R-proj/R/RcppExports.R b/R-proj/R/RcppExports.R deleted file mode 100644 index 5713d11a3..000000000 --- a/R-proj/R/RcppExports.R +++ /dev/null @@ -1,464 +0,0 @@ -# Generated by using Rcpp::compileAttributes() -> do not edit by hand -# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#' Construct a copula using uniform sampling from the unit simplex -#' -#' Given two families of parallel hyperplanes or a family of parallel hyperplanes and a family of concentric ellispoids centered at the origin intersecting the canonical simplex, this function uniformly samples from the canonical simplex and construct an approximation of the bivariate probability distribution, called copula (see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}). -#' At least two families of hyperplanes or one family of hyperplanes and one family of ellipsoids have to be given as input. -#' -#' @param r1 The \eqn{d}-dimensional normal vector of the first family of parallel hyperplanes. -#' @param r2 Optional. The \eqn{d}-dimensional normal vector of the second family of parallel hyperplanes. -#' @param sigma Optional. The \eqn{d\times d} symmetric positive semidefine matrix that describes the family of concentric ellipsoids centered at the origin. -#' @param m The number of the slices for the copula. The default value is 100. -#' @param n The number of points to sample. The default value is \eqn{5\cdot 10^5}. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -#' \dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -#' -#' @return A \eqn{m\times m} numerical matrix that corresponds to a copula. -#' @examples -#' # compute a copula for two random families of parallel hyperplanes -#' h1 = runif(n = 10, min = 1, max = 1000) -#' h1 = h1 / 1000 -#' h2=runif(n = 10, min = 1, max = 1000) -#' h2 = h2 / 1000 -#' cop = copula(r1 = h1, r2 = h2, m = 10, n = 100000) -#' -#' # compute a copula for a family of parallel hyperplanes and a family of conentric ellipsoids -#' h = runif(n = 10, min = 1, max = 1000) -#' h = h / 1000 -#' E = replicate(10, rnorm(20)) -#' E = cov(E) -#' cop = copula(r1 = h, sigma = E, m = 10, n = 100000) -#' -#' @export -copula <- function(r1, r2 = NULL, sigma = NULL, m = NULL, n = NULL, seed = NULL) { - .Call(`_volesti_copula`, r1, r2, sigma, m, n, seed) -} - -#' Sample perfect uniformly distributed points from well known convex bodies: (a) the unit simplex, (b) the canonical simplex, (c) the boundary of a hypersphere or (d) the interior of a hypersphere. -#' -#' The \eqn{d}-dimensional unit simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i\leq 1}, \eqn{x_i\geq 0}. The \eqn{d}-dimensional canonical simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i = 1}, \eqn{x_i\geq 0}. -#' -#' @param body A list to request exact uniform sampling from special well known convex bodies through the following input parameters: -#' \itemize{ -#' \item{\code{type} }{ A string that declares the type of the body for the exact sampling: a) \code{'unit_simplex'} for the unit simplex, b) \code{'canonical_simplex'} for the canonical simplex, c) \code{'hypersphere'} for the boundary of a hypersphere centered at the origin, d) \code{'ball'} for the interior of a hypersphere centered at the origin.} -#' \item{\code{dimension} }{ An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.} -#' \item{\code{radius} }{ The radius of the \eqn{d}-dimensional hypersphere. The default value is \eqn{1}.} -#' } -#' @param n The number of points that the function is going to sample. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{R.Y. Rubinstein and B. Melamed, -#' \dQuote{Modern simulation and modeling} \emph{ Wiley Series in Probability and Statistics,} 1998.} -#' @references \cite{A Smith, Noah and W Tromble, Roy, -#' \dQuote{Sampling Uniformly from the Unit Simplex,} \emph{ Center for Language and Speech Processing Johns Hopkins University,} 2004.} -#' -#' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -#' @examples -#' # 100 uniform points from the 2-d unit ball -#' points = direct_sampling(n = 100, body = list("type" = "ball", "dimension" = 2)) -#' @export -direct_sampling <- function(body, n, seed = NULL) { - .Call(`_volesti_direct_sampling`, body, n, seed) -} - -#' Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' -#' @references \cite{Gelman, A. and Rubin, D. B., -#' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -#' -#' @references \cite{Brooks, S. and Gelman, A., -#' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -#' -#' @return A vector that contains the values of PSRF for each coordinate -#' -#' @export -ess <- function(samples) { - .Call(`_volesti_ess`, samples) -} - -#' Compute the exact volume of (a) a zonotope (b) an arbitrary simplex in V-representation or (c) if the volume is known and declared by the input object. -#' -#' Given a zonotope (as an object of class Zonotope), this function computes the sum of the absolute values of the determinants of all the \eqn{d \times d} submatrices of the \eqn{m\times d} matrix \eqn{G} that contains row-wise the \eqn{m} \eqn{d}-dimensional segments that define the zonotope. -#' For an arbitrary simplex that is given in V-representation this function computes the absolute value of the determinant formed by the simplex's points assuming it is shifted to the origin. -#' -#' @param P A polytope -#' -#' @references \cite{E. Gover and N. Krikorian, -#' \dQuote{Determinants and the Volumes of Parallelotopes and Zonotopes,} \emph{Linear Algebra and its Applications, 433(1), 28 - 40,} 2010.} -#' -#' @return The exact volume of the input polytope, for zonotopes, simplices in V-representation and polytopes with known exact volume -#' @examples -#' -#' # compute the exact volume of a 5-dimensional zonotope defined by the Minkowski sum of 10 segments -#' Z = gen_rand_zonotope(2, 5) -#' vol = exact_vol(Z) -#' -#' \donttest{# compute the exact volume of a 2-d arbitrary simplex -#' V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE) -#' P = Vpolytope$new(V) -#' vol = exact_vol(P) -#' } -#' -#' # compute the exact volume the 10-dimensional cross polytope -#' P = gen_cross(10,'V') -#' vol = exact_vol(P) -#' @export -exact_vol <- function(P) { - .Call(`_volesti_exact_vol`, P) -} - -#' Compute the percentage of the volume of the simplex that is contained in the intersection of a half-space and the simplex. -#' -#' A half-space \eqn{H} is given as a pair of a vector \eqn{a\in R^d} and a scalar \eqn{z0\in R} s.t.: \eqn{a^Tx\leq z0}. This function calls the Ali's version of the Varsi formula to compute a frustum of the simplex. -#' -#' @param a A \eqn{d}-dimensional vector that defines the direction of the hyperplane. -#' @param z0 The scalar that defines the half-space. -#' -#' @references \cite{Varsi, Giulio, -#' \dQuote{The multidimensional content of the frustum of the simplex,} \emph{Pacific J. Math. 46, no. 1, 303--314,} 1973.} -#' -#' @references \cite{Ali, Mir M., -#' \dQuote{Content of the frustum of a simplex,} \emph{ Pacific J. Math. 48, no. 2, 313--322,} 1973.} -#' -#' @return The percentage of the volume of the simplex that is contained in the intersection of a given half-space and the simplex. -#' -#' @examples -#' # compute the frustum of H: -x1+x2<=0 -#' a=c(-1,1) -#' z0=0 -#' frustum = frustum_of_simplex(a, z0) -#' @export -frustum_of_simplex <- function(a, z0) { - .Call(`_volesti_frustum_of_simplex`, a, z0) -} - -#' Geweke's MCMC diagnostic -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' @param frac_first Optional. The portion of the first in order points in matrix samples. -#' @param frac_last Optional. The portion of the last in order points in matrix samples. -#' -#' @references \cite{Geweke, J., -#' \dQuote{Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,} \emph{ In Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -#' -#' @return A boolean to denote if the result of Geweke diagnostic: (i) false if the null hypothesis is rejected, (ii) true if the null hypothesis is not rejected. -#' -#' @export -geweke <- function(samples, frac_first = NULL, frac_last = NULL) { - .Call(`_volesti_geweke`, samples, frac_first, frac_last) -} - -#' Compute an inscribed ball of a convex polytope -#' -#' For a H-polytope described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }, this function computes the largest inscribed ball (Chebychev ball) by solving the corresponding linear program. -#' For both zonotopes and V-polytopes the function computes the minimum \eqn{r} s.t.: \eqn{ r e_i \in P} for all \eqn{i=1, \dots ,d}. Then the ball centered at the origin with radius \eqn{r/ \sqrt{d}} is an inscribed ball. -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -#' @param lpsolve Optional. A boolean variable to compute the Chebychev ball of an H-polytope using the lpsolve library. -#' -#' @return A \eqn{(d+1)}-dimensional vector that describes the inscribed ball. The first \eqn{d} coordinates corresponds to the center of the ball and the last one to the radius. -#' -#' @examples -#' # compute the Chebychev ball of the 2d unit simplex -#' P = gen_cube(10,'H') -#' ball_vec = inner_ball(P) -#' -#' # compute an inscribed ball of the 3-dimensional unit cube in V-representation -#' P = gen_cube(3, 'V') -#' ball_vec = inner_ball(P, lpsolve = TRUE) -#' @export -inner_ball <- function(P, lpsolve = NULL) { - .Call(`_volesti_inner_ball`, P, lpsolve) -} - -#' Solve an ODE of the form dx^n / dt^n = F(x, t) -#' -#' @param n The number of steps. -#' @param step_size The step size. -#' @param order The ODE order (default is n = 1) -#' @param dimension The dimension of each derivative -#' @param initial_time The initial time -#' @param F The function oracle F(x, t) in the ODE. -#' @param method The method to be used -#' @param initial_conditions The initial conditions provided to the solver. Must be provided in a list with keys "x_1", ..., "x_n" and column vectors as values. The state "x_n" represents the (n-1)-th order derivative with respect to time -#' @param domains A list of n H-polytopes with keys "P_1", "P_2", ..., "P_n" that correspond to each derivative's domain -#' -#' @return A list which contains elements "x_1", ..., "x_n" representing each derivative results. Each "x_i" corresponds to a d x n matrix where each column represents a certain timestep of the solver. -#' -#' @examples -#' # Please visit the examples directory on examples demonstrating usage of the ODE solvers. -#' -#' @export -ode_solve <- function(n, step_size, order, dimension, initial_time, F, method, domains = NULL, initial_conditions = NULL) { - .Call(`_volesti_ode_solve`, n, step_size, order, dimension, initial_time, F, method, domains, initial_conditions) -} - -#' An internal Rccp function as a polytope generator -#' -#' @param kind_gen An integer to declare the type of the polytope. -#' @param Vpoly_gen A boolean parameter to declare if the requested polytope has to be in V-representation. -#' @param Zono_gen A boolean parameter to declare if the requested polytope has to be a zonotope. -#' @param dim_gen An integer to declare the dimension of the requested polytope. -#' @param m_gen An integer to declare the number of generators for the requested random zonotope or the number of vertices for a V-polytope. -#' @param seed Optional. A fixed seed for the random polytope generator. -#' -#' @keywords internal -#' -#' @return A numerical matrix describing the requested polytope -poly_gen <- function(kind_gen, Vpoly_gen, Zono_gen, dim_gen, m_gen, seed = NULL) { - .Call(`_volesti_poly_gen`, kind_gen, Vpoly_gen, Zono_gen, dim_gen, m_gen, seed) -} - -#' Gelman-Rubin Potential Scale Reduction Factor (PSRF) -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' -#' @references \cite{Gelman, A. and Rubin, D. B., -#' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -#' -#' @references \cite{Brooks, S. and Gelman, A., -#' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -#' -#' @return The value of multivariate PSRF by S. Brooks and A. Gelman. -#' -#' @export -psrf_multivariate <- function(samples) { - .Call(`_volesti_psrf_multivariate`, samples) -} - -#' Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' @param method A string to reauest diagnostic: (i) \code{'normal'} for psrf of Gelman-Rubin and (ii) \code{'interval'} for psrf of Brooks-Gelman. -#' -#' @references \cite{Gelman, A. and Rubin, D. B., -#' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -#' -#' @references \cite{Brooks, S. and Gelman, A., -#' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -#' -#' @return A vector that contains the values of PSRF for each coordinate -#' -#' @export -psrf_univariate <- function(samples, method = NULL) { - .Call(`_volesti_psrf_univariate`, samples, method) -} - -#' Raftery and Lewis MCMC diagnostic -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' @param q Optional. The quantile of the quantity of interest. The default value is 0.025. -#' @param r Optional. The level of precision desired. The default value is 0.01. -#' @param s Optional. The probability associated with r. The default value is 0.95. -#' -#' @references \cite{Raftery, A. E. and Lewis, S. M., -#' \dQuote{How many iterations in the Gibbs sampler?,} \emph{Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -#' -#' @return (i) The number of draws required for burn-in, (ii) the skip parameter for 1st-order Markov chain, (iii) the skip parameter sufficient to get independence chain, (iv) the number of draws required to achieve r precision, (v) the number of draws if the chain is white noise, (vi) the I-statistic from Raftery and Lewis (1992). -#' -#' @export -raftery <- function(samples, q = NULL, r = NULL, s = NULL) { - .Call(`_volesti_raftery`, samples, q, r, s) -} - -#' An internal Rccp function for the random rotation of a convex polytope -#' -#' @param P A convex polytope (H-, V-polytope or a zonotope). -#' @param T Optional. A rotation matrix. -#' @param seed Optional. A fixed seed for the random linear map generator. -#' -#' @keywords internal -#' -#' @return A matrix that describes the rotated polytope -rotating <- function(P, T = NULL, seed = NULL) { - .Call(`_volesti_rotating`, P, T, seed) -} - -#' Internal rcpp function for the rounding of a convex polytope -#' -#' @param P A convex polytope (H- or V-representation or zonotope). -#' @param method Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a uniform sample from P, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid in P, (c) \code{'isotropy'} for the method based on isotropy. The default method is \code{'min_ellipsoid'} for all the representations. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @keywords internal -#' -#' @return A numerical matrix that describes the rounded polytope, a numerical matrix of the inverse linear transofmation that is applied on the input polytope, the numerical vector the the input polytope is shifted and the determinant of the matrix of the linear transformation that is applied on the input polytope. -rounding <- function(P, method = NULL, seed = NULL) { - .Call(`_volesti_rounding`, P, method, seed) -} - -#' Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -#' @param n The number of points that the function is going to sample from the convex polytope. -#' @param random_walk Optional. A list that declares the random walk and some related parameters as follows: -#' \itemize{ -#' \item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR x) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave densities) xi) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method xii) \code{'ExactHMC'} for exact Hamiltonian Monte Carlo with reflections (spherical Gaussian or exponential distribution). The default walk is \code{'aBiW'} for the uniform distribution or \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes.} -#' \item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.} -#' \item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.} -#' \item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.} -#' \item{\code{BaW_rad} }{ The radius for the ball walk.} -#' \item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.} -#' \item{\code{solver} }{ Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson} -#' \item{\code{step_size }{ Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.} -#' } -#' @param distribution Optional. A list that declares the target density and some related parameters as follows: -#' \itemize{ -#' \item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution c) \code{logconcave} with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex d) \code{'exponential'} for the exponential distribution. The default target distribution is the uniform distribution.} -#' \item{\code{variance} }{ The variance of the multidimensional spherical gaussian or the exponential distribution. The default value is 1.} -#' \item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.} -#' \item{\code{bias} }{ The bias vector for the exponential distribution. The default vector is \eqn{c_1 = 1} and \eqn{c_i = 0} for \eqn{i \neq 1}.} -#' \item{\code{L_} }{ Smoothness constant (for logconcave). } -#' \item{\code{m} }{ Strong-convexity constant (for logconcave). } -#' \item{\code{negative_logprob} }{ Negative log-probability (for logconcave). } -#' \item{\code{negative_logprob_gradient} }{ Negative log-probability gradient (for logconcave). } -#' } -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{Robert L. Smith, -#' \dQuote{Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions,} \emph{Operations Research,} 1984.}, -#' -#' @references \cite{B.T. Polyak, E.N. Gryazina, -#' \dQuote{Billiard walk - a new sampling algorithm for control and optimization,} \emph{IFAC Proceedings Volumes,} 2014.}, -#' -#' @references \cite{Y. Chen, R. Dwivedi, M. J. Wainwright and B. Yu, -#' \dQuote{Fast MCMC Sampling Algorithms on Polytopes,} \emph{Journal of Machine Learning Research,} 2018.} -#' -#' @references \cite{Lee, Yin Tat, Ruoqi Shen, and Kevin Tian, -#' \dQuote{"Logsmooth Gradient Concentration and Tighter Runtimes for Metropolized Hamiltonian Monte Carlo,"} \emph{arXiv preprint arXiv:2002.04121}, 2020.} -#' -#' @references \cite{Shen, Ruoqi, and Yin Tat Lee, -#' \dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.} -#' -#' @references \cite{Augustin Chevallier, Sylvain Pion, Frederic Cazals, -#' \dQuote{"Hamiltonian Monte Carlo with boundary reflections, and application to polytope volume calculations,"} \emph{Research Report preprint hal-01919855}, 2018.} -#' -#' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -#' @examples -#' # uniform distribution from the 3d unit cube in H-representation using ball walk -#' P = gen_cube(3, 'H') -#' points = sample_points(P, n = 100, random_walk = list("walk" = "BaW", "walk_length" = 5)) -#' -#' # gaussian distribution from the 2d unit simplex in H-representation with variance = 2 -#' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) -#' b = c(0,0,1) -#' P = Hpolytope$new(A,b) -#' points = sample_points(P, n = 100, distribution = list("density" = "gaussian", "variance" = 2)) -#' -#' # uniform points from the boundary of a 2-dimensional random H-polytope -#' P = gen_rand_hpoly(2,20) -#' points = sample_points(P, n = 100, random_walk = list("walk" = "BRDHR")) -#' -#' # For sampling from logconcave densities see the examples directory -#' -#' @export -sample_points <- function(P, n, random_walk = NULL, distribution = NULL, seed = NULL) { - .Call(`_volesti_sample_points`, P, n, random_walk, distribution, seed) -} - -#' @export -sample_spectra <- function(file = NULL, N = NULL, walk_length = NULL) { - .Call(`_volesti_sample_spectra`, file, N, walk_length) -} - -#' Write a SDPA format file -#' -#' Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function) -#' to a SDPA format file. -#' -#' @param spectrahedron A spectrahedron in n dimensions; must be an object of class Spectrahedron -#' @param objectiveFunction A numerical vector of length n -#' @param outputFile Name of the output file -#' -#' @examples -#' \dontrun{ -#' A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) -#' A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) -#' A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) -#' lmi = list(A0, A1, A2) -#' S = Spectrahedron$new(lmi); -#' objFunction = c(1,1) -#' writeSdpaFormatFile(S, objFunction, "output.txt") -#' } -#' @export -writeSdpaFormatFile <- function(spectrahedron = NULL, objectiveFunction = NULL, outputFile = NULL) { - invisible(.Call(`_volesti_writeSdpaFormatFile`, spectrahedron, objectiveFunction, outputFile)) -} - -#' Read a SDPA format file -#' -#' @param inputFile Name of the input file -#' -#' @return A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction" -#' -#' @examples -#' path = system.file('extdata', package = 'volesti') -#' l = loadSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -#' @export -loadSdpaFormatFile <- function(inputFile = NULL) { - .Call(`_volesti_loadSdpaFormatFile`, inputFile) -} - -#' The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). It returns a list with two elements: (a) the logarithm of the estimated volume and (b) the estimated volume -#' -#' For the volume approximation can be used three algorithms. Either CoolingBodies (CB) or SequenceOfBalls (SOB) or CoolingGaussian (CG). An H-polytope with \eqn{m} facets is described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which correspond to the vertices of P. A zonotope is desrcibed by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -#' -#' @param P A convex polytope. It is an object from class a) Hpolytope or b) Vpolytope or c) Zonotope or d) VpolytopeIntersection. -#' @param settings Optional. A list that declares which algorithm, random walk and values of parameters to use, as follows: -#' \itemize{ -#' \item{\code{algorithm} }{ A string to set the algorithm to use: a) \code{'CB'} for CB algorithm, b) \code{'SoB'} for SOB algorithm or b) \code{'CG'} for CG algorithm. The defalut algorithm is \code{'CB'}.} -#' \item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{1} for SOB algorithm and \eqn{0.1} otherwise.} -#' \item{\code{random_walk} }{ A string that declares the random walk method: a) \code{'CDHR'} for Coordinate Directions Hit-and-Run, b) \code{'RDHR'} for Random Directions Hit-and-Run, c) \code{'BaW'} for Ball Walk, or \code{'BiW'} for Billiard walk. For CB algorithm the default walk is \code{'BiW'}. For CG and SOB algorithms the default walk is \code{'CDHR'} for H-polytopes and \code{'RDHR'} for the other representations.} -#' \item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{\lfloor 10 + d/10\rfloor} for \code{'SOB'} and \eqn{1} otherwise.} -#' \item{\code{win_len} }{ The length of the sliding window for CB or CG algorithm. The default value is \eqn{250} for CB with BiW and \eqn{400+3d^2} for CB and any other random walk and \eqn{500+4d^2} for CG.} -#' \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm when the input polytope is a zonotope. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -#' } -#' @param rounding Optional. A string parameter to request a rounding method to be applied in the input polytope before volume computation: a) \code{'min_ellipsoid'}, b) \code{'svd'}, c) \code{'max_ellipsoid'} and d) \code{'none'} for no rounding. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{I.Z.Emiris and V. Fisikopoulos, -#' \dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, -#' @references \cite{A. Chalkis and I.Z.Emiris and V. Fisikopoulos, -#' \dQuote{Practical Volume Estimation by a New Annealing Schedule for Cooling Convex Bodies,} \emph{CoRR, abs/1905.05494,} 2019.}, -#' @references \cite{B. Cousins and S. Vempala, \dQuote{A practical volume algorithm,} \emph{Springer-Verlag Berlin Heidelberg and The Mathematical Programming Society,} 2015.} -#' -#' -#' @return The approximation of the volume of a convex polytope. -#' @examples -#' -#' # calling SOB algorithm for a H-polytope (5d unit simplex) -#' HP = gen_cube(5,'H') -#' pair_vol = volume(HP) -#' -#' # calling CG algorithm for a V-polytope (3d simplex) -#' VP = gen_simplex(3,'V') -#' pair_vol = volume(VP, settings = list("algorithm" = "CG")) -#' -#' # calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments -#' Z = gen_rand_zonotope(2, 4) -#' pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2)) -#' -#' @export -volume <- function(P, settings = NULL, rounding = NULL, seed = NULL) { - .Call(`_volesti_volume`, P, settings, rounding, seed) -} - -#' An internal Rccp function for the over-approximation of a zonotope -#' -#' @param Z A zonotope. -#' @param fit_ratio Optional. A boolean parameter to request the computation of the ratio of fitness. -#' @param settings Optional. A list that declares the values of the parameters of CB algorithm. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @keywords internal -#' -#' @return A List that contains a numerical matrix that describes the PCA approximation as a H-polytope and the ratio of fitness. -zono_approx <- function(Z, fit_ratio = NULL, settings = NULL, seed = NULL) { - .Call(`_volesti_zono_approx`, Z, fit_ratio, settings, seed) -} - diff --git a/R-proj/R/compute_indicators.R b/R-proj/R/compute_indicators.R deleted file mode 100644 index fe82cdee3..000000000 --- a/R-proj/R/compute_indicators.R +++ /dev/null @@ -1,104 +0,0 @@ -#' Compute an indicator for each time period that describes the state of a market. -#' -#' Given a matrix that contains row-wise the assets' returns and a sliding window \code{win_length}, this function computes an approximation of the joint distribution (copula, e.g. see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}) between portfolios' return and volatility in each time period defined by \code{win_len}. -#' For each copula it computes an indicator: If the indicator is large it corresponds to a crisis period and if it is small it corresponds to a normal period. -#' In particular, the periods over which the indicator is greater than 1 for more than 60 consecutive sliding windows are warnings and for more than 100 are crisis. The sliding window is shifted by one day. -#' -#' @param returns A \eqn{d}-dimensional vector that describes the direction of the first family of parallel hyperplanes. -#' @param win_length Optional. The length of the sliding window. The default value is 60. -#' @param m Optional. The number of slices for the copula. The default value is 100. -#' @param n Optional. The number of points to sample. The default value is \eqn{5\cdot 10^5}. -#' @param nwarning Optional. The number of consecutive indicators larger than 1 required to declare a warning period. The default value is 60. -#' @param ncrisis Optional. The number of consecutive indicators larger than 1 required to declare a crisis period. The default value is 100. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -#' \dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -#' -#' @return A list that contains the indicators and the corresponding vector that label each time period with respect to the market state: a) normal, b) crisis, c) warning. -#' -#' @examples -#' # simple example on random asset returns -#' asset_returns = replicate(10, rnorm(14)) -#' market_states_and_indicators = compute_indicators(asset_returns, 10, 10, 10000, 2, 3) -#' -#' @export -compute_indicators <- function(returns, win_length = NULL, m = NULL, n = NULL, nwarning = NULL, ncrisis = NULL, seed = NULL) { - - if (is.null(win_length)) win_length = 60 - if (is.null(m)) m = 100 - if (is.null(n)) n = 500000 - if (is.null(nwarning)) nwarning = 60 - if (is.null(ncrisis)) ncrisis = 100 - - nrows = dim(returns)[1] - nassets = dim(returns)[2] - wl = win_length-1 - - indicators = c() - for (i in 1:(nrows-wl)) { - - Win=i:(i+wl) - E = cov(returns[Win,]) - - compRet = rep(1,nassets) - for (j in 1:nassets) { - for (k in Win) { - compRet[j] = compRet[j] * (1 + returns[k, j]) - } - compRet[j] = compRet[j] - 1 - } - - cop = copula(r1 = compRet, sigma = E, m = m, n = n, seed = seed) - blue_mass = 0 - red_mass = 0 - - for (row in 1:m) { - for (col in 1:m) { - if (row-col<=0.2*m && row-col>=-0.2*m) { - if (row+col<0.8*m || row+col>1.2*m) { - red_mass = red_mass + cop[row,col] - } - } else { - if (row+col>=0.8*m+1 && row+col<=1.2*m+1) { - blue_mass = blue_mass + cop[row,col] - } - } - } - } - indicators = c(indicators, blue_mass / red_mass) - } - - N = length(indicators) - - index = 0 - set_index = FALSE - col = rep("normal", N) - - for (i in 1:N) { - - if(indicators[i]>1 && !set_index){ - index = i - set_index = TRUE - } else if (indicators[i]<1) { - if(set_index){ - if(i-index > nwarning-1 && i-index <= ncrisis-1){ - col[index:(i-1)] = "warning" - } else if(i-index > ncrisis-1) { - col[index:(i-1)] = "crisis" - } - } - set_index = FALSE - } - } - if(set_index){ - if(N-index+1 > nwarning-1 && N-index+1 <= ncrisis-1){ - col[index:i] = "warning" - } else if(N-index+1 > ncrisis-1) { - col[index:i] = "crisis" - } - } - - return(list("indicators" = indicators, market_states = col)) - -} diff --git a/R-proj/R/estimate_lipschitz_constant.R b/R-proj/R/estimate_lipschitz_constant.R deleted file mode 100644 index c1fac15e0..000000000 --- a/R-proj/R/estimate_lipschitz_constant.R +++ /dev/null @@ -1,53 +0,0 @@ -#' Inverse weibull distribution PDF with location parameter -#' @param x The argument of the PDF -#' @param k The shape parameter -#' @param lambda The scale parameter -#' @param theta The location parameter -#' -#' @return The value of the PDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at x -#' @export -dinvweibull_with_loc <- function (x, k, lambda, theta) { - return ((k / lambda) * ((x - theta) / lambda)^(k - 1) * exp(- ((x - theta) / lambda)^k) * as.double(x >= 0)) -} - -#' Inverse weibull distribution CDF with location parameter -#' @param q The argument of the CDF -#' @param k The shape parameter -#' @param lambda The scale parameter -#' @param theta The location parameter -#' -#' @return The value of the CDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at q -#' @export -pinvweibull_with_loc <- function (q, k, lambda, theta) { - return ((1 - exp(-((q - theta) / lambda)^k)) * as.double(q >= 0)) -} - - -#' Estimate the Lipschitz Constant of a function f -#' -#' @param f Function whose Lipschitz constant is to be estimated -#' @param P Domain of f (a convex polytope) -#' @param n Number of samples to take -#' -#' The procedure draws n uniform samples from P and evaluates the Lipschitz -#' constant at subsequent samples (where the sampler moves to a new point), -#' It then returns the maximum observation -#' -#' @return An estimate of the Lipschitz constant -#' -#' @export -estimtate_lipschitz_constant <- function (f, P, n) { - points = volesti::sample_points(P, n = 1000, random_walk = list("walk" = "BaW", "walk_length" = 1)) - l = matrix(0, 1, n-1) - - for (i in seq(n-1)) { - l[1, i] <- norm(as.matrix(f(points[,i+1])) - as.matrix(f(points[,i])), type='F') / norm(as.matrix(points[,i+1]) - as.matrix(points[,i]), type='F') - } - - na_cols <- is.nan(l[1,]) - - l <- as.matrix(l[1, !na_cols]) - - # TODO Implement weibull distribution fitting method to estimate the Lipschitz constant - return(max(l)) -} \ No newline at end of file diff --git a/R-proj/R/file_to_polytope.R b/R-proj/R/file_to_polytope.R deleted file mode 100644 index 19dd61acf..000000000 --- a/R-proj/R/file_to_polytope.R +++ /dev/null @@ -1,113 +0,0 @@ -#' function to get an ine or an ext file and returns the corresponding polytope -#' -#' For an ".ine" file it generates the corresponding H-polytope. For an ".ext" file it generates the corresponding V-polytope or zonotope. -#' For more details on those file formats see \url{https://github.com/GeomScale/volume_approximation/blob/develop/doc/cpp_interface.md#polytope-input}. -#' -#' @param path A string that containes the path to an ine or a ext file. The ine file desrcibes a H-polytope and ext file describes a V-polytope or a zonotope. -#' @param zonotope A boolean parameter. It has to be TRUE when the path leads to an .ext file that describes a zonotope. -#' -#' @return A polytope class. If the path corresponds to an ine file then the return value represents a H-polytope. If it corresponds to an ext file the return value represents a V-polytope (default choice) or a zonotope if the second argument is TRUE. -#' -#' @export -#' @useDynLib volesti, .registration=TRUE -#' @importFrom Rcpp evalCpp -#' @importFrom Rcpp loadModule -#' @importFrom "utils" "read.csv" -#' @importFrom "stats" "cov" -#' @importFrom "methods" "new" -#' @exportPattern "^[[:alpha:]]+" -file_to_polytope <- function(path, zonotope = FALSE){ - - ineorext=substr(path, start = nchar(path) - 2, stop = nchar(path)) - if(ineorext!="ine" && ineorext!="ext") { - stop("Only ine or ext files can be handled by this function!") - } - P = read.csv(path) - r = as.character(P[3,1]) - count_sp = 1 - str = "" - beg = 0 - for (j in 1:nchar(r)) { - if (substr(r, start=j, stop=j) == " ") { - beg = beg + 1 - } else { - break - } - } - for (i in seq(from= beg + 1, to=nchar(r), by=1)) { - if (substr(r, start=i, stop=i) == " ") { - if (count_sp == 1) { - m = as.numeric(str) - str = "" - count_sp = count_sp + 1 - } else { - d = as.numeric(str) - str = "" - break - } - } else { - str = paste0(str, substr(r, start=i, stop=i)) - } - } - A = rep(0,d) - A[1] = m - A[2] = d - newrow = rep(0,d) - for (i in 4:(dim(P)[1] - 2)) { - r = P[i,1] - r = as.character(r) - str = "" - count = 1 - beg = 0 - for (j in 1:nchar(r)) { - if(substr(r, start=j, stop=j)==" "){ - beg = beg + 1 - } else { - break - } - } - sp_bef = FALSE - for (j in seq(from=beg + 1, to=nchar(r), by=1)) { - if (substr(r, start=j, stop=j) == " "){ - if (sp_bef) { - next - } - sp_bef = TRUE - newrow[count] = as.numeric(str) - str = "" - count = count + 1 - } else { - str = paste0(str, substr(r, start=j, stop=j)) - sp_bef = FALSE - if (j == nchar(r)) { - newrow[count] = as.numeric(str) - } - } - } - A = rbind(A,newrow) - newrow = rep(0,d) - } - A = matrix(A, ncol=dim(A)[2]) # now matrix A is in ine or ext format - - # remove first row - A = A[-c(1),] - - # first column is the vector b - b = A[,1] - - # remove first column - A2 = A[,-c(1)] - - if(ineorext=="ine") { - P = Hpolytope$new(-A2,b) - } else { - if(!missing(zonotope)){ - if(zonotope) { - P = Zonotope$new(A2) - return(P) - } - } - P = Vpolytope$new(A2) - } - return(P) -} diff --git a/R-proj/R/gen_birkhoff.R b/R-proj/R/gen_birkhoff.R deleted file mode 100644 index 935f637e2..000000000 --- a/R-proj/R/gen_birkhoff.R +++ /dev/null @@ -1,28 +0,0 @@ -#' Generator function for Birkhoff polytope -#' -#' This function can be used to generate the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -#' The dimension of the generated polytope is \eqn{(n-1)^2}. -#' -#' @param n The order of the Birkhoff polytope -#' -#' @return A polytope class representing the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -#' @examples -#' # generate the Birkhoff polytope of order 5 -#' P = gen_birkhoff(5) -#' @export -gen_birkhoff <- function(n) { - - kind_gen = 7 - m_gen = 0 - - Mat = poly_gen(kind_gen, FALSE, FALSE, n, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(Mat, b) - - return(P) - -} diff --git a/R-proj/R/gen_cross.R b/R-proj/R/gen_cross.R deleted file mode 100644 index d782f3991..000000000 --- a/R-proj/R/gen_cross.R +++ /dev/null @@ -1,41 +0,0 @@ -#' Generator function for cross polytopes -#' -#' This function generates the \eqn{d}-dimensional cross polytope in H- or V-representation. -#' -#' @param dimension The dimension of the cross polytope. -#' @param representation A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation. -#' -#' @return A polytope class representing a cross polytope in H- or V-representation. -#' @examples -#' # generate a 10-dimensional cross polytope in H-representation -#' P = gen_cross(5, 'H') -#' -#' # generate a 15-dimension cross polytope in V-representation -#' P = gen_cross(15, 'V') -#' @export -gen_cross <- function(dimension, representation) { - - kind_gen = 2 - m_gen = 0 - if (representation == "V") { - Vpoly_gen = TRUE - } else if (representation == "H") { - Vpoly_gen = FALSE - } else { - stop('Not a known representation.') - } - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - if (Vpoly_gen) { - P = Vpolytope$new(Mat, 2^dimension / prod(1:dimension)) - } else { - P = Hpolytope$new(-Mat, b, 2^dimension / prod(1:dimension)) - } - - return(P) -} diff --git a/R-proj/R/gen_cube.R b/R-proj/R/gen_cube.R deleted file mode 100644 index bcbf1f025..000000000 --- a/R-proj/R/gen_cube.R +++ /dev/null @@ -1,41 +0,0 @@ -#' Generator function for hypercubes -#' -#' This function generates the \eqn{d}-dimensional unit hypercube \eqn{[-1,1]^d} in H- or V-representation. -#' -#' @param dimension The dimension of the hypercube -#' @param representation A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation. -#' -#' @return A polytope class representing the unit \eqn{d}-dimensional hypercube in H- or V-representation. -#' @examples -#' # generate a 10-dimensional hypercube in H-representation -#' P = gen_cube(10, 'H') -#' -#' # generate a 15-dimension hypercube in V-representation -#' P = gen_cube(5, 'V') -#' @export -gen_cube <- function(dimension, representation) { - - kind_gen = 1 - m_gen = 0 - if (representation == "V") { - Vpoly_gen = TRUE - } else if (representation == "H") { - Vpoly_gen = FALSE - } else { - stop('Not a known representation.') - } - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - if (Vpoly_gen) { - P = Vpolytope$new(Mat, 2^dimension) - } else { - P = Hpolytope$new(-Mat, b, 2^dimension) - } - - return(P) - -} diff --git a/R-proj/R/gen_prod_simplex.R b/R-proj/R/gen_prod_simplex.R deleted file mode 100644 index a0505880c..000000000 --- a/R-proj/R/gen_prod_simplex.R +++ /dev/null @@ -1,29 +0,0 @@ -#' Generator function for product of simplices -#' -#' This function generates a \eqn{2d}-dimensional polytope that is defined as the product of two \eqn{d}-dimensional unit simplices in H-representation. -#' -#' @param dimension The dimension of the simplices. -#' -#' @return A polytope class representing the product of the two \eqn{d}-dimensional unit simplices in H-representation. -#' -#' @examples -#' # generate a product of two 5-dimensional simplices. -#' P = gen_prod_simplex(5) -#' @export -gen_prod_simplex <- function(dimension) { - - kind_gen = 4 - m_gen = 0 - Vpoly_gen = FALSE - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(-Mat, b, (1/prod(1:dimension))^2) - - return(P) - -} diff --git a/R-proj/R/gen_rand_hpoly.R b/R-proj/R/gen_rand_hpoly.R deleted file mode 100644 index 2785a28b4..000000000 --- a/R-proj/R/gen_rand_hpoly.R +++ /dev/null @@ -1,28 +0,0 @@ -#' Generator function for random H-polytopes -#' -#' This function generates a \eqn{d}-dimensional polytope in H-representation with \eqn{m} facets. We pick \eqn{m} random hyperplanes tangent on the \eqn{d}-dimensional unit hypersphere as facets. -#' -#' @param dimension The dimension of the convex polytope. -#' @param nfacets The number of the facets. -#' @param seed Optional. A fixed seed for the generator. -#' -#' @return A polytope class representing a H-polytope. -#' @examples -#' # generate a 10-dimensional polytope with 50 facets -#' P = gen_rand_hpoly(10, 50) -#' @export -gen_rand_hpoly <- function(dimension, nfacets, seed = NULL) { - - kind_gen = 6 - Vpoly_gen = FALSE - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, nfacets, seed) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(Mat, b) - - return(P) -} diff --git a/R-proj/R/gen_rand_vpoly.R b/R-proj/R/gen_rand_vpoly.R deleted file mode 100644 index 31cc561c0..000000000 --- a/R-proj/R/gen_rand_vpoly.R +++ /dev/null @@ -1,36 +0,0 @@ -#' Generator function for random V-polytopes -#' -#' This function generates a \eqn{d}-dimensional polytope in V-representation with \eqn{m} vertices. We pick \eqn{m} random points from the boundary of the \eqn{d}-dimensional unit hypersphere as vertices. -#' -#' @param dimension The dimension of the convex polytope. -#' @param nvertices The number of the vertices. -#' @param generator The body that the generator samples uniformly the vertices from: (a) 'cube' or (b) 'sphere'. -#' @param seed Optional. A fixed seed for the generator. -#' -#' @return A polytope class representing a V-polytope. -#' @examples -#' # generate a 10-dimensional polytope defined as the convex hull of 25 random vertices -#' P = gen_rand_vpoly(10, 25) -#' @export -gen_rand_vpoly <- function(dimension, nvertices, generator = NULL, seed = NULL) { - - kind_gen = 4 - - if(!is.null(generator)){ - if (generator == 'cube'){ - kind_gen = 5 - } else if (generator != 'sphere') { - stop("Wrong generator!") - } - } - - Mat = poly_gen(kind_gen, TRUE, FALSE, dimension, nvertices, seed) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Vpolytope$new(Mat) - - return(P) -} diff --git a/R-proj/R/gen_rand_zonotope.R b/R-proj/R/gen_rand_zonotope.R deleted file mode 100644 index 3a2c8c1b2..000000000 --- a/R-proj/R/gen_rand_zonotope.R +++ /dev/null @@ -1,40 +0,0 @@ -#' Generator function for zonotopes -#' -#' This function generates a random \eqn{d}-dimensional zonotope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -#' The function considers \eqn{m} random directions in \eqn{R^d}. There are three strategies to pick the length of each segment: a) it is uniformly sampled from \eqn{[0,100]}, b) it is random from \eqn{\mathcal{N}(50,(50/3)^2)} truncated to \eqn{[0,100]}, c) it is random from \eqn{Exp(1/30)} truncated to \eqn{[0,100]}. -#' -#' @param dimension The dimension of the zonotope. -#' @param nsegments The number of segments that generate the zonotope. -#' @param generator The distribution to pick the length of each segment from \eqn{[0,100]}: (a) 'uniform', (b) 'gaussian' or (c) 'exponential'. -#' @param seed Optional. A fixed seed for the generator. -#' -#' @return A polytope class representing a zonotope. -#' -#' @examples -#' # generate a 10-dimensional zonotope defined by the Minkowski sum of 20 segments -#' P = gen_rand_zonotope(10, 20) -#' @export -gen_rand_zonotope <- function(dimension, nsegments, generator = NULL, seed = NULL) { - - kind_gen = 1 - - if (!is.null(generator)) { - if (generator == 'gaussian') { - kind_gen = 2 - } else if (generator == 'exponential') { - kind_gen = 3 - } else if (generator != 'uniform'){ - stop("Wrong generator!") - } - } - - Mat = poly_gen(kind_gen, FALSE, TRUE, dimension, nsegments, seed) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Zonotope$new(Mat) - - return(P) -} diff --git a/R-proj/R/gen_simplex.R b/R-proj/R/gen_simplex.R deleted file mode 100644 index aa2ca4a6a..000000000 --- a/R-proj/R/gen_simplex.R +++ /dev/null @@ -1,41 +0,0 @@ -#' Generator function for simplices -#' -#' This function generates the \eqn{d}-dimensional unit simplex in H- or V-representation. -#' -#' @param dimension The dimension of the unit simplex. -#' @param representation A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation. -#' -#' @return A polytope class representing the \eqn{d}-dimensional unit simplex in H- or V-representation. -#' @examples -#' # generate a 10-dimensional simplex in H-representation -#' PolyList = gen_simplex(10, 'H') -#' -#' # generate a 20-dimensional simplex in V-representation -#' P = gen_simplex(20, 'V') -#' @export -gen_simplex <- function(dimension, representation) { - - kind_gen = 3 - m_gen = 0 - if (representation == "V") { - Vpoly_gen = TRUE - } else if (representation == "H") { - Vpoly_gen = FALSE - } else { - stop('Not a known representation.') - } - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - if (Vpoly_gen) { - P = Vpolytope$new(Mat, 1/prod(1:dimension)) - } else { - P = Hpolytope$new(-Mat, b, 1/prod(1:dimension)) - } - - return(P) -} diff --git a/R-proj/R/gen_skinny_cube.R b/R-proj/R/gen_skinny_cube.R deleted file mode 100644 index 0a1df0eb0..000000000 --- a/R-proj/R/gen_skinny_cube.R +++ /dev/null @@ -1,28 +0,0 @@ -#' Generator function for skinny hypercubes -#' -#' This function generates a \eqn{d}-dimensional skinny hypercube \eqn{[-1,1]^{d-1}\times [-100,100]}. -#' -#' @param dimension The dimension of the skinny hypercube. -#' -#' @return A polytope class representing the \eqn{d}-dimensional skinny hypercube in H-representation. -#' -#' @examples -#' # generate a 10-dimensional skinny hypercube. -#' P = gen_skinny_cube(10) -#' @export -gen_skinny_cube <- function(dimension) { - - kind_gen = 5 - m_gen = 0 - Vpoly_gen = FALSE - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(-Mat, b, 2^(dimension -1)*200) - - return(P) -} diff --git a/R-proj/R/read_sdpa_file.R b/R-proj/R/read_sdpa_file.R deleted file mode 100644 index 83c10c528..000000000 --- a/R-proj/R/read_sdpa_file.R +++ /dev/null @@ -1,26 +0,0 @@ -#' Read a SDPA format file -#' -#' Read a SDPA format file and return a spectrahedron (an object of class Spectrahedron) which is defined by -#' the linear matrix inequality in the input file, and the objective function. -#' -#' @param path Name of the input file -#' -#' @return A list with two named items: an item "matrices" which is an object of class Spectrahedron and an vector "objFunction" -#' -#' @examples -#' path = system.file('extdata', package = 'volesti') -#' l = readSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -#' Spectrahedron = l$spectrahedron -#' objFunction = l$objFunction -#' @export -#' @useDynLib volesti, .registration=TRUE -#' @importFrom Rcpp evalCpp -#' @importFrom Rcpp loadModule -#' @importFrom "methods" "new" -#' @exportPattern "^[[:alpha:]]+" -readSdpaFormatFile <- function(path){ - l = loadSdpaFormatFile(path) - S = Spectrahedron$new(l$matrices) - - return(list("spectrahedron"=S, "objFunction"= l$objFunction)) -} diff --git a/R-proj/R/rotate_polytope.R b/R-proj/R/rotate_polytope.R deleted file mode 100644 index 12ce246b8..000000000 --- a/R-proj/R/rotate_polytope.R +++ /dev/null @@ -1,57 +0,0 @@ -#' Apply a random rotation to a convex polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes) -#' -#' Given a convex H- or V- polytope or a zonotope or an intersection of two V-polytopes as input, this function applies (a) a random rotation or (b) a given rotation by an input matrix \eqn{T}. -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope, (b) Vpolytope, (c) Zonotope, (d) intersection of two V-polytopes. -#' @param T Optional. A \eqn{d\times d} rotation matrix. -#' @param seed Optional. A fixed seed for the random linear map generator. -#' -#' @return A list that contains the rotated polytope and the matrix \eqn{T} of the linear transformation. -#' -#' @details Let \eqn{P} be the given polytope and \eqn{Q} the rotated one and \eqn{T} be the matrix of the linear transformation. -#' \itemize{ -#' \item{If \eqn{P} is in H-representation and \eqn{A} is the matrix that contains the normal vectors of the facets of \eqn{Q} then \eqn{AT} contains the normal vactors of the facets of \eqn{P}.} -#' \item{If \eqn{P} is in V-representation and \eqn{V} is the matrix that contains column-wise the vertices of \eqn{Q} then \eqn{T^TV} contains the vertices of \eqn{P}.} -#' \item{If \eqn{P} is a zonotope and \eqn{G} is the matrix that contains column-wise the generators of \eqn{Q} then \eqn{T^TG} contains the generators of \eqn{P}.} -#' \item{If \eqn{M} is a matrix that contains column-wise points in \eqn{Q} then \eqn{T^TM} contains points in \eqn{P}.} -#' } -#' @examples -#' # rotate a H-polytope (2d unit simplex) -#' P = gen_simplex(2,'H') -#' poly_matrix_list = rotate_polytope(P) -#' -#' # rotate a V-polytope (3d cube) -#' P = gen_cube(3, 'V') -#' poly_matrix_list = rotate_polytope(P) -#' -#' # rotate a 5-dimensional zonotope defined by the Minkowski sum of 15 segments -#' Z = gen_rand_zonotope(3,6) -#' poly_matrix_list = rotate_polytope(Z) -#' @export -rotate_polytope <- function(P, T = NULL, seed = NULL){ - - #call rcpp rotating function - Mat = rotating(P, T, seed) - - n = P$dimension - m=dim(Mat)[2]-n - Tr = Mat[,-c(1:(dim(Mat)[2]-n))] - Tr = Tr[1:n, 1:n] - Mat = t(Mat[,1:m]) - - # first column is the vector b - b = Mat[,1] - - # remove first column - A = Mat[,-c(1)] - - type = P$type - if (type == 2) { - PP = Vpolytope$new(A) - }else if (type == 3) { - PP = Zonotope$new(A) - } else { - PP = Hpolytope$new(A, b) - } - return(list("P" = PP, "T" = Tr)) -} diff --git a/R-proj/R/round_polytope.R b/R-proj/R/round_polytope.R deleted file mode 100644 index f95649c66..000000000 --- a/R-proj/R/round_polytope.R +++ /dev/null @@ -1,60 +0,0 @@ -#' Apply rounding to a convex polytope (H-polytope, V-polytope or a zonotope) -#' -#' Given a convex H or V polytope or a zonotope as input this function brings the polytope in rounded position based on minimum volume enclosing ellipsoid of a pointset. -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope. -#' @param method Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a dataset, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid, (c) \code{'isotropy'} for the method based on svd decomposition. The default method is \code{'mee'} for all the representations. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @return A list with 4 elements: (a) a polytope of the same class as the input polytope class and (b) the element "T" which is the matrix of the inverse linear transformation that is applied on the input polytope, (c) the element "shift" which is the opposite vector of that which has shifted the input polytope, (d) the element "round_value" which is the determinant of the square matrix of the linear transformation that is applied on the input polytope. -#' -#' @references \cite{I.Z.Emiris and V. Fisikopoulos, -#' \dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, -#' @references \cite{Michael J. Todd and E. Alper Yildirim, -#' \dQuote{On Khachiyan’s Algorithm for the Computation of Minimum Volume Enclosing Ellipsoids,} \emph{Discrete Applied Mathematics,} 2007.} -#' @references \cite{B. Cousins and S. Vempala, -#' \dQuote{A practical volume algorithm,} \emph{Math. Prog. Comp.,} 2016.}, -#' @references \cite{Yin Zhang and Liyan Gao, -#' \dQuote{On Numerical Solution of the Maximum Volume Ellipsoid Problem,} \emph{SIAM Journal on Optimization,} 2003.}, -#' -#' -#' @examples -#' # round a 5d skinny cube -#' P = gen_skinny_cube(5) -#' listHpoly = round_polytope(P) -#' -#' # round a V-polytope (3d unit cube) -#' P = gen_cube(3, 'V') -#' ListVpoly = round_polytope(P) -#' -#' # round a 2-dimensional zonotope defined by 6 generators -#' Z = gen_rand_zonotope(2,6) -#' ListZono = round_polytope(Z) -#' @export -round_polytope <- function(P, method = NULL, seed = NULL){ - - ret_list = rounding(P, method, seed) - - #get the matrix that describes the polytope - Mat = ret_list$Mat - - # first column is the vector b - b = Mat[,1] - - # remove first column - A = Mat[,-c(1)] - - type = P$type - if (type == 2) { - PP = list("P" = Vpolytope$new(A), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value) - }else if (type == 3) { - PP = list("P" = Zonotope$new(A), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value) - } else { - if (dim(P$Aeq)[1] > 0){ - PP = list("P" = Hpolytope$new(A,b), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value, "N" = ret_list$N, "N_shift" = ret_list$N_shift, "svd_prod" = ret_list$svd_prod) - } else { - PP = list("P" = Hpolytope$new(A,b), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value) - } - } - return(PP) -} diff --git a/R-proj/R/zonotope_approximation.R b/R-proj/R/zonotope_approximation.R deleted file mode 100644 index 8c56f6d23..000000000 --- a/R-proj/R/zonotope_approximation.R +++ /dev/null @@ -1,42 +0,0 @@ -#' A function to over-approximate a zonotope with PCA method and to evaluate the approximation by computing a ratio of fitness. -#' -#' For the evaluation of the PCA method the exact volume of the approximation body is computed and the volume of the input zonotope is computed by CoolingBodies algorithm. The ratio of fitness is \eqn{R=vol(P) / vol(P_{red})}, where \eqn{P_{red}} is the approximate polytope. -#' -#' @param Z A zonotope. -#' @param fit_ratio Optional. A boolean parameter to request the computation of the ratio of fitness. -#' @param settings Optional. A list that declares the values of the parameters of CB algorithm as follows: -#' \itemize{ -#' \item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{0.1}.} -#' \item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{1}.} -#' \item{\code{win_len} }{ The length of the sliding window for CB algorithm. The default value is \eqn{200}.} -#' \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -#' } -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @return A list that contains the approximation body in H-representation and the ratio of fitness -#' -#' @references \cite{A.K. Kopetzki and B. Schurmann and M. Althoff, -#' \dQuote{Methods for Order Reduction of Zonotopes,} \emph{IEEE Conference on Decision and Control,} 2017.} -#' -#' @examples -#' # over-approximate a 2-dimensional zonotope with 10 generators and compute the ratio of fitness -#' Z = gen_rand_zonotope(2,12) -#' retList = zonotope_approximation(Z = Z) -#' -#' @export -zonotope_approximation <- function(Z, fit_ratio = NULL, settings = NULL, seed = NULL){ - - ret_list = zono_approx(Z, fit_ratio, settings, seed) - - Mat = ret_list$Mat - - # first column is the vector b - b = Mat[,1] - - # remove first column - A = Mat[,-c(1)] - PP = list("P" = Hpolytope$new(A,b), "fit_ratio" = ret_list$fit_ratio) - - return(PP) - -} diff --git a/R-proj/R/zzz.R b/R-proj/R/zzz.R deleted file mode 100644 index 564a20b9c..000000000 --- a/R-proj/R/zzz.R +++ /dev/null @@ -1,11 +0,0 @@ -## Up until R 2.15.0, the require("methods") is needed but (now) -## triggers an warning from R CMD check -#.onLoad <- function(libname, pkgname){ -# #require("methods") ## needed with R <= 2.15.0 -# loadRcppModules() - -## For R 2.15.1 and later this also works. Note that calling loadModule() triggers -## a load action, so this does not have to be placed in .onLoad() or evalqOnLoad(). - -loadModule("polytopes", TRUE) -loadModule("spectrahedron", TRUE) diff --git a/R-proj/examples/logconcave/data/polytope_e_coli.mat b/R-proj/examples/logconcave/data/polytope_e_coli.mat deleted file mode 100644 index cc0dee3ef..000000000 Binary files a/R-proj/examples/logconcave/data/polytope_e_coli.mat and /dev/null differ diff --git a/R-proj/examples/logconcave/generalized_hyperbolic.R b/R-proj/examples/logconcave/generalized_hyperbolic.R deleted file mode 100644 index e0f9b90ce..000000000 --- a/R-proj/examples/logconcave/generalized_hyperbolic.R +++ /dev/null @@ -1,65 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for sampling from a Generalized Hyperbolic density - -# Import required libraries -library(ggplot2) -library(volesti) -library(numDeriv) -library(GeneralizedHyperbolic) - -A = matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b = c(4,4) - -f <- function(x) (-log(dghyp(x))) -grad_f <- function(x) (-ddghyp(x)/dghyp(x)) - -x_min = matrix(0, 1, 1) - -# Create domain of truncation -P <- volesti::Hpolytope$new(A, b) - -# Smoothness and strong-convexity -L <- estimtate_lipschitz_constant(grad_f, P, 1000) -m <- L - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) - -# Sample points -n_samples <- 10000 -n_burns <- n_samples / 2 - -pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.5, "nburns" = n_burns, "walk_length" = 1, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) - -# Plot histogram -hist(pts, - probability=TRUE, - breaks = 100, - border="blue", - main="Genrealized Hyperbolic Density with lambda = 1, alpha = 1, beta = 0, delta = 1, mu = 0", - xlab="Samples", - ylab="Density" -) - -cat("Sample mean is: ") -sample_mean <- mean(pts) -cat(sample_mean) -cat("\n") -cat("Sample variance is: ") -sample_variance <- mean((pts - sample_mean)^2) -cat(sample_variance) - -n_ess = min(ess(pts)) -psrf = max(psrf_univariate(pts)) - -cat("\nEffective sample size: ", n_ess, append=TRUE) -cat("\nPSRF: ", psrf, append=TRUE) diff --git a/R-proj/examples/logconcave/metabolic.R b/R-proj/examples/logconcave/metabolic.R deleted file mode 100644 index 7785de0d7..000000000 --- a/R-proj/examples/logconcave/metabolic.R +++ /dev/null @@ -1,111 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) -library(R.matlab) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - - -# Load polytopes from mat file -metabolic_polytope_mat <- readMat('./data/polytope_e_coli.mat') -A <- as.matrix(metabolic_polytope_mat$polytope[[1]]) -b <- as.matrix(metabolic_polytope_mat$polytope[[2]]) -center <- as.matrix(metabolic_polytope_mat$polytope[[3]]) -radius <- as.numeric(metabolic_polytope_mat$polytope[[4]]) -sigma <- 1 -dimension <- dim(A)[2] - - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 / (2 * sigma^2)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (x / sigma^2) - - -# Smoothness and strong-convexity -L <- 1 / sigma^2 -m <- 1 / sigma^2 - -# Center polytope -b_new <- b - A %*% center - -# Create volesti polytope -P <- Hpolytope$new(A = A, b = c(b_new)) - -# Rounding -#Tr <- rounding(H) - -#P <- Hpolytope$new(A = Tr$Mat[1:nrow(Tr$Mat), 2:ncol(Tr$Mat)], b = Tr$Mat[,1]) - -# Center is origin (after shift) -x_min = matrix(0, dimension, 1) - -# Generate samples with HNR -start_time <- Sys.time() -rdhr_samples <- sample_points(P, n = 10, random_walk = list("walk" = "RDHR", "nburns" = 10, "walk_length" = 1), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) -end_time <- Sys.time() - -# Calculate Effective Sample size -rdhr_ess = ess(rdhr_samples) -min_ess <- min(rdhr_ess) - -# Calculate PSRF -rdhr_psrfs = psrf_univariate(rdhr_samples) -max_psrf = max(rdhr_psrfs) -elapsed_time <- end_time - start_time - -# Print results -cat('Min Effective Sample Size: ') -cat(min_ess) -cat('\n') -cat('Maximum PSRF: ') -cat(max_psrf) -cat('\n') -cat('Time per independent sample: ') -cat(elapsed_time / min_ess) -cat('sec') - -outfile <- '/home/marios/samples_hnr_iAB_PLT_283.txt' - -write.table(rdhr_samples, file=outfile, row.names=FALSE, col.names=FALSE) - -start_time <- Sys.time() -hmc_samples <- sample_points(P, n = 10, random_walk = list("walk" = "HMC", "step_size" = 0.07, "nburns" = 10, "walk_length" = 30, "solver" = "leapfrog", "starting_point" = rdhr_samples[, ncol(rdhr_samples)]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) -end_time <- Sys.time() - -# Calculate Effective Sample size -hmc_ess = ess(hmc_samples) -min_ess <- min(hmc_ess) - -# Calculate PSRF -hmc_psrfs = psrf_univariate(hmc_samples) -max_psrf = max(hmc_psrfs) -elapsed_time <- end_time - start_time - -# Print results -cat('HMC\n') -cat('Min Effective Sample Size: ') -cat(min_ess) -cat('\n') -cat('Maximum PSRF: ') -cat(max_psrf) -cat('\n') -cat('Time per independent sample: ') -cat(elapsed_time / min_ess) -cat('sec') diff --git a/R-proj/examples/logconcave/simple_hmc.R b/R-proj/examples/logconcave/simple_hmc.R deleted file mode 100644 index 860677468..000000000 --- a/R-proj/examples/logconcave/simple_hmc.R +++ /dev/null @@ -1,61 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 + sum(x)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (2 * x + 1) - -# Interval [-1, 1] -A = matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b = c(2,1) - -# Create domain of truncation -P <- volesti::Hpolytope$new(A, b) - -# Mode of logconcave density -x_min <- c(-0.5) - -# Smoothness and strong-convexity -L <- 2 -m <- 2 - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) - -# Sample points -n_samples <- 20000 -n_burns <- n_samples / 2 - -pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 3, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) -# pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 3, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "mode" = x_min, "variance" = 1)) - -# Plot histogram -hist(pts, probability=TRUE, breaks = 100) - -cat("Sample mean is: ") -sample_mean <- mean(pts) -cat(sample_mean) -cat("\n") -cat("Sample variance is: ") -sample_variance <- mean((pts - sample_mean)^2) -cat(sample_variance) diff --git a/R-proj/examples/logconcave/simple_hmc_rand_poly.R b/R-proj/examples/logconcave/simple_hmc_rand_poly.R deleted file mode 100644 index 9f785aaa8..000000000 --- a/R-proj/examples/logconcave/simple_hmc_rand_poly.R +++ /dev/null @@ -1,58 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 + sum(x)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (2 * x + 1) - -dimension <- 50 -facets <- 200 - -# Create domain of truncation -H <- gen_rand_hpoly(dimension, facets) - -# Rounding -Tr <- rounding(H) - -P <- Hpolytope$new(A = Tr$Mat[1:nrow(Tr$Mat), 2:ncol(Tr$Mat)], b = Tr$Mat[,1]) - -x_min = matrix(0, dimension, 1) - -# Smoothness and strong-convexity -L <- 2 -m <- 2 - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) - -# Sample points -n_samples <- 20000 -n_burns <- n_samples / 2 - -samples <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.03, "nburns" = n_burns, "walk_length" = 3, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) - -# Plot histogram -hist(samples[1,], probability=TRUE, breaks = 100) - -psrfs <- psrf_univariate(samples) -n_ess <- ess(samples) \ No newline at end of file diff --git a/R-proj/examples/logconcave/simple_ode.R b/R-proj/examples/logconcave/simple_ode.R deleted file mode 100644 index 10d0c6d88..000000000 --- a/R-proj/examples/logconcave/simple_ode.R +++ /dev/null @@ -1,31 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for ODE solvers -library(volesti) - -F <- function (x) (-x) -order <- 2 -step_size <- 0.01 -n <- 1000 -initial_conditions <- list("x_1" = c(0), "x_2" = c(1)) -initial_time <- 0 - -# Do not impose constraints -domains <- list() - -# Call the ode solver -states <- volesti::ode_solve(dimension=1, n=n, F=F, initial_time=initial_time, step_size=step_size, order=order, method="leapfrog", initial_conditions=initial_conditions, domains = list()) - -x <- states[["x_1"]] -v <- states[["x_2"]] - -plot(x, v) - diff --git a/R-proj/examples/logconcave/simple_ode_truncated.R b/R-proj/examples/logconcave/simple_ode_truncated.R deleted file mode 100644 index be2706c46..000000000 --- a/R-proj/examples/logconcave/simple_ode_truncated.R +++ /dev/null @@ -1,34 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for truncated ODE solvers -library(volesti) - -F <- function (x) (x) -order <- 1 -step_size <- 0.01 -n <- 1000 -initial_conditions <- list("x_1" = c(0.1)) -initial_time <- 0 - -A <- matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b <- c(1, 0) - -# Create domain of truncation -P_1 <- volesti::Hpolytope$new(A, b) -domains <- list("P_1" = P_1) - -# Call the ode solver -states <- volesti::ode_solve(dimension=1, n=n, F=F, initial_time=initial_time, step_size=step_size, order=order, method="euler", initial_conditions=initial_conditions, domains = domains) - -x <- states[["x_1"]] -t <- step_size * seq(0, n - 1) - -plot(t, x) diff --git a/R-proj/inst/AUTHORS b/R-proj/inst/AUTHORS deleted file mode 100644 index 956eb3255..000000000 --- a/R-proj/inst/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -1. Bojan Nikolic . We have modified the implementations of Khachiyan's Algorithm by B. Nikolic from bnmin1-1.11 package for the Computation of Minimum Volume Enclosing Ellipsoids in /src/external/minimum_ellipsoid. - -2. Kjell Konis , Stefan I. Larimore and Timothy A. Davis , Kjell Eikland, Michel Berkelaar, Richard Stallman, Authors of lpsolve package , in /src/external/lpsolve. - diff --git a/R-proj/inst/COPYRIGHTS b/R-proj/inst/COPYRIGHTS deleted file mode 100644 index 39cabd5a7..000000000 --- a/R-proj/inst/COPYRIGHTS +++ /dev/null @@ -1,6 +0,0 @@ -All files in src/external are taken from -(i) lpsolve (https://cran.r-project.org/src/contrib/Archive/lpSolveAPI) version 5.5.2.0, -(ii) bnmin1 (https://www.mrao.cam.ac.uk/~bn204/oof/bnmin1.html) version 1.11 - -Copyrights and modification details are explicitly described at the beginning of each of those files. - diff --git a/R-proj/inst/checks/README.md b/R-proj/inst/checks/README.md deleted file mode 100644 index a21b374b9..000000000 --- a/R-proj/inst/checks/README.md +++ /dev/null @@ -1,31 +0,0 @@ -| Check | cran-name | ERRORS | WARNINGS | NOTES | URL | -| ----------------------- |-------------|:-------------:| :-------: | :---: | -- | -| `macOS 10.9 Mavericks, R-oldrel (experimental)` | `r-oldrel-osx-x86_64` | 0 | 0 | 0 | [PREPERROR](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-4561558b7b96f9d9ab4662b565f1b871)* | -| `macOS 10.11 El Capitan, R-release (experimental)` | `r-release-osx-x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-b02c328852acddb3fcd3048f9f327055) | -| `Windows Server 2008 R2 SP1, R-oldrel, 32/64 bit` | `r-oldrel-windows-ix86+x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-f43945e177bd0a39f2a4effa8f6e9c88) | -| `Windows Server 2008 R2 SP1, R-release, 32/64 bit` | `r-release-windows-ix86+x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-707ffbeaa5fb7f3b00a1cff357e63c7f) | -| `Windows Server 2008 R2 SP1, R-patched, 32/64 bit` | `N/A` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-3376f9b5f6a17ba0a2c30b0cbf0bf917) | -| `Windows Server 2008 R2 SP1, R-devel, 32/64 bit` | `r-devel-windows-ix86+x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-901e108dfc1802c6f8726f162c95e597) | -| `Windows Server 2012, R-devel, Rtools4.0, 32/64 bit (experimental)` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-c48dc0fa6839ef8b509c73c48f0ca887) | -| `Oracle Solaris 10, x86, 32 bit, R-patched (experimental)` | `r-patched-solaris-x86` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-39bda3d243591a660eb3a4d2cdb4ac3f) | -| `Debian Linux, R-devel, GCC` | `r-devel-linux-x86_64-debian-gcc` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-907c4d873965c64d435bc672335063eb) | -| `Debian Linux, R-devel, GCC, no long double` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-cb5a82d9e3112bb706e6c767e778e3a5) | -| `Debian Linux, R-release, GCC` | `r-release-linux-x86_64` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-4c142b0323d2f174d53a761564e0b498) | -| `Debian Linux, R-patched, GCC` | `r-patched-linux-x86_64` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-031047558bf41664b387180f558adfd1) | -| `Debian Linux, R-devel, clang, ISO-8859-15 locale` | `r-devel-linux-x86_64-debian-clang` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-eecaf29af2fd88fdf148667c5463e141) | -| `Fedora Linux, R-devel, GCC` | `r-devel-linux-x86_64-fedora-gcc` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-f919c24153e9afd09ef0654d4799fb12) | -| `Fedora Linux, R-devel, clang, gfortran` | `r-devel-linux-x86_64-fedora-clang` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-0efbc2539568b86e2fa716db1a1231d6) | -| `Ubuntu Linux 16.04 LTS, R-devel, GCC` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-7d47fbd13a90cb4c3712232cfa320fc3) | -| `Ubuntu Linux 16.04 LTS, R-release, GCC` |`N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-6911a48496c075be151e7ba5d6326fbb) | -| `CentOS 6, stock R from EPEL` |`N/A` | 1 | 0 | 0 | [ERROR](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-6f5d27f5b548d46da8fcafab677b86e4)** | -| `CentOS 6 with Redhat Developer Toolset, R from EPEL` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-efce07b30b0a73c6c4f39db5fed70efa) | -| `Debian Linux, R-devel, GCC ASAN/UBSAN` *** | `N/A` | | | | [SUCCESS](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-1d695055bc3e2facdc252827c5d27f1b) | -| `Ubuntu Linux 16.04 LTS, R-devel with rchk` *** | `N/A` | | | | [SUCCESS](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-a35e57a5f29f45f2e74e07fd3b72c9e5) | - -All the checks above have performed via [rhub](https://cran.r-project.org/web/packages/rhub/index.html) package. For more details on system characteristics see [rhub's vignettes](https://cran.r-project.org/web/packages/rhub/vignettes/rhub.html). **cran-name** column shows the correspondance to [CRAN package check flavors](https://cran.r-project.org/web/checks/check_flavors.html) - -*The check on `macOS 10.9 Mavericks, R-oldrel (experimental)` fails because the system fails to install `RcppEigen`. You can see our [issue](https://github.com/r-hub/rhub/issues/280) at [rhub's github page](https://github.com/r-hub/rhub). - -** This is expected since our C++ code needs C++11 standard at least while this systems uses gcc4.4.X which does not support C++11 - -*** Checks for compiled code diff --git a/R-proj/inst/extdata/birk4.ine b/R-proj/inst/extdata/birk4.ine deleted file mode 100644 index f7515b94d..000000000 --- a/R-proj/inst/extdata/birk4.ine +++ /dev/null @@ -1,22 +0,0 @@ -birk4.ine -H-representation -begin - 16 10 integer --2 1 1 1 1 1 1 1 1 1 - 1 -1 0 0 -1 0 0 -1 0 0 - 1 0 -1 0 0 -1 0 0 -1 0 - 1 0 0 -1 0 0 -1 0 0 -1 - 1 -1 -1 -1 0 0 0 0 0 0 - 1 0 0 0 -1 -1 -1 0 0 0 - 1 0 0 0 0 0 0 -1 -1 -1 - 0 1 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 1 -end -input_incidence diff --git a/R-proj/inst/extdata/birk5.ine b/R-proj/inst/extdata/birk5.ine deleted file mode 100644 index 7a59b3f11..000000000 --- a/R-proj/inst/extdata/birk5.ine +++ /dev/null @@ -1,31 +0,0 @@ -birk5.ine -H-representation -begin - 25 17 integer --3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 -1 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 -1 -1 -1 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 -1 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -end -input_incidence diff --git a/R-proj/inst/extdata/cross_10.ext b/R-proj/inst/extdata/cross_10.ext deleted file mode 100644 index c14ee63c5..000000000 --- a/R-proj/inst/extdata/cross_10.ext +++ /dev/null @@ -1,27 +0,0 @@ -cross_10.ext -V-representation -begin - 20 11 integer - 1 0 0 0 0 0 0 0 0 0 1 - 1 1 0 0 0 0 0 0 0 0 0 - 1 0 1 0 0 0 0 0 0 0 0 - 1 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 1 0 0 0 0 0 0 - 1 0 0 0 0 1 0 0 0 0 0 - 1 0 0 0 0 0 1 0 0 0 0 - 1 0 0 0 0 0 0 1 0 0 0 - 1 0 0 0 0 0 0 0 1 0 0 - 1 0 0 0 0 0 0 0 0 1 0 - 1 0 0 0 0 0 0 0 0 0 -1 - 1 0 0 0 0 0 0 0 0 -1 0 - 1 0 0 0 0 0 0 0 -1 0 0 - 1 0 0 0 0 0 0 -1 0 0 0 - 1 0 0 0 0 0 -1 0 0 0 0 - 1 0 0 0 0 -1 0 0 0 0 0 - 1 0 0 0 -1 0 0 0 0 0 0 - 1 0 0 -1 0 0 0 0 0 0 0 - 1 0 -1 0 0 0 0 0 0 0 0 - 1 -1 0 0 0 0 0 0 0 0 0 -end -hull -incidence diff --git a/R-proj/inst/extdata/cross_10.ine b/R-proj/inst/extdata/cross_10.ine deleted file mode 100644 index 6f1b30487..000000000 --- a/R-proj/inst/extdata/cross_10.ine +++ /dev/null @@ -1,1030 +0,0 @@ -cross_10.ine -H-representation -begin - 1024 11 integer - 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 - 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 - 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 - 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 - 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 - 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 - 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 - 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 - 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 - 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 - 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 - 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 - 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 - 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 - 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 - 1 1 1 1 1 -1 -1 -1 -1 -1 -1 - 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 - 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 - 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 - 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 - 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 - 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 - 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 - 1 1 1 1 -1 1 -1 -1 -1 -1 -1 - 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 - 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 - 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 - 1 1 1 -1 1 1 -1 -1 -1 -1 -1 - 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 - 1 1 -1 1 1 1 -1 -1 -1 -1 -1 - 1 -1 1 1 1 1 -1 -1 -1 -1 -1 - 1 1 1 1 1 1 -1 -1 -1 -1 -1 - 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 - 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 - 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 - 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 - 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 - 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 - 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 - 1 1 1 1 -1 -1 1 -1 -1 -1 -1 - 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 - 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 - 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 - 1 1 1 -1 1 -1 1 -1 -1 -1 -1 - 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 - 1 1 -1 1 1 -1 1 -1 -1 -1 -1 - 1 -1 1 1 1 -1 1 -1 -1 -1 -1 - 1 1 1 1 1 -1 1 -1 -1 -1 -1 - 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 - 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 - 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 - 1 1 1 -1 -1 1 1 -1 -1 -1 -1 - 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 - 1 1 -1 1 -1 1 1 -1 -1 -1 -1 - 1 -1 1 1 -1 1 1 -1 -1 -1 -1 - 1 1 1 1 -1 1 1 -1 -1 -1 -1 - 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 - 1 1 -1 -1 1 1 1 -1 -1 -1 -1 - 1 -1 1 -1 1 1 1 -1 -1 -1 -1 - 1 1 1 -1 1 1 1 -1 -1 -1 -1 - 1 -1 -1 1 1 1 1 -1 -1 -1 -1 - 1 1 -1 1 1 1 1 -1 -1 -1 -1 - 1 -1 1 1 1 1 1 -1 -1 -1 -1 - 1 1 1 1 1 1 1 -1 -1 -1 -1 - 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 - 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 - 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 - 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 - 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 - 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 - 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 - 1 1 1 1 -1 -1 -1 1 -1 -1 -1 - 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 - 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 - 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 - 1 1 1 -1 1 -1 -1 1 -1 -1 -1 - 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 - 1 1 -1 1 1 -1 -1 1 -1 -1 -1 - 1 -1 1 1 1 -1 -1 1 -1 -1 -1 - 1 1 1 1 1 -1 -1 1 -1 -1 -1 - 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 - 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 - 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 - 1 1 1 -1 -1 1 -1 1 -1 -1 -1 - 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 - 1 1 -1 1 -1 1 -1 1 -1 -1 -1 - 1 -1 1 1 -1 1 -1 1 -1 -1 -1 - 1 1 1 1 -1 1 -1 1 -1 -1 -1 - 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 - 1 1 -1 -1 1 1 -1 1 -1 -1 -1 - 1 -1 1 -1 1 1 -1 1 -1 -1 -1 - 1 1 1 -1 1 1 -1 1 -1 -1 -1 - 1 -1 -1 1 1 1 -1 1 -1 -1 -1 - 1 1 -1 1 1 1 -1 1 -1 -1 -1 - 1 -1 1 1 1 1 -1 1 -1 -1 -1 - 1 1 1 1 1 1 -1 1 -1 -1 -1 - 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 - 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 - 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 - 1 1 1 -1 -1 -1 1 1 -1 -1 -1 - 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 - 1 1 -1 1 -1 -1 1 1 -1 -1 -1 - 1 -1 1 1 -1 -1 1 1 -1 -1 -1 - 1 1 1 1 -1 -1 1 1 -1 -1 -1 - 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 - 1 1 -1 -1 1 -1 1 1 -1 -1 -1 - 1 -1 1 -1 1 -1 1 1 -1 -1 -1 - 1 1 1 -1 1 -1 1 1 -1 -1 -1 - 1 -1 -1 1 1 -1 1 1 -1 -1 -1 - 1 1 -1 1 1 -1 1 1 -1 -1 -1 - 1 -1 1 1 1 -1 1 1 -1 -1 -1 - 1 1 1 1 1 -1 1 1 -1 -1 -1 - 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 - 1 1 -1 -1 -1 1 1 1 -1 -1 -1 - 1 -1 1 -1 -1 1 1 1 -1 -1 -1 - 1 1 1 -1 -1 1 1 1 -1 -1 -1 - 1 -1 -1 1 -1 1 1 1 -1 -1 -1 - 1 1 -1 1 -1 1 1 1 -1 -1 -1 - 1 -1 1 1 -1 1 1 1 -1 -1 -1 - 1 1 1 1 -1 1 1 1 -1 -1 -1 - 1 -1 -1 -1 1 1 1 1 -1 -1 -1 - 1 1 -1 -1 1 1 1 1 -1 -1 -1 - 1 -1 1 -1 1 1 1 1 -1 -1 -1 - 1 1 1 -1 1 1 1 1 -1 -1 -1 - 1 -1 -1 1 1 1 1 1 -1 -1 -1 - 1 1 -1 1 1 1 1 1 -1 -1 -1 - 1 -1 1 1 1 1 1 1 -1 -1 -1 - 1 1 1 1 1 1 1 1 -1 -1 -1 - 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 - 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 - 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 - 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 - 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 - 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 - 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 - 1 1 1 1 -1 -1 -1 -1 1 -1 -1 - 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 - 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 - 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 - 1 1 1 -1 1 -1 -1 -1 1 -1 -1 - 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 - 1 1 -1 1 1 -1 -1 -1 1 -1 -1 - 1 -1 1 1 1 -1 -1 -1 1 -1 -1 - 1 1 1 1 1 -1 -1 -1 1 -1 -1 - 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 - 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 - 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 - 1 1 1 -1 -1 1 -1 -1 1 -1 -1 - 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 - 1 1 -1 1 -1 1 -1 -1 1 -1 -1 - 1 -1 1 1 -1 1 -1 -1 1 -1 -1 - 1 1 1 1 -1 1 -1 -1 1 -1 -1 - 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 - 1 1 -1 -1 1 1 -1 -1 1 -1 -1 - 1 -1 1 -1 1 1 -1 -1 1 -1 -1 - 1 1 1 -1 1 1 -1 -1 1 -1 -1 - 1 -1 -1 1 1 1 -1 -1 1 -1 -1 - 1 1 -1 1 1 1 -1 -1 1 -1 -1 - 1 -1 1 1 1 1 -1 -1 1 -1 -1 - 1 1 1 1 1 1 -1 -1 1 -1 -1 - 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 - 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 - 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 - 1 1 1 -1 -1 -1 1 -1 1 -1 -1 - 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 - 1 1 -1 1 -1 -1 1 -1 1 -1 -1 - 1 -1 1 1 -1 -1 1 -1 1 -1 -1 - 1 1 1 1 -1 -1 1 -1 1 -1 -1 - 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 - 1 1 -1 -1 1 -1 1 -1 1 -1 -1 - 1 -1 1 -1 1 -1 1 -1 1 -1 -1 - 1 1 1 -1 1 -1 1 -1 1 -1 -1 - 1 -1 -1 1 1 -1 1 -1 1 -1 -1 - 1 1 -1 1 1 -1 1 -1 1 -1 -1 - 1 -1 1 1 1 -1 1 -1 1 -1 -1 - 1 1 1 1 1 -1 1 -1 1 -1 -1 - 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 - 1 1 -1 -1 -1 1 1 -1 1 -1 -1 - 1 -1 1 -1 -1 1 1 -1 1 -1 -1 - 1 1 1 -1 -1 1 1 -1 1 -1 -1 - 1 -1 -1 1 -1 1 1 -1 1 -1 -1 - 1 1 -1 1 -1 1 1 -1 1 -1 -1 - 1 -1 1 1 -1 1 1 -1 1 -1 -1 - 1 1 1 1 -1 1 1 -1 1 -1 -1 - 1 -1 -1 -1 1 1 1 -1 1 -1 -1 - 1 1 -1 -1 1 1 1 -1 1 -1 -1 - 1 -1 1 -1 1 1 1 -1 1 -1 -1 - 1 1 1 -1 1 1 1 -1 1 -1 -1 - 1 -1 -1 1 1 1 1 -1 1 -1 -1 - 1 1 -1 1 1 1 1 -1 1 -1 -1 - 1 -1 1 1 1 1 1 -1 1 -1 -1 - 1 1 1 1 1 1 1 -1 1 -1 -1 - 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 - 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 - 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 - 1 1 1 -1 -1 -1 -1 1 1 -1 -1 - 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 - 1 1 -1 1 -1 -1 -1 1 1 -1 -1 - 1 -1 1 1 -1 -1 -1 1 1 -1 -1 - 1 1 1 1 -1 -1 -1 1 1 -1 -1 - 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 - 1 1 -1 -1 1 -1 -1 1 1 -1 -1 - 1 -1 1 -1 1 -1 -1 1 1 -1 -1 - 1 1 1 -1 1 -1 -1 1 1 -1 -1 - 1 -1 -1 1 1 -1 -1 1 1 -1 -1 - 1 1 -1 1 1 -1 -1 1 1 -1 -1 - 1 -1 1 1 1 -1 -1 1 1 -1 -1 - 1 1 1 1 1 -1 -1 1 1 -1 -1 - 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 - 1 1 -1 -1 -1 1 -1 1 1 -1 -1 - 1 -1 1 -1 -1 1 -1 1 1 -1 -1 - 1 1 1 -1 -1 1 -1 1 1 -1 -1 - 1 -1 -1 1 -1 1 -1 1 1 -1 -1 - 1 1 -1 1 -1 1 -1 1 1 -1 -1 - 1 -1 1 1 -1 1 -1 1 1 -1 -1 - 1 1 1 1 -1 1 -1 1 1 -1 -1 - 1 -1 -1 -1 1 1 -1 1 1 -1 -1 - 1 1 -1 -1 1 1 -1 1 1 -1 -1 - 1 -1 1 -1 1 1 -1 1 1 -1 -1 - 1 1 1 -1 1 1 -1 1 1 -1 -1 - 1 -1 -1 1 1 1 -1 1 1 -1 -1 - 1 1 -1 1 1 1 -1 1 1 -1 -1 - 1 -1 1 1 1 1 -1 1 1 -1 -1 - 1 1 1 1 1 1 -1 1 1 -1 -1 - 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 - 1 1 -1 -1 -1 -1 1 1 1 -1 -1 - 1 -1 1 -1 -1 -1 1 1 1 -1 -1 - 1 1 1 -1 -1 -1 1 1 1 -1 -1 - 1 -1 -1 1 -1 -1 1 1 1 -1 -1 - 1 1 -1 1 -1 -1 1 1 1 -1 -1 - 1 -1 1 1 -1 -1 1 1 1 -1 -1 - 1 1 1 1 -1 -1 1 1 1 -1 -1 - 1 -1 -1 -1 1 -1 1 1 1 -1 -1 - 1 1 -1 -1 1 -1 1 1 1 -1 -1 - 1 -1 1 -1 1 -1 1 1 1 -1 -1 - 1 1 1 -1 1 -1 1 1 1 -1 -1 - 1 -1 -1 1 1 -1 1 1 1 -1 -1 - 1 1 -1 1 1 -1 1 1 1 -1 -1 - 1 -1 1 1 1 -1 1 1 1 -1 -1 - 1 1 1 1 1 -1 1 1 1 -1 -1 - 1 -1 -1 -1 -1 1 1 1 1 -1 -1 - 1 1 -1 -1 -1 1 1 1 1 -1 -1 - 1 -1 1 -1 -1 1 1 1 1 -1 -1 - 1 1 1 -1 -1 1 1 1 1 -1 -1 - 1 -1 -1 1 -1 1 1 1 1 -1 -1 - 1 1 -1 1 -1 1 1 1 1 -1 -1 - 1 -1 1 1 -1 1 1 1 1 -1 -1 - 1 1 1 1 -1 1 1 1 1 -1 -1 - 1 -1 -1 -1 1 1 1 1 1 -1 -1 - 1 1 -1 -1 1 1 1 1 1 -1 -1 - 1 -1 1 -1 1 1 1 1 1 -1 -1 - 1 1 1 -1 1 1 1 1 1 -1 -1 - 1 -1 -1 1 1 1 1 1 1 -1 -1 - 1 1 -1 1 1 1 1 1 1 -1 -1 - 1 -1 1 1 1 1 1 1 1 -1 -1 - 1 1 1 1 1 1 1 1 1 -1 -1 - 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 - 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 - 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 - 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 - 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 - 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 - 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 - 1 1 1 1 -1 -1 -1 -1 -1 1 -1 - 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 - 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 - 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 - 1 1 1 -1 1 -1 -1 -1 -1 1 -1 - 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 - 1 1 -1 1 1 -1 -1 -1 -1 1 -1 - 1 -1 1 1 1 -1 -1 -1 -1 1 -1 - 1 1 1 1 1 -1 -1 -1 -1 1 -1 - 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 - 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 - 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 - 1 1 1 -1 -1 1 -1 -1 -1 1 -1 - 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 - 1 1 -1 1 -1 1 -1 -1 -1 1 -1 - 1 -1 1 1 -1 1 -1 -1 -1 1 -1 - 1 1 1 1 -1 1 -1 -1 -1 1 -1 - 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 - 1 1 -1 -1 1 1 -1 -1 -1 1 -1 - 1 -1 1 -1 1 1 -1 -1 -1 1 -1 - 1 1 1 -1 1 1 -1 -1 -1 1 -1 - 1 -1 -1 1 1 1 -1 -1 -1 1 -1 - 1 1 -1 1 1 1 -1 -1 -1 1 -1 - 1 -1 1 1 1 1 -1 -1 -1 1 -1 - 1 1 1 1 1 1 -1 -1 -1 1 -1 - 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 - 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 - 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 - 1 1 1 -1 -1 -1 1 -1 -1 1 -1 - 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 - 1 1 -1 1 -1 -1 1 -1 -1 1 -1 - 1 -1 1 1 -1 -1 1 -1 -1 1 -1 - 1 1 1 1 -1 -1 1 -1 -1 1 -1 - 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 - 1 1 -1 -1 1 -1 1 -1 -1 1 -1 - 1 -1 1 -1 1 -1 1 -1 -1 1 -1 - 1 1 1 -1 1 -1 1 -1 -1 1 -1 - 1 -1 -1 1 1 -1 1 -1 -1 1 -1 - 1 1 -1 1 1 -1 1 -1 -1 1 -1 - 1 -1 1 1 1 -1 1 -1 -1 1 -1 - 1 1 1 1 1 -1 1 -1 -1 1 -1 - 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 - 1 1 -1 -1 -1 1 1 -1 -1 1 -1 - 1 -1 1 -1 -1 1 1 -1 -1 1 -1 - 1 1 1 -1 -1 1 1 -1 -1 1 -1 - 1 -1 -1 1 -1 1 1 -1 -1 1 -1 - 1 1 -1 1 -1 1 1 -1 -1 1 -1 - 1 -1 1 1 -1 1 1 -1 -1 1 -1 - 1 1 1 1 -1 1 1 -1 -1 1 -1 - 1 -1 -1 -1 1 1 1 -1 -1 1 -1 - 1 1 -1 -1 1 1 1 -1 -1 1 -1 - 1 -1 1 -1 1 1 1 -1 -1 1 -1 - 1 1 1 -1 1 1 1 -1 -1 1 -1 - 1 -1 -1 1 1 1 1 -1 -1 1 -1 - 1 1 -1 1 1 1 1 -1 -1 1 -1 - 1 -1 1 1 1 1 1 -1 -1 1 -1 - 1 1 1 1 1 1 1 -1 -1 1 -1 - 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 - 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 - 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 - 1 1 1 -1 -1 -1 -1 1 -1 1 -1 - 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 - 1 1 -1 1 -1 -1 -1 1 -1 1 -1 - 1 -1 1 1 -1 -1 -1 1 -1 1 -1 - 1 1 1 1 -1 -1 -1 1 -1 1 -1 - 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 - 1 1 -1 -1 1 -1 -1 1 -1 1 -1 - 1 -1 1 -1 1 -1 -1 1 -1 1 -1 - 1 1 1 -1 1 -1 -1 1 -1 1 -1 - 1 -1 -1 1 1 -1 -1 1 -1 1 -1 - 1 1 -1 1 1 -1 -1 1 -1 1 -1 - 1 -1 1 1 1 -1 -1 1 -1 1 -1 - 1 1 1 1 1 -1 -1 1 -1 1 -1 - 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 - 1 1 -1 -1 -1 1 -1 1 -1 1 -1 - 1 -1 1 -1 -1 1 -1 1 -1 1 -1 - 1 1 1 -1 -1 1 -1 1 -1 1 -1 - 1 -1 -1 1 -1 1 -1 1 -1 1 -1 - 1 1 -1 1 -1 1 -1 1 -1 1 -1 - 1 -1 1 1 -1 1 -1 1 -1 1 -1 - 1 1 1 1 -1 1 -1 1 -1 1 -1 - 1 -1 -1 -1 1 1 -1 1 -1 1 -1 - 1 1 -1 -1 1 1 -1 1 -1 1 -1 - 1 -1 1 -1 1 1 -1 1 -1 1 -1 - 1 1 1 -1 1 1 -1 1 -1 1 -1 - 1 -1 -1 1 1 1 -1 1 -1 1 -1 - 1 1 -1 1 1 1 -1 1 -1 1 -1 - 1 -1 1 1 1 1 -1 1 -1 1 -1 - 1 1 1 1 1 1 -1 1 -1 1 -1 - 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 - 1 1 -1 -1 -1 -1 1 1 -1 1 -1 - 1 -1 1 -1 -1 -1 1 1 -1 1 -1 - 1 1 1 -1 -1 -1 1 1 -1 1 -1 - 1 -1 -1 1 -1 -1 1 1 -1 1 -1 - 1 1 -1 1 -1 -1 1 1 -1 1 -1 - 1 -1 1 1 -1 -1 1 1 -1 1 -1 - 1 1 1 1 -1 -1 1 1 -1 1 -1 - 1 -1 -1 -1 1 -1 1 1 -1 1 -1 - 1 1 -1 -1 1 -1 1 1 -1 1 -1 - 1 -1 1 -1 1 -1 1 1 -1 1 -1 - 1 1 1 -1 1 -1 1 1 -1 1 -1 - 1 -1 -1 1 1 -1 1 1 -1 1 -1 - 1 1 -1 1 1 -1 1 1 -1 1 -1 - 1 -1 1 1 1 -1 1 1 -1 1 -1 - 1 1 1 1 1 -1 1 1 -1 1 -1 - 1 -1 -1 -1 -1 1 1 1 -1 1 -1 - 1 1 -1 -1 -1 1 1 1 -1 1 -1 - 1 -1 1 -1 -1 1 1 1 -1 1 -1 - 1 1 1 -1 -1 1 1 1 -1 1 -1 - 1 -1 -1 1 -1 1 1 1 -1 1 -1 - 1 1 -1 1 -1 1 1 1 -1 1 -1 - 1 -1 1 1 -1 1 1 1 -1 1 -1 - 1 1 1 1 -1 1 1 1 -1 1 -1 - 1 -1 -1 -1 1 1 1 1 -1 1 -1 - 1 1 -1 -1 1 1 1 1 -1 1 -1 - 1 -1 1 -1 1 1 1 1 -1 1 -1 - 1 1 1 -1 1 1 1 1 -1 1 -1 - 1 -1 -1 1 1 1 1 1 -1 1 -1 - 1 1 -1 1 1 1 1 1 -1 1 -1 - 1 -1 1 1 1 1 1 1 -1 1 -1 - 1 1 1 1 1 1 1 1 -1 1 -1 - 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 - 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 - 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 - 1 1 1 -1 -1 -1 -1 -1 1 1 -1 - 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 - 1 1 -1 1 -1 -1 -1 -1 1 1 -1 - 1 -1 1 1 -1 -1 -1 -1 1 1 -1 - 1 1 1 1 -1 -1 -1 -1 1 1 -1 - 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 - 1 1 -1 -1 1 -1 -1 -1 1 1 -1 - 1 -1 1 -1 1 -1 -1 -1 1 1 -1 - 1 1 1 -1 1 -1 -1 -1 1 1 -1 - 1 -1 -1 1 1 -1 -1 -1 1 1 -1 - 1 1 -1 1 1 -1 -1 -1 1 1 -1 - 1 -1 1 1 1 -1 -1 -1 1 1 -1 - 1 1 1 1 1 -1 -1 -1 1 1 -1 - 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 - 1 1 -1 -1 -1 1 -1 -1 1 1 -1 - 1 -1 1 -1 -1 1 -1 -1 1 1 -1 - 1 1 1 -1 -1 1 -1 -1 1 1 -1 - 1 -1 -1 1 -1 1 -1 -1 1 1 -1 - 1 1 -1 1 -1 1 -1 -1 1 1 -1 - 1 -1 1 1 -1 1 -1 -1 1 1 -1 - 1 1 1 1 -1 1 -1 -1 1 1 -1 - 1 -1 -1 -1 1 1 -1 -1 1 1 -1 - 1 1 -1 -1 1 1 -1 -1 1 1 -1 - 1 -1 1 -1 1 1 -1 -1 1 1 -1 - 1 1 1 -1 1 1 -1 -1 1 1 -1 - 1 -1 -1 1 1 1 -1 -1 1 1 -1 - 1 1 -1 1 1 1 -1 -1 1 1 -1 - 1 -1 1 1 1 1 -1 -1 1 1 -1 - 1 1 1 1 1 1 -1 -1 1 1 -1 - 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 - 1 1 -1 -1 -1 -1 1 -1 1 1 -1 - 1 -1 1 -1 -1 -1 1 -1 1 1 -1 - 1 1 1 -1 -1 -1 1 -1 1 1 -1 - 1 -1 -1 1 -1 -1 1 -1 1 1 -1 - 1 1 -1 1 -1 -1 1 -1 1 1 -1 - 1 -1 1 1 -1 -1 1 -1 1 1 -1 - 1 1 1 1 -1 -1 1 -1 1 1 -1 - 1 -1 -1 -1 1 -1 1 -1 1 1 -1 - 1 1 -1 -1 1 -1 1 -1 1 1 -1 - 1 -1 1 -1 1 -1 1 -1 1 1 -1 - 1 1 1 -1 1 -1 1 -1 1 1 -1 - 1 -1 -1 1 1 -1 1 -1 1 1 -1 - 1 1 -1 1 1 -1 1 -1 1 1 -1 - 1 -1 1 1 1 -1 1 -1 1 1 -1 - 1 1 1 1 1 -1 1 -1 1 1 -1 - 1 -1 -1 -1 -1 1 1 -1 1 1 -1 - 1 1 -1 -1 -1 1 1 -1 1 1 -1 - 1 -1 1 -1 -1 1 1 -1 1 1 -1 - 1 1 1 -1 -1 1 1 -1 1 1 -1 - 1 -1 -1 1 -1 1 1 -1 1 1 -1 - 1 1 -1 1 -1 1 1 -1 1 1 -1 - 1 -1 1 1 -1 1 1 -1 1 1 -1 - 1 1 1 1 -1 1 1 -1 1 1 -1 - 1 -1 -1 -1 1 1 1 -1 1 1 -1 - 1 1 -1 -1 1 1 1 -1 1 1 -1 - 1 -1 1 -1 1 1 1 -1 1 1 -1 - 1 1 1 -1 1 1 1 -1 1 1 -1 - 1 -1 -1 1 1 1 1 -1 1 1 -1 - 1 1 -1 1 1 1 1 -1 1 1 -1 - 1 -1 1 1 1 1 1 -1 1 1 -1 - 1 1 1 1 1 1 1 -1 1 1 -1 - 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 - 1 1 -1 -1 -1 -1 -1 1 1 1 -1 - 1 -1 1 -1 -1 -1 -1 1 1 1 -1 - 1 1 1 -1 -1 -1 -1 1 1 1 -1 - 1 -1 -1 1 -1 -1 -1 1 1 1 -1 - 1 1 -1 1 -1 -1 -1 1 1 1 -1 - 1 -1 1 1 -1 -1 -1 1 1 1 -1 - 1 1 1 1 -1 -1 -1 1 1 1 -1 - 1 -1 -1 -1 1 -1 -1 1 1 1 -1 - 1 1 -1 -1 1 -1 -1 1 1 1 -1 - 1 -1 1 -1 1 -1 -1 1 1 1 -1 - 1 1 1 -1 1 -1 -1 1 1 1 -1 - 1 -1 -1 1 1 -1 -1 1 1 1 -1 - 1 1 -1 1 1 -1 -1 1 1 1 -1 - 1 -1 1 1 1 -1 -1 1 1 1 -1 - 1 1 1 1 1 -1 -1 1 1 1 -1 - 1 -1 -1 -1 -1 1 -1 1 1 1 -1 - 1 1 -1 -1 -1 1 -1 1 1 1 -1 - 1 -1 1 -1 -1 1 -1 1 1 1 -1 - 1 1 1 -1 -1 1 -1 1 1 1 -1 - 1 -1 -1 1 -1 1 -1 1 1 1 -1 - 1 1 -1 1 -1 1 -1 1 1 1 -1 - 1 -1 1 1 -1 1 -1 1 1 1 -1 - 1 1 1 1 -1 1 -1 1 1 1 -1 - 1 -1 -1 -1 1 1 -1 1 1 1 -1 - 1 1 -1 -1 1 1 -1 1 1 1 -1 - 1 -1 1 -1 1 1 -1 1 1 1 -1 - 1 1 1 -1 1 1 -1 1 1 1 -1 - 1 -1 -1 1 1 1 -1 1 1 1 -1 - 1 1 -1 1 1 1 -1 1 1 1 -1 - 1 -1 1 1 1 1 -1 1 1 1 -1 - 1 1 1 1 1 1 -1 1 1 1 -1 - 1 -1 -1 -1 -1 -1 1 1 1 1 -1 - 1 1 -1 -1 -1 -1 1 1 1 1 -1 - 1 -1 1 -1 -1 -1 1 1 1 1 -1 - 1 1 1 -1 -1 -1 1 1 1 1 -1 - 1 -1 -1 1 -1 -1 1 1 1 1 -1 - 1 1 -1 1 -1 -1 1 1 1 1 -1 - 1 -1 1 1 -1 -1 1 1 1 1 -1 - 1 1 1 1 -1 -1 1 1 1 1 -1 - 1 -1 -1 -1 1 -1 1 1 1 1 -1 - 1 1 -1 -1 1 -1 1 1 1 1 -1 - 1 -1 1 -1 1 -1 1 1 1 1 -1 - 1 1 1 -1 1 -1 1 1 1 1 -1 - 1 -1 -1 1 1 -1 1 1 1 1 -1 - 1 1 -1 1 1 -1 1 1 1 1 -1 - 1 -1 1 1 1 -1 1 1 1 1 -1 - 1 1 1 1 1 -1 1 1 1 1 -1 - 1 -1 -1 -1 -1 1 1 1 1 1 -1 - 1 1 -1 -1 -1 1 1 1 1 1 -1 - 1 -1 1 -1 -1 1 1 1 1 1 -1 - 1 1 1 -1 -1 1 1 1 1 1 -1 - 1 -1 -1 1 -1 1 1 1 1 1 -1 - 1 1 -1 1 -1 1 1 1 1 1 -1 - 1 -1 1 1 -1 1 1 1 1 1 -1 - 1 1 1 1 -1 1 1 1 1 1 -1 - 1 -1 -1 -1 1 1 1 1 1 1 -1 - 1 1 -1 -1 1 1 1 1 1 1 -1 - 1 -1 1 -1 1 1 1 1 1 1 -1 - 1 1 1 -1 1 1 1 1 1 1 -1 - 1 -1 -1 1 1 1 1 1 1 1 -1 - 1 1 -1 1 1 1 1 1 1 1 -1 - 1 -1 1 1 1 1 1 1 1 1 -1 - 1 1 1 1 1 1 1 1 1 1 -1 - 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 - 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 - 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 - 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 - 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 - 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 - 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 - 1 1 1 1 -1 -1 -1 -1 -1 -1 1 - 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 - 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 - 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 - 1 1 1 -1 1 -1 -1 -1 -1 -1 1 - 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 - 1 1 -1 1 1 -1 -1 -1 -1 -1 1 - 1 -1 1 1 1 -1 -1 -1 -1 -1 1 - 1 1 1 1 1 -1 -1 -1 -1 -1 1 - 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 - 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 - 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 - 1 1 1 -1 -1 1 -1 -1 -1 -1 1 - 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 - 1 1 -1 1 -1 1 -1 -1 -1 -1 1 - 1 -1 1 1 -1 1 -1 -1 -1 -1 1 - 1 1 1 1 -1 1 -1 -1 -1 -1 1 - 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 - 1 1 -1 -1 1 1 -1 -1 -1 -1 1 - 1 -1 1 -1 1 1 -1 -1 -1 -1 1 - 1 1 1 -1 1 1 -1 -1 -1 -1 1 - 1 -1 -1 1 1 1 -1 -1 -1 -1 1 - 1 1 -1 1 1 1 -1 -1 -1 -1 1 - 1 -1 1 1 1 1 -1 -1 -1 -1 1 - 1 1 1 1 1 1 -1 -1 -1 -1 1 - 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 - 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 - 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 - 1 1 1 -1 -1 -1 1 -1 -1 -1 1 - 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 - 1 1 -1 1 -1 -1 1 -1 -1 -1 1 - 1 -1 1 1 -1 -1 1 -1 -1 -1 1 - 1 1 1 1 -1 -1 1 -1 -1 -1 1 - 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 - 1 1 -1 -1 1 -1 1 -1 -1 -1 1 - 1 -1 1 -1 1 -1 1 -1 -1 -1 1 - 1 1 1 -1 1 -1 1 -1 -1 -1 1 - 1 -1 -1 1 1 -1 1 -1 -1 -1 1 - 1 1 -1 1 1 -1 1 -1 -1 -1 1 - 1 -1 1 1 1 -1 1 -1 -1 -1 1 - 1 1 1 1 1 -1 1 -1 -1 -1 1 - 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 - 1 1 -1 -1 -1 1 1 -1 -1 -1 1 - 1 -1 1 -1 -1 1 1 -1 -1 -1 1 - 1 1 1 -1 -1 1 1 -1 -1 -1 1 - 1 -1 -1 1 -1 1 1 -1 -1 -1 1 - 1 1 -1 1 -1 1 1 -1 -1 -1 1 - 1 -1 1 1 -1 1 1 -1 -1 -1 1 - 1 1 1 1 -1 1 1 -1 -1 -1 1 - 1 -1 -1 -1 1 1 1 -1 -1 -1 1 - 1 1 -1 -1 1 1 1 -1 -1 -1 1 - 1 -1 1 -1 1 1 1 -1 -1 -1 1 - 1 1 1 -1 1 1 1 -1 -1 -1 1 - 1 -1 -1 1 1 1 1 -1 -1 -1 1 - 1 1 -1 1 1 1 1 -1 -1 -1 1 - 1 -1 1 1 1 1 1 -1 -1 -1 1 - 1 1 1 1 1 1 1 -1 -1 -1 1 - 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 - 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 - 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 - 1 1 1 -1 -1 -1 -1 1 -1 -1 1 - 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 - 1 1 -1 1 -1 -1 -1 1 -1 -1 1 - 1 -1 1 1 -1 -1 -1 1 -1 -1 1 - 1 1 1 1 -1 -1 -1 1 -1 -1 1 - 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 - 1 1 -1 -1 1 -1 -1 1 -1 -1 1 - 1 -1 1 -1 1 -1 -1 1 -1 -1 1 - 1 1 1 -1 1 -1 -1 1 -1 -1 1 - 1 -1 -1 1 1 -1 -1 1 -1 -1 1 - 1 1 -1 1 1 -1 -1 1 -1 -1 1 - 1 -1 1 1 1 -1 -1 1 -1 -1 1 - 1 1 1 1 1 -1 -1 1 -1 -1 1 - 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 - 1 1 -1 -1 -1 1 -1 1 -1 -1 1 - 1 -1 1 -1 -1 1 -1 1 -1 -1 1 - 1 1 1 -1 -1 1 -1 1 -1 -1 1 - 1 -1 -1 1 -1 1 -1 1 -1 -1 1 - 1 1 -1 1 -1 1 -1 1 -1 -1 1 - 1 -1 1 1 -1 1 -1 1 -1 -1 1 - 1 1 1 1 -1 1 -1 1 -1 -1 1 - 1 -1 -1 -1 1 1 -1 1 -1 -1 1 - 1 1 -1 -1 1 1 -1 1 -1 -1 1 - 1 -1 1 -1 1 1 -1 1 -1 -1 1 - 1 1 1 -1 1 1 -1 1 -1 -1 1 - 1 -1 -1 1 1 1 -1 1 -1 -1 1 - 1 1 -1 1 1 1 -1 1 -1 -1 1 - 1 -1 1 1 1 1 -1 1 -1 -1 1 - 1 1 1 1 1 1 -1 1 -1 -1 1 - 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 - 1 1 -1 -1 -1 -1 1 1 -1 -1 1 - 1 -1 1 -1 -1 -1 1 1 -1 -1 1 - 1 1 1 -1 -1 -1 1 1 -1 -1 1 - 1 -1 -1 1 -1 -1 1 1 -1 -1 1 - 1 1 -1 1 -1 -1 1 1 -1 -1 1 - 1 -1 1 1 -1 -1 1 1 -1 -1 1 - 1 1 1 1 -1 -1 1 1 -1 -1 1 - 1 -1 -1 -1 1 -1 1 1 -1 -1 1 - 1 1 -1 -1 1 -1 1 1 -1 -1 1 - 1 -1 1 -1 1 -1 1 1 -1 -1 1 - 1 1 1 -1 1 -1 1 1 -1 -1 1 - 1 -1 -1 1 1 -1 1 1 -1 -1 1 - 1 1 -1 1 1 -1 1 1 -1 -1 1 - 1 -1 1 1 1 -1 1 1 -1 -1 1 - 1 1 1 1 1 -1 1 1 -1 -1 1 - 1 -1 -1 -1 -1 1 1 1 -1 -1 1 - 1 1 -1 -1 -1 1 1 1 -1 -1 1 - 1 -1 1 -1 -1 1 1 1 -1 -1 1 - 1 1 1 -1 -1 1 1 1 -1 -1 1 - 1 -1 -1 1 -1 1 1 1 -1 -1 1 - 1 1 -1 1 -1 1 1 1 -1 -1 1 - 1 -1 1 1 -1 1 1 1 -1 -1 1 - 1 1 1 1 -1 1 1 1 -1 -1 1 - 1 -1 -1 -1 1 1 1 1 -1 -1 1 - 1 1 -1 -1 1 1 1 1 -1 -1 1 - 1 -1 1 -1 1 1 1 1 -1 -1 1 - 1 1 1 -1 1 1 1 1 -1 -1 1 - 1 -1 -1 1 1 1 1 1 -1 -1 1 - 1 1 -1 1 1 1 1 1 -1 -1 1 - 1 -1 1 1 1 1 1 1 -1 -1 1 - 1 1 1 1 1 1 1 1 -1 -1 1 - 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 - 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 - 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 - 1 1 1 -1 -1 -1 -1 -1 1 -1 1 - 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 - 1 1 -1 1 -1 -1 -1 -1 1 -1 1 - 1 -1 1 1 -1 -1 -1 -1 1 -1 1 - 1 1 1 1 -1 -1 -1 -1 1 -1 1 - 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 - 1 1 -1 -1 1 -1 -1 -1 1 -1 1 - 1 -1 1 -1 1 -1 -1 -1 1 -1 1 - 1 1 1 -1 1 -1 -1 -1 1 -1 1 - 1 -1 -1 1 1 -1 -1 -1 1 -1 1 - 1 1 -1 1 1 -1 -1 -1 1 -1 1 - 1 -1 1 1 1 -1 -1 -1 1 -1 1 - 1 1 1 1 1 -1 -1 -1 1 -1 1 - 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 - 1 1 -1 -1 -1 1 -1 -1 1 -1 1 - 1 -1 1 -1 -1 1 -1 -1 1 -1 1 - 1 1 1 -1 -1 1 -1 -1 1 -1 1 - 1 -1 -1 1 -1 1 -1 -1 1 -1 1 - 1 1 -1 1 -1 1 -1 -1 1 -1 1 - 1 -1 1 1 -1 1 -1 -1 1 -1 1 - 1 1 1 1 -1 1 -1 -1 1 -1 1 - 1 -1 -1 -1 1 1 -1 -1 1 -1 1 - 1 1 -1 -1 1 1 -1 -1 1 -1 1 - 1 -1 1 -1 1 1 -1 -1 1 -1 1 - 1 1 1 -1 1 1 -1 -1 1 -1 1 - 1 -1 -1 1 1 1 -1 -1 1 -1 1 - 1 1 -1 1 1 1 -1 -1 1 -1 1 - 1 -1 1 1 1 1 -1 -1 1 -1 1 - 1 1 1 1 1 1 -1 -1 1 -1 1 - 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 - 1 1 -1 -1 -1 -1 1 -1 1 -1 1 - 1 -1 1 -1 -1 -1 1 -1 1 -1 1 - 1 1 1 -1 -1 -1 1 -1 1 -1 1 - 1 -1 -1 1 -1 -1 1 -1 1 -1 1 - 1 1 -1 1 -1 -1 1 -1 1 -1 1 - 1 -1 1 1 -1 -1 1 -1 1 -1 1 - 1 1 1 1 -1 -1 1 -1 1 -1 1 - 1 -1 -1 -1 1 -1 1 -1 1 -1 1 - 1 1 -1 -1 1 -1 1 -1 1 -1 1 - 1 -1 1 -1 1 -1 1 -1 1 -1 1 - 1 1 1 -1 1 -1 1 -1 1 -1 1 - 1 -1 -1 1 1 -1 1 -1 1 -1 1 - 1 1 -1 1 1 -1 1 -1 1 -1 1 - 1 -1 1 1 1 -1 1 -1 1 -1 1 - 1 1 1 1 1 -1 1 -1 1 -1 1 - 1 -1 -1 -1 -1 1 1 -1 1 -1 1 - 1 1 -1 -1 -1 1 1 -1 1 -1 1 - 1 -1 1 -1 -1 1 1 -1 1 -1 1 - 1 1 1 -1 -1 1 1 -1 1 -1 1 - 1 -1 -1 1 -1 1 1 -1 1 -1 1 - 1 1 -1 1 -1 1 1 -1 1 -1 1 - 1 -1 1 1 -1 1 1 -1 1 -1 1 - 1 1 1 1 -1 1 1 -1 1 -1 1 - 1 -1 -1 -1 1 1 1 -1 1 -1 1 - 1 1 -1 -1 1 1 1 -1 1 -1 1 - 1 -1 1 -1 1 1 1 -1 1 -1 1 - 1 1 1 -1 1 1 1 -1 1 -1 1 - 1 -1 -1 1 1 1 1 -1 1 -1 1 - 1 1 -1 1 1 1 1 -1 1 -1 1 - 1 -1 1 1 1 1 1 -1 1 -1 1 - 1 1 1 1 1 1 1 -1 1 -1 1 - 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 - 1 1 -1 -1 -1 -1 -1 1 1 -1 1 - 1 -1 1 -1 -1 -1 -1 1 1 -1 1 - 1 1 1 -1 -1 -1 -1 1 1 -1 1 - 1 -1 -1 1 -1 -1 -1 1 1 -1 1 - 1 1 -1 1 -1 -1 -1 1 1 -1 1 - 1 -1 1 1 -1 -1 -1 1 1 -1 1 - 1 1 1 1 -1 -1 -1 1 1 -1 1 - 1 -1 -1 -1 1 -1 -1 1 1 -1 1 - 1 1 -1 -1 1 -1 -1 1 1 -1 1 - 1 -1 1 -1 1 -1 -1 1 1 -1 1 - 1 1 1 -1 1 -1 -1 1 1 -1 1 - 1 -1 -1 1 1 -1 -1 1 1 -1 1 - 1 1 -1 1 1 -1 -1 1 1 -1 1 - 1 -1 1 1 1 -1 -1 1 1 -1 1 - 1 1 1 1 1 -1 -1 1 1 -1 1 - 1 -1 -1 -1 -1 1 -1 1 1 -1 1 - 1 1 -1 -1 -1 1 -1 1 1 -1 1 - 1 -1 1 -1 -1 1 -1 1 1 -1 1 - 1 1 1 -1 -1 1 -1 1 1 -1 1 - 1 -1 -1 1 -1 1 -1 1 1 -1 1 - 1 1 -1 1 -1 1 -1 1 1 -1 1 - 1 -1 1 1 -1 1 -1 1 1 -1 1 - 1 1 1 1 -1 1 -1 1 1 -1 1 - 1 -1 -1 -1 1 1 -1 1 1 -1 1 - 1 1 -1 -1 1 1 -1 1 1 -1 1 - 1 -1 1 -1 1 1 -1 1 1 -1 1 - 1 1 1 -1 1 1 -1 1 1 -1 1 - 1 -1 -1 1 1 1 -1 1 1 -1 1 - 1 1 -1 1 1 1 -1 1 1 -1 1 - 1 -1 1 1 1 1 -1 1 1 -1 1 - 1 1 1 1 1 1 -1 1 1 -1 1 - 1 -1 -1 -1 -1 -1 1 1 1 -1 1 - 1 1 -1 -1 -1 -1 1 1 1 -1 1 - 1 -1 1 -1 -1 -1 1 1 1 -1 1 - 1 1 1 -1 -1 -1 1 1 1 -1 1 - 1 -1 -1 1 -1 -1 1 1 1 -1 1 - 1 1 -1 1 -1 -1 1 1 1 -1 1 - 1 -1 1 1 -1 -1 1 1 1 -1 1 - 1 1 1 1 -1 -1 1 1 1 -1 1 - 1 -1 -1 -1 1 -1 1 1 1 -1 1 - 1 1 -1 -1 1 -1 1 1 1 -1 1 - 1 -1 1 -1 1 -1 1 1 1 -1 1 - 1 1 1 -1 1 -1 1 1 1 -1 1 - 1 -1 -1 1 1 -1 1 1 1 -1 1 - 1 1 -1 1 1 -1 1 1 1 -1 1 - 1 -1 1 1 1 -1 1 1 1 -1 1 - 1 1 1 1 1 -1 1 1 1 -1 1 - 1 -1 -1 -1 -1 1 1 1 1 -1 1 - 1 1 -1 -1 -1 1 1 1 1 -1 1 - 1 -1 1 -1 -1 1 1 1 1 -1 1 - 1 1 1 -1 -1 1 1 1 1 -1 1 - 1 -1 -1 1 -1 1 1 1 1 -1 1 - 1 1 -1 1 -1 1 1 1 1 -1 1 - 1 -1 1 1 -1 1 1 1 1 -1 1 - 1 1 1 1 -1 1 1 1 1 -1 1 - 1 -1 -1 -1 1 1 1 1 1 -1 1 - 1 1 -1 -1 1 1 1 1 1 -1 1 - 1 -1 1 -1 1 1 1 1 1 -1 1 - 1 1 1 -1 1 1 1 1 1 -1 1 - 1 -1 -1 1 1 1 1 1 1 -1 1 - 1 1 -1 1 1 1 1 1 1 -1 1 - 1 -1 1 1 1 1 1 1 1 -1 1 - 1 1 1 1 1 1 1 1 1 -1 1 - 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 - 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 - 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 - 1 1 1 -1 -1 -1 -1 -1 -1 1 1 - 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 - 1 1 -1 1 -1 -1 -1 -1 -1 1 1 - 1 -1 1 1 -1 -1 -1 -1 -1 1 1 - 1 1 1 1 -1 -1 -1 -1 -1 1 1 - 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 - 1 1 -1 -1 1 -1 -1 -1 -1 1 1 - 1 -1 1 -1 1 -1 -1 -1 -1 1 1 - 1 1 1 -1 1 -1 -1 -1 -1 1 1 - 1 -1 -1 1 1 -1 -1 -1 -1 1 1 - 1 1 -1 1 1 -1 -1 -1 -1 1 1 - 1 -1 1 1 1 -1 -1 -1 -1 1 1 - 1 1 1 1 1 -1 -1 -1 -1 1 1 - 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 - 1 1 -1 -1 -1 1 -1 -1 -1 1 1 - 1 -1 1 -1 -1 1 -1 -1 -1 1 1 - 1 1 1 -1 -1 1 -1 -1 -1 1 1 - 1 -1 -1 1 -1 1 -1 -1 -1 1 1 - 1 1 -1 1 -1 1 -1 -1 -1 1 1 - 1 -1 1 1 -1 1 -1 -1 -1 1 1 - 1 1 1 1 -1 1 -1 -1 -1 1 1 - 1 -1 -1 -1 1 1 -1 -1 -1 1 1 - 1 1 -1 -1 1 1 -1 -1 -1 1 1 - 1 -1 1 -1 1 1 -1 -1 -1 1 1 - 1 1 1 -1 1 1 -1 -1 -1 1 1 - 1 -1 -1 1 1 1 -1 -1 -1 1 1 - 1 1 -1 1 1 1 -1 -1 -1 1 1 - 1 -1 1 1 1 1 -1 -1 -1 1 1 - 1 1 1 1 1 1 -1 -1 -1 1 1 - 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 - 1 1 -1 -1 -1 -1 1 -1 -1 1 1 - 1 -1 1 -1 -1 -1 1 -1 -1 1 1 - 1 1 1 -1 -1 -1 1 -1 -1 1 1 - 1 -1 -1 1 -1 -1 1 -1 -1 1 1 - 1 1 -1 1 -1 -1 1 -1 -1 1 1 - 1 -1 1 1 -1 -1 1 -1 -1 1 1 - 1 1 1 1 -1 -1 1 -1 -1 1 1 - 1 -1 -1 -1 1 -1 1 -1 -1 1 1 - 1 1 -1 -1 1 -1 1 -1 -1 1 1 - 1 -1 1 -1 1 -1 1 -1 -1 1 1 - 1 1 1 -1 1 -1 1 -1 -1 1 1 - 1 -1 -1 1 1 -1 1 -1 -1 1 1 - 1 1 -1 1 1 -1 1 -1 -1 1 1 - 1 -1 1 1 1 -1 1 -1 -1 1 1 - 1 1 1 1 1 -1 1 -1 -1 1 1 - 1 -1 -1 -1 -1 1 1 -1 -1 1 1 - 1 1 -1 -1 -1 1 1 -1 -1 1 1 - 1 -1 1 -1 -1 1 1 -1 -1 1 1 - 1 1 1 -1 -1 1 1 -1 -1 1 1 - 1 -1 -1 1 -1 1 1 -1 -1 1 1 - 1 1 -1 1 -1 1 1 -1 -1 1 1 - 1 -1 1 1 -1 1 1 -1 -1 1 1 - 1 1 1 1 -1 1 1 -1 -1 1 1 - 1 -1 -1 -1 1 1 1 -1 -1 1 1 - 1 1 -1 -1 1 1 1 -1 -1 1 1 - 1 -1 1 -1 1 1 1 -1 -1 1 1 - 1 1 1 -1 1 1 1 -1 -1 1 1 - 1 -1 -1 1 1 1 1 -1 -1 1 1 - 1 1 -1 1 1 1 1 -1 -1 1 1 - 1 -1 1 1 1 1 1 -1 -1 1 1 - 1 1 1 1 1 1 1 -1 -1 1 1 - 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 - 1 1 -1 -1 -1 -1 -1 1 -1 1 1 - 1 -1 1 -1 -1 -1 -1 1 -1 1 1 - 1 1 1 -1 -1 -1 -1 1 -1 1 1 - 1 -1 -1 1 -1 -1 -1 1 -1 1 1 - 1 1 -1 1 -1 -1 -1 1 -1 1 1 - 1 -1 1 1 -1 -1 -1 1 -1 1 1 - 1 1 1 1 -1 -1 -1 1 -1 1 1 - 1 -1 -1 -1 1 -1 -1 1 -1 1 1 - 1 1 -1 -1 1 -1 -1 1 -1 1 1 - 1 -1 1 -1 1 -1 -1 1 -1 1 1 - 1 1 1 -1 1 -1 -1 1 -1 1 1 - 1 -1 -1 1 1 -1 -1 1 -1 1 1 - 1 1 -1 1 1 -1 -1 1 -1 1 1 - 1 -1 1 1 1 -1 -1 1 -1 1 1 - 1 1 1 1 1 -1 -1 1 -1 1 1 - 1 -1 -1 -1 -1 1 -1 1 -1 1 1 - 1 1 -1 -1 -1 1 -1 1 -1 1 1 - 1 -1 1 -1 -1 1 -1 1 -1 1 1 - 1 1 1 -1 -1 1 -1 1 -1 1 1 - 1 -1 -1 1 -1 1 -1 1 -1 1 1 - 1 1 -1 1 -1 1 -1 1 -1 1 1 - 1 -1 1 1 -1 1 -1 1 -1 1 1 - 1 1 1 1 -1 1 -1 1 -1 1 1 - 1 -1 -1 -1 1 1 -1 1 -1 1 1 - 1 1 -1 -1 1 1 -1 1 -1 1 1 - 1 -1 1 -1 1 1 -1 1 -1 1 1 - 1 1 1 -1 1 1 -1 1 -1 1 1 - 1 -1 -1 1 1 1 -1 1 -1 1 1 - 1 1 -1 1 1 1 -1 1 -1 1 1 - 1 -1 1 1 1 1 -1 1 -1 1 1 - 1 1 1 1 1 1 -1 1 -1 1 1 - 1 -1 -1 -1 -1 -1 1 1 -1 1 1 - 1 1 -1 -1 -1 -1 1 1 -1 1 1 - 1 -1 1 -1 -1 -1 1 1 -1 1 1 - 1 1 1 -1 -1 -1 1 1 -1 1 1 - 1 -1 -1 1 -1 -1 1 1 -1 1 1 - 1 1 -1 1 -1 -1 1 1 -1 1 1 - 1 -1 1 1 -1 -1 1 1 -1 1 1 - 1 1 1 1 -1 -1 1 1 -1 1 1 - 1 -1 -1 -1 1 -1 1 1 -1 1 1 - 1 1 -1 -1 1 -1 1 1 -1 1 1 - 1 -1 1 -1 1 -1 1 1 -1 1 1 - 1 1 1 -1 1 -1 1 1 -1 1 1 - 1 -1 -1 1 1 -1 1 1 -1 1 1 - 1 1 -1 1 1 -1 1 1 -1 1 1 - 1 -1 1 1 1 -1 1 1 -1 1 1 - 1 1 1 1 1 -1 1 1 -1 1 1 - 1 -1 -1 -1 -1 1 1 1 -1 1 1 - 1 1 -1 -1 -1 1 1 1 -1 1 1 - 1 -1 1 -1 -1 1 1 1 -1 1 1 - 1 1 1 -1 -1 1 1 1 -1 1 1 - 1 -1 -1 1 -1 1 1 1 -1 1 1 - 1 1 -1 1 -1 1 1 1 -1 1 1 - 1 -1 1 1 -1 1 1 1 -1 1 1 - 1 1 1 1 -1 1 1 1 -1 1 1 - 1 -1 -1 -1 1 1 1 1 -1 1 1 - 1 1 -1 -1 1 1 1 1 -1 1 1 - 1 -1 1 -1 1 1 1 1 -1 1 1 - 1 1 1 -1 1 1 1 1 -1 1 1 - 1 -1 -1 1 1 1 1 1 -1 1 1 - 1 1 -1 1 1 1 1 1 -1 1 1 - 1 -1 1 1 1 1 1 1 -1 1 1 - 1 1 1 1 1 1 1 1 -1 1 1 - 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 - 1 1 -1 -1 -1 -1 -1 -1 1 1 1 - 1 -1 1 -1 -1 -1 -1 -1 1 1 1 - 1 1 1 -1 -1 -1 -1 -1 1 1 1 - 1 -1 -1 1 -1 -1 -1 -1 1 1 1 - 1 1 -1 1 -1 -1 -1 -1 1 1 1 - 1 -1 1 1 -1 -1 -1 -1 1 1 1 - 1 1 1 1 -1 -1 -1 -1 1 1 1 - 1 -1 -1 -1 1 -1 -1 -1 1 1 1 - 1 1 -1 -1 1 -1 -1 -1 1 1 1 - 1 -1 1 -1 1 -1 -1 -1 1 1 1 - 1 1 1 -1 1 -1 -1 -1 1 1 1 - 1 -1 -1 1 1 -1 -1 -1 1 1 1 - 1 1 -1 1 1 -1 -1 -1 1 1 1 - 1 -1 1 1 1 -1 -1 -1 1 1 1 - 1 1 1 1 1 -1 -1 -1 1 1 1 - 1 -1 -1 -1 -1 1 -1 -1 1 1 1 - 1 1 -1 -1 -1 1 -1 -1 1 1 1 - 1 -1 1 -1 -1 1 -1 -1 1 1 1 - 1 1 1 -1 -1 1 -1 -1 1 1 1 - 1 -1 -1 1 -1 1 -1 -1 1 1 1 - 1 1 -1 1 -1 1 -1 -1 1 1 1 - 1 -1 1 1 -1 1 -1 -1 1 1 1 - 1 1 1 1 -1 1 -1 -1 1 1 1 - 1 -1 -1 -1 1 1 -1 -1 1 1 1 - 1 1 -1 -1 1 1 -1 -1 1 1 1 - 1 -1 1 -1 1 1 -1 -1 1 1 1 - 1 1 1 -1 1 1 -1 -1 1 1 1 - 1 -1 -1 1 1 1 -1 -1 1 1 1 - 1 1 -1 1 1 1 -1 -1 1 1 1 - 1 -1 1 1 1 1 -1 -1 1 1 1 - 1 1 1 1 1 1 -1 -1 1 1 1 - 1 -1 -1 -1 -1 -1 1 -1 1 1 1 - 1 1 -1 -1 -1 -1 1 -1 1 1 1 - 1 -1 1 -1 -1 -1 1 -1 1 1 1 - 1 1 1 -1 -1 -1 1 -1 1 1 1 - 1 -1 -1 1 -1 -1 1 -1 1 1 1 - 1 1 -1 1 -1 -1 1 -1 1 1 1 - 1 -1 1 1 -1 -1 1 -1 1 1 1 - 1 1 1 1 -1 -1 1 -1 1 1 1 - 1 -1 -1 -1 1 -1 1 -1 1 1 1 - 1 1 -1 -1 1 -1 1 -1 1 1 1 - 1 -1 1 -1 1 -1 1 -1 1 1 1 - 1 1 1 -1 1 -1 1 -1 1 1 1 - 1 -1 -1 1 1 -1 1 -1 1 1 1 - 1 1 -1 1 1 -1 1 -1 1 1 1 - 1 -1 1 1 1 -1 1 -1 1 1 1 - 1 1 1 1 1 -1 1 -1 1 1 1 - 1 -1 -1 -1 -1 1 1 -1 1 1 1 - 1 1 -1 -1 -1 1 1 -1 1 1 1 - 1 -1 1 -1 -1 1 1 -1 1 1 1 - 1 1 1 -1 -1 1 1 -1 1 1 1 - 1 -1 -1 1 -1 1 1 -1 1 1 1 - 1 1 -1 1 -1 1 1 -1 1 1 1 - 1 -1 1 1 -1 1 1 -1 1 1 1 - 1 1 1 1 -1 1 1 -1 1 1 1 - 1 -1 -1 -1 1 1 1 -1 1 1 1 - 1 1 -1 -1 1 1 1 -1 1 1 1 - 1 -1 1 -1 1 1 1 -1 1 1 1 - 1 1 1 -1 1 1 1 -1 1 1 1 - 1 -1 -1 1 1 1 1 -1 1 1 1 - 1 1 -1 1 1 1 1 -1 1 1 1 - 1 -1 1 1 1 1 1 -1 1 1 1 - 1 1 1 1 1 1 1 -1 1 1 1 - 1 -1 -1 -1 -1 -1 -1 1 1 1 1 - 1 1 -1 -1 -1 -1 -1 1 1 1 1 - 1 -1 1 -1 -1 -1 -1 1 1 1 1 - 1 1 1 -1 -1 -1 -1 1 1 1 1 - 1 -1 -1 1 -1 -1 -1 1 1 1 1 - 1 1 -1 1 -1 -1 -1 1 1 1 1 - 1 -1 1 1 -1 -1 -1 1 1 1 1 - 1 1 1 1 -1 -1 -1 1 1 1 1 - 1 -1 -1 -1 1 -1 -1 1 1 1 1 - 1 1 -1 -1 1 -1 -1 1 1 1 1 - 1 -1 1 -1 1 -1 -1 1 1 1 1 - 1 1 1 -1 1 -1 -1 1 1 1 1 - 1 -1 -1 1 1 -1 -1 1 1 1 1 - 1 1 -1 1 1 -1 -1 1 1 1 1 - 1 -1 1 1 1 -1 -1 1 1 1 1 - 1 1 1 1 1 -1 -1 1 1 1 1 - 1 -1 -1 -1 -1 1 -1 1 1 1 1 - 1 1 -1 -1 -1 1 -1 1 1 1 1 - 1 -1 1 -1 -1 1 -1 1 1 1 1 - 1 1 1 -1 -1 1 -1 1 1 1 1 - 1 -1 -1 1 -1 1 -1 1 1 1 1 - 1 1 -1 1 -1 1 -1 1 1 1 1 - 1 -1 1 1 -1 1 -1 1 1 1 1 - 1 1 1 1 -1 1 -1 1 1 1 1 - 1 -1 -1 -1 1 1 -1 1 1 1 1 - 1 1 -1 -1 1 1 -1 1 1 1 1 - 1 -1 1 -1 1 1 -1 1 1 1 1 - 1 1 1 -1 1 1 -1 1 1 1 1 - 1 -1 -1 1 1 1 -1 1 1 1 1 - 1 1 -1 1 1 1 -1 1 1 1 1 - 1 -1 1 1 1 1 -1 1 1 1 1 - 1 1 1 1 1 1 -1 1 1 1 1 - 1 -1 -1 -1 -1 -1 1 1 1 1 1 - 1 1 -1 -1 -1 -1 1 1 1 1 1 - 1 -1 1 -1 -1 -1 1 1 1 1 1 - 1 1 1 -1 -1 -1 1 1 1 1 1 - 1 -1 -1 1 -1 -1 1 1 1 1 1 - 1 1 -1 1 -1 -1 1 1 1 1 1 - 1 -1 1 1 -1 -1 1 1 1 1 1 - 1 1 1 1 -1 -1 1 1 1 1 1 - 1 -1 -1 -1 1 -1 1 1 1 1 1 - 1 1 -1 -1 1 -1 1 1 1 1 1 - 1 -1 1 -1 1 -1 1 1 1 1 1 - 1 1 1 -1 1 -1 1 1 1 1 1 - 1 -1 -1 1 1 -1 1 1 1 1 1 - 1 1 -1 1 1 -1 1 1 1 1 1 - 1 -1 1 1 1 -1 1 1 1 1 1 - 1 1 1 1 1 -1 1 1 1 1 1 - 1 -1 -1 -1 -1 1 1 1 1 1 1 - 1 1 -1 -1 -1 1 1 1 1 1 1 - 1 -1 1 -1 -1 1 1 1 1 1 1 - 1 1 1 -1 -1 1 1 1 1 1 1 - 1 -1 -1 1 -1 1 1 1 1 1 1 - 1 1 -1 1 -1 1 1 1 1 1 1 - 1 -1 1 1 -1 1 1 1 1 1 1 - 1 1 1 1 -1 1 1 1 1 1 1 - 1 -1 -1 -1 1 1 1 1 1 1 1 - 1 1 -1 -1 1 1 1 1 1 1 1 - 1 -1 1 -1 1 1 1 1 1 1 1 - 1 1 1 -1 1 1 1 1 1 1 1 - 1 -1 -1 1 1 1 1 1 1 1 1 - 1 1 -1 1 1 1 1 1 1 1 1 - 1 -1 1 1 1 1 1 1 1 1 1 - 1 1 1 1 1 1 1 1 1 1 1 -end -input_incidence diff --git a/R-proj/inst/extdata/cube10.ine b/R-proj/inst/extdata/cube10.ine deleted file mode 100644 index 1f035f33c..000000000 --- a/R-proj/inst/extdata/cube10.ine +++ /dev/null @@ -1,26 +0,0 @@ -cube10.ine -H-representation -begin - 20 11 real - 1 1 0 0 0 0 0 0 0 0 0 - 1 0 1 0 0 0 0 0 0 0 0 - 1 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 1 0 0 0 0 0 0 - 1 0 0 0 0 1 0 0 0 0 0 - 1 0 0 0 0 0 1 0 0 0 0 - 1 0 0 0 0 0 0 1 0 0 0 - 1 0 0 0 0 0 0 0 1 0 0 - 1 0 0 0 0 0 0 0 0 1 0 - 1 0 0 0 0 0 0 0 0 0 1 - 1 -1 0 0 0 0 0 0 0 0 0 - 1 0 -1 0 0 0 0 0 0 0 0 - 1 0 0 -1 0 0 0 0 0 0 0 - 1 0 0 0 -1 0 0 0 0 0 0 - 1 0 0 0 0 -1 0 0 0 0 0 - 1 0 0 0 0 0 -1 0 0 0 0 - 1 0 0 0 0 0 0 -1 0 0 0 - 1 0 0 0 0 0 0 0 -1 0 0 - 1 0 0 0 0 0 0 0 0 -1 0 - 1 0 0 0 0 0 0 0 0 0 -1 -end -input_incidence diff --git a/R-proj/inst/extdata/cube_10.ext b/R-proj/inst/extdata/cube_10.ext deleted file mode 100644 index ed4dd559e..000000000 --- a/R-proj/inst/extdata/cube_10.ext +++ /dev/null @@ -1,1031 +0,0 @@ -cube_10.ext -V-representation -begin -1024 11 integer -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 1 -1 -1 -1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 1 -1 -1 -1 1 1 1 1 1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 1 -1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 -1 1 1 -1 1 1 -1 1 1 -1 -1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 1 1 1 1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 -1 1 1 1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 -1 1 1 -1 -1 1 1 1 -1 1 1 1 -1 1 -1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 -1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 -1 1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 1 -1 -1 1 1 1 1 1 -1 1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 1 1 -1 -1 1 1 1 1 1 1 1 -1 1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 1 1 1 1 1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 -1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 1 1 1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 -1 1 1 1 1 1 -1 1 -1 1 -1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 1 -1 1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 1 -1 -1 1 -1 1 1 -1 1 1 1 1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 1 1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 1 1 1 -1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 1 -1 1 1 1 1 1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 1 1 1 -1 1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 1 1 1 1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 1 1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 1 -1 1 -1 1 -1 -1 1 1 -1 1 1 -1 1 -1 1 1 -1 1 1 -1 1 1 -1 1 1 -1 -1 -1 1 1 -1 1 1 -1 1 1 -1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 1 1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 -1 -1 1 -1 1 1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 -1 1 1 1 1 1 -1 1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 1 1 -1 -1 1 1 1 -1 -1 -1 1 1 1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 1 1 -1 1 -1 1 1 1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 -1 -1 1 1 1 1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 1 1 1 -1 1 -1 -1 1 1 1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 -1 1 1 1 -1 -1 1 1 1 -1 1 -1 1 1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 1 1 1 -1 1 1 -1 1 1 -1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 -1 1 -1 -1 1 1 1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 1 1 1 -1 1 1 1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 1 -1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 1 1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 1 1 -1 1 1 1 1 -1 1 1 1 -1 1 -1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 1 1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 1 1 1 1 1 -1 -1 1 1 1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 1 -1 1 -1 1 -1 -1 1 1 1 1 1 -1 1 -1 1 1 -1 1 1 1 1 1 -1 1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 -1 1 -1 1 1 1 1 1 -1 1 1 1 -1 -1 1 1 1 1 1 -1 1 1 1 1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 1 1 1 1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 1 -1 1 -1 1 1 1 1 1 1 -1 1 1 -1 -1 1 1 1 1 1 1 -1 1 1 1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 1 -1 1 1 1 1 1 1 1 -1 1 -1 -1 1 1 1 1 1 1 1 -1 1 1 -1 1 1 1 1 1 1 1 1 -1 1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -end -hull -incidence diff --git a/R-proj/inst/extdata/linear_extensions/simple.txt b/R-proj/inst/extdata/linear_extensions/simple.txt deleted file mode 100644 index b50a96df4..000000000 --- a/R-proj/inst/extdata/linear_extensions/simple.txt +++ /dev/null @@ -1,2 +0,0 @@ -50 20 -[[1,2],[1,3],[1,5],[1,7],[2,3],[2,5],[2,8],[3,4],[3,9],[4,5],[4,7],[4,10],[5,6],[5,8],[6,7],[6,8],[6,9],[7,8],[7,9],[9,10]] diff --git a/R-proj/inst/extdata/linear_extensions/simple_poset.txt b/R-proj/inst/extdata/linear_extensions/simple_poset.txt deleted file mode 100644 index 8998e738c..000000000 --- a/R-proj/inst/extdata/linear_extensions/simple_poset.txt +++ /dev/null @@ -1,2 +0,0 @@ -4 3 -[[1,2],[1,3],[3,4]] diff --git a/R-proj/inst/extdata/prod_simplex_10_10.ine b/R-proj/inst/extdata/prod_simplex_10_10.ine deleted file mode 100644 index 0eca1b7d1..000000000 --- a/R-proj/inst/extdata/prod_simplex_10_10.ine +++ /dev/null @@ -1,28 +0,0 @@ -prod_simplex_10.ine -H-representation -begin - 21 21 integer -0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 -end -input_incidence diff --git a/R-proj/inst/extdata/sdpa_n2m3.txt b/R-proj/inst/extdata/sdpa_n2m3.txt deleted file mode 100644 index 0459374cf..000000000 --- a/R-proj/inst/extdata/sdpa_n2m3.txt +++ /dev/null @@ -1,13 +0,0 @@ -2 -1 -3 -1 1 --1 0 0 - 0 -2 1 - 0 1 -2 - 1 -0 -0 --0 -0 -1 --0 -1 -0 --0 -0 1 --0 -0 -0 - 1 -0 -0 diff --git a/R-proj/inst/extdata/simplex10.ext b/R-proj/inst/extdata/simplex10.ext deleted file mode 100644 index c40976554..000000000 --- a/R-proj/inst/extdata/simplex10.ext +++ /dev/null @@ -1,18 +0,0 @@ -simplex_10.ext -V-representation -begin - 11 11 integer -1 1 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 0 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 0 0 -1 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 1 0 -1 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 -end -hull -incidence diff --git a/R-proj/inst/extdata/simplex10.ine b/R-proj/inst/extdata/simplex10.ine deleted file mode 100644 index 0e3cb59ac..000000000 --- a/R-proj/inst/extdata/simplex10.ine +++ /dev/null @@ -1,17 +0,0 @@ -simplex_10.ine -H-representation -begin - 11 11 integer -0 1 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 0 -0 0 0 1 0 0 0 0 0 0 0 -0 0 0 0 1 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 0 -0 0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 1 0 0 0 -0 0 0 0 0 0 0 0 1 0 0 -0 0 0 0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 0 0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -end -input_incidence diff --git a/R-proj/inst/extdata/skinny_cube10.ine b/R-proj/inst/extdata/skinny_cube10.ine deleted file mode 100644 index aba4f0524..000000000 --- a/R-proj/inst/extdata/skinny_cube10.ine +++ /dev/null @@ -1,26 +0,0 @@ -cube_10.ine -H-representation -begin - 20 11 integer - 100 1 0 0 0 0 0 0 0 0 0 - 1 0 1 0 0 0 0 0 0 0 0 - 1 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 1 0 0 0 0 0 0 - 1 0 0 0 0 1 0 0 0 0 0 - 1 0 0 0 0 0 1 0 0 0 0 - 1 0 0 0 0 0 0 1 0 0 0 - 1 0 0 0 0 0 0 0 1 0 0 - 1 0 0 0 0 0 0 0 0 1 0 - 1 0 0 0 0 0 0 0 0 0 1 - 100 -1 0 0 0 0 0 0 0 0 0 - 1 0 -1 0 0 0 0 0 0 0 0 - 1 0 0 -1 0 0 0 0 0 0 0 - 1 0 0 0 -1 0 0 0 0 0 0 - 1 0 0 0 0 -1 0 0 0 0 0 - 1 0 0 0 0 0 -1 0 0 0 0 - 1 0 0 0 0 0 0 -1 0 0 0 - 1 0 0 0 0 0 0 0 -1 0 0 - 1 0 0 0 0 0 0 0 0 -1 0 - 1 0 0 0 0 0 0 0 0 0 -1 -end -input_incidence diff --git a/R-proj/man/Hpolytope.Rd b/R-proj/man/Hpolytope.Rd deleted file mode 100644 index c0b826747..000000000 --- a/R-proj/man/Hpolytope.Rd +++ /dev/null @@ -1,19 +0,0 @@ -\name{Hpolytope} -\alias{Hpolytope} -\title{An \code{R} class to represent H-polytopes.} - -\description{ -A H-polytope is a convex polytope defined by a set of linear inequalities or equivalently a \eqn{d}-dimensional H-polytope with \eqn{m} facets is defined by a \eqn{m\times d} matrix A and a \eqn{m}-dimensional vector b, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. -} -\section{Fields}{ -\itemize{ -\item{\code{A} }{ A \eqn{m\times d} numerical matrix A} - -\item{\code{b} }{ \eqn{m}-dimensional vector b} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For H-representation the default value is 1.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/Rcpp_Hpolytope.Rd b/R-proj/man/Rcpp_Hpolytope.Rd deleted file mode 100644 index 88fa5b766..000000000 --- a/R-proj/man/Rcpp_Hpolytope.Rd +++ /dev/null @@ -1,28 +0,0 @@ -\docType{class} -\name{Rcpp_Hpolytope} -\alias{Rcpp_Hpolytope-class} -\alias{[,Rcpp_Hpolytope-method} -\alias{[,Rcpp_Hpolytope,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Hpolytope-method} -\alias{$,Rcpp_Hpolytope-method} -\alias{filepaths<-,Rcpp_Hpolytope-method} -\title{ -An \code{Rcpp} class to represent H-polytopes, exposed to \code{R} via modules. -} -\description{ -A H-polytope is a convex polytope defined by a set of linear inequalities or equivalently a \eqn{d}-dimensional H-polytope with \eqn{m} facets is defined by a \eqn{m\times d} matrix A and a \eqn{m}-dimensional vector b, s.t.: \eqn{P=\{ Ax\leq b \} }. -} -\details{ -\describe{ -\item{\code{A} }{ A \eqn{m\times d} numerical matrix A} - -\item{\code{b} }{ \eqn{m}-dimensional vector b} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For H-representation the default value is 1.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_Spectrahedron.Rd b/R-proj/man/Rcpp_Spectrahedron.Rd deleted file mode 100644 index 3ac432e59..000000000 --- a/R-proj/man/Rcpp_Spectrahedron.Rd +++ /dev/null @@ -1,21 +0,0 @@ -\docType{class} -\name{Rcpp_Spectrahedron} -\alias{Rcpp_Spectrahedron-class} -\alias{[,Rcpp_Spectrahedron-method} -\alias{[,Rcpp_Spectrahedron,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Spectrahedron-method} -\alias{$,Rcpp_Spectrahedron-method} -\alias{filepaths<-,Rcpp_Spectrahedron-method} -\title{ -An \code{Rcpp} class to represent spectrahedra, exposed to \code{R} via modules. -} -\description{ -A spectrahedron is a convex body defined by a linear matrix inequality of the form \eqn{A_0 + x_1 A_1 + ... + x_n A_n \preceq 0}. -The matrices \eqn{A_i} are symmetric \eqn{m \times m} real matrices and \eqn{\preceq 0} denoted negative semidefiniteness. -} -\details{ -\describe{ -\item{\code{matrices} }{A list with the matrices \eqn{A_0, A_1, ..., A_n}} - } -} - diff --git a/R-proj/man/Rcpp_Vpolytope.Rd b/R-proj/man/Rcpp_Vpolytope.Rd deleted file mode 100644 index 95c46c099..000000000 --- a/R-proj/man/Rcpp_Vpolytope.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\docType{class} -\name{Rcpp_Vpolytope} -\alias{Rcpp_Vpolytope-class} -\alias{[,Rcpp_Vpolytope-method} -\alias{[,Rcpp_Vpolytope,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Vpolytope-method} -\alias{$,Rcpp_Vpolytope-method} -\alias{filepaths<-,Rcpp_Vpolytope-method} -\title{ -An \code{Rcpp} class to represent V-polytopes, exposed to \code{R} via modules. -} -\description{ -A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which corresponds to its vertices. -} -\details{ -\describe{ - \item{\code{V} }{ A \eqn{m\times d} numerical matrix that contains the vertices row-wise} - - \item{\code{type} }{ An integer that declares the representation of the polytope. For V-representation the default value is 2.} - - \item{\code{dimension} }{ The dimension of the polytope.} - - \item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_VpolytopeIntersection.Rd b/R-proj/man/Rcpp_VpolytopeIntersection.Rd deleted file mode 100644 index ec308c3be..000000000 --- a/R-proj/man/Rcpp_VpolytopeIntersection.Rd +++ /dev/null @@ -1,28 +0,0 @@ -\docType{class} -\name{Rcpp_VpolytopeIntersection} -\alias{Rcpp_VpolytopeIntersection-class} -\alias{[,Rcpp_VpolytopeIntersection-method} -\alias{[,Rcpp_VpolytopeIntersection,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_VpolytopeIntersection-method} -\alias{$,Rcpp_VpolytopeIntersection-method} -\alias{filepaths<-,Rcpp_VpolytopeIntersection-method} -\title{ -An \code{Rcpp} class to represent the intersection of two V-polytope, exposed to \code{R} via modules. -} -\description{ -An intersection of two V-polytopes, \eqn{P_1}, \eqn{P_2}, is defined by the intersection of the two coresponding convex hulls. -} -\details{ -\describe{ -\item{\code{V1} }{ The numerical matrix that contains the vertices of \eqn{P_1} row-wise.} - -\item{\code{V2} }{ The numerical matrix that contains the vertices of \eqn{P_2} row-wise.} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For these kinf of polytopes the default value is 4.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_Zonotope.Rd b/R-proj/man/Rcpp_Zonotope.Rd deleted file mode 100644 index 8c010851e..000000000 --- a/R-proj/man/Rcpp_Zonotope.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\docType{class} -\name{Rcpp_Zonotope} -\alias{Rcpp_Zonotope-class} -\alias{[,Rcpp_Zonotope-method} -\alias{[,Rcpp_Zonotope,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Zonotope-method} -\alias{$,Rcpp_Zonotope-method} -\alias{filepaths<-,Rcpp_Zonotope-method} -\title{ -An \code{Rcpp} class to represent zonotopes, exposed to \code{R} via modules. -} -\description{ -A zonotope is a convex polytope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -} -\details{ -\describe{ - \item{\code{G} }{ A \eqn{m\times d} numerical matrix that contains the segments (or generators) row-wise} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For zonotopes the default value is 3.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Spectrahedron.Rd b/R-proj/man/Spectrahedron.Rd deleted file mode 100644 index 6c6df1d8a..000000000 --- a/R-proj/man/Spectrahedron.Rd +++ /dev/null @@ -1,12 +0,0 @@ -\name{Spectrahedron} -\alias{Spectrahedron} -\title{An \code{R} class to represent spectrahedra.} - -\description{ -A spectrahedron is a convex body defined by a linear matrix inequality of the form \eqn{A_0 + x_1 A_1 + ... + x_n A_n \preceq 0}. -The matrices \eqn{A_i} are symmetric \eqn{m \times m} real matrices and \eqn{\preceq 0} denoted negative semidefiniteness. -} -\section{Fields}{ -\itemize{ -\item{\code{matrices} }{A list with the matrices \eqn{A_0, A_1, ..., A_n}} -}} diff --git a/R-proj/man/Vpolytope.Rd b/R-proj/man/Vpolytope.Rd deleted file mode 100644 index e330af8b3..000000000 --- a/R-proj/man/Vpolytope.Rd +++ /dev/null @@ -1,17 +0,0 @@ -\name{Vpolytope} -\alias{Vpolytope} -\title{An \code{R} class to represent V-polytopes.} - -\description{ - A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which corresponds to its vertices. -} -\section{Fields}{ -\itemize{ - \item{\code{V} }{ A \eqn{m\times d} numerical matrix that contains the vertices row-wise} - - \item{\code{type} }{ An integer that declares the representation of the polytope. For V-representation the default value is 2.} - - \item{\code{dimension} }{ The dimension of the polytope.} - - \item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/VpolytopeIntersection.Rd b/R-proj/man/VpolytopeIntersection.Rd deleted file mode 100644 index f7a75c662..000000000 --- a/R-proj/man/VpolytopeIntersection.Rd +++ /dev/null @@ -1,19 +0,0 @@ -\name{VpolytopeIntersection} -\alias{VpolytopeIntersection} -\title{An \code{R} class to represent the intersection of two V-polytopes.} - -\description{ - An intersection of two V-polytopes, \eqn{P_1}, \eqn{P_2}, is defined by the intersection of the two corresponding convex hulls. -} -\section{Fields}{ -\itemize{ -\item{\code{V1} }{ The numerical matrix that contains the vertices of \eqn{P_1} row-wise.} - -\item{\code{V2} }{ The numerical matrix that contains the vertices of \eqn{P_2} row-wise.} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For this polytope the default value is 4.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/Zonotope.Rd b/R-proj/man/Zonotope.Rd deleted file mode 100644 index 959fbed5d..000000000 --- a/R-proj/man/Zonotope.Rd +++ /dev/null @@ -1,17 +0,0 @@ -\name{Zonotope} -\alias{Zonotope} -\title{An \code{R} class to represent zonotopes.} - -\description{ -A zonotope is a convex polytope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -} -\section{Fields}{ -\itemize{ -\item{\code{G} }{ A \eqn{m\times d} numerical matrix that contains the segments (or generators) row-wise} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For zonotopes the default value is 3.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/compute_indicators.Rd b/R-proj/man/compute_indicators.Rd deleted file mode 100644 index c0eaadd9e..000000000 --- a/R-proj/man/compute_indicators.Rd +++ /dev/null @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compute_indicators.R -\name{compute_indicators} -\alias{compute_indicators} -\title{Compute an indicator for each time period that describes the state of a market.} -\usage{ -compute_indicators( - returns, - win_length = NULL, - m = NULL, - n = NULL, - nwarning = NULL, - ncrisis = NULL, - seed = NULL -) -} -\arguments{ -\item{returns}{A \eqn{d}-dimensional vector that describes the direction of the first family of parallel hyperplanes.} - -\item{win_length}{Optional. The length of the sliding window. The default value is 60.} - -\item{m}{Optional. The number of slices for the copula. The default value is 100.} - -\item{n}{Optional. The number of points to sample. The default value is \eqn{5\cdot 10^5}.} - -\item{nwarning}{Optional. The number of consecutive indicators larger than 1 required to declare a warning period. The default value is 60.} - -\item{ncrisis}{Optional. The number of consecutive indicators larger than 1 required to declare a crisis period. The default value is 100.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A list that contains the indicators and the corresponding vector that label each time period with respect to the market state: a) normal, b) crisis, c) warning. -} -\description{ -Given a matrix that contains row-wise the assets' returns and a sliding window \code{win_length}, this function computes an approximation of the joint distribution (copula, e.g. see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}) between portfolios' return and volatility in each time period defined by \code{win_len}. -For each copula it computes an indicator: If the indicator is large it corresponds to a crisis period and if it is small it corresponds to a normal period. -In particular, the periods over which the indicator is greater than 1 for more than 60 consecutive sliding windows are warnings and for more than 100 are crisis. The sliding window is shifted by one day. -} -\examples{ -# simple example on random asset returns -asset_returns = replicate(10, rnorm(14)) -market_states_and_indicators = compute_indicators(asset_returns, 10, 10, 10000, 2, 3) - -} -\references{ -\cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -\dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -} diff --git a/R-proj/man/copula.Rd b/R-proj/man/copula.Rd deleted file mode 100644 index be99e4892..000000000 --- a/R-proj/man/copula.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{copula} -\alias{copula} -\title{Construct a copula using uniform sampling from the unit simplex} -\usage{ -copula(r1, r2 = NULL, sigma = NULL, m = NULL, n = NULL, seed = NULL) -} -\arguments{ -\item{r1}{The \eqn{d}-dimensional normal vector of the first family of parallel hyperplanes.} - -\item{r2}{Optional. The \eqn{d}-dimensional normal vector of the second family of parallel hyperplanes.} - -\item{sigma}{Optional. The \eqn{d\times d} symmetric positive semidefine matrix that describes the family of concentric ellipsoids centered at the origin.} - -\item{m}{The number of the slices for the copula. The default value is 100.} - -\item{n}{The number of points to sample. The default value is \eqn{5\cdot 10^5}.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A \eqn{m\times m} numerical matrix that corresponds to a copula. -} -\description{ -Given two families of parallel hyperplanes or a family of parallel hyperplanes and a family of concentric ellispoids centered at the origin intersecting the canonical simplex, this function uniformly samples from the canonical simplex and construct an approximation of the bivariate probability distribution, called copula (see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}). -At least two families of hyperplanes or one family of hyperplanes and one family of ellipsoids have to be given as input. -} -\examples{ -# compute a copula for two random families of parallel hyperplanes -h1 = runif(n = 10, min = 1, max = 1000) -h1 = h1 / 1000 -h2=runif(n = 10, min = 1, max = 1000) -h2 = h2 / 1000 -cop = copula(r1 = h1, r2 = h2, m = 10, n = 100000) - -# compute a copula for a family of parallel hyperplanes and a family of conentric ellipsoids -h = runif(n = 10, min = 1, max = 1000) -h = h / 1000 -E = replicate(10, rnorm(20)) -E = cov(E) -cop = copula(r1 = h, sigma = E, m = 10, n = 100000) - -} -\references{ -\cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -\dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -} diff --git a/R-proj/man/dinvweibull_with_loc.Rd b/R-proj/man/dinvweibull_with_loc.Rd deleted file mode 100644 index b6600f816..000000000 --- a/R-proj/man/dinvweibull_with_loc.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_lipschitz_constant.R -\name{dinvweibull_with_loc} -\alias{dinvweibull_with_loc} -\title{Inverse weibull distribution PDF with location parameter} -\usage{ -dinvweibull_with_loc(x, k, lambda, theta) -} -\arguments{ -\item{x}{The argument of the PDF} - -\item{k}{The shape parameter} - -\item{lambda}{The scale parameter} - -\item{theta}{The location parameter} -} -\value{ -The value of the PDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at x -} -\description{ -Inverse weibull distribution PDF with location parameter -} diff --git a/R-proj/man/direct_sampling.Rd b/R-proj/man/direct_sampling.Rd deleted file mode 100644 index 4609ec03d..000000000 --- a/R-proj/man/direct_sampling.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{direct_sampling} -\alias{direct_sampling} -\title{Sample perfect uniformly distributed points from well known convex bodies: (a) the unit simplex, (b) the canonical simplex, (c) the boundary of a hypersphere or (d) the interior of a hypersphere.} -\usage{ -direct_sampling(body, n, seed = NULL) -} -\arguments{ -\item{body}{A list to request exact uniform sampling from special well known convex bodies through the following input parameters: -\itemize{ -\item{\code{type} }{ A string that declares the type of the body for the exact sampling: a) \code{'unit_simplex'} for the unit simplex, b) \code{'canonical_simplex'} for the canonical simplex, c) \code{'hypersphere'} for the boundary of a hypersphere centered at the origin, d) \code{'ball'} for the interior of a hypersphere centered at the origin.} -\item{\code{dimension} }{ An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.} -\item{\code{radius} }{ The radius of the \eqn{d}-dimensional hypersphere. The default value is \eqn{1}.} -}} - -\item{n}{The number of points that the function is going to sample.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -} -\description{ -The \eqn{d}-dimensional unit simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i\leq 1}, \eqn{x_i\geq 0}. The \eqn{d}-dimensional canonical simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i = 1}, \eqn{x_i\geq 0}. -} -\examples{ -# 100 uniform points from the 2-d unit ball -points = direct_sampling(n = 100, body = list("type" = "ball", "dimension" = 2)) -} -\references{ -\cite{R.Y. Rubinstein and B. Melamed, -\dQuote{Modern simulation and modeling} \emph{ Wiley Series in Probability and Statistics,} 1998.} - -\cite{A Smith, Noah and W Tromble, Roy, -\dQuote{Sampling Uniformly from the Unit Simplex,} \emph{ Center for Language and Speech Processing Johns Hopkins University,} 2004.} -} diff --git a/R-proj/man/ess.Rd b/R-proj/man/ess.Rd deleted file mode 100644 index f9fbcbcb8..000000000 --- a/R-proj/man/ess.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{ess} -\alias{ess} -\title{Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal} -\usage{ -ess(samples) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} -} -\value{ -A vector that contains the values of PSRF for each coordinate -} -\description{ -Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -} -\references{ -\cite{Gelman, A. and Rubin, D. B., -\dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} - -\cite{Brooks, S. and Gelman, A., -\dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -} diff --git a/R-proj/man/estimtate_lipschitz_constant.Rd b/R-proj/man/estimtate_lipschitz_constant.Rd deleted file mode 100644 index 5418857d2..000000000 --- a/R-proj/man/estimtate_lipschitz_constant.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_lipschitz_constant.R -\name{estimtate_lipschitz_constant} -\alias{estimtate_lipschitz_constant} -\title{Estimate the Lipschitz Constant of a function f} -\usage{ -estimtate_lipschitz_constant(f, P, n) -} -\arguments{ -\item{f}{Function whose Lipschitz constant is to be estimated} - -\item{P}{Domain of f (a convex polytope)} - -\item{n}{Number of samples to take - -The procedure draws n uniform samples from P and evaluates the Lipschitz -constant at subsequent samples (where the sampler moves to a new point), -It then returns the maximum observation} -} -\value{ -An estimate of the Lipschitz constant -} -\description{ -Estimate the Lipschitz Constant of a function f -} diff --git a/R-proj/man/exact_vol.Rd b/R-proj/man/exact_vol.Rd deleted file mode 100644 index 593247409..000000000 --- a/R-proj/man/exact_vol.Rd +++ /dev/null @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{exact_vol} -\alias{exact_vol} -\title{Compute the exact volume of (a) a zonotope (b) an arbitrary simplex in V-representation or (c) if the volume is known and declared by the input object.} -\usage{ -exact_vol(P) -} -\arguments{ -\item{P}{A polytope} -} -\value{ -The exact volume of the input polytope, for zonotopes, simplices in V-representation and polytopes with known exact volume -} -\description{ -Given a zonotope (as an object of class Zonotope), this function computes the sum of the absolute values of the determinants of all the \eqn{d \times d} submatrices of the \eqn{m\times d} matrix \eqn{G} that contains row-wise the \eqn{m} \eqn{d}-dimensional segments that define the zonotope. -For an arbitrary simplex that is given in V-representation this function computes the absolute value of the determinant formed by the simplex's points assuming it is shifted to the origin. -} -\examples{ - -# compute the exact volume of a 5-dimensional zonotope defined by the Minkowski sum of 10 segments -Z = gen_rand_zonotope(2, 5) -vol = exact_vol(Z) - -\donttest{# compute the exact volume of a 2-d arbitrary simplex -V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE) -P = Vpolytope$new(V) -vol = exact_vol(P) -} - -# compute the exact volume the 10-dimensional cross polytope -P = gen_cross(10,'V') -vol = exact_vol(P) -} -\references{ -\cite{E. Gover and N. Krikorian, -\dQuote{Determinants and the Volumes of Parallelotopes and Zonotopes,} \emph{Linear Algebra and its Applications, 433(1), 28 - 40,} 2010.} -} diff --git a/R-proj/man/file_to_polytope.Rd b/R-proj/man/file_to_polytope.Rd deleted file mode 100644 index 8ec843d53..000000000 --- a/R-proj/man/file_to_polytope.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/file_to_polytope.R -\name{file_to_polytope} -\alias{file_to_polytope} -\title{function to get an ine or an ext file and returns the corresponding polytope} -\usage{ -file_to_polytope(path, zonotope = FALSE) -} -\arguments{ -\item{path}{A string that containes the path to an ine or a ext file. The ine file desrcibes a H-polytope and ext file describes a V-polytope or a zonotope.} - -\item{zonotope}{A boolean parameter. It has to be TRUE when the path leads to an .ext file that describes a zonotope.} -} -\value{ -A polytope class. If the path corresponds to an ine file then the return value represents a H-polytope. If it corresponds to an ext file the return value represents a V-polytope (default choice) or a zonotope if the second argument is TRUE. -} -\description{ -For an ".ine" file it generates the corresponding H-polytope. For an ".ext" file it generates the corresponding V-polytope or zonotope. -For more details on those file formats see \url{https://github.com/GeomScale/volume_approximation/blob/develop/doc/cpp_interface.md#polytope-input}. -} diff --git a/R-proj/man/frustum_of_simplex.Rd b/R-proj/man/frustum_of_simplex.Rd deleted file mode 100644 index bcb075eb4..000000000 --- a/R-proj/man/frustum_of_simplex.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{frustum_of_simplex} -\alias{frustum_of_simplex} -\title{Compute the percentage of the volume of the simplex that is contained in the intersection of a half-space and the simplex.} -\usage{ -frustum_of_simplex(a, z0) -} -\arguments{ -\item{a}{A \eqn{d}-dimensional vector that defines the direction of the hyperplane.} - -\item{z0}{The scalar that defines the half-space.} -} -\value{ -The percentage of the volume of the simplex that is contained in the intersection of a given half-space and the simplex. -} -\description{ -A half-space \eqn{H} is given as a pair of a vector \eqn{a\in R^d} and a scalar \eqn{z0\in R} s.t.: \eqn{a^Tx\leq z0}. This function calls the Ali's version of the Varsi formula to compute a frustum of the simplex. -} -\examples{ -# compute the frustum of H: -x1+x2<=0 -a=c(-1,1) -z0=0 -frustum = frustum_of_simplex(a, z0) -} -\references{ -\cite{Varsi, Giulio, -\dQuote{The multidimensional content of the frustum of the simplex,} \emph{Pacific J. Math. 46, no. 1, 303--314,} 1973.} - -\cite{Ali, Mir M., -\dQuote{Content of the frustum of a simplex,} \emph{ Pacific J. Math. 48, no. 2, 313--322,} 1973.} -} diff --git a/R-proj/man/gen_birkhoff.Rd b/R-proj/man/gen_birkhoff.Rd deleted file mode 100644 index b5659c021..000000000 --- a/R-proj/man/gen_birkhoff.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_birkhoff.R -\name{gen_birkhoff} -\alias{gen_birkhoff} -\title{Generator function for Birkhoff polytope} -\usage{ -gen_birkhoff(n) -} -\arguments{ -\item{n}{The order of the Birkhoff polytope} -} -\value{ -A polytope class representing the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -} -\description{ -This function can be used to generate the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -The dimension of the generated polytope is \eqn{(n-1)^2}. -} -\examples{ -# generate the Birkhoff polytope of order 5 -P = gen_birkhoff(5) -} diff --git a/R-proj/man/gen_cross.Rd b/R-proj/man/gen_cross.Rd deleted file mode 100644 index 53e84c78d..000000000 --- a/R-proj/man/gen_cross.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_cross.R -\name{gen_cross} -\alias{gen_cross} -\title{Generator function for cross polytopes} -\usage{ -gen_cross(dimension, representation) -} -\arguments{ -\item{dimension}{The dimension of the cross polytope.} - -\item{representation}{A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation.} -} -\value{ -A polytope class representing a cross polytope in H- or V-representation. -} -\description{ -This function generates the \eqn{d}-dimensional cross polytope in H- or V-representation. -} -\examples{ -# generate a 10-dimensional cross polytope in H-representation -P = gen_cross(5, 'H') - -# generate a 15-dimension cross polytope in V-representation -P = gen_cross(15, 'V') -} diff --git a/R-proj/man/gen_cube.Rd b/R-proj/man/gen_cube.Rd deleted file mode 100644 index efb486d61..000000000 --- a/R-proj/man/gen_cube.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_cube.R -\name{gen_cube} -\alias{gen_cube} -\title{Generator function for hypercubes} -\usage{ -gen_cube(dimension, representation) -} -\arguments{ -\item{dimension}{The dimension of the hypercube} - -\item{representation}{A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation.} -} -\value{ -A polytope class representing the unit \eqn{d}-dimensional hypercube in H- or V-representation. -} -\description{ -This function generates the \eqn{d}-dimensional unit hypercube \eqn{[-1,1]^d} in H- or V-representation. -} -\examples{ -# generate a 10-dimensional hypercube in H-representation -P = gen_cube(10, 'H') - -# generate a 15-dimension hypercube in V-representation -P = gen_cube(5, 'V') -} diff --git a/R-proj/man/gen_prod_simplex.Rd b/R-proj/man/gen_prod_simplex.Rd deleted file mode 100644 index 108a2dc1b..000000000 --- a/R-proj/man/gen_prod_simplex.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_prod_simplex.R -\name{gen_prod_simplex} -\alias{gen_prod_simplex} -\title{Generator function for product of simplices} -\usage{ -gen_prod_simplex(dimension) -} -\arguments{ -\item{dimension}{The dimension of the simplices.} -} -\value{ -A polytope class representing the product of the two \eqn{d}-dimensional unit simplices in H-representation. -} -\description{ -This function generates a \eqn{2d}-dimensional polytope that is defined as the product of two \eqn{d}-dimensional unit simplices in H-representation. -} -\examples{ -# generate a product of two 5-dimensional simplices. -P = gen_prod_simplex(5) -} diff --git a/R-proj/man/gen_rand_hpoly.Rd b/R-proj/man/gen_rand_hpoly.Rd deleted file mode 100644 index e4db1c9e5..000000000 --- a/R-proj/man/gen_rand_hpoly.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_rand_hpoly.R -\name{gen_rand_hpoly} -\alias{gen_rand_hpoly} -\title{Generator function for random H-polytopes} -\usage{ -gen_rand_hpoly(dimension, nfacets, seed = NULL) -} -\arguments{ -\item{dimension}{The dimension of the convex polytope.} - -\item{nfacets}{The number of the facets.} - -\item{seed}{Optional. A fixed seed for the generator.} -} -\value{ -A polytope class representing a H-polytope. -} -\description{ -This function generates a \eqn{d}-dimensional polytope in H-representation with \eqn{m} facets. We pick \eqn{m} random hyperplanes tangent on the \eqn{d}-dimensional unit hypersphere as facets. -} -\examples{ -# generate a 10-dimensional polytope with 50 facets -P = gen_rand_hpoly(10, 50) -} diff --git a/R-proj/man/gen_rand_vpoly.Rd b/R-proj/man/gen_rand_vpoly.Rd deleted file mode 100644 index e2c3c0978..000000000 --- a/R-proj/man/gen_rand_vpoly.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_rand_vpoly.R -\name{gen_rand_vpoly} -\alias{gen_rand_vpoly} -\title{Generator function for random V-polytopes} -\usage{ -gen_rand_vpoly(dimension, nvertices, generator = NULL, seed = NULL) -} -\arguments{ -\item{dimension}{The dimension of the convex polytope.} - -\item{nvertices}{The number of the vertices.} - -\item{generator}{The body that the generator samples uniformly the vertices from: (a) 'cube' or (b) 'sphere'.} - -\item{seed}{Optional. A fixed seed for the generator.} -} -\value{ -A polytope class representing a V-polytope. -} -\description{ -This function generates a \eqn{d}-dimensional polytope in V-representation with \eqn{m} vertices. We pick \eqn{m} random points from the boundary of the \eqn{d}-dimensional unit hypersphere as vertices. -} -\examples{ -# generate a 10-dimensional polytope defined as the convex hull of 25 random vertices -P = gen_rand_vpoly(10, 25) -} diff --git a/R-proj/man/gen_rand_zonotope.Rd b/R-proj/man/gen_rand_zonotope.Rd deleted file mode 100644 index ab971d35e..000000000 --- a/R-proj/man/gen_rand_zonotope.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_rand_zonotope.R -\name{gen_rand_zonotope} -\alias{gen_rand_zonotope} -\title{Generator function for zonotopes} -\usage{ -gen_rand_zonotope(dimension, nsegments, generator = NULL, seed = NULL) -} -\arguments{ -\item{dimension}{The dimension of the zonotope.} - -\item{nsegments}{The number of segments that generate the zonotope.} - -\item{generator}{The distribution to pick the length of each segment from \eqn{[0,100]}: (a) 'uniform', (b) 'gaussian' or (c) 'exponential'.} - -\item{seed}{Optional. A fixed seed for the generator.} -} -\value{ -A polytope class representing a zonotope. -} -\description{ -This function generates a random \eqn{d}-dimensional zonotope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -The function considers \eqn{m} random directions in \eqn{R^d}. There are three strategies to pick the length of each segment: a) it is uniformly sampled from \eqn{[0,100]}, b) it is random from \eqn{\mathcal{N}(50,(50/3)^2)} truncated to \eqn{[0,100]}, c) it is random from \eqn{Exp(1/30)} truncated to \eqn{[0,100]}. -} -\examples{ -# generate a 10-dimensional zonotope defined by the Minkowski sum of 20 segments -P = gen_rand_zonotope(10, 20) -} diff --git a/R-proj/man/gen_simplex.Rd b/R-proj/man/gen_simplex.Rd deleted file mode 100644 index bed04a3a6..000000000 --- a/R-proj/man/gen_simplex.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_simplex.R -\name{gen_simplex} -\alias{gen_simplex} -\title{Generator function for simplices} -\usage{ -gen_simplex(dimension, representation) -} -\arguments{ -\item{dimension}{The dimension of the unit simplex.} - -\item{representation}{A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation.} -} -\value{ -A polytope class representing the \eqn{d}-dimensional unit simplex in H- or V-representation. -} -\description{ -This function generates the \eqn{d}-dimensional unit simplex in H- or V-representation. -} -\examples{ -# generate a 10-dimensional simplex in H-representation -PolyList = gen_simplex(10, 'H') - -# generate a 20-dimensional simplex in V-representation -P = gen_simplex(20, 'V') -} diff --git a/R-proj/man/gen_skinny_cube.Rd b/R-proj/man/gen_skinny_cube.Rd deleted file mode 100644 index 916f5e20a..000000000 --- a/R-proj/man/gen_skinny_cube.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_skinny_cube.R -\name{gen_skinny_cube} -\alias{gen_skinny_cube} -\title{Generator function for skinny hypercubes} -\usage{ -gen_skinny_cube(dimension) -} -\arguments{ -\item{dimension}{The dimension of the skinny hypercube.} -} -\value{ -A polytope class representing the \eqn{d}-dimensional skinny hypercube in H-representation. -} -\description{ -This function generates a \eqn{d}-dimensional skinny hypercube \eqn{[-1,1]^{d-1}\times [-100,100]}. -} -\examples{ -# generate a 10-dimensional skinny hypercube. -P = gen_skinny_cube(10) -} diff --git a/R-proj/man/geweke.Rd b/R-proj/man/geweke.Rd deleted file mode 100644 index bcaa199d8..000000000 --- a/R-proj/man/geweke.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{geweke} -\alias{geweke} -\title{Geweke's MCMC diagnostic} -\usage{ -geweke(samples, frac_first = NULL, frac_last = NULL) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} - -\item{frac_first}{Optional. The portion of the first in order points in matrix samples.} - -\item{frac_last}{Optional. The portion of the last in order points in matrix samples.} -} -\value{ -A boolean to denote if the result of Geweke diagnostic: (i) false if the null hypothesis is rejected, (ii) true if the null hypothesis is not rejected. -} -\description{ -Geweke's MCMC diagnostic -} -\references{ -\cite{Geweke, J., -\dQuote{Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,} \emph{ In Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -} diff --git a/R-proj/man/inner_ball.Rd b/R-proj/man/inner_ball.Rd deleted file mode 100644 index f267faad1..000000000 --- a/R-proj/man/inner_ball.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{inner_ball} -\alias{inner_ball} -\title{Compute an inscribed ball of a convex polytope} -\usage{ -inner_ball(P, lpsolve = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection.} - -\item{lpsolve}{Optional. A boolean variable to compute the Chebychev ball of an H-polytope using the lpsolve library.} -} -\value{ -A \eqn{(d+1)}-dimensional vector that describes the inscribed ball. The first \eqn{d} coordinates corresponds to the center of the ball and the last one to the radius. -} -\description{ -For a H-polytope described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }, this function computes the largest inscribed ball (Chebychev ball) by solving the corresponding linear program. -For both zonotopes and V-polytopes the function computes the minimum \eqn{r} s.t.: \eqn{ r e_i \in P} for all \eqn{i=1, \dots ,d}. Then the ball centered at the origin with radius \eqn{r/ \sqrt{d}} is an inscribed ball. -} -\examples{ -# compute the Chebychev ball of the 2d unit simplex -P = gen_cube(10,'H') -ball_vec = inner_ball(P) - -# compute an inscribed ball of the 3-dimensional unit cube in V-representation -P = gen_cube(3, 'V') -ball_vec = inner_ball(P, lpsolve = TRUE) -} diff --git a/R-proj/man/loadSdpaFormatFile.Rd b/R-proj/man/loadSdpaFormatFile.Rd deleted file mode 100644 index bb6aa7558..000000000 --- a/R-proj/man/loadSdpaFormatFile.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{loadSdpaFormatFile} -\alias{loadSdpaFormatFile} -\title{Read a SDPA format file} -\usage{ -loadSdpaFormatFile(inputFile = NULL) -} -\arguments{ -\item{inputFile}{Name of the input file} -} -\value{ -A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction" -} -\description{ -Read a SDPA format file -} -\examples{ -path = system.file('extdata', package = 'volesti') -l = loadSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -} diff --git a/R-proj/man/ode_solve.Rd b/R-proj/man/ode_solve.Rd deleted file mode 100644 index b4e8e4b90..000000000 --- a/R-proj/man/ode_solve.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{ode_solve} -\alias{ode_solve} -\title{Solve an ODE of the form dx^n / dt^n = F(x, t)} -\usage{ -ode_solve( - n, - step_size, - order, - dimension, - initial_time, - F, - method, - domains = NULL, - initial_conditions = NULL -) -} -\arguments{ -\item{n}{The number of steps.} - -\item{step_size}{The step size.} - -\item{order}{The ODE order (default is n = 1)} - -\item{dimension}{The dimension of each derivative} - -\item{initial_time}{The initial time} - -\item{F}{The function oracle F(x, t) in the ODE.} - -\item{method}{The method to be used} - -\item{domains}{A list of n H-polytopes with keys "P_1", "P_2", ..., "P_n" that correspond to each derivative's domain} - -\item{initial_conditions}{The initial conditions provided to the solver. Must be provided in a list with keys "x_1", ..., "x_n" and column vectors as values. The state "x_n" represents the (n-1)-th order derivative with respect to time} -} -\value{ -A list which contains elements "x_1", ..., "x_n" representing each derivative results. Each "x_i" corresponds to a d x n matrix where each column represents a certain timestep of the solver. -} -\description{ -Solve an ODE of the form dx^n / dt^n = F(x, t) -} -\examples{ -# Please visit the examples directory on examples demonstrating usage of the ODE solvers. - -} diff --git a/R-proj/man/pinvweibull_with_loc.Rd b/R-proj/man/pinvweibull_with_loc.Rd deleted file mode 100644 index 08eecf30c..000000000 --- a/R-proj/man/pinvweibull_with_loc.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_lipschitz_constant.R -\name{pinvweibull_with_loc} -\alias{pinvweibull_with_loc} -\title{Inverse weibull distribution CDF with location parameter} -\usage{ -pinvweibull_with_loc(q, k, lambda, theta) -} -\arguments{ -\item{q}{The argument of the CDF} - -\item{k}{The shape parameter} - -\item{lambda}{The scale parameter} - -\item{theta}{The location parameter} -} -\value{ -The value of the CDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at q -} -\description{ -Inverse weibull distribution CDF with location parameter -} diff --git a/R-proj/man/poly_gen.Rd b/R-proj/man/poly_gen.Rd deleted file mode 100644 index be2ed4dd0..000000000 --- a/R-proj/man/poly_gen.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{poly_gen} -\alias{poly_gen} -\title{An internal Rccp function as a polytope generator} -\usage{ -poly_gen(kind_gen, Vpoly_gen, Zono_gen, dim_gen, m_gen, seed = NULL) -} -\arguments{ -\item{kind_gen}{An integer to declare the type of the polytope.} - -\item{Vpoly_gen}{A boolean parameter to declare if the requested polytope has to be in V-representation.} - -\item{Zono_gen}{A boolean parameter to declare if the requested polytope has to be a zonotope.} - -\item{dim_gen}{An integer to declare the dimension of the requested polytope.} - -\item{m_gen}{An integer to declare the number of generators for the requested random zonotope or the number of vertices for a V-polytope.} - -\item{seed}{Optional. A fixed seed for the random polytope generator.} -} -\value{ -A numerical matrix describing the requested polytope -} -\description{ -An internal Rccp function as a polytope generator -} -\keyword{internal} diff --git a/R-proj/man/psrf_multivariate.Rd b/R-proj/man/psrf_multivariate.Rd deleted file mode 100644 index b941783fa..000000000 --- a/R-proj/man/psrf_multivariate.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{psrf_multivariate} -\alias{psrf_multivariate} -\title{Gelman-Rubin Potential Scale Reduction Factor (PSRF)} -\usage{ -psrf_multivariate(samples) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} -} -\value{ -The value of multivariate PSRF by S. Brooks and A. Gelman. -} -\description{ -Gelman-Rubin Potential Scale Reduction Factor (PSRF) -} -\references{ -\cite{Gelman, A. and Rubin, D. B., -\dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} - -\cite{Brooks, S. and Gelman, A., -\dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -} diff --git a/R-proj/man/psrf_univariate.Rd b/R-proj/man/psrf_univariate.Rd deleted file mode 100644 index 45aff7ee0..000000000 --- a/R-proj/man/psrf_univariate.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{psrf_univariate} -\alias{psrf_univariate} -\title{Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal} -\usage{ -psrf_univariate(samples, method = NULL) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} - -\item{method}{A string to reauest diagnostic: (i) \code{'normal'} for psrf of Gelman-Rubin and (ii) \code{'interval'} for psrf of Brooks-Gelman.} -} -\value{ -A vector that contains the values of PSRF for each coordinate -} -\description{ -Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -} -\references{ -\cite{Gelman, A. and Rubin, D. B., -\dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} - -\cite{Brooks, S. and Gelman, A., -\dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -} diff --git a/R-proj/man/raftery.Rd b/R-proj/man/raftery.Rd deleted file mode 100644 index 0415442e7..000000000 --- a/R-proj/man/raftery.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{raftery} -\alias{raftery} -\title{Raftery and Lewis MCMC diagnostic} -\usage{ -raftery(samples, q = NULL, r = NULL, s = NULL) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} - -\item{q}{Optional. The quantile of the quantity of interest. The default value is 0.025.} - -\item{r}{Optional. The level of precision desired. The default value is 0.01.} - -\item{s}{Optional. The probability associated with r. The default value is 0.95.} -} -\value{ -(i) The number of draws required for burn-in, (ii) the skip parameter for 1st-order Markov chain, (iii) the skip parameter sufficient to get independence chain, (iv) the number of draws required to achieve r precision, (v) the number of draws if the chain is white noise, (vi) the I-statistic from Raftery and Lewis (1992). -} -\description{ -Raftery and Lewis MCMC diagnostic -} -\references{ -\cite{Raftery, A. E. and Lewis, S. M., -\dQuote{How many iterations in the Gibbs sampler?,} \emph{Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -} diff --git a/R-proj/man/readSdpaFormatFile.Rd b/R-proj/man/readSdpaFormatFile.Rd deleted file mode 100644 index 878a11965..000000000 --- a/R-proj/man/readSdpaFormatFile.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_sdpa_file.R -\name{readSdpaFormatFile} -\alias{readSdpaFormatFile} -\title{Read a SDPA format file} -\usage{ -readSdpaFormatFile(path) -} -\arguments{ -\item{path}{Name of the input file} -} -\value{ -A list with two named items: an item "matrices" which is an object of class Spectrahedron and an vector "objFunction" -} -\description{ -Read a SDPA format file and return a spectrahedron (an object of class Spectrahedron) which is defined by -the linear matrix inequality in the input file, and the objective function. -} -\examples{ -path = system.file('extdata', package = 'volesti') -l = readSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -Spectrahedron = l$spectrahedron -objFunction = l$objFunction -} diff --git a/R-proj/man/rotate_polytope.Rd b/R-proj/man/rotate_polytope.Rd deleted file mode 100644 index 70c9c3adf..000000000 --- a/R-proj/man/rotate_polytope.Rd +++ /dev/null @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rotate_polytope.R -\name{rotate_polytope} -\alias{rotate_polytope} -\title{Apply a random rotation to a convex polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes)} -\usage{ -rotate_polytope(P, T = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope, (b) Vpolytope, (c) Zonotope, (d) intersection of two V-polytopes.} - -\item{T}{Optional. A \eqn{d\times d} rotation matrix.} - -\item{seed}{Optional. A fixed seed for the random linear map generator.} -} -\value{ -A list that contains the rotated polytope and the matrix \eqn{T} of the linear transformation. -} -\description{ -Given a convex H- or V- polytope or a zonotope or an intersection of two V-polytopes as input, this function applies (a) a random rotation or (b) a given rotation by an input matrix \eqn{T}. -} -\details{ -Let \eqn{P} be the given polytope and \eqn{Q} the rotated one and \eqn{T} be the matrix of the linear transformation. -\itemize{ -\item{If \eqn{P} is in H-representation and \eqn{A} is the matrix that contains the normal vectors of the facets of \eqn{Q} then \eqn{AT} contains the normal vactors of the facets of \eqn{P}.} -\item{If \eqn{P} is in V-representation and \eqn{V} is the matrix that contains column-wise the vertices of \eqn{Q} then \eqn{T^TV} contains the vertices of \eqn{P}.} -\item{If \eqn{P} is a zonotope and \eqn{G} is the matrix that contains column-wise the generators of \eqn{Q} then \eqn{T^TG} contains the generators of \eqn{P}.} -\item{If \eqn{M} is a matrix that contains column-wise points in \eqn{Q} then \eqn{T^TM} contains points in \eqn{P}.} -} -} -\examples{ -# rotate a H-polytope (2d unit simplex) -P = gen_simplex(2,'H') -poly_matrix_list = rotate_polytope(P) - -# rotate a V-polytope (3d cube) -P = gen_cube(3, 'V') -poly_matrix_list = rotate_polytope(P) - -# rotate a 5-dimensional zonotope defined by the Minkowski sum of 15 segments -Z = gen_rand_zonotope(3,6) -poly_matrix_list = rotate_polytope(Z) -} diff --git a/R-proj/man/rotating.Rd b/R-proj/man/rotating.Rd deleted file mode 100644 index 4b091f815..000000000 --- a/R-proj/man/rotating.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{rotating} -\alias{rotating} -\title{An internal Rccp function for the random rotation of a convex polytope} -\usage{ -rotating(P, T = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope (H-, V-polytope or a zonotope).} - -\item{T}{Optional. A rotation matrix.} - -\item{seed}{Optional. A fixed seed for the random linear map generator.} -} -\value{ -A matrix that describes the rotated polytope -} -\description{ -An internal Rccp function for the random rotation of a convex polytope -} -\keyword{internal} diff --git a/R-proj/man/round_polytope.Rd b/R-proj/man/round_polytope.Rd deleted file mode 100644 index 787e40fb0..000000000 --- a/R-proj/man/round_polytope.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/round_polytope.R -\name{round_polytope} -\alias{round_polytope} -\title{Apply rounding to a convex polytope (H-polytope, V-polytope or a zonotope)} -\usage{ -round_polytope(P, method = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope.} - -\item{method}{Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a dataset, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid, (c) \code{'isotropy'} for the method based on svd decomposition. The default method is \code{'mee'} for all the representations.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A list with 4 elements: (a) a polytope of the same class as the input polytope class and (b) the element "T" which is the matrix of the inverse linear transformation that is applied on the input polytope, (c) the element "shift" which is the opposite vector of that which has shifted the input polytope, (d) the element "round_value" which is the determinant of the square matrix of the linear transformation that is applied on the input polytope. -} -\description{ -Given a convex H or V polytope or a zonotope as input this function brings the polytope in rounded position based on minimum volume enclosing ellipsoid of a pointset. -} -\examples{ -# round a 5d skinny cube -P = gen_skinny_cube(5) -listHpoly = round_polytope(P) - -# round a V-polytope (3d unit cube) -P = gen_cube(3, 'V') -ListVpoly = round_polytope(P) - -# round a 2-dimensional zonotope defined by 6 generators -Z = gen_rand_zonotope(2,6) -ListZono = round_polytope(Z) -} -\references{ -\cite{I.Z.Emiris and V. Fisikopoulos, -\dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, - -\cite{Michael J. Todd and E. Alper Yildirim, -\dQuote{On Khachiyan’s Algorithm for the Computation of Minimum Volume Enclosing Ellipsoids,} \emph{Discrete Applied Mathematics,} 2007.} - -\cite{B. Cousins and S. Vempala, -\dQuote{A practical volume algorithm,} \emph{Math. Prog. Comp.,} 2016.}, - -\cite{Yin Zhang and Liyan Gao, -\dQuote{On Numerical Solution of the Maximum Volume Ellipsoid Problem,} \emph{SIAM Journal on Optimization,} 2003.}, -} diff --git a/R-proj/man/rounding.Rd b/R-proj/man/rounding.Rd deleted file mode 100644 index 75be33968..000000000 --- a/R-proj/man/rounding.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{rounding} -\alias{rounding} -\title{Internal rcpp function for the rounding of a convex polytope} -\usage{ -rounding(P, method = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope (H- or V-representation or zonotope).} - -\item{method}{Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a uniform sample from P, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid in P, (c) \code{'isotropy'} for the method based on isotropy. The default method is \code{'min_ellipsoid'} for all the representations.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A numerical matrix that describes the rounded polytope, a numerical matrix of the inverse linear transofmation that is applied on the input polytope, the numerical vector the the input polytope is shifted and the determinant of the matrix of the linear transformation that is applied on the input polytope. -} -\description{ -Internal rcpp function for the rounding of a convex polytope -} -\keyword{internal} diff --git a/R-proj/man/sample_points.Rd b/R-proj/man/sample_points.Rd deleted file mode 100644 index f5ea6f2bf..000000000 --- a/R-proj/man/sample_points.Rd +++ /dev/null @@ -1,78 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{sample_points} -\alias{sample_points} -\title{Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes).} -\usage{ -sample_points(P, n, random_walk = NULL, distribution = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection.} - -\item{n}{The number of points that the function is going to sample from the convex polytope.} - -\item{random_walk}{Optional. A list that declares the random walk and some related parameters as follows: -\itemize{ -\item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR x) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave) xi) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method. The default walk is \code{'aBiW'} for the uniform distribution or \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes.} -\item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.} -\item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.} -\item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.} -\item{\code{BaW_rad} }{ The radius for the ball walk.} -\item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.} -\item{\code{solver}} {Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson} -\item{\code{step_size} {Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.}} -}} - -\item{distribution}{Optional. A list that declares the target density and some related parameters as follows: -\itemize{ -\item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution. The default target distribution is uniform. c) Logconcave with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex. } -\item{\code{variance} }{ The variance of the multidimensional spherical gaussian. The default value is 1.} -\item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.} -\item{\code{L_}} { Smoothness constant (for logconcave). } -\item{\code{m}} { Strong-convexity constant (for logconcave). } -\item{\code{negative_logprob}} { Negative log-probability (for logconcave). } -\item{\code{negative_logprob_gradient}} { Negative log-probability gradient (for logconcave). } -}} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -} -\description{ -Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). -} -\examples{ -# uniform distribution from the 3d unit cube in H-representation using ball walk -P = gen_cube(3, 'H') -points = sample_points(P, n = 100, random_walk = list("walk" = "BaW", "walk_length" = 5)) - -# gaussian distribution from the 2d unit simplex in H-representation with variance = 2 -A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) -b = c(0,0,1) -P = Hpolytope$new(A,b) -points = sample_points(P, n = 100, distribution = list("density" = "gaussian", "variance" = 2)) - -# uniform points from the boundary of a 2-dimensional random H-polytope -P = gen_rand_hpoly(2,20) -points = sample_points(P, n = 100, random_walk = list("walk" = "BRDHR")) - -# For sampling from logconcave densities see the examples directory - -} -\references{ -\cite{Robert L. Smith, -\dQuote{Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions,} \emph{Operations Research,} 1984.}, - -\cite{B.T. Polyak, E.N. Gryazina, -\dQuote{Billiard walk - a new sampling algorithm for control and optimization,} \emph{IFAC Proceedings Volumes,} 2014.}, - -\cite{Y. Chen, R. Dwivedi, M. J. Wainwright and B. Yu, -\dQuote{Fast MCMC Sampling Algorithms on Polytopes,} \emph{Journal of Machine Learning Research,} 2018.} - -\cite{Lee, Yin Tat, Ruoqi Shen, and Kevin Tian, -\dQuote{"Logsmooth Gradient Concentration and Tighter Runtimes for Metropolized Hamiltonian Monte Carlo,"} \emph{arXiv preprint arXiv:2002.04121}, 2020.} - -\cite{Shen, Ruoqi, and Yin Tat Lee, -\dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.} -} diff --git a/R-proj/man/volume.Rd b/R-proj/man/volume.Rd deleted file mode 100644 index cd325c87f..000000000 --- a/R-proj/man/volume.Rd +++ /dev/null @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{volume} -\alias{volume} -\title{The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). It returns a list with two elements: (a) the logarithm of the estimated volume and (b) the estimated volume} -\usage{ -volume(P, settings = NULL, rounding = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class a) Hpolytope or b) Vpolytope or c) Zonotope or d) VpolytopeIntersection.} - -\item{settings}{Optional. A list that declares which algorithm, random walk and values of parameters to use, as follows: -\itemize{ -\item{\code{algorithm} }{ A string to set the algorithm to use: a) \code{'CB'} for CB algorithm, b) \code{'SoB'} for SOB algorithm or b) \code{'CG'} for CG algorithm. The defalut algorithm is \code{'CB'}.} -\item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{1} for SOB algorithm and \eqn{0.1} otherwise.} -\item{\code{random_walk} }{ A string that declares the random walk method: a) \code{'CDHR'} for Coordinate Directions Hit-and-Run, b) \code{'RDHR'} for Random Directions Hit-and-Run, c) \code{'BaW'} for Ball Walk, or \code{'BiW'} for Billiard walk. For CB algorithm the default walk is \code{'BiW'}. For CG and SOB algorithms the default walk is \code{'CDHR'} for H-polytopes and \code{'RDHR'} for the other representations.} -\item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{\lfloor 10 + d/10\rfloor} for \code{'SOB'} and \eqn{1} otherwise.} -\item{\code{win_len} }{ The length of the sliding window for CB or CG algorithm. The default value is \eqn{250} for CB with BiW and \eqn{400+3d^2} for CB and any other random walk and \eqn{500+4d^2} for CG.} -\item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm when the input polytope is a zonotope. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -}} - -\item{rounding}{Optional. A string parameter to request a rounding method to be applied in the input polytope before volume computation: a) \code{'min_ellipsoid'}, b) \code{'svd'}, c) \code{'max_ellipsoid'} and d) \code{'none'} for no rounding.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -The approximation of the volume of a convex polytope. -} -\description{ -For the volume approximation can be used three algorithms. Either CoolingBodies (CB) or SequenceOfBalls (SOB) or CoolingGaussian (CG). An H-polytope with \eqn{m} facets is described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which correspond to the vertices of P. A zonotope is desrcibed by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -} -\examples{ - -# calling SOB algorithm for a H-polytope (5d unit simplex) -HP = gen_cube(5,'H') -pair_vol = volume(HP) - -# calling CG algorithm for a V-polytope (3d simplex) -VP = gen_simplex(3,'V') -pair_vol = volume(VP, settings = list("algorithm" = "CG")) - -# calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments -Z = gen_rand_zonotope(2, 4) -pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2)) - -} -\references{ -\cite{I.Z.Emiris and V. Fisikopoulos, -\dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, - -\cite{A. Chalkis and I.Z.Emiris and V. Fisikopoulos, -\dQuote{Practical Volume Estimation by a New Annealing Schedule for Cooling Convex Bodies,} \emph{CoRR, abs/1905.05494,} 2019.}, - -\cite{B. Cousins and S. Vempala, \dQuote{A practical volume algorithm,} \emph{Springer-Verlag Berlin Heidelberg and The Mathematical Programming Society,} 2015.} -} diff --git a/R-proj/man/writeSdpaFormatFile.Rd b/R-proj/man/writeSdpaFormatFile.Rd deleted file mode 100644 index 7c791dce0..000000000 --- a/R-proj/man/writeSdpaFormatFile.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{writeSdpaFormatFile} -\alias{writeSdpaFormatFile} -\title{Write a SDPA format file} -\usage{ -writeSdpaFormatFile( - spectrahedron = NULL, - objectiveFunction = NULL, - outputFile = NULL -) -} -\arguments{ -\item{spectrahedron}{A spectrahedron in n dimensions; must be an object of class Spectrahedron} - -\item{objectiveFunction}{A numerical vector of length n} - -\item{outputFile}{Name of the output file} -} -\description{ -Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function) -to a SDPA format file. -} -\examples{ -\dontrun{ -A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) -A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) -A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) -lmi = list(A0, A1, A2) -S = Spectrahedron$new(lmi); -objFunction = c(1,1) -writeSdpaFormatFile(S, objFunction, "output.txt") -} -} diff --git a/R-proj/man/zono_approx.Rd b/R-proj/man/zono_approx.Rd deleted file mode 100644 index 9c27c369c..000000000 --- a/R-proj/man/zono_approx.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{zono_approx} -\alias{zono_approx} -\title{An internal Rccp function for the over-approximation of a zonotope} -\usage{ -zono_approx(Z, fit_ratio = NULL, settings = NULL, seed = NULL) -} -\arguments{ -\item{Z}{A zonotope.} - -\item{fit_ratio}{Optional. A boolean parameter to request the computation of the ratio of fitness.} - -\item{settings}{Optional. A list that declares the values of the parameters of CB algorithm.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A List that contains a numerical matrix that describes the PCA approximation as a H-polytope and the ratio of fitness. -} -\description{ -An internal Rccp function for the over-approximation of a zonotope -} -\keyword{internal} diff --git a/R-proj/man/zonotope_approximation.Rd b/R-proj/man/zonotope_approximation.Rd deleted file mode 100644 index 152a0b0a7..000000000 --- a/R-proj/man/zonotope_approximation.Rd +++ /dev/null @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/zonotope_approximation.R -\name{zonotope_approximation} -\alias{zonotope_approximation} -\title{A function to over-approximate a zonotope with PCA method and to evaluate the approximation by computing a ratio of fitness.} -\usage{ -zonotope_approximation(Z, fit_ratio = NULL, settings = NULL, seed = NULL) -} -\arguments{ -\item{Z}{A zonotope.} - -\item{fit_ratio}{Optional. A boolean parameter to request the computation of the ratio of fitness.} - -\item{settings}{Optional. A list that declares the values of the parameters of CB algorithm as follows: -\itemize{ -\item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{0.1}.} -\item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{1}.} -\item{\code{win_len} }{ The length of the sliding window for CB algorithm. The default value is \eqn{200}.} -\item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -}} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A list that contains the approximation body in H-representation and the ratio of fitness -} -\description{ -For the evaluation of the PCA method the exact volume of the approximation body is computed and the volume of the input zonotope is computed by CoolingBodies algorithm. The ratio of fitness is \eqn{R=vol(P) / vol(P_{red})}, where \eqn{P_{red}} is the approximate polytope. -} -\examples{ -# over-approximate a 2-dimensional zonotope with 10 generators and compute the ratio of fitness -Z = gen_rand_zonotope(2,12) -retList = zonotope_approximation(Z = Z) - -} -\references{ -\cite{A.K. Kopetzki and B. Schurmann and M. Althoff, -\dQuote{Methods for Order Reduction of Zonotopes,} \emph{IEEE Conference on Decision and Control,} 2017.} -} diff --git a/R-proj/src/Makevars b/R-proj/src/Makevars deleted file mode 100644 index 8f401249e..000000000 --- a/R-proj/src/Makevars +++ /dev/null @@ -1,14 +0,0 @@ -PKG_CPPFLAGS= -I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include - -PKG_CXXFLAGS= -Wno-deprecated-declarations -lm -ldl -Wno-ignored-attributes -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES - -CXX_STD = CXX11 - -PKG_LIBS=-LRproj_externals/lp_solve -llp_solve $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): Rproj_externals/lp_solve/liblp_solve.a - -Rproj_externals/lp_solve/liblp_solve.a: - @(cd Rproj_externals/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)") diff --git a/R-proj/src/Makevars.win b/R-proj/src/Makevars.win deleted file mode 100644 index 867308b75..000000000 --- a/R-proj/src/Makevars.win +++ /dev/null @@ -1,13 +0,0 @@ -PKG_CPPFLAGS=-I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include -I../../include/convex_bodies/spectrahedra -PKG_CXXFLAGS= -Wno-deprecated-declarations -lm -ldl -Wno-ignored-attributes -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES -CXX_STD = CXX11 - -PKG_LIBS=-LRproj_externals/lp_solve -llp_solve $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): Rproj_externals/lp_solve/liblp_solve.a - -Rproj_externals/lp_solve/liblp_solve.a: - @(cd Rproj_externals/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS) -DUSRDLL -DINLINE=static" \ - CFLAGS="$(CFLAGS)" CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" \ - RANLIB="$(RANLIB)") diff --git a/R-proj/src/copula.cpp b/R-proj/src/copula.cpp deleted file mode 100644 index 0e8069ea2..000000000 --- a/R-proj/src/copula.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - - -#include -#include -#include -#include "convex_bodies/ellipsoid.h" -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include "sampling/simplex.hpp" -#include "volume/copulas.h" - -//' Construct a copula using uniform sampling from the unit simplex -//' -//' Given two families of parallel hyperplanes or a family of parallel hyperplanes and a family of concentric ellispoids centered at the origin intersecting the canonical simplex, this function uniformly samples from the canonical simplex and construct an approximation of the bivariate probability distribution, called copula (see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}). -//' At least two families of hyperplanes or one family of hyperplanes and one family of ellipsoids have to be given as input. -//' -//' @param r1 The \eqn{d}-dimensional normal vector of the first family of parallel hyperplanes. -//' @param r2 Optional. The \eqn{d}-dimensional normal vector of the second family of parallel hyperplanes. -//' @param sigma Optional. The \eqn{d\times d} symmetric positive semidefine matrix that describes the family of concentric ellipsoids centered at the origin. -//' @param m The number of the slices for the copula. The default value is 100. -//' @param n The number of points to sample. The default value is \eqn{5\cdot 10^5}. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -//' \dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -//' -//' @return A \eqn{m\times m} numerical matrix that corresponds to a copula. -//' @examples -//' # compute a copula for two random families of parallel hyperplanes -//' h1 = runif(n = 10, min = 1, max = 1000) -//' h1 = h1 / 1000 -//' h2=runif(n = 10, min = 1, max = 1000) -//' h2 = h2 / 1000 -//' cop = copula(r1 = h1, r2 = h2, m = 10, n = 100000) -//' -//' # compute a copula for a family of parallel hyperplanes and a family of conentric ellipsoids -//' h = runif(n = 10, min = 1, max = 1000) -//' h = h / 1000 -//' E = replicate(10, rnorm(20)) -//' E = cov(E) -//' cop = copula(r1 = h, sigma = E, m = 10, n = 100000) -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix copula (Rcpp::Nullable r1, - Rcpp::Nullable r2 = R_NilValue, - Rcpp::Nullable sigma = R_NilValue, - Rcpp::Nullable m = R_NilValue, - Rcpp::Nullable n = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef Eigen::Matrix MT; - typedef Eigen::Matrix VT; - typedef Ellipsoid CopEll; - unsigned int num_slices = 100, numpoints = 500000; - - if (m.isNotNull()) { - num_slices = Rcpp::as(m); - } - - if (n.isNotNull()) { - numpoints = Rcpp::as(n); - } - - double seed3 = (!seed.isNotNull()) ? std::numeric_limits::signaling_NaN() : Rcpp::as(seed); - - Rcpp::NumericMatrix copula(num_slices, num_slices); - std::vector > StdCopula; - unsigned int dim = Rcpp::as >(r1).size(), i, j; - - std::vector hyp1 = Rcpp::as >(r1); - if (r2.isNotNull()) { - - std::vector hyp2 = Rcpp::as < std::vector < NT > > (r2); - StdCopula = twoParHypFam(dim, numpoints, num_slices, hyp1, hyp2, seed3); - - } else if (sigma.isNotNull()) { - - std::vector > Gin(dim, std::vector(dim)); - MT EE = Rcpp::as(sigma); - for (int i=0; i(dim, numpoints, num_slices, hyp1, Ell, seed3); - } else { - - throw Rcpp::exception("You have to give as input either two families of hyperplanes or one family of hyperplanes and one family of ellipsoids!"); - - } - - for(int i=0; i -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "volume/volume_sequence_of_balls.hpp" -#include "sampling/simplex.hpp" - -//' Sample perfect uniformly distributed points from well known convex bodies: (a) the unit simplex, (b) the canonical simplex, (c) the boundary of a hypersphere or (d) the interior of a hypersphere. -//' -//' The \eqn{d}-dimensional unit simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i\leq 1}, \eqn{x_i\geq 0}. The \eqn{d}-dimensional canonical simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i = 1}, \eqn{x_i\geq 0}. -//' -//' @param body A list to request exact uniform sampling from special well known convex bodies through the following input parameters: -//' \itemize{ -//' \item{\code{type} }{ A string that declares the type of the body for the exact sampling: a) \code{'unit_simplex'} for the unit simplex, b) \code{'canonical_simplex'} for the canonical simplex, c) \code{'hypersphere'} for the boundary of a hypersphere centered at the origin, d) \code{'ball'} for the interior of a hypersphere centered at the origin.} -//' \item{\code{dimension} }{ An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.} -//' \item{\code{radius} }{ The radius of the \eqn{d}-dimensional hypersphere. The default value is \eqn{1}.} -//' } -//' @param n The number of points that the function is going to sample. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{R.Y. Rubinstein and B. Melamed, -//' \dQuote{Modern simulation and modeling} \emph{ Wiley Series in Probability and Statistics,} 1998.} -//' @references \cite{A Smith, Noah and W Tromble, Roy, -//' \dQuote{Sampling Uniformly from the Unit Simplex,} \emph{ Center for Language and Speech Processing Johns Hopkins University,} 2004.} -//' -//' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -//' @examples -//' # 100 uniform points from the 2-d unit ball -//' points = direct_sampling(n = 100, body = list("type" = "ball", "dimension" = 2)) -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix direct_sampling(Rcpp::Nullable body, - Rcpp::Nullable n, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef boost::mt19937 RNGType2; - typedef typename Kernel::Point Point; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef BoostRandomNumberGenerator RNGType; - - int dim, numpoints; - NT radius = 1.0; - std::list randPoints; - - if (!Rcpp::as(body).containsElementNamed("dimension")) { - throw Rcpp::exception("Dimension has to be given as input!"); - } - dim = Rcpp::as(Rcpp::as(body)["dimension"]); - if (dim <=1) throw Rcpp::exception("Dimension has to be larger than 1!"); - RNGType rng(dim); - - if (seed.isNotNull()) { - unsigned seed2 = Rcpp::as(seed); - rng.set_seed(seed2); - } - double seed3 = (!seed.isNotNull()) ? std::numeric_limits::signaling_NaN() : Rcpp::as(seed); - //RNGType rng2(5); - - numpoints = (!n.isNotNull()) ? 100 : Rcpp::as(n); - - numpoints = Rcpp::as(n); - if (numpoints <= 0) throw Rcpp::exception("The number of samples has to be a positice integer!"); - - - if (Rcpp::as(body).containsElementNamed("radius")) { - - radius = Rcpp::as(Rcpp::as(body)["radius"]); - if (radius <= NT(0)) throw Rcpp::exception("Radius has to be a positive number!"); - - } - if (!Rcpp::as(body).containsElementNamed("type")) { - - throw Rcpp::exception("The kind of body has to be given as input!"); - - } - if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("hypersphere"))==0) { - - for (unsigned int k = 0; k < numpoints; ++k) { - randPoints.push_back(GetPointOnDsphere::apply(dim, radius, rng)); - } - - } else if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("ball"))==0) { - - for (unsigned int k = 0; k < numpoints; ++k) { - randPoints.push_back(GetPointInDsphere::apply(dim, radius, rng)); - } - - } else if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("unit_simplex"))==0) { - - Sam_Unit(dim, numpoints, randPoints, seed3); - - } else if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("canonical_simplex"))==0) { - - Sam_Canon_Unit(dim, numpoints, randPoints, seed3); - - } else { - - throw Rcpp::exception("Wrong input!"); - - } - - MT RetMat(dim, numpoints); - unsigned int jj = 0; - - for (typename std::list::iterator rpit = randPoints.begin(); rpit!=randPoints.end(); rpit++, jj++) { - RetMat.col(jj) = rpit->getCoefficients(); - } - return Rcpp::wrap(RetMat); -} diff --git a/R-proj/src/ess.cpp b/R-proj/src/ess.cpp deleted file mode 100644 index 15730557c..000000000 --- a/R-proj/src/ess.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/effective_sample_size.hpp" - -//' Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' -//' @references \cite{Gelman, A. and Rubin, D. B., -//' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -//' -//' @references \cite{Brooks, S. and Gelman, A., -//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -//' -//' @return A vector that contains the values of PSRF for each coordinate -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericVector ess(Rcpp::NumericMatrix samples) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - MT samples_ = Rcpp::as(samples); - unsigned int min_ess = 0; - VT Neff = effective_sample_size(samples_, min_ess); - - return Rcpp::wrap(Neff); -} diff --git a/R-proj/src/exact_vol.cpp b/R-proj/src/exact_vol.cpp deleted file mode 100644 index d60d8fa4b..000000000 --- a/R-proj/src/exact_vol.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2019 Vissarion Fisikopoulos -// Copyright (c) 2018-2019 Apostolos Chalkis - - -#include -#include -#include -#include -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include "convex_bodies/hpolytope.h" -#include "convex_bodies/vpolytope.h" -#include "convex_bodies/zpolytope.h" -#include "volume/exact_vols.h" - -template -FT factorial(FT n) -{ - return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n; -} - -//' Compute the exact volume of (a) a zonotope (b) an arbitrary simplex in V-representation or (c) if the volume is known and declared by the input object. -//' -//' Given a zonotope (as an object of class Zonotope), this function computes the sum of the absolute values of the determinants of all the \eqn{d \times d} submatrices of the \eqn{m\times d} matrix \eqn{G} that contains row-wise the \eqn{m} \eqn{d}-dimensional segments that define the zonotope. -//' For an arbitrary simplex that is given in V-representation this function computes the absolute value of the determinant formed by the simplex's points assuming it is shifted to the origin. -//' -//' @param P A polytope -//' -//' @references \cite{E. Gover and N. Krikorian, -//' \dQuote{Determinants and the Volumes of Parallelotopes and Zonotopes,} \emph{Linear Algebra and its Applications, 433(1), 28 - 40,} 2010.} -//' -//' @return The exact volume of the input polytope, for zonotopes, simplices in V-representation and polytopes with known exact volume -//' @examples -//' -//' # compute the exact volume of a 5-dimensional zonotope defined by the Minkowski sum of 10 segments -//' Z = gen_rand_zonotope(2, 5) -//' vol = exact_vol(Z) -//' -//' \donttest{# compute the exact volume of a 2-d arbitrary simplex -//' V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE) -//' P = Vpolytope$new(V) -//' vol = exact_vol(P) -//' } -//' -//' # compute the exact volume the 10-dimensional cross polytope -//' P = gen_cross(10,'V') -//' vol = exact_vol(P) -//' @export -// [[Rcpp::export]] -double exact_vol(Rcpp::Nullable P) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - if (NT(Rcpp::as(P).field("volume")) > 0.0) { - return NT(Rcpp::as(P).field("volume")); - } - - int type = Rcpp::as(P).field("type"), dim; - NT vol; - - if (type == 2) { - - dim = Rcpp::as(P).field("dimension"); - - if (Rcpp::as(Rcpp::as(P).field("V")).rows() == - Rcpp::as(Rcpp::as(P).field("V")).cols() + 1) { - - MT V = Rcpp::as(Rcpp::as(P).field("V")).transpose(), V2(dim,dim); - VT v0 = V.col(dim); - - for (int i = 0; i < dim; ++i) { - V2.col(i) = V.col(i) - v0; - } - vol = std::abs(V2.determinant()) / factorial(NT(dim)); - - } else { - throw Rcpp::exception("Volume unknown!"); - } - - } else if (type == 3) { - - typedef Zonotope zonotope; - dim = Rcpp::as(P).field("dimension"); - - zonotope ZP(dim, Rcpp::as(Rcpp::as(P).field("G")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("G")).rows())); - vol = exact_zonotope_vol(ZP); - - } else { - throw Rcpp::exception("Volume unknown!"); - } - - return vol; -} diff --git a/R-proj/src/extractMatPoly.h b/R-proj/src/extractMatPoly.h deleted file mode 100644 index 5adb9d56b..000000000 --- a/R-proj/src/extractMatPoly.h +++ /dev/null @@ -1,37 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2018 Vissarion Fisikopoulos, Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - -// VolEsti is free software: you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// VolEsti is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// See the file COPYING.LESSER for the text of the GNU Lesser General -// Public License. If you did not receive this file along with HeaDDaCHe, -// see . - - -#ifndef EXTRACTMATPOLY_H -#define EXTRACTMATPOLY_H - -// Take a H or a V-polytope and return a numerical matrix in ine or ext format respectively -template -Rcpp::NumericMatrix extractMatPoly(Polytope P) { - - typedef typename Polytope::MT MT; - - MT Mat(P.get_mat().rows(), P.dimension()+1); - Mat << P.get_vec(), P.get_mat(); - - return Rcpp::wrap(Mat); -} - -#endif diff --git a/R-proj/src/frustum_of_simplex.cpp b/R-proj/src/frustum_of_simplex.cpp deleted file mode 100644 index 6b191079e..000000000 --- a/R-proj/src/frustum_of_simplex.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -#include -#include -#include "volume/exact_vols.h" - -//' Compute the percentage of the volume of the simplex that is contained in the intersection of a half-space and the simplex. -//' -//' A half-space \eqn{H} is given as a pair of a vector \eqn{a\in R^d} and a scalar \eqn{z0\in R} s.t.: \eqn{a^Tx\leq z0}. This function calls the Ali's version of the Varsi formula to compute a frustum of the simplex. -//' -//' @param a A \eqn{d}-dimensional vector that defines the direction of the hyperplane. -//' @param z0 The scalar that defines the half-space. -//' -//' @references \cite{Varsi, Giulio, -//' \dQuote{The multidimensional content of the frustum of the simplex,} \emph{Pacific J. Math. 46, no. 1, 303--314,} 1973.} -//' -//' @references \cite{Ali, Mir M., -//' \dQuote{Content of the frustum of a simplex,} \emph{ Pacific J. Math. 48, no. 2, 313--322,} 1973.} -//' -//' @return The percentage of the volume of the simplex that is contained in the intersection of a given half-space and the simplex. -//' -//' @examples -//' # compute the frustum of H: -x1+x2<=0 -//' a=c(-1,1) -//' z0=0 -//' frustum = frustum_of_simplex(a, z0) -//' @export -// [[Rcpp::export]] -double frustum_of_simplex(Rcpp::NumericVector a, double z0){ - - unsigned int dim = a.size(); - if (dim < 2) { - throw Rcpp::exception("Dimension has to be greater than 2"); - } - std::vector hyp = Rcpp::as >(a); - - return vol_Ali(hyp, -z0, dim); -} diff --git a/R-proj/src/geweke.cpp b/R-proj/src/geweke.cpp deleted file mode 100644 index 4c41b227e..000000000 --- a/R-proj/src/geweke.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/geweke.hpp" - -//' Geweke's MCMC diagnostic -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' @param frac_first Optional. The portion of the first in order points in matrix samples. -//' @param frac_last Optional. The portion of the last in order points in matrix samples. -//' -//' @references \cite{Geweke, J., -//' \dQuote{Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,} \emph{ In Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -//' -//' @return A boolean to denote if the result of Geweke diagnostic: (i) false if the null hypothesis is rejected, (ii) true if the null hypothesis is not rejected. -//' -//' @export -// [[Rcpp::export]] -bool geweke(Rcpp::NumericMatrix samples, - Rcpp::Nullable frac_first = R_NilValue, - Rcpp::Nullable frac_last = R_NilValue) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - NT frac_1, frac_2; - - frac_1 = (!frac_first.isNotNull()) ? NT(0.1) : Rcpp::as(frac_first); - frac_2 = (!frac_last.isNotNull()) ? NT(0.5) : Rcpp::as(frac_last); - - return perform_geweke(Rcpp::as(samples), frac_1, frac_2); -} diff --git a/R-proj/src/inner_ball.cpp b/R-proj/src/inner_ball.cpp deleted file mode 100644 index 8472ad3b8..000000000 --- a/R-proj/src/inner_ball.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "volume/volume_sequence_of_balls.hpp" -#include "preprocess/max_inscribed_ball.hpp" - -//' Compute an inscribed ball of a convex polytope -//' -//' For a H-polytope described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }, this function computes the largest inscribed ball (Chebychev ball) by solving the corresponding linear program. -//' For both zonotopes and V-polytopes the function computes the minimum \eqn{r} s.t.: \eqn{ r e_i \in P} for all \eqn{i=1, \dots ,d}. Then the ball centered at the origin with radius \eqn{r/ \sqrt{d}} is an inscribed ball. -//' -//' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -//' @param lpsolve Optional. A boolean variable to compute the Chebychev ball of an H-polytope using the lpsolve library. -//' -//' @return A \eqn{(d+1)}-dimensional vector that describes the inscribed ball. The first \eqn{d} coordinates corresponds to the center of the ball and the last one to the radius. -//' -//' @examples -//' # compute the Chebychev ball of the 2d unit simplex -//' P = gen_cube(10,'H') -//' ball_vec = inner_ball(P) -//' -//' # compute an inscribed ball of the 3-dimensional unit cube in V-representation -//' P = gen_cube(3, 'V') -//' ball_vec = inner_ball(P, lpsolve = TRUE) -//' @export -// [[Rcpp::export]] -Rcpp::NumericVector inner_ball(Rcpp::Reference P, - Rcpp::Nullable lpsolve = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - unsigned int n = P.field("dimension"), type = P.field("type"); - - std::pair InnerBall; - bool lp_solve = (lpsolve.isNotNull()) ? Rcpp::as(lpsolve) : false; - - switch (type) { - case 1: { - // Hpolytope - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - if (lp_solve) { - InnerBall = ComputeChebychevBall(HP.get_mat(), HP.get_vec()); - } else { - InnerBall = HP.ComputeInnerBall(); - } - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - InnerBall = VP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - InnerBall = ZP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - case 4: { - // Intersection of two V-polytopes - Vpolytope VP1(n, Rcpp::as(P.field("V1")), VT::Ones(Rcpp::as(P.field("V1")).rows())); - Vpolytope VP2(n, Rcpp::as(P.field("V2")), VT::Ones(Rcpp::as(P.field("V2")).rows())); - InterVP VPcVP(VP1, VP2); - if (!VPcVP.is_feasible()) throw Rcpp::exception("Empty set!"); - InnerBall = VPcVP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - } - - Rcpp::NumericVector vec(n + 1); - for (unsigned int k = 0; k < n; ++k){ - vec[k] = InnerBall.first[k]; - } - - vec[n] = InnerBall.second; - return vec; -} diff --git a/R-proj/src/ode_solve.cpp b/R-proj/src/ode_solve.cpp deleted file mode 100644 index 07766d33a..000000000 --- a/R-proj/src/ode_solve.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis -// Copyright (c) 2020-2020 Marios Papachristou - -//Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2018 and 2019 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "sampling/sampling.hpp" -#include "ode_solvers/ode_solvers.hpp" -#include "oracle_functors_rcpp.h" - -template < - typename Solver, - typename MT -> -void run_ode_solver( - Solver &solver, - unsigned int &order, - unsigned int &num_steps, - unsigned int &dimension, - Rcpp::List &results) { - - std::vector results_temp; - - for (unsigned int i = 0; i < order; i++) { - MT temp_result; - temp_result.resize(dimension, num_steps); - results_temp.push_back(temp_result); - } - - for (unsigned int i = 0; i < num_steps; i++) { - for (unsigned int j = 0; j < order; j++) { - results_temp[j].col(i) = solver.xs[j].getCoefficients(); - } - solver.step(i, true); - } - - for (unsigned int i = 0; i < order; i++) { - std::ostringstream stringStream; - stringStream << "x_" << i + 1; - std::string state_name = stringStream.str(); - - results.push_back(Rcpp::wrap(results_temp[i]), state_name.c_str()); - - } - -} - -//' Solve an ODE of the form dx^n / dt^n = F(x, t) -//' -//' @param n The number of steps. -//' @param step_size The step size. -//' @param order The ODE order (default is n = 1) -//' @param dimension The dimension of each derivative -//' @param initial_time The initial time -//' @param F The function oracle F(x, t) in the ODE. -//' @param method The method to be used -//' @param initial_conditions The initial conditions provided to the solver. Must be provided in a list with keys "x_1", ..., "x_n" and column vectors as values. The state "x_n" represents the (n-1)-th order derivative with respect to time -//' @param domains A list of n H-polytopes with keys "P_1", "P_2", ..., "P_n" that correspond to each derivative's domain -//' -//' @return A list which contains elements "x_1", ..., "x_n" representing each derivative results. Each "x_i" corresponds to a d x n matrix where each column represents a certain timestep of the solver. -//' -//' @examples -//' # Please visit the examples directory on examples demonstrating usage of the ODE solvers. -//' -//' @export -// [[Rcpp::export]] -Rcpp::List ode_solve(Rcpp::Nullable n, - Rcpp::Nullable step_size, - Rcpp::Nullable order, - Rcpp::Nullable dimension, - Rcpp::Nullable initial_time, - Rcpp::Function F, - Rcpp::Nullable method, - Rcpp::Nullable domains = R_NilValue, - Rcpp::Nullable initial_conditions = R_NilValue) -{ - - typedef double NT; - typedef Cartesian Kernel; - typedef BoostRandomNumberGenerator RNGType; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef std::vector pts; - typedef std::vector hp_bounds; - typedef RcppFunctor::GradientFunctor func; - - unsigned int n_ = Rcpp::as(n); - NT step_size_ = Rcpp::as(step_size); - unsigned int order_ = Rcpp::as(order); - std::string method_ = Rcpp::as(method); - unsigned int dim = Rcpp::as(dimension); - NT initial_time_ = Rcpp::as(initial_time); - - // Create functors - RcppFunctor::parameters rcpp_functor_params(1, 1, order_); - - // Create C++ functor - func F_(rcpp_functor_params, F, false); - - // Initialize initial conditions - pts initial_conditions_; - VT temp_initial_condition; - - for (unsigned int i = 1; i <= order_; i++) { - std::ostringstream stringStream; - stringStream << "x_" << i; - std::string state_name = stringStream.str(); - - if (Rcpp::as(initial_conditions).containsElementNamed(state_name.c_str())) { - temp_initial_condition = Rcpp::as(Rcpp::as(initial_conditions)[state_name.c_str()]); - Point p(temp_initial_condition); - initial_conditions_.push_back(p); - } else { - Point p(dim); - initial_conditions_.push_back(p); - } - - } - - unsigned int i = 0; - unsigned int t = 0; - F_(i, initial_conditions_, t); - - hp_bounds domains_; - - // Initialize domains - // TODO Test and add other polytope types - for (unsigned int i = 0; i < order_; i++) { - std::ostringstream stringStream; - stringStream << "P_" << i + 1; - std::string domain_name = stringStream.str(); - - if (Rcpp::as(domains).containsElementNamed(domain_name.c_str())) { - - Hpolytope HP(dim, Rcpp::as( - Rcpp::as(Rcpp::as(domains) - [domain_name.c_str()]).field("A")), - Rcpp::as( - Rcpp::as(Rcpp::as(domains) - [domain_name.c_str()]).field("b")) - ); - - HP.normalize(); - - Hpolytope *HP_ref = &HP; - - if (!HP_ref->is_in(initial_conditions_[i])) { - std::ostringstream errStream; - errStream << "Initial condition out of bounds for state " << i + 1 << ".\n"; - throw Rcpp::exception(errStream.str().c_str()); - } - domains_.push_back(HP_ref); - } else { - domains_.push_back(NULL); - } - } - - Rcpp::List results; - - if (method_ == "euler") { - EulerODESolver euler_solver = - EulerODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(euler_solver, order_, n_, dim, results); - } else if (method_ == "leapfrog") { - if (order_ % 2 == 1) { - throw Rcpp::exception("Leapfrog is an even order solver."); - } - LeapfrogODESolver leapfrog_solver = - LeapfrogODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(leapfrog_solver, order_, n_, dim, results); - } else if (method_ == "runge_kutta") { - RKODESolver rk_solver = - RKODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(rk_solver, order_, n_, dim, results); - } else if (method_ == "richardson") { - RichardsonExtrapolationODESolver r_solver = - RichardsonExtrapolationODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(r_solver, order_, n_, dim, results); - } else { - throw Rcpp::exception("Unrecognized solver. Aborting."); - } - - return results; -} diff --git a/R-proj/src/oracle_functors_rcpp.h b/R-proj/src/oracle_functors_rcpp.h deleted file mode 100644 index 558ac1b07..000000000 --- a/R-proj/src/oracle_functors_rcpp.h +++ /dev/null @@ -1,123 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis -// Copyright (c) 2020-2020 Marios Papachristou - -// Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -// Licensed under GNU LGPL.3, see LICENCE file - -#ifndef ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP -#define ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP - -enum ode_solvers { - no_solver, - leapfrog, - euler, - runge_kutta, - richardson, - collocation -}; - -// Holds Oracle Functor that wraps an R function via RCpp -// The R function is provided as an Rcpp::Function object -// The functor uses Rcpp::as and Rcpp::wrap to do the conversion, -// call the oracle, and convert the results back to C++ -struct RcppFunctor { - - template < - typename NT - > - struct parameters { - NT L; // Lipschitz constant of gradient - NT m; // Strong-convexity parameter - NT eta; // Step-size (if defined by user) - NT kappa; // Condition number - unsigned int order; // Order of ODE functor - - parameters( - NT L_, - NT m_, - NT eta_, - unsigned int order_=2 - ) : - L(L_), - m(m_), - eta(eta_), - kappa(L_ / m_), - order(order_) - {} - }; - - // Log-probability gradient functor - template - < - typename Point - > - struct GradientFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - typedef std::vector pts; - - parameters params; - Rcpp::Function neg_grad_f; // Negative gradient as an Rcpp::Function - bool negate; - - GradientFunctor( - parameters params_, - Rcpp::Function neg_grad_f_, - bool negate_=true): - params(params_), - neg_grad_f(neg_grad_f_), - negate(negate_) - {}; - - // The index i represents the state vector index - Point operator() (unsigned int const& i, pts const& xs, NT const& t) const { - if (i == params.order - 1) { - // Convert point to Rcpp::NumericMatrix - - VT y = Rcpp::as(neg_grad_f(Rcpp::wrap(xs[0].getCoefficients()))); - - Point z(y); - - if (negate) z = (-1.0) * z; - - // Return result as Point - return z; - } else { - return xs[i + 1]; // returns derivative - } - } - - }; - - // Negative log-probability functor - template - < - typename Point - > - struct FunctionFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - - parameters params; - Rcpp::Function negative_logprob; - - FunctionFunctor( - parameters params_, - Rcpp::Function negative_logprob_) : - params(params_), - negative_logprob(negative_logprob_) - {}; - - NT operator() (Point const& x) const { - return Rcpp::as(negative_logprob(Rcpp::wrap(x.getCoefficients()))); - } - - }; - -}; - -#endif diff --git a/R-proj/src/poly_gen.cpp b/R-proj/src/poly_gen.cpp deleted file mode 100644 index 1ffa75d7f..000000000 --- a/R-proj/src/poly_gen.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "convex_bodies/hpolytope.h" -#include "convex_bodies/vpolytope.h" -#include "convex_bodies/zpolytope.h" -#include "generators/known_polytope_generators.h" -#include "generators/h_polytopes_generator.h" -#include "generators/v_polytopes_generators.h" -#include "generators/z_polytopes_generators.h" -#include "extractMatPoly.h" - -//' An internal Rccp function as a polytope generator -//' -//' @param kind_gen An integer to declare the type of the polytope. -//' @param Vpoly_gen A boolean parameter to declare if the requested polytope has to be in V-representation. -//' @param Zono_gen A boolean parameter to declare if the requested polytope has to be a zonotope. -//' @param dim_gen An integer to declare the dimension of the requested polytope. -//' @param m_gen An integer to declare the number of generators for the requested random zonotope or the number of vertices for a V-polytope. -//' @param seed Optional. A fixed seed for the random polytope generator. -//' -//' @keywords internal -//' -//' @return A numerical matrix describing the requested polytope -// [[Rcpp::export]] -Rcpp::NumericMatrix poly_gen (int kind_gen, bool Vpoly_gen, bool Zono_gen, int dim_gen, int m_gen, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - - double seed_rcpp = (!seed.isNotNull()) ? std::numeric_limits::signaling_NaN() : Rcpp::as(seed); - - if (Zono_gen) { - switch (kind_gen) { - - case 1: - return extractMatPoly(gen_zonotope_uniform(dim_gen, m_gen, seed_rcpp)); - case 2: - return extractMatPoly(gen_zonotope_gaussian(dim_gen, m_gen, seed_rcpp)); - case 3: - return extractMatPoly(gen_zonotope_exponential(dim_gen, m_gen, seed_rcpp)); - - } - - } else if (Vpoly_gen) { - switch (kind_gen) { - - case 1: - return extractMatPoly(generate_cube(dim_gen, true)); - - case 2: - return extractMatPoly(generate_cross(dim_gen, true)); - - case 3: - return extractMatPoly(generate_simplex(dim_gen, true)); - - case 4: - return extractMatPoly(random_vpoly(dim_gen, m_gen, seed_rcpp)); - - case 5: - return extractMatPoly(random_vpoly_incube(dim_gen, m_gen, seed_rcpp)); - - } - } else { - switch (kind_gen) { - - case 1: - return extractMatPoly(generate_cube(dim_gen, false)); - - case 2: - return extractMatPoly(generate_cross(dim_gen, false)); - - case 3: - return extractMatPoly(generate_simplex(dim_gen, false)); - - case 4: - return extractMatPoly(generate_prod_simplex(dim_gen)); - - case 5: - return extractMatPoly(generate_skinny_cube(dim_gen)); - - case 6: - return extractMatPoly(random_hpoly(dim_gen, m_gen, seed_rcpp)); - - case 7: - return extractMatPoly(generate_birkhoff(dim_gen)); - - } - } - - throw Rcpp::exception("Wrong inputs!"); - -} diff --git a/R-proj/src/polytopes_modules.cpp b/R-proj/src/polytopes_modules.cpp deleted file mode 100644 index 88c036988..000000000 --- a/R-proj/src/polytopes_modules.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2019 Vissarion Fisikopoulos -// Copyright (c) 2018-2019 Apostolos Chalkis - - -#include - -class Hpolytope { -public: - Hpolytope() {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b) : A(_A), b(_b), Aeq(Rcpp::NumericMatrix(0,0)), - beq(Rcpp::NumericVector(0)), vol(std::numeric_limits::signaling_NaN()), dimension(_A.ncol()), type(1) {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b, Rcpp::NumericMatrix _Aeq, Rcpp::NumericVector _beq) : - A(_A), b(_b), Aeq(_Aeq), beq(_beq), vol(std::numeric_limits::signaling_NaN()), dimension(_A.ncol()), type(1) {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b, double volume) : A(_A), b(_b), - Aeq(Rcpp::NumericMatrix(0,0)), beq(Rcpp::NumericVector(0)), vol(volume), dimension(_A.ncol()), type(1) {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b, Rcpp::NumericMatrix _Aeq, Rcpp::NumericVector _beq, - double volume) : A(_A), b(_b), Aeq(_Aeq), beq(_beq), vol(volume), dimension(_A.ncol()), type(1) {} - Rcpp::NumericMatrix A; - Rcpp::NumericVector b; - Rcpp::NumericMatrix Aeq; - Rcpp::NumericVector beq; - double vol; - unsigned int dimension; - int type; -}; - -class Vpolytope { -public: - Vpolytope() {} - Vpolytope(Rcpp::NumericMatrix _V) : V(_V), vol(std::numeric_limits::signaling_NaN()), dimension(_V.ncol()), type(2) {} - Vpolytope(Rcpp::NumericMatrix _V, double volume) : V(_V), vol(volume), dimension(_V.ncol()), type(2) {} - Rcpp::NumericMatrix V; - double vol; - unsigned int dimension; - int type; -}; - -class Zonotope { -public: - Zonotope() {} - Zonotope(Rcpp::NumericMatrix _G) : G(_G), vol(std::numeric_limits::signaling_NaN()), dimension(_G.ncol()), type(3) {} - Zonotope(Rcpp::NumericMatrix _G, double volume) : G(_G), vol(volume), dimension(_G.ncol()), type(3) {} - Rcpp::NumericMatrix G; - double vol; - unsigned int dimension; - int type; -}; - -class VPinterVP { -public: - VPinterVP() {} - VPinterVP(Rcpp::NumericMatrix _V1, Rcpp::NumericMatrix _V2) : V1(_V1), V2(_V2), vol(std::numeric_limits::signaling_NaN()), dimension(_V1.ncol()), type(4) {} - VPinterVP(Rcpp::NumericMatrix _V1, Rcpp::NumericMatrix _V2, double volume) : V1(_V1), V2(_V2), vol(volume), dimension(_V1.ncol()), type(4) {} - Rcpp::NumericMatrix V1; - Rcpp::NumericMatrix V2; - double vol; - unsigned int dimension; - int type; -}; - -RCPP_MODULE(polytopes){ - using namespace Rcpp ; - - //' An exposed class to represent a H-polytope - //' - //' @description A H-polytope is a convex polytope defined by a set of linear inequalities or equivalently a \eqn{d}-dimensional H-polytope with \eqn{m} facets is defined by a \eqn{m\times d} matrix A and a \eqn{m}-dimensional vector b, s.t.: \eqn{Ax\leq b}. - //' - //' @field A \eqn{m\times d} numerical matrix A - //' @field b \eqn{m}-dimensional vector b - //' @field Aeq \eqn{q\times d} numerical matrix Aeq - //' @field beq \eqn{q}-dimensional vector beq - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 1. It has not be given to the constructor. - //' - //' @example - //' # create a 2-d unit simplex - //' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) - //' b = c(0,0,1) - //' P = Hpolytope$new(A,b) - //' @export - class_("Hpolytope") - // expose the default constructor - .constructor() - .constructor() - .constructor() - .constructor() - .constructor() - - .field( "A", &Hpolytope::A ) - .field( "b", &Hpolytope::b ) - .field( "Aeq", &Hpolytope::Aeq ) - .field( "beq", &Hpolytope::beq ) - .field( "volume", &Hpolytope::vol ) - .field( "dimension", &Hpolytope::dimension ) - .field( "type", &Hpolytope::type ); - - //' An exposed C++ class to represent a V-polytope - //' - //' @description A V-polytope is a convex polytope defined by the set of its vertices. - //' - //' @field V \eqn{m\times d} numerical matrix that contains the vertices row-wise - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 2. It has not be given to the constructor. - //' - //' @example - //' # Create a 2-d cube in V-representation - //' V = matrix(c(-1,1,1,1,1,-1,-1,-1), ncol=3, byrow=TRUE) - //' P = Vpolytope$new(V) - //' @export - class_("Vpolytope") - // expose the default constructor - .constructor() - .constructor() - .constructor() - - .field( "V", &Vpolytope::V ) - .field( "volume", &Vpolytope::vol ) - .field( "dimension", &Vpolytope::dimension ) - .field( "type", &Vpolytope::type ); - - //' An exposed C++ class to represent a zonotope - //' - //' @description A zonotope is a convex polytope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. - //' - //' @field G \eqn{m\times d} numerical matrix that contains the segments (or generators) row-wise - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 3. It has not be given to the constructor. - //' - //' @example - //' # Create a 2-d zonotope with 4 generators - //' G = matrix(c(1,0,0,1,-0.73,0.67,-0.25,0.96), ncol = 2, nrow = 4, byrow = TRUE) - //' P = Zonotope$new(G) - //' @export - class_("Zonotope") - // expose the default constructor - .constructor() - .constructor() - .constructor() - - .field( "G", &Zonotope::G ) - .field( "volume", &Zonotope::vol ) - .field( "dimension", &Zonotope::dimension ) - .field( "type", &Zonotope::type ); - - //' An exposed C++ class to represent an intersection of two V-polytopes - //' - //' @description An intersection of two V-polytopes is defined by the intersection of the two coresponding convex hulls. - //' - //' @field V1 \eqn{m\times d} numerical matrix that contains the vertices of the first V-polytope (row-wise) - //' @field V2 \eqn{q\times d} numerical matrix that contains the vertices of the second V-polytope (row-wise) - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 4. It has not be given to the constructor. - //' - //' @example - //' # define the intwrsection of a 2-d simplex with a 2-d cross polytope - //' P1 = gen_simplex(2,'V') - //' P2 = gen_cross(2,'V') - //' P = VpolytopeIntersection$new(P1$V, P2$V) - //' @export - class_("VpolytopeIntersection") - // expose the default constructor - .constructor() - .constructor() - .constructor() - - .field( "V1", &VPinterVP::V1 ) - .field( "V2", &VPinterVP::V2 ) - .field( "volume", &VPinterVP::vol ) - .field( "dimension", &VPinterVP::dimension ) - .field( "type", &VPinterVP::type ); -} - -extern SEXP _rcpp_module_boot_polytopes(void); diff --git a/R-proj/src/psrf_multivariate.cpp b/R-proj/src/psrf_multivariate.cpp deleted file mode 100644 index d9392f3f8..000000000 --- a/R-proj/src/psrf_multivariate.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/multivariate_psrf.hpp" - -//' Gelman-Rubin Potential Scale Reduction Factor (PSRF) -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' -//' @references \cite{Gelman, A. and Rubin, D. B., -//' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -//' -//' @references \cite{Brooks, S. and Gelman, A., -//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -//' -//' @return The value of multivariate PSRF by S. Brooks and A. Gelman. -//' -//' @export -// [[Rcpp::export]] -double psrf_multivariate(Rcpp::NumericMatrix samples) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - return multivariate_psrf(Rcpp::as(samples)); -} diff --git a/R-proj/src/psrf_univariate.cpp b/R-proj/src/psrf_univariate.cpp deleted file mode 100644 index f01edadaf..000000000 --- a/R-proj/src/psrf_univariate.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/univariate_psrf.hpp" -#include "diagnostics/interval_psrf.hpp" - -//' Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' @param method A string to reauest diagnostic: (i) \code{'normal'} for psrf of Gelman-Rubin and (ii) \code{'interval'} for psrf of Brooks-Gelman. -//' -//' @references \cite{Gelman, A. and Rubin, D. B., -//' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -//' -//' @references \cite{Brooks, S. and Gelman, A., -//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -//' -//' @return A vector that contains the values of PSRF for each coordinate -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericVector psrf_univariate(Rcpp::NumericMatrix samples, - Rcpp::Nullable method = R_NilValue) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - VT scores(samples.nrow()); - - std::string method_rcpp = std::string("normal"); - if(method.isNotNull()) { - method_rcpp = Rcpp::as(method); - } - - if (method_rcpp.compare(std::string("normal")) == 0) { - scores = univariate_psrf(Rcpp::as(samples)); - } else if(method_rcpp.compare(std::string("interval")) == 0) { - scores = interval_psrf(Rcpp::as(samples)); - } else { - throw Rcpp::exception("Unknown method!"); - } - - return Rcpp::wrap(scores); -} diff --git a/R-proj/src/raftery.cpp b/R-proj/src/raftery.cpp deleted file mode 100644 index e8e4f9ec8..000000000 --- a/R-proj/src/raftery.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "diagnostics/raftery.hpp" - -//' Raftery and Lewis MCMC diagnostic -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' @param q Optional. The quantile of the quantity of interest. The default value is 0.025. -//' @param r Optional. The level of precision desired. The default value is 0.01. -//' @param s Optional. The probability associated with r. The default value is 0.95. -//' -//' @references \cite{Raftery, A. E. and Lewis, S. M., -//' \dQuote{How many iterations in the Gibbs sampler?,} \emph{Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -//' -//' @return (i) The number of draws required for burn-in, (ii) the skip parameter for 1st-order Markov chain, (iii) the skip parameter sufficient to get independence chain, (iv) the number of draws required to achieve r precision, (v) the number of draws if the chain is white noise, (vi) the I-statistic from Raftery and Lewis (1992). -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix raftery(Rcpp::NumericMatrix samples, - Rcpp::Nullable q = R_NilValue, - Rcpp::Nullable r = R_NilValue, - Rcpp::Nullable s = R_NilValue) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - NT _q = (!q.isNotNull()) ? 0.025 : Rcpp::as(q); - NT _r = (!r.isNotNull()) ? 0.01 : Rcpp::as(r); - NT _s = (!s.isNotNull()) ? 0.95 : Rcpp::as(s); - - MT results = perform_raftery(Rcpp::as(samples), _q, _r, _s); - - return Rcpp::wrap(results); -} diff --git a/R-proj/src/rotating.cpp b/R-proj/src/rotating.cpp deleted file mode 100644 index 607c00921..000000000 --- a/R-proj/src/rotating.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/rotating.hpp" -#include "extractMatPoly.h" - -//' An internal Rccp function for the random rotation of a convex polytope -//' -//' @param P A convex polytope (H-, V-polytope or a zonotope). -//' @param T Optional. A rotation matrix. -//' @param seed Optional. A fixed seed for the random linear map generator. -//' -//' @keywords internal -//' -//' @return A matrix that describes the rotated polytope -// [[Rcpp::export]] -Rcpp::NumericMatrix rotating (Rcpp::Reference P, Rcpp::Nullable T = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - MT TransorfMat; - Rcpp::NumericMatrix Mat; - unsigned int n = P.field("dimension"), type = P.field("type"); - - int seed_rcpp = (!seed.isNotNull()) ? std::chrono::system_clock::now() - .time_since_epoch().count() - : Rcpp::as(seed); - - switch (type) { - case 1: { - // Hpolytope - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - if (T.isNotNull()) { - TransorfMat = Rcpp::as(T); - HP.linear_transformIt(TransorfMat.inverse()); - } else { - TransorfMat = rotating < MT > (HP, seed_rcpp); - } - Mat = extractMatPoly(HP); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - if (T.isNotNull()) { - TransorfMat = Rcpp::as(T); - VP.linear_transformIt(TransorfMat.inverse()); - } else { - TransorfMat = rotating < MT > (VP, seed_rcpp); - } - Mat = extractMatPoly(VP); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - if (T.isNotNull()) { - TransorfMat = Rcpp::as(T); - ZP.linear_transformIt(TransorfMat.inverse()); - } else { - TransorfMat = rotating < MT > (ZP, seed_rcpp); - } - Mat = extractMatPoly(ZP); - break; - } - case 4: { - throw Rcpp::exception("volesti does not support rotation for this representation currently."); - } - } - - TransorfMat.conservativeResize(n+1, n); - TransorfMat.row(n) = VT::Ones(n); - MT res(TransorfMat.rows(), Rcpp::as(Mat).rows()+n); - res << Rcpp::as(Mat).transpose(), TransorfMat; - return Rcpp::wrap(res); -} diff --git a/R-proj/src/rounding.cpp b/R-proj/src/rounding.cpp deleted file mode 100644 index 0b2cbe0f0..000000000 --- a/R-proj/src/rounding.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "preprocess/min_sampling_covering_ellipsoid_rounding.hpp" -#include "preprocess/svd_rounding.hpp" -#include "preprocess/max_inscribed_ellipsoid_rounding.hpp" -#include "extractMatPoly.h" - -template -< - typename MT, - typename VT, - typename WalkType, - typename Polytope, - typename Point, - typename NT, - typename RNGType -> -std::tuple apply_rounding(Polytope &P, - std::string const& method_rcpp, - unsigned int const& walkL, - std::pair &InnerBall, - RNGType &rng) -{ - std::tuple round_res; - if (method_rcpp.compare(std::string("min_ellipsoid")) == 0) { - round_res = min_sampling_covering_ellipsoid_rounding(P, InnerBall, walkL, rng); - } else if (method_rcpp.compare(std::string("isotropy")) == 0) { - round_res = svd_rounding(P, InnerBall, walkL, rng); - } else { - throw Rcpp::exception("Unknown method!"); - } - return round_res; -} - -//' Internal rcpp function for the rounding of a convex polytope -//' -//' @param P A convex polytope (H- or V-representation or zonotope). -//' @param method Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a uniform sample from P, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid in P, (c) \code{'isotropy'} for the method based on isotropy. The default method is \code{'min_ellipsoid'} for all the representations. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @keywords internal -//' -//' @return A numerical matrix that describes the rounded polytope, a numerical matrix of the inverse linear transofmation that is applied on the input polytope, the numerical vector the the input polytope is shifted and the determinant of the matrix of the linear transformation that is applied on the input polytope. -// [[Rcpp::export]] -Rcpp::List rounding (Rcpp::Reference P, - Rcpp::Nullable method = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - unsigned int n = P.field("dimension"), walkL = 2, type = P.field("type"); - std::string method_rcpp = std::string("isotropy"); - if(method.isNotNull()) { - method_rcpp = Rcpp::as(method); - if (method_rcpp.compare(std::string("max_ellipsoid")) == 0 && type != 1) { - Rcpp::exception("This method can not be used for V- or Z-polytopes!"); - } - } - - RNGType rng(n); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - std::pair InnerBall; - Rcpp::NumericMatrix Mat; - - std::tuple round_res; - switch (type) { - case 1: { - // Hpolytope - - if (Rcpp::as(P.field("Aeq")).rows() > 0) { - throw Rcpp::exception("volesti supports rounding for full dimensional polytopes"); - } - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - InnerBall = HP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (method_rcpp.compare(std::string("max_ellipsoid")) == 0) { - round_res = max_inscribed_ellipsoid_rounding(HP, InnerBall.first); - } else { - round_res = apply_rounding(HP, method_rcpp, walkL, InnerBall, rng); - } - Mat = extractMatPoly(HP); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - InnerBall = VP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - round_res = apply_rounding(VP, method_rcpp, walkL, InnerBall, rng); - Mat = extractMatPoly(VP); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - InnerBall = ZP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - round_res = apply_rounding(ZP, method_rcpp, walkL, InnerBall, rng); - Mat = extractMatPoly(ZP); - break; - } - case 4: { - throw Rcpp::exception("volesti does not support rounding for this representation currently."); - } - } - - return Rcpp::List::create(Rcpp::Named("Mat") = Mat, Rcpp::Named("T") = Rcpp::wrap(std::get<0>(round_res)), - Rcpp::Named("shift") = Rcpp::wrap(std::get<1>(round_res)), - Rcpp::Named("round_value") = std::get<2>(round_res)); -} diff --git a/R-proj/src/sample_points.cpp b/R-proj/src/sample_points.cpp deleted file mode 100644 index d03c9b33f..000000000 --- a/R-proj/src/sample_points.cpp +++ /dev/null @@ -1,718 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2021 Vissarion Fisikopoulos -// Copyright (c) 2018-2021 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 and 2019 program. - -// Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "sampling/sampling.hpp" -#include "ode_solvers/ode_solvers.hpp" -#include "oracle_functors_rcpp.h" - -enum random_walks { - ball_walk, - rdhr, - cdhr, - billiard, - accelarated_billiard, - dikin_walk, - vaidya_walk, - john_walk, - brdhr, - bcdhr, - hmc, - gaussian_hmc, - exponential_hmc, - uld -}; - -template < - typename Polytope, - typename RNGType, - typename PointList, - typename NT, - typename Point, - typename NegativeGradientFunctor, - typename NegativeLogprobFunctor -> -void sample_from_polytope(Polytope &P, int type, RNGType &rng, PointList &randPoints, - unsigned int const& walkL, unsigned int const& numpoints, - bool const& gaussian, NT const& a, NT const& L, Point const& c, - Point const& StartingPoint, unsigned int const& nburns, - bool const& set_L, NT const& eta, random_walks walk, - NegativeGradientFunctor *F=NULL, NegativeLogprobFunctor *f=NULL, - ode_solvers solver_type = no_solver) -{ - switch (walk) - { - case bcdhr: - uniform_sampling_boundary (randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - break; - case brdhr: - uniform_sampling_boundary (randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - break; - case cdhr: - if(gaussian) { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, - a, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case rdhr: - if(gaussian) { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, - a, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case gaussian_hmc: - if(set_L) { - GaussianHamiltonianMonteCarloExactWalk WalkType(L); - gaussian_sampling(randPoints, P, rng, WalkType, walkL, numpoints, a, StartingPoint, nburns); - } else { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, a, - StartingPoint, nburns); - } - break; - case vaidya_walk: - if (set_L) { - VaidyaWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case dikin_walk: - if (set_L) { - DikinWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case john_walk: - if (set_L) { - JohnWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case billiard: - if(set_L) { - BilliardWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case accelarated_billiard: - if(set_L) { - AcceleratedBilliardWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case exponential_hmc: - if (set_L) { - ExponentialHamiltonianMonteCarloExactWalk WalkType(L); - exponential_sampling(randPoints, P, rng, WalkType, walkL, numpoints, c, a, StartingPoint, nburns); - } else { - exponential_sampling(randPoints, P, rng, walkL, numpoints, c, a, - StartingPoint, nburns); - } - break; - case ball_walk: - if (set_L) { - if (gaussian) { - GaussianBallWalk WalkType(L); - gaussian_sampling(randPoints, P, rng, WalkType, walkL, numpoints, a, - StartingPoint, nburns); - } else { - BallWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, - StartingPoint, nburns); - } - } else { - if(gaussian) { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, - a, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - } - break; - case hmc: - switch (solver_type) { - case leapfrog: - logconcave_sampling < - PointList, - Polytope, - RNGType, - HamiltonianMonteCarloWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - LeapfrogODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - break; - case euler: - logconcave_sampling < - PointList, - Polytope, - RNGType, - HamiltonianMonteCarloWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - EulerODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - break; - default: - break; - } - - break; - case uld: - - logconcave_sampling < - PointList, - Polytope, - RNGType, - UnderdampedLangevinWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - LeapfrogODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - - break; - default: - throw Rcpp::exception("Unknown random walk!"); - } -} - -//' Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). -//' -//' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -//' @param n The number of points that the function is going to sample from the convex polytope. -//' @param random_walk Optional. A list that declares the random walk and some related parameters as follows: -//' \itemize{ -//' \item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR x) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave densities) xi) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method xii) \code{'ExactHMC'} for exact Hamiltonian Monte Carlo with reflections (spherical Gaussian or exponential distribution). The default walk is \code{'aBiW'} for the uniform distribution or \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes.} -//' \item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.} -//' \item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.} -//' \item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.} -//' \item{\code{BaW_rad} }{ The radius for the ball walk.} -//' \item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.} -//' \item{\code{solver} }{ Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson} -//' \item{\code{step_size }{ Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.} -//' } -//' @param distribution Optional. A list that declares the target density and some related parameters as follows: -//' \itemize{ -//' \item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution c) \code{logconcave} with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex d) \code{'exponential'} for the exponential distribution. The default target distribution is the uniform distribution.} -//' \item{\code{variance} }{ The variance of the multidimensional spherical gaussian or the exponential distribution. The default value is 1.} -//' \item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.} -//' \item{\code{bias} }{ The bias vector for the exponential distribution. The default vector is \eqn{c_1 = 1} and \eqn{c_i = 0} for \eqn{i \neq 1}.} -//' \item{\code{L_} }{ Smoothness constant (for logconcave). } -//' \item{\code{m} }{ Strong-convexity constant (for logconcave). } -//' \item{\code{negative_logprob} }{ Negative log-probability (for logconcave). } -//' \item{\code{negative_logprob_gradient} }{ Negative log-probability gradient (for logconcave). } -//' } -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{Robert L. Smith, -//' \dQuote{Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions,} \emph{Operations Research,} 1984.}, -//' -//' @references \cite{B.T. Polyak, E.N. Gryazina, -//' \dQuote{Billiard walk - a new sampling algorithm for control and optimization,} \emph{IFAC Proceedings Volumes,} 2014.}, -//' -//' @references \cite{Y. Chen, R. Dwivedi, M. J. Wainwright and B. Yu, -//' \dQuote{Fast MCMC Sampling Algorithms on Polytopes,} \emph{Journal of Machine Learning Research,} 2018.} -//' -//' @references \cite{Lee, Yin Tat, Ruoqi Shen, and Kevin Tian, -//' \dQuote{"Logsmooth Gradient Concentration and Tighter Runtimes for Metropolized Hamiltonian Monte Carlo,"} \emph{arXiv preprint arXiv:2002.04121}, 2020.} -//' -//' @references \cite{Shen, Ruoqi, and Yin Tat Lee, -//' \dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.} -//' -//' @references \cite{Augustin Chevallier, Sylvain Pion, Frederic Cazals, -//' \dQuote{"Hamiltonian Monte Carlo with boundary reflections, and application to polytope volume calculations,"} \emph{Research Report preprint hal-01919855}, 2018.} -//' -//' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -//' @examples -//' # uniform distribution from the 3d unit cube in H-representation using ball walk -//' P = gen_cube(3, 'H') -//' points = sample_points(P, n = 100, random_walk = list("walk" = "BaW", "walk_length" = 5)) -//' -//' # gaussian distribution from the 2d unit simplex in H-representation with variance = 2 -//' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) -//' b = c(0,0,1) -//' P = Hpolytope$new(A,b) -//' points = sample_points(P, n = 100, distribution = list("density" = "gaussian", "variance" = 2)) -//' -//' # uniform points from the boundary of a 2-dimensional random H-polytope -//' P = gen_rand_hpoly(2,20) -//' points = sample_points(P, n = 100, random_walk = list("walk" = "BRDHR")) -//' -//' # For sampling from logconcave densities see the examples directory -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix sample_points(Rcpp::Nullable P, - Rcpp::Nullable n, - Rcpp::Nullable random_walk = R_NilValue, - Rcpp::Nullable distribution = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef BoostRandomNumberGenerator RNGType; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - unsigned int type = Rcpp::as(P).field("type"), dim = Rcpp::as(P).field("dimension"), - walkL = 1, numpoints, nburns = 0; - - RcppFunctor::GradientFunctor *F = NULL; - RcppFunctor::FunctionFunctor *f = NULL; - GaussianFunctor::GradientFunctor *G = NULL; - GaussianFunctor::FunctionFunctor *g = NULL; - bool functor_defined = true; - - - RNGType rng(dim); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - Point c(dim); - - NT radius = 1.0, L; - bool set_mode = false, gaussian = false, logconcave = false, exponential = false, - set_starting_point = false, set_L = false; - - random_walks walk; - ode_solvers solver; // Used only for logconcave sampling - - NT eta; - std::list randPoints; - std::pair InnerBall; - Point mode(dim); - - numpoints = Rcpp::as(n); - if (numpoints <= 0) throw Rcpp::exception("The number of samples has to be a positive integer!"); - - if (!distribution.isNotNull() || !Rcpp::as(distribution).containsElementNamed("density")) { - walk = billiard; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("uniform")) == 0) { - walk = billiard; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("gaussian")) == 0) { - gaussian = true; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("exponential")) == 0) { - walk = exponential_hmc; - exponential = true; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("logconcave")) == 0) { - logconcave = true; - } else { - throw Rcpp::exception("Wrong distribution!"); - } - - if (Rcpp::as(distribution).containsElementNamed("mode")) { - if (!(gaussian || logconcave)) throw Rcpp::exception("Mode is given only for Gaussian/logconcave sampling!"); - if (Rcpp::as(Rcpp::as(distribution)["mode"]).size() != dim) { - throw Rcpp::exception("Mode has to be a point in the same dimension as the polytope P"); - } else { - set_mode = true; - VT temp = Rcpp::as(Rcpp::as(distribution)["mode"]); - mode = Point(dim, std::vector(&temp[0], temp.data() + temp.cols() * temp.rows())); - } - } - - NT a = 0.5; - if (Rcpp::as(distribution).containsElementNamed("variance")) { - a = 1.0 / (2.0 * Rcpp::as(Rcpp::as(distribution)["variance"])); - if (exponential) a = Rcpp::as(Rcpp::as(distribution)["variance"]); - if (!(gaussian || logconcave || exponential)) { - Rcpp::warning("The variance can be set only for Gaussian and exponential sampling!"); - } else if (a <= 0.0) { - throw Rcpp::exception("The variance has to be positive!"); - } - } - - if (Rcpp::as(distribution).containsElementNamed("bias")) { - c = Point(Rcpp::as(Rcpp::as(distribution)["bias"])); - } - - if (Rcpp::as(distribution).containsElementNamed("negative_logprob") && - Rcpp::as(distribution).containsElementNamed("negative_logprob_gradient")) { - - if (!logconcave) { - throw Rcpp::exception("The negative logprob and its gradient can be set only for logconcave sampling!"); - } - - // Parse arguments - Rcpp::Function negative_logprob = Rcpp::as(distribution)["negative_logprob"]; - Rcpp::Function negative_logprob_gradient = Rcpp::as(distribution)["negative_logprob_gradient"]; - - NT L_, m, eta; - - if (Rcpp::as(distribution).containsElementNamed("L_")) { - L_ = Rcpp::as(Rcpp::as(distribution)["L_"]); - } else { - throw Rcpp::exception("The smoothness constant is absent"); - } - - if (Rcpp::as(distribution).containsElementNamed("m")) { - m = Rcpp::as(Rcpp::as(distribution)["m"]); - } else { - throw Rcpp::exception("The strong-convexity constant is absent"); - } - - if (Rcpp::as(random_walk).containsElementNamed("step_size")) { - eta = NT(Rcpp::as(Rcpp::as(random_walk)["step_size"])); - if (eta <= NT(0)) { - throw Rcpp::exception("Step size must be positive"); - } - } else { - eta = NT(-1); - } - - if (Rcpp::as(random_walk).containsElementNamed("solver")) { - std::string solver_str = Rcpp::as(Rcpp::as(random_walk)["solver"]); - if (solver_str == "leapfrog") { - solver = leapfrog; - } else if (solver_str == "euler") { - solver = euler; - } else { - throw Rcpp::exception("Invalid ODE solver specified. Aborting."); - } - } else { - Rcpp::warning("Solver set to leapfrog."); - solver = leapfrog; - } - - // Create functors - RcppFunctor::parameters rcpp_functor_params(L_, m, eta, 2); - F = new RcppFunctor::GradientFunctor(rcpp_functor_params, negative_logprob_gradient); - f = new RcppFunctor::FunctionFunctor(rcpp_functor_params, negative_logprob); - - } - - else if (logconcave && !Rcpp::as(distribution).containsElementNamed("negative_logprob") && - !Rcpp::as(distribution).containsElementNamed("negative_logprob_gradient")) { - - functor_defined = false; - - NT eta; - - if (Rcpp::as(random_walk).containsElementNamed("step_size")) { - eta = NT(Rcpp::as(Rcpp::as(random_walk)["step_size"])); - if (eta <= NT(0)) { - throw Rcpp::exception("Step size must be positive"); - } - } else { - eta = NT(-1); - } - - if (Rcpp::as(random_walk).containsElementNamed("solver")) { - std::string solver_str = Rcpp::as(Rcpp::as(random_walk)["solver"]); - if (solver_str == "leapfrog") { - solver = leapfrog; - } else if (solver_str == "euler") { - solver = euler; - } else { - throw Rcpp::exception("Invalid ODE solver specified. Aborting."); - } - } else { - Rcpp::warning("Solver set to leapfrog."); - solver = leapfrog; - } - - // Create functors - GaussianFunctor::parameters gaussian_functor_params(mode, a, eta); - G = new GaussianFunctor::GradientFunctor(gaussian_functor_params); - g = new GaussianFunctor::FunctionFunctor(gaussian_functor_params); - - } - - if (!random_walk.isNotNull() || !Rcpp::as(random_walk).containsElementNamed("walk")) { - if (exponential) { - if (type !=1) { - throw Rcpp::exception("Exponential sampling is supported only for H-polytopes"); - } - walk = exponential_hmc; - } else if (gaussian) { - if (type == 1) { - walk = cdhr; - } else { - walk = rdhr; - } - } else { - if (type == 1) { - walk = accelarated_billiard; - } else { - walk = billiard; - } - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("CDHR")) == 0) { - walk = cdhr; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("dikin")) == 0) { - walk = dikin_walk; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("vaidya")) == 0) { - walk = vaidya_walk; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("john")) == 0) { - walk = john_walk; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("RDHR")) == 0) { - walk = rdhr; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BaW")) == 0) { - walk = ball_walk; - if (Rcpp::as(random_walk).containsElementNamed("BaW_rad")) { - L = Rcpp::as(Rcpp::as(random_walk)["BaW_rad"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("BaW diameter must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BiW")) == 0) { - if (gaussian) throw Rcpp::exception("Billiard walk can be used only for uniform sampling!"); - walk = billiard; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("aBiW")) == 0) { - if (gaussian) throw Rcpp::exception("Billiard walk can be used only for uniform sampling!"); - walk = accelarated_billiard; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BRDHR")) == 0) { - if (gaussian || exponential) throw Rcpp::exception("Gaussian sampling from the boundary is not supported!"); - walk = brdhr; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BCDHR")) == 0) { - if (gaussian) throw Rcpp::exception("Gaussian sampling from the boundary is not supported!"); - walk = bcdhr; - } else if(Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("ExactHMC")) == 0) { - if (!exponential && !gaussian) throw Rcpp::exception("Exact HMC is supported only for exponential or spherical Gaussian sampling."); - if(exponential){ - walk = exponential_hmc; - } else { - walk = gaussian_hmc; - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("HMC")) == 0) { - if (!logconcave) throw Rcpp::exception("HMC is not supported for non first-order sampling"); - walk = hmc; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("ULD")) == 0) { - if (!logconcave) throw Rcpp::exception("ULD is not supported for non first-order sampling"); - walk = uld; - } else { - throw Rcpp::exception("Unknown walk type!"); - } - - Point StartingPoint; - if (Rcpp::as(random_walk).containsElementNamed("starting_point")) { - if (Rcpp::as(Rcpp::as(random_walk)["starting_point"]).size() != dim) { - throw Rcpp::exception("Starting Point has to lie in the same dimension as the polytope P"); - } else { - set_starting_point = true; - VT temp = Rcpp::as(Rcpp::as(random_walk)["starting_point"]); - StartingPoint = Point(dim, std::vector(&temp[0], temp.data() + temp.cols() * temp.rows())); - } - } - - if (Rcpp::as(random_walk).containsElementNamed("walk_length")) { - walkL = Rcpp::as(Rcpp::as(random_walk)["walk_length"]); - if (walkL <= 0) { - throw Rcpp::exception("The walk length has to be a positive integer!"); - } - } - - if (Rcpp::as(random_walk).containsElementNamed("nburns")) { - nburns = Rcpp::as(Rcpp::as(random_walk)["nburns"]); - if (nburns < 0) { - throw Rcpp::exception("The number of points to burn before sampling has to be a positive integer!"); - } - } - - switch(type) { - case 1: { - // Hpolytope - Hpolytope HP(dim, Rcpp::as(Rcpp::as(P).field("A")), - Rcpp::as(Rcpp::as(P).field("b"))); - - InnerBall = HP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point || (!set_mode && gaussian)) { - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - } - if (HP.is_in(StartingPoint) == 0) { - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - } - if (gaussian) { - StartingPoint = StartingPoint - mode; - HP.shift(mode.getCoefficients()); - } - if (functor_defined) { - sample_from_polytope(HP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, solver); - } - else { - sample_from_polytope(HP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, G, g, solver); - } - break; - } - case 2: { - // Vpolytope - Vpolytope VP(dim, Rcpp::as(Rcpp::as(P).field("V")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("V")).rows())); - - InnerBall = VP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point || (!set_mode && gaussian)) { - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - } - if (VP.is_in(StartingPoint) == 0) - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - if (gaussian) { - StartingPoint = StartingPoint - mode; - VP.shift(mode.getCoefficients()); - } - sample_from_polytope(VP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, solver); - break; - } - case 3: { - // Zonotope - zonotope ZP(dim, Rcpp::as(Rcpp::as(P).field("G")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("G")).rows())); - - InnerBall = ZP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point || (!set_mode && gaussian)) { - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - } - if (ZP.is_in(StartingPoint) == 0) - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - if (gaussian) { - StartingPoint = StartingPoint - mode; - ZP.shift(mode.getCoefficients()); - } - sample_from_polytope(ZP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, solver); - break; - } - case 4: { - // Intersection of two V-polytopes - Vpolytope VP1(dim, Rcpp::as(Rcpp::as(P).field("V1")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("V1")).rows())); - Vpolytope VP2(dim, Rcpp::as(Rcpp::as(P).field("V2")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("V2")).rows())); - InterVP VPcVP(VP1, VP2); - - if (!VPcVP.is_feasible()) throw Rcpp::exception("Empty set!"); - InnerBall = VPcVP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - if (VPcVP.is_in(StartingPoint) == 0) - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - if (gaussian) { - StartingPoint = StartingPoint - mode; - VPcVP.shift(mode.getCoefficients()); - } - sample_from_polytope(VPcVP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, solver); - break; - } - } - - if (numpoints % 2 == 1 && (walk == brdhr || walk == bcdhr)) numpoints--; - MT RetMat(dim, numpoints); - unsigned int jj = 0; - - for (typename std::list::iterator rpit = randPoints.begin(); rpit!=randPoints.end(); rpit++, jj++) { - if (gaussian) { - RetMat.col(jj) = (*rpit).getCoefficients() + mode.getCoefficients(); - } else { - RetMat.col(jj) = (*rpit).getCoefficients(); - } - } - - return Rcpp::wrap(RetMat); -} diff --git a/R-proj/src/spectrahedron.cpp b/R-proj/src/spectrahedron.cpp deleted file mode 100644 index e7926597c..000000000 --- a/R-proj/src/spectrahedron.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Repouskos Panagiotis, as part of Google Summer of Code 2019 program. - -// Licensed under GNU LGPL.3, see LICENCE file - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "convex_bodies/spectrahedra/LMI.h" -#include "convex_bodies/spectrahedra/spectrahedron.h" -#include "SDPAFormatManager.h" - -//' Write a SDPA format file -//' -//' Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function) -//' to a SDPA format file. -//' -//' @param spectrahedron A spectrahedron in n dimensions; must be an object of class Spectrahedron -//' @param objectiveFunction A numerical vector of length n -//' @param outputFile Name of the output file -//' -//' @examples -//' \dontrun{ -//' A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) -//' A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) -//' A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) -//' lmi = list(A0, A1, A2) -//' S = Spectrahedron$new(lmi); -//' objFunction = c(1,1) -//' writeSdpaFormatFile(S, objFunction, "output.txt") -//' } -//' @export -// [[Rcpp::export]] -void writeSdpaFormatFile(Rcpp::Nullable spectrahedron = R_NilValue, - Rcpp::Nullable objectiveFunction = R_NilValue, - Rcpp::Nullable outputFile = R_NilValue) { - - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef LMI LMI; - typedef Spectrahedron Spectrahedron; - - std::vector matrices = Rcpp::as > (Rcpp::as (spectrahedron).field("matrices")); - LMI lmi(matrices); - Spectrahedron _spectrahedron(lmi); - Point c(Rcpp::as (objectiveFunction)); - - std::filebuf fb; - fb.open(Rcpp::as (outputFile), std::ios::out); - std::ostream os(&fb); - - SdpaFormatManager sdpaFormatManager; - sdpaFormatManager.writeSDPAFormatFile(os, _spectrahedron, c); - - return; -} - - - -//' Read a SDPA format file -//' -//' @param inputFile Name of the input file -//' -//' @return A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction" -//' -//' @examples -//' path = system.file('extdata', package = 'volesti') -//' l = loadSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -//' @export -// [[Rcpp::export]] -Rcpp::List loadSdpaFormatFile(Rcpp::Nullable inputFile = R_NilValue) { - - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef LMI LMI; - typedef Spectrahedron Spectrahedron; - - Spectrahedron _spectrahedron; - Point c; - - // open stream - std::ifstream os; - os.open(Rcpp::as (inputFile),std::ifstream::in); - - // read file - SdpaFormatManager sdpaFormatManager; - sdpaFormatManager.loadSDPAFormatFile(os, _spectrahedron, c); - - std::vector matrices = _spectrahedron.getLMI().getMatrices(); - - // return spectrahedron and objective function - Rcpp::List _matrices; - - for (auto matrix : matrices) - _matrices.push_back(Rcpp::wrap(matrix)); - - Rcpp::List retList = Rcpp::List::create(Rcpp::Named("matrices") = _matrices , Rcpp::_["objFunction"] = Rcpp::wrap(c.getCoefficients())); - return Rcpp::wrap(retList); -} diff --git a/R-proj/src/spectrahedron_module.cpp b/R-proj/src/spectrahedron_module.cpp deleted file mode 100644 index 8dedd2dc1..000000000 --- a/R-proj/src/spectrahedron_module.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Repouskos Panagiotis, as part of Google Summer of Code 2019 program. - -// Licensed under GNU LGPL.3, see LICENCE file - - -#include - -class Spectrahedron { -public: - /// A list with the matrices A0, ..., An - Rcpp::List matrices; - - Spectrahedron() {} - - Spectrahedron(Rcpp::List _matrices) : matrices(_matrices) {} -}; - -RCPP_MODULE(spectrahedron){ - using namespace Rcpp ; - - //' An exposed class to represent a spectrahedron - //' - //' @description A spectrahedron is a convex body defined by a linear matrix inequality of the form \eqn{A_0 + x_1 A_1 + ... + x_n A_n \preceq 0}. - //' The matrices \eqn{A_i} are symmetric \eqn{m \times m} real matrices and \eqn{\preceq 0} denoted negative semidefiniteness. - //' - //' @field matrices The matrices \eqn{A_0, A_1, ..., A_n} - //' - //' @example - //' A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) - //' A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) - //' A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) - //' lmi = list(M0, M1,M2) - //' S = Spectrahedron$new(lmi); - //' - //' @export - class_("Spectrahedron") - // expose the default constructor - .constructor() - .constructor() - .field( "matrices", &Spectrahedron::matrices); -} - -extern SEXP _rcpp_module_boot_spectrahedron(void); diff --git a/R-proj/src/volume.cpp b/R-proj/src/volume.cpp deleted file mode 100644 index 0a47210aa..000000000 --- a/R-proj/src/volume.cpp +++ /dev/null @@ -1,407 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 and 2019 program. - - -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_cooling_balls.hpp" -#include "volume/volume_cooling_hpoly.hpp" -#include "preprocess/max_inscribed_ellipsoid_rounding.hpp" -#include "preprocess/svd_rounding.hpp" - -enum random_walks {ball_walk, rdhr, cdhr, billiard, accelarated_billiard}; -enum volume_algorithms {CB, CG, SOB}; -enum rounding_type {none, min_ellipsoid, max_ellipsoid, isotropy}; - -template -std::pair generic_volume(Polytope& P, RNGType &rng, unsigned int walk_length, NT e, - volume_algorithms const& algo, unsigned int win_len, - rounding_type const& rounding, random_walks const& walk) -{ - typedef typename Polytope::MT MT; - typedef typename Polytope::VT VT; - typedef typename Polytope::PointType Point; - - typedef HPolytope Hpolytope; - - NT round_val = 1.0; - unsigned int n = P.dimension(); - std::pair InnerBall; - - if (rounding != none){ - InnerBall = P.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - } - - switch (rounding) - { - case min_ellipsoid: - switch (walk) - { - case cdhr: - round_val = std::get<2>(min_sampling_covering_ellipsoid_rounding(P, InnerBall, 10 + 10 * n, rng)); - break; - case accelarated_billiard: - round_val = std::get<2>(min_sampling_covering_ellipsoid_rounding(P, InnerBall, 2, rng)); - break; - default: - round_val = std::get<2>(min_sampling_covering_ellipsoid_rounding(P, InnerBall, 2, rng)); - break; - } - break; - case isotropy: - switch (walk) - { - case cdhr: - round_val = std::get<2>(svd_rounding(P, InnerBall, 10 + 10 * n, rng)); - break; - case accelarated_billiard: - round_val = std::get<2>(svd_rounding(P, InnerBall, 2, rng)); - break; - default: - round_val = std::get<2>(svd_rounding(P, InnerBall, 2, rng)); - break; - } - break; - case max_ellipsoid: - round_val = std::get<2>(max_inscribed_ellipsoid_rounding(P, InnerBall.first)); - break; - default: - break; - } - - NT vol; - std::pair pair_vol; - switch (algo) - { - case CG: - switch (walk) - { - case cdhr: - vol = volume_cooling_gaussians(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case rdhr: - vol = volume_cooling_gaussians(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case ball_walk: - vol = volume_cooling_gaussians(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - default: - throw Rcpp::exception("This random walk can not be used by CG algorithm!"); - break; - } - break; - case CB: - switch (walk) - { - case cdhr: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case rdhr: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case ball_walk: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case billiard: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case accelarated_billiard: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - default: - throw Rcpp::exception("This random walk can not be used by CB algorithm!"); - break; - } - break; - case SOB: - switch (walk) - { - case cdhr: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case rdhr: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case ball_walk: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case billiard: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - break; - case accelarated_billiard: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - default: - throw Rcpp::exception("This random walk can not be used by CB algorithm!"); - break; - } - break; - default: - throw Rcpp::exception("Unknown algorithm!"); - break; - } - if (pair_vol.second < 0.0) throw Rcpp::exception("volesti failed to terminate."); - pair_vol.first += std::log(round_val); - pair_vol.second *= round_val; - return pair_vol; -} - -//' The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). It returns a list with two elements: (a) the logarithm of the estimated volume and (b) the estimated volume -//' -//' For the volume approximation can be used three algorithms. Either CoolingBodies (CB) or SequenceOfBalls (SOB) or CoolingGaussian (CG). An H-polytope with \eqn{m} facets is described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which correspond to the vertices of P. A zonotope is desrcibed by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -//' -//' @param P A convex polytope. It is an object from class a) Hpolytope or b) Vpolytope or c) Zonotope or d) VpolytopeIntersection. -//' @param settings Optional. A list that declares which algorithm, random walk and values of parameters to use, as follows: -//' \itemize{ -//' \item{\code{algorithm} }{ A string to set the algorithm to use: a) \code{'CB'} for CB algorithm, b) \code{'SoB'} for SOB algorithm or b) \code{'CG'} for CG algorithm. The defalut algorithm is \code{'CB'}.} -//' \item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{1} for SOB algorithm and \eqn{0.1} otherwise.} -//' \item{\code{random_walk} }{ A string that declares the random walk method: a) \code{'CDHR'} for Coordinate Directions Hit-and-Run, b) \code{'RDHR'} for Random Directions Hit-and-Run, c) \code{'BaW'} for Ball Walk, or \code{'BiW'} for Billiard walk. For CB algorithm the default walk is \code{'BiW'}. For CG and SOB algorithms the default walk is \code{'CDHR'} for H-polytopes and \code{'RDHR'} for the other representations.} -//' \item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{\lfloor 10 + d/10\rfloor} for \code{'SOB'} and \eqn{1} otherwise.} -//' \item{\code{win_len} }{ The length of the sliding window for CB or CG algorithm. The default value is \eqn{250} for CB with BiW and \eqn{400+3d^2} for CB and any other random walk and \eqn{500+4d^2} for CG.} -//' \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm when the input polytope is a zonotope. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -//' } -//' @param rounding Optional. A string parameter to request a rounding method to be applied in the input polytope before volume computation: a) \code{'min_ellipsoid'}, b) \code{'svd'}, c) \code{'max_ellipsoid'} and d) \code{'none'} for no rounding. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{I.Z.Emiris and V. Fisikopoulos, -//' \dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, -//' @references \cite{A. Chalkis and I.Z.Emiris and V. Fisikopoulos, -//' \dQuote{Practical Volume Estimation by a New Annealing Schedule for Cooling Convex Bodies,} \emph{CoRR, abs/1905.05494,} 2019.}, -//' @references \cite{B. Cousins and S. Vempala, \dQuote{A practical volume algorithm,} \emph{Springer-Verlag Berlin Heidelberg and The Mathematical Programming Society,} 2015.} -//' -//' -//' @return The approximation of the volume of a convex polytope. -//' @examples -//' -//' # calling SOB algorithm for a H-polytope (5d unit simplex) -//' HP = gen_cube(5,'H') -//' pair_vol = volume(HP) -//' -//' # calling CG algorithm for a V-polytope (3d simplex) -//' VP = gen_simplex(3,'V') -//' pair_vol = volume(VP, settings = list("algorithm" = "CG")) -//' -//' # calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments -//' Z = gen_rand_zonotope(2, 4) -//' pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2)) -//' -//' @export -// [[Rcpp::export]] -Rcpp::List volume (Rcpp::Reference P, - Rcpp::Nullable settings = R_NilValue, - Rcpp::Nullable rounding = R_NilValue, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - unsigned int n = P.field("dimension"), walkL, type = P.field("type"); - - RNGType rng(n); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - bool round = false, hpoly = false; - unsigned int win_len = 300; - - random_walks walk; - volume_algorithms algo; - rounding_type rounding_method; - - if (!rounding.isNotNull()) { - rounding_method = (type == 2) ? min_ellipsoid : none; - } else if (Rcpp::as(rounding).compare(std::string("min_ellipsoid")) == 0) { - rounding_method = min_ellipsoid; - } else if (Rcpp::as(rounding).compare(std::string("max_ellipsoid")) == 0) { - if (type != 1) throw Rcpp::exception("This rounding method can be used only for H-polytopes!"); - rounding_method = max_ellipsoid; - } else if (Rcpp::as(rounding).compare(std::string("isotropy")) == 0) { - rounding_method = isotropy; - } else if (Rcpp::as(rounding).compare(std::string("none")) == 0) { - rounding_method = none; - } - - NT e; - - if (!Rcpp::as(settings).containsElementNamed("algorithm")) { - algo = CB; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else if (Rcpp::as(Rcpp::as(settings)["algorithm"]).compare(std::string("SOB")) == 0) { - algo = SOB; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 10 + n / 10 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 1.0 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else if (Rcpp::as(Rcpp::as(settings)["algorithm"]).compare(std::string("CG")) == 0) { - algo = CG; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else if (Rcpp::as(Rcpp::as(settings)["algorithm"]).compare(std::string("CB")) == 0) { - algo = CB; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else { - throw Rcpp::exception("Unknown method!"); - } - - if (!Rcpp::as(settings).containsElementNamed("random_walk")) { - if (algo == CB) { - walk = (type == 1) ? accelarated_billiard : billiard; - } else { - win_len = 4 * n * n + 500; - if (type == 1) { - walk = cdhr; - } else { - walk = rdhr; - } - } - }else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("CDHR")) == 0) { - walk = cdhr; - if (algo == CB) win_len = 3*n*n+400; - } else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("RDHR")) == 0) { - walk = rdhr; - if (algo == CB) win_len = 3*n*n+400; - } else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("BaW")) == 0) { - walk = ball_walk; - if (algo == CB) win_len = 3*n*n+400; - } else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("BiW")) == 0) { - if (algo == CG) { - if (type !=1){ - Rcpp::Rcout << "Billiard walk is not supported for CG algorithm. RDHR is used."<(settings).containsElementNamed("win_len")) { - win_len = Rcpp::as(Rcpp::as(settings)["win_len"]); - if (algo == SOB) Rf_warning("input 'win_len' can be used only for CG or CB algorithms."); - } - - std::pair pair_vol; - NT vol; - - switch(type) { - case 1: { - // Hpolytope - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - pair_vol = generic_volume(HP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - pair_vol = generic_volume(VP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - if (Rcpp::as(settings).containsElementNamed("hpoly")) { - hpoly = Rcpp::as(Rcpp::as(settings)["hpoly"]); - if (hpoly && (algo == CG || algo == SOB)) - Rf_warning("flag 'hpoly' can be used to only in MMC of CB algorithm for zonotopes."); - } else if (ZP.num_of_generators() / ZP.dimension() < 5) { - hpoly = true; - } else { - hpoly = false; - } - if (hpoly && algo == CB) { - switch (walk) - { - case cdhr: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case rdhr: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case ball_walk: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case billiard: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case accelarated_billiard: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - default: - throw Rcpp::exception("This random walk can not be used by CB algorithm!"); - break; - } - } - pair_vol = generic_volume(ZP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - case 4: { - // Intersection of two V-polytopes - Vpolytope VP1(n, Rcpp::as(P.field("V1")), VT::Ones(Rcpp::as(P.field("V1")).rows())); - Vpolytope VP2(n, Rcpp::as(P.field("V2")), VT::Ones(Rcpp::as(P.field("V2")).rows())); - InterVP VPcVP; - if (!seed.isNotNull()) { - InterVP VPcVP(VP1, VP2); - } else { - unsigned seed3 = Rcpp::as(seed); - InterVP VPcVP(VP1, VP2, seed3); - } - if (!VPcVP.is_feasible()) throw Rcpp::exception("Empty set!"); - pair_vol = generic_volume(VPcVP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - } - - return Rcpp::List::create(Rcpp::Named("log_volume") = pair_vol.first, Rcpp::Named("volume") = pair_vol.second); -} diff --git a/R-proj/src/zonotope_approximation.cpp b/R-proj/src/zonotope_approximation.cpp deleted file mode 100644 index 237ec96e1..000000000 --- a/R-proj/src/zonotope_approximation.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - - -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_cooling_balls.hpp" -#include "volume/volume_cooling_hpoly.hpp" - -//' An internal Rccp function for the over-approximation of a zonotope -//' -//' @param Z A zonotope. -//' @param fit_ratio Optional. A boolean parameter to request the computation of the ratio of fitness. -//' @param settings Optional. A list that declares the values of the parameters of CB algorithm. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @keywords internal -//' -//' @return A List that contains a numerical matrix that describes the PCA approximation as a H-polytope and the ratio of fitness. -// [[Rcpp::export]] -Rcpp::List zono_approx (Rcpp::Reference Z, - Rcpp::Nullable fit_ratio = R_NilValue, - Rcpp::Nullable settings = R_NilValue, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef BoostRandomNumberGenerator RNGType; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - typedef Zonotope zonotope; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - int n = Rcpp::as(Z.field("dimension")), k = Rcpp::as(Z.field("G")).rows(), win_len = 200, walkL = 1; - - RNGType rng(n); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - NT e = 0.1, ratio = std::numeric_limits::signaling_NaN(); - bool hpoly = false; - - MT X(n, 2 * k); - X << Rcpp::as(Z.field("G")).transpose(), -Rcpp::as(Z.field("G")).transpose(); - Eigen::JacobiSVD svd(X * X.transpose(), Eigen::ComputeFullU | Eigen::ComputeFullV); - MT G(k, 2 * n); - G << Rcpp::as(Z.field("G")) * svd.matrixU(), Rcpp::as(Z.field("G")) * svd.matrixU(); - VT Gred_ii = G.transpose().cwiseAbs().rowwise().sum(); - MT A(n, 2 * n); - A << -MT::Identity(n, n), MT::Identity(n, n); - MT Mat(2 * n, n + 1); - Mat << Gred_ii, A.transpose() * svd.matrixU().transpose(); - - //Hpolytope HP(n, A.transpose() * svd.matrixU().transpose(), Gred_ii); - - if (fit_ratio.isNotNull() && Rcpp::as(fit_ratio)) { - NT vol_red = std::abs(svd.matrixU().determinant()); - for (int i = 0; i < n; ++i) { - vol_red *= 2.0 * Gred_ii(i); - } - - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - win_len = (!Rcpp::as(settings).containsElementNamed("win_len")) ? 200 : Rcpp::as( - Rcpp::as(settings)["win_len"]); - - zonotope ZP(n, Rcpp::as(Z.field("G")), VT::Ones(Rcpp::as(Z.field("G")).rows())); - - if (Rcpp::as(settings).containsElementNamed("hpoly")) { - hpoly = Rcpp::as(Rcpp::as(settings)["hpoly"]); - } else if (ZP.num_of_generators() / ZP.dimension() < 5 ) { - hpoly = true; - } else { - hpoly = false; - } - - NT vol; - if (!hpoly) { - vol = volume_cooling_balls(ZP, rng, e, walkL, win_len).second; - } else { - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - } - ratio = std::pow(vol_red / vol, 1.0 / NT(n)); - } - - return Rcpp::List::create(Rcpp::Named("Mat") = Rcpp::wrap(Mat), Rcpp::Named("fit_ratio") = ratio); -} diff --git a/R-proj/tests/testthat.R b/R-proj/tests/testthat.R deleted file mode 100644 index 051a041f8..000000000 --- a/R-proj/tests/testthat.R +++ /dev/null @@ -1,3 +0,0 @@ -library(testthat) - -test_check("volesti") diff --git a/R-proj/tests/testthat/test_Hvol.R b/R-proj/tests/testthat/test_Hvol.R deleted file mode 100644 index 061a33acf..000000000 --- a/R-proj/tests/testthat/test_Hvol.R +++ /dev/null @@ -1,66 +0,0 @@ -context("H-polytopes' volume test") - -library(volesti) - - -Hruntest <- function(P, name_string, exactvol, tol, num_of_exps, alg, seed){ - - vol = 0 - for (j in 1:num_of_exps) { - if (alg == "CB") { - vol = vol + volume(P, seed = seed)$volume - } else if (alg == "SOB") { - vol = vol + volume(P, settings = list("algorithm" = "SOB"), seed = seed)$volume - } else { - vol = vol + volume(P, settings = list("algorithm" = "CG"), seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -cran_only = TRUE - -for (i in 1:2) { - - if (i==1) { - algo = 'CG' - num_of_exps = 10 - } else { - algo = 'CB' - num_of_exps = 10 - } - - - test_that("Volume H-cube10", { - P = gen_cube(10, 'H') - res = Hruntest(P, 'H-cube10', 1024, 0.2, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - - test_that("Volume H-cross5", { - P = gen_cross(5, 'H') - res = Hruntest(P, 'H-cross10', 0.2666667, 0.2, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - - - test_that("Volume H-prod_simplex_5_5", { - P = gen_prod_simplex(5) - res = Hruntest(P, 'H-prod_simplex_5_5', (1/prod(1:5))^2, 0.2, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - - test_that("Volume H-cube10", { - P = gen_cube(10, 'H') - res = Hruntest(P, 'H-cube10', 1024, 0.2, 5, "SOB", 5) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/tests/testthat/test_InnerBall.R b/R-proj/tests/testthat/test_InnerBall.R deleted file mode 100644 index cb19e1c00..000000000 --- a/R-proj/tests/testthat/test_InnerBall.R +++ /dev/null @@ -1,135 +0,0 @@ -context("Chebychev ball test") - -library(volesti) - -runCheTest <- function(P, name_string, radius, tol) { - - vec_ball = inner_ball(P, lpsolve = TRUE) - rad = vec_ball[length(vec_ball)] - - error = abs(radius - rad) / radius - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -tol = 0.00001 - -test_that("Chebychev test", { - P = gen_cube(10, 'H') - res = runCheTest(P, 'H-cube10', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_cube(20, 'H') - res = runCheTest(P, 'H-cube20', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_cube(30, 'H') - res = runCheTest(P, 'H-cube30', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_cross(10, 'H') - res = runCheTest(P, 'H-cross10', 0.316228, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_birkhoff(3) - res = runCheTest(P, 'H-birk3', 0.207107, tol) - expect_equal(res, 1) -}) - - -test_that("Chebychev test", { - P = gen_birkhoff(4) - res = runCheTest(P, 'H-birk4', 0.122008, tol) - expect_equal(res, 1) -}) - - -test_that("Chebychev test", { - P = gen_birkhoff(5) - res = runCheTest(P, 'H-birk5', 0.0833333, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_birkhoff(6) - res = runCheTest(P, 'H-birk6', 0.0618034, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(5) - res = runCheTest(P, 'H-prod_simplex_5_5', 0.138197, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(10) - res = runCheTest(P, 'H-prod_simplex_10_10', 0.0759747, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(15) - res = runCheTest(P, 'H-prod_simplex_15_15', 0.0529858, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(20) - res = runCheTest(P, 'H-prod_simplex_20_20', 0.0408628, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(10, 'H') - res = runCheTest(P, 'H-simplex10', 0.0759747, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(20, 'H') - res = runCheTest(P, 'H-simplex20', 0.0408628, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(30, 'H') - res = runCheTest(P, 'H-simplex30', 0.0281871, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(40, 'H') - res = runCheTest(P, 'H-simplex40', 0.0215868, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(50, 'H') - res = runCheTest(P, 'H-simplex50', 0.017522, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_skinny_cube(10) - res = runCheTest(P, 'H-skinny_cube10', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_skinny_cube(20) - res = runCheTest(P, 'H-skinny_cube20', 1.0, tol) - expect_equal(res, 1) -}) diff --git a/R-proj/tests/testthat/test_Vvol.R b/R-proj/tests/testthat/test_Vvol.R deleted file mode 100644 index 9e18e52b2..000000000 --- a/R-proj/tests/testthat/test_Vvol.R +++ /dev/null @@ -1,44 +0,0 @@ -context("V-polytopes' volume test") - -library(volesti) - -Vruntest <- function(P, name_string, exactvol, tol, num_of_exps, algorithm,seed){ - - vol = 0 - for (j in 1:num_of_exps) { - if (algorithm == "CB") { - vol = vol + volume(P, rounding = "none", seed = seed)$volume - } else { - vol = vol + volume(P, settings = list("algorithm" = "CG", "error" = 0.1), rounding = "none", seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -cran_only = TRUE -num_of_exps = 2 - -for (i in 1:2) { - seed = 5 - if (i==1) { - algo = 'CG' - tol = 0.2 - } else { - algo = 'CB' - tol = 0.2 - } - - test_that("Volume V-simplex3", { - P = gen_simplex(3, 'V') - res = Vruntest(P, 'V-simplex3', 1/prod(1:3), tol, num_of_exps, algo, seed) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/tests/testthat/test_Zvol.R b/R-proj/tests/testthat/test_Zvol.R deleted file mode 100644 index f382b003c..000000000 --- a/R-proj/tests/testthat/test_Zvol.R +++ /dev/null @@ -1,45 +0,0 @@ -context("Zonotopes' volume test") - -library(volesti) - -Zruntest <- function(P, name_string, tol, num_of_exps, algo, seed){ - - exactvol = exact_vol(P) - vol = 0 - for (j in 1:num_of_exps) { - if (algo == "CB") { - vol = vol + volume(P, settings = list("hpoly" = FALSE), rounding = "none", seed = seed)$volume - } else { - vol = vol + volume(P, settings = list("algorithm" = "CG", "error" = 0.1), rounding = "none", seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -cran_only = TRUE -num_of_exps = 2 - -for (i in 1:2) { - if (i==1) { - algo = 'CG' - tol = 0.2 - } else { - algo = 'CB' - tol = 0.2 - } - - test_that("Volume Zonotope_2_4", { - #skip_if(Sys.info()[["machine"]] %in% c("x86_32")) - Z = gen_rand_zonotope(2, 4, seed = 127) - res = Zruntest(Z, 'Zonotope_2_4', tol, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/tests/testthat/test_copulas.R b/R-proj/tests/testthat/test_copulas.R deleted file mode 100644 index e0ee51375..000000000 --- a/R-proj/tests/testthat/test_copulas.R +++ /dev/null @@ -1,23 +0,0 @@ -context("Copulas' test") - -library(volesti) - -test_that("10-dimensional 2-hyp_fam copula", { - h1 = h1 = runif(n = 10, min = 1, max = 1000) - h1 = h1 / 1000 - h2 = h2 = runif(n = 10, min = 1, max = 1000) - h2 = h1 / 1000 - cop = copula(r1 = h1 , r2 = h2 , m = 10, n = 100000) - res = sum(cop) - expect_equal(res, 1) -}) - -test_that("20-dimensional 1_hyp_1_ell fam copula", { - h = h = runif(n = 20, min = 1, max = 1000) - h = h / 1000 - E = replicate(20, rnorm(30)) - E = cov(E) - cop = copula(r1 = h , sigma = E , m = 100, n = 100000) - res = sum(cop) - expect_equal(res, 1) -}) \ No newline at end of file diff --git a/R-proj/tests/testthat/test_rounding.R b/R-proj/tests/testthat/test_rounding.R deleted file mode 100644 index 5d308e367..000000000 --- a/R-proj/tests/testthat/test_rounding.R +++ /dev/null @@ -1,49 +0,0 @@ -context("Rounding test") - -library(volesti) - -testRound <- function(P, exactvol, tol, name_string, num_of_exps, algo, rotation,seed){ - - if (rotation) { - P = rand_rotate(P) - listHpoly = round_polytope(P, seed = seed) - } else { - listHpoly = round_polytope(P, seed = seed) - } - vol = 0 - for (j in 1:num_of_exps) { - if (algo == "CB") { - vol = vol + listHpoly$round_value * volume(listHpoly$P, seed = seed)$volume - } else { - vol = vol + listHpoly$round_value * volume(listHpoly$P, settings=list("algorithm"="CG", "error"=0.1), seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) - - -} - -cran_only = TRUE - -for (i in 1:2) { - - num_of_exps = 10 - - - - test_that("Rounding H-skinny_cube10", { - seed=5 - P = gen_skinny_cube(10) - res = testRound(P, 102400, 0.3, 'H-skinny_cube10', num_of_exps, 'CB', FALSE,seed) - expect_equal(res, 1) - }) - - -} diff --git a/R-proj/tests/testthat/test_sampling.R b/R-proj/tests/testthat/test_sampling.R deleted file mode 100644 index 1950eda07..000000000 --- a/R-proj/tests/testthat/test_sampling.R +++ /dev/null @@ -1,76 +0,0 @@ -context("Sampling test") - -library(volesti) - -runsample <- function(P, name_string, dist){ - if (dist == "uniform") { - p = sample_points(P, n = 100) - } else { - p = sample_points(P, n = 100, distribution = list("density" = "gaussian")) - } - if (length(p[is.nan(p)])>0 | length(p[is.infinite(p)])>0) { - res = 0 - } else { - res = 1 - } - return(res) - -} - -for (i in 1:2) { - - if (i==1) { - distribution = 'gaussian' - } else { - distribution = 'uniform' - } - - test_that("Sampling test", { - P= gen_cube(10, 'H') - res = runsample(P, 'H-cube10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_cross(10, 'H') - res = runsample(P, 'H-cross10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_prod_simplex(5) - res = runsample(P, 'H-prod_simplex_5_5', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_prod_simplex(10) - res = runsample(P, 'H-prod_simplex_10_10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_simplex(10, 'H') - res = runsample(P, 'H-prod_simplex10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_skinny_cube(10) - res = runsample(P, 'H-skinny_cube10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_skinny_cube(20) - res = runsample(P, 'H-skinny_cube20', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - Z = gen_rand_zonotope(4, 8) - res = runsample(Z, 'zonotope_4_8', distribution) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/vignettes/Arxiv.Rnw b/R-proj/vignettes/Arxiv.Rnw deleted file mode 100644 index f6c506299..000000000 --- a/R-proj/vignettes/Arxiv.Rnw +++ /dev/null @@ -1,7 +0,0 @@ -\documentclass{article} -\usepackage{pdfpages} -%\VignetteIndexEntry{Arxiv paper} - -\begin{document} -\includepdf[pages=-, fitpaper=true]{volesti_arxiv.pdf} -\end{document} diff --git a/R-proj/vignettes/volesti_arxiv.pdf b/R-proj/vignettes/volesti_arxiv.pdf deleted file mode 100644 index 1b9438218..000000000 Binary files a/R-proj/vignettes/volesti_arxiv.pdf and /dev/null differ diff --git a/R-proj/volesti.Rproj b/R-proj/volesti.Rproj deleted file mode 100644 index 21a4da087..000000000 --- a/R-proj/volesti.Rproj +++ /dev/null @@ -1,17 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/cran_gen/.Rbuildignore b/cran_gen/.Rbuildignore deleted file mode 100644 index fd2ed1b3d..000000000 --- a/cran_gen/.Rbuildignore +++ /dev/null @@ -1,4 +0,0 @@ -^.*\.Rproj$ -^\.Rproj\.user$ -^volesti\.Rproj$ -^inst/checks$ diff --git a/cran_gen/Makefile b/cran_gen/Makefile deleted file mode 100644 index 3f53931a7..000000000 --- a/cran_gen/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -LP_SOLVE_CPPFLAGS=$(CPPFLAGS) -I../../headers/include \ - -I$(R_INCLUDE_DIR) \ - -DYY_NEVER_INTERACTIVE \ - -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL \ - -DRoleIsExternalInvEngine - -LP_SOLVE_SOURCES=colamd.c lp_MDO.c lp_mipbb.c lp_rlp.c mmio.c commonlib.c \ - lp_MPS.c lp_params.c lp_scale.c lp_SOS.c \ - lp_presolve.c lp_simplex.c yacc_read.c ini.c lp_crash.c \ - lp_price.c lp_utils.c lp_Hash.c lp_lib.c lp_pricePSE.c \ - lp_wlp.c lp_LUSOL.c lp_matrix.c lp_report.c lusol.c \ - myblas.c - -LP_SOLVE_OBJECTS=$(LP_SOLVE_SOURCES:.c=.o) - -liblp_solve.a: $(LP_SOLVE_OBJECTS) - $(AR) rc liblp_solve.a $(LP_SOLVE_OBJECTS) && $(RANLIB) liblp_solve.a - -.c.o: - $(CC) $(CFLAGS) $(CPICFLAGS) $(LP_SOLVE_CPPFLAGS) -c $< -o $@ - -clean: - rm -rf $(LP_SOLVE_OBJECTS) liblp_solve.a diff --git a/cran_gen/Makevars b/cran_gen/Makevars deleted file mode 100644 index a609d3dac..000000000 --- a/cran_gen/Makevars +++ /dev/null @@ -1,12 +0,0 @@ -PKG_CPPFLAGS=-Iexternal -Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude -Iinclude/convex_bodies/spectrahedra -PKG_CXXFLAGS= -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES -CXX_STD = CXX11 - -PKG_LIBS=-Lexternal/lpsolve/build/lp_solve -llp_solve $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): external/lpsolve/build/lp_solve/liblp_solve.a - -external/lpsolve/build/lp_solve/liblp_solve.a: - @(cd external/lpsolve/build/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)") diff --git a/cran_gen/Makevars.win b/cran_gen/Makevars.win deleted file mode 100644 index 70005148e..000000000 --- a/cran_gen/Makevars.win +++ /dev/null @@ -1,13 +0,0 @@ -PKG_CPPFLAGS=-Iexternal -Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude -Iinclude/convex_bodies/spectrahedra -PKG_CXXFLAGS= -lm -ldl -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES -CXX_STD = CXX11 - -PKG_LIBS=-Lexternal/lpsolve/build/lp_solve -llp_solve $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): external/lpsolve/build/lp_solve/liblp_solve.a - -external/lpsolve/build/lp_solve/liblp_solve.a: - @(cd external/lpsolve/build/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS) -DUSRDLL -DINLINE=static" \ - CFLAGS="$(CFLAGS)" CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" \ - RANLIB="$(RANLIB)") diff --git a/cran_gen/NEWS.md b/cran_gen/NEWS.md deleted file mode 100644 index 5038f653b..000000000 --- a/cran_gen/NEWS.md +++ /dev/null @@ -1,31 +0,0 @@ -# volesti 1.0.0 - -* This is the first release of volesti R-Package. - -# volesti 1.0.1 - -* Fix some bugs for solaris os. - -# volesti 1.0.2 - -* Remove r-striper to avoid CRAN policy violation. - -# volesti 1.0.3 - -* Fix CRAN warnings. - -# volesti 1.1.0 - -* New volume computation algorithm. -* Billiard walk for uniform sampling. -* Modified exact volume computation function. -* Implementation and evaluation of PCA method for zonotope approximation. -* Boundary sampling. -* Improved functionality for finance applications. -* Improved names for functions and input variables. -* Use exclusively Eigen/BH library for linear algebra. - -# volesti 1.1.1 - -* Fix CRAN warnings about deprecated use of ftime - diff --git a/cran_gen/README.md b/cran_gen/README.md deleted file mode 100644 index 8a9245ec5..000000000 --- a/cran_gen/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Volume computation and sampling - -## About -The `volesti` package provides [R](https://www.r-project.org/) with functions for volume estimation and sampling. In particular, it provides an R interface for the C++ library [**volesti**](https://github.com/GeomScale/volume_approximation). - -`volesti` computes approximations of volume of polytopes given as a set of points or linear inequalities or as a Minkowski sum of segments (zonotopes). There are algorithms for volume approximation as well as algorithms for sampling, rounding and rotating polytopes. Last but not least, `volesti` provides implementations of geometric algorithms to compute the score of a portfolio given asset returns and to detect financial crises in stock markets. - -## Download and install - -* The latest stable version is available from CRAN. -* The latest development version is available on Github `www.github.com/GeomScale/volume_approximation` - -* Install `volesti` by running: -``` -install.packages("volesti") -``` -* The package-dependencies are: `Rcpp`, `RcppEigen`, `BH`. - -## Documentation - -* [Using the R Interface](https://github.com/GeomScale/volume_approximation/blob/v1.1.1/doc/r_interface.md) -* [Wikipage with Tutorials and Demos](https://github.com/GeomScale/volume_approximation/wiki) -* [Tutorial given to PyData meetup](https://vissarion.github.io/tutorials/volesti_tutorial_pydata.html) - - -## Credits - -* [Contributors and Package History](https://github.com/GeomScale/volume_approximation/blob/v1.1.1/doc/credits.md) -* [List of Publications](https://github.com/GeomScale/volume_approximation/blob/v1.1.1/doc/publications.md) - -Copyright (c) 2012-2020 Vissarion Fisikopoulos -Copyright (c) 2018-2020 Apostolos Chalkis - -You may redistribute or modify the software under the GNU Lesser General Public License as published by Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. - diff --git a/cran_gen/genCRANpkg.R b/cran_gen/genCRANpkg.R deleted file mode 100644 index f12905f06..000000000 --- a/cran_gen/genCRANpkg.R +++ /dev/null @@ -1,182 +0,0 @@ -# create cran package folder -dir.create("cran_package") -# set /root as main path -path = getwd() -path = substr(path, start=1, stop=nchar(path)-9) - -# download lpSolveAPI and crate src/Rproj_externals/lp_solve -library(downloader) -download("https://cran.r-project.org/src/contrib/Archive/lpSolveAPI/lpSolveAPI_5.5.2.0-17.6.tar.gz", dest="lpSolve.tar.gz", mode="wb") -untar("lpSolve.tar.gz", exdir = path) -unlink("lpSolve.tar.gz") -dir.create(paste0(path,"/R-proj/src/Rproj_externals")) -dir_lp = paste0(path,"/lpSolveAPI/src/lp_solve") -lp_dist = paste0(path,"/R-proj/src/Rproj_externals") -file.copy(dir_lp, lp_dist, recursive=TRUE) - -# fix ftime deprecation, taken from: https://github.com/GeomScale/volesti/pull/89/files -library(xfun) -gsub_file( - paste0(path,"/R-proj/src/Rproj_externals/lp_solve/commonlib.c"), - "struct timeb buf;", "", - fixed=TRUE) -gsub_file( - paste0(path,"/R-proj/src/Rproj_externals/lp_solve/commonlib.c"), - "ftime(&buf);", "", - fixed=TRUE) -gsub_file( - paste0(path,"/R-proj/src/Rproj_externals/lp_solve/commonlib.c"), - "return((double)buf.time+((double) buf.millitm)/1000.0);", - "return((double)0);", - fixed=TRUE) - -# add lpsolve header files in external -library(downloader) -download("https://cran.r-project.org/src/contrib/Archive/lpSolve/lpSolve_5.6.15.tar.gz", dest="lpSolve.tar.gz", mode="wb") -untar("lpSolve.tar.gz", exdir = path) -unlink("lpSolve.tar.gz") -dir.create(paste0(path,"/external/LPsolve_src")) -dir.create(paste0(path,"/external/LPsolve_src/include")) -dir.create(paste0(path,"/external/LPsolve_src/run_headers")) -dir_lp = paste0(path,"/lpSolveAPI/inst/include") -h_files = dir(dir_lp, "*.h", ignore.case = TRUE, all.files = TRUE) -lp_dist = paste0(path,"/external/LPsolve_src/include") -file.copy(file.path(dir_lp, h_files), lp_dist, recursive=TRUE, overwrite=TRUE) -dir_lp = paste0(path,"/lpSolve/src") -h_files = dir(dir_lp, "*.h", ignore.case = TRUE, all.files = TRUE) -lp_dist = paste0(path,"/external/LPsolve_src/run_headers") -file.copy(file.path(dir_lp, h_files), lp_dist, recursive=TRUE) -unlink(paste0(path,"/lpSolveAPI"), recursive=TRUE) -unlink(paste0(path,"/lpSolve"), recursive=TRUE) - -# copy paste the src folder -src_dir = paste0(path,'/R-proj/src') -src_dist = paste0(path,'/cran_gen/cran_package') -file.copy(src_dir, src_dist, recursive=TRUE) - -# copy paste the inst folder -inst_dir = paste0(path,'/R-proj/inst') -inst_dist = paste0(path,'/cran_gen/cran_package') -file.copy(inst_dir, inst_dist, recursive=TRUE) - -# copy paste the man folder -man_dir = paste0(path,'/R-proj/man') -man_dist = paste0(path,'/cran_gen/cran_package') -file.copy(man_dir, man_dist, recursive=TRUE) - -# copy paste the R folder -R_dir = paste0(path,'/R-proj/R') -R_dist = paste0(path,'/cran_gen/cran_package') -file.copy(R_dir, R_dist, recursive=TRUE) - -# copy paste the tests folder -tests_dir = paste0(path,'/R-proj/tests') -tests_dist = paste0(path,'/cran_gen/cran_package') -file.copy(tests_dir, tests_dist, recursive=TRUE) - -# copy paste the DESCRIPTION file -descr_dir = paste0(path,'/R-proj/DESCRIPTION') -descr_dist = paste0(path,'/cran_gen/cran_package') -file.copy(descr_dir, descr_dist, recursive=TRUE) - -# copy paste the NAMESPACE file -namesp_dir = paste0(path,'/R-proj/NAMESPACE') -namesp_dist = paste0(path,'/cran_gen/cran_package') -file.copy(namesp_dir, namesp_dist, recursive=TRUE) - -# copy paste the volesti.Rproj -volpro_dir = paste0(path,'/R-proj/volesti.Rproj') -volpro_dist = paste0(path,'/cran_gen/cran_package') -file.copy(volpro_dir, volpro_dist, recursive=TRUE) - -# copy paste the external folder -external_dir = paste0(path,'/external') -external_dist = paste0(path,'/cran_gen/cran_package/src') -file.copy(external_dir, external_dist, recursive=TRUE) - -# copy paste the include folder -include_dir = paste0(path,'/include') -include_dist = paste0(path,'/cran_gen/cran_package/src') -file.copy(include_dir, include_dist, recursive=TRUE) - -# copy paste the README.md file -readme_dir = paste0(path,'/cran_gen/README.md') -readme_dist = paste0(path,'/cran_gen/cran_package') -file.copy(readme_dir, readme_dist, recursive=TRUE) - -# copy paste the NEWS.md file -news_dir = paste0(path,'/cran_gen/NEWS.md') -news_dist = paste0(path,'/cran_gen/cran_package') -file.copy(news_dir, news_dist, recursive=TRUE) - -# copy paste the cran-comments.md file -#cran_com_dir = paste0(path,'/cran_gen/cran-comments.md') -#cran_com_dist = paste0(path,'/cran_gen/cran_package') -#file.copy(cran_com_dir, cran_com_dist, recursive=TRUE) - -# copy paste the Rbuildignore.md file -Rbuild_dir = paste0(path,'/cran_gen/.Rbuildignore') -Rbuild_dist = paste0(path,'/cran_gen/cran_package') -file.copy(Rbuild_dir, Rbuild_dist, recursive=TRUE) - -# replace the Makevars -makevars_dir = paste0(path,'/cran_gen/Makevars') -makevars_dist = paste0(path, '/cran_gen/cran_package/src') -file.copy(makevars_dir, makevars_dist, recursive=TRUE) - -# replace the Makevars.win -makevarswin_dir = paste0(path,'/cran_gen/Makevars.win') -makevarswin_dist = paste0(path, '/cran_gen/cran_package/src') -file.copy(makevarswin_dir, makevarswin_dist, recursive=TRUE) - -# copy paste the LICENCE -dir_lic = paste0(path,'/LICENSE') -lic_dist = paste0(path,'/cran_package/inst/doc') - -# delete misc.h from include -dir_misc = paste0(path,'/cran_gen/cran_package/src/include/misc.h') -unlink(dir_misc, recursive = TRUE) - -# delete linear_extensions.h from include -dir_lin_ext = paste0(path,'/cran_gen/cran_package/src/include/linear_extensions.h') -unlink(dir_lin_ext, recursive = TRUE) - -# create lpsolve folder -dir.create(paste0(path,"/cran_gen/cran_package/src/external/lpsolve")) -dir.create(paste0(path,"/cran_gen/cran_package/src/external/lpsolve/build")) -dir.create(paste0(path,"/cran_gen/cran_package/src/external/lpsolve/headers")) -dir_lp = paste0(path,"/cran_gen/cran_package/src/Rproj_externals/lp_solve") -lp_dist = (paste0(path,"/cran_gen/cran_package/src/external/lpsolve/build")) -file.copy(dir_lp, lp_dist, recursive=TRUE) -dir_lp = paste0(path,"/cran_gen/cran_package/src/external/LPsolve_src/include") -lp_dist = (paste0(path,"/cran_gen/cran_package/src/external/lpsolve/headers")) -file.copy(dir_lp, lp_dist, recursive=TRUE) -dir_lp = paste0(path,"/cran_gen/cran_package/src/external/LPsolve_src/run_headers") -lp_dist = (paste0(path,"/cran_gen/cran_package/src/external/lpsolve/headers")) -file.copy(dir_lp, lp_dist, recursive=TRUE) -dir_lpsolve_heds = paste0(path,"/cran_gen/cran_package/src/external/LPsolve_src") -unlink(dir_lpsolve_heds, recursive = TRUE) -dir_lpsolve_heds = paste0(path,"/cran_gen/cran_package/src/Rproj_externals") -unlink(dir_lpsolve_heds, recursive = TRUE) - -# replace the Makefile -makefile_dir = paste0(path,'/cran_gen/Makefile') -makefile_dist = paste0(path, '/cran_gen/cran_package/src/external/lpsolve/build/lp_solve') -file.copy(makefile_dir, makefile_dist, recursive=TRUE) - -# set new cran package folder as wrking directory -setwd(paste0(path,'/cran_gen/cran_package')) -# enable devtools and Rcpp libraries -library(devtools) -library(Rcpp) - -# build package tar.gz -Rcpp::compileAttributes() -devtools::build() - -# set /root/R-proj as the working directory -setwd(paste0(path,'/R-proj')) - -# delete folder cran_package -#dir_cr_pkg = paste0(path,'/cran_gen/cran_package') -#unlink(dir_cr_pkg, recursive = TRUE) diff --git a/docs/getting_started/cpp_example.md b/docs/getting_started/cpp_example.md index 82ac82902..e3e39dcbf 100644 --- a/docs/getting_started/cpp_example.md +++ b/docs/getting_started/cpp_example.md @@ -5,7 +5,6 @@ Here we give step-by-step instructions for how to estimate the volume of a 3-dim Write the following C++ code and save it in `volume_example.cpp` ```c++ - #include "Eigen/Eigen" #include "cartesian_geom/cartesian_kernel.h" #include "convex_bodies/hpolytope.h" @@ -30,8 +29,7 @@ int main() { double e = 0.1; // Calculating volume of the passed polytope - double volume = volume_cooling_balls - (HP, e, walk_len).second; + double volume = volume_cooling_balls(HP, e, walk_len).second; std::cout << "Volume of the cube: " << volume << std::endl; @@ -46,18 +44,15 @@ project( VolEsti-cpp-example ) CMAKE_MINIMUM_REQUIRED(VERSION 3.11) -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) - -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - add_definitions(-DDISABLE_NLP_ORACLES) -option(BUILTIN_EIGEN "Use eigen from ../../external" OFF) - include("../../external/cmake-files/Eigen.cmake") GetEigen() +if (${CMAKE_VERSION} VERSION_LESS "3.12.0") + add_compile_options(-D "EIGEN_NO_DEBUG") +else () + add_compile_definitions("EIGEN_NO_DEBUG") +endif () include("../../external/cmake-files/Boost.cmake") GetBoost() @@ -65,33 +60,13 @@ GetBoost() include("../../external/cmake-files/LPSolve.cmake") GetLPSolve() -# Find lpsolve library -find_library(LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve) - -if (NOT LP_SOLVE) - message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") -else () - message(STATUS "Library lp_solve found: ${LP_SOLVE}") - - set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") - - include_directories (BEFORE ../../external) - include_directories (BEFORE ../../include) - - # for Eigen - if (${CMAKE_VERSION} VERSION_LESS "3.12.0") - add_compile_options(-D "EIGEN_NO_DEBUG") - else () - add_compile_definitions("EIGEN_NO_DEBUG") - endif () - - - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard +set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") - add_executable (volume_example volume_example.cpp) - TARGET_LINK_LIBRARIES(volume_example ${LP_SOLVE}) +include_directories (BEFORE ../../external) +include_directories (BEFORE ../../include) -endif() +add_executable (volume_example volume_example.cpp) +target_link_libraries(volume_example PUBLIC lp_solve) ``` We will use `cmake` to build the makefile and compile our example. diff --git a/docs/getting_started/install.md b/docs/getting_started/install.md index cfdb773e7..58fcfe163 100644 --- a/docs/getting_started/install.md +++ b/docs/getting_started/install.md @@ -6,16 +6,13 @@ Installation Guide ### Compile C++ sources and run tests --- -To compile the C++ code you need the [lp_solve](http://lpsolve.sourceforge.net/5.5/) library. For example, for Unix/Linux you need `liblpsolve55.so`. This is available from the library's [webpage](http://lpsolve.sourceforge.net/5.5/) as well as a package in several linux distributions e.g. [debian](https://packages.debian.org/stretch/liblpsolve55-dev) `sudo apt-get install lp-solve`. - -You have to specify the path to `liblpsolve55.so/dll/dylib`, by running, in folder test: +To compile the tests of the C++ interface simply ```bash mkdir -p test/build && cd test/build -cmake -DLP_SOLVE=_PATH_TO_LIB_FILE_ .. +cmake .. make ``` -For example: `-DLP_SOLVE=/usr/lib/lpsolve/liblpsolve55.so` In WSL (Windows Subsystem Linux), you can run the following command to install libc6-dev-i386. This will be required for `ieeefp.h` which is used by `qd` library, @@ -59,43 +56,7 @@ docker run -it -v $PWD:/volesti -w /volesti --name=volesti-dev volesti:dev /bin/ ## R Interface -### Install Rcpp package ---- - -1. Install package-dependencies: ``Rcpp``, ``RcppEigen``, ``BH``. - -2. Then use ``devtools`` package to install ``volesti`` Rcpp package. From terminal go to folder ``/root/R-proj`` and run in terminal: - -```bash - Rscript -e 'Rcpp::compileAttributes()' - R CMD INSTALL --no-multiarch --with-keep.source . -``` - -3. You can use Rstudio as well to open ``volesti.Rproj`` and then click `build source Package` and then `Install and Restart` in `Build` at the menu bar. - -### Generate CRAN version ---- - -To generate the CRAN version of the R package follow the instructions below: - -1. From the command line navigate to folder ``/cran_gen``. Then Run: - -```r - source('genCRANpkg.R') -``` - -2. Open ``genCRANpkg.R`` script with `Rstudio` and run it. - -### Run volesti from R ---- - -* The main function is ``volume()``. It can be used to approximate the volume of a convex polytope given as a set of linear inequalities or a set of vertices (d-dimensional points) or as a Minkowski sum of segments (zonotope). There are three algorithms that can be used (``SequenceOfBalls``, ``CoolingGaussian`` and ``CoolingBalls``). -* The function ``sample_points()`` can be used to sample points from a convex polytope with uniform or spherical gaussian target distribution. -* The function ``round_polytope()`` can be used to round a convex polytope. -* The function ``rand_rotate()`` can be used to apply a random rotation to a convex polytope. - -For more details you can read the documentation in folder ``/inst/doc``. - +An ``R`` interface is available from the package [Rvolesti](https://github.com/GeomScale/Rvolesti). ## Python Interface diff --git a/docs/getting_started/r_example.md b/docs/getting_started/r_example.md deleted file mode 100644 index 0850de823..000000000 --- a/docs/getting_started/r_example.md +++ /dev/null @@ -1,7 +0,0 @@ -# How to create your first example using the R interface - -Here we give step-by-step instructions for how to estimate the volume of a 3-dimensional cube using the R interface of the `volesti` library. - -The user first should install the R interface by following instructions in {doc}`installation guide `. - -to be written ... diff --git a/docs/index.rst b/docs/index.rst index a64b5bf4b..ce0b73886 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,7 +12,6 @@ Welcome to VolEsti's documentation! getting_started/install.md getting_started/cpp_example.md - getting_started/r_example.md .. toctree:: :caption: Tutorials diff --git a/docs/misc/documentation.md b/docs/misc/documentation.md deleted file mode 100644 index 35e066604..000000000 --- a/docs/misc/documentation.md +++ /dev/null @@ -1,20 +0,0 @@ -# Generate documentation - -## How to generate documentation - -Technologies used: Doxygen + Spnynx + Breathe - -to be written ... - -## Create pdf documentation from Rd files - -* Install volesti library. -* In `R` mode (or in Rstudio) Run -```r -pack = "volesti" -path = find.package(pack) -system(paste(shQuote(file.path(R.home("bin"), "R")), - "CMD", "Rd2pdf", shQuote(path))) -``` -* The pdf will be created and saved in `R-proj` folder. -* We give such a documentation in `/R-proj/doc` folder. diff --git a/docs/requirements.txt b/docs/requirements.txt index f02db7709..9fa3dfbed 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,3 +2,4 @@ breathe sphinx_sitemap myst_parser sphinx-math-dollar +sphinx_rtd_theme diff --git a/examples/autopoint/CMakeLists.txt b/examples/autopoint/CMakeLists.txt new file mode 100644 index 000000000..77e592dd0 --- /dev/null +++ b/examples/autopoint/CMakeLists.txt @@ -0,0 +1,167 @@ +# VolEsti (volume computation and sampling library) +# Copyright (c) 2012-2018 Vissarion Fisikopoulos +# Copyright (c) 2018 Apostolos Chalkis +# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. +# Contributed and/or modified by Zhang zhuyan, as part of Google Summer of Code 2022 program. +# Licensed under GNU LGPL.3, see LICENCE file + + +project( VolEsti ) + + +option(DISABLE_NLP_ORACLES "Disable non-linear oracles (used in collocation)" ON) +option(BUILTIN_EIGEN "Use eigen from ../external" OFF) +option(USE_MKL "Use MKL library to build eigen" OFF) + +CMAKE_MINIMUM_REQUIRED(VERSION 3.17) + +set(MKLROOT /opt/intel/oneapi/mkl/2023.0.0) +message( "MKLROOT" ${MKLROOT}) +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + +if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + + +if(DISABLE_NLP_ORACLES) + add_definitions(-DDISABLE_NLP_ORACLES) +else() + find_library(IFOPT NAMES libifopt_core.so PATHS /usr/local/lib) + find_library(IFOPT_IPOPT NAMES libifopt_ipopt.so PATHS /usr/local/lib) + find_library(GMP NAMES libgmp.so PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu) + find_library(MPSOLVE NAMES libmps.so PATHS /usr/local/lib) + find_library(PTHREAD NAMES libpthread.so PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu) + find_library(FFTW3 NAMES libfftw3.so.3 PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu) + + if (NOT IFOPT) + + message(FATAL_ERROR "This program requires the ifopt library, and will not be compiled.") + + elseif (NOT GMP) + + message(FATAL_ERROR "This program requires the gmp library, and will not be compiled.") + + elseif (NOT MPSOLVE) + + message(FATAL_ERROR "This program requires the mpsolve library, and will not be compiled.") + + elseif (NOT FFTW3) + + message(FATAL_ERROR "This program requires the fftw3 library, and will not be compiled.") + + else() + message(STATUS "Library ifopt found: ${IFOPT}") + message(STATUS "Library gmp found: ${GMP}") + message(STATUS "Library mpsolve found: ${MPSOLVE}") + message(STATUS "Library fftw3 found:" ${FFTW3}) + + endif(NOT IFOPT) + +endif(DISABLE_NLP_ORACLES) + +option(BUILTIN_AUTODIFF "Use autodiff from ../external" OFF) +include("../../external/cmake-files/Autodiff.cmake") +GetAutodiff() +if (BUILTIN_AUTODIFF) + include_directories (BEFORE ../../external/_deps/Autodiff) +else () + include_directories(BEFORE /usr/local/include) +endif(BUILTIN_AUTODIFF) + +include("../../external/cmake-files/Eigen.cmake") +GetEigen() + +include("../../external/cmake-files/Boost.cmake") +GetBoost() + +include("../../external/cmake-files/LPSolve.cmake") +GetLPSolve() + +if (BUILTIN_EIGEN) + include_directories (BEFORE ../../external/_deps/Eigen) +else () + include_directories(BEFORE /usr/include/eigen3) +endif(BUILTIN_EIGEN) + + +if (USE_MKL) +find_library(BLAS +NAMES libblas.so +PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/lib64/atlas /usr/lib/atlas /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib +) + +message("Found MKL: ${MKLROOT}") + include_directories (BEFORE ${MKLROOT}/include) + set(PROJECT_LIBS ${BLAS_LIBRARIES}) + set(MKL_LINK "-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") + add_definitions(-DEIGEN_USE_MKL_ALL) +endif(USE_MKL) + +# Find lpsolve library +find_library(LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve) + +if (NOT LP_SOLVE) + message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") +else () + message(STATUS "Library lp_solve found: ${LP_SOLVE} ${BLAS}") + + set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") + + include_directories (BEFORE ../../external) + include_directories (BEFORE ../../external/minimum_ellipsoid) + include_directories (BEFORE ../../include/generators) + include_directories (BEFORE ../../include/volume) + include_directories (BEFORE ../../include) + include_directories (BEFORE ../../include/lp_oracles) + include_directories (BEFORE ../../include/nlp_oracles) + include_directories (BEFORE ../../include/convex_bodies) + include_directories (BEFORE ../../include/random_walks) + include_directories (BEFORE ../../include/annealing) + include_directories (BEFORE ../../include/ode_solvers) + include_directories (BEFORE ../../include/root_finders) + include_directories (BEFORE ../../include/samplers) + include_directories (BEFORE ../../include/misc) + include_directories (BEFORE ../../include/optimization) + + # for Eigen + if (${CMAKE_VERSION} VERSION_LESS "3.12.0") + add_compile_options(-D "EIGEN_NO_DEBUG") + else () + add_compile_definitions("EIGEN_NO_DEBUG") + endif () + + + message("THIS IS mkl ${MKL_INCLUDE_DIRS}") + if (MKL_FOUND) + message("MKL") + message("${MKL_INCLUDE_DIRS}") +endif() + + + + add_definitions(${CMAKE_CXX_FLAGS} "-std=c++17") # enable C++14 standard + add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler + add_definitions(${CMAKE_CXX_FLAGS} "-pthread") # optimization of the compiler + + #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") + add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") + add_definitions(${CMAKE_CXX_FLAGS} "-DMKL_ILP64") + add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") + add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") + + add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-D_REENTRANT") + #add_definitions( "-O3 -lgsl -lm -ldl -lgslcblas" ) + + add_executable (userDefinedFunction_manual_gradient userDefinedFunction_manual_gradient.cpp) + TARGET_LINK_LIBRARIES(userDefinedFunction_manual_gradient ${LP_SOLVE} ${BLAS} ${MKL_LINK}) + add_executable (userDefinedFunction_autopoint userDefinedFunction_autopoint.cpp) + TARGET_LINK_LIBRARIES(userDefinedFunction_autopoint ${LP_SOLVE} ${BLAS} ${MKL_LINK}) + add_executable (Gaussian_mixture_autopoint Gaussian_mixture_autopoint.cpp readData.cpp) + TARGET_LINK_LIBRARIES(Gaussian_mixture_autopoint ${LP_SOLVE} ${BLAS} ${MKL_LINK}) + add_executable (MultidimensionalGaussian_mixture_autopoint MultidimensionalGaussian_mixture_autopoint.cpp readData.cpp) + TARGET_LINK_LIBRARIES(MultidimensionalGaussian_mixture_autopoint ${LP_SOLVE} ${BLAS} ${MKL_LINK}) + + + endif() + diff --git a/examples/autopoint/Gaussian_mixture_autopoint.cpp b/examples/autopoint/Gaussian_mixture_autopoint.cpp new file mode 100644 index 000000000..44dbbd539 --- /dev/null +++ b/examples/autopoint/Gaussian_mixture_autopoint.cpp @@ -0,0 +1,123 @@ +// Use forward-mode automatic differentiation using Autodiff Library + +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2020-2020 Marios Papachristou +// Copyright (c) 2022-2022 Zhang zhuyan + +// Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. +// Contributed and/or modified by Zhang zhuyan, as part of Google Summer of Code 2020 program. + +// Licensed under GNU LGPL.3, see LICENCE file + +// task number 1 use array and fix the problem first done +// difference between EigenArray and EigenVector + +#include +#include +#include +#include +#include +#include +#include + +#include "Eigen/Eigen" + +#include "ode_solvers/ode_solvers.hpp" +#include "ode_solvers/oracle_autodiff_functors.hpp" +#include "random.hpp" +#include "random/uniform_int.hpp" +#include "random/normal_distribution.hpp" +#include "random/uniform_real_distribution.hpp" +#include "random_walks/random_walks.hpp" +#include "volume/volume_sequence_of_balls.hpp" +#include "volume/volume_cooling_gaussians.hpp" +#include "volume/volume_cooling_balls.hpp" +#include "generators/known_polytope_generators.h" +#include "readData.h" +#include "diagnostics/diagnostics.hpp" +#include "cartesian_geom/autopoint.h" + +template +void run_main() +{ + typedef Cartesian Kernel; + typedef typename Kernel::Point Point; + typedef std::vector pts; + typedef HPolytope Hpolytope; + typedef BoostRandomNumberGenerator RandomNumberGenerator; + typedef AutoDiffFunctor::GradientFunctor NegativeGradientFunctor; + typedef AutoDiffFunctor::FunctionFunctor NegativeLogprobFunctor; + typedef LeapfrogODESolver Solver; + typedef typename Hpolytope::MT MT; + typedef typename Hpolytope::VT VT; + AutoDiffFunctor::parameters params; + params.data = readMatrix("data.txt"); + NegativeGradientFunctor F(params); + NegativeLogprobFunctor f(params); + RandomNumberGenerator rng(1); + unsigned int dim = 2; + + HamiltonianMonteCarloWalk::parameters hmc_params(F, dim); + hmc_params.eta=0.00005;// working learning rate for this specific example + std::chrono::time_point start, stop; + + Hpolytope P = generate_cube(dim, false); + + Point x0 = -0.25 * Point::all_ones(dim); + + // In the first argument put in the address of an H-Polytope + // for truncated sampling and NULL for untruncated + HamiltonianMonteCarloWalk::Walk + hmc(&P, x0, F, f, hmc_params); + int n_samples = 50000; // Half will be burned + int max_actual_draws = n_samples / 2; + unsigned int min_ess = 0; + MT samples; + samples.resize(dim, max_actual_draws); + + for (int i = 0; i < n_samples - max_actual_draws; i++) { + hmc.apply(rng, 3); + } + start = std::chrono::high_resolution_clock::now(); + std::cerr << (long)std::chrono::duration_cast(start - stop).count(); + for (int i = 0; i < max_actual_draws; i++) { + std::cout << hmc.x.getCoefficients().transpose() << std::endl; + hmc.apply(rng, 3); + samples.col(i) = hmc.x.getCoefficients(); + } + stop = std::chrono::high_resolution_clock::now(); + long ETA = (long)std::chrono::duration_cast(stop - start).count(); + std::cerr << "total time taken " << ETA << std::endl; + std::cerr << std::endl; + print_diagnostics(samples, min_ess, std::cerr); + std::cerr << "min ess " << min_ess << "us" << std::endl; + std::cerr << "Average time per sample: " << ETA / max_actual_draws << "us" << std::endl; + std::cerr << "Average time per independent sample: " << ETA / min_ess << "us" << std::endl; + std::cerr << "Average number of reflections: " << (1.0 * hmc.solver->num_reflections) / hmc.solver->num_steps << std::endl; + std::cerr << "Step size (final): " << hmc.solver->eta << std::endl; + std::cerr << "Discard Ratio: " << hmc.discard_ratio << std::endl; + std::cerr << "Average Acceptance Probability: " << exp(hmc.average_acceptance_log_prob) << std::endl; + std::cerr << "PSRF: " << multivariate_psrf(samples) << std::endl; + std::cerr << std::endl; +} +using TT = double; +typedef Eigen::Matrix EigenMatrix; +typename autopoint::FT pdf_(const autopoint &x, const Eigen::Matrix &data_) { + // define your function here, + autopoint data_auto = autopoint(data_); + autopoint result = (((-0.5 * 100 * (data_auto - x.getCoefficients()[0]).pow(2)).exp() + (-0.5 * 100 * (data_auto - x.getCoefficients()[1]).pow(2)).exp())).log(); + + auto y = (result * -1.0).sum(); + return y; +} + +template <> +std::function::FT(const autopoint &, const EigenMatrix&)> AutoDiffFunctor::FunctionFunctor_internal::pdf = pdf_; + +int main() { + run_main(); + return 0; +} diff --git a/examples/autopoint/MultidimensionalGaussian_mixture_autopoint.cpp b/examples/autopoint/MultidimensionalGaussian_mixture_autopoint.cpp new file mode 100644 index 000000000..432b7141a --- /dev/null +++ b/examples/autopoint/MultidimensionalGaussian_mixture_autopoint.cpp @@ -0,0 +1,127 @@ +// Use forward-mode automatic differentiation using Autodiff Library + +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2020-2020 Marios Papachristou +// Copyright (c) 2022-2022 Zhang zhuyan + +// Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. +// Contributed and/or modified by Zhang zhuyan, as part of Google Summer of Code 2020 program. + +// Licensed under GNU LGPL.3, see LICENCE file + + +#include +#include +#include +#include +#include +#include +#include + +#include "Eigen/Eigen" + +#include "ode_solvers/ode_solvers.hpp" +#include "ode_solvers/oracle_autodiff_functors.hpp" +#include "random.hpp" +#include "random/uniform_int.hpp" +#include "random/normal_distribution.hpp" +#include "random/uniform_real_distribution.hpp" +#include "random_walks/random_walks.hpp" +#include "volume/volume_sequence_of_balls.hpp" +#include "volume/volume_cooling_gaussians.hpp" +#include "volume/volume_cooling_balls.hpp" +#include "generators/known_polytope_generators.h" +#include "readData.h" +#include "diagnostics/diagnostics.hpp" + + +template +void run_main() +{ + typedef Cartesian Kernel; + typedef typename Kernel::Point Point; + typedef std::vector pts; + typedef HPolytope Hpolytope; + typedef BoostRandomNumberGenerator RandomNumberGenerator; + typedef AutoDiffFunctor::GradientFunctor NegativeGradientFunctor; + typedef AutoDiffFunctor::FunctionFunctor NegativeLogprobFunctor; + typedef LeapfrogODESolver Solver; + typedef typename Hpolytope::MT MT; + typedef typename Hpolytope::VT VT; + AutoDiffFunctor::parameters params; + params.data=readMatrix("data.txt"); + NegativeGradientFunctor F(params); + NegativeLogprobFunctor f(params); + RandomNumberGenerator rng(1); + unsigned int dim = 4; + + HamiltonianMonteCarloWalk::parameters hmc_params(F, dim); + std::chrono::time_point start,stop; + + Hpolytope P = generate_cube(dim, false); + + Point x0 = -0.25 * Point::all_ones(dim); + + // In the first argument put in the address of an H-Polytope + // for truncated sampling and NULL for untruncated + HamiltonianMonteCarloWalk::Walk + hmc(&P, x0, F, f, hmc_params); + int n_samples = 50000; // Half will be burned + int max_actual_draws = n_samples / 2; + unsigned int min_ess = 0; + MT samples; + samples.resize(dim, max_actual_draws); + + for (int i = 0; i < n_samples - max_actual_draws; i++) { + hmc.apply(rng, 3); + } + start = std::chrono::high_resolution_clock::now(); + std::cerr << (long)std::chrono::duration_cast(start - stop).count(); + for (int i = 0; i < max_actual_draws; i++) { + std::cout << hmc.x.getCoefficients().transpose() << std::endl; + hmc.apply(rng, 3); + samples.col(i) = hmc.x.getCoefficients(); + } + stop = std::chrono::high_resolution_clock::now(); + long ETA = (long)std::chrono::duration_cast(stop - start).count(); + std::cerr << "total time taken " << ETA << std::endl; + std::cerr << std::endl; + print_diagnostics(samples, min_ess, std::cerr); + std::cerr << "min ess " << min_ess << "us" << std::endl; + std::cerr << "Average time per sample: " << ETA / max_actual_draws << "us" << std::endl; + std::cerr << "Average time per independent sample: " << ETA / min_ess << "us" << std::endl; + std::cerr << "Average number of reflections: " << (1.0 * hmc.solver->num_reflections) / hmc.solver->num_steps << std::endl; + std::cerr << "Step size (final): " << hmc.solver->eta << std::endl; + std::cerr << "Discard Ratio: " << hmc.discard_ratio << std::endl; + std::cerr << "Average Acceptance Probability: " << exp(hmc.average_acceptance_log_prob) << std::endl; + std::cerr << "PSRF: " << multivariate_psrf(samples) << std::endl; + std::cerr << std::endl; +} +using TT=double; +typedef Eigen::Matrix EigenMatrix; +typename autopoint::FT pdf_(const autopoint& x,const EigenMatrix& data_) { + int d=x.getCoefficients().rows(); + autopoint firstX=x.head(d/2); + autopoint secondX=x.tail(d/2); + typename autopoint::FT SUM=0; + auto I=Eigen::Matrix::Identity(d,d); + for(int i=0;i datavector=data_.row(i).transpose(); + autopoint data_autopoint= autopoint(datavector); + autopoint x_mu_first= data_autopoint - firstX; + autopoint x_mu_second= data_autopoint -secondX; + SUM +=(-log(exp(-0.5*x_mu_first.pow(2).sum()) + exp(-0.5*x_mu_second.pow(2).sum() ) )); + } + return SUM; +} +template <> std::function::FT(const autopoint&,const EigenMatrix&)> AutoDiffFunctor::FunctionFunctor_internal::pdf=pdf_; + + + +int main() { + run_main(); + return 0; +} diff --git a/examples/autopoint/README.md b/examples/autopoint/README.md new file mode 100644 index 000000000..d49ffd8ea --- /dev/null +++ b/examples/autopoint/README.md @@ -0,0 +1,65 @@ + +## Background information +Autopoint is implemented using [Autodiff Library]( +https://github.com/autodiff/autodiff/), after experiments of comparing various automatic differentiating libraries.Read [here](https://gist.github.com/zhanggiene/8471601fa25ba9db90303661b0e2237b) to find out more! + +## Compilation +``` +cmake . +build +``` + +## Running the examples + +For plotting the results: + * `examples/python_utilities/plot_samples.py` for plotting the outputs of the HMC sampler + +The script has requirements listed in `requirements.txt`. Install via +``` +pip install -r requirements.txt +``` + +You can also use the `--limits` argument to set {x, y, z}-limits for the joint plots. + + +### 1. User defined function where the pdf function is explicitly defined by the user. + +``` +./userDefinedFunction_autopoint > userDefinedFunction_autopoint.txt + +python ../python_utilities/plot_samples.py < userDefinedFunction_autopoint.txt +``` +The histogram of samples from user defined distribution.It is the same as the real pdf of the distribution when -1 data.txt +``` +2. Data from the true distribution is used to define the pdf. +``` +./Gaussian_mixture_autopoint > Gaussian_mixture.txt +``` +3. Plot the graph +``` +python ../python_utilities/plot_samples.py < Gaussian_mixture.txt +``` +![gaussian_mixture](./2.2.png) + +### 3.The pdf is defined using a mixture of multi-dimensional gaussian distribution with multi-dimensional data. + +1. Generating data points from a mixture of multi-dimensional gaussian distribution with mean of dimension d. The variable d can be changed to be any integer number, but it should be the same as unsigned int dim variable in MultidimensionalGaussian_mixture_autopoint.cpp +``` +python generate_multidimensional_gaussian_mixture_data.py -d=4 > data.txt +``` +2. Conduct hmc sampling + +``` +./MultidimensionalGaussian_mixture_autopoint +``` +### Points to take note +it is advised to use NutsHamiltonianMonteCarloWalk instead of HamiltonianMonteCarloWalk. diff --git a/examples/autopoint/generate_multidimensional_gaussian_mixture_data.py b/examples/autopoint/generate_multidimensional_gaussian_mixture_data.py new file mode 100644 index 000000000..011957d23 --- /dev/null +++ b/examples/autopoint/generate_multidimensional_gaussian_mixture_data.py @@ -0,0 +1,18 @@ +import numpy as np +import random +import argparse + +argParser = argparse.ArgumentParser() +argParser.add_argument("-d", "--dimension", type=int,help="dimension of mean of normal distribution.There will be samples from two normal distribution") +argParser.add_argument("-n", "--number", type=int,default=4000,help="number of samples") +args = argParser.parse_args() +mean1_=[random.random() for i in range(args.dimension) ] +#the two mean are directly opposite for maximum sampling efficiency +mean2_=[-i for i in mean1_] +cov = 0.1*np.identity(args.dimension) +pts1 = np.random.multivariate_normal(mean1_, cov, size=args.number//2) +pts2 = np.random.multivariate_normal(mean2_, cov, size=args.number//2) +sample=np.r_[pts1,pts2] +for i in sample: + print(" ".join(map(str, i))) + diff --git a/examples/autopoint/readData.cpp b/examples/autopoint/readData.cpp new file mode 100644 index 000000000..d6de0b497 --- /dev/null +++ b/examples/autopoint/readData.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +using namespace std; +using namespace Eigen; + +#define MAXBUFSIZE ((int)1e6) + +template +Matrix readMatrix(const char * filename) { + int cols=0, rows=0; + NT buff[MAXBUFSIZE]; + + ifstream infile; + infile.open(filename); + while(!infile.eof()) { + string line; + getline(infile,line); + int temp_cols=0; + stringstream stream(line); + while(!stream.eof()) stream>>buff[cols*rows+temp_cols++]; + if(temp_cols==0) continue; + if (cols==0) cols=temp_cols; + rows++; + } + infile.close(); + Matrix result(rows,cols); + for(int i =0;i +#include "readData.cpp" +template +Eigen::Matrix readMatrix(const char * filename); + +#endif /* BCC3CEE0_8697_484B_B5E2_2A7DAFF1284D */ diff --git a/examples/autopoint/requirements.txt b/examples/autopoint/requirements.txt new file mode 100644 index 000000000..010503e45 --- /dev/null +++ b/examples/autopoint/requirements.txt @@ -0,0 +1,3 @@ +matplotlib==3.3.2 +numpy==1.22.0 +seaborn==0.11.0 diff --git a/examples/autopoint/test1.txt b/examples/autopoint/test1.txt new file mode 100644 index 000000000..928bebb1e --- /dev/null +++ b/examples/autopoint/test1.txt @@ -0,0 +1,8000 @@ +1.4389312743620264 +-1.3429444686350107 +-1.2839824846615373 +0.17425408483408453 +-0.317145414150371 +1.210417765935969 +2.039815431693488 +-0.5586309991920968 +0.25595721573618835 +0.4125979094251532 +0.11088989514699005 +-1.627890496582001 +-0.3648803571858281 +-1.2187669402757682 +-0.64164859953216 +-0.14014893845852533 +-2.192549685553632 +-0.703492429957417 +0.2918256467137392 +-0.9017002976066446 +0.02565575937218867 +1.0830978980411001 +-0.14516470354384836 +-0.9575137523854835 +0.5075367023443571 +-0.3513244668242659 +1.0797989152122078 +0.9739864440041945 +0.2532335178221895 +0.48175990748697717 +0.8500197831092988 +1.8017048246439276 +0.7887751223651034 +1.4549203439068983 +0.6255030928484168 +2.2378551855131112 +1.0065242521713897 +1.1795749577734629 +-0.4302437038198378 +0.45480938619056627 +-0.0011808096668151913 +1.1258892192432781 +0.6069789421218854 +0.9160927288248275 +0.39748850536432584 +0.8831544974680436 +0.3994892273436168 +1.4061619639702572 +-1.085973406450066 +0.7686596105872932 +0.9781093810583458 +-0.754029794246235 +-0.7129413467343139 +-0.3856079035191352 +-0.7745884207207039 +1.2668228183988122 +-0.5646556010405765 +0.9060209589591424 +0.051019830316273634 +-2.776780689778862 +-1.2282112447259785 +0.8469631329207489 +-0.5851887314152927 +0.6770760708033563 +2.3308072757033322 +0.4044141919592825 +-1.2543455178446206 +0.2552835519304951 +0.9532588583974619 +1.0277235161253313 +0.040326507313035415 +-0.2258535735124716 +0.39058120726948026 +-0.9689652457692679 +0.5434508983126822 +-0.17962132262618064 +-0.7627440801279135 +0.5370193569007295 +2.606502131994561 +0.8346227834131333 +-0.7617367340068403 +-0.7260524574687648 +0.5919346827508521 +1.5201713581765384 +2.0859168058130675 +0.15767055958538195 +-2.000025713391259 +-0.9733150696065462 +0.19414726767515228 +0.357644614680221 +-0.43997799021248585 +-0.7014061651843775 +-1.3987951445206552 +0.34042221741881007 +1.416999758159151 +0.4442134654050433 +-0.19080070963211399 +-0.37535207015084093 +1.060910553289824 +0.04380585991006472 +-0.4085230020575795 +1.0800530738944984 +1.9447471487295913 +2.1504491095802325 +2.5930541270661047 +0.8929829819113982 +-1.8183468554916191 +1.4045651031304427 +0.9935379535436617 +-0.812446388283558 +1.293236836321771 +1.3944789206654218 +0.9869385666313367 +-0.18171187356315 +-0.9214432351180788 +0.8155416065038007 +1.6219806093417823 +-0.4030286757774162 +0.6315122109708535 +-1.9712132813251453 +0.27916890974784403 +-0.2495201884114409 +1.5511788223987006 +-0.5486730589546956 +0.11540261156781831 +0.8881406105586184 +0.4356953844726819 +-0.05085095929111627 +2.3818442532998114 +-0.3327795836658318 +0.2729726340106885 +0.3574164671859378 +2.693476001543927 +0.5975330043740719 +0.7533835684867694 +1.863080723006012 +0.423198384786203 +-0.7625599629265221 +-0.3550998394494326 +1.2235960243636892 +1.4617266836784346 +-0.3846619729113996 +0.9638539029381655 +-0.9823621644552614 +0.3988788558778702 +0.5522506652319159 +-0.8613777285723414 +-1.124546689535219 +1.8142441679229053 +0.6930134331237859 +1.2123294485343012 +-0.4599584645997532 +0.3164237862039946 +0.1299855401688784 +0.6106386975349418 +1.282741631712128 +-0.2137405613804912 +-0.1339769830132017 +0.686213957033106 +0.896044544373173 +0.5550667160771849 +1.3810336530101317 +-0.5258798568120143 +-1.0221313246604071 +-0.014427461117132584 +-1.2461113228399405 +-1.3637095410731377 +0.8681810509161852 +0.2104121944945841 +-0.20579626223894526 +1.5806476987635913 +-0.2958396216325586 +-0.19087979307927755 +1.862712391766958 +0.13370338278363003 +1.5680546335072894 +0.28764580517391164 +0.1857776783287964 +0.006596538960246562 +0.34977159348435033 +0.1382394722302465 +0.44555828302148665 +-2.1767683370178776 +-0.18270087070759905 +1.3159357009944808 +1.585748854087624 +1.7017818326051481 +1.2431260148036063 +0.9947703104153859 +0.7339615481432674 +-0.7371473176289575 +-0.1456839327490746 +-0.41765343657725396 +-0.12450775838161104 +-1.0525926353581374 +1.146239074174727 +1.1646840503628726 +-0.268564622075392 +0.8660546889984144 +-0.15569466371137985 +0.5732900045811375 +-0.14877202828857855 +-0.5141544120658305 +0.2753170956561294 +-0.974045025903292 +0.11204533319141508 +-0.022073143570356085 +1.432248303002012 +2.53429835765564 +0.06806482416872318 +-0.6096633074573565 +0.28420190009806906 +1.747047533673821 +0.5078280631116362 +-1.6689520256019543 +0.7016629187920355 +-0.34167063932929176 +-1.347329354908254 +-0.3089433544728062 +1.237785604579344 +0.5978549765679249 +1.0007600328383326 +1.7215099835707568 +-0.12416581594156545 +0.7854572921273687 +-0.2341909963345763 +1.1520782988589229 +0.30372901076093956 +-0.4029977387355893 +0.08075298483986314 +-0.08913782828846761 +0.9842576411192376 +-1.5994514364809682 +-0.07045083503051497 +0.9368521850772835 +1.1609966271822183 +2.949145527568252 +-0.11006435493510458 +-0.4901630895841025 +-0.41040283171542813 +0.16782717752075246 +0.23459957397686632 +0.27969452960398533 +1.5885236719212554 +-0.014375419925456517 +0.7681448884491527 +1.525676111296602 +0.041419096194456495 +-0.5621769743636449 +2.5807504775686283 +0.6808139259179025 +-1.1630380214725957 +-0.6481383953833989 +0.10798578434791818 +-0.4575180944445433 +0.13745667668118108 +-0.6473384002288922 +-0.022260745266244303 +0.05558981708504637 +0.47953114254108353 +-0.11336660093194312 +-0.5232024355815905 +1.1230831284633398 +0.5120488543676602 +2.238632218665824 +0.2983690227913586 +-1.1542525648977622 +0.5467127993538798 +0.41261049485391965 +-0.16915061223862654 +-0.9256376042382952 +0.3084311847298725 +1.4665491109498612 +-0.9755727885738921 +-2.126287008968516 +1.4057843161067785 +0.6815790663673456 +1.7203048870785176 +0.5696043501233603 +-0.42239019638393605 +2.5641782476343984 +0.333705780254793 +1.6439822535022293 +0.21673763483821112 +-1.3549718960871617 +0.1880359422150748 +1.5381282674874004 +0.7255235364645972 +0.052168531879254326 +0.19437674623957685 +0.10268504295096714 +-0.45284900501993897 +-0.5601872259941293 +1.2423975623069436 +0.9372106015500493 +1.1131828679753624 +0.3469142897399695 +0.8519099664755511 +0.4524955445282952 +-0.3958368008094012 +0.006987539565988549 +1.1041671549361414 +1.1483098276058386 +-2.3286822749451686 +0.6542755208413851 +-1.2162776396162795 +-2.370553422667758 +-0.6404850774400347 +0.5492567344535221 +0.4021411843852788 +0.20715721866041087 +-0.30862695787426636 +0.3863136941106339 +-0.1423918494244124 +-2.7589803027333613 +0.8623299441302312 +1.3769652479351022 +2.105770184802287 +0.4460609650743488 +-2.275162518968023 +0.4653352759430595 +1.1766090352774223 +0.32407108267174844 +-1.9425917866380054 +-0.4179633525747998 +0.14502429422575178 +1.2248490887918568 +-0.3624557171049767 +0.9052464534561482 +-0.10857118655052533 +1.105417894294232 +0.13339222669025266 +-0.3538796618777278 +-0.34245712187411514 +0.18208919456586856 +-0.38686901757630365 +0.6414247769810986 +1.8841292156776595 +-0.8879003281240496 +1.5734897086962485 +2.6872109495375796 +0.13145956728537003 +3.0089177074631355 +-0.7270505753537252 +-0.13177183575316426 +1.6172126380192657 +1.8496684263609613 +-1.3492517213961361 +-0.062117400736129424 +-0.31816291576023215 +0.24503954211099668 +-0.8234618512843568 +-0.19462564700786184 +0.005329143276808335 +-0.5725994094502492 +-0.12403635407058927 +0.9240275383399548 +-1.3932232523069146 +0.7568723285298065 +-2.960578666919784 +1.0663737595604295 +0.3323113169496679 +-0.8495192928065638 +1.7433083951175854 +-0.5843793333705019 +-0.8957339994772793 +-1.6534985061948482 +0.7224382538011832 +-0.5426521416566354 +-0.8293208175858151 +-0.7431193805283998 +0.17811029046939514 +-0.5363105682520661 +0.22781548187212813 +0.1756350550673646 +0.9894358778751396 +1.584961907483094 +2.345812593449944 +-0.006830462025120443 +-0.14615450724023804 +-1.7305448950812632 +-0.9831559613152623 +1.7159685505223754 +1.0768516852018841 +0.6682935244313462 +0.5624995878875156 +0.162967455296286 +1.2221277791212724 +0.20162059665485296 +-0.13339112382460494 +1.698858894323301 +-0.13861983297223718 +0.692845608994738 +-1.3953532222779732 +-0.014148316017940893 +-0.8813123797802103 +0.032781801034983016 +1.5682559653706731 +0.35530613318271403 +0.25963768024955713 +-0.5345360423865787 +1.1125840527700999 +-0.13834890142465606 +0.3839008876089417 +2.066199334914972 +1.279172297032458 +-0.4385800494534281 +0.17557630411188907 +-1.0446917292886166 +0.4094218082101718 +0.3053345322511208 +-0.042804533704990017 +-0.7538149099278381 +0.14226086734708868 +-0.028403343964443883 +-0.1845123366175977 +0.4427360329837772 +1.0253740921013736 +1.538855882198877 +0.3598467227919546 +0.5875603350211789 +1.3436475597726119 +1.0601572399162533 +0.4378962862563608 +-1.0161028346276897 +-0.2697549916424518 +0.8673174436450288 +-1.3575098245024821 +-0.3814225234083112 +1.6183830767250231 +0.27745366811806516 +-0.2572038136144182 +0.7879557331471672 +-1.064695145063001 +-1.927958055612285 +0.02599334467059683 +0.047478936179838394 +0.9203232618872975 +-1.2268443351167302 +1.7787788550392991 +-1.5381007801357622 +0.38263773000901197 +-1.364794607147365 +-0.15820208514434975 +-0.24163953461494952 +0.26716378726033396 +-1.1554831380510782 +0.7120773235374662 +0.4925966890409565 +-0.6064192626348373 +0.8889334922686424 +-1.3463288721677542 +1.0069646422203244 +1.765352960449221 +-0.5817003063128859 +0.49288162185734363 +0.21468168581854752 +-1.4846203593810734 +1.0179054588688419 +-0.3346712505197862 +-0.42883248325406054 +1.0315199086353688 +-0.5213541904463107 +0.8650786283296585 +0.401031841586423 +-1.067543062754412 +-0.09720951568522179 +1.4882055927224687 +0.9465864339766087 +0.4407030608167036 +0.3697936769067162 +-0.0006080954943673833 +0.4480419984977911 +-0.44610040231053605 +2.1530706488971347 +-0.05680758771746022 +0.8329359702744177 +0.16112261702187822 +0.792040234035573 +-0.13772836787712045 +0.07753432945861129 +0.1218692844585247 +0.6246315363264597 +0.3916269123243369 +-1.4390245811228084 +0.033904241967934734 +1.2549568663370194 +-0.23150162679526376 +-0.5389787857974818 +1.8919345624053572 +1.977850213071629 +-0.3966124822565389 +0.004196626905056761 +0.8649025609068441 +1.5280914703045276 +-0.628173779291751 +0.8838210719290766 +-0.10301764008403524 +-0.2889541375672139 +0.08695230098536784 +-0.19831446657840268 +2.6674504567858595 +0.09681064705364427 +-0.5645993667744608 +-1.5027633688717914 +-0.34953575416209604 +-0.35735825655036224 +1.8665454829492443 +0.7567330493878769 +-0.8003963960250374 +1.9674253894885991 +0.8390276131934888 +2.0415725206173336 +0.4073749478455591 +2.4437882580029537 +-0.9375193014651053 +2.074486987876393 +-0.4706286911471712 +-0.09852331183623064 +-0.5657169540770844 +0.02928075643923453 +1.5410728116476242 +1.9642058795388464 +1.0271737818878641 +-0.03966552514988653 +-1.0501312540187542 +0.4195348807543381 +-0.9676481851416554 +0.21506201397352084 +0.3207726328847261 +-0.14464970670716537 +-0.011886004031352704 +0.358327809222576 +-0.6046305958688758 +-1.0337525923412818 +-0.8209997762928523 +-0.7087454544406989 +1.6621944726276678 +1.33150834275908 +-0.31611597597681174 +1.0090351523092824 +-0.8693550602985283 +2.3743821070414217 +-0.4860969305480195 +1.2179349834862223 +-0.640834251593063 +-1.81650674141358 +-0.41416006232339087 +-0.0842852159107656 +0.5080157975938056 +1.1086571518586827 +0.4814493819876181 +0.1319968072629058 +1.1148354014579676 +0.14991773808153477 +1.6238520004775916 +2.6165026662070705 +1.0592607752032919 +-0.3042703852006516 +0.7069223222991128 +0.4129988849482207 +-0.38594348142915924 +-0.2635115314974777 +-0.7276227621740073 +1.3719860753863757 +-0.24270366174642088 +-1.1070078598487223 +-0.8512918681598529 +-0.6197219489092591 +2.016112729041194 +0.1553921973379822 +0.4165338239940918 +-1.8923731525403429 +0.18757397519051014 +-1.531910488065769 +-0.049087453865025305 +2.4517123250840855 +-1.2811634480350254 +-0.8985701615401582 +0.7094809639529166 +0.26829642378004853 +0.9725035462765602 +-0.550463780045868 +-0.6788008778565775 +1.1423117703382026 +0.9686494960951288 +1.1960762518767638 +2.562327281625546 +-0.09713610602659445 +-0.5736399961737636 +0.8073691451458054 +0.8880694892886741 +0.2750384266483562 +0.035909284428600086 +2.3685164737124946 +-1.0652179957145702 +-0.313918218888122 +-1.2013796557953331 +-0.028002229263854594 +-0.6843816163330418 +0.5205110384569231 +-0.4302021937333851 +-1.0816709372818798 +0.1586430181936621 +2.1206897584857822 +0.8149663566278115 +-0.7286081946803837 +0.31113855617873065 +0.7571682975087223 +2.086756865513243 +-0.4522567207012437 +-0.2130515503784996 +1.6322989037779647 +-1.136172624714986 +-1.7408235185218832 +0.7774461936260683 +0.0790931485234116 +-1.0267856671066726 +-0.1018014119325858 +0.5893900968203897 +1.7255348186809634 +-1.1162911563520805 +1.280581097050053 +-0.15282248387809388 +0.28509927107631 +0.3272269565248911 +1.4460499151422213 +1.3281392783463004 +0.4606239962924887 +1.4046214936337535 +0.6996247541516841 +1.0347728659375348 +0.43151949024882397 +1.5747652185559091 +-0.006394562660284264 +-0.3405394724817672 +-0.1130775547237351 +-2.09250631257288 +0.13564308726619048 +1.16293533042098 +-1.1406935908288187 +1.9674821725166254 +0.9282901172755424 +-0.4051627366693139 +0.7942001308963352 +0.5962424931536736 +1.0661870621280536 +1.3138592366684054 +0.9193642017628658 +1.3004682910208607 +-1.1711601423691504 +1.5491918957157844 +0.496937651221855 +-1.0750252707730534 +-0.7717848916665278 +0.3231712900583267 +-0.9114434992991602 +-0.5237621330244833 +-1.289695122923207 +-1.5503035455418044 +-1.3101421891116944 +-0.1559988393078176 +0.09255120293591532 +-0.19936560968272743 +-1.2806103948873684 +-0.14472619295951505 +-0.0020394735312094514 +0.5164917786459285 +-0.8610841974066301 +-2.749729842978522 +-1.0804400307380546 +0.5106793001677035 +0.6773500893903555 +0.7056811935499703 +1.3687646664362088 +-0.2954285656682946 +-0.4199274251476379 +1.028874639455589 +1.2024433603704543 +-2.525187986182715 +2.680150376821378 +-0.6770662383200605 +0.6697931907620212 +0.13842640325814498 +1.4517876900360633 +0.6694660611030168 +3.6979781523299478 +0.6664496195088546 +0.47627102533125243 +-0.6831232730978971 +0.2149766596316214 +-0.24175756886968564 +0.34769542815226784 +-1.5105428606058224 +0.23862809217867842 +0.8998359278753197 +-1.7487869237287057 +-1.1238538009179064 +0.7400028587582744 +-0.46391665162168405 +0.4511774810365649 +0.299097506263858 +0.6491306761528888 +0.05653079284849613 +-0.3374678876001629 +-1.3195585952261097 +-0.25845800776111627 +0.9415091366083757 +-0.3358340747965638 +1.4746379059583135 +0.41208008359384385 +0.5275045959438074 +-1.9533745135515657 +-1.2811042937791304 +-0.38487500010052933 +0.1382676620154556 +0.5671120573812782 +0.147302466853873 +0.3180663089975624 +0.6176790879434725 +0.05244794754024412 +0.21355075319256014 +-0.678990982306402 +-0.23217661441812026 +-1.2616600826525877 +0.5510739282427639 +0.04614229612685236 +-0.7249260964872748 +0.46512310177838473 +0.5084750997164954 +-1.1046093551319718 +-1.3918222571778596 +0.6357822484004989 +-0.6369310622443048 +0.9751750130926079 +-0.215918326723594 +-0.84535152871658 +0.6575854948818975 +-0.7112485555134526 +-0.3992936882776549 +-1.4499708994239278 +0.39431361357379213 +-0.15274696742200405 +1.2077542664045977 +0.6847103554356022 +0.6655479508810478 +0.006626610031813196 +-0.10470298611094991 +1.4490011699087622 +-2.222182800167926 +-1.289354237703813 +-0.23343381529862617 +0.5822926784375628 +-0.25174764808445793 +0.5269935824716594 +0.40120164979007444 +0.12512311565887135 +-0.0916166314552942 +0.9533744207835851 +0.42311964472781427 +-0.450743221494345 +2.4113051200080946 +0.32692912793102735 +-0.5982450887260461 +0.8709255531467722 +1.0822391777141767 +-0.6117919115107293 +1.7376264617215418 +1.5493869096218431 +1.593854534485795 +-0.45995592960241216 +1.2305530889868619 +0.7182943032039822 +0.1341464353149367 +-0.4745441558555388 +0.017184962736261078 +-0.596998368107729 +-0.19741365540760708 +1.5568120110684303 +1.2874922137360485 +0.5612429145830525 +-0.23660524959531326 +-0.3510992479373817 +-1.358375567652577 +-1.6184071049803554 +1.4040366067529069 +-1.4777621115275115 +-0.41377139094682824 +0.38157444978898536 +2.130985968560063 +0.5424876126752749 +1.3078332279810339 +0.0857652485910418 +-1.1682453814122884 +-2.0085220073250243 +1.1357319484242816 +0.7485874750265599 +0.362993159814215 +-1.824491372843992 +-1.0332321402915157 +-0.10806218976392867 +0.14182982273508152 +1.0732308643137878 +0.2676612535508777 +0.06324098788095611 +0.8279596270616729 +0.09793997119637289 +-0.7745271293087521 +1.3820821422596885 +0.4965116549219473 +0.47863018889017067 +0.08154379946127445 +-0.8355968005609438 +-1.358094874582965 +-1.1496873448170002 +-1.3442830449348313 +-0.6925452185585584 +-1.4774474201632313 +0.1550630101021208 +-1.3426479370775743 +1.0064992077365127 +0.6724830706242244 +1.262582574234698 +0.8979809337598831 +0.7292435339765511 +-0.7889302667876492 +2.2176950972119958 +0.6398659934507027 +0.48358645043847026 +0.01379891925302823 +2.920120889629805 +0.7867142163116002 +0.22506308782385775 +-0.2603098770624625 +-1.0455620864218922 +-0.8542423724431241 +1.299935488999902 +0.40652487481070265 +0.6400646671079518 +-0.045072107297613684 +2.230479856359918 +0.5326063493640069 +0.25124354956596767 +0.8971313455533219 +0.02285810198468677 +1.1477842959637732 +0.4717108615622739 +-1.1836360704054183 +-1.8409273733635627 +0.5592594317107064 +0.13351398805685127 +1.3579483275645161 +-0.8009024602079566 +0.884149494549367 +0.21267521317134624 +-1.3221477858442303 +1.3771409858541006 +-0.5539886004230409 +0.9911920941630766 +-0.12708587582296327 +3.1478656600583204 +-0.3852221840552008 +-0.7588467409647544 +1.905693383607005 +-1.5826497858555302 +2.094874907229495 +2.773012025809309 +-0.09097015802694891 +0.5165643656296954 +2.273110919195533 +1.0411908106928551 +1.3245114396877817 +-0.38714602350169636 +0.7081361097071645 +0.8832209115575388 +-0.7010808227056209 +1.5147904980515987 +0.5425108039755632 +1.5684171311218487 +0.4602767472670886 +1.038291111113826 +-1.4821924901013217 +-0.4457795415451973 +-1.4235637494060767 +-0.05843974584066339 +0.2206373883247093 +1.4756228961028632 +0.08178951480218141 +0.4294218601931943 +0.011397720790373461 +1.1621882064431288 +-0.6008636275045282 +0.7899754982645887 +-0.2945681793280924 +-0.37416159783507097 +1.1828495177909586 +0.7579312433951858 +-0.9803480152615041 +0.2963154935303343 +0.5438029433750587 +0.19997247725242775 +1.1760225980888508 +0.8833985297750673 +-0.30139203833515293 +-0.5704110762301484 +1.068757255822224 +0.08782781786658125 +0.9691650437768525 +1.7854417556164741 +-0.8559889861344705 +-0.33812445966465343 +1.3652577377907262 +-0.5824374832713433 +-1.7389869145597632 +1.6342379434898207 +-0.22346414046525193 +-0.11101856909808078 +-0.7669022458868221 +0.9084602628024293 +-0.37643844920969183 +-1.1597528270011204 +-1.55539067592519 +-0.823820862471691 +1.2753663401866442 +0.5668771011802578 +0.6646454249561629 +-0.5715047606698784 +0.0958308279825154 +1.6770384152523252 +-0.3267756855680357 +1.1874096859579861 +1.0646958000063036 +1.484572302211001 +-0.4716129762841671 +-1.1211807435205605 +-1.316833402224791 +0.4299221396070196 +-0.14380942457771684 +-0.24095498432284773 +-0.11821152902830862 +-0.7831718354291981 +0.09493545649933022 +0.7547278364442995 +0.35836909531852446 +1.1510694035923839 +-0.15810646373586096 +-1.1808430824882674 +0.4440265253459133 +-0.2828951632040667 +-1.5914878039540106 +-0.24951824286041457 +1.37954705244461 +-1.232490657647633 +0.532336897059523 +0.8602994145667038 +-0.37351723736086373 +0.4061833901286957 +0.5632246403929703 +1.4489663020943924 +-0.2581618468745478 +1.0948785261930067 +-0.4608423439149225 +-1.3559594993486597 +0.855931479276968 +0.39566856190157407 +0.09710727196565971 +0.4003653669527595 +-0.6070841831261452 +-0.5714536095648495 +0.9968055587505017 +-1.7840111319338645 +-0.041849307633435334 +1.629752339678787 +-1.7701849209119946 +-2.3383058332516766 +0.35145539785293056 +0.09665275641371296 +-0.2549936764427113 +-0.5582207434439171 +1.423792906821755 +0.08292761537346971 +-0.12528900385812897 +0.19746518730543539 +-0.5821422225965789 +-1.2697123645057724 +2.5041667516050117 +-0.5435071015033427 +1.2805481990897056 +-0.27141241139397615 +-1.5409612052596207 +0.8861252690220941 +1.5500425967631615 +-0.35778893747152973 +0.4666809803587525 +2.651445808102711 +-0.3644162183085159 +0.20917523006577293 +0.7325429326792078 +-0.8061333671935731 +-0.03734499674361491 +0.12390789068248943 +0.439730451358399 +-0.839530134079369 +0.6325007487600653 +-0.6641609433126797 +1.6291989813856247 +0.8864982485220373 +0.2807932178311149 +-1.7328324542739793 +0.20562583050088964 +-1.8515604082148325 +-1.1996936564591472 +0.4190119452893982 +-0.536981593343709 +0.6243644815063885 +0.13117601121725234 +0.5018234987920287 +1.1183982735622733 +-0.4404063850482419 +-0.4977240782959901 +1.257715634937693 +1.7770924521701719 +-0.4887912554575732 +-0.16078253308274465 +0.8607273107888783 +0.6471445400372847 +-0.5403848237520475 +0.7226428768046724 +-0.17362543369952643 +-0.15684470267595935 +-0.7422207365774102 +-0.5820457624640119 +2.454623800060779 +-2.1452823374489505 +0.8556524808550426 +-0.911711150409676 +1.3826482900969899 +-0.10515025757610064 +0.5119612907909594 +1.1260932827370889 +-0.5555850302802333 +0.9140035908885377 +1.4659552479204683 +-0.35629760420425904 +-0.23538932846998445 +1.244264756259445 +1.7725953530813792 +0.10642030456228412 +-0.4511351197885827 +0.23255008517177472 +1.4690727317733339 +0.7274076757563126 +-0.46214369835821323 +-0.18914163778611276 +0.35635964484344285 +0.5259141010890197 +-0.5808323548590367 +-1.2374395559458669 +2.6797766300603483 +-0.9892967481481778 +1.1277448720884202 +0.21919038263409413 +-0.15642976741169784 +0.06722740718059256 +0.37728694715530875 +-0.2553176445417456 +0.19924972237556898 +0.3238657759650568 +1.3725135829449369 +0.6560389170517884 +0.8069520540192848 +0.9405536400267392 +1.0444292379590374 +0.2454551735225721 +1.149944924787935 +-0.6073787073195279 +-1.0266973237791368 +-2.410621397544811 +-0.017652886820084035 +-0.781747043075181 +-0.9715499378157451 +-0.7393524258002182 +1.7519824455375548 +1.2042109493038848 +1.4414511028569046 +-0.2989812818510331 +-1.5877092760984672 +-0.6350731388909361 +0.09662326297588297 +2.3595180347598363 +-0.23135263305676845 +1.3253684015000968 +1.2877714619390837 +-0.016406368523743053 +0.3282981575346147 +0.07684613740478115 +0.8699983335472947 +1.11631334481477 +0.08317320169232831 +-1.370910520942273 +0.12061573320381741 +1.6233846328177015 +1.099180573020747 +-0.16732080116867365 +-0.57218154804481 +1.9770468170352236 +-0.8292280353676225 +2.0788970203767545 +0.6861507323415885 +0.23266066637982002 +0.7569617194946353 +-1.8574769259822232 +-0.9000458813322003 +-0.31994954234617734 +0.6691966237096416 +-1.111291538117263 +0.6619318483999148 +1.6238779323508894 +-0.1083052008813557 +0.6770044324484263 +-0.49052757654744383 +0.16876977664522952 +1.440963534233286 +2.8844953780288485 +0.8307614920207261 +0.4241557955805578 +0.7066828308637986 +0.36187725399981535 +0.3050382156553555 +-1.4002825114922892 +-0.46675419044158395 +-0.6734579100666267 +-1.1831555359429522 +1.394191369253104 +0.06296992620673766 +-1.1286884632243217 +-1.4619955232580881 +-1.653266380386268 +1.2876612806618715 +0.2726197186666408 +-0.3532857155900101 +0.10963853945163488 +0.8204917063927171 +0.1162396985167445 +0.25793729540875504 +-1.31386211770855 +0.6941412832761519 +0.5998168294631911 +0.7713929640919448 +0.8251978348227446 +0.24816909023003064 +-0.39791977343039 +0.0516286823000687 +0.5860271660106403 +-0.15408967275619223 +-0.7778398569094773 +1.768216184116797 +-0.5682748231502225 +-1.215889600621365 +-2.4816250612091473 +0.7566359228485726 +0.42970386145315087 +1.4563974530301917 +-0.421552135265451 +-1.08407356273903 +0.33192818326091433 +-1.0169766414542665 +-0.7242610950227851 +-0.5144568938030659 +-0.5649663576782047 +-0.4646563913927646 +-0.3983762647174526 +-0.22004434195145278 +-0.6895686891394903 +0.12454248668236513 +0.04607522288537033 +0.4037113838830687 +-0.4920391273136917 +1.6862179803250659 +-0.5007939345854971 +-1.8775559045001862 +0.591581707613821 +0.2921047456100207 +-0.5488369277042439 +0.18189787544242403 +1.52116143498705 +0.6396360601730187 +-0.15449909227726977 +-0.63080214389388 +-0.28721517838659527 +-1.2293702059968958 +-1.1465728267145212 +1.6590593872443524 +-2.3109052821410794 +0.09983393946405587 +0.2060671707090354 +-2.1298391299313524 +-0.6230393856279974 +-1.358953100614956 +1.551695153170227 +-0.8811367442004698 +-0.8108778865938122 +-0.36181438746575645 +-0.4488014285387397 +0.19007212724065908 +0.7254378239654562 +0.12862621452721165 +1.2710096783475289 +0.19340810177090065 +-0.3730416655520554 +-0.22616698083119025 +0.6952525650574088 +0.9233193798039776 +-0.40258048974194605 +1.0245666041970556 +1.0987232440955137 +-0.05820783186114048 +0.3699322777728846 +-0.2881053174116157 +-0.0721297202813736 +-0.046124483453624854 +0.4475668661002609 +1.3230711210869535 +-0.0673380266522452 +1.2179485871887303 +0.9650794276583264 +-0.31142851768594737 +-0.76114690499524 +0.19011306745597334 +0.11543394253197815 +0.04681831221913513 +-1.347803978216084 +0.9692771529895091 +-0.8122786317772479 +2.4749276046583972 +0.7822728028801771 +-0.20174868446640015 +1.8609628030839485 +0.6284809986861262 +-0.8936317291823523 +2.3325638018146355 +1.4367452211796103 +0.47200200704079875 +1.0166163761865756 +1.0127692278065314 +0.904220569396564 +-0.6613286397795063 +-0.015260428769946877 +-0.3272607661207937 +0.03172034213739944 +-0.13408226186916822 +-0.08890464723924485 +-0.5093162840324816 +1.5765061773894715 +-0.7036642098077586 +-0.5355137070235761 +0.8675315516958614 +-1.1308502235178783 +0.9023499853421273 +0.005878029737790336 +-1.1130324499657076 +-2.4334393354021557 +-0.9792606042737737 +-0.7593235278436709 +0.23872948572804342 +1.1508365613943958 +-1.3166307855104071 +0.16050323610718137 +-0.12820787132339045 +0.9731997498126089 +1.8530532416120202 +-0.2652130237559444 +0.6609228409261791 +0.7652273492085722 +-0.019998204120835222 +0.23236223151268023 +1.9993243216744754 +-0.5592314943187748 +0.3195593952222715 +0.8853890064904526 +0.9829490801312147 +-0.8088536468523129 +-0.4857875552494444 +-0.004975370006673002 +0.46331189199790407 +-0.6337330885926085 +-0.12004760717490548 +0.13237666703422785 +-0.1902503299214826 +0.49387091923280035 +1.0744233978112652 +0.9526701911961981 +-0.1323890490264923 +-2.603889981637895 +1.2146124043987525 +0.11136618098692667 +-1.77258142370055 +-0.3469569311271131 +0.08564251506078768 +2.611594735905479 +-1.0452397522856067 +0.5990942970046629 +1.8212863567595972 +0.7534622637600948 +1.4594722410691794 +1.5967604080032933 +-0.9650366570427431 +-0.7969813384726113 +-0.918117183325551 +0.20886246994791316 +0.9089828244306798 +0.6209420477407332 +2.1410509549063397 +0.7821011659108271 +0.01475226971152685 +0.2383920751788755 +1.7096378612886345 +0.9956773317900421 +0.9379445374508757 +0.7634193672831455 +0.5695227300426483 +0.7623400271762614 +-0.6972061621567189 +-1.1617776651098577 +0.6276795587400046 +0.21392101927821364 +1.3534801982221032 +-0.36458018828768546 +-0.7374355145442656 +-0.9621406933315244 +-0.5773132630848239 +0.06234905153977033 +1.6046654934124995 +0.30888315070082073 +-0.7236378775714916 +0.03444761752526884 +0.4519321024028991 +-0.39980742562142846 +-0.6122668348849546 +-1.1539593526779655 +-0.05626148356391719 +0.09021842184883017 +0.2939870506768224 +0.1701384004973595 +-0.2824236025276138 +0.4832921684882478 +0.9256375106081983 +-0.8493181660231712 +0.6733386886221829 +-0.9949215628978738 +-1.0513487424089112 +0.615785954171238 +-0.026817363599353383 +-0.1908278729226952 +1.1085231497008352 +0.46438397679381954 +-0.23562768938981365 +-0.7016273772487348 +0.4363639208747443 +0.017075454592124617 +-0.04682136717962804 +0.7669882078056617 +0.40270965247058144 +-0.5612960933151725 +-1.1966563575605766 +0.8669042502692752 +-1.2513654019312217 +-0.6214234014686713 +-0.2567572618873129 +-0.8389849592101211 +-0.6422119241266259 +0.9710153499698136 +0.7973817723962144 +0.5383320499971951 +-0.1702059178874546 +0.08412579932802021 +-0.5696308228447879 +1.1789692842944322 +0.899290118536553 +1.4520170224426658 +0.17550669919945414 +0.6892806570944322 +-1.8992472675184058 +-0.7243813976749768 +0.018470929270117148 +1.1535170748011974 +0.2017735484286274 +0.4109866280734199 +0.7108792020559722 +-0.42543528316600376 +-0.9449501319612876 +0.47265417914973207 +-1.5712793841807007 +0.5340064633733361 +-0.15486203335021104 +0.02228365583266409 +0.2656137301723211 +0.8076279983926479 +-1.1843426445941914 +0.05457499366797253 +0.3646734849913163 +0.13191014740315812 +0.08685818486502393 +1.1232196962609713 +-0.25511532053330843 +1.0809248096507331 +-0.8182110890057748 +-0.5561858156319563 +1.0375660415003172 +0.46091907842579505 +-0.06078240534463991 +0.801301295911144 +-1.3997917201741807 +0.7802273065826547 +-0.3035049638700489 +-2.3189609679284473 +-0.39577763857729964 +-0.6172163156297907 +0.27724900601195235 +-0.5092183525498213 +1.0644879476749536 +1.355478113788748 +-0.7447538959847041 +-0.5159785977629595 +0.17321780883243162 +0.9979037400710719 +1.8254641886555665 +0.5137651008473507 +0.7115455870858788 +0.6645188810548076 +0.9053004471891708 +-1.4328116300846299 +1.4300517993506037 +0.2639067386680266 +0.838677517238674 +-0.8316049141348898 +-2.0572803088863116 +0.017237452605121356 +-1.2348306255633652 +-0.16521378503441747 +-0.5093354810830527 +1.690896040870111 +-1.8800229464043026 +-0.7692061417093073 +0.18872928911628728 +0.5906220022765668 +1.3629915152581293 +0.005373820123711015 +-0.4638375269070468 +0.008854943282941785 +-0.34994842506893153 +2.0503226162257358 +-0.007693790257141647 +1.1635400849014395 +0.6656572800671603 +0.5291826794186695 +-0.7063435956022732 +0.3524275546710609 +1.6092752024620225 +-2.035866130535638 +1.9636918641979717 +0.1956770990364833 +1.0736621981818861 +-0.04645401594363882 +1.0078045613228745 +-0.3793266763849491 +0.5360708308798297 +0.8126597322523152 +0.6210042788614667 +-1.0161536172497563 +1.392256346814862 +0.19691974692923064 +1.8221748936621691 +0.40656977435764163 +2.0306771113706605 +-0.02736054203859306 +0.45898618302116934 +0.3069597970241615 +0.21975964985767998 +-0.7947977501789688 +0.9887418777808616 +-1.2825512519753688 +-0.25895424406122386 +-0.7126778121467918 +0.7785674202118006 +-1.5655324542129618 +-0.4886311055894328 +-0.8059403197325703 +0.8772577815662045 +-0.3585216802273876 +0.9725836724670401 +0.061049072169750446 +0.036870058353884766 +-0.34628197502983304 +0.7904323109962521 +-0.02201353752864177 +-1.221345630086332 +0.5001478726538497 +-0.5726902465313886 +1.7843907887428083 +-1.734850125325094 +0.08391965794006936 +0.056748337460987425 +1.2111900591290237 +0.2577459451062921 +1.5215197015164463 +-0.343335973785057 +0.5804500793596217 +1.1558441425604464 +-0.08579693358383222 +0.7373147645561309 +1.4523606776063618 +2.5810392118411167 +-1.457296669079773 +0.6125525573833919 +0.0616673747267876 +1.6212838626394726 +0.9321271116250711 +0.07183903203374795 +0.42981016030581337 +1.128678870289832 +1.9876212626759162 +1.7469032014932424 +-1.927727592249891 +0.20768068996502548 +-0.05535352476439798 +-1.3619127224832492 +0.12793727782705985 +-0.5375736649062056 +0.6327977235218263 +0.509511098708328 +-1.7060721699496553 +0.9575002258490836 +1.4775312194273373 +0.2976058562822328 +-0.39608459148172703 +-0.16496961797337373 +-0.6825550087638497 +-0.8983742039358675 +-0.8278174425457174 +0.14602893542632994 +0.4955145427308621 +0.6814050845247153 +-1.660019512412794 +0.6255315195433548 +-0.6153695531626405 +1.5866252886003347 +1.4415701056706853 +-0.6517307288354767 +0.0988365466404955 +-0.5622030192102443 +-1.9717452589977518 +0.019668270869736465 +-2.0332677709550167 +1.2255183315597393 +2.0624542049488293 +-0.18702349383686812 +1.3771562188217976 +1.157976044846877 +0.47554349746260854 +0.6829544631179906 +0.1208285678075511 +1.184632631320179 +0.378144329553867 +1.3007656479138578 +0.4129365797577975 +0.37538025157644195 +-0.847972503077038 +-0.9648470991674984 +2.4380289313664854 +-1.272557325172425 +1.4810177009747825 +-0.2950714701471087 +2.3407642706615723 +1.0739946335697832 +-1.3974881259203171 +0.23134580628849094 +-1.7234015815280066 +1.8253091380490942 +-0.7296124422547103 +-0.6514491447986372 +-0.298495962726599 +-0.9632625926487759 +0.6101406059151587 +2.1308105592689817 +0.21492292443410002 +-0.6252626542665131 +0.7403464039150386 +0.4370527875418825 +3.3411563171233736 +0.17644151055842522 +1.4808335356670095 +0.048751957600273205 +0.6647212528653372 +-0.09998210193309204 +-1.5119339904846631 +-0.46541731967291444 +-1.3241381772095158 +-0.488065222055296 +-0.028864527706136123 +0.6635462474929759 +-0.019210778723023708 +0.8508119576440499 +0.1925169956776205 +-1.3417995164527359 +0.6025557480716488 +-0.46012602936096025 +0.038908402102884904 +-0.6217486046968986 +1.6973090493175615 +0.7373914743240669 +0.5145003886773607 +0.8665371126718037 +1.3622236887149028 +-0.22172512299386615 +-0.41963867927863596 +0.6714930640066329 +-0.6484533782158172 +1.64063868969409 +0.6086273447411491 +-0.5396852979189923 +2.4272773137670276 +-0.6049064835978252 +-0.6088777697287929 +0.34962879250619805 +2.535445692118138 +0.5876822091886782 +0.05279243681617918 +1.4611263270767656 +-0.9417681686460371 +1.479875336054064 +-1.3142175562994562 +-1.3162535952118095 +0.8568612514218854 +1.0732465005325547 +0.61606646172662 +-0.8530545062977652 +0.3159296549255468 +0.5357718555198763 +-0.18903629680678524 +-0.9647977575142705 +-0.9747982110512166 +0.5595772825712026 +-0.22921312007366162 +-1.2684255054576732 +1.0622883754037002 +-1.3877328833245943 +0.7112753137414857 +0.4967693904461396 +-0.4447415568384746 +0.744459263272112 +-0.8867216389190455 +-0.8027195806064259 +2.2159970850261184 +1.4622719128958441 +0.24564503396438456 +-0.548054988662048 +-1.5581919403032718 +2.005764505381067 +0.1690138494861152 +0.28380164136286934 +-1.452034079888736 +0.033544397956097594 +-0.4290490909286422 +1.4779844993962985 +0.32574965104947295 +-1.3574829677936966 +-1.138576288817797 +0.39831751438895613 +0.33951372105659045 +1.1701394693288756 +-1.29756246117952 +-1.4691865836098486 +0.43722690354085425 +-1.102775310768499 +-0.4158210703291849 +-0.30777044203627546 +1.1328752220809282 +-0.9210890958336804 +-1.640839941454587 +-0.3667181617356038 +2.096882576185715 +0.4770708008056486 +-1.4588514331152234 +0.5797705341935799 +0.7642655239916951 +-1.2193934234037733 +0.14261084907745386 +-0.08503710243638252 +0.7129797640882629 +-0.6795064863624014 +1.8702831663225952 +0.7606903682542412 +-0.2284825738800449 +1.0915176291689799 +0.8669772385309241 +-0.11047983965721037 +-1.1693399238269424 +1.3417444233032465 +0.6815357918792005 +0.6470311918381413 +-0.6031668921607377 +-1.8166110514844258 +1.760302098291604 +-1.2323345538416108 +-1.4033236886076679 +0.768448541486551 +1.5119334147616934 +-0.9350690631208545 +0.19008242267006029 +-0.955130249075415 +0.7326867385083907 +0.016730868126284187 +-0.9441737991756696 +-0.3828062231000249 +-0.08152020782366065 +-0.5022211447218126 +0.04208062377261412 +-0.13127482092400317 +-0.21483297242837296 +1.712037986162943 +-0.08265780928324284 +0.11844157045562571 +0.8907923560542391 +0.03146841898192099 +-0.5919774538895607 +-0.8006658190377774 +1.8579608046760716 +1.0982683810996414 +0.7944949678765404 +-1.4851249880703468 +1.0031783472062203 +0.5722135516612603 +0.5262914505467016 +2.2889122317317625 +-0.7634922650707462 +-1.073978739266046 +1.3881038171847002 +-0.6406982674904819 +-1.0898402210772489 +0.6192643955353326 +-0.37457113121596264 +1.8048683427388643 +0.37233892615928116 +-0.1876313369620889 +0.5137440414280559 +0.41046763739553604 +-0.4768943759876777 +0.6220860373184542 +-0.6501370518480376 +-0.5189784678405732 +-0.4828877676542598 +1.0027350182763053 +2.0774226129589213 +-0.5138492925910971 +1.3539832088131296 +1.6118695528345512 +0.6299339828967534 +0.030122049993206584 +0.7699695760619661 +-0.191737305210406 +0.7000623847150933 +-1.2431435835462146 +0.2719004413092697 +-0.8109905954899432 +2.1473075023443924 +-0.31425368236828355 +-0.18807739420118846 +1.3213478988101237 +0.702242910508013 +-0.062290136281198116 +0.707329025355364 +-0.5682325143893578 +1.9438024249369423 +1.2007759035493946 +1.7036180373073797 +0.3498327566496791 +1.874680287849774 +0.23639881700800747 +0.9357579059684239 +0.26100012420981245 +0.6671853006138581 +-0.190527852968137 +-2.227165811613448 +-0.9922151199750289 +1.4532395531654174 +-0.046782115976259864 +0.10829737700573372 +1.6739369042807601 +0.3534404345534631 +0.8423317199154041 +0.20009361632442133 +-0.14855641716542228 +-0.3212064647221008 +1.5792472703148956 +1.073307541886471 +1.8562180886093815 +-1.2652918046445663 +1.391353189706275 +-1.8794783033056468 +2.1088915281949205 +0.09401485763939568 +0.8165505785357291 +1.5887501213332078 +-1.7722171588604372 +-0.22144697773070893 +-1.2938152356074024 +0.48268569615681556 +-0.5375989292163981 +1.0911139640884502 +0.1698716874918963 +-0.10171814302456877 +1.5586589585610178 +0.26535485631396516 +0.39148231730558425 +-0.7745625717460368 +0.8679185651808713 +0.9427096502634669 +-0.29636582194527494 +1.374296689501818 +-0.02561363632250785 +-0.5473946107945576 +-1.3954859853898611 +-1.1089390135858879 +-1.0368644870209298 +2.2209573380616963 +0.8132278899014825 +0.41414025722270653 +0.5757798756530206 +0.8449107668412675 +-0.17363750807337708 +1.7410503424440633 +-1.4879088971145007 +-1.2495625836745843 +0.8420304033711112 +0.5809583098638639 +1.3991784202419961 +-0.9396947150612129 +0.3670577836897946 +0.4633128657756747 +-0.21847627919223572 +-0.7521554493582632 +0.4466313212472867 +0.31130361292554126 +-0.21525099030960282 +0.24554477719064455 +1.1867077537903858 +0.8600717387696246 +-0.4681796819339994 +0.6842506165166371 +-0.7764585463536416 +-0.8934303934087948 +0.8190715546528756 +0.10336398940048175 +-1.024054393395088 +0.7823412493569867 +-0.5961429537621016 +-0.05256449225256782 +0.12672461972430615 +0.941247529374149 +-0.3615794264589721 +-0.9596046504320781 +0.8742743899913249 +-0.3717430155871255 +-0.4363738873406341 +-1.0627922248208028 +1.5303235370365658 +-0.5032993485841818 +0.8545027001406711 +0.10287524331490248 +1.2387885259698872 +-0.05129727176663204 +-2.0692031759774903 +-0.7138339461254446 +0.8217351426646788 +0.14928511226516694 +-0.18990874668450514 +-0.4041228269892416 +-0.8026880284991447 +1.102718714680544 +0.6402667298041864 +0.2517941804482199 +-0.02408667419906868 +1.3996952756316017 +1.0244872523359567 +0.13700268346220534 +-0.31756793859198584 +0.22071728509159988 +0.13706770581827726 +-0.7421828576453114 +0.5446449368403312 +1.2467383413556272 +0.5565752928288266 +0.047769873943517005 +1.9815410446935895 +0.3761171213612433 +-1.6044718289783269 +-2.0947211055124555 +-0.9250033334793617 +2.0387063590129575 +1.2463878110577526 +0.10147401214072124 +-1.4765169484541887 +1.7922057196385746 +-0.3673095288116647 +-1.205374445283422 +-0.9441373871715075 +-1.2778140921260073 +-1.3918925382786276 +-0.787968248958409 +0.1607492191697285 +-0.49012147689087937 +-0.9774703731627159 +0.25776446950299114 +-1.4258007766482252 +0.1483235255521746 +0.5416587830815824 +0.9782641487829176 +0.06474286963632704 +0.62547420705687 +0.2179454267449247 +-2.3253800730741707 +-0.5113840295878241 +-1.2423883736563988 +1.333092632188741 +1.5972076979584628 +0.6196149421994548 +1.106685643322094 +1.2544209908183424 +1.1155392112254026 +0.1885744993371681 +0.6765618202434955 +-0.4492618836984493 +1.8720100568621107 +1.1272512883308476 +0.08532437064709342 +1.1013750968383018 +1.2122522659028336 +-1.273214060701584 +1.6591442067374695 +0.9401071493163867 +-0.19024856078015273 +2.0363738686278112 +1.7150937399569761 +-0.3047372655168651 +1.8098323042234121 +-0.6002736638496922 +-0.9018332397309119 +0.5400099809190406 +-0.03161298202350199 +-0.48232581754571835 +-0.19100971408960382 +0.10139958107856091 +1.1630843352293538 +1.8206552835507728 +-0.36016537313994856 +-1.6313882676045293 +-0.003883031913486462 +-0.33534779210168697 +-0.8667214297458177 +-0.7184086519790478 +-0.9273387752184039 +-0.20786696228894902 +1.718297368870471 +1.7184989742433128 +-1.5241228444017563 +0.7764779984553867 +1.1065451454736355 +0.028583604442159433 +-0.31907392624332376 +0.5444120368247931 +0.2159215602358029 +1.3778137015100207 +-0.050161634916398135 +-0.32225820678377637 +-0.3895059785509364 +-0.4895604121813464 +-1.3570439812857626 +-0.2643719198252031 +-0.16172143772711278 +-0.30459719289161086 +0.9201124098481693 +-0.8157226029610598 +0.7129104292185738 +1.2811856584837753 +-1.0691774018174407 +-1.1416886630784528 +-0.8654165437840329 +-0.2106295017881682 +-0.7548436927006045 +0.6228414353127307 +1.878610139106758 +-1.2042978497177586 +-0.8865956761331817 +0.5316311108405114 +0.07317618852480841 +1.3503803639357919 +0.5464888296959514 +-0.7410769327207017 +-0.4094664578760038 +-1.2384689476179482 +-0.8602508514396456 +0.4082633134603373 +0.9648779887679307 +0.6718638672510118 +-0.380945400081949 +-1.0846350737307262 +0.38513415238929644 +-0.41778473561387786 +-1.6752955851754439 +0.12921173333116803 +-1.074406945339614 +-0.305848915606318 +-2.1965849216684292 +-0.6757913698585005 +1.2837382658783218 +1.0294810510919339 +1.1989219238096824 +-0.5200137977174021 +0.17533527500620746 +0.24226204036068022 +1.4400384837950222 +0.44690670683270034 +1.1659775714357186 +0.045701417459360516 +-1.1660170164299128 +-1.7538625665289809 +0.4133122105028211 +1.2898774294873654 +-0.4580437099760326 +0.510440436214603 +-0.9293470434870204 +-0.348575112527138 +-0.30604480747763624 +-0.27131196697230225 +0.6697200641683064 +0.1796835470569691 +0.02188848297740653 +-1.4910397852164363 +0.4322525970564232 +-0.31659356766616176 +1.6763748841397097 +-0.06391271181415592 +-0.10718519730727122 +-0.9879484158046163 +-0.3808227860307217 +-0.27772471230571516 +-1.5796643611695056 +-1.1138138343450465 +-0.6552444430043213 +2.289016056971038 +0.26138848275235377 +0.32800479924085213 +1.345768306915638 +-1.9506298132134543 +1.452362282855328 +-0.2342425402130886 +-1.3286731854513738 +1.3929843117608636 +0.1125122334891134 +0.5460069626916202 +0.527963092450606 +0.557680600426965 +-1.892550242720916 +0.7293235063740622 +1.3686572995865363 +2.3086959640016547 +0.6504217868112931 +-1.3355999399399106 +-0.048597158483394465 +-1.4108228747951348 +-0.29225916225344245 +1.4231961617800428 +-0.5767834737166059 +1.0584438921293233 +-0.03408490573987577 +-0.5959908556223402 +0.8653999451324862 +1.5234603395272863 +1.480377856695763 +-0.3749676127207541 +-0.27992484556426517 +0.8177012061343986 +0.801878405044666 +1.77152110509731 +1.0522183463602757 +0.5813920915245894 +1.137210402139152 +-1.3097093694697681 +0.20745824453788447 +-2.359881088311522 +-0.3479456918766728 +1.5014888837809826 +-0.15176341173193775 +0.18551231307130825 +0.9576173087465989 +0.6788740187637254 +0.9234486130640991 +0.617405863373278 +2.0599379266922018 +0.4404193815736114 +0.3072080067082125 +0.18757706846998712 +-1.2982238830999087 +-1.640037025276268 +-0.1775051410603783 +-1.0867029350466082 +0.6052230640479492 +0.9337064365046672 +1.8390746327253429 +-0.18528737371335724 +0.05916482423403979 +0.19517942217738368 +2.1593866724314106 +1.3029574199735383 +0.7915613702398859 +0.08167357937284411 +2.2302189214090617 +0.699587188626604 +0.9138067962475209 +0.9595013545817455 +2.0590366894423724 +0.8224705722257941 +0.7506425486683297 +-1.3709027007272994 +-0.38985726135523224 +0.8271838830154606 +0.7247261180523193 +0.8361954325646234 +-0.30922013997645686 +-1.8201373033835038 +0.868672868147114 +-0.6633327126129447 +0.09911813232328597 +0.6763453197591627 +1.320036875607884 +-2.013299559087936 +-1.307600567878796 +-1.4318027317654256 +-0.9099914385045105 +0.9340914808364509 +0.5134482435562077 +2.745670710680617 +-0.0709025448312024 +-0.17984923330905744 +1.9658361145161867 +-1.6410720412193378 +-1.5520251469794346 +0.38743630035921356 +-0.397703940248339 +0.7582526767630952 +-0.13490548773024363 +1.359699443275172 +-0.29447211502217013 +0.0177443537065953 +-1.3050022982783516 +-1.4560655696229852 +-0.182312389759902 +0.2391648310343088 +0.06586815174573528 +-0.37970913580740273 +-0.7949397945631532 +-0.39459054946210204 +1.0202737788044782 +-0.6939750145599884 +-0.30691352385324355 +1.0325023188961213 +-1.4646885874510258 +0.22246122974010812 +1.457040342666715 +-0.05678624740927746 +0.9829973363960512 +0.9409464579672082 +-0.2924939768061884 +0.7927627790026943 +0.791331691466735 +-1.0519158535910818 +0.0140545051291939 +0.22035311288989015 +0.0223836500031796 +0.8689626819370084 +-0.4925077677380393 +1.1865335890818594 +-0.10754146582505175 +1.6184507610940533 +-0.9949816574248425 +0.5235516337654146 +-1.207358272628297 +-0.8002343123690238 +-0.858949883352681 +-0.4771567914963244 +0.34712678598585867 +1.3241845475324614 +0.15965941254148822 +-0.20530550526043012 +1.1349325512672421 +0.30653321725118243 +-0.1926344156894142 +-1.379816974466837 +-0.921068051484041 +0.683959653199113 +0.6920756547484345 +-0.33588528876869805 +-1.280471966518406 +1.6903081251286796 +0.21418824091104405 +-1.1305845518682696 +0.6147418229570067 +1.0575606230830483 +-0.3120047307525712 +0.4335040418902366 +0.7065735616131191 +0.23018960175344508 +1.1345823053669037 +-0.3630640222713848 +-0.8287583868133761 +-0.5121111423361784 +-0.6565925136387623 +0.01816268697437895 +1.4732071971427598 +1.2395033582327 +0.04798783317351574 +-0.3437135238192718 +-0.5810576333075448 +-0.8469918749544725 +0.05584183856017849 +1.3279931355317078 +0.15084494548538419 +0.8542029707471042 +1.3874421815372155 +-0.8680616386570348 +0.8056318285559377 +1.6404398732832417 +-0.9898734483689928 +1.3101404371237486 +1.0063654486661575 +0.0010593062670503361 +0.28211633422261695 +0.497963938430455 +0.029940060970704035 +1.2912921748378428 +-0.22926080580895158 +1.6395868423620956 +-1.50525586000008 +2.5498650177514364 +-0.4879596018433575 +1.5604340569419608 +-1.7736242780613323 +-0.5177564189246827 +0.5280879975553043 +0.21990751259210406 +-0.05689533000739003 +0.16580797889743093 +-0.3322380954391515 +1.0721504959610613 +-0.12903096690699745 +-0.12800972598538746 +-0.010470918991349942 +-0.9857211979864005 +1.1537797196924382 +0.2088931375944896 +0.9385646108363899 +-0.10956479531335878 +-0.640551855962357 +-0.5133035073728148 +-0.4944989292300338 +-0.13560109412130117 +0.7304219720746368 +0.5817599155797972 +0.5031378696833222 +0.562587216845194 +0.2329746049532391 +1.0139354406876653 +-0.5678559121173097 +-0.24548532762509256 +-1.209362387180273 +1.6733659104817262 +-0.6781495083484073 +-0.14618330808672325 +0.8075945535536622 +0.8200950104371931 +2.280013455203232 +-0.813033624544921 +0.6356056769440646 +2.579740329515957 +-0.6837043550289481 +-0.6194361904563022 +0.034483911754381535 +-0.09958153643306389 +-0.6838936364642986 +0.30002305796375456 +0.13708165864929767 +-1.0218995404664182 +-0.7199409792186646 +1.7443888351009573 +-0.16792914525667174 +0.4497832978519205 +-0.9863526193413898 +1.6301516394720112 +0.796679646551754 +-0.2580333033942081 +0.3725365211402264 +0.09205000128452046 +-0.8607751591386639 +0.5890163714891737 +1.2278753273614922 +0.5470733852876393 +2.6185558456492055 +-0.4619614472065229 +0.9033753846939053 +0.11561273652061985 +0.2515631073543385 +1.857615172625083 +-0.43926884130074184 +0.15135506208627825 +0.4676796628626666 +-1.51894178906342 +-0.4750592426524276 +-0.3764156527236264 +1.7055366220889625 +1.5003947552678178 +-0.945846565828391 +0.12714117160961752 +-0.9144193182131157 +-0.6300128325820588 +0.9052410510288189 +0.627778570341039 +0.7025373466652173 +-0.3205341411032855 +-0.5580608710079624 +1.3360146798159875 +-0.8220347903830596 +0.6668721152453295 +0.20452459474714077 +0.6633268347850321 +-0.09826425947687467 +-0.5107303564169435 +0.9761323121336706 +-0.8206495839169765 +0.023634360774693997 +1.1563946279212827 +-0.9615299730962079 +0.6270235537866162 +-0.31037378446280256 +-0.980322335592698 +0.3320884743333653 +0.2774655442096933 +0.16532598325139763 +-0.10953634340402096 +0.7043615640784678 +-0.7765838638911513 +-0.634267360076366 +0.2281569593862236 +1.7999449522558344 +-0.5931808781701544 +1.1881251705749205 +-0.4132367312377402 +-0.5133603392289734 +0.5258395907696602 +-0.328892009128136 +1.689439740427955 +1.1897716646899514 +-0.2690727285307384 +0.06835853246686209 +-0.10813208352299686 +0.13972839366652268 +1.776516187588702 +-0.05455646234684264 +-0.9963923609383083 +0.5219787336313714 +0.48698435265160667 +-0.338269771381262 +0.03834216631159118 +-0.14781763173542511 +-0.0846168513443672 +-0.5313960392055992 +1.034123036098124 +1.4531776264808305 +0.7376090750197843 +1.037066780070535 +1.0818989345067824 +-0.1886754212389013 +-0.03433054178608455 +1.3356834713251382 +2.0484094538587683 +0.025820672537921585 +-1.095155621559718 +-0.1399380752496665 +-0.18394211448663872 +0.9595091359161991 +0.7835321954383465 +-1.4834720375006825 +2.0660277946064878 +0.07356154876767768 +-0.09149502200804382 +1.3925409644501132 +0.40059999870909474 +0.3943204799962443 +-0.7330811766405696 +0.0649558253750766 +1.8675773169177317 +-1.479612478694913 +-0.16528071628465796 +1.1885125005258552 +0.051035999464953324 +0.16460575214488943 +-0.04424763112578273 +0.3032975603165259 +-0.223590069476238 +-1.37103521336031 +-1.9587240474217864 +0.5834920578088794 +-1.2143501153408194 +-0.1738409898125297 +-2.3666670781127994 +0.5657001079632307 +-0.48142428876256393 +0.13998771801299587 +0.1997799847077868 +0.29212591568852064 +0.5045200515021979 +-0.7931402674092912 +0.7985977148027582 +1.7902309768213758 +0.9167503105256893 +2.264131353353 +-0.5966572107658159 +0.5215841092334498 +-0.46027880040417557 +1.5585981325864213 +-0.4145508182168173 +-0.6350785313899003 +-0.6286167251784132 +-0.8175124877628663 +1.62448315506752 +0.6205708640437031 +0.5639189715859989 +-1.2001296293799928 +0.3482273169521186 +-2.7543392259715445 +0.6464912949199115 +0.3808126915271779 +0.6832945313558818 +0.40725803746984157 +0.7729102659971442 +-0.3072286811852653 +1.1174568887956755 +0.925514896331927 +0.39178541674180134 +-1.194131318424715 +-0.867247705761919 +0.5642185693747004 +0.4132865453733835 +-1.4421117808184323 +0.21945834982130094 +1.4509841475386718 +1.5889099271815588 +-1.6764548753009672 +0.32355384232539797 +-1.3718761579118792 +0.40986905971223353 +-0.3887922778118408 +1.1904812040293773 +-0.13179087059520206 +0.1370588493488526 +-0.049983648031828865 +0.1168711516932349 +-1.3408061183850382 +0.15621274126627907 +-0.9063779676990198 +1.394701096974176 +-0.746555207836222 +1.2694742746792518 +1.194895947180708 +-0.5389450219087809 +0.526847096380525 +-0.9388042777523686 +1.493016287790803 +-1.3553327238932285 +0.6655621790991426 +0.3920743901695499 +-1.9910863504765313 +-1.2655397504849573 +0.6641887334781187 +-0.706687904483404 +0.3218415436310236 +-0.8590671624136612 +0.2462310190417926 +0.19930073379494853 +0.11626182296876639 +-0.6292236766036204 +-2.4742816787235444 +0.9945312180014825 +-0.8256080551359759 +0.9625840645244625 +-0.24353263089327637 +1.5298569500914656 +1.0069576517508052 +-0.6791943662087887 +-0.4978991056655079 +-0.9456900661925354 +-0.39630788260629324 +1.119790954281704 +0.5821770305681951 +0.6517640134526159 +0.8299579007844078 +1.1175569079991932 +1.0089235348836212 +1.1204019871368045 +0.2372388645970008 +2.140884436784794 +0.16717276437324546 +0.3555796789113812 +-1.042172753689866 +-1.0139398998112445 +-1.8861785108715987 +1.7026294753459335 +1.5282235071615062 +0.17571148529873193 +0.6843881853695217 +1.3286080527206852 +1.5969899948329371 +0.6622014116755236 +0.5841647158630606 +-1.6606597671142322 +-1.4357771201417902 +0.3547218906319311 +0.18728961342469072 +0.23021484475353954 +2.1959483379545457 +0.3007305405641982 +-0.1046582530544114 +1.6361612888469332 +0.1821589010962961 +1.4876143563662112 +2.1039933988822463 +-0.499473833143808 +1.7765320021092974 +0.12035071875964283 +-0.7484533487692088 +-0.6179386468401467 +-1.5948322605180443 +1.0737229881885548 +0.49737683219708745 +-0.1945746216446536 +0.04772240492422489 +-0.7105566214206027 +0.8537578621278598 +-0.4177629879375344 +1.6366828831032307 +-0.7092759306472197 +0.531485651305827 +1.475078081798118 +-0.6821875822494506 +1.4916171238274671 +-0.019944876309265863 +-0.2561435542435612 +0.07318211131145243 +-0.00976799522999297 +1.355904850183318 +-0.4977013591619599 +-1.1930613827800014 +-0.852078462317077 +0.6332142360154283 +1.7250919157654048 +-0.4592757989973717 +0.4020184781401637 +0.14213417490259747 +-0.7955081287995989 +0.7790563408865 +-0.3436083834059256 +1.2467743814187737 +0.23657797005614775 +1.0037570271582732 +0.6134127655114145 +1.6622529983070617 +-0.7904163305208595 +-0.047470856787408366 +-0.35376984586133675 +0.7624694293021619 +0.4620575923294458 +0.02269727904720817 +0.25174231373925093 +-1.5143822489966043 +1.1038687871592279 +-0.20920939652989085 +-0.26206693689723803 +-1.865653799886686 +0.18878304582520838 +0.6946301886406521 +0.5734808618863869 +-0.4250760747189114 +0.1697990113088118 +-0.8602260609206296 +0.7203506949226789 +-0.23724609279620013 +1.3909135963004968 +1.0124042317070057 +-0.23611303125221106 +0.13289497862837868 +1.6300367239623874 +0.3747498403875746 +1.7395454001548092 +-0.7790860374133082 +-0.038819242931902836 +-1.1282797605179218 +0.9251211272109577 +-1.270145208096469 +1.8380529723702628 +-0.6444447680979029 +-1.3640419352496456 +-0.062218152973370355 +1.4423550371833618 +-0.08500350429404757 +-0.014969775676171637 +-0.9936502289390707 +0.16969078101743648 +0.2487358114574331 +-1.4640349943963056 +-0.40616426511600223 +0.7468260751082857 +0.8535122258832282 +-1.1438698624628016 +-0.9041704676010596 +1.8062687996437625 +-0.5401699838498474 +0.1674808939221977 +1.783438588861682 +1.2717095637097773 +1.6146527322868944 +0.2762634019921481 +0.5402064274246279 +0.5394750530580377 +0.24708584488018365 +0.9570629699591058 +0.419764169472779 +0.4025125528844481 +-0.3466529168600515 +-1.5100350566573046 +-0.35786176253850643 +0.15274864325668705 +-0.9353691086106726 +1.1566586637828002 +0.20414616080219158 +0.02313849514828964 +1.3302426134419165 +-0.2383703511454907 +1.9773556973828181 +0.27963963638251754 +1.105427075771226 +-0.5267909629197604 +0.914390651241842 +1.0233891676207683 +0.6589721353126546 +1.036316497819456 +0.5591600163890482 +2.134736985971143 +1.9783855786613074 +-0.3928868791314112 +0.8838568625527284 +2.0103689427783555 +0.9953164375118925 +-0.20937620668623225 +-1.1732171098534254 +-0.7910329112971713 +0.37289413603785543 +1.1453579795188396 +0.5576220850672067 +0.5524081183514765 +0.2251488806284519 +-1.3042128798271468 +-0.7210939231658511 +1.0987984575852905 +0.9215445801014962 +-0.741046417332307 +0.8175268177605205 +1.6678051569716057 +1.0108783910578825 +0.5624426603259012 +-0.9379114264795871 +-0.7238991643737599 +-0.5803813556500457 +0.29712829258842377 +-0.4613715734560867 +1.6784707718905787 +-0.5734872999850709 +1.08388895678392 +-0.011178182997688718 +-1.998102211588926 +1.4651629952691323 +-0.4110117283177632 +-0.1334446303263146 +0.041675587073378734 +-1.0120098896415082 +-1.586777826702473 +0.011328519515649532 +0.8230709950121643 +-0.19855258381871338 +-2.1921428579909232 +-1.039333159298878 +-0.5215392024669983 +1.9085005235767494 +-0.41767270432161363 +-0.12219158393416096 +0.21175296456941547 +-0.6541815281693866 +-1.035200599330072 +1.9512416922953824 +1.4741447766875293 +-1.7100036906454354 +0.37001963698605095 +1.2813514987722192 +0.510527765509992 +0.18026398766685278 +1.3653380714784091 +1.3131642021952883 +-0.43490903921865876 +-1.663143834382452 +0.8327296368245926 +-1.1187206588844225 +0.36522945776228327 +1.5268030934363086 +0.5918255197173077 +0.8229273816862719 +0.6540085530204726 +0.6764805983247617 +-0.12040437500060874 +1.0518598522451632 +0.5083910693768483 +-0.9477221028564418 +0.23802292124759727 +0.4107437719745798 +-0.43230382669361866 +-0.617907651755641 +1.277401316525236 +0.4356357682040378 +-0.5257716485332494 +-1.4753647669288814 +1.1718681718474055 +1.3760463852766345 +1.051875820892668 +1.6393817452081636 +-0.7097410300469855 +0.07421100672642983 +-1.3962960699431377 +-2.3689888605684786 +1.2444880948536183 +0.8536679302032048 +0.178573656447173 +0.6894617661780036 +2.9382330511515695 +-0.4192412193336753 +0.9931054400275033 +0.8629411798016035 +1.3397083954890978 +-0.7296472907926981 +-0.697006104333357 +0.5843031931110007 +0.6037803315297474 +-1.5938203772053166 +1.2827743131017826 +-1.016827042850221 +-1.1396576671046736 +1.3713064351150694 +-0.8016710777716743 +0.3382132030651309 +1.1704780958199943 +2.961912601871566 +0.2969911910897105 +0.385246343109823 +0.040205625024756775 +-0.1267461621189641 +0.5099335838437549 +-0.16367305253227715 +1.9050654153162585 +-2.1610476426924947 +0.23123403983758853 +-2.323200335556365 +0.5285290409544369 +0.47173674553721456 +-0.9603636171263881 +-0.47462528568561857 +0.1185664517511554 +-0.09503239108635758 +0.31801164753873645 +0.22433576621236123 +0.6411904314966449 +0.15641275615519057 +0.6735150020303938 +-0.8303348578257044 +0.5000402665730527 +0.381930958315017 +-2.1975731593003953 +-0.40766055846348304 +-0.07501537696270161 +-0.20281974376669226 +0.8798621808810743 +-1.1788364426633244 +0.804132812403254 +-0.22708841934308144 +0.5103335598855219 +0.3190541733183466 +-0.9539633594995798 +0.10965246903916107 +-0.9249585625356411 +-1.4913088066623086 +-0.3106852751630145 +-1.9019024972793275 +-1.04863341137811 +1.1116192105011367 +1.034258567730269 +0.5212247379636581 +0.36388342383820405 +1.7850501727281642 +1.226725050675546 +-0.5213170749943287 +-0.6413861868303042 +1.3873822572370225 +3.105573630507438 +1.4264816368258744 +1.0577277149638962 +0.5185209622218894 +0.22733217145997264 +0.7394583405632421 +0.08175215850251628 +-0.1726897761877756 +-0.7312209189998021 +-0.29522592572923434 +0.08100388353817825 +-0.30516470899698983 +0.8569201853064713 +1.6630753059776282 +0.4703793240951193 +0.9441659261391667 +1.6871594530724838 +0.26526016993012624 +0.8078784528013755 +-1.2924325421666831 +0.16414361663105115 +0.28075706868938854 +-1.0314052618088185 +-1.6526214613473407 +1.251539849343449 +1.0573760274801414 +0.8595459131490355 +1.495870023689733 +0.8616936558897622 +1.1887408987540509 +-0.4080439797117501 +0.9471866211041071 +0.19865129198475112 +-0.7427837800767021 +0.3328278812186022 +0.3766997975751307 +-0.14549534416702614 +0.6199743777136947 +0.6999520084766161 +-0.019785427669209266 +2.521714210846662 +-0.24130804388086619 +-0.8012659068673872 +-0.3740768737055312 +0.2858424291164375 +1.438865009010542 +0.9792631077410975 +0.6798723666712538 +1.9591065818665296 +1.5649085251909405 +0.5458900153705478 +1.5325028659046063 +-0.45151732998128447 +-1.2995833663103311 +1.3765156361850903 +-0.23731825769617892 +-1.1765904230341588 +1.4047831579527916 +0.6596684518626579 +0.27606655811129654 +0.24468256727477977 +0.198124603200795 +0.22608856006681932 +1.0788823082074483 +-0.8439238382880885 +0.1008103335717571 +0.7386697446388495 +0.34437154421802574 +-0.262536039329864 +-1.2247393876730313 +0.8812411313004225 +0.2529998342330793 +-0.6175076332875994 +1.1521523274524057 +-0.7847748690721243 +1.0217024470383824 +0.01909525880244295 +-0.1189253204647206 +-0.37766823084989876 +-0.767326912884355 +-1.4666124733465713 +-0.05567568719074753 +1.1949430036048128 +0.5744700939717313 +-0.8289814353117153 +0.28022421437349254 +2.07254695851333 +1.0355930125893522 +-0.27094026440004887 +-0.23728562049169577 +-0.04744844000772455 +0.911395959348468 +1.3934030067174799 +0.8493581162051017 +0.38885997047055243 +0.486045845147015 +1.2383098227784612 +0.14946481176142448 +1.987741994700814 +0.21464743264956396 +0.35107814532687664 +-0.45339625101975356 +-1.4040891510303843 +0.6935429796665831 +1.283840804307126 +-0.0607123045894119 +-0.920434853757963 +0.09991710973264241 +0.6623581511011758 +0.6485356667377635 +-0.8224115986555329 +-2.227667102746687 +-1.3735641664238505 +1.9342870679477941 +-1.31117805368489 +0.3861890082839594 +0.16569493610063551 +0.235120232926058 +1.8495961631127575 +0.6993407093927551 +2.0290412149258272 +-0.8496151326954369 +-1.5139768884018567 +-0.1944627721654345 +-1.0598058272877293 +1.3872264712590734 +-0.4331364351809548 +0.08186776336786644 +-0.28037487445115067 +0.5708766256793634 +-1.0913199820865602 +2.6350208405116113 +-1.2417459854782644 +0.09687074136640784 +-0.5836448690999256 +1.026072477554158 +-0.6810986991548711 +1.3192082248942905 +0.5378774497626568 +-0.7548658433605415 +1.17867610920249 +0.4785111666025638 +0.621805566728659 +-0.7439211865805899 +0.3227221168894964 +0.6285774184190838 +0.37180898848084615 +-0.7225965729397669 +0.5733421000407216 +0.42297715301830074 +0.6644943269610444 +1.107235271634151 +0.1408742004149007 +-0.5626675822187677 +-0.07392036419515813 +0.27906600916755875 +1.4287746424893568 +-0.14796192310565892 +0.18819211576933173 +0.23603917338498398 +1.3019299764245307 +0.37376017045784565 +1.4090724782002633 +0.19567350552080345 +1.4159940020695718 +-0.24300242366752473 +-1.3964612175415023 +-1.1140461611070454 +2.3439174761814066 +0.28099621436429667 +-0.9869489863523884 +-1.4745507151844506 +-1.4386902127884384 +-0.48665482185672104 +0.14774938005446683 +-0.2976002840536494 +-0.1319155350371674 +-1.1477194516884615 +0.011716041092344004 +0.7974503821898079 +-0.33038930044856385 +1.8673909830088424 +1.2007909478257157 +-0.20951641249439906 +-1.7480281380211833 +-0.2081547923121574 +-1.4345336745518382 +0.822729702333271 +1.5989557529997143 +-1.5520059771151242 +-1.4684445201004588 +-0.8430449152835762 +-1.8961437277986521 +1.4159843855002299 +1.2659823987254313 +0.714579644149559 +0.24913783861158542 +-1.5885910906110143 +-0.1535916699292254 +1.2189825954961646 +1.137482090025186 +0.4320905970878795 +1.8404463243405873 +0.33834228411962985 +-0.5628234818230414 +0.5012646131837426 +1.6296729811651836 +-1.066195824571896 +1.478240877625184 +1.342345733667123 +-0.15825835346560668 +-1.0705879237169407 +-0.2933718444693986 +-0.19232376660590111 +1.6238764047011967 +-1.2210600570420467 +1.8165145668137281 +-0.3870804393581798 +1.362591630125569 +1.3001259981682078 +0.1593416480104564 +0.7040391180246228 +1.7090327330630442 +1.6342408782036448 +1.5384518596730177 +-0.22331504535734242 +0.9450020710128103 +0.10164669007978729 +1.298004729838883 +2.188591956659545 +0.9678445666527893 +-0.9241437628466778 +0.09394377812448977 +-0.12569852417879235 +-0.39210821256472395 +0.5881532507770708 +0.48491261921671985 +0.2006128759398269 +0.5680342953284345 +0.7614324881519818 +-0.3077509184693323 +-0.08377442723447476 +1.8157973113008803 +0.14481030225120328 +-0.14274258520304806 +0.05618625941561983 +-1.303096643278292 +-0.9584381925582568 +-1.190111221691659 +-0.20774143337395556 +1.734198978036265 +0.8289036281791442 +1.4681814429918543 +-0.0054954594564212145 +-0.09841089054329233 +0.42907953722600356 +0.8899211328086682 +1.319313314327042 +0.0013130672671821386 +1.088442274370523 +-1.1787120404339597 +0.6596234660638082 +1.1370408073273919 +-0.3274343890848549 +0.6060876865374271 +-0.7726065379416063 +0.3895451922065647 +1.5658602912533357 +1.3237949625219099 +0.9973200446076765 +0.1442461439595356 +0.32641561354960946 +0.22425028602376207 +0.6057550272510187 +-1.2073431780262427 +0.5828112850522766 +0.9645593574424589 +-0.14941968936250605 +-0.2499590089190724 +-0.1090941828638925 +-0.6036176556519792 +0.24540232893120156 +1.8294766333777224 +-0.07369778373806035 +0.17217627877889324 +3.7949383073214147 +-0.15928715430595225 +-0.01903150960269029 +0.5630069609522164 +0.6841404185257954 +0.7226807374153351 +-0.3650086694594943 +-0.35925773634682245 +-0.9486973632457816 +1.3693975293767007 +-0.12628773319564135 +0.6345187485275304 +1.725977721588366 +0.5531804666003 +0.8184730727395684 +0.3027508635270485 +-0.10231477548481738 +-0.8448685563502905 +1.103770364526492 +0.9361753745115011 +0.532421190405516 +2.380471942667289 +-2.5040973215208666 +0.553005464913497 +-1.3485312904582079 +2.1281795180918746 +1.0867139281556868 +0.6931406317470974 +1.4439527295235375 +0.2572794115294971 +1.3928599802772126 +0.6272666008101822 +1.0409506435346638 +1.381693571518166 +-0.25347418165641306 +1.5518601849648899 +1.269902738066085 +-0.7775051435314402 +0.8757382396098483 +1.2386862741626408 +-2.0573337913799357 +1.5567923588790236 +1.0179298940839683 +-1.6073778670692713 +-1.4705344503443454 +-0.25441751793210016 +1.8294427991015332 +1.695478042144156 +1.2325301055751792 +0.2633753575778295 +0.3509104135840675 +-0.16137290664112663 +0.11157114836982213 +2.6657250444256055 +1.1899453706644132 +0.6371766957773805 +1.3056660325253955 +1.0685866618871436 +0.25184136842807586 +0.34066446360989966 +2.029086749330785 +0.3564417256267346 +-0.057330323158705704 +0.7374190448114625 +2.675376077238414 +0.07990266394585692 +1.6623232991635148 +-0.6704968490605684 +1.4226839669747413 +0.42612037075299525 +-2.7920584616614983 +-1.4166954245993428 +-1.355155970631996 +0.2861218641843788 +-0.44032926088768964 +2.466940572270543 +1.3422144203782154 +-0.609801638400084 +1.6551589872147492 +1.5778583151469834 +2.9091833534302616 +0.04285256769851514 +1.1620547525786162 +-0.2908637000416618 +-0.669075524154352 +-0.5020084521309621 +1.0952418152742236 +0.17565193666767942 +1.0411274117902396 +1.0315581124379989 +-0.17851185558805976 +0.026328011543065022 +0.3072207970988099 +0.8603810458050326 +0.10499219395166451 +-0.5999542039576634 +-2.375486178638652 +0.452729464333793 +2.318068347990458 +0.07393294023483275 +-2.2424893281806684 +-0.07600655421203117 +-1.9008596085189524 +1.2434437714171949 +1.0832063003973795 +0.9488133561198199 +-1.6437034843647287 +1.078506903974319 +1.237439257102859 +1.2395247938593692 +0.043039997088589826 +2.9187286677194155 +-0.14187386136372532 +2.734992693501403 +-0.6316685030959204 +1.4282800254122836 +0.922913013858676 +-0.0732408482457238 +0.4215339764955095 +0.18788812565848492 +2.3145138220894497 +-1.9163649573334405 +-0.0008051077677666274 +1.5592203520200927 +-0.08310374132485454 +-1.3869861868158488 +0.20461682324658342 +0.9172250588720979 +-1.7254296492107721 +0.1410657738038331 +2.5431254679730984 +-0.3911415583816511 +0.7759143202788553 +1.6017562444621745 +0.34591492613704705 +-1.054122832173228 +-0.43046468643339464 +-0.20134128809288832 +-1.095219316496816 +-0.289101581879348 +-0.4752776383131736 +-0.023318346479924562 +0.32738783632930574 +-0.02069468752220266 +0.5996389164638158 +0.6759768103378627 +-1.3963041239705463 +-1.450141304407074 +0.9262489089346576 +0.41920825849404253 +0.7566372994796392 +1.298574379432211 +0.46028274467179753 +-0.3685568293926538 +-1.302828324504403 +1.019624605045132 +-0.9680143192583106 +-0.020684930269797563 +0.7444965357297688 +0.18791508372073396 +1.3887214448127096 +1.9133811838793797 +0.3904210395534625 +-0.4254393295512654 +-0.7778484648930404 +1.1871105761874343 +1.1463857330969103 +0.5730241503713088 +1.2260495893915355 +-0.5592195628414821 +-1.0302930438894906 +2.3911604951051233 +1.0178988919307645 +0.9139792432243412 +0.49383262490922397 +1.0723482331299565 +0.8488049977193342 +-0.4500466977684353 +1.7131086186208577 +0.4498343105215671 +0.7448634119261787 +-0.2716974293227804 +-1.3260613693191259 +0.4838664501277701 +0.10119411051269146 +1.4541841012121441 +0.5317602708222441 +0.47620381778999166 +-0.4625920375121837 +0.6442679950838376 +-1.3079781477014776 +-1.55034085465704 +-0.17867644181926456 +-0.24255197989637256 +-0.32101940171747134 +0.26652906150073485 +-1.6725131646615148 +0.07428190087396062 +0.17873450793720183 +1.442206746588422 +0.09932861376198882 +0.646041637789167 +-1.2200908203973828 +0.48413675331989686 +-0.08385425061545176 +-0.558304802966499 +1.2842435539473185 +-0.06560108310863155 +-0.5902059273063794 +0.4319269974069788 +-1.0507998042982745 +1.3804734810134802 +0.45463311924512817 +0.10302095748270418 +0.700133797106159 +-0.8549336640285001 +2.309764126078779 +-0.7600591739847193 +1.2066170186861658 +0.1113361731771329 +-1.9896617011048596 +-0.982797207801539 +0.7019395471606489 +-0.10386765863164982 +0.4358408833590275 +-0.6172112942562289 +0.7790877118349813 +-0.6514677588225067 +-0.974997236930552 +0.2654035191234496 +1.6251706083484838 +-0.21608502404737462 +-0.8326656023193264 +0.43621886406416843 +0.7036063516084708 +-0.3587387927244863 +-0.8966479965773908 +0.3340860821361288 +0.36984612300217456 +1.1648942294777433 +0.9008469700596696 +0.4955470320447602 +-0.18347627090590884 +-2.464768730611328 +-0.13273479374952352 +-0.254644658029836 +1.816077712758787 +1.2336236983458366 +0.5669329370572045 +0.3936881946175229 +1.4546304922578661 +0.8012730698860364 +-0.8467793445628848 +0.15585373456869728 +1.273378440042486 +0.6277346823879659 +0.10348069047339653 +0.8461241763249892 +-2.2831114567583297 +1.3436723928474863 +-1.9056149184520634 +0.0057294263291425285 +-0.2304812741201619 +-1.0678203300900126 +-2.7047602997763605 +-0.6936094862371411 +0.42065297817206226 +0.3322188050206277 +0.6787343943600945 +1.7080253530845915 +1.3795405034606565 +-0.5746131125873327 +0.09163622202969772 +1.2108137001516275 +0.25027099435398875 +0.4731993434440104 +2.0295744923216366 +1.7605230719368743 +1.000009939839073 +0.9381425253242374 +-0.8474920032049249 +0.76303128276364 +-0.5020216453709219 +-0.3200711046482758 +3.0729260398064833 +0.8843990410639989 +0.2132260070370065 +0.8352224630739621 +-1.2672970290605734 +0.4313279198433818 +-0.42557828698574496 +0.2575704054400757 +1.1323669619006864 +-1.75818672253006 +1.3852294259939297 +-1.5697419322646216 +0.7591434244059171 +-1.361619507659585 +0.3886612160487663 +0.9182812875456278 +-0.8841770948377032 +0.7580800307105886 +-0.5274591296354724 +0.40626502814496146 +0.41747417090899175 +0.4010506943454897 +-0.87410237875934 +-0.8136968530253408 +1.0722095671890113 +0.08919059625032735 +-0.7059853964676924 +-0.9040538761941472 +-0.2607919730191271 +-2.903054709761583 +0.2223955749174442 +-1.0139295176836787 +-1.0112173904843604 +1.003136362550702 +1.889458998155602 +-0.06322737751324314 +0.028330066598794307 +-0.5686709370886536 +-0.30303852845687906 +0.8790288264369791 +-1.3442619834106124 +2.5318436956229604 +-1.1466543990770333 +0.3036547015967411 +-2.2057725121363667 +0.8105404854515265 +0.2052315265792118 +1.4613460567637926 +-0.2202390928015227 +-0.39528541793831884 +0.910017204507663 +-2.0756623480334992 +-0.8759347576848793 +-0.2576063304003868 +-0.08164420346764906 +0.2841373829648496 +0.7660503479407803 +-0.5008815923507329 +-0.6061747609506503 +0.03292170723427357 +0.24362119566286763 +0.39053395396527557 +-0.026566643830483128 +0.4980954537210563 +1.627964028715392 +1.7737715461648627 +-1.1893952302578747 +-0.17285762112891095 +-0.5259871177244544 +-1.4568034244672328 +-0.03462399289164106 +0.319406138447692 +-1.1624674592762987 +0.883246383265618 +-1.3706925296447527 +-0.16213602936603294 +1.2661298882783458 +0.4484797929114466 +-0.10289539171635276 +0.17550364496328075 +1.2681065657566144 +0.8209004749413236 +0.0801979448251197 +-0.5495970942196697 +-0.45778275143532154 +1.821677600447471 +-1.022465694372524 +-0.4547622147741658 +-0.5836821822663985 +2.094591559796947 +-0.5497734619093327 +-0.1298712104173111 +-0.2985368492755876 +0.3917357012280269 +1.3163091159695757 +-0.6842158975938002 +0.6836244738118828 +1.3115415094658207 +0.7477218683638457 +-0.958785079489215 +0.7681528419704207 +0.5011785379446716 +1.2942507061299524 +-1.5995885881298735 +0.176454385200318 +0.1609299154151636 +0.14256477020454073 +0.8481398918971516 +0.46579663790978804 +0.370248100695346 +-1.0358642878080424 +-0.10223539484891558 +-0.32191289151297287 +-1.0705453216412 +-0.49606840162490784 +-0.4352861475168197 +-1.6571107873670499 +-2.1214760707228004 +-0.8669867753499678 +-0.5435096910538 +-0.17634571894851714 +0.038520043034445284 +0.908117423151357 +-0.28774917165733455 +-0.36799904506419046 +0.05700622641313266 +-0.8572783052129236 +0.20410930799902313 +-0.6208592713509855 +0.20582768352815273 +-0.6862438149251237 +-0.18769216675749784 +1.6498123067065562 +0.6614275744487674 +1.489824158821772 +-0.4896070264195964 +-0.5108795101241798 +0.20567802655412426 +0.8292110105391818 +0.1932763262067024 +-0.2761141336807619 +-1.163116197069357 +0.056606929249444465 +-0.9736434031398986 +-0.7336509773309016 +-1.3019696077357161 +0.667759532721579 +-0.11284126464708205 +1.464385033502714 +-0.4592668327325463 +0.8871896810985562 +0.87827435816543 +0.35617153264388796 +0.9228915904669938 +0.4493897907975648 +-0.3069392599225692 +0.2857359349538817 +-0.4194850087426787 +-0.1369465899743439 +2.421810986755097 +0.3332265133000364 +1.1930108756232887 +-0.4589746576863277 +1.6464522531933843 +1.194920852805113 +-0.10634630872785478 +-0.23220099924278198 +1.4349197017521147 +-0.4107453958549615 +1.3036807612214594 +0.42862120444139973 +1.084735027153143 +-1.9428372090802928 +-0.06381208324217652 +2.1589528761616803 +1.470061615315896 +0.6549380003813624 +0.27290455537063607 +0.28321834443337035 +-1.2449639149485932 +-0.04140440886783839 +0.6141179606100563 +0.8473117937448739 +0.04434751048991406 +0.9998150381609779 +0.14522295131231444 +-1.3876857830208411 +-0.09698372317079529 +-1.218363134607081 +1.4541039752347928 +-0.9671532863029033 +0.0011343836843301647 +-1.2081446443635282 +-0.89963388038485 +0.6922603818949897 +1.2535337307501364 +0.9868648575283225 +-1.0466229502462956 +-0.05095083987246046 +1.199827060234204 +-0.6373262618232812 +1.0372930338655157 +0.8071415214794921 +-1.1109023465040402 +1.7517740750692918 +1.9534091841010137 +1.4222141024691282 +-0.7440705692917007 +-0.33985317871173537 +-0.45679334976192687 +0.8797628667178605 +1.2506211365106181 +1.2414843064063081 +0.998562265239485 +-0.22753087905748742 +-0.5978839778271713 +0.021017624603982737 +1.8747849498774292 +0.25754510961257016 +1.4124476461398534 +-0.7421443155531428 +1.3652946508048125 +0.48996789149535064 +0.9860407143230946 +-0.7835811724261145 +-0.4815103891755803 +-1.3695322533770438 +-0.11681307292717241 +0.9969728142963991 +-2.45061813090397 +1.0906965826551045 +0.25759464188162906 +1.649180630787329 +0.7236968811150226 +0.9645922582379047 +-0.2995963671082836 +2.440326967306465 +0.9511510558003972 +0.9045089461250815 +0.7669909635667742 +0.3415190304658261 +-0.647854207553221 +1.2194322694666677 +-0.9326985910966323 +0.5201768355937686 +-0.5601126779918039 +2.225057656514771 +1.098210928684789 +-0.23996603817663165 +1.0456057748818262 +0.35445208855796706 +0.4820906779233735 +2.435743724262756 +1.1158945947574797 +-0.3028013960034932 +1.773003573764693 +1.4444487535083377 +0.8789668417946562 +-0.3293798715237526 +-0.3324354805284473 +-1.1951649933120447 +-1.0383966505341355 +0.23951703985861705 +0.34809323548836435 +1.3835988966807864 +0.7191380653745171 +0.020692898755533318 +-0.3125443411867651 +0.9904154484703355 +0.13064240854589068 +-0.022030908493016754 +-0.7106136957657889 +-2.1550172888580015 +-1.7240320096135748 +0.4083495491417444 +-0.6967305895868569 +-0.09893261843202317 +1.3575062590346512 +1.2598816974856293 +1.2891106220169364 +-0.2924160695899492 +0.6323521774138297 +-1.5801593755726 +1.077820815972116 +-0.34279116745841853 +0.5086238455710201 +0.3269650905178285 +0.10310490191483039 +-0.9095042718190403 +-0.8131866054125549 +-0.5645498214417737 +-1.9905016296044467 +0.1165113910346144 +0.2145275452550661 +0.3329491807520125 +0.09111940603377665 +3.0809470390304865 +1.2957339178831788 +2.5634591599656558 +-0.2476011530453462 +-0.24150321081208975 +-0.26851011600737107 +-0.1787426909243926 +1.628216343480337 +1.424073804988091 +0.5313782171838051 +0.41872507596566044 +-1.3381272266101452 +1.4608174485701084 +-0.20640172131921614 +-0.6896461441625659 +-0.2912496464964759 +2.4816931109398723 +0.815362895979695 +-0.2120237978075285 +0.1584547176120776 +0.17099413394143664 +-0.42091032873186685 +1.877893702228225 +-2.35827162535856 +-1.3671357204058214 +0.8075822949860931 +0.032891387253618315 +2.410481244556829 +0.0503958018102969 +-0.9046604873050248 +0.19729060890119787 +0.9333619289471164 +-0.19391966373396907 +-0.7832657432051874 +1.3527064827997382 +0.8136177937045463 +0.3311216599378296 +1.9420375564906367 +1.5251890978933997 +-0.8841934746210978 +1.1525684711604822 +1.4160438618169486 +-0.34305222834762505 +3.1036285729502913 +1.225677408592554 +0.33080284868611176 +0.279115273183959 +0.1793982656450738 +-0.04489941087220381 +0.6586730794909601 +-1.31463453149617 +-0.5011136573375548 +0.8753788571080556 +-1.125165820442272 +-0.5898611496391646 +0.09873694980074357 +0.2145740179035615 +2.3043264757186552 +-2.1266253681671206 +0.12831467290009455 +0.9051699240031221 +0.9161700785946324 +0.07994725101015825 +0.5236798668263256 +-0.9079750576854038 +1.9501953900990625 +0.8040880410117435 +0.3082765527709315 +-0.45538053413348356 +-0.4006359616417632 +-0.044631366369905084 +-0.0019193588936645134 +-0.9056095976446763 +-0.7072505114608804 +1.8267627980002428 +1.1796219580843332 +-0.9647379818428861 +0.696155471777447 +0.766097866234959 +-0.96622547960011 +1.5088792218045683 +1.1457613870676675 +1.6522076853801018 +0.23836189151113224 +-0.27736513586427786 +2.6375423761182946 +0.16388935054758508 +0.3870468863098335 +2.4526039966643696 +-2.1303864639823393 +-1.5286533340697654 +0.2582097623086193 +-0.8103033801673738 +-0.5055956477994954 +0.06200301144135628 +1.0605361302916736 +-0.6303108910696477 +0.08594189793295705 +-0.6938242208705662 +0.5460672261232307 +0.3688589905618084 +0.3022471698251696 +-0.6963981754093597 +0.09297684170828963 +0.22320207643310275 +1.139310801095999 +0.21402841342153167 +1.2342701173061335 +-1.3151258383285813 +-0.8589524381111766 +1.2691077424715693 +1.2052280766519283 +0.800872027136392 +1.452173339943604 +1.67842554416665 +-1.2106233913086968 +0.9931119336868605 +-1.1644132846497666 +0.1237706657072489 +-0.1315905416078424 +1.401231486420975 +-0.42037281679861427 +1.5636130311915835 +0.5176739591996188 +-0.6015717979333427 +-0.513313091521782 +-1.6762197577865745 +1.2581604643965965 +1.5490281317435028 +-0.5179343315481336 +-0.4532950353506586 +1.6092003448980419 +0.49958957769153994 +-0.5593983505016985 +-1.4751666544629507 +-0.3284767986141147 +-0.09186222292265833 +0.6674674363521016 +-1.0798587457787927 +0.6236350397102983 +-0.9485394994798069 +1.5370537083526494 +-0.07887156705158954 +2.3546468302864785 +-0.49703582194638674 +0.4129110047658656 +0.005648460410288547 +-0.05391845973775833 +0.9518750909896192 +1.0926930751504713 +0.30375754890192974 +1.7403065030090872 +-0.582220270381627 +0.38590662474173854 +1.1764775580607096 +1.0019972338577343 +-0.46831318484647744 +-1.1719348773708373 +1.6949686988421522 +0.7266889682296116 +0.0326049150008893 +0.8534818470177303 +2.125493507933524 +0.41248793902547665 +-0.4130713436087352 +1.2079780895329582 +1.5872781077043905 +0.6456953727779484 +0.002371613431566333 +0.7767096327680236 +-0.9416746271022916 +0.28759509465355015 +-0.20600220064623287 +-1.1572544416139086 +0.29245322251547423 +-0.9614079843977537 +-1.2200725558500478 +1.2149695095973683 +-0.496686825169082 +1.5177796442495128 +-0.32060112676378405 +-0.9302495464653404 +-0.08523235015534697 +1.300778406841158 +1.1217079961921845 +0.4203331535083778 +0.8106879976644689 +0.11762102106277045 +0.0894563135307097 +0.966410890058823 +-1.1957266106507263 +1.0173039604027005 +1.1436620424389772 +-0.5153134680728456 +-0.4308591886073093 +0.6227679856938841 +1.1563092590429003 +-0.6331105287067077 +0.28777065253214323 +0.8911601903817098 +-1.177800859104574 +-0.18534577193975305 +-0.8345363799336749 +-0.40336422680228656 +-0.269395145152949 +-1.2476924894241321 +-1.461461877197099 +1.8308446540138694 +-0.23040164377538275 +-0.38309262204595607 +-1.1054299437870017 +-0.4040587278679477 +1.5180063179249985 +-0.5718055675345044 +1.099458171853282 +0.45714723869181617 +-1.3262551098114592 +0.37943651486341456 +0.7134145061366024 +1.0130351769961279 +1.404264288446382 +2.167751510779852 +0.297328275985547 +-1.7246459882500522 +2.2904340179429026 +-0.9217607550802105 +-0.11697511841721331 +-0.5389754243047756 +-0.9182383642994649 +1.5085979456709344 +-0.16831235931726746 +0.5082175173189585 +0.8252748939395532 +-0.3010856701604726 +-0.0014576509300233687 +0.34996533108853817 +-1.640926080261362 +0.9909750805063805 +1.7363083402611548 +1.1333263768620339 +-0.002352609050833787 +-0.6586963060210368 +1.987514734704109 +-1.6637756778080006 +-0.027157193879346536 +0.31188046590038043 +1.8875364133363823 +0.6139553947239119 +0.4414967992401523 +-0.47782685027639704 +-2.9102338147695583 +-0.023411020076703315 +0.007047862488012341 +0.2163525641644825 +0.04177570146679918 +0.8586425607171417 +-0.38259026678782004 +0.17066153773807488 +-0.8706003295189706 +-0.8714703420407233 +-0.021607992928903252 +-0.3735182048157857 +-0.9864826652540246 +1.4113742419666322 +1.4865406104172976 +0.8188254341897984 +0.11673988539038471 +-0.7187155125645309 +0.9677312432734696 +-0.3480615006737132 +0.8695282901704957 +-0.4116649324414713 +0.5838351187643956 +0.3216849025306453 +0.2760725222113813 +0.15938401096373644 +0.3217939837657888 +1.0130243339109537 +1.9627026520806825 +0.05641274471179353 +-1.5596978915966044 +-1.0253892603828174 +1.5178803767457634 +1.0337683429442115 +0.1381601108825597 +-0.7811110754704346 +-0.0803567943309697 +0.5541907039747771 +-0.059588321541128475 +1.3253889598413622 +-0.6948420661078136 +2.252975108579051 +1.371293400611175 +-0.9865407536234339 +0.18072894659155214 +-1.6559113358482327 +0.32552991905828693 +0.7408217141763853 +-1.358400106626451 +-1.3165919869522134 +1.6362632806409156 +0.05273662268364754 +0.5655454519871312 +-0.5445935471754932 +-0.6432864772922485 +1.1272279475820226 +-2.1821457681684846 +-0.30735170132983075 +0.25859780767927154 +-1.7290785258896408 +-0.24673345729515306 +0.24017576396254792 +0.07410754188276318 +2.8262390356907794 +0.3362081597434361 +0.8276833220758496 +-0.02460048281179919 +0.6283803983061906 +-1.4600860904453035 +-0.7149831668613129 +0.12233460045440353 +0.0033321243255929056 +0.01859939599869742 +-1.1215642206797023 +-0.7980041772876838 +-0.8191543933737947 +0.43328067910779744 +0.41351354307585764 +-0.35538505045612934 +-1.8829581725672337 +0.12926924057800027 +-1.2036491779078133 +-1.4121815611494508 +-0.5199026978700891 +-1.7286290691362929 +-0.9272273266426524 +-3.0618357468162305 +-1.5568511876477493 +0.18395988289002313 +-0.5178652990922499 +-1.6642150552654924 +-0.5116586182773535 +-1.0807326650649773 +0.17123249078293534 +0.06907090051279358 +0.8381720205524201 +-0.5716378946460405 +-1.1043313046682537 +1.71202456475811 +1.1077388073419123 +-1.8890487224948198 +1.613142392324331 +-0.9000811594461972 +-0.7065876322225005 +-2.431251023522986 +-0.8335176549754953 +-0.3627206812992297 +-0.007116847654763503 +1.194970062982587 +0.27436678906976114 +-0.07688869695459069 +-0.7965089661068977 +-0.3545439155872201 +1.37829137356014 +0.21642807403007286 +0.9257127207892508 +-2.321051390513423 +-0.4278970682645424 +-1.6421102322383125 +-0.4505713690759077 +-0.6847331468507121 +-0.04374078903734824 +-1.4375754610744629 +1.6981970403196927 +-2.8484078785260802 +-0.5507326464643504 +-0.5245791517865377 +1.2677076882561857 +0.8107230092867668 +-0.08254412154570921 +1.6975657026853679 +0.8601023620876163 +0.5878751010590288 +0.03400750146972081 +0.1440996595797454 +-1.5909891803067153 +-1.2198565993782478 +0.6184637576055411 +-1.1957778564972188 +-0.046519769085608065 +0.746088342189616 +0.21503348970942732 +-1.2345921340216 +-1.3380563124460767 +0.4414725321516577 +0.7842583994970285 +-0.14986794381300514 +0.19587550909112666 +0.061539461485076774 +0.09322299585939464 +-0.0967121865424705 +-1.5512202215961959 +-1.4028623517303576 +-0.9901406168475619 +0.07686636508162698 +-1.0723545444506302 +-0.5822578610711322 +-1.6488076406175434 +-0.034076327928854344 +1.4999911249044624 +0.5659421656531032 +-1.2449369234634633 +0.24426160290861426 +-0.8271138555284232 +1.1675812897691875 +0.5863630149750069 +-1.3637406347002339 +-1.5093891085430153 +-1.0509252632198018 +-1.3243244181738547 +-0.1260463235556284 +-1.1418863680153613 +1.0209956414231536 +1.6170697666248528 +-0.09700026764816723 +1.1384666616155863 +-0.5291000221229304 +2.0709394950628415 +-1.3681839865234604 +-0.21660540825881214 +-0.058232293765342585 +0.008929277209600378 +-0.5793624974715121 +1.876842481439579 +0.35310550119808715 +-0.34709029188656115 +-0.2592880880206686 +0.5815399595681017 +-0.1999893454072299 +-1.0615004962852352 +0.16135791712248204 +2.45701024485434 +0.6998611517414023 +-0.7331098909203525 +-0.695900764807608 +0.13308231076297422 +-1.5748905602498438 +0.8898325718301652 +0.8938519635001123 +-0.444370820450136 +-0.24432195172109417 +0.25018267204094824 +0.41191844193975646 +-0.006325051062871817 +-0.035798936644472396 +1.240943990974859 +-0.5506508841349235 +-2.573987812060362 +0.3252445335945332 +0.41124689789039637 +0.4598121196132875 +0.496169743780398 +0.899282600314449 +0.14565761495688107 +1.7097964425336245 +-0.47086902237662864 +-0.21467264044258358 +-0.7263358193659305 +-0.22056358595308434 +-0.20937671205667663 +-0.07669742946161968 +-0.7339261682172668 +0.48212640560190434 +-0.6494041737977194 +0.39274255093944443 +1.2215620795208784 +0.5049439294977723 +-0.5158760007430456 +0.42620816607891576 +-0.8941025239610579 +-0.3786194992389138 +0.7353733693851894 +-0.18025710357320585 +-0.47091835916421665 +-0.6833002289751853 +-1.3861835368923017 +-0.18546751470731504 +-1.3738076809407287 +-1.0926561962926018 +-1.015375562988036 +0.6528201889651672 +-1.2722580639005785 +1.03782901539655 +0.5518146274468929 +0.3399684675021045 +0.1714591471207958 +-0.6098934155983466 +0.6997211886857572 +-0.7606272119825161 +-0.33052764536689117 +2.267634311912345 +-1.1010245731656958 +0.9924558226751583 +-1.952642310103916 +-2.0885998164701594 +1.2098969473029166 +-0.04644102309478104 +-0.38360295140881684 +-1.3944057069502664 +1.0758393903160817 +-0.32042113410668904 +0.8939040722879354 +-0.988109144524996 +-0.6850895628707265 +-0.39563309401998004 +0.4655422966820433 +-0.7133088799866104 +0.6898758264122878 +0.16900554883056051 +-2.2054783090810695 +1.1229003487185683 +1.1414026779918198 +-0.716027357907616 +-0.21146123420692725 +0.9050322076754216 +-1.237778218167496 +0.9290201560410583 +-0.8658437317016295 +0.5329390111324757 +-1.1947484322967021 +-0.7376982039620994 +-0.6336875342646728 +-1.6155947280316143 +-0.5897786955023514 +0.5341747134733327 +-0.5760806032184245 +-1.1681974050228643 +-1.7330725688525643 +-1.0588974439978265 +-0.08445142664132266 +0.7683557186647314 +-0.26945329264331885 +-0.21055816613460981 +-0.7395289596915877 +-1.16654950837437 +-1.0201481559142087 +-1.1524567451464258 +-1.3798586269048896 +-1.5787507110068206 +-0.2811433986477702 +0.08871384853455139 +-0.5366752616221386 +-1.0072784410657976 +0.19979319180799582 +1.713090602282254 +-0.6340169858591163 +1.4507991182241537 +-2.3183189072981465 +0.24828642302804693 +-0.3036714391627156 +0.1089996368923356 +-1.1123539988536093 +-2.216094331719037 +0.5018243114326929 +-0.2291382934886284 +2.2106977131281864 +-1.2596421373948716 +1.2118249338666554 +-0.6097525132272128 +-0.04549331870082238 +-0.34505220129753 +0.40144603072398743 +-1.2308716174970042 +-0.10308517641300315 +-0.6459037130737424 +-1.431692670946572 +0.6472412679805053 +0.6176250473319645 +-1.2011650961869753 +-0.16269440953223255 +-0.46231401995427224 +0.8253335111778735 +0.17421582519142054 +0.14521714183070517 +-0.19229146703137726 +-0.9451036755142699 +-0.12218918104792004 +-1.077874069107812 +0.12214042404938558 +0.1375581218277977 +-0.3622273403322493 +-0.12250017684374996 +-0.8395240482344362 +0.3792531507471304 +0.529462533294301 +-0.31271857997626024 +-0.7042106776491929 +1.5227344060954444 +0.07736046424575255 +0.34075544130119684 +-1.7633748159414737 +1.0655393194936198 +2.276677152293604 +0.30588477616655135 +-0.4444060227426224 +0.7414399977442822 +-1.269418820139246 +-0.42566086727293934 +-1.2574614706343972 +-1.1054903004123608 +1.3321801502925956 +-0.8209765786162079 +0.7234332394934513 +-0.20820818548766784 +0.592151919499979 +3.2170407434772894 +1.355033753780594 +-1.1195409859180647 +0.31974274571673933 +-2.258589211102037 +0.32968188203603854 +-0.716809235979197 +-0.4346072856373978 +-0.19759268024825383 +-1.349990341948865 +-0.3606009995573896 +0.0727812696896013 +0.41406382826456567 +-2.0901904746506412 +-1.069792952520425 +0.8353047296452216 +-0.14265232555098217 +0.5258033170754549 +0.16461656514457174 +-0.8513061294403697 +-1.6061801424969626 +-1.7675354290541347 +0.2055815241473689 +-0.9804967397128352 +-0.23315792517114997 +-0.5841368797523143 +-0.17408986685002428 +1.2839836528612645 +-0.9013890873244286 +1.0986441166734005 +-0.24588621372389086 +-0.27237181521784476 +-1.037494163151057 +0.2603422116358486 +0.40066721408185024 +-0.05174484667825352 +1.2134753197656714 +1.0672560904446213 +-0.2745018633145475 +1.471324771290552 +-0.9300196696184376 +-0.08526830952053531 +0.4556274563412751 +1.3717836481440102 +0.8002069540737424 +-0.17537579342761597 +-0.03788623188496518 +-1.5197844425985878 +1.0096009644836392 +0.8660938244750642 +-1.2639749550568176 +0.9729934797633257 +0.9766712659244643 +1.6031986195281254 +-0.6313076392583519 +1.1129826451654958 +-0.6060772086623376 +0.00025283746498702686 +-1.2428084375139485 +-0.3732291749040076 +0.895202554928406 +1.087113011725791 +0.013468249724925302 +0.6081778759306085 +-0.9587287465031342 +-0.016995263693190904 +0.3986497708203669 +0.2737084246385405 +0.01071305687547111 +0.9009127144297089 +0.5203242789805835 +0.925387782640567 +0.18298447390377792 +-0.4692459872799249 +0.565504186070676 +-0.05663192505143788 +-0.0535316419688841 +1.7014436966465405 +0.689495027264182 +-0.843245783045855 +0.6993693025808576 +-1.651919046005432 +0.43554814519698726 +-0.6790373350773069 +-0.7977408573108742 +0.5761376706241028 +-0.20283447076562547 +0.5416366179211013 +1.0741411186922327 +-0.5000266078297597 +-0.07885572788594457 +0.6655915252550306 +-2.233408112626572 +1.436525598341936 +-0.2638516661548222 +-2.3870001806760595 +-0.07435091369406067 +1.4163366812444627 +-0.4107411059321591 +0.40992725883565195 +0.4516722983127178 +-1.052873983471056 +-1.2349760797299336 +1.5851456609953027 +0.11928113148200159 +0.509371262010074 +1.2085508938437297 +1.583976093808063 +-1.2475034757376935 +-2.104817417821501 +-1.190230859659118 +0.9725601679975722 +-0.6499070998820405 +0.7318484661370985 +0.6212261784727499 +-0.9158201821389896 +0.09242956759142362 +-0.22290969869060243 +0.3133187203063178 +1.178866797570563 +-0.25095423340605527 +0.7134938314353065 +-0.13497030974313795 +-0.14529894843576915 +0.42284406945969344 +1.057018738720987 +-0.916082270585854 +3.321863072452028 +0.43566754992658896 +-0.8020078782280166 +0.7732348957679065 +0.5508230467167478 +-0.8551140651374262 +0.15542468812250765 +-1.9613903138039477 +-1.3393553415812538 +-0.8683712757416925 +-0.5300697221513098 +-1.8418473616807545 +0.8031209397915254 +-0.8441030528374414 +-0.3852524397752042 +-0.4294105537680321 +-1.1391483738614308 +0.49474909825582725 +-1.4947964720111702 +0.012497812035102807 +0.5122607584800077 +-0.4449881586664327 +-2.002343346527703 +-0.10657280829806828 +0.11135314783404182 +-0.24579358499539136 +0.38231932555755466 +-1.2728073488825138 +-0.4704026515137036 +0.5551442448790551 +1.0520399893298034 +1.3621566323501477 +-0.532801793983334 +0.63587184245535 +1.2840604517863654 +-0.30188552610388164 +1.694814782844542 +-1.4551627685621515 +-0.7293388278964048 +1.1756788330210606 +-0.3664528982717207 +0.2880322145541254 +-0.86067881809761 +1.1704617652324165 +-1.394816658892283 +0.33377334010642357 +0.08739007362628404 +-0.6408472695080709 +-0.19814040099971103 +-1.2019403886739128 +-0.08525754592388578 +1.54360088262733 +2.854068535004016 +-1.8681943317126166 +-1.6196119418008614 +-1.302484792597769 +0.8768638500262194 +0.0850466058939513 +-0.2067111439066743 +-0.220821692396727 +1.9752874210749385 +-0.44537181229626865 +-0.2730284253127251 +-0.9335303395873579 +2.9779548944995575 +-0.09197935458067832 +-0.1918794367667514 +-0.06945077806799203 +-1.5114302009580776 +0.4500064332839411 +-1.2938429541782683 +0.34112821570257656 +1.9873411283937255 +-1.2926882669776585 +-0.7625032875076124 +-0.9730845679601606 +0.33702868127449037 +-1.0559507710974279 +0.3879777482526854 +0.3897493918013447 +0.2957149098769265 +1.804125491919261 +2.273018545655302 +0.32459768058694494 +-0.5153364289012035 +0.9518734358930301 +0.8856874813992499 +-0.301752540079327 +1.6460441995447128 +-2.1546022346924927 +0.09562478680945474 +-0.27508501820643416 +-0.18346250803213254 +-0.6371609350097982 +0.4173545795945244 +-1.5327080640477717 +-2.9570727154362784 +0.3970366642360105 +0.199494518703341 +-0.46388337922656114 +-0.4309401174123661 +-0.8880238110692076 +-0.11066197202868495 +0.35254882918369135 +-0.49708190160306 +-2.549019302852421 +0.3994513777337403 +1.965612115728366 +-0.05949742066181313 +0.6861327788073939 +0.19516726631584386 +0.298059145922872 +0.5450030478420633 +-0.19378645600721017 +-1.6926581263117817 +-0.31630475376678024 +0.6927899171041934 +-0.3990290243794454 +-0.17522239333605405 +-0.443924054422962 +-0.9656974706433077 +-2.492329522297764 +0.22634446031496364 +1.2943380313093018 +-0.24842139071673183 +1.3536238967265761 +-0.7133688056056462 +0.4809325731666151 +0.17182399740920418 +-0.29734511831637267 +-0.34303214194832077 +-0.5055259556516044 +0.354965983396047 +-0.21680946972002177 +-0.46530757680008933 +0.42858543745156663 +0.017805275290902728 +-1.111092499048369 +-1.3588888493473903 +0.5018002318206464 +0.13665622629069252 +-0.49408732907938246 +-0.3614071351895636 +1.237191272122078 +0.014255583328500104 +-0.44474776168719143 +-0.11698413873578997 +1.0858081030583508 +0.22789294941087168 +0.24349808664797534 +-0.21530359783472253 +-0.7518844410603481 +-1.2317545233122307 +-1.703182531387335 +-0.61331308393324 +1.7929608854200494 +0.4946588476627283 +-0.5605590317179447 +1.108070295471876 +0.41046042934017823 +-0.5875716952105692 +-1.1786865821937713 +0.18249966881539031 +0.5432058157009474 +-3.2081350615511006 +0.9856690512424502 +-0.4699090598735873 +-0.7309749118471113 +-1.3268112423941325 +0.1731710333795911 +0.2828723772808437 +-1.3300382356749787 +-0.49353434685027425 +-0.5116654555142219 +-1.0605973730313645 +-0.9486629681615544 +0.7279100835469935 +0.3924097736226182 +0.5479853255662365 +0.8958435994841345 +-0.5932752667865052 +-0.07245859924226687 +-0.7080357728779031 +-0.5840001172885985 +-2.1778725952509954 +-0.4572613518147426 +-0.33719459570908805 +-2.5214048414497565 +-0.15059080696171062 +0.4161042054000349 +0.8148274334333456 +-0.6377051089775381 +-0.47067865361684097 +-0.5742333186729223 +-0.5122084662684149 +-0.6140082661738187 +-0.08716516322688124 +0.9059723761275913 +-1.2920758525877436 +-0.6299638455163852 +-1.3237084214476262 +-0.14310127722239868 +0.15641881115137118 +-0.9100544175873676 +-0.6448207227391332 +-1.0579626298492988 +-2.0704305792996482 +0.3893520085133785 +-0.667058252262615 +-0.42245937795209676 +-0.04550202367386624 +1.1572672859675484 +0.3722939510035068 +-2.063321091283162 +0.3024054484104057 +-0.700291773488686 +1.1000011171529624 +1.2052330297486284 +-2.0931058311113535 +-0.6388150683616918 +-0.42003045989914023 +0.545249743568139 +0.3653186317493472 +-0.5648922586354896 +1.056254943613555 +-0.23061556967622643 +-1.3215805895749282 +-0.4606842748307508 +0.05245629528665194 +-0.22409471222138827 +-1.6950240710531366 +-1.5660077675786535 +-1.0248358360505823 +0.6217455803580404 +-0.9172296974158916 +0.7806257474151329 +-0.5013388503289389 +-1.351374356483556 +-0.46250309228483094 +-0.07511646726764885 +0.44402805033275883 +0.09507441916555281 +-1.1218921652668277 +0.2933808729955312 +1.5418775350156795 +1.0562836643466311 +-1.2911501401093355 +-0.2803833831692364 +-0.4762480827047481 +-2.2712248181945744 +0.05988292206322643 +-1.3821569884184832 +-0.20895981470030842 +-0.03138888812217061 +1.3345443800759311 +-0.16896864310075216 +0.8412315084713184 +-0.19474410090923644 +-0.7630430883390302 +2.140675425515239 +0.400243297237176 +-0.2281817469548963 +-0.485401903499863 +-0.044603367357153756 +0.8128217088486858 +0.10070640266378544 +1.365150997178593 +-1.3882108653485594 +-1.4653684466127075 +-0.7037188651268435 +-0.429106407660411 +-0.7270871075587874 +-0.5706416318403528 +1.0624765208298113 +1.570119331151273 +-0.960472611009175 +-0.6936688924790022 +1.177767659508761 +0.5072640998459993 +0.5776662347445676 +-1.8108157860105005 +0.04958613449603996 +-0.12964171933361363 +0.14571404383605613 +-0.15660318702953038 +-1.4610084245363706 +-1.5578071186693114 +-0.5453132072475275 +-1.6035091537361383 +-0.5759211539727266 +-0.9194729623351613 +0.30504212112658863 +-0.6079451938385118 +-1.8252090130439724 +0.7473665841123117 +-0.33901442281279 +-1.4767395093731481 +0.7481392692795489 +-0.9954575496391265 +0.127108649142195 +0.21570821187519157 +-1.0181811140257322 +-1.4570002818004082 +-0.28031068408498694 +0.3903016435464338 +0.2825971071035759 +0.5280689793357782 +0.28322643002923203 +-0.640944532271325 +-0.2507057433744972 +-0.14216033506116552 +-2.0987219080393533 +-1.7133307599384815 +-0.7053598588860208 +-0.5277419564590984 +-0.3119051995931621 +-1.088819318292433 +-0.13666520591307982 +-0.5195013600654814 +-2.0052243621412993 +-0.43379215963878653 +1.3677280050523848 +-0.23644667646081483 +-0.028090436226725968 +-1.1826799863800055 +-0.9415981892058791 +-0.08695864421830124 +0.6910292804498204 +-1.6857391372569326 +-0.8671535359281468 +-0.41329378693218854 +1.321292600439497 +-0.9372222931884244 +-1.2953637475998794 +-0.05030492089702382 +-0.7141823812796749 +0.652278430437196 +0.9124618480894029 +0.24325392491968173 +0.8549237851720934 +0.46876570476903956 +-0.22626198140597678 +0.7703427676560508 +-1.4870678290323622 +0.21188714377152817 +-1.5264160418620796 +1.875228513804218 +-0.4107366179536251 +-0.48420210953000803 +-0.7298234580377781 +-1.4996904035187757 +1.1086404885114585 +0.8026891147008685 +0.17308648427467754 +-1.3626691349764588 +-0.23936651691252087 +-0.3956622608928295 +-0.16593680021699317 +-1.0606514746971754 +-2.2921539425327797 +0.7717209133794058 +0.6578152436595118 +0.26284196447293406 +1.4634586200063295 +-0.02222316290882595 +0.6879793620869371 +-0.6071774732338964 +1.0665537504681508 +0.6563429206306709 +-1.083838351019648 +1.2741097025920243 +2.478512059117868 +-0.743373612406418 +-0.08085810348022143 +-2.462354717032646 +-1.8028435233777067 +-1.9907170865273112 +-0.3485586735305523 +0.37406576574292616 +-1.0371053167045718 +-1.6490716715983 +-1.746714185776434 +-0.5438171793231474 +0.8954333636349339 +0.9911742743779106 +-2.6253065551782573 +-0.16660463301844333 +-0.9185108906859387 +2.4186770376715225 +-0.4805315790073687 +-1.2746850797561387 +-0.9904097394020842 +0.16347549287352592 +0.5372409774521764 +0.6725495997371392 +0.15313719430496164 +0.8517572712303072 +-0.4308489479164756 +1.2712943572733266 +0.2995780210341545 +0.45278339429421477 +0.13558198588419662 +-2.486177305174052 +-0.5532033617714922 +0.28841243110907155 +-0.24431353079563856 +-2.095825086449289 +1.9449312393734457 +-1.516775894557876 +-0.9660178714003314 +-0.8779248799168988 +-2.065762785271952 +-0.12843148981251878 +-0.9025401953370394 +-0.7100327866192145 +-1.7920908474227222 +0.6083921513149825 +-1.6790408953470781 +0.9192001975724085 +-0.23574865140420023 +1.1718674157200366 +-0.31989075149941393 +-1.1777719271106744 +-0.3680735362851025 +-1.194120857248142 +-0.7492328593583727 +-0.8501026373385839 +0.7659155257616421 +-0.9159775835738616 +-1.2392651522821314 +0.2462726193042814 +0.8080555981572963 +-0.8365541233768239 +-1.497932997177817 +-0.8488487100622226 +-1.399764383761647 +0.2595374322736104 +-0.7483123958960954 +0.37909263025132334 +-0.8496113611572829 +-0.6028860435770784 +0.7976352630709432 +0.12416545463085077 +0.6084107943336736 +-0.12428722083335869 +0.3970358865259217 +-2.0849970608051516 +-0.9911339306142896 +1.1847197473206639 +-0.04559776600066209 +0.3577343795766076 +0.921285491993564 +-0.3771154706181314 +-2.016287360509775 +-0.3067514504399191 +0.31898694707574937 +-0.27525715018819297 +-0.15241389906138678 +-1.1142997014791525 +0.625501100918591 +1.627829975295175 +-0.4132807524013949 +0.16682008558217387 +-0.9484678969307107 +0.4872216527275075 +-0.7530038415649103 +0.2963496677214782 +0.1650156172475833 +1.250721695308706 +0.06336871607943212 +-0.8333853634791066 +-0.9631082685778117 +-1.3066963066449604 +0.5219607640324508 +-0.6505591536316091 +-1.131074122686389 +-1.0702011114181098 +-1.3123477439438578 +-0.2632125358544848 +-0.9478088289139514 +-0.3125549951962573 +0.031062279438700574 +-0.14843426542124113 +-0.6368168913575227 +-0.7755165153832855 +-0.2540329868987584 +-1.3655604307599902 +1.5290289768563836 +-1.3755083266732422 +0.4430832418588837 +-1.4125094115444061 +-0.575418135196299 +0.2480699441210093 +-1.1004094057432479 +0.860356985962728 +-1.0890334965190145 +-1.2035710133340787 +-0.13099306413245052 +0.3327621253170542 +-2.525793974670913 +-0.09680120303824818 +-0.19954397811399308 +-0.8375183644309835 +1.2661358304529482 +0.028874527130682504 +0.5023641413659764 +0.03812048199116924 +0.243356732764951 +-0.04715551581340921 +-0.7977175365264867 +-0.02986396008242323 +0.7198338560054137 +0.4094454651383804 +-0.43066220746120365 +0.10355670942732886 +0.5331935969134488 +-0.5334667205690047 +1.0981852409260942 +1.2468829550474574 +-0.3120446675728998 +-1.654942412892756 +-1.0382960844123441 +-1.7402559428840545 +0.9194185587573303 +-0.03512614878052461 +0.7336152301394919 +1.152081520293718 +-2.158393994839072 +-1.8234223717968767 +0.7267084965293035 +0.06409557293289514 +0.49263040736312136 +-0.08672860636842157 +0.19910469694624605 +-0.4461485878778357 +0.9414140590015219 +-0.5740246034673816 +-0.4564192730810323 +-1.210974362138516 +-0.5498722938869682 +0.7066735833076894 +0.8515477430833078 +0.5359653044699326 +-0.0860278133422742 +-0.5448392347799349 +-0.8995513724266492 +-0.304198737170698 +0.2557614019628058 +-1.7626498428165047 +-0.3881848099708584 +0.3210366539832842 +-1.0711934856149403 +0.020366220643908806 +-1.6278215794603808 +0.8182846369448373 +0.551377078209017 +-0.11385643137336439 +-0.7008176871923261 +0.31631275961436667 +0.5439923572698733 +-0.9703825818808504 +-0.5254586453100896 +-0.1418054994318974 +-0.38375549877137693 +-0.6480064351906603 +-0.22932031162867694 +-0.34031433193107974 +-1.3384146079862318 +-1.3484669092198416 +-0.4842240690220444 +0.795406183512517 +0.6355540619346645 +0.19917186221097932 +0.3476913101036274 +0.6865800051893245 +1.7268222370722635 +-1.2073527634192995 +-0.5258438290969034 +-1.1203140217403562 +-1.5989654709428747 +2.5911673634274015 +0.988722049255695 +-0.3230684933315423 +-0.9346839103504466 +-0.33230701581362243 +0.10945451177812032 +-0.24549972218047286 +-0.13942668449990003 +-0.6074764736475948 +-1.5943687856388309 +0.574725714618835 +0.524807177282081 +0.4691046863913819 +0.9403586035315656 +-0.7352919378592128 +-1.4717770986191598 +-1.1554074232704332 +0.6333991828549429 +0.4511050985359627 +-1.0629098714642042 +-0.7436640980589222 +0.10729825375993096 +-0.2568070682274068 +0.3213652679120196 +0.5202585924598655 +1.7020306856820022 +-1.890535287889752 +-0.4259895958581235 +0.20945522751877937 +-1.1980240134733104 +0.6979532625066532 +-1.7030925862990833 +-0.6528091170033885 +0.35780991073529955 +-0.3691546318854974 +-0.47309259919590335 +0.7031537013022564 +0.7076889107260775 +-1.2531500026777427 +1.0466490923277245 +-1.1535235487319477 +-1.3625823983769296 +0.8641458153595551 +0.06762106107745858 +0.02972222402624705 +1.7289261054534655 +1.0074785195764624 +-2.00541876952755 +-0.47560003633156933 +0.5961720846654052 +-0.6630434248972245 +-0.10442821094510238 +-1.2264187346778037 +-0.7820355069681394 +-0.22694051407488 +0.30515790128989567 +0.009757819896865527 +-0.014944541762866193 +0.22390860853991384 +1.3238223669649245 +-0.11813332488030402 +-0.280255615913469 +-0.3822732390881708 +0.1944785968734331 +0.05198445438126292 +-0.5664788033534122 +-0.26034800597063 +-1.6479426808489308 +-1.3220137197190558 +-0.1881634568652983 +0.21102193095534466 +-1.21963500714856 +-0.18183776242976316 +-1.317418052183747 +-1.295842049962646 +-0.7350238863756289 +-0.24167945832228768 +0.139755599470887 +-2.0180222695157264 +0.0005846050464974051 +1.2366226143830736 +1.713318412562053 +-0.7954452081567077 +0.8882314680638164 +1.7871657899767048 +0.2593765300055616 +-1.270257191217519 +0.42049958132484644 +-2.1700195351381217 +-0.1790748638483784 +-1.0713936838121265 +0.32876644827490087 +-1.3247714787956337 +1.6364605249511888 +0.4367100968664205 +-1.3042197981637387 +0.8171206054593756 +-0.3771815375479596 +-1.0835691771814586 +0.3322083877304456 +0.21564088642302776 +1.6512917563914684 +-1.5835400814630616 +-1.1838523765811766 +-1.2962390392946879 +-0.8371789865658613 +-0.9941988993940014 +0.3984367192059566 +0.40512212096261335 +0.8297124357034467 +0.21325252530650168 +0.41772688884554554 +-0.84915981358114 +-0.23449882187033014 +-2.5361515905643843 +1.1323000773373593 +-0.7863670075932726 +0.21808227347546816 +0.9490679566873921 +-0.900531024385327 +0.8322235157492583 +-1.7448810152408893 +1.572137181978058 +0.477524844062886 +0.7549179563746176 +1.1044903698161783 +-0.10776174159049404 +0.40470847134582166 +1.3798280876238822 +0.23977419498854863 +-0.24705503726205538 +1.1391180748332237 +-0.5957048028612009 +1.3886283130034467 +0.48244658951476227 +-0.29586773957052787 +-1.3581437285384377 +-0.04354241520209562 +3.5632478778501993 +1.8853146270250416 +0.6599596500364152 +-0.6649493290878816 +-1.1516443807114263 +1.31635416551257 +-1.1130369448288044 +0.15681770433570008 +1.0753812928981774 +-1.1314399507346597 +-0.6326268136912789 +-0.41567783707199346 +-0.40811773600791945 +0.7876991702402487 +0.11233439407916063 +1.6229611676004918 +-1.0706746565070664 +-0.8760982592490217 +0.5385918228030676 +-0.9393458335478398 +-2.159299333026354 +0.16031833221977843 +0.014728343814164602 +-0.7460232678973372 +-1.4289926162014706 +-0.5733193737323257 +0.9615476065268915 +-1.630379906823947 +-0.449777385433024 +-0.21209047135094636 +0.39857970081974337 +-2.3965490205720634 +-1.7575364659144614 +-0.8894765781590848 +0.6977554234767904 +-0.8542834055969898 +1.0409059321192173 +-0.08463624665621898 +0.5582654070521057 +-0.301550991312976 +-0.15013544061239437 +-1.2085354627604594 +-0.02373519134888688 +-0.2356960572315609 +-0.8504710896103725 +0.66386230563097 +0.7593568560082878 +0.34316173871087474 +0.4478221726734025 +-0.564843717900352 +0.8331216713034253 +-1.367271237083117 +2.979407502611756 +1.1190008587077869 +-2.159099625352588 +0.8972862939521635 +-0.12461312266503874 +-1.5581974185809913 +-1.4153906196260926 +0.3366097029927262 +-0.2842585801419673 +-0.5822396328260045 +-1.1679741794172716 +-0.49408514223237504 +0.7750681360631211 +-0.02996592410474086 +-0.3616238743648891 +1.3431294817625952 +1.5567600490628257 +0.3160546078582821 +-0.9399500063399322 +0.9856726053050888 +-0.4056217263413337 +1.7227648515908518 +-1.0380884976183729 +-0.9131633894727688 +-1.037785834591435 +1.755234645091972 +0.12509102681796108 +0.9932082224470142 +-1.13543544313903 +1.1412444295928554 +-0.8040902643831184 +0.29138533010506906 +0.17031987368832013 +0.5912844654311283 +-0.21854396253711075 +-2.749381029481146 +0.35982914468598026 +-1.6995215539356503 +-0.8618474309571733 +0.2063329395293661 +-0.9131656352495441 +0.9070106844987944 +0.7479255787299492 +-0.997552540623617 +0.8219391329442456 +-1.1876978756984686 +-0.24979595155201317 +-0.019561766256200236 +-0.20368299024026446 +-1.4404837476414776 +1.2841338647731955 +-1.0929958038417438 +1.0566946026263961 +-0.33454243448265175 +-1.191243896247595 +-0.24426130575970745 +0.15832336839611955 +-1.4725331373597286 +0.19423139910249376 +-0.3306169038689033 +-0.927305215744065 +0.4849322312889832 +-0.820564601277947 +-1.3374865927904807 +-0.0962396314356765 +-0.44852377876711397 +-0.7337619008714876 +0.8206952810877193 +-0.3318357684333637 +0.1104807485631667 +0.8639211896097003 +0.3891335251809991 +-0.802600932317808 +-0.6873613058384025 +-0.6567434696747212 +0.3635984448317582 +-2.7582619775260566 +0.07341842750458627 +-0.8496829299740982 +0.05593577608370759 +-1.7172811034768058 +0.7803150148325588 +-0.6261721308176595 +-1.0873901862357203 +-1.2146114529254415 +-0.508222216267711 +0.9579706433498405 +-0.843954003706589 +-1.5765790179963461 +-0.766635078167746 +0.497797226915654 +0.8594698636648233 +-0.5888337764518472 +-1.3863079839282655 +2.065749621291266 +-1.5213981123310234 +-0.6249539248500215 +1.3233710198152606 +-0.2474893445956393 +-1.0945998858065593 +1.7468069477637345 +1.6974790208440949 +-2.3530459981510488 +0.6762283399533059 +-0.7530862635295341 +1.290776775935304 +-1.0036572542798254 +-0.1905280528162265 +-0.8800626387329882 +0.5454229205209716 +0.19832858660739267 +-1.591559463846585 +0.21289149580119215 +-0.6985223945442138 +0.2563597677167787 +-0.8378866687973489 +0.04718842130520465 +0.12393251836355673 +-0.9488860164935158 +-0.5412302566366006 +0.9161931466818829 +-1.1423027468355587 +-0.7483933426205971 +-0.618275101624971 +-0.7399467382768412 +-1.4052528566335387 +0.38979213095833465 +-0.9638067754647005 +-0.4663663005781761 +0.8001774340469945 +0.03372096822381607 +0.5198081792659877 +1.322114734652013 +0.37455101858512063 +-1.5824834907662908 +0.2167301066771466 +-0.735505337444645 +0.8139551663249252 +0.3657290097969004 +0.45014798651933063 +-0.4414905627383413 +0.3099969142726889 +-1.5279927772081512 +-0.32060920262851106 +0.19086137225691513 +-0.37051608900935507 +0.3779129293860948 +-0.16139700218211603 +-0.03367284943692361 +-2.1581880865586562 +0.1068107947718468 +-0.018417692301850502 +1.432669225550967 +-0.7127449150248419 +-0.21756058784484997 +0.12865989077385936 +-1.2948619245083963 +0.5281401695347729 +0.6894666010428886 +-0.25225818557535695 +0.649754413615886 +-0.9328659362568735 +0.5293867434812509 +0.6705227554031884 +-2.9161646276326714 +-0.042026113158767225 +2.407875150387752 +-1.0056711802219764 +-0.35621061304544965 +0.3671799943963122 +0.8949159139660614 +0.27617380225724275 +2.7159449561708913 +0.2626555203855548 +2.427427998397344 +-1.8436436361949917 +-2.351243694210182 +0.05021209750455971 +-0.3921002880150871 +0.7037332288832171 +-1.7864016382462353 +0.8312503158350093 +-1.207640766800524 +-0.9005519102588776 +-0.04045336367218408 +1.6359162810080203 +2.048479389059442 +0.12287795405390356 +-2.2939249370619965 +0.8203396966578937 +-0.580138629976931 +0.9494075276325562 +-0.7814962393088907 +-0.25397095982834383 +-0.7793781046162893 +0.30168342901590073 +-1.068116719492402 +0.598145397347043 +-0.5038309121435713 +0.41190782956462724 +0.11329982257828686 +-1.6777600609924228 +1.088222485648992 +0.7474633010028072 +-0.5177693742669783 +-0.38257477978995097 +0.64386432627865 +0.10425612816686619 +0.503602052480853 +0.44883369960574393 +0.09189781876337105 +-0.9867779678977429 +0.5691035684819035 +0.08089027691154838 +-1.0730799592117872 +0.6159627292687722 +0.23659153867224691 +1.3267009013461286 +-0.12377162590576359 +-0.8779443495121002 +0.3048246648407983 +0.0758267699899633 +-0.4430898456487769 +-0.4970920176962062 +0.2430579150840272 +-0.7718673786342733 +-0.22383372204267463 +0.951689901640862 +0.24100341517657015 +-1.5416724970027937 +1.7500055978003728 +0.4893931018480544 +1.1007667047934133 +1.6290954174675694 +1.2425113450389065 +-0.48451418162858334 +-0.3690491943129217 +1.0366194250172345 +-0.30237390173695133 +-1.12814598726899 +0.1570525732865643 +1.174379382396115 +0.35168836168659756 +0.23882857667339785 +0.04621795526907102 +0.5865538235964006 +-0.9419820645976578 +0.7489223378193548 +0.30202297723721017 +-0.6859587496919939 +2.265478596696637 +-0.7966742790944523 +-0.606555976762257 +0.10324887786000042 +0.7529849802758501 +1.2631466755854321 +0.23760498657974083 +-0.7996460632845526 +-0.4732740638794045 +-0.5410279987236954 +-1.5006167305699931 +-1.1913499439946067 +-1.0369415151654429 +1.2251589154811084 +-0.4267612273171211 +0.5030660576899803 +0.5970161814795646 +1.1198637121848252 +-0.7681140859364674 +0.21206433299393385 +-0.2266366680198363 +-0.0914224495820837 +0.7427750116087792 +0.39972426387013915 +-1.9905723400313828 +-1.0313556573179805 +0.22863789815390673 +-1.6622581270031753 +-1.1963720377116365 +1.1618353391678466 +-0.9181000813311989 +2.040056339534261 +-0.1217599966011715 +-0.45899298659227294 +0.9478897268462205 +-2.111128112483919 +-1.5915685871345842 +-0.5070758213425767 +0.42381863293048827 +-0.5939157140699656 +1.286271985619625 +-0.22839782330800035 +1.1413121008032048 +-0.3628874883878575 +-0.13260494470118053 +-1.2062999081073622 +-0.12234919742735222 +-1.0003462468236588 +0.4645244650012158 +-0.23983112374382437 +-0.5759951827124907 +-0.14510041947581956 +-0.9804876319824404 +-0.7826416033182262 +-1.660022457604261 +0.2563399299201878 +-0.2876774753190361 +-1.0301709905511833 +-1.4032341929147722 +-0.19840843415697265 +0.27693431146808756 +0.16312788912820364 +-0.1845788255264212 +2.6712828139130256 +-0.03595510334765181 +-1.2808121707741489 +-0.422590221670059 +0.2275558450970141 +0.166423845100375 +-1.0320070789445706 +-1.5213829939529173 +-0.58959736368923 +0.3199524147109185 +1.9887568659285153 +-0.39038899843957375 +0.4635426543347386 +-0.1883966197183137 +-0.5687597277374441 +-0.9123589351395479 +0.40473404261419754 +-1.892801299890621 +0.869457400380961 +-0.5482192359242459 +-0.0978689509947029 +-0.3642751263328745 +0.4317044832999123 +-1.2023540263550223 +-0.605960144464991 +-0.642546175123017 +1.6441562303327892 +0.7361785647102694 +-0.7885050519315134 +0.21162830070760535 +1.0575111143036977 +-0.6521064197498241 +-1.5661858883767061 +-0.2282374433693459 +1.1944275377068987 +1.0439831131128987 +-1.840975483373095 +1.2092504196741214 +-0.41322874982557123 +0.6015706849263532 +0.8223501963880886 +-1.7899456147607091 +-1.2713763591187026 +0.3879786944328981 +-1.0632975708107675 +0.36026356787698843 +2.2792058892173293 +-1.2752938140890584 +-1.903090200325068 +-1.3823057491097561 +-1.796522632596494 +-1.6055724208988695 +1.2616204812823806 +-1.0627273881242978 +0.8953727456399667 +0.9827662482161861 +-0.7742938775580835 +-0.03518322543130131 +-0.05865697422669092 +0.15121711965391188 +-0.994166724096983 +-0.8052739979627893 +0.5020860521667773 +-1.1323756675395389 +0.6128870977886972 +1.3713495336804546 +0.5939727565947236 +1.2681898731173464 +0.9431344904866239 +-0.1547287098876136 +0.6347572569052626 +-1.2132255799557157 +1.462822789167987 +-0.4037830723146584 +1.622864453944396 +0.027846384139583125 +0.8208519439676296 +-1.0448678302650856 +-2.299143828930248 +-1.1503646700874148 +-1.3063920760134728 +-0.07733962894490501 +0.46652398239864556 +-0.40870563626493 +0.35727694390673015 +-1.072625724736982 +-0.09358467172685604 +0.6074663286720187 +1.0380672179972639 +-1.0475241755667 +-2.2236777270068577 +-0.33930899811712234 +0.13082993146876948 +-0.3488198040975682 +-0.5538221065550712 +0.794921554853817 +-0.6198947977714324 +0.3643205709700993 +-1.181810068339646 +0.6428811639883445 +-0.1531007935924602 +0.7105988181333667 +-0.5610424052582695 +-1.7411147412015138 +-2.0046399115824762 +-0.8698872483901487 +-0.3537815971561089 +1.4332050229334043 +-0.16349162568549813 +-1.2154959886078762 +0.3580784225475525 +-0.9943397916887924 +-1.7269166441228696 +-0.18536597903804736 +-1.3860062930631158 +-0.6451664302390321 +-1.7815339080887738 +-0.01839115985976275 +-1.4853405334413698 +-0.47028154870058264 +0.7403503758560616 +-0.8162523157011645 +-0.4798823473759429 +0.8142688778553693 +0.013055640752185488 +-0.9059605887493304 +-0.5145498017748538 +-0.23683415310146388 +1.694335986134775 +0.2139670589524234 +-0.21638284869256713 +0.3574066218160701 +-0.18470011491586608 +-0.910972243754756 +-0.11678680393918303 +-1.7794526447452013 +-1.0118557603272689 +0.29137103002569137 +-1.4626521331559816 +-0.2080564086800033 +0.027473433342594722 +-1.401702424476833 +0.7290545474746487 +-1.5276716157782857 +-0.29642375148670563 +1.0557788049585661 +-2.1860632928964057 +0.9483887104007755 +0.3667019593528761 +0.2912026137769021 +0.23280880085370087 +2.037103942623058 +0.5599471697135849 +-0.44073486919526994 +1.918473919800438 +-1.369021374548868 +1.357655855244384 +-1.507304748312681 +-0.4248468844958976 +-0.8442950308349461 +0.47851428615535796 +-0.7421567946869745 +-1.2097128694192782 +0.7679596642821048 +1.3311762004295267 +0.18274548490805448 +-1.011424153214732 +-1.2530659405603128 +-0.5004249537932253 +-0.7462090306883007 +-0.4419393319101959 +-0.11288850926591443 +-0.1200762714726744 +0.4410651674096069 +-0.7427650880328427 +-0.34098589593531115 +-0.01763715504997157 +0.4361886528466212 +1.3614576186470588 +-0.2384131348524848 +-1.257875219223736 +1.7013068426172089 +-0.9945396499503976 +-0.22286437774043028 +-0.4351824916157052 +-1.0697021793770078 +-0.44449355423832093 +-0.14410938083737543 +-1.4319980411288373 +-2.0450448091822695 +-1.7323705246231627 +0.22466764814052814 +-0.9929363398124791 +-1.078618439144614 +-0.46214791835449304 +-0.3000240946091115 +0.20181974850847895 +1.1557554623734552 +-0.9600653828089902 +0.21437906991036032 +0.16475831244254524 +0.10430622012452218 +-0.15891835640451024 +-0.5988330456639129 +-0.924664572425478 +-0.9059891585717318 +-0.6237080498075719 +-2.039515061320368 +-0.5402078564969776 +-0.6533723149517663 +0.059750543499416386 +-2.0006119815527352 +-1.2356324249004622 +0.352068754012278 +0.682249026936741 +-0.46503779728364386 +-0.5282290306937005 +-1.785921656032224 +-1.3712670848513113 +0.21009154395167695 +-1.045365711807869 +0.6805610917025467 +1.8369004076266504 +1.515686866853454 +-2.3178847628421444 +0.6346919832927149 +-0.3317764051740858 +-1.3650662889299319 +1.121035733547873 +0.22984823199809673 +-0.955565697963394 +-0.969510464371505 +0.5655970790459957 +-0.8763757718792603 +-1.1160393286125008 +0.4191108577067013 +-0.9306040154442035 +-1.343148170125647 +-0.3689336062225982 +-0.03573287538779066 +-0.4561480122016106 +0.34440172339681796 +-0.6727999190503826 +-2.2194323474650135 +-0.5100061265929429 +1.9088198966773076 +0.045747415603164754 +-0.41308318167397995 +0.010007710334960035 +-1.2943938049474004 +0.32231639764026854 +0.6389047194162121 +-0.7459307055675729 +1.2795521524881412 +-0.6900062655399584 +-1.062956610956196 +-1.847635144245307 +0.10289765175497195 +1.0429313936363707 +0.12183848142918818 +-2.0582096879196285 +-1.2563160998919092 +-2.8030938168921713 +-0.15399425825989538 +0.7293236626194616 +-0.48921735023833907 +-0.6020400905442528 +-0.7036085598082763 +-0.2121958417075185 +-0.758657487208609 +-0.31813219720331853 +-0.9996710052948755 +0.1021950572472668 +1.9021870213264005 +-0.8182155778071376 +-0.4807572495054099 +0.384211932889458 +0.2647384789705633 +-1.892159135138419 +-0.5552075217678197 +1.3016338586065468 +1.06885785862528 +-1.0561578835470016 +-0.19248290544253654 +1.7776395182050466 +-1.9082541562150745 +1.627021246879945 +-2.5178526187000694 +-0.8355375124812834 +0.5194368938927376 +1.2779225910391698 +-0.561475494268782 +0.9928250322023768 +-0.5617969214595252 +-0.4508951721697754 +-0.6699388193445318 +-0.6964387827495008 +-0.5376797680657428 +-0.2789715866482353 +0.24731038224882052 +-0.6173999426114269 +-0.17863023785401314 +-0.9998008228690717 +-0.16178735585511886 +0.2912402084118832 +-0.24725558944824524 +0.07210100479003717 +0.6988126759520144 +1.3714596330192494 +-0.9347588606437827 +-0.5467382243301043 +0.5952441915843552 +0.7312555482467834 +0.8212127678247156 +-1.0457976342923514 +0.27464457805510334 +-1.0308945809847712 +-0.0925520546642483 +-0.3352276159313238 +1.1879447464118693 +-0.48698789032441936 +0.026849854847905114 +1.3478224637849532 +0.7124985081183862 +1.3476421574702768 +-0.6708800418501233 +0.7414669128157311 +0.10550606202833235 +1.0550356356839228 +0.4175817337638208 +-0.8740693987023469 +-0.8585787028482871 +-0.0659205631906056 +0.2155536249565434 +-0.9403186045791526 +-0.23618361443276828 +0.012498861558122132 +0.5002663470525951 +-0.36946520927549165 +1.4603134934426008 +0.6282994991649007 +-0.3367027004651365 +-1.358944471067653 +0.14211832630194976 +0.13060973517314362 +1.1595204371884473 +0.03416110632810121 +-1.9255359308445081 +-1.9187754053963735 +-1.8400672074710873 +0.7187156339146302 +-1.103392544605807 +-2.2822554027798967 +-0.5572860104110791 +0.1726975895506997 +-1.5775451063636632 +-1.0967364576630507 +-1.1782082837023538 +-1.3750462518902515 +-0.5189167710015172 +-1.263822738703791 +-1.6677230734018718 +0.26348208562683945 +0.23616585334666435 +-0.4358528001168416 +-0.8359761760133982 +0.6160778339835071 +1.043223994238776 +-1.2331177963949687 +0.7479914616439051 +-2.42195498872928 +0.7150199955976222 +0.027794178160713612 +-0.9539489375636706 +-1.2412466967369513 +2.004239804130518 +0.21265504642897987 +-0.7151193132381695 +1.4932838170578695 +-1.3669820518338527 +0.25633158637011433 +0.7547194280466083 +-1.6757663633473785 +-0.3074261400297914 +-1.0087687712394233 +-1.1842936517703122 +-1.2833882163618384 +0.30161223946177596 +0.09727219589308528 +0.9413665114033751 +0.7664290242097105 +-1.648578887544653 +0.09687993704112974 +-0.3114091761899967 +0.16619261840664445 +-1.101788415425081 +-0.4869241528144538 +-0.3081844941904411 +0.04022844723861663 +0.6441174140677366 +-1.9594828433079714 +0.610040870982901 +0.9543973702928987 +-0.6214895884142471 +-0.6750994217747 +-0.1784594536274006 +-1.4207388585643932 +1.7422549492296837 +0.4036825345501026 +0.005640794569612723 +-0.015027232321311146 +-0.5418968944917459 +0.16905355899952362 +-2.2631481112933836 +-0.07429985953340917 +-0.832222346377557 +0.7258886044330269 +-2.212896916491447 +-0.2558456180969366 +-0.4766444951092505 +-0.8197978869926268 +-0.982737154792622 +1.6601208239529148 +0.07604591853676279 +-1.5105270215593505 +-0.5201293561769396 +-0.4500567207936854 +0.71804238349813 +-1.2682175506381743 +0.9237096423021269 +-0.5170637082253913 +-0.7271938649144968 +0.7171947184822947 +-0.031222338806331185 +-0.3127161992725801 +0.6283803539618851 +0.37108064253255224 +-0.23980954335537058 +-1.4757484708789923 +0.457703537610039 +2.089489982651645 +-0.47827806612937007 +-0.45409366316232563 +-0.6169881311518404 +0.32222094794417844 +-0.5731961515336224 +-0.733958836356902 +1.6517024117149117 +-0.891995333981032 +-0.27740311206026497 +-0.6764068676769555 +-0.1148965267482539 +-0.8736742523528537 +-0.4596003604687651 +0.9222679194511274 +0.3808545767180107 +0.670932618669033 +0.8601759507031737 +-2.137803236175894 +0.3446407036102892 +-0.3273496155022917 +0.31926879266025954 +0.4504795394897513 +0.19122604277042948 +1.210161579069504 +0.11950410472953765 +0.014139862165900657 +-1.1400789063345003 +-0.8979741526985248 +-1.63239413969507 +-0.8721870916926957 +0.9990277788577653 +-0.8771482163045252 +-0.7265296184945748 +1.6057792160159314 +0.6012801999934229 +-0.05734668626395423 +2.083149844958357 +-0.6380390611149446 +0.38819504132207117 +0.17659890092968816 +0.020561319270549716 +0.28713151855168845 +0.046134093143127886 +-0.44888227277497655 +-0.13992676368940687 +1.3782128599794445 +0.6404114584396627 +-0.13874089421343683 +0.06340751077156637 +1.1516015084950266 +0.7415740282766257 +1.2963686332816806 +-0.39946743978845184 +-1.5403950933843455 +0.30563666567231446 +1.4658434461621095 +0.01735224570253291 +-2.0694982949287937 +-1.1540384397572019 +-0.0506007115643812 +0.4727914850443725 +-0.24872734482353734 +-1.0067264905906546 +-0.3445933760748916 +-0.24461938985620899 +-0.1741784872300101 +1.09048401382364 +-2.811577215344994 +1.240323114686649 +-0.013507308345303504 +0.016732234323570183 +-0.37898375095466363 +-0.2748707045596091 +0.27118404022907 +2.099309359644299 +-1.2706009128026499 +-0.3464767940627186 +-0.2933676732243083 +-0.4079450921773563 +-1.398958734377734 +-0.3555639451547934 +-0.2836662444891627 +-1.4064457318494863 +0.7741234584674677 +0.5139263154760148 +0.07667552325890459 +-0.110637984771668 +0.9186237120067864 +1.624890883302646 +0.5377291090889208 +-1.4415826647022691 +-1.1380313836815614 +0.7182881754954321 +0.8545191672690915 +0.7970173583008271 +-0.7076301175726878 +0.4180748500664957 +0.2943404208581519 +-0.7637055513169798 +0.12817992864985117 +0.8893001992360086 +0.96069346470952 +1.0799865177314423 +-1.0248165473780841 +-2.7766111098303163 +-0.34691744485563103 +-0.7032065442505019 +0.28478394203450036 +-0.6030317866285885 +-1.4564789744429019 +-0.8766062026913357 +-1.1852182128388338 +0.03860852342039742 +-3.0826679076084798 +0.0424121235627572 +-1.3850733984372352 +-1.4302099676710742 +-1.7622638322606505 +-0.9552112459750055 +-0.1880019153415771 +0.20084304935368946 +-0.21109998126852259 +1.830089501950156 +-0.8161220478622051 +-1.823355255064003 +1.0399269644499551 +0.1881276764219797 +-0.6830162471566019 +-1.1014884975153092 +1.5501637929696936 +0.17116219408814798 +1.2866572918895414 +-0.5277719318857246 +-1.1181656737816117 +-0.01071287397023546 +0.39352528585552093 +-0.3222002214251817 +-1.0127742197852894 +-0.5610819155149762 +0.19257995443577403 +-1.4121344535286147 +-1.9285134959316967 +-0.3335661191834974 +1.6171913346897542 +-0.28737007071810144 +-1.6851260097801946 +-0.39161538958426556 +0.909012480847647 +-0.8153471544330475 +-0.9790424832218033 +-1.3342033144804535 +0.0811277034422882 +0.23136697945229068 +-0.888912365645463 +-1.0546793203859188 +-1.3929113613592354 +-0.13258352923181993 +-0.48002259300969424 +-0.7188790519838365 +1.6370137038857213 +1.3005690932036875 +-1.0804423408989172 +0.7405747494058541 +-1.3715121959816947 +0.1160167802523076 +-0.6330902348238776 +0.22910025276095508 +-0.9249323013651282 +-0.6426025733414735 +-1.1808589065297603 +1.1313985104043565 +-0.4661683834653531 +0.5766690371857687 +-0.1081343239232433 +-2.642405478535496 +0.6370931473927226 +-0.36134429220341846 +1.5202401759640707 +2.086280493779057 +2.0650563899748464 +-1.2379618258197873 +0.2684798741289653 +1.2837524567017213 +0.49374752351400153 +1.6732483196344994 +0.6382352360979433 +-0.7669404591867421 +-1.3314915121140258 +0.9150201038017876 +-0.19921834967344987 +0.7700397590334774 +0.2642967077582339 +-2.916664926708947 +0.6175073877440906 +1.3064089288249325 +-0.3299857079629202 +0.6283979074637659 +-0.9713767083463335 +-0.003006348382744356 +-0.5929299300671591 +-3.3543692025073577 +-0.3255729044068847 +-1.47381298668609 +-0.15247018002560284 +-1.51724376140373 +1.1041713343474857 +0.26000744527764436 +0.039552020428223505 +-1.370326758638305 +0.2261643089973676 +0.9004148227438977 +-0.7750123198835086 +-0.061688340142468795 +-0.26022748485681174 +-0.5240787919567615 +-0.15960033071476074 +-1.441904330970349 +0.10129008378047893 +-1.504970228652604 +-0.2967038268328482 +-0.6232821537366191 +-0.935023770885235 +-1.523399488028381 +0.6217823003810254 +0.6838720800575977 +-0.6615585155775008 +-0.7165208799288265 +0.10947210721257644 +0.7974973441620953 +-1.4564531335881015 +1.5958211458195866 +-0.11674568781469813 +-1.4587948311920136 +2.1545803778054093 +0.5744650235092882 +-1.2911516235683094 +0.3846604360878888 +1.1565174308084536 +0.11462838692809135 +-1.4699920083692195 +-0.6549179442554928 +-1.4558750248949697 +-2.7308422581338734 +-2.0144693599455348 +-0.5505861868513434 +0.0034855470415915413 +-1.0476916162163554 +0.41634861982697113 +0.8612189653800806 +0.4865520940535125 +0.6261054018142126 +0.9198306192842087 +1.1554045642373834 +-0.655642635939721 +0.5555033265742271 +-1.3589049930005972 +1.2093021414916714 +0.6968574153872129 +-0.6312941859522978 +-2.1165729140460146 +-0.041606905629676755 +-0.9091328412476386 +-0.8618255151660561 +0.8016965325079719 +-0.2003951836701499 +-0.8068795367011111 +1.1042919369504263 +-1.3138022768005169 +-0.8944846541921476 +0.30675037730907295 +2.4416834370253007 +-0.4853729850721811 +1.1986756289986245 +-1.8553593591556847 +0.519017367618534 +-0.13370108171908632 +0.9553800676315027 +-0.22091755613060643 +0.06596629657140851 +0.41939642515664677 +-0.656594676824346 +0.6374318286650927 +0.668140038820131 +0.2306595724552299 +0.6894557533909634 +-0.3939735080072491 +1.0155167379065642 +0.7749568040547203 +-1.0251428496024917 +-0.49556766563513316 +0.8736816917227113 +0.3747457450874515 +-0.927068225221655 +0.770696433387897 +-1.360399850293356 +-0.18086268901003796 +-0.6129426736109153 +-0.7437971342185916 +-1.440724741676569 +-0.5441317400528987 +-0.9258710785594703 +0.7058268403784255 +-0.6326167691498684 +1.9366846341330943 +-1.217020108140362 +-0.21745659741894333 +2.964353648343711 +-1.3709593813325778 +-1.349190814759849 +0.006987818872316309 +0.35673603875134585 +-0.7160993709229032 +0.06845350323863619 +-0.6294711844982044 +0.603527294323014 +-1.084039850666679 +-0.3251908739196548 +0.702862673145339 +-0.372605767000794 +-0.16958865422667252 +0.034741180181248305 +0.017634735612116564 +-1.0629923478422767 +-0.07425412690453718 +0.16588605620191765 +-2.1119220703267345 +0.08150844106137739 +-0.17309268368482988 +1.1392607443188905 +0.17473285687014617 +-0.5609755593187612 +-0.6877213240934101 +-0.8390425641469814 +1.661275541542151 +-0.9522815491612179 +-1.3651428130088046 +0.1994795026911606 +0.15182732416533246 +1.5960169784301754 +-0.09414366362281806 +-0.8330465880932504 +0.2314281134331745 +-0.3678445144635362 +-1.9294422914893496 +0.3007822200026867 +-1.0107073706041225 +1.6590461087087593 +-1.0396883315831031 +-0.5219413363462879 +1.4970875475780185 +0.13284362384107873 +0.5877632693941384 +0.5131160856291562 +-0.24482893865788757 +-0.3559412780058726 +0.9042388929107263 +0.06176446734595048 +-0.027895870765777625 +1.0104689097711625 +-0.7917510479451202 +1.113196290891145 +0.9429202914210719 +-0.6161551807567135 +0.502003929809907 +-1.0357799841877284 +-0.5611769396238092 +0.2331115601151174 +-0.15754539781944765 +-1.0457751698907303 +-1.8342077831533266 +-0.8516583038078641 +-1.1254175196110596 +0.35420269416059225 +-1.958066171250726 +-0.3749764013181224 +0.08403144096591325 +0.6527415327098425 +-2.9162535589845895 +-0.5677188970101282 +0.11577225432104787 +-0.9065821807233782 +1.30956053847228 +0.8930403261301416 +-0.06923903675840665 +-0.39122478061319643 +1.7750045031810149 +0.5595009173898837 +0.9252421120404701 +-2.358083926017816 +-0.24704979172163646 +-0.2492994237599802 +0.10236456128506222 +1.0986908380719824 +0.03286353792207408 +-0.6557365695777332 +0.3189474584370101 +0.10486780293656284 +0.44897581624214133 +-0.2509334351687043 +1.0467530101326754 +0.5193572599199942 +-0.544184056123497 +1.3446334679697984 +0.7263577218066567 +0.4018676403158411 +0.5529455684743526 +-1.9582632410268517 +-1.0938178772609377 +1.1056768189916133 +-0.8444898002355123 +1.4012445047728956 +0.47328408540452993 +-0.15055388467367845 +0.5437468403671301 +0.7982688587823957 +-0.5693020271759562 +1.3268578686620802 +0.656351904725035 +-0.1557606369983058 +-1.6529831553889984 +0.34460766446503344 +0.7675476380847245 +-0.1197937094204504 +-0.039480725156342156 +-1.4452980776248572 +0.24196509586173487 +-0.2984074835188621 +0.3992452747741396 +0.21523185550297058 +0.5079210980824156 +0.8041634888182585 +0.1149325507265826 +-1.2226897241599464 +0.2514808707810854 +1.1088491993100211 +-0.36546415843453717 +0.640531158973919 +1.087979394963793 +-0.5563822553965629 +-0.15775207188878 +0.006200221397158562 +-0.0783737774607207 +-0.6175262004521521 +0.4437270876422006 +-0.4670746196712082 +-0.5843757191054015 +-1.8934278182618263 +-0.4813328489694604 +-0.8907227285421261 +1.036259649467289 +1.843792921843727 +-0.7624319924810284 +-0.9174607290082711 +0.03435698712640317 +-0.11384972665852994 +-1.3101053015775639 +0.1637573999888291 +-0.06101683176448239 +0.008603899931604653 +-0.8673580313584444 +-2.1168150437270175 +-0.08380987239973317 +0.23922528927489822 +-0.8159704271818852 +-2.0821978182979084 +-0.028677895186391522 +-0.48697010670248203 +-2.562331184822387 +1.2638491690159004 +-0.16322736449578204 +-0.0281475548848642 +0.19179072035962352 +-0.5115121113457611 +-1.216092581961743 +-0.37197101085161866 +-1.1228891986564684 +1.530611279935868 +-1.645293593751148 +-0.31966288913526786 +-0.3224022425207107 +0.6876822411274209 +0.8588838908835899 +1.1858781473089388 +0.21214946660153766 +-2.2777942239405977 +0.0793702492319372 +-0.9635649918497059 +-0.22811427889122537 +-1.3476682815484173 +-0.16330628035763295 +0.06688221857923565 +-0.2854520860006716 +0.00313509644922913 +-1.2422407282854009 +0.7917309242705692 +-1.0495146728759188 +-1.1364600190133456 +1.6549605133795324 +1.136662949582947 +-1.408548323742787 +-0.8020504286287846 +-0.4141973192340182 +-0.08399395786473313 +-1.4969409472035287 +-0.3650113514655534 +-1.5404277557487365 +1.3871726694086501 +-1.125068068277399 +0.43790383024794544 +1.0876860298735977 +-1.2992009746671975 +-0.7013900857207577 +-1.2600698829199635 +0.9583260506370499 +0.20250143618885236 +-0.1445613616786014 +-0.5282385889848432 +-0.05873029673618199 +-0.14979080483730775 +0.6962617761938527 +0.16438272515827557 +0.8311917265582294 +-1.1818611326916204 +-0.7450089824074639 +0.3761583533648629 +1.1846018038222124 +-1.4537038579997095 +-0.3016022731499668 +-0.7000498208578896 +-0.9794561936775553 +0.06346652314524298 +-0.3869109830073247 +1.407268581018489 +1.4388428052334346 +-1.9727458415639785 +1.81673384196293 +0.4821244332600986 +0.21334786981074738 +0.9113050050239608 +0.04715888249686487 +-0.9802718439397652 +-0.2527314263795757 +0.18033805740743886 +-0.5136936101560146 +0.44054055476975207 +-1.353539974948879 +0.040219509921977314 +-0.606337537252817 +-0.7291432691478267 +-1.2493523727071993 +0.2832688467918175 +1.1974098828140367 +0.9335277070801307 +0.5305613314103012 +-1.091650484775249 +1.0545132468827392 +0.9832868448772132 +-0.9935607567540136 +-0.6625741771928879 +-0.21629688534159539 +-0.23091487139574535 +-1.3949278994923766 +-1.4568475108202432 +-1.531860962340051 +0.5729206682833685 +0.12066840408864232 +-0.3937448246985331 +-0.08373725906458072 +1.0541631981034625 +-0.21561860211052947 +-0.8189116193542829 +-0.03476672759971988 +-1.295237630748267 +-0.472203251092988 +-1.6549359850403753 +1.2886445109728386 +1.4266248892677265 +0.3051018163779958 +-2.433864029298202 +2.805863847926351 +-0.2825074669223043 +1.2003008251425562 +0.5350895936175615 +-1.0503423150031082 +0.22214561240497938 +-0.37320095000827497 +0.9987738969820863 +-0.08844537791986672 +0.2928367997372638 +0.777418976776762 +-0.3677138078054827 +0.1501371355267377 +-1.146058131988791 +-0.4152692490452542 +0.22165199076279524 +1.5419029332151202 +0.45650772921049365 +-0.8321906327971222 +-0.10109974055272189 +2.2518275936524255 +-0.4613464737298429 +0.14765997031608352 +1.8601322797281992 +-0.4662756653722047 +-0.01775760231090287 +-1.819017822635981 +-0.26962119914745497 +0.4121141629276801 +-1.29122468385404 +0.10908690962565465 +-0.8528281823762462 +-1.1436752458033772 +-0.5561452786230205 +1.8663411590190362 +0.3858722701262194 +-0.9181987745978514 +-1.005625360355789 +-1.9020135134256293 +-0.5624527295538069 +-1.2322941519187065 +0.7415397661317503 +1.7949825023398511 +0.7325191066880591 +0.060600342128112605 +-0.4348781202983969 +-0.47628722749183094 +-0.0549715083505416 +1.7957295686966575 +-0.8609766804785224 +-1.0813345356930004 +0.23205279683122731 +0.2549945532260841 +0.5892041689311452 +-0.028450442192351683 +-1.739639707186091 +-0.12896330285598662 +-0.2945746722508282 +0.8352205173842351 +-1.295851924643467 +0.7089033702346619 +-1.3424480084758683 +-0.1304391226523049 +0.21844480682159617 +0.6347101362879037 +0.12082498122265145 +-1.5209623217353925 +0.6576733703515673 +-1.5139188066503373 +0.8898866623027515 +-0.6123912600436103 +-0.9086539564050832 +-0.30589573072444687 +-0.6937003781621187 +0.1971808588282038 +0.521980510257675 +-1.4799018638460257 +0.4592407386213434 +-1.2157649187291333 +-1.3743399477365936 +0.7336692162553451 +1.1266858187340605 +-1.1954225676474064 +-0.4386347826773802 +0.030572039578748517 +-0.7187112862933294 +-0.11447820273666419 +0.3623254396439908 +-0.31323733750910054 +-0.16041579735710326 +-0.19916989112989708 +-0.380489404546473 +-1.1350904936050843 +-1.7844172602876738 +1.7595088190424077 +-0.8157955800472592 +-1.0751216101512697 +-3.249475474093238 +-0.11290813694621908 +0.7041354308177792 +1.2778115951087965 +-0.8461191016709886 +0.1401156569341639 +0.11646534811580572 +0.08818338079999599 +1.5878983602585817 +-0.5880207730997167 +-0.08539533832547752 +-0.3967156815146442 +0.47540126768446866 +-0.11001869549660792 +0.20730885009297417 +1.5966060756116895 +1.133261480806282 +-1.2870853869720449 +-1.8688012311464524 +0.5728994862128641 +-0.04345844747734698 +0.4872834177429859 +-0.9837047989250444 +0.46252105837110324 +0.20253402724221048 +-1.437776668615327 +1.2779076897015225 +1.1107791321698044 +0.11926741757482823 +1.251574957628737 +-0.9369130394471155 +-0.8478205083391929 +-0.4234753115419799 +0.28695080422753405 +-1.7087227497545472 +-0.05247647304444236 +0.23976697539584196 +0.2812288730459196 +-0.6411108103259731 +-0.7201521215884661 +-1.6029147590962998 +0.1480987535071297 +0.48762944557647747 +0.09153263812231821 +0.440924652858367 +1.2882188115237507 +-0.17541684287397616 +-1.4016282866004621 +-0.2165117714661539 +-0.9395703242680025 +-0.3976873911538641 +-0.6899066039494114 +1.0762894402932321 +2.0464077136331174 +0.7428408951271105 +-0.8326386743534622 +-0.9780374303109143 +0.24627509571872308 +0.9239541038135999 +-2.354515366078923 +0.9265655329295563 +-0.7089370606253024 +0.8737005833666667 +-0.278099543950329 +-1.6251056700319892 +0.730815604226913 +-2.095722201631115 +-0.1766421703015406 +0.5937206885072928 +-0.03369354039446629 +0.46474344135191503 +-0.7553366505717349 +-0.2626178309746296 +-1.7268911000246325 +0.05412630147675557 +-1.001372072575218 +1.4469610090071934 +-0.0639340894959178 +0.5516264100216354 +-0.13053787012443557 +-0.10911940290423064 +-0.21524415379245773 +-1.14184755535829 +0.4776162282983648 +0.559538393049549 +0.2885629913064308 +-0.7411717175458925 +1.5234944412128337 +-0.8875691437911327 +-1.5376809442843538 +-1.4911172584249326 +-1.5689830162921743 +-0.2345010099221812 +1.4910886260743683 +0.14848741757194228 +0.6208485861098582 +-0.9626539855771553 +2.1256652702611403 +0.007860318291271207 +-0.8524878623680743 +-1.0481540238453029 +-0.4306114474122479 +-0.4370631980655601 +0.7083626341901221 +-2.432283649821194 +-0.19505793818115763 +1.2311150311423569 +0.623679159117066 +-0.4696552920099294 +-1.7948264901974995 +-1.5287394123144358 +1.3532565465590076 +-0.7796388901619321 +-2.2095151966293747 +0.0958526898418206 +-0.6442067248740477 +0.598561556089742 +-1.9941197830893458 +0.9476128483185884 +0.6499835073365386 +0.9063144240220418 +-1.5878788468376472 +1.5445700851937203 +-1.4518006564543013 +0.9798575305382231 +-0.44724761364503296 +0.5525843629539976 +-1.4964528886625175 +-0.6020519974856624 +-0.8888593024689784 +-0.37344745385030725 +-1.9465415164665434 +-0.9526900761936526 +1.8561651604964575 +1.1421371808667309 +-2.277506136036976 +-0.1807001818666239 +-0.21779984872297087 +-0.9112742729840142 +0.026414576140739526 +-1.8259751308104502 +-0.9379804563650959 +-0.007439043661947448 +1.6686780251441697 +-0.32255143456772034 +1.0252161252783374 +-0.6697749913652873 +-1.086086878243179 +-0.37763783927342076 +-0.057301466784810545 +-0.5226939064313767 +-0.7047946033277296 +-0.4634213031725821 +0.573115608490927 +1.299427055802589 +0.5546116898085908 +-2.3523856611058704 +-0.03779144614858079 +-1.7871393031008174 +-1.3151748073994143 +0.040260021433942195 +0.53078602164831 +1.175767460017178 +0.8989419795467091 +-0.7801593662451566 +0.6354153674998418 +-1.2919432944729075 +0.13646699072934482 +0.4628814829452915 +2.035289562758771 +-0.002034193191187389 +-1.412770173563923 +-0.5005155249945892 +0.7538290555231432 +-0.15027773287885735 +-0.1593932008694905 +-0.2850789256205771 +1.4274700040525314 +-0.7782385087434543 +1.7112669461937642 +-0.7002183868593574 +-0.19137686402190127 +0.09536205743381793 +-0.4225734506208435 +-0.5498989341927063 +-0.5960640468177167 +0.4430018376270618 +-0.7146644431373576 +-2.112248343978446 +0.5850847880254454 +-0.4422632477633438 +0.16646134897415205 +-1.583204324561666 +-1.5026192340867202 +-1.3791110909741633 +-2.232158301677708 +-0.10510392023123587 +0.9781492291981704 +-2.1902115567544973 +0.5775135137038445 +1.869435932142972 +-0.6991396276621802 +-1.4839547710482726 +0.7697394448905402 +-1.7225192063732893 +-0.04247608006634493 +-0.0569771039586883 +1.485489236257864 +-0.20620788202868842 +1.4760602495697872 +0.18632563945060177 +-0.19292587081685092 +0.42446160251641374 +-0.20727059503465295 +-0.609762497173177 +-0.3350543312905352 +-0.29485882165145894 +-0.5800964899028798 +1.195728310798129 +0.44211131003395565 +0.81398480316185 +0.7913655018458251 +0.14651936995117104 +0.08929500652554173 +0.4810040244900955 +-1.6334250764863696 +1.1800401274220778 +-0.8058072329306383 +-0.08585884861684784 +0.5612314886307731 +-2.1064966258655984 +1.18241130554363 +-1.5714069451900292 +-0.6193492267703844 +-1.190486337712071 +0.09818296717425568 +-0.16663622534744701 +-1.586235726090922 +-0.017394450075083556 +-1.4354995959214811 +-1.1950284520176568 +0.12807122718406988 +0.5595855161403548 +-1.3207633508258338 +0.0644263198568949 +-1.986354265395907 +0.5774728517995346 +-1.475031679014968 +-0.18179015948954697 +-0.08639964494288392 +0.23329978948760288 +0.3585136861745153 +-1.313150761585055 +-0.37661091787605805 +0.4973419323217091 +-0.6149937053205474 +-1.1897613548677182 +0.13113456490805286 +-0.9627838088715064 +0.9050025376102531 +1.300866781432874 +-0.21577737855714269 +-2.2230002533638684 +0.40533458340261364 +-0.8613472182035112 +-0.36802961556377745 +1.556865315048536 +-1.6966715348158645 +0.6073364133450517 +-0.5486516305992009 +0.25464641168063046 +-1.4970736114103929 +0.010431366983904705 +0.050684873981325096 +1.5284581761650118 +1.33443707857094 +1.0090809124202942 +0.2875633351362131 +-1.2181091508487136 +-0.5118560326299231 +0.9069819512883719 +0.9995225688507845 +-0.39905428823396316 +-1.0414137390658578 +0.029134013343068504 +0.1242209702213703 +-0.6974966604917628 +1.0402166341787429 +-1.4598964108657244 +0.5161223341195424 +-0.33857566305210407 +1.0375836167595303 +-1.2074231741515247 +-1.2987150651008326 +-0.4928338076801051 +-0.327876223600739 +-0.29703128608783935 +-1.038937369165508 +-0.23492038049467942 +-0.10036455006093285 +-0.7967333964948587 +-0.6391394891771747 +-0.7634336142411765 +-1.2056334580580406 +-0.7399589078619205 +1.156625412846026 +-0.6332473037886217 +1.287149368303167 +-0.36281504858889335 +-1.3576919745765224 +1.2572418685718787 +-0.2029129641244042 +-1.4103591513656017 +-0.30113923024100053 +0.6085354641896854 +0.35524942846392205 +-0.10582460357805189 +1.932408712141833 +0.38816716724983413 +-0.5367588852458962 +-1.0468142882712712 +-0.6786109832732925 +0.29448182514735816 +-3.043636780438897 +-0.4053788132235965 +0.7924860767989383 +0.6281454509023587 +-0.5751382361115827 +-0.004662075056424908 +-0.1707031922622208 +-1.0044250340201297 +1.2173604136431793 +-1.2480254448002905 +-0.7147562273114726 +0.04795323952083072 +0.19047863689413336 +0.5567982675081186 +0.11871626081618636 +0.5345378785213579 +0.0684689459375204 +-1.0653883417850172 +0.11016172983310074 +-0.9617496848316895 +-0.05438144939896836 +0.23097722089257366 +0.38360167987186755 +0.18562022547940343 +-2.276109852926031 +-0.5207010533292511 +-0.287266344319173 +0.26881866071327815 +0.6821904384114088 +-1.8203148682599297 +-2.611416799228609 +-0.4430042279846862 +-0.16858270542270656 +-0.43060115690757045 +-1.3184391660501955 +-0.7268904690477757 +-1.1829923014819101 +-0.24979578849507472 +-0.6774635441263221 +0.2769002549152712 +1.297784286539689 +-0.7178897208011531 +1.6284949955287094 +-0.3528459127538463 +0.10640664305109693 +-0.4534465836434587 +1.7184027393304577 +-0.22469796532548483 +-0.04317371532946607 +0.12144518472175109 +-0.1488299991336489 +-0.33351047743925233 +-0.4915471562782807 +0.9706358561181727 +-0.5977676471297282 +-0.9132164850272964 +0.700109087912856 +0.06329060306494927 +0.4015603873819422 +-0.9149345697593133 +0.840772605749555 +0.18791453264869473 +-1.8034624901999388 +0.2807455166331584 +1.0994163185490524 +0.14419540366865796 +-1.7828177299233583 +-1.3886404134436527 +-0.9936378181757314 +0.6929566806545132 +-1.0900990130784556 +-0.19244734274907327 +-0.621633360319985 +-1.378959888044851 +0.46808272015261565 +-0.16203099875108914 +-0.41595015819926173 +-0.5959667209197752 +0.5458126468229565 +1.0143942952614862 +-0.1743951759282862 +-0.2533166696084833 +0.40221700217098133 +-1.463343983801706 +-0.9069663832226552 +-0.29507098431723916 +-0.7456875458454121 +0.7690073871227928 +-0.6707040220046343 +-0.2989177878114936 +-0.4261920742215888 +-1.3168332934877982 +-0.360288748500612 +1.33248803390787 +0.4982221259551699 +1.1720475829200794 +-0.30114037626680035 +-0.977765416894781 +0.18680870724062965 +0.11978602084230161 +-2.011469994198622 +-0.8937951061560906 +1.3903246912928289 +-0.08422940385825659 +1.688142722397871 +0.4936649372554711 +-1.5622516158657844 +-0.052686300306615114 +-2.13131597161847 +-0.8449831027004446 +-0.9505737746584851 +-0.7004739879774315 +0.362319145816954 +1.3539151321984668 +-0.5255932336996932 +0.40420127563615205 +-0.01896012498329458 +1.7148613140354187 +-1.8811152207593942 +1.0520661840616583 +1.00835374142407 +-1.4698192627951538 +0.4984911010027021 +-1.1565964736200058 +0.333702304561156 +1.2454396531162597 +-0.09443359114621422 +-1.335564290496113 +-0.7599248372020617 +0.4602613257646875 +0.8881090810262631 +0.9017224174611942 +-0.6121539818215034 +1.5767675221247146 +-1.3344730673707852 +1.322967582961102 +-0.056649169381079556 +0.1440121105498643 +-1.1864610094628318 +-0.48124607955903503 +-1.14846936387521 +-1.1056297811502511 +-1.3706238901787404 +-0.20047419444399056 +-0.010196223435075202 +-0.8754743576259397 +1.221350883036168 +0.517093327077931 +-1.4619352776177814 +1.0555857820371242 +0.7626667772155785 +0.7540427780368589 +-0.6609016588212644 +0.02162646185285816 +0.8290043202009589 +-0.37857869087795804 +0.2456219034960101 +0.23040394994474273 +-0.4846783908003308 +-1.4303206025490163 +-0.4451177241021445 +-0.296315495979574 +0.02938449398483678 +-0.25404491742738505 +1.6486553677179463 +0.3019536759473401 +-0.5207766902592625 +-1.1017882316489191 +-2.2397061828657856 +-0.0696070673876238 +-0.020632285766544023 +0.8585937126182122 +-0.09006375000329393 +-0.5500986577322263 +-1.8029910388277206 +1.2793167918446147 +-1.3398529748850718 +0.5468634161766063 +-0.4889727455083073 +-2.3842540686870377 +-0.34433097484434566 +-0.14904650944729164 +-0.1920643219299434 +0.09903862752599807 +-0.03552292880973454 +-2.4272778974206872 +-0.20867328025319282 +0.24273140776686636 +0.39354300827064725 +-1.0419994994665975 +1.9929503207546284 +0.593463143225543 +0.5243523884240251 +0.28552179691815915 +-1.2747439115101507 +-0.7889465929637272 +-0.08765318835957499 +-0.8782780716686579 +-0.9463246112964029 +-0.6538864851472388 +-1.9082785899334347 +2.552233227421098 +0.041250774659824074 +0.7329734873827719 +-0.8505979447248122 +1.105204786817467 +-0.5217530482004511 +-0.23836711273886946 +-0.1906183345948253 +-0.2179936538271439 +0.01012200244220543 +-0.20382002721651746 +-1.6452547516976834 +-0.9875282621949066 +-0.24249790077417144 +-0.7910456885407356 +-0.328349221415132 +0.35385662326284184 +1.4528730563140964 +-0.6572594405622925 +1.511374902300063 +-0.8822390263268783 +-0.8657844445322564 +-1.73701556002488 +-1.0971905158757338 +-0.1704196712416656 +1.179079997449402 +0.5086514448970549 +0.4632135984309723 +0.512379412600454 +-0.7560961000932244 +0.41779308818865935 +0.4071403026153537 +0.9360524778151298 +0.2080371537548648 +-1.1124012591414714 +-0.5344770554586633 +-1.5276396449424157 +-1.1087508797598353 +0.5004922114529198 +-0.7123809902009781 +-0.06261268013946181 +1.0854374611564384 +-0.26060023242073005 +0.15780396332366192 +-0.5690937049545814 +-0.7516297466302132 +-1.4548669165908732 +-0.397139847131835 +0.2832291346464465 +1.7380448021162522 +0.7774603687999034 +0.5384117623028832 +-0.5703629813707924 +-1.202576241708606 +-1.9140380937486292 +-0.12182955925463897 +-0.7769765977265003 +0.8391785199498247 +-0.009706641159253793 +-1.5209193065956397 +-0.33100748531100527 +-0.6050899187563581 +0.37801516583232786 +1.0838797961840638 +0.8860859018357552 +0.8167304555181485 +-0.4569701982000472 +-0.23414450638010448 +0.08456469229552743 +-0.31314542562746356 +0.891932775244094 +-2.9023026111519368 +0.5383876638754227 +-0.09941737454918713 +-0.5617939027218304 +-0.0305023489554197 +-0.07166265720214884 +0.5267959226443932 +-1.526997498756762 +-1.2189299168786085 +0.31294198690024766 +-1.3049298395583016 +0.45618029052315523 +0.07365359473411259 +0.9994998307603384 +-1.148726154093095 +-1.4578855837378377 +1.8781373940782797 +0.24732529106728218 +-1.3501149504586654 +1.0304877968429917 +-0.45687854530156036 +-0.6359163694474709 +-0.6568249247355415 +-1.4204055751034175 +1.3448641722808417 +0.1830823260950475 +0.46492946804157564 +2.527593759154481 +-1.5572199389109864 +0.9168749750104448 +-1.565089835757598 +0.20675323282909686 +-0.4756348031773189 +-0.8307771932901811 +0.9060043707748411 +0.3253233930884257 +-0.6423198721124651 +-0.7698059631510906 +0.9789997279351472 +1.5157157049859875 +0.745306590922413 +-1.1430094465383789 +0.7935785047867563 +0.1610421574135661 +0.4023257957674591 +-0.7808114753492034 +-1.320430004449756 +0.16058875721562044 +-1.4309235775473401 +-0.24263374702600216 +0.3208170129800688 +-0.8219398709884063 +-0.23382828347418907 +0.5245489305616184 +-0.9342280086830683 +-0.5130904883040777 +-0.8407537063435591 +0.596297275312319 +-3.0473684435688844 +-0.8325698442356687 +-0.7934051917812307 +-0.8260650495982004 +-1.0278476102064857 +-0.32169019625857825 +1.439495947562741 +-0.2979914523461771 +-1.3628576629257119 +-1.348395345993469 +1.5811528720779464 +-0.6557728277315376 +-1.1312817048053354 +-0.8472279163592117 +0.675079726821688 +-0.5163414948441412 +-0.021361227244695052 +-0.1929062573227877 +0.3657315648265953 +-0.36029679730955705 +0.06117773857253589 +-0.7562198527694924 +0.1863504873729362 +-1.4981271793467774 +1.8165559000897578 +-0.5048110049080912 +0.8211938676973325 +-1.0605526986445935 +-0.06933898657001893 +0.265137755775302 +-1.5171354881853718 +0.3166327070538737 +-0.322379607686529 +-0.5198056938483939 +-0.14387846539100124 +-0.9127347456142317 +-1.0900510428804817 +-0.0929300241285483 +0.40134524064279464 +1.3264249180939645 +-0.5796262838474324 +0.330287220771596 +0.33913905094964025 +-0.8407450188308838 +1.7302036411578265 +0.49714360977726235 +-0.008170512358351367 +-0.15654757789846824 +-1.0107593717930172 +-0.8725899837914657 +1.4461453674099403 +-2.256287602885373 +-1.1166602868775115 +-1.5028321597085876 +-1.1940714297943256 +-1.4758084721055134 +-0.7770955529720226 +0.7776550901004162 +-1.0922699675282586 +-0.2768065385995611 +-0.5287737328756013 +-2.089970170573957 +0.19654715792260247 +1.4836950868362175 +1.3422301269999715 +1.7302180825377864 +0.6100314885766583 +-0.9874672786641797 +1.2008767516956222 +1.4874022793549955 +2.715515603980254 +-2.6023398904423 +-0.056551233368690224 +-0.31334911980421143 +0.4614229071274344 +0.3845352911699855 +1.3695314425267782 +-0.485710220490662 +0.13929493997040943 +-0.2103810855552281 +-1.1822852115045013 +-2.109627852211506 +1.7707400861753533 +0.06957651649614416 +0.7822819543842012 +-0.015600603236556876 +-0.613453222737449 +0.037128367144034446 +-0.02273785709980608 +-1.5633815617842841 +-0.6093599150092834 +0.06138458138117886 +-0.29275034535519606 +0.3362937500532457 +-0.7360573545188009 +-0.6044632324338898 +0.5309568697472467 +-1.1305832746634183 +0.8439072424104364 +0.058595235104205945 +-2.496475301341518 +-0.25631291608435 +-0.2578268967947494 +0.05557133702501171 +1.060050509375589 +-0.2587477901872881 +-0.0522732119493409 +0.025279956616611254 +-1.4334881709064762 +-1.168716604205711 +-0.3522764319323958 +0.024200186159046566 +0.11865085279433618 +-0.5689801525642927 +-0.1381591194276279 +0.041838608450123466 +-0.45608778275086065 +-0.12377541319483382 +-1.1547356645116502 +-0.22669415491618872 +-1.9126076090933348 +-2.9650736592162135 +0.8678607032925929 +-0.9353757797787722 +0.046394576488213796 +-0.01847359390611361 +-0.86334730504568 +0.37549221815888223 +0.4483895475885905 +-0.029764301849169783 +-0.3859749702344575 +0.10765003063484463 +-0.5856264075243944 +0.9820127902301927 +0.7676547221818123 +0.11748128081550913 +-0.1377630183182014 +-0.7090643998695998 +0.23357134543199098 +-0.7282511349125055 +0.4115821348902253 +0.04190376209332397 +-1.2119385088632577 +0.5333515027325112 +0.5926388251825154 +0.7586455742296204 +-0.4761664785796674 +-0.16883806450535796 +0.6376018879041222 +0.961764954101076 +-0.1760443238435498 +0.27713139960382893 +-0.3748074485720251 +1.0281029691859938 +0.9830130838462332 +1.616937163500639 +0.9046209527771849 +-1.0203371939363983 +-0.47302555036353977 +0.7283498005781732 +-0.5294000604408515 +-0.3948731461361614 +0.31438351847567436 +0.7606763047789505 +-2.090759988715677 +-1.8611000829035478 +-0.7545143369193448 +-1.691207266109225 +-0.20176928942655095 +-1.1330443123445537 +0.1929500342096141 +-1.619258391847175 +-1.3037703421092 +-0.9366475430829034 +0.03075415015128985 +0.8252809558416723 +-0.8853729876550895 +0.2715447554657882 +-1.377783741362088 +-0.35254348255855705 +-0.5266587144823349 +0.7638973968525938 +-1.7828444232862017 +0.500085070504374 +-1.5980059803906033 +1.4213864212874148 +-0.6174046135332192 +0.8569992117112957 +0.4607421357407412 +-0.786267999249157 +0.5588490041255523 +-0.5683889778910207 +0.5041457672609317 +1.021630853307196 +-0.308773848771226 +0.2960362851979556 +0.7970814599918816 +0.5708441953045098 +-1.7687865899716404 +0.47014885273114504 +-1.390549113198971 +0.3248929898459063 +0.6466611234419433 +0.4545464920543295 +1.6268704450814893 +-0.697275971364129 +-0.30773037579620366 +-1.6335144614539605 +0.054947279203898 +0.5651315901140322 +-1.1013511790787585 +-0.25511332661760505 +-1.5158053407400693 +-0.16439030504421845 +-2.1170295457955763 +0.565402384677245 +-1.5753458556119218 +0.9723645446461808 +-0.7452812784776812 +-1.4707169731900502 +-1.3117023650171198 +0.4574807910705839 +-1.6795113063873748 +-0.0858150077053238 +-0.5596332735164263 +-0.6568306630471109 +-0.7704971834905208 +0.9311068377011915 +0.4712412381903629 +0.7368103407302887 +-0.9933830929274942 +-0.15134552562087825 +0.4614922975239423 +1.2527639162375483 +-0.06690530721199364 +-1.16106892348221 +-1.235357995389731 +-1.3194159285427873 +1.0208292640843966 +-1.2175854529822467 +-0.5173431952641502 +-0.6381351911006803 +0.8848837346809875 +-0.11394463708943194 +-1.4341318710052888 +-0.4157220768393288 +-0.003910742339254786 +-0.11553444957979116 +-0.40593069140190907 +-0.3530855998322703 +0.09458930958740308 +0.9417220801966095 +-0.6288395049375399 +0.24648829919162724 +0.08044873268725328 +-0.24862853938170476 +0.38627098372065005 +-0.07718618221992578 +-0.762841926934619 +-0.6884127919961165 +-1.50098882990373 +1.1715107083129817 +0.758773893063477 +0.5187888081282658 +1.4506145658723648 +-1.3720208158056828 +-0.7240087017051069 +-0.9586614250618539 +0.17442005380737702 +0.3914457259889491 +1.4384632458971207 +0.270061982467562 +-1.6875898700119119 +-1.5901003737224924 +-0.24628193454579964 +-1.4900152514325573 +0.4113750827457282 +0.1976486792262785 +-1.87215866771435 +-0.7087330994499172 +1.5986447917441586 +0.7142422545386216 +-0.4254146333603285 +-1.5561437413060626 +-1.3524581064320813 +3.086224137464513 +-2.8072112259645037 +0.15711580403464115 +-0.19325362335072124 +0.42599665298456735 +-1.0617207972106102 +-1.1571403381943786 +-0.26595594245868176 +-1.18823698563071 +-0.36154800440667834 +0.25725597085448826 +-0.26917010128676433 +-0.497590476408843 +-0.8685717877781709 +0.46816644702848176 +0.15196615271316777 +-0.8612268640400913 +-1.8045826245429424 +-0.6012713701618343 +0.6790873163434467 +-1.7551206683969347 +-1.7559928438566803 +-0.9425623455812824 +-1.4943571390893584 +-0.6052327663890181 +0.36751997067916087 +-0.3840017683840248 +-1.382637757151524 +-0.05854716397965862 +0.26290599349132804 +-1.9669749874821725 +-0.21040970928851124 +-0.8045552411325279 +0.16028683752881995 +1.7931388394000065 +-1.1314252553893285 +0.036280813494500186 +0.8497109655062125 +-0.09531915220257384 +0.7470346469421143 +0.7107143686928078 +-0.9422873812174043 +0.26971558974547344 +0.7058059913185473 +-0.4179220902973746 +-0.43150034367224627 +-0.7115602217024287 +-0.42501479932411507 +-1.4235890274566256 +-2.316429843220857 +0.156880394887837 +-0.8214259813198929 +-0.4270281020415292 +1.2844241451680019 +0.15379433171567847 +1.0268133913816664 +0.10443144327389625 +1.1452356912735995 +0.08270394124135116 +-0.2601455993132917 +0.09694968711435609 +0.7797223636048055 +0.7268289930008472 +0.23772378351064866 +0.6183835292085454 +-0.9808224716559094 +0.29670952766961234 +-0.08254143287551047 +-1.0206237293794547 +-1.6940773778940283 +1.154868378874594 +0.9413801346744943 +-1.9432537101614769 +1.1418872840958412 +0.9867056513771693 +-0.9252808325981103 +-0.40737543711982743 +-2.1828385431819104 +1.0412740299145131 +0.11489326327671212 +-1.2814076210077074 +-0.5715159412659772 +1.484659809276309 +1.1808926159245923 +0.02423719627096438 +1.1729827094673089 +-0.19588535697587584 +-0.6086021174804288 +-0.2711090281921026 +0.2333458416163609 +0.5354194361092384 +1.15767027850335 +-0.1129436604343529 +-1.355189505111472 +0.055148921681024476 +1.975520552329442 +1.2259218502091243 +0.2289341357631367 +0.7484434507340016 +0.9904919319492864 +-0.1767617828914444 +-2.6108494305116823 +0.22936439999633929 +1.68187709574696 +-0.7357784488186089 +1.1468273823871253 +0.2583846235328432 +0.23925519895237407 +-0.6994861948249753 +0.4726079955867425 +2.9268647805121955 +-0.00991382827629611 +0.555178591227263 +-1.9736054706417783 +-1.27376881520058 +-0.7863193041996693 +0.4702182634724359 +-0.6946750936484918 +0.4731972886113678 +-0.939230774943658 +-1.7980208806111944 +0.49800686364376845 +-0.8469171476095663 +0.4370793269059212 +0.6196324512057119 +0.8037259852882771 +0.9639919688359526 +0.40491500691865656 +0.22171562961441094 +-0.8555783451265943 +1.4876609800589826 +-0.24733927533965944 +0.6404196483181417 +-1.4457647728068448 +-1.0675578072076528 +-1.2229672967131415 +-0.2453293001942472 +-1.7432997273381854 +0.5763606995858834 +-1.4698917621542806 +-0.2359136466246813 +-0.3999043303372685 +0.883660722516781 +0.9507743310934484 +0.8798201537000718 +-1.3821252728501827 +0.6816640024574853 +-0.2153452464761386 +-0.6106877625874965 +-1.6937911836468627 +0.9272941771630865 +0.13915170839131263 +1.195136113773425 +1.3301974355615678 +-0.5422909335025696 +0.42722381676879895 +0.6261084227582653 +-1.0735977176217713 +0.4795777155513896 +0.6244011176993527 +0.4497753285132884 +-0.2698024962793968 +-0.4330704957300914 +-0.7043951344480153 +-1.0975793682494088 +-0.6397188871012365 +0.7010574058423693 +0.05957394174339006 +-0.39866737462427526 +-1.5922470061026033 +-0.09817942803015797 +0.29575679496035406 +-1.182461823704034 +-1.2929970800114878 +-0.17012386043659625 +-0.015739025495248166 +1.2071150942736415 +-0.7522710257654472 +0.11982858788734252 +0.811265802247052 +1.0286820423480145 +-1.1906237329009906 +-0.9797211244210796 +0.4153651195298068 +-1.5449234707753332 +0.8672149542261796 +0.5602167498268816 +-0.3881021216684415 +0.4299549664665263 +0.09083077246757554 +-1.5173483015012248 +-0.10299843819226881 +0.3259466824449625 +-1.1973863793792052 +1.2597772623296883 +-0.6692258337935308 +2.100769405410592 +-0.6383987876579421 +0.7288572264087906 +0.3413961985776983 +0.16559917051705209 +-0.35565174447702697 +-0.8250796139000143 +0.25733299906922324 +-0.8855556299077152 +-1.0013081408125606 +0.222588219497598 +-1.0144313523147899 +-0.4519909083044866 +-1.1362234227030135 +-1.9441133060229732 +-0.5978400750813458 +-1.651436698945158 +0.7268865082751652 +0.4149997982479874 +-0.1537236746073783 +-0.5036405897543841 +0.7355646002944153 +-1.2656243419996096 +-0.6942181539545585 +-1.0419715405731997 +-1.6795452632458607 +0.3035641147906926 +-0.3783947722981099 +-1.0674575407815914 +-0.6061780890863644 +0.977762372981283 +-1.2164390854884672 +1.5653485072440305 +-0.38873526094603333 +-1.567807718273953 +-0.5620504531471695 +-0.02382326613518515 +-2.889185310183975 +-0.4595066085395619 +0.4565367086784581 +-0.586238093566043 +-2.481458566823333 +-4.629288765628514e-05 +0.3332327951568438 +-0.07223505818925878 +-0.24005288713058934 +0.8768494363157369 +-0.4870028799997523 +-0.6931372849250399 +-0.24643649933094705 +-0.5738108802126709 +0.5745194740981637 +-0.09151384475047894 +0.2916572571928455 +0.49018248006102216 +0.36326517847102324 +-0.932578325193456 +-0.9634383588162886 +-1.6457179634326953 +-0.6922346487091204 +0.24046575516990532 +-0.26686076943188364 +0.24721543814614716 +0.2433410935068147 +-0.28332202118251 +-0.5983760289458442 +-1.5019046557032685 +-2.153098255245384 +-1.474488191667656 +-0.036690922559119404 +-0.6868304381553301 +0.09349061255043195 +0.015120448905443784 +0.799889206580091 +-0.7245755133115368 +-0.4711266426065429 +-2.0763743850869743 +-0.4616512874907712 +0.48451924983385963 +0.3147963461097567 +-0.040344065229834164 +-1.2622674949373738 +-0.08515678982677927 +1.686041386870572 +-0.9194415410388961 +-0.15575973801724938 +0.786106144217328 +1.3467453546480845 +-2.0530926548446704 +1.35110081748984 +-1.8510702992326944 +0.33516246489001533 +-0.28008291674730657 +-0.4397846751823654 +-0.22211608037403152 +0.9499929966484268 +-0.41140954751241327 +-1.214783451413488 +-0.44867975715223063 +0.21633768209853138 +-0.4716685969058245 +-0.16984626144866205 +0.5307559026974367 +-0.7121789787450382 +-0.9142931250310352 +0.03859792620423319 +1.1712561681307465 +-0.13859241065163344 +-0.785113981591501 +1.5982533477218783 +-1.309682580065397 +1.1125633211656785 +0.12263112709730001 +-2.692106109979636 +1.5419165853030994 +-1.44929323530895 +-1.8543495636313791 +0.3700201575887012 +-1.158160536889976 +-1.6056258690390337 +2.0238677858667646 +0.9854270578881394 +-0.7373282425146647 +-0.11650228090299154 +1.0023919344522254 +1.6975947611931754 +-0.4527536734501653 +-0.3257488331462113 +-1.3789117296683449 +-0.8773512275530334 +-0.6032207705827685 +-0.7255730088432996 +1.3690962044533979 +-0.31189600979179066 +0.7275418782086742 +0.28453258285667654 +-0.08286911467537547 +-0.6826905874714331 +0.0793694485078153 +-0.4910089584163958 +-1.542964508770462 +-0.0564779803630841 +-2.4708446346525985 +-0.18501562071743058 +-0.06350727231655434 +-1.998568125059844 +0.2807281848567677 +0.7286948918708911 +0.2885909361565546 +-0.5764513998587237 +-0.04627937206147356 +0.7567051505548409 +-0.11182825648688219 +0.35522800549100275 +-0.3995296024956345 +0.6726836178147788 +-0.8047665356982018 +-1.608074794953116 +-0.521080390270724 +-0.7921292575623186 +0.430979406925342 +0.5435429706549625 +-2.8095182540436907 +-1.4297185593416628 +0.7367759792097397 +-0.6784961178905673 +0.5011705825497351 +-0.5462227113750269 +-1.0688204295407426 +0.2122632838027524 +0.30309967134334653 +-0.44115146739856986 +-2.8492513713626533 +-2.3339779038021335 +0.12104151183159867 +-0.4275551359822489 +-1.5125803273869889 +0.5484929022028407 +0.3338995738133935 +0.586666605405285 +-0.5298965471839951 +0.5462709694488687 +-0.9488777879824258 +-0.3270483213074797 +-0.9494878998339236 +1.0430988496018856 +-0.1472857831745118 +0.5842905956636592 +0.014204210007452034 +0.0078069551128781 +-0.21549702242920693 +1.1678239115554907 +-0.625390440660448 +1.3511021950053976 +-1.554425584840543 +-0.8271758676721596 +-0.5823899578142254 +0.9639983919713215 +0.08901643312073632 +-1.3409706670572088 +0.5964524310612603 +-0.7869381778294696 +-0.5246501927693339 +0.8389610088574786 +-0.5233624002093205 +0.6359960518946526 +0.015910999619248356 +-1.3418354767115586 +1.1269998300063016 +-0.08584077932067836 +-0.4677770373709801 +0.07180367274916688 +0.5021550598976916 +-2.0667895161792718 +-0.44819922478836555 +-0.5962871570007688 +0.132953208675807 +-0.5836532746385351 +0.7709592396699259 +1.026303271467577 +-1.2616730442996185 +1.3324247573271175 +-1.6238761471802916 +-0.715896715250673 +-1.134867149923318 +-1.416152132945864 +-1.1971297110888204 +-0.29077915089505113 +-0.6032217300898974 +1.4641946616453276 +0.2141103158047799 +0.845312782727405 +-1.2225293787156881 +-0.3208784040195324 +-0.043323194043350166 +0.26677782706942493 +-1.1804184772545505 +0.7034165931005523 +0.9263060329538959 +-1.0803739371976238 +0.4726286931326179 diff --git a/examples/autopoint/userDefinedFunction_autopoint.cpp b/examples/autopoint/userDefinedFunction_autopoint.cpp new file mode 100755 index 000000000..f0f7a734a --- /dev/null +++ b/examples/autopoint/userDefinedFunction_autopoint.cpp @@ -0,0 +1,112 @@ +// Use forward-mode automatic differentiation using Autodiff Library +// sampling from log-density equal to f(x) = x^4 -2 * x^2; +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2020-2020 Marios Papachristou +// Copyright (c) 2022-2022 Zhang zhuyan + +// Contributed and/or modified by Zhang zhuyan, as part of Google Summer of Code 2022 program. + +// Licensed under GNU LGPL.3, see LICENCE file + +#include +#include +#include +#include +#include +#include +#include + +#include "Eigen/Eigen" + +#include "ode_solvers/ode_solvers.hpp" +#include "ode_solvers/oracle_autodiff_functors.hpp" +#include "random.hpp" +#include "random/uniform_int.hpp" +#include "random/normal_distribution.hpp" +#include "random/uniform_real_distribution.hpp" +#include "random_walks/random_walks.hpp" +#include "volume/volume_sequence_of_balls.hpp" +#include "volume/volume_cooling_gaussians.hpp" +#include "volume/volume_cooling_balls.hpp" +#include "generators/known_polytope_generators.h" +#include +#include +#include "diagnostics/diagnostics.hpp" + +template +void run_main() +{ + typedef Cartesian Kernel; + typedef typename Kernel::Point Point; + typedef std::vector pts; + typedef HPolytope Hpolytope; + typedef BoostRandomNumberGenerator RandomNumberGenerator; + typedef AutoDiffFunctor::GradientFunctor NegativeGradientFunctor; + typedef AutoDiffFunctor::FunctionFunctor NegativeLogprobFunctor; + typedef LeapfrogODESolver Solver; + typedef typename Hpolytope::MT MT; + typedef typename Hpolytope::VT VT; + + AutoDiffFunctor::parameters params; + + NegativeGradientFunctor F(params); + NegativeLogprobFunctor f(params); + RandomNumberGenerator rng(1); + unsigned int dim = 2; + + HamiltonianMonteCarloWalk::parameters hmc_params(F, dim); + + Hpolytope P = generate_cube(dim, false); + + Point x0 = -0.25 * Point::all_ones(dim); + + // In the first argument put in the address of an H-Polytope + // for truncated sampling and NULL for untruncated + HamiltonianMonteCarloWalk::Walk + hmc(&P, x0, F, f, hmc_params); + std::chrono::time_point start, stop; + int n_samples = 50000; // Half will be burned + int max_actual_draws = n_samples / 2; + unsigned int min_ess = 0; + MT samples; + samples.resize(dim, max_actual_draws); + + for (int i = 0; i < n_samples - max_actual_draws; i++) { + hmc.apply(rng, 3); + } + start = std::chrono::high_resolution_clock::now(); + for (int i = 0; i < max_actual_draws; i++) { + std::cout << hmc.x.getCoefficients().transpose() << std::endl; + hmc.apply(rng, 3); + samples.col(i) = hmc.x.getCoefficients(); + } + stop = std::chrono::high_resolution_clock::now(); + long ETA = (long)std::chrono::duration_cast(stop - start).count(); + std::cerr << "total time taken " << ETA << std::endl; + std::cerr << std::endl; + print_diagnostics(samples, min_ess, std::cerr); + std::cerr << "min ess " << min_ess << "us" << std::endl; + std::cerr << "Average time per sample: " << ETA / max_actual_draws << "us" << std::endl; + std::cerr << "Average time per independent sample: " << ETA / min_ess << "us" << std::endl; + std::cerr << "Average number of reflections: " << (1.0 * hmc.solver->num_reflections) / hmc.solver->num_steps << std::endl; + std::cerr << "Step size (final): " << hmc.solver->eta << std::endl; + std::cerr << "PSRF: " << multivariate_psrf(samples) << std::endl; + std::cerr << std::endl; +} +using TT=double; +typedef Eigen::Matrix EigenMatrix; +typename autopoint::FT pdf_(const autopoint& x,const EigenMatrix& data_) { + // define your function here, + return x.pow(4).sum() - 2 * x.pow(2).sum() + (autopoint::FT)(2 * 0.795); +} + +template <> std::function::FT(const autopoint&,const EigenMatrix&)> AutoDiffFunctor::FunctionFunctor_internal::pdf=pdf_; + +int main() { + run_main(); + + return 0; +} diff --git a/examples/autopoint/userDefinedFunction_manual_gradient.cpp b/examples/autopoint/userDefinedFunction_manual_gradient.cpp new file mode 100644 index 000000000..5224b3759 --- /dev/null +++ b/examples/autopoint/userDefinedFunction_manual_gradient.cpp @@ -0,0 +1,155 @@ +// Use manual gradient function in existing sampling method +// sampling from log-density equal to f(x) = x^4 -2 * x^2; + +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2020-2020 Marios Papachristou +// Copyright (c) 2022-2022 Zhang zhuyan + +// Licensed under GNU LGPL.3, see LICENCE file + +#include +#include +#include +#include +#include +#include +#include + +#include "Eigen/Eigen" + +#include "ode_solvers/ode_solvers.hpp" +#include "ode_solvers/oracle_autodiff_functors.hpp" +#include "random.hpp" +#include "random/uniform_int.hpp" +#include "random/normal_distribution.hpp" +#include "random/uniform_real_distribution.hpp" +#include "random_walks/random_walks.hpp" +#include "volume/volume_sequence_of_balls.hpp" +#include "volume/volume_cooling_gaussians.hpp" +#include "volume/volume_cooling_balls.hpp" +#include "generators/known_polytope_generators.h" +#include "diagnostics/diagnostics.hpp" + +struct CustomFunctor { + + template < + typename NT> + struct parameters { + unsigned int order; + NT L; // Lipschitz constant for gradient + NT m; // Strong convexity constant + NT kappa; // Condition number + + parameters() : order(2), L(4), m(4), kappa(1){}; + }; + + template < + typename Point> + struct GradientFunctor { + typedef typename Point::FT NT; + typedef std::vector pts; + + parameters ¶ms; + + GradientFunctor(parameters ¶ms_) : params(params_){}; + + // The index i represents the state vector index + Point operator()(unsigned int const &i, pts const &xs, NT const &t) const { + if (i == params.order - 1) { + auto temp = xs[0].getCoefficients().array(); + auto result = -4 * temp.pow(3) + 4 * temp; + Point y(result); + return y; + } + else { + return xs[i + 1]; // returns derivative + } + } + }; + + template < + typename Point> + struct FunctionFunctor { + typedef typename Point::FT NT; + + parameters ¶ms; + + FunctionFunctor(parameters ¶ms_) : params(params_){}; + + // The index i represents the state vector index + NT operator()(Point const &x) const { + auto temp = x.getCoefficients().array(); + NT y = temp.pow(4).sum() - 2 * temp.pow(2).sum() + 2 * 0.795; + return y; + } + }; +}; + +template +void run_main() { + typedef Cartesian Kernel; + typedef typename Kernel::Point Point; + typedef std::vector pts; + typedef HPolytope Hpolytope; + typedef BoostRandomNumberGenerator RandomNumberGenerator; + typedef CustomFunctor::GradientFunctor NegativeGradientFunctor; + typedef CustomFunctor::FunctionFunctor NegativeLogprobFunctor; + typedef LeapfrogODESolver Solver; + + typedef typename Hpolytope::MT MT; + typedef typename Hpolytope::VT VT; + CustomFunctor::parameters params; + + NegativeGradientFunctor F(params); + NegativeLogprobFunctor f(params); + + RandomNumberGenerator rng(1); + unsigned int dim = 2; + + HamiltonianMonteCarloWalk::parameters hmc_params(F, dim); + + Hpolytope P = generate_cube(dim, false); + + Point x0 = -0.25 * Point::all_ones(dim); + + // In the first argument put in the address of an H-Polytope + // for truncated sampling and NULL for untruncated + HamiltonianMonteCarloWalk::Walk + hmc(&P, x0, F, f, hmc_params); + std::chrono::time_point start, stop; + + int n_samples = 50000; // Half will be burned + int max_actual_draws = n_samples / 2; + unsigned int min_ess = 0; + MT samples; + samples.resize(dim, max_actual_draws); + + for (int i = 0; i < n_samples - max_actual_draws; i++) { + hmc.apply(rng, 3); + } + start = std::chrono::high_resolution_clock::now(); + for (int i = 0; i < max_actual_draws; i++) { + std::cout << hmc.x.getCoefficients().transpose() << std::endl; + hmc.apply(rng, 3); + samples.col(i) = hmc.x.getCoefficients(); + } + stop = std::chrono::high_resolution_clock::now(); + long ETA = (long)std::chrono::duration_cast(stop - start).count(); + std::cerr << "total time taken " << ETA << std::endl; + std::cerr << std::endl; + print_diagnostics(samples, min_ess, std::cerr); + std::cerr << "min ess " << min_ess << "us" << std::endl; + std::cerr << "Average time per sample: " << ETA / max_actual_draws << "us" << std::endl; + std::cerr << "Average time per independent sample: " << ETA / min_ess << "us" << std::endl; + std::cerr << "Average number of reflections: " << (1.0 * hmc.solver->num_reflections) / hmc.solver->num_steps << std::endl; + std::cerr << "Step size (final): " << hmc.solver->eta << std::endl; + std::cerr << "PSRF: " << multivariate_psrf(samples) << std::endl; +} + +int main() { + run_main(); + return 0; +} diff --git a/examples/correlation_matrices/CMakeLists.txt b/examples/correlation_matrices/CMakeLists.txt index 7871ba5fa..bfc4b513c 100644 --- a/examples/correlation_matrices/CMakeLists.txt +++ b/examples/correlation_matrices/CMakeLists.txt @@ -62,6 +62,16 @@ else() endif(DISABLE_NLP_ORACLES) +option(BUILTIN_AUTODIFF "Use autodiff from ../external" OFF) +include("../../external/cmake-files/Autodiff.cmake") +GetAutodiff() +if (BUILTIN_AUTODIFF) + include_directories (BEFORE ../../external/_deps/Autodiff) +else () + include_directories(BEFORE /usr/local/include) +endif(BUILTIN_AUTODIFF) +add_definitions(${CMAKE_CXX_FLAGS} "-std=c++17") #enable the c++17 support needed by autodiff + include("../../external/cmake-files/Eigen.cmake") GetEigen() @@ -125,7 +135,6 @@ else () add_compile_definitions("EIGEN_NO_DEBUG") endif () - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") diff --git a/examples/count-linear-extensions-using-hpolytope/CMakeLists.txt b/examples/count-linear-extensions-using-hpolytope/CMakeLists.txt index d42d2b7a8..f3e66b634 100644 --- a/examples/count-linear-extensions-using-hpolytope/CMakeLists.txt +++ b/examples/count-linear-extensions-using-hpolytope/CMakeLists.txt @@ -98,8 +98,6 @@ else () add_compile_definitions("EIGEN_NO_DEBUG") endif () - - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") diff --git a/examples/crhmc_prepare/CMakeLists.txt b/examples/crhmc_prepare/CMakeLists.txt index 6bdf831b2..3575c4a46 100644 --- a/examples/crhmc_prepare/CMakeLists.txt +++ b/examples/crhmc_prepare/CMakeLists.txt @@ -76,52 +76,42 @@ GetLPSolve() include("../../external/cmake-files/QD.cmake") GetQD() -# Find lpsolve library -find_library(LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve) - -if (NOT LP_SOLVE) - message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") -else () - - message(STATUS "Library lp_solve found: ${LP_SOLVE}") - set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") - - if (USE_MKL) - find_library(BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib) - find_library(GFORTRAN NAME libgfortran.dylib PATHS /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10) - find_library(LAPACK NAME liblapack.dylib PATHS /usr/lib) - find_library(OPENMP NAME libiomp5.dylib PATHS /opt/intel/oneapi/compiler/2021.1.1/mac/compiler/lib) - - include_directories (BEFORE ${MKLROOT}/include) - set(PROJECT_LIBS ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN_LIBRARIES}) - set(MKL_LINK "-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") - add_definitions(-DEIGEN_USE_MKL_ALL) - else() - set(MKL_LINK "") - endif(USE_MKL) +set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") + +if (USE_MKL) + find_library(BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib) + find_library(GFORTRAN NAME libgfortran.dylib PATHS /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10) + find_library(LAPACK NAME liblapack.dylib PATHS /usr/lib) + find_library(OPENMP NAME libiomp5.dylib PATHS /opt/intel/oneapi/compiler/2021.1.1/mac/compiler/lib) + + include_directories (BEFORE ${MKLROOT}/include) + set(PROJECT_LIBS ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN_LIBRARIES}) + set(MKL_LINK "-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") + add_definitions(-DEIGEN_USE_MKL_ALL) +else() + set(MKL_LINK "") +endif(USE_MKL) - include_directories (BEFORE ../../external) - include_directories (BEFORE ../../external/minimum_ellipsoid) - include_directories (BEFORE ../../include/) +include_directories (BEFORE ../../external) +include_directories (BEFORE ../../external/minimum_ellipsoid) +include_directories (BEFORE ../../include/) - # for Eigen - if (${CMAKE_VERSION} VERSION_LESS "3.12.0") - add_compile_options(-D "EIGEN_NO_DEBUG") - else () - add_compile_definitions("EIGEN_NO_DEBUG") - endif () +# for Eigen +if (${CMAKE_VERSION} VERSION_LESS "3.12.0") + add_compile_options(-D "EIGEN_NO_DEBUG") +else () + add_compile_definitions("EIGEN_NO_DEBUG") +endif () - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard - #add_definitions(${CMAKE_CXX_FLAGS} "-g") # enable debuger - set(ADDITIONAL_FLAGS "-march=native -DSIMD_LEN=0 -DTIME_KEEPING") - add_definitions(${CMAKE_CXX_FLAGS} "-O3 " ${ADDITIONAL_FLAGS}) # optimization of the compiler - #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") +#add_definitions(${CMAKE_CXX_FLAGS} "-g") # enable debuger +set(ADDITIONAL_FLAGS "-march=native -DSIMD_LEN=0 -DTIME_KEEPING") +add_definitions(${CMAKE_CXX_FLAGS} "-O3 " ${ADDITIONAL_FLAGS}) # optimization of the compiler +#add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") - add_executable (crhmc_prepare crhmc_prepare.cpp) - TARGET_LINK_LIBRARIES(crhmc_prepare ${QD_LIB} ${MKL_LINK} ${LP_SOLVE}) +add_executable (crhmc_prepare crhmc_prepare.cpp ) +TARGET_LINK_LIBRARIES(crhmc_prepare QD_LIB ${MKL_LINK}) -endif() diff --git a/examples/crhmc_sampling/.gitignore b/examples/crhmc_sampling/.gitignore index 5ba563ce6..60b43389a 100644 --- a/examples/crhmc_sampling/.gitignore +++ b/examples/crhmc_sampling/.gitignore @@ -1,3 +1,7 @@ crhmc_sampling +crhmc_sample_sparse samples.txt +CRHMC_SIMD_* +sampling_functions +simple_crhmc libQD_LIB.a diff --git a/examples/crhmc_sampling/CMakeLists.txt b/examples/crhmc_sampling/CMakeLists.txt index bb206ea49..91fe46a7f 100644 --- a/examples/crhmc_sampling/CMakeLists.txt +++ b/examples/crhmc_sampling/CMakeLists.txt @@ -114,15 +114,16 @@ else () add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard - #add_definitions(${CMAKE_CXX_FLAGS} "-g") # enable debuger set(ADDITIONAL_FLAGS "-march=native -DSIMD_LEN=0 -DTIME_KEEPING") - add_definitions(${CMAKE_CXX_FLAGS} "-O3 " ${ADDITIONAL_FLAGS}) # optimization of the compiler + add_definitions(${CMAKE_CXX_FLAGS} "-O3 -DTIME_KEEPING" ${ADDITIONAL_FLAGS}) # optimization of the compiler #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") - add_executable (crhmc_sampling crhmc_sampling.cpp) - TARGET_LINK_LIBRARIES(crhmc_sampling ${QD_LIB} ${MKL_LINK} ${LP_SOLVE}) + add_executable (sampling_functions sampling_functions.cpp) + TARGET_LINK_LIBRARIES(sampling_functions QD_LIB ${MKL_LINK} ${LP_SOLVE}) + add_executable (simple_crhmc simple_crhmc.cpp) + TARGET_LINK_LIBRARIES(simple_crhmc QD_LIB ${MKL_LINK} ${LP_SOLVE}) endif() diff --git a/examples/crhmc_sampling/README.md b/examples/crhmc_sampling/README.md index 38070b2d3..e70ada760 100644 --- a/examples/crhmc_sampling/README.md +++ b/examples/crhmc_sampling/README.md @@ -11,11 +11,16 @@ Build the example by running the following commands in this directory. cmake . -DLP_SOLVE=_PATH_TO_LIB_FILE make ``` -You have to specify the path to liblpsolve55.so/dll/dylib. +You have to specify the path to liblpsolve55.so. For example: -DLP_SOLVE=/usr/lib/lpsolve/liblpsolve55.so ## Running: ```bash - ./crhmc_sampling >samples.txt - python3 ../python_utilities/plot_samples.py -#include -#include -#include -#include -#include -#include - -#include "Eigen/Eigen" -#include "cartesian_geom/cartesian_kernel.h" -#include "diagnostics/multivariate_psrf.hpp" -#include "ode_solvers/ode_solvers.hpp" -#include "preprocess/crhmc/crhmc_input.h" -#include "preprocess/crhmc/crhmc_problem.h" -#include "random.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_int.hpp" -#include "random/uniform_real_distribution.hpp" -#include "random_walks/random_walks.hpp" -#include "ode_solvers/oracle_functors.hpp" - -template -void run_main(int n_samples = 10000, int n_burns = -1, int dimension = 2, - int walk_length = 1, int burn_steps = 1) { - using Kernel = Cartesian; - using Point = typename Kernel::Point; - using MT = Eigen::Matrix; - using VT = Eigen::Matrix; - using RandomNumberGenerator = BoostRandomNumberGenerator; - using Func = GaussianFunctor::FunctionFunctor; - using Grad = GaussianFunctor::GradientFunctor; - using Hess = GaussianFunctor::HessianFunctor; - using func_params = GaussianFunctor::parameters; - using Input = crhmc_input; - using CrhmcProblem = crhmc_problem; - using Solver = ImplicitMidpointODESolver; - using Opts = opts; - using Hpolytope = HPolytope; - - func_params params = func_params(Point(dimension), 4, 1); - Func f(params); - Grad g(params); - Hess h(params); - if (n_burns == -1) { - n_burns = n_samples / 2; - } - RandomNumberGenerator rng(1); - unsigned int dim = dimension; - Opts options; - - CRHMCWalk::parameters crhmc_params(g, dim, options); - Input input = Input(dim, f, g, h); - input.lb = -VT::Ones(dim); - input.ub = VT::Ones(dim); - CrhmcProblem P = CrhmcProblem(input, options); - P.print(); - Point x0 = Point(P.center); - crhmc_params.eta = 0.2; - crhmc_params.momentum = 0.8; - CRHMCWalk::Walk - crhmc(P, x0, g, f, crhmc_params); - MT samples = MT(dim, n_samples - n_burns); -#ifdef TIME_KEEPING - std::chrono::time_point start, end; - start = std::chrono::high_resolution_clock::now(); -#endif -#ifdef TIME_KEEPING - std::chrono::time_point start_file, - end_file; - std::chrono::duration total_time_file = - std::chrono::duration::zero(); -#endif - int j = 0; - for (int i = 0; i < n_samples; i++) { - if (i % 1000 == 0) { - std::cerr << i << " out of " << n_samples << "\n"; - } - for (int k = 0; k < burn_steps; k++) { - crhmc.apply(rng, walk_length, true); - } -#ifdef TIME_KEEPING - start_file = std::chrono::high_resolution_clock::now(); -#endif - if (i >= n_burns) { - VT sample = crhmc.getPoint().getCoefficients(); - samples.col(j) = VT(sample); - j++; - } -#ifdef TIME_KEEPING - end_file = std::chrono::high_resolution_clock::now(); - total_time_file += end_file - start_file; -#endif - } - std::cerr << "\n"; -#ifdef TIME_KEEPING - end = std::chrono::high_resolution_clock::now(); - std::chrono::duration total_time = end - start; - std::cerr << "Total time: " << total_time.count() << "\n"; - crhmc.print_timing_information(); -#endif - - std::cerr << "Step size (final): " << crhmc.solver->eta << std::endl; - std::cerr << "Discard Ratio: " << crhmc.discard_ratio << std::endl; - std::cerr << "Average Acceptance Probability: " - << crhmc.average_acceptance_prob << std::endl; - std::cerr << "PSRF: " << multivariate_psrf(samples) << std::endl; -#ifdef TIME_KEEPING - start_file = std::chrono::high_resolution_clock::now(); -#endif - std::cerr << "Writing samples in a file \n"; - std::cout << samples.transpose() << std::endl; -#ifdef TIME_KEEPING - end_file = std::chrono::high_resolution_clock::now(); - total_time_file += end_file - start_file; - std::cerr << "Time for writing the file: " << total_time_file.count() << "\n"; -#endif -} - -int main(int argc, char *argv[]) { - std::cerr << "Example Usage: ./crhmc_sampling n_sample initial_burns " - "dimension ode_steps steps_bettween_samples\n"; - std::cerr << "Example Usage: ./crhmc_sampling 10000 5000 " - "2 1 1\n"; - if (argc == 1) - run_main(); - else if (argc == 2) - run_main(atoi(argv[1])); - else if (argc == 3) - run_main(atoi(argv[1]), atoi(argv[2])); - else if (argc == 4) - run_main(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); - else if (argc == 5) - run_main(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), - atoi(argv[4])); - return 0; -} diff --git a/examples/crhmc_sampling/data/afiro.mm b/examples/crhmc_sampling/data/afiro.mm new file mode 100644 index 000000000..28d2ef31c --- /dev/null +++ b/examples/crhmc_sampling/data/afiro.mm @@ -0,0 +1,112 @@ +%%MatrixMarket matrix coordinate real general +% Generated 25-Sep-2022 +27 52 109 +3 1 1 +4 2 1 +7 3 1 +8 4 1 +9 5 1 +10 6 1 +13 7 1 +14 8 1 +17 9 1 +18 10 1 +19 11 1 +20 12 1 +21 13 1 +22 14 1 +23 15 1 +24 16 1 +25 17 1 +26 18 1 +27 19 1 +1 20 -1 +2 20 -1.06 +3 20 1 +24 20 0.301 +1 21 1 +4 21 -1 +1 22 1 +22 22 -1 +2 23 1 +26 23 1 +5 24 -1 +6 24 -1.06 +7 24 1 +25 24 0.301 +5 25 -1 +6 25 -1.06 +8 25 1 +25 25 0.313 +5 26 -1 +6 26 -0.96 +9 26 1 +25 26 0.313 +5 27 -1 +6 27 -0.86 +10 27 1 +25 27 0.326 +7 28 -1 +21 28 2.364 +8 29 -1 +21 29 2.386 +9 30 -1 +21 30 2.408 +10 31 -1 +21 31 2.429 +4 32 1.4 +5 32 1 +5 33 1 +23 33 -1 +6 34 1 +27 34 1 +11 35 -1 +12 35 -0.43 +13 35 1 +22 35 0.109 +11 36 1 +14 36 -1 +11 37 1 +24 37 -1 +11 38 1 +21 38 -1 +12 39 1 +26 39 1 +15 40 -0.43 +16 40 1 +17 40 1 +23 40 0.109 +15 41 -0.43 +16 41 1 +18 41 1 +23 41 0.108 +15 42 -0.39 +16 42 1 +19 42 1 +23 42 0.108 +15 43 -0.37 +16 43 1 +20 43 1 +23 43 0.107 +17 44 -1 +21 44 2.191 +18 45 -1 +21 45 2.219 +19 46 -1 +21 46 2.249 +20 47 -1 +21 47 2.279 +14 48 1.4 +16 48 -1 +16 49 1 +25 49 -1 +15 50 1 +27 50 1 +16 51 1 +3 52 80 +7 52 80 +13 52 500 +16 52 44 +17 52 500 +26 52 310 +27 52 300 diff --git a/examples/crhmc_sampling/data/afiro_bounds.mm b/examples/crhmc_sampling/data/afiro_bounds.mm new file mode 100644 index 000000000..7041a15ef --- /dev/null +++ b/examples/crhmc_sampling/data/afiro_bounds.mm @@ -0,0 +1,54 @@ +%%MatrixMarket matrix coordinate real general +% Generated 25-Sep-2022 +51 2 51 +1 2 1000000000 +2 2 1000000000 +3 2 1000000000 +4 2 1000000000 +5 2 1000000000 +6 2 1000000000 +7 2 1000000000 +8 2 1000000000 +9 2 1000000000 +10 2 1000000000 +11 2 1000000000 +12 2 1000000000 +13 2 1000000000 +14 2 1000000000 +15 2 1000000000 +16 2 1000000000 +17 2 1000000000 +18 2 1000000000 +19 2 1000000000 +20 2 1000000000 +21 2 1000000000 +22 2 1000000000 +23 2 1000000000 +24 2 1000000000 +25 2 1000000000 +26 2 1000000000 +27 2 1000000000 +28 2 1000000000 +29 2 1000000000 +30 2 1000000000 +31 2 1000000000 +32 2 1000000000 +33 2 1000000000 +34 2 1000000000 +35 2 1000000000 +36 2 1000000000 +37 2 1000000000 +38 2 1000000000 +39 2 1000000000 +40 2 1000000000 +41 2 1000000000 +42 2 1000000000 +43 2 1000000000 +44 2 1000000000 +45 2 1000000000 +46 2 1000000000 +47 2 1000000000 +48 2 1000000000 +49 2 1000000000 +50 2 1000000000 +51 2 1000000000 diff --git a/examples/crhmc_sampling/data/cube2d.jpg b/examples/crhmc_sampling/data/cube2d.jpg new file mode 100644 index 000000000..63e7c2b7b Binary files /dev/null and b/examples/crhmc_sampling/data/cube2d.jpg differ diff --git a/examples/crhmc_sampling/data/simplex2d.jpg b/examples/crhmc_sampling/data/simplex2d.jpg new file mode 100644 index 000000000..6bc2eaefb Binary files /dev/null and b/examples/crhmc_sampling/data/simplex2d.jpg differ diff --git a/examples/crhmc_sampling/data/simplex3.mm b/examples/crhmc_sampling/data/simplex3.mm new file mode 100644 index 000000000..ef342e474 --- /dev/null +++ b/examples/crhmc_sampling/data/simplex3.mm @@ -0,0 +1,7 @@ +%%MatrixMarket matrix coordinate real general +% Generated 28-Sep-2022 +1 4 4 +1 1 1 +1 2 1 +1 3 1 +1 4 1 diff --git a/examples/crhmc_sampling/data/simplex3_bounds.mm b/examples/crhmc_sampling/data/simplex3_bounds.mm new file mode 100644 index 000000000..2438aa676 --- /dev/null +++ b/examples/crhmc_sampling/data/simplex3_bounds.mm @@ -0,0 +1,6 @@ +%%MatrixMarket matrix coordinate real general +% Generated 28-Sep-2022 +3 2 3 +1 2 1000000000 +2 2 1000000000 +3 2 1000000000 diff --git a/examples/crhmc_sampling/helper_functions.hpp b/examples/crhmc_sampling/helper_functions.hpp new file mode 100644 index 000000000..7f92f925e --- /dev/null +++ b/examples/crhmc_sampling/helper_functions.hpp @@ -0,0 +1,61 @@ +#ifndef HELPER_FUNCTIONS_HPP +#define HELPER_FUNCTIONS_HPP +#include "diagnostics/diagnostics.hpp" +#include + +inline bool exists_check(const std::string &name) { + std::ifstream f(name.c_str()); + return f.good(); +} +/*Problem on the form X=[A|b] bounds=[lb|ub] */ +template< typename SpMat, typename VT> +void load_crhmc_problem(SpMat &A, VT &b, VT &lb, VT &ub, int &dimension, + std::string problem_name) { + { + std::string fileName("./data/"); + fileName.append(problem_name); + fileName.append(".mm"); + if(!exists_check(fileName)){ + std::cerr<<"Problem does not exist.\n"; + exit(1);} + SpMat X; + loadMarket(X, fileName); + int m = X.rows(); + dimension = X.cols() - 1; + A = X.leftCols(dimension); + b = VT(X.col(dimension)); + } + { + std::string fileName("./data/"); + fileName.append(problem_name); + fileName.append("_bounds.mm"); + if(!exists_check(fileName)){ + std::cerr<<"Problem does not exist.\n"; + exit(1);} + SpMat bounds; + loadMarket(bounds, fileName); + lb = VT(bounds.col(0)); + ub = VT(bounds.col(1)); + } +} +template +NT max_interval_psrf(MT &samples) { + NT max_psrf = NT(0); + VT intv_psrf = interval_psrf(samples); + unsigned int d = intv_psrf.rows(); + for (unsigned int i = 0; i < d; i++) { + if (intv_psrf(i) > max_psrf) + max_psrf = intv_psrf(i); + } + return max_psrf; +} +template +void diagnose(MT &samples, StreamType &stream) { + unsigned int min_ess = 0; + print_diagnostics(samples, min_ess, stream); + NT max_psrf = max_interval_psrf(samples); + stream << "max_psrf: " << max_psrf << std::endl; + stream << "min ess " << min_ess << std::endl; +} + +#endif diff --git a/examples/crhmc_sampling/sampling_functions.cpp b/examples/crhmc_sampling/sampling_functions.cpp new file mode 100644 index 000000000..61242b253 --- /dev/null +++ b/examples/crhmc_sampling/sampling_functions.cpp @@ -0,0 +1,143 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2022-2022 Ioannis Iakovidis + +// Contributed and/or modified by Ioannis Iakovidis, as part of Google Summer of +// Code 2022 program. + +// Licensed under GNU LGPL.3, see LICENCE file + +// References +// Yunbum Kook, Yin Tat Lee, Ruoqi Shen, Santosh S. Vempala. "Sampling with +// Riemannian Hamiltonian +// Monte Carlo in a Constrained Space" +#include "Eigen/Eigen" +#include "cartesian_geom/cartesian_kernel.h" +#include "volume/sampling_policies.hpp" +#include "ode_solvers/ode_solvers.hpp" +#include "preprocess/crhmc/crhmc_input.h" +#include "preprocess/crhmc/crhmc_problem.h" +#include "sampling/random_point_generators.hpp" +#include "sampling/sampling.hpp" +#include "misc/misc.h" +#include "random.hpp" +#include +#include "random_walks/random_walks.hpp" +#include "generators/known_polytope_generators.h" +#include "helper_functions.hpp" +using NT = double; +using Kernel = Cartesian; +using Point = typename Kernel::Point; +using Func = GaussianFunctor::FunctionFunctor; +using Grad = GaussianFunctor::GradientFunctor; +using Hess = GaussianFunctor::HessianFunctor; +using PolytopeType = HPolytope; +using MT = PolytopeType::MT; +using VT = Eigen::Matrix; +using func_params = GaussianFunctor::parameters; +using RNG = BoostRandomNumberGenerator; +template +void sample_hpoly(int n_samples = 80000, + int n_burns = 20000) { + std::string problem_name("simplex"); + std::cerr << "CRHMC on " << problem_name << "\n"; + using Input = crhmc_input; + using CrhmcProblem = crhmc_problem; + using Solver = + ImplicitMidpointODESolver; + RNG rng(1); + PolytopeType HP=generate_simplex(2,false); + int dimension = HP.dimension(); + func_params params = func_params(Point(dimension), 0.5, 1); + Func f(params); + Grad g(params); + Hess h(params); + std::list PointList; + crhmc_sampling, PolytopeType, RNG, CRHMCWalk, NT, Point, Grad, Func, Hess, Solver>( + PointList, HP, rng, 1, n_samples, n_burns, g, f, h, simdLen); + MT samples = MT(dimension, PointList.size()); + int i=0; + for (std::list::iterator it = PointList.begin(); it != PointList.end(); ++it){ + samples.col(i) = (*it).getCoefficients(); + i++; + } + std::ofstream diagnostics_stream; + diagnostics_stream.open("CRHMC_SIMD_" + std::to_string(simdLen) + "_" + + problem_name + "_diagnostics.txt"); + diagnose(samples, diagnostics_stream); + std::ofstream samples_stream; + samples_stream.open("CRHMC_SIMD_" + std::to_string(simdLen) + "_" + + problem_name + "_samples.txt"); + samples_stream << samples.transpose() << std::endl; +} + +template +void sample_sparse_problem(int n_samples = 80000, + int n_burns = 20000){ + using SpMat = Eigen::SparseMatrix; + using ConstraintProblem =constraint_problem; + std::string problem_name("simplex3"); + std::cerr << "CRHMC on " << problem_name << "\n"; + using Input = crhmc_input; + using CrhmcProblem = crhmc_problem; + using Solver = + ImplicitMidpointODESolver; + + RNG rng(1); + SpMat A; + VT b, lb, ub; + int dimension; + load_crhmc_problem(A, b, lb, ub, dimension, problem_name); + ConstraintProblem problem = ConstraintProblem(dimension); + problem.set_equality_constraints(A, b); + problem.set_bounds(lb, ub); + func_params params = func_params(Point(dimension), 0.5, 1); + Func f(params); + Grad g(params); + Hess h(params); + std::list PointList; + crhmc_sampling, ConstraintProblem, RNG, CRHMCWalk, NT, Point, Grad, Func, Hess, Solver>( + PointList, problem, rng, 1, n_samples, n_burns, g, f, h, simdLen); + MT samples = MT(dimension, PointList.size()); + int i=0; + for (std::list::iterator it = PointList.begin(); it != PointList.end(); ++it){ + samples.col(i) = (*it).getCoefficients(); + i++; + } + std::ofstream diagnostics_stream; + diagnostics_stream.open("CRHMC_SIMD_" + std::to_string(simdLen) + "_" + + problem_name + "_diagnostics.txt"); + diagnose(samples, diagnostics_stream); + std::ofstream samples_stream; + samples_stream.open("CRHMC_SIMD_" + std::to_string(simdLen) + "_" + + problem_name + "_samples.txt"); + samples_stream << samples.transpose() << std::endl; +} +template +void run_main(int n_samples = 80000, + int n_burns = 20000){ + std::cerr<<"Sampling HPolytope\n"; + sample_hpoly(n_samples, n_burns); + std::cerr<<"Sampling Sparse Problem\n"; + sample_sparse_problem(n_samples, n_burns); +} +int main(int argc, char *argv[]) { + if (argc != 4) { + std::cerr << "Example Usage: ./crhmc_sample_sparse " + "[simdLen] [n_samples] [n_burns]\n"; + std::cerr << "i.e.: ./crhmc_sample_ 4 1000 500\n"; + exit(1); + } + if (atoi(argv[1]) == 1) { + run_main<1>(atoi(argv[2]), atoi(argv[3])); + } else if (atoi(argv[1]) == 4) { + run_main<4>(atoi(argv[2]), atoi(argv[3])); + } else if (atoi(argv[1]) == 8) { + run_main<8>(atoi(argv[2]), atoi(argv[3])); + } else if (atoi(argv[1]) == 16) { + run_main<16>(atoi(argv[2]), atoi(argv[3])); + } + return 0; +} diff --git a/examples/crhmc_sampling/simple_crhmc.cpp b/examples/crhmc_sampling/simple_crhmc.cpp new file mode 100644 index 000000000..8f07065b0 --- /dev/null +++ b/examples/crhmc_sampling/simple_crhmc.cpp @@ -0,0 +1,94 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2022-2022 Ioannis Iakovidis + +// Contributed and/or modified by Ioannis Iakovidis, as part of Google Summer of +// Code 2022 program. + +// Licensed under GNU LGPL.3, see LICENCE file + +// References +// Yunbum Kook, Yin Tat Lee, Ruoqi Shen, Santosh S. Vempala. "Sampling with +// Riemannian Hamiltonian +// Monte Carlo in a Constrained Space" +#include "Eigen/Eigen" +#include "cartesian_geom/cartesian_kernel.h" +#include "volume/sampling_policies.hpp" +#include "ode_solvers/ode_solvers.hpp" +#include "preprocess/crhmc/crhmc_input.h" +#include "preprocess/crhmc/crhmc_problem.h" +#include "sampling/random_point_generators.hpp" +#include "sampling/sampling.hpp" +#include "misc/misc.h" +#include "random.hpp" +#include +#include "random_walks/random_walks.hpp" +#include "generators/known_polytope_generators.h" +#include "helper_functions.hpp" + +template +void sample_hpoly(int n_samples = 80000, + int n_burns = 20000, int dim = 2) { + using NT = double; + using Kernel = Cartesian; + using Point = typename Kernel::Point; + using Func = ZeroScalarFunctor; + using Grad = ZeroFunctor; + using Hess = ZeroFunctor; + using PolytopeType = HPolytope; + using VT = Eigen::Matrix; + using MT = PolytopeType::MT; + using RNG = BoostRandomNumberGenerator; + std::string problem_name("simplex"); + std::cerr << "CRHMC on " << problem_name << "\n"; + RNG rng(1); + PolytopeType HP=generate_simplex(dim,false); + int dimension = HP.dimension(); + Func * f = new Func; + Grad * g = new Grad; + std::list PointList; + execute_crhmc< PolytopeType, RNG, std::list, Grad, Func, Hess, CRHMCWalk, simdLen>( + HP, rng, PointList, 1, n_samples, n_burns, g, f); + MT samples = MT(dimension, PointList.size()); + int i=0; + for (std::list::iterator it = PointList.begin(); it != PointList.end(); ++it){ + samples.col(i) = (*it).getCoefficients(); + i++; + } + std::cerr<<"max_psrf: "<< max_interval_psrf(samples)<<"\n"; + std::ofstream samples_stream; + samples_stream.open("CRHMC_SIMD_" + std::to_string(simdLen) + "_" + + problem_name + "_samples.txt"); + samples_stream << samples.transpose() << std::endl; + delete f; + delete g; +} + +template +void run_main(int n_samples = 80000, + int n_burns = 20000, + int dimension = 2){ + std::cerr<<"Sampling HPolytope\n"; + sample_hpoly(n_samples, n_burns, dimension); +} +int main(int argc, char *argv[]) { + if (argc != 5) { + std::cerr << "Example Usage: ./simple_crhmc " + "[simdLen] [n_samples] [n_burns] [dimension]\n"; + std::cerr << "i.e.: ./simple_crhmc 4 1000 500 2\n"; + exit(1); + } + std::cerr << "To plot: python3 ../python_utilities/plot_samples.py (atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); + } else if (atoi(argv[1]) == 4) { + run_main<4>(atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); + } else if (atoi(argv[1]) == 8) { + run_main<8>(atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); + } else if (atoi(argv[1]) == 16) { + run_main<16>(atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); + } + return 0; +} diff --git a/examples/hpolytope-volume/CMakeLists.txt b/examples/hpolytope-volume/CMakeLists.txt index 1d923f238..eff88889a 100644 --- a/examples/hpolytope-volume/CMakeLists.txt +++ b/examples/hpolytope-volume/CMakeLists.txt @@ -6,7 +6,6 @@ project( VolEsti ) - CMAKE_MINIMUM_REQUIRED(VERSION 3.11) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) @@ -15,11 +14,10 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) - -option(DISABLE_NLP_ORACLES "Disable non-linear oracles (used in collocation)" ON) -option(BUILTIN_EIGEN "Use eigen from ../../external" OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") +option(DISABLE_NLP_ORACLES "Disable non-linear oracles (used in collocation)" ON) if(DISABLE_NLP_ORACLES) add_definitions(-DDISABLE_NLP_ORACLES) else() @@ -53,60 +51,47 @@ else() message(STATUS "Library fftw3 found:" ${FFTW3}) endif(NOT IFOPT) - endif(DISABLE_NLP_ORACLES) +# eigen +option(BUILTIN_EIGEN "Use eigen from ../../external" OFF) include("../../external/cmake-files/Eigen.cmake") GetEigen() +if (${CMAKE_VERSION} VERSION_LESS "3.12.0") + add_compile_options(-D "EIGEN_NO_DEBUG") +else () + add_compile_definitions("EIGEN_NO_DEBUG") +endif () + +# boost include("../../external/cmake-files/Boost.cmake") GetBoost() +# lp_solve include("../../external/cmake-files/LPSolve.cmake") GetLPSolve() -# Find lpsolve library -find_library(LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve) - -if (NOT LP_SOLVE) - message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") -else () - message(STATUS "Library lp_solve found: ${LP_SOLVE}") - - set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") - - include_directories (BEFORE ../../external) - include_directories (BEFORE ../../external/minimum_ellipsoid) - include_directories (BEFORE ../../include/generators) - include_directories (BEFORE ../../include/volume) - include_directories (BEFORE ../../include) - include_directories (BEFORE ../../include/convex_bodies) - include_directories (BEFORE ../../include/random_walks) - include_directories (BEFORE ../../include/annealing) - include_directories (BEFORE ../../include/ode_solvers) - include_directories (BEFORE ../../include/root_finders) - include_directories (BEFORE ../../include/samplers) - include_directories (BEFORE ../../include/lp_oracles) - include_directories (BEFORE ../../include/nlp_oracles) - include_directories (BEFORE ../../include/misc) - include_directories (BEFORE ../../include/optimization) - - # for Eigen - if (${CMAKE_VERSION} VERSION_LESS "3.12.0") - add_compile_options(-D "EIGEN_NO_DEBUG") - else () - add_compile_definitions("EIGEN_NO_DEBUG") - endif () - - - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard - add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler - #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") - - add_executable (hpolytopeVolume hpolytopeVolume.cpp) - TARGET_LINK_LIBRARIES(hpolytopeVolume ${LP_SOLVE}) - -endif() +include_directories (BEFORE ../../external) +include_directories (BEFORE ../../external/minimum_ellipsoid) +include_directories (BEFORE ../../include/generators) +include_directories (BEFORE ../../include/volume) +include_directories (BEFORE ../../include) +include_directories (BEFORE ../../include/convex_bodies) +include_directories (BEFORE ../../include/random_walks) +include_directories (BEFORE ../../include/annealing) +include_directories (BEFORE ../../include/ode_solvers) +include_directories (BEFORE ../../include/root_finders) +include_directories (BEFORE ../../include/samplers) +include_directories (BEFORE ../../include/lp_oracles) +include_directories (BEFORE ../../include/nlp_oracles) +include_directories (BEFORE ../../include/misc) +include_directories (BEFORE ../../include/optimization) + +add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") + +add_executable(hpolytopeVolume hpolytopeVolume.cpp) +target_link_libraries(hpolytopeVolume PUBLIC lp_solve) diff --git a/examples/logconcave/CMakeLists.txt b/examples/logconcave/CMakeLists.txt index 0448ce3e3..33725d0c9 100644 --- a/examples/logconcave/CMakeLists.txt +++ b/examples/logconcave/CMakeLists.txt @@ -20,7 +20,7 @@ endif(COMMAND cmake_policy) option(DISABLE_NLP_ORACLES "Disable non-linear oracles (used in collocation)" ON) option(BUILTIN_EIGEN "Use eigen from ../external" OFF) -option(USE_MKL "Use MKL library to build eigen" ON) +option(USE_MKL "Use MKL library to build eigen" OFF) if(DISABLE_NLP_ORACLES) add_definitions(-DDISABLE_NLP_ORACLES) @@ -73,16 +73,24 @@ else () include_directories(BEFORE /usr/include/eigen3) endif(BUILTIN_EIGEN) +find_library(BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib) + if (USE_MKL) - find_library(BLAS NAME libblas.so PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu) + find_library(BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib) + find_library(GFORTRAN NAME libgfortran.dylib PATHS /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10) + find_library(LAPACK NAME liblapack.dylib PATHS /usr/lib) + find_library(OPENMP NAME libiomp5.dylib PATHS /opt/intel/oneapi/compiler/2021.1.1/mac/compiler/lib) + include_directories (BEFORE ${MKLROOT}/include) - set(PROJECT_LIBS ${BLAS_LIBRARIES}) + set(PROJECT_LIBS ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN_LIBRARIES}) set(MKL_LINK "-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") add_definitions(-DEIGEN_USE_MKL_ALL) +else() + set(MKL_LINK "") endif(USE_MKL) # Find lpsolve library -find_library(LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve) +find_library(LP_SOLVE NAMES liblpsolve55.so liblpsolve55.dylib PATHS /usr/lib/lp_solve /usr/local/lib) if (NOT LP_SOLVE) message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") @@ -145,6 +153,6 @@ else () TARGET_LINK_LIBRARIES(simple_hmc ${LP_SOLVE} ${BLAS} ${MKL_LINK} ) TARGET_LINK_LIBRARIES(exponential_exact_hmc ${LP_SOLVE} ${BLAS} ${MKL_LINK} ) TARGET_LINK_LIBRARIES(gaussian_exact_hmc ${LP_SOLVE} ${BLAS} ${MKL_LINK} ) - + endif() diff --git a/examples/optimization_spectrahedra/readWriteSdpaFile.cpp b/examples/optimization_spectrahedra/readWriteSdpaFile.cpp deleted file mode 100644 index c734ccac5..000000000 --- a/examples/optimization_spectrahedra/readWriteSdpaFile.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Repouskos Panagiotis, as part of Google Summer of Code 2019 program. - -// Licensed under GNU LGPL.3, see LICENCE file - -// This examples illustrates how to read and write SDPA format files. -// It will read a semidefinite program from data/sdp_n2m3.txt, print it and then write it to a new file - -#define VOLESTI_DEBUG -#include "Eigen/Eigen" -#include "vector" -#include -#include "cartesian_geom/cartesian_kernel.h" -#include "random.hpp" -#include "spectrahedron.h" -#include "SDPAFormatManager.h" -#include "string" -#include "iostream" - -typedef double NT; -typedef Eigen::Matrix VT; -typedef Eigen::Matrix MT; -typedef Cartesian Kernel; -typedef typename Kernel::Point Point; -typedef Spectrahedron SPECTRAHEDRON; - - -int main(int argc, char* argv[]) { - std::string fileName("data/sdp_n2m3.txt"); - std::string outputFile("new_sdp_n2m3.txt"); - - SPECTRAHEDRON spectrahedron; - Point objFunction; - - // read the semidefinite program - // and create a vector (objective function) and a spectrahedron - - // open a stream to read the input file - std::ifstream in; - in.open(fileName, std::ifstream::in); - - // read the file - SdpaFormatManager sdpaFormatManager; - sdpaFormatManager.loadSDPAFormatFile(in, spectrahedron, objFunction); - - // print the contents - std::cout << "The objective Function:\n\n"; - objFunction.print(); - std::cout << "\n\nThe matrices of the spectrahedron:\n\n"; - spectrahedron.getLMI().print(); - - // open a stream to an output file - std::filebuf fb; - fb.open(outputFile, std::ios::out); - std::ostream os(&fb); - - // write a SDPA format file using the data we read before - sdpaFormatManager.writeSDPAFormatFile(os, spectrahedron, objFunction); - - return 0; -} - diff --git a/examples/vpolytope-volume/CMakeLists.txt b/examples/vpolytope-volume/CMakeLists.txt index 5ffd4784b..e1a0c2576 100644 --- a/examples/vpolytope-volume/CMakeLists.txt +++ b/examples/vpolytope-volume/CMakeLists.txt @@ -65,48 +65,37 @@ GetBoost() include("../../external/cmake-files/LPSolve.cmake") GetLPSolve() -# Find lpsolve library -find_library(LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve) -if (NOT LP_SOLVE) - message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") +set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") + +include_directories (BEFORE ../../external) +include_directories (BEFORE ../../external/minimum_ellipsoid) +include_directories (BEFORE ../../include/generators) +include_directories (BEFORE ../../include/volume) +include_directories (BEFORE ../../include) +include_directories (BEFORE ../../include/convex_bodies) +include_directories (BEFORE ../../include/random_walks) +include_directories (BEFORE ../../include/annealing) +include_directories (BEFORE ../../include/ode_solvers) +include_directories (BEFORE ../../include/root_finders) +include_directories (BEFORE ../../include/samplers) +include_directories (BEFORE ../../include/lp_oracles) +include_directories (BEFORE ../../include/nlp_oracles) +include_directories (BEFORE ../../include/misc) +include_directories (BEFORE ../../include/optimization) + +# for Eigen +if (${CMAKE_VERSION} VERSION_LESS "3.12.0") + add_compile_options(-D "EIGEN_NO_DEBUG") else () - message(STATUS "Library lp_solve found: ${LP_SOLVE}") - - set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") - - include_directories (BEFORE ../../external) - include_directories (BEFORE ../../external/minimum_ellipsoid) - include_directories (BEFORE ../../include/generators) - include_directories (BEFORE ../../include/volume) - include_directories (BEFORE ../../include) - include_directories (BEFORE ../../include/convex_bodies) - include_directories (BEFORE ../../include/random_walks) - include_directories (BEFORE ../../include/annealing) - include_directories (BEFORE ../../include/ode_solvers) - include_directories (BEFORE ../../include/root_finders) - include_directories (BEFORE ../../include/samplers) - include_directories (BEFORE ../../include/lp_oracles) - include_directories (BEFORE ../../include/nlp_oracles) - include_directories (BEFORE ../../include/misc) - include_directories (BEFORE ../../include/optimization) - - # for Eigen - if (${CMAKE_VERSION} VERSION_LESS "3.12.0") - add_compile_options(-D "EIGEN_NO_DEBUG") - else () - add_compile_definitions("EIGEN_NO_DEBUG") - endif () - - - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard - add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler - #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") - - add_executable (vpolytopevolume vpolytopevolume.cpp) - TARGET_LINK_LIBRARIES(vpolytopevolume ${LP_SOLVE}) - -endif() + add_compile_definitions("EIGEN_NO_DEBUG") +endif () + +add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler +#add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") + +add_executable (vpolytopevolume vpolytopevolume.cpp) +TARGET_LINK_LIBRARIES(vpolytopevolume lp_solve) diff --git a/external/PackedCSparse/FloatArray.h b/external/PackedCSparse/FloatArray.h index 28d1c5da6..a85f56fd3 100644 --- a/external/PackedCSparse/FloatArray.h +++ b/external/PackedCSparse/FloatArray.h @@ -8,7 +8,6 @@ //(https://github.com/ConstrainedSampler/PolytopeSamplerMatlab/blob/master/code/solver/PackedCSparse/PackedChol.h) by Ioannis Iakovidis #pragma once -#include #include #include namespace PackedCSparse { diff --git a/external/PackedCSparse/PackedChol.h b/external/PackedCSparse/PackedChol.h index 57a2b9232..97d102206 100644 --- a/external/PackedCSparse/PackedChol.h +++ b/external/PackedCSparse/PackedChol.h @@ -14,7 +14,7 @@ #include "leverage.h" #include "leverageJL.h" #include "multiply.h" -#include "dd_real.h" +#include "qd/dd_real.h" #include #include using namespace PackedCSparse; diff --git a/external/PackedCSparse/qd/COPYING b/external/PackedCSparse/qd/COPYING new file mode 100644 index 000000000..a20ad70eb --- /dev/null +++ b/external/PackedCSparse/qd/COPYING @@ -0,0 +1,16 @@ +This work was supported by the Director, Office of Science, Division +of Mathematical, Information, and Computational Sciences of the +U.S. Department of Energy under contract numbers DE-AC03-76SF00098 and +DE-AC02-05CH11231. + +Copyright (c) 2003-2009, The Regents of the University of California, +through Lawrence Berkeley National Laboratory (subject to receipt of +any required approvals from U.S. Dept. of Energy) All rights reserved. + +By downloading or using this software you are agreeing to the modified +BSD license that is in file "BSD-LBNL-License.doc" in the main ARPREC +directory. If you wish to use the software for commercial purposes +please contact the Technology Transfer Department at TTD@lbl.gov or +call 510-286-6457." + + diff --git a/external/PackedCSparse/qd/Makefile b/external/PackedCSparse/qd/Makefile new file mode 100644 index 000000000..791e92b99 --- /dev/null +++ b/external/PackedCSparse/qd/Makefile @@ -0,0 +1,15 @@ +QD_CPPFLAGS=$(CPPFLAGS) -I$(R_INCLUDE_DIR) -march=native + +QD_SOURCES= bits.cc c_dd.cc c_qd.cc dd_const.cc dd_real.cc fpu.cc \ + qd_const.cc qd_real.cc util.cc + +QD_OBJECTS=$(QD_SOURCES:.cc=.o) + +libqd.a: $(QD_OBJECTS) + $(AR) rc libqd.a $(QD_OBJECTS) + +.cc.o: + $(CC) $(CFLAGS) $(CPICFLAGS) $(QD_CPPFLAGS) -c $< -o $@ + +clean: + rm -rf $(QD_OBJECTS) libqd.a diff --git a/external/PackedCSparse/qd/NEWS b/external/PackedCSparse/qd/NEWS new file mode 100644 index 000000000..f32a75751 --- /dev/null +++ b/external/PackedCSparse/qd/NEWS @@ -0,0 +1,181 @@ +Changes for 2.3.22 + Made changes suggested by Vasiliy Sotnikov + +Changes for 2.3.21 + Changed renorm in include/qd/qd_inline.h + +Changes for 2.3.20 + added #include to quadt_test.cpp + changed references to 2.3.20 from 2.3.18 + +Changes for 2.3.19 + - Updated qd_real.cpp and dd_real.cpp to fix a buffer overflow problem. + +Changes for 2.3.18 + - Updated qd_real.cpp and dd_real.cpp to fix a problem in output. + +Changes for 2.3.17 + - updated qd_real.cpp, to fix a problem with improper treatment of + negative arguments in nroot. + +Changes for 2.3.16 + - Updated dd_real.cpp, to fix a problem with inaccurate values of + tanh for small arguments. + +Changes for 2.3.15 + - Updated qd_real.cpp, to fix a problem with static definitions. + +Changes for 2.3.14 + - Updated autoconfig (replaced config.sub and config.guess) + +Changes for 2.3.7 + - Fixed bug in to_digits where digits larger than 10 + where output occasionally. + +Changes for 2.3.6 + - Added fmod (C++) and mod (Fortran) functions. + +Changes for 2.3.5 + - Fixed bug in division of qd_real by dd_real. + - Fixed bug in ddoutc (Fortran ddmod.f). + - Now compiles with g++ 4.3. + - Distribute tests/coeff.dat. + +Changes for 2.3.4 + - Fixed bug in Makefile for cygwin / mingw systems. + +Changes for 2.3.3 + - Fixed bug in atan2. + +Changes for 2.3.2 + - Fixed bug in sin / cos / sincos where too much accuracy was + lost for (moderately) large angles. + - Use fused-multiply add intrinsics on IA-64 platforms if + compiled by Intel compiler. + - Fixed bug in c_dd_write and c_qd_write. + - Fixed bug were qdext.mod was not being installed. + +Changes for 2.3.1 + - Fixed bug in sincos and cos_taylor. This affected the result + of trigonometric functions in some cases. + +Changes for 2.3.0 + This is a fairly significant change, breaking API compatibility. + - Moved C++ main entry in libqdmod.a to libqd_f_main.a. + This allows to link Fortran code using QD with custom + C++ main function. Pure Fortran code will need to be linked + with qd_f_main library in addition to qdmod and qd library. + - Constructors accepting pointers made explicit. + - Fortran routines labeled as elemental or pure, where appropriate. + - Write() is now to_string(), and now takes a single fmtflag. + - dd_real addition and multiplication made commutative. + - dd_real now represented as array of two doubles, instead of + two discrete scalars. + - New Fortran generic routines to read / write, operations with + complex and integers. + - Improved exp, sin, and cos functions. + - Removed unused constants and obscure constants only used internally + from public interface. + +Changes for 2.2.6 + - Fixed bug in mixed precision multiplication: qd_real * dd_real. + +Changes for 2.2.5 + - Bug fix in qd_real addition when --enable-ieee-add is specified. + - Debugging routines dump and dump_bits updated; + dump_components removed (just use dump). + - Fortran support for Fortran strings. Use character arrays instead. + - Return NaN under error conditions. + - Added _inf constant; exp now returns Inf when argument is too large. + - Output formatting fixes for Inf and NaNs. + - Added more real-complex mixed arithmetic routines in Fortran + interface. + +Changes for 2.2.4 + - Added random_number interface for Fortran modules. + - Use slightly more conservative values for eps. + - Avoid unnecessary overflow near overflow threshold. + - Added radix, digits, min/maxexponent, range, and precision + intrinsics to Fortran interface. + - Added safe_max (C++) and safe_huge (Fortran). + +Changes for 2.2.3 + - Fix sign function bug in Fortran modules. + +Changes for 2.2.2 + - Do not bother setting uninitialized dd_real and qd_reals to zero. + - Use clock_gettime if available for timing. + - Fortran I/O should be more consistent with C++ version. + - fpu.h is now included with dd_real.h. + +Changes for 2.2.1 + - Minor fixes when printing in scientific format. + - Change search order of C++ compilers in Apple systems to avoid + case insensitive filesystems. + +Changes for 2.2.0 + - Added F95 interface for complex types. + - Renamed dd.h and qd.h to dd_real.h and qd_real.h, respectively. + This will break older C++ code using 2.1.x library, but it was + conflicting with QuickDraw libraries on Macs. (Hence the version + bump to 2.2). + - Removed overloaded typecast operators for int and double. These + permitted *automatic* conversion of dd_real/qd_real to double or + int, which is somewhat dangerous. Instead to_int and to_double + routines are added. + +Changes for 2.1.214 + - Updated pslq_test. + - Implmented numeric_limits<>. + - Better polyroot. + - Added isnan, isfinite, isinf functions. + - Fix / improve input output functions. + - Drop Microsoft Visual C++ 6.0 support. + - More efficient dd_real::sin. + +Changes for 2.1.213 + - Support for x86_64 platforms. + - Drop libtool support for now. + +Changes for 2.1.212 + - Support for pathCC compiler. + - Added accurate and sloppy versions of add / sub / mul / div avaialble. + - Added autodetection of fma functions. + +Changes for 2.1 (2003-12-30) + - added automake scripts. + - use libtool to compile / link and build libraries. + - supports standard installation targets (make install). + - support for Intel C++ compilers (icc / ecc). + - Fortran programs are now linked by C++ compiler. + - support for building shared library. + - minor bug fixes. + +Changes for 2.0 (2003-12-08) + - all header files are in "include/qd" directory. + - added autoconf scripts. + - added config.h and qd_config.h to store configuration information. + - renamed x86_* routines to fpu_* routines. + - added separate Fortran interface (f_* routines). + - options for sloppy multiply and sloppy divison separated. + - fixed C interface to be actually in C syntax. + - updated / added README, AUTHORS, NEWS, and LICENSE files. + - minor bug fixes. + +Changes for 1.2 (2003-12-04) + - added "dist-clean" target in Makefile + - initialize dd and qd variables to zero + - increases tolerance for qd / dd tests + - changed .cc extension to .cpp + - updated README, COPYING, and NEWS files + - added ChangeLog file + - fixed bug in '-all' flag in qd_test + - minor bug fixes + +Changes for 1.1 (2002-10-22) + - added "Changes" file (this file) + - fixed to + - fixed constant (3/4) * pi + - fixed exp(x) to return zero if x is a large negative number + - removed "docs" target in Makefile + diff --git a/external/PackedCSparse/qd/README b/external/PackedCSparse/qd/README new file mode 100644 index 000000000..8a085d72c --- /dev/null +++ b/external/PackedCSparse/qd/README @@ -0,0 +1,437 @@ +Quad Double computation package +Copyright (C) 2003-2019 +================================================ + +Revision date: 26 February 2019 + +Authors: +Yozo Hida U.C. Berkeley yozo@cs.berkeley.edu +Xiaoye S. Li Lawrence Berkeley Natl Lab xiaoye@nersc.gov +David H. Bailey Lawrence Berkeley Natl Lab dhbailey@lbl.gov + +C++ usage guide: +Alex Kaiser Lawrence Berkeley Natl Lab adkaiser@lbl.gov + +This work was supported by the Director, Office of Science, Division of Mathematical, +Information, and Computational Sciences of the U.S. Department of Energy under contract +number DE-AC02-05CH11231. + +This work was supported by the Director, Office of Science, Division of Mathematical, +Information, and Computational Sciences of the U.S. Department of Energy under contract +numbers DE-AC03-76SF00098 and DE-AC02-05CH11231. + +*** IMPORTANT NOTES: + +See the file COPYING for modified BSD license information. +See the file INSTALL for installation instructions. +See the file NEWS for recent revisions. +See the file docs/qd.pdf for additional information. + +Outline: + +I. Introduction +II. Installation of package, and linking and executing user files +III. C++ Usage +IV. Fortran Usage +V. Note on x86-Based Processors (MOST systems in use today) + + +I. Introduction + +This package provides numeric types of twice the precision of IEEE double (106 mantissa +bits, or approximately 32 decimal digits) and four times the precision of IEEE double (212 +mantissa bits, or approximately 64 decimal digits). Due to features such as operator and +function overloading, these facilities can be utilized with only minor modifications to +conventional C++ and Fortran-90 programs. + +In addition to the basic arithmetic operations (add, subtract, multiply, divide, square root), +common transcendental functions such as the exponential, logarithm, trigonometric and +hyperbolic functions are also included. A detailed description of the algorithms used is +available in the docs subdirectory (see docs/qd.pdf). An abridged version of this paper, +which was presented at the ARITH-15 conference, is also available at: + +Yozo Hida, Xiaoye S. Li and David H. Bailey, "Algorithms for quad-double precision + floating point arithmetic," 15th IEEE Symposium on Computer Arithmetic, IEEE Computer + Society, 2001, pg. 155-162, available at + https://www.davidhbailey.com/dhbpapers/arith15.pdf. + + +II. Installation of package, and linking and executing user files + +A. Directories + +There are six directories and several files in the main directory of this distribution, +described below + +src This contains the source code of the quad-double and double-double + library. This source code does not include inline functions, + which are found in the header files in the include directory. + +include This directory contains the header files. + +fortran This directory contains Fortran-90 files. + +tests This directory contains some simple (not comprehensive) tests. + +docs This directory contains a technical paper describing the algorithms. + +config This directory contains various scripts used by the configure + script and the Makefile. + +Please note that all commands refer to a Unix-type environment such as Mac OSX or Ubuntu +Linux using the bash shell. + +B. Installing and building + +To build the library, first run the included configure script by typing + + ./configure + +This script automatically generates makefiles for building the library and selects compilers +and necessary flags and libraries to include. If the user wishes to specify compilers or flags +they may use the following options. + + CXX C++ compiler to use + CXXFLAGS C++ compiler flags to use + CC C compiler to use (for C demo program) + CFLAGS C compiler flags to use (for C demo program) + FC Fortran 90 compiler + FCFLAGS Fortran 90 compiler flags to use + FCLIBS Fortran 90 libraries needed to link with C++ code. + +For example, if one is using GNU compilers, configure with: + + ./configure CXX=g++ FC=gfortran + +The Fortran and C++ compilers must produce compatible binaries. On some systems +additional flags must be included to ensure that portions of the +library are not built with 32 and 64 bit object files. For example, on +64-Bit Mac OSX 10.6 (Snow Leopard) and 10.7 (Lion) the correct +configure line using GNU compilers is: + + ./configure CXX=g++ FC=gfortran FCFLAGS=-m64 + +To build the library, simply type + + make + +and the automatically generated makefiles will build the library including archive files. + +To allow for easy linking to the library, the user may also wish to +install the archive files to a standard place. To do this type: + + make install + +This will also build the library if it has not already been built. Many systems, including Mac +and Ubuntu Linux systems, require administrator privileges to install the library at such +standard places. On such systems, one may type: + + sudo make install + +instead if one has sufficient access. + +The directory "tests" contains programs for high precision quadrature and integer-relation +detection. To build such programs, type: + + make demo + +in the "tests" directory. + +C. Linking and executing user programs + +C++ source files: + +The simplest way to link to the library is to install it to a standard place as described above, and use the -l option. For example + + g++ compileExample.cpp -o compileExample -l qd + +One can also use this method to build with make. A file called "compileExample.cpp" and the +associated makefile "makeCompileExample" illustrate the process. + +A third alternative is to use a link script. If one types "make demo" in the test +directory, the output produced gives guidance as to how to build the files. By +following the structure of the compiling commands one may copy the appropriate portions, +perhaps replacing the filename with an argument that the user can include at link time. +An example of such a script is as follows: + +g++ -DHAVE_CONFIG_H -I.. -I../include -I../include -O2 -MT $1.o -MD -MP -MF +.deps/qd_test.Tpo -c -o $1.o $1.cpp +mv -f .deps/$1.Tpo .deps/$1.Po +g++ -O2 -o $1 $1.o ../src/libqd.a -lm + +To use the link script, make it executable (by typing "chmod +x link.scr) and then type: + +./link.scr compileExample + +Note that the file extension is not included because the script handles all extensions, +expecting the source file to have the extension ".cpp". + +Fortran-90 source files: + +Similarly, a script for compiling fortran programs may be constructed as follows. +In the fortran directory, type "make quadtsq". This compiles the Fortran program +tquadts.f, links with all necessary library files, and produces the executable +"quadts". As this is being done, all flags and linked libraries are displayed. +For instance, on a 2019-era Apple Macintosh system, where the library was installed +as above with g++ for C++ and gfortran for Fortran-90, the following is output: + +gfortran -m64 -ffree-form -c -o tquadtsq.o tquadtsq.f +/bin/sh ../libtool --tag=CXX --mode=link g++ -O2 -o quadtsq tquadtsq.o second.o +libqdmod.la libqd_f_main.la ../src/libqd.la +-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 +-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0/../../.. +-lgfortran -lquadmath -lm -lm + +Thus a general compile-link script is the following: + +gfortran -m64 -ffree-form -c -o $1.o $1.f90 +/bin/sh ../libtool --tag=CXX --mode=link g++ -O2 -o $1 $1.o second.o \ + libqdmod.la libqd_f_main.la ../src/libqd.la \ + -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 \ + -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0/../../.. \ + -lgfortran -lquadmath -lm -lm + +Note that if the .f90 suffix is used for Fortran-90 source files, the +-ffree-form flag may be omitted, but the first line above should end with +"$1.f90" (as shown above). After forming the script, name file, "complink.scr", +and then type "chmod +x complink.scr". To use this script compile and link a +program named "prog.f90", type "./complink.scr prog". + + +III. C++ usage + +As much as possible, operator overloading is included to make basic programming as much +like using standard typed floating-point arithmetic. Changing many codes should be as +simple as changing type statements and a few other lines. + +i. Constructors + +To create dd_real and qd_real variables calculated to the proper precision, one must use +care to use the included constructors properly. Many computations in which variables are +not explicitly typed to multiple-precision may be evaluated with double-precision +arithmetic. The user must take care to ensure that this does not cause errors. In particular, +an expression such as 1.0/3.0 will be evaluated to double precision before assignment or +further arithmetic. Upon assignment to a multi-precision variable, the value will be zero +padded. This problem is serious and potentially difficult to debug. To avoid this, use the +included constructors to force arithmetic to be performed in the full precision requested. + +For a table with descriptions, please see the documentation file qd.pdf in the docs directory. + +ii. Included functions and Constants + +Supported functions include assignment operators, comparisons, arithmetic and +assignment operators, and increments for integer types. Standard C math functions such as +exponentiation, trigonometric, logarithmic, hyperbolic, exponential and rounding functions +are included. As in assignment statements, one must be careful with implied typing of +constants when using these functions. Many codes need particular conversion for the power +function, which is frequently used with constants that must be explicitly typed for multi- +precision codes. + +Many constants are included, which are global and calculated upon initialization. The +following list of constants is calculated for both the dd_real and qd_real classes separately. +Use care to select the correct value. + +For a table with descriptions, please see the included file README.pdf + +ii. Conversion of types + +Static casts may be used to convert constants between types. One may also use constructors +to return temporary multi-precision types within expressions, but should be careful, as this +will waste memory if done repeatedly. For example: + + qd_real y ; + y = sin( qd_real(4.0) / 3.0 ) ; + +C-style casts may be used, but are not recommended. Dynamic and reinterpret casts are +not supported and should be considered unreliable. Casting between multi-precision and +standard precision types can be dangerous, and care must be taken to ensure that programs +are working properly and accuracy has not degraded by use of a misplaced type-conversion. + +D. Available precision, Control of Precision Levels, + +The library provides greatly extended accuracy when compared to standard double +precision. The type dd_real provides for 106 mantissa bits, or about 32 decimal digits. The +type qd_real provides for 212 mantissa bits, or about 64 decimal digits. + +Both the dd_real and qd_real values use the exponent from the highest double-precision +word for arithmetic, and as such do not extend the total range of values available. That +means that the maximum absolute value for either data type is the same as that of double- +precision, or approximately 10^308. The precision near this range, however, is greatly +increased. + +E. I/O + +The standard I/O stream routines have been overloaded to be fully compatible with all +included data types. One may need to manually reset the precision of the stream to obtain +full output. For example, if 60 digits are desired, use: + +cout.precision(60) ; + +When reading values using cin, each input numerical value must start on a separate +line. Two formats are acceptable: + + 1. Write the full constant + 3. Mantissa e exponent + +Here are three valid examples: + + 1.1 + 3.14159 26535 89793 + 123.123123e50 + +When read using cin, these constants will be converted using full multi-precision accuracy. + + +IV. Fortran-90 Usage + +NEW (2007-01-10): The Fortran translation modules now support the complex datatypes +"dd_complex" and "qd_complex". + +Since the quad-double library is written in C++, it must be linked in with a C++ compiler (so +that C++ specific things such as static initializations are correctly handled). Thus the main +program must be written in C/C++ and call the Fortran 90 subroutine. The Fortran 90 +subroutine should be called f_main. + +Here is a sample Fortran-90 program, equivalent to the above C++ program: + + subroutine f_main + use qdmodule + implicit none + type (qd_real) a, b + a = 1.d0 + b = cos(a)**2 + sin(a)**2 - 1.d0 + call qdwrite(6, b) + stop + end subroutine + +This verifies that cos^2(1) + sin^2(1) = 1 to 64 digit accuracy. + +Most operators and generic function references, including many mixed-mode type +combinations with double-precision (ie real*8), have been overloaded (extended) to work +with double-double and quad-double data. It is important, however, that users keep in +mind the fact that expressions are evaluated strictly according to conventional Fortran +operator precedence rules. Thus some subexpressions may be evaluated only to 15-digit +accuracy. For example, with the code + + real*8 d1 + type (dd_real) t1, t2 + ... + t1 = cos (t2) + d1/3.d0 + +the expression d1/3.d0 is computed to real*8 accuracy only (about 15 digits), since both d1 +and 3.d0 have type real*8. This result is then converted to dd_real by zero extension before +being added to cos(t2). So, for example, if d1 held the value 1.d0, then the quotient d1/3.d0 +would only be accurate to 15 digits. If a fully accurate double-double quotient is required, +this should be written: + + real*8 d1 + type (dd_real) t1, t2 + ... + t1 = cos (t2) + ddreal (d1) / 3.d0 + +which forces all operations to be performed with double-double arithmetic. + +Along this line, a constant such as 1.1 appearing in an expression is evaluated only to real*4 +accuracy, and a constant such as 1.1d0 is evaluated only to real*8 accuracy (this is +according to standard Fortran conventions). If full quad-double accuracy is required, for +instance, one should write + + type (qd_real) t1 + ... + t1 = '1.1' + +The quotes enclosing 1.1 specify to the compiler that the constant is to be converted to +binary using quad-double arithmetic, before assignment to t1. Quoted constants may only +appear in assignment statements such as this. + +To link a Fortran-90 program with the C++ qd library, it is recommended to link with the +C++ compiler used to generate the library. The Fortran 90 interface (along with a C-style +main function calling f_main) is found in qdmod library. The qd-config script installed +during "make install" can be used to determine which flags to pass to compile and link your +programs: + + "qd-config --fcflags" displays compiler flags needed to compile your Fortran files. + "qd-config --fclibs" displays linker flags needed by the C++ linker to link in all the +necessary libraries. + +A sample Makefile that can be used as a template for compiling Fortran programs using +quad-double library is found in fortran/Makefile.sample. + +F90 functions defined with dd_real arguments: + Arithmetic: + - * / ** + Comparison tests: == < > <= >= /= + Others: abs, acos, aint, anint, asin, atan, atan2, cos, cosh, dble, erf, + erfc, exp, int, log, log10, max, min, mod, ddcsshf (cosh and sinh), + ddcssnf (cos and sin), ddranf (random number generator in (0,1)), + ddnrtf (n-th root), sign, sin, sinh, sqr, sqrt, tan, tanh + +Similar functions are provided for qd_real arguments with function names qdcsshf, +qdcssnf, qdranf and qdnrtf instead of the names in the list above. + +Input and output of double-double and quad-double data is done using the special +subroutines ddread, ddwrite, qdread and qdwrite. The first argument of these subroutines +is the Fortran I/O unit number, while additional arguments (as many as needed, up to 9 +arguments) are scalar variables or array elements of the appropriate type. Example: + + integer n + type (qd_real) qda, qdb, qdc(n) + ... + call qdwrite (6, qda, qdb) + do j = 1, n + call qdwrite (6, qdc(j)) + enddo + +Each input values must be on a separate line, and may include D or E exponents. Double- +double and quad-double constants may also be specified in assignment statements by +enclosing them in quotes, as in + + ... + type (qd_real) pi + ... + pi = +"3.14159265358979323846264338327950288419716939937510582097494459230" + ... + +Sample Fortran-90 programs illustrating some of these features are provided in the f90 +subdirectory. + + +V. Note on x86-Based Processors (MOST systems in use today) + +The algorithms in this library assume IEEE double precision floating point arithmetic. Since +Intel x86 processors have extended (80-bit) floating point registers, some compilers, +albeit a declining number, may generate commands for the 80-bit instructions. The QD +library does NOT work correctly with 80-bit instructions, so if one's code does not operate +correctly, this may be the reason. To avoid such problems, the round-to-double flag must be +enabled in the control word of the FPU for this library to function properly. The following +functions contains appropriate code to facilitate manipulation of this flag. For non-x86 +systems these functions do nothing (but still exist). + +fpu_fix_start This turns on the round-to-double bit in the control word. +fpu_fix_end This restores the control flag. + +These functions must be called by the main program, as follows: + + int main() { + unsigned int old_cw; + fpu_fix_start(&old_cw); + + ... user code using quad-double library ... + + fpu_fix_end(&old_cw); + } + +A Fortran-90 example is the following: + + subroutine f_main + use qdmodule + implicit none + integer*4 old_cw + + call f_fpu_fix_start(old_cw) + + ... user code using quad-double library ... + + call f_fpu_fix_end(old_cw) + end subroutine + diff --git a/external/PackedCSparse/qd/bits.cc b/external/PackedCSparse/qd/bits.cc new file mode 100644 index 000000000..4eaf9a265 --- /dev/null +++ b/external/PackedCSparse/qd/bits.cc @@ -0,0 +1,85 @@ +/* + * src/bits.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Defines various routines to get / set bits of a IEEE floating point + * number. This used by the library for debugging purposes. + */ + +#include +#include +#include +#include + +#include "qd_config.h" +#include "inline.h" +#include "bits.h" + +#ifdef HAVE_IEEEFP_H +#include +#endif + +using std::setw; + +int get_double_expn(double x) { + if (x == 0.0) + return INT_MIN; + if (QD_ISINF(x) || QD_ISNAN(x)) + return INT_MAX; + + double y = std::abs(x); + int i = 0; + if (y < 1.0) { + while (y < 1.0) { + y *= 2.0; + i++; + } + return -i; + } else if (y >= 2.0) { + while (y >= 2.0) { + y *= 0.5; + i++; + } + return i; + } + return 0; +} + +void print_double_info(std::ostream &os, double x) { + std::streamsize old_prec = os.precision(19); + std::ios_base::fmtflags old_flags = os.flags(); + os << std::scientific; + + os << setw(27) << x << ' '; + if (QD_ISNAN(x) || QD_ISINF(x) || (x == 0.0)) { + os << " "; + } else { + + x = std::abs(x); + int expn = get_double_expn(x); + double d = std::ldexp(1.0, expn); + os << setw(5) << expn << " "; + for (int i = 0; i < 53; i++) { + if (x >= d) { + x -= d; + os << '1'; + } else + os << '0'; + d *= 0.5; + } + + if (x != 0.0) { + // should not happen + os << " +trailing stuff"; + } + } + + os.precision(old_prec); + os.flags(old_flags); +} + diff --git a/external/PackedCSparse/qd/bits.h b/external/PackedCSparse/qd/bits.h new file mode 100644 index 000000000..58570aac5 --- /dev/null +++ b/external/PackedCSparse/qd/bits.h @@ -0,0 +1,32 @@ +/* + * include/bits.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * This file defines various routines to get / set bits of a IEEE floating + * point number. This is used by the library for debugging purposes. + */ + +#ifndef _QD_BITS_H +#define _QD_BITS_H + +#include +#include "qd_config.h" + +/* Returns the exponent of the double precision number. + Returns INT_MIN is x is zero, and INT_MAX if x is INF or NaN. */ +int get_double_expn(double x); + +/* Prints + SIGN EXPN MANTISSA + of the given double. If x is NaN, INF, or Zero, this + prints out the strings NaN, +/- INF, and 0. */ +void print_double_info(std::ostream &os, double x); + + +#endif /* _QD_BITS_H */ + diff --git a/external/PackedCSparse/qd/c_dd.cc b/external/PackedCSparse/qd/c_dd.cc new file mode 100644 index 000000000..0a7c12ac2 --- /dev/null +++ b/external/PackedCSparse/qd/c_dd.cc @@ -0,0 +1,314 @@ +/* + * src/c_dd.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains the C wrapper functions for double-double precision arithmetic. + * This can be used from Fortran code. + */ +#include + +#include "qd_config.h" +#include "dd_real.h" +#include "c_dd.h" + +#define TO_DOUBLE_PTR(a, ptr) ptr[0] = a.x[0]; ptr[1] = a.x[1]; + +extern "C" { + +/* add */ +void c_dd_add(const double *a, const double *b, double *c) { + dd_real cc; + cc = dd_real(a) + dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_dd_add_dd_d(const double *a, double b, double *c) { + dd_real cc; + cc = dd_real(a) + b; + TO_DOUBLE_PTR(cc, c); +} +void c_dd_add_d_dd(double a, const double *b, double *c) { + dd_real cc; + cc = a + dd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + +/* sub */ +void c_dd_sub(const double *a, const double *b, double *c) { + dd_real cc; + cc = dd_real(a) - dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_dd_sub_dd_d(const double *a, double b, double *c) { + dd_real cc; + cc = dd_real(a) - b; + TO_DOUBLE_PTR(cc, c); +} +void c_dd_sub_d_dd(double a, const double *b, double *c) { + dd_real cc; + cc = a - dd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + +/* mul */ +void c_dd_mul(const double *a, const double *b, double *c) { + dd_real cc; + cc = dd_real(a) * dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_dd_mul_dd_d(const double *a, double b, double *c) { + dd_real cc; + cc = dd_real(a) * b; + TO_DOUBLE_PTR(cc, c); +} +void c_dd_mul_d_dd(double a, const double *b, double *c) { + dd_real cc; + cc = a * dd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + +/* div */ +void c_dd_div(const double *a, const double *b, double *c) { + dd_real cc; + cc = dd_real(a) / dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_dd_div_dd_d(const double *a, double b, double *c) { + dd_real cc; + cc = dd_real(a) / b; + TO_DOUBLE_PTR(cc, c); +} +void c_dd_div_d_dd(double a, const double *b, double *c) { + dd_real cc; + cc = a / dd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + +/* copy */ +void c_dd_copy(const double *a, double *b) { + b[0] = a[0]; + b[1] = a[1]; +} +void c_dd_copy_d(double a, double *b) { + b[0] = a; + b[1] = 0.0; +} + + +void c_dd_sqrt(const double *a, double *b) { + dd_real bb; + bb = sqrt(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_sqr(const double *a, double *b) { + dd_real bb; + bb = sqr(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_abs(const double *a, double *b) { + dd_real bb; + bb = abs(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_npwr(const double *a, int n, double *b) { + dd_real bb; + bb = npwr(dd_real(a), n); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_nroot(const double *a, int n, double *b) { + dd_real bb; + bb = nroot(dd_real(a), n); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_nint(const double *a, double *b) { + dd_real bb; + bb = nint(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_aint(const double *a, double *b) { + dd_real bb; + bb = aint(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_floor(const double *a, double *b) { + dd_real bb; + bb = floor(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_ceil(const double *a, double *b) { + dd_real bb; + bb = ceil(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_log(const double *a, double *b) { + dd_real bb; + bb = log(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_log10(const double *a, double *b) { + dd_real bb; + bb = log10(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_exp(const double *a, double *b) { + dd_real bb; + bb = exp(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_sin(const double *a, double *b) { + dd_real bb; + bb = sin(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_cos(const double *a, double *b) { + dd_real bb; + bb = cos(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_tan(const double *a, double *b) { + dd_real bb; + bb = tan(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_asin(const double *a, double *b) { + dd_real bb; + bb = asin(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_acos(const double *a, double *b) { + dd_real bb; + bb = acos(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_atan(const double *a, double *b) { + dd_real bb; + bb = atan(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_atan2(const double *a, const double *b, double *c) { + dd_real cc; + cc = atan2(dd_real(a), dd_real(b)); + TO_DOUBLE_PTR(cc, c); +} + +void c_dd_sinh(const double *a, double *b) { + dd_real bb; + bb = sinh(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_cosh(const double *a, double *b) { + dd_real bb; + bb = cosh(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_tanh(const double *a, double *b) { + dd_real bb; + bb = tanh(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_asinh(const double *a, double *b) { + dd_real bb; + bb = asinh(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_acosh(const double *a, double *b) { + dd_real bb; + bb = acosh(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_dd_atanh(const double *a, double *b) { + dd_real bb; + bb = atanh(dd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_dd_sincos(const double *a, double *s, double *c) { + dd_real ss, cc; + sincos(dd_real(a), ss, cc); + TO_DOUBLE_PTR(ss, s); + TO_DOUBLE_PTR(cc, c); +} + +void c_dd_sincosh(const double *a, double *s, double *c) { + dd_real ss, cc; + sincosh(dd_real(a), ss, cc); + TO_DOUBLE_PTR(ss, s); + TO_DOUBLE_PTR(cc, c); +} + +void c_dd_read(const char *s, double *a) { + dd_real aa(s); + TO_DOUBLE_PTR(aa, a); +} + +void c_dd_swrite(const double *a, int precision, char *s, int len) { + dd_real(a).write(s, len, precision); +} + +void c_dd_write(const double *a) { + std::cout << dd_real(a).to_string(dd_real::_ndigits) << std::endl; +} + +void c_dd_neg(const double *a, double *b) { + b[0] = -a[0]; + b[1] = -a[1]; +} + +void c_dd_rand(double *a) { + dd_real aa; + aa = ddrand(); + TO_DOUBLE_PTR(aa, a); +} + +void c_dd_comp(const double *a, const double *b, int *result) { + dd_real aa(a), bb(b); + if (aa < bb) + *result = -1; + else if (aa > bb) + *result = 1; + else + *result = 0; +} + +void c_dd_comp_dd_d(const double *a, double b, int *result) { + dd_real aa(a), bb(b); + if (aa < bb) + *result = -1; + else if (aa > bb) + *result = 1; + else + *result = 0; +} + +void c_dd_comp_d_dd(double a, const double *b, int *result) { + dd_real aa(a), bb(b); + if (aa < bb) + *result = -1; + else if (aa > bb) + *result = 1; + else + *result = 0; +} + +void c_dd_pi(double *a) { + TO_DOUBLE_PTR(dd_real::_pi, a); +} + +} diff --git a/external/PackedCSparse/qd/c_dd.h b/external/PackedCSparse/qd/c_dd.h new file mode 100644 index 000000000..310162edc --- /dev/null +++ b/external/PackedCSparse/qd/c_dd.h @@ -0,0 +1,98 @@ +/* + * include/c_dd.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains C wrapper function prototypes for double-double precision + * arithmetic. This can also be used from fortran code. + */ +#ifndef _QD_C_DD_H +#define _QD_C_DD_H + +#include "qd_config.h" +#include "fpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* add */ +void c_dd_add(const double *a, const double *b, double *c); +void c_dd_add_d_dd(double a, const double *b, double *c); +void c_dd_add_dd_d(const double *a, double b, double *c); + +/* sub */ +void c_dd_sub(const double *a, const double *b, double *c); +void c_dd_sub_d_dd(double a, const double *b, double *c); +void c_dd_sub_dd_d(const double *a, double b, double *c); + +/* mul */ +void c_dd_mul(const double *a, const double *b, double *c); +void c_dd_mul_d_dd(double a, const double *b, double *c); +void c_dd_mul_dd_d(const double *a, double b, double *c); + +/* div */ +void c_dd_div(const double *a, const double *b, double *c); +void c_dd_div_d_dd(double a, const double *b, double *c); +void c_dd_div_dd_d(const double *a, double b, double *c); + +/* copy */ +void c_dd_copy(const double *a, double *b); +void c_dd_copy_d(double a, double *b); + +void c_dd_sqrt(const double *a, double *b); +void c_dd_sqr(const double *a, double *b); + +void c_dd_abs(const double *a, double *b); + +void c_dd_npwr(const double *a, int b, double *c); +void c_dd_nroot(const double *a, int b, double *c); + +void c_dd_nint(const double *a, double *b); +void c_dd_aint(const double *a, double *b); +void c_dd_floor(const double *a, double *b); +void c_dd_ceil(const double *a, double *b); + +void c_dd_exp(const double *a, double *b); +void c_dd_log(const double *a, double *b); +void c_dd_log10(const double *a, double *b); + +void c_dd_sin(const double *a, double *b); +void c_dd_cos(const double *a, double *b); +void c_dd_tan(const double *a, double *b); + +void c_dd_asin(const double *a, double *b); +void c_dd_acos(const double *a, double *b); +void c_dd_atan(const double *a, double *b); +void c_dd_atan2(const double *a, const double *b, double *c); + +void c_dd_sinh(const double *a, double *b); +void c_dd_cosh(const double *a, double *b); +void c_dd_tanh(const double *a, double *b); + +void c_dd_asinh(const double *a, double *b); +void c_dd_acosh(const double *a, double *b); +void c_dd_atanh(const double *a, double *b); + +void c_dd_sincos(const double *a, double *s, double *c); +void c_dd_sincosh(const double *a, double *s, double *c); + +void c_dd_read(const char *s, double *a); +void c_dd_swrite(const double *a, int precision, char *s, int len); +void c_dd_write(const double *a); +void c_dd_neg(const double *a, double *b); +void c_dd_rand(double *a); +void c_dd_comp(const double *a, const double *b, int *result); +void c_dd_comp_dd_d(const double *a, double b, int *result); +void c_dd_comp_d_dd(double a, const double *b, int *result); +void c_dd_pi(double *a); + +#ifdef __cplusplus +} +#endif + +#endif /* _QD_C_DD_H */ diff --git a/external/PackedCSparse/qd/c_qd.cc b/external/PackedCSparse/qd/c_qd.cc new file mode 100644 index 000000000..fd50e9228 --- /dev/null +++ b/external/PackedCSparse/qd/c_qd.cc @@ -0,0 +1,450 @@ +/* + * src/c_qd.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains C wrapper function for quad-double precision arithmetic. + * This can be used from fortran code. + */ +#include + +#include "qd_config.h" +#include "qd_real.h" +#include "c_qd.h" + +#define TO_DOUBLE_PTR(a, ptr) ptr[0] = a.x[0]; ptr[1] = a.x[1]; \ + ptr[2] = a.x[2]; ptr[3] = a.x[3]; + +extern "C" { + + + +/* add */ +void c_qd_add(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) + qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_add_qd_dd(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) + dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_add_dd_qd(const double *a, const double *b, double *c) { + qd_real cc; + cc = dd_real(a) + qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_add_qd_d(const double *a, double b, double *c) { + qd_real cc; + cc = qd_real(a) + b; + TO_DOUBLE_PTR(cc, c); +} +void c_qd_add_d_qd(double a, const double *b, double *c) { + qd_real cc; + cc = a + qd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + + +/* sub */ +void c_qd_sub(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) - qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_sub_qd_dd(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) - dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_sub_dd_qd(const double *a, const double *b, double *c) { + qd_real cc; + cc = dd_real(a) - qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_sub_qd_d(const double *a, double b, double *c) { + qd_real cc; + cc = qd_real(a) - b; + TO_DOUBLE_PTR(cc, c); +} +void c_qd_sub_d_qd(double a, const double *b, double *c) { + qd_real cc; + cc = a - qd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + + +/* mul */ +void c_qd_mul(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) * qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_mul_qd_dd(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) * dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_mul_dd_qd(const double *a, const double *b, double *c) { + qd_real cc; + cc = dd_real(a) * qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_mul_qd_d(const double *a, double b, double *c) { + qd_real cc; + cc = qd_real(a) * b; + TO_DOUBLE_PTR(cc, c); +} +void c_qd_mul_d_qd(double a, const double *b, double *c) { + qd_real cc; + cc = a * qd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + + +/* div */ +void c_qd_div(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) / qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_div_qd_dd(const double *a, const double *b, double *c) { + qd_real cc; + cc = qd_real(a) / dd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_div_dd_qd(const double *a, const double *b, double *c) { + qd_real cc; + cc = dd_real(a) / qd_real(b); + TO_DOUBLE_PTR(cc, c); +} +void c_qd_div_qd_d(const double *a, double b, double *c) { + qd_real cc; + cc = qd_real(a) / b; + TO_DOUBLE_PTR(cc, c); +} +void c_qd_div_d_qd(double a, const double *b, double *c) { + qd_real cc; + cc = a / qd_real(b); + TO_DOUBLE_PTR(cc, c); +} + + + + +/* selfadd */ +void c_qd_selfadd(const double *a, double *b) { + qd_real bb(b); + bb += qd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfadd_dd(const double *a, double *b) { + qd_real bb(b); + bb += dd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfadd_d(double a, double *b) { + qd_real bb(b); + bb += a; + TO_DOUBLE_PTR(bb, b); +} + + + +/* selfsub */ +void c_qd_selfsub(const double *a, double *b) { + qd_real bb(b); + bb -= qd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfsub_dd(const double *a, double *b) { + qd_real bb(b); + bb -= dd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfsub_d(double a, double *b) { + qd_real bb(b); + bb -= a; + TO_DOUBLE_PTR(bb, b); +} + + + +/* selfmul */ +void c_qd_selfmul(const double *a, double *b) { + qd_real bb(b); + bb *= qd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfmul_dd(const double *a, double *b) { + qd_real bb(b); + bb *= dd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfmul_d(double a, double *b) { + qd_real bb(b); + bb *= a; + TO_DOUBLE_PTR(bb, b); +} + + + +/* selfdiv */ +void c_qd_selfdiv(const double *a, double *b) { + qd_real bb(b); + bb /= qd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfdiv_dd(const double *a, double *b) { + qd_real bb(b); + bb /= dd_real(a); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_selfdiv_d(double a, double *b) { + qd_real bb(b); + bb /= a; + TO_DOUBLE_PTR(bb, b); +} + + + +/* copy */ +void c_qd_copy(const double *a, double *b) { + b[0] = a[0]; + b[1] = a[1]; + b[2] = a[2]; + b[3] = a[3]; +} +void c_qd_copy_dd(const double *a, double *b) { + b[0] = a[0]; + b[1] = a[1]; + b[2] = 0.0; + b[3] = 0.0; +} +void c_qd_copy_d(double a, double *b) { + b[0] = a; + b[1] = 0.0; + b[2] = 0.0; + b[3] = 0.0; +} + + +void c_qd_sqrt(const double *a, double *b) { + qd_real bb; + bb = sqrt(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_sqr(const double *a, double *b) { + qd_real bb; + bb = sqr(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_abs(const double *a, double *b) { + qd_real bb; + bb = abs(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_npwr(const double *a, int n, double *b) { + qd_real bb; + bb = npwr(qd_real(a), n); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_nroot(const double *a, int n, double *b) { + qd_real bb; + bb = nroot(qd_real(a), n); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_nint(const double *a, double *b) { + qd_real bb; + bb = nint(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_aint(const double *a, double *b) { + qd_real bb; + bb = aint(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_floor(const double *a, double *b) { + qd_real bb; + bb = floor(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_ceil(const double *a, double *b) { + qd_real bb; + bb = ceil(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_log(const double *a, double *b) { + qd_real bb; + bb = log(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_log10(const double *a, double *b) { + qd_real bb; + bb = log10(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_exp(const double *a, double *b) { + qd_real bb; + bb = exp(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_sin(const double *a, double *b) { + qd_real bb; + bb = sin(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_cos(const double *a, double *b) { + qd_real bb; + bb = cos(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_tan(const double *a, double *b) { + qd_real bb; + bb = tan(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_asin(const double *a, double *b) { + qd_real bb; + bb = asin(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_acos(const double *a, double *b) { + qd_real bb; + bb = acos(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_atan(const double *a, double *b) { + qd_real bb; + bb = atan(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_atan2(const double *a, const double *b, double *c) { + qd_real cc; + cc = atan2(qd_real(a), qd_real(b)); + TO_DOUBLE_PTR(cc, c); +} + +void c_qd_sinh(const double *a, double *b) { + qd_real bb; + bb = sinh(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_cosh(const double *a, double *b) { + qd_real bb; + bb = cosh(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_tanh(const double *a, double *b) { + qd_real bb; + bb = tanh(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_asinh(const double *a, double *b) { + qd_real bb; + bb = asinh(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_acosh(const double *a, double *b) { + qd_real bb; + bb = acosh(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} +void c_qd_atanh(const double *a, double *b) { + qd_real bb; + bb = atanh(qd_real(a)); + TO_DOUBLE_PTR(bb, b); +} + +void c_qd_sincos(const double *a, double *s, double *c) { + qd_real ss, cc; + sincos(qd_real(a), ss, cc); + TO_DOUBLE_PTR(cc, c); + TO_DOUBLE_PTR(ss, s); +} + +void c_qd_sincosh(const double *a, double *s, double *c) { + qd_real ss, cc; + sincosh(qd_real(a), ss, cc); + TO_DOUBLE_PTR(cc, c); + TO_DOUBLE_PTR(ss, s); +} + +void c_qd_read(const char *s, double *a) { + qd_real aa(s); + TO_DOUBLE_PTR(aa, a); +} + +void c_qd_swrite(const double *a, int precision, char *s, int len) { + qd_real(a).write(s, len, precision); +} + +void c_qd_write(const double *a) { + std::cout << qd_real(a).to_string(qd_real::_ndigits) << std::endl; +} + +void c_qd_neg(const double *a, double *b) { + b[0] = -a[0]; + b[1] = -a[1]; + b[2] = -a[2]; + b[3] = -a[3]; +} + +void c_qd_rand(double *a) { + qd_real aa; + aa = qdrand(); + TO_DOUBLE_PTR(aa, a); +} + +void c_qd_comp(const double *a, const double *b, int *result) { + qd_real aa(a), bb(b); + if (aa < bb) + *result = -1; + else if (aa > bb) + *result = 1; + else + *result = 0; +} + +void c_qd_comp_qd_d(const double *a, double b, int *result) { + qd_real aa(a); + if (aa < b) + *result = -1; + else if (aa > b) + *result = 1; + else + *result = 0; +} + +void c_qd_comp_d_qd(double a, const double *b, int *result) { + qd_real bb(b); + if (a < bb) + *result = -1; + else if (a > bb) + *result = 1; + else + *result = 0; +} + +void c_qd_pi(double *a) { + TO_DOUBLE_PTR(qd_real::_pi, a); +} + +} diff --git a/external/PackedCSparse/qd/c_qd.h b/external/PackedCSparse/qd/c_qd.h new file mode 100644 index 000000000..d11a7ff17 --- /dev/null +++ b/external/PackedCSparse/qd/c_qd.h @@ -0,0 +1,119 @@ +/* + * include/c_qd.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains C wrapper function prototypes for quad-double precision + * arithmetic. This can also be used from fortran code. + */ +#ifndef _QD_C_QD_H +#define _QD_C_QD_H + +#include "c_dd.h" +#include "qd_config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* add */ +void c_qd_add(const double *a, const double *b, double *c); +void c_qd_add_dd_qd(const double *a, const double *b, double *c); +void c_qd_add_qd_dd(const double *a, const double *b, double *c); +void c_qd_add_d_qd(double a, const double *b, double *c); +void c_qd_add_qd_d(const double *a, double b, double *c); +void c_qd_selfadd(const double *a, double *b); +void c_qd_selfadd_dd(const double *a, double *b); +void c_qd_selfadd_d(double a, double *b); + +/* sub */ +void c_qd_sub(const double *a, const double *b, double *c); +void c_qd_sub_dd_qd(const double *a, const double *b, double *c); +void c_qd_sub_qd_dd(const double *a, const double *b, double *c); +void c_qd_sub_d_qd(double a, const double *b, double *c); +void c_qd_sub_qd_d(const double *a, double b, double *c); +void c_qd_selfsub(const double *a, double *b); +void c_qd_selfsub_dd(const double *a, double *b); +void c_qd_selfsub_d(double a, double *b); + +/* mul */ +void c_qd_mul(const double *a, const double *b, double *c); +void c_qd_mul_dd_qd(const double *a, const double *b, double *c); +void c_qd_mul_qd_dd(const double *a, const double *b, double *c); +void c_qd_mul_d_qd(double a, const double *b, double *c); +void c_qd_mul_qd_d(const double *a, double b, double *c); +void c_qd_selfmul(const double *a, double *b); +void c_qd_selfmul_dd(const double *a, double *b); +void c_qd_selfmul_d(double a, double *b); + +/* div */ +void c_qd_div(const double *a, const double *b, double *c); +void c_qd_div_dd_qd(const double *a, const double *b, double *c); +void c_qd_div_qd_dd(const double *a, const double *b, double *c); +void c_qd_div_d_qd(double a, const double *b, double *c); +void c_qd_div_qd_d(const double *a, double b, double *c); +void c_qd_selfdiv(const double *a, double *b); +void c_qd_selfdiv_dd(const double *a, double *b); +void c_qd_selfdiv_d(double a, double *b); + +/* copy */ +void c_qd_copy(const double *a, double *b); +void c_qd_copy_dd(const double *a, double *b); +void c_qd_copy_d(double a, double *b); + +void c_qd_sqrt(const double *a, double *b); +void c_qd_sqr(const double *a, double *b); + +void c_qd_abs(const double *a, double *b); + +void c_qd_npwr(const double *a, int b, double *c); +void c_qd_nroot(const double *a, int b, double *c); + +void c_qd_nint(const double *a, double *b); +void c_qd_aint(const double *a, double *b); +void c_qd_floor(const double *a, double *b); +void c_qd_ceil(const double *a, double *b); + +void c_qd_exp(const double *a, double *b); +void c_qd_log(const double *a, double *b); +void c_qd_log10(const double *a, double *b); + +void c_qd_sin(const double *a, double *b); +void c_qd_cos(const double *a, double *b); +void c_qd_tan(const double *a, double *b); + +void c_qd_asin(const double *a, double *b); +void c_qd_acos(const double *a, double *b); +void c_qd_atan(const double *a, double *b); +void c_qd_atan2(const double *a, const double *b, double *c); + +void c_qd_sinh(const double *a, double *b); +void c_qd_cosh(const double *a, double *b); +void c_qd_tanh(const double *a, double *b); + +void c_qd_asinh(const double *a, double *b); +void c_qd_acosh(const double *a, double *b); +void c_qd_atanh(const double *a, double *b); + +void c_qd_sincos(const double *a, double *s, double *c); +void c_qd_sincosh(const double *a, double *s, double *c); + +void c_qd_read(const char *s, double *a); +void c_qd_swrite(const double *a, int precision, char *s, int len); +void c_qd_write(const double *a); +void c_qd_neg(const double *a, double *b); +void c_qd_rand(double *a); +void c_qd_comp(const double *a, const double *b, int *result); +void c_qd_comp_qd_d(const double *a, double b, int *result); +void c_qd_comp_d_qd(double a, const double *b, int *result); +void c_qd_pi(double *a); + +#ifdef __cplusplus +} +#endif + +#endif /* _QD_C_QD_H */ diff --git a/external/PackedCSparse/qd/dd_const.cc b/external/PackedCSparse/qd/dd_const.cc new file mode 100644 index 000000000..38b7b5ae6 --- /dev/null +++ b/external/PackedCSparse/qd/dd_const.cc @@ -0,0 +1,40 @@ +/* + * src/dd_const.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2007 + */ +#include "qd_config.h" +#include "dd_real.h" + +const dd_real dd_real::_2pi = dd_real(6.283185307179586232e+00, + 2.449293598294706414e-16); +const dd_real dd_real::_pi = dd_real(3.141592653589793116e+00, + 1.224646799147353207e-16); +const dd_real dd_real::_pi2 = dd_real(1.570796326794896558e+00, + 6.123233995736766036e-17); +const dd_real dd_real::_pi4 = dd_real(7.853981633974482790e-01, + 3.061616997868383018e-17); +const dd_real dd_real::_3pi4 = dd_real(2.356194490192344837e+00, + 9.1848509936051484375e-17); +const dd_real dd_real::_e = dd_real(2.718281828459045091e+00, + 1.445646891729250158e-16); +const dd_real dd_real::_log2 = dd_real(6.931471805599452862e-01, + 2.319046813846299558e-17); +const dd_real dd_real::_log10 = dd_real(2.302585092994045901e+00, + -2.170756223382249351e-16); +const dd_real dd_real::_nan = dd_real(qd::_d_nan, qd::_d_nan); +const dd_real dd_real::_inf = dd_real(qd::_d_inf, qd::_d_inf); + +const double dd_real::_eps = 4.93038065763132e-32; // 2^-104 +const double dd_real::_min_normalized = 2.0041683600089728e-292; // = 2^(-1022 + 53) +const dd_real dd_real::_max = + dd_real(1.79769313486231570815e+308, 9.97920154767359795037e+291); +const dd_real dd_real::_safe_max = + dd_real(1.7976931080746007281e+308, 9.97920154767359795037e+291); +const int dd_real::_ndigits = 31; + + diff --git a/external/PackedCSparse/qd/dd_inline.h b/external/PackedCSparse/qd/dd_inline.h new file mode 100644 index 000000000..89bc24f2a --- /dev/null +++ b/external/PackedCSparse/qd/dd_inline.h @@ -0,0 +1,621 @@ +/* + * include/dd_inline.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains small functions (suitable for inlining) in the double-double + * arithmetic package. + */ +#ifndef _QD_DD_INLINE_H +#define _QD_DD_INLINE_H + +#include +#include "inline.h" + +#ifndef QD_INLINE +#define inline +#endif + + +/*********** Additions ************/ +/* double-double = double + double */ +inline dd_real dd_real::add(double a, double b) { + double s, e; + s = qd::two_sum(a, b, e); + return dd_real(s, e); +} + +/* double-double + double */ +inline dd_real operator+(const dd_real &a, double b) { + double s1, s2; + s1 = qd::two_sum(a.x[0], b, s2); + s2 += a.x[1]; + s1 = qd::quick_two_sum(s1, s2, s2); + return dd_real(s1, s2); +} + +/* double-double + double-double */ +inline dd_real dd_real::ieee_add(const dd_real &a, const dd_real &b) { + /* This one satisfies IEEE style error bound, + due to K. Briggs and W. Kahan. */ + double s1, s2, t1, t2; + + s1 = qd::two_sum(a.x[0], b.x[0], s2); + t1 = qd::two_sum(a.x[1], b.x[1], t2); + s2 += t1; + s1 = qd::quick_two_sum(s1, s2, s2); + s2 += t2; + s1 = qd::quick_two_sum(s1, s2, s2); + return dd_real(s1, s2); +} + +inline dd_real dd_real::sloppy_add(const dd_real &a, const dd_real &b) { + /* This is the less accurate version ... obeys Cray-style + error bound. */ + double s, e; + + s = qd::two_sum(a.x[0], b.x[0], e); + e += (a.x[1] + b.x[1]); + s = qd::quick_two_sum(s, e, e); + return dd_real(s, e); +} + +inline dd_real operator+(const dd_real &a, const dd_real &b) { +#ifndef QD_IEEE_ADD + return dd_real::sloppy_add(a, b); +#else + return dd_real::ieee_add(a, b); +#endif +} + +/* double + double-double */ +inline dd_real operator+(double a, const dd_real &b) { + return (b + a); +} + + +/*********** Self-Additions ************/ +/* double-double += double */ +inline dd_real &dd_real::operator+=(double a) { + double s1, s2; + s1 = qd::two_sum(x[0], a, s2); + s2 += x[1]; + x[0] = qd::quick_two_sum(s1, s2, x[1]); + return *this; +} + +/* double-double += double-double */ +inline dd_real &dd_real::operator+=(const dd_real &a) { +#ifndef QD_IEEE_ADD + double s, e; + s = qd::two_sum(x[0], a.x[0], e); + e += x[1]; + e += a.x[1]; + x[0] = qd::quick_two_sum(s, e, x[1]); + return *this; +#else + double s1, s2, t1, t2; + s1 = qd::two_sum(x[0], a.x[0], s2); + t1 = qd::two_sum(x[1], a.x[1], t2); + s2 += t1; + s1 = qd::quick_two_sum(s1, s2, s2); + s2 += t2; + x[0] = qd::quick_two_sum(s1, s2, x[1]); + return *this; +#endif +} + +/*********** Subtractions ************/ +/* double-double = double - double */ +inline dd_real dd_real::sub(double a, double b) { + double s, e; + s = qd::two_diff(a, b, e); + return dd_real(s, e); +} + +/* double-double - double */ +inline dd_real operator-(const dd_real &a, double b) { + double s1, s2; + s1 = qd::two_diff(a.x[0], b, s2); + s2 += a.x[1]; + s1 = qd::quick_two_sum(s1, s2, s2); + return dd_real(s1, s2); +} + +/* double-double - double-double */ +inline dd_real operator-(const dd_real &a, const dd_real &b) { +#ifndef QD_IEEE_ADD + double s, e; + s = qd::two_diff(a.x[0], b.x[0], e); + e += a.x[1]; + e -= b.x[1]; + s = qd::quick_two_sum(s, e, e); + return dd_real(s, e); +#else + double s1, s2, t1, t2; + s1 = qd::two_diff(a.x[0], b.x[0], s2); + t1 = qd::two_diff(a.x[1], b.x[1], t2); + s2 += t1; + s1 = qd::quick_two_sum(s1, s2, s2); + s2 += t2; + s1 = qd::quick_two_sum(s1, s2, s2); + return dd_real(s1, s2); +#endif +} + +/* double - double-double */ +inline dd_real operator-(double a, const dd_real &b) { + double s1, s2; + s1 = qd::two_diff(a, b.x[0], s2); + s2 -= b.x[1]; + s1 = qd::quick_two_sum(s1, s2, s2); + return dd_real(s1, s2); +} + +/*********** Self-Subtractions ************/ +/* double-double -= double */ +inline dd_real &dd_real::operator-=(double a) { + double s1, s2; + s1 = qd::two_diff(x[0], a, s2); + s2 += x[1]; + x[0] = qd::quick_two_sum(s1, s2, x[1]); + return *this; +} + +/* double-double -= double-double */ +inline dd_real &dd_real::operator-=(const dd_real &a) { +#ifndef QD_IEEE_ADD + double s, e; + s = qd::two_diff(x[0], a.x[0], e); + e += x[1]; + e -= a.x[1]; + x[0] = qd::quick_two_sum(s, e, x[1]); + return *this; +#else + double s1, s2, t1, t2; + s1 = qd::two_diff(x[0], a.x[0], s2); + t1 = qd::two_diff(x[1], a.x[1], t2); + s2 += t1; + s1 = qd::quick_two_sum(s1, s2, s2); + s2 += t2; + x[0] = qd::quick_two_sum(s1, s2, x[1]); + return *this; +#endif +} + +/*********** Unary Minus ***********/ +inline dd_real dd_real::operator-() const { + return dd_real(-x[0], -x[1]); +} + +/*********** Multiplications ************/ +/* double-double = double * double */ +inline dd_real dd_real::mul(double a, double b) { + double p, e; + p = qd::two_prod(a, b, e); + return dd_real(p, e); +} + +/* double-double * (2.0 ^ exp) */ +inline dd_real ldexp(const dd_real &a, int exp) { + return dd_real(std::ldexp(a.x[0], exp), std::ldexp(a.x[1], exp)); +} + +/* double-double * double, where double is a power of 2. */ +inline dd_real mul_pwr2(const dd_real &a, double b) { + return dd_real(a.x[0] * b, a.x[1] * b); +} + +/* double-double * double */ +inline dd_real operator*(const dd_real &a, double b) { + double p1, p2; + + p1 = qd::two_prod(a.x[0], b, p2); + p2 += (a.x[1] * b); + p1 = qd::quick_two_sum(p1, p2, p2); + return dd_real(p1, p2); +} + +/* double-double * double-double */ +inline dd_real operator*(const dd_real &a, const dd_real &b) { + double p1, p2; + + p1 = qd::two_prod(a.x[0], b.x[0], p2); + p2 += (a.x[0] * b.x[1] + a.x[1] * b.x[0]); + p1 = qd::quick_two_sum(p1, p2, p2); + return dd_real(p1, p2); +} + +/* double * double-double */ +inline dd_real operator*(double a, const dd_real &b) { + return (b * a); +} + +/*********** Self-Multiplications ************/ +/* double-double *= double */ +inline dd_real &dd_real::operator*=(double a) { + double p1, p2; + p1 = qd::two_prod(x[0], a, p2); + p2 += x[1] * a; + x[0] = qd::quick_two_sum(p1, p2, x[1]); + return *this; +} + +/* double-double *= double-double */ +inline dd_real &dd_real::operator*=(const dd_real &a) { + double p1, p2; + p1 = qd::two_prod(x[0], a.x[0], p2); + p2 += a.x[1] * x[0]; + p2 += a.x[0] * x[1]; + x[0] = qd::quick_two_sum(p1, p2, x[1]); + return *this; +} + +/*********** Divisions ************/ +inline dd_real dd_real::div(double a, double b) { + double q1, q2; + double p1, p2; + double s, e; + + q1 = a / b; + + /* Compute a - q1 * b */ + p1 = qd::two_prod(q1, b, p2); + s = qd::two_diff(a, p1, e); + e -= p2; + + /* get next approximation */ + q2 = (s + e) / b; + + s = qd::quick_two_sum(q1, q2, e); + + return dd_real(s, e); +} + +/* double-double / double */ +inline dd_real operator/(const dd_real &a, double b) { + + double q1, q2; + double p1, p2; + double s, e; + dd_real r; + + q1 = a.x[0] / b; /* approximate quotient. */ + + /* Compute this - q1 * d */ + p1 = qd::two_prod(q1, b, p2); + s = qd::two_diff(a.x[0], p1, e); + e += a.x[1]; + e -= p2; + + /* get next approximation. */ + q2 = (s + e) / b; + + /* renormalize */ + r.x[0] = qd::quick_two_sum(q1, q2, r.x[1]); + + return r; +} + +inline dd_real dd_real::sloppy_div(const dd_real &a, const dd_real &b) { + double s1, s2; + double q1, q2; + dd_real r; + + q1 = a.x[0] / b.x[0]; /* approximate quotient */ + + /* compute this - q1 * dd */ + r = b * q1; + s1 = qd::two_diff(a.x[0], r.x[0], s2); + s2 -= r.x[1]; + s2 += a.x[1]; + + /* get next approximation */ + q2 = (s1 + s2) / b.x[0]; + + /* renormalize */ + r.x[0] = qd::quick_two_sum(q1, q2, r.x[1]); + return r; +} + +inline dd_real dd_real::accurate_div(const dd_real &a, const dd_real &b) { + double q1, q2, q3; + dd_real r; + + q1 = a.x[0] / b.x[0]; /* approximate quotient */ + + r = a - q1 * b; + + q2 = r.x[0] / b.x[0]; + r -= (q2 * b); + + q3 = r.x[0] / b.x[0]; + + q1 = qd::quick_two_sum(q1, q2, q2); + r = dd_real(q1, q2) + q3; + return r; +} + +/* double-double / double-double */ +inline dd_real operator/(const dd_real &a, const dd_real &b) { +#ifdef QD_SLOPPY_DIV + return dd_real::sloppy_div(a, b); +#else + return dd_real::accurate_div(a, b); +#endif +} + +/* double / double-double */ +inline dd_real operator/(double a, const dd_real &b) { + return dd_real(a) / b; +} + +inline dd_real inv(const dd_real &a) { + return 1.0 / a; +} + +/*********** Self-Divisions ************/ +/* double-double /= double */ +inline dd_real &dd_real::operator/=(double a) { + *this = *this / a; + return *this; +} + +/* double-double /= double-double */ +inline dd_real &dd_real::operator/=(const dd_real &a) { + *this = *this / a; + return *this; +} + +/********** Remainder **********/ +inline dd_real drem(const dd_real &a, const dd_real &b) { + dd_real n = nint(a / b); + return (a - n * b); +} + +inline dd_real divrem(const dd_real &a, const dd_real &b, dd_real &r) { + dd_real n = nint(a / b); + r = a - n * b; + return n; +} + +/*********** Squaring **********/ +inline dd_real sqr(const dd_real &a) { + double p1, p2; + double s1, s2; + p1 = qd::two_sqr(a.x[0], p2); + p2 += 2.0 * a.x[0] * a.x[1]; + p2 += a.x[1] * a.x[1]; + s1 = qd::quick_two_sum(p1, p2, s2); + return dd_real(s1, s2); +} + +inline dd_real dd_real::sqr(double a) { + double p1, p2; + p1 = qd::two_sqr(a, p2); + return dd_real(p1, p2); +} + + +/********** Exponentiation **********/ +inline dd_real dd_real::operator^(int n) { + return npwr(*this, n); +} + + +/*********** Assignments ************/ +/* double-double = double */ +inline dd_real &dd_real::operator=(double a) { + x[0] = a; + x[1] = 0.0; + return *this; +} + +/*********** Equality Comparisons ************/ +/* double-double == double */ +inline bool operator==(const dd_real &a, double b) { + return (a.x[0] == b && a.x[1] == 0.0); +} + +/* double-double == double-double */ +inline bool operator==(const dd_real &a, const dd_real &b) { + return (a.x[0] == b.x[0] && a.x[1] == b.x[1]); +} + +/* double == double-double */ +inline bool operator==(double a, const dd_real &b) { + return (a == b.x[0] && b.x[1] == 0.0); +} + +/*********** Greater-Than Comparisons ************/ +/* double-double > double */ +inline bool operator>(const dd_real &a, double b) { + return (a.x[0] > b || (a.x[0] == b && a.x[1] > 0.0)); +} + +/* double-double > double-double */ +inline bool operator>(const dd_real &a, const dd_real &b) { + return (a.x[0] > b.x[0] || (a.x[0] == b.x[0] && a.x[1] > b.x[1])); +} + +/* double > double-double */ +inline bool operator>(double a, const dd_real &b) { + return (a > b.x[0] || (a == b.x[0] && b.x[1] < 0.0)); +} + +/*********** Less-Than Comparisons ************/ +/* double-double < double */ +inline bool operator<(const dd_real &a, double b) { + return (a.x[0] < b || (a.x[0] == b && a.x[1] < 0.0)); +} + +/* double-double < double-double */ +inline bool operator<(const dd_real &a, const dd_real &b) { + return (a.x[0] < b.x[0] || (a.x[0] == b.x[0] && a.x[1] < b.x[1])); +} + +/* double < double-double */ +inline bool operator<(double a, const dd_real &b) { + return (a < b.x[0] || (a == b.x[0] && b.x[1] > 0.0)); +} + +/*********** Greater-Than-Or-Equal-To Comparisons ************/ +/* double-double >= double */ +inline bool operator>=(const dd_real &a, double b) { + return (a.x[0] > b || (a.x[0] == b && a.x[1] >= 0.0)); +} + +/* double-double >= double-double */ +inline bool operator>=(const dd_real &a, const dd_real &b) { + return (a.x[0] > b.x[0] || (a.x[0] == b.x[0] && a.x[1] >= b.x[1])); +} + +/* double >= double-double */ +inline bool operator>=(double a, const dd_real &b) { + return (b <= a); +} + +/*********** Less-Than-Or-Equal-To Comparisons ************/ +/* double-double <= double */ +inline bool operator<=(const dd_real &a, double b) { + return (a.x[0] < b || (a.x[0] == b && a.x[1] <= 0.0)); +} + +/* double-double <= double-double */ +inline bool operator<=(const dd_real &a, const dd_real &b) { + return (a.x[0] < b.x[0] || (a.x[0] == b.x[0] && a.x[1] <= b.x[1])); +} + +/* double <= double-double */ +inline bool operator<=(double a, const dd_real &b) { + return (b >= a); +} + +/*********** Not-Equal-To Comparisons ************/ +/* double-double != double */ +inline bool operator!=(const dd_real &a, double b) { + return (a.x[0] != b || a.x[1] != 0.0); +} + +/* double-double != double-double */ +inline bool operator!=(const dd_real &a, const dd_real &b) { + return (a.x[0] != b.x[0] || a.x[1] != b.x[1]); +} + +/* double != double-double */ +inline bool operator!=(double a, const dd_real &b) { + return (a != b.x[0] || b.x[1] != 0.0); +} + +/*********** Micellaneous ************/ +/* this == 0 */ +inline bool dd_real::is_zero() const { + return (x[0] == 0.0); +} + +/* this == 1 */ +inline bool dd_real::is_one() const { + return (x[0] == 1.0 && x[1] == 0.0); +} + +/* this > 0 */ +inline bool dd_real::is_positive() const { + return (x[0] > 0.0); +} + +/* this < 0 */ +inline bool dd_real::is_negative() const { + return (x[0] < 0.0); +} + +inline dd_real::operator bool() const { + return (x[0] != 0.0); +} + +inline dd_real::operator double() const { + return to_double(*this); +} + +/* Absolute value */ +inline dd_real abs(const dd_real &a) { + return (a.x[0] < 0.0) ? -a : a; +} + +inline dd_real fabs(const dd_real &a) { + return abs(a); +} + +/* Round to Nearest integer */ +inline dd_real nint(const dd_real &a) { + double hi = qd::nint(a.x[0]); + double lo; + + if (hi == a.x[0]) { + /* High word is an integer already. Round the low word.*/ + lo = qd::nint(a.x[1]); + + /* Renormalize. This is needed if x[0] = some integer, x[1] = 1/2.*/ + hi = qd::quick_two_sum(hi, lo, lo); + } else { + /* High word is not an integer. */ + lo = 0.0; + if (std::abs(hi-a.x[0]) == 0.5 && a.x[1] < 0.0) { + /* There is a tie in the high word, consult the low word + to break the tie. */ + hi -= 1.0; /* NOTE: This does not cause INEXACT. */ + } + } + + return dd_real(hi, lo); +} + +inline dd_real floor(const dd_real &a) { + double hi = std::floor(a.x[0]); + double lo = 0.0; + + if (hi == a.x[0]) { + /* High word is integer already. Round the low word. */ + lo = std::floor(a.x[1]); + hi = qd::quick_two_sum(hi, lo, lo); + } + + return dd_real(hi, lo); +} + +inline dd_real ceil(const dd_real &a) { + double hi = std::ceil(a.x[0]); + double lo = 0.0; + + if (hi == a.x[0]) { + /* High word is integer already. Round the low word. */ + lo = std::ceil(a.x[1]); + hi = qd::quick_two_sum(hi, lo, lo); + } + + return dd_real(hi, lo); +} + +inline dd_real aint(const dd_real &a) { + return (a.x[0] >= 0.0) ? floor(a) : ceil(a); +} + +/* Cast to double. */ +inline double to_double(const dd_real &a) { + return a.x[0]; +} + +/* Cast to int. */ +inline int to_int(const dd_real &a) { + return static_cast(a.x[0]); +} + +/* Random number generator */ +inline dd_real dd_real::rand() { + return ddrand(); +} + +#endif /* _QD_DD_INLINE_H */ diff --git a/external/PackedCSparse/qd/dd_real.cc b/external/PackedCSparse/qd/dd_real.cc new file mode 100644 index 000000000..ff4d52231 --- /dev/null +++ b/external/PackedCSparse/qd/dd_real.cc @@ -0,0 +1,1303 @@ +/* + * src/dd_real.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2007 + * + * Contains implementation of non-inlined functions of double-double + * package. Inlined functions are found in dd_inline.h (in include directory). + */ +#include +#include +#include +#include +#include +#include +#include + +#include "qd_config.h" +#include "dd_real.h" +#include "util.h" + +#include "bits.h" + +#ifndef QD_INLINE +#include "dd_inline.h" +#endif + +using std::cout; +using std::cerr; +using std::endl; +using std::ostream; +using std::istream; +using std::ios_base; +using std::string; +using std::setw; + +/* This routine is called whenever a fatal error occurs. */ +void dd_real::error(const char *msg) { + //if (msg) { cerr << "ERROR " << msg << endl; } +} + +/* Computes the square root of the double-double number dd. + NOTE: dd must be a non-negative number. */ +QD_API dd_real sqrt(const dd_real &a) { + /* Strategy: Use Karp's trick: if x is an approximation + to sqrt(a), then + + sqrt(a) = a*x + [a - (a*x)^2] * x / 2 (approx) + + The approximation is accurate to twice the accuracy of x. + Also, the multiplication (a*x) and [-]*x can be done with + only half the precision. + */ + + if (a.is_zero()) + return 0.0; + + if (a.is_negative()) { + dd_real::error("(dd_real::sqrt): Negative argument."); + return dd_real::_nan; + } + + double x = 1.0 / std::sqrt(a.x[0]); + double ax = a.x[0] * x; + return dd_real::add(ax, (a - dd_real::sqr(ax)).x[0] * (x * 0.5)); +} + +/* Computes the square root of a double in double-double precision. + NOTE: d must not be negative. */ +dd_real dd_real::sqrt(double d) { + return ::sqrt(dd_real(d)); +} + +/* Computes the n-th root of the double-double number a. + NOTE: n must be a positive integer. + NOTE: If n is even, then a must not be negative. */ +dd_real nroot(const dd_real &a, int n) { + /* Strategy: Use Newton iteration for the function + + f(x) = x^(-n) - a + + to find its root a^{-1/n}. The iteration is thus + + x' = x + x * (1 - a * x^n) / n + + which converges quadratically. We can then find + a^{1/n} by taking the reciprocal. + */ + + if (n <= 0) { + dd_real::error("(dd_real::nroot): N must be positive."); + return dd_real::_nan; + } + + if (n%2 == 0 && a.is_negative()) { + dd_real::error("(dd_real::nroot): Negative argument."); + return dd_real::_nan; + } + + if (n == 1) { + return a; + } + if (n == 2) { + return sqrt(a); + } + + if (a.is_zero()) + return 0.0; + + /* Note a^{-1/n} = exp(-log(a)/n) */ + dd_real r = abs(a); + dd_real x = std::exp(-std::log(r.x[0]) / n); + + /* Perform Newton's iteration. */ + x += x * (1.0 - r * npwr(x, n)) / static_cast(n); + if (a.x[0] < 0.0) + x = -x; + return 1.0/x; +} + +/* Computes the n-th power of a double-double number. + NOTE: 0^0 causes an error. */ +dd_real npwr(const dd_real &a, int n) { + + if (n == 0) { + if (a.is_zero()) { + dd_real::error("(dd_real::npwr): Invalid argument."); + return dd_real::_nan; + } + return 1.0; + } + + dd_real r = a; + dd_real s = 1.0; + int N = std::abs(n); + + if (N > 1) { + /* Use binary exponentiation */ + while (N > 0) { + if (N % 2 == 1) { + s *= r; + } + N /= 2; + if (N > 0) + r = sqr(r); + } + } else { + s = r; + } + + /* Compute the reciprocal if n is negative. */ + if (n < 0) + return (1.0 / s); + + return s; +} + +dd_real pow(const dd_real &a, int n) { + return npwr(a, n); +} + +dd_real pow(const dd_real &a, const dd_real &b) { + return exp(b * log(a)); +} + +static const int n_inv_fact = 15; +static const double inv_fact[n_inv_fact][2] = { + { 1.66666666666666657e-01, 9.25185853854297066e-18}, + { 4.16666666666666644e-02, 2.31296463463574266e-18}, + { 8.33333333333333322e-03, 1.15648231731787138e-19}, + { 1.38888888888888894e-03, -5.30054395437357706e-20}, + { 1.98412698412698413e-04, 1.72095582934207053e-22}, + { 2.48015873015873016e-05, 2.15119478667758816e-23}, + { 2.75573192239858925e-06, -1.85839327404647208e-22}, + { 2.75573192239858883e-07, 2.37677146222502973e-23}, + { 2.50521083854417202e-08, -1.44881407093591197e-24}, + { 2.08767569878681002e-09, -1.20734505911325997e-25}, + { 1.60590438368216133e-10, 1.25852945887520981e-26}, + { 1.14707455977297245e-11, 2.06555127528307454e-28}, + { 7.64716373181981641e-13, 7.03872877733453001e-30}, + { 4.77947733238738525e-14, 4.39920548583408126e-31}, + { 2.81145725434552060e-15, 1.65088427308614326e-31} +}; + +/* Exponential. Computes exp(x) in double-double precision. */ +dd_real exp(const dd_real &a) { + /* Strategy: We first reduce the size of x by noting that + + exp(kr + m * log(2)) = 2^m * exp(r)^k + + where m and k are integers. By choosing m appropriately + we can make |kr| <= log(2) / 2 = 0.347. Then exp(r) is + evaluated using the familiar Taylor series. Reducing the + argument substantially speeds up the convergence. */ + + const double k = 512.0; + const double inv_k = 1.0 / k; + + if (a.x[0] <= -709.0) + return 0.0; + + if (a.x[0] >= 709.0) + return dd_real::_inf; + + if (a.is_zero()) + return 1.0; + + if (a.is_one()) + return dd_real::_e; + + double m = std::floor(a.x[0] / dd_real::_log2.x[0] + 0.5); + dd_real r = mul_pwr2(a - dd_real::_log2 * m, inv_k); + dd_real s, t, p; + + p = sqr(r); + s = r + mul_pwr2(p, 0.5); + p *= r; + t = p * dd_real(inv_fact[0][0], inv_fact[0][1]); + int i = 0; + do { + s += t; + p *= r; + ++i; + t = p * dd_real(inv_fact[i][0], inv_fact[i][1]); + } while (std::abs(to_double(t)) > inv_k * dd_real::_eps && i < 5); + + s += t; + + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s += 1.0; + + return ldexp(s, static_cast(m)); +} + +/* Logarithm. Computes log(x) in double-double precision. + This is a natural logarithm (i.e., base e). */ +dd_real log(const dd_real &a) { + /* Strategy. The Taylor series for log converges much more + slowly than that of exp, due to the lack of the factorial + term in the denominator. Hence this routine instead tries + to determine the root of the function + + f(x) = exp(x) - a + + using Newton iteration. The iteration is given by + + x' = x - f(x)/f'(x) + = x - (1 - a * exp(-x)) + = x + a * exp(-x) - 1. + + Only one iteration is needed, since Newton's iteration + approximately doubles the number of digits per iteration. */ + + if (a.is_one()) { + return 0.0; + } + + if (a.x[0] <= 0.0) { + dd_real::error("(dd_real::log): Non-positive argument."); + return dd_real::_nan; + } + + dd_real x = std::log(a.x[0]); /* Initial approximation */ + + x = x + a * exp(-x) - 1.0; + return x; +} + +dd_real log10(const dd_real &a) { + return log(a) / dd_real::_log10; +} + +static const dd_real _pi16 = dd_real(1.963495408493620697e-01, + 7.654042494670957545e-18); + +/* Table of sin(k * pi/16) and cos(k * pi/16). */ +static const double sin_table [4][2] = { + {1.950903220161282758e-01, -7.991079068461731263e-18}, + {3.826834323650897818e-01, -1.005077269646158761e-17}, + {5.555702330196021776e-01, 4.709410940561676821e-17}, + {7.071067811865475727e-01, -4.833646656726456726e-17} +}; + +static const double cos_table [4][2] = { + {9.807852804032304306e-01, 1.854693999782500573e-17}, + {9.238795325112867385e-01, 1.764504708433667706e-17}, + {8.314696123025452357e-01, 1.407385698472802389e-18}, + {7.071067811865475727e-01, -4.833646656726456726e-17} +}; + +/* Computes sin(a) using Taylor series. + Assumes |a| <= pi/32. */ +static dd_real sin_taylor(const dd_real &a) { + const double thresh = 0.5 * std::abs(to_double(a)) * dd_real::_eps; + dd_real r, s, t, x; + + if (a.is_zero()) { + return 0.0; + } + + int i = 0; + x = -sqr(a); + s = a; + r = a; + do { + r *= x; + t = r * dd_real(inv_fact[i][0], inv_fact[i][1]); + s += t; + i += 2; + } while (i < n_inv_fact && std::abs(to_double(t)) > thresh); + + return s; +} + +static dd_real cos_taylor(const dd_real &a) { + const double thresh = 0.5 * dd_real::_eps; + dd_real r, s, t, x; + + if (a.is_zero()) { + return 1.0; + } + + x = -sqr(a); + r = x; + s = 1.0 + mul_pwr2(r, 0.5); + int i = 1; + do { + r *= x; + t = r * dd_real(inv_fact[i][0], inv_fact[i][1]); + s += t; + i += 2; + } while (i < n_inv_fact && std::abs(to_double(t)) > thresh); + + return s; +} + +static void sincos_taylor(const dd_real &a, + dd_real &sin_a, dd_real &cos_a) { + if (a.is_zero()) { + sin_a = 0.0; + cos_a = 1.0; + return; + } + + sin_a = sin_taylor(a); + cos_a = sqrt(1.0 - sqr(sin_a)); +} + + +dd_real sin(const dd_real &a) { + + /* Strategy. To compute sin(x), we choose integers a, b so that + + x = s + a * (pi/2) + b * (pi/16) + + and |s| <= pi/32. Using the fact that + + sin(pi/16) = 0.5 * sqrt(2 - sqrt(2 + sqrt(2))) + + we can compute sin(x) from sin(s), cos(s). This greatly + increases the convergence of the sine Taylor series. */ + + if (a.is_zero()) { + return 0.0; + } + + // approximately reduce modulo 2*pi + dd_real z = nint(a / dd_real::_2pi); + dd_real r = a - dd_real::_2pi * z; + + // approximately reduce modulo pi/2 and then modulo pi/16. + dd_real t; + double q = std::floor(r.x[0] / dd_real::_pi2.x[0] + 0.5); + t = r - dd_real::_pi2 * q; + int j = static_cast(q); + q = std::floor(t.x[0] / _pi16.x[0] + 0.5); + t -= _pi16 * q; + int k = static_cast(q); + int abs_k = std::abs(k); + + if (j < -2 || j > 2) { + dd_real::error("(dd_real::sin): Cannot reduce modulo pi/2."); + return dd_real::_nan; + } + + if (abs_k > 4) { + dd_real::error("(dd_real::sin): Cannot reduce modulo pi/16."); + return dd_real::_nan; + } + + if (k == 0) { + switch (j) { + case 0: + return sin_taylor(t); + case 1: + return cos_taylor(t); + case -1: + return -cos_taylor(t); + default: + return -sin_taylor(t); + } + } + + dd_real u(cos_table[abs_k-1][0], cos_table[abs_k-1][1]); + dd_real v(sin_table[abs_k-1][0], sin_table[abs_k-1][1]); + dd_real sin_t, cos_t; + sincos_taylor(t, sin_t, cos_t); + if (j == 0) { + if (k > 0) { + r = u * sin_t + v * cos_t; + } else { + r = u * sin_t - v * cos_t; + } + } else if (j == 1) { + if (k > 0) { + r = u * cos_t - v * sin_t; + } else { + r = u * cos_t + v * sin_t; + } + } else if (j == -1) { + if (k > 0) { + r = v * sin_t - u * cos_t; + } else if (k < 0) { + r = -u * cos_t - v * sin_t; + } + } else { + if (k > 0) { + r = -u * sin_t - v * cos_t; + } else { + r = v * cos_t - u * sin_t; + } + } + + return r; +} + +dd_real cos(const dd_real &a) { + + if (a.is_zero()) { + return 1.0; + } + + // approximately reduce modulo 2*pi + dd_real z = nint(a / dd_real::_2pi); + dd_real r = a - z * dd_real::_2pi; + + // approximately reduce modulo pi/2 and then modulo pi/16 + dd_real t; + double q = std::floor(r.x[0] / dd_real::_pi2.x[0] + 0.5); + t = r - dd_real::_pi2 * q; + int j = static_cast(q); + q = std::floor(t.x[0] / _pi16.x[0] + 0.5); + t -= _pi16 * q; + int k = static_cast(q); + int abs_k = std::abs(k); + + if (j < -2 || j > 2) { + dd_real::error("(dd_real::cos): Cannot reduce modulo pi/2."); + return dd_real::_nan; + } + + if (abs_k > 4) { + dd_real::error("(dd_real::cos): Cannot reduce modulo pi/16."); + return dd_real::_nan; + } + + if (k == 0) { + switch (j) { + case 0: + return cos_taylor(t); + case 1: + return -sin_taylor(t); + case -1: + return sin_taylor(t); + default: + return -cos_taylor(t); + } + } + + dd_real sin_t, cos_t; + sincos_taylor(t, sin_t, cos_t); + dd_real u(cos_table[abs_k-1][0], cos_table[abs_k-1][1]); + dd_real v(sin_table[abs_k-1][0], sin_table[abs_k-1][1]); + + if (j == 0) { + if (k > 0) { + r = u * cos_t - v * sin_t; + } else { + r = u * cos_t + v * sin_t; + } + } else if (j == 1) { + if (k > 0) { + r = - u * sin_t - v * cos_t; + } else { + r = v * cos_t - u * sin_t; + } + } else if (j == -1) { + if (k > 0) { + r = u * sin_t + v * cos_t; + } else { + r = u * sin_t - v * cos_t; + } + } else { + if (k > 0) { + r = v * sin_t - u * cos_t; + } else { + r = - u * cos_t - v * sin_t; + } + } + + return r; +} + +void sincos(const dd_real &a, dd_real &sin_a, dd_real &cos_a) { + + if (a.is_zero()) { + sin_a = 0.0; + cos_a = 1.0; + return; + } + + // approximately reduce modulo 2*pi + dd_real z = nint(a / dd_real::_2pi); + dd_real r = a - dd_real::_2pi * z; + + // approximately reduce module pi/2 and pi/16 + dd_real t; + double q = std::floor(r.x[0] / dd_real::_pi2.x[0] + 0.5); + t = r - dd_real::_pi2 * q; + int j = static_cast(q); + int abs_j = std::abs(j); + q = std::floor(t.x[0] / _pi16.x[0] + 0.5); + t -= _pi16 * q; + int k = static_cast(q); + int abs_k = std::abs(k); + + if (abs_j > 2) { + dd_real::error("(dd_real::sincos): Cannot reduce modulo pi/2."); + cos_a = sin_a = dd_real::_nan; + return; + } + + if (abs_k > 4) { + dd_real::error("(dd_real::sincos): Cannot reduce modulo pi/16."); + cos_a = sin_a = dd_real::_nan; + return; + } + + dd_real sin_t, cos_t; + dd_real s, c; + + sincos_taylor(t, sin_t, cos_t); + + if (abs_k == 0) { + s = sin_t; + c = cos_t; + } else { + dd_real u(cos_table[abs_k-1][0], cos_table[abs_k-1][1]); + dd_real v(sin_table[abs_k-1][0], sin_table[abs_k-1][1]); + + if (k > 0) { + s = u * sin_t + v * cos_t; + c = u * cos_t - v * sin_t; + } else { + s = u * sin_t - v * cos_t; + c = u * cos_t + v * sin_t; + } + } + + if (abs_j == 0) { + sin_a = s; + cos_a = c; + } else if (j == 1) { + sin_a = c; + cos_a = -s; + } else if (j == -1) { + sin_a = -c; + cos_a = s; + } else { + sin_a = -s; + cos_a = -c; + } + +} + +dd_real atan(const dd_real &a) { + return atan2(a, dd_real(1.0)); +} + +dd_real atan2(const dd_real &y, const dd_real &x) { + /* Strategy: Instead of using Taylor series to compute + arctan, we instead use Newton's iteration to solve + the equation + + sin(z) = y/r or cos(z) = x/r + + where r = sqrt(x^2 + y^2). + The iteration is given by + + z' = z + (y - sin(z)) / cos(z) (for equation 1) + z' = z - (x - cos(z)) / sin(z) (for equation 2) + + Here, x and y are normalized so that x^2 + y^2 = 1. + If |x| > |y|, then first iteration is used since the + denominator is larger. Otherwise, the second is used. + */ + + if (x.is_zero()) { + + if (y.is_zero()) { + /* Both x and y is zero. */ + dd_real::error("(dd_real::atan2): Both arguments zero."); + return dd_real::_nan; + } + + return (y.is_positive()) ? dd_real::_pi2 : -dd_real::_pi2; + } else if (y.is_zero()) { + return (x.is_positive()) ? dd_real(0.0) : dd_real::_pi; + } + + if (x == y) { + return (y.is_positive()) ? dd_real::_pi4 : -dd_real::_3pi4; + } + + if (x == -y) { + return (y.is_positive()) ? dd_real::_3pi4 : -dd_real::_pi4; + } + + dd_real r = sqrt(sqr(x) + sqr(y)); + dd_real xx = x / r; + dd_real yy = y / r; + + /* Compute double precision approximation to atan. */ + dd_real z = std::atan2(to_double(y), to_double(x)); + dd_real sin_z, cos_z; + + if (std::abs(xx.x[0]) > std::abs(yy.x[0])) { + /* Use Newton iteration 1. z' = z + (y - sin(z)) / cos(z) */ + sincos(z, sin_z, cos_z); + z += (yy - sin_z) / cos_z; + } else { + /* Use Newton iteration 2. z' = z - (x - cos(z)) / sin(z) */ + sincos(z, sin_z, cos_z); + z -= (xx - cos_z) / sin_z; + } + + return z; +} + +dd_real tan(const dd_real &a) { + dd_real s, c; + sincos(a, s, c); + return s/c; +} + +dd_real asin(const dd_real &a) { + dd_real abs_a = abs(a); + + if (abs_a > 1.0) { + dd_real::error("(dd_real::asin): Argument out of domain."); + return dd_real::_nan; + } + + if (abs_a.is_one()) { + return (a.is_positive()) ? dd_real::_pi2 : -dd_real::_pi2; + } + + return atan2(a, sqrt(1.0 - sqr(a))); +} + +dd_real acos(const dd_real &a) { + dd_real abs_a = abs(a); + + if (abs_a > 1.0) { + dd_real::error("(dd_real::acos): Argument out of domain."); + return dd_real::_nan; + } + + if (abs_a.is_one()) { + return (a.is_positive()) ? dd_real(0.0) : dd_real::_pi; + } + + return atan2(sqrt(1.0 - sqr(a)), a); +} + +dd_real sinh(const dd_real &a) { + if (a.is_zero()) { + return 0.0; + } + + if (abs(a) > 0.05) { + dd_real ea = exp(a); + return mul_pwr2(ea - inv(ea), 0.5); + } + + /* since a is small, using the above formula gives + a lot of cancellation. So use Taylor series. */ + dd_real s = a; + dd_real t = a; + dd_real r = sqr(t); + double m = 1.0; + double thresh = std::abs((to_double(a)) * dd_real::_eps); + + do { + m += 2.0; + t *= r; + t /= (m-1) * m; + + s += t; + } while (abs(t) > thresh); + + return s; + +} + +dd_real cosh(const dd_real &a) { + if (a.is_zero()) { + return 1.0; + } + + dd_real ea = exp(a); + return mul_pwr2(ea + inv(ea), 0.5); +} + +dd_real tanh(const dd_real &a) { + if (a.is_zero()) { + return 0.0; + } + + if (std::abs(to_double(a)) > 0.05) { + dd_real ea = exp(a); + dd_real inv_ea = inv(ea); + return (ea - inv_ea) / (ea + inv_ea); + } else { + dd_real s, c; + s = sinh(a); + c = sqrt(1.0 + sqr(s)); + return s / c; + } +} + +void sincosh(const dd_real &a, dd_real &s, dd_real &c) { + if (std::abs(to_double(a)) <= 0.05) { + s = sinh(a); + c = sqrt(1.0 + sqr(s)); + } else { + dd_real ea = exp(a); + dd_real inv_ea = inv(ea); + s = mul_pwr2(ea - inv_ea, 0.5); + c = mul_pwr2(ea + inv_ea, 0.5); + } +} + +dd_real asinh(const dd_real &a) { + return log(a + sqrt(sqr(a) + 1.0)); +} + +dd_real acosh(const dd_real &a) { + if (a < 1.0) { + dd_real::error("(dd_real::acosh): Argument out of domain."); + return dd_real::_nan; + } + + return log(a + sqrt(sqr(a) - 1.0)); +} + +dd_real atanh(const dd_real &a) { + if (abs(a) >= 1.0) { + dd_real::error("(dd_real::atanh): Argument out of domain."); + return dd_real::_nan; + } + + return mul_pwr2(log((1.0 + a) / (1.0 - a)), 0.5); +} + +QD_API dd_real fmod(const dd_real &a, const dd_real &b) { + dd_real n = aint(a / b); + return (a - b * n); +} + +QD_API dd_real ddrand() { + static const double m_const = 4.6566128730773926e-10; /* = 2^{-31} */ + double m = m_const; + dd_real r = 0.0; + double d; + + /* Strategy: Generate 31 bits at a time, using lrand48 + random number generator. Shift the bits, and reapeat + 4 times. */ + + for (int i = 0; i < 4; i++, m *= m_const) { +// d = lrand48() * m; + d = std::rand() * m; + r += d; + } + + return r; +} + +/* polyeval(c, n, x) + Evaluates the given n-th degree polynomial at x. + The polynomial is given by the array of (n+1) coefficients. */ +dd_real polyeval(const dd_real *c, int n, const dd_real &x) { + /* Just use Horner's method of polynomial evaluation. */ + dd_real r = c[n]; + + for (int i = n-1; i >= 0; i--) { + r *= x; + r += c[i]; + } + + return r; +} + +/* polyroot(c, n, x0) + Given an n-th degree polynomial, finds a root close to + the given guess x0. Note that this uses simple Newton + iteration scheme, and does not work for multiple roots. */ +QD_API dd_real polyroot(const dd_real *c, int n, + const dd_real &x0, int max_iter, double thresh) { + dd_real x = x0; + dd_real f; + dd_real *d = new dd_real[n]; + bool conv = false; + int i; + double max_c = std::abs(to_double(c[0])); + double v; + + if (thresh == 0.0) thresh = dd_real::_eps; + + /* Compute the coefficients of the derivatives. */ + for (i = 1; i <= n; i++) { + v = std::abs(to_double(c[i])); + if (v > max_c) max_c = v; + d[i-1] = c[i] * static_cast(i); + } + thresh *= max_c; + + /* Newton iteration. */ + for (i = 0; i < max_iter; i++) { + f = polyeval(c, n, x); + + if (abs(f) < thresh) { + conv = true; + break; + } + x -= (f / polyeval(d, n-1, x)); + } + delete [] d; + + if (!conv) { + dd_real::error("(dd_real::polyroot): Failed to converge."); + return dd_real::_nan; + } + + return x; +} + + +/* Constructor. Reads a double-double number from the string s + and constructs a double-double number. */ +dd_real::dd_real(const char *s) { + if (dd_real::read(s, *this)) { + dd_real::error("(dd_real::dd_real): INPUT ERROR."); + *this = dd_real::_nan; + } +} + +dd_real &dd_real::operator=(const char *s) { + if (dd_real::read(s, *this)) { + dd_real::error("(dd_real::operator=): INPUT ERROR."); + *this = dd_real::_nan; + } + return *this; +} + +/* Outputs the double-double number dd. */ +ostream &operator<<(ostream &os, const dd_real &dd) { + bool showpos = (os.flags() & ios_base::showpos) != 0; + bool uppercase = (os.flags() & ios_base::uppercase) != 0; + return os << dd.to_string((int)os.precision(), (int)os.width(), os.flags(), + showpos, uppercase, os.fill()); +} + +/* Reads in the double-double number a. */ +istream &operator>>(istream &s, dd_real &a) { + char str[255]; + s >> str; + a = dd_real(str); + return s; +} + +void dd_real::to_digits(char *s, int &expn, int precision) const { + int D = precision + 1; /* number of digits to compute */ + + dd_real r = abs(*this); + int e; /* exponent */ + int i, d; + + if (x[0] == 0.0) { + /* this == 0.0 */ + expn = 0; + for (i = 0; i < precision; i++) s[i] = '0'; + return; + } + + /* First determine the (approximate) exponent. */ + e = to_int(std::floor(std::log10(std::abs(x[0])))); + + if (e < -300) { + r *= dd_real(10.0) ^ 300; + r /= dd_real(10.0) ^ (e + 300); + } else if (e > 300) { + r = ldexp(r, -53); + r /= dd_real(10.0) ^ e; + r = ldexp(r, 53); + } else { + r /= dd_real(10.0) ^ e; + } + + /* Fix exponent if we are off by one */ + if (r >= 10.0) { + r /= 10.0; + e++; + } else if (r < 1.0) { + r *= 10.0; + e--; + } + + if (r >= 10.0 || r < 1.0) { + dd_real::error("(dd_real::to_digits): can't compute exponent."); + return; + } + + /* Extract the digits */ + for (i = 0; i < D; i++) { + d = static_cast(r.x[0]); + r -= d; + r *= 10.0; + + s[i] = static_cast(d + '0'); + } + + /* Fix out of range digits. */ + for (i = D-1; i > 0; i--) { + if (s[i] < '0') { + s[i-1]--; + s[i] += 10; + } else if (s[i] > '9') { + s[i-1]++; + s[i] -= 10; + } + } + + if (s[0] <= '0') { + dd_real::error("(dd_real::to_digits): non-positive leading digit."); + return; + } + + /* Round, handle carry */ + if (s[D-1] >= '5') { + s[D-2]++; + + i = D-2; + while (i > 0 && s[i] > '9') { + s[i] -= 10; + s[--i]++; + } + } + + /* If first digit is 10, shift everything. */ + if (s[0] > '9') { + e++; + for (i = precision; i >= 2; i--) s[i] = s[i-1]; + s[0] = '1'; + s[1] = '0'; + } + + s[precision] = 0; + expn = e; +} + +/* Writes the double-double number into the character array s of length len. + The integer d specifies how many significant digits to write. + The string s must be able to hold at least (d+8) characters. + showpos indicates whether to use the + sign, and uppercase indicates + whether the E or e is to be used for the exponent. */ +void dd_real::write(char *s, int len, int precision, + bool showpos, bool uppercase) const { + string str = to_string(precision, 0, ios_base::scientific, showpos, uppercase); + std::strncpy(s, str.c_str(), len-1); + s[len-1] = 0; +} + + +void round_string(char *s, int precision, int *offset){ + /* + Input string must be all digits or errors will occur. + */ + + int i; + int D = precision ; + + /* Round, handle carry */ + if (D>0 && s[D] >= '5') { + s[D-1]++; + + i = D-1; + while (i > 0 && s[i] > '9') { + s[i] -= 10; + s[--i]++; + } + } + + /* If first digit is 10, shift everything. */ + if (s[0] > '9') { + // e++; // don't modify exponent here + for (i = precision; i >= 1; i--) s[i+1] = s[i]; + s[0] = '1'; + s[1] = '0'; + + (*offset)++ ; // now offset needs to be increased by one + precision++ ; + } + + s[precision] = 0; // add terminator for array +} + +string dd_real::to_string(int precision, int width, ios_base::fmtflags fmt, + bool showpos, bool uppercase, char fill) const { + string s; + bool fixed = (fmt & ios_base::fixed) != 0; + bool sgn = true; + int i, e = 0; + + if (isnan()) { + s = uppercase ? "NAN" : "nan"; + sgn = false; + } else { + if (*this < 0.0) + s += '-'; + else if (showpos) + s += '+'; + else + sgn = false; + + if (isinf()) { + s += uppercase ? "INF" : "inf"; + } else if (*this == 0.0) { + /* Zero case */ + s += '0'; + if (precision > 0) { + s += '.'; + s.append(precision, '0'); + } + } else { + /* Non-zero case */ + int off = (fixed ? (1 + to_int(floor(log10(abs(*this))))) : 1); + int d = precision + off; + + int d_with_extra = d; + if(fixed) + d_with_extra = std::max(60, d); // longer than the max accuracy for DD + + // highly special case - fixed mode, precision is zero, abs(*this) < 1.0 + // without this trap a number like 0.9 printed fixed with 0 precision prints as 0 + // should be rounded to 1. + if(fixed && (precision == 0) && (abs(*this) < 1.0)){ + if(abs(*this) >= 0.5) + s += '1'; + else + s += '0'; + + return s; + } + + // handle near zero to working precision (but not exactly zero) + if (fixed && d <= 0) { + s += '0'; + if (precision > 0) { + s += '.'; + s.append(precision, '0'); + } + } else { // default + + char *t; // = new char[d+1]; + int j; + + if(fixed){ + t = new char[d_with_extra+1]; + to_digits(t, e, d_with_extra); + } + else{ + t = new char[d+1]; + to_digits(t, e, d); + } + + off = e + 1; + + if (fixed) { + // fix the string if it's been computed incorrectly + // round here in the decimal string if required + round_string(t, d, &off); + + if (off > 0) { + for (i = 0; i < off; i++) s += t[i]; + if (precision > 0) { + s += '.'; + for (j = 0; j < precision; j++, i++) s += t[i]; + } + } else { + s += "0."; + if (off < 0) s.append(-off, '0'); + for (i = 0; i < d; i++) s += t[i]; + } + } else { + s += t[0]; + if (precision > 0) s += '.'; + + for (i = 1; i <= precision; i++) + s += t[i]; + + } + delete [] t; + } + } + + // trap for improper offset with large values + // without this trap, output of values of the for 10^j - 1 fail for j > 28 + // and are output with the point in the wrong place, leading to a dramatically off value + if(fixed && (precision > 0)){ + // make sure that the value isn't dramatically larger + double from_string = atof(s.c_str()); + + // if this ratio is large, then we've got problems + if( fabs( from_string / this->x[0] ) > 3.0 ){ + + // loop on the string, find the point, move it up one + // don't act on the first character + for(i=1; i < (int)s.length(); i++){ + if(s[i] == '.'){ + s[i] = s[i-1] ; + s[i-1] = '.' ; + break; + } + } + + from_string = atof(s.c_str()); + // if this ratio is large, then the string has not been fixed + if( fabs( from_string / this->x[0] ) > 3.0 ){ + dd_real::error("Re-rounding unsuccessful in large number fixed point trap.") ; + } + } + } + + + if (!fixed && !isinf()) { + /* Fill in exponent part */ + s += uppercase ? 'E' : 'e'; + append_expn(s, e); + } + } + + /* Fill in the blanks */ + int len = s.length(); + if (len < width) { + int delta = width - len; + if (fmt & ios_base::internal) { + if (sgn) + s.insert(static_cast(1), delta, fill); + else + s.insert(static_cast(0), delta, fill); + } else if (fmt & ios_base::left) { + s.append(delta, fill); + } else { + s.insert(static_cast(0), delta, fill); + } + } + + return s; +} + +/* Reads in a double-double number from the string s. */ +int dd_real::read(const char *s, dd_real &a) { + const char *p = s; + char ch; + int sign = 0; + int point = -1; + int nd = 0; + int e = 0; + bool done = false; + dd_real r = 0.0; + int nread; + + /* Skip any leading spaces */ + while (*p == ' ') + p++; + + while (!done && (ch = *p) != '\0') { + if (ch >= '0' && ch <= '9') { + int d = ch - '0'; + r *= 10.0; + r += static_cast(d); + nd++; + } else { + + switch (ch) { + + case '.': + if (point >= 0) + return -1; + point = nd; + break; + + case '-': + case '+': + if (sign != 0 || nd > 0) + return -1; + sign = (ch == '-') ? -1 : 1; + break; + + case 'E': + case 'e': + nread = std::sscanf(p+1, "%d", &e); + done = true; + if (nread != 1) + return -1; + break; + + default: + return -1; + } + } + + p++; + } + + if (point >= 0) { + e -= (nd - point); + } + + if (e != 0) { + r *= (dd_real(10.0) ^ e); + } + + a = (sign == -1) ? -r : r; + return 0; +} + +/* Debugging routines */ +void dd_real::dump(const string &name, std::ostream &os) const { + std::ios_base::fmtflags old_flags = os.flags(); + std::streamsize old_prec = os.precision(19); + os << std::scientific; + + if (name.length() > 0) os << name << " = "; + os << "[ " << setw(27) << x[0] << ", " << setw(27) << x[1] << " ]" << endl; + + os.precision(old_prec); + os.flags(old_flags); +} + +void dd_real::dump_bits(const string &name, std::ostream &os) const { + string::size_type len = name.length(); + if (len > 0) { + os << name << " = "; + len +=3; + } + os << "[ "; + len += 2; + print_double_info(os, x[0]); + os << endl; + for (string::size_type i = 0; i < len; i++) os << ' '; + print_double_info(os, x[1]); + os << " ]" << endl; +} + +dd_real dd_real::debug_rand() { + + if (std::rand() % 2 == 0) + return ddrand(); + + int expn = 0; + dd_real a = 0.0; + double d; + for (int i = 0; i < 2; i++) { + d = std::ldexp(static_cast(std::rand()) / RAND_MAX, -expn); + a += d; + expn = expn + 54 + std::rand() % 200; + } + return a; +} diff --git a/external/PackedCSparse/dd_real.h b/external/PackedCSparse/qd/dd_real.h similarity index 92% rename from external/PackedCSparse/dd_real.h rename to external/PackedCSparse/qd/dd_real.h index 5fe3491e5..e16438aa0 100644 --- a/external/PackedCSparse/dd_real.h +++ b/external/PackedCSparse/qd/dd_real.h @@ -1,12 +1,3 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis -// Copyright (c) 2022 Ioannis Iakovidis - -// This file is converted from QD library -//(https://www.davidhbailey.com/dhbsoftware) by Ioannis Iakovidis - /* * include/dd_real.h * @@ -18,14 +9,14 @@ * * Double-double precision (>= 106-bit significand) floating point * arithmetic package based on David Bailey's Fortran-90 double-double - * package, with some changes. See + * package, with some changes. See * * http://www.nersc.gov/~dhbailey/mpdist/mpdist.html - * + * * for the original Fortran-90 version. * * Overall structure is similar to that of Keith Brigg's C++ double-double - * package. See + * package. See * * http://www-epidem.plansci.cam.ac.uk/~kbriggs/doubledouble.html * @@ -42,8 +33,8 @@ #include #include #include -#include "qd/qd_config.h" -#include "qd/fpu.h" +#include "qd_config.h" +#include "fpu.h" // Some compilers define isnan, isfinite, and isinf as macros, even for // C++ codes, which cause havoc when overloading these functions. We undef @@ -70,11 +61,7 @@ struct QD_API dd_real { double x[2]; - inline operator bool() const // new - { - return (x[0] != 0.0); - } dd_real(double hi, double lo) { x[0] = hi; x[1] = lo; } dd_real() {x[0] = 0.0; x[1] = 0.0; } dd_real(double h) { x[0] = h; x[1] = 0.0; } @@ -136,7 +123,7 @@ struct QD_API dd_real { static dd_real div(double a, double b); static dd_real sloppy_div(const dd_real &a, const dd_real &b); static dd_real accurate_div(const dd_real &a, const dd_real &b); - + dd_real &operator/=(double a); dd_real &operator/=(const dd_real &a); @@ -147,26 +134,28 @@ struct QD_API dd_real { static dd_real sqr(double d); static dd_real sqrt(double a); - + bool is_zero() const; bool is_one() const; bool is_positive() const; bool is_negative() const; + explicit operator bool() const; // new + explicit operator double() const; // new static dd_real rand(void); void to_digits(char *s, int &expn, int precision = _ndigits) const; - void write(char *s, int len, int precision = _ndigits, + void write(char *s, int len, int precision = _ndigits, bool showpos = false, bool uppercase = false) const; - std::string to_string(int precision = _ndigits, int width = 0, - std::ios_base::fmtflags fmt = static_cast(0), + std::string to_string(int precision = _ndigits, int width = 0, + std::ios_base::fmtflags fmt = static_cast(0), bool showpos = false, bool uppercase = false, char fill = ' ') const; int read(const char *s, dd_real &a); /* Debugging Methods */ void dump(const std::string &name, std::ostream &os = std::cerr) const; - void dump_bits(const std::string &name, + void dump_bits(const std::string &name, std::ostream &os = std::cerr) const; static dd_real debug_rand(); @@ -190,7 +179,7 @@ QD_API dd_real ddrand(void); QD_API dd_real sqrt(const dd_real &a); QD_API dd_real polyeval(const dd_real *c, int n, const dd_real &x); -QD_API dd_real polyroot(const dd_real *c, int n, +QD_API dd_real polyroot(const dd_real *c, int n, const dd_real &x0, int max_iter = 32, double thresh = 0.0); QD_API inline bool isnan(const dd_real &a) { return a.isnan(); } @@ -282,7 +271,7 @@ QD_API dd_real atan2(const dd_real &y, const dd_real &x); QD_API dd_real sinh(const dd_real &a); QD_API dd_real cosh(const dd_real &a); QD_API dd_real tanh(const dd_real &a); -QD_API void sincosh(const dd_real &a, +QD_API void sincosh(const dd_real &a, dd_real &sinh_a, dd_real &cosh_a); QD_API dd_real asinh(const dd_real &a); @@ -297,7 +286,8 @@ QD_API dd_real fmod(const dd_real &a, const dd_real &b); QD_API std::ostream& operator<<(std::ostream &s, const dd_real &a); QD_API std::istream& operator>>(std::istream &s, dd_real &a); #ifdef QD_INLINE -#include "qd/dd_inline.h" +#include "dd_inline.h" #endif #endif /* _QD_DD_REAL_H */ + diff --git a/external/PackedCSparse/qd/fpu.cc b/external/PackedCSparse/qd/fpu.cc new file mode 100644 index 000000000..96ddc488f --- /dev/null +++ b/external/PackedCSparse/qd/fpu.cc @@ -0,0 +1,124 @@ +/* + * src/fpu.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains functions to set and restore the round-to-double flag in the + * control word of a x86 FPU. + */ + +#include "qd_config.h" +#include "fpu.h" + +#ifdef X86 +#ifdef _WIN32 +#include +#else + +#ifdef HAVE_FPU_CONTROL_H +#include +#endif + +#ifndef _FPU_GETCW +#define _FPU_GETCW(x) asm volatile ("fnstcw %0":"=m" (x)); +#endif + +#ifndef _FPU_SETCW +#define _FPU_SETCW(x) asm volatile ("fldcw %0": :"m" (x)); +#endif + +#ifndef _FPU_EXTENDED +#define _FPU_EXTENDED 0x0300 +#endif + +#ifndef _FPU_DOUBLE +#define _FPU_DOUBLE 0x0200 +#endif + +#endif +#endif /* X86 */ + +extern "C" { + +void fpu_fix_start(unsigned int *old_cw) { +#ifdef X86 +#ifdef _WIN32 +#ifdef __BORLANDC__ + /* Win 32 Borland C */ + unsigned short cw = _control87(0, 0); + _control87(0x0200, 0x0300); + if (old_cw) { + *old_cw = cw; + } +#else + /* Win 32 MSVC */ + unsigned int cw = _control87(0, 0); + _control87(0x00010000, 0x00030000); + if (old_cw) { + *old_cw = cw; + } +#endif +#else + /* Linux */ + volatile unsigned short cw, new_cw; + _FPU_GETCW(cw); + + new_cw = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; + _FPU_SETCW(new_cw); + + if (old_cw) { + *old_cw = cw; + } +#endif +#endif +} + +void fpu_fix_end(unsigned int *old_cw) { +#ifdef X86 +#ifdef _WIN32 + +#ifdef __BORLANDC__ + /* Win 32 Borland C */ + if (old_cw) { + unsigned short cw = (unsigned short) *old_cw; + _control87(cw, 0xFFFF); + } +#else + /* Win 32 MSVC */ + if (old_cw) { + _control87(*old_cw, 0xFFFFFFFF); + } +#endif + +#else + /* Linux */ + if (old_cw) { + int cw; + cw = *old_cw; + _FPU_SETCW(cw); + } +#endif +#endif +} + +#ifdef HAVE_FORTRAN + +#define f_fpu_fix_start FC_FUNC_(f_fpu_fix_start, F_FPU_FIX_START) +#define f_fpu_fix_end FC_FUNC_(f_fpu_fix_end, F_FPU_FIX_END) + +void f_fpu_fix_start(unsigned int *old_cw) { + fpu_fix_start(old_cw); +} + +void f_fpu_fix_end(unsigned int *old_cw) { + fpu_fix_end(old_cw); +} + +#endif + +} + diff --git a/external/PackedCSparse/qd/fpu.h b/external/PackedCSparse/qd/fpu.h new file mode 100644 index 000000000..35eab18cf --- /dev/null +++ b/external/PackedCSparse/qd/fpu.h @@ -0,0 +1,39 @@ +/* + * include/fpu.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2001 + * + * Contains functions to set and restore the round-to-double flag in the + * control word of a x86 FPU. The algorithms in the double-double and + * quad-double package does not function with the extended mode found in + * these FPU. + */ +#ifndef _QD_FPU_H +#define _QD_FPU_H + +#include "qd_config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Set the round-to-double flag, and save the old control word in old_cw. + * If old_cw is NULL, the old control word is not saved. + */ +QD_API void fpu_fix_start(unsigned int *old_cw); + +/* + * Restore the control word. + */ +QD_API void fpu_fix_end(unsigned int *old_cw); + +#ifdef __cplusplus +} +#endif + +#endif /* _QD_FPU_H */ diff --git a/external/PackedCSparse/qd/inline.h b/external/PackedCSparse/qd/inline.h new file mode 100644 index 000000000..52425545b --- /dev/null +++ b/external/PackedCSparse/qd/inline.h @@ -0,0 +1,143 @@ +/* + * include/inline.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * This file contains the basic functions used both by double-double + * and quad-double package. These are declared as inline functions as + * they are the smallest building blocks of the double-double and + * quad-double arithmetic. + */ +#ifndef _QD_INLINE_H +#define _QD_INLINE_H + +#define _QD_SPLITTER 134217729.0 // = 2^27 + 1 +#define _QD_SPLIT_THRESH 6.69692879491417e+299 // = 2^996 + +#ifdef QD_VACPP_BUILTINS_H +/* For VisualAge C++ __fmadd */ +#include +#endif + +#include +#include + +namespace qd { + +static const double _d_nan = std::numeric_limits::quiet_NaN(); +static const double _d_inf = std::numeric_limits::infinity(); + +/*********** Basic Functions ************/ +/* Computes fl(a+b) and err(a+b). Assumes |a| >= |b|. */ +inline double quick_two_sum(double a, double b, double &err) { + double s = a + b; + err = b - (s - a); + return s; +} + +/* Computes fl(a-b) and err(a-b). Assumes |a| >= |b| */ +inline double quick_two_diff(double a, double b, double &err) { + double s = a - b; + err = (a - s) - b; + return s; +} + +/* Computes fl(a+b) and err(a+b). */ +inline double two_sum(double a, double b, double &err) { + double s = a + b; + double bb = s - a; + err = (a - (s - bb)) + (b - bb); + return s; +} + +/* Computes fl(a-b) and err(a-b). */ +inline double two_diff(double a, double b, double &err) { + double s = a - b; + double bb = s - a; + err = (a - (s - bb)) - (b + bb); + return s; +} + +#ifndef QD_FMS +/* Computes high word and lo word of a */ +inline void split(double a, double &hi, double &lo) { + double temp; + if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) { + a *= 3.7252902984619140625e-09; // 2^-28 + temp = _QD_SPLITTER * a; + hi = temp - (temp - a); + lo = a - hi; + hi *= 268435456.0; // 2^28 + lo *= 268435456.0; // 2^28 + } else { + temp = _QD_SPLITTER * a; + hi = temp - (temp - a); + lo = a - hi; + } +} +#endif + +/* Computes fl(a*b) and err(a*b). */ +inline double two_prod(double a, double b, double &err) { +#ifdef QD_FMS + double p = a * b; + err = QD_FMS(a, b, p); + return p; +#else + double a_hi, a_lo, b_hi, b_lo; + double p = a * b; + split(a, a_hi, a_lo); + split(b, b_hi, b_lo); + err = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo; + return p; +#endif +} + +/* Computes fl(a*a) and err(a*a). Faster than the above method. */ +inline double two_sqr(double a, double &err) { +#ifdef QD_FMS + double p = a * a; + err = QD_FMS(a, a, p); + return p; +#else + double hi, lo; + double q = a * a; + split(a, hi, lo); + err = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo; + return q; +#endif +} + +/* Computes the nearest integer to d. */ +inline double nint(double d) { + if (d == std::floor(d)) + return d; + return std::floor(d + 0.5); +} + +/* Computes the truncated integer. */ +inline double aint(double d) { + return (d >= 0.0) ? std::floor(d) : std::ceil(d); +} + +/* These are provided to give consistent + interface for double with double-double and quad-double. */ +inline void sincosh(double t, double &sinh_t, double &cosh_t) { + sinh_t = std::sinh(t); + cosh_t = std::cosh(t); +} + +inline double sqr(double t) { + return t * t; +} + +inline double to_double(double a) { return a; } +inline int to_int(double a) { return static_cast(a); } + +} + +#endif /* _QD_INLINE_H */ diff --git a/external/PackedCSparse/qd/qd.pdf b/external/PackedCSparse/qd/qd.pdf new file mode 100644 index 000000000..9525b8cac Binary files /dev/null and b/external/PackedCSparse/qd/qd.pdf differ diff --git a/external/PackedCSparse/qd/qd_config.h b/external/PackedCSparse/qd/qd_config.h new file mode 100644 index 000000000..d23e33a64 --- /dev/null +++ b/external/PackedCSparse/qd/qd_config.h @@ -0,0 +1,92 @@ +#include +#include + +/* include/qd/qd_config.h. Generated from qd_config.h.in by configure. */ +#ifndef _QD_QD_CONFIG_H +#define _QD_QD_CONFIG_H 1 + +#ifndef QD_API +#define QD_API /**/ +#endif + +/* Set to 1 if using VisualAge C++ compiler for __fmadd builtin. */ +#ifndef QD_VACPP_BUILTINS_H +/* #undef QD_VACPP_BUILTINS_H */ +#endif + +/* If fused multiply-add is available, define to correct macro for + using it. It is invoked as QD_FMA(a, b, c) to compute fl(a * b + c). + If correctly rounded multiply-add is not available (or if unsure), + keep it undefined.*/ +#ifndef QD_FMA +/* #undef QD_FMA */ +#endif + +/* If fused multiply-subtract is available, define to correct macro for + using it. It is invoked as QD_FMS(a, b, c) to compute fl(a * b - c). + If correctly rounded multiply-add is not available (or if unsure), + keep it undefined.*/ +#ifndef QD_FMS +#define QD_FMS(a, b, c) std::fma(a,b,-c) +/* #undef QD_FMS */ +#endif + +/* Set the following to 1 to define commonly used function + to be inlined. This should be set to 1 unless the compiler + does not support the "inline" keyword, or if building for + debugging purposes. */ +#ifndef QD_INLINE +#define QD_INLINE 1 +#endif + +/* Set the following to 1 to use ANSI C++ standard header files + such as cmath, iostream, etc. If set to zero, it will try to + include math.h, iostream.h, etc, instead. */ +#ifndef QD_HAVE_STD +#define QD_HAVE_STD 1 +#endif + +/* Set the following to 1 to make the addition and subtraction + to satisfy the IEEE-style error bound + + fl(a + b) = (1 + d) * (a + b) + + where |d| <= eps. If set to 0, the addition and subtraction + will satisfy the weaker Cray-style error bound + + fl(a + b) = (1 + d1) * a + (1 + d2) * b + + where |d1| <= eps and |d2| eps. */ +#ifndef QD_IEEE_ADD +/* #undef QD_IEEE_ADD */ +#endif + +/* Set the following to 1 to use slightly inaccurate but faster + version of multiplication. */ +#ifndef QD_SLOPPY_MUL +#define QD_SLOPPY_MUL 1 +#endif + +/* Set the following to 1 to use slightly inaccurate but faster + version of division. */ +#ifndef QD_SLOPPY_DIV +#define QD_SLOPPY_DIV 1 +#endif + +/* Define this macro to be the isfinite(x) function. */ +#ifndef QD_ISFINITE +#define QD_ISFINITE(x) std::isfinite(x) +#endif + +/* Define this macro to be the isinf(x) function. */ +#ifndef QD_ISINF +#define QD_ISINF(x) std::isinf(x) +#endif + +/* Define this macro to be the isnan(x) function. */ +#ifndef QD_ISNAN +#define QD_ISNAN(x) std::isnan(x) +#endif + + +#endif /* _QD_QD_CONFIG_H */ diff --git a/external/PackedCSparse/qd/qd_const.cc b/external/PackedCSparse/qd/qd_const.cc new file mode 100644 index 000000000..6f4e01d2a --- /dev/null +++ b/external/PackedCSparse/qd/qd_const.cc @@ -0,0 +1,62 @@ +/* + * src/qd_const.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Defines constants used in quad-double package. + */ +#include "qd_config.h" +#include "qd_real.h" + +/* Some useful constants. */ +const qd_real qd_real::_2pi = qd_real(6.283185307179586232e+00, + 2.449293598294706414e-16, + -5.989539619436679332e-33, + 2.224908441726730563e-49); +const qd_real qd_real::_pi = qd_real(3.141592653589793116e+00, + 1.224646799147353207e-16, + -2.994769809718339666e-33, + 1.112454220863365282e-49); +const qd_real qd_real::_pi2 = qd_real(1.570796326794896558e+00, + 6.123233995736766036e-17, + -1.497384904859169833e-33, + 5.562271104316826408e-50); +const qd_real qd_real::_pi4 = qd_real(7.853981633974482790e-01, + 3.061616997868383018e-17, + -7.486924524295849165e-34, + 2.781135552158413204e-50); +const qd_real qd_real::_3pi4 = qd_real(2.356194490192344837e+00, + 9.1848509936051484375e-17, + 3.9168984647504003225e-33, + -2.5867981632704860386e-49); +const qd_real qd_real::_e = qd_real(2.718281828459045091e+00, + 1.445646891729250158e-16, + -2.127717108038176765e-33, + 1.515630159841218954e-49); +const qd_real qd_real::_log2 = qd_real(6.931471805599452862e-01, + 2.319046813846299558e-17, + 5.707708438416212066e-34, + -3.582432210601811423e-50); +const qd_real qd_real::_log10 = qd_real(2.302585092994045901e+00, + -2.170756223382249351e-16, + -9.984262454465776570e-33, + -4.023357454450206379e-49); +const qd_real qd_real::_nan = qd_real(qd::_d_nan, qd::_d_nan, + qd::_d_nan, qd::_d_nan); +const qd_real qd_real::_inf = qd_real(qd::_d_inf, qd::_d_inf, + qd::_d_inf, qd::_d_inf); + +const double qd_real::_eps = 1.21543267145725e-63; // = 2^-209 +const double qd_real::_min_normalized = 1.6259745436952323e-260; // = 2^(-1022 + 3*53) +const qd_real qd_real::_max = qd_real( + 1.79769313486231570815e+308, 9.97920154767359795037e+291, + 5.53956966280111259858e+275, 3.07507889307840487279e+259); +const qd_real qd_real::_safe_max = qd_real( + 1.7976931080746007281e+308, 9.97920154767359795037e+291, + 5.53956966280111259858e+275, 3.07507889307840487279e+259); +const int qd_real::_ndigits = 62; + diff --git a/external/PackedCSparse/qd/qd_inline.h b/external/PackedCSparse/qd/qd_inline.h new file mode 100644 index 000000000..89ba275b5 --- /dev/null +++ b/external/PackedCSparse/qd/qd_inline.h @@ -0,0 +1,1047 @@ +/* + * include/qd_inline.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2001 + * + * Contains small functions (suitable for inlining) in the quad-double + * arithmetic package. + */ +#ifndef _QD_QD_INLINE_H +#define _QD_QD_INLINE_H + +#include +#include "inline.h" + +#ifndef QD_INLINE +#define inline +#endif + +/********** Constructors **********/ +inline qd_real::qd_real(double x0, double x1, double x2, double x3) { + x[0] = x0; + x[1] = x1; + x[2] = x2; + x[3] = x3; +} + +inline qd_real::qd_real(const double *xx) { + x[0] = xx[0]; + x[1] = xx[1]; + x[2] = xx[2]; + x[3] = xx[3]; +} + +inline qd_real::qd_real(double x0) { + x[0] = x0; + x[1] = x[2] = x[3] = 0.0; +} + +inline qd_real::qd_real() { + x[0] = 0.0; + x[1] = 0.0; + x[2] = 0.0; + x[3] = 0.0; +} + +inline qd_real::qd_real(const dd_real &a) { + x[0] = a._hi(); + x[1] = a._lo(); + x[2] = x[3] = 0.0; +} + +inline qd_real::qd_real(int i) { + x[0] = static_cast(i); + x[1] = x[2] = x[3] = 0.0; +} + +/********** Accessors **********/ +inline double qd_real::operator[](int i) const { + return x[i]; +} + +inline double &qd_real::operator[](int i) { + return x[i]; +} + +inline bool qd_real::isnan() const { + return QD_ISNAN(x[0]) || QD_ISNAN(x[1]) || QD_ISNAN(x[2]) || QD_ISNAN(x[3]); +} + +/********** Renormalization **********/ +namespace qd { +inline void quick_renorm(double &c0, double &c1, + double &c2, double &c3, double &c4) { + double t0, t1, t2, t3; + double s; + s = qd::quick_two_sum(c3, c4, t3); + s = qd::quick_two_sum(c2, s , t2); + s = qd::quick_two_sum(c1, s , t1); + c0 = qd::quick_two_sum(c0, s , t0); + + s = qd::quick_two_sum(t2, t3, t2); + s = qd::quick_two_sum(t1, s , t1); + c1 = qd::quick_two_sum(t0, s , t0); + + s = qd::quick_two_sum(t1, t2, t1); + c2 = qd::quick_two_sum(t0, s , t0); + + c3 = t0 + t1; +} + +inline void renorm(double &c0, double &c1, + double &c2, double &c3) { + double s0, s1, s2 = 0.0, s3 = 0.0; + + if (QD_ISINF(c0)) return; + + s0 = qd::quick_two_sum(c2, c3, c3); + s0 = qd::quick_two_sum(c1, s0, c2); + c0 = qd::quick_two_sum(c0, s0, c1); + + s0 = c0; + s1 = c1; + if (s1 != 0.0) { + s1 = qd::quick_two_sum(s1, c2, s2); + if (s2 != 0.0) + s2 = qd::quick_two_sum(s2, c3, s3); + else + s1 = qd::quick_two_sum(s1, c3, s2); + } else { + s0 = qd::quick_two_sum(s0, c2, s1); + if (s1 != 0.0) + s1 = qd::quick_two_sum(s1, c3, s2); + else + s0 = qd::quick_two_sum(s0, c3, s1); + } + + c0 = s0; + c1 = s1; + c2 = s2; + c3 = s3; +} + +inline void renorm(double &c0, double &c1, + double &c2, double &c3, double &c4) { + double s0, s1, s2 = 0.0, s3 = 0.0; + + if (QD_ISINF(c0)) return; + + s0 = qd::quick_two_sum(c3, c4, c4); + s0 = qd::quick_two_sum(c2, s0, c3); + s0 = qd::quick_two_sum(c1, s0, c2); + c0 = qd::quick_two_sum(c0, s0, c1); + + s0 = c0; + s1 = c1; + + if (s1 != 0.0) { + s1 = qd::quick_two_sum(s1, c2, s2); + if (s2 != 0.0) { + s2 = qd::quick_two_sum(s2, c3, s3); + if (s3 != 0.0) + s3 += c4; + else + s2 = qd::quick_two_sum(s2, c4, s3); + } else { + s1 = qd::quick_two_sum(s1, c3, s2); + if (s2 != 0.0) + s2 = qd::quick_two_sum(s2, c4, s3); + else + s1 = qd::quick_two_sum(s1, c4, s2); + } + } else { + s0 = qd::quick_two_sum(s0, c2, s1); + if (s1 != 0.0) { + s1 = qd::quick_two_sum(s1, c3, s2); + if (s2 != 0.0) + s2 = qd::quick_two_sum(s2, c4, s3); + else + s1 = qd::quick_two_sum(s1, c4, s2); + } else { + s0 = qd::quick_two_sum(s0, c3, s1); + if (s1 != 0.0) + s1 = qd::quick_two_sum(s1, c4, s2); + else + s0 = qd::quick_two_sum(s0, c4, s1); + } + } + + c0 = s0; + c1 = s1; + c2 = s2; + c3 = s3; +} +} + +inline void qd_real::renorm() { + qd::renorm(x[0], x[1], x[2], x[3]); +} + +inline void qd_real::renorm(double &e) { + qd::renorm(x[0], x[1], x[2], x[3], e); +} + + +/********** Additions ************/ +namespace qd { + +inline void three_sum(double &a, double &b, double &c) { + double t1, t2, t3; + t1 = qd::two_sum(a, b, t2); + a = qd::two_sum(c, t1, t3); + b = qd::two_sum(t2, t3, c); +} + +inline void three_sum2(double &a, double &b, double &c) { + double t1, t2, t3; + t1 = qd::two_sum(a, b, t2); + a = qd::two_sum(c, t1, t3); + b = t2 + t3; +} + +} + +/* quad-double + double */ +inline qd_real operator+(const qd_real &a, double b) { + double c0, c1, c2, c3; + double e; + + c0 = qd::two_sum(a[0], b, e); + c1 = qd::two_sum(a[1], e, e); + c2 = qd::two_sum(a[2], e, e); + c3 = qd::two_sum(a[3], e, e); + + qd::renorm(c0, c1, c2, c3, e); + + return qd_real(c0, c1, c2, c3); +} + +/* quad-double + double-double */ +inline qd_real operator+(const qd_real &a, const dd_real &b) { + + double s0, s1, s2, s3; + double t0, t1; + + s0 = qd::two_sum(a[0], b._hi(), t0); + s1 = qd::two_sum(a[1], b._lo(), t1); + + s1 = qd::two_sum(s1, t0, t0); + + s2 = a[2]; + qd::three_sum(s2, t0, t1); + + s3 = qd::two_sum(t0, a[3], t0); + t0 += t1; + + qd::renorm(s0, s1, s2, s3, t0); + return qd_real(s0, s1, s2, s3); +} + + +/* double + quad-double */ +inline qd_real operator+(double a, const qd_real &b) { + return (b + a); +} + +/* double-double + quad-double */ +inline qd_real operator+(const dd_real &a, const qd_real &b) { + return (b + a); +} + +namespace qd { + +/* s = quick_three_accum(a, b, c) adds c to the dd-pair (a, b). + * If the result does not fit in two doubles, then the sum is + * output into s and (a,b) contains the remainder. Otherwise + * s is zero and (a,b) contains the sum. */ +inline double quick_three_accum(double &a, double &b, double c) { + double s; + bool za, zb; + + s = qd::two_sum(b, c, b); + s = qd::two_sum(a, s, a); + + za = (a != 0.0); + zb = (b != 0.0); + + if (za && zb) + return s; + + if (!zb) { + b = a; + a = s; + } else { + a = s; + } + + return 0.0; +} + +} + +inline qd_real qd_real::ieee_add(const qd_real &a, const qd_real &b) { + int i, j, k; + double s, t; + double u, v; /* double-length accumulator */ + double x[4] = {0.0, 0.0, 0.0, 0.0}; + + i = j = k = 0; + if (std::abs(a[i]) > std::abs(b[j])) + u = a[i++]; + else + u = b[j++]; + if (std::abs(a[i]) > std::abs(b[j])) + v = a[i++]; + else + v = b[j++]; + + u = qd::quick_two_sum(u, v, v); + + while (k < 4) { + if (i >= 4 && j >= 4) { + x[k] = u; + if (k < 3) + x[++k] = v; + break; + } + + if (i >= 4) + t = b[j++]; + else if (j >= 4) + t = a[i++]; + else if (std::abs(a[i]) > std::abs(b[j])) { + t = a[i++]; + } else + t = b[j++]; + + s = qd::quick_three_accum(u, v, t); + + if (s != 0.0) { + x[k++] = s; + } + } + + /* add the rest. */ + for (k = i; k < 4; k++) + x[3] += a[k]; + for (k = j; k < 4; k++) + x[3] += b[k]; + + qd::renorm(x[0], x[1], x[2], x[3]); + return qd_real(x[0], x[1], x[2], x[3]); +} + +inline qd_real qd_real::sloppy_add(const qd_real &a, const qd_real &b) { + /* + double s0, s1, s2, s3; + double t0, t1, t2, t3; + + s0 = qd::two_sum(a[0], b[0], t0); + s1 = qd::two_sum(a[1], b[1], t1); + s2 = qd::two_sum(a[2], b[2], t2); + s3 = qd::two_sum(a[3], b[3], t3); + + s1 = qd::two_sum(s1, t0, t0); + qd::three_sum(s2, t0, t1); + qd::three_sum2(s3, t0, t2); + t0 = t0 + t1 + t3; + + qd::renorm(s0, s1, s2, s3, t0); + return qd_real(s0, s1, s2, s3, t0); + */ + + /* Same as above, but addition re-organized to minimize + data dependency ... unfortunately some compilers are + not very smart to do this automatically */ + double s0, s1, s2, s3; + double t0, t1, t2, t3; + + double v0, v1, v2, v3; + double u0, u1, u2, u3; + double w0, w1, w2, w3; + + s0 = a[0] + b[0]; + s1 = a[1] + b[1]; + s2 = a[2] + b[2]; + s3 = a[3] + b[3]; + + v0 = s0 - a[0]; + v1 = s1 - a[1]; + v2 = s2 - a[2]; + v3 = s3 - a[3]; + + u0 = s0 - v0; + u1 = s1 - v1; + u2 = s2 - v2; + u3 = s3 - v3; + + w0 = a[0] - u0; + w1 = a[1] - u1; + w2 = a[2] - u2; + w3 = a[3] - u3; + + u0 = b[0] - v0; + u1 = b[1] - v1; + u2 = b[2] - v2; + u3 = b[3] - v3; + + t0 = w0 + u0; + t1 = w1 + u1; + t2 = w2 + u2; + t3 = w3 + u3; + + s1 = qd::two_sum(s1, t0, t0); + qd::three_sum(s2, t0, t1); + qd::three_sum2(s3, t0, t2); + t0 = t0 + t1 + t3; + + /* renormalize */ + qd::renorm(s0, s1, s2, s3, t0); + return qd_real(s0, s1, s2, s3); +} + +/* quad-double + quad-double */ +inline qd_real operator+(const qd_real &a, const qd_real &b) { +#ifndef QD_IEEE_ADD + return qd_real::sloppy_add(a, b); +#else + return qd_real::ieee_add(a, b); +#endif +} + + + +/********** Self-Additions ************/ +/* quad-double += double */ +inline qd_real &qd_real::operator+=(double a) { + *this = *this + a; + return *this; +} + +/* quad-double += double-double */ +inline qd_real &qd_real::operator+=(const dd_real &a) { + *this = *this + a; + return *this; +} + +/* quad-double += quad-double */ +inline qd_real &qd_real::operator+=(const qd_real &a) { + *this = *this + a; + return *this; +} + +/********** Unary Minus **********/ +inline qd_real qd_real::operator-() const { + return qd_real(-x[0], -x[1], -x[2], -x[3]); +} + +/********** Subtractions **********/ +inline qd_real operator-(const qd_real &a, double b) { + return (a + (-b)); +} + +inline qd_real operator-(double a, const qd_real &b) { + return (a + (-b)); +} + +inline qd_real operator-(const qd_real &a, const dd_real &b) { + return (a + (-b)); +} + +inline qd_real operator-(const dd_real &a, const qd_real &b) { + return (a + (-b)); +} + +inline qd_real operator-(const qd_real &a, const qd_real &b) { + return (a + (-b)); +} + +/********** Self-Subtractions **********/ +inline qd_real &qd_real::operator-=(double a) { + return ((*this) += (-a)); +} + +inline qd_real &qd_real::operator-=(const dd_real &a) { + return ((*this) += (-a)); +} + +inline qd_real &qd_real::operator-=(const qd_real &a) { + return ((*this) += (-a)); +} + + +inline qd_real operator*(double a, const qd_real &b) { + return (b * a); +} + +inline qd_real operator*(const dd_real &a, const qd_real &b) { + return (b * a); +} + +inline qd_real mul_pwr2(const qd_real &a, double b) { + return qd_real(a[0] * b, a[1] * b, a[2] * b, a[3] * b); +} + +/********** Multiplications **********/ +inline qd_real operator*(const qd_real &a, double b) { + double p0, p1, p2, p3; + double q0, q1, q2; + double s0, s1, s2, s3, s4; + + p0 = qd::two_prod(a[0], b, q0); + p1 = qd::two_prod(a[1], b, q1); + p2 = qd::two_prod(a[2], b, q2); + p3 = a[3] * b; + + s0 = p0; + + s1 = qd::two_sum(q0, p1, s2); + + qd::three_sum(s2, q1, p2); + + qd::three_sum2(q1, q2, p3); + s3 = q1; + + s4 = q2 + p2; + + qd::renorm(s0, s1, s2, s3, s4); + return qd_real(s0, s1, s2, s3); + +} + +/* quad-double * double-double */ +/* a0 * b0 0 + a0 * b1 1 + a1 * b0 2 + a1 * b1 3 + a2 * b0 4 + a2 * b1 5 + a3 * b0 6 + a3 * b1 7 */ +inline qd_real operator*(const qd_real &a, const dd_real &b) { + double p0, p1, p2, p3, p4; + double q0, q1, q2, q3, q4; + double s0, s1, s2; + double t0, t1; + + p0 = qd::two_prod(a[0], b._hi(), q0); + p1 = qd::two_prod(a[0], b._lo(), q1); + p2 = qd::two_prod(a[1], b._hi(), q2); + p3 = qd::two_prod(a[1], b._lo(), q3); + p4 = qd::two_prod(a[2], b._hi(), q4); + + qd::three_sum(p1, p2, q0); + + /* Five-Three-Sum */ + qd::three_sum(p2, p3, p4); + q1 = qd::two_sum(q1, q2, q2); + s0 = qd::two_sum(p2, q1, t0); + s1 = qd::two_sum(p3, q2, t1); + s1 = qd::two_sum(s1, t0, t0); + s2 = t0 + t1 + p4; + p2 = s0; + + p3 = a[2] * b._hi() + a[3] * b._lo() + q3 + q4; + qd::three_sum2(p3, q0, s1); + p4 = q0 + s2; + + qd::renorm(p0, p1, p2, p3, p4); + return qd_real(p0, p1, p2, p3); +} + +/* quad-double * quad-double */ +/* a0 * b0 0 + a0 * b1 1 + a1 * b0 2 + a0 * b2 3 + a1 * b1 4 + a2 * b0 5 + a0 * b3 6 + a1 * b2 7 + a2 * b1 8 + a3 * b0 9 */ +inline qd_real qd_real::sloppy_mul(const qd_real &a, const qd_real &b) { + double p0, p1, p2, p3, p4, p5; + double q0, q1, q2, q3, q4, q5; + double t0, t1; + double s0, s1, s2; + + p0 = qd::two_prod(a[0], b[0], q0); + + p1 = qd::two_prod(a[0], b[1], q1); + p2 = qd::two_prod(a[1], b[0], q2); + + p3 = qd::two_prod(a[0], b[2], q3); + p4 = qd::two_prod(a[1], b[1], q4); + p5 = qd::two_prod(a[2], b[0], q5); + + /* Start Accumulation */ + qd::three_sum(p1, p2, q0); + + /* Six-Three Sum of p2, q1, q2, p3, p4, p5. */ + qd::three_sum(p2, q1, q2); + qd::three_sum(p3, p4, p5); + /* compute (s0, s1, s2) = (p2, q1, q2) + (p3, p4, p5). */ + s0 = qd::two_sum(p2, p3, t0); + s1 = qd::two_sum(q1, p4, t1); + s2 = q2 + p5; + s1 = qd::two_sum(s1, t0, t0); + s2 += (t0 + t1); + + /* O(eps^3) order terms */ + s1 += a[0]*b[3] + a[1]*b[2] + a[2]*b[1] + a[3]*b[0] + q0 + q3 + q4 + q5; + qd::renorm(p0, p1, s0, s1, s2); + return qd_real(p0, p1, s0, s1); +} + +inline qd_real qd_real::accurate_mul(const qd_real &a, const qd_real &b) { + double p0, p1, p2, p3, p4, p5; + double q0, q1, q2, q3, q4, q5; + double p6, p7, p8, p9; + double q6, q7, q8, q9; + double r0, r1; + double t0, t1; + double s0, s1, s2; + + p0 = qd::two_prod(a[0], b[0], q0); + + p1 = qd::two_prod(a[0], b[1], q1); + p2 = qd::two_prod(a[1], b[0], q2); + + p3 = qd::two_prod(a[0], b[2], q3); + p4 = qd::two_prod(a[1], b[1], q4); + p5 = qd::two_prod(a[2], b[0], q5); + + /* Start Accumulation */ + qd::three_sum(p1, p2, q0); + + /* Six-Three Sum of p2, q1, q2, p3, p4, p5. */ + qd::three_sum(p2, q1, q2); + qd::three_sum(p3, p4, p5); + /* compute (s0, s1, s2) = (p2, q1, q2) + (p3, p4, p5). */ + s0 = qd::two_sum(p2, p3, t0); + s1 = qd::two_sum(q1, p4, t1); + s2 = q2 + p5; + s1 = qd::two_sum(s1, t0, t0); + s2 += (t0 + t1); + + /* O(eps^3) order terms */ + p6 = qd::two_prod(a[0], b[3], q6); + p7 = qd::two_prod(a[1], b[2], q7); + p8 = qd::two_prod(a[2], b[1], q8); + p9 = qd::two_prod(a[3], b[0], q9); + + /* Nine-Two-Sum of q0, s1, q3, q4, q5, p6, p7, p8, p9. */ + q0 = qd::two_sum(q0, q3, q3); + q4 = qd::two_sum(q4, q5, q5); + p6 = qd::two_sum(p6, p7, p7); + p8 = qd::two_sum(p8, p9, p9); + /* Compute (t0, t1) = (q0, q3) + (q4, q5). */ + t0 = qd::two_sum(q0, q4, t1); + t1 += (q3 + q5); + /* Compute (r0, r1) = (p6, p7) + (p8, p9). */ + r0 = qd::two_sum(p6, p8, r1); + r1 += (p7 + p9); + /* Compute (q3, q4) = (t0, t1) + (r0, r1). */ + q3 = qd::two_sum(t0, r0, q4); + q4 += (t1 + r1); + /* Compute (t0, t1) = (q3, q4) + s1. */ + t0 = qd::two_sum(q3, s1, t1); + t1 += q4; + + /* O(eps^4) terms -- Nine-One-Sum */ + t1 += a[1] * b[3] + a[2] * b[2] + a[3] * b[1] + q6 + q7 + q8 + q9 + s2; + + qd::renorm(p0, p1, s0, t0, t1); + return qd_real(p0, p1, s0, t0); +} + +inline qd_real operator*(const qd_real &a, const qd_real &b) { +#ifdef QD_SLOPPY_MUL + return qd_real::sloppy_mul(a, b); +#else + return qd_real::accurate_mul(a, b); +#endif +} + +/* quad-double ^ 2 = (x0 + x1 + x2 + x3) ^ 2 + = x0 ^ 2 + 2 x0 * x1 + (2 x0 * x2 + x1 ^ 2) + + (2 x0 * x3 + 2 x1 * x2) */ +inline qd_real sqr(const qd_real &a) { + double p0, p1, p2, p3, p4, p5; + double q0, q1, q2, q3; + double s0, s1; + double t0, t1; + + p0 = qd::two_sqr(a[0], q0); + p1 = qd::two_prod(2.0 * a[0], a[1], q1); + p2 = qd::two_prod(2.0 * a[0], a[2], q2); + p3 = qd::two_sqr(a[1], q3); + + p1 = qd::two_sum(q0, p1, q0); + + q0 = qd::two_sum(q0, q1, q1); + p2 = qd::two_sum(p2, p3, p3); + + s0 = qd::two_sum(q0, p2, t0); + s1 = qd::two_sum(q1, p3, t1); + + s1 = qd::two_sum(s1, t0, t0); + t0 += t1; + + s1 = qd::quick_two_sum(s1, t0, t0); + p2 = qd::quick_two_sum(s0, s1, t1); + p3 = qd::quick_two_sum(t1, t0, q0); + + p4 = 2.0 * a[0] * a[3]; + p5 = 2.0 * a[1] * a[2]; + + p4 = qd::two_sum(p4, p5, p5); + q2 = qd::two_sum(q2, q3, q3); + + t0 = qd::two_sum(p4, q2, t1); + t1 = t1 + p5 + q3; + + p3 = qd::two_sum(p3, t0, p4); + p4 = p4 + q0 + t1; + + qd::renorm(p0, p1, p2, p3, p4); + return qd_real(p0, p1, p2, p3); + +} + +/********** Self-Multiplication **********/ +/* quad-double *= double */ +inline qd_real &qd_real::operator*=(double a) { + *this = (*this * a); + return *this; +} + +/* quad-double *= double-double */ +inline qd_real &qd_real::operator*=(const dd_real &a) { + *this = (*this * a); + return *this; +} + +/* quad-double *= quad-double */ +inline qd_real &qd_real::operator*=(const qd_real &a) { + *this = *this * a; + return *this; +} + +inline qd_real operator/ (const qd_real &a, const dd_real &b) { +#ifdef QD_SLOPPY_DIV + return qd_real::sloppy_div(a, b); +#else + return qd_real::accurate_div(a, b); +#endif +} + +inline qd_real operator/(const qd_real &a, const qd_real &b) { +#ifdef QD_SLOPPY_DIV + return qd_real::sloppy_div(a, b); +#else + return qd_real::accurate_div(a, b); +#endif +} + +/* double / quad-double */ +inline qd_real operator/(double a, const qd_real &b) { + return qd_real(a) / b; +} + +/* double-double / quad-double */ +inline qd_real operator/(const dd_real &a, const qd_real &b) { + return qd_real(a) / b; +} + +/********** Self-Divisions **********/ +/* quad-double /= double */ +inline qd_real &qd_real::operator/=(double a) { + *this = (*this / a); + return *this; +} + +/* quad-double /= double-double */ +inline qd_real &qd_real::operator/=(const dd_real &a) { + *this = (*this / a); + return *this; +} + +/* quad-double /= quad-double */ +inline qd_real &qd_real::operator/=(const qd_real &a) { + *this = (*this / a); + return *this; +} + + +/********** Exponentiation **********/ +inline qd_real qd_real::operator^(int n) const { + return pow(*this, n); +} + +/********** Miscellaneous **********/ +inline qd_real abs(const qd_real &a) { + return (a[0] < 0.0) ? -a : a; +} + +inline qd_real fabs(const qd_real &a) { + return abs(a); +} + +/* Quick version. May be off by one when qd is very close + to the middle of two integers. */ +inline qd_real quick_nint(const qd_real &a) { + qd_real r = qd_real(qd::nint(a[0]), qd::nint(a[1]), + qd::nint(a[2]), qd::nint(a[3])); + r.renorm(); + return r; +} + +/*********** Assignments ************/ +/* quad-double = double */ +inline qd_real &qd_real::operator=(double a) { + x[0] = a; + x[1] = x[2] = x[3] = 0.0; + return *this; +} + +/* quad-double = double-double */ +inline qd_real &qd_real::operator=(const dd_real &a) { + x[0] = a._hi(); + x[1] = a._lo(); + x[2] = x[3] = 0.0; + return *this; +} + +/********** Equality Comparison **********/ +inline bool operator==(const qd_real &a, double b) { + return (a[0] == b && a[1] == 0.0 && a[2] == 0.0 && a[3] == 0.0); +} + +inline bool operator==(double a, const qd_real &b) { + return (b == a); +} + +inline bool operator==(const qd_real &a, const dd_real &b) { + return (a[0] == b._hi() && a[1] == b._lo() && + a[2] == 0.0 && a[3] == 0.0); +} + +inline bool operator==(const dd_real &a, const qd_real &b) { + return (b == a); +} + +inline bool operator==(const qd_real &a, const qd_real &b) { + return (a[0] == b[0] && a[1] == b[1] && + a[2] == b[2] && a[3] == b[3]); +} + + +/********** Less-Than Comparison ***********/ +inline bool operator<(const qd_real &a, double b) { + return (a[0] < b || (a[0] == b && a[1] < 0.0)); +} + +inline bool operator<(double a, const qd_real &b) { + return (b > a); +} + +inline bool operator<(const qd_real &a, const dd_real &b) { + return (a[0] < b._hi() || + (a[0] == b._hi() && (a[1] < b._lo() || + (a[1] == b._lo() && a[2] < 0.0)))); +} + +inline bool operator<(const dd_real &a, const qd_real &b) { + return (b > a); +} + +inline bool operator<(const qd_real &a, const qd_real &b) { + return (a[0] < b[0] || + (a[0] == b[0] && (a[1] < b[1] || + (a[1] == b[1] && (a[2] < b[2] || + (a[2] == b[2] && a[3] < b[3])))))); +} + +/********** Greater-Than Comparison ***********/ +inline bool operator>(const qd_real &a, double b) { + return (a[0] > b || (a[0] == b && a[1] > 0.0)); +} + +inline bool operator>(double a, const qd_real &b) { + return (b < a); +} + +inline bool operator>(const qd_real &a, const dd_real &b) { + return (a[0] > b._hi() || + (a[0] == b._hi() && (a[1] > b._lo() || + (a[1] == b._lo() && a[2] > 0.0)))); +} + +inline bool operator>(const dd_real &a, const qd_real &b) { + return (b < a); +} + +inline bool operator>(const qd_real &a, const qd_real &b) { + return (a[0] > b[0] || + (a[0] == b[0] && (a[1] > b[1] || + (a[1] == b[1] && (a[2] > b[2] || + (a[2] == b[2] && a[3] > b[3])))))); +} + + +/********** Less-Than-Or-Equal-To Comparison **********/ +inline bool operator<=(const qd_real &a, double b) { + return (a[0] < b || (a[0] == b && a[1] <= 0.0)); +} + +inline bool operator<=(double a, const qd_real &b) { + return (b >= a); +} + +inline bool operator<=(const qd_real &a, const dd_real &b) { + return (a[0] < b._hi() || + (a[0] == b._hi() && (a[1] < b._lo() || + (a[1] == b._lo() && a[2] <= 0.0)))); +} + +inline bool operator<=(const dd_real &a, const qd_real &b) { + return (b >= a); +} + +inline bool operator<=(const qd_real &a, const qd_real &b) { + return (a[0] < b[0] || + (a[0] == b[0] && (a[1] < b[1] || + (a[1] == b[1] && (a[2] < b[2] || + (a[2] == b[2] && a[3] <= b[3])))))); +} + +/********** Greater-Than-Or-Equal-To Comparison **********/ +inline bool operator>=(const qd_real &a, double b) { + return (a[0] > b || (a[0] == b && a[1] >= 0.0)); +} + +inline bool operator>=(double a, const qd_real &b) { + return (b <= a); +} + +inline bool operator>=(const qd_real &a, const dd_real &b) { + return (a[0] > b._hi() || + (a[0] == b._hi() && (a[1] > b._lo() || + (a[1] == b._lo() && a[2] >= 0.0)))); +} + +inline bool operator>=(const dd_real &a, const qd_real &b) { + return (b <= a); +} + +inline bool operator>=(const qd_real &a, const qd_real &b) { + return (a[0] > b[0] || + (a[0] == b[0] && (a[1] > b[1] || + (a[1] == b[1] && (a[2] > b[2] || + (a[2] == b[2] && a[3] >= b[3])))))); +} + + + +/********** Not-Equal-To Comparison **********/ +inline bool operator!=(const qd_real &a, double b) { + return !(a == b); +} + +inline bool operator!=(double a, const qd_real &b) { + return !(a == b); +} + +inline bool operator!=(const qd_real &a, const dd_real &b) { + return !(a == b); +} + +inline bool operator!=(const dd_real &a, const qd_real &b) { + return !(a == b); +} + +inline bool operator!=(const qd_real &a, const qd_real &b) { + return !(a == b); +} + + + +inline qd_real aint(const qd_real &a) { + return (a[0] >= 0) ? floor(a) : ceil(a); +} + +inline bool qd_real::is_zero() const { + return (x[0] == 0.0); +} + +inline bool qd_real::is_one() const { + return (x[0] == 1.0 && x[1] == 0.0 && x[2] == 0.0 && x[3] == 0.0); +} + +inline bool qd_real::is_positive() const { + return (x[0] > 0.0); +} + +inline bool qd_real::is_negative() const { + return (x[0] < 0.0); +} + +inline qd_real::operator bool() const { + return (x[0] != 0.0); +} + +inline qd_real::operator double() const { + return to_double(*this); +} + +inline dd_real to_dd_real(const qd_real &a) { + return dd_real(a[0], a[1]); +} + +inline double to_double(const qd_real &a) { + return a[0]; +} + +inline int to_int(const qd_real &a) { + return static_cast(a[0]); +} + +inline qd_real inv(const qd_real &qd) { + return 1.0 / qd; +} + +inline qd_real max(const qd_real &a, const qd_real &b) { + return (a > b) ? a : b; +} + +inline qd_real max(const qd_real &a, const qd_real &b, + const qd_real &c) { + return (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c); +} + +inline qd_real min(const qd_real &a, const qd_real &b) { + return (a < b) ? a : b; +} + +inline qd_real min(const qd_real &a, const qd_real &b, + const qd_real &c) { + return (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c); +} + +/* Random number generator */ +inline qd_real qd_real::rand() { + return qdrand(); +} + +inline qd_real ldexp(const qd_real &a, int n) { + return qd_real(std::ldexp(a[0], n), std::ldexp(a[1], n), + std::ldexp(a[2], n), std::ldexp(a[3], n)); +} + +#endif /* _QD_QD_INLINE_H */ diff --git a/external/PackedCSparse/qd/qd_real.cc b/external/PackedCSparse/qd/qd_real.cc new file mode 100644 index 000000000..02cb7aa3b --- /dev/null +++ b/external/PackedCSparse/qd/qd_real.cc @@ -0,0 +1,2624 @@ +/* + * src/qd_real.cc + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2007 + * + * Contains implementation of non-inlined functions of quad-double + * package. Inlined functions are found in qd_inline.h (in include directory). + */ +#include +#include +#include +#include +#include +#include +#include + +#include "qd_config.h" +#include "qd_real.h" +#include "util.h" + +#include "bits.h" + +#ifndef QD_INLINE +#include "qd_inline.h" +#endif + +using std::cout; +using std::cerr; +using std::endl; +using std::istream; +using std::ostream; +using std::ios_base; +using std::string; +using std::setw; + +using namespace qd; + +void qd_real::error(const char *msg) { + //if (msg) { cerr << "ERROR " << msg << endl; } +} + +/********** Multiplications **********/ + +qd_real nint(const qd_real &a) { + double x0, x1, x2, x3; + + x0 = nint(a[0]); + x1 = x2 = x3 = 0.0; + + if (x0 == a[0]) { + /* First double is already an integer. */ + x1 = nint(a[1]); + + if (x1 == a[1]) { + /* Second double is already an integer. */ + x2 = nint(a[2]); + + if (x2 == a[2]) { + /* Third double is already an integer. */ + x3 = nint(a[3]); + } else { + if (std::abs(x2 - a[2]) == 0.5 && a[3] < 0.0) { + x2 -= 1.0; + } + } + + } else { + if (std::abs(x1 - a[1]) == 0.5 && a[2] < 0.0) { + x1 -= 1.0; + } + } + + } else { + /* First double is not an integer. */ + if (std::abs(x0 - a[0]) == 0.5 && a[1] < 0.0) { + x0 -= 1.0; + } + } + + renorm(x0, x1, x2, x3); + return qd_real(x0, x1, x2, x3); +} + +qd_real floor(const qd_real &a) { + double x0, x1, x2, x3; + x1 = x2 = x3 = 0.0; + x0 = std::floor(a[0]); + + if (x0 == a[0]) { + x1 = std::floor(a[1]); + + if (x1 == a[1]) { + x2 = std::floor(a[2]); + + if (x2 == a[2]) { + x3 = std::floor(a[3]); + } + } + + renorm(x0, x1, x2, x3); + return qd_real(x0, x1, x2, x3); + } + + return qd_real(x0, x1, x2, x3); +} + +qd_real ceil(const qd_real &a) { + double x0, x1, x2, x3; + x1 = x2 = x3 = 0.0; + x0 = std::ceil(a[0]); + + if (x0 == a[0]) { + x1 = std::ceil(a[1]); + + if (x1 == a[1]) { + x2 = std::ceil(a[2]); + + if (x2 == a[2]) { + x3 = std::ceil(a[3]); + } + } + + renorm(x0, x1, x2, x3); + return qd_real(x0, x1, x2, x3); + } + + return qd_real(x0, x1, x2, x3); +} + + + +/********** Divisions **********/ +/* quad-double / double */ +qd_real operator/(const qd_real &a, double b) { + /* Strategy: compute approximate quotient using high order + doubles, and then correct it 3 times using the remainder. + (Analogous to long division.) */ + double t0, t1; + double q0, q1, q2, q3; + qd_real r; + + q0 = a[0] / b; /* approximate quotient */ + + /* Compute the remainder a - q0 * b */ + t0 = two_prod(q0, b, t1); + r = a - dd_real(t0, t1); + + /* Compute the first correction */ + q1 = r[0] / b; + t0 = two_prod(q1, b, t1); + r -= dd_real(t0, t1); + + /* Second correction to the quotient. */ + q2 = r[0] / b; + t0 = two_prod(q2, b, t1); + r -= dd_real(t0, t1); + + /* Final correction to the quotient. */ + q3 = r[0] / b; + + renorm(q0, q1, q2, q3); + return qd_real(q0, q1, q2, q3); +} + +qd_real::qd_real(const char *s) { + if (qd_real::read(s, *this)) { + qd_real::error("(qd_real::qd_real): INPUT ERROR."); + *this = qd_real::_nan; + } +} + +qd_real &qd_real::operator=(const char *s) { + if (qd_real::read(s, *this)) { + qd_real::error("(qd_real::operator=): INPUT ERROR."); + *this = qd_real::_nan; + } + return *this; +} + +istream &operator>>(istream &s, qd_real &qd) { + char str[255]; + s >> str; + qd = qd_real(str); + return s; +} + +ostream &operator<<(ostream &os, const qd_real &qd) { + bool showpos = (os.flags() & ios_base::showpos) != 0; + bool uppercase = (os.flags() & ios_base::uppercase) != 0; + return os << qd.to_string((int)os.precision(), (int)os.width(), os.flags(), + showpos, uppercase, os.fill()); +} + +/* Read a quad-double from s. */ +int qd_real::read(const char *s, qd_real &qd) { + const char *p = s; + char ch; + int sign = 0; + int point = -1; /* location of decimal point */ + int nd = 0; /* number of digits read */ + int e = 0; /* exponent. */ + bool done = false; + qd_real r = 0.0; /* number being read */ + + /* Skip any leading spaces */ + while (*p == ' ') p++; + + while (!done && (ch = *p) != '\0') { + if (ch >= '0' && ch <= '9') { + /* It's a digit */ + int d = ch - '0'; + r *= 10.0; + r += static_cast(d); + nd++; + } else { + /* Non-digit */ + switch (ch) { + case '.': + if (point >= 0) + return -1; /* we've already encountered a decimal point. */ + point = nd; + break; + case '-': + case '+': + if (sign != 0 || nd > 0) + return -1; /* we've already encountered a sign, or if its + not at first position. */ + sign = (ch == '-') ? -1 : 1; + break; + case 'E': + case 'e': + int nread; + nread = std::sscanf(p+1, "%d", &e); + done = true; + if (nread != 1) + return -1; /* read of exponent failed. */ + break; + case ' ': + done = true; + break; + default: + return -1; + + } + } + + p++; + } + + + + /* Adjust exponent to account for decimal point */ + if (point >= 0) { + e -= (nd - point); + } + + /* Multiply the the exponent */ + if (e != 0) { + r *= (qd_real(10.0) ^ e); + } + + qd = (sign < 0) ? -r : r; + return 0; +} + +void qd_real::to_digits(char *s, int &expn, int precision) const { + int D = precision + 1; /* number of digits to compute */ + + qd_real r = abs(*this); + int e; /* exponent */ + int i, d; + + if (x[0] == 0.0) { + /* this == 0.0 */ + expn = 0; + for (i = 0; i < precision; i++) s[i] = '0'; + return; + } + + /* First determine the (approximate) exponent. */ + e = static_cast(std::floor(std::log10(std::abs(x[0])))); + + if (e < -300) { + r *= qd_real(10.0) ^ 300; + r /= qd_real(10.0) ^ (e + 300); + } else if (e > 300) { + r = ldexp(r, -53); + r /= qd_real(10.0) ^ e; + r = ldexp(r, 53); + } else { + r /= qd_real(10.0) ^ e; + } + + /* Fix exponent if we are off by one */ + if (r >= 10.0) { + r /= 10.0; + e++; + } else if (r < 1.0) { + r *= 10.0; + e--; + } + + if (r >= 10.0 || r < 1.0) { + qd_real::error("(qd_real::to_digits): can't compute exponent."); + return; + } + + /* Extract the digits */ + for (i = 0; i < D; i++) { + d = static_cast(r[0]); + r -= d; + r *= 10.0; + + s[i] = static_cast(d + '0'); + } + + /* Fix out of range digits. */ + for (i = D-1; i > 0; i--) { + if (s[i] < '0') { + s[i-1]--; + s[i] += 10; + } else if (s[i] > '9') { + s[i-1]++; + s[i] -= 10; + } + } + + if (s[0] <= '0') { + qd_real::error("(qd_real::to_digits): non-positive leading digit."); + return; + } + + /* Round, handle carry */ + if (s[D-1] >= '5') { + s[D-2]++; + + i = D-2; + while (i > 0 && s[i] > '9') { + s[i] -= 10; + s[--i]++; + } + } + + /* If first digit is 10, shift everything. */ + if (s[0] > '9') { + e++; + for (i = precision; i >= 2; i--) s[i] = s[i-1]; + s[0] = '1'; + s[1] = '0'; + } + + s[precision] = 0; + expn = e; +} + +/* Writes the quad-double number into the character array s of length len. + The integer d specifies how many significant digits to write. + The string s must be able to hold at least (d+8) characters. + showpos indicates whether to use the + sign, and uppercase indicates + whether the E or e is to be used for the exponent. */ +void qd_real::write(char *s, int len, int precision, + bool showpos, bool uppercase) const { + string str = to_string(precision, 0, ios_base::scientific, showpos, uppercase); + strncpy(s, str.c_str(), len-1); + s[len-1] = 0; +} + +void round_string_qd(char *s, int precision, int *offset){ + /* + Input string must be all digits or errors will occur. + */ + + int i; + int D = precision ; + + /* Round, handle carry */ + if (D>0 && s[D] >= '5') { + s[D-1]++; + + i = D-1; + while (i > 0 && s[i] > '9') { + s[i] -= 10; + s[--i]++; + } + } + + /* If first digit is 10, shift everything. */ + if (s[0] > '9') { + // e++; // don't modify exponent here + for (i = precision; i >= 1; i--) s[i+1] = s[i]; + s[0] = '1'; + s[1] = '0'; + + (*offset)++ ; // now offset needs to be increased by one + precision++ ; + } + + s[precision] = 0; // add terminator for array +} + + +string qd_real::to_string(int precision, int width, ios_base::fmtflags fmt, + bool showpos, bool uppercase, char fill) const { + string s; + bool fixed = (fmt & ios_base::fixed) != 0; + bool sgn = true; + int i, e = 0; + + if (isinf()) { + if (*this < 0.0) + s += '-'; + else if (showpos) + s += '+'; + else + sgn = false; + s += uppercase ? "INF" : "inf"; + } else if (isnan()) { + s = uppercase ? "NAN" : "nan"; + sgn = false; + } else { + if (*this < 0.0) + s += '-'; + else if (showpos) + s += '+'; + else + sgn = false; + + if (*this == 0.0) { + /* Zero case */ + s += '0'; + if (precision > 0) { + s += '.'; + s.append(precision, '0'); + } + } else { + /* Non-zero case */ + int off = (fixed ? (1 + to_int(floor(log10(abs(*this))))) : 1); + int d = precision + off; + + int d_with_extra = d; + if(fixed) + d_with_extra = std::max(120, d); // longer than the max accuracy for DD + + // highly special case - fixed mode, precision is zero, abs(*this) < 1.0 + // without this trap a number like 0.9 printed fixed with 0 precision prints as 0 + // should be rounded to 1. + if(fixed && (precision == 0) && (abs(*this) < 1.0)){ + if(abs(*this) >= 0.5) + s += '1'; + else + s += '0'; + + return s; + } + + // handle near zero to working precision (but not exactly zero) + if (fixed && d <= 0) { + s += '0'; + if (precision > 0) { + s += '.'; + s.append(precision, '0'); + } + } else { // default + + char *t ; // = new char[d+1]; + int j; + + if(fixed){ + t = new char[d_with_extra+1]; + to_digits(t, e, d_with_extra); + } + else{ + t = new char[d+1]; + to_digits(t, e, d); + } + + off = e + 1; + + if (fixed) { + // fix the string if it's been computed incorrectly + // round here in the decimal string if required + round_string_qd(t, d, &off); + + if (off > 0) { + for (i = 0; i < off; i++) s += t[i]; + if (precision > 0) { + s += '.'; + for (j = 0; j < precision; j++, i++) s += t[i]; + } + } else { + s += "0."; + if (off < 0) s.append(-off, '0'); + for (i = 0; i < d; i++) s += t[i]; + } + } else { + s += t[0]; + if (precision > 0) s += '.'; + + for (i = 1; i <= precision; i++) + s += t[i]; + + } + delete [] t; + } + } + + // trap for improper offset with large values + // without this trap, output of values of the for 10^j - 1 fail for j > 28 + // and are output with the point in the wrong place, leading to a dramatically off value + if(fixed && (precision > 0)){ + // make sure that the value isn't dramatically larger + double from_string = atof(s.c_str()); + + // if this ratio is large, then we've got problems + if( fabs( from_string / this->x[0] ) > 3.0 ){ + + // loop on the string, find the point, move it up one + // don't act on the first character + for(i=1; i < (int)s.length(); i++){ + if(s[i] == '.'){ + s[i] = s[i-1] ; + s[i-1] = '.' ; + break; + } + } + + from_string = atof(s.c_str()); + // if this ratio is large, then the string has not been fixed + if( fabs( from_string / this->x[0] ) > 3.0 ){ + dd_real::error("Re-rounding unsuccessful in large number fixed point trap.") ; + } + } + } + + if (!fixed) { + /* Fill in exponent part */ + s += uppercase ? 'E' : 'e'; + append_expn(s, e); + } + } + + /* Fill in the blanks */ + size_t len = s.length(); + if (len < width) { + int delta = width - len; + if (fmt & ios_base::internal) { + if (sgn) + s.insert(static_cast(1), delta, fill); + else + s.insert(static_cast(0), delta, fill); + } else if (fmt & ios_base::left) { + s.append(delta, fill); + } else { + s.insert(static_cast(0), delta, fill); + } + } + + return s; +} + +/* Computes qd^n, where n is an integer. */ +qd_real pow(const qd_real &a, int n) { + if (n == 0) + return 1.0; + + qd_real r = a; /* odd-case multiplier */ + qd_real s = 1.0; /* current answer */ + int N = std::abs(n); + + if (N > 1) { + + /* Use binary exponentiation. */ + while (N > 0) { + if (N % 2 == 1) { + /* If odd, multiply by r. Note eventually N = 1, so this + eventually executes. */ + s *= r; + } + N /= 2; + if (N > 0) + r = sqr(r); + } + + } else { + s = r; + } + + if (n < 0) + return (1.0 / s); + + return s; +} + +qd_real pow(const qd_real &a, const qd_real &b) { + return exp(b * log(a)); +} + +qd_real npwr(const qd_real &a, int n) { + return pow(a, n); +} + +/* Debugging routines */ +void qd_real::dump_bits(const string &name, std::ostream &os) const { + string::size_type len = name.length(); + if (len > 0) { + os << name << " = "; + len += 3; + } + os << "[ "; + len += 2; + for (int j = 0; j < 4; j++) { + if (j > 0) for (string::size_type i = 0; i < len; i++) os << ' '; + print_double_info(os, x[j]); + if (j < 3) + os << endl; + else + os << " ]" << endl; + } +} + +void qd_real::dump(const string &name, std::ostream &os) const { + std::ios_base::fmtflags old_flags = os.flags(); + std::streamsize old_prec = os.precision(19); + os << std::scientific; + + string::size_type len = name.length(); + if (len > 0) { + os << name << " = "; + len += 3; + } + os << "[ "; + len += 2; + os << setw(27) << x[0] << ", " << setw(26) << x[1] << "," << endl; + for (string::size_type i = 0; i < len; i++) os << ' '; + os << setw(27) << x[2] << ", " << setw(26) << x[3] << " ]" << endl; + + os.precision(old_prec); + os.flags(old_flags); +} + +/* Divisions */ +/* quad-double / double-double */ +qd_real qd_real::sloppy_div(const qd_real &a, const dd_real &b) { + double q0, q1, q2, q3; + qd_real r; + qd_real qd_b(b); + + q0 = a[0] / b._hi(); + r = a - q0 * qd_b; + + q1 = r[0] / b._hi(); + r -= (q1 * qd_b); + + q2 = r[0] / b._hi(); + r -= (q2 * qd_b); + + q3 = r[0] / b._hi(); + + ::renorm(q0, q1, q2, q3); + return qd_real(q0, q1, q2, q3); +} + +qd_real qd_real::accurate_div(const qd_real &a, const dd_real &b) { + double q0, q1, q2, q3, q4; + qd_real r; + qd_real qd_b(b); + + q0 = a[0] / b._hi(); + r = a - q0 * qd_b; + + q1 = r[0] / b._hi(); + r -= (q1 * qd_b); + + q2 = r[0] / b._hi(); + r -= (q2 * qd_b); + + q3 = r[0] / b._hi(); + r -= (q3 * qd_b); + + q4 = r[0] / b._hi(); + + ::renorm(q0, q1, q2, q3, q4); + return qd_real(q0, q1, q2, q3); +} + +/* quad-double / quad-double */ +qd_real qd_real::sloppy_div(const qd_real &a, const qd_real &b) { + double q0, q1, q2, q3; + + qd_real r; + + q0 = a[0] / b[0]; + r = a - (b * q0); + + q1 = r[0] / b[0]; + r -= (b * q1); + + q2 = r[0] / b[0]; + r -= (b * q2); + + q3 = r[0] / b[0]; + + ::renorm(q0, q1, q2, q3); + + return qd_real(q0, q1, q2, q3); +} + +qd_real qd_real::accurate_div(const qd_real &a, const qd_real &b) { + double q0, q1, q2, q3; + + qd_real r; + + q0 = a[0] / b[0]; + r = a - (b * q0); + + q1 = r[0] / b[0]; + r -= (b * q1); + + q2 = r[0] / b[0]; + r -= (b * q2); + + q3 = r[0] / b[0]; + + r -= (b * q3); + double q4 = r[0] / b[0]; + + ::renorm(q0, q1, q2, q3, q4); + + return qd_real(q0, q1, q2, q3); +} + +QD_API qd_real sqrt(const qd_real &a) { + /* Strategy: + + Perform the following Newton iteration: + + x' = x + (1 - a * x^2) * x / 2; + + which converges to 1/sqrt(a), starting with the + double precision approximation to 1/sqrt(a). + Since Newton's iteration more or less doubles the + number of correct digits, we only need to perform it + twice. + */ + + if (a.is_zero()) + return 0.0; + + if (a.is_negative()) { + qd_real::error("(qd_real::sqrt): Negative argument."); + return qd_real::_nan; + } + + qd_real r = (1.0 / std::sqrt(a[0])); + qd_real h = mul_pwr2(a, 0.5); + + r += ((0.5 - h * sqr(r)) * r); + r += ((0.5 - h * sqr(r)) * r); + r += ((0.5 - h * sqr(r)) * r); + + r *= a; + return r; +} + + +/* Computes the n-th root of a */ +qd_real nroot(const qd_real &a, int n) { + /* Strategy: Use Newton's iteration to solve + + 1/(x^n) - a = 0 + + Newton iteration becomes + + x' = x + x * (1 - a * x^n) / n + + Since Newton's iteration converges quadratically, + we only need to perform it twice. + + */ + if (n <= 0) { + qd_real::error("(qd_real::nroot): N must be positive."); + return qd_real::_nan; + } + + if (n % 2 == 0 && a.is_negative()) { + qd_real::error("(qd_real::nroot): Negative argument."); + return qd_real::_nan; + } + + if (n == 1) { + return a; + } + if (n == 2) { + return sqrt(a); + } + if (a.is_zero()) { + return qd_real(0.0); + } + + + /* Note a^{-1/n} = exp(-log(a)/n) */ + qd_real r = abs(a); + qd_real x = std::exp(-std::log(r.x[0]) / n); + + /* Perform Newton's iteration. */ + double dbl_n = static_cast(n); + x += x * (1.0 - r * npwr(x, n)) / dbl_n; + x += x * (1.0 - r * npwr(x, n)) / dbl_n; + x += x * (1.0 - r * npwr(x, n)) / dbl_n; + if (a[0] < 0.0){ + x = -x; + } + return 1.0 / x; +} + +static const int n_inv_fact = 15; +static const qd_real inv_fact[n_inv_fact] = { + qd_real( 1.66666666666666657e-01, 9.25185853854297066e-18, + 5.13581318503262866e-34, 2.85094902409834186e-50), + qd_real( 4.16666666666666644e-02, 2.31296463463574266e-18, + 1.28395329625815716e-34, 7.12737256024585466e-51), + qd_real( 8.33333333333333322e-03, 1.15648231731787138e-19, + 1.60494162032269652e-36, 2.22730392507682967e-53), + qd_real( 1.38888888888888894e-03, -5.30054395437357706e-20, + -1.73868675534958776e-36, -1.63335621172300840e-52), + qd_real( 1.98412698412698413e-04, 1.72095582934207053e-22, + 1.49269123913941271e-40, 1.29470326746002471e-58), + qd_real( 2.48015873015873016e-05, 2.15119478667758816e-23, + 1.86586404892426588e-41, 1.61837908432503088e-59), + qd_real( 2.75573192239858925e-06, -1.85839327404647208e-22, + 8.49175460488199287e-39, -5.72661640789429621e-55), + qd_real( 2.75573192239858883e-07, 2.37677146222502973e-23, + -3.26318890334088294e-40, 1.61435111860404415e-56), + qd_real( 2.50521083854417202e-08, -1.44881407093591197e-24, + 2.04267351467144546e-41, -8.49632672007163175e-58), + qd_real( 2.08767569878681002e-09, -1.20734505911325997e-25, + 1.70222792889287100e-42, 1.41609532150396700e-58), + qd_real( 1.60590438368216133e-10, 1.25852945887520981e-26, + -5.31334602762985031e-43, 3.54021472597605528e-59), + qd_real( 1.14707455977297245e-11, 2.06555127528307454e-28, + 6.88907923246664603e-45, 5.72920002655109095e-61), + qd_real( 7.64716373181981641e-13, 7.03872877733453001e-30, + -7.82753927716258345e-48, 1.92138649443790242e-64), + qd_real( 4.77947733238738525e-14, 4.39920548583408126e-31, + -4.89221204822661465e-49, 1.20086655902368901e-65), + qd_real( 2.81145725434552060e-15, 1.65088427308614326e-31, + -2.87777179307447918e-50, 4.27110689256293549e-67) +}; + +qd_real exp(const qd_real &a) { + /* Strategy: We first reduce the size of x by noting that + + exp(kr + m * log(2)) = 2^m * exp(r)^k + + where m and k are integers. By choosing m appropriately + we can make |kr| <= log(2) / 2 = 0.347. Then exp(r) is + evaluated using the familiar Taylor series. Reducing the + argument substantially speeds up the convergence. */ + + const double k = ldexp(1.0, 16); + const double inv_k = 1.0 / k; + + if (a[0] <= -709.0) + return 0.0; + + if (a[0] >= 709.0) + return qd_real::_inf; + + if (a.is_zero()) + return 1.0; + + if (a.is_one()) + return qd_real::_e; + + double m = std::floor(a.x[0] / qd_real::_log2.x[0] + 0.5); + qd_real r = mul_pwr2(a - qd_real::_log2 * m, inv_k); + qd_real s, p, t; + double thresh = inv_k * qd_real::_eps; + + p = sqr(r); + s = r + mul_pwr2(p, 0.5); + int i = 0; + do { + p *= r; + t = p * inv_fact[i++]; + s += t; + } while (std::abs(to_double(t)) > thresh && i < 9); + + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s = mul_pwr2(s, 2.0) + sqr(s); + s += 1.0; + return ldexp(s, static_cast(m)); +} + +/* Logarithm. Computes log(x) in quad-double precision. + This is a natural logarithm (i.e., base e). */ +qd_real log(const qd_real &a) { + /* Strategy. The Taylor series for log converges much more + slowly than that of exp, due to the lack of the factorial + term in the denominator. Hence this routine instead tries + to determine the root of the function + + f(x) = exp(x) - a + + using Newton iteration. The iteration is given by + + x' = x - f(x)/f'(x) + = x - (1 - a * exp(-x)) + = x + a * exp(-x) - 1. + + Two iteration is needed, since Newton's iteration + approximately doubles the number of digits per iteration. */ + + if (a.is_one()) { + return 0.0; + } + + if (a[0] <= 0.0) { + qd_real::error("(qd_real::log): Non-positive argument."); + return qd_real::_nan; + } + + if (a[0] == 0.0) { + return -qd_real::_inf; + } + + qd_real x = std::log(a[0]); /* Initial approximation */ + + x = x + a * exp(-x) - 1.0; + x = x + a * exp(-x) - 1.0; + x = x + a * exp(-x) - 1.0; + + return x; +} + +qd_real log10(const qd_real &a) { + return log(a) / qd_real::_log10; +} + +static const qd_real _pi1024 = qd_real( + 3.067961575771282340e-03, 1.195944139792337116e-19, + -2.924579892303066080e-36, 1.086381075061880158e-52); + +/* Table of sin(k * pi/1024) and cos(k * pi/1024). */ +static const qd_real sin_table [] = { + qd_real( 3.0679567629659761e-03, 1.2690279085455925e-19, + 5.2879464245328389e-36, -1.7820334081955298e-52), + qd_real( 6.1358846491544753e-03, 9.0545257482474933e-20, + 1.6260113133745320e-37, -9.7492001208767410e-55), + qd_real( 9.2037547820598194e-03, -1.2136591693535934e-19, + 5.5696903949425567e-36, 1.2505635791936951e-52), + qd_real( 1.2271538285719925e-02, 6.9197907640283170e-19, + -4.0203726713435555e-36, -2.0688703606952816e-52), + qd_real( 1.5339206284988102e-02, -8.4462578865401696e-19, + 4.6535897505058629e-35, -1.3923682978570467e-51), + qd_real( 1.8406729905804820e-02, 7.4195533812833160e-19, + 3.9068476486787607e-35, 3.6393321292898614e-52), + qd_real( 2.1474080275469508e-02, -4.5407960207688566e-19, + -2.2031770119723005e-35, 1.2709814654833741e-51), + qd_real( 2.4541228522912288e-02, -9.1868490125778782e-20, + 4.8706148704467061e-36, -2.8153947855469224e-52), + qd_real( 2.7608145778965743e-02, -1.5932358831389269e-18, + -7.0475416242776030e-35, -2.7518494176602744e-51), + qd_real( 3.0674803176636626e-02, -1.6936054844107918e-20, + -2.0039543064442544e-36, -1.6267505108658196e-52), + qd_real( 3.3741171851377587e-02, -2.0096074292368340e-18, + -1.3548237016537134e-34, 6.5554881875899973e-51), + qd_real( 3.6807222941358832e-02, 6.1060088803529842e-19, + -4.0448721259852727e-35, -2.1111056765671495e-51), + qd_real( 3.9872927587739811e-02, 4.6657453481183289e-19, + 3.4119333562288684e-35, 2.4007534726187511e-51), + qd_real( 4.2938256934940820e-02, 2.8351940588660907e-18, + 1.6991309601186475e-34, 6.8026536098672629e-51), + qd_real( 4.6003182130914630e-02, -1.1182813940157788e-18, + 7.5235020270378946e-35, 4.1187304955493722e-52), + qd_real( 4.9067674327418015e-02, -6.7961037205182801e-19, + -4.4318868124718325e-35, -9.9376628132525316e-52), + qd_real( 5.2131704680283324e-02, -2.4243695291953779e-18, + -1.3675405320092298e-34, -8.3938137621145070e-51), + qd_real( 5.5195244349689941e-02, -1.3340299860891103e-18, + -3.4359574125665608e-35, 1.1911462755409369e-51), + qd_real( 5.8258264500435759e-02, 2.3299905496077492e-19, + 1.9376108990628660e-36, -5.1273775710095301e-53), + qd_real( 6.1320736302208578e-02, -5.1181134064638108e-19, + -4.2726335866706313e-35, 2.6368495557440691e-51), + qd_real( 6.4382630929857465e-02, -4.2325997000052705e-18, + 3.3260117711855937e-35, 1.4736267706718352e-51), + qd_real( 6.7443919563664065e-02, -6.9221796556983636e-18, + 1.5909286358911040e-34, -7.8828946891835218e-51), + qd_real( 7.0504573389613870e-02, -6.8552791107342883e-18, + -1.9961177630841580e-34, 2.0127129580485300e-50), + qd_real( 7.3564563599667426e-02, -2.7784941506273593e-18, + -9.1240375489852821e-35, -1.9589752023546795e-51), + qd_real( 7.6623861392031492e-02, 2.3253700287958801e-19, + -1.3186083921213440e-36, -4.9927872608099673e-53), + qd_real( 7.9682437971430126e-02, -4.4867664311373041e-18, + 2.8540789143650264e-34, 2.8491348583262741e-51), + qd_real( 8.2740264549375692e-02, 1.4735983530877760e-18, + 3.7284093452233713e-35, 2.9024430036724088e-52), + qd_real( 8.5797312344439894e-02, -3.3881893830684029e-18, + -1.6135529531508258e-34, 7.7294651620588049e-51), + qd_real( 8.8853552582524600e-02, -3.7501775830290691e-18, + 3.7543606373911573e-34, 2.2233701854451859e-50), + qd_real( 9.1908956497132724e-02, 4.7631594854274564e-18, + 1.5722874642939344e-34, -4.8464145447831456e-51), + qd_real( 9.4963495329639006e-02, -6.5885886400417564e-18, + -2.1371116991641965e-34, 1.3819370559249300e-50), + qd_real( 9.8017140329560604e-02, -1.6345823622442560e-18, + -1.3209238810006454e-35, -3.5691060049117942e-52), + qd_real( 1.0106986275482782e-01, 3.3164325719308656e-18, + -1.2004224885132282e-34, 7.2028828495418631e-51), + qd_real( 1.0412163387205457e-01, 6.5760254085385100e-18, + 1.7066246171219214e-34, -4.9499340996893514e-51), + qd_real( 1.0717242495680884e-01, 6.4424044279026198e-18, + -8.3956976499698139e-35, -4.0667730213318321e-51), + qd_real( 1.1022220729388306e-01, -5.6789503537823233e-19, + 1.0380274792383233e-35, 1.5213997918456695e-52), + qd_real( 1.1327095217756435e-01, 2.7100481012132900e-18, + 1.5323292999491619e-35, 4.9564432810360879e-52), + qd_real( 1.1631863091190477e-01, 1.0294914877509705e-18, + -9.3975734948993038e-35, 1.3534827323719708e-52), + qd_real( 1.1936521481099137e-01, -3.9500089391898506e-18, + 3.5317349978227311e-34, 1.8856046807012275e-51), + qd_real( 1.2241067519921620e-01, 2.8354501489965335e-18, + 1.8151655751493305e-34, -2.8716592177915192e-51), + qd_real( 1.2545498341154623e-01, 4.8686751763148235e-18, + 5.9878105258097936e-35, -3.3534629098722107e-51), + qd_real( 1.2849811079379317e-01, 3.8198603954988802e-18, + -1.8627501455947798e-34, -2.4308161133527791e-51), + qd_real( 1.3154002870288312e-01, -5.0039708262213813e-18, + -1.2983004159245552e-34, -4.6872034915794122e-51), + qd_real( 1.3458070850712620e-01, -9.1670359171480699e-18, + 1.5916493007073973e-34, 4.0237002484366833e-51), + qd_real( 1.3762012158648604e-01, 6.6253255866774482e-18, + -2.3746583031401459e-34, -9.3703876173093250e-52), + qd_real( 1.4065823933284924e-01, -7.9193932965524741e-18, + 6.0972464202108397e-34, 2.4566623241035797e-50), + qd_real( 1.4369503315029444e-01, 1.1472723016618666e-17, + -5.1884954557576435e-35, -4.2220684832186607e-51), + qd_real( 1.4673047445536175e-01, 3.7269471470465677e-18, + 3.7352398151250827e-34, -4.0881822289508634e-51), + qd_real( 1.4976453467732151e-01, 8.0812114131285151e-18, + 1.2979142554917325e-34, 9.9380667487736254e-51), + qd_real( 1.5279718525844344e-01, -7.6313573938416838e-18, + 5.7714690450284125e-34, -3.7731132582986687e-50), + qd_real( 1.5582839765426523e-01, 3.0351307187678221e-18, + -1.0976942315176184e-34, 7.8734647685257867e-51), + qd_real( 1.5885814333386145e-01, -4.0163200573859079e-18, + -9.2840580257628812e-35, -2.8567420029274875e-51), + qd_real( 1.6188639378011183e-01, 1.1850519643573528e-17, + -5.0440990519162957e-34, 3.0510028707928009e-50), + qd_real( 1.6491312048996992e-01, -7.0405288319166738e-19, + 3.3211107491245527e-35, 8.6663299254686031e-52), + qd_real( 1.6793829497473117e-01, 5.4284533721558139e-18, + -3.3263339336181369e-34, -1.8536367335123848e-50), + qd_real( 1.7096188876030122e-01, 9.1919980181759094e-18, + -6.7688743940982606e-34, -1.0377711384318389e-50), + qd_real( 1.7398387338746382e-01, 5.8151994618107928e-18, + -1.6751014298301606e-34, -6.6982259797164963e-51), + qd_real( 1.7700422041214875e-01, 6.7329300635408167e-18, + 2.8042736644246623e-34, 3.6786888232793599e-51), + qd_real( 1.8002290140569951e-01, 7.9701826047392143e-18, + -7.0765920110524977e-34, 1.9622512608461784e-50), + qd_real( 1.8303988795514095e-01, 7.7349918688637383e-18, + -4.4803769968145083e-34, 1.1201148793328890e-50), + qd_real( 1.8605515166344666e-01, -1.2564893007679552e-17, + 7.5953844248530810e-34, -3.8471695132415039e-51), + qd_real( 1.8906866414980622e-01, -7.6208955803527778e-18, + -4.4792298656662981e-34, -4.4136824096645007e-50), + qd_real( 1.9208039704989244e-01, 4.3348343941174903e-18, + -2.3404121848139937e-34, 1.5789970962611856e-50), + qd_real( 1.9509032201612828e-01, -7.9910790684617313e-18, + 6.1846270024220713e-34, -3.5840270918032937e-50), + qd_real( 1.9809841071795359e-01, -1.8434411800689445e-18, + 1.4139031318237285e-34, 1.0542811125343809e-50), + qd_real( 2.0110463484209190e-01, 1.1010032669300739e-17, + -3.9123576757413791e-34, 2.4084852500063531e-51), + qd_real( 2.0410896609281687e-01, 6.0941297773957752e-18, + -2.8275409970449641e-34, 4.6101008563532989e-51), + qd_real( 2.0711137619221856e-01, -1.0613362528971356e-17, + 2.2456805112690884e-34, 1.3483736125280904e-50), + qd_real( 2.1011183688046961e-01, 1.1561548476512844e-17, + 6.0355905610401254e-34, 3.3329909618405675e-50), + qd_real( 2.1311031991609136e-01, 1.2031873821063860e-17, + -3.4142699719695635e-34, -1.2436262780241778e-50), + qd_real( 2.1610679707621952e-01, -1.0111196082609117e-17, + 7.2789545335189643e-34, -2.9347540365258610e-50), + qd_real( 2.1910124015686980e-01, -3.6513812299150776e-19, + -2.3359499418606442e-35, 3.1785298198458653e-52), + qd_real( 2.2209362097320354e-01, -3.0337210995812162e-18, + 6.6654668033632998e-35, 2.0110862322656942e-51), + qd_real( 2.2508391135979283e-01, 3.9507040822556510e-18, + 2.4287993958305375e-35, 5.6662797513020322e-52), + qd_real( 2.2807208317088573e-01, 8.2361837339258012e-18, + 6.9786781316397937e-34, -6.4122962482639504e-51), + qd_real( 2.3105810828067111e-01, 1.0129787149761869e-17, + -6.9359234615816044e-34, -2.8877355604883782e-50), + qd_real( 2.3404195858354343e-01, -6.9922402696101173e-18, + -5.7323031922750280e-34, 5.3092579966872727e-51), + qd_real( 2.3702360599436720e-01, 8.8544852285039918e-18, + 1.3588480826354134e-34, 1.0381022520213867e-50), + qd_real( 2.4000302244874150e-01, -1.2137758975632164e-17, + -2.6448807731703891e-34, -1.9929733800670473e-51), + qd_real( 2.4298017990326390e-01, -8.7514315297196632e-18, + -6.5723260373079431e-34, -1.0333158083172177e-50), + qd_real( 2.4595505033579462e-01, -1.1129044052741832e-17, + 4.3805998202883397e-34, 1.2219399554686291e-50), + qd_real( 2.4892760574572018e-01, -8.1783436100020990e-18, + 5.5666875261111840e-34, 3.8080473058748167e-50), + qd_real( 2.5189781815421697e-01, -1.7591436032517039e-17, + -1.0959681232525285e-33, 5.6209426020232456e-50), + qd_real( 2.5486565960451457e-01, -1.3602299806901461e-19, + -6.0073844642762535e-36, -3.0072751311893878e-52), + qd_real( 2.5783110216215899e-01, 1.8480038630879957e-17, + 3.3201664714047599e-34, -5.5547819290576764e-51), + qd_real( 2.6079411791527551e-01, 4.2721420983550075e-18, + 5.6782126934777920e-35, 3.1428338084365397e-51), + qd_real( 2.6375467897483140e-01, -1.8837947680038700e-17, + 1.3720129045754794e-33, -8.2763406665966033e-50), + qd_real( 2.6671275747489837e-01, 2.0941222578826688e-17, + -1.1303466524727989e-33, 1.9954224050508963e-50), + qd_real( 2.6966832557291509e-01, 1.5765657618133259e-17, + -6.9696142173370086e-34, -4.0455346879146776e-50), + qd_real( 2.7262135544994898e-01, 7.8697166076387850e-18, + 6.6179388602933372e-35, -2.7642903696386267e-51), + qd_real( 2.7557181931095814e-01, 1.9320328962556582e-17, + 1.3932094180100280e-33, 1.3617253920018116e-50), + qd_real( 2.7851968938505312e-01, -1.0030273719543544e-17, + 7.2592115325689254e-34, -1.0068516296655851e-50), + qd_real( 2.8146493792575800e-01, -1.2322299641274009e-17, + -1.0564788706386435e-34, 7.5137424251265885e-51), + qd_real( 2.8440753721127182e-01, 2.2209268510661475e-17, + -9.1823095629523708e-34, -5.2192875308892218e-50), + qd_real( 2.8734745954472951e-01, 1.5461117367645717e-17, + -6.3263973663444076e-34, -2.2982538416476214e-50), + qd_real( 2.9028467725446239e-01, -1.8927978707774251e-17, + 1.1522953157142315e-33, 7.4738655654716596e-50), + qd_real( 2.9321916269425863e-01, 2.2385430811901833e-17, + 1.3662484646539680e-33, -4.2451325253996938e-50), + qd_real( 2.9615088824362384e-01, -2.0220736360876938e-17, + -7.9252212533920413e-35, -2.8990577729572470e-51), + qd_real( 2.9907982630804048e-01, 1.6701181609219447e-18, + 8.6091151117316292e-35, 3.9931286230012102e-52), + qd_real( 3.0200594931922808e-01, -1.7167666235262474e-17, + 2.3336182149008069e-34, 8.3025334555220004e-51), + qd_real( 3.0492922973540243e-01, -2.2989033898191262e-17, + -1.4598901099661133e-34, 3.7760487693121827e-51), + qd_real( 3.0784964004153487e-01, 2.7074088527245185e-17, + 1.2568858206899284e-33, 7.2931815105901645e-50), + qd_real( 3.1076715274961147e-01, 2.0887076364048513e-17, + -3.0130590791065942e-34, 1.3876739009935179e-51), + qd_real( 3.1368174039889146e-01, 1.4560447299968912e-17, + 3.6564186898011595e-34, 1.1654264734999375e-50), + qd_real( 3.1659337555616585e-01, 2.1435292512726283e-17, + 1.2338169231377316e-33, 3.3963542100989293e-50), + qd_real( 3.1950203081601569e-01, -1.3981562491096626e-17, + 8.1730000697411350e-34, -7.7671096270210952e-50), + qd_real( 3.2240767880106985e-01, -4.0519039937959398e-18, + 3.7438302780296796e-34, 8.7936731046639195e-51), + qd_real( 3.2531029216226293e-01, 7.9171249463765892e-18, + -6.7576622068146391e-35, 2.3021655066929538e-51), + qd_real( 3.2820984357909255e-01, -2.6693140719641896e-17, + 7.8928851447534788e-34, 2.5525163821987809e-51), + qd_real( 3.3110630575987643e-01, -2.7469465474778694e-17, + -1.3401245916610206e-33, 6.5531762489976163e-50), + qd_real( 3.3399965144200938e-01, 2.2598986806288142e-17, + 7.8063057192586115e-34, 2.0427600895486683e-50), + qd_real( 3.3688985339222005e-01, -4.2000940033475092e-19, + -2.9178652969985438e-36, -1.1597376437036749e-52), + qd_real( 3.3977688440682685e-01, 6.6028679499418282e-18, + 1.2575009988669683e-34, 2.5569067699008304e-51), + qd_real( 3.4266071731199438e-01, 1.9261518449306319e-17, + -9.2754189135990867e-34, 8.5439996687390166e-50), + qd_real( 3.4554132496398904e-01, 2.7251143672916123e-17, + 7.0138163601941737e-34, -1.4176292197454015e-50), + qd_real( 3.4841868024943456e-01, 3.6974420514204918e-18, + 3.5532146878499996e-34, 1.9565462544501322e-50), + qd_real( 3.5129275608556715e-01, -2.2670712098795844e-17, + -1.6994216673139631e-34, -1.2271556077284517e-50), + qd_real( 3.5416352542049040e-01, -1.6951763305764860e-17, + 1.2772331777814617e-33, -3.3703785435843310e-50), + qd_real( 3.5703096123343003e-01, -4.8218191137919166e-19, + -4.1672436994492361e-35, -7.1531167149364352e-52), + qd_real( 3.5989503653498817e-01, -1.7601687123839282e-17, + 1.3375125473046791e-33, 7.9467815593584340e-50), + qd_real( 3.6275572436739723e-01, -9.1668352663749849e-18, + -7.4317843956936735e-34, -2.0199582511804564e-50), + qd_real( 3.6561299780477385e-01, 1.6217898770457546e-17, + 1.1286970151961055e-33, -7.1825287318139010e-50), + qd_real( 3.6846682995337232e-01, 1.0463640796159268e-17, + 2.0554984738517304e-35, 1.0441861305618769e-51), + qd_real( 3.7131719395183754e-01, 3.4749239648238266e-19, + -7.5151053042866671e-37, -2.8153468438650851e-53), + qd_real( 3.7416406297145799e-01, 8.0114103761962118e-18, + 5.3429599813406052e-34, 1.0351378796539210e-50), + qd_real( 3.7700741021641826e-01, -2.7255302041956930e-18, + 6.3646586445018137e-35, 8.3048657176503559e-52), + qd_real( 3.7984720892405116e-01, 9.9151305855172370e-18, + 4.8761409697224886e-34, 1.4025084000776705e-50), + qd_real( 3.8268343236508978e-01, -1.0050772696461588e-17, + -2.0605316302806695e-34, -1.2717724698085205e-50), + qd_real( 3.8551605384391885e-01, 1.5177665396472313e-17, + 1.4198230518016535e-33, 5.8955167159904235e-50), + qd_real( 3.8834504669882630e-01, -1.0053770598398717e-17, + 7.5942999255057131e-34, -3.1967974046654219e-50), + qd_real( 3.9117038430225387e-01, 1.7997787858243995e-17, + -1.0613482402609856e-33, -5.4582148817791032e-50), + qd_real( 3.9399204006104810e-01, 9.7649241641239336e-18, + -2.1233599441284617e-34, -5.5529836795340819e-51), + qd_real( 3.9680998741671031e-01, 2.0545063670840126e-17, + 6.1347058801922842e-34, 1.0733788150636430e-50), + qd_real( 3.9962419984564684e-01, -1.5065497476189372e-17, + -9.9653258881867298e-34, -5.7524323712725355e-50), + qd_real( 4.0243465085941843e-01, 1.0902619339328270e-17, + 7.3998528125989765e-34, 2.2745784806823499e-50), + qd_real( 4.0524131400498986e-01, 9.9111401942899884e-18, + -2.5169070895434648e-34, 9.2772984818436573e-53), + qd_real( 4.0804416286497869e-01, -7.0006015137351311e-18, + -1.4108207334268228e-34, 1.5175546997577136e-52), + qd_real( 4.1084317105790397e-01, -2.4219835190355499e-17, + -1.1418902925313314e-33, -2.0996843165093468e-50), + qd_real( 4.1363831223843456e-01, -1.0393984940597871e-17, + -1.1481681174503880e-34, -2.0281052851028680e-51), + qd_real( 4.1642956009763721e-01, -2.5475580413131732e-17, + -3.4482678506112824e-34, 7.1788619351865480e-51), + qd_real( 4.1921688836322396e-01, -4.2232463750110590e-18, + -3.6053023045255790e-34, -2.2209673210025631e-50), + qd_real( 4.2200027079979968e-01, 4.3543266994128527e-18, + 3.1734310272251190e-34, -1.3573247980738668e-50), + qd_real( 4.2477968120910881e-01, 2.7462312204277281e-17, + -4.6552847802111948e-34, 6.5961781099193122e-51), + qd_real( 4.2755509343028208e-01, 9.4111898162954726e-18, + -1.7446682426598801e-34, -2.2054492626480169e-51), + qd_real( 4.3032648134008261e-01, 2.2259686974092690e-17, + 8.5972591314085075e-34, -2.9420897889003020e-50), + qd_real( 4.3309381885315196e-01, 1.1224283329847517e-17, + 5.3223748041075651e-35, 5.3926192627014212e-51), + qd_real( 4.3585707992225547e-01, 1.6230515450644527e-17, + -6.4371449063579431e-35, -6.9102436481386757e-51), + qd_real( 4.3861623853852766e-01, -2.0883315831075090e-17, + -1.4259583540891877e-34, 6.3864763590657077e-52), + qd_real( 4.4137126873171667e-01, 2.2360783886964969e-17, + 1.1864769603515770e-34, -3.8087003266189232e-51), + qd_real( 4.4412214457042926e-01, -2.4218874422178315e-17, + 2.2205230838703907e-34, 9.2133035911356258e-51), + qd_real( 4.4686884016237421e-01, -1.9222136142309382e-17, + -4.4425678589732049e-35, -1.3673609292149535e-51), + qd_real( 4.4961132965460660e-01, 4.8831924232035243e-18, + 2.7151084498191381e-34, -1.5653993171613154e-50), + qd_real( 4.5234958723377089e-01, -1.4827977472196122e-17, + -7.6947501088972324e-34, 1.7656856882031319e-50), + qd_real( 4.5508358712634384e-01, -1.2379906758116472e-17, + 5.5289688955542643e-34, -8.5382312840209386e-51), + qd_real( 4.5781330359887723e-01, -8.4554254922295949e-18, + -6.3770394246764263e-34, 3.1778253575564249e-50), + qd_real( 4.6053871095824001e-01, 1.8488777492177872e-17, + -1.0527732154209725e-33, 3.3235593490947102e-50), + qd_real( 4.6325978355186020e-01, -7.3514924533231707e-18, + 6.7175396881707035e-34, 3.9594127612123379e-50), + qd_real( 4.6597649576796618e-01, -3.3023547778235135e-18, + 3.4904677050476886e-35, 3.4483855263874246e-51), + qd_real( 4.6868882203582796e-01, -2.2949251681845054e-17, + -1.1364757641823658e-33, 6.8840522501918612e-50), + qd_real( 4.7139673682599764e-01, 6.5166781360690130e-18, + 2.9457546966235984e-34, -6.2159717738836630e-51), + qd_real( 4.7410021465055002e-01, -8.1451601548978075e-18, + -3.4789448555614422e-34, -1.1681943974658508e-50), + qd_real( 4.7679923006332214e-01, -1.0293515338305794e-17, + -3.6582045008369952e-34, 1.7424131479176475e-50), + qd_real( 4.7949375766015301e-01, 1.8419999662684771e-17, + -1.3040838621273312e-33, 1.0977131822246471e-50), + qd_real( 4.8218377207912277e-01, -2.5861500925520442e-17, + -6.2913197606500007e-36, 4.0802359808684726e-52), + qd_real( 4.8486924800079112e-01, -1.8034004203262245e-17, + -3.5244276906958044e-34, -1.7138318654749246e-50), + qd_real( 4.8755016014843594e-01, 1.4231090931273653e-17, + -1.8277733073262697e-34, -1.5208291790429557e-51), + qd_real( 4.9022648328829116e-01, -5.1496145643440404e-18, + -3.6903027405284104e-34, 1.5172940095151304e-50), + qd_real( 4.9289819222978404e-01, -1.0257831676562186e-18, + 6.9520817760885069e-35, -2.4260961214090389e-51), + qd_real( 4.9556526182577254e-01, -9.4323241942365362e-18, + 3.1212918657699143e-35, 4.2009072375242736e-52), + qd_real( 4.9822766697278187e-01, -1.6126383830540798e-17, + -1.5092897319298871e-33, 1.1049298890895917e-50), + qd_real( 5.0088538261124083e-01, -3.9604015147074639e-17, + -2.2208395201898007e-33, 1.3648202735839417e-49), + qd_real( 5.0353838372571758e-01, -1.6731308204967497e-17, + -1.0140233644074786e-33, 4.0953071937671477e-50), + qd_real( 5.0618664534515534e-01, -4.8321592986493711e-17, + 9.2858107226642252e-34, 4.2699802401037005e-50), + qd_real( 5.0883014254310699e-01, 4.7836968268014130e-17, + -1.0727022928806035e-33, 2.7309374513672757e-50), + qd_real( 5.1146885043797041e-01, -1.3088001221007579e-17, + 4.0929033363366899e-34, -3.7952190153477926e-50), + qd_real( 5.1410274419322177e-01, -4.5712707523615624e-17, + 1.5488279442238283e-33, -2.5853959305521130e-50), + qd_real( 5.1673179901764987e-01, 8.3018617233836515e-18, + 5.8251027467695202e-34, -2.2812397190535076e-50), + qd_real( 5.1935599016558964e-01, -5.5331248144171145e-17, + -3.1628375609769026e-35, -2.4091972051188571e-51), + qd_real( 5.2197529293715439e-01, -4.6555795692088883e-17, + 4.6378980936850430e-34, -3.3470542934689532e-51), + qd_real( 5.2458968267846895e-01, -4.3068869040082345e-17, + -4.2013155291932055e-34, -1.5096069926700274e-50), + qd_real( 5.2719913478190139e-01, -4.2202983480560619e-17, + 8.5585916184867295e-34, 7.9974339336732307e-50), + qd_real( 5.2980362468629472e-01, -4.8067841706482342e-17, + 5.8309721046630296e-34, -8.9740761521756660e-51), + qd_real( 5.3240312787719801e-01, -4.1020306135800895e-17, + -1.9239996374230821e-33, -1.5326987913812184e-49), + qd_real( 5.3499761988709726e-01, -5.3683132708358134e-17, + -1.3900569918838112e-33, 2.7154084726474092e-50), + qd_real( 5.3758707629564551e-01, -2.2617365388403054e-17, + -5.9787279033447075e-34, 3.1204419729043625e-51), + qd_real( 5.4017147272989285e-01, 2.7072447965935839e-17, + 1.1698799709213829e-33, -5.9094668515881500e-50), + qd_real( 5.4275078486451589e-01, 1.7148261004757101e-17, + -1.3525905925200870e-33, 4.9724411290727323e-50), + qd_real( 5.4532498842204646e-01, -4.1517817538384258e-17, + -1.5318930219385941e-33, 6.3629921101413974e-50), + qd_real( 5.4789405917310019e-01, -2.4065878297113363e-17, + -3.5639213669362606e-36, -2.6013270854271645e-52), + qd_real( 5.5045797293660481e-01, -8.3319903015807663e-18, + -2.3058454035767633e-34, -2.1611290432369010e-50), + qd_real( 5.5301670558002758e-01, -4.7061536623798204e-17, + -1.0617111545918056e-33, -1.6196316144407379e-50), + qd_real( 5.5557023301960218e-01, 4.7094109405616768e-17, + -2.0640520383682921e-33, 1.2290163188567138e-49), + qd_real( 5.5811853122055610e-01, 1.3481176324765226e-17, + -5.5016743873011438e-34, -2.3484822739335416e-50), + qd_real( 5.6066157619733603e-01, -7.3956418153476152e-18, + 3.9680620611731193e-34, 3.1995952200836223e-50), + qd_real( 5.6319934401383409e-01, 2.3835775146854829e-17, + 1.3511793173769814e-34, 9.3201311581248143e-51), + qd_real( 5.6573181078361323e-01, -3.4096079596590466e-17, + -1.7073289744303546e-33, 8.9147089975404507e-50), + qd_real( 5.6825895267013160e-01, -5.0935673642769248e-17, + -1.6274356351028249e-33, 9.8183151561702966e-51), + qd_real( 5.7078074588696726e-01, 2.4568151455566208e-17, + -1.2844481247560350e-33, -1.8037634376936261e-50), + qd_real( 5.7329716669804220e-01, 8.5176611669306400e-18, + -6.4443208788026766e-34, 2.2546105543273003e-50), + qd_real( 5.7580819141784534e-01, -3.7909495458942734e-17, + -2.7433738046854309e-33, 1.1130841524216795e-49), + qd_real( 5.7831379641165559e-01, -2.6237691512372831e-17, + 1.3679051680738167e-33, -3.1409808935335900e-50), + qd_real( 5.8081395809576453e-01, 1.8585338586613408e-17, + 2.7673843114549181e-34, 1.9605349619836937e-50), + qd_real( 5.8330865293769829e-01, 3.4516601079044858e-18, + 1.8065977478946306e-34, -6.3953958038544646e-51), + qd_real( 5.8579785745643886e-01, -3.7485501964311294e-18, + 2.7965403775536614e-34, -7.1816936024157202e-51), + qd_real( 5.8828154822264533e-01, -2.9292166725006846e-17, + -2.3744954603693934e-33, -1.1571631191512480e-50), + qd_real( 5.9075970185887428e-01, -4.7013584170659542e-17, + 2.4808417611768356e-33, 1.2598907673643198e-50), + qd_real( 5.9323229503979980e-01, 1.2892320944189053e-17, + 5.3058364776359583e-34, 4.1141674699390052e-50), + qd_real( 5.9569930449243336e-01, -1.3438641936579467e-17, + -6.7877687907721049e-35, -5.6046937531684890e-51), + qd_real( 5.9816070699634227e-01, 3.8801885783000657e-17, + -1.2084165858094663e-33, -4.0456610843430061e-50), + qd_real( 6.0061647938386897e-01, -4.6398198229461932e-17, + -1.6673493003710801e-33, 5.1982824378491445e-50), + qd_real( 6.0306659854034816e-01, 3.7323357680559650e-17, + 2.7771920866974305e-33, -1.6194229649742458e-49), + qd_real( 6.0551104140432555e-01, -3.1202672493305677e-17, + 1.2761267338680916e-33, -4.0859368598379647e-50), + qd_real( 6.0794978496777363e-01, 3.5160832362096660e-17, + -2.5546242776778394e-34, -1.4085313551220694e-50), + qd_real( 6.1038280627630948e-01, -2.2563265648229169e-17, + 1.3185575011226730e-33, 8.2316691420063460e-50), + qd_real( 6.1281008242940971e-01, -4.2693476568409685e-18, + 2.5839965886650320e-34, 1.6884412005622537e-50), + qd_real( 6.1523159058062682e-01, 2.6231417767266950e-17, + -1.4095366621106716e-33, 7.2058690491304558e-50), + qd_real( 6.1764730793780398e-01, -4.7478594510902452e-17, + -7.2986558263123996e-34, -3.0152327517439154e-50), + qd_real( 6.2005721176328921e-01, -2.7983410837681118e-17, + 1.1649951056138923e-33, -5.4539089117135207e-50), + qd_real( 6.2246127937414997e-01, 5.2940728606573002e-18, + -4.8486411215945827e-35, 1.2696527641980109e-52), + qd_real( 6.2485948814238634e-01, 3.3671846037243900e-17, + -2.7846053391012096e-33, 5.6102718120012104e-50), + qd_real( 6.2725181549514408e-01, 3.0763585181253225e-17, + 2.7068930273498138e-34, -1.1172240309286484e-50), + qd_real( 6.2963823891492698e-01, 4.1115334049626806e-17, + -1.9167473580230747e-33, 1.1118424028161730e-49), + qd_real( 6.3201873593980906e-01, -4.0164942296463612e-17, + -7.2208643641736723e-34, 3.7828920470544344e-50), + qd_real( 6.3439328416364549e-01, 1.0420901929280035e-17, + 4.1174558929280492e-34, -1.4464152986630705e-51), + qd_real( 6.3676186123628420e-01, 3.1419048711901611e-17, + -2.2693738415126449e-33, -1.6023584204297388e-49), + qd_real( 6.3912444486377573e-01, 1.2416796312271043e-17, + -6.2095419626356605e-34, 2.7762065999506603e-50), + qd_real( 6.4148101280858316e-01, -9.9883430115943310e-18, + 4.1969230376730128e-34, 5.6980543799257597e-51), + qd_real( 6.4383154288979150e-01, -3.2084798795046886e-17, + -1.2595311907053305e-33, -4.0205885230841536e-50), + qd_real( 6.4617601298331639e-01, -2.9756137382280815e-17, + -1.0275370077518259e-33, 8.0852478665893014e-51), + qd_real( 6.4851440102211244e-01, 3.9870270313386831e-18, + 1.9408388509540788e-34, -5.1798420636193190e-51), + qd_real( 6.5084668499638088e-01, 3.9714670710500257e-17, + 2.9178546787002963e-34, 3.8140635508293278e-51), + qd_real( 6.5317284295377676e-01, 8.5695642060026238e-18, + -6.9165322305070633e-34, 2.3873751224185395e-50), + qd_real( 6.5549285299961535e-01, 3.5638734426385005e-17, + 1.2695365790889811e-33, 4.3984952865412050e-50), + qd_real( 6.5780669329707864e-01, 1.9580943058468545e-17, + -1.1944272256627192e-33, 2.8556402616436858e-50), + qd_real( 6.6011434206742048e-01, -1.3960054386823638e-19, + 6.1515777931494047e-36, 5.3510498875622660e-52), + qd_real( 6.6241577759017178e-01, -2.2615508885764591e-17, + 5.0177050318126862e-34, 2.9162532399530762e-50), + qd_real( 6.6471097820334490e-01, -3.6227793598034367e-17, + -9.0607934765540427e-34, 3.0917036342380213e-50), + qd_real( 6.6699992230363747e-01, 3.5284364997428166e-17, + -1.0382057232458238e-33, 7.3812756550167626e-50), + qd_real( 6.6928258834663612e-01, -5.4592652417447913e-17, + -2.5181014709695152e-33, -1.6867875999437174e-49), + qd_real( 6.7155895484701844e-01, -4.0489037749296692e-17, + 3.1995835625355681e-34, -1.4044414655670960e-50), + qd_real( 6.7382900037875604e-01, 2.3091901236161086e-17, + 5.7428037192881319e-34, 1.1240668354625977e-50), + qd_real( 6.7609270357531592e-01, 3.7256902248049466e-17, + 1.7059417895764375e-33, 9.7326347795300652e-50), + qd_real( 6.7835004312986147e-01, 1.8302093041863122e-17, + 9.5241675746813072e-34, 5.0328101116133503e-50), + qd_real( 6.8060099779545302e-01, 2.8473293354522047e-17, + 4.1331805977270903e-34, 4.2579030510748576e-50), + qd_real( 6.8284554638524808e-01, -1.2958058061524531e-17, + 1.8292386959330698e-34, 3.4536209116044487e-51), + qd_real( 6.8508366777270036e-01, 2.5948135194645137e-17, + -8.5030743129500702e-34, -6.9572086141009930e-50), + qd_real( 6.8731534089175916e-01, -5.5156158714917168e-17, + 1.1896489854266829e-33, -7.8505896218220662e-51), + qd_real( 6.8954054473706694e-01, -1.5889323294806790e-17, + 9.1242356240205712e-34, 3.8315454152267638e-50), + qd_real( 6.9175925836415775e-01, 2.7406078472410668e-17, + 1.3286508943202092e-33, 1.0651869129580079e-51), + qd_real( 6.9397146088965400e-01, 7.4345076956280137e-18, + 7.5061528388197460e-34, -1.5928000240686583e-50), + qd_real( 6.9617713149146299e-01, -4.1224081213582889e-17, + -3.1838716762083291e-35, -3.9625587412119131e-51), + qd_real( 6.9837624940897280e-01, 4.8988282435667768e-17, + 1.9134010413244152e-33, 2.6161153243793989e-50), + qd_real( 7.0056879394324834e-01, 3.1027960192992922e-17, + 9.5638250509179997e-34, 4.5896916138107048e-51), + qd_real( 7.0275474445722530e-01, 2.5278294383629822e-18, + -8.6985561210674942e-35, -5.6899862307812990e-51), + qd_real( 7.0493408037590488e-01, 2.7608725585748502e-17, + 2.9816599471629137e-34, 1.1533044185111206e-50), + qd_real( 7.0710678118654757e-01, -4.8336466567264567e-17, + 2.0693376543497068e-33, 2.4677734957341755e-50) +}; + +static const qd_real cos_table [] = { + qd_real( 9.9999529380957619e-01, -1.9668064285322189e-17, + -6.3053955095883481e-34, 5.3266110855726731e-52), + qd_real( 9.9998117528260111e-01, 3.3568103522895585e-17, + -1.4740132559368063e-35, 9.8603097594755596e-52), + qd_real( 9.9995764455196390e-01, -3.1527836866647287e-17, + 2.6363251186638437e-33, 1.0007504815488399e-49), + qd_real( 9.9992470183914450e-01, 3.7931082512668012e-17, + -8.5099918660501484e-35, -4.9956973223295153e-51), + qd_real( 9.9988234745421256e-01, -3.5477814872408538e-17, + 1.7102001035303974e-33, -1.0725388519026542e-49), + qd_real( 9.9983058179582340e-01, 1.8825140517551119e-17, + -5.1383513457616937e-34, -3.8378827995403787e-50), + qd_real( 9.9976940535121528e-01, 4.2681177032289012e-17, + 1.9062302359737099e-33, -6.0221153262881160e-50), + qd_real( 9.9969881869620425e-01, -2.9851486403799753e-17, + -1.9084787370733737e-33, 5.5980260344029202e-51), + qd_real( 9.9961882249517864e-01, -4.1181965521424734e-17, + 2.0915365593699916e-33, 8.1403390920903734e-50), + qd_real( 9.9952941750109314e-01, 2.0517917823755591e-17, + -4.7673802585706520e-34, -2.9443604198656772e-50), + qd_real( 9.9943060455546173e-01, 3.9644497752257798e-17, + -2.3757223716722428e-34, -1.2856759011361726e-51), + qd_real( 9.9932238458834954e-01, -4.2858538440845682e-17, + 3.3235101605146565e-34, -8.3554272377057543e-51), + qd_real( 9.9920475861836389e-01, 9.1796317110385693e-18, + 5.5416208185868570e-34, 8.0267046717615311e-52), + qd_real( 9.9907772775264536e-01, 2.1419007653587032e-17, + -7.9048203318529618e-34, -5.3166296181112712e-50), + qd_real( 9.9894129318685687e-01, -2.0610641910058638e-17, + -1.2546525485913485e-33, -7.5175888806157064e-50), + qd_real( 9.9879545620517241e-01, -1.2291693337075465e-17, + 2.4468446786491271e-34, 1.0723891085210268e-50), + qd_real( 9.9864021818026527e-01, -4.8690254312923302e-17, + -2.9470881967909147e-34, -1.3000650761346907e-50), + qd_real( 9.9847558057329477e-01, -2.2002931182778795e-17, + -1.2371509454944992e-33, -2.4911225131232065e-50), + qd_real( 9.9830154493389289e-01, -5.1869402702792278e-17, + 1.0480195493633452e-33, -2.8995649143155511e-50), + qd_real( 9.9811811290014918e-01, 2.7935487558113833e-17, + 2.4423341255830345e-33, -6.7646699175334417e-50), + qd_real( 9.9792528619859600e-01, 1.7143659778886362e-17, + 5.7885840902887460e-34, -9.2601432603894597e-51), + qd_real( 9.9772306664419164e-01, -2.6394475274898721e-17, + -1.6176223087661783e-34, -9.9924942889362281e-51), + qd_real( 9.9751145614030345e-01, 5.6007205919806937e-18, + -5.9477673514685690e-35, -1.4166807162743627e-54), + qd_real( 9.9729045667869021e-01, 9.1647695371101735e-18, + 6.7824134309739296e-34, -8.6191392795543357e-52), + qd_real( 9.9706007033948296e-01, 1.6734093546241963e-17, + -1.3169951440780028e-33, 1.0311048767952477e-50), + qd_real( 9.9682029929116567e-01, 4.7062820708615655e-17, + 2.8412041076474937e-33, -8.0006155670263622e-50), + qd_real( 9.9657114579055484e-01, 1.1707179088390986e-17, + -7.5934413263024663e-34, 2.8474848436926008e-50), + qd_real( 9.9631261218277800e-01, 1.1336497891624735e-17, + 3.4002458674414360e-34, 7.7419075921544901e-52), + qd_real( 9.9604470090125197e-01, 2.2870031707670695e-17, + -3.9184839405013148e-34, -3.7081260416246375e-50), + qd_real( 9.9576741446765982e-01, -2.3151908323094359e-17, + -1.6306512931944591e-34, -1.5925420783863192e-51), + qd_real( 9.9548075549192694e-01, 3.2084621412226554e-18, + -4.9501292146013023e-36, -2.7811428850878516e-52), + qd_real( 9.9518472667219693e-01, -4.2486913678304410e-17, + 1.3315510772504614e-33, 6.7927987417051888e-50), + qd_real( 9.9487933079480562e-01, 4.2130813284943662e-18, + -4.2062597488288452e-35, 2.5157064556087620e-51), + qd_real( 9.9456457073425542e-01, 3.6745069641528058e-17, + -3.0603304105471010e-33, 1.0397872280487526e-49), + qd_real( 9.9424044945318790e-01, 4.4129423472462673e-17, + -3.0107231708238066e-33, 7.4201582906861892e-50), + qd_real( 9.9390697000235606e-01, -1.8964849471123746e-17, + -1.5980853777937752e-35, -8.5374807150597082e-52), + qd_real( 9.9356413552059530e-01, 2.9752309927797428e-17, + -4.5066707331134233e-34, -3.3548191633805036e-50), + qd_real( 9.9321194923479450e-01, 3.3096906261272262e-17, + 1.5592811973249567e-33, 1.4373977733253592e-50), + qd_real( 9.9285041445986510e-01, -1.4094517733693302e-17, + -1.1954558131616916e-33, 1.8761873742867983e-50), + qd_real( 9.9247953459870997e-01, 3.1093055095428906e-17, + -1.8379594757818019e-33, -3.9885758559381314e-51), + qd_real( 9.9209931314219180e-01, -3.9431926149588778e-17, + -6.2758062911047230e-34, -1.2960929559212390e-50), + qd_real( 9.9170975366909953e-01, -2.3372891311883661e-18, + 2.7073298824968591e-35, -1.2569459441802872e-51), + qd_real( 9.9131085984611544e-01, -2.5192111583372105e-17, + -1.2852471567380887e-33, 5.2385212584310483e-50), + qd_real( 9.9090263542778001e-01, 1.5394565094566704e-17, + -1.0799984133184567e-33, 2.7451115960133595e-51), + qd_real( 9.9048508425645709e-01, -5.5411437553780867e-17, + -1.4614017210753585e-33, -3.8339374397387620e-50), + qd_real( 9.9005821026229712e-01, -1.7055485906233963e-17, + 1.3454939685758777e-33, 7.3117589137300036e-50), + qd_real( 9.8962201746320089e-01, -5.2398217968132530e-17, + 1.3463189211456219e-33, 5.8021640554894872e-50), + qd_real( 9.8917650996478101e-01, -4.0987309937047111e-17, + -4.4857560552048437e-34, -3.9414504502871125e-50), + qd_real( 9.8872169196032378e-01, -1.0976227206656125e-17, + 3.2311342577653764e-34, 9.6367946583575041e-51), + qd_real( 9.8825756773074946e-01, 2.7030607784372632e-17, + 7.7514866488601377e-35, 2.1019644956864938e-51), + qd_real( 9.8778414164457218e-01, -2.3600693397159021e-17, + -1.2323283769707861e-33, 3.0130900716803339e-50), + qd_real( 9.8730141815785843e-01, -5.2332261255715652e-17, + -2.7937644333152473e-33, 1.2074160567958408e-49), + qd_real( 9.8680940181418553e-01, -5.0287214351061075e-17, + -2.2681526238144461e-33, 4.4003694320169133e-50), + qd_real( 9.8630809724459867e-01, -2.1520877103013341e-17, + 1.1866528054187716e-33, -7.8532199199813836e-50), + qd_real( 9.8579750916756748e-01, -5.1439452979953012e-17, + 2.6276439309996725e-33, 7.5423552783286347e-50), + qd_real( 9.8527764238894122e-01, 2.3155637027900207e-17, + -7.5275971545764833e-34, 1.0582231660456094e-50), + qd_real( 9.8474850180190421e-01, 1.0548144061829957e-17, + 2.8786145266267306e-34, -3.6782210081466112e-51), + qd_real( 9.8421009238692903e-01, 4.7983922627050691e-17, + 2.2597419645070588e-34, 1.7573875814863400e-50), + qd_real( 9.8366241921173025e-01, 1.9864948201635255e-17, + -1.0743046281211033e-35, 1.7975662796558100e-52), + qd_real( 9.8310548743121629e-01, 4.2170007522888628e-17, + 8.2396265656440904e-34, -8.0803700139096561e-50), + qd_real( 9.8253930228744124e-01, 1.5149580813777224e-17, + -4.1802771422186237e-34, -2.2150174326226160e-50), + qd_real( 9.8196386910955524e-01, 2.1108443711513084e-17, + -1.5253013442896054e-33, -6.8388082079337969e-50), + qd_real( 9.8137919331375456e-01, 1.3428163260355633e-17, + -6.5294290469962986e-34, 2.7965412287456268e-51), + qd_real( 9.8078528040323043e-01, 1.8546939997825006e-17, + -1.0696564445530757e-33, 6.6668174475264961e-50), + qd_real( 9.8018213596811743e-01, -3.6801786963856159e-17, + 6.3245171387992842e-34, 1.8600176137175971e-50), + qd_real( 9.7956976568544052e-01, 1.5573991584990420e-17, + -1.3401066029782990e-33, -1.7263702199862149e-50), + qd_real( 9.7894817531906220e-01, -2.3817727961148053e-18, + -1.0694750370381661e-34, -8.2293047196087462e-51), + qd_real( 9.7831737071962765e-01, -2.1623082233344895e-17, + 1.0970403012028032e-33, 7.7091923099369339e-50), + qd_real( 9.7767735782450993e-01, 5.0514136167059628e-17, + -1.3254751701428788e-33, 7.0161254312124538e-50), + qd_real( 9.7702814265775439e-01, -4.3353875751555997e-17, + 5.4948839831535478e-34, -9.2755263105377306e-51), + qd_real( 9.7636973133002114e-01, 9.3093931526213780e-18, + -4.1184949155685665e-34, -3.1913926031393690e-50), + qd_real( 9.7570213003852857e-01, -2.5572556081259686e-17, + -9.3174244508942223e-34, -8.3675863211646863e-51), + qd_real( 9.7502534506699412e-01, 2.6642660651899135e-17, + 1.7819392739353853e-34, -3.3159625385648947e-51), + qd_real( 9.7433938278557586e-01, 2.3041221476151512e-18, + 1.0758686005031430e-34, 5.1074116432809478e-51), + qd_real( 9.7364424965081198e-01, -5.1729808691005871e-17, + -1.5508473005989887e-33, -1.6505125917675401e-49), + qd_real( 9.7293995220556018e-01, -3.1311211122281800e-17, + -2.6874087789006141e-33, -2.1652434818822145e-51), + qd_real( 9.7222649707893627e-01, 3.6461169785938221e-17, + 3.0309636883883133e-33, -1.2702716907967306e-51), + qd_real( 9.7150389098625178e-01, -7.9865421122289046e-18, + -4.3628417211263380e-34, 3.4307517798759352e-51), + qd_real( 9.7077214072895035e-01, -4.7992163325114922e-17, + 3.0347528910975783e-33, 8.5989199506479701e-50), + qd_real( 9.7003125319454397e-01, 1.8365300348428844e-17, + -1.4311097571944918e-33, 8.5846781998740697e-51), + qd_real( 9.6928123535654853e-01, -4.5663660261927896e-17, + 9.6147526917239387e-34, 8.1267605207871330e-51), + qd_real( 9.6852209427441727e-01, 4.9475074918244771e-17, + 2.8558738351911241e-33, 6.2948422316507461e-50), + qd_real( 9.6775383709347551e-01, -4.5512132825515820e-17, + -1.4127617988719093e-33, -8.4620609089704578e-50), + qd_real( 9.6697647104485207e-01, 3.8496228837337864e-17, + -5.3881631542745647e-34, -3.5221863171458959e-50), + qd_real( 9.6619000344541250e-01, 5.1298840401665493e-17, + 1.4564075904769808e-34, 1.0095973971377432e-50), + qd_real( 9.6539444169768940e-01, -2.3745389918392156e-17, + 5.9221515590053862e-34, -3.8811192556231094e-50), + qd_real( 9.6458979328981276e-01, -3.4189470735959786e-17, + 2.2982074155463522e-33, -4.5128791045607634e-50), + qd_real( 9.6377606579543984e-01, 2.6463950561220029e-17, + -2.9073234590199323e-36, -1.2938328629395601e-52), + qd_real( 9.6295326687368388e-01, 8.9341960404313634e-18, + -3.9071244661020126e-34, 1.6212091116847394e-50), + qd_real( 9.6212140426904158e-01, 1.5236770453846305e-17, + -1.3050173525597142e-33, 7.9016122394092666e-50), + qd_real( 9.6128048581132064e-01, 2.0933955216674039e-18, + 1.0768607469015692e-34, -5.9453639304361774e-51), + qd_real( 9.6043051941556579e-01, 2.4653904815317185e-17, + -1.3792169410906322e-33, -4.7726598378506903e-51), + qd_real( 9.5957151308198452e-01, 1.1000640085000957e-17, + -4.2036030828223975e-34, 4.0023704842606573e-51), + qd_real( 9.5870347489587160e-01, -4.3685014392372053e-17, + 2.2001800662729131e-33, -1.0553721324358075e-49), + qd_real( 9.5782641302753291e-01, -1.7696710075371263e-17, + 1.9164034110382190e-34, 8.1489235071754813e-51), + qd_real( 9.5694033573220882e-01, 4.0553869861875701e-17, + -1.7147013364302149e-33, 2.5736745295329455e-50), + qd_real( 9.5604525134999641e-01, 3.7705045279589067e-17, + 1.9678699997347571e-33, 8.5093177731230180e-50), + qd_real( 9.5514116830577067e-01, 5.0088652955014668e-17, + -2.6983181838059211e-33, 1.0102323575596493e-49), + qd_real( 9.5422809510910567e-01, -3.7545901690626874e-17, + 1.4951619241257764e-33, -8.2717333151394973e-50), + qd_real( 9.5330604035419386e-01, -2.5190738779919934e-17, + -1.4272239821134379e-33, -4.6717286809283155e-50), + qd_real( 9.5237501271976588e-01, -2.0269300462299272e-17, + -1.0635956887246246e-33, -3.5514537666487619e-50), + qd_real( 9.5143502096900834e-01, 3.1350584123266695e-17, + -2.4824833452737813e-33, 9.5450335525380613e-51), + qd_real( 9.5048607394948170e-01, 1.9410097562630436e-17, + -8.1559393949816789e-34, -1.0501209720164562e-50), + qd_real( 9.4952818059303667e-01, -7.5544151928043298e-18, + -5.1260245024046686e-34, 1.8093643389040406e-50), + qd_real( 9.4856134991573027e-01, 2.0668262262333232e-17, + -5.9440730243667306e-34, 1.4268853111554300e-50), + qd_real( 9.4758559101774109e-01, 4.3417993852125991e-17, + -2.7728667889840373e-34, 5.5709160196519968e-51), + qd_real( 9.4660091308328353e-01, 3.5056800210680730e-17, + 9.8578536940318117e-34, 6.6035911064585197e-50), + qd_real( 9.4560732538052128e-01, 4.6019102478523738e-17, + -6.2534384769452059e-34, 1.5758941215779961e-50), + qd_real( 9.4460483726148026e-01, 8.8100545476641165e-18, + 5.2291695602757842e-34, -3.3487256018407123e-50), + qd_real( 9.4359345816196039e-01, -2.4093127844404214e-17, + 1.0283279856803939e-34, -2.3398232614531355e-51), + qd_real( 9.4257319760144687e-01, 1.3235564806436886e-17, + -5.7048262885386911e-35, 3.9947050442753744e-51), + qd_real( 9.4154406518302081e-01, -2.7896379547698341e-17, + 1.6273236356733898e-33, -5.3075944708471203e-51), + qd_real( 9.4050607059326830e-01, 2.8610421567116268e-17, + 2.9261501147538827e-33, -2.6849867690896925e-50), + qd_real( 9.3945922360218992e-01, -7.0152867943098655e-18, + -5.6395693818011210e-34, 3.5568142678987651e-50), + qd_real( 9.3840353406310806e-01, 5.4242545044795490e-17, + -1.9039966607859759e-33, -1.5627792988341215e-49), + qd_real( 9.3733901191257496e-01, -3.6570926284362776e-17, + -1.1902940071273247e-33, -1.1215082331583223e-50), + qd_real( 9.3626566717027826e-01, -1.3013766145497654e-17, + 5.2229870061990595e-34, -3.3972777075634108e-51), + qd_real( 9.3518350993894761e-01, -3.2609395302485065e-17, + -8.1813015218875245e-34, 5.5642140024928139e-50), + qd_real( 9.3409255040425887e-01, 4.4662824360767511e-17, + -2.5903243047396916e-33, 8.1505209004343043e-50), + qd_real( 9.3299279883473885e-01, 4.2041415555384355e-17, + 9.0285896495521276e-34, 5.3019984977661259e-50), + qd_real( 9.3188426558166815e-01, -4.0785944377318095e-17, + 1.7631450298754169e-33, 2.5776403305507453e-50), + qd_real( 9.3076696107898371e-01, 1.9703775102838329e-17, + 6.5657908718278205e-34, -1.9480347966259524e-51), + qd_real( 9.2964089584318121e-01, 5.1282530016864107e-17, + 2.3719739891916261e-34, -1.7230065426917127e-50), + qd_real( 9.2850608047321559e-01, -2.3306639848485943e-17, + -7.7799084333208503e-34, -5.8597558009300305e-50), + qd_real( 9.2736252565040111e-01, -2.7677111692155437e-17, + 2.2110293450199576e-34, 2.0349190819680613e-50), + qd_real( 9.2621024213831138e-01, -3.7303754586099054e-17, + 2.0464457809993405e-33, 1.3831799631231817e-49), + qd_real( 9.2504924078267758e-01, 6.0529447412576159e-18, + -8.8256517760278541e-35, 1.8285462122388328e-51), + qd_real( 9.2387953251128674e-01, 1.7645047084336677e-17, + -5.0442537321586818e-34, -4.0478677716823890e-50), + qd_real( 9.2270112833387852e-01, 5.2963798918539814e-17, + -5.7135699628876685e-34, 3.0163671797219087e-50), + qd_real( 9.2151403934204190e-01, 4.1639843390684644e-17, + 1.1891485604702356e-33, 2.0862437594380324e-50), + qd_real( 9.2031827670911059e-01, -2.7806888779036837e-17, + 2.7011013677071274e-33, 1.1998578792455499e-49), + qd_real( 9.1911385169005777e-01, -2.6496484622344718e-17, + 6.5403604763461920e-34, -2.8997180201186078e-50), + qd_real( 9.1790077562139050e-01, -3.9074579680849515e-17, + 2.3004636541490264e-33, 3.9851762744443107e-50), + qd_real( 9.1667905992104270e-01, -4.1733978698287568e-17, + 1.2094444804381172e-33, 4.9356916826097816e-50), + qd_real( 9.1544871608826783e-01, -1.3591056692900894e-17, + 5.9923027475594735e-34, 2.1403295925962879e-50), + qd_real( 9.1420975570353069e-01, -3.6316182527814423e-17, + -1.9438819777122554e-33, 2.8340679287728316e-50), + qd_real( 9.1296219042839821e-01, -4.7932505228039469e-17, + -1.7753551889428638e-33, 4.0607782903868160e-51), + qd_real( 9.1170603200542988e-01, -2.6913273175034130e-17, + -5.1928101916162528e-35, 1.1338175936090630e-51), + qd_real( 9.1044129225806725e-01, -5.0433041673313820e-17, + 1.0938746257404305e-33, 9.5378272084170731e-51), + qd_real( 9.0916798309052238e-01, -3.6878564091359894e-18, + 2.9951330310507693e-34, -1.2225666136919926e-50), + qd_real( 9.0788611648766626e-01, -4.9459964301225840e-17, + -1.6599682707075313e-33, -5.1925202712634716e-50), + qd_real( 9.0659570451491533e-01, 3.0506718955442023e-17, + -1.4478836557141204e-33, 1.8906373784448725e-50), + qd_real( 9.0529675931811882e-01, -4.1153099826889901e-17, + 2.9859368705184223e-33, 5.1145293917439211e-50), + qd_real( 9.0398929312344334e-01, -6.6097544687484308e-18, + 1.2728013034680357e-34, -4.3026097234014823e-51), + qd_real( 9.0267331823725883e-01, -1.9250787033961483e-17, + 1.3242128993244527e-33, -5.2971030688703665e-50), + qd_real( 9.0134884704602203e-01, -1.3524789367698682e-17, + 6.3605353115880091e-34, 3.6227400654573828e-50), + qd_real( 9.0001589201616028e-01, -5.0639618050802273e-17, + 1.0783525384031576e-33, 2.8130016326515111e-50), + qd_real( 8.9867446569395382e-01, 2.6316906461033013e-17, + 3.7003137047796840e-35, -2.3447719900465938e-51), + qd_real( 8.9732458070541832e-01, -3.6396283314867290e-17, + -2.3611649895474815e-33, 1.1837247047900082e-49), + qd_real( 8.9596624975618511e-01, 4.9025099114811813e-17, + -1.9440489814795326e-33, -1.7070486667767033e-49), + qd_real( 8.9459948563138270e-01, -1.7516226396814919e-17, + -1.3200670047246923e-33, -1.5953009884324695e-50), + qd_real( 8.9322430119551532e-01, -4.1161239151908913e-18, + 2.5380253805715999e-34, 4.2849455510516192e-51), + qd_real( 8.9184070939234272e-01, 4.6690228137124547e-18, + 1.6150254286841982e-34, -3.9617448820725012e-51), + qd_real( 8.9044872324475788e-01, 1.1781931459051803e-17, + -1.3346142209571930e-34, -9.4982373530733431e-51), + qd_real( 8.8904835585466457e-01, -1.1164514966766675e-17, + -3.4797636107798736e-34, -1.5605079997040631e-50), + qd_real( 8.8763962040285393e-01, 1.2805091918587960e-17, + 3.9948742059584459e-35, 3.8940716325338136e-51), + qd_real( 8.8622253014888064e-01, -6.7307369600274315e-18, + 1.2385593432917413e-34, 2.0364014759133320e-51), + qd_real( 8.8479709843093779e-01, -9.4331469628972690e-18, + -5.7106541478701439e-34, 1.8260134111907397e-50), + qd_real( 8.8336333866573158e-01, 1.5822643380255127e-17, + -7.8921320007588250e-34, -1.4782321016179836e-50), + qd_real( 8.8192126434835505e-01, -1.9843248405890562e-17, + -7.0412114007673834e-34, -1.0636770169389104e-50), + qd_real( 8.8047088905216075e-01, 1.6311096602996350e-17, + -5.7541360594724172e-34, -4.0128611862170021e-50), + qd_real( 8.7901222642863353e-01, -4.7356837291118011e-17, + 1.4388771297975192e-33, -2.9085554304479134e-50), + qd_real( 8.7754529020726124e-01, 5.0113311846499550e-17, + 2.8382769008739543e-34, 1.5550640393164140e-50), + qd_real( 8.7607009419540660e-01, 5.8729024235147677e-18, + 2.7941144391738458e-34, -1.8536073846509828e-50), + qd_real( 8.7458665227817611e-01, -5.7216617730397065e-19, + -2.9705811503689596e-35, 8.7389593969796752e-52), + qd_real( 8.7309497841829009e-01, 7.8424672990129903e-18, + -4.8685015839797165e-34, -2.2815570587477527e-50), + qd_real( 8.7159508665595109e-01, -5.5272998038551050e-17, + -2.2104090204984907e-33, -9.7749763187643172e-50), + qd_real( 8.7008699110871146e-01, -4.1888510868549968e-17, + 7.0900185861878415e-34, 3.7600251115157260e-50), + qd_real( 8.6857070597134090e-01, 2.7192781689782903e-19, + -1.6710140396932428e-35, -1.2625514734637969e-51), + qd_real( 8.6704624551569265e-01, 3.0267859550930567e-18, + -1.1559438782171572e-34, -5.3580556397808012e-52), + qd_real( 8.6551362409056909e-01, -6.3723113549628899e-18, + 2.3725520321746832e-34, 1.5911880348395175e-50), + qd_real( 8.6397285612158670e-01, 4.1486355957361607e-17, + 2.2709976932210266e-33, -8.1228385659479984e-50), + qd_real( 8.6242395611104050e-01, 3.7008992527383130e-17, + 5.2128411542701573e-34, 2.6945600081026861e-50), + qd_real( 8.6086693863776731e-01, -3.0050048898573656e-17, + -8.8706183090892111e-34, 1.5005320558097301e-50), + qd_real( 8.5930181835700836e-01, 4.2435655816850687e-17, + 7.6181814059912025e-34, -3.9592127850658708e-50), + qd_real( 8.5772861000027212e-01, -4.8183447936336620e-17, + -1.1044130517687532e-33, -8.7400233444645562e-50), + qd_real( 8.5614732837519447e-01, 9.1806925616606261e-18, + 5.6328649785951470e-34, 2.3326646113217378e-51), + qd_real( 8.5455798836540053e-01, -1.2991124236396092e-17, + 1.2893407722948080e-34, -3.6506925747583053e-52), + qd_real( 8.5296060493036363e-01, 2.7152984251981370e-17, + 7.4336483283120719e-34, 4.2162417622350668e-50), + qd_real( 8.5135519310526520e-01, -5.3279874446016209e-17, + 2.2281156380919942e-33, -4.0281886404138477e-50), + qd_real( 8.4974176800085244e-01, 5.1812347659974015e-17, + 3.0810626087331275e-33, -2.5931308201994965e-50), + qd_real( 8.4812034480329723e-01, 1.8762563415239981e-17, + 1.4048773307919617e-33, -2.4915221509958691e-50), + qd_real( 8.4649093877405213e-01, -4.7969419958569345e-17, + -2.7518267097886703e-33, -7.3518959727313350e-50), + qd_real( 8.4485356524970712e-01, -4.3631360296879637e-17, + -2.0307726853367547e-33, 4.3097229819851761e-50), + qd_real( 8.4320823964184544e-01, 9.6536707005959077e-19, + 2.8995142431556364e-36, 9.6715076811480284e-53), + qd_real( 8.4155497743689844e-01, -3.4095465391321557e-17, + -8.4130208607579595e-34, -4.9447283960568686e-50), + qd_real( 8.3989379419599952e-01, -1.6673694881511411e-17, + -1.4759184141750289e-33, -7.5795098161914058e-50), + qd_real( 8.3822470555483808e-01, -3.5560085052855026e-17, + 1.1689791577022643e-33, -5.8627347359723411e-50), + qd_real( 8.3654772722351201e-01, -2.0899059027066533e-17, + -9.8104097821002585e-35, -3.1609177868229853e-51), + qd_real( 8.3486287498638001e-01, 4.6048430609159657e-17, + -5.1827423265239912e-34, -7.0505343435504109e-51), + qd_real( 8.3317016470191319e-01, 1.3275129507229764e-18, + 4.8589164115370863e-35, 4.5422281300506859e-51), + qd_real( 8.3146961230254524e-01, 1.4073856984728024e-18, + 4.6951315383980830e-35, 5.1431906049905658e-51), + qd_real( 8.2976123379452305e-01, -2.9349109376485597e-18, + 1.1496917934149818e-34, 3.5186665544980233e-51), + qd_real( 8.2804504525775580e-01, -4.4196593225871532e-17, + 2.7967864855211251e-33, 1.0030777287393502e-49), + qd_real( 8.2632106284566353e-01, -5.3957485453612902e-17, + 6.8976896130138550e-34, 3.8106164274199196e-50), + qd_real( 8.2458930278502529e-01, -2.6512360488868275e-17, + 1.6916964350914386e-34, 6.7693974813562649e-51), + qd_real( 8.2284978137582632e-01, 1.5193019034505495e-17, + 9.6890547246521685e-34, 5.6994562923653264e-50), + qd_real( 8.2110251499110465e-01, 3.0715131609697682e-17, + -1.7037168325855879e-33, -1.1149862443283853e-49), + qd_real( 8.1934752007679701e-01, -4.8200736995191133e-17, + -1.5574489646672781e-35, -9.5647853614522216e-53), + qd_real( 8.1758481315158371e-01, -1.4883149812426772e-17, + -7.8273262771298917e-34, 4.1332149161031594e-50), + qd_real( 8.1581441080673378e-01, 8.2652693782130871e-18, + -2.3028778135179471e-34, 1.5102071387249843e-50), + qd_real( 8.1403632970594841e-01, -5.2127351877042624e-17, + -1.9047670611316360e-33, -1.6937269585941507e-49), + qd_real( 8.1225058658520388e-01, 3.1054545609214803e-17, + 2.2649541922707251e-34, -7.4221684154649405e-51), + qd_real( 8.1045719825259477e-01, 2.3520367349840499e-17, + -7.7530070904846341e-34, -7.2792616357197140e-50), + qd_real( 8.0865618158817498e-01, 9.3251597879721674e-18, + -7.1823301933068394e-34, 2.3925440846132106e-50), + qd_real( 8.0684755354379922e-01, 4.9220603766095546e-17, + 2.9796016899903487e-33, 1.5220754223615788e-49), + qd_real( 8.0503133114296355e-01, 5.1368289568212149e-17, + 6.3082807402256524e-34, 7.3277646085129827e-51), + qd_real( 8.0320753148064494e-01, -3.3060609804814910e-17, + -1.2242726252420433e-33, 2.8413673268630117e-50), + qd_real( 8.0137617172314024e-01, -2.0958013413495834e-17, + -4.3798162198006931e-34, 2.0235690497752515e-50), + qd_real( 7.9953726910790501e-01, 2.0356723822005431e-17, + -9.7448513696896360e-34, 5.3608109599696008e-52), + qd_real( 7.9769084094339116e-01, -4.6730759884788944e-17, + 2.3075897077191757e-33, 3.1605567774640253e-51), + qd_real( 7.9583690460888357e-01, -3.0062724851910721e-17, + -2.2496210832042235e-33, -6.5881774117183040e-50), + qd_real( 7.9397547755433717e-01, -7.4194631759921416e-18, + 2.4124341304631069e-34, -4.9956808616244972e-51), + qd_real( 7.9210657730021239e-01, -3.7087850202326467e-17, + -1.4874457267228264e-33, 2.9323097289153505e-50), + qd_real( 7.9023022143731003e-01, 2.3056905954954492e-17, + 1.4481080533260193e-33, -7.6725237057203488e-50), + qd_real( 7.8834642762660623e-01, 3.4396993154059708e-17, + 1.7710623746737170e-33, 1.7084159098417402e-49), + qd_real( 7.8645521359908577e-01, -9.7841429939305265e-18, + 3.3906063272445472e-34, 5.7269505320382577e-51), + qd_real( 7.8455659715557524e-01, -8.5627965423173476e-18, + -2.1106834459001849e-34, -1.6890322182469603e-50), + qd_real( 7.8265059616657573e-01, 9.0745866975808825e-18, + 6.7623847404278666e-34, -1.7173237731987271e-50), + qd_real( 7.8073722857209449e-01, -9.9198782066678806e-18, + -2.1265794012162715e-36, 3.0772165598957647e-54), + qd_real( 7.7881651238147598e-01, -2.4891385579973807e-17, + 6.7665497024807980e-35, -6.5218594281701332e-52), + qd_real( 7.7688846567323244e-01, 7.7418602570672864e-18, + -5.9986517872157897e-34, 3.0566548232958972e-50), + qd_real( 7.7495310659487393e-01, -5.2209083189826433e-17, + -9.6653593393686612e-34, 3.7027750076562569e-50), + qd_real( 7.7301045336273699e-01, -3.2565907033649772e-17, + 1.3860807251523929e-33, -3.9971329917586022e-50), + qd_real( 7.7106052426181382e-01, -4.4558442347769265e-17, + -2.9863565614083783e-33, -6.8795262083596236e-50), + qd_real( 7.6910333764557959e-01, 5.1546455184564817e-17, + 2.6142829553524292e-33, -1.6199023632773298e-49), + qd_real( 7.6713891193582040e-01, -1.8885903683750782e-17, + -1.3659359331495433e-33, -2.2538834962921934e-50), + qd_real( 7.6516726562245896e-01, -3.2707225612534598e-17, + 1.1177117747079528e-33, -3.7005182280175715e-50), + qd_real( 7.6318841726338127e-01, 2.6314748416750748e-18, + 1.4048039063095910e-34, 8.9601886626630321e-52), + qd_real( 7.6120238548426178e-01, 3.5315510881690551e-17, + 1.2833566381864357e-33, 8.6221435180890613e-50), + qd_real( 7.5920918897838807e-01, -3.8558842175523123e-17, + 2.9720241208332759e-34, -1.2521388928220163e-50), + qd_real( 7.5720884650648457e-01, -1.9909098777335502e-17, + 3.9409283266158482e-34, 2.0744254207802976e-50), + qd_real( 7.5520137689653655e-01, -1.9402238001823017e-17, + -3.7756206444727573e-34, -2.1212242308178287e-50), + qd_real( 7.5318679904361252e-01, -3.7937789838736540e-17, + -6.7009539920231559e-34, -6.7128562115050214e-51), + qd_real( 7.5116513190968637e-01, 4.3499761158645868e-17, + 2.5227718971102212e-33, -6.5969709212757102e-50), + qd_real( 7.4913639452345937e-01, -4.4729078447011889e-17, + -2.4206025249983768e-33, 1.1336681351116422e-49), + qd_real( 7.4710060598018013e-01, 1.1874824875965430e-17, + 2.1992523849833518e-34, 1.1025018564644483e-50), + qd_real( 7.4505778544146595e-01, 1.5078686911877863e-17, + 8.0898987212942471e-34, 8.2677958765323532e-50), + qd_real( 7.4300795213512172e-01, -2.5144629669719265e-17, + 7.1128989512526157e-34, 3.0181629077821220e-50), + qd_real( 7.4095112535495911e-01, -1.4708616952297345e-17, + -4.9550433827142032e-34, 3.1434132533735671e-50), + qd_real( 7.3888732446061511e-01, 3.4324874808225091e-17, + -1.3706639444717610e-33, -3.3520827530718938e-51), + qd_real( 7.3681656887736990e-01, -2.8932468101656295e-17, + -3.4649887126202378e-34, -1.8484474476291476e-50), + qd_real( 7.3473887809596350e-01, -3.4507595976263941e-17, + -2.3718000676666409e-33, -3.9696090387165402e-50), + qd_real( 7.3265427167241282e-01, 1.8918673481573520e-17, + -1.5123719544119886e-33, -9.7922152011625728e-51), + qd_real( 7.3056276922782759e-01, -2.9689959904476928e-17, + -1.1276871244239744e-33, -3.0531520961539007e-50), + qd_real( 7.2846439044822520e-01, 1.1924642323370718e-19, + 5.9001892316611011e-36, 1.2178089069502704e-52), + qd_real( 7.2635915508434601e-01, -3.1917502443460542e-17, + 7.7047912412039396e-34, 4.1455880160182123e-50), + qd_real( 7.2424708295146689e-01, 2.9198471334403004e-17, + 2.3027324968739464e-33, -1.2928820533892183e-51), + qd_real( 7.2212819392921535e-01, -2.3871262053452047e-17, + 1.0636125432862273e-33, -4.4598638837802517e-50), + qd_real( 7.2000250796138165e-01, -2.5689658854462333e-17, + -9.1492566948567925e-34, 4.4403780801267786e-50), + qd_real( 7.1787004505573171e-01, 2.7006476062511453e-17, + -2.2854956580215348e-34, 9.1726903890287867e-51), + qd_real( 7.1573082528381871e-01, -5.1581018476410262e-17, + -1.3736271349300259e-34, -1.2734611344111297e-50), + qd_real( 7.1358486878079364e-01, -4.2342504403133584e-17, + -4.2690366101617268e-34, -2.6352370883066522e-50), + qd_real( 7.1143219574521643e-01, 7.9643298613856813e-18, + 2.9488239510721469e-34, 1.6985236437666356e-50), + qd_real( 7.0927282643886569e-01, -3.7597359110245730e-17, + 1.0613125954645119e-34, 8.9465480185486032e-51), + qd_real( 7.0710678118654757e-01, -4.8336466567264567e-17, + 2.0693376543497068e-33, 2.4677734957341755e-50) +}; + +/* Computes sin(a) and cos(a) using Taylor series. + Assumes |a| <= pi/2048. */ +static void sincos_taylor(const qd_real &a, + qd_real &sin_a, qd_real &cos_a) { + const double thresh = 0.5 * qd_real::_eps * std::abs(to_double(a)); + qd_real p, s, t, x; + + if (a.is_zero()) { + sin_a = 0.0; + cos_a = 1.0; + return; + } + + x = -sqr(a); + s = a; + p = a; + int i = 0; + do { + p *= x; + t = p * inv_fact[i]; + s += t; + i += 2; + } while (i < n_inv_fact && std::abs(to_double(t)) > thresh); + + sin_a = s; + cos_a = sqrt(1.0 - sqr(s)); +} + +static qd_real sin_taylor(const qd_real &a) { + const double thresh = 0.5 * qd_real::_eps * std::abs(to_double(a)); + qd_real p, s, t, x; + + if (a.is_zero()) { + return 0.0; + } + + x = -sqr(a); + s = a; + p = a; + int i = 0; + do { + p *= x; + t = p * inv_fact[i]; + s += t; + i += 2; + } while (i < n_inv_fact && std::abs(to_double(t)) > thresh); + + return s; +} + +static qd_real cos_taylor(const qd_real &a) { + const double thresh = 0.5 * qd_real::_eps; + qd_real p, s, t, x; + + if (a.is_zero()) { + return 1.0; + } + + x = -sqr(a); + s = 1.0 + mul_pwr2(x, 0.5); + p = x; + int i = 1; + do { + p *= x; + t = p * inv_fact[i]; + s += t; + i += 2; + } while (i < n_inv_fact && std::abs(to_double(t)) > thresh); + + return s; +} + +qd_real sin(const qd_real &a) { + + /* Strategy. To compute sin(x), we choose integers a, b so that + + x = s + a * (pi/2) + b * (pi/1024) + + and |s| <= pi/2048. Using a precomputed table of + sin(k pi / 1024) and cos(k pi / 1024), we can compute + sin(x) from sin(s) and cos(s). This greatly increases the + convergence of the sine Taylor series. */ + + if (a.is_zero()) { + return 0.0; + } + + // approximately reduce modulo 2*pi + qd_real z = nint(a / qd_real::_2pi); + qd_real r = a - qd_real::_2pi * z; + + // approximately reduce modulo pi/2 and then modulo pi/1024 + double q = std::floor(r.x[0] / qd_real::_pi2[0] + 0.5); + qd_real t = r - qd_real::_pi2 * q; + int j = static_cast(q); + q = std::floor(t.x[0] / _pi1024[0] + 0.5); + t -= _pi1024 * q; + int k = static_cast(q); + int abs_k = std::abs(k); + + if (j < -2 || j > 2) { + qd_real::error("(qd_real::sin): Cannot reduce modulo pi/2."); + return qd_real::_nan; + } + + if (abs_k > 256) { + qd_real::error("(qd_real::sin): Cannot reduce modulo pi/1024."); + return qd_real::_nan; + } + + if (k == 0) { + switch (j) { + case 0: + return sin_taylor(t); + case 1: + return cos_taylor(t); + case -1: + return -cos_taylor(t); + default: + return -sin_taylor(t); + } + } + + qd_real sin_t, cos_t; + qd_real u = cos_table[abs_k-1]; + qd_real v = sin_table[abs_k-1]; + sincos_taylor(t, sin_t, cos_t); + + if (j == 0) { + if (k > 0) { + r = u * sin_t + v * cos_t; + } else { + r = u * sin_t - v * cos_t; + } + } else if (j == 1) { + if (k > 0) { + r = u * cos_t - v * sin_t; + } else { + r = u * cos_t + v * sin_t; + } + } else if (j == -1) { + if (k > 0) { + r = v * sin_t - u * cos_t; + } else { + r = - u * cos_t - v * sin_t; + } + } else { + if (k > 0) { + r = - u * sin_t - v * cos_t; + } else { + r = v * cos_t - u * sin_t; + } + } + + return r; +} + +qd_real cos(const qd_real &a) { + + if (a.is_zero()) { + return 1.0; + } + + // approximately reduce modulo 2*pi + qd_real z = nint(a / qd_real::_2pi); + qd_real r = a - qd_real::_2pi * z; + + // approximately reduce modulo pi/2 and then modulo pi/1024 + double q = std::floor(r.x[0] / qd_real::_pi2.x[0] + 0.5); + qd_real t = r - qd_real::_pi2 * q; + int j = static_cast(q); + q = std::floor(t.x[0] / _pi1024.x[0] + 0.5); + t -= _pi1024 * q; + int k = static_cast(q); + int abs_k = std::abs(k); + + if (j < -2 || j > 2) { + qd_real::error("(qd_real::cos): Cannot reduce modulo pi/2."); + return qd_real::_nan; + } + + if (abs_k > 256) { + qd_real::error("(qd_real::cos): Cannot reduce modulo pi/1024."); + return qd_real::_nan; + } + + if (k == 0) { + switch (j) { + case 0: + return cos_taylor(t); + case 1: + return -sin_taylor(t); + case -1: + return sin_taylor(t); + default: + return -cos_taylor(t); + } + } + + qd_real sin_t, cos_t; + sincos_taylor(t, sin_t, cos_t); + + qd_real u = cos_table[abs_k-1]; + qd_real v = sin_table[abs_k-1]; + + if (j == 0) { + if (k > 0) { + r = u * cos_t - v * sin_t; + } else { + r = u * cos_t + v * sin_t; + } + } else if (j == 1) { + if (k > 0) { + r = - u * sin_t - v * cos_t; + } else { + r = v * cos_t - u * sin_t; + } + } else if (j == -1) { + if (k > 0) { + r = u * sin_t + v * cos_t; + } else { + r = u * sin_t - v * cos_t; + } + } else { + if (k > 0) { + r = v * sin_t - u * cos_t; + } else { + r = - u * cos_t - v * sin_t; + } + } + + return r; +} + +void sincos(const qd_real &a, qd_real &sin_a, qd_real &cos_a) { + + if (a.is_zero()) { + sin_a = 0.0; + cos_a = 1.0; + return; + } + + // approximately reduce by 2*pi + qd_real z = nint(a / qd_real::_2pi); + qd_real t = a - qd_real::_2pi * z; + + // approximately reduce by pi/2 and then by pi/1024. + double q = std::floor(t.x[0] / qd_real::_pi2.x[0] + 0.5); + t -= qd_real::_pi2 * q; + int j = static_cast(q); + q = std::floor(t.x[0] / _pi1024.x[0] + 0.5); + t -= _pi1024 * q; + int k = static_cast(q); + int abs_k = std::abs(k); + + if (j < -2 || j > 2) { + qd_real::error("(qd_real::sincos): Cannot reduce modulo pi/2."); + cos_a = sin_a = qd_real::_nan; + return; + } + + if (abs_k > 256) { + qd_real::error("(qd_real::sincos): Cannot reduce modulo pi/1024."); + cos_a = sin_a = qd_real::_nan; + return; + } + + qd_real sin_t, cos_t; + sincos_taylor(t, sin_t, cos_t); + + if (k == 0) { + if (j == 0) { + sin_a = sin_t; + cos_a = cos_t; + } else if (j == 1) { + sin_a = cos_t; + cos_a = -sin_t; + } else if (j == -1) { + sin_a = -cos_t; + cos_a = sin_t; + } else { + sin_a = -sin_t; + cos_a = -cos_t; + } + return; + } + + qd_real u = cos_table[abs_k-1]; + qd_real v = sin_table[abs_k-1]; + + if (j == 0) { + if (k > 0) { + sin_a = u * sin_t + v * cos_t; + cos_a = u * cos_t - v * sin_t; + } else { + sin_a = u * sin_t - v * cos_t; + cos_a = u * cos_t + v * sin_t; + } + } else if (j == 1) { + if (k > 0) { + cos_a = - u * sin_t - v * cos_t; + sin_a = u * cos_t - v * sin_t; + } else { + cos_a = v * cos_t - u * sin_t; + sin_a = u * cos_t + v * sin_t; + } + } else if (j == -1) { + if (k > 0) { + cos_a = u * sin_t + v * cos_t; + sin_a = v * sin_t - u * cos_t; + } else { + cos_a = u * sin_t - v * cos_t; + sin_a = - u * cos_t - v * sin_t; + } + } else { + if (k > 0) { + sin_a = - u * sin_t - v * cos_t; + cos_a = v * sin_t - u * cos_t; + } else { + sin_a = v * cos_t - u * sin_t; + cos_a = - u * cos_t - v * sin_t; + } + } +} + +qd_real atan(const qd_real &a) { + return atan2(a, qd_real(1.0)); +} + +qd_real atan2(const qd_real &y, const qd_real &x) { + /* Strategy: Instead of using Taylor series to compute + arctan, we instead use Newton's iteration to solve + the equation + + sin(z) = y/r or cos(z) = x/r + + where r = sqrt(x^2 + y^2). + The iteration is given by + + z' = z + (y - sin(z)) / cos(z) (for equation 1) + z' = z - (x - cos(z)) / sin(z) (for equation 2) + + Here, x and y are normalized so that x^2 + y^2 = 1. + If |x| > |y|, then first iteration is used since the + denominator is larger. Otherwise, the second is used. + */ + + if (x.is_zero()) { + + if (y.is_zero()) { + /* Both x and y is zero. */ + qd_real::error("(qd_real::atan2): Both arguments zero."); + return qd_real::_nan; + } + + return (y.is_positive()) ? qd_real::_pi2 : -qd_real::_pi2; + } else if (y.is_zero()) { + return (x.is_positive()) ? qd_real(0.0) : qd_real::_pi; + } + + if (x == y) { + return (y.is_positive()) ? qd_real::_pi4 : -qd_real::_3pi4; + } + + if (x == -y) { + return (y.is_positive()) ? qd_real::_3pi4 : -qd_real::_pi4; + } + + qd_real r = sqrt(sqr(x) + sqr(y)); + qd_real xx = x / r; + qd_real yy = y / r; + + /* Compute double precision approximation to atan. */ + qd_real z = std::atan2(to_double(y), to_double(x)); + qd_real sin_z, cos_z; + + if (std::abs(xx.x[0]) > std::abs(yy.x[0])) { + /* Use Newton iteration 1. z' = z + (y - sin(z)) / cos(z) */ + sincos(z, sin_z, cos_z); + z += (yy - sin_z) / cos_z; + sincos(z, sin_z, cos_z); + z += (yy - sin_z) / cos_z; + sincos(z, sin_z, cos_z); + z += (yy - sin_z) / cos_z; + } else { + /* Use Newton iteration 2. z' = z - (x - cos(z)) / sin(z) */ + sincos(z, sin_z, cos_z); + z -= (xx - cos_z) / sin_z; + sincos(z, sin_z, cos_z); + z -= (xx - cos_z) / sin_z; + sincos(z, sin_z, cos_z); + z -= (xx - cos_z) / sin_z; + } + + return z; +} + + +qd_real drem(const qd_real &a, const qd_real &b) { + qd_real n = nint(a/b); + return (a - n * b); +} + +qd_real divrem(const qd_real &a, const qd_real &b, qd_real &r) { + qd_real n = nint(a/b); + r = a - n * b; + return n; +} + +qd_real tan(const qd_real &a) { + qd_real s, c; + sincos(a, s, c); + return s/c; +} + +qd_real asin(const qd_real &a) { + qd_real abs_a = abs(a); + + if (abs_a > 1.0) { + qd_real::error("(qd_real::asin): Argument out of domain."); + return qd_real::_nan; + } + + if (abs_a.is_one()) { + return (a.is_positive()) ? qd_real::_pi2 : -qd_real::_pi2; + } + + return atan2(a, sqrt(1.0 - sqr(a))); +} + +qd_real acos(const qd_real &a) { + qd_real abs_a = abs(a); + + if (abs_a > 1.0) { + qd_real::error("(qd_real::acos): Argument out of domain."); + return qd_real::_nan; + } + + if (abs_a.is_one()) { + return (a.is_positive()) ? qd_real(0.0) : qd_real::_pi; + } + + return atan2(sqrt(1.0 - sqr(a)), a); +} + +qd_real sinh(const qd_real &a) { + if (a.is_zero()) { + return 0.0; + } + + if (abs(a) > 0.05) { + qd_real ea = exp(a); + return mul_pwr2(ea - inv(ea), 0.5); + } + + /* Since a is small, using the above formula gives + a lot of cancellation. So use Taylor series. */ + qd_real s = a; + qd_real t = a; + qd_real r = sqr(t); + double m = 1.0; + double thresh = std::abs(to_double(a) * qd_real::_eps); + + do { + m += 2.0; + t *= r; + t /= (m-1) * m; + + s += t; + } while (abs(t) > thresh); + + return s; +} + +qd_real cosh(const qd_real &a) { + if (a.is_zero()) { + return 1.0; + } + + qd_real ea = exp(a); + return mul_pwr2(ea + inv(ea), 0.5); +} + +qd_real tanh(const qd_real &a) { + if (a.is_zero()) { + return 0.0; + } + + if (std::abs(to_double(a)) > 0.05) { + qd_real ea = exp(a); + qd_real inv_ea = inv(ea); + return (ea - inv_ea) / (ea + inv_ea); + } else { + qd_real s, c; + s = sinh(a); + c = sqrt(1.0 + sqr(s)); + return s / c; + } +} + +void sincosh(const qd_real &a, qd_real &s, qd_real &c) { + if (std::abs(to_double(a)) <= 0.05) { + s = sinh(a); + c = sqrt(1.0 + sqr(s)); + } else { + qd_real ea = exp(a); + qd_real inv_ea = inv(ea); + s = mul_pwr2(ea - inv_ea, 0.5); + c = mul_pwr2(ea + inv_ea, 0.5); + } +} + +qd_real asinh(const qd_real &a) { + return log(a + sqrt(sqr(a) + 1.0)); +} + +qd_real acosh(const qd_real &a) { + if (a < 1.0) { + qd_real::error("(qd_real::acosh): Argument out of domain."); + return qd_real::_nan; + } + + return log(a + sqrt(sqr(a) - 1.0)); +} + +qd_real atanh(const qd_real &a) { + if (abs(a) >= 1.0) { + qd_real::error("(qd_real::atanh): Argument out of domain."); + return qd_real::_nan; + } + + return mul_pwr2(log((1.0 + a) / (1.0 - a)), 0.5); +} + +QD_API qd_real fmod(const qd_real &a, const qd_real &b) { + qd_real n = aint(a / b); + return (a - b * n); +} + +QD_API qd_real qdrand() { + static const double m_const = 4.6566128730773926e-10; /* = 2^{-31} */ + double m = m_const; + qd_real r = 0.0; + double d; + + /* Strategy: Generate 31 bits at a time, using lrand48 + random number generator. Shift the bits, and repeat + 7 times. */ + + for (int i = 0; i < 7; i++, m *= m_const) { + d = std::rand() * m; + r += d; + } + + return r; +} + + +/* polyeval(c, n, x) + Evaluates the given n-th degree polynomial at x. + The polynomial is given by the array of (n+1) coefficients. */ +qd_real polyeval(const qd_real *c, int n, const qd_real &x) { + /* Just use Horner's method of polynomial evaluation. */ + qd_real r = c[n]; + + for (int i = n-1; i >= 0; i--) { + r *= x; + r += c[i]; + } + + return r; +} + +/* polyroot(c, n, x0) + Given an n-th degree polynomial, finds a root close to + the given guess x0. Note that this uses simple Newton + iteration scheme, and does not work for multiple roots. */ +QD_API qd_real polyroot(const qd_real *c, int n, + const qd_real &x0, int max_iter, double thresh) { + qd_real x = x0; + qd_real f; + qd_real *d = new qd_real[n]; + bool conv = false; + int i; + double max_c = std::abs(to_double(c[0])); + double v; + + if (thresh == 0.0) thresh = qd_real::_eps; + + /* Compute the coefficients of the derivatives. */ + for (i = 1; i <= n; i++) { + v = std::abs(to_double(c[i])); + if (v > max_c) max_c = v; + d[i-1] = c[i] * static_cast(i); + } + thresh *= max_c; + + /* Newton iteration. */ + for (i = 0; i < max_iter; i++) { + f = polyeval(c, n, x); + + if (abs(f) < thresh) { + conv = true; + break; + } + x -= (f / polyeval(d, n-1, x)); + } + delete [] d; + + if (!conv) { + qd_real::error("(qd_real::polyroot): Failed to converge."); + return qd_real::_nan; + } + + return x; +} + +qd_real qd_real::debug_rand() { + if (std::rand() % 2 == 0) + return qdrand(); + + int expn = 0; + qd_real a = 0.0; + double d; + for (int i = 0; i < 4; i++) { + d = std::ldexp(std::rand() / static_cast(RAND_MAX), -expn); + a += d; + expn = expn + 54 + std::rand() % 200; + } + return a; +} + diff --git a/external/PackedCSparse/qd/qd_real.h b/external/PackedCSparse/qd/qd_real.h new file mode 100644 index 000000000..1ecfc732c --- /dev/null +++ b/external/PackedCSparse/qd/qd_real.h @@ -0,0 +1,296 @@ +/* + * include/qd_real.h + * + * This work was supported by the Director, Office of Science, Division + * of Mathematical, Information, and Computational Sciences of the + * U.S. Department of Energy under contract number DE-AC03-76SF00098. + * + * Copyright (c) 2000-2007 + * + * Quad-double precision (>= 212-bit significand) floating point arithmetic + * package, written in ANSI C++, taking full advantage of operator overloading. + * Uses similar techniques as that of David Bailey's double-double package + * and that of Jonathan Shewchuk's adaptive precision floating point + * arithmetic package. See + * + * http://www.nersc.gov/~dhbailey/mpdist/mpdist.html + * http://www.cs.cmu.edu/~quake/robust.html + * + * for more details. + * + * Yozo Hida + */ +#ifndef _QD_QD_REAL_H +#define _QD_QD_REAL_H + +#include +#include +#include +#include "qd_config.h" +#include "dd_real.h" + +struct QD_API qd_real { + double x[4]; /* The Components. */ + + /* Eliminates any zeros in the middle component(s). */ + void zero_elim(); + void zero_elim(double &e); + + void renorm(); + void renorm(double &e); + + void quick_accum(double d, double &e); + void quick_prod_accum(double a, double b, double &e); + + qd_real(double x0, double x1, double x2, double x3); + explicit qd_real(const double *xx); + + static const qd_real _2pi; + static const qd_real _pi; + static const qd_real _3pi4; + static const qd_real _pi2; + static const qd_real _pi4; + static const qd_real _e; + static const qd_real _log2; + static const qd_real _log10; + static const qd_real _nan; + static const qd_real _inf; + + static const double _eps; + static const double _min_normalized; + static const qd_real _max; + static const qd_real _safe_max; + static const int _ndigits; + + qd_real(); + qd_real(const char *s); + qd_real(const dd_real &dd); + qd_real(double d); + qd_real(int i); + + double operator[](int i) const; + double &operator[](int i); + + static void error(const char *msg); + + bool isnan() const; + bool isfinite() const { return QD_ISFINITE(x[0]); } + bool isinf() const { return QD_ISINF(x[0]); } + + static qd_real ieee_add(const qd_real &a, const qd_real &b); + static qd_real sloppy_add(const qd_real &a, const qd_real &b); + + qd_real &operator+=(double a); + qd_real &operator+=(const dd_real &a); + qd_real &operator+=(const qd_real &a); + + qd_real &operator-=(double a); + qd_real &operator-=(const dd_real &a); + qd_real &operator-=(const qd_real &a); + + static qd_real sloppy_mul(const qd_real &a, const qd_real &b); + static qd_real accurate_mul(const qd_real &a, const qd_real &b); + + qd_real &operator*=(double a); + qd_real &operator*=(const dd_real &a); + qd_real &operator*=(const qd_real &a); + + static qd_real sloppy_div(const qd_real &a, const dd_real &b); + static qd_real accurate_div(const qd_real &a, const dd_real &b); + static qd_real sloppy_div(const qd_real &a, const qd_real &b); + static qd_real accurate_div(const qd_real &a, const qd_real &b); + + qd_real &operator/=(double a); + qd_real &operator/=(const dd_real &a); + qd_real &operator/=(const qd_real &a); + + qd_real operator^(int n) const; + + qd_real operator-() const; + + qd_real &operator=(double a); + qd_real &operator=(const dd_real &a); + qd_real &operator=(const char *s); + + bool is_zero() const; + bool is_one() const; + bool is_positive() const; + bool is_negative() const; + + explicit operator bool() const; // new + explicit operator double() const; // new + + static qd_real rand(void); + + void to_digits(char *s, int &expn, int precision = _ndigits) const; + void write(char *s, int len, int precision = _ndigits, + bool showpos = false, bool uppercase = false) const; + std::string to_string(int precision = _ndigits, int width = 0, + std::ios_base::fmtflags fmt = static_cast(0), + bool showpos = false, bool uppercase = false, char fill = ' ') const; + static int read(const char *s, qd_real &a); + + /* Debugging methods */ + void dump(const std::string &name, std::ostream &os = std::cerr) const; + void dump_bits(const std::string &name, + std::ostream &os = std::cerr) const; + + static qd_real debug_rand(); + +}; + +namespace std { + template <> + class numeric_limits : public numeric_limits { + public: + inline static double epsilon() { return qd_real::_eps; } + inline static double min() { return qd_real::_min_normalized; } + inline static qd_real max() { return qd_real::_max; } + inline static qd_real safe_max() { return qd_real::_safe_max; } + static const int digits = 209; + static const int digits10 = 62; + }; +} + +QD_API qd_real polyeval(const qd_real *c, int n, const qd_real &x); +QD_API qd_real polyroot(const qd_real *c, int n, + const qd_real &x0, int max_iter = 64, double thresh = 0.0); + +QD_API qd_real qdrand(void); +QD_API qd_real sqrt(const qd_real &a); + +QD_API inline bool isnan(const qd_real &a) { return a.isnan(); } +QD_API inline bool isfinite(const qd_real &a) { return a.isfinite(); } +QD_API inline bool isinf(const qd_real &a) { return a.isinf(); } + +/* Computes qd * d where d is known to be a power of 2. + This can be done component wise. */ +QD_API qd_real mul_pwr2(const qd_real &qd, double d); + +QD_API qd_real operator+(const qd_real &a, const qd_real &b); +QD_API qd_real operator+(const dd_real &a, const qd_real &b); +QD_API qd_real operator+(const qd_real &a, const dd_real &b); +QD_API qd_real operator+(const qd_real &a, double b); +QD_API qd_real operator+(double a, const qd_real &b); + +QD_API qd_real operator-(const qd_real &a, const qd_real &b); +QD_API qd_real operator-(const dd_real &a, const qd_real &b); +QD_API qd_real operator-(const qd_real &a, const dd_real &b); +QD_API qd_real operator-(const qd_real &a, double b); +QD_API qd_real operator-(double a, const qd_real &b); + +QD_API qd_real operator*(const qd_real &a, const qd_real &b); +QD_API qd_real operator*(const dd_real &a, const qd_real &b); +QD_API qd_real operator*(const qd_real &a, const dd_real &b); +QD_API qd_real operator*(const qd_real &a, double b); +QD_API qd_real operator*(double a, const qd_real &b); + +QD_API qd_real operator/(const qd_real &a, const qd_real &b); +QD_API qd_real operator/(const dd_real &a, const qd_real &b); +QD_API qd_real operator/(const qd_real &a, const dd_real &b); +QD_API qd_real operator/(const qd_real &a, double b); +QD_API qd_real operator/(double a, const qd_real &b); + +QD_API qd_real sqr(const qd_real &a); +QD_API qd_real sqrt(const qd_real &a); +QD_API qd_real pow(const qd_real &a, int n); +QD_API qd_real pow(const qd_real &a, const qd_real &b); +QD_API qd_real npwr(const qd_real &a, int n); + +QD_API qd_real nroot(const qd_real &a, int n); + +QD_API qd_real rem(const qd_real &a, const qd_real &b); +QD_API qd_real drem(const qd_real &a, const qd_real &b); +QD_API qd_real divrem(const qd_real &a, const qd_real &b, qd_real &r); + +dd_real to_dd_real(const qd_real &a); +double to_double(const qd_real &a); +int to_int(const qd_real &a); + +QD_API bool operator==(const qd_real &a, const qd_real &b); +QD_API bool operator==(const qd_real &a, const dd_real &b); +QD_API bool operator==(const dd_real &a, const qd_real &b); +QD_API bool operator==(double a, const qd_real &b); +QD_API bool operator==(const qd_real &a, double b); + +QD_API bool operator<(const qd_real &a, const qd_real &b); +QD_API bool operator<(const qd_real &a, const dd_real &b); +QD_API bool operator<(const dd_real &a, const qd_real &b); +QD_API bool operator<(double a, const qd_real &b); +QD_API bool operator<(const qd_real &a, double b); + +QD_API bool operator>(const qd_real &a, const qd_real &b); +QD_API bool operator>(const qd_real &a, const dd_real &b); +QD_API bool operator>(const dd_real &a, const qd_real &b); +QD_API bool operator>(double a, const qd_real &b); +QD_API bool operator>(const qd_real &a, double b); + +QD_API bool operator<=(const qd_real &a, const qd_real &b); +QD_API bool operator<=(const qd_real &a, const dd_real &b); +QD_API bool operator<=(const dd_real &a, const qd_real &b); +QD_API bool operator<=(double a, const qd_real &b); +QD_API bool operator<=(const qd_real &a, double b); + +QD_API bool operator>=(const qd_real &a, const qd_real &b); +QD_API bool operator>=(const qd_real &a, const dd_real &b); +QD_API bool operator>=(const dd_real &a, const qd_real &b); +QD_API bool operator>=(double a, const qd_real &b); +QD_API bool operator>=(const qd_real &a, double b); + +QD_API bool operator!=(const qd_real &a, const qd_real &b); +QD_API bool operator!=(const qd_real &a, const dd_real &b); +QD_API bool operator!=(const dd_real &a, const qd_real &b); +QD_API bool operator!=(double a, const qd_real &b); +QD_API bool operator!=(const qd_real &a, double b); + +QD_API qd_real fabs(const qd_real &a); +QD_API qd_real abs(const qd_real &a); /* same as fabs */ + +QD_API qd_real ldexp(const qd_real &a, int n); + +QD_API qd_real nint(const qd_real &a); +QD_API qd_real quick_nint(const qd_real &a); +QD_API qd_real floor(const qd_real &a); +QD_API qd_real ceil(const qd_real &a); +QD_API qd_real aint(const qd_real &a); + +QD_API qd_real sin(const qd_real &a); +QD_API qd_real cos(const qd_real &a); +QD_API qd_real tan(const qd_real &a); +QD_API void sincos(const qd_real &a, qd_real &s, qd_real &c); + +QD_API qd_real asin(const qd_real &a); +QD_API qd_real acos(const qd_real &a); +QD_API qd_real atan(const qd_real &a); +QD_API qd_real atan2(const qd_real &y, const qd_real &x); + +QD_API qd_real exp(const qd_real &a); +QD_API qd_real log(const qd_real &a); +QD_API qd_real log10(const qd_real &a); + +QD_API qd_real sinh(const qd_real &a); +QD_API qd_real cosh(const qd_real &a); +QD_API qd_real tanh(const qd_real &a); +QD_API void sincosh(const qd_real &a, qd_real &sin_qd, qd_real &cos_qd); + +QD_API qd_real asinh(const qd_real &a); +QD_API qd_real acosh(const qd_real &a); +QD_API qd_real atanh(const qd_real &a); + +QD_API qd_real qdrand(void); + +QD_API qd_real max(const qd_real &a, const qd_real &b); +QD_API qd_real max(const qd_real &a, const qd_real &b, const qd_real &c); +QD_API qd_real min(const qd_real &a, const qd_real &b); +QD_API qd_real min(const qd_real &a, const qd_real &b, const qd_real &c); + +QD_API qd_real fmod(const qd_real &a, const qd_real &b); + +QD_API std::ostream &operator<<(std::ostream &s, const qd_real &a); +QD_API std::istream &operator>>(std::istream &s, qd_real &a); +#ifdef QD_INLINE +#include "qd_inline.h" +#endif + +#endif /* _QD_QD_REAL_H */ + diff --git a/external/PackedCSparse/qd/util.cc b/external/PackedCSparse/qd/util.cc new file mode 100644 index 000000000..ab9620817 --- /dev/null +++ b/external/PackedCSparse/qd/util.cc @@ -0,0 +1,22 @@ +#include +#include "util.h" + +void append_expn(std::string &str, int expn) { + int k; + + str += (expn < 0 ? '-' : '+'); + expn = std::abs(expn); + + if (expn >= 100) { + k = (expn / 100); + str += '0' + k; + expn -= 100*k; + } + + k = (expn / 10); + str += '0' + k; + expn -= 10*k; + + str += '0' + expn; +} + diff --git a/external/PackedCSparse/qd/util.h b/external/PackedCSparse/qd/util.h new file mode 100644 index 000000000..7de358363 --- /dev/null +++ b/external/PackedCSparse/qd/util.h @@ -0,0 +1,4 @@ +#include + +void append_expn(std::string &str, int expn); + diff --git a/external/cmake-files/Autodiff.cmake b/external/cmake-files/Autodiff.cmake new file mode 100644 index 000000000..06e593548 --- /dev/null +++ b/external/cmake-files/Autodiff.cmake @@ -0,0 +1,31 @@ +set(AUTODIFF_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) +function(GetAutodiff) + find_path(AUTODIFF_DIR NAMES autodiff PATHS ${AUTODIFF_CMAKE_DIR}/../_deps/autodiff-src) + + if (NOT AUTODIFF_DIR ) + include(FetchContent) + set(FETCHCONTENT_BASE_DIR "${AUTODIFF_CMAKE_DIR}/../_deps") + FetchContent_Declare(autodiff + GIT_REPOSITORY https://github.com/autodiff/autodiff.git + GIT_TAG v0.6.12 + ) + + FetchContent_GetProperties(autodiff) + + if(NOT autodiff_POPULATED) + message(STATUS "Autodiff library not found locally, downloading it.") + FetchContent_Populate(autodiff) + endif() + + set(AUTODIFF_DIR ${autodiff_SOURCE_DIR}) + message(STATUS "Using downloaded Autodiff library at: ${AUTODIFF_DIR}") + + else () + + message(STATUS "Autodiff Library found: ${AUTODIFF_DIR}") + + endif() + + include_directories(${AUTODIFF_DIR}) + +endfunction() \ No newline at end of file diff --git a/external/cmake-files/Boost.cmake b/external/cmake-files/Boost.cmake index 48dad5e6f..4c17f3753 100644 --- a/external/cmake-files/Boost.cmake +++ b/external/cmake-files/Boost.cmake @@ -2,10 +2,10 @@ set(BOOST_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) function(GetBoost) find_path(BOOST_DIR NAMES boost PATHS ${BOOST_CMAKE_DIR}/../_deps/boost-src) - if (NOT BOOST_DIR) - - set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2" CACHE STRING "Boost download URL") - set(BOOST_URL_SHA256 "f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41" CACHE STRING "Boost download URL SHA256 checksum") + if (NOT BOOST_DIR) + + set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.bz2" CACHE STRING "Boost download URL") + set(BOOST_URL_SHA256 "cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454" CACHE STRING "Boost download URL SHA256 checksum") include(FetchContent) set(FETCHCONTENT_BASE_DIR "${BOOST_CMAKE_DIR}/../_deps") diff --git a/external/cmake-files/Eigen.cmake b/external/cmake-files/Eigen.cmake index 974a6f184..7e68e3ba9 100644 --- a/external/cmake-files/Eigen.cmake +++ b/external/cmake-files/Eigen.cmake @@ -1,6 +1,6 @@ set(EIGEN_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) function(GetEigen) - find_path(EIGEN_DIR NAMES Eigen PATHS ${EIGEN_CMAKE_DIR}/../_deps/eigen-src) + find_path(EIGEN_DIR NAMES signature_of_eigen3_matrix_library PATHS ${EIGEN_CMAKE_DIR}/../_deps/eigen-src PATH_SUFFIXES eigen3 eigen) if (NOT EIGEN_DIR) include(FetchContent) diff --git a/external/cmake-files/LPSolve.cmake b/external/cmake-files/LPSolve.cmake index b3f3cf98b..3ef605104 100644 --- a/external/cmake-files/LPSolve.cmake +++ b/external/cmake-files/LPSolve.cmake @@ -1,6 +1,8 @@ set(LP_SOLVE_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) function(GetLPSolve) +if(NOT APPLE) find_path(LP_SOLVE_DIR NAMES lpsolve.h PATHS ${LP_SOLVE_CMAKE_DIR}/../_deps/lpsolve-src) +endif(NOT APPLE) if (NOT LP_SOLVE_DIR) include(FetchContent) @@ -27,6 +29,46 @@ function(GetLPSolve) endif() - include_directories(${LP_SOLVE_DIR}) + #to disable interactive mode of lp_solve lex parser + add_compile_options(-DYY_NEVER_INTERACTIVE) + + add_compile_options(-DLoadInverseLib=0) + add_compile_options(-DLoadLanguageLib=0) + add_compile_definitions(RoleIsExternalInvEngine) + add_compile_definitions(INVERSE_ACTIVE=3) + add_compile_options(-DLoadableBlasLib=0) + + include_directories (BEFORE ${LP_SOLVE_DIR}) + include_directories (BEFORE ${LP_SOLVE_DIR}/bfp) + include_directories (BEFORE ${LP_SOLVE_DIR}/bfp/bfp_LUSOL) + include_directories (BEFORE ${LP_SOLVE_DIR}/bfp/bfp_LUSOL/LUSOL) + include_directories (BEFORE ${LP_SOLVE_DIR}/colamd) + include_directories (BEFORE ${LP_SOLVE_DIR}/shared) + + add_library (lp_solve + ${LP_SOLVE_DIR}/bfp/bfp_LUSOL/lp_LUSOL.c + ${LP_SOLVE_DIR}/bfp/bfp_LUSOL/LUSOL/lusol.c + ${LP_SOLVE_DIR}/colamd/colamd.c + ${LP_SOLVE_DIR}/ini.c + ${LP_SOLVE_DIR}/shared/commonlib.c + ${LP_SOLVE_DIR}/shared/mmio.c + ${LP_SOLVE_DIR}/shared/myblas.c + ${LP_SOLVE_DIR}/lp_crash.c + ${LP_SOLVE_DIR}/lp_Hash.c + ${LP_SOLVE_DIR}/lp_lib.c + ${LP_SOLVE_DIR}/lp_matrix.c + ${LP_SOLVE_DIR}/lp_MDO.c + ${LP_SOLVE_DIR}/lp_mipbb.c + ${LP_SOLVE_DIR}/lp_MPS.c + ${LP_SOLVE_DIR}/lp_params.c + ${LP_SOLVE_DIR}/lp_presolve.c + ${LP_SOLVE_DIR}/lp_price.c + ${LP_SOLVE_DIR}/lp_pricePSE.c + ${LP_SOLVE_DIR}/lp_report.c + ${LP_SOLVE_DIR}/lp_scale.c + ${LP_SOLVE_DIR}/lp_simplex.c + ${LP_SOLVE_DIR}/lp_SOS.c + ${LP_SOLVE_DIR}/lp_utils.c + ${LP_SOLVE_DIR}/lp_wlp.c) endfunction() diff --git a/external/cmake-files/QD.cmake b/external/cmake-files/QD.cmake index b65e4f51c..a2e3e5e6d 100644 --- a/external/cmake-files/QD.cmake +++ b/external/cmake-files/QD.cmake @@ -1,54 +1,18 @@ set(QD_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) function(GetQD) - find_path(QD_DIR NAMES config.h PATHS ${QD_CMAKE_DIR}/../_deps/qd-src/) - - if (NOT QD_DIR) - include(FetchContent) - set(FETCHCONTENT_BASE_DIR "${QD_CMAKE_DIR}/../_deps") - FetchContent_Declare( - qd - URL https://www.davidhbailey.com/dhbsoftware/qd-2.3.23.tar.gz - ) - - FetchContent_GetProperties(qd) - - if(NOT qd_POPULATED) - message(STATUS "QD library not found locally, downloading it.") - FetchContent_Populate(qd) - endif() - - set(QD_DIR "${qd_SOURCE_DIR}") - message(STATUS "Using downloaded QD at: ${QD_DIR}") - - else() - - message(STATUS "QD library found: ${QD_DIR}") - - endif() - - include_directories(BEFORE "${QD_DIR}/include/") - message(STATUS "configuring the QD library") - execute_process( - COMMAND ./configure - WORKING_DIRECTORY ${QD_DIR} - OUTPUT_FILE CMD_OUTPUT - RESULT_VARIABLE EXECUTE - ) - if(NOT ${EXECUTE} EQUAL "0") - message(FATAL_ERROR "./configure QD library failed") - endif() - - execute_process( - COMMAND make - WORKING_DIRECTORY ${QD_DIR} - OUTPUT_FILE qd_compilation.txt - RESULT_VARIABLE EXECUTE_MAKE - ) - - if(NOT ${EXECUTE_MAKE} EQUAL "0") - message(FATAL_ERROR "building the QD library failed") - endif() - - find_library(QD_LIB NAMES libqd.a PATHS "${QD_DIR}/src/.libs") + set(QD_DIR "${QD_CMAKE_DIR}/../PackedCSparse/qd") + include_directories(BEFORE "${QD_DIR}") + set(QD_SOURCES + ${QD_DIR}/bits.cc + ${QD_DIR}/c_dd.cc + ${QD_DIR}/c_qd.cc + ${QD_DIR}/dd_const.cc + ${QD_DIR}/dd_real.cc + ${QD_DIR}/fpu.cc + ${QD_DIR}/qd_const.cc + ${QD_DIR}/qd_real.cc + ${QD_DIR}/util.cc + ) + add_library(QD_LIB ${QD_SOURCES}) endfunction() diff --git a/external/cmake-files/lpsolve_modified_header_files/lp_rlp.h b/external/cmake-files/lpsolve_modified_header_files/lp_rlp.h new file mode 100644 index 000000000..058b45232 --- /dev/null +++ b/external/cmake-files/lpsolve_modified_header_files/lp_rlp.h @@ -0,0 +1,2460 @@ +// Copyright(c) 2016-2018 Kjell Konis . +// Version: 5.5.2.0-17 +// Description: The lpSolveAPI package provides an R interface to 'lp_solve', +// a Mixed Integer Linear Programming (MILP) solver with support for pure +// linear, (mixed) integer/binary, semi-continuous and special ordered sets +// (SOS) models. +// License: LGPL-2 +// Repository: CRAN + + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define lp_yyconst const +#else +#define lp_yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* lp_yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define lp_yyin lp_yyg->lp_yyin_r +#define lp_yyout lp_yyg->lp_yyout_r +#define lp_yyextra lp_yyg->lp_yyextra_r +#define lp_yyleng lp_yyg->lp_yyleng_r +#define lp_yytext lp_yyg->lp_yytext_r +#define lp_yylineno (YY_CURRENT_BUFFER_LVALUE->lp_yy_bs_lineno) +#define lp_yycolumn (YY_CURRENT_BUFFER_LVALUE->lp_yy_bs_column) +#define lp_yy_flex_debug lp_yyg->lp_yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN lp_yyg->lp_yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((lp_yyg->lp_yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE lp_yyrestart(lp_yyin ,lp_yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(lp_yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct lp_yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for lp_yy_rule_can_match_eol because it requires + * access to the local variable lp_yy_act. Since lp_yyless() is a macro, it would break + * existing scanners that call lp_yyless() from OUTSIDE lp_yylex. + * One obvious solution it to make lp_yy_act a global. I tried that, and saw + * a 5% performance hit in a non-lp_yylineno scanner, because lp_yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int lp_yyl;\ + for ( lp_yyl = n; lp_yyl < lp_yyleng; ++lp_yyl )\ + if ( lp_yytext[lp_yyl] == '\n' )\ + --lp_yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define lp_yyless(n) \ + do \ + { \ + /* Undo effects of setting up lp_yytext. */ \ + int lp_yyless_macro_arg = (n); \ + YY_LESS_LINENO(lp_yyless_macro_arg);\ + *lp_yy_cp = lp_yyg->lp_yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + lp_yyg->lp_yy_c_buf_p = lp_yy_cp = lp_yy_bp + lp_yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up lp_yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) lp_yyunput( c, lp_yyg->lp_yytext_ptr , lp_yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t lp_yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct lp_yy_buffer_state + { + FILE *lp_yy_input_file; + + char *lp_yy_ch_buf; /* input buffer */ + char *lp_yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + lp_yy_size_t lp_yy_buf_size; + + /* Number of characters read into lp_yy_ch_buf, not including EOB + * characters. + */ + int lp_yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int lp_yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int lp_yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int lp_yy_at_bol; + + int lp_yy_bs_lineno; /**< The line count. */ + int lp_yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int lp_yy_fill_buffer; + + int lp_yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via lp_yyrestart()), so that the user can continue scanning by + * just pointing lp_yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( lp_yyg->lp_yy_buffer_stack \ + ? lp_yyg->lp_yy_buffer_stack[lp_yyg->lp_yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE lp_yyg->lp_yy_buffer_stack[lp_yyg->lp_yy_buffer_stack_top] + +void lp_yyrestart (FILE *input_file ,lp_yyscan_t lp_yyscanner ); +void lp_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,lp_yyscan_t lp_yyscanner ); +YY_BUFFER_STATE lp_yy_create_buffer (FILE *file,int size ,lp_yyscan_t lp_yyscanner ); +void lp_yy_delete_buffer (YY_BUFFER_STATE b ,lp_yyscan_t lp_yyscanner ); +void lp_yy_flush_buffer (YY_BUFFER_STATE b ,lp_yyscan_t lp_yyscanner ); +void lp_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,lp_yyscan_t lp_yyscanner ); +void lp_yypop_buffer_state (lp_yyscan_t lp_yyscanner ); + +static void lp_yyensure_buffer_stack (lp_yyscan_t lp_yyscanner ); +static void lp_yy_load_buffer_state (lp_yyscan_t lp_yyscanner ); +static void lp_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,lp_yyscan_t lp_yyscanner ); + +#define YY_FLUSH_BUFFER lp_yy_flush_buffer(YY_CURRENT_BUFFER ,lp_yyscanner) + +YY_BUFFER_STATE lp_yy_scan_buffer (char *base,lp_yy_size_t size ,lp_yyscan_t lp_yyscanner ); +YY_BUFFER_STATE lp_yy_scan_string (lp_yyconst char *lp_yy_str ,lp_yyscan_t lp_yyscanner ); +YY_BUFFER_STATE lp_yy_scan_bytes (lp_yyconst char *bytes,int len ,lp_yyscan_t lp_yyscanner ); + +void *lp_yyalloc (lp_yy_size_t ,lp_yyscan_t lp_yyscanner ); +void *lp_yyrealloc (void *,lp_yy_size_t ,lp_yyscan_t lp_yyscanner ); +void lp_yyfree (void * ,lp_yyscan_t lp_yyscanner ); + +#define lp_yy_new_buffer lp_yy_create_buffer + +#define lp_yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + lp_yyensure_buffer_stack (lp_yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + lp_yy_create_buffer(lp_yyin,YY_BUF_SIZE ,lp_yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->lp_yy_is_interactive = is_interactive; \ + } + +#define lp_yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + lp_yyensure_buffer_stack (lp_yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + lp_yy_create_buffer(lp_yyin,YY_BUF_SIZE ,lp_yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol) + +/* Begin user sect3 */ + +#define lp_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int lp_yy_state_type; + +#define lp_yytext_ptr lp_yytext_r + +static lp_yy_state_type lp_yy_get_previous_state (lp_yyscan_t lp_yyscanner ); +static lp_yy_state_type lp_yy_try_NUL_trans (lp_yy_state_type current_state ,lp_yyscan_t lp_yyscanner); +static int lp_yy_get_next_buffer (lp_yyscan_t lp_yyscanner ); +static void lp_yy_fatal_error (lp_yyconst char msg[] ,lp_yyscan_t lp_yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up lp_yytext. + */ +#define YY_DO_BEFORE_ACTION \ + lp_yyg->lp_yytext_ptr = lp_yy_bp; \ + lp_yyleng = (size_t) (lp_yy_cp - lp_yy_bp); \ + lp_yyg->lp_yy_hold_char = *lp_yy_cp; \ + *lp_yy_cp = '\0'; \ + lp_yyg->lp_yy_c_buf_p = lp_yy_cp; + +#define YY_NUM_RULES 33 +#define YY_END_OF_BUFFER 34 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct lp_yy_trans_info + { + flex_int32_t lp_yy_verify; + flex_int32_t lp_yy_nxt; + }; +static lp_yyconst flex_int16_t lp_yy_accept[144] = + { 0, + 0, 0, 0, 0, 0, 0, 34, 32, 10, 10, + 27, 17, 11, 32, 32, 14, 26, 31, 29, 28, + 30, 25, 25, 10, 25, 25, 25, 25, 3, 4, + 3, 3, 9, 7, 8, 10, 17, 17, 0, 15, + 1, 6, 15, 14, 0, 29, 30, 0, 25, 24, + 0, 25, 25, 10, 0, 0, 0, 0, 25, 25, + 25, 25, 25, 2, 0, 15, 0, 15, 22, 0, + 25, 25, 0, 0, 0, 0, 0, 19, 25, 18, + 20, 25, 25, 21, 0, 25, 0, 13, 25, 0, + 12, 25, 19, 0, 18, 20, 21, 25, 23, 25, + + 20, 21, 21, 16, 16, 0, 25, 25, 0, 23, + 0, 21, 25, 25, 0, 0, 25, 25, 0, 0, + 19, 25, 0, 0, 25, 25, 19, 0, 18, 0, + 0, 25, 25, 18, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + } ; + +static lp_yyconst flex_int32_t lp_yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 5, 6, 5, 5, 5, 1, + 1, 7, 8, 9, 10, 11, 12, 13, 14, 14, + 13, 13, 13, 13, 13, 13, 13, 15, 16, 17, + 18, 19, 1, 5, 20, 21, 22, 23, 24, 25, + 26, 23, 27, 23, 23, 23, 28, 29, 30, 23, + 23, 31, 32, 33, 34, 23, 23, 35, 36, 37, + 5, 1, 5, 5, 5, 1, 20, 21, 22, 23, + + 24, 25, 26, 23, 27, 23, 23, 23, 28, 29, + 30, 23, 23, 31, 32, 33, 34, 23, 23, 35, + 36, 37, 5, 1, 5, 5, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static lp_yyconst flex_int32_t lp_yy_meta[38] = + { 0, + 1, 2, 3, 3, 4, 5, 6, 3, 6, 3, + 5, 5, 5, 5, 7, 6, 7, 6, 6, 4, + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4 + } ; + +static lp_yyconst flex_int16_t lp_yy_base[150] = + { 0, + 0, 36, 36, 38, 43, 45, 366, 388, 48, 62, + 388, 338, 388, 40, 48, 60, 388, 388, 346, 388, + 326, 60, 65, 91, 81, 74, 85, 102, 388, 388, + 388, 330, 388, 388, 388, 125, 313, 134, 308, 96, + 388, 388, 117, 132, 139, 388, 388, 88, 146, 320, + 0, 149, 152, 0, 307, 301, 294, 83, 153, 156, + 157, 189, 160, 388, 286, 126, 65, 108, 388, 289, + 181, 185, 272, 273, 250, 249, 220, 199, 203, 208, + 192, 211, 219, 227, 243, 109, 163, 225, 202, 174, + 224, 215, 213, 207, 191, 388, 189, 227, 228, 231, + + 244, 240, 253, 276, 388, 170, 260, 262, 166, 388, + 169, 179, 263, 241, 166, 159, 270, 272, 149, 155, + 284, 288, 130, 124, 296, 303, 388, 103, 300, 96, + 45, 324, 328, 388, 82, 311, 79, 68, 54, 56, + 25, 12, 388, 345, 353, 360, 367, 372, 379 + } ; + +static lp_yyconst flex_int16_t lp_yy_def[150] = + { 0, + 143, 1, 144, 144, 145, 145, 143, 143, 143, 143, + 143, 146, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 147, 147, 143, 147, 147, 147, 147, 143, 143, + 143, 143, 143, 143, 143, 143, 146, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 147, 143, + 148, 147, 147, 24, 143, 143, 143, 143, 147, 147, + 147, 147, 147, 143, 143, 143, 143, 143, 143, 148, + 147, 147, 143, 143, 143, 143, 143, 147, 147, 147, + 147, 147, 147, 147, 149, 143, 143, 143, 62, 143, + 143, 62, 143, 143, 143, 143, 143, 62, 62, 62, + + 62, 62, 62, 143, 143, 143, 62, 62, 143, 143, + 143, 143, 62, 62, 143, 143, 62, 62, 143, 143, + 62, 62, 143, 143, 62, 62, 143, 143, 62, 143, + 143, 147, 147, 143, 143, 149, 143, 143, 143, 143, + 143, 143, 0, 143, 143, 143, 143, 143, 143 + } ; + +static lp_yyconst flex_int16_t lp_yy_nxt[426] = + { 0, + 8, 9, 10, 9, 8, 8, 11, 12, 13, 12, + 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, + 22, 22, 22, 22, 22, 22, 22, 23, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 24, 30, 31, + 30, 31, 32, 96, 32, 34, 35, 34, 35, 36, + 36, 36, 40, 40, 41, 37, 25, 37, 142, 42, + 26, 48, 27, 36, 36, 36, 48, 28, 136, 37, + 43, 37, 44, 44, 50, 48, 51, 68, 68, 50, + 136, 51, 48, 45, 52, 141, 48, 140, 50, 48, + 51, 53, 54, 36, 36, 50, 139, 51, 37, 50, + + 37, 51, 50, 48, 60, 138, 76, 59, 40, 40, + 48, 55, 77, 61, 137, 56, 50, 57, 51, 45, + 68, 68, 58, 50, 135, 62, 36, 36, 36, 66, + 66, 63, 37, 134, 37, 38, 38, 38, 66, 66, + 45, 38, 43, 38, 44, 44, 67, 48, 67, 45, + 48, 68, 68, 48, 48, 45, 131, 48, 48, 130, + 50, 48, 51, 50, 87, 51, 50, 50, 51, 51, + 50, 50, 51, 51, 50, 90, 51, 88, 128, 79, + 72, 78, 87, 71, 127, 124, 90, 123, 91, 80, + 48, 84, 112, 48, 120, 88, 119, 51, 116, 91, + + 48, 51, 112, 50, 48, 51, 50, 89, 51, 48, + 81, 92, 48, 50, 111, 51, 82, 50, 98, 51, + 48, 83, 50, 49, 51, 50, 99, 51, 48, 107, + 110, 100, 109, 50, 49, 51, 49, 101, 69, 69, + 103, 50, 108, 51, 104, 104, 104, 49, 49, 49, + 102, 97, 49, 115, 49, 49, 114, 113, 49, 49, + 49, 49, 49, 49, 122, 49, 103, 49, 49, 106, + 96, 49, 49, 49, 49, 81, 49, 104, 104, 104, + 49, 49, 95, 49, 49, 49, 117, 49, 118, 49, + 49, 49, 49, 49, 49, 49, 94, 49, 121, 49, + + 93, 125, 49, 126, 49, 49, 125, 86, 126, 49, + 85, 49, 104, 104, 104, 49, 49, 49, 129, 132, + 49, 49, 75, 49, 49, 87, 133, 49, 49, 90, + 49, 74, 49, 73, 69, 49, 65, 143, 88, 39, + 51, 64, 91, 47, 51, 29, 29, 29, 29, 29, + 29, 29, 29, 33, 33, 33, 33, 33, 33, 33, + 33, 38, 38, 46, 39, 143, 143, 38, 49, 143, + 49, 49, 143, 49, 49, 70, 70, 143, 143, 70, + 105, 105, 143, 105, 105, 105, 105, 7, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143 + } ; + +static lp_yyconst flex_int16_t lp_yy_chk[426] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, + 4, 4, 3, 142, 4, 5, 5, 6, 6, 9, + 9, 9, 14, 14, 15, 9, 2, 9, 141, 15, + 2, 22, 2, 10, 10, 10, 23, 2, 131, 10, + 16, 10, 16, 16, 22, 26, 22, 67, 67, 23, + 131, 23, 25, 16, 23, 140, 27, 139, 26, 48, + 26, 23, 24, 24, 24, 25, 138, 25, 24, 27, + + 24, 27, 48, 28, 26, 137, 58, 25, 40, 40, + 86, 24, 58, 27, 135, 24, 28, 24, 28, 40, + 68, 68, 24, 86, 130, 28, 36, 36, 36, 43, + 43, 28, 36, 128, 36, 38, 38, 38, 66, 66, + 43, 38, 44, 38, 44, 44, 45, 49, 45, 66, + 52, 45, 45, 53, 59, 44, 124, 60, 61, 123, + 49, 63, 49, 52, 87, 52, 53, 59, 53, 59, + 60, 61, 60, 61, 63, 90, 63, 87, 120, 60, + 53, 59, 71, 52, 119, 116, 72, 115, 90, 61, + 62, 63, 112, 81, 111, 71, 109, 71, 106, 72, + + 78, 72, 97, 62, 79, 62, 81, 71, 81, 80, + 62, 72, 82, 78, 95, 78, 62, 79, 78, 79, + 83, 62, 80, 89, 80, 82, 79, 82, 84, 89, + 94, 80, 93, 83, 89, 83, 92, 82, 91, 88, + 84, 84, 92, 84, 85, 85, 85, 92, 98, 99, + 83, 77, 100, 101, 98, 99, 100, 98, 100, 98, + 99, 102, 114, 100, 114, 101, 103, 102, 114, 85, + 76, 101, 102, 114, 103, 101, 101, 104, 104, 104, + 103, 107, 75, 108, 113, 103, 107, 107, 108, 108, + 113, 117, 107, 118, 108, 113, 74, 117, 113, 118, + + 73, 117, 117, 118, 118, 121, 117, 70, 118, 122, + 65, 121, 136, 136, 136, 122, 121, 125, 122, 125, + 122, 129, 57, 125, 126, 132, 126, 129, 125, 133, + 126, 56, 129, 55, 50, 126, 39, 136, 132, 37, + 132, 32, 133, 21, 133, 144, 144, 144, 144, 144, + 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, + 145, 146, 146, 19, 12, 7, 0, 146, 147, 0, + 147, 147, 0, 147, 147, 148, 148, 0, 0, 148, + 149, 149, 0, 149, 149, 149, 149, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143 + } ; + +/* Table of booleans, true if rule could match eol. */ +static lp_yyconst flex_int32_t lp_yy_rule_can_match_eol[34] = + { 0, +0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define lp_yymore() lp_yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +/* + made reentrant with help of + http://www.usualcoding.eu/post/2007/09/03/Building-a-reentrant-parser-in-C-with-Flex/Bison +*/ +/* + Note that a minimum version of flex is needed to be able to compile this. + Older version don't know the reentrant code. + Version 2.5.4 is not enough. Probably at least v2.5.31 is needed. Tested with v2.5.35 +*/ +/* +** We want the scanner to be reentrant, therefore generate no global variables. +** That what the 'reentrant' option is for. +** 'bison-bridge' is used to create a bison compatible scanner and share lp_yylval +*/ + +#define INITIAL 0 +#define COMMENT 1 +#define LINECOMMENT 2 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct lp_yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE lp_yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *lp_yyin_r, *lp_yyout_r; + size_t lp_yy_buffer_stack_top; /**< index of top of stack. */ + size_t lp_yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * lp_yy_buffer_stack; /**< Stack as an array. */ + char lp_yy_hold_char; + int lp_yy_n_chars; + int lp_yyleng_r; + char *lp_yy_c_buf_p; + int lp_yy_init; + int lp_yy_start; + int lp_yy_did_buffer_switch_on_eof; + int lp_yy_start_stack_ptr; + int lp_yy_start_stack_depth; + int *lp_yy_start_stack; + lp_yy_state_type lp_yy_last_accepting_state; + char* lp_yy_last_accepting_cpos; + + int lp_yylineno_r; + int lp_yy_flex_debug_r; + + char *lp_yytext_r; + int lp_yy_more_flag; + int lp_yy_more_len; + + YYSTYPE * lp_yylval_r; + + }; /* end struct lp_yyguts_t */ + +static int lp_yy_init_globals (lp_yyscan_t lp_yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define lp_yylval lp_yyg->lp_yylval_r + +int lp_yylex_init (lp_yyscan_t* scanner); + +int lp_yylex_init_extra (YY_EXTRA_TYPE user_defined,lp_yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int lp_yylex_destroy (lp_yyscan_t lp_yyscanner ); + +int lp_yyget_debug (lp_yyscan_t lp_yyscanner ); + +void lp_yyset_debug (int debug_flag ,lp_yyscan_t lp_yyscanner ); + +YY_EXTRA_TYPE lp_yyget_extra (lp_yyscan_t lp_yyscanner ); + +void lp_yyset_extra (YY_EXTRA_TYPE user_defined ,lp_yyscan_t lp_yyscanner ); + +FILE *lp_yyget_in (lp_yyscan_t lp_yyscanner ); + +void lp_yyset_in (FILE * in_str ,lp_yyscan_t lp_yyscanner ); + +FILE *lp_yyget_out (lp_yyscan_t lp_yyscanner ); + +void lp_yyset_out (FILE * out_str ,lp_yyscan_t lp_yyscanner ); + +int lp_yyget_leng (lp_yyscan_t lp_yyscanner ); + +char *lp_yyget_text (lp_yyscan_t lp_yyscanner ); + +int lp_yyget_lineno (lp_yyscan_t lp_yyscanner ); + +void lp_yyset_lineno (int line_number ,lp_yyscan_t lp_yyscanner ); + +YYSTYPE * lp_yyget_lval (lp_yyscan_t lp_yyscanner ); + +void lp_yyset_lval (YYSTYPE * lp_yylval_param ,lp_yyscan_t lp_yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int lp_yywrap (lp_yyscan_t lp_yyscanner ); +#else +extern int lp_yywrap (lp_yyscan_t lp_yyscanner ); +#endif +#endif + + static void lp_yyunput (int c,char *buf_ptr ,lp_yyscan_t lp_yyscanner); + +#ifndef lp_yytext_ptr +static void lp_yy_flex_strncpy (char *,lp_yyconst char *,int ,lp_yyscan_t lp_yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int lp_yy_flex_strlen (lp_yyconst char * ,lp_yyscan_t lp_yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int lp_yyinput (lp_yyscan_t lp_yyscanner ); +#else +static int input (lp_yyscan_t lp_yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( lp_yytext, lp_yyleng, 1, lp_yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->lp_yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( lp_yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( lp_yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, lp_yyin))==0 && ferror(lp_yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(lp_yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "lp_yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef lp_yyterminate +#define lp_yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) lp_yy_fatal_error( msg , lp_yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int lp_yylex \ + (YYSTYPE * lp_yylval_param ,lp_yyscan_t lp_yyscanner); + +#define YY_DECL int lp_yylex \ + (YYSTYPE * lp_yylval_param , lp_yyscan_t lp_yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after lp_yytext and lp_yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( lp_yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol = \ + (lp_yytext[lp_yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register lp_yy_state_type lp_yy_current_state; + register char *lp_yy_cp, *lp_yy_bp; + register int lp_yy_act; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + lp_yylval = lp_yylval_param; + + if ( !lp_yyg->lp_yy_init ) + { + lp_yyg->lp_yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! lp_yyg->lp_yy_start ) + lp_yyg->lp_yy_start = 1; /* first start state */ + + if ( ! lp_yyin ) + lp_yyin = stdin; + + if ( ! lp_yyout ) + lp_yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + lp_yyensure_buffer_stack (lp_yyscanner); + YY_CURRENT_BUFFER_LVALUE = + lp_yy_create_buffer(lp_yyin,YY_BUF_SIZE ,lp_yyscanner); + } + + lp_yy_load_buffer_state(lp_yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + lp_yy_cp = lp_yyg->lp_yy_c_buf_p; + + /* Support of lp_yytext. */ + *lp_yy_cp = lp_yyg->lp_yy_hold_char; + + /* lp_yy_bp points to the position in lp_yy_ch_buf of the start of + * the current run. + */ + lp_yy_bp = lp_yy_cp; + + lp_yy_current_state = lp_yyg->lp_yy_start; + lp_yy_current_state += YY_AT_BOL(); +lp_yy_match: + do + { + register YY_CHAR lp_yy_c = lp_yy_ec[YY_SC_TO_UI(*lp_yy_cp)]; + if ( lp_yy_accept[lp_yy_current_state] ) + { + lp_yyg->lp_yy_last_accepting_state = lp_yy_current_state; + lp_yyg->lp_yy_last_accepting_cpos = lp_yy_cp; + } + while ( lp_yy_chk[lp_yy_base[lp_yy_current_state] + lp_yy_c] != lp_yy_current_state ) + { + lp_yy_current_state = (int) lp_yy_def[lp_yy_current_state]; + if ( lp_yy_current_state >= 144 ) + lp_yy_c = lp_yy_meta[(unsigned int) lp_yy_c]; + } + lp_yy_current_state = lp_yy_nxt[lp_yy_base[lp_yy_current_state] + (unsigned int) lp_yy_c]; + ++lp_yy_cp; + } + while ( lp_yy_base[lp_yy_current_state] != 388 ); + +lp_yy_find_action: + lp_yy_act = lp_yy_accept[lp_yy_current_state]; + if ( lp_yy_act == 0 ) + { /* have to back up */ + lp_yy_cp = lp_yyg->lp_yy_last_accepting_cpos; + lp_yy_current_state = lp_yyg->lp_yy_last_accepting_state; + lp_yy_act = lp_yy_accept[lp_yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( lp_yy_act != YY_END_OF_BUFFER && lp_yy_rule_can_match_eol[lp_yy_act] ) + { + int lp_yyl; + for ( lp_yyl = 0; lp_yyl < lp_yyleng; ++lp_yyl ) + if ( lp_yytext[lp_yyl] == '\n' ) + + do{ lp_yylineno++; + lp_yycolumn=0; + }while(0) +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( lp_yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *lp_yy_cp = lp_yyg->lp_yy_hold_char; + lp_yy_cp = lp_yyg->lp_yy_last_accepting_cpos; + lp_yy_current_state = lp_yyg->lp_yy_last_accepting_state; + goto lp_yy_find_action; + +case 1: +YY_RULE_SETUP +{ + BEGIN COMMENT; +} /* begin skip comment */ + YY_BREAK +case 2: +YY_RULE_SETUP +{ + BEGIN INITIAL; +} /* end skip comment */ + YY_BREAK +case 3: +YY_RULE_SETUP +{ +} + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +{ +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ +} + YY_BREAK +case 6: +YY_RULE_SETUP +{ + BEGIN LINECOMMENT; +} /* begin skip LINECOMMENT */ + YY_BREAK +case 7: +/* rule 7 can match eol */ +YY_RULE_SETUP +{ + BEGIN INITIAL; +} /* end skip LINECOMMENT */ + YY_BREAK +case 8: +YY_RULE_SETUP +{ + BEGIN INITIAL; +} /* end skip LINECOMMENT */ + YY_BREAK +case 9: +YY_RULE_SETUP +{ +} + YY_BREAK +case 10: +/* rule 10 can match eol */ +YY_RULE_SETUP +{ +} + YY_BREAK +case 11: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + + pp->lineno = lp_yylineno; + return(COMMA); +} + YY_BREAK +case 12: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + + pp->lineno = lp_yylineno; + return(MINIMISE); +} + YY_BREAK +case 13: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + + pp->lineno = lp_yylineno; + return(MAXIMISE); +} + YY_BREAK +case 14: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + pv->f = atof((char *)lp_yytext); + return(INTCONS); +} /* f contains the last float */ + YY_BREAK +case 15: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + pv->f = atof((char *)lp_yytext); + return(CONS); +} /* f contains the last float */ + YY_BREAK +case 16: +/* rule 16 can match eol */ +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + char *ptr, c; + + pp->lineno = lp_yylineno; + pv->f = DEF_INFINITE; + pv->Sign = 0; + ptr = (char *)lp_yytext; + while (isspace(*ptr)) ptr++; + if(*ptr == '-') + pv->Sign = 1; + if(lp_yyleng > 0) { + c = lp_yytext[lp_yyleng - 1]; + if(!isalnum(c)) + unput(c); + } + return(INF); +} /* f contains the last float */ + YY_BREAK +case 17: +/* rule 17 can match eol */ +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + int x; + + pp->lineno = lp_yylineno; + pv->Sign = 0; + for(x = 0; x < lp_yyleng; x++) + if(lp_yytext[x] == '-' || lp_yytext[x] == '+') + pv->Sign = (pv->Sign == (lp_yytext[x] == '+')); + return (TOK_SIGN); + /* Sign is TRUE if the sign-string + represents a '-'. Otherwise Sign + is FALSE */ +} + YY_BREAK +case 18: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + if((!pv->Within_int_decl) && (!pv->Within_sec_decl) && (!pv->Within_sos_decl) && (!pv->Within_free_decl)) { + pv->Within_int_decl = 1; + pv->Within_sos_decl1 = FALSE; + } + return(SEC_INT); +} + YY_BREAK +case 19: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + if((!pv->Within_int_decl) && (!pv->Within_sec_decl) && (!pv->Within_sos_decl) && (!pv->Within_free_decl)) { + pv->Within_int_decl = 2; + pv->Within_sos_decl1 = FALSE; + } + return(SEC_BIN); +} + YY_BREAK +case 20: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + if((!pv->Within_int_decl) && (!pv->Within_sec_decl) && (!pv->Within_sos_decl) && (!pv->Within_free_decl)) { + pv->Within_sec_decl = TRUE; + pv->Within_sos_decl1 = FALSE; + } + return(SEC_SEC); +} + YY_BREAK +case 21: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + if(!pv->Within_sos_decl) + pv->SOStype0 = (short)atoi(((char *)lp_yytext) + 3); + if((!pv->Within_int_decl) && (!pv->Within_sec_decl) && (!pv->Within_sos_decl) && (!pv->Within_free_decl)) + pv->Within_sos_decl = TRUE; + return(SEC_SOS); +} + YY_BREAK +case 22: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + FREE(pv->Last_var); + pv->Last_var = strdup((char *)lp_yytext); + pv->Last_var[strlen(pv->Last_var) - 2] = 0; + return(SOSDESCR); +} + YY_BREAK +case 23: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + if((!pv->Within_int_decl) && (!pv->Within_sec_decl) && (!pv->Within_sos_decl) && (!pv->Within_free_decl)) { + pv->Within_free_decl = TRUE; + pv->Within_sos_decl1 = FALSE; + } + return(SEC_FREE); +} + YY_BREAK +case 24: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + char *ptr; + + pp->lineno = lp_yylineno; + FREE(pv->Last_var); + pv->Last_var = strdup((char *)lp_yytext); + ptr = pv->Last_var + strlen(pv->Last_var); + ptr[-1] = ' '; + while ((--ptr >= pv->Last_var) && (isspace(*ptr))) + *ptr = 0; + return(VARIABLECOLON); +} + YY_BREAK +case 25: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + FREE(pv->Last_var); + pv->Last_var = strdup((char *)lp_yytext); + return(VAR); +} + YY_BREAK +case 26: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + + pp->lineno = lp_yylineno; + return (COLON); +} + YY_BREAK +case 27: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + + pp->lineno = lp_yylineno; + return(AR_M_OP); +} + YY_BREAK +case 28: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + pv->OP = *lp_yytext; + return(RE_OPEQ); +} + YY_BREAK +case 29: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + pv->OP = *lp_yytext; + return(RE_OPLE); +} + YY_BREAK +case 30: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + pv->OP = *lp_yytext; + return(RE_OPGE); +} + YY_BREAK +case 31: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + parse_vars *pv = (parse_vars *) pp->parse_vars; + + pp->lineno = lp_yylineno; + pv->Within_int_decl = pv->Within_sec_decl = pv->Within_sos_decl = pv->Within_free_decl = FALSE; + check_int_sec_sos_free_decl(pp, (int) pv->Within_int_decl, (int) pv->Within_sec_decl, (int) pv->Within_sos_decl, (int) pv->Within_free_decl); + return(END_C); +} + YY_BREAK +case 32: +YY_RULE_SETUP +{ + parse_parm *pp = PARM; + + pp->lineno = lp_yylineno; + report(NULL, CRITICAL, "LEX ERROR : %s lineno %d\n", lp_yytext, lp_yylineno); + return(UNDEFINED); +} + YY_BREAK +case 33: +YY_RULE_SETUP +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT): +case YY_STATE_EOF(LINECOMMENT): + lp_yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int lp_yy_amount_of_matched_text = (int) (lp_yy_cp - lp_yyg->lp_yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *lp_yy_cp = lp_yyg->lp_yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->lp_yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed lp_yyin at a new source and called + * lp_yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + lp_yyg->lp_yy_n_chars = YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->lp_yy_input_file = lp_yyin; + YY_CURRENT_BUFFER_LVALUE->lp_yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for lp_yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since lp_yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( lp_yyg->lp_yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[lp_yyg->lp_yy_n_chars] ) + { /* This was really a NUL. */ + lp_yy_state_type lp_yy_next_state; + + lp_yyg->lp_yy_c_buf_p = lp_yyg->lp_yytext_ptr + lp_yy_amount_of_matched_text; + + lp_yy_current_state = lp_yy_get_previous_state( lp_yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * lp_yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + lp_yy_next_state = lp_yy_try_NUL_trans( lp_yy_current_state , lp_yyscanner); + + lp_yy_bp = lp_yyg->lp_yytext_ptr + YY_MORE_ADJ; + + if ( lp_yy_next_state ) + { + /* Consume the NUL. */ + lp_yy_cp = ++lp_yyg->lp_yy_c_buf_p; + lp_yy_current_state = lp_yy_next_state; + goto lp_yy_match; + } + + else + { + lp_yy_cp = lp_yyg->lp_yy_c_buf_p; + goto lp_yy_find_action; + } + } + + else switch ( lp_yy_get_next_buffer( lp_yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + lp_yyg->lp_yy_did_buffer_switch_on_eof = 0; + + if ( lp_yywrap(lp_yyscanner ) ) + { + /* Note: because we've taken care in + * lp_yy_get_next_buffer() to have set up + * lp_yytext, we can now set up + * lp_yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + lp_yyg->lp_yy_c_buf_p = lp_yyg->lp_yytext_ptr + YY_MORE_ADJ; + + lp_yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! lp_yyg->lp_yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + lp_yyg->lp_yy_c_buf_p = + lp_yyg->lp_yytext_ptr + lp_yy_amount_of_matched_text; + + lp_yy_current_state = lp_yy_get_previous_state( lp_yyscanner ); + + lp_yy_cp = lp_yyg->lp_yy_c_buf_p; + lp_yy_bp = lp_yyg->lp_yytext_ptr + YY_MORE_ADJ; + goto lp_yy_match; + + case EOB_ACT_LAST_MATCH: + lp_yyg->lp_yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[lp_yyg->lp_yy_n_chars]; + + lp_yy_current_state = lp_yy_get_previous_state( lp_yyscanner ); + + lp_yy_cp = lp_yyg->lp_yy_c_buf_p; + lp_yy_bp = lp_yyg->lp_yytext_ptr + YY_MORE_ADJ; + goto lp_yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of lp_yylex */ + +/* lp_yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int lp_yy_get_next_buffer (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf; + register char *source = lp_yyg->lp_yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( lp_yyg->lp_yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[lp_yyg->lp_yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->lp_yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( lp_yyg->lp_yy_c_buf_p - lp_yyg->lp_yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (lp_yyg->lp_yy_c_buf_p - lp_yyg->lp_yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->lp_yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars = lp_yyg->lp_yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int lp_yy_c_buf_p_offset = + (int) (lp_yyg->lp_yy_c_buf_p - b->lp_yy_ch_buf); + + if ( b->lp_yy_is_our_buffer ) + { + int new_size = b->lp_yy_buf_size * 2; + + if ( new_size <= 0 ) + b->lp_yy_buf_size += b->lp_yy_buf_size / 8; + else + b->lp_yy_buf_size *= 2; + + b->lp_yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + lp_yyrealloc((void *) b->lp_yy_ch_buf,b->lp_yy_buf_size + 2 ,lp_yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->lp_yy_ch_buf = 0; + + if ( ! b->lp_yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + lp_yyg->lp_yy_c_buf_p = &b->lp_yy_ch_buf[lp_yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[number_to_move]), + lp_yyg->lp_yy_n_chars, (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars = lp_yyg->lp_yy_n_chars; + } + + if ( lp_yyg->lp_yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + lp_yyrestart(lp_yyin ,lp_yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->lp_yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((lp_yy_size_t) (lp_yyg->lp_yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + lp_yy_size_t new_size = lp_yyg->lp_yy_n_chars + number_to_move + (lp_yyg->lp_yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf = (char *) lp_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf,new_size ,lp_yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yy_get_next_buffer()" ); + } + + lp_yyg->lp_yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[lp_yyg->lp_yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[lp_yyg->lp_yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + lp_yyg->lp_yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[0]; + + return ret_val; +} + +/* lp_yy_get_previous_state - get the state just before the EOB char was reached */ + + static lp_yy_state_type lp_yy_get_previous_state (lp_yyscan_t lp_yyscanner) +{ + register lp_yy_state_type lp_yy_current_state; + register char *lp_yy_cp; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + lp_yy_current_state = lp_yyg->lp_yy_start; + lp_yy_current_state += YY_AT_BOL(); + + for ( lp_yy_cp = lp_yyg->lp_yytext_ptr + YY_MORE_ADJ; lp_yy_cp < lp_yyg->lp_yy_c_buf_p; ++lp_yy_cp ) + { + register YY_CHAR lp_yy_c = (*lp_yy_cp ? lp_yy_ec[YY_SC_TO_UI(*lp_yy_cp)] : 1); + if ( lp_yy_accept[lp_yy_current_state] ) + { + lp_yyg->lp_yy_last_accepting_state = lp_yy_current_state; + lp_yyg->lp_yy_last_accepting_cpos = lp_yy_cp; + } + while ( lp_yy_chk[lp_yy_base[lp_yy_current_state] + lp_yy_c] != lp_yy_current_state ) + { + lp_yy_current_state = (int) lp_yy_def[lp_yy_current_state]; + if ( lp_yy_current_state >= 144 ) + lp_yy_c = lp_yy_meta[(unsigned int) lp_yy_c]; + } + lp_yy_current_state = lp_yy_nxt[lp_yy_base[lp_yy_current_state] + (unsigned int) lp_yy_c]; + } + + return lp_yy_current_state; +} + +/* lp_yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = lp_yy_try_NUL_trans( current_state ); + */ + static lp_yy_state_type lp_yy_try_NUL_trans (lp_yy_state_type lp_yy_current_state , lp_yyscan_t lp_yyscanner) +{ + register int lp_yy_is_jam; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; /* This var may be unused depending upon options. */ + register char *lp_yy_cp = lp_yyg->lp_yy_c_buf_p; + + register YY_CHAR lp_yy_c = 1; + if ( lp_yy_accept[lp_yy_current_state] ) + { + lp_yyg->lp_yy_last_accepting_state = lp_yy_current_state; + lp_yyg->lp_yy_last_accepting_cpos = lp_yy_cp; + } + while ( lp_yy_chk[lp_yy_base[lp_yy_current_state] + lp_yy_c] != lp_yy_current_state ) + { + lp_yy_current_state = (int) lp_yy_def[lp_yy_current_state]; + if ( lp_yy_current_state >= 144 ) + lp_yy_c = lp_yy_meta[(unsigned int) lp_yy_c]; + } + lp_yy_current_state = lp_yy_nxt[lp_yy_base[lp_yy_current_state] + (unsigned int) lp_yy_c]; + lp_yy_is_jam = (lp_yy_current_state == 143); + + return lp_yy_is_jam ? 0 : lp_yy_current_state; +} + + static void lp_yyunput (int c, register char * lp_yy_bp , lp_yyscan_t lp_yyscanner) +{ + register char *lp_yy_cp; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + lp_yy_cp = lp_yyg->lp_yy_c_buf_p; + + /* undo effects of setting up lp_yytext */ + *lp_yy_cp = lp_yyg->lp_yy_hold_char; + + if ( lp_yy_cp < YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = lp_yyg->lp_yy_n_chars + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf ) + *--dest = *--source; + + lp_yy_cp += (int) (dest - source); + lp_yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars = + lp_yyg->lp_yy_n_chars = YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_size; + + if ( lp_yy_cp < YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--lp_yy_cp = (char) c; + + if ( c == '\n' ){ + --lp_yylineno; + } + + lp_yyg->lp_yytext_ptr = lp_yy_bp; + lp_yyg->lp_yy_hold_char = *lp_yy_cp; + lp_yyg->lp_yy_c_buf_p = lp_yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static inline int lp_yyinput (lp_yyscan_t lp_yyscanner) +#else + static inline int input (lp_yyscan_t lp_yyscanner) +#endif + +{ + int c; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + *lp_yyg->lp_yy_c_buf_p = lp_yyg->lp_yy_hold_char; + + if ( *lp_yyg->lp_yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* lp_yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( lp_yyg->lp_yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->lp_yy_ch_buf[lp_yyg->lp_yy_n_chars] ) + /* This was really a NUL. */ + *lp_yyg->lp_yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = lp_yyg->lp_yy_c_buf_p - lp_yyg->lp_yytext_ptr; + ++lp_yyg->lp_yy_c_buf_p; + + switch ( lp_yy_get_next_buffer( lp_yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because lp_yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + lp_yyrestart(lp_yyin ,lp_yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( lp_yywrap(lp_yyscanner ) ) + return EOF; + + if ( ! lp_yyg->lp_yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return lp_yyinput(lp_yyscanner); +#else + return input(lp_yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + lp_yyg->lp_yy_c_buf_p = lp_yyg->lp_yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) lp_yyg->lp_yy_c_buf_p; /* cast for 8-bit char's */ + *lp_yyg->lp_yy_c_buf_p = '\0'; /* preserve lp_yytext */ + lp_yyg->lp_yy_hold_char = *++lp_yyg->lp_yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->lp_yy_at_bol ) + + do{ lp_yylineno++; + lp_yycolumn=0; + }while(0) +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param lp_yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void lp_yyrestart (FILE * input_file , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + lp_yyensure_buffer_stack (lp_yyscanner); + YY_CURRENT_BUFFER_LVALUE = + lp_yy_create_buffer(lp_yyin,YY_BUF_SIZE ,lp_yyscanner); + } + + lp_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,lp_yyscanner); + lp_yy_load_buffer_state(lp_yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param lp_yyscanner The scanner object. + */ + void lp_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * lp_yypop_buffer_state(); + * lp_yypush_buffer_state(new_buffer); + */ + lp_yyensure_buffer_stack (lp_yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *lp_yyg->lp_yy_c_buf_p = lp_yyg->lp_yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_pos = lp_yyg->lp_yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars = lp_yyg->lp_yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + lp_yy_load_buffer_state(lp_yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (lp_yywrap()) processing, but the only time this flag + * is looked at is after lp_yywrap() is called, so it's safe + * to go ahead and always set it. + */ + lp_yyg->lp_yy_did_buffer_switch_on_eof = 1; +} + +static void lp_yy_load_buffer_state (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + lp_yyg->lp_yy_n_chars = YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars; + lp_yyg->lp_yytext_ptr = lp_yyg->lp_yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_pos; + lp_yyin = YY_CURRENT_BUFFER_LVALUE->lp_yy_input_file; + lp_yyg->lp_yy_hold_char = *lp_yyg->lp_yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param lp_yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE lp_yy_create_buffer (FILE * file, int size , lp_yyscan_t lp_yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) lp_yyalloc(sizeof( struct lp_yy_buffer_state ) ,lp_yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yy_create_buffer()" ); + + b->lp_yy_buf_size = size; + + /* lp_yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->lp_yy_ch_buf = (char *) lp_yyalloc(b->lp_yy_buf_size + 2 ,lp_yyscanner ); + if ( ! b->lp_yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yy_create_buffer()" ); + + b->lp_yy_is_our_buffer = 1; + + lp_yy_init_buffer(b,file ,lp_yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with lp_yy_create_buffer() + * @param lp_yyscanner The scanner object. + */ + void lp_yy_delete_buffer (YY_BUFFER_STATE b , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->lp_yy_is_our_buffer ) + lp_yyfree((void *) b->lp_yy_ch_buf ,lp_yyscanner ); + + lp_yyfree((void *) b ,lp_yyscanner ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a lp_yyrestart() or at EOF. + */ + static void lp_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , lp_yyscan_t lp_yyscanner) + +{ + int oerrno = errno; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + lp_yy_flush_buffer(b ,lp_yyscanner); + + b->lp_yy_input_file = file; + b->lp_yy_fill_buffer = 1; + + /* If b is the current buffer, then lp_yy_init_buffer was _probably_ + * called from lp_yyrestart() or through lp_yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->lp_yy_bs_lineno = 1; + b->lp_yy_bs_column = 0; + } + + b->lp_yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param lp_yyscanner The scanner object. + */ + void lp_yy_flush_buffer (YY_BUFFER_STATE b , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + if ( ! b ) + return; + + b->lp_yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->lp_yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->lp_yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->lp_yy_buf_pos = &b->lp_yy_ch_buf[0]; + + b->lp_yy_at_bol = 1; + b->lp_yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + lp_yy_load_buffer_state(lp_yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param lp_yyscanner The scanner object. + */ +void lp_yypush_buffer_state (YY_BUFFER_STATE new_buffer , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + if (new_buffer == NULL) + return; + + lp_yyensure_buffer_stack(lp_yyscanner); + + /* This block is copied from lp_yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *lp_yyg->lp_yy_c_buf_p = lp_yyg->lp_yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->lp_yy_buf_pos = lp_yyg->lp_yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->lp_yy_n_chars = lp_yyg->lp_yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + lp_yyg->lp_yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from lp_yy_switch_to_buffer. */ + lp_yy_load_buffer_state(lp_yyscanner ); + lp_yyg->lp_yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param lp_yyscanner The scanner object. + */ +void lp_yypop_buffer_state (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + lp_yy_delete_buffer(YY_CURRENT_BUFFER ,lp_yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (lp_yyg->lp_yy_buffer_stack_top > 0) + --lp_yyg->lp_yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + lp_yy_load_buffer_state(lp_yyscanner ); + lp_yyg->lp_yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void lp_yyensure_buffer_stack (lp_yyscan_t lp_yyscanner) +{ + int num_to_alloc; + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + if (!lp_yyg->lp_yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + lp_yyg->lp_yy_buffer_stack = (struct lp_yy_buffer_state**)lp_yyalloc + (num_to_alloc * sizeof(struct lp_yy_buffer_state*) + , lp_yyscanner); + if ( ! lp_yyg->lp_yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yyensure_buffer_stack()" ); + + memset(lp_yyg->lp_yy_buffer_stack, 0, num_to_alloc * sizeof(struct lp_yy_buffer_state*)); + + lp_yyg->lp_yy_buffer_stack_max = num_to_alloc; + lp_yyg->lp_yy_buffer_stack_top = 0; + return; + } + + if (lp_yyg->lp_yy_buffer_stack_top >= (lp_yyg->lp_yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = lp_yyg->lp_yy_buffer_stack_max + grow_size; + lp_yyg->lp_yy_buffer_stack = (struct lp_yy_buffer_state**)lp_yyrealloc + (lp_yyg->lp_yy_buffer_stack, + num_to_alloc * sizeof(struct lp_yy_buffer_state*) + , lp_yyscanner); + if ( ! lp_yyg->lp_yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(lp_yyg->lp_yy_buffer_stack + lp_yyg->lp_yy_buffer_stack_max, 0, grow_size * sizeof(struct lp_yy_buffer_state*)); + lp_yyg->lp_yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param lp_yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE lp_yy_scan_buffer (char * base, lp_yy_size_t size , lp_yyscan_t lp_yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) lp_yyalloc(sizeof( struct lp_yy_buffer_state ) ,lp_yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yy_scan_buffer()" ); + + b->lp_yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->lp_yy_buf_pos = b->lp_yy_ch_buf = base; + b->lp_yy_is_our_buffer = 0; + b->lp_yy_input_file = 0; + b->lp_yy_n_chars = b->lp_yy_buf_size; + b->lp_yy_is_interactive = 0; + b->lp_yy_at_bol = 1; + b->lp_yy_fill_buffer = 0; + b->lp_yy_buffer_status = YY_BUFFER_NEW; + + lp_yy_switch_to_buffer(b ,lp_yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to lp_yylex() will + * scan from a @e copy of @a str. + * @param lp_yystr a NUL-terminated string to scan + * @param lp_yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * lp_yy_scan_bytes() instead. + */ +YY_BUFFER_STATE lp_yy_scan_string (lp_yyconst char * lp_yystr , lp_yyscan_t lp_yyscanner) +{ + + return lp_yy_scan_bytes(lp_yystr,strlen(lp_yystr) ,lp_yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to lp_yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param lp_yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE lp_yy_scan_bytes (lp_yyconst char * lp_yybytes, int _lp_yybytes_len , lp_yyscan_t lp_yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + lp_yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _lp_yybytes_len + 2; + buf = (char *) lp_yyalloc(n ,lp_yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in lp_yy_scan_bytes()" ); + + for ( i = 0; i < _lp_yybytes_len; ++i ) + buf[i] = lp_yybytes[i]; + + buf[_lp_yybytes_len] = buf[_lp_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = lp_yy_scan_buffer(buf,n ,lp_yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in lp_yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->lp_yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void lp_yy_fatal_error (lp_yyconst char* msg , lp_yyscan_t lp_yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine lp_yyless() so it works in section 3 code. */ + +#undef lp_yyless +#define lp_yyless(n) \ + do \ + { \ + /* Undo effects of setting up lp_yytext. */ \ + int lp_yyless_macro_arg = (n); \ + YY_LESS_LINENO(lp_yyless_macro_arg);\ + lp_yytext[lp_yyleng] = lp_yyg->lp_yy_hold_char; \ + lp_yyg->lp_yy_c_buf_p = lp_yytext + lp_yyless_macro_arg; \ + lp_yyg->lp_yy_hold_char = *lp_yyg->lp_yy_c_buf_p; \ + *lp_yyg->lp_yy_c_buf_p = '\0'; \ + lp_yyleng = lp_yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param lp_yyscanner The scanner object. + */ +YY_EXTRA_TYPE lp_yyget_extra (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yyextra; +} + +/** Get the current line number. + * @param lp_yyscanner The scanner object. + */ +int lp_yyget_lineno (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return lp_yylineno; +} + +/** Get the current column number. + * @param lp_yyscanner The scanner object. + */ +int lp_yyget_column (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return lp_yycolumn; +} + +/** Get the input stream. + * @param lp_yyscanner The scanner object. + */ +FILE *lp_yyget_in (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yyin; +} + +/** Get the output stream. + * @param lp_yyscanner The scanner object. + */ +FILE *lp_yyget_out (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yyout; +} + +/** Get the length of the current token. + * @param lp_yyscanner The scanner object. + */ +int lp_yyget_leng (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yyleng; +} + +/** Get the current token. + * @param lp_yyscanner The scanner object. + */ + +char *lp_yyget_text (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param lp_yyscanner The scanner object. + */ +void lp_yyset_extra (YY_EXTRA_TYPE user_defined , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + lp_yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param lp_yyscanner The scanner object. + */ +void lp_yyset_lineno (int line_number , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + lp_yy_fatal_error( "lp_yyset_lineno called with no buffer" , lp_yyscanner); + + lp_yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param lp_yyscanner The scanner object. + */ +void lp_yyset_column (int column_no , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + lp_yy_fatal_error( "lp_yyset_column called with no buffer" , lp_yyscanner); + + lp_yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param lp_yyscanner The scanner object. + * @see lp_yy_switch_to_buffer + */ +void lp_yyset_in (FILE * in_str , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + lp_yyin = in_str ; +} + +void lp_yyset_out (FILE * out_str , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + lp_yyout = out_str ; +} + +int lp_yyget_debug (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yy_flex_debug; +} + +void lp_yyset_debug (int bdebug , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + lp_yy_flex_debug = bdebug ; +} + +/* Accessor methods for lp_yylval and lp_yylloc */ + +YYSTYPE * lp_yyget_lval (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + return lp_yylval; +} + +void lp_yyset_lval (YYSTYPE * lp_yylval_param , lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + lp_yylval = lp_yylval_param; +} + +/* User-visible API */ + +/* lp_yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int lp_yylex_init(lp_yyscan_t* ptr_lp_yy_globals) + +{ + if (ptr_lp_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_lp_yy_globals = (lp_yyscan_t) lp_yyalloc ( sizeof( struct lp_yyguts_t ), NULL ); + + if (*ptr_lp_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in lp_yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_lp_yy_globals,0x00,sizeof(struct lp_yyguts_t)); + + return lp_yy_init_globals ( *ptr_lp_yy_globals ); +} + +/* lp_yylex_init_extra has the same functionality as lp_yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to lp_yyalloc in + * the lp_yyextra field. + */ + +int lp_yylex_init_extra(YY_EXTRA_TYPE lp_yy_user_defined,lp_yyscan_t* ptr_lp_yy_globals ) + +{ + struct lp_yyguts_t dummy_lp_yyguts; + + lp_yyset_extra (lp_yy_user_defined, &dummy_lp_yyguts); + + if (ptr_lp_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_lp_yy_globals = (lp_yyscan_t) lp_yyalloc ( sizeof( struct lp_yyguts_t ), &dummy_lp_yyguts ); + + if (*ptr_lp_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + lp_yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_lp_yy_globals,0x00,sizeof(struct lp_yyguts_t)); + + lp_yyset_extra (lp_yy_user_defined, *ptr_lp_yy_globals); + + return lp_yy_init_globals ( *ptr_lp_yy_globals ); +} + +static int lp_yy_init_globals (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from lp_yylex_destroy(), so don't allocate here. + */ + + lp_yyg->lp_yy_buffer_stack = 0; + lp_yyg->lp_yy_buffer_stack_top = 0; + lp_yyg->lp_yy_buffer_stack_max = 0; + lp_yyg->lp_yy_c_buf_p = (char *) 0; + lp_yyg->lp_yy_init = 0; + lp_yyg->lp_yy_start = 0; + + lp_yyg->lp_yy_start_stack_ptr = 0; + lp_yyg->lp_yy_start_stack_depth = 0; + lp_yyg->lp_yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + lp_yyin = stdin; + lp_yyout = stdout; +#else + lp_yyin = (FILE *) 0; + lp_yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * lp_yylex_init() + */ + return 0; +} + +/* lp_yylex_destroy is for both reentrant and non-reentrant scanners. */ +int lp_yylex_destroy (lp_yyscan_t lp_yyscanner) +{ + struct lp_yyguts_t * lp_yyg = (struct lp_yyguts_t*)lp_yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + lp_yy_delete_buffer(YY_CURRENT_BUFFER ,lp_yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + lp_yypop_buffer_state(lp_yyscanner); + } + + /* Destroy the stack itself. */ + lp_yyfree(lp_yyg->lp_yy_buffer_stack ,lp_yyscanner); + lp_yyg->lp_yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + lp_yyfree(lp_yyg->lp_yy_start_stack ,lp_yyscanner ); + lp_yyg->lp_yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * lp_yylex() is called, initialization will occur. */ + lp_yy_init_globals( lp_yyscanner); + + /* Destroy the main struct (reentrant only). */ + lp_yyfree ( lp_yyscanner , lp_yyscanner ); + lp_yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef lp_yytext_ptr +static void lp_yy_flex_strncpy (char* s1, lp_yyconst char * s2, int n , lp_yyscan_t lp_yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int lp_yy_flex_strlen (lp_yyconst char * s , lp_yyscan_t lp_yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *lp_yyalloc (lp_yy_size_t size , lp_yyscan_t lp_yyscanner) +{ + return (void *) malloc( size ); +} + +void *lp_yyrealloc (void * ptr, lp_yy_size_t size , lp_yyscan_t lp_yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void lp_yyfree (void * ptr , lp_yyscan_t lp_yyscanner) +{ + free( (char *) ptr ); /* see lp_yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "lp_yytables" + diff --git a/include/cartesian_geom/autopoint.h b/include/cartesian_geom/autopoint.h new file mode 100644 index 000000000..41dccf47e --- /dev/null +++ b/include/cartesian_geom/autopoint.h @@ -0,0 +1,321 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2024 Vissarion Fisikopoulos + +// Licensed under GNU LGPL.3, see LICENCE file + +#ifndef CARTESIAN_KERNEL_AUTOPOINT_H +#define CARTESIAN_KERNEL_AUTOPOINT_H + +#include +#include + +/// This class manipulates a point used for automatic differentation +/// parameterized by a number type e.g. double +/// \tparam T Numerical Type +template +class autopoint +{ + public: + unsigned int d; + Eigen::Matrix, Eigen::Dynamic,1> coeffs; + typedef typename std::vector>::iterator iter; + typedef typename autodiff::detail::Real<1, T> FT; + typedef Eigen::Matrix coeff; + typedef Eigen::Matrix, Eigen::Dynamic,1> Coeff; + autopoint() {} + + autopoint(const unsigned int dim) + { + d = dim; + coeffs.setZero(d); + } + + autopoint(const unsigned int dim, iter begin, iter endit) + { + d = dim; + coeffs.resize(d); + int i = 0; + + for (iter it=begin ; it != endit ; it++) + coeffs(i++) = *it; + } + FT operator()(int i,int j) + { + return coeffs(i,j); + } + + autopoint(const Coeff& coeffs) + { + d = coeffs.rows(); + this->coeffs = coeffs; + } + + autopoint(const coeff& coeffs) + { + d = coeffs.rows(); + // Coeff temp= coeffs; + this->coeffs = (Coeff)coeffs; + } + + + autopoint(const unsigned int dim, std::vector> cofs) + { + d = dim; + coeffs.resize(d); + iter it = cofs.begin(); + int i=0; + + for (; it != cofs.end(); it++,i++) + coeffs(i) = *it; + + } + + void add(const Coeff& coeffs) + { + this->coeffs += coeffs; + } + + const Coeff& getCoefficients() const + { + return coeffs; + } + + int dimension() const + { + return d; + } + + void set_dimension(const unsigned int dim) + { + d = dim; + coeffs.setZero(d); + } + + void set_coord(const unsigned int i, FT coord) + { + coeffs(i) = coord; + } + + void set_coeffs (const Coeff& coeffs2) { + d = coeffs2.rows(); + coeffs = coeffs2; + } + + void set_to_origin() { + coeffs.setZero(d); + } + + FT operator[] (const unsigned int i) const + { + return coeffs(i); + } + + FT* pointerToData() + { + return coeffs.data(); + } + + FT sum() const { + return coeffs.sum(); + } + autopoint head(int n) const + { + return autopoint((Coeff)coeffs.head(n)); + } + + autopoint tail(int n) const + { + return autopoint((Coeff)coeffs.tail(n)); + } + + autopoint pow(int n) const { + autopoint temp; + temp.d = d; + temp.coeffs=coeffs.array().pow(n).matrix(); + return temp; + } + + + autopoint log() const { + autopoint temp; + temp.d = d; + temp.coeffs=coeffs.array().log().matrix(); + return temp; + } + + autopoint exp() const { + autopoint temp; + temp.d = d; + temp.coeffs=coeffs.array().exp().matrix(); + return temp; + } + void operator+= (const autopoint& p) + { + coeffs += p.getCoefficients(); + } + + void operator+= (const Coeff& coeffs) + { + this->coeffs += coeffs ; + } + + void operator-= (const autopoint& p) + { + coeffs -= p.getCoefficients(); + } + + void operator-= (const Coeff& coeffs) + { + this->coeffs -= coeffs ; + } + + + void operator= (const Coeff& coeffs) + { + this->coeffs = coeffs; + d = coeffs.rows(); + } + + // copy assignment + autopoint& operator=(const autopoint& coeffs) + { + // Guard self assignment + if (this == &coeffs) + return *this; + this->coeffs = coeffs; + d = coeffs.rows(); + return *this; + } + autopoint transpose() const + { + return autopoint((Coeff)coeffs.transpose()); + } + + autopoint operator+ (const autopoint& p) const + { + return autopoint((Coeff)(coeffs+p.getCoefficients())); + } + autopoint operator- (const autopoint& p) const + { + return autopoint((Coeff)(coeffs-p.getCoefficients())); + } + + autopoint operator- (const FT p) const + { + autopoint temp_auto; + temp_auto.d=d; + auto temp=coeffs.array(); + temp_auto.coeffs=(temp-p).matrix(); + return temp_auto; + } + autopoint operator- (T p) const + { + autopoint temp_auto; + temp_auto.d=d; + auto temp=coeffs.array(); + temp_auto.coeffs=(temp-p).matrix(); + return temp_auto; + } + + autopoint operator* (const FT k) + { + return autopoint(coeffs * k); + } + + autopoint operator* (T k) const + { + return autopoint((Coeff)(coeffs * ((FT)k))); + } + + autopoint operator* (T k) + { + return autopoint((Coeff)(coeffs * ((FT)k))); + } + // matrix multiplication + autopoint operator* (const autopoint& autopoint_) + { + return autopoint((Coeff)(coeffs * autopoint_.getCoefficients())); + } + // matrix multiplication with normal matrix + autopoint operator* (const coeff& matrix_) + { + return autopoint(( autopoint(matrix_) * autopoint(coeffs) )); + } + + void operator*= (const FT k) + { + coeffs *= k; + } + + void operator*= (const T k) + { + FT k_=k; + coeffs *= k_; + } + + + void operator/= (const FT k) + { + coeffs /= k; + } + + + FT distance(const autopoint& p) const + { + return (this->coeffs - p.coeffs).norm(); + } + + FT dot(const autopoint& p) const + { + return coeffs.dot(p.getCoefficients()); + } + + FT dot(const Coeff& coeffs) const + { + return this->coeffs.dot(coeffs); + } + + FT squared_length() const { + FT lsq = length(); + return lsq * lsq; + } + + FT length() const { + return coeffs.norm(); + } + + void print() const + { + for(unsigned int i=0; i +autopoint operator* ( K k, autopoint const& p) +{ + return p * k; +} + +// matrix times autopoint +template +autopoint operator* ( Eigen::Matrix matrix_, autopoint const& p) +{ + Eigen::Matrix, Eigen::Dynamic,1> temp= matrix_*p.getCoefficients(); + return autopoint(temp); +} + + + +#endif // CARTESIAN_KERNEL_AUTOPOINT_H diff --git a/include/cartesian_geom/point.h b/include/cartesian_geom/point.h index a2209f4f5..b8c8e32b4 100644 --- a/include/cartesian_geom/point.h +++ b/include/cartesian_geom/point.h @@ -81,6 +81,7 @@ class point void set_dimension(const unsigned int dim) { d = dim; + coeffs.setZero(d); } void set_coord(const unsigned int i, FT coord) diff --git a/include/convex_bodies/orderpolytope.h b/include/convex_bodies/orderpolytope.h index 66854234b..2df5c6619 100644 --- a/include/convex_bodies/orderpolytope.h +++ b/include/convex_bodies/orderpolytope.h @@ -208,7 +208,32 @@ class OrderPolytope { std::pair ComputeInnerBall() { normalize(); - return ComputeChebychevBall(_A, b); + std::pair inner_ball; + #ifndef DISABLE_LPSOLVE + inner_ball = ComputeChebychevBall(_A, b); // use lpsolve library + #else + + if (inner_ball.second <= NT(0)) { + + NT const tol = 0.00000001; + std::tuple inner_ball = max_inscribed_ball(_A, b, 150, tol); + + // check if the solution is feasible + if (is_in(Point(std::get<0>(inner_ball))) == 0 || std::get<1>(inner_ball) < NT(0) || + std::isnan(std::get<1>(inner_ball)) || std::isinf(std::get<1>(inner_ball)) || + !std::get<2>(inner_ball) || is_inner_point_nan_inf(std::get<0>(inner_ball))) + { + inner_ball.second = -1.0; + } else + { + inner_ball.first = Point(std::get<0>(inner_ball)); + inner_ball.second = std::get<1>(inner_ball); + } + } + #endif + + return inner_ball; + } diff --git a/include/diagnostics/effective_sample_size.hpp b/include/diagnostics/effective_sample_size.hpp index aaf418529..c372eb696 100644 --- a/include/diagnostics/effective_sample_size.hpp +++ b/include/diagnostics/effective_sample_size.hpp @@ -68,7 +68,7 @@ VT effective_sample_size(MT const& samples, unsigned int &min_ess) { variance = NT(0); for (int j = 0; j < N; j++) { - variance += pow(normalized_sample_row[j], 2); + variance += std::pow(normalized_sample_row[j], 2); } variance *= (1.0 / N); diff --git a/include/diagnostics/print_diagnostics.hpp b/include/diagnostics/print_diagnostics.hpp index 91bd8b0ed..9e27f0bc7 100644 --- a/include/diagnostics/print_diagnostics.hpp +++ b/include/diagnostics/print_diagnostics.hpp @@ -42,14 +42,14 @@ void print_diagnostics(MT const& samples, unsigned int &min_ess, StreamType &str row_mean = samples.row(i).mean(); row_std = NT(0); for (int j = 0; j < N; j++) { - row_std += pow(samples(i, j) - row_mean, 2); + row_std += std::pow(samples(i, j) - row_mean, 2); } row_std = sqrt(row_std / N); vt.addRow(i + 1, row_mean, row_std, ess(i), intv_psrf(i)); } vt.print(stream); - std::cout << "interval_psrf = " << intv_psrf.maxCoeff() << "us" << std::endl; + stream << "interval_psrf = " << intv_psrf.maxCoeff() << "us" << std::endl; } diff --git a/include/generators/known_polytope_generators.h b/include/generators/known_polytope_generators.h index 050918ad0..8d014621d 100644 --- a/include/generators/known_polytope_generators.h +++ b/include/generators/known_polytope_generators.h @@ -17,7 +17,7 @@ /// The result can be either in V-representation (Vpoly=true) or in H-representation (V-poly-false) /// @tparam Polytope Type of returned polytope template -Polytope generate_cube(const unsigned int& dim, const bool& Vpoly) { +Polytope generate_cube(const unsigned int& dim, const bool& Vpoly,typename Polytope::NT scale=1) { typedef typename Polytope::MT MT; typedef typename Polytope::VT VT; @@ -30,7 +30,7 @@ Polytope generate_cube(const unsigned int& dim, const bool& Vpoly) { A.resize(2 * dim, dim); b.resize(2 * dim); for (unsigned int i = 0; i < dim; ++i) { - b(i) = 1.0; + b(i) = scale; for (unsigned int j = 0; j < dim; ++j) { if (i == j) { A(i, j) = 1.0; @@ -40,7 +40,7 @@ Polytope generate_cube(const unsigned int& dim, const bool& Vpoly) { } } for (unsigned int i = 0; i < dim; ++i) { - b(i + dim) = 1.0; + b(i + dim) = scale; for (unsigned int j = 0; j < dim; ++j) { if (i == j) { A(i + dim, j) = -1.0; diff --git a/include/integration/simple_MC_integration.hpp b/include/integration/simple_MC_integration.hpp index 58739650d..75f60a1c0 100644 --- a/include/integration/simple_MC_integration.hpp +++ b/include/integration/simple_MC_integration.hpp @@ -16,16 +16,17 @@ #include #include #include -#include "convex_bodies/hpolytope.h" + #include "Eigen/Eigen" +#include "convex_bodies/hpolytope.h" #include "generators/known_polytope_generators.h" -#include "boost_random_number_generator.hpp" +#include "generators/boost_random_number_generator.hpp" #include "cartesian_geom/cartesian_kernel.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "misc.h" +#include "misc/misc.h" typedef double NT; typedef Cartesian Kernel; diff --git a/include/ode_solvers/implicit_midpoint.hpp b/include/ode_solvers/implicit_midpoint.hpp index 71408e542..7efba90ec 100644 --- a/include/ode_solvers/implicit_midpoint.hpp +++ b/include/ode_solvers/implicit_midpoint.hpp @@ -53,16 +53,15 @@ inline std::vector operator-(const std::vector &v1, return v1 + v2 * (-1.0); } -template +template struct ImplicitMidpointODESolver { using VT = typename Polytope::VT; using MT = typename Polytope::MT; - using pts = std::vector; - using hamiltonian = Hamiltonian; + using pts = std::vector; + using hamiltonian = Hamiltonian; using Opts = opts; unsigned int dim; - NT eta; int num_steps = 0; NT t; @@ -75,17 +74,14 @@ struct ImplicitMidpointODESolver { func F; Polytope &P; Opts &options; - VT nu; - + MT nu; + int num_runs = 0; hamiltonian ham; - bool done; #ifdef TIME_KEEPING std::chrono::time_point start, end; - std::chrono::duration DU_duration = - std::chrono::duration::zero(); - std::chrono::duration approxDK_duration = - std::chrono::duration::zero(); + std::chrono::duration DU_duration = std::chrono::duration::zero(); + std::chrono::duration approxDK_duration = std::chrono::duration::zero(); #endif ImplicitMidpointODESolver(NT initial_time, NT step, @@ -101,44 +97,46 @@ struct ImplicitMidpointODESolver { options(user_options), ham(hamiltonian(boundaries)) { - dim = xs[0].dimension(); + dim = xs[0].rows(); }; void step(int k, bool accepted) { + num_runs++; pts partialDerivatives; #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif partialDerivatives = ham.DU(xs); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); DU_duration += end - start; #endif xs = xs + partialDerivatives * (eta / 2); xs_prev = xs; done = false; - nu = VT::Zero(P.equations()); + nu = MT::Zero(P.equations(), simdLen); for (int i = 0; i < options.maxODEStep; i++) { pts xs_old = xs; pts xmid = (xs_prev + xs) / 2.0; #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif partialDerivatives = ham.approxDK(xmid, nu); + #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); approxDK_duration += end - start; #endif xs = xs_prev + partialDerivatives * (eta); - NT dist = ham.x_norm(xmid, xs - xs_old) / eta; - NT maxdist = dist; + VT dist = ham.x_norm(xmid, xs - xs_old) / eta; + NT maxdist = dist.maxCoeff(); //If the estimate does not change terminate if (maxdist < options.implicitTol) { done = true; num_steps = i; break; - //If the estimate is very bad sample another velocity - } else if (maxdist > options.convergence_limit) { + //If the estimate is very bad, sample another velocity + } else if (maxdist > options.convergence_bound) { xs = xs * std::nan("1"); done = true; num_steps = i; @@ -146,11 +144,11 @@ struct ImplicitMidpointODESolver { } } #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif partialDerivatives = ham.DU(xs); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); DU_duration += end - start; #endif xs = xs + partialDerivatives * (eta / 2); @@ -163,16 +161,15 @@ struct ImplicitMidpointODESolver { } } - Point get_state(int index) { return xs[index]; } + MT get_state(int index) { return xs[index]; } - void set_state(int index, Point p) { xs[index] = p; } - void print_state() { + void set_state(int index, MT p) { xs[index] = p; } + template + void print_state(StreamType &stream) { for (int j = 0; j < xs.size(); j++) { - std::cerr << "state " << j << ": "; - for (unsigned int i = 0; i < xs[j].dimension(); i++) { - std::cerr << xs[j][i] << " "; - } - std::cerr << '\n'; + stream << "state " << j << ": \n"; + stream << xs[j]; + stream << '\n'; } } }; diff --git a/include/ode_solvers/leapfrog.hpp b/include/ode_solvers/leapfrog.hpp index 4c1f299b0..b7f2724b4 100644 --- a/include/ode_solvers/leapfrog.hpp +++ b/include/ode_solvers/leapfrog.hpp @@ -56,6 +56,8 @@ struct LeapfrogODESolver { pts xs; pts xs_prev; + Point grad_x; + MT _AA; std::pair pbpair; @@ -69,11 +71,11 @@ struct LeapfrogODESolver { eta(step), eta0(step), t(initial_time), F(oracle), Ks(boundaries), xs(initial_state), adaptive(adaptive_) { dim = xs[0].dimension(); _update_parameters = update_parameters(); + grad_x.set_dimension(dim); initialize(); }; - void initialize() { for (unsigned int i = 0; i < xs.size(); i++) { VT ar, av; @@ -88,7 +90,6 @@ struct LeapfrogODESolver { Av.push_back(av); lambda_prev.push_back(NT(0)); } - //step(); } void disable_adaptive() { @@ -101,27 +102,28 @@ struct LeapfrogODESolver { void step(int k, bool accepted) { num_steps++; - if (adaptive) eta = (eta0 * num_steps) / (num_steps + num_reflections); xs_prev = xs; unsigned int x_index, v_index, it; t += eta; + Point y; for (unsigned int i = 1; i < xs.size(); i += 2) { - //pbpair.second = -1; + x_index = i - 1; v_index = i; // v' <- v + eta / 2 F(x) - Point z = F(v_index, xs_prev, t); - z = (eta / 2) * z; - xs[v_index] = xs[v_index] + z; + if (k == 0 && !accepted) { + grad_x = F(v_index, xs_prev, t); + } + xs[v_index] += (eta / 2) * grad_x; // x <- x + eta v' - Point y = xs[v_index]; + y = xs[v_index]; if (Ks[x_index] == NULL) { - xs[x_index] = xs_prev[x_index] + eta*y; + xs[x_index] += eta*y; } else { // Find intersection (assuming a line trajectory) between x and y @@ -173,10 +175,8 @@ struct LeapfrogODESolver { } // tilde v <- v + eta / 2 F(tilde x) - z = F(v_index, xs, t); - z = (eta / 2) * z; - xs[v_index] = xs[v_index] + z; - + grad_x = F(v_index, xs, t); + xs[v_index] += (eta / 2) * grad_x; } } @@ -202,6 +202,19 @@ struct LeapfrogODESolver { xs[index] = p; } + NT get_eta() { + return eta; + } + + void set_eta(NT &eta_) { + eta = eta_; + eta0 = eta_; + } + + bounds get_bounds() { + return Ks; + } + }; diff --git a/include/ode_solvers/oracle_autodiff_functors.hpp b/include/ode_solvers/oracle_autodiff_functors.hpp new file mode 100644 index 000000000..20500141f --- /dev/null +++ b/include/ode_solvers/oracle_autodiff_functors.hpp @@ -0,0 +1,94 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2024 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis + +// Licensed under GNU LGPL.3, see LICENCE file + +#ifndef ODE_SOLVERS_ORACLE_AUTODIFF_FUNCTORS_HPP +#define ODE_SOLVERS_ORACLE_AUTODIFF_FUNCTORS_HPP + +#include "Eigen/Eigen" +#include +#include +#include "cartesian_geom/cartesian_kernel.h" +#include "cartesian_geom/autopoint.h" + +struct AutoDiffFunctor { + + template + struct parameters { + unsigned int order; + NT L; // Lipschitz constant for gradient + NT m; // Strong convexity constant + NT kappa; // Condition number + Eigen::Matrix data; + parameters() : order(2), L(4), m(4), kappa(1){}; + }; + + template + struct FunctionFunctor_internal { + using Autopoint = autopoint; + using Coeff = typename autopoint::Coeff; + using FT = typename autopoint::FT; + using Point = typename Cartesian::Point; + + static std::function &)> pdf; + + FT static result_internal(const Coeff &x, const Eigen::Matrix &data){ + return pdf(x, data); // + } + + // external interface + Point static differentiate(Point const &x0, const Eigen::Matrix &data) { + Autopoint x = Autopoint(x0.getCoefficients()); // cast into autopoint + auto x1 = x.getCoefficients(); + Coeff y = autodiff::gradient(result_internal, autodiff::wrt(x1), autodiff::at(x1, data)); + auto result = y.template cast(); + return -1 * Point(result); + } + + NT static result(Point const &x0, const Eigen::Matrix &data) { + Autopoint x = Autopoint(x0.getCoefficients()); // cast to autopoint + auto x1 = x.getCoefficients(); + return result_internal(x1, data).val(); + } + }; + + template + struct GradientFunctor { + using NT = typename Point::FT; + + FunctionFunctor_internal F; + parameters ¶ms; + + GradientFunctor(parameters ¶ms_) : params(params_){}; + + // The index i represents the state vector index + Point operator()(unsigned int const &i, std::vector const &xs, NT const &t) const { + // std::cout<<"calling gradient functor"< + struct FunctionFunctor { + using NT = typename Point::FT; + parameters ¶ms; + + FunctionFunctor(parameters ¶ms_) : params(params_){}; + // The index i represents the state vector index + FunctionFunctor_internal F; + + NT operator()(Point const &x) const { + return F.result(x, params.data); + } + }; +}; + +#endif //ODE_SOLVERS_ORACLE_AUTODIFF_FUNCTORS_HPP \ No newline at end of file diff --git a/include/ode_solvers/oracle_functors.hpp b/include/ode_solvers/oracle_functors.hpp index 056e96c3a..35fc8887b 100644 --- a/include/ode_solvers/oracle_functors.hpp +++ b/include/ode_solvers/oracle_functors.hpp @@ -142,11 +142,11 @@ struct IsotropicQuadraticFunctor { return xs[i + 1]; // returns derivative } } - - Point operator()(Point const&x){ - Point y = (-params.alpha)*x; - return y; - } + + Point operator()(Point const &x){ + Point y = (-params.alpha) * x; + return y; + } }; @@ -243,7 +243,7 @@ struct IsotropicLinearFunctor { }; -struct LinearProgramFunctor { +struct ExponentialFunctor { // Sample from linear program c^T x (exponential density) template < @@ -256,8 +256,10 @@ struct LinearProgramFunctor { NT m; // Strong convexity constant NT kappa; // Condition number Point c; // Coefficients of LP objective + NT a; // Inverse variance - parameters(Point c_) : order(2), L(1), m(1), kappa(1), c(c_) {}; + parameters(Point c_) : order(2), L(1), m(1), kappa(1), c(c_), a(1.0) {}; + parameters(Point c_, NT a_) : order(2), L(1), m(1), kappa(1), c(c_), a(a_) {}; }; @@ -277,7 +279,7 @@ struct LinearProgramFunctor { Point operator() (unsigned int const& i, pts const& xs, NT const& t) const { if (i == params.order - 1) { Point y(params.c); - return (-1.0) * y; + return (-params.a) * y; } else { return xs[i + 1]; // returns derivative } @@ -298,7 +300,7 @@ struct LinearProgramFunctor { // The index i represents the state vector index NT operator() (Point const& x) const { - return x.dot(params.c); + return params.a * x.dot(params.c); } }; diff --git a/include/ode_solvers/oracle_functors_rcpp.hpp b/include/ode_solvers/oracle_functors_rcpp.hpp deleted file mode 100644 index 558ac1b07..000000000 --- a/include/ode_solvers/oracle_functors_rcpp.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis -// Copyright (c) 2020-2020 Marios Papachristou - -// Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -// Licensed under GNU LGPL.3, see LICENCE file - -#ifndef ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP -#define ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP - -enum ode_solvers { - no_solver, - leapfrog, - euler, - runge_kutta, - richardson, - collocation -}; - -// Holds Oracle Functor that wraps an R function via RCpp -// The R function is provided as an Rcpp::Function object -// The functor uses Rcpp::as and Rcpp::wrap to do the conversion, -// call the oracle, and convert the results back to C++ -struct RcppFunctor { - - template < - typename NT - > - struct parameters { - NT L; // Lipschitz constant of gradient - NT m; // Strong-convexity parameter - NT eta; // Step-size (if defined by user) - NT kappa; // Condition number - unsigned int order; // Order of ODE functor - - parameters( - NT L_, - NT m_, - NT eta_, - unsigned int order_=2 - ) : - L(L_), - m(m_), - eta(eta_), - kappa(L_ / m_), - order(order_) - {} - }; - - // Log-probability gradient functor - template - < - typename Point - > - struct GradientFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - typedef std::vector pts; - - parameters params; - Rcpp::Function neg_grad_f; // Negative gradient as an Rcpp::Function - bool negate; - - GradientFunctor( - parameters params_, - Rcpp::Function neg_grad_f_, - bool negate_=true): - params(params_), - neg_grad_f(neg_grad_f_), - negate(negate_) - {}; - - // The index i represents the state vector index - Point operator() (unsigned int const& i, pts const& xs, NT const& t) const { - if (i == params.order - 1) { - // Convert point to Rcpp::NumericMatrix - - VT y = Rcpp::as(neg_grad_f(Rcpp::wrap(xs[0].getCoefficients()))); - - Point z(y); - - if (negate) z = (-1.0) * z; - - // Return result as Point - return z; - } else { - return xs[i + 1]; // returns derivative - } - } - - }; - - // Negative log-probability functor - template - < - typename Point - > - struct FunctionFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - - parameters params; - Rcpp::Function negative_logprob; - - FunctionFunctor( - parameters params_, - Rcpp::Function negative_logprob_) : - params(params_), - negative_logprob(negative_logprob_) - {}; - - NT operator() (Point const& x) const { - return Rcpp::as(negative_logprob(Rcpp::wrap(x.getCoefficients()))); - } - - }; - -}; - -#endif diff --git a/include/preprocess/crhmc/analytic_center.h b/include/preprocess/crhmc/analytic_center.h index 35d4349aa..7124626b4 100644 --- a/include/preprocess/crhmc/analytic_center.h +++ b/include/preprocess/crhmc/analytic_center.h @@ -27,14 +27,6 @@ #endif const size_t chol_k2 = (SIMD_LEN == 0) ? 1 : SIMD_LEN; -using NT = double; -using MT = Eigen::Matrix; -using VT = Eigen::Matrix; -using SpMat = Eigen::SparseMatrix; -using CholObj = PackedChol; -using Triple = Eigen::Triplet; -using Tx = FloatArray; -using Opts = opts; /*This function computes the analytic center of the polytope*/ //And detects additional constraint that need to be added // x - It outputs the minimizer of min f(x) subjects to {Ax=b} @@ -43,9 +35,12 @@ using Opts = opts; // because of the dom(f), the algorithm will detect the collapsed dimension // and output the detected constraint C x = d // d - detected constraint vector -template +template std::tuple analytic_center(SpMat const &A, VT const &b, Polytope &f, Opts const &options, VT x = VT::Zero(0, 1)) { + using CholObj = typename Polytope::CholObj; + using Triple = typename Polytope::Triple; + using Tx = typename Polytope::Tx; // initial conditions int n = A.cols(); int m = A.rows(); @@ -65,7 +60,7 @@ std::tuple analytic_center(SpMat const &A, VT const &b, Polytope std::vector idx; CholObj solver = CholObj(transform_format(A)); - + solver.accuracyThreshold = 0; for (int iter = 0; iter < options.ipmMaxIter; iter++) { std::pair pair_analytic_oracle = f.analytic_center_oracle(x); @@ -159,14 +154,14 @@ std::tuple analytic_center(SpMat const &A, VT const &b, Polytope std::pair pboundary = f.barrier.boundary(x); VT A_ = pboundary.first; VT b_ = pboundary.second; - A_ = A_(idx); std::vector sparseIdx; for (int i = 0; i < idx.size(); i++) { - sparseIdx.push_back(Triple(i, i, A_(i))); + sparseIdx.push_back(Triple(i, idx[i], A_(idx[i]))); } C.setFromTriplets(sparseIdx.begin(), sparseIdx.end()); - d = b_(idx); + d.resize(idx.size(), 1); + copy_indicies(d, b_, idx); } else { diff --git a/include/preprocess/crhmc/constraint_problem.h b/include/preprocess/crhmc/constraint_problem.h new file mode 100644 index 000000000..829315059 --- /dev/null +++ b/include/preprocess/crhmc/constraint_problem.h @@ -0,0 +1,81 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis +// Copyright (c) 2022-2022 Ioannis Iakovidis + +// Contributed and/or modified by Ioannis Iakovidis, as part of Google Summer of +// Code 2022 program. + +// Licensed under GNU LGPL.3, see LICENCE file + +#ifndef CONSTRAINT_PROBLEM_H +#define CONSTRAINT_PROBLEM_H +#include "Eigen/Eigen" +/*Input structure: With this the user can define a polytope sampling problem*/ +template +class constraint_problem { +public: + using Type = typename Point::FT; + using PointType = Point; + using VT = Eigen::Matrix; + using MT = MatrixType; +private: + unsigned int num_vars; // num_vars of the original problem + MatrixType Aeq; // Matrix of coefficients for the equality constraints + VT beq; // Right hand side of the equality constraints + MatrixType Aineq; // Matrix of coefficients for the inequality constraints + VT bineq; // Right hand side of the inequality constraints + VT lb; // lb on the output coordinates preset to -1e9 + VT ub; // ub on the output coordinates preset to +1e9 + Type inf = 1e9; +public: + /*Constructors for different input instances*/ + constraint_problem(const int dim, MT const &Aeq_, VT const &beq_, MT const &Aineq_, + VT const &bineq_, VT const &lb_, VT const &ub_) + : num_vars(dim), Aeq(Aeq_), beq(beq_), Aineq(Aineq_), bineq(bineq_), + lb(lb_), ub(ub_) { + } + + constraint_problem(const int dim) { + num_vars = dim; + init(num_vars); + } + + + void init(int num_vars) { + Aineq.resize(0, num_vars); + Aeq.resize(0, num_vars); + bineq.resize(0, 1); + beq.resize(0, 1); + lb = -VT::Ones(num_vars) * inf; + ub = VT::Ones(num_vars) * inf; + } + void set_equality_constraints(MT const &Aeq_, VT const &beq_){ + Aeq = Aeq_; + beq = beq_; + } + void set_inequality_constraints(MT const &Aineq_, VT const &bineq_){ + Aineq = Aineq_; + bineq = bineq_; + } + void set_bounds(VT const &lb_, VT const &ub_){ + lb = lb_; + ub = ub_; + } + std::pair get_equations(){ + return std::make_pair(Aeq,beq); + } + std::pair get_inequalities(){ + return std::make_pair(Aineq,bineq); + } + std::pair get_bounds(){ + return std::make_pair(lb,ub); + } + unsigned int dimension(){ + return num_vars; + } + +}; + +#endif diff --git a/include/preprocess/crhmc/crhmc_input.h b/include/preprocess/crhmc/crhmc_input.h index 1a674f1e4..05f61c4b8 100644 --- a/include/preprocess/crhmc/crhmc_input.h +++ b/include/preprocess/crhmc/crhmc_input.h @@ -17,12 +17,20 @@ #define CRHMC_INPUT_H #include "Eigen/Eigen" #include "opts.h" +#include "convex_bodies/hpolytope.h" +#include "preprocess/crhmc/constraint_problem.h" /*0 funciton handles are given as a reference in case the user gives no function. Then the uniform function is implied*/ template struct ZeroFunctor { + using Type = typename Point::FT; Point operator()(Point const &x) const { return Point(x.dimension()); } + struct parameters { + Type L=1; + Type eta=1; + }; + struct parameters params; }; template struct ZeroScalarFunctor @@ -45,9 +53,11 @@ class crhmc_input ZeroScalarFunctor zerosf; public: + using MT = MatrixType; using Func = func; using Grad = grad; using Hess = hess; + using point= Point; MatrixType Aineq; // Matrix of coefficients for the inequality constraints VT bineq; // Right hand side of the inequality constraints MatrixType Aeq; // Matrix of coefficients for the equality constraints @@ -62,37 +72,38 @@ class crhmc_input bool fHandle; // whether f is handle or not bool dfHandle; // whether df is handle or not bool ddfHandle; // whether ddf is handle or not + unsigned int dimension; // dimension of the original problem const Type inf = options.max_coord + 1; // helper for barrier handling /*Constructors for different input instances*/ - crhmc_input(int dimension, func &function, grad &g, hess &h) + crhmc_input(int dim, func &function, grad &g, hess &h) : f(function), df(g), ddf(h) - { + { dimension=dim; fZero = false; fHandle = true; dfHandle = true; ddfHandle = true; init(dimension); } - crhmc_input(int dimension, func &function) + crhmc_input(int dim, func &function) : f(function), df(zerof), ddf(zerof) - { + { dimension=dim; fZero = false; fHandle = true; dfHandle = false; ddfHandle = false; init(dimension); } - crhmc_input(int dimension, func &function, grad &g) + crhmc_input(int dim, func &function, grad &g) : f(function), df(g), ddf(zerof) - { + { dimension=dim; fZero = false; fHandle = true; dfHandle = true; ddfHandle = false; init(dimension); } - crhmc_input(int dimension) : f(zerosf), df(zerof), ddf(zerof) - { + crhmc_input(int dim) : f(zerosf), df(zerof), ddf(zerof) + { dimension=dim; fZero = true; fHandle = false; dfHandle = false; @@ -110,4 +121,52 @@ class crhmc_input ub = VT::Ones(dimension) * inf; } }; +#include + +template < + typename Input, typename Polytope, typename Func, typename Grad, typename Hess, + typename std::enable_if>::value>::type * = nullptr> +inline Input convert2crhmc_input(Polytope &P, Func &f, Grad &g, Hess &h) { + int dimension = P.dimension(); + Input input = Input(dimension, f, g, h); + if (std::is_same< + Hess, ZeroFunctor>::value){ + input.ddfHandle=false; + } + input.Aineq = P.get_mat(); + input.bineq = P.get_vec(); + return input; +} + +template >::value>::type + * = nullptr> +inline Input convert2crhmc_input(Polytope &P, Func &f, Grad &g, Hess &h) { + int dimension = P.dimension(); + Input input = Input(dimension, f, g, h); + if (std::is_same< + Hess, ZeroFunctor>::value){ + input.ddfHandle=false; + } + std::tie(input.Aineq, input.bineq) = P.get_inequalities(); + std::tie(input.Aeq, input.beq) = P.get_equations(); + std::tie(input.lb, input.ub) = P.get_bounds(); + return input; +} +template >::value && + !std::is_same>::value>:: + type * = nullptr> +inline Input convert2crhmc_input(Polytope &P, Func &f, Grad &g, Hess &h) { + /*CRHMC works only for H-polytopes and constraint_problems for now*/ + int dimension = 0; + Input input = Input(dimension, f, g, h); + return input; +} #endif diff --git a/include/preprocess/crhmc/crhmc_problem.h b/include/preprocess/crhmc/crhmc_problem.h index 68ccb25e5..641b5c615 100644 --- a/include/preprocess/crhmc/crhmc_problem.h +++ b/include/preprocess/crhmc/crhmc_problem.h @@ -60,6 +60,7 @@ class crhmc_problem { using Func = typename Input::Func; using Grad = typename Input::Grad; using Hess = typename Input::Hess; + using Crhmc_problem=crhmc_problem; unsigned int _d; // dimension // Problem variables Ax=b st lb<=x<=ub @@ -93,15 +94,20 @@ class crhmc_problem { bool fHandle; // whether f is handle or not bool dfHandle; // whether df is handle or not bool ddfHandle; // whether ddf is handle or not + /*Invalid polytope variables*/ + bool terminate=false; + std::string terminate_message; #ifdef TIME_KEEPING //Timing information std::chrono::duration rescale_duration, sparsify_duration, reordering_duration, rm_rows_duration, rm_fixed_vars_duration, ex_collapsed_vars_duration, shift_barrier_duration, lewis_center_duration; #endif - const NT inf = options.max_coord + 1; // helper for barrier handling + const NT inf = options.max_coord; // helper for barrier handling + const NT barrier_bound = 1e7; int equations() const { return Asp.rows(); } int dimension() const { return Asp.cols(); } + int nnz() const { return Asp.nonZeros(); } // Remove varibles that have width under some tolerance int remove_fixed_variables(const NT tol = 1e-12) { @@ -109,6 +115,7 @@ class crhmc_problem { int n = Asp.cols(); VT d = estimate_width(); CholObj solver = CholObj(transform_format(Asp)); + solver.accuracyThreshold = 0; VT w = VT::Ones(n, 1); solver.decompose((Tx *)w.data()); VT out_vector = VT(m, 1); @@ -133,7 +140,16 @@ class crhmc_problem { SpMat S = SpMat(n, freeIndices.size()); S.setFromTriplets(freeIndices.begin(), freeIndices.end()); append_map(S, x); - barrier.set_bound(barrier.lb(indices), barrier.ub(indices)); + copy_indicies(barrier.lb, barrier.lb, indices); + copy_indicies(barrier.ub, barrier.ub, indices); + barrier.lb.conservativeResize(indices.size()); + barrier.ub.conservativeResize(indices.size()); + + barrier.set_bound(barrier.lb, barrier.ub); + if (!isempty_center) { + copy_indicies(center, center, indices); + center.conservativeResize(indices.size()); + } return 1; } return 0; @@ -143,20 +159,20 @@ class crhmc_problem { SpMat Ac; VT bc; if (isempty_center) { - std::tie(center, Ac, bc) = analytic_center(Asp, b, *this, options); + std::tie(center, Ac, bc) = analytic_center(Asp, b, *this, options); isempty_center = false; } else { std::tie(center, Ac, bc) = - analytic_center(Asp, b, *this, options, center); + analytic_center(Asp, b, *this, options, center); analytic_ctr=center; } if (Ac.rows() == 0) { return 0; } - SpMat _A = Asp; - sparse_stack_v(Ac, _A, Asp); - b.resize(b.rows() + bc.rows(), 1); - b << bc, b; + SpMat _A = SpMat(Asp); + sparse_stack_v(_A, Ac, Asp); + b.conservativeResize(b.rows() + bc.rows(), 1); + b.bottomRows(bc.rows()) = bc; return 1; } // Rescale the polytope for numerical stability @@ -273,68 +289,64 @@ class crhmc_problem { // Reorder the polytope accordint to the AMD Reordering for better sparsity // pattern in the Cholesky decomposition void reorder() { - if (!options.EnableReordering) { + if (!options.EnableReordering || Asp.rows()*Asp.cols() < options.maxNZ) { return; } - Asp.prune(0.0); - Asp.makeCompressed(); - int m = Asp.rows(); - SpMat H; - H = Asp * SpMat(Asp.transpose()) + MT::Identity(m, m); - H.makeCompressed(); - PM permed = permuteMatAMD(H); - H = permed * H * permed.transpose(); - PM post_perm = postOrderPerm(H); - PM perm = permed * post_perm; - Asp = perm * Asp; - b = perm * b; + fillin_reduce(Asp,b); } //Using the Cholesky decomposition remove dependent rows in the systen Asp*x=b int remove_dependent_rows(NT tolerance = 1e-12, NT infinity = 1e+64) { - //this approach does not work with 0 collumns - remove_zero_rows(Asp); + //this approach does not work with 0 rows + remove_zero_rows(Asp, b); int m = Asp.rows(); int n = Asp.cols(); VT v = VT(m); VT w = VT::Ones(n, 1); CholObj solver = CholObj(transform_format(Asp)); + solver.accuracyThreshold = 0; solver.decompose((Tx *)w.data()); solver.diagL((Tx *)v.data()); - std::vector indices; + std::vector indices(m, false); + std::vector idx; + bool changed = false; for (int i = 0; i < m; i++) { if ((v(i) > tolerance) && (v(i) < infinity)) { - indices.push_back(i); + indices[i] = true; + idx.push_back(i); + }else{ + changed=true; } } - if (indices.size() == m) { + if (!changed) { return 0; } - Asp = A(indices, Eigen::all).sparseView(); - b = b(indices); + remove_rows(Asp, indices); + copy_indicies(b, b, idx); + b.conservativeResize(idx.size(), 1); return 1; } //Apply number of operations that simplify the problem void simplify() { #ifdef TIME_KEEPING std::chrono::time_point start, end; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif rescale(); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); rescale_duration += end - start; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif splitDenseCols(options.maxNZ); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); sparsify_duration += end - start; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif reorder(); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); reordering_duration += end - start; #endif int changed = 1; @@ -342,41 +354,45 @@ class crhmc_problem { while (changed) { changed = 0; #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif changed += remove_dependent_rows(); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); rm_rows_duration += end - start; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif changed += remove_fixed_variables(); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); rm_fixed_vars_duration += end - start; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif reorder(); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); reordering_duration += end - start; #endif } #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif changed += extract_collapsed_variables(); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); ex_collapsed_vars_duration += end - start; #endif } } - VT estimate_width() { + VT estimate_width(bool use_center=false) { int n = Asp.cols(); VT hess = VT::Ones(n, 1); + if(use_center){ + std::tie(std::ignore, hess)=analytic_center_oracle(center); + } CholObj solver = CholObj(transform_format(Asp)); + solver.accuracyThreshold = 0; solver.decompose((Tx *)hess.data()); VT w_vector(n, 1); solver.leverageScoreComplement((Tx *)w_vector.data()); @@ -386,75 +402,110 @@ class crhmc_problem { return tau; } - void print(std::string const message = "Printing Sparse problem") { - std::cerr << "----------------" << message << "--------------" << '\n'; - std::cerr << "(m,n) = " << equations() << " , " << dimension() + template + void print(StreamType &stream, std::string const message = "Printing Sparse problem") { + stream << "----------------" << message << "--------------" << '\n'; + stream << "(m,n) = " << equations() << " , " << dimension() << " nnz= " << Asp.nonZeros() << "\n"; if (equations() > 20 || dimension() > 20) { - std::cerr << "too big for complete visulization\n"; + stream << "too big for complete visulization\n"; return; } - std::cerr << "A=\n"; + stream << "A=\n"; - std::cerr << MT(Asp); - std::cerr << "\n"; + stream << MT(Asp); + stream << "\n"; - std::cerr << "b=\n"; - std::cerr << b; - std::cerr << "\n"; + stream << "b=\n"; + stream << b; + stream << "\n"; - std::cerr << "lb=\n"; - std::cerr << barrier.lb; - std::cerr << "\n"; + stream << "lb=\n"; + stream << barrier.lb; + stream << "\n"; - std::cerr << "ub=\n"; - std::cerr << barrier.ub; - std::cerr << "\n"; + stream << "ub=\n"; + stream << barrier.ub; + stream << "\n"; - std::cerr << "T=\n"; - std::cerr << MT(T); - std::cerr << "\n"; + stream << "T=\n"; + stream << MT(T); + stream << "\n"; - std::cerr << "y=\n"; - std::cerr << y; - std::cerr << "\n"; + stream << "y=\n"; + stream << y; + stream << "\n"; - std::cerr << "center=\n"; - std::cerr << center; - std::cerr << "\n"; + stream << "center=\n"; + stream << center; + stream << "\n"; } - void print(const char *fileName) { - std::ofstream myfile; - myfile.open(fileName); - myfile << Asp.rows() << " " << Asp.cols() << "\n"; - - myfile << MT(Asp); - myfile << "\n"; - myfile << "\n"; - - myfile << b; - myfile << "\n"; - myfile << "\n"; - - myfile << barrier.lb; - myfile << "\n"; - myfile << "\n"; - - myfile << barrier.ub; - myfile << "\n"; - myfile << "\n"; - - myfile << MT(T); - myfile << "\n"; - myfile << "\n"; - - myfile << y; - myfile << "\n"; - myfile << "\n"; - - myfile << center; - } + void make_format(Input const &input, MT const &S) { + nP = input.Aeq.cols(); + int nIneq = input.Aineq.rows(); + int nEq = input.Aeq.rows(); + A.resize(nEq + nIneq, nP + nIneq); + A << input.Aeq, MT::Zero(nEq, nIneq), input.Aineq, MT::Identity(nIneq, nIneq); + b.resize(nEq + nIneq, 1); + b << input.beq, input.bineq; + lb.resize(nP + nIneq, 1); + ub.resize(nP + nIneq, 1); + lb << input.lb, MT::Zero(nIneq, 1); + ub << input.ub, MT::Ones(nIneq, 1) * inf; + Asp.resize(nEq + nIneq, nP + nIneq); + int n = dimension(); + /*Move lb=ub to Ax=b*/ + for (int i = 0; i < n; i++) { + if (doubleVectorEqualityComparison(lb(i), ub(i))) { + MT temp = MT::Zero(1, n); + temp(i) = 1; + A.conservativeResize(A.rows() + 1, A.cols()); + A.row(A.rows() - 1) = temp; + b.conservativeResize(b.rows() + 1); + b(b.rows() - 1) = (lb(i) + ub(i)) / 2; + lb(i) = -inf; + ub(i) = inf; + } + } + Asp = A.sparseView(); + } + void make_format(Input const &input, SpMat const &S) { + nP = input.Aeq.cols(); + int nIneq = input.Aineq.rows(); + int nEq = input.Aeq.rows(); + Asp.resize(nEq + nIneq, nP + nIneq); + SpMat B = SpMat(input.Aeq); + SpMat C = SpMat(input.Aineq); + B.conservativeResize(nEq, nIneq + nP); + SpMat temp = SpMat(nIneq, nIneq); + temp.setIdentity(); + sparse_stack_h_inplace(C, temp); + sparse_stack_v(B, C, Asp); + b.resize(nEq + nIneq, 1); + b << input.beq, input.bineq; + lb.resize(nP + nIneq, 1); + ub.resize(nP + nIneq, 1); + lb << input.lb, MT::Zero(nIneq, 1); + ub << input.ub, MT::Ones(nIneq, 1) * inf; + int n = dimension(); + /*Move lb=ub to Ax=b*/ + for (int i = 0; i < n; i++) { + if (doubleVectorEqualityComparison(lb(i), ub(i))) { + B.resize(Asp.rows(), Asp.cols()); + B = SpMat(Asp); + MT temp = MT::Zero(1, n); + temp(i) = 1; + C = temp.sparseView(); + sparse_stack_v(B, C, Asp); + b.conservativeResize(b.rows() + 1); + b(b.rows() - 1) = (lb(i) + ub(i)) / 2; + lb(i) = -inf; + ub(i) = inf; + } + } + Asp.makeCompressed(); + } //Class constructor crhmc_problem(Input const &input, Opts _options = Opts()) : options(_options), func(input.f), df(input.df), ddf(input.ddf), @@ -467,41 +518,13 @@ class crhmc_problem { std::chrono::duration::zero(); #endif - nP = input.Aeq.cols(); - int nIneq = input.Aineq.rows(); - int nEq = input.Aeq.rows(); - A.resize(nEq + nIneq, nP + nIneq); - A << input.Aeq, MT::Zero(nEq, nIneq), input.Aineq, - MT::Identity(nIneq, nIneq); - b.resize(nEq + nIneq, 1); - b << input.beq, input.bineq; - lb.resize(nP + nIneq, 1); - ub.resize(nP + nIneq, 1); - lb << input.lb, MT::Zero(nIneq, 1); - ub << input.ub, MT::Ones(nIneq, 1) * inf; - Asp.resize(nEq + nIneq, nP + nIneq); + make_format(input, input.Aeq); PreproccessProblem(); } // Initialization funciton void PreproccessProblem() { int n = dimension(); - /*Move lb=ub to Ax=b*/ - for (int i = 0; i < n; i++) { - if (doubleVectorEqualityComparison(lb(i), ub(i))) { - MT temp = MT::Zero(1, n); - temp(i) = 1; - A.conservativeResize(A.rows() + 1, A.cols()); - A.row(A.rows() - 1) = temp; - b.conservativeResize(b.rows() + 1); - b(b.rows() - 1) = (lb(i) + ub(i)) / 2; - lb(i) = -inf; - ub(i) = inf; - } - } - - barrier.set_bound(lb.cwiseMax(-1e7), ub.cwiseMin(1e7)); - - Asp = A.sparseView(); + barrier.set_bound(lb.cwiseMax(-barrier_bound), ub.cwiseMin(barrier_bound)); NT tol = std::numeric_limits::epsilon(); Asp.prune(tol, tol); /*Update the transformation Tx + y*/ @@ -523,36 +546,31 @@ class crhmc_problem { simplify(); #ifdef TIME_KEEPING std::chrono::time_point start, end; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif if (isempty_center) { std::tie(center, std::ignore, std::ignore) = - analytic_center(Asp, b, *this, options); + analytic_center(Asp, b, *this, options); isempty_center = false; } shift_barrier(center); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); shift_barrier_duration += end - start; #endif reorder(); - width = estimate_width(); - if (width.maxCoeff() > 1e9) { - std::cerr << "Domain seems to be unbounded. Either add a Gaussian term " - "via f, df, ddf or add bounds to variable via lb and ub." - << '\n'; - exit(1); - } + width = estimate_width(true); // Recenter again and make sure it is feasible VT hess; #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif std::tie(center, std::ignore, std::ignore, w_center) = - lewis_center(Asp, b, *this, options, center); + lewis_center(Asp, b, *this, options, center); std::tie(std::ignore, hess) = lewis_center_oracle(center, w_center); CholObj solver = CholObj(transform_format(Asp)); + solver.accuracyThreshold = 0; VT Hinv = hess.cwiseInverse(); solver.decompose((Tx *)Hinv.data()); VT out(equations(), 1); @@ -560,86 +578,106 @@ class crhmc_problem { solver.solve((Tx *)input.data(), (Tx *)out.data()); center = center + (Asp.transpose() * out).cwiseProduct(Hinv); #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); lewis_center_duration += end - start; #endif if ((center.array() > barrier.ub.array()).any() || (center.array() < barrier.lb.array()).any()) { - std::cerr << "Polytope:Infeasible. The algorithm cannot find a feasible " - "point.\n"; - exit(1); + terminate = true; + terminate_message = "Polytope:Infeasible. The algorithm cannot find a feasible point.\n"; + return; } + } #ifdef TIME_KEEPING - std::cerr << "Rescale completed in time, "; - std::cerr << rescale_duration.count() << " secs " << std::endl; - std::cerr << "Split dense columns completed in time, "; - std::cerr << sparsify_duration.count() << " secs " << std::endl; - std::cerr << "Reordering completed in time, "; - std::cerr << reordering_duration.count() << " secs " << std::endl; - std::cerr << "Removing dependent rows completed in time, "; - std::cerr << rm_rows_duration.count() << " secs " << std::endl; - std::cerr << "Removing fixed variables completed in time, "; - std::cerr << rm_fixed_vars_duration.count() << " secs " << std::endl; - std::cerr << "Extracting collapsed variables completed in time, "; - std::cerr << ex_collapsed_vars_duration.count() << " secs " << std::endl; - std::cerr << "Shift_barrier completed in time, "; - std::cerr << shift_barrier_duration.count() << " secs " << std::endl; - std::cerr << "Finding Center completed in time, "; - std::cerr << lewis_center_duration.count() << " secs " << std::endl; +template +void print_preparation_time(StreamType& stream){ + stream << "---Preparation Timing Information"<< std::endl; + stream << "Rescale completed in time, "; + stream << rescale_duration.count() << " secs " << std::endl; + stream << "Split dense columns completed in time, "; + stream << sparsify_duration.count() << " secs " << std::endl; + stream << "Reordering completed in time, "; + stream << reordering_duration.count() << " secs " << std::endl; + stream << "Removing dependent rows completed in time, "; + stream << rm_rows_duration.count() << " secs " << std::endl; + stream << "Removing fixed variables completed in time, "; + stream << rm_fixed_vars_duration.count() << " secs " << std::endl; + stream << "Extracting collapsed variables completed in time, "; + stream << ex_collapsed_vars_duration.count() << " secs " << std::endl; + stream << "Shift_barrier completed in time, "; + stream << shift_barrier_duration.count() << " secs " << std::endl; + stream << "Finding Center completed in time, "; + stream << lewis_center_duration.count() << " secs " << std::endl; +} #endif - } - // Gradient and hessian of for the analytic center std::pair analytic_center_oracle(VT const &x) { - VT g, h; + MT g, h; std::tie(std::ignore, g, h) = f_oracle(x); return std::make_pair(g + barrier.gradient(x), h + barrier.hessian(x)); } // Gradient and hessian of for the lewis center std::pair lewis_center_oracle(VT const &x, VT const &w) { - VT g, h; + MT g, h; std::tie(std::ignore, g, h) = f_oracle(x); return std::make_pair(g + w.cwiseProduct(barrier.gradient(x)), h + w.cwiseProduct(barrier.hessian(x))); } // Function that uses the transformation (T,y) to apply the function to the // original variables - std::tuple f_oracle(VT x) { - NT f; - VT g, h; + std::tuple f_oracle(MT const &x) { int n = x.rows(); + int m=x.cols(); + VT f=VT(m); + MT g=MT(n,m); + MT h=MT(n,m); if (fZero) { - f = 0; - g = VT::Zero(n); - h = VT::Zero(n); + f = VT::Zero(m); + g = MT::Zero(n,m); + h = MT::Zero(n,m); return std::make_tuple(f, g, h); } // Take the correpsonding point in the original space - VT z = VT::Zero(n); + MT z = MT::Zero(y.rows(), m); if (fHandle || dfHandle || ddfHandle) { - z(Tidx, Eigen::all) = Ta.cwiseProduct(x(Tidx, Eigen::all)) + y; + for(int k=0;k #include "PackedCSparse/SparseMatrix.h" #include #include @@ -93,6 +94,7 @@ void sparse_stack_h(const SparseMatrixType &left, const SparseMatrixType &right, [&](int i) { return i + left.nonZeros(); }); } +#include template void sparse_stack_h_inplace(SparseMatrixType &left, @@ -116,16 +118,13 @@ void sparse_stack_h_inplace(SparseMatrixType &left, { return i + leftnz; }); } -template -void remove_zero_rows(SparseMatrixType &A) -{ +template +void remove_zero_rows(SparseMatrixType &A, VectorType &b) { std::vector> tripletList; unsigned Ndata = A.cols(); unsigned Nbins = A.rows(); - for (int k = 0; k < A.outerSize(); ++k) - { - for (typename SparseMatrixType::InnerIterator it(A, k); it; ++it) - { + for (int k = 0; k < A.outerSize(); ++k) { + for (typename SparseMatrixType::InnerIterator it(A, k); it; ++it) { tripletList.push_back( Eigen::Triplet(it.row(), it.col(), it.value())); } @@ -134,20 +133,19 @@ void remove_zero_rows(SparseMatrixType &A) std::vector has_value(Nbins, false); for (auto tr : tripletList) has_value[tr.row()] = true; - if (std::all_of(has_value.begin(), has_value.end(), - [](bool v) - { return v; })) - { + [](bool v) { return v; })) { return; } // create map from old to new indices std::map row_map; unsigned new_idx = 0; for (unsigned old_idx = 0; old_idx < Nbins; old_idx++) - if (has_value[old_idx]) - row_map[old_idx] = new_idx++; - + if (has_value[old_idx]) { + row_map[old_idx] = new_idx; + b(new_idx) = b(old_idx); + new_idx++; + } // make new triplet list, dropping empty rows std::vector> newTripletList; newTripletList.reserve(Ndata); @@ -156,36 +154,15 @@ void remove_zero_rows(SparseMatrixType &A) Eigen::Triplet(row_map[tr.row()], tr.col(), tr.value())); // form new matrix and return - SparseMatrixType ret(new_idx, Ndata); - ret.setFromTriplets(newTripletList.begin(), newTripletList.end()); - A = SparseMatrixType(ret); + A.resize(new_idx, Ndata); + A.setFromTriplets(newTripletList.begin(), newTripletList.end()); + b.conservativeResize(new_idx); } template -void remove_rows(SparseMatrixType &A, std::vector indices) -{ - std::vector> tripletList; +void remove_rows(SparseMatrixType &A, std::vector ¬Removed) { unsigned Ndata = A.cols(); unsigned Nbins = A.rows(); - for (int k = 0; k < A.outerSize(); ++k) - { - for (typename SparseMatrixType::InnerIterator it(A, k); it; ++it) - { - tripletList.push_back( - Eigen::Triplet(it.row(), it.col(), it.value())); - } - } - - std::vector notRemoved(Nbins, false); - for (auto tr : indices) - notRemoved[tr] = true; - - if (std::all_of(notRemoved.begin(), notRemoved.end(), - [](bool v) - { return v; })) - { - return; - } // create map from old to new indices std::map row_map; unsigned new_idx = 0; @@ -193,17 +170,18 @@ void remove_rows(SparseMatrixType &A, std::vector indices) if (notRemoved[old_idx]) row_map[old_idx] = new_idx++; - // make new triplet list, dropping empty rows - std::vector> newTripletList; - newTripletList.reserve(Ndata); - for (auto tr : tripletList) - newTripletList.push_back( - Eigen::Triplet(row_map[tr.row()], tr.col(), tr.value())); - + std::vector> tripletList; + for (int k = 0; k < A.outerSize(); ++k) { + for (typename SparseMatrixType::InnerIterator it(A, k); it; ++it) { + if (notRemoved[it.row()]) { + tripletList.push_back( + Eigen::Triplet(row_map[it.row()], it.col(), it.value())); + } + } + } // form new matrix and return - SparseMatrixType ret(new_idx, Ndata); - ret.setFromTriplets(newTripletList.begin(), newTripletList.end()); - A = SparseMatrixType(ret); + A.resize(new_idx, Ndata); + A.setFromTriplets(tripletList.begin(), tripletList.end()); } template @@ -352,6 +330,17 @@ PM postOrderPerm(SparseMatrixType const &A) return post_perm; } +template +void fillin_reduce(SparseMatrixType &X,VectorType& b){ + SparseMatrixType I = SparseMatrixType(Eigen::VectorXd::Ones(X.rows()).asDiagonal()); + SparseMatrixType XX = X * X.transpose() + I; + XX.makeCompressed(); + Eigen::SimplicialLDLT> cholesky; + cholesky.analyzePattern(XX); + X = cholesky.permutationP() * X; + b = cholesky.permutationP() *b; +} template PackedCSparse::SparseMatrix transform_format(SparseMatrixType const &mat) { PackedCSparse::SparseMatrix A = PackedCSparse::SparseMatrix(mat.rows(), mat.cols(), mat.nonZeros()); @@ -367,5 +356,51 @@ PackedCSparse::SparseMatrix transform_format(SparseMatrixType co A.p[A.n] = nnz; return A; } - +template +void copy_indicies(MatrixType& a, MatrixType& b, std::vectorconst & a_idx, std::vectorconst & b_idx){ +for(int i=0;i +void copy_indicies(MatrixType& a, MatrixType b, std::vectorconst & b_idx){ +for(int i=0;i +void set(MatrixType &a, std::vectorconst & idx, const Type c){ + for(int i=0;i +void volesti_saxpy(MatrixType &a,MatrixType const &b,MatrixType const& c, std::vectorconst & a_idx, std::vectorconst & b_idx){ +for(int i=0;i +void load_problem(SpMat &A, VT &b, VT &lb, VT &ub, int &dimension, + std::string problem_name) { + { + std::string fileName(problem_name); + fileName.append(".mm"); + SpMat X; + loadMarket(X, fileName); + int m = X.rows(); + dimension = X.cols() - 1; + A = X.leftCols(dimension); + b = VT(X.col(dimension)); + } + { + std::string fileName(problem_name); + fileName.append("_bounds.mm"); + SpMat bounds; + loadMarket(bounds, fileName); + lb = VT(bounds.col(0)); + ub = VT(bounds.col(1)); + } +} #endif diff --git a/include/preprocess/crhmc/lewis_center.h b/include/preprocess/crhmc/lewis_center.h index f6ee7b22e..5bf89d151 100644 --- a/include/preprocess/crhmc/lewis_center.h +++ b/include/preprocess/crhmc/lewis_center.h @@ -28,15 +28,6 @@ #endif const size_t chol_k3 = (SIMD_LEN == 0) ? 1 : SIMD_LEN; -using NT = double; -using MT = Eigen::Matrix; -using VT = Eigen::Matrix; -using SpMat = Eigen::SparseMatrix; -using CholObj = PackedChol; -using Triple = Eigen::Triplet; -using Tx = FloatArray; -using Opts = opts; -NT epsilon = 1e-8; /*This function computes the Lewis center of the polytope*/ //And detects additional constraint that need to be added // x - It outputs the minimizer of min f(x) subjects to {Ax=b} @@ -46,9 +37,13 @@ NT epsilon = 1e-8; // because of the dom(f), the algorithm will detect the collapsed dimension // and output the detected constraint C x = d // d - detected constraint vector -template +template std::tuple lewis_center(SpMat const &A, VT const &b, Polytope &f, Opts const &options, VT x = VT::Zero(0, 1)) { + using CholObj = typename Polytope::CholObj; + using Triple = typename Polytope::Triple; + using Tx = typename Polytope::Tx; + NT epsilon = 1e-8; // initial conditions int n = A.cols(); int m = A.rows(); @@ -173,14 +168,14 @@ std::tuple lewis_center(SpMat const &A, VT const &b, Polytope std::pair pboundary = f.barrier.boundary(x); VT A_ = pboundary.first; VT b_ = pboundary.second; - A_ = A_(idx); std::vector sparseIdx; for (int i = 0; i < idx.size(); i++) { - sparseIdx.push_back(Triple(i, i, A_(i))); + sparseIdx.push_back(Triple(i, idx[i], A_(idx[i]))); } C.setFromTriplets(sparseIdx.begin(), sparseIdx.end()); - d = b_(idx); + d.resize(idx.size(), 1); + copy_indicies(d, b_, idx); } else { diff --git a/include/preprocess/crhmc/opts.h b/include/preprocess/crhmc/opts.h index df73d5a7c..573a69dbd 100644 --- a/include/preprocess/crhmc/opts.h +++ b/include/preprocess/crhmc/opts.h @@ -26,28 +26,31 @@ template class opts { const Type ipmDistanceTol = 1e-8; const Type ipmDualTol = 1e-12; int maxNZ = 30; - Type max_coord = 1e7; - bool EnableReordering = false; + Type max_coord = 1e9; + bool EnableReordering = true; const int min_convergence_steps=8; /*ODE options*/ const Type implicitTol = 1e-5; const int maxODEStep = 30; Type initialStep = 0.2; - Type convergence_limit = 1e16; + Type convergence_bound = 1e16; + + /*PackedCS Solver Options*/ Type solver_accuracy_threshold=1e-2; + int simdLen=1; /*Sampler options*/ bool DynamicWeight = true; //Enable the use of dynamic weights for each variable when sampling bool DynamicStepSize = true; // Enable adaptive step size that avoids low acceptance probability bool DynamicRegularizer = true; //Enable the addition of a regularization term - + Type regularization_factor=1e-20; /*Dynamic step choices*/ Type warmUpStep = 10; - Type maxConsecutiveBadStep = 10; + int maxConsecutiveBadStep = 10; Type targetODEStep = 10; Type shrinkFactor = 1.1; - Type minStepSize = 0.001; + Type minStepSize = 1e-5; Type effectiveStepSize = 1; opts() {} diff --git a/include/preprocess/crhmc/two_sided_barrier.h b/include/preprocess/crhmc/two_sided_barrier.h index 39b27bab9..8678d3515 100644 --- a/include/preprocess/crhmc/two_sided_barrier.h +++ b/include/preprocess/crhmc/two_sided_barrier.h @@ -21,6 +21,7 @@ #include "Eigen/Eigen" #include "cartesian_geom/cartesian_kernel.h" +#include "preprocess/crhmc/crhmc_utils.h" #include /// @brief A two sided barrier used by crhmc sampler @@ -43,16 +44,18 @@ template class two_sided_barrier { const NT max_step = 1e16; // largest step size const NT regularization_constant = 1e-20; // small regularization to not have a large inverse const NT unbounded_center_coord = 1e6; - VT extraHessian; //Regularization factor + MT extraHessian; const NT inf = std::numeric_limits::infinity(); - //initialization function - void set_bound(VT const &_lb, VT const &_ub) { + void set_bound(VT const &_lb, VT const &_ub) { + n = _lb.rows(); + extraHessian.resize(n, 1); + lb.resize(n); + ub.resize(n); lb = _lb; ub = _ub; - n = lb.rows(); - extraHessian = regularization_constant * VT::Ones(n); + extraHessian = regularization_constant * MT::Ones(n, 1); int x1 = 0, x2 = 0, x3 = 0; for (int i = 0; i < n; i++) { if (lb(i) == -inf) { @@ -69,35 +72,44 @@ template class two_sided_barrier { } VT c = (ub + lb) / 2; - - c(lowerIdx) = lb(lowerIdx) + VT::Ones(x2, 1) * unbounded_center_coord; - c(upperIdx) = ub(upperIdx) - VT::Ones(x1, 1) * unbounded_center_coord; - c(freeIdx) *= 0.0; + VT bias1=VT::Ones(x2, 1) * unbounded_center_coord; + volesti_saxpy(c,lb,bias1,lowerIdx,lowerIdx); + VT bias2=-VT::Ones(x1, 1) * unbounded_center_coord; + volesti_saxpy(c,ub,bias2,upperIdx,upperIdx); + set(c, freeIdx, 0.0); center = c; } two_sided_barrier(VT const &_lb, VT const &_ub, int _vdim = 1) { set_bound(_lb, _ub); vdim = _vdim; - extraHessian = regularization_constant * VT::Ones(n); + extraHessian = regularization_constant * MT::Ones(n,1); } two_sided_barrier() { vdim = 1; } - //barrier function gradient + VT gradient(VT const &x) { return (ub - x).cwiseInverse() - (x - lb).cwiseInverse(); } - //Return the barrier hessian with the extra Regularization + VT hessian(VT const &x) { VT d = ((ub - x).cwiseProduct((ub - x))).cwiseInverse() + ((x - lb).cwiseProduct((x - lb))).cwiseInverse(); return d + extraHessian; } - //third derivative of the barrier - VT tensor(VT const &x) { - VT d = 2 * (((ub - x).cwiseProduct((ub - x))).cwiseProduct((ub - x))).cwiseInverse() - - 2 * (((x - lb).cwiseProduct((x - lb))).cwiseProduct((x - lb))).cwiseInverse(); + MT hessian(MT const &x){ + MT d = (((- x).colwise()+ub).cwiseProduct(((- x).colwise()+ub))).cwiseInverse() + + ((x.colwise() - lb).cwiseProduct((x.colwise() - lb))).cwiseInverse(); + return d + extraHessian; + } + MT tensor(MT const &x) { + MT d = 2 * ((((-x).colwise()+ub).cwiseProduct(((-x).colwise()+ub))).cwiseProduct(((-x).colwise()+ub))).cwiseInverse() - + 2 * (((x.colwise() - lb).cwiseProduct(( x.colwise() - lb))).cwiseProduct(( x.colwise() - lb))).cwiseInverse(); return d; } + MT quadratic_form_gradient(MT const &x, MT const &u) { + // Output the -grad of u' (hess phi(x)) u. + return (u.cwiseProduct(u)).cwiseProduct(tensor(x)); + } VT quadratic_form_gradient(VT const &x, VT const &u) { // Output the -grad of u' (hess phi(x)) u. @@ -119,13 +131,19 @@ template class two_sided_barrier { VT boundary_distance(VT const &x) { // Output the distance of x with its closest boundary for each // coordinate - return ((x - lb).cwiseMin(ub - x)).cwiseAbs(); } bool feasible(VT const &x) { return (x.array() > lb.array() && x.array() < ub.array()).all(); } + VT feasible(MT const &x) { + VT result=VT::Ones(x.cols()); + for(int i=0;i lb.array() && x.col(i).array() < ub.array()).all(); + } + return result; + } std::pair analytic_center_oracle(VT const &x) { VT g = VT::Zero(n, 1); @@ -136,8 +154,7 @@ template class two_sided_barrier { std::pair lewis_center_oracle(VT const &x, VT const &w) { VT g = VT::Zero(n, 1); VT h = VT::Zero(n, 1); - return std::make_pair(g + w.cwiseProduct(gradient(x)), - h + w.cwiseProduct(hessian(x))); + return std::make_pair(g + w.cwiseProduct(gradient(x)),h + w.cwiseProduct(hessian(x))); } std::pair boundary(VT const &x) { @@ -145,11 +162,9 @@ template class two_sided_barrier { // Assume: only 1 vector is given VT A = VT::Ones(x.rows(), 1); - VT b = ub; b = (x.array() < center.array()).select(-lb, b); - A = (x.array() < center.array()).select(-A, A); return std::make_pair(A, b); diff --git a/include/preprocess/crhmc/weighted_two_sided_barrier.h b/include/preprocess/crhmc/weighted_two_sided_barrier.h index 1bda5d3bf..4df8cc967 100644 --- a/include/preprocess/crhmc/weighted_two_sided_barrier.h +++ b/include/preprocess/crhmc/weighted_two_sided_barrier.h @@ -21,6 +21,7 @@ #include "Eigen/Eigen" #include "cartesian_geom/cartesian_kernel.h" +#include "preprocess/crhmc/crhmc_utils.h" #include /// @brief A weighted two sided barrier used by crhmc sampler @@ -43,8 +44,7 @@ template class weighted_two_sided_barrier { const NT max_step = 1e16; // largest step size const NT regularization_constant = 1e-20; // small regularization to not have a large inverse const NT unbounded_center_coord = 1e6; - VT extraHessian; - + MT extraHessian; const NT inf = std::numeric_limits::infinity(); VT w; @@ -54,7 +54,7 @@ template class weighted_two_sided_barrier { set_bound(_lb, _ub); w = _w; vdim = _vdim; - extraHessian = regularization_constant * VT::Ones(n); + extraHessian = regularization_constant * VT::Ones(n,1); } weighted_two_sided_barrier() { vdim = 1; } @@ -67,11 +67,25 @@ template class weighted_two_sided_barrier { w.cwiseQuotient((x - lb).cwiseProduct((x - lb))); return d + extraHessian; } + MT hessian(MT const &x){ + MT d = (((- x).colwise()+ub).cwiseProduct(((- x).colwise()+ub))).cwiseInverse() + + ((x.colwise() - lb).cwiseProduct((x.colwise() - lb))).cwiseInverse(); + return w.asDiagonal()*d + extraHessian; + } VT tensor(VT const &x) { VT d = 2 * w.cwiseQuotient(((ub - x).cwiseProduct((ub - x))).cwiseProduct((ub - x))) - 2 * w.cwiseQuotient(((x - lb).cwiseProduct((x - lb))).cwiseProduct((x - lb))); return d; } + MT tensor(MT const &x) { + MT d = 2 * ((((-x).colwise()+ub).cwiseProduct(((-x).colwise()+ub))).cwiseProduct(((-x).colwise()+ub))).cwiseInverse() - + 2 * (((x.colwise() - lb).cwiseProduct(( x.colwise() - lb))).cwiseProduct(( x.colwise() - lb))).cwiseInverse(); + return w.asDiagonal()*d; + } + MT quadratic_form_gradient(MT const &x, MT const &u) { + // Output the -grad of u' (hess phi(x)) u. + return (u.cwiseProduct(u)).cwiseProduct(tensor(x)); + } VT quadratic_form_gradient(VT const &x, VT const &u) { // Output the -grad of u' (hess phi(x)) u. @@ -99,7 +113,13 @@ template class weighted_two_sided_barrier { bool feasible(VT const &x) { return (x.array() > lb.array() && x.array() < ub.array()).all(); } - + VT feasible(MT const &x) { + VT result=VT::Ones(x.cols()); + for(int i=0;i lb.array() && x.col(i).array() < ub.array()).all(); + } + return result; + } void set_bound(VT const &_lb, VT const &_ub) { lb = _lb; @@ -122,10 +142,11 @@ template class weighted_two_sided_barrier { } VT c = (ub + lb) / 2; - - c(lowerIdx) = lb(lowerIdx) + VT::Ones(x2, 1) * unbounded_center_coord; - c(upperIdx) = ub(upperIdx) - VT::Ones(x1, 1) * unbounded_center_coord; - c(freeIdx) *= 0.0; + VT bias1=VT::Ones(x2, 1) * unbounded_center_coord; + volesti_saxpy(c,lb,bias1,lowerIdx,lowerIdx); + VT bias2=-VT::Ones(x1, 1) * unbounded_center_coord; + volesti_saxpy(c,ub,bias2,upperIdx,upperIdx); + set(c, freeIdx, 0.0); center = c; } @@ -133,13 +154,10 @@ template class weighted_two_sided_barrier { std::pair boundary(VT const &x) { // Output the normal at the boundary around x for each barrier. // Assume: only 1 vector is given - VT A = VT::Ones(x.rows(), 1); - VT b = ub; b = (x.array() < center.array()).select(-lb, b); - A = (x.array() < center.array()).select(-A, A); return std::make_pair(A, b); diff --git a/include/preprocess/estimate_L_smooth_parameter.hpp b/include/preprocess/estimate_L_smooth_parameter.hpp new file mode 100644 index 000000000..8f5a1e89c --- /dev/null +++ b/include/preprocess/estimate_L_smooth_parameter.hpp @@ -0,0 +1,73 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2020 Vissarion Fisikopoulos +// Copyright (c) 2018-2020 Apostolos Chalkis + +//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. + +// Licensed under GNU LGPL.3, see LICENCE file + + +#ifndef ESTIMATE_L_SMOOTH_PARAMETER_HPP +#define ESTIMATE_L_SMOOTH_PARAMETER_HPP + +#include "random_walks/random_walks.hpp" + +template +< + typename WalkTypePolicy = AcceleratedBilliardWalk, + typename Polytope, + typename Point, + typename NegativeGradientFunctor, + typename RandomNumberGenerator +> +double estimate_L_smooth(Polytope &P, Point &p, unsigned int const& walk_length, + NegativeGradientFunctor F, RandomNumberGenerator &rng) +{ + typedef typename Point::FT NT; + typedef typename WalkTypePolicy::template Walk + < + Polytope, + RandomNumberGenerator + > RandomWalk; + + P.ComputeInnerBall(); + + unsigned int d = P.dimension(); + unsigned int rnum = 5 * d; + std::vector randPoints(1); + std::vector vecPoint1; + std::vector vecPoint2; + std::vector< std::vector > listOfPoints; + Point F1; + + RandomWalk walk(P, p, rng); + for (unsigned int i=0; i::lowest(), Ltemp; + + for (auto pit=listOfPoints.begin(); pit!=(listOfPoints.end()-1); ++pit) + { + F1 = F(1, *pit, 0); + + for (auto qit=(pit+1); qit!=listOfPoints.end(); ++qit) + { + vecPoint2 = *qit; + Ltemp = (F1 - F(1, *qit, 0)).length() / ((*pit)[0] - (*qit)[0]).length(); + + if (Ltemp > L) + { + L = Ltemp; + } + } + } + return L; +} + + +#endif diff --git a/include/preprocess/min_sampling_covering_ellipsoid_rounding.hpp b/include/preprocess/min_sampling_covering_ellipsoid_rounding.hpp index 1e97835d9..0a2aba7c5 100644 --- a/include/preprocess/min_sampling_covering_ellipsoid_rounding.hpp +++ b/include/preprocess/min_sampling_covering_ellipsoid_rounding.hpp @@ -11,7 +11,7 @@ #define MIN_ELLIPSOID_ROUNDING_HPP #include -#include "khach.h" +#include "minimum_ellipsoid/khach.h" #include "sampling/random_point_generators.hpp" #include "volume/sampling_policies.hpp" diff --git a/include/random_walks/crhmc/additional_units/auto_tuner.hpp b/include/random_walks/crhmc/additional_units/auto_tuner.hpp index 0fc50e79a..66a8d51a7 100644 --- a/include/random_walks/crhmc/additional_units/auto_tuner.hpp +++ b/include/random_walks/crhmc/additional_units/auto_tuner.hpp @@ -33,24 +33,23 @@ class auto_tuner { public: Opts options; - weight_tuner *tune_weights; - regularizion_tuner *tune_regularization; - step_size_tuner *tune_step_size; + std::unique_ptr tune_weights; + std::unique_ptr tune_regularization; + std::unique_ptr tune_step_size; auto_tuner(Sampler &s) : options(s.params.options) { if (options.DynamicWeight) { - tune_weights = new weight_tuner(s); + tune_weights = std::unique_ptr(new weight_tuner(s)); } if (options.DynamicRegularizer) { - tune_regularization = new regularizion_tuner(s); + tune_regularization = std::unique_ptr(new regularizion_tuner(s)); } if (options.DynamicStepSize) { - tune_step_size = new step_size_tuner(s); + tune_step_size = std::unique_ptr(new step_size_tuner(s)); } } - void updateModules(Sampler &s, RandomNumberGenerator &rng) - { + void updateModules(Sampler &s, RandomNumberGenerator &rng) { if (options.DynamicWeight) { tune_weights->update_weights(s, rng); } diff --git a/include/random_walks/crhmc/additional_units/dynamic_regularizer.hpp b/include/random_walks/crhmc/additional_units/dynamic_regularizer.hpp index 9cd80b18d..81449836b 100644 --- a/include/random_walks/crhmc/additional_units/dynamic_regularizer.hpp +++ b/include/random_walks/crhmc/additional_units/dynamic_regularizer.hpp @@ -25,33 +25,34 @@ class dynamic_regularizer { public: using NT = typename Sampler::NT; using Point = typename Sampler::point; - using VT = Eigen::Matrix; + using MT = Eigen::Matrix; using Opts = typename Sampler::Opts; int n; - VT bound; + int simdLen; + MT bound; Opts &options; - VT &extraHessian; + MT &extraHessian; dynamic_regularizer(Sampler &s) : + simdLen(s.simdLen), options(s.params.options), extraHessian(options.DynamicWeight ? s.solver->ham.weighted_barrier->extraHessian : s.solver->ham.barrier->extraHessian) { n = s.dim; - bound = VT::Ones(n); - extraHessian = VT::Ones(n); + bound = MT::Ones(n, simdLen); + extraHessian = MT::Ones(n, simdLen); } - void update_regularization_factor(Sampler &s, RandomNumberGenerator &rng) - { - VT x = s.x.getCoefficients(); - x = (x.cwiseAbs()).cwiseMax(VT::Ones(n)); + void update_regularization_factor(Sampler &s, RandomNumberGenerator &rng) { + MT x = s.x; + x = (x.cwiseAbs()).cwiseMax(1); bound = bound.cwiseMax(x); - if ((2 / (bound.array() * bound.array()) < n * extraHessian.array()).any()) { extraHessian = (0.5 / n) * (bound.cwiseProduct(bound)).cwiseInverse(); + s.solver->ham.forceUpdate = true; s.solver->ham.move({s.x, s.v}); - s.v = s.get_direction_with_momentum(n, rng, s.x, Point(n), false); + s.v = s.get_direction_with_momentum(n, rng, s.x, MT::Zero(n, simdLen), 0, false); } } }; diff --git a/include/random_walks/crhmc/additional_units/dynamic_step_size.hpp b/include/random_walks/crhmc/additional_units/dynamic_step_size.hpp index ef1871731..367211962 100644 --- a/include/random_walks/crhmc/additional_units/dynamic_step_size.hpp +++ b/include/random_walks/crhmc/additional_units/dynamic_step_size.hpp @@ -22,26 +22,34 @@ template class dynamic_step_size { using NT = typename Sampler::NT; using Opts = typename Sampler::Opts; + using IVT = Eigen::Array; + using VT = Eigen::Array; public: - int consecutiveBadStep = 0; + int simdLen; + IVT consecutiveBadStep; int iterSinceShrink = 0; - NT rejectSinceShrink = 0; + VT rejectSinceShrink; int ODEStepSinceShrink = 0; int effectiveStep = 0; bool warmupFinished = false; Opts &options; NT η NT &momentum; - NT acceptedStep = 0; + VT acceptedStep; + VT nEffectiveStep; // number of effective steps NT accumulatedMomentum = 0; - NT nEffectiveStep = 0; // number of effective steps - dynamic_step_size(Sampler &s) : + simdLen(s.simdLen), options(s.params.options), eta(s.solver->eta), momentum(s.params.momentum) { + nEffectiveStep = VT::Zero(simdLen); + acceptedStep = VT::Zero(simdLen); + consecutiveBadStep = IVT::Zero(simdLen); + rejectSinceShrink = VT::Zero(simdLen); + if (options.warmUpStep > 0) { eta = 1e-3; } else { @@ -49,53 +57,58 @@ class dynamic_step_size { } } void update_step_size(Sampler &s) { - acceptedStep = acceptedStep + s.prob; - accumulatedMomentum = s.prob * momentum * accumulatedMomentum + eta; - nEffectiveStep = nEffectiveStep + eta * accumulatedMomentum * s.accept; - - int bad_step = s.prob < 0.5 || s.solver->num_steps == options.maxODEStep ? 1 : 0; + acceptedStep = acceptedStep + s.prob.array(); + accumulatedMomentum = s.prob.mean() * momentum * accumulatedMomentum + eta; + Eigen::Matrix accept = (s.accept.template cast()); + nEffectiveStep = nEffectiveStep + eta * accumulatedMomentum * accept.array(); + IVT bad_step = IVT::Zero(simdLen); + if (s.solver->num_steps == options.maxODEStep) { + bad_step += 1; + } else { + bad_step = (s.prob.array() < 0.5).select(1, IVT::Zero(simdLen)); + } consecutiveBadStep = bad_step * consecutiveBadStep + bad_step; - NT warmupRatio = nEffectiveStep / options.warmUpStep; + NT warmupRatio = nEffectiveStep.mean() / options.warmUpStep; if (warmupRatio < 1 && !warmupFinished && - consecutiveBadStep < options.maxConsecutiveBadStep) { + consecutiveBadStep.maxCoeff() < options.maxConsecutiveBadStep) { eta = options.initialStep * std::min(warmupRatio + 1e-2, 1.0); momentum = 1 - std::min(1.0, eta / options.effectiveStepSize); return; } + if (!warmupFinished) { - acceptedStep = 0; - nEffectiveStep = 0; + acceptedStep = VT::Zero(simdLen); + nEffectiveStep = VT::Zero(simdLen); warmupFinished = true; } iterSinceShrink++; - rejectSinceShrink += 1 - s.prob; + rejectSinceShrink += 1 - s.prob.array(); ODEStepSinceShrink += s.solver->num_steps; int shrink = 0; NT shiftedIter = iterSinceShrink + 20 / (1 - momentum); NT targetProbability = std::pow((1.0 - momentum), (2 / 3)) / 4; - if (rejectSinceShrink > targetProbability * shiftedIter || - consecutiveBadStep > options.maxConsecutiveBadStep || + if (rejectSinceShrink.maxCoeff() > targetProbability * shiftedIter|| + consecutiveBadStep.maxCoeff() > options.maxConsecutiveBadStep || ODEStepSinceShrink > options.targetODEStep * shiftedIter) { shrink = 1; } if (shrink == 1) { iterSinceShrink = 0; - rejectSinceShrink = 0; ODEStepSinceShrink = 0; - consecutiveBadStep = 0; + rejectSinceShrink = VT::Zero(simdLen); + consecutiveBadStep = IVT::Zero(simdLen); eta /= options.shrinkFactor; momentum = 1 - std::min(0.999, eta / options.effectiveStepSize); if (eta < options.minStepSize) { - std::cerr << "Algorithm fails to converge even with step size h = " - << eta << "\n"; - exit(1); + s.P.terminate=true; + s.P.terminate_message="Algorithm fails to converge even with step size h = "+std::to_string(eta)+"\n"; } } diff --git a/include/random_walks/crhmc/additional_units/dynamic_weight.hpp b/include/random_walks/crhmc/additional_units/dynamic_weight.hpp index ce945216f..6b9433774 100644 --- a/include/random_walks/crhmc/additional_units/dynamic_weight.hpp +++ b/include/random_walks/crhmc/additional_units/dynamic_weight.hpp @@ -23,48 +23,52 @@ class dynamic_weight { using NT = typename Sampler::NT; using Point = typename Sampler::point; using VT = Eigen::Matrix; + using MT = Eigen::Matrix; + using IVT = Eigen::Array; using Opts = typename Sampler::Opts; public: - int consecutiveBadStep = 0; + int simdLen; + IVT consecutiveBadStep; int n; VT &w; Opts options; - dynamic_weight(Sampler &s) : - w(s.solver->ham.weighted_barrier->w), - options(s.params.options) + dynamic_weight(Sampler &s) + : simdLen(s.simdLen), w(s.solver->ham.weighted_barrier->w), options(s.params.options) { n = s.dim; + consecutiveBadStep = IVT::Zero(simdLen); } // If we have consecutive bad steps update the weights with // the help of the leverage scores. void update_weights(Sampler &s, RandomNumberGenerator &rng) { - int bad_step = 0; - NT threshold; - if (s.prob < 0.5 || s.solver->num_steps == options.maxODEStep) { - bad_step = 1; + IVT bad_step = IVT::Zero(simdLen); + if (s.solver->num_steps == options.maxODEStep) { + bad_step += 1; + } else { + bad_step = (s.prob.array() < 0.5).select(1, IVT::Zero(simdLen)); } + NT threshold; consecutiveBadStep = bad_step * consecutiveBadStep + bad_step; - if (!s.accepted) { - VT lsc = s.solver->ham.lsc; + if (s.accept.sum() < simdLen) { + VT lsc = s.solver->ham.lsc.colwise().maxCoeff().transpose(); /*The more bad steps in a row we have the higher we want the threshold to be In order to change w more drasticaly according to the leverage scores. So if we have more than 2 bad steps in a row we elect to set the threshold to 4 else to 16. Not many changes will be possible as the w should be upperbounded by 1*/ - if (consecutiveBadStep > 2) { + if (consecutiveBadStep.maxCoeff() > 2) { threshold = 4; } else { threshold = 16; } bool changed = (lsc.array() > threshold * w.array()).any(); - w = (lsc.array() > threshold * w.array()) - .select((w * threshold).cwiseMin(VT::Ones(n)), w); if (changed) { + w = (lsc.array() > threshold * w.array()).select((w * threshold).cwiseMin(1), w); s.solver->ham.forceUpdate = true; s.solver->ham.move({s.x, s.v}); - s.v = s.get_direction_with_momentum(n, rng, s.x, Point(n), false); + s.v = s.get_direction_with_momentum(n, rng, s.x, MT::Zero(n, simdLen), false); } } } diff --git a/include/random_walks/crhmc/crhmc_walk.hpp b/include/random_walks/crhmc/crhmc_walk.hpp index b97d79fa9..f40fe5979 100644 --- a/include/random_walks/crhmc/crhmc_walk.hpp +++ b/include/random_walks/crhmc/crhmc_walk.hpp @@ -36,7 +36,7 @@ struct CRHMCWalk { parameters(OracleFunctor const &F, unsigned int dim, Opts &user_options, - NT epsilon_ = 2) : + NT epsilon_ = 2) : options(user_options) { epsilon = epsilon_; @@ -59,17 +59,19 @@ struct CRHMCWalk { using pts = std::vector; using NT = typename Point::FT; using VT = Eigen::Matrix; + using MT = Eigen::Matrix; using Sampler = CRHMCWalk::Walk; using Opts = typename Polytope::Opts; + using IVT = Eigen::Matrix; // Hyperparameters of the sampler parameters ¶ms; // Numerical ODE solver - Solver *solver; + std::unique_ptr solver; // Dimension unsigned int dim; @@ -87,25 +89,25 @@ struct CRHMCWalk { float average_acceptance_prob = 0; // Acceptance probability - NT prob; + VT prob; bool accepted; - NT accept; + IVT accept; bool update_modules; - + int simdLen; // References to xs - Point x, v; + MT x, v; // Proposal points - Point x_tilde, v_tilde; + MT x_tilde, v_tilde; // Gradient function NegativeGradientFunctor &F; // Auto tuner - auto_tuner *module_update; + std::unique_ptr>module_update; // Helper variables - NT H, H_tilde, log_prob, u_logprob; + VT H, H_tilde; // Density exponent NegativeLogprobFunctor &f; #ifdef TIME_KEEPING @@ -118,41 +120,50 @@ struct CRHMCWalk { NegativeLogprobFunctor &neg_logprob_f, parameters ¶m) : params(param), + P(Problem), F(neg_grad_f), - f(neg_logprob_f), - P(Problem) + f(neg_logprob_f) { dim = p.dimension(); - + simdLen = params.options.simdLen; // Starting point is provided from outside - x = p; + x = p.getCoefficients() * MT::Ones(1, simdLen); accepted = false; // Initialize solver - solver = - new Solver(0.0, params.eta, pts{x, x}, F, Problem, params.options); - v = solver->get_state(1); - module_update = new auto_tuner(*this); + solver = std::unique_ptr(new Solver(0.0, params.eta, {x, x}, F, Problem, params.options)); + v = MT::Zero(dim, simdLen); + module_update = std::unique_ptr>(new auto_tuner(*this)); update_modules = params.options.DynamicWeight || params.options.DynamicRegularizer || params.options.DynamicStepSize; }; - Point get_direction_with_momentum(unsigned int const &dim, - RandomNumberGenerator &rng, - Point x, - Point v, - NT momentum = 0, - bool normalize = true) + // Sample a new velocity with momentum + MT get_direction_with_momentum(unsigned int const &dim, + RandomNumberGenerator &rng, MT const &x, MT v, + NT momentum = 0, bool normalize = true) { - Point z = GetDirection::apply(dim, rng, normalize); + MT z = MT(dim, simdLen); + for (int i = 0; i < simdLen; i++) + { + z.col(i) = GetDirection::apply(dim, rng, normalize).getCoefficients(); + } solver->ham.move({x, v}); - VT sqrthess = (solver->ham.hess).cwiseSqrt(); - z = Point(sqrthess.cwiseProduct(z.getCoefficients())); + MT sqrthess = (solver->ham.hess).cwiseSqrt(); + z = sqrthess.cwiseProduct(z); return v * std::sqrt(momentum) + z * std::sqrt(1 - momentum); } // Returns the current point in the tranformed in the original space - inline Point getPoint() { return Point(P.T * x.getCoefficients() + P.y); } + inline MT getPoints() { return (P.T * x).colwise() + P.y; } + // Returns the current point in the tranformed in the original space + inline Point getPoint() { return Point(P.T * x.col(0) + P.y); } + inline MT masked_choose(MT &x, MT &x_tilde, IVT &accept) { + return accept.transpose().replicate(x.rows(), 1).select(x_tilde, x); + } + inline void disable_adaptive(){ + update_modules=false; + } inline void apply(RandomNumberGenerator &rng, int walk_length = 1, bool metropolis_filter = true) @@ -160,47 +171,45 @@ struct CRHMCWalk { num_runs++; // Pick a random velocity with momentum v = get_direction_with_momentum(dim, rng, x, v, params.momentum, false); - solver->set_state(0, x); solver->set_state(1, v); // Get proposals solver->steps(walk_length, accepted); x_tilde = solver->get_state(0); v_tilde = solver->get_state(1); - if (metropolis_filter) { #ifdef TIME_KEEPING - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); #endif // Calculate initial Hamiltonian H = solver->ham.hamiltonian(x, v); + // Calculate new Hamiltonian - H_tilde = solver->ham.hamiltonian(x_tilde, Point(dim) - v_tilde); + H_tilde = solver->ham.hamiltonian(x_tilde, -v_tilde); + #ifdef TIME_KEEPING - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); H_duration += end - start; #endif - NT feasible = solver->ham.feasible(x_tilde.getCoefficients(), - v_tilde.getCoefficients()); - prob = std::min(1.0, exp(H - H_tilde)) * feasible; - - log_prob = log(prob); - total_acceptance_prob += prob; - - // Decide to switch - if (rng.sample_urdist() < prob) { - x = x_tilde; - v = v_tilde; - accepted = true; - } - else { - total_discarded_samples++; - accepted = false; - v = Point(dim) - v; + VT feasible = solver->ham.feasible(x_tilde, + v_tilde); + prob = (1.0 < exp((H - H_tilde).array())).select(1.0, exp((H - H_tilde).array())); + prob = (feasible.array() > 0.5).select(prob, 0); + + total_acceptance_prob += prob.sum(); + VT rng_vector = VT(simdLen); + for (int i = 0; i < simdLen; i++) + { + rng_vector(i) = rng.sample_urdist(); } - discard_ratio = (1.0 * total_discarded_samples) / num_runs; - average_acceptance_prob = total_acceptance_prob / num_runs; - accept = accepted ? 1 : 0; + accept = (rng_vector.array() < prob.array()).select(1 * IVT::Ones(simdLen), 0 * IVT::Ones(simdLen)); + + x = masked_choose(x, x_tilde, accept); + v = -v; + v = masked_choose(v, v_tilde, accept); + total_discarded_samples += simdLen - accept.sum(); + discard_ratio = (1.0 * total_discarded_samples) / (num_runs * simdLen); + average_acceptance_prob = total_acceptance_prob / (num_runs * simdLen); } else { x = x_tilde; v = v_tilde; @@ -210,18 +219,24 @@ struct CRHMCWalk { } } #ifdef TIME_KEEPING - void print_timing_information() { - std::cerr << "--------------Timing Information--------------\n"; + void initialize_timers() { + H_duration = std::chrono::duration::zero(); + solver->DU_duration = std::chrono::duration::zero(); + solver->approxDK_duration = std::chrono::duration::zero(); + } + template + void print_timing_information(StreamType &stream) { + stream << "---Sampling Timing Information" << std::endl; double DU_time = solver->DU_duration.count(); double DK_time = solver->approxDK_duration.count(); double H_time = H_duration.count(); double total_time = H_time + DK_time + DU_time; - std::cerr << "Computing the Hamiltonian in time, " << H_time << " secs\n"; - std::cerr << "Computing DU partial derivatives in time, " << DU_time - << " secs\n"; - std::cerr << "Computing DK partial derivatives in time, " << DK_time - << " secs\n"; - std::cerr << "H_time + DK_time + DU_time: " << total_time << "\n"; + stream << "Computing the Hamiltonian in time, " << H_time << " secs\n"; + stream << "Computing DU partial derivatives in time, " << DU_time + << " secs\n"; + stream << "Computing DK partial derivatives in time, " << DK_time + << " secs\n"; + stream << "H_time + DK_time + DU_time: " << total_time << "\n"; } #endif }; diff --git a/include/random_walks/crhmc/hamiltonian.hpp b/include/random_walks/crhmc/hamiltonian.hpp index d8cb5a82e..0d9ef5465 100644 --- a/include/random_walks/crhmc/hamiltonian.hpp +++ b/include/random_walks/crhmc/hamiltonian.hpp @@ -17,42 +17,43 @@ #define HAMILTONIAN_HPP #include "preprocess/crhmc/two_sided_barrier.h" #include "preprocess/crhmc/weighted_two_sided_barrier.h" +#include "PackedCSparse/PackedChol.h" #include "preprocess/crhmc/crhmc_utils.h" #include -/// @brief Class for the hamiltonian used in crhmc sampler -/// @tparam Polytope Polytope Type -/// @tparam Point Point Type -template +template class Hamiltonian { using VT = typename Polytope::VT; + using IVT = Eigen::Array; + using BVT = Eigen::Matrix; using NT = typename Polytope::NT; using MT = typename Polytope::MT; - using Tx = typename Polytope::Tx; - using CholObj = typename Polytope::CholObj; - using Opts = typename Polytope::Opts; using SpMat = typename Polytope::SpMat; - using pts = std::vector; + using Tx = FloatArray; + using CholObj = PackedChol; + using Opts = typename Polytope::Opts; + using pts = std::vector; using Barrier = two_sided_barrier; using WeightedBarrier = weighted_two_sided_barrier; public: bool prepared = false; - bool forceUpdate = true; + bool forceUpdate = true; // Update function oracle temporary varibles Polytope &P; - VT hess; + MT hess; bool dUDx_empty = true; - Point last_dUdx; + MT last_dUdx; CholObj solver; pts xs; - VT x; - VT dfx; - VT lsc; - NT fx = 0; + MT x; + MT dfx; + MT lsc; + VT fx; int n; int m; + int num_runs = 0; Barrier *barrier; - WeightedBarrier *weighted_barrier; + std::unique_ptr weighted_barrier; Opts &options; Hamiltonian(Polytope &boundaries) : P(boundaries), @@ -61,111 +62,122 @@ class Hamiltonian { { n = P.dimension(); m = P.equations(); - x = VT::Zero(n); - xs = {Point(n), Point(n)}; - lsc = VT::Zero(n); + x = MT::Zero(n, simdLen); + xs = {x, x}; + lsc = MT::Zero(simdLen, n); solver.accuracyThreshold = options.solver_accuracy_threshold; - if (options.DynamicWeight) { + if (options.DynamicWeight) + { weighted_barrier = - new WeightedBarrier(P.barrier.lb, P.barrier.ub, P.w_center); + std::unique_ptr(new WeightedBarrier(P.barrier.lb, P.barrier.ub, P.w_center)); + weighted_barrier->extraHessian.resize(n, simdLen); + weighted_barrier->extraHessian = MT::Ones(n, simdLen) * options.regularization_factor; } barrier = &P.barrier; + barrier->extraHessian.resize(n, simdLen); + barrier->extraHessian = MT::Ones(n, simdLen) * options.regularization_factor; } // Compute H(x,v) - NT hamiltonian(Point x, Point v) + VT hamiltonian(MT x, MT v) { prepare({x, v}); pts pd = DK({x, v}); - NT K = 0.5 * v.dot(pd[0]); - NT U = 0.5 * (solver.logdet() + ((hess.array()).log()).sum()); - U = U + fx; - NT E = U + K; + VT K = 0.5 * (v.cwiseProduct(pd[0])).colwise().sum(); + Tx out=solver.logdet(); + VT logdet=VT(simdLen); + for (int i = 0; i < simdLen; i++) + logdet(i) = get(out, i); + VT U = ((hess.array()).log()).colwise().sum(); + U = (U + logdet) * 0.5 + fx; + VT E = U + K; return E; } // Helper is nan function for vectors template - bool isnan(MatrixType x) + IVT is_not_nan(MatrixType x) { + IVT result = IVT::Ones(x.cols()); for (int i = 0; i < x.rows(); i++) { for (int j = 0; j < x.cols(); j++) { if (std::isnan(x(i, j))) { - return true; + result(j) = 0; } } } - return false; + return result; } // Test if the values of x and v are valid and if x is feasible - NT feasible(VT x, VT v) + VT feasible(MT x, MT v) { - bool feasible_coordinate = true; + VT feasible_coordinate = VT::Ones(x.cols()); if (options.DynamicWeight) { feasible_coordinate = weighted_barrier->feasible(x); } else { feasible_coordinate = barrier->feasible(x); } - bool r = !isnan(x) && !isnan(v) && feasible_coordinate; - if (r) { - return 1; - } - return 0; + VT r = feasible_coordinate.cwiseProduct((is_not_nan(x) * is_not_nan(v)).matrix()); + return r; } // prepare the solver weighted by the hessian void prepare(pts const &xs) { move(xs); if (!prepared) { - VT Hinv = hess.cwiseInverse(); + MT Hinv = (hess.cwiseInverse()).transpose(); solver.decompose((Tx *)Hinv.data()); + dUDx_empty = true; } - dUDx_empty = true; prepared = true; } // Computation of the partial derivatives of the K term pts DK(pts const &x_bar) { - VT x = x_bar[0].getCoefficients(); - VT v = x_bar[1].getCoefficients(); + MT x = x_bar[0]; + MT v = x_bar[1]; move(x_bar); - VT invHessV = v.cwiseQuotient(hess); - VT input_vector = P.Asp * invHessV; - VT out_vector = VT::Zero(m); + MT invHessV = v.cwiseQuotient(hess); + MT input_vector = P.Asp * invHessV; + input_vector.transposeInPlace(); + MT out_vector = MT::Zero(simdLen, m); solver.solve((Tx *)input_vector.data(), (Tx *)out_vector.data()); - Point dKdv = - Point(invHessV - (P.Asp.transpose() * out_vector).cwiseQuotient(hess)); + out_vector.transposeInPlace(); + MT dKdv = + invHessV - (P.Asp.transpose() * out_vector).cwiseQuotient(hess); - Point dKdx = Point(n); + MT dKdx = MT::Zero(n, simdLen); if (options.DynamicWeight) { - dKdx = Point( - weighted_barrier->quadratic_form_gradient(x, dKdv.getCoefficients()) / - 2); + dKdx = + weighted_barrier->quadratic_form_gradient(x, dKdv) / + 2; } else { - dKdx = Point(barrier->quadratic_form_gradient(x, dKdv.getCoefficients()) / - 2); + dKdx = barrier->quadratic_form_gradient(x, dKdv) / + 2; } return {dKdv, dKdx}; } // Approximate computation of the partial derivatives of the K term - pts approxDK(pts const &x_bar, VT &nu) + pts approxDK(pts const &x_bar, MT &nu) { - VT x = x_bar[0].getCoefficients(); - VT v = x_bar[1].getCoefficients(); + MT x = x_bar[0]; + MT v = x_bar[1]; move(x_bar); - VT dUdv_b = P.Asp * (v - P.Asp.transpose() * nu).cwiseQuotient(hess); - VT out_solver = VT(nu.rows(), nu.cols()); + MT dUdv_b = P.Asp * (v - P.Asp.transpose() * nu).cwiseQuotient(hess); + dUdv_b.transposeInPlace(); + MT out_solver = MT(nu.cols(), nu.rows()); solver.solve((Tx *)dUdv_b.data(), (Tx *)out_solver.data()); - nu = nu + out_solver; - Point dKdv = Point((v - P.Asp.transpose() * nu).cwiseQuotient(hess)); - Point dKdx = Point(n); + nu = nu + out_solver.transpose(); + + MT dKdv = (v - P.Asp.transpose() * nu).cwiseQuotient(hess); + MT dKdx = MT::Zero(n, simdLen); if (options.DynamicWeight) { - dKdx = Point( - weighted_barrier->quadratic_form_gradient(x, dKdv.getCoefficients()) / - 2); + dKdx = + weighted_barrier->quadratic_form_gradient(x, dKdv) / + 2; } else { - dKdx = Point(barrier->quadratic_form_gradient(x, dKdv.getCoefficients()) / - 2); + dKdx = barrier->quadratic_form_gradient(x, dKdv) / + 2; } return {dKdv, dKdx}; } @@ -173,24 +185,25 @@ class Hamiltonian { // This is only dependent on x and so DU/Dv=0 pts DU(pts const &x_bar) { - VT x = x_bar[0].getCoefficients(); + MT x = x_bar[0]; move(x_bar); if (!prepared || dUDx_empty) { prepare(x_bar); solver.leverageScoreComplement((Tx *)lsc.data()); if (options.DynamicWeight) { - last_dUdx = Point(-(weighted_barrier->tensor(x).cwiseProduct(lsc)) - .cwiseQuotient(2 * hess) - - dfx); + last_dUdx = (weighted_barrier->tensor(x).cwiseProduct(lsc.transpose())) + .cwiseQuotient(2 * hess) + + dfx; } else { - last_dUdx = Point( - -(barrier->tensor(x).cwiseProduct(lsc)).cwiseQuotient(2 * hess) - - dfx); + last_dUdx = + (barrier->tensor(x).cwiseProduct(lsc.transpose())).cwiseQuotient(2 * hess) + + dfx; } dUDx_empty = false; } - return {Point(n), last_dUdx}; + + return {MT::Zero(n, simdLen), -last_dUdx}; } // Compute the computations involving only x iff x has been changed // Else they are stored @@ -200,37 +213,37 @@ class Hamiltonian { return; } xs = y; - x = xs[0].getCoefficients(); - VT h; + x = xs[0]; + MT h; std::tie(fx, dfx, h) = P.f_oracle(x); if (options.DynamicWeight) { hess = weighted_barrier->hessian(x) + h; } else { hess = barrier->hessian(x) + h; } - forceUpdate = false; prepared = false; } // Project x to the polytope - void project(pts &xs) - { + void project(pts &xs) { move(xs); - VT x = xs[0].getCoefficients(); + MT x = xs[0]; int m = P.Asp.rows(); - VT out_vector = VT(m); - VT in_vector = P.b - P.Asp * x; + MT out_vector = MT(simdLen, m); + MT in_vector = (-P.Asp * x).colwise() + P.b; + in_vector.transposeInPlace(); solver.solve((Tx *)in_vector.data(), (Tx *)out_vector.data()); + out_vector.transposeInPlace(); out_vector = P.Asp.transpose() * out_vector; - xs[0] = xs[0] + Point((out_vector).cwiseQuotient(hess)); + xs[0] = xs[0] + (out_vector).cwiseQuotient(hess); } // Get the inner product of x and ds weighted by the hessian - NT x_norm(pts const &xs, pts const &dx) + VT x_norm(pts const &xs, pts const &dx) { move(xs); - VT dx_x = dx[0].getCoefficients(); - VT r = (dx_x.cwiseProduct(dx_x)).cwiseProduct(hess); - return r.sum(); + MT dx_x = dx[0]; + MT r = (dx_x.cwiseProduct(dx_x)).cwiseProduct(hess); + return r.colwise().sum(); } }; #endif diff --git a/include/random_walks/hamiltonian_monte_carlo_walk.hpp b/include/random_walks/hamiltonian_monte_carlo_walk.hpp index 3c50ca5e9..23342ea57 100644 --- a/include/random_walks/hamiltonian_monte_carlo_walk.hpp +++ b/include/random_walks/hamiltonian_monte_carlo_walk.hpp @@ -114,12 +114,10 @@ struct HamiltonianMonteCarloWalk { }; - inline void apply( - RandomNumberGenerator &rng, - int walk_length=1, - bool metropolis_filter=true) + inline void apply(RandomNumberGenerator &rng, + int walk_length=1, + bool metropolis_filter=true) { - num_runs++; // Pick a random velocity @@ -156,6 +154,7 @@ struct HamiltonianMonteCarloWalk { } } else { x = x_tilde; + accepted = true; } discard_ratio = (1.0 * total_discarded_samples) / num_runs; diff --git a/include/random_walks/nuts_hmc_walk.hpp b/include/random_walks/nuts_hmc_walk.hpp new file mode 100644 index 000000000..857064c0e --- /dev/null +++ b/include/random_walks/nuts_hmc_walk.hpp @@ -0,0 +1,380 @@ +// VolEsti (volume computation and sampling library) + +// Copyright (c) 2012-2022 Vissarion Fisikopoulos +// Copyright (c) 2018-2022 Apostolos Chalkis +// Copyright (c) 2020-2022 Elias Tsigaridas +// Copyright (c) 2020-2022 Marios Papachristou + +// Licensed under GNU LGPL.3, see LICENCE file + +// References +// Matthew D. Hoffman, Andrew Gelman. "The No-U-Turn Sampler: +// Adaptively Setting Path Lengths in Hamiltonian Monte Carlo", 2011. + +// Comment: Compared to [Matthew D. Hoffman, Andrew Gelman, 2011] +// we modify the step of Nesterov's algorithm in the burn in phase. + +#ifndef NUTS_HAMILTONIAN_MONTE_CARLO_WALK_HPP +#define NUTS_HAMILTONIAN_MONTE_CARLO_WALK_HPP + + +#include "generators/boost_random_number_generator.hpp" +#include "random_walks/gaussian_helpers.hpp" +#include "ode_solvers/ode_solvers.hpp" +#include "preprocess/estimate_L_smooth_parameter.hpp" + +struct NutsHamiltonianMonteCarloWalk { + + template + < + typename NT, + typename OracleFunctor + > + struct parameters { + NT epsilon; // tolerance in mixing + NT eta; // step size + + parameters( + OracleFunctor const& F, + unsigned int dim, + NT epsilon_=2) + { + epsilon = epsilon_; + eta = F.params.L > 0 ? 10.0 / (dim * sqrt(F.params.L)) : 0.005; + } + }; + + template + < + typename Point, + typename Polytope, + typename RandomNumberGenerator, + typename NegativeGradientFunctor, + typename NegativeLogprobFunctor, + typename Solver + > + struct Walk { + + typedef std::vector pts; + typedef typename Point::FT NT; + typedef std::vector bounds; + + // Hyperparameters of the sampler + parameters ¶ms; + + // Numerical ODE solver + Solver *solver; + + // Dimension + unsigned int dim; + + // Discarded Samples + long num_runs = 0; + long total_acceptance = 0; + + // Average acceptance probability + NT average_acceptance = 0; + + // References to xs + Point x, v; + + // Helper points + Point v_pl, v_min, v_min_j, v_pl_j, X_pl, X_pl_j, X_min, X, X_rnd_j, X_min_j, x_pl_min; + + // Gradient function + NegativeGradientFunctor &F; + + bool accepted; + + // Burnin parameters + NT eps_step, mu, log_tilde_eps, H_tilde, alpha, na; + const NT delta = NT(0.65), Delta_max = NT(1000), gamma = NT(0.05), t0 = NT(10), kk = NT(0.85); + + // Density exponent + NegativeLogprobFunctor &f; + + Walk(Polytope *P, + Point &p, + NegativeGradientFunctor &neg_grad_f, + NegativeLogprobFunctor &neg_logprob_f, + parameters ¶m, + bool burn_in_phase = true) : + params(param), + F(neg_grad_f), + f(neg_logprob_f) + { + dim = p.dimension(); + + v_pl.set_dimension(dim); + v_min.set_dimension(dim); + v_min_j.set_dimension(dim); + v_pl_j.set_dimension(dim); + X_pl.set_dimension(dim); + X_pl_j.set_dimension(dim); + X_min.set_dimension(dim); + X.set_dimension(dim); + X_rnd_j.set_dimension(dim); + X_min_j.set_dimension(dim); + x_pl_min.set_dimension(dim); + + eps_step = params.eta; + mu = std::log(10*eps_step); + log_tilde_eps = NT(0); + H_tilde = NT(0); + alpha = NT(0); + na = NT(0); + + // Starting point is provided from outside + x = p; + + accepted = false; + + // Initialize solver + solver = new Solver(0, params.eta, pts{x, x}, F, bounds{P, NULL}); + disable_adaptive(); + + if (burn_in_phase) + { + RandomNumberGenerator rng(dim); + burnin(rng); + } + }; + + + inline void burnin(RandomNumberGenerator &rng, + unsigned int N = 1000, + unsigned int walk_length=1) + { + reset_num_runs(); + Point p = x; + NT L; + + if ((solver->get_bounds())[0] == NULL) + { + L = (NT(100) / NT(dim)) * (NT(100) / NT(dim)); + } + else + { + Polytope K = *(solver->get_bounds())[0]; + L = estimate_L_smooth(K, p, walk_length, F, rng); + } + + eps_step = NT(5) / (NT(dim) * std::sqrt(L)); + solver->set_eta(eps_step); + + for (int i = 0; i < N; i++) + { + apply(rng, walk_length, true); + solver->set_eta(eps_step); + } + reset_num_runs(); + } + + + inline void apply(RandomNumberGenerator &rng, + unsigned int walk_length=1, + bool burnin = false) + { + num_runs++; + + int x_counting_total = 0; + + // Pick a random velocity + v = GetDirection::apply(dim, rng, false); + + v_pl = v; + v_min = NT(-1) * v; + X_pl = x; + X_min = x; + + NT h1 = hamiltonian(x, v); + + NT uu = std::log(rng.sample_urdist()) - h1; + int j = -1; + bool s = true; + bool updated = false; + bool pos_state_single = false; + + if (burnin) + { + alpha = NT(0); + } + + while (s) + { + j++; + + if (burnin) + { + na = std::pow(NT(2), NT(j)); + } + + NT dir = rng.sample_urdist(); + + if (dir > 0.5) + { + v = v_pl; + X = X_pl; + } + else + { + v = v_min; + X = X_min; + } + X_rnd_j = X; + + int x_counting = 0; + int num_samples = int(std::pow(NT(2), NT(j))); + accepted = false; + + for (int k = 1; k <= num_samples; k++) + { + if (!accepted) + { + solver->set_state(0, X); + solver->set_state(1, v); + } + + // Get proposals + solver->steps(walk_length, accepted); + accepted = true; + + X = solver->get_state(0); + v = solver->get_state(1); + + NT hj = hamiltonian(X, v); + + if (burnin) + { + alpha += std::min(NT(1), std::exp(-hj + h1)); + } + + if (uu > Delta_max - hj) + { + s = false; + break; + } + + bool pos_state = false; + if (uu < -hj) + { + pos_state = true; + pos_state_single = true; + x_counting = x_counting + 1; + x_counting_total = x_counting_total + 1; + } + + if (k == 1) + { + if (dir > 0.5) + { + X_min_j = X; + v_min_j = v; + } + else + { + X_pl_j = X; + v_pl_j = v; + } + } + if (k == num_samples) + { + if (dir > 0.5) + { + x_pl_min = X - X_min_j; + if ((x_pl_min.dot(v) < 0) || (x_pl_min.dot(v_min_j) < 0)) + { + s = false; + } + } + else + { + x_pl_min = X_pl_j - X; + if ((x_pl_min.dot(v) < 0) || (x_pl_min.dot(v_pl_j) < 0)) + { + s = false; + } + } + } + if ((rng.sample_urdist() < (1/NT(x_counting))) && pos_state) + { + X_rnd_j = X; + } + } + + if (dir > 0.5) + { + X_pl = X; + v_pl = v; + } + else + { + X_min = X; + v_min = v; + } + + if (s && (rng.sample_urdist() < (NT(x_counting) / NT(x_counting_total)))) + { + x = X_rnd_j; + if (pos_state_single) + { + updated = true; + } + } + + if (s) + { + x_pl_min = X_pl - X_min; + if ((x_pl_min.dot(v_min) < 0) || (x_pl_min.dot(v_pl) < 0)) + { + s = false; + } + } + } + + if (updated) + { + total_acceptance++; + } + average_acceptance = NT(total_acceptance) / NT(num_runs); + + if (burnin) + { + H_tilde = (NT(1) - NT(1) / (NT(num_runs) + t0)) * H_tilde + (NT(1) / (NT(num_runs) + t0)) * (delta - alpha / na); + NT log_eps = mu - (std::sqrt(NT(num_runs)) / gamma) * H_tilde; + + // TODO: use the following to generalize Nesterov's algorithm + //log_tilde_eps = std::pow(mu,-kk) * log_eps + (NT(1) - std::pow(mu,-kk))*log_tilde_eps; + + eps_step = std::exp(log_eps); + } + } + + inline NT hamiltonian(Point &pos, Point &vel) const { + return f(pos) + 0.5 * vel.dot(vel); + } + + inline NT get_eta_solver() { + return solver->get_eta(); + } + + void disable_adaptive() { + solver->disable_adaptive(); + } + + void enable_adaptive() { + solver->enable_adaptive(); + } + + void reset_num_runs() { + num_runs = 0; + total_acceptance = 0; + } + + NT get_ratio_acceptance() { + return average_acceptance; + } + }; +}; + +#endif // HAMILTONIAN_MONTE_CARLO_WALK_HPP diff --git a/include/random_walks/random_walks.hpp b/include/random_walks/random_walks.hpp index 4affee74d..6c36457c1 100644 --- a/include/random_walks/random_walks.hpp +++ b/include/random_walks/random_walks.hpp @@ -28,6 +28,7 @@ #include "random_walks/exponential_hamiltonian_monte_carlo_exact_walk.hpp" #include "random_walks/uniform_accelerated_billiard_walk_parallel.hpp" #include "random_walks/hamiltonian_monte_carlo_walk.hpp" +#include "random_walks/nuts_hmc_walk.hpp" #include "random_walks/langevin_walk.hpp" #include "random_walks/crhmc/crhmc_walk.hpp" #endif // RANDOM_WALKS_RANDOM_WALKS_HPP diff --git a/include/sampling/random_point_generators.hpp b/include/sampling/random_point_generators.hpp index 86b10666c..e70e14617 100644 --- a/include/sampling/random_point_generators.hpp +++ b/include/sampling/random_point_generators.hpp @@ -228,6 +228,38 @@ template typename Walk > struct LogconcaveRandomPointGenerator +{ + + template + < typename PointList, + typename WalkPolicy, + typename RandomNumberGenerator + > + static void apply(unsigned int const& rnum, + unsigned int const& walk_length, + PointList &randPoints, + WalkPolicy &policy, + RandomNumberGenerator &rng, + Walk &walk) + { + typedef double NT; + + for (unsigned int i = 0; i < rnum; ++i) + { + // Gather one sample + walk.apply(rng, walk_length); + + // Use PushBackWalkPolicy + policy.apply(randPoints, walk.x); + } + } +}; + +template +< + typename Walk +> +struct CrhmcRandomPointGenerator { template @@ -251,22 +283,38 @@ struct LogconcaveRandomPointGenerator NegativeGradientFunctor &F, NegativeLogprobFunctor &f, Parameters ¶meters, - Walk &walk) + Walk &walk, + int simdLen=1, + bool raw_output= false) { - typedef double NT; - - for (unsigned int i = 0; i < rnum; ++i) + typedef typename Walk::MT MT; + for (unsigned int i = 0; i < std::ceil((float)rnum/simdLen); ++i) { // Gather one sample walk.apply(rng, walk_length); - + if(walk.P.terminate){return;} + MT x; + if(raw_output){ + x=walk.x; + }else{ + x=walk.getPoints(); + } + if((i + 1) * simdLen > rnum){ + for(int j = 0; j < rnum-simdLen*i; j++){ + Point p = Point(x.col(j)); + policy.apply(randPoints, p); + } + break; + } // Use PushBackWalkPolicy - policy.apply(randPoints, walk.x); + for(int j=0; j void uniform_sampling(PointList &randPoints, Polytope &P, @@ -232,14 +232,14 @@ template < typename Solver > void logconcave_sampling(PointList &randPoints, - Polytope &P, - RandomNumberGenerator &rng, - const unsigned int &walk_len, - const unsigned int &rnum, - const Point &starting_point, - unsigned int const& nburns, - NegativeGradientFunctor &F, - NegativeLogprobFunctor &f) + Polytope &P, + RandomNumberGenerator &rng, + const unsigned int &walk_len, + const unsigned int &rnum, + const Point &starting_point, + unsigned int const& nburns, + NegativeGradientFunctor &F, + NegativeLogprobFunctor &f) { typedef typename WalkTypePolicy::template Walk < @@ -272,19 +272,168 @@ void logconcave_sampling(PointList &randPoints, walk logconcave_walk(&P, p, F, f, params); typedef LogconcaveRandomPointGenerator RandomPointGenerator; - - RandomPointGenerator::apply(P, p, nburns, walk_len, randPoints, - push_back_policy, rng, F, f, params, logconcave_walk); - + + if (nburns > 0) { + RandomPointGenerator::apply(nburns, walk_len, randPoints, + push_back_policy, rng, logconcave_walk); + } logconcave_walk.disable_adaptive(); randPoints.clear(); - RandomPointGenerator::apply(P, p, rnum, walk_len, randPoints, - push_back_policy, rng, F, f, params, logconcave_walk); - + RandomPointGenerator::apply(rnum, walk_len, randPoints, + push_back_policy, rng, logconcave_walk); +} +#include "preprocess/crhmc/crhmc_input.h" +#include "preprocess/crhmc/crhmc_problem.h" +template + < + typename PointList, + typename Polytope, + typename RandomNumberGenerator, + typename WalkTypePolicy, + typename NT, + typename Point, + typename NegativeGradientFunctor, + typename NegativeLogprobFunctor, + typename HessianFunctor, + typename Solver + > +void crhmc_sampling(PointList &randPoints, + Polytope &P, + RandomNumberGenerator &rng, + const int walk_len, + const unsigned int rnum, + const unsigned int nburns, + NegativeGradientFunctor &F, + NegativeLogprobFunctor &f, + HessianFunctor &h, + int simdLen = 1, + bool raw_output=false) { + typedef typename Polytope::MT MatrixType; + typedef crhmc_input + < + MatrixType, + Point, + NegativeLogprobFunctor, + NegativeGradientFunctor, + HessianFunctor + > Input; + Input input = convert2crhmc_input(P, f, F, h); + typedef crhmc_problem CrhmcProblem; + CrhmcProblem problem = CrhmcProblem(input); + if(problem.terminate){return;} + typedef typename WalkTypePolicy::template Walk + < + Point, + CrhmcProblem, + RandomNumberGenerator, + NegativeGradientFunctor, + NegativeLogprobFunctor, + Solver + > walk; + typedef typename WalkTypePolicy::template parameters + < + NT, + NegativeGradientFunctor + > walk_params; + Point p = Point(problem.center); + problem.options.simdLen=simdLen; + walk_params params(input.df, p.dimension(), problem.options); + + if (input.df.params.eta > 0) { + params.eta = input.df.params.eta; + } + + PushBackWalkPolicy push_back_policy; + + walk crhmc_walk = walk(problem, p, input.df, input.f, params); + + typedef CrhmcRandomPointGenerator RandomPointGenerator; + + RandomPointGenerator::apply(problem, p, nburns, walk_len, randPoints, + push_back_policy, rng, F, f, params, crhmc_walk); + //crhmc_walk.disable_adaptive(); + randPoints.clear(); + RandomPointGenerator::apply(problem, p, rnum, walk_len, randPoints, + push_back_policy, rng, F, f, params, crhmc_walk, simdLen, raw_output); +} +#include "ode_solvers/ode_solvers.hpp" +template < + typename Polytope, + typename RNGType, + typename PointList, + typename NegativeGradientFunctor, + typename NegativeLogprobFunctor, + typename HessianFunctor, + typename CRHMCWalk, + int simdLen=1 +> +void execute_crhmc(Polytope &P, RNGType &rng, PointList &randPoints, + unsigned int const& walkL, unsigned int const& numpoints, + unsigned int const& nburns, NegativeGradientFunctor *F=NULL, + NegativeLogprobFunctor *f=NULL, HessianFunctor *h=NULL, bool raw_output= false){ +typedef typename Polytope::MT MatrixType; +typedef typename Polytope::PointType Point; +typedef typename Point::FT NT; +if(h!=NULL){ +typedef crhmc_input + < + MatrixType, + Point, + NegativeLogprobFunctor, + NegativeGradientFunctor, + HessianFunctor + > Input; +typedef crhmc_problem CrhmcProblem; +crhmc_sampling < + PointList, + Polytope, + RNGType, + CRHMCWalk, + NT, + Point, + NegativeGradientFunctor, + NegativeLogprobFunctor, + HessianFunctor, + ImplicitMidpointODESolver < + Point, + NT, + CrhmcProblem, + NegativeGradientFunctor, + simdLen + > +>(randPoints, P, rng, walkL, numpoints, nburns, *F, *f, *h, simdLen, raw_output); +}else{ + typedef crhmc_input + < + MatrixType, + Point, + NegativeLogprobFunctor, + NegativeGradientFunctor, + ZeroFunctor + > Input; + typedef crhmc_problem CrhmcProblem; + ZeroFunctor zerof; +crhmc_sampling < + PointList, + Polytope, + RNGType, + CRHMCWalk, + NT, + Point, + NegativeGradientFunctor, + NegativeLogprobFunctor, + ZeroFunctor, + ImplicitMidpointODESolver < + Point, + NT, + CrhmcProblem, + NegativeGradientFunctor, + simdLen + > +>(randPoints, P, rng, walkL, numpoints, nburns, *F, *f, zerof, simdLen, raw_output); +} } - - template < typename WalkTypePolicy, diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ddd40e362..cd07db64c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,8 @@ endif() option(DISABLE_NLP_ORACLES "Disable non-linear oracles (used in collocation)" ON) option(BUILTIN_EIGEN "Use eigen from ../external" OFF) -option(USE_MKL "Use MKL library to build eigen" ON) +option(BUILTIN_AUTODIFF "Use autodiff from ../external" ON) +option(USE_MKL "Use MKL library to build eigen" OFF) if(DISABLE_NLP_ORACLES) add_definitions(-DDISABLE_NLP_ORACLES) @@ -106,6 +107,9 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) +include("../external/cmake-files/Autodiff.cmake") +GetAutodiff() + include("../external/cmake-files/Eigen.cmake") GetEigen() @@ -136,264 +140,251 @@ if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") endif() endif(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") -find_library(LP_SOLVE NAMES liblpsolve55.so liblpsolve55.dylib PATHS /usr/lib/lp_solve /usr/local/lib) - -if (NOT LP_SOLVE) - - message(FATAL_ERROR "This program requires the lp_solve library, and will not be compiled.") - +if (BUILTIN_AUTODIFF) + include_directories (BEFORE ../../external/_deps/Autodiff) else () + include_directories(BEFORE /usr/local/include) +endif(BUILTIN_AUTODIFF) + +set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") + +if (USE_MKL) + find_library(BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib) + find_library(GFORTRAN NAME libgfortran.dylib PATHS /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10) + find_library(LAPACK NAME liblapack.dylib PATHS /usr/lib) + find_library(OPENMP NAME libiomp5.dylib PATHS /opt/intel/oneapi/compiler/2021.1.1/mac/compiler/lib) + include_directories (BEFORE ${MKLROOT}/include) + set(PROJECT_LIBS ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN_LIBRARIES}) + set(MKL_LINK "-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") + add_definitions(-DEIGEN_USE_MKL_ALL) +else() + set(MKL_LINK "") +endif(USE_MKL) - message(STATUS "Library lp_solve found: ${LP_SOLVE}") - set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") - - if (USE_MKL) - find_library(BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib) - find_library(GFORTRAN NAME libgfortran.dylib PATHS /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10) - find_library(LAPACK NAME liblapack.dylib PATHS /usr/lib) - find_library(OPENMP NAME libiomp5.dylib PATHS /opt/intel/oneapi/compiler/2021.1.1/mac/compiler/lib) - - include_directories (BEFORE ${MKLROOT}/include) - set(PROJECT_LIBS ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN_LIBRARIES}) - set(MKL_LINK "-L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") - add_definitions(-DEIGEN_USE_MKL_ALL) - else() - set(MKL_LINK "") - endif(USE_MKL) - - include_directories (BEFORE ../external) - include_directories (BEFORE ../external/minimum_ellipsoid) - include_directories (BEFORE ../include/generators) - include_directories (BEFORE ../include/volume) - include_directories (BEFORE ../include) - include_directories (BEFORE ../include/integration) - include_directories (BEFORE ../include/convex_bodies) - include_directories (BEFORE ../include/convex_bodies/spectrahedra) - include_directories (BEFORE ../include/annealing) - include_directories (BEFORE ../include/ode_solvers) - include_directories (BEFORE ../include/root_finders) - include_directories (BEFORE ../include/samplers) - include_directories (BEFORE ../include/lp_oracles) - include_directories (BEFORE ../include/nlp_oracles) - include_directories (BEFORE ../include/misc) - include_directories (BEFORE ../test) - - #for Eigen - if (${CMAKE_VERSION} VERSION_LESS "3.12.0") - add_compile_options(-D "EIGEN_NO_DEBUG") - else () - add_compile_definitions("EIGEN_NO_DEBUG") - endif () - - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard - add_definitions(${CMAKE_CXX_FLAGS} "-g") # enable debuger - #add_definitions(${CMAKE_CXX_FLAGS} "-Wint-in-bool-context") - #add_definitions(${CMAKE_CXX_FLAGS} "-Wall") - - add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler - #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") - add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") - add_definitions(${CMAKE_CXX_FLAGS} "-DMKL_ILP64") - #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgslcblas") - #add_definitions( "-O3 -lgsl -lm -ldl -lgslcblas" ) - - add_executable (new_volume_example new_volume_example.cpp) - add_executable (benchmarks_sob benchmarks_sob.cpp) - add_executable (benchmarks_cg benchmarks_cg.cpp) - add_executable (benchmarks_cb benchmarks_cb.cpp) - - add_library(test_main OBJECT test_main.cpp) - - add_executable (mcmc_diagnostics_test mcmc_diagnostics_test.cpp $) - add_test(NAME test_psrf COMMAND mcmc_diagnostics_test -tc=psrf) - add_test(NAME test_univariate_psrf COMMAND mcmc_diagnostics_test -tc=univariate_psrf) - add_test(NAME test_interval_psrf COMMAND mcmc_diagnostics_test -tc=interval_psrf) - add_test(NAME test_ess COMMAND mcmc_diagnostics_test -tc=ess) - add_test(NAME test_geweke COMMAND mcmc_diagnostics_test -tc=geweke) - add_test(NAME test_raftery COMMAND mcmc_diagnostics_test -tc=raftery) - - add_executable (sampling_test sampling_test.cpp $) - add_test(NAME test_dikin COMMAND sampling_test -tc=dikin) - add_test(NAME test_john COMMAND sampling_test -tc=john) - add_test(NAME test_vaidya COMMAND sampling_test -tc=vaidya) - add_test(NAME test_brdhr COMMAND sampling_test -tc=brdhr) - add_test(NAME test_bcdhr COMMAND sampling_test -tc=bcdhr) - add_test(NAME test_grdhr COMMAND sampling_test -tc=grdhr) - add_test(NAME test_gbaw COMMAND sampling_test -tc=gbaw) - add_test(NAME test_ghmc COMMAND sampling_test -tc=ghmc) - - add_executable (mmcs_test mmcs_test.cpp $) - add_test(NAME test_mmcs COMMAND mmcs_test -tc=mmcs) - - add_executable (ode_solvers_test ode_solvers_test.cpp $) - add_test(NAME ode_solvers_test_first_order - COMMAND ode_solvers_test -tc=first_order) - add_test(NAME ode_solvers_test_second_order - COMMAND ode_solvers_test -tc=second_order) - - add_executable (root_finders_test root_finders_test.cpp $) - add_test(NAME root_finders_test_root_finders - COMMAND root_finders_test -tc=root_finders) - - #add_executable (benchmarks_crhmc benchmarks_crhmc.cpp ) - #add_executable (benchmarks_crhmc_sampling benchmarks_crhmc_sampling.cpp ) - - add_executable (crhmc_polytope_preparation_test crhmc_polytope_preparation_test.cpp $) - add_test(NAME crhmc_polytope_test_preparation - COMMAND crhmc_polytope_preparation_test -tc=test_preparation_crhmc) - add_test(NAME crhmc_test_fixed_vars - COMMAND crhmc_polytope_preparation_test -tc=test_fixed_vars_crhmc) - add_test(NAME crhmc_test_dep_vars - COMMAND crhmc_polytope_preparation_test -tc=test_dep_vars_crhmc) - add_test(NAME crhmc_test_center_computation - COMMAND crhmc_polytope_preparation_test -tc=test_center_computation) - - add_executable (boundary_oracles_test boundary_oracles_test.cpp $) - add_test(NAME boundary_oracles_test_h_poly_oracles - COMMAND boundary_oracles_test -tc=h_poly_oracles) - - add_executable (volume_sob_hpolytope volume_sob_hpolytope.cpp $) - add_test(NAME volume_sob_hpolytope_cube COMMAND volume_sob_hpolytope -tc=cube) - add_test(NAME volume_sob_hpolytope_cross COMMAND volume_sob_hpolytope -tc=cross) - add_test(NAME volume_sob_hpolytope_birkhoff COMMAND volume_sob_hpolytope -tc=birk) - add_test(NAME volume_sob_hpolytope_prod_simplex COMMAND volume_sob_hpolytope -tc=prod_simplex) - add_test(NAME volume_sob_hpolytope_simplex COMMAND volume_sob_hpolytope -tc=simplex) - add_test(NAME volume_sob_hpolytope_skinny_cube COMMAND volume_sob_hpolytope -tc=skinny_cube) - add_test(NAME volume_sob_hpolytope_cube_overflow COMMAND volume_sob_hpolytope -tc=cube_overflow) - set_property(TEST volume_sob_hpolytope_cube_overflow PROPERTY TIMEOUT 1) - - add_executable (volume_sob_vpolytope volume_sob_vpolytope.cpp $) - add_test(NAME volume_sob_vpolytope_cube COMMAND volume_sob_vpolytope -tc=cube) - add_test(NAME volume_sob_vpolytope_cross COMMAND volume_sob_vpolytope -tc=cross) - add_test(NAME volume_sob_vpolytope_simplex COMMAND volume_sob_vpolytope -tc=simplex) - - add_executable (volume_cg_hpolytope volume_cg_hpolytope.cpp $) - add_test(NAME volume_cg_hpolytope_cube COMMAND volume_cg_hpolytope -tc=cube) - add_test(NAME volume_cg_hpolytope_cross COMMAND volume_cg_hpolytope -tc=cross) - add_test(NAME volume_cg_hpolytope_birkhoff COMMAND volume_cg_hpolytope -tc=birk) - add_test(NAME volume_cg_hpolytope_prod_simplex COMMAND volume_cg_hpolytope -tc=prod_simplex) - add_test(NAME volume_cg_hpolytope_simplex COMMAND volume_cg_hpolytope -tc=simplex) - add_test(NAME volume_cg_hpolytope_skinny_cube COMMAND volume_cg_hpolytope -tc=skinny_cube) - - add_executable (volume_cg_vpolytope volume_cg_vpolytope.cpp $) - add_test(NAME volume_cg_vpolytope_cube COMMAND volume_cg_vpolytope -tc=cube) - add_test(NAME volume_cg_vpolytope_cross COMMAND volume_cg_vpolytope -tc=cross) - add_test(NAME volume_cg_vpolytope_simplex COMMAND volume_cg_vpolytope -tc=simplex) - - add_executable (volume_cb_hpolytope volume_cb_hpolytope.cpp $) - add_test(NAME volume_cb_hpolytope_cube COMMAND volume_cb_hpolytope -tc=cube) - add_test(NAME volume_cb_hpolytope_cross COMMAND volume_cb_hpolytope -tc=cross) - add_test(NAME volume_cb_hpolytope_birkhoff COMMAND volume_cb_hpolytope -tc=birk) - add_test(NAME volume_cb_hpolytope_prod_simplex COMMAND volume_cb_hpolytope -tc=prod_simplex) - add_test(NAME volume_cb_hpolytope_simplex COMMAND volume_cb_hpolytope -tc=simplex) - add_test(NAME volume_cb_hpolytope_skinny_cube COMMAND volume_cb_hpolytope -tc=skinny_cube) - - add_executable (volume_cb_vpolytope volume_cb_vpolytope.cpp $) - add_test(NAME volume_cb_vpolytope_cube COMMAND volume_cb_vpolytope -tc=cube) - add_test(NAME volume_cb_vpolytope_cross COMMAND volume_cb_vpolytope -tc=cross) - add_test(NAME volume_cb_vpolytope_simplex COMMAND volume_cb_vpolytope -tc=simplex) - - add_executable (volume_cb_zonotopes volume_cb_zonotopes.cpp $) - add_test(NAME volume_cb_zonotopes_uniform_zonotopes - COMMAND volume_cb_zonotopes -tc=uniform_zonotopes) - - add_executable (volume_cb_vpoly_intersection_vpoly volume_cb_vpoly_intersection_vpoly.cpp $) - add_test(NAME volume_cb_vpoly_intersection_vpoly_random_vpoly_sphere - COMMAND volume_cb_vpoly_intersection_vpoly -tc=random_vpoly_sphere) - - add_executable (new_rounding_test new_rounding_test.cpp $) - add_test(NAME test_round_min_ellipsoid - COMMAND new_rounding_test -tc=round_min_ellipsoid) - add_test(NAME test_round_max_ellipsoid - COMMAND new_rounding_test -tc=round_max_ellipsoid) - add_test(NAME test_round_svd - COMMAND new_rounding_test -tc=round_svd) - - add_executable (logconcave_sampling_test logconcave_sampling_test.cpp $) - add_test(NAME logconcave_sampling_test_hmc - COMMAND logconcave_sampling_test -tc=hmc) - add_test(NAME logconcave_sampling_test_uld - COMMAND logconcave_sampling_test -tc=uld) - add_test(NAME logconcave_sampling_test_exponential_biomass_sampling - COMMAND logconcave_sampling_test -tc=exponential_biomass_sampling) - - add_executable (crhmc_sampling_test crhmc_sampling_test.cpp $) - add_test(NAME crhmc_sampling_test_crhmc - COMMAND crhmc_sampling_test -tc=crhmc) - add_test(NAME crhmc_test_polytope_sampling - COMMAND crhmc_sampling_test -tc=test_polytope_sampling_crhmc) - - add_executable (simple_mc_integration simple_mc_integration.cpp $) - add_test(NAME simple_mc_integration_over_limits - COMMAND simple_mc_integration -tc=rectangle) - add_test(NAME simple_mc_integration_over_cubes - COMMAND simple_mc_integration -tc=cube) - add_test(NAME simple_mc_integration_over_simplices - COMMAND simple_mc_integration -tc=simplex) - add_test(NAME simple_mc_integration_over_product_simplices - COMMAND simple_mc_integration -tc=prod_simplex) - add_test(NAME simple_mc_integration_over_cross_polytopes - COMMAND simple_mc_integration -tc=cross) - add_test(NAME simple_mc_integration_over_birkhoff_polytopes - COMMAND simple_mc_integration -tc=birkhoff) - - add_executable (order_polytope order_polytope.cpp $) - add_test(NAME order_polytope_basics COMMAND order_polytope -tc=basics) - add_test(NAME order_polytope_line_intersect COMMAND order_polytope -tc=line_intersect) - add_test(NAME order_polytope_reflection COMMAND order_polytope -tc=reflection) - add_test(NAME order_polytope_vec_mult COMMAND order_polytope -tc=vec_mult) - - add_executable (matrix_sampling_test sampling_correlation_matrices_test.cpp $) - add_test(NAME test_corre_spectra_classes COMMAND matrix_sampling_test -tc=corre_spectra) - add_test(NAME test_new_ball_uniform COMMAND matrix_sampling_test -tc=new_ball_uniform) - add_test(NAME test_new_billiard_uniform COMMAND matrix_sampling_test -tc=new_billiard_uniform) - add_test(NAME test_new_accelerated_billiard_uniform COMMAND matrix_sampling_test -tc=new_accelerated_billiard_uniform) - add_test(NAME test_new_ball_uniform_MT COMMAND matrix_sampling_test -tc=new_ball_uniform_MT) - add_test(NAME test_new_rdhr_uniform_MT COMMAND matrix_sampling_test -tc=new_rdhr_uniform_MT) - add_test(NAME test_new_billiard_uniform_MT COMMAND matrix_sampling_test -tc=new_billiard_uniform_MT) - add_test(NAME test_new_accelerated_billiard_uniform_MT COMMAND matrix_sampling_test -tc=new_accelerated_billiard_uniform_MT) - - set(ADDITIONAL_FLAGS "-march=native -DSIMD_LEN=0 -DTIME_KEEPING") - - #set_target_properties(benchmarks_crhmc - # PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) - #set_target_properties(benchmarks_crhmc_sampling - # PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) - set_target_properties(crhmc_polytope_preparation_test - PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) - set_target_properties(crhmc_sampling_test - PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) - - TARGET_LINK_LIBRARIES(new_volume_example ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(new_volume_example ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_sob_hpolytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_sob_vpolytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cg_hpolytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cg_vpolytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cb_hpolytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cb_vpolytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cb_zonotopes ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cb_vpoly_intersection_vpoly ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(volume_cb_vpoly_intersection_vpoly ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(new_rounding_test ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(mcmc_diagnostics_test ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(sampling_test ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(mmcs_test ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(benchmarks_sob ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(benchmarks_cg ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(benchmarks_cb ${LP_SOLVE} ${MKL_LINK} coverage_config) - #TARGET_LINK_LIBRARIES(benchmarks_crhmc_sampling ${LP_SOLVE} ${MKL_LINK} ${QD_LIB} coverage_config) - #TARGET_LINK_LIBRARIES(benchmarks_crhmc ${LP_SOLVE} ${MKL_LINK} ${QD_LIB} coverage_config) - TARGET_LINK_LIBRARIES(simple_mc_integration ${LP_SOLVE} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(ode_solvers_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} ${QD_LIB} coverage_config) - TARGET_LINK_LIBRARIES(boundary_oracles_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(root_finders_test ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(crhmc_polytope_preparation_test ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} ${QD_LIB} coverage_config) - TARGET_LINK_LIBRARIES(logconcave_sampling_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} coverage_config) - TARGET_LINK_LIBRARIES(crhmc_sampling_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} ${QD_LIB} coverage_config) - TARGET_LINK_LIBRARIES(order_polytope ${LP_SOLVE} coverage_config) - TARGET_LINK_LIBRARIES(matrix_sampling_test ${LP_SOLVE} ${MKL_LINK} coverage_config) +include_directories (BEFORE ../external) +include_directories (BEFORE ../include) -endif() +#for Eigen +if (${CMAKE_VERSION} VERSION_LESS "3.12.0") + add_compile_options(-D "EIGEN_NO_DEBUG") +else () + add_compile_definitions("EIGEN_NO_DEBUG") +endif () + +add_definitions(${CMAKE_CXX_FLAGS} "-g") # enable debuger +#add_definitions(${CMAKE_CXX_FLAGS} "-Wint-in-bool-context") +#add_definitions(${CMAKE_CXX_FLAGS} "-Wall") + +add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler +set(CMAKE_CXX_STANDARD 17) #enable the c++17 support needed by autodiff +#add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") +add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") +add_definitions(${CMAKE_CXX_FLAGS} "-DMKL_ILP64") +#add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgslcblas") +#add_definitions( "-O3 -lgsl -lm -ldl -lgslcblas" ) + +add_executable (new_volume_example new_volume_example.cpp) +add_executable (benchmarks_sob benchmarks_sob.cpp) +add_executable (benchmarks_cg benchmarks_cg.cpp) +add_executable (benchmarks_cb benchmarks_cb.cpp) + +add_library(test_main OBJECT test_main.cpp) + +add_executable (mcmc_diagnostics_test mcmc_diagnostics_test.cpp $) +add_test(NAME test_psrf COMMAND mcmc_diagnostics_test -tc=psrf) +add_test(NAME test_univariate_psrf COMMAND mcmc_diagnostics_test -tc=univariate_psrf) +add_test(NAME test_interval_psrf COMMAND mcmc_diagnostics_test -tc=interval_psrf) +add_test(NAME test_ess COMMAND mcmc_diagnostics_test -tc=ess) +add_test(NAME test_geweke COMMAND mcmc_diagnostics_test -tc=geweke) +add_test(NAME test_raftery COMMAND mcmc_diagnostics_test -tc=raftery) + +add_executable (sampling_test sampling_test.cpp $) +add_test(NAME test_dikin COMMAND sampling_test -tc=dikin) +add_test(NAME test_john COMMAND sampling_test -tc=john) +add_test(NAME test_vaidya COMMAND sampling_test -tc=vaidya) +add_test(NAME test_brdhr COMMAND sampling_test -tc=brdhr) +add_test(NAME test_bcdhr COMMAND sampling_test -tc=bcdhr) +add_test(NAME test_grdhr COMMAND sampling_test -tc=grdhr) +add_test(NAME test_gbaw COMMAND sampling_test -tc=gbaw) +add_test(NAME test_ghmc COMMAND sampling_test -tc=ghmc) + +add_executable (mmcs_test mmcs_test.cpp $) +add_test(NAME test_mmcs COMMAND mmcs_test -tc=mmcs) + +add_executable (ode_solvers_test ode_solvers_test.cpp $) +add_test(NAME ode_solvers_test_first_order + COMMAND ode_solvers_test -tc=first_order) +add_test(NAME ode_solvers_test_second_order + COMMAND ode_solvers_test -tc=second_order) + +add_executable (root_finders_test root_finders_test.cpp $) +add_test(NAME root_finders_test_root_finders + COMMAND root_finders_test -tc=root_finders) + +#add_executable (benchmarks_crhmc benchmarks_crhmc.cpp ) +#add_executable (benchmarks_crhmc_sampling benchmarks_crhmc_sampling.cpp ) + +add_executable (crhmc_polytope_preparation_test crhmc_polytope_preparation_test.cpp $) +add_test(NAME crhmc_polytope_test_preparation + COMMAND crhmc_polytope_preparation_test -tc=test_preparation_crhmc) +add_test(NAME crhmc_test_fixed_vars + COMMAND crhmc_polytope_preparation_test -tc=test_fixed_vars_crhmc) +add_test(NAME crhmc_test_dep_vars + COMMAND crhmc_polytope_preparation_test -tc=test_dep_vars_crhmc) +add_test(NAME crhmc_test_center_computation + COMMAND crhmc_polytope_preparation_test -tc=test_center_computation) + +add_executable (boundary_oracles_test boundary_oracles_test.cpp $) +add_test(NAME boundary_oracles_test_h_poly_oracles + COMMAND boundary_oracles_test -tc=h_poly_oracles) + +add_executable (volume_sob_hpolytope volume_sob_hpolytope.cpp $) +add_test(NAME volume_sob_hpolytope_cube COMMAND volume_sob_hpolytope -tc=cube) +add_test(NAME volume_sob_hpolytope_cross COMMAND volume_sob_hpolytope -tc=cross) +add_test(NAME volume_sob_hpolytope_birkhoff COMMAND volume_sob_hpolytope -tc=birk) +add_test(NAME volume_sob_hpolytope_prod_simplex COMMAND volume_sob_hpolytope -tc=prod_simplex) +add_test(NAME volume_sob_hpolytope_simplex COMMAND volume_sob_hpolytope -tc=simplex) +add_test(NAME volume_sob_hpolytope_skinny_cube COMMAND volume_sob_hpolytope -tc=skinny_cube) +add_test(NAME volume_sob_hpolytope_cube_overflow COMMAND volume_sob_hpolytope -tc=cube_overflow) +set_property(TEST volume_sob_hpolytope_cube_overflow PROPERTY TIMEOUT 1) + +add_executable (volume_sob_vpolytope volume_sob_vpolytope.cpp $) +add_test(NAME volume_sob_vpolytope_cube COMMAND volume_sob_vpolytope -tc=cube) +add_test(NAME volume_sob_vpolytope_cross COMMAND volume_sob_vpolytope -tc=cross) +add_test(NAME volume_sob_vpolytope_simplex COMMAND volume_sob_vpolytope -tc=simplex) + +add_executable (volume_cg_hpolytope volume_cg_hpolytope.cpp $) +add_test(NAME volume_cg_hpolytope_cube COMMAND volume_cg_hpolytope -tc=cube) +add_test(NAME volume_cg_hpolytope_cross COMMAND volume_cg_hpolytope -tc=cross) +add_test(NAME volume_cg_hpolytope_birkhoff COMMAND volume_cg_hpolytope -tc=birk) +add_test(NAME volume_cg_hpolytope_prod_simplex COMMAND volume_cg_hpolytope -tc=prod_simplex) +add_test(NAME volume_cg_hpolytope_simplex COMMAND volume_cg_hpolytope -tc=simplex) +add_test(NAME volume_cg_hpolytope_skinny_cube COMMAND volume_cg_hpolytope -tc=skinny_cube) + +add_executable (volume_cg_vpolytope volume_cg_vpolytope.cpp $) +add_test(NAME volume_cg_vpolytope_cube COMMAND volume_cg_vpolytope -tc=cube) +add_test(NAME volume_cg_vpolytope_cross COMMAND volume_cg_vpolytope -tc=cross) +add_test(NAME volume_cg_vpolytope_simplex COMMAND volume_cg_vpolytope -tc=simplex) + +add_executable (volume_cb_hpolytope volume_cb_hpolytope.cpp $) +add_test(NAME volume_cb_hpolytope_cube COMMAND volume_cb_hpolytope -tc=cube) +add_test(NAME volume_cb_hpolytope_cross COMMAND volume_cb_hpolytope -tc=cross) +add_test(NAME volume_cb_hpolytope_birkhoff COMMAND volume_cb_hpolytope -tc=birk) +add_test(NAME volume_cb_hpolytope_prod_simplex COMMAND volume_cb_hpolytope -tc=prod_simplex) +add_test(NAME volume_cb_hpolytope_simplex COMMAND volume_cb_hpolytope -tc=simplex) +add_test(NAME volume_cb_hpolytope_skinny_cube COMMAND volume_cb_hpolytope -tc=skinny_cube) + +add_executable (volume_cb_vpolytope volume_cb_vpolytope.cpp $) +add_test(NAME volume_cb_vpolytope_cube COMMAND volume_cb_vpolytope -tc=cube) +add_test(NAME volume_cb_vpolytope_cross COMMAND volume_cb_vpolytope -tc=cross) +add_test(NAME volume_cb_vpolytope_simplex COMMAND volume_cb_vpolytope -tc=simplex) + +add_executable (volume_cb_zonotopes volume_cb_zonotopes.cpp $) +add_test(NAME volume_cb_zonotopes_uniform_zonotopes + COMMAND volume_cb_zonotopes -tc=uniform_zonotopes) + +add_executable (volume_cb_vpoly_intersection_vpoly volume_cb_vpoly_intersection_vpoly.cpp $) +add_test(NAME volume_cb_vpoly_intersection_vpoly_random_vpoly_sphere + COMMAND volume_cb_vpoly_intersection_vpoly -tc=random_vpoly_sphere) + +add_executable (new_rounding_test new_rounding_test.cpp $) +add_test(NAME test_round_min_ellipsoid + COMMAND new_rounding_test -tc=round_min_ellipsoid) +add_test(NAME test_round_max_ellipsoid + COMMAND new_rounding_test -tc=round_max_ellipsoid) +add_test(NAME test_round_svd + COMMAND new_rounding_test -tc=round_svd) + +add_executable (logconcave_sampling_test logconcave_sampling_test.cpp $) +add_test(NAME logconcave_sampling_test_hmc + COMMAND logconcave_sampling_test -tc=hmc) +add_test(NAME logconcave_sampling_test_uld + COMMAND logconcave_sampling_test -tc=uld) +add_test(NAME logconcave_sampling_test_exponential_biomass_sampling + COMMAND logconcave_sampling_test -tc=exponential_biomass_sampling) +add_test(NAME logconcave_sampling_test_nuts_hmc_truncated + COMMAND logconcave_sampling_test -tc=benchmark_nuts_hmc_truncated) +add_test(NAME logconcave_sampling_test_nuts_hmc + COMMAND logconcave_sampling_test -tc=benchmark_nuts_hmc) + + + +add_executable (crhmc_sampling_test crhmc_sampling_test.cpp $) +add_test(NAME crhmc_sampling_test_crhmc + COMMAND crhmc_sampling_test -tc=crhmc) +add_test(NAME crhmc_test_polytope_sampling + COMMAND crhmc_sampling_test -tc=test_polytope_sampling_crhmc) +add_test(NAME crhmc_test_sparse_sampling + COMMAND crhmc_sampling_test -tc=test_sampling_sparse_problem) +add_executable (simple_mc_integration simple_mc_integration.cpp $) +add_test(NAME simple_mc_integration_over_limits + COMMAND simple_mc_integration -tc=rectangle) +add_test(NAME simple_mc_integration_over_cubes + COMMAND simple_mc_integration -tc=cube) +add_test(NAME simple_mc_integration_over_simplices + COMMAND simple_mc_integration -tc=simplex) +add_test(NAME simple_mc_integration_over_product_simplices + COMMAND simple_mc_integration -tc=prod_simplex) +add_test(NAME simple_mc_integration_over_cross_polytopes + COMMAND simple_mc_integration -tc=cross) +add_test(NAME simple_mc_integration_over_birkhoff_polytopes + COMMAND simple_mc_integration -tc=birkhoff) + +add_executable (order_polytope order_polytope.cpp $) +add_test(NAME order_polytope_basics COMMAND order_polytope -tc=basics) +add_test(NAME order_polytope_line_intersect COMMAND order_polytope -tc=line_intersect) +add_test(NAME order_polytope_reflection COMMAND order_polytope -tc=reflection) +add_test(NAME order_polytope_vec_mult COMMAND order_polytope -tc=vec_mult) + +add_executable (matrix_sampling_test sampling_correlation_matrices_test.cpp $) +add_test(NAME test_corre_spectra_classes COMMAND matrix_sampling_test -tc=corre_spectra) +add_test(NAME test_new_ball_uniform COMMAND matrix_sampling_test -tc=new_ball_uniform) +add_test(NAME test_new_billiard_uniform COMMAND matrix_sampling_test -tc=new_billiard_uniform) +add_test(NAME test_new_accelerated_billiard_uniform COMMAND matrix_sampling_test -tc=new_accelerated_billiard_uniform) +add_test(NAME test_new_ball_uniform_MT COMMAND matrix_sampling_test -tc=new_ball_uniform_MT) +add_test(NAME test_new_rdhr_uniform_MT COMMAND matrix_sampling_test -tc=new_rdhr_uniform_MT) +add_test(NAME test_new_billiard_uniform_MT COMMAND matrix_sampling_test -tc=new_billiard_uniform_MT) +add_test(NAME test_new_accelerated_billiard_uniform_MT COMMAND matrix_sampling_test -tc=new_accelerated_billiard_uniform_MT) + +set(ADDITIONAL_FLAGS "-march=native -DSIMD_LEN=0 -DTIME_KEEPING") + +#set_target_properties(benchmarks_crhmc +# PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) +#set_target_properties(benchmarks_crhmc_sampling +# PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) +set_target_properties(crhmc_polytope_preparation_test + PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) +set_target_properties(crhmc_sampling_test + PROPERTIES COMPILE_FLAGS ${ADDITIONAL_FLAGS}) + +TARGET_LINK_LIBRARIES(new_volume_example lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(new_volume_example lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_sob_hpolytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_sob_vpolytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cg_hpolytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cg_vpolytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cb_hpolytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cb_vpolytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cb_zonotopes lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cb_vpoly_intersection_vpoly lp_solve coverage_config) +TARGET_LINK_LIBRARIES(volume_cb_vpoly_intersection_vpoly lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(new_rounding_test lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(mcmc_diagnostics_test lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(sampling_test lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(mmcs_test lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(benchmarks_sob lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(benchmarks_cg lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(benchmarks_cb lp_solve ${MKL_LINK} coverage_config) +#TARGET_LINK_LIBRARIES(benchmarks_crhmc_sampling lp_solve ${MKL_LINK} QD_LIB coverage_config) +#TARGET_LINK_LIBRARIES(benchmarks_crhmc lp_solve ${MKL_LINK} QD_LIB coverage_config) +TARGET_LINK_LIBRARIES(simple_mc_integration lp_solve ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(ode_solvers_test lp_solve ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} QD_LIB coverage_config) +TARGET_LINK_LIBRARIES(boundary_oracles_test lp_solve ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(root_finders_test ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(crhmc_polytope_preparation_test ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} QD_LIB coverage_config) +TARGET_LINK_LIBRARIES(logconcave_sampling_test lp_solve ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} coverage_config) +TARGET_LINK_LIBRARIES(crhmc_sampling_test lp_solve ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${MKL_LINK} QD_LIB coverage_config) +TARGET_LINK_LIBRARIES(order_polytope lp_solve coverage_config) +TARGET_LINK_LIBRARIES(matrix_sampling_test lp_solve ${MKL_LINK} coverage_config) diff --git a/test/benchmarks_cb.cpp b/test/benchmarks_cb.cpp index 5837109e3..6d6c95a6d 100644 --- a/test/benchmarks_cb.cpp +++ b/test/benchmarks_cb.cpp @@ -21,7 +21,7 @@ #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "exact_vols.h" +#include "volume/exact_vols.h" #include "generators/known_polytope_generators.h" int main() diff --git a/test/benchmarks_cg.cpp b/test/benchmarks_cg.cpp index d9c6964d9..4a6a91198 100644 --- a/test/benchmarks_cg.cpp +++ b/test/benchmarks_cg.cpp @@ -21,7 +21,7 @@ #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "exact_vols.h" +#include "volume/exact_vols.h" #include "generators/known_polytope_generators.h" int main() diff --git a/test/benchmarks_crhmc.cpp b/test/benchmarks_crhmc.cpp index 848c4d6db..2354a4964 100644 --- a/test/benchmarks_crhmc.cpp +++ b/test/benchmarks_crhmc.cpp @@ -24,12 +24,13 @@ #include #include using NT = double; +using VT = Eigen::Matrix; +using MT = Eigen::Matrix; using Kernel = Cartesian; using Point = typename Kernel::Point; using Hpolytope = HPolytope; using Input = crhmc_input; using CrhmcProblem = crhmc_problem; -using VT = Eigen::Matrix; inline bool exists_check(const std::string &name) { std::ifstream f(name.c_str()); @@ -50,9 +51,9 @@ double benchmark(std::string fileName) { std::chrono::time_point start, end; std::cout << "CRHMC polytope preparation for " << fileName << std::endl; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); CrhmcProblem P = CrhmcProblem(input); - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); std::cout << "Preparation completed in time, "; std::chrono::duration elapsed_seconds = end - start; @@ -79,9 +80,9 @@ int main() { std::cout << "CRHMC polytope preparation 100000 dimensional Cube " << std::endl; - start = std::chrono::system_clock::now(); + start = std::chrono::high_resolution_clock::now(); CrhmcProblem P = CrhmcProblem(input); - end = std::chrono::system_clock::now(); + end = std::chrono::high_resolution_clock::now(); std::cout << "Preparation completed in time, "; std::chrono::duration elapsed_seconds = end - start; diff --git a/test/benchmarks_crhmc_sampling.cpp b/test/benchmarks_crhmc_sampling.cpp index 27460b5be..6706553a7 100644 --- a/test/benchmarks_crhmc_sampling.cpp +++ b/test/benchmarks_crhmc_sampling.cpp @@ -51,8 +51,7 @@ struct SimulationStats { NT average_acceptance_prob = NT(0); NT step_size = NT(0); - friend std::ostream &operator<<(std::ostream &out, - const SimulationStats &stats) + friend std::ostream &operator<<(std::ostream &out, const SimulationStats &stats) { out << stats.method << "," << stats.walk_length << "," << stats.min_ess << "," << stats.max_psrf << "," << stats.time_per_draw << "," @@ -147,13 +146,12 @@ NT check_interval_psrf(MT &samples, NT target = NT(1.2)) { } return max_psrf; } -template -std::vector> benchmark_polytope_sampling( - Polytope &P, NT eta = NT(-1), unsigned int walk_length = 1, - double target_time = std::numeric_limits::max(), bool rounding = false, - bool centered = false, unsigned int max_draws = 80000, - unsigned int num_burns = 20000) -{ +template +std::vector> benchmark_polytope_sampling(StreamType &stream, + Polytope &P, NT eta = NT(-1), unsigned int walk_length = 1, + double target_time = std::numeric_limits::max(), bool rounding = false, + bool centered = false, unsigned int max_draws = 80000, + unsigned int num_burns = 20000) { using Kernel = Cartesian; using Point = typename Kernel::Point; using MT = typename Polytope::MT; @@ -164,7 +162,7 @@ std::vector> benchmark_polytope_sampling( using Input = crhmc_input; using CrhmcProblem = crhmc_problem; using Opts = opts; - using Solver = ImplicitMidpointODESolver; + using Solver = ImplicitMidpointODESolver; using RandomNumberGenerator = BoostRandomNumberGenerator; SimulationStats rdhr_stats; @@ -187,7 +185,7 @@ std::vector> benchmark_polytope_sampling( unsigned int dim = x0.dimension(); if (rounding) { - std::cout << "SVD Rounding" << std::endl; + stream << "SVD Rounding" << std::endl; svd_rounding(P, inner_ball, walk_length, rng); } @@ -207,12 +205,17 @@ std::vector> benchmark_polytope_sampling( std::chrono::time_point start, stop; Opts options; + options.simdLen = simdLen; CRHMCWalk::parameters crhmc_params(F, dim, options); Input input = Input(P.dimension(), f, F, H); input.Aineq = P.get_mat(); input.bineq = P.get_vec(); CrhmcProblem crhmc_problem = CrhmcProblem(input); +#ifdef TIME_KEEPING + crhmc_problem.print_preparation_time(stream); +#endif + Point x_start(crhmc_problem.center); CRHMCWalk::Walk @@ -237,13 +240,20 @@ std::vector> benchmark_polytope_sampling( std::cout << std::endl; std::cout << "Sampling" << std::endl; - +#ifdef TIME_KEEPING + crhmc.initialize_timers(); +#endif start = std::chrono::high_resolution_clock::now(); - for (unsigned int i = 0; i < max_actual_draws; i++) { + for (unsigned int i = 0; i < std::ceil(max_actual_draws / simdLen); i++) { for (int k = 0; k < walk_length; k++) { crhmc.apply(rng, 1); } - samples.col(i) = crhmc.getPoint().getCoefficients(); + MT sample = crhmc.getPoints(); + if (i * simdLen + simdLen - 1 < max_actual_draws) { + samples(Eigen::all, Eigen::seq(i * simdLen, i * simdLen + simdLen - 1)) = sample; + } else { + samples(Eigen::all, Eigen::seq(i * simdLen, max_actual_draws - 1)) = sample(Eigen::all, Eigen::seq(0, max_actual_draws - 1 - simdLen * i)); + } if (i % 1000 == 0 && i > 0) std::cout << "."; } @@ -251,30 +261,31 @@ std::vector> benchmark_polytope_sampling( ETA = (NT)std::chrono::duration_cast(stop - start) .count(); - std::cout << std::endl; -#ifdef TIME_KEEPING std::chrono::duration total_time = stop - start; - std::cerr << "Total time: " << total_time.count() << "\n"; + stream << "Total Sampling time: " << total_time.count() << "\n"; assert(total_time.count() < target_time); - std::cout << "Assertion (preparation_time< " << target_time - << " secs) passed!" << std::endl - << std::endl; - crhmc.print_timing_information(); + stream << "Assertion (preparation_time< " << target_time + << " secs) passed!" << std::endl + << std::endl; +#ifdef TIME_KEEPING + crhmc.print_timing_information(stream); #endif print_diagnostics(samples, min_ess, std::cout); - std::cout << "min ess " << min_ess << "us" << std::endl; - std::cout << "Average time per sample: " << ETA / max_actual_draws << "us" - << std::endl; - std::cout << "Average time per independent sample: " << ETA / min_ess << "us" - << std::endl; - std::cout << "Step size (final): " << crhmc.solver->eta << std::endl; - std::cout << "Discard Ratio: " << crhmc.discard_ratio << std::endl; - std::cout << "Average Acceptance Probability: " - << crhmc.average_acceptance_prob << std::endl; + stream << "Problem original size: m= " << P.num_of_hyperplanes() << ", n= " << P.dimension() << std::endl; + stream << "Number of non Zeros: " << crhmc_problem.nnz() << std::endl; + stream << "min ess " << min_ess << std::endl; + stream << "Average time per sample: " << ETA / max_actual_draws << "us" + << std::endl; + stream << "Average time per independent sample: " << ETA / min_ess << "us" + << std::endl; + stream << "Step size (final): " << crhmc.solver->eta << std::endl; + stream << "Discard Ratio: " << crhmc.discard_ratio << std::endl; + stream << "Average Acceptance Probability: " + << crhmc.average_acceptance_prob << std::endl; max_psrf = check_interval_psrf(samples); - std::cout << "max_psrf: " << max_psrf << std::endl; - std::cout << std::endl; + stream << "max_psrf: " << max_psrf << std::endl; + stream << std::endl; crhmc_stats.method = "CRHMC"; crhmc_stats.walk_length = walk_length; @@ -288,31 +299,33 @@ std::vector> benchmark_polytope_sampling( return std::vector>{rdhr_stats, crhmc_stats}; } -template -void test_benchmark_polytope( - HPolytope &P, std::string &name, bool centered, - double target_time = std::numeric_limits::max(), int walk_length = 1) -{ +template +void test_benchmark_polytope(StreamType &stream, + HPolytope &P, std::string &name, bool centered, + double target_time = std::numeric_limits::max(), int walk_length = 1) { + stream << "CRHMC polytope preparation for " << name << std::endl; std::cout << "CRHMC polytope preparation for " << name << std::endl; std::vector> results; NT step_size = 0; std::pair inner_ball; std::ofstream outfile; - std::cout << name << std::endl; outfile.open("results_" + name + "_new.txt"); P.normalize(); inner_ball = P.ComputeInnerBall(); step_size = inner_ball.second / 10; - results = benchmark_polytope_sampling(P, step_size, walk_length, target_time, - false, centered); + results = benchmark_polytope_sampling(stream, P, step_size, walk_length, target_time, + false, centered); outfile << results[0]; outfile << results[1]; outfile.close(); } -template +template void call_test_benchmark_polytope() { + std::ofstream stream; + stream.open("CRHMC_SIMD_" + std::to_string(simdLen) + ".txt"); + stream << "---------------Using simdLen= " << simdLen << "---------------" << std::endl; using Kernel = Cartesian; using Point = typename Kernel::Point; using Hpolytope = HPolytope; @@ -321,7 +334,7 @@ void call_test_benchmark_polytope() { std::string name = "100_skinny_cube"; bool centered = false; double target_time = 20; // secs - test_benchmark_polytope(P, name, false, target_time); + test_benchmark_polytope(stream, P, name, target_time, false); } { @@ -329,23 +342,23 @@ void call_test_benchmark_polytope() { std::string name = "5_cross"; bool centered = false; double target_time = 10; // secs - test_benchmark_polytope(P, name, centered, target_time); + test_benchmark_polytope(stream, P, name, target_time, centered); } { Hpolytope P = generate_simplex(100, false); std::string name = "100_simplex"; bool centered = false; - double target_time = 15; // secs - test_benchmark_polytope(P, name, centered, target_time); + double target_time = 20; // secs + test_benchmark_polytope(stream, P, name, target_time, centered); } { Hpolytope P = generate_prod_simplex(50, false); std::string name = "50_prod_simplex"; bool centered = false; - double target_time = 15; // secs - test_benchmark_polytope(P, name, centered, target_time); + double target_time = 20; // secs + test_benchmark_polytope(stream, P, name, target_time, centered); } { @@ -353,35 +366,36 @@ void call_test_benchmark_polytope() { std::string name = "10_birkhoff"; bool centered = false; double target_time = 15; // secs - test_benchmark_polytope(P, name, centered, target_time); + test_benchmark_polytope(stream, P, name, target_time, centered); } - if (exists_check("netlib/afiro.ine")) - { - Hpolytope P = read_polytope("netlib/afiro.ine"); + if (exists_check("../test/netlib/afiro.ine")) { + Hpolytope P = read_polytope("../test/netlib/afiro.ine"); std::string name = "afiro"; bool centered = true; double target_time = 100; // secs - test_benchmark_polytope(P, name, centered, target_time); + test_benchmark_polytope(stream, P, name, target_time, centered); } - if (exists_check("metabolic_full_dim/polytope_e_coli.ine")) - { + if (exists_check("../test/metabolic_full_dim/polytope_e_coli.ine")) { Hpolytope P = - read_polytope("metabolic_full_dim/polytope_e_coli.ine"); + read_polytope("../test/metabolic_full_dim/polytope_e_coli.ine"); std::string name = "e_coli"; bool centered = true; double target_time = 600; // secs - test_benchmark_polytope(P, name, centered, target_time); + test_benchmark_polytope(stream, P, name, target_time, centered); } + + stream.close(); } int main() { - std::cout << "---------------CRHMC polytope sampling benchmarking---------------" << std::endl << std::endl; - call_test_benchmark_polytope(); + call_test_benchmark_polytope(); + call_test_benchmark_polytope(); + call_test_benchmark_polytope(); return 0; } diff --git a/test/benchmarks_sob.cpp b/test/benchmarks_sob.cpp index 5fe46e209..44350a1c2 100644 --- a/test/benchmarks_sob.cpp +++ b/test/benchmarks_sob.cpp @@ -21,7 +21,7 @@ #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "exact_vols.h" +#include "volume/exact_vols.h" #include "generators/known_polytope_generators.h" int main() diff --git a/test/boundary_oracles_test.cpp b/test/boundary_oracles_test.cpp index 62cbdf86e..b0a043602 100755 --- a/test/boundary_oracles_test.cpp +++ b/test/boundary_oracles_test.cpp @@ -22,10 +22,11 @@ #include "Eigen/Eigen" #include "doctest.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" +#include +#include +#include +#include + #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" diff --git a/test/crhmc_polytope_preparation_test.cpp b/test/crhmc_polytope_preparation_test.cpp index 6da13269b..db6fa0674 100644 --- a/test/crhmc_polytope_preparation_test.cpp +++ b/test/crhmc_polytope_preparation_test.cpp @@ -117,6 +117,8 @@ template void test_crhmc_dependent_polytope() { using VT = Eigen::Matrix; using Input = crhmc_input; using CrhmcProblem = crhmc_problem; + using SpMat = typename CrhmcProblem::SpMat; + using InputSparse = crhmc_input; using PolytopeType = HPolytope; using Opts = opts; unsigned d = 3; @@ -131,6 +133,13 @@ template void test_crhmc_dependent_polytope() { options.EnableReordering = true; CrhmcProblem P = CrhmcProblem(input, options); CHECK(P.equations() == 2); + + SpMat A = Aeq.sparseView(); + InputSparse input_sparse = InputSparse(d); + input_sparse.Aeq = A; + input_sparse.beq = beq; + crhmc_problem Q = crhmc_problem(input_sparse,options); + CHECK(Q.equations() == 2); } template void test_center_computation() { @@ -188,6 +197,7 @@ template void call_test_center_computation(){ std::cout << "--- Testing CRHMC polytope-center computation" << std::endl; test_center_computation(); } + TEST_CASE("test_preparation_crhmc") { call_test_crhmc_preprocesssing(); } diff --git a/test/crhmc_sampling_test.cpp b/test/crhmc_sampling_test.cpp index 2bd1b7995..79697b4a4 100644 --- a/test/crhmc_sampling_test.cpp +++ b/test/crhmc_sampling_test.cpp @@ -13,9 +13,10 @@ #include "doctest.h" #include "generators/known_polytope_generators.h" #include "misc/misc.h" -#include "ode_solvers.hpp" #include "preprocess/crhmc/crhmc_input.h" #include "preprocess/crhmc/crhmc_problem.h" +#include "preprocess/crhmc/crhmc_problem.h" +#include "preprocess/crhmc/crhmc_utils.h" #include "random.hpp" #include "random/normal_distribution.hpp" #include "random/uniform_int.hpp" @@ -33,6 +34,7 @@ #include #include #include "preprocess/svd_rounding.hpp" +#include "sampling/sampling.hpp" struct InnerBallFunctor { // Gaussian density centered at the inner ball center @@ -178,15 +180,14 @@ template = skip_samples) { - Point x = sampler.getPoint(); + Point x = Point(sampler.getPoints().rowwise().sum()); mean = mean + x; } @@ -228,12 +229,11 @@ Polytope read_polytope(std::string filename) { return P; } -template +template void crhmc_polytope_sampling( Polytope &P, NT eta = NT(-1), unsigned int walk_length = 1, bool rounding = false, bool centered = false, - unsigned int max_draws = 80000, unsigned int num_burns = 20000) -{ + unsigned int max_draws = 80000, unsigned int num_burns = 20000) { using Kernel = Cartesian; using Point = typename Kernel::Point; using RandomNumberGenerator = BoostRandomNumberGenerator; @@ -246,8 +246,7 @@ void crhmc_polytope_sampling( NegativeGradientFunctor, HessianFunctor>; using CrhmcProblem = crhmc_problem; using Opts = opts; - using Solver = ImplicitMidpointODESolver; + using Solver = ImplicitMidpointODESolver; std::pair inner_ball; if (centered) { @@ -286,8 +285,8 @@ void crhmc_polytope_sampling( NT max_psrf; Opts options; - CRHMCWalk::parameters crhmc_params(F, dim, - options); + options.simdLen = simdLen; + CRHMCWalk::parameters crhmc_params(F, dim,options); Input input = Input(P.dimension(), f, F, H); input.Aineq = P.get_mat(); input.bineq = P.get_vec(); @@ -318,11 +317,16 @@ void crhmc_polytope_sampling( std::cout << std::endl; std::cout << "Sampling" << std::endl; - for (unsigned int i = 0; i < max_actual_draws; i++) { + for (unsigned int i = 0; i < std::ceil(max_actual_draws / simdLen); i++) { for (int k = 0; k < walk_length; k++) { crhmc.apply(rng, 1); } - samples.col(i) = crhmc.getPoint().getCoefficients(); + MT sample = crhmc.getPoints(); + if (i * simdLen + simdLen - 1 < max_actual_draws) { + samples(Eigen::all, Eigen::seq(i * simdLen, i * simdLen + simdLen - 1)) = sample; + } else { + samples(Eigen::all, Eigen::seq(i * simdLen, max_actual_draws - 1)) = sample(Eigen::all, Eigen::seq(0, max_actual_draws - 1 - simdLen * i)); + } if (i % 1000 == 0 && i > 0) std::cout << "."; } @@ -340,7 +344,7 @@ inline bool exists_check(const std::string &name) { return f.good(); } -template +template void test_sampling_polytope(HPolytope &P, std::string &name, bool centered, int walk_length = 1) { NT step_size = 0; @@ -349,9 +353,9 @@ void test_sampling_polytope(HPolytope &P, std::string &name, bool centered, P.normalize(); inner_ball = P.ComputeInnerBall(); step_size = inner_ball.second / 10; - crhmc_polytope_sampling(P, step_size, walk_length, false, centered); + crhmc_polytope_sampling(P, step_size, walk_length, false, centered); } -template +template void call_test_sampling_polytope() { using Kernel = Cartesian; using Point = typename Kernel::Point; @@ -362,35 +366,35 @@ void call_test_sampling_polytope() { Hpolytope P = generate_skinny_cube(100, false); std::string name = "100_skinny_cube"; bool centered = false; - test_sampling_polytope(P, name, false); + test_sampling_polytope(P, name, false); } { Hpolytope P = generate_cross(5, false); std::string name = "5_cross"; bool centered = false; - test_sampling_polytope(P, name, centered); + test_sampling_polytope(P, name, centered); } { Hpolytope P = generate_simplex(100, false); std::string name = "100_simplex"; bool centered = false; - test_sampling_polytope(P, name, centered); + test_sampling_polytope(P, name, centered); } { Hpolytope P = generate_prod_simplex(50, false); std::string name = "50_prod_simplex"; bool centered = false; - test_sampling_polytope(P, name, centered); + test_sampling_polytope(P, name, centered); } { Hpolytope P = generate_birkhoff(10); std::string name = "10_birkhoff"; bool centered = false; - test_sampling_polytope(P, name, centered); + test_sampling_polytope(P, name, centered); } } @@ -443,7 +447,7 @@ void benchmark_cube_crhmc() { } } -template +template void test_crhmc() { using Kernel = Cartesian; using Point = typename Kernel::Point; @@ -458,8 +462,7 @@ void test_crhmc() { crhmc_input; using CrhmcProblem = crhmc_problem; using RandomNumberGenerator = BoostRandomNumberGenerator; - using Solver = ImplicitMidpointODESolver; + using Solver = ImplicitMidpointODESolver; using Opts = opts; IsotropicQuadraticFunctor::parameters params; params.order = 2; @@ -468,12 +471,16 @@ void test_crhmc() { RandomNumberGenerator rng(1); unsigned int dim = 10; Opts options; + options.simdLen = simdLen; + options.DynamicWeight=false; + options.DynamicStepSize=false; + options.DynamicRegularizer=false; CRHMCWalk::parameters crhmc_params(g, dim, options); Input input = Input(dim, f, g); input.lb = -VT::Ones(dim); input.ub = VT::Ones(dim); - CrhmcProblem P = CrhmcProblem(input); + CrhmcProblem P = CrhmcProblem(input,options); Point x0(dim); CRHMCWalk::Walk @@ -486,13 +493,68 @@ template void call_test_crhmc() { std::cout << "--- Testing Constrained Riemannian Hamiltonian Monte Carlo" << std::endl; - test_crhmc(); + std::cout << "------------SIMDLEN=1-------------------\n" + << std::endl; + test_crhmc(); + std::cout << "------------SIMDLEN=4-------------------\n" + << std::endl; + test_crhmc(); } template void call_test_benchmark_cube_crhmc() { benchmark_cube_crhmc(); } +template +void test_polytope_sampling_sparse_problem(ConstraintProblem &problem, int n_samples = 80000, int n_burns = 20000){ + using NT = typename Point::FT; + using VT = Eigen::Matrix; + using MT = Eigen::Matrix; + using Func = GaussianFunctor::FunctionFunctor; + using Grad = GaussianFunctor::GradientFunctor; + using Hess = GaussianFunctor::HessianFunctor; + using func_params = GaussianFunctor::parameters; + using RNG = BoostRandomNumberGenerator; + func_params params = func_params(Point(problem.dimension()), 0.5, 1); + Func* f= new Func(params); + Grad* g= new Grad(params); + Hess* h= new Hess(params); + RNG rng(1); + std::list PointList; + execute_crhmc, Grad, Func, Hess, CRHMCWalk, simdLen>(problem, rng, PointList, 1, n_samples, n_burns, g, f, h, true); + std::cout<<"Here--------------------------\n"; + MT samples = MT(PointList.front().dimension(), PointList.size()); + int i=0; + for (typename std::list::iterator it = PointList.begin(); it != PointList.end(); ++it){ + samples.col(i) = (*it).getCoefficients(); + i++; + } + NT max_psrf = check_interval_psrf(samples); + std::cout<<"PSRF: "< +void call_test_polytope_sampling_sparse_problem(){ + std::cout << " ---Sampling sparse problems " << std::endl; + using SpMat = Eigen::SparseMatrix; + using Kernel = Cartesian; + using Point = typename Kernel::Point; + using VT = Eigen::Matrix; + using ConstraintProblem =constraint_problem; + if(exists_check("../test/netlib/degen2.mm")){ + std::cout<<"Problem name: degen2" << std::endl; + SpMat A; + VT b, lb, ub; + int dimension; + load_problem(A, b, lb, ub, dimension, "../test/netlib/degen2"); + ConstraintProblem problem = ConstraintProblem(dimension); + problem.set_equality_constraints(A, b); + problem.set_bounds(lb, ub); + test_polytope_sampling_sparse_problem(problem); + } +} TEST_CASE("crhmc") { call_test_crhmc(); } @@ -502,5 +564,19 @@ TEST_CASE("benchmark_crhmc_cube") { } TEST_CASE("test_polytope_sampling_crhmc") { - call_test_sampling_polytope(); + std::cout << "------------SIMDLEN=1-------------------\n" + << std::endl; + call_test_sampling_polytope(); + std::cout << "------------SIMDLEN=4-------------------\n" + << std::endl; + call_test_sampling_polytope(); +} + +TEST_CASE("test_sampling_sparse_problem") { + std::cout << "------------SIMDLEN=1-------------------\n" + << std::endl; + call_test_polytope_sampling_sparse_problem(); + std::cout << "------------SIMDLEN=4-------------------\n" + << std::endl; + call_test_polytope_sampling_sparse_problem(); } diff --git a/test/logconcave_sampling_test.cpp b/test/logconcave_sampling_test.cpp index f8f6901cd..f0f7fab97 100644 --- a/test/logconcave_sampling_test.cpp +++ b/test/logconcave_sampling_test.cpp @@ -23,13 +23,15 @@ #include "doctest.h" #include "Eigen/Eigen" -#include "ode_solvers.hpp" + +#include +#include +#include +#include + +#include "ode_solvers/ode_solvers.hpp" #include "diagnostics/diagnostics.hpp" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" @@ -39,6 +41,8 @@ #include "generators/h_polytopes_generator.h" #include "generators/convex_bodies_generator.h" +#include "diagnostics/univariate_psrf.hpp" + #include "preprocess/svd_rounding.hpp" #include "misc/misc.h" @@ -308,6 +312,80 @@ void benchmark_hmc(bool truncated) { } +template +void benchmark_nuts_hmc(bool truncated) { + typedef Cartesian Kernel; + typedef typename Kernel::Point Point; + typedef std::vector pts; + typedef HPolytope Hpolytope; + typedef BoostRandomNumberGenerator RandomNumberGenerator; + typedef CustomFunctor::GradientFunctor NegativeGradientFunctor; + typedef CustomFunctor::FunctionFunctor NegativeLogprobFunctor; + typedef LeapfrogODESolver Solver; + + typedef Eigen::Matrix MT; + typedef Eigen::Matrix VT; + + NegativeGradientFunctor F; + NegativeLogprobFunctor f; + RandomNumberGenerator rng(1); + unsigned int dim_min = 10; + unsigned int dim_max = 100; + int n_samples = 1000; + long ETA; + bool automatic_burnin = false; + std::chrono::time_point start, stop; + + for (unsigned int dim = dim_min; dim <= dim_max; dim+=10) + { + MT samples(dim, n_samples); + Point x0(dim); + NutsHamiltonianMonteCarloWalk::parameters hmc_params(F, dim); + if (truncated) + { + Hpolytope P = generate_cube(dim, false); + + std::cout << "eta0: " << hmc_params.eta << std::endl; + + NutsHamiltonianMonteCarloWalk::Walk + hmc(&P, x0, F, f, hmc_params, automatic_burnin); + + hmc.burnin(rng); + std::cout << "eta: " << hmc.get_eta_solver() << std::endl; + + start = std::chrono::high_resolution_clock::now(); + for (int i = 0; i < n_samples; i++) { + hmc.apply(rng); + samples.col(i) = hmc.x.getCoefficients(); + } + stop = std::chrono::high_resolution_clock::now(); + std::cout << "proportion of sucussfull steps: " << hmc.get_ratio_acceptance() << std::endl; + } + else + { + NutsHamiltonianMonteCarloWalk::Walk + hmc(NULL, x0, F, f, hmc_params, automatic_burnin); + + hmc.burnin(rng); + std::cout << "eta: " << hmc.get_eta_solver() << std::endl; + + start = std::chrono::high_resolution_clock::now(); + for (int i = 0; i < n_samples; i++) { + hmc.apply(rng); + samples.col(i) = hmc.x.getCoefficients(); + } + stop = std::chrono::high_resolution_clock::now(); + std::cout << "proportion of sucussfull steps: " << hmc.get_ratio_acceptance() << std::endl; + } + + std::cout << "PSRF: " << univariate_psrf(samples).maxCoeff() << std::endl; + + ETA = (long) std::chrono::duration_cast(stop - start).count(); + std::cout<< "time: " << ETA << "\n" << std::endl; + } + +} + template void test_hmc() { typedef Cartesian Kernel; @@ -708,8 +786,8 @@ void benchmark_polytope_linear_program_optimization( typedef std::vector pts; typedef boost::mt19937 RNGType; typedef BoostRandomNumberGenerator RandomNumberGenerator; - typedef LinearProgramFunctor::GradientFunctor NegativeGradientFunctor; - typedef LinearProgramFunctor::FunctionFunctor NegativeLogprobFunctor; + typedef ExponentialFunctor::GradientFunctor NegativeGradientFunctor; + typedef ExponentialFunctor::FunctionFunctor NegativeLogprobFunctor; typedef OptimizationFunctor::GradientFunctor NegativeGradientOptimizationFunctor; typedef OptimizationFunctor::FunctionFunctor lp_params(coeffs); + ExponentialFunctor::parameters lp_params(coeffs); NegativeGradientFunctor F_lp(lp_params); NegativeLogprobFunctor f_lp(lp_params); @@ -878,6 +956,11 @@ void call_test_benchmark_hmc(bool truncated) { benchmark_hmc(truncated); } +template +void call_test_benchmark_nuts_hmc(bool truncated) { + benchmark_nuts_hmc(truncated); +} + template void call_test_benchmark_polytopes_grid_search() { typedef Cartesian Kernel; @@ -1035,8 +1118,8 @@ void call_test_exp_sampling() { typedef HPolytope Hpolytope; std::string name; std::vector> polytopes; - - + + if (exists_check("metabolic_full_dim/e_coli_biomass_function.txt") && exists_check("metabolic_full_dim/polytope_e_coli.ine")){ Point biomass_function_e_coli = load_biomass_function("metabolic_full_dim/e_coli_biomass_function.txt"); polytopes.push_back(std::make_tuple(read_polytope("metabolic_full_dim/polytope_e_coli.ine"), biomass_function_e_coli, "e_coli", true)); @@ -1196,6 +1279,14 @@ TEST_CASE("exponential_biomass_sampling") { call_test_exp_sampling(); } +TEST_CASE("benchmark_nuts_hmc_truncated") { + call_test_benchmark_nuts_hmc(true); +} + +TEST_CASE("benchmark_nuts_hmc") { + call_test_benchmark_nuts_hmc(false); +} + TEST_CASE("benchmark_hmc") { call_test_benchmark_hmc(false); } diff --git a/test/max_ellipsoid_rounding_test.cpp b/test/max_ellipsoid_rounding_test.cpp index 086dcabe5..a9c25b8c1 100644 --- a/test/max_ellipsoid_rounding_test.cpp +++ b/test/max_ellipsoid_rounding_test.cpp @@ -8,11 +8,13 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" @@ -22,7 +24,7 @@ #include "preprocess/max_inscribed_ellipsoid_rounding.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/mcmc_diagnostics_test.cpp b/test/mcmc_diagnostics_test.cpp index 4d303004b..93f4cbbb6 100644 --- a/test/mcmc_diagnostics_test.cpp +++ b/test/mcmc_diagnostics_test.cpp @@ -10,18 +10,20 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" #include "sampling/sampling.hpp" #include "diagnostics/effective_sample_size.hpp" diff --git a/test/netlib/degen2.mm b/test/netlib/degen2.mm new file mode 100644 index 000000000..0232eff96 --- /dev/null +++ b/test/netlib/degen2.mm @@ -0,0 +1,4447 @@ +%%MatrixMarket matrix coordinate real general +% Generated 28-Oct-2022 +444 758 4444 +1 1 1 +2 2 1 +3 3 1 +225 4 1 +226 5 1 +227 6 1 +228 7 1 +229 8 1 +230 9 1 +231 10 1 +232 11 1 +233 12 1 +234 13 1 +235 14 1 +236 15 1 +237 16 1 +238 17 1 +239 18 1 +240 19 1 +241 20 1 +242 21 1 +243 22 1 +244 23 1 +245 24 1 +246 25 1 +247 26 1 +248 27 1 +249 28 1 +250 29 1 +251 30 1 +252 31 1 +253 32 1 +254 33 1 +255 34 1 +256 35 1 +257 36 1 +258 37 1 +259 38 1 +260 39 1 +261 40 1 +262 41 1 +263 42 1 +264 43 1 +265 44 1 +266 45 1 +267 46 1 +268 47 1 +269 48 1 +270 49 1 +271 50 1 +272 51 1 +273 52 1 +274 53 1 +275 54 1 +276 55 1 +277 56 1 +278 57 1 +279 58 1 +280 59 1 +281 60 1 +282 61 1 +283 62 1 +284 63 1 +285 64 1 +286 65 1 +287 66 1 +288 67 1 +289 68 1 +290 69 1 +291 70 1 +292 71 1 +293 72 1 +294 73 1 +295 74 1 +296 75 1 +297 76 1 +298 77 1 +299 78 1 +300 79 1 +301 80 1 +302 81 1 +303 82 1 +304 83 1 +305 84 1 +306 85 1 +307 86 1 +308 87 1 +309 88 1 +310 89 1 +311 90 1 +312 91 1 +313 92 1 +314 93 1 +315 94 1 +316 95 1 +317 96 1 +318 97 1 +319 98 1 +320 99 1 +321 100 1 +322 101 1 +323 102 1 +324 103 1 +325 104 1 +326 105 1 +327 106 1 +328 107 1 +329 108 1 +330 109 1 +331 110 1 +332 111 1 +333 112 1 +334 113 1 +335 114 1 +336 115 1 +337 116 1 +338 117 1 +339 118 1 +340 119 1 +341 120 1 +342 121 1 +343 122 1 +344 123 1 +345 124 1 +346 125 1 +347 126 1 +348 127 1 +349 128 1 +350 129 1 +351 130 1 +352 131 1 +353 132 1 +354 133 1 +355 134 1 +356 135 1 +357 136 1 +358 137 1 +359 138 1 +360 139 1 +361 140 1 +362 141 1 +363 142 1 +364 143 1 +365 144 1 +366 145 1 +367 146 1 +368 147 1 +369 148 1 +370 149 1 +371 150 1 +372 151 1 +373 152 1 +374 153 1 +375 154 1 +376 155 1 +377 156 1 +378 157 1 +379 158 1 +380 159 1 +381 160 1 +382 161 1 +383 162 1 +384 163 1 +385 164 1 +386 165 1 +387 166 1 +388 167 1 +389 168 1 +390 169 1 +391 170 1 +392 171 1 +393 172 1 +394 173 1 +395 174 1 +396 175 1 +397 176 1 +398 177 1 +399 178 1 +400 179 1 +401 180 1 +402 181 1 +403 182 1 +404 183 1 +405 184 1 +406 185 1 +407 186 1 +408 187 1 +409 188 1 +410 189 1 +411 190 1 +412 191 1 +413 192 1 +414 193 1 +415 194 1 +416 195 1 +417 196 1 +418 197 1 +419 198 1 +420 199 1 +421 200 1 +422 201 1 +423 202 1 +424 203 1 +425 204 1 +426 205 1 +427 206 1 +428 207 1 +429 208 1 +430 209 1 +431 210 1 +432 211 1 +433 212 1 +434 213 1 +435 214 1 +436 215 1 +437 216 1 +438 217 1 +439 218 1 +440 219 1 +441 220 1 +442 221 1 +443 222 1 +444 223 1 +1 224 1 +4 224 1 +193 224 -1 +202 224 1 +291 224 -1 +292 224 -1 +2 225 1 +4 225 1 +194 225 -1 +203 225 1 +296 225 -1 +297 225 -1 +1 226 1 +5 226 1 +197 226 1 +202 226 -1 +331 226 -1 +332 226 -1 +333 226 -1 +334 226 -1 +2 227 1 +5 227 1 +198 227 1 +203 227 -1 +339 227 -1 +340 227 -1 +341 227 -1 +1 228 1 +6 228 1 +197 228 -1 +202 228 1 +305 228 -1 +306 228 -1 +2 229 1 +6 229 1 +198 229 -1 +203 229 1 +308 229 -1 +309 229 -1 +1 230 1 +7 230 1 +197 230 1 +202 230 -1 +327 230 -1 +328 230 -1 +329 230 -1 +330 230 -1 +331 230 -1 +332 230 -1 +333 230 -1 +334 230 -1 +2 231 1 +7 231 1 +198 231 1 +203 231 -1 +336 231 -1 +337 231 -1 +338 231 -1 +339 231 -1 +340 231 -1 +341 231 -1 +8 232 1 +197 232 -1 +202 232 1 +306 232 -1 +327 232 1 +328 232 1 +329 232 1 +330 232 1 +331 232 1 +332 232 1 +333 232 1 +334 232 1 +8 233 1 +198 233 -1 +203 233 1 +309 233 -1 +336 233 1 +337 233 1 +338 233 1 +339 233 1 +340 233 1 +341 233 1 +9 234 1 +193 234 1 +202 234 -1 +291 234 1 +292 234 1 +333 234 -1 +334 234 -1 +9 235 1 +194 235 1 +203 235 -1 +296 235 1 +297 235 1 +341 235 -1 +10 236 1 +193 236 -1 +202 236 1 +292 236 -1 +329 236 1 +330 236 1 +331 236 1 +332 236 1 +333 236 1 +334 236 1 +10 237 1 +194 237 -1 +203 237 1 +297 237 -1 +337 237 1 +338 237 1 +339 237 1 +340 237 1 +341 237 1 +11 238 1 +197 238 1 +202 238 -1 +305 238 1 +306 238 1 +333 238 -1 +334 238 -1 +11 239 1 +198 239 1 +203 239 -1 +308 239 1 +309 239 1 +341 239 -1 +1 240 1 +12 240 1 +197 240 1 +220 240 -1 +418 240 -1 +419 240 -1 +2 241 1 +12 241 1 +198 241 1 +221 241 -1 +421 241 -1 +422 241 -1 +13 242 1 +197 242 -1 +220 242 1 +306 242 -1 +418 242 1 +419 242 1 +13 243 1 +198 243 -1 +221 243 1 +309 243 -1 +421 243 1 +422 243 1 +14 244 1 +193 244 1 +202 244 -1 +288 244 1 +289 244 1 +290 244 1 +291 244 1 +292 244 1 +326 244 -1 +327 244 -1 +328 244 -1 +329 244 -1 +330 244 -1 +331 244 -1 +332 244 -1 +333 244 -1 +334 244 -1 +14 245 1 +194 245 1 +203 245 -1 +293 245 1 +294 245 1 +295 245 1 +296 245 1 +297 245 1 +335 245 -1 +336 245 -1 +337 245 -1 +338 245 -1 +339 245 -1 +340 245 -1 +341 245 -1 +15 246 1 +197 246 -1 +222 246 1 +428 246 1 +429 246 1 +430 246 1 +431 246 1 +432 246 1 +15 247 1 +198 247 -1 +223 247 1 +436 247 1 +437 247 1 +438 247 1 +439 247 1 +440 247 1 +1 248 1 +16 248 1 +197 248 1 +222 248 -1 +427 248 -1 +428 248 -1 +429 248 -1 +430 248 -1 +431 248 -1 +432 248 -1 +2 249 1 +16 249 1 +198 249 1 +223 249 -1 +435 249 -1 +436 249 -1 +437 249 -1 +438 249 -1 +439 249 -1 +440 249 -1 +1 250 1 +17 250 1 +197 250 -1 +222 250 1 +305 250 -1 +306 250 -1 +2 251 1 +17 251 1 +198 251 -1 +223 251 1 +308 251 -1 +309 251 -1 +18 252 1 +197 252 -1 +222 252 1 +431 252 1 +432 252 1 +18 253 1 +198 253 -1 +223 253 1 +439 253 1 +440 253 1 +1 254 1 +19 254 1 +197 254 1 +222 254 -1 +429 254 -1 +430 254 -1 +431 254 -1 +432 254 -1 +2 255 1 +19 255 1 +198 255 1 +223 255 -1 +437 255 -1 +438 255 -1 +439 255 -1 +440 255 -1 +20 256 1 +197 256 -1 +202 256 1 +334 256 1 +20 257 1 +198 257 -1 +203 257 1 +341 257 1 +21 258 1 +197 258 1 +222 258 -1 +305 258 1 +306 258 1 +431 258 -1 +432 258 -1 +21 259 1 +198 259 1 +223 259 -1 +308 259 1 +309 259 1 +439 259 -1 +440 259 -1 +22 260 1 +193 260 -1 +222 260 1 +428 260 1 +429 260 1 +430 260 1 +431 260 1 +432 260 1 +22 261 1 +194 261 -1 +223 261 1 +436 261 1 +437 261 1 +438 261 1 +439 261 1 +440 261 1 +22 262 1 +442 262 1 +23 263 1 +193 263 1 +222 263 -1 +288 263 1 +289 263 1 +290 263 1 +291 263 1 +292 263 1 +428 263 -1 +429 263 -1 +430 263 -1 +431 263 -1 +432 263 -1 +23 264 1 +194 264 1 +223 264 -1 +293 264 1 +294 264 1 +295 264 1 +296 264 1 +297 264 1 +436 264 -1 +437 264 -1 +438 264 -1 +439 264 -1 +440 264 -1 +3 265 1 +23 265 1 +442 265 -1 +24 266 1 +193 266 1 +202 266 -1 +292 266 1 +24 267 1 +194 267 1 +203 267 -1 +297 267 1 +1 268 1 +25 268 1 +193 268 -1 +202 268 1 +288 268 -1 +289 268 -1 +290 268 -1 +291 268 -1 +292 268 -1 +333 268 1 +334 268 1 +2 269 1 +25 269 1 +194 269 -1 +203 269 1 +293 269 -1 +294 269 -1 +295 269 -1 +296 269 -1 +297 269 -1 +341 269 1 +1 270 1 +26 270 1 +197 270 -1 +220 270 1 +304 270 -1 +305 270 -1 +306 270 -1 +2 271 1 +26 271 1 +198 271 -1 +221 271 1 +307 271 -1 +308 271 -1 +309 271 -1 +27 272 1 +197 272 1 +220 272 -1 +305 272 1 +306 272 1 +27 273 1 +198 273 1 +221 273 -1 +308 273 1 +309 273 1 +1 274 1 +28 274 1 +195 274 -1 +222 274 1 +302 274 -1 +2 275 1 +28 275 1 +196 275 -1 +223 275 1 +303 275 -1 +1 276 1 +29 276 1 +195 276 -1 +202 276 1 +302 276 -1 +2 277 1 +29 277 1 +196 277 -1 +203 277 1 +303 277 -1 +1 278 1 +30 278 1 +185 278 1 +222 278 -1 +427 278 -1 +428 278 -1 +429 278 -1 +430 278 -1 +431 278 -1 +432 278 -1 +2 279 1 +30 279 1 +186 279 1 +223 279 -1 +435 279 -1 +436 279 -1 +437 279 -1 +438 279 -1 +439 279 -1 +440 279 -1 +31 280 1 +202 280 1 +212 280 -1 +329 280 1 +330 280 1 +331 280 1 +332 280 1 +333 280 1 +334 280 1 +31 281 1 +203 281 1 +213 281 -1 +337 281 1 +338 281 1 +339 281 1 +340 281 1 +341 281 1 +32 282 1 +195 282 1 +202 282 -1 +302 282 1 +333 282 -1 +334 282 -1 +32 283 1 +196 283 1 +203 283 -1 +303 283 1 +341 283 -1 +33 284 1 +195 284 1 +222 284 -1 +302 284 1 +431 284 -1 +432 284 -1 +33 285 1 +196 285 1 +223 285 -1 +303 285 1 +439 285 -1 +440 285 -1 +34 286 1 +185 286 -1 +222 286 1 +427 286 1 +428 286 1 +429 286 1 +430 286 1 +431 286 1 +432 286 1 +34 287 1 +186 287 -1 +223 287 1 +435 287 1 +436 287 1 +437 287 1 +438 287 1 +439 287 1 +440 287 1 +1 288 1 +35 288 1 +195 288 1 +202 288 -1 +326 288 -1 +327 288 -1 +328 288 -1 +329 288 -1 +330 288 -1 +331 288 -1 +332 288 -1 +333 288 -1 +334 288 -1 +2 289 1 +35 289 1 +196 289 1 +203 289 -1 +335 289 -1 +336 289 -1 +337 289 -1 +338 289 -1 +339 289 -1 +340 289 -1 +341 289 -1 +36 290 1 +187 290 1 +208 290 -1 +247 290 1 +248 290 1 +36 291 1 +188 291 1 +209 291 -1 +250 291 1 +251 291 1 +36 292 1 +253 292 1 +254 292 1 +37 293 1 +181 293 -1 +202 293 1 +326 293 1 +327 293 1 +328 293 1 +329 293 1 +330 293 1 +331 293 1 +332 293 1 +333 293 1 +334 293 1 +37 294 1 +182 294 -1 +203 294 1 +335 294 1 +336 294 1 +337 294 1 +338 294 1 +339 294 1 +340 294 1 +341 294 1 +38 295 1 +183 295 1 +222 295 -1 +236 295 1 +237 295 1 +431 295 -1 +432 295 -1 +38 296 1 +184 296 1 +223 296 -1 +239 296 1 +240 296 1 +439 296 -1 +440 296 -1 +39 297 1 +183 297 -1 +222 297 1 +427 297 1 +428 297 1 +429 297 1 +430 297 1 +431 297 1 +432 297 1 +39 298 1 +184 298 -1 +223 298 1 +435 298 1 +436 298 1 +437 298 1 +438 298 1 +439 298 1 +440 298 1 +1 299 1 +40 299 1 +183 299 1 +222 299 -1 +427 299 -1 +428 299 -1 +429 299 -1 +430 299 -1 +431 299 -1 +432 299 -1 +2 300 1 +40 300 1 +184 300 1 +223 300 -1 +435 300 -1 +436 300 -1 +437 300 -1 +438 300 -1 +439 300 -1 +440 300 -1 +1 301 1 +41 301 1 +183 301 -1 +222 301 1 +236 301 -1 +237 301 -1 +2 302 1 +41 302 1 +184 302 -1 +223 302 1 +239 302 -1 +240 302 -1 +1 303 1 +42 303 1 +181 303 1 +202 303 -1 +328 303 -1 +329 303 -1 +330 303 -1 +331 303 -1 +332 303 -1 +333 303 -1 +334 303 -1 +2 304 1 +42 304 1 +182 304 1 +203 304 -1 +337 304 -1 +338 304 -1 +339 304 -1 +340 304 -1 +341 304 -1 +43 305 1 +195 305 -1 +202 305 1 +334 305 1 +43 306 1 +196 306 -1 +203 306 1 +341 306 1 +1 307 1 +44 307 1 +202 307 -1 +212 307 1 +327 307 -1 +328 307 -1 +329 307 -1 +330 307 -1 +331 307 -1 +332 307 -1 +333 307 -1 +334 307 -1 +2 308 1 +44 308 1 +203 308 -1 +213 308 1 +336 308 -1 +337 308 -1 +338 308 -1 +339 308 -1 +340 308 -1 +341 308 -1 +1 309 1 +45 309 1 +183 309 -1 +202 309 1 +237 309 -1 +2 310 1 +45 310 1 +184 310 -1 +203 310 1 +240 310 -1 +1 311 1 +46 311 1 +202 311 -1 +214 311 1 +328 311 -1 +329 311 -1 +330 311 -1 +331 311 -1 +332 311 -1 +333 311 -1 +334 311 -1 +2 312 1 +46 312 1 +203 312 -1 +215 312 1 +337 312 -1 +338 312 -1 +339 312 -1 +340 312 -1 +341 312 -1 +47 313 1 +202 313 1 +214 313 -1 +329 313 1 +330 313 1 +331 313 1 +332 313 1 +333 313 1 +334 313 1 +47 314 1 +203 314 1 +215 314 -1 +337 314 1 +338 314 1 +339 314 1 +340 314 1 +341 314 1 +48 315 1 +202 315 -1 +208 315 1 +333 315 -1 +334 315 -1 +365 315 1 +366 315 1 +367 315 1 +368 315 1 +48 316 1 +203 316 -1 +209 316 1 +341 316 -1 +377 316 1 +378 316 1 +379 316 1 +380 316 1 +49 317 1 +202 317 1 +208 317 -1 +331 317 1 +332 317 1 +333 317 1 +334 317 1 +49 318 1 +203 318 1 +209 318 -1 +339 318 1 +340 318 1 +341 318 1 +1 319 1 +50 319 1 +202 319 -1 +212 319 1 +332 319 -1 +333 319 -1 +334 319 -1 +2 320 1 +50 320 1 +203 320 -1 +213 320 1 +340 320 -1 +341 320 -1 +51 321 1 +183 321 1 +202 321 -1 +237 321 1 +51 322 1 +184 322 1 +203 322 -1 +240 322 1 +52 323 1 +199 323 1 +202 323 -1 +52 324 1 +53 325 1 +208 325 1 +222 325 -1 +360 325 1 +361 325 1 +362 325 1 +363 325 1 +364 325 1 +365 325 1 +366 325 1 +367 325 1 +368 325 1 +430 325 -1 +431 325 -1 +432 325 -1 +53 326 1 +209 326 1 +223 326 -1 +374 326 1 +375 326 1 +376 326 1 +377 326 1 +378 326 1 +379 326 1 +380 326 1 +438 326 -1 +439 326 -1 +440 326 -1 +1 327 1 +54 327 1 +212 327 -1 +222 327 1 +398 327 -1 +2 328 1 +54 328 1 +213 328 -1 +223 328 1 +401 328 -1 +1 329 1 +55 329 1 +212 329 1 +222 329 -1 +427 329 -1 +428 329 -1 +429 329 -1 +430 329 -1 +431 329 -1 +432 329 -1 +2 330 1 +55 330 1 +213 330 1 +223 330 -1 +435 330 -1 +436 330 -1 +437 330 -1 +438 330 -1 +439 330 -1 +440 330 -1 +1 331 1 +56 331 1 +431 331 -1 +432 331 -1 +3 332 1 +56 332 1 +57 333 1 +208 333 1 +222 333 -1 +358 333 1 +359 333 1 +360 333 1 +361 333 1 +362 333 1 +363 333 1 +364 333 1 +365 333 1 +366 333 1 +367 333 1 +368 333 1 +426 333 -1 +427 333 -1 +428 333 -1 +429 333 -1 +430 333 -1 +431 333 -1 +432 333 -1 +57 334 1 +209 334 1 +223 334 -1 +371 334 1 +372 334 1 +373 334 1 +374 334 1 +375 334 1 +376 334 1 +377 334 1 +378 334 1 +379 334 1 +380 334 1 +434 334 -1 +435 334 -1 +436 334 -1 +437 334 -1 +438 334 -1 +439 334 -1 +440 334 -1 +58 335 1 +212 335 -1 +222 335 1 +427 335 1 +428 335 1 +429 335 1 +430 335 1 +431 335 1 +432 335 1 +58 336 1 +213 336 -1 +223 336 1 +435 336 1 +436 336 1 +437 336 1 +438 336 1 +439 336 1 +440 336 1 +59 337 1 +208 337 -1 +222 337 1 +430 337 1 +431 337 1 +432 337 1 +59 338 1 +209 338 -1 +223 338 1 +438 338 1 +439 338 1 +440 338 1 +60 339 1 +199 339 -1 +202 339 1 +328 339 1 +329 339 1 +330 339 1 +331 339 1 +332 339 1 +333 339 1 +334 339 1 +60 340 1 +342 340 1 +343 340 1 +344 340 1 +345 340 1 +61 341 1 +212 341 1 +222 341 -1 +396 341 1 +397 341 1 +398 341 1 +431 341 -1 +432 341 -1 +61 342 1 +213 342 1 +223 342 -1 +399 342 1 +400 342 1 +401 342 1 +439 342 -1 +440 342 -1 +1 343 1 +62 343 1 +208 343 -1 +222 343 1 +357 343 -1 +358 343 -1 +359 343 -1 +360 343 -1 +361 343 -1 +362 343 -1 +363 343 -1 +364 343 -1 +365 343 -1 +366 343 -1 +367 343 -1 +368 343 -1 +432 343 1 +2 344 1 +62 344 1 +209 344 -1 +223 344 1 +369 344 -1 +370 344 -1 +371 344 -1 +372 344 -1 +373 344 -1 +374 344 -1 +375 344 -1 +376 344 -1 +377 344 -1 +378 344 -1 +379 344 -1 +380 344 -1 +440 344 1 +1 345 1 +63 345 1 +193 345 -1 +220 345 1 +291 345 -1 +292 345 -1 +2 346 1 +63 346 1 +194 346 -1 +221 346 1 +296 346 -1 +297 346 -1 +3 347 1 +63 347 1 +301 347 -1 +1 348 1 +64 348 1 +212 348 -1 +220 348 1 +2 349 1 +64 349 1 +213 349 -1 +221 349 1 +3 350 1 +64 350 1 +65 351 1 +208 351 1 +210 351 -1 +365 351 1 +366 351 1 +367 351 1 +368 351 1 +65 352 1 +209 352 1 +211 352 -1 +377 352 1 +378 352 1 +379 352 1 +380 352 1 +65 353 1 +388 353 1 +389 353 1 +390 353 1 +391 353 1 +66 354 1 +208 354 -1 +210 354 1 +364 354 -1 +365 354 -1 +366 354 -1 +367 354 -1 +368 354 -1 +392 354 1 +393 354 1 +2 355 1 +66 355 1 +209 355 -1 +211 355 1 +376 355 -1 +377 355 -1 +378 355 -1 +379 355 -1 +380 355 -1 +3 356 1 +66 356 1 +387 356 -1 +388 356 -1 +389 356 -1 +390 356 -1 +391 356 -1 +1 357 1 +67 357 1 +183 357 -1 +220 357 1 +236 357 -1 +237 357 -1 +2 358 1 +67 358 1 +184 358 -1 +221 358 1 +239 358 -1 +240 358 -1 +3 359 1 +67 359 1 +242 359 -1 +68 360 1 +193 360 1 +220 360 -1 +289 360 1 +290 360 1 +291 360 1 +292 360 1 +68 361 1 +194 361 1 +221 361 -1 +294 361 1 +295 361 1 +296 361 1 +297 361 1 +68 362 1 +298 362 1 +299 362 1 +300 362 1 +301 362 1 +69 363 1 +181 363 1 +220 363 -1 +226 363 1 +227 363 1 +69 364 1 +182 364 1 +221 364 -1 +229 364 1 +230 364 1 +69 365 1 +232 365 1 +233 365 1 +1 366 1 +70 366 1 +183 366 1 +220 366 -1 +419 366 -1 +2 367 1 +70 367 1 +184 367 1 +221 367 -1 +422 367 -1 +3 368 1 +70 368 1 +424 368 -1 +71 369 1 +189 369 1 +197 369 -1 +256 369 1 +257 369 1 +258 369 1 +259 369 1 +260 369 1 +261 369 1 +262 369 1 +305 369 -1 +306 369 -1 +71 370 1 +190 370 1 +198 370 -1 +264 370 1 +265 370 1 +266 370 1 +267 370 1 +268 370 1 +269 370 1 +270 370 1 +308 370 -1 +309 370 -1 +71 371 1 +272 371 1 +273 371 1 +274 371 1 +275 371 1 +276 371 1 +277 371 1 +278 371 1 +310 371 -1 +1 372 1 +72 372 1 +197 372 1 +202 372 -1 +330 372 -1 +331 372 -1 +332 372 -1 +333 372 -1 +334 372 -1 +2 373 1 +72 373 1 +198 373 1 +203 373 -1 +338 373 -1 +339 373 -1 +340 373 -1 +341 373 -1 +3 374 1 +72 374 1 +344 374 -1 +345 374 -1 +73 375 1 +197 375 1 +222 375 -1 +304 375 1 +305 375 1 +306 375 1 +432 375 -1 +73 376 1 +198 376 1 +223 376 -1 +307 376 1 +308 376 1 +309 376 1 +440 376 -1 +3 377 1 +73 377 1 +74 378 1 +189 378 1 +197 378 -1 +259 378 1 +260 378 1 +261 378 1 +262 378 1 +74 379 1 +190 379 1 +198 379 -1 +267 379 1 +268 379 1 +269 379 1 +270 379 1 +74 380 1 +275 380 1 +276 380 1 +277 380 1 +278 380 1 +75 381 1 +193 381 -1 +202 381 1 +330 381 1 +331 381 1 +332 381 1 +333 381 1 +334 381 1 +75 382 1 +194 382 -1 +203 382 1 +338 382 1 +339 382 1 +340 382 1 +341 382 1 +75 383 1 +344 383 1 +345 383 1 +76 384 1 +193 384 1 +222 384 -1 +290 384 1 +291 384 1 +292 384 1 +431 384 -1 +432 384 -1 +76 385 1 +194 385 1 +223 385 -1 +295 385 1 +296 385 1 +297 385 1 +439 385 -1 +440 385 -1 +76 386 1 +300 386 1 +301 386 1 +77 387 1 +193 387 -1 +218 387 1 +410 387 1 +411 387 1 +77 388 1 +194 388 -1 +219 388 1 +412 388 1 +413 388 1 +414 388 1 +77 389 1 +415 389 1 +416 389 1 +1 390 1 +78 390 1 +202 390 1 +212 390 -1 +397 390 -1 +398 390 -1 +2 391 1 +78 391 1 +203 391 1 +213 391 -1 +400 391 -1 +401 391 -1 +78 392 1 +79 393 1 +193 393 -1 +200 393 1 +313 393 1 +314 393 1 +315 393 1 +79 394 1 +194 394 -1 +201 394 1 +318 394 1 +319 394 1 +320 394 1 +79 395 1 +323 395 1 +324 395 1 +325 395 1 +1 396 1 +80 396 1 +191 396 1 +200 396 -1 +312 396 -1 +313 396 -1 +314 396 -1 +315 396 -1 +2 397 1 +80 397 1 +192 397 1 +201 397 -1 +317 397 -1 +318 397 -1 +319 397 -1 +320 397 -1 +3 398 1 +80 398 1 +322 398 -1 +323 398 -1 +324 398 -1 +325 398 -1 +81 399 1 +193 399 1 +218 399 -1 +288 399 1 +289 399 1 +290 399 1 +291 399 1 +292 399 1 +410 399 -1 +411 399 -1 +81 400 1 +194 400 1 +219 400 -1 +293 400 1 +294 400 1 +295 400 1 +296 400 1 +297 400 1 +412 400 -1 +413 400 -1 +414 400 -1 +3 401 1 +81 401 1 +415 401 -1 +416 401 -1 +1 402 -1 +82 402 1 +189 402 1 +216 402 -1 +255 402 1 +256 402 1 +257 402 1 +258 402 1 +259 402 1 +260 402 1 +261 402 1 +262 402 1 +2 403 -1 +82 403 1 +190 403 1 +217 403 -1 +263 403 1 +264 403 1 +265 403 1 +266 403 1 +267 403 1 +268 403 1 +269 403 1 +270 403 1 +3 404 -1 +82 404 1 +271 404 1 +272 404 1 +273 404 1 +274 404 1 +275 404 1 +276 404 1 +277 404 1 +278 404 1 +83 405 1 +189 405 -1 +208 405 1 +368 405 1 +83 406 1 +190 406 -1 +209 406 1 +380 406 1 +83 407 1 +391 407 1 +84 408 1 +191 408 -1 +200 408 1 +312 408 1 +313 408 1 +314 408 1 +315 408 1 +84 409 1 +192 409 -1 +201 409 1 +317 409 1 +318 409 1 +319 409 1 +320 409 1 +84 410 1 +322 410 1 +323 410 1 +324 410 1 +325 410 1 +1 411 1 +85 411 1 +195 411 1 +202 411 -1 +331 411 -1 +332 411 -1 +333 411 -1 +334 411 -1 +2 412 1 +85 412 1 +196 412 1 +203 412 -1 +339 412 -1 +340 412 -1 +341 412 -1 +3 413 1 +85 413 1 +345 413 -1 +86 414 1 +189 414 1 +208 414 -1 +261 414 1 +262 414 1 +86 415 1 +190 415 1 +209 415 -1 +269 415 1 +270 415 1 +86 416 1 +277 416 1 +278 416 1 +87 417 1 +208 417 -1 +212 417 1 +367 417 -1 +368 417 -1 +398 417 1 +87 418 1 +209 418 -1 +213 418 1 +379 418 -1 +380 418 -1 +401 418 1 +3 419 1 +87 419 1 +390 419 -1 +391 419 -1 +88 420 1 +181 420 -1 +208 420 1 +226 420 -1 +227 420 -1 +359 420 1 +360 420 1 +361 420 1 +362 420 1 +363 420 1 +364 420 1 +365 420 1 +366 420 1 +367 420 1 +368 420 1 +88 421 1 +182 421 -1 +209 421 1 +229 421 -1 +230 421 -1 +373 421 1 +374 421 1 +375 421 1 +376 421 1 +377 421 1 +378 421 1 +379 421 1 +380 421 1 +88 422 1 +232 422 -1 +233 422 -1 +385 422 1 +386 422 1 +387 422 1 +388 422 1 +389 422 1 +390 422 1 +391 422 1 +89 423 1 +189 423 1 +204 423 -1 +257 423 1 +258 423 1 +259 423 1 +260 423 1 +261 423 1 +262 423 1 +346 423 -1 +347 423 -1 +89 424 1 +190 424 1 +205 424 -1 +265 424 1 +266 424 1 +267 424 1 +268 424 1 +269 424 1 +270 424 1 +348 424 -1 +349 424 -1 +89 425 1 +273 425 1 +274 425 1 +275 425 1 +276 425 1 +277 425 1 +278 425 1 +350 425 -1 +351 425 -1 +1 426 1 +90 426 1 +187 426 -1 +189 426 1 +246 426 -1 +247 426 -1 +248 426 -1 +2 427 1 +90 427 1 +188 427 -1 +190 427 1 +249 427 -1 +250 427 -1 +251 427 -1 +3 428 1 +90 428 1 +252 428 -1 +253 428 -1 +254 428 -1 +91 429 1 +193 429 1 +208 429 -1 +291 429 1 +292 429 1 +367 429 -1 +368 429 -1 +91 430 1 +194 430 1 +209 430 -1 +296 430 1 +297 430 1 +379 430 -1 +380 430 -1 +91 431 1 +301 431 1 +390 431 -1 +391 431 -1 +92 432 1 +193 432 -1 +208 432 1 +290 432 -1 +291 432 -1 +292 432 -1 +359 432 1 +360 432 1 +361 432 1 +362 432 1 +363 432 1 +364 432 1 +365 432 1 +366 432 1 +367 432 1 +368 432 1 +92 433 1 +194 433 -1 +209 433 1 +295 433 -1 +296 433 -1 +297 433 -1 +373 433 1 +374 433 1 +375 433 1 +376 433 1 +377 433 1 +378 433 1 +379 433 1 +380 433 1 +92 434 1 +299 434 -1 +300 434 -1 +301 434 -1 +385 434 1 +386 434 1 +387 434 1 +388 434 1 +389 434 1 +390 434 1 +391 434 1 +1 435 1 +93 435 1 +2 436 1 +93 436 1 +3 437 1 +93 437 1 +94 438 1 +189 438 -1 +222 438 1 +261 438 -1 +262 438 -1 +429 438 1 +430 438 1 +431 438 1 +432 438 1 +94 439 1 +190 439 -1 +223 439 1 +269 439 -1 +270 439 -1 +437 439 1 +438 439 1 +439 439 1 +440 439 1 +94 440 1 +277 440 -1 +278 440 -1 +442 440 1 +1 441 -1 +95 441 1 +206 441 -1 +208 441 1 +358 441 1 +359 441 1 +360 441 1 +361 441 1 +362 441 1 +363 441 1 +364 441 1 +365 441 1 +366 441 1 +367 441 1 +368 441 1 +2 442 -1 +95 442 1 +207 442 -1 +209 442 1 +371 442 1 +372 442 1 +373 442 1 +374 442 1 +375 442 1 +376 442 1 +377 442 1 +378 442 1 +379 442 1 +380 442 1 +95 443 1 +355 443 -1 +356 443 -1 +383 443 1 +384 443 1 +385 443 1 +386 443 1 +387 443 1 +388 443 1 +389 443 1 +390 443 1 +391 443 1 +96 444 1 +183 444 -1 +189 444 1 +259 444 1 +260 444 1 +261 444 1 +262 444 1 +96 445 1 +184 445 -1 +190 445 1 +267 445 1 +268 445 1 +269 445 1 +270 445 1 +96 446 1 +275 446 1 +276 446 1 +277 446 1 +278 446 1 +97 447 1 +195 447 -1 +220 447 1 +417 447 1 +418 447 1 +419 447 1 +97 448 1 +196 448 -1 +221 448 1 +420 448 1 +421 448 1 +422 448 1 +97 449 1 +423 449 1 +424 449 1 +1 450 1 +98 450 1 +206 450 -1 +216 450 1 +2 451 1 +98 451 1 +207 451 -1 +217 451 1 +3 452 1 +98 452 1 +99 453 1 +209 453 1 +224 453 -1 +372 453 1 +373 453 1 +374 453 1 +375 453 1 +376 453 1 +377 453 1 +378 453 1 +379 453 1 +380 453 1 +443 453 -1 +99 454 1 +384 454 1 +385 454 1 +386 454 1 +387 454 1 +388 454 1 +389 454 1 +390 454 1 +391 454 1 +444 454 -1 +100 455 1 +183 455 -1 +200 455 1 +311 455 1 +312 455 1 +313 455 1 +314 455 1 +315 455 1 +100 456 1 +184 456 -1 +201 456 1 +316 456 1 +317 456 1 +318 456 1 +319 456 1 +320 456 1 +100 457 1 +321 457 1 +322 457 1 +323 457 1 +324 457 1 +325 457 1 +101 458 1 +197 458 1 +208 458 -1 +306 458 1 +101 459 1 +198 459 1 +209 459 -1 +309 459 1 +101 460 1 +310 460 1 +102 461 1 +193 461 1 +200 461 -1 +288 461 1 +289 461 1 +290 461 1 +291 461 1 +292 461 1 +314 461 -1 +315 461 -1 +102 462 1 +194 462 1 +201 462 -1 +293 462 1 +294 462 1 +295 462 1 +296 462 1 +297 462 1 +319 462 -1 +320 462 -1 +3 463 1 +102 463 1 +324 463 -1 +325 463 -1 +103 464 1 +187 464 -1 +208 464 1 +247 464 -1 +248 464 -1 +358 464 1 +359 464 1 +360 464 1 +361 464 1 +362 464 1 +363 464 1 +364 464 1 +365 464 1 +366 464 1 +367 464 1 +368 464 1 +103 465 1 +188 465 -1 +209 465 1 +250 465 -1 +251 465 -1 +371 465 1 +372 465 1 +373 465 1 +374 465 1 +375 465 1 +376 465 1 +377 465 1 +378 465 1 +379 465 1 +380 465 1 +103 466 1 +253 466 -1 +254 466 -1 +383 466 1 +384 466 1 +385 466 1 +386 466 1 +387 466 1 +388 466 1 +389 466 1 +390 466 1 +391 466 1 +104 467 1 +187 467 1 +208 467 -1 +246 467 1 +247 467 1 +248 467 1 +359 467 -1 +360 467 -1 +361 467 -1 +362 467 -1 +363 467 -1 +364 467 -1 +365 467 -1 +366 467 -1 +367 467 -1 +368 467 -1 +104 468 1 +188 468 1 +209 468 -1 +249 468 1 +250 468 1 +251 468 1 +373 468 -1 +374 468 -1 +375 468 -1 +376 468 -1 +377 468 -1 +378 468 -1 +379 468 -1 +380 468 -1 +104 469 1 +252 469 1 +253 469 1 +254 469 1 +385 469 -1 +386 469 -1 +387 469 -1 +388 469 -1 +389 469 -1 +390 469 -1 +391 469 -1 +105 470 1 +189 470 -1 +204 470 1 +260 470 -1 +261 470 -1 +262 470 -1 +346 470 1 +347 470 1 +105 471 1 +190 471 -1 +205 471 1 +268 471 -1 +269 471 -1 +270 471 -1 +348 471 1 +349 471 1 +105 472 1 +276 472 -1 +277 472 -1 +278 472 -1 +350 472 1 +351 472 1 +1 473 1 +106 473 1 +204 473 1 +208 473 -1 +359 473 -1 +360 473 -1 +361 473 -1 +362 473 -1 +363 473 -1 +364 473 -1 +365 473 -1 +366 473 -1 +367 473 -1 +368 473 -1 +2 474 1 +106 474 1 +205 474 1 +209 474 -1 +373 474 -1 +374 474 -1 +375 474 -1 +376 474 -1 +377 474 -1 +378 474 -1 +379 474 -1 +380 474 -1 +3 475 1 +106 475 1 +385 475 -1 +386 475 -1 +387 475 -1 +388 475 -1 +389 475 -1 +390 475 -1 +391 475 -1 +107 476 1 +204 476 -1 +218 476 1 +411 476 1 +107 477 1 +205 477 -1 +219 477 1 +414 477 1 +107 478 1 +416 478 1 +108 479 1 +189 479 -1 +191 479 1 +281 479 1 +108 480 1 +190 480 -1 +192 480 1 +284 480 1 +108 481 1 +287 481 1 +109 482 1 +181 482 1 +189 482 -1 +225 482 1 +226 482 1 +227 482 1 +259 482 -1 +260 482 -1 +261 482 -1 +262 482 -1 +109 483 1 +182 483 1 +190 483 -1 +228 483 1 +229 483 1 +230 483 1 +267 483 -1 +268 483 -1 +269 483 -1 +270 483 -1 +109 484 1 +231 484 1 +232 484 1 +233 484 1 +275 484 -1 +276 484 -1 +277 484 -1 +278 484 -1 +110 485 1 +187 485 1 +204 485 -1 +248 485 1 +347 485 -1 +110 486 1 +188 486 1 +205 486 -1 +251 486 1 +349 486 -1 +110 487 1 +254 487 1 +351 487 -1 +1 488 1 +111 488 1 +187 488 -1 +206 488 1 +248 488 -1 +2 489 1 +111 489 1 +188 489 -1 +207 489 1 +251 489 -1 +111 490 1 +254 490 -1 +355 490 1 +356 490 1 +1 491 1 +112 491 1 +189 491 -1 +208 491 1 +255 491 -1 +256 491 -1 +257 491 -1 +258 491 -1 +259 491 -1 +260 491 -1 +261 491 -1 +262 491 -1 +365 491 1 +366 491 1 +367 491 1 +368 491 1 +2 492 1 +112 492 1 +190 492 -1 +209 492 1 +263 492 -1 +264 492 -1 +265 492 -1 +266 492 -1 +267 492 -1 +268 492 -1 +269 492 -1 +270 492 -1 +377 492 1 +378 492 1 +379 492 1 +380 492 1 +3 493 1 +112 493 1 +271 493 -1 +272 493 -1 +273 493 -1 +274 493 -1 +275 493 -1 +276 493 -1 +277 493 -1 +278 493 -1 +388 493 1 +389 493 1 +390 493 1 +391 493 1 +1 494 1 +113 494 1 +189 494 -1 +200 494 1 +255 494 -1 +256 494 -1 +257 494 -1 +258 494 -1 +259 494 -1 +260 494 -1 +261 494 -1 +262 494 -1 +314 494 1 +315 494 1 +2 495 1 +113 495 1 +190 495 -1 +201 495 1 +263 495 -1 +264 495 -1 +265 495 -1 +266 495 -1 +267 495 -1 +268 495 -1 +269 495 -1 +270 495 -1 +319 495 1 +320 495 1 +3 496 1 +113 496 1 +271 496 -1 +272 496 -1 +273 496 -1 +274 496 -1 +275 496 -1 +276 496 -1 +277 496 -1 +278 496 -1 +324 496 1 +325 496 1 +1 497 1 +114 497 1 +200 497 -1 +202 497 1 +311 497 -1 +312 497 -1 +313 497 -1 +314 497 -1 +315 497 -1 +2 498 1 +114 498 1 +201 498 -1 +203 498 1 +316 498 -1 +317 498 -1 +318 498 -1 +319 498 -1 +320 498 -1 +3 499 1 +114 499 1 +321 499 -1 +322 499 -1 +323 499 -1 +324 499 -1 +325 499 -1 +1 500 1 +115 500 1 +191 500 1 +208 500 -1 +357 500 -1 +358 500 -1 +359 500 -1 +360 500 -1 +361 500 -1 +362 500 -1 +363 500 -1 +364 500 -1 +365 500 -1 +366 500 -1 +367 500 -1 +368 500 -1 +2 501 1 +115 501 1 +192 501 1 +209 501 -1 +370 501 -1 +371 501 -1 +372 501 -1 +373 501 -1 +374 501 -1 +375 501 -1 +376 501 -1 +377 501 -1 +378 501 -1 +379 501 -1 +380 501 -1 +3 502 1 +115 502 1 +382 502 -1 +383 502 -1 +384 502 -1 +385 502 -1 +386 502 -1 +387 502 -1 +388 502 -1 +389 502 -1 +390 502 -1 +391 502 -1 +116 503 1 +208 503 -1 +216 503 1 +366 503 -1 +367 503 -1 +368 503 -1 +407 503 1 +116 504 1 +209 504 -1 +217 504 1 +378 504 -1 +379 504 -1 +380 504 -1 +408 504 1 +116 505 1 +389 505 -1 +390 505 -1 +391 505 -1 +409 505 1 +1 506 1 +117 506 1 +187 506 1 +189 506 -1 +258 506 -1 +259 506 -1 +260 506 -1 +261 506 -1 +262 506 -1 +2 507 1 +117 507 1 +188 507 1 +190 507 -1 +266 507 -1 +267 507 -1 +268 507 -1 +269 507 -1 +270 507 -1 +3 508 1 +117 508 1 +274 508 -1 +275 508 -1 +276 508 -1 +277 508 -1 +278 508 -1 +118 509 1 +185 509 -1 +189 509 1 +243 509 -1 +256 509 1 +257 509 1 +258 509 1 +259 509 1 +260 509 1 +261 509 1 +262 509 1 +118 510 1 +186 510 -1 +190 510 1 +244 510 -1 +264 510 1 +265 510 1 +266 510 1 +267 510 1 +268 510 1 +269 510 1 +270 510 1 +118 511 1 +245 511 -1 +272 511 1 +273 511 1 +274 511 1 +275 511 1 +276 511 1 +277 511 1 +278 511 1 +119 512 1 +191 512 -1 +208 512 1 +279 512 -1 +280 512 -1 +281 512 -1 +358 512 1 +359 512 1 +360 512 1 +361 512 1 +362 512 1 +363 512 1 +364 512 1 +365 512 1 +366 512 1 +367 512 1 +368 512 1 +119 513 1 +192 513 -1 +209 513 1 +282 513 -1 +283 513 -1 +284 513 -1 +371 513 1 +372 513 1 +373 513 1 +374 513 1 +375 513 1 +376 513 1 +377 513 1 +378 513 1 +379 513 1 +380 513 1 +119 514 1 +285 514 -1 +286 514 -1 +287 514 -1 +383 514 1 +384 514 1 +385 514 1 +386 514 1 +387 514 1 +388 514 1 +389 514 1 +390 514 1 +391 514 1 +1 515 1 +120 515 1 +193 515 1 +208 515 -1 +358 515 -1 +359 515 -1 +360 515 -1 +361 515 -1 +362 515 -1 +363 515 -1 +364 515 -1 +365 515 -1 +366 515 -1 +367 515 -1 +368 515 -1 +2 516 1 +120 516 1 +194 516 1 +209 516 -1 +371 516 -1 +372 516 -1 +373 516 -1 +374 516 -1 +375 516 -1 +376 516 -1 +377 516 -1 +378 516 -1 +379 516 -1 +380 516 -1 +3 517 1 +120 517 1 +383 517 -1 +384 517 -1 +385 517 -1 +386 517 -1 +387 517 -1 +388 517 -1 +389 517 -1 +390 517 -1 +391 517 -1 +1 518 1 +121 518 1 +181 518 -1 +208 518 1 +225 518 -1 +226 518 -1 +227 518 -1 +2 519 1 +121 519 1 +182 519 -1 +209 519 1 +228 519 -1 +229 519 -1 +230 519 -1 +3 520 1 +121 520 1 +231 520 -1 +232 520 -1 +233 520 -1 +122 521 1 +193 521 1 +218 521 -1 +290 521 1 +291 521 1 +292 521 1 +122 522 1 +194 522 1 +219 522 -1 +295 522 1 +296 522 1 +297 522 1 +122 523 1 +299 523 1 +300 523 1 +301 523 1 +123 524 1 +189 524 1 +208 524 -1 +257 524 1 +258 524 1 +259 524 1 +260 524 1 +261 524 1 +262 524 1 +366 524 -1 +367 524 -1 +368 524 -1 +123 525 1 +190 525 1 +209 525 -1 +265 525 1 +266 525 1 +267 525 1 +268 525 1 +269 525 1 +270 525 1 +378 525 -1 +379 525 -1 +380 525 -1 +123 526 1 +273 526 1 +274 526 1 +275 526 1 +276 526 1 +277 526 1 +278 526 1 +389 526 -1 +390 526 -1 +391 526 -1 +124 527 1 +202 527 -1 +212 527 1 +333 527 -1 +334 527 -1 +397 527 1 +398 527 1 +124 528 1 +203 528 -1 +213 528 1 +341 528 -1 +400 528 1 +401 528 1 +3 529 1 +124 529 1 +125 530 1 +183 530 1 +189 530 -1 +236 530 1 +237 530 1 +262 530 -1 +125 531 1 +184 531 1 +190 531 -1 +239 531 1 +240 531 1 +270 531 -1 +125 532 1 +242 532 1 +278 532 -1 +126 533 1 +198 533 -1 +223 533 1 +309 533 -1 +433 533 1 +434 533 1 +435 533 1 +436 533 1 +437 533 1 +438 533 1 +439 533 1 +440 533 1 +126 534 1 +310 534 -1 +441 534 1 +442 534 1 +127 535 1 +181 535 1 +189 535 -1 +225 535 1 +226 535 1 +227 535 1 +260 535 -1 +261 535 -1 +262 535 -1 +127 536 1 +182 536 1 +190 536 -1 +228 536 1 +229 536 1 +230 536 1 +268 536 -1 +269 536 -1 +270 536 -1 +127 537 1 +231 537 1 +232 537 1 +233 537 1 +276 537 -1 +277 537 -1 +278 537 -1 +128 538 1 +189 538 -1 +200 538 1 +315 538 1 +128 539 1 +190 539 -1 +201 539 1 +320 539 1 +128 540 1 +325 540 1 +129 541 1 +189 541 1 +191 541 -1 +256 541 1 +257 541 1 +258 541 1 +259 541 1 +260 541 1 +261 541 1 +262 541 1 +280 541 -1 +281 541 -1 +129 542 1 +190 542 1 +192 542 -1 +264 542 1 +265 542 1 +266 542 1 +267 542 1 +268 542 1 +269 542 1 +270 542 1 +283 542 -1 +284 542 -1 +129 543 1 +272 543 1 +273 543 1 +274 543 1 +275 543 1 +276 543 1 +277 543 1 +278 543 1 +286 543 -1 +287 543 -1 +1 544 1 +130 544 1 +200 544 1 +208 544 -1 +361 544 -1 +362 544 -1 +363 544 -1 +364 544 -1 +365 544 -1 +366 544 -1 +367 544 -1 +368 544 -1 +2 545 1 +130 545 1 +201 545 1 +209 545 -1 +375 545 -1 +376 545 -1 +377 545 -1 +378 545 -1 +379 545 -1 +380 545 -1 +3 546 1 +130 546 1 +386 546 -1 +387 546 -1 +388 546 -1 +389 546 -1 +390 546 -1 +391 546 -1 +131 547 1 +200 547 -1 +206 547 1 +352 547 1 +131 548 1 +201 548 -1 +207 548 1 +354 548 1 +131 549 1 +356 549 1 +1 550 1 +132 550 1 +183 550 1 +200 550 -1 +313 550 -1 +314 550 -1 +315 550 -1 +2 551 1 +132 551 1 +184 551 1 +201 551 -1 +318 551 -1 +319 551 -1 +320 551 -1 +3 552 1 +132 552 1 +323 552 -1 +324 552 -1 +325 552 -1 +1 553 1 +133 553 1 +206 553 -1 +222 553 1 +352 553 -1 +2 554 1 +133 554 1 +207 554 -1 +223 554 1 +354 554 -1 +3 555 1 +133 555 1 +356 555 -1 +1 556 1 +134 556 1 +189 556 -1 +210 556 1 +255 556 -1 +256 556 -1 +257 556 -1 +258 556 -1 +259 556 -1 +260 556 -1 +261 556 -1 +262 556 -1 +393 556 1 +2 557 1 +134 557 1 +190 557 -1 +211 557 1 +263 557 -1 +264 557 -1 +265 557 -1 +266 557 -1 +267 557 -1 +268 557 -1 +269 557 -1 +270 557 -1 +394 557 1 +3 558 1 +134 558 1 +271 558 -1 +272 558 -1 +273 558 -1 +274 558 -1 +275 558 -1 +276 558 -1 +277 558 -1 +278 558 -1 +395 558 1 +1 559 1 +135 559 1 +189 559 1 +212 559 -1 +396 559 -1 +397 559 -1 +398 559 -1 +2 560 1 +135 560 1 +190 560 1 +213 560 -1 +399 560 -1 +400 560 -1 +401 560 -1 +135 561 1 +136 562 1 +202 562 -1 +208 562 1 +327 562 -1 +328 562 -1 +329 562 -1 +330 562 -1 +331 562 -1 +332 562 -1 +333 562 -1 +334 562 -1 +358 562 1 +359 562 1 +360 562 1 +361 562 1 +362 562 1 +363 562 1 +364 562 1 +365 562 1 +366 562 1 +367 562 1 +368 562 1 +136 563 1 +203 563 -1 +209 563 1 +336 563 -1 +337 563 -1 +338 563 -1 +339 563 -1 +340 563 -1 +341 563 -1 +371 563 1 +372 563 1 +373 563 1 +374 563 1 +375 563 1 +376 563 1 +377 563 1 +378 563 1 +379 563 1 +380 563 1 +136 564 1 +342 564 -1 +343 564 -1 +344 564 -1 +345 564 -1 +383 564 1 +384 564 1 +385 564 1 +386 564 1 +387 564 1 +388 564 1 +389 564 1 +390 564 1 +391 564 1 +137 565 1 +181 565 -1 +189 565 1 +258 565 1 +259 565 1 +260 565 1 +261 565 1 +262 565 1 +137 566 1 +182 566 -1 +190 566 1 +266 566 1 +267 566 1 +268 566 1 +269 566 1 +270 566 1 +137 567 1 +274 567 1 +275 567 1 +276 567 1 +277 567 1 +278 567 1 +1 568 1 +138 568 1 +208 568 -1 +218 568 1 +361 568 -1 +362 568 -1 +363 568 -1 +364 568 -1 +365 568 -1 +366 568 -1 +367 568 -1 +368 568 -1 +2 569 1 +138 569 1 +209 569 -1 +219 569 1 +375 569 -1 +376 569 -1 +377 569 -1 +378 569 -1 +379 569 -1 +380 569 -1 +3 570 1 +138 570 1 +386 570 -1 +387 570 -1 +388 570 -1 +389 570 -1 +390 570 -1 +391 570 -1 +139 571 1 +191 571 1 +222 571 -1 +280 571 1 +281 571 1 +431 571 -1 +432 571 -1 +139 572 1 +192 572 1 +223 572 -1 +283 572 1 +284 572 1 +439 572 -1 +440 572 -1 +139 573 1 +286 573 1 +287 573 1 +1 574 1 +140 574 1 +183 574 1 +218 574 -1 +411 574 -1 +2 575 1 +140 575 1 +184 575 1 +219 575 -1 +414 575 -1 +3 576 1 +140 576 1 +416 576 -1 +141 577 1 +183 577 1 +200 577 -1 +234 577 1 +235 577 1 +236 577 1 +237 577 1 +315 577 -1 +2 578 1 +141 578 1 +184 578 1 +201 578 -1 +320 578 -1 +3 579 1 +141 579 1 +325 579 -1 +142 580 1 +181 580 1 +208 580 -1 +227 580 1 +368 580 -1 +142 581 1 +182 581 1 +209 581 -1 +230 581 1 +380 581 -1 +142 582 1 +233 582 1 +391 582 -1 +1 583 1 +143 583 1 +206 583 1 +208 583 -1 +364 583 -1 +365 583 -1 +366 583 -1 +367 583 -1 +368 583 -1 +143 584 1 +207 584 1 +209 584 -1 +353 584 1 +354 584 1 +376 584 -1 +377 584 -1 +378 584 -1 +379 584 -1 +380 584 -1 +143 585 1 +355 585 1 +356 585 1 +387 585 -1 +388 585 -1 +389 585 -1 +390 585 -1 +391 585 -1 +1 586 1 +144 586 1 +185 586 1 +216 586 -1 +407 586 -1 +2 587 1 +144 587 1 +186 587 1 +217 587 -1 +408 587 -1 +3 588 1 +144 588 1 +409 588 -1 +145 589 1 +204 589 1 +208 589 -1 +347 589 1 +145 590 1 +205 590 1 +209 590 -1 +349 590 1 +145 591 1 +351 591 1 +146 592 1 +189 592 1 +208 592 -1 +259 592 1 +260 592 1 +261 592 1 +262 592 1 +366 592 -1 +367 592 -1 +368 592 -1 +146 593 1 +190 593 1 +209 593 -1 +267 593 1 +268 593 1 +269 593 1 +270 593 1 +378 593 -1 +379 593 -1 +380 593 -1 +146 594 1 +275 594 1 +276 594 1 +277 594 1 +278 594 1 +389 594 -1 +390 594 -1 +391 594 -1 +1 595 1 +147 595 1 +202 595 1 +222 595 -1 +425 595 -1 +426 595 -1 +427 595 -1 +428 595 -1 +429 595 -1 +430 595 -1 +431 595 -1 +432 595 -1 +2 596 1 +147 596 1 +203 596 1 +223 596 -1 +433 596 -1 +434 596 -1 +435 596 -1 +436 596 -1 +437 596 -1 +438 596 -1 +439 596 -1 +440 596 -1 +3 597 1 +147 597 1 +441 597 -1 +442 597 -1 +148 598 1 +202 598 1 +220 598 -1 +332 598 1 +333 598 1 +334 598 1 +148 599 1 +203 599 1 +221 599 -1 +340 599 1 +341 599 1 +148 600 1 +345 600 1 +1 601 1 +149 601 1 +202 601 -1 +220 601 1 +329 601 -1 +330 601 -1 +331 601 -1 +332 601 -1 +333 601 -1 +334 601 -1 +2 602 1 +149 602 1 +203 602 -1 +221 602 1 +337 602 -1 +338 602 -1 +339 602 -1 +340 602 -1 +341 602 -1 +3 603 1 +149 603 1 +343 603 -1 +344 603 -1 +345 603 -1 +150 604 1 +202 604 1 +220 604 -1 +329 604 1 +330 604 1 +331 604 1 +332 604 1 +333 604 1 +334 604 1 +419 604 -1 +150 605 1 +203 605 1 +221 605 -1 +337 605 1 +338 605 1 +339 605 1 +340 605 1 +341 605 1 +422 605 -1 +150 606 1 +343 606 1 +344 606 1 +345 606 1 +424 606 -1 +151 607 1 +202 607 -1 +220 607 1 +332 607 -1 +333 607 -1 +334 607 -1 +419 607 1 +151 608 1 +203 608 -1 +221 608 1 +340 608 -1 +341 608 -1 +422 608 1 +151 609 1 +345 609 -1 +424 609 1 +152 610 1 +189 610 1 +220 610 -1 +255 610 1 +256 610 1 +257 610 1 +258 610 1 +259 610 1 +260 610 1 +261 610 1 +262 610 1 +417 610 -1 +418 610 -1 +419 610 -1 +152 611 1 +190 611 1 +221 611 -1 +263 611 1 +264 611 1 +265 611 1 +266 611 1 +267 611 1 +268 611 1 +269 611 1 +270 611 1 +420 611 -1 +421 611 -1 +422 611 -1 +152 612 1 +271 612 1 +272 612 1 +273 612 1 +274 612 1 +275 612 1 +276 612 1 +277 612 1 +278 612 1 +423 612 -1 +424 612 -1 +1 613 1 +153 613 1 +189 613 -1 +200 613 1 +256 613 -1 +257 613 -1 +258 613 -1 +259 613 -1 +260 613 -1 +261 613 -1 +262 613 -1 +2 614 1 +153 614 1 +190 614 -1 +201 614 1 +264 614 -1 +265 614 -1 +266 614 -1 +267 614 -1 +268 614 -1 +269 614 -1 +270 614 -1 +3 615 1 +153 615 1 +272 615 -1 +273 615 -1 +274 615 -1 +275 615 -1 +276 615 -1 +277 615 -1 +278 615 -1 +154 616 1 +191 616 -1 +208 616 1 +364 616 1 +365 616 1 +366 616 1 +367 616 1 +368 616 1 +154 617 1 +192 617 -1 +209 617 1 +376 617 1 +377 617 1 +378 617 1 +379 617 1 +380 617 1 +154 618 1 +387 618 1 +388 618 1 +389 618 1 +390 618 1 +391 618 1 +155 619 1 +191 619 -1 +208 619 1 +281 619 -1 +362 619 1 +363 619 1 +364 619 1 +365 619 1 +366 619 1 +367 619 1 +368 619 1 +155 620 1 +192 620 -1 +209 620 1 +284 620 -1 +375 620 1 +376 620 1 +377 620 1 +378 620 1 +379 620 1 +380 620 1 +155 621 1 +287 621 -1 +386 621 1 +387 621 1 +388 621 1 +389 621 1 +390 621 1 +391 621 1 +156 622 1 +183 622 -1 +208 622 1 +235 622 -1 +236 622 -1 +237 622 -1 +359 622 1 +360 622 1 +361 622 1 +362 622 1 +363 622 1 +364 622 1 +365 622 1 +366 622 1 +367 622 1 +368 622 1 +156 623 1 +184 623 -1 +209 623 1 +238 623 -1 +239 623 -1 +240 623 -1 +373 623 1 +374 623 1 +375 623 1 +376 623 1 +377 623 1 +378 623 1 +379 623 1 +380 623 1 +156 624 1 +241 624 -1 +242 624 -1 +385 624 1 +386 624 1 +387 624 1 +388 624 1 +389 624 1 +390 624 1 +391 624 1 +157 625 1 +183 625 -1 +208 625 1 +366 625 1 +367 625 1 +368 625 1 +157 626 1 +184 626 -1 +209 626 1 +378 626 1 +379 626 1 +380 626 1 +157 627 1 +389 627 1 +390 627 1 +391 627 1 +158 628 1 +187 628 -1 +208 628 1 +364 628 1 +365 628 1 +366 628 1 +367 628 1 +368 628 1 +158 629 1 +188 629 -1 +209 629 1 +376 629 1 +377 629 1 +378 629 1 +379 629 1 +380 629 1 +158 630 1 +387 630 1 +388 630 1 +389 630 1 +390 630 1 +391 630 1 +159 631 1 +185 631 1 +208 631 -1 +243 631 1 +365 631 -1 +366 631 -1 +367 631 -1 +368 631 -1 +159 632 1 +186 632 1 +209 632 -1 +244 632 1 +377 632 -1 +378 632 -1 +379 632 -1 +380 632 -1 +159 633 1 +245 633 1 +388 633 -1 +389 633 -1 +390 633 -1 +391 633 -1 +160 634 1 +181 634 -1 +208 634 1 +227 634 -1 +362 634 1 +363 634 1 +364 634 1 +365 634 1 +366 634 1 +367 634 1 +368 634 1 +160 635 1 +182 635 -1 +209 635 1 +230 635 -1 +375 635 1 +376 635 1 +377 635 1 +378 635 1 +379 635 1 +380 635 1 +160 636 1 +233 636 -1 +386 636 1 +387 636 1 +388 636 1 +389 636 1 +390 636 1 +391 636 1 +161 637 1 +181 637 -1 +208 637 1 +366 637 1 +367 637 1 +368 637 1 +161 638 1 +182 638 -1 +209 638 1 +378 638 1 +379 638 1 +380 638 1 +161 639 1 +389 639 1 +390 639 1 +391 639 1 +162 640 1 +185 640 -1 +208 640 1 +366 640 1 +367 640 1 +368 640 1 +162 641 1 +186 641 -1 +209 641 1 +378 641 1 +379 641 1 +380 641 1 +162 642 1 +389 642 1 +390 642 1 +391 642 1 +1 643 1 +163 643 1 +181 643 1 +208 643 -1 +359 643 -1 +360 643 -1 +361 643 -1 +362 643 -1 +363 643 -1 +364 643 -1 +365 643 -1 +366 643 -1 +367 643 -1 +368 643 -1 +2 644 1 +163 644 1 +182 644 1 +209 644 -1 +372 644 -1 +373 644 -1 +374 644 -1 +375 644 -1 +376 644 -1 +377 644 -1 +378 644 -1 +379 644 -1 +380 644 -1 +3 645 1 +163 645 1 +384 645 -1 +385 645 -1 +386 645 -1 +387 645 -1 +388 645 -1 +389 645 -1 +390 645 -1 +391 645 -1 +1 646 1 +164 646 1 +189 646 -1 +210 646 1 +257 646 -1 +258 646 -1 +259 646 -1 +260 646 -1 +261 646 -1 +262 646 -1 +2 647 1 +164 647 1 +190 647 -1 +211 647 1 +265 647 -1 +266 647 -1 +267 647 -1 +268 647 -1 +269 647 -1 +270 647 -1 +3 648 1 +164 648 1 +273 648 -1 +274 648 -1 +275 648 -1 +276 648 -1 +277 648 -1 +278 648 -1 +165 649 1 +189 649 1 +210 649 -1 +260 649 1 +261 649 1 +262 649 1 +165 650 1 +190 650 1 +211 650 -1 +268 650 1 +269 650 1 +270 650 1 +165 651 1 +276 651 1 +277 651 1 +278 651 1 +166 652 1 +190 652 -1 +224 652 1 +267 652 -1 +268 652 -1 +269 652 -1 +270 652 -1 +443 652 1 +166 653 1 +275 653 -1 +276 653 -1 +277 653 -1 +278 653 -1 +444 653 1 +2 654 1 +167 654 1 +190 654 -1 +224 654 1 +265 654 -1 +266 654 -1 +267 654 -1 +268 654 -1 +269 654 -1 +270 654 -1 +3 655 1 +167 655 1 +273 655 -1 +274 655 -1 +275 655 -1 +276 655 -1 +277 655 -1 +278 655 -1 +168 656 1 +189 656 -1 +222 656 1 +259 656 -1 +260 656 -1 +261 656 -1 +262 656 -1 +426 656 1 +427 656 1 +428 656 1 +429 656 1 +430 656 1 +431 656 1 +432 656 1 +168 657 1 +190 657 -1 +223 657 1 +267 657 -1 +268 657 -1 +269 657 -1 +270 657 -1 +434 657 1 +435 657 1 +436 657 1 +437 657 1 +438 657 1 +439 657 1 +440 657 1 +168 658 1 +275 658 -1 +276 658 -1 +277 658 -1 +278 658 -1 +441 658 1 +442 658 1 +169 659 1 +208 659 -1 +214 659 1 +368 659 -1 +403 659 1 +169 660 1 +209 660 -1 +215 660 1 +380 660 -1 +405 660 1 +169 661 1 +391 661 -1 +406 661 1 +170 662 1 +208 662 -1 +214 662 1 +365 662 -1 +366 662 -1 +367 662 -1 +368 662 -1 +402 662 1 +403 662 1 +170 663 1 +209 663 -1 +215 663 1 +377 663 -1 +378 663 -1 +379 663 -1 +380 663 -1 +404 663 1 +405 663 1 +3 664 1 +170 664 1 +388 664 -1 +389 664 -1 +390 664 -1 +391 664 -1 +171 665 1 +208 665 1 +214 665 -1 +364 665 1 +365 665 1 +366 665 1 +367 665 1 +368 665 1 +403 665 -1 +171 666 1 +209 666 1 +215 666 -1 +376 666 1 +377 666 1 +378 666 1 +379 666 1 +380 666 1 +405 666 -1 +171 667 1 +387 667 1 +388 667 1 +389 667 1 +390 667 1 +391 667 1 +406 667 -1 +172 668 1 +208 668 1 +214 668 -1 +361 668 1 +362 668 1 +363 668 1 +364 668 1 +365 668 1 +366 668 1 +367 668 1 +368 668 1 +402 668 -1 +403 668 -1 +172 669 1 +209 669 1 +215 669 -1 +375 669 1 +376 669 1 +377 669 1 +378 669 1 +379 669 1 +380 669 1 +404 669 -1 +405 669 -1 +3 670 -1 +172 670 1 +386 670 1 +387 670 1 +388 670 1 +389 670 1 +390 670 1 +391 670 1 +173 671 1 +183 671 1 +208 671 -1 +235 671 1 +236 671 1 +237 671 1 +365 671 -1 +366 671 -1 +367 671 -1 +368 671 -1 +173 672 1 +184 672 1 +209 672 -1 +238 672 1 +239 672 1 +240 672 1 +377 672 -1 +378 672 -1 +379 672 -1 +380 672 -1 +173 673 1 +241 673 1 +242 673 1 +388 673 -1 +389 673 -1 +390 673 -1 +391 673 -1 +174 674 1 +357 674 1 +358 674 1 +359 674 1 +360 674 1 +361 674 1 +362 674 1 +174 675 1 +370 675 1 +371 675 1 +372 675 1 +373 675 1 +374 675 1 +375 675 1 +174 676 1 +382 676 1 +383 676 1 +384 676 1 +385 676 1 +386 676 1 +175 677 1 +191 677 1 +208 677 -1 +279 677 1 +280 677 1 +281 677 1 +360 677 -1 +361 677 -1 +362 677 -1 +363 677 -1 +364 677 -1 +365 677 -1 +366 677 -1 +367 677 -1 +368 677 -1 +175 678 1 +192 678 1 +209 678 -1 +282 678 1 +283 678 1 +284 678 1 +374 678 -1 +375 678 -1 +376 678 -1 +377 678 -1 +378 678 -1 +379 678 -1 +380 678 -1 +175 679 1 +285 679 1 +286 679 1 +287 679 1 +386 679 -1 +387 679 -1 +388 679 -1 +389 679 -1 +390 679 -1 +391 679 -1 +176 680 1 +193 680 -1 +208 680 1 +289 680 -1 +290 680 -1 +291 680 -1 +292 680 -1 +358 680 1 +359 680 1 +360 680 1 +361 680 1 +362 680 1 +363 680 1 +364 680 1 +365 680 1 +366 680 1 +367 680 1 +368 680 1 +176 681 1 +194 681 -1 +209 681 1 +294 681 -1 +295 681 -1 +296 681 -1 +297 681 -1 +371 681 1 +372 681 1 +373 681 1 +374 681 1 +375 681 1 +376 681 1 +377 681 1 +378 681 1 +379 681 1 +380 681 1 +176 682 1 +298 682 -1 +299 682 -1 +300 682 -1 +301 682 -1 +383 682 1 +384 682 1 +385 682 1 +386 682 1 +387 682 1 +388 682 1 +389 682 1 +390 682 1 +391 682 1 +177 683 1 +189 683 1 +200 683 -1 +262 683 1 +177 684 1 +190 684 1 +201 684 -1 +270 684 1 +177 685 1 +278 685 1 +1 686 1 +178 686 1 +187 686 1 +208 686 -1 +357 686 -1 +358 686 -1 +359 686 -1 +360 686 -1 +361 686 -1 +362 686 -1 +363 686 -1 +364 686 -1 +365 686 -1 +366 686 -1 +367 686 -1 +368 686 -1 +2 687 1 +178 687 1 +188 687 1 +209 687 -1 +370 687 -1 +371 687 -1 +372 687 -1 +373 687 -1 +374 687 -1 +375 687 -1 +376 687 -1 +377 687 -1 +378 687 -1 +379 687 -1 +380 687 -1 +3 688 1 +178 688 1 +381 688 -1 +382 688 -1 +383 688 -1 +384 688 -1 +385 688 -1 +386 688 -1 +387 688 -1 +388 688 -1 +389 688 -1 +390 688 -1 +391 688 -1 +179 689 1 +187 689 -1 +208 689 1 +367 689 1 +368 689 1 +179 690 1 +188 690 -1 +209 690 1 +379 690 1 +380 690 1 +179 691 1 +390 691 1 +391 691 1 +180 692 1 +189 692 1 +210 692 -1 +255 692 1 +256 692 1 +257 692 1 +258 692 1 +259 692 1 +260 692 1 +261 692 1 +262 692 1 +393 692 -1 +180 693 1 +190 693 1 +211 693 -1 +263 693 1 +264 693 1 +265 693 1 +266 693 1 +267 693 1 +268 693 1 +269 693 1 +270 693 1 +394 693 -1 +180 694 1 +271 694 1 +272 694 1 +273 694 1 +274 694 1 +275 694 1 +276 694 1 +277 694 1 +278 694 1 +395 694 -1 +1 695 1 +225 695 -1 +226 695 -1 +227 695 -1 +2 696 1 +228 696 -1 +229 696 -1 +230 696 -1 +3 697 1 +231 697 -1 +232 697 -1 +233 697 -1 +1 698 1 +234 698 -1 +235 698 -1 +236 698 -1 +237 698 -1 +2 699 1 +238 699 -1 +239 699 -1 +240 699 -1 +3 700 1 +241 700 -1 +242 700 -1 +1 701 1 +243 701 -1 +2 702 1 +244 702 -1 +3 703 1 +245 703 -1 +1 704 1 +246 704 -1 +247 704 -1 +248 704 -1 +2 705 1 +249 705 -1 +250 705 -1 +251 705 -1 +3 706 1 +252 706 -1 +253 706 -1 +254 706 -1 +1 707 1 +255 707 -1 +256 707 -1 +257 707 -1 +258 707 -1 +259 707 -1 +260 707 -1 +261 707 -1 +262 707 -1 +2 708 1 +263 708 -1 +264 708 -1 +265 708 -1 +266 708 -1 +267 708 -1 +268 708 -1 +269 708 -1 +270 708 -1 +3 709 1 +271 709 -1 +272 709 -1 +273 709 -1 +274 709 -1 +275 709 -1 +276 709 -1 +277 709 -1 +278 709 -1 +1 710 1 +279 710 -1 +280 710 -1 +281 710 -1 +2 711 1 +282 711 -1 +283 711 -1 +284 711 -1 +3 712 1 +285 712 -1 +286 712 -1 +287 712 -1 +1 713 1 +288 713 -1 +289 713 -1 +290 713 -1 +291 713 -1 +292 713 -1 +2 714 1 +293 714 -1 +294 714 -1 +295 714 -1 +296 714 -1 +297 714 -1 +3 715 1 +298 715 -1 +299 715 -1 +300 715 -1 +301 715 -1 +1 716 1 +302 716 -1 +2 717 1 +303 717 -1 +1 718 1 +304 718 -1 +305 718 -1 +306 718 -1 +2 719 1 +307 719 -1 +308 719 -1 +309 719 -1 +3 720 1 +310 720 -1 +1 721 1 +311 721 -1 +312 721 -1 +313 721 -1 +314 721 -1 +315 721 -1 +2 722 1 +316 722 -1 +317 722 -1 +318 722 -1 +319 722 -1 +320 722 -1 +3 723 1 +321 723 -1 +322 723 -1 +323 723 -1 +324 723 -1 +325 723 -1 +1 724 1 +326 724 -1 +327 724 -1 +328 724 -1 +329 724 -1 +330 724 -1 +331 724 -1 +332 724 -1 +333 724 -1 +334 724 -1 +2 725 1 +335 725 -1 +336 725 -1 +337 725 -1 +338 725 -1 +339 725 -1 +340 725 -1 +341 725 -1 +3 726 1 +342 726 -1 +343 726 -1 +344 726 -1 +345 726 -1 +1 727 1 +346 727 -1 +347 727 -1 +2 728 1 +348 728 -1 +349 728 -1 +3 729 1 +350 729 -1 +351 729 -1 +1 730 1 +352 730 -1 +2 731 1 +353 731 -1 +354 731 -1 +3 732 1 +355 732 -1 +356 732 -1 +1 733 1 +357 733 -1 +358 733 -1 +359 733 -1 +360 733 -1 +361 733 -1 +362 733 -1 +363 733 -1 +364 733 -1 +365 733 -1 +366 733 -1 +367 733 -1 +368 733 -1 +2 734 1 +369 734 -1 +370 734 -1 +371 734 -1 +372 734 -1 +373 734 -1 +374 734 -1 +375 734 -1 +376 734 -1 +377 734 -1 +378 734 -1 +379 734 -1 +380 734 -1 +3 735 1 +381 735 -1 +382 735 -1 +383 735 -1 +384 735 -1 +385 735 -1 +386 735 -1 +387 735 -1 +388 735 -1 +389 735 -1 +390 735 -1 +391 735 -1 +1 736 1 +392 736 -1 +393 736 -1 +2 737 1 +394 737 -1 +3 738 1 +395 738 -1 +1 739 1 +396 739 -1 +397 739 -1 +398 739 -1 +2 740 1 +399 740 -1 +400 740 -1 +401 740 -1 +1 741 1 +402 741 -1 +403 741 -1 +2 742 1 +404 742 -1 +405 742 -1 +3 743 1 +406 743 -1 +1 744 1 +407 744 -1 +2 745 1 +408 745 -1 +3 746 1 +409 746 -1 +1 747 1 +410 747 -1 +411 747 -1 +2 748 1 +412 748 -1 +413 748 -1 +414 748 -1 +3 749 1 +415 749 -1 +416 749 -1 +1 750 1 +417 750 -1 +418 750 -1 +419 750 -1 +2 751 1 +420 751 -1 +421 751 -1 +422 751 -1 +3 752 1 +423 752 -1 +424 752 -1 +1 753 1 +425 753 -1 +426 753 -1 +427 753 -1 +428 753 -1 +429 753 -1 +430 753 -1 +431 753 -1 +432 753 -1 +2 754 1 +433 754 -1 +434 754 -1 +435 754 -1 +436 754 -1 +437 754 -1 +438 754 -1 +439 754 -1 +440 754 -1 +3 755 1 +441 755 -1 +442 755 -1 +2 756 1 +443 756 -1 +3 757 1 +444 757 -1 +1 758 38 +2 758 16 +3 758 19 +4 758 1 +5 758 1 +6 758 1 +7 758 1 +8 758 1 +9 758 1 +10 758 1 +11 758 1 +12 758 1 +13 758 1 +14 758 1 +15 758 1 +16 758 1 +17 758 1 +18 758 1 +19 758 1 +20 758 1 +21 758 1 +22 758 1 +23 758 1 +24 758 1 +25 758 1 +26 758 1 +27 758 1 +28 758 1 +29 758 1 +30 758 1 +31 758 1 +32 758 1 +33 758 1 +34 758 1 +35 758 1 +36 758 1 +37 758 1 +38 758 1 +39 758 1 +40 758 1 +41 758 1 +42 758 1 +43 758 1 +44 758 1 +45 758 1 +46 758 1 +47 758 1 +48 758 1 +49 758 1 +50 758 1 +51 758 1 +52 758 1 +53 758 1 +54 758 1 +55 758 1 +56 758 1 +57 758 1 +58 758 1 +59 758 1 +60 758 1 +61 758 1 +62 758 1 +63 758 1 +64 758 1 +65 758 1 +66 758 1 +67 758 1 +68 758 1 +69 758 1 +70 758 1 +71 758 1 +72 758 1 +73 758 1 +74 758 1 +75 758 1 +76 758 1 +77 758 1 +78 758 1 +79 758 1 +80 758 1 +81 758 1 +82 758 1 +83 758 1 +84 758 1 +85 758 1 +86 758 1 +87 758 1 +88 758 1 +89 758 1 +90 758 1 +91 758 1 +92 758 1 +93 758 1 +94 758 1 +95 758 1 +96 758 1 +97 758 1 +98 758 1 +99 758 1 +100 758 1 +101 758 1 +102 758 1 +103 758 1 +104 758 1 +105 758 1 +106 758 1 +107 758 1 +108 758 1 +109 758 1 +110 758 1 +111 758 1 +112 758 1 +113 758 1 +114 758 1 +115 758 1 +116 758 1 +117 758 1 +118 758 1 +119 758 1 +120 758 1 +121 758 1 +122 758 1 +123 758 1 +124 758 1 +125 758 1 +126 758 1 +127 758 1 +128 758 1 +129 758 1 +130 758 1 +131 758 1 +132 758 1 +133 758 1 +134 758 1 +135 758 1 +136 758 1 +137 758 1 +138 758 1 +139 758 1 +140 758 1 +141 758 1 +142 758 1 +143 758 1 +144 758 1 +145 758 1 +146 758 1 +147 758 1 +148 758 1 +149 758 1 +150 758 1 +151 758 1 +152 758 1 +153 758 1 +154 758 1 +155 758 1 +156 758 1 +157 758 1 +158 758 1 +159 758 1 +160 758 1 +161 758 1 +162 758 1 +163 758 1 +164 758 1 +165 758 1 +166 758 1 +167 758 1 +168 758 1 +169 758 1 +170 758 1 +171 758 1 +172 758 1 +173 758 1 +174 758 1 +175 758 1 +176 758 1 +177 758 1 +178 758 1 +179 758 1 +180 758 1 +183 758 1 +202 758 -1 +207 758 1 +209 758 -1 +234 758 1 +235 758 1 +236 758 1 +237 758 1 +263 758 1 +264 758 1 +265 758 1 +266 758 1 +267 758 1 +268 758 1 +269 758 1 +270 758 1 +300 758 1 +301 758 1 +331 758 -1 +332 758 -1 +334 758 1 +335 758 -1 +336 758 -1 +337 758 -1 +338 758 -1 +339 758 -1 +340 758 -1 +353 758 1 +354 758 1 +358 758 -1 +359 758 -1 +360 758 -1 +361 758 -1 +363 758 -1 +369 758 -1 +370 758 -1 +371 758 -1 +372 758 -1 +373 758 -1 +374 758 -1 +375 758 -1 +376 758 -1 +377 758 -1 +378 758 -1 +379 758 -1 +380 758 -1 +381 758 -1 +382 758 -1 +383 758 -1 +384 758 -1 +385 758 -1 +386 758 -1 +387 758 -1 +388 758 -1 +389 758 -1 +390 758 -1 +391 758 -1 +425 758 -2 +426 758 -2 +427 758 -2 +428 758 -2 +429 758 -2 +430 758 -2 diff --git a/test/netlib/degen2_bounds.mm b/test/netlib/degen2_bounds.mm new file mode 100644 index 000000000..d4fd6fb88 --- /dev/null +++ b/test/netlib/degen2_bounds.mm @@ -0,0 +1,760 @@ +%%MatrixMarket matrix coordinate real general +% Generated 28-Oct-2022 +757 2 757 +1 2 1000000000 +2 2 1000000000 +3 2 1000000000 +4 2 1000000000 +5 2 1000000000 +6 2 1000000000 +7 2 1000000000 +8 2 1000000000 +9 2 1000000000 +10 2 1000000000 +11 2 1000000000 +12 2 1000000000 +13 2 1000000000 +14 2 1000000000 +15 2 1000000000 +16 2 1000000000 +17 2 1000000000 +18 2 1000000000 +19 2 1000000000 +20 2 1000000000 +21 2 1000000000 +22 2 1000000000 +23 2 1000000000 +24 2 1000000000 +25 2 1000000000 +26 2 1000000000 +27 2 1000000000 +28 2 1000000000 +29 2 1000000000 +30 2 1000000000 +31 2 1000000000 +32 2 1000000000 +33 2 1000000000 +34 2 1000000000 +35 2 1000000000 +36 2 1000000000 +37 2 1000000000 +38 2 1000000000 +39 2 1000000000 +40 2 1000000000 +41 2 1000000000 +42 2 1000000000 +43 2 1000000000 +44 2 1000000000 +45 2 1000000000 +46 2 1000000000 +47 2 1000000000 +48 2 1000000000 +49 2 1000000000 +50 2 1000000000 +51 2 1000000000 +52 2 1000000000 +53 2 1000000000 +54 2 1000000000 +55 2 1000000000 +56 2 1000000000 +57 2 1000000000 +58 2 1000000000 +59 2 1000000000 +60 2 1000000000 +61 2 1000000000 +62 2 1000000000 +63 2 1000000000 +64 2 1000000000 +65 2 1000000000 +66 2 1000000000 +67 2 1000000000 +68 2 1000000000 +69 2 1000000000 +70 2 1000000000 +71 2 1000000000 +72 2 1000000000 +73 2 1000000000 +74 2 1000000000 +75 2 1000000000 +76 2 1000000000 +77 2 1000000000 +78 2 1000000000 +79 2 1000000000 +80 2 1000000000 +81 2 1000000000 +82 2 1000000000 +83 2 1000000000 +84 2 1000000000 +85 2 1000000000 +86 2 1000000000 +87 2 1000000000 +88 2 1000000000 +89 2 1000000000 +90 2 1000000000 +91 2 1000000000 +92 2 1000000000 +93 2 1000000000 +94 2 1000000000 +95 2 1000000000 +96 2 1000000000 +97 2 1000000000 +98 2 1000000000 +99 2 1000000000 +100 2 1000000000 +101 2 1000000000 +102 2 1000000000 +103 2 1000000000 +104 2 1000000000 +105 2 1000000000 +106 2 1000000000 +107 2 1000000000 +108 2 1000000000 +109 2 1000000000 +110 2 1000000000 +111 2 1000000000 +112 2 1000000000 +113 2 1000000000 +114 2 1000000000 +115 2 1000000000 +116 2 1000000000 +117 2 1000000000 +118 2 1000000000 +119 2 1000000000 +120 2 1000000000 +121 2 1000000000 +122 2 1000000000 +123 2 1000000000 +124 2 1000000000 +125 2 1000000000 +126 2 1000000000 +127 2 1000000000 +128 2 1000000000 +129 2 1000000000 +130 2 1000000000 +131 2 1000000000 +132 2 1000000000 +133 2 1000000000 +134 2 1000000000 +135 2 1000000000 +136 2 1000000000 +137 2 1000000000 +138 2 1000000000 +139 2 1000000000 +140 2 1000000000 +141 2 1000000000 +142 2 1000000000 +143 2 1000000000 +144 2 1000000000 +145 2 1000000000 +146 2 1000000000 +147 2 1000000000 +148 2 1000000000 +149 2 1000000000 +150 2 1000000000 +151 2 1000000000 +152 2 1000000000 +153 2 1000000000 +154 2 1000000000 +155 2 1000000000 +156 2 1000000000 +157 2 1000000000 +158 2 1000000000 +159 2 1000000000 +160 2 1000000000 +161 2 1000000000 +162 2 1000000000 +163 2 1000000000 +164 2 1000000000 +165 2 1000000000 +166 2 1000000000 +167 2 1000000000 +168 2 1000000000 +169 2 1000000000 +170 2 1000000000 +171 2 1000000000 +172 2 1000000000 +173 2 1000000000 +174 2 1000000000 +175 2 1000000000 +176 2 1000000000 +177 2 1000000000 +178 2 1000000000 +179 2 1000000000 +180 2 1000000000 +181 2 1000000000 +182 2 1000000000 +183 2 1000000000 +184 2 1000000000 +185 2 1000000000 +186 2 1000000000 +187 2 1000000000 +188 2 1000000000 +189 2 1000000000 +190 2 1000000000 +191 2 1000000000 +192 2 1000000000 +193 2 1000000000 +194 2 1000000000 +195 2 1000000000 +196 2 1000000000 +197 2 1000000000 +198 2 1000000000 +199 2 1000000000 +200 2 1000000000 +201 2 1000000000 +202 2 1000000000 +203 2 1000000000 +204 2 1000000000 +205 2 1000000000 +206 2 1000000000 +207 2 1000000000 +208 2 1000000000 +209 2 1000000000 +210 2 1000000000 +211 2 1000000000 +212 2 1000000000 +213 2 1000000000 +214 2 1000000000 +215 2 1000000000 +216 2 1000000000 +217 2 1000000000 +218 2 1000000000 +219 2 1000000000 +220 2 1000000000 +221 2 1000000000 +222 2 1000000000 +223 2 1000000000 +224 2 1000000000 +225 2 1000000000 +226 2 1000000000 +227 2 1000000000 +228 2 1000000000 +229 2 1000000000 +230 2 1000000000 +231 2 1000000000 +232 2 1000000000 +233 2 1000000000 +234 2 1000000000 +235 2 1000000000 +236 2 1000000000 +237 2 1000000000 +238 2 1000000000 +239 2 1000000000 +240 2 1000000000 +241 2 1000000000 +242 2 1000000000 +243 2 1000000000 +244 2 1000000000 +245 2 1000000000 +246 2 1000000000 +247 2 1000000000 +248 2 1000000000 +249 2 1000000000 +250 2 1000000000 +251 2 1000000000 +252 2 1000000000 +253 2 1000000000 +254 2 1000000000 +255 2 1000000000 +256 2 1000000000 +257 2 1000000000 +258 2 1000000000 +259 2 1000000000 +260 2 1000000000 +261 2 1000000000 +262 2 1000000000 +263 2 1000000000 +264 2 1000000000 +265 2 1000000000 +266 2 1000000000 +267 2 1000000000 +268 2 1000000000 +269 2 1000000000 +270 2 1000000000 +271 2 1000000000 +272 2 1000000000 +273 2 1000000000 +274 2 1000000000 +275 2 1000000000 +276 2 1000000000 +277 2 1000000000 +278 2 1000000000 +279 2 1000000000 +280 2 1000000000 +281 2 1000000000 +282 2 1000000000 +283 2 1000000000 +284 2 1000000000 +285 2 1000000000 +286 2 1000000000 +287 2 1000000000 +288 2 1000000000 +289 2 1000000000 +290 2 1000000000 +291 2 1000000000 +292 2 1000000000 +293 2 1000000000 +294 2 1000000000 +295 2 1000000000 +296 2 1000000000 +297 2 1000000000 +298 2 1000000000 +299 2 1000000000 +300 2 1000000000 +301 2 1000000000 +302 2 1000000000 +303 2 1000000000 +304 2 1000000000 +305 2 1000000000 +306 2 1000000000 +307 2 1000000000 +308 2 1000000000 +309 2 1000000000 +310 2 1000000000 +311 2 1000000000 +312 2 1000000000 +313 2 1000000000 +314 2 1000000000 +315 2 1000000000 +316 2 1000000000 +317 2 1000000000 +318 2 1000000000 +319 2 1000000000 +320 2 1000000000 +321 2 1000000000 +322 2 1000000000 +323 2 1000000000 +324 2 1000000000 +325 2 1000000000 +326 2 1000000000 +327 2 1000000000 +328 2 1000000000 +329 2 1000000000 +330 2 1000000000 +331 2 1000000000 +332 2 1000000000 +333 2 1000000000 +334 2 1000000000 +335 2 1000000000 +336 2 1000000000 +337 2 1000000000 +338 2 1000000000 +339 2 1000000000 +340 2 1000000000 +341 2 1000000000 +342 2 1000000000 +343 2 1000000000 +344 2 1000000000 +345 2 1000000000 +346 2 1000000000 +347 2 1000000000 +348 2 1000000000 +349 2 1000000000 +350 2 1000000000 +351 2 1000000000 +352 2 1000000000 +353 2 1000000000 +354 2 1000000000 +355 2 1000000000 +356 2 1000000000 +357 2 1000000000 +358 2 1000000000 +359 2 1000000000 +360 2 1000000000 +361 2 1000000000 +362 2 1000000000 +363 2 1000000000 +364 2 1000000000 +365 2 1000000000 +366 2 1000000000 +367 2 1000000000 +368 2 1000000000 +369 2 1000000000 +370 2 1000000000 +371 2 1000000000 +372 2 1000000000 +373 2 1000000000 +374 2 1000000000 +375 2 1000000000 +376 2 1000000000 +377 2 1000000000 +378 2 1000000000 +379 2 1000000000 +380 2 1000000000 +381 2 1000000000 +382 2 1000000000 +383 2 1000000000 +384 2 1000000000 +385 2 1000000000 +386 2 1000000000 +387 2 1000000000 +388 2 1000000000 +389 2 1000000000 +390 2 1000000000 +391 2 1000000000 +392 2 1000000000 +393 2 1000000000 +394 2 1000000000 +395 2 1000000000 +396 2 1000000000 +397 2 1000000000 +398 2 1000000000 +399 2 1000000000 +400 2 1000000000 +401 2 1000000000 +402 2 1000000000 +403 2 1000000000 +404 2 1000000000 +405 2 1000000000 +406 2 1000000000 +407 2 1000000000 +408 2 1000000000 +409 2 1000000000 +410 2 1000000000 +411 2 1000000000 +412 2 1000000000 +413 2 1000000000 +414 2 1000000000 +415 2 1000000000 +416 2 1000000000 +417 2 1000000000 +418 2 1000000000 +419 2 1000000000 +420 2 1000000000 +421 2 1000000000 +422 2 1000000000 +423 2 1000000000 +424 2 1000000000 +425 2 1000000000 +426 2 1000000000 +427 2 1000000000 +428 2 1000000000 +429 2 1000000000 +430 2 1000000000 +431 2 1000000000 +432 2 1000000000 +433 2 1000000000 +434 2 1000000000 +435 2 1000000000 +436 2 1000000000 +437 2 1000000000 +438 2 1000000000 +439 2 1000000000 +440 2 1000000000 +441 2 1000000000 +442 2 1000000000 +443 2 1000000000 +444 2 1000000000 +445 2 1000000000 +446 2 1000000000 +447 2 1000000000 +448 2 1000000000 +449 2 1000000000 +450 2 1000000000 +451 2 1000000000 +452 2 1000000000 +453 2 1000000000 +454 2 1000000000 +455 2 1000000000 +456 2 1000000000 +457 2 1000000000 +458 2 1000000000 +459 2 1000000000 +460 2 1000000000 +461 2 1000000000 +462 2 1000000000 +463 2 1000000000 +464 2 1000000000 +465 2 1000000000 +466 2 1000000000 +467 2 1000000000 +468 2 1000000000 +469 2 1000000000 +470 2 1000000000 +471 2 1000000000 +472 2 1000000000 +473 2 1000000000 +474 2 1000000000 +475 2 1000000000 +476 2 1000000000 +477 2 1000000000 +478 2 1000000000 +479 2 1000000000 +480 2 1000000000 +481 2 1000000000 +482 2 1000000000 +483 2 1000000000 +484 2 1000000000 +485 2 1000000000 +486 2 1000000000 +487 2 1000000000 +488 2 1000000000 +489 2 1000000000 +490 2 1000000000 +491 2 1000000000 +492 2 1000000000 +493 2 1000000000 +494 2 1000000000 +495 2 1000000000 +496 2 1000000000 +497 2 1000000000 +498 2 1000000000 +499 2 1000000000 +500 2 1000000000 +501 2 1000000000 +502 2 1000000000 +503 2 1000000000 +504 2 1000000000 +505 2 1000000000 +506 2 1000000000 +507 2 1000000000 +508 2 1000000000 +509 2 1000000000 +510 2 1000000000 +511 2 1000000000 +512 2 1000000000 +513 2 1000000000 +514 2 1000000000 +515 2 1000000000 +516 2 1000000000 +517 2 1000000000 +518 2 1000000000 +519 2 1000000000 +520 2 1000000000 +521 2 1000000000 +522 2 1000000000 +523 2 1000000000 +524 2 1000000000 +525 2 1000000000 +526 2 1000000000 +527 2 1000000000 +528 2 1000000000 +529 2 1000000000 +530 2 1000000000 +531 2 1000000000 +532 2 1000000000 +533 2 1000000000 +534 2 1000000000 +535 2 1000000000 +536 2 1000000000 +537 2 1000000000 +538 2 1000000000 +539 2 1000000000 +540 2 1000000000 +541 2 1000000000 +542 2 1000000000 +543 2 1000000000 +544 2 1000000000 +545 2 1000000000 +546 2 1000000000 +547 2 1000000000 +548 2 1000000000 +549 2 1000000000 +550 2 1000000000 +551 2 1000000000 +552 2 1000000000 +553 2 1000000000 +554 2 1000000000 +555 2 1000000000 +556 2 1000000000 +557 2 1000000000 +558 2 1000000000 +559 2 1000000000 +560 2 1000000000 +561 2 1000000000 +562 2 1000000000 +563 2 1000000000 +564 2 1000000000 +565 2 1000000000 +566 2 1000000000 +567 2 1000000000 +568 2 1000000000 +569 2 1000000000 +570 2 1000000000 +571 2 1000000000 +572 2 1000000000 +573 2 1000000000 +574 2 1000000000 +575 2 1000000000 +576 2 1000000000 +577 2 1000000000 +578 2 1000000000 +579 2 1000000000 +580 2 1000000000 +581 2 1000000000 +582 2 1000000000 +583 2 1000000000 +584 2 1000000000 +585 2 1000000000 +586 2 1000000000 +587 2 1000000000 +588 2 1000000000 +589 2 1000000000 +590 2 1000000000 +591 2 1000000000 +592 2 1000000000 +593 2 1000000000 +594 2 1000000000 +595 2 1000000000 +596 2 1000000000 +597 2 1000000000 +598 2 1000000000 +599 2 1000000000 +600 2 1000000000 +601 2 1000000000 +602 2 1000000000 +603 2 1000000000 +604 2 1000000000 +605 2 1000000000 +606 2 1000000000 +607 2 1000000000 +608 2 1000000000 +609 2 1000000000 +610 2 1000000000 +611 2 1000000000 +612 2 1000000000 +613 2 1000000000 +614 2 1000000000 +615 2 1000000000 +616 2 1000000000 +617 2 1000000000 +618 2 1000000000 +619 2 1000000000 +620 2 1000000000 +621 2 1000000000 +622 2 1000000000 +623 2 1000000000 +624 2 1000000000 +625 2 1000000000 +626 2 1000000000 +627 2 1000000000 +628 2 1000000000 +629 2 1000000000 +630 2 1000000000 +631 2 1000000000 +632 2 1000000000 +633 2 1000000000 +634 2 1000000000 +635 2 1000000000 +636 2 1000000000 +637 2 1000000000 +638 2 1000000000 +639 2 1000000000 +640 2 1000000000 +641 2 1000000000 +642 2 1000000000 +643 2 1000000000 +644 2 1000000000 +645 2 1000000000 +646 2 1000000000 +647 2 1000000000 +648 2 1000000000 +649 2 1000000000 +650 2 1000000000 +651 2 1000000000 +652 2 1000000000 +653 2 1000000000 +654 2 1000000000 +655 2 1000000000 +656 2 1000000000 +657 2 1000000000 +658 2 1000000000 +659 2 1000000000 +660 2 1000000000 +661 2 1000000000 +662 2 1000000000 +663 2 1000000000 +664 2 1000000000 +665 2 1000000000 +666 2 1000000000 +667 2 1000000000 +668 2 1000000000 +669 2 1000000000 +670 2 1000000000 +671 2 1000000000 +672 2 1000000000 +673 2 1000000000 +674 2 1000000000 +675 2 1000000000 +676 2 1000000000 +677 2 1000000000 +678 2 1000000000 +679 2 1000000000 +680 2 1000000000 +681 2 1000000000 +682 2 1000000000 +683 2 1000000000 +684 2 1000000000 +685 2 1000000000 +686 2 1000000000 +687 2 1000000000 +688 2 1000000000 +689 2 1000000000 +690 2 1000000000 +691 2 1000000000 +692 2 1000000000 +693 2 1000000000 +694 2 1000000000 +695 2 1000000000 +696 2 1000000000 +697 2 1000000000 +698 2 1000000000 +699 2 1000000000 +700 2 1000000000 +701 2 1000000000 +702 2 1000000000 +703 2 1000000000 +704 2 1000000000 +705 2 1000000000 +706 2 1000000000 +707 2 1000000000 +708 2 1000000000 +709 2 1000000000 +710 2 1000000000 +711 2 1000000000 +712 2 1000000000 +713 2 1000000000 +714 2 1000000000 +715 2 1000000000 +716 2 1000000000 +717 2 1000000000 +718 2 1000000000 +719 2 1000000000 +720 2 1000000000 +721 2 1000000000 +722 2 1000000000 +723 2 1000000000 +724 2 1000000000 +725 2 1000000000 +726 2 1000000000 +727 2 1000000000 +728 2 1000000000 +729 2 1000000000 +730 2 1000000000 +731 2 1000000000 +732 2 1000000000 +733 2 1000000000 +734 2 1000000000 +735 2 1000000000 +736 2 1000000000 +737 2 1000000000 +738 2 1000000000 +739 2 1000000000 +740 2 1000000000 +741 2 1000000000 +742 2 1000000000 +743 2 1000000000 +744 2 1000000000 +745 2 1000000000 +746 2 1000000000 +747 2 1000000000 +748 2 1000000000 +749 2 1000000000 +750 2 1000000000 +751 2 1000000000 +752 2 1000000000 +753 2 1000000000 +754 2 1000000000 +755 2 1000000000 +756 2 1000000000 +757 2 1000000000 diff --git a/test/new_rounding_test.cpp b/test/new_rounding_test.cpp index b3f6a2adf..87c63a32a 100644 --- a/test/new_rounding_test.cpp +++ b/test/new_rounding_test.cpp @@ -8,12 +8,13 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" @@ -24,7 +25,7 @@ #include "preprocess/max_inscribed_ellipsoid_rounding.hpp" #include "preprocess/svd_rounding.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/new_volume_example.cpp b/test/new_volume_example.cpp index 205316559..b2838f04e 100644 --- a/test/new_volume_example.cpp +++ b/test/new_volume_example.cpp @@ -10,10 +10,14 @@ #include "Eigen/Eigen" //#define VOLESTI_DEBUG #include + + #include -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" +#include +#include +#include + + #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" @@ -21,7 +25,7 @@ #include "misc/misc.h" #include "misc/linear_extensions.h" #include "sampling/sampling.hpp" -#include "exact_vols.h" +#include "volume/exact_vols.h" #include "generators/known_polytope_generators.h" #include "generators/z_polytopes_generators.h" diff --git a/test/ode_solvers_test.cpp b/test/ode_solvers_test.cpp index b8cfd9d6d..4a82472d8 100644 --- a/test/ode_solvers_test.cpp +++ b/test/ode_solvers_test.cpp @@ -18,17 +18,19 @@ #include #include -#include "Eigen/Eigen" #include "doctest.h" +#include "Eigen/Eigen" + +#include +#include +#include +#include + #include "generators/known_polytope_generators.h" -#include "ode_solvers.hpp" +#include "ode_solvers/ode_solvers.hpp" #include "preprocess/crhmc/crhmc_input.h" #include "preprocess/crhmc/crhmc_problem.h" -#include "random.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_int.hpp" -#include "random/uniform_real_distribution.hpp" #include "random_walks/random_walks.hpp" #include "volume/volume_cooling_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" @@ -132,12 +134,12 @@ void check_norm_progress(Solver &solver, int num_steps, std::vector target, #else for (int i = 0; i < num_steps; i++) { solver.step(i, true); - solver.print_state(); + solver.print_state(std::cerr); } #endif NT norm = NT(0); for (unsigned int i = 0; i < solver.xs.size(); i++) { - norm += solver.xs[i].dot(solver.xs[i]); + norm += (solver.xs[i].cwiseProduct(solver.xs[i])).sum(); } norm = sqrt(norm); @@ -155,7 +157,9 @@ void check_norm_progress(Solver &solver, int num_steps, std::vector target, template void test_implicit_midpoint() { typedef Cartesian Kernel; typedef typename Kernel::Point Point; - typedef std::vector pts; + using MT = Eigen::Matrix; + using VT = Eigen::Matrix; + typedef std::vector pts; typedef GaussianFunctor::GradientFunctor grad; typedef GaussianFunctor::FunctionFunctor func; typedef GaussianFunctor::parameters func_params; @@ -172,13 +176,14 @@ template void test_implicit_midpoint() { Input input = Input(d, f, F); input.lb = -VT::Ones(d); input.ub = VT::Ones(d); - CrhmcProblem P = CrhmcProblem(input); + opts.EnableReordering=false; + opts.DynamicWeight = false; + CrhmcProblem P = CrhmcProblem(input,opts); d = P.dimension(); - Point x0 = Point(d); - Point v0 = Point::all_ones(d); + MT x0 = MT::Zero(d,1); + MT v0 = MT::Ones(d,1); pts q{x0, v0}; opts.solver_accuracy_threshold = 1e-2; - opts.DynamicWeight = false; ImplicitMidpointODESolver implicit_midpoint_solver = ImplicitMidpointODESolver(0, 0.01, q, diff --git a/test/order_polytope.cpp b/test/order_polytope.cpp index ddc7b54f3..e2ad4300d 100644 --- a/test/order_polytope.cpp +++ b/test/order_polytope.cpp @@ -11,12 +11,19 @@ #include "doctest.h" #include #include + + +#include +#include +#include +#include + #include "cartesian_geom/cartesian_kernel.h" #include "cartesian_geom/point.h" -#include "poset.h" -#include "orderpolytope.h" -#include "misc.h" -#include "random.hpp" +#include "convex_bodies/orderpolytope.h" +#include "misc/poset.h" +#include "misc/misc.h" + template diff --git a/test/sampling_correlation_matrices_test.cpp b/test/sampling_correlation_matrices_test.cpp index f2f90c529..39bb0e605 100644 --- a/test/sampling_correlation_matrices_test.cpp +++ b/test/sampling_correlation_matrices_test.cpp @@ -9,18 +9,18 @@ #include "doctest.h" #include -#include "misc.h" + #include "random.hpp" #include "random/uniform_int.hpp" #include "random/normal_distribution.hpp" #include "random/uniform_real_distribution.hpp" #include "cartesian_geom/cartesian_kernel.h" +#include "diagnostics/univariate_psrf.hpp" +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "sampling/sample_correlation_matrices.hpp" -#include "diagnostics/univariate_psrf.hpp" - template MT rebuildMatrix(const VT &xvector, const unsigned int n){ MT mat = MT::Identity(n,n); diff --git a/test/sampling_test.cpp b/test/sampling_test.cpp index 3831e1ea4..8e82e5818 100644 --- a/test/sampling_test.cpp +++ b/test/sampling_test.cpp @@ -11,16 +11,19 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" #include "sampling/sampling.hpp" #include "diagnostics/univariate_psrf.hpp" diff --git a/test/simple_mc_integration.cpp b/test/simple_mc_integration.cpp index ca633f8f6..c1b6b9ecd 100644 --- a/test/simple_mc_integration.cpp +++ b/test/simple_mc_integration.cpp @@ -10,18 +10,20 @@ // Link to the Latte-Integrale Software: https://www.math.ucdavis.edu/~latte/software.php // Link to the tests: https://github.com/surajchoubey/latte-integrale-checks +#include +#include +#include + #include "doctest.h" -#include "simple_MC_integration.hpp" + #include "Eigen/Eigen" -#include +#include "integration/simple_MC_integration.hpp" #include "cartesian_geom/cartesian_kernel.h" #include "convex_bodies/hpolytope.h" #include "generators/known_polytope_generators.h" #include "ode_solvers/oracle_functors.hpp" #include "random_walks/random_walks.hpp" -#include -#include -#include "misc.h" +#include "misc/misc.h" template NT exp_normsq(Point X) { diff --git a/test/volume_cb_hpolytope.cpp b/test/volume_cb_hpolytope.cpp index cd0df2d83..e938cc255 100644 --- a/test/volume_cb_hpolytope.cpp +++ b/test/volume_cb_hpolytope.cpp @@ -10,18 +10,20 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/volume_cb_vpoly_intersection_vpoly.cpp b/test/volume_cb_vpoly_intersection_vpoly.cpp index a9f7d9cb6..204a560bf 100644 --- a/test/volume_cb_vpoly_intersection_vpoly.cpp +++ b/test/volume_cb_vpoly_intersection_vpoly.cpp @@ -8,20 +8,22 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" -#include "v_polytopes_generators.h" +#include "generators/known_polytope_generators.h" +#include "generators/v_polytopes_generators.h" template NT factorial(NT n) diff --git a/test/volume_cb_vpolytope.cpp b/test/volume_cb_vpolytope.cpp index eb32dd4dc..7b261ac18 100644 --- a/test/volume_cb_vpolytope.cpp +++ b/test/volume_cb_vpolytope.cpp @@ -8,18 +8,21 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/volume_cb_zonotopes.cpp b/test/volume_cb_zonotopes.cpp index 77bc6db20..a6b40d7d3 100644 --- a/test/volume_cb_zonotopes.cpp +++ b/test/volume_cb_zonotopes.cpp @@ -8,12 +8,13 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" @@ -21,8 +22,8 @@ #include "volume/volume_cooling_balls.hpp" #include "volume/volume_cooling_hpoly.hpp" -#include "exact_vols.h" -#include "z_polytopes_generators.h" +#include "volume/exact_vols.h" +#include "generators/z_polytopes_generators.h" template NT factorial(NT n) diff --git a/test/volume_cg_hpolytope.cpp b/test/volume_cg_hpolytope.cpp index 2d2f5bb97..2e9060e45 100644 --- a/test/volume_cg_hpolytope.cpp +++ b/test/volume_cg_hpolytope.cpp @@ -8,18 +8,20 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/volume_cg_vpolytope.cpp b/test/volume_cg_vpolytope.cpp index 7809199ff..eac97d976 100644 --- a/test/volume_cg_vpolytope.cpp +++ b/test/volume_cg_vpolytope.cpp @@ -8,18 +8,20 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/volume_sob_hpolytope.cpp b/test/volume_sob_hpolytope.cpp index 18fa28bb0..0d2ea5c85 100644 --- a/test/volume_sob_hpolytope.cpp +++ b/test/volume_sob_hpolytope.cpp @@ -8,18 +8,20 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n) diff --git a/test/volume_sob_vpolytope.cpp b/test/volume_sob_vpolytope.cpp index 41b963be2..76b3c784a 100644 --- a/test/volume_sob_vpolytope.cpp +++ b/test/volume_sob_vpolytope.cpp @@ -8,18 +8,20 @@ #include "doctest.h" #include #include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" + +#include +#include +#include +#include + +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "volume/volume_sequence_of_balls.hpp" #include "volume/volume_cooling_gaussians.hpp" #include "volume/volume_cooling_balls.hpp" -#include "known_polytope_generators.h" +#include "generators/known_polytope_generators.h" template NT factorial(NT n)