<commit_before>/* Copyright (C) 2015 <NAME>

   This file is part of fplll. fplll 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 2.1 of the License, or (at your option) any later version.

   fplll 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 Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with fplll. If not, see <http://www.gnu.org/licenses/>. */

#include <cstring>
#include <hlll.h>
#include <householder.h>
#include <test_utils.h>

using namespace std;
using namespace fplll;

#ifndef TESTDATADIR
#define TESTDATADIR ".."
#endif

template <class ZT, class FT> int test_lll(ZZ_mat<ZT> &A, int flags, int prec = 53)
{
  MatHouseholder<Z_NR<ZT>, FP_NR<FT>> Mhouseholder(A, flags);
  HouseholderLLLReduction<Z_NR<ZT>, FP_NR<FT>> hlll_obj(Mhouseholder, 0.99, 0.52, 0.01);
  hlll_obj.lll();
  MatHouseholder<Z_NR<ZT>, FP_NR<double>> M(A, flags);
  int status = is_hlll_reduced<Z_NR<ZT>, FP_NR<double>>(M, 0.99, 0.52);

  if (status == 0)
    cerr << "Output of HLLL reduction is not HLLL reduced." << endl;

  return (status == 0);
}

/**
   @brief Test HLLL for matrix stored in file pointed to by `input_filename`.

   @param input_filename   a path
   @param flags            flags to use

   @return zero on success
*/

template <class ZT, class FT> int test_filename(const char *input_filename, int flags)
{
  ZZ_mat<ZT> A;
  int status = 0;
  status |= read_matrix(A, input_filename);
  status |= test_lll<ZT, FT>(A, flags);
  return status;
}

/**
   @brief Construct d × (d+1) integer relations matrix with bit size b and test LLL.

   @param d                dimension
   @param b                bit size
   @param method           LLL method to test
   @param float_type       floating point type to test
   @param flags            flags to use
   @param prec             precision used for is_lll_reduced

   @return zero on success
*/

