<commit_before>
/* Francis algorithm in C; see README */

#include "util.h"
#include <stdio.h>



/** Display a matrix as follows:
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *            ...           ...                   ...
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn];
 */
void showmat(size_t nrows, size_t ncols, double *M) {
	int r, c;

	printf("M=[");
	for (r = 0; r < nrows; r++) {
		for (c = 0; c < ncols; c++) {
			printf("\t%+3.6f", M[c + r*ncols]);

			/* formatting and frill */
			if (c == ncols - 1) {
				if (r == nrows - 1) {
					printf("];\n");
				} else {
					printf(";\n");
				}
			} else {
				putchar(',');
			}
		}
	}
}



/** Display a matrix and a description as follows:
 *
 * <description>:
 *
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,<commit_msg>Add option for "unclean" printing of matrices. These are not parsable by octave.<commit_after>
/* Francis algorithm in C; see README */

#include "util.h"
#include <stdio.h>
#include <math.h>
//#define UNCLEAN_MATRICES 1



/** Display a matrix as follows:
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *            ...           ...                   ...
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn];
 */
void showmat(size_t nrows, size_t ncols, double *M) {
	int r, c;
#ifdef UNCLEAN_MATRICES
	int insignificant = 0;
#endif

	printf("M=[");
	for (r = 0; r < nrows; r++) {
		for (c = 0; c < ncols; c++) {
#ifdef UNCLEAN_MATRICES
			insignificant = (fabs(M[c + r*ncols]) < 0.001);
			if (insignificant) {
				printf("\t          ");
			} else {
#endif
				printf("\t%+3.6f", M[c + r*ncols]);
#ifdef UNCLEAN_MATRICES
			}
#endif

			/* formatting and frill */
			if (c == ncols - 1) {
				if (r == nrows - 1) {
					printf("];\n");
				} else {
					printf(";\n");
				}
			} else {
#ifdef UNCLEAN_MATRICES
				if (!insignificant) {
#endif
					putchar(',');
#ifdef UNCLEAN_MATRICES
				}
#endif
			}
		}
	}
}



/** Display a matrix and a description as follows:
 *
 * <description>:
 *
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
{'fraction_non_alphanumeric': 0.20536756126021002, 'fraction_numerical': 0.007001166861143524, 'mean_word_length': 1.9160997732426304, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 8, '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': '4168875', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1098, 'n_words': 224}