<commit_before>#include "../../src/SDPSolver.h"
#include "../../src/Timers.h"
#include "../../src/parse.h"

// FIXME: This should not be a global
Timers timers;

int main() {

  mp_bitcnt_t precision(1024);
  mpf_set_default_prec(precision);

  std::cout.precision(static_cast<int>(precision * 0.31 + 5));

  const size_t N(1);
  Matrix matrix(N, N), square_gmp(N, N);
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j) {
      Real ri(i + 1), rj(j + 1);
      matrix.elt(i, j) = sqrt(ri+rj);
      // matrix.elt(i, j) = ri / 3 + rj / 5 + (ri * rj) / 7;
    }

  std::cout << matrix.elt(0,0) << "\n";
  
  matrixSquareIntoBlock(matrix, square_gmp, 0, 0);

  mpmat workspace(100);

  mpf_set_default_prec(mpf_get_default_prec() + 256);
  Matrix square_mpmat(N, N);
  mpf_set_default_prec(mpf_get_default_prec() - 256);

  workspace.syrk_reduced(CblasRowMajor, CblasTrans, matrix.cols, matrix.rows,
                         matrix.elements.data(), square_mpmat.elements.data());

  // matrixSquareIntoBlockMpmat(workspace, matrix, square_mpmat, 0, 0);

  Real residue(1e100);
  residue = residue / (residue * residue * residue * residue * residue *
                       residue * residue);
  for (size_t i = 0; i < N; ++i) {
    for (size_t j = 0; j < N; ++j) {
      // if (abs((square_gmp.elt(i, j) - square_mpmat.elt(i, j)) /
      //         (square_gmp.elt(i, j) + square_mpmat.elt(i, j))) > residue) {
      std::cout << i << " " << j << "\n\t" << square_gmp.elt(i, j) << "\n\t"
                << square_mpmat.elt(i, j) << "\n\t"
                << (square_gmp.elt(i, j) - square_mpmat.elt(i, j)) << "\n";
      // }
    }
  }

  // SDPSolverParameters parameters;
  // parameters.precision = 2048;
  // parameters.resetPrecision();
  // parameters.maxThreads = 1;
  // // parameters.maxThreads=128;

  // omp_set_num_threads(parameters.maxThreads);

  // SDPSolver solver(readBootstrapSDP(std::vector<boost::filesystem::path>(
  //                      // {"../inputs/TTTTtestsmall.xml"})),
  //                      {"test/mpmat/input.xml"})),
  //                  parameters);
  // solver.testMultiplication(1, 1, 5);
}
<commit_msg>Increase precision in mpmat_test to demonstrate bug<commit_after>#include "../../src/SDPSolver.h"
#include "../../src/Timers.h"
#include "../../src/parse.h"

// FIXME: This should not be a global
Timers timers;

int main() {

  mp_bitcnt_t precision(2048);
  mpf_set_default_prec(precision);

  std::cout.precision(static_cast<int>(precision * 0.31 + 5));

  const size_t N(1);
  Matrix matrix(N, N), square_gmp(N, N);
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j) {
      Real ri(i + 1), rj(j + 1);
      matrix.elt(i, j) = sqrt(ri+rj);
      // matrix.elt(i, j) = ri / 3 + rj / 5 + (ri * rj) / 7;
    }

  std::cout << matrix.elt(0,0) << "\n";
  
  matrixSquareIntoBlock(matrix, square_gmp, 0, 0);

  mpmat workspace(100);

  mpf_set_default_prec(mpf_get_default_prec() + 256);
  Matrix square_mpmat(N, N);
  mpf_set_default_prec(mpf_get_default_prec() - 256);

  workspace.syrk_reduced(CblasRowMajor, CblasTrans, matrix.cols, matrix.rows,
                         matrix.elements.data(), square_mpmat.elements.data());

  // matrixSquareIntoBlockMpmat(workspace, matrix, square_mpmat, 0, 0);

  Real residue(1e100);
  residue = residue / (residue * residue * residue * residue * residue *
                       residue * residue);
  for (size_t i = 0; i < N; ++i) {
    for (size_t j = 0; j < N; ++j) {
      // if (abs((square_gmp.elt(i, j) - square_mpmat.elt(i, j)) /
      //         (square_gmp.elt(i, j) + square_mpmat.elt(i, j))) > residue) {
      std::cout << i << " " << j << "\n\t" << square_gmp.elt(i, j) << "\n\t"
                << square_mpmat.elt(i, j) << "\n\t"
                << (square_gmp.elt(i, j) - square_mpmat.elt(i, j)) << "\n";
      // }
    }
  }

  // SDPSolverParameters parameters;
  // parameters.precision = 2048;
  // parameters.resetPrecision();
  // parameters.maxThreads = 1;
  // // parameters.maxThreads=128;

  // omp_set_num_threads(parameters.maxThreads);

  // SDPSolver solver(readBootstrapSDP(std::vector<boost::filesystem::path>(
  //                      // {"../inputs/TTTTtestsmall.xml"})),
  //                      {"test/mpmat/input.xml"})),
  //                  parameters);
  // solver.testMultiplication(1, 1, 5);
}

{'fraction_non_alphanumeric': 0.18632400183570444, 'fraction_numerical': 0.02202845341899954, 'mean_word_length': 2.451306413301663, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3594896', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1625, 'n_words': 318}