<commit_before>use std::ops::{
	Index, IndexMut, 
	Neg, Add, Sub, Mul, Div, Rem, 
	AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, 
	Not, BitAnd, BitOr, BitXor,
	BitAndAssign, BitOrAssign, BitXorAssign,
};
use std::fmt::{Display, Debug, Formatter, Result as FmtResult};
pub use num::{Num, Zero, Signed, Float};

macro_rules! vec_struct {
	($V:ident, $N:expr) => (
		#[allow(non_camel_case_types)]
		#[derive(Clone, Copy, PartialEq)]
		pub struct $V<T: Copy> {
			pub d: [T; $N],
		}
	)
}

macro_rules! vec_data {
	($V:ident, $N:expr) => (
		impl<T> $V<T> where T: Copy {
			pub fn data(&self) -> &[T; $N] {
				&self.d
			}
		}
	)
}

macro_rules! vec_fmt {
	($V:ident, $N:expr) => (
		impl<T> Display for $V<T> where T: Copy + Display {
			fn fmt(&self, f: &mut Formatter) -> FmtResult {
				try!(write!(f, "{} [ ", stringify!($V)));
				for i in 0..$N {
					try!(write!(f, "\t{}, ", self[i]));
				}
				try!(write!(f, "]"));
				Ok(())
			}
		}

		impl<T> Debug for $V<T> where T: Copy + Display {
			#[inline]
			fn fmt(&self, f: &mut Formatter) -> FmtResult {
				Display::fmt(self, f)
			}
		}
	)
}

macro_rules! vec_map {
	[$i:ident; $v:expr; $V:ident, $N:expr] => ({
		let mut out = $V::new();
		for $i in 0..$N {
			out[$i] = $v;
		}
		out
	})
}

macro_rules! vec_index {
	($V:ident, $N:expr) => (
		impl<T> Index<usize> for $V<T> where T: Copy {
			type Output = T;
			#[inline]
			fn index(&self, i: usize) -> &Self::Output {
				&self.d[i]
			}
		}

		impl<T> IndexMut<usize> for $V<T> where T: Copy {
			#[inline]
			fn index_mut(&mut self, i: usize) -> &mut Self::Output {
				&mut self.d[i]
			}
		}
	)
}

macro_rules! vec_new {
	($V:ident, $N:expr) => (
		impl<T> $V<T> where T: Copy + Default {
			pub fn new() -> Self {
				$V::<T> { d: [T::default(); $N] }
			}
		}
	)
}

macro_rules! vec_from {
	($V:ident, $N:expr) => (
		impl<T, U> From<[U; $N]> for $V<T> where T: Copy + Default + From<U>, U: Copy {
			fn from(a: [U; $N]) -> Self {
				vec_map![i; T::from(a[i]); $V, $N]
			}
		}

		/*
		// Waiting for negative traits implementation in Rust
		impl<T, U: !T> From<$V<U>> for $V<T> where T: Copy + Default + From<U>, U: Copy {
			fn from(a: $V<U>) -> Self {
				$V::<T>::from(a.data())
			}
		}
		*/
	)
}

macro_rules! vec_neg {
	($V:ident, $N:expr) => (
		impl<T> Neg for $V<T> where T: Copy + Default + Num + Signed {
			type Output = $V<T>;
			fn neg(self) -> Self::Output {<commit_msg>vector conversion and mapping<commit_after>use std::ops::{
	Index, IndexMut, 
	Neg, Add, Sub, Mul, Div, Rem, 
	AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, 
	Not, BitAnd, BitOr, BitXor,
	BitAndAssign, BitOrAssign, BitXorAssign,
};
use std::fmt::{Display, Debug, Formatter, Result as FmtResult};
pub use num::{Num, Zero, Signed, Float};

macro_rules! vec_struct {
	($V:ident, $N:expr) => (
		#[allow(non_camel_case_types)]
		#[derive(Clone, Copy, PartialEq)]
		pub struct $V<T: Copy> {
			pub d: [T; $N],
		}
	)
}

macro_rules! vec_data {
	($V:ident, $N:expr) => (
		impl<T> $V<T> where T: Copy {
			pub fn data(&self) -> &[T; $N] {
				&self.d
			}
		}
	)
}

macro_rules! vec_fmt {
	($V:ident, $N:expr) => (
		impl<T> Display for $V<T> where T: Copy + Display {
			fn fmt(&self, f: &mut Formatter) -> FmtResult {
				try!(write!(f, "{} [ ", stringify!($V)));
				for i in 0..$N {
					try!(write!(f, "\t{}, ", self[i]));
				}
				try!(write!(f, "]"));
				Ok(())
			}
		}

		impl<T> Debug for $V<T> where T: Copy + Display {
			#[inline]
			fn fmt(&self, f: &mut Formatter) -> FmtResult {
				Display::fmt(self, f)
			}
		}
	)
}

macro_rules! vec_map {
	[$i:ident; $v:expr; $V:ident, $N:expr] => ({
		let mut out = $V::new();
		for $i in 0..$N {
			out[$i] = $v;
		}
		out
	})
}

macro_rules! vec_index {
	($V:ident, $N:expr) => (
		impl<T> Index<usize> for $V<T> where T: Copy {
			type Output = T;
			#[inline]
			fn index(&self, i: usize) -> &Self::Output {
				&self.d[i]
			}
		}

		impl<T> IndexMut<usize> for $V<T> where T: Copy {
			#[inline]
			fn index_mut(&mut self, i: usize) -> &mut Self::Output {
				&mut self.d[i]
			}
		}
	)
}

macro_rules! vec_new {
	($V:ident, $N:expr) => (
		impl<T> $V<T> where T: Copy + Default {
			pub fn new() -> Self {
				$V::<T> { d: [T::default(); $N] }
			}
			
			pub fn map<F>(f: F) -> Self where F: Fn(usize) -> T {
				vec_map![i; f(i); $V, $N]
			}
		}
	)
}

pub trait From_<VU> {
	fn from_(v: VU) -> Self;
}

pub trait Into_<VT> {
	fn into_(self) -> VT;
}

macro_rules! vec_from {
	($V:ident, $N:expr) => (
		impl<'a, T, U> From<&'a [U; $N]> for $V<T> where T: Copy + Default + From<U>, U: Copy {
			fn from(a: &'a [U; $N]) -> Self {
				vec_map![i; T::from(a[i]); $V, $N]
			}
		}

		impl<T, U> From<[U; $N]> for $V<T> where T: Copy + Default + From<U>, U: Copy {
			fn from(a: [U; $N]) -> Self {
				Self::from(&a)
			}
		}

		impl<T, U> From_<$V<U>> for $V<T> where T: Copy + Default + From<U>, U: Copy + Default {
			fn from_(a: $V<U>) -> Self {
				Self::from(a.data())
			}
		}

		impl<T, U> Into_<$V<T>> for $V<U> where T: Copy + Default + From<U>, U: Copy + Default {
			fn into_(self) -> $V<T> {
				self.data().into()
			}
		}
	)
}

macro_rules! vec_neg {
	($V:ident, $N:expr) => (
		impl<T> Neg for $V<T> where T: Copy + Default + Num + Signed {
			type Output = $V<T>;
			fn neg(self) -> Self::Output {
{'fraction_non_alphanumeric': 0.22503303756843496, 'fraction_numerical': 0.0007551444213705871, 'mean_word_length': 2.9566840926064226, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 115, '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': '4060326', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2361, 'n_words': 573}