int main(int /*argc*/, char ** /*argv*/)
{

  int status = 0;

  status |=
      test_filename<mpz_t, double>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
#ifdef FPLLL_WITH_LONG_DOUBLE
  status |= test_filename<mpz_t, long double>(TESTDATADIR "/tests/lattices/dim55_in",
                                              HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_LONG_DOUBLE
#ifdef FPLLL_WITH_DPE
  status |=
      test_filename<mpz_t, dpe_t>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_DPE
#ifdef FPLLL_WITH_QD
  status |=
      test_filename<mpz_t, qd_real>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
  status |=
      test_filename<mpz_t, dd_real>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_QD
// status |= test_filename<mpz_t, mpfr_t>(TESTDATADIR "/tests/lattices/dim55_in",
// HOUSEHOLDER_DEFAULT);

#if 0
  status |= test_filename<mpz_t, double>(TESTDATADIR "/tests/lattices/example_in", HOUSEHOLDER_DEFAULT);
#ifdef FPLLL_WITH_LONG_DOUBLE
  status |= test_filename<mpz_t, long double>(TESTDATADIR "/tests/lattices/example_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_LONG_DOUBLE
#ifdef FPLLL_WITH_DPE
  status |= test_filename<mpz_t, dpe_t>(TESTDATADIR "/tests/lattices/example_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_DPE
#ifdef FPLLL_WITH_QD
  status |= test_filename<mpz_t, qd_real>(TESTDATADIR "/tests/lattices/example_in", HOUSEHOLDER_DEFAULT);
  status |= test_filename<mpz_t, dd_real>(TESTDATADIR "/tests/lattices/example_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_QD
  //status |= test_filename<mpz_t, mpfr_t>(TESTDATADIR "/tests/lattices/example_in", HOUSEHOLDER_DEFAULT);
#endif  // 0

  if (status == 0)
  {
    cerr << "All tests passed." << endl;
    return 0;
  }
  else
  {<commit_msg>Add new tests for H-LLL.<commit_after>/* Copyright (C) 2015 <NAME>

   This file is part of fplll. fplll 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 2.1 of the License, or (at your option) any later version.

   fplll 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 Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with fplll. If not, see <http://www.gnu.org/licenses/>. */

#include <cstring>
#include <hlll.h>
#include <householder.h>
#include <test_utils.h>

using namespace std;
using namespace fplll;

#ifndef TESTDATADIR
#define TESTDATADIR ".."
#endif

template <class ZT, class FT> int test_lll(ZZ_mat<ZT> &A, int flags, int prec = 53)
{
  MatHouseholder<Z_NR<ZT>, FP_NR<FT>> Mhouseholder(A, flags);
  HouseholderLLLReduction<Z_NR<ZT>, FP_NR<FT>> hlll_obj(Mhouseholder, 0.99, 0.52, 0.01);
  hlll_obj.lll();
  MatHouseholder<Z_NR<ZT>, FP_NR<double>> M(A, flags);
  int status = is_hlll_reduced<Z_NR<ZT>, FP_NR<double>>(M, 0.99, 0.52);

  if (status == 0)
    cerr << "Output of HLLL reduction is not HLLL reduced." << endl;

  return (status == 0);
}

/**
   @brief Test HLLL for matrix stored in file pointed to by `input_filename`.

   @param input_filename   a path
   @param flags            flags to use

   @return zero on success
*/

template <class ZT, class FT> int test_filename(const char *input_filename, int flags)
{
  ZZ_mat<ZT> A;
  int status = 0;
  status |= read_matrix(A, input_filename);
  status |= test_lll<ZT, FT>(A, flags);
  return status;
}

/**
   @brief Construct d × (d+1) integer relations matrix with bit size b and test LLL.

   @param d                dimension
   @param b                bit size
   @param method           LLL method to test
   @param float_type       floating point type to test
   @param flags            flags to use
   @param prec             precision used for is_lll_reduced

   @return zero on success
*/

int main(int /*argc*/, char ** /*argv*/)
{

  int status = 0;

  status |=
      test_filename<mpz_t, double>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
#ifdef FPLLL_WITH_LONG_DOUBLE
  status |= test_filename<mpz_t, long double>(TESTDATADIR "/tests/lattices/dim55_in",
                                              HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_LONG_DOUBLE
#ifdef FPLLL_WITH_DPE
  status |=
      test_filename<mpz_t, dpe_t>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_DPE
#ifdef FPLLL_WITH_QD
  status |=
      test_filename<mpz_t, qd_real>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
  status |=
      test_filename<mpz_t, dd_real>(TESTDATADIR "/tests/lattices/dim55_in", HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_QD
        // status |= test_filename<mpz_t, mpfr_t>(TESTDATADIR "/tests/lattices/dim55_in",
        // HOUSEHOLDER_DEFAULT);

  status |= test_filename<mpz_t, double>(TESTDATADIR "/tests/lattices/example_cvp_in_lattice4",
                                         HOUSEHOLDER_DEFAULT);
#ifdef FPLLL_WITH_LONG_DOUBLE
  status |= test_filename<mpz_t, long double>(TESTDATADIR "/tests/lattices/example_cvp_in_lattice4",
                                              HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_LONG_DOUBLE
#ifdef FPLLL_WITH_DPE
  status |= test_filename<mpz_t, dpe_t>(TESTDATADIR "/tests/lattices/example_cvp_in_lattice4",
                                        HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_DPE
#ifdef FPLLL_WITH_QD
  status |= test_filename<mpz_t, qd_real>(TESTDATADIR "/tests/lattices/example_cvp_in_lattice4",
                                          HOUSEHOLDER_DEFAULT);
  status |= test_filename<mpz_t, dd_real>(TESTDATADIR "/tests/lattices/example_cvp_in_lattice4",
                                          HOUSEHOLDER_DEFAULT);
#endif  // FPLLL_WITH_QD
  // status |= test_filename<mpz_t, mpfr_t>(TESTDATADIR "/tests/lattices/example_cvp_in_lattice4",
  // HOUSEHOLDER_DEFAULT);

  if (status == 0)
  {
    cerr << "All tests passed." << endl;
    return 0;
  }
  else
  {
{'fraction_non_alphanumeric': 0.10481283422459893, 'fraction_numerical': 0.01093285799168152, 'mean_word_length': 3.3696780893042577, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6917876', 'n_tokens_mistral': 3014, 'n_tokens_neox': 2888, 'n_words': 776}