<commit_before>/** \file gr1c_util.h
 * \brief Small handy routines not otherwise sorted.
 *
 *
 * SCL; 2013, 2014.
 */


#ifndef GR1C_UTIL_H
#define GR1C_UTIL_H

#include "common.h"
#include "ptree.h"


/** Convert unsigned bitvector into integer.

   \param vec array that represents the bitvector, where the least significant
   bit is first.

   \param vec_len length of \p vec.

   \return integer obtained by unsigned interpretation of given bitvector. */
int bitvec_to_int( vartype *vec, int vec_len );

/** Convert integer to unsigned bitvector.

   \param x integer that is to be converted.

   \param vec_len maximum length of the allocated array (bitvector).
   If \p vec_len is not sufficiently large, then the result is effectively a
   truncated form of the full bitvector for the given integer.

   \return pointer to array that represents the bitvector, where the least
   significant bit is first. The caller is assumed to free the allocated
   array. E.g., call free() on the return value. */
vartype *int_to_bitvec( int x, int vec_len );


/** Expand any variables with integral domains.

   Expand any variables with integral domains in given lists of variables, where
   the expansion is as performed by var_to_bool() (cf. ptree.h). Variables that
   have type boolean are ignored.

   \param evar_list linked list of environment variables.

   \param svar_list linked list of system variables.

   \param verbose level of detail in logging; larger implies more detail. 0
   (zero) to be quiet.

   \return list of names of replaced variables. The caller is assumed to free
   this, e.g., using delete_tree(). */
ptree_t *expand_nonbool_variables( ptree_t **evar_list, ptree_t **svar_list,
                                   unsigned char verbose );

/** Return an array of length mapped_len where the nonboolean
   variables in given state array have been expanded according to
   their offsets and widths in offw.  Return NULL if error. */
vartype *expand_nonbool_state( vartype *state, int *offw, int num_nonbool,<commit_msg>DOC: Clarify size of the array from int_to_bitvec<commit_after>/** \file gr1c_util.h
 * \brief Small handy routines not otherwise sorted.
 *
 *
 * SCL; 2013, 2014.
 */


#ifndef GR1C_UTIL_H
#define GR1C_UTIL_H

#include "common.h"
#include "ptree.h"


/** Convert unsigned bitvector into integer.

   \param vec array that represents the bitvector, where the least significant
   bit is first.

   \param vec_len length of \p vec.

   \return integer obtained by unsigned interpretation of given bitvector. */
int bitvec_to_int( vartype *vec, int vec_len );

/** Convert integer to unsigned bitvector.

   \param x integer that is to be converted.

   \param vec_len length of the allocated array (bitvector).
   If \p vec_len is not sufficiently large, then the result is effectively a
   truncated form of the full bitvector for the given integer.

   \return pointer to array that represents the bitvector, where the least
   significant bit is first. The caller is assumed to free the allocated
   array. E.g., call free() on the return value. */
vartype *int_to_bitvec( int x, int vec_len );


/** Expand any variables with integral domains.

   Expand any variables with integral domains in given lists of variables, where
   the expansion is as performed by var_to_bool() (cf. ptree.h). Variables that
   have type boolean are ignored.

   \param evar_list linked list of environment variables.

   \param svar_list linked list of system variables.

   \param verbose level of detail in logging; larger implies more detail. 0
   (zero) to be quiet.

   \return list of names of replaced variables. The caller is assumed to free
   this, e.g., using delete_tree(). */
ptree_t *expand_nonbool_variables( ptree_t **evar_list, ptree_t **svar_list,
                                   unsigned char verbose );

/** Return an array of length mapped_len where the nonboolean
   variables in given state array have been expanded according to
   their offsets and widths in offw.  Return NULL if error. */
vartype *expand_nonbool_state( vartype *state, int *offw, int num_nonbool,
{'fraction_non_alphanumeric': 0.06616577799321377, 'fraction_numerical': 0.0058167716917111, 'mean_word_length': 3.367195767195767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6294702', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1133, 'n_words': 545}