<commit_before>use MultiVector::BitEncoded;
use MultiVector::BitEncoded::BasisBlade;
unit class MultiVector::BitEncoded::Default does MultiVector::BitEncoded;

has UIntHash $.bitEncoding;

# Constructors required by roles
multi method new(Real $s) { self.new: :bitEncoding((0 => $s).MixHash) }
multi method new(UIntHash $bitEncoding) { self.new: :$bitEncoding }

multi method add(::?CLASS $A) { self.new: (flat self.pairs, $A.pairs).MixHash }
multi method add(Real $s) { self.new: (0 => $s, |self.pairs).MixHash }

multi method scale(Real $s) {
    self.new: self.pairs.map({ Pair.new: .key, $s*.value }).MixHash
}

my %product;
method gp(::?CLASS $A) { %product<gp>(self, $A) }
method ip(::?CLASS $A) { %product<ip>(self, $A) }
method op(::?CLASS $A) { %product<op>(self, $A) }

%product = <gp ip op> Z=>
map -> &basis-blade-product {
    sub ($A, $B) {
	my @a = (|.push-to-diagonal-basis for $A.basis-blades);
	my @b = (|.push-to-diagonal-basis for $B.basis-blades);
	return $A.new:
	do for @a -> $a {
	    |do for @b -> $b {
		&basis-blade-product($a, $b);
	    }
	}.map(&MultiVector::BitEncoded::BasisBlade::pop-from-diagonal-basis).flat.MixHash;
    }
}, 
# work around #128010
{ MultiVector::BitEncoded::BasisBlade::geometric-product($^a, $^b) },
{ MultiVector::BitEncoded::BasisBlade::inner-product($^a, $^b) },
{ MultiVector::BitEncoded::BasisBlade::outer-product($^a, $^b) };<commit_msg>use pointy block instead of sub<commit_after>use MultiVector::BitEncoded;
use MultiVector::BitEncoded::BasisBlade;
unit class MultiVector::BitEncoded::Default does MultiVector::BitEncoded;

has UIntHash $.bitEncoding;

# Constructors required by roles
multi method new(Real $s) { self.new: :bitEncoding((0 => $s).MixHash) }
multi method new(UIntHash $bitEncoding) { self.new: :$bitEncoding }

multi method add(::?CLASS $A) { self.new: (flat self.pairs, $A.pairs).MixHash }
multi method add(Real $s) { self.new: (0 => $s, |self.pairs).MixHash }

multi method scale(Real $s) {
    self.new: self.pairs.map({ Pair.new: .key, $s*.value }).MixHash
}

my %product;
method gp(::?CLASS $A) { %product<gp>(self, $A) }
method ip(::?CLASS $A) { %product<ip>(self, $A) }
method op(::?CLASS $A) { %product<op>(self, $A) }

%product = <gp ip op> Z=>
map -> &basis-blade-product {
    -> $A, $B {
	my @a = (|.push-to-diagonal-basis for $A.basis-blades);
	my @b = (|.push-to-diagonal-basis for $B.basis-blades);
	$A.new: do for @a -> $a {
	    |do for @b -> $b {
		&basis-blade-product($a, $b);
	    }
	}.map(&MultiVector::BitEncoded::BasisBlade::pop-from-diagonal-basis).flat.MixHash;
    }
}, 
# work around #128010
{ MultiVector::BitEncoded::BasisBlade::geometric-product($^a, $^b) },
{ MultiVector::BitEncoded::BasisBlade::inner-product($^a, $^b) },
{ MultiVector::BitEncoded::BasisBlade::outer-product($^a, $^b) };
{'fraction_non_alphanumeric': 0.20650232225794926, 'fraction_numerical': 0.0057163272597356195, 'mean_word_length': 4.894736842105263, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 24, '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': '5986338', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1077, 'n_words': 231}