<commit_before>#include "bh_tsne_ref.h"
#include "common.h"

double * BHTSNERef::computeEdgeForces(float * Xs, float * Ys, float NDIMS, float PROJDIMS, int N, int K, float sigma) {
	double * dXs = (double *) malloc(N * NDIMS * sizeof(double));
	double * dYs = (double *) malloc(N * PROJDIMS * sizeof(double));
	double * edgeForces = (double *) calloc(N * NDIMS, sizeof(double));
	for (int i = 0; i < N * NDIMS; i++) {
		dXs[i] = (double) Xs[i];
		dYs[i] = (double) Ys[i];
	}
	unsigned int * row_P;
    unsigned int * col_P;
	double * val_P;
	computeGaussianPerplexity(dXs, N, NDIMS, &row_P, &col_P, &val_P, (double) sigma, K);

	symmetrizeMatrix(&row_P, &col_P, &val_P, N);
  //  for(int i = 0; i < row_P[N]; i++) val_P[i] *= 12.0;

	BHTSNERef::SPTree * tree = new BHTSNERef::SPTree(PROJDIMS, dYs, N);
	tree->computeEdgeForces(row_P, col_P, val_P, N, edgeForces);
	return edgeForces;
}

double BHTSNERef::euclidean_distance(const BHTSNERef::DataPoint &t1, const BHTSNERef::DataPoint &t2){
        double dd = .0;
        double* x1 = t1._x;
        double* x2 = t2._x;
        double diff;
        for(int d = 0; d < t1._D; d++) {
            diff = (x1[d] - x2[d]);
            dd += diff * diff;
        }<commit_msg>BHTSNE Ref Implementation on Master<commit_after>#include "bh_tsne_ref.h"
#include "common.h"

double * BHTSNERef::computeEdgeForces(float * Xs, float * Ys, float NDIMS, float PROJDIMS, int N, int K, float sigma) {
	double * dXs = (double *) malloc(N * NDIMS * sizeof(double));
	double * dYs = (double *) malloc(N * PROJDIMS * sizeof(double));
	double * edgeForces = (double *) calloc(N * NDIMS, sizeof(double));
	for (int i = 0; i < N * NDIMS; i++) {
		dXs[i] = (double) Xs[i];
		dYs[i] = (double) Ys[i];
	}
	unsigned int * row_P;
    unsigned int * col_P;
	double * val_P;
	computeGaussianPerplexity(dXs, N, NDIMS, &row_P, &col_P, &val_P, (double) sigma, K);

	symmetrizeMatrix(&row_P, &col_P, &val_P, N);
    for(int i = 0; i < row_P[N]; i++) val_P[i] *= 12.0;

	BHTSNERef::SPTree * tree = new BHTSNERef::SPTree(PROJDIMS, dYs, N);
	tree->computeEdgeForces(row_P, col_P, val_P, N, edgeForces);
	return edgeForces;
}

double BHTSNERef::euclidean_distance(const BHTSNERef::DataPoint &t1, const BHTSNERef::DataPoint &t2){
        double dd = .0;
        double* x1 = t1._x;
        double* x2 = t2._x;
        double diff;
        for(int d = 0; d < t1._D; d++) {
            diff = (x1[d] - x2[d]);
            dd += diff * diff;
        }
{'fraction_non_alphanumeric': 0.16680227827502034, 'fraction_numerical': 0.013018714401952807, 'mean_word_length': 3.3989266547406083, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1830827', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1038, 'n_words': 250}