<commit_before>/*
 * <NAME>
 * <EMAIL>
 */
#include "lib.h"

Vector *new_vector(int size) {
  Vector *v;

  v = MALLOC(Vector, 1);

  v->size = size;
  v->data = MALLOC(double, v->size);

  return v;
}

void set_vector_with_var(Vector *p, double x) {
  int i;

  for(i=0; i < p->size; i++) {
    p->data[i] = x;
  }
}

void set_vector_with_vars(Vector *p, double *data) {
  int i;

  for(i=0; i < p->size; i++) {
    p->data[i] = data[i];
  }
}

void print_vector(Vector *p, char *name) {
  int i;

  printf("%s(%i):[ ", name, p->size);
  for(i=0; i < p->size; i++) {
    if((i+1) == p->size) {
      printf("%4.2lf ]\n", p->data[i]);
    } else {
      printf("%4.2lf, ", p->data[i]);
    }
  }
}

/*
 * Be sure that p->size >= q->size!
 */
Vector *add_vectors(Vector *p, Vector *q) {
  Vector *v;
  int i;

  v = new_vector(p->size);

  for(i=0; i < q->size; i++) {
    v->data[i] = p->data[i] + q->data[i];
  }
  if(i < p->size) {
    for(i=i; i < p->size; i++) {
      v->data[i] = p->data[i];
    }
  }

  return v;
}

void multiply_vector_by(Vector *p, double a) {
  int i;

  for(i=0; i < p->size; i++) {
    p->data[i] *= a;
  }
}

Vector *multiply_vectors(Vector *p, Vector *q) {
  Vector *v;
  int i, size;

  if(p->size < q->size) {
    size = q->size;
  } else {
    size = p->size;
  }

  v = new_vector(size);

  for(i=0; i < size; i++) {
    if(p->size <= i && q->size <= i) {
      v->data[i] = p->data[i] * q->data[i];
    } else {
      v->data[i] = 0;
    }
  }

  return v;
}

void delete_vector(Vector *p) {
  free(p->data);
  free(p);
}

double reduce_vector(Vector *p, int start, int end) {
  int i;
  double sum = 0.0;

  for(i=start; i < end; i++) {
    sum += *(p->data + i);
  }

  return sum;
}<commit_msg>Fixed multipling vectors.<commit_after>/*
 * <NAME>
 * <EMAIL>
 */
#include "lib.h"

Vector *new_vector(int size) {
  Vector *v;

  v = MALLOC(Vector, 1);

  v->size = size;
  v->data = MALLOC(double, v->size);

  return v;
}

void set_vector_with_var(Vector *p, double x) {
  int i;

  for(i=0; i < p->size; i++) {
    p->data[i] = x;
  }
}

void set_vector_with_vars(Vector *p, double *data) {
  int i;

  for(i=0; i < p->size; i++) {
    p->data[i] = data[i];
  }
}

void print_vector(Vector *p, char *name) {
  int i;

  printf("%s(%i):[ ", name, p->size);
  for(i=0; i < p->size; i++) {
    if((i+1) == p->size) {
      printf("%4.2lf ]\n", p->data[i]);
    } else {
      printf("%4.2lf, ", p->data[i]);
    }
  }
}

/*
 * Be sure that p->size >= q->size!
 */
Vector *add_vectors(Vector *p, Vector *q) {
  Vector *v;
  int i;

  v = new_vector(p->size);

  for(i=0; i < q->size; i++) {
    v->data[i] = p->data[i] + q->data[i];
  }
  if(i < p->size) {
    for(i=i; i < p->size; i++) {
      v->data[i] = p->data[i];
    }
  }

  return v;
}

void multiply_vector_by(Vector *p, double a) {
  int i;

  for(i=0; i < p->size; i++) {
    p->data[i] *= a;
  }
}

Vector *multiply_vectors(Vector *p, Vector *q) {
  Vector *v;
  int i, size;

  if(p->size < q->size) {
    size = q->size;
  } else {
    size = p->size;
  }

  v = new_vector(size);

  for(i=0; i < size; i++) {
    if(i <= p->size && i <= q->size) {
      v->data[i] = p->data[i] * q->data[i];
    } else {
      v->data[i] = 0;
    }
  }

  return v;
}

void delete_vector(Vector *p) {
  free(p->data);
  free(p);
}

double reduce_vector(Vector *p, int start, int end) {
  int i;
  double sum = 0.0;

  for(i=start; i < end; i++) {
    sum += *(p->data + i);
  }

  return sum;
}
{'fraction_non_alphanumeric': 0.23591954022988507, 'fraction_numerical': 0.008620689655172414, 'mean_word_length': 2.373062015503876, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 83, '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': '5460474', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1578, 'n_words': 352}