<commit_before>/* Copyright (C) 2005-2008 <NAME>.
   Copyright (C) 2007 <NAME>.
   Copyright (C) 2011 <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/>. */
/** \file util.h
    Miscellaneous. */

#ifndef FPLLL_UTIL_H
#define FPLLL_UTIL_H

#include "nr/matrix.h"

FPLLL_BEGIN_NAMESPACE

static inline int cputime()
{
#ifdef FPLLL_WITH_GETRUSAGE
  struct rusage rus;
  getrusage(RUSAGE_SELF, &rus);
  return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
#else
  return time(NULL) * 1000;
#endif
}

/* Computes result = x * m (it is not required that result is initialized,
   x.size() must be equal to m.GetNumRows()) */
template <class ZT>
void vector_matrix_product(vector<ZT> &result, const vector<ZT> &x, const Matrix<ZT> &m)
{
  int nrows = m.get_rows(), ncols = m.get_cols();
  if (x.size() != nrows)
   throw std::runtime_error("vector_matrix_product(): dimensions do not match!");
  gen_zero_vect(result, ncols);
  for (int i = 0; i < nrows; i++)
    for (int j = 0; j < ncols; j++)
      result[j].addmul(x[i], m(i, j));
}

/* Computes result = x * m (it is not required that result is initialized,
   x.size() must be equal to m.GetNumRows()) */
template <class ZT>
void vector_matrix_product(NumVect<ZT> &result, const NumVect<ZT> &x, const Matrix<ZT> &m)
{
  int nrows = m.get_rows(), ncols = m.get_cols();
  if (x.size() != nrows)
   throw std::runtime_error("vector_matrix_product(): dimensions do not match!");
  result.gen_zero(ncols);
  for (int i = 0; i < nrows; i++)
    for (int j = 0; j < ncols; j++)
      result[j].addmul(x[i], m(i, j));
}<commit_msg>util.h: check-style<commit_after>/* Copyright (C) 2005-2008 <NAME>.
   Copyright (C) 2007 <NAME>.
   Copyright (C) 2011 <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/>. */
/** \file util.h
    Miscellaneous. */

#ifndef FPLLL_UTIL_H
#define FPLLL_UTIL_H

#include "nr/matrix.h"

FPLLL_BEGIN_NAMESPACE

static inline int cputime()
{
#ifdef FPLLL_WITH_GETRUSAGE
  struct rusage rus;
  getrusage(RUSAGE_SELF, &rus);
  return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
#else
  return time(NULL) * 1000;
#endif
}

/* Computes result = x * m (it is not required that result is initialized,
   x.size() must be equal to m.GetNumRows()) */
template <class ZT>
void vector_matrix_product(vector<ZT> &result, const vector<ZT> &x, const Matrix<ZT> &m)
{
  int nrows = m.get_rows(), ncols = m.get_cols();
  if (x.size() != nrows)
    throw std::runtime_error("vector_matrix_product(): dimensions do not match!");
  gen_zero_vect(result, ncols);
  for (int i = 0; i < nrows; i++)
    for (int j = 0; j < ncols; j++)
      result[j].addmul(x[i], m(i, j));
}

/* Computes result = x * m (it is not required that result is initialized,
   x.size() must be equal to m.GetNumRows()) */
template <class ZT>
void vector_matrix_product(NumVect<ZT> &result, const NumVect<ZT> &x, const Matrix<ZT> &m)
{
  int nrows = m.get_rows(), ncols = m.get_cols();
  if (x.size() != nrows)
    throw std::runtime_error("vector_matrix_product(): dimensions do not match!");
  result.gen_zero(ncols);
  for (int i = 0; i < nrows; i++)
    for (int j = 0; j < ncols; j++)
      result[j].addmul(x[i], m(i, j));
}
{'fraction_non_alphanumeric': 0.12342057761732853, 'fraction_numerical': 0.015342960288808664, 'mean_word_length': 3.7666666666666666, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, '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': '3542989', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1523, 'n_words': 549}