<commit_before>import {Config} from "src/Config.js"
import {Gate} from "src/circuit/Gate.js"
import {ketArgs, ketShaderPermute, ketInputGateShaderCode} from "src/circuit/KetShaderUtil.js"

let XorGates = {};

const XOR_SHADER = ketShaderPermute(
    ketInputGateShaderCode('A'),
    `
        float srcMask = mod(read_input_A(), span);
        float bitPos = 1.0;
        float result = 0.0;
        for (int i = 0; i < ${Config.MAX_WIRE_COUNT}; i++) {
            float srcBit = mod(floor(srcMask/bitPos), 2.0);
            float dstBit = mod(floor(out_id/bitPos), 2.0);
            result += (dstBit + srcBit - dstBit * srcBit * 2.0) * bitPos;
            bitPos *= 2.0;
        }
        return result;`);

XorGates.XorAFamily = Gate.buildFamily(1, 8, (span, builder) => builder.
    setSerializedId("^=A" + span).
    setSymbol("⊕A").
    setTitle("Xor Gate [input A]").
    setBlurb("Xors input A into the qubits covered by this gate.").
    setRequiredContextKeys("Input Range A").
    setKnownEffectToParametrizedPermutation((t, a) => t ^ (a & ((1<<span)-1))).
    setActualEffectToShaderProvider(ctx => XOR_SHADER.withArgs(...ketArgs(ctx, span, ['A']))));

XorGates.all = [
    ...XorGates.XorAFamily.all,<commit_msg>Expand xor gate to max-height 16<commit_after>import {Config} from "src/Config.js"
import {Gate} from "src/circuit/Gate.js"
import {ketArgs, ketShaderPermute, ketInputGateShaderCode} from "src/circuit/KetShaderUtil.js"

let XorGates = {};

const XOR_SHADER = ketShaderPermute(
    ketInputGateShaderCode('A'),
    `
        float srcMask = mod(read_input_A(), span);
        float bitPos = 1.0;
        float result = 0.0;
        for (int i = 0; i < ${Config.MAX_WIRE_COUNT}; i++) {
            float srcBit = mod(floor(srcMask/bitPos), 2.0);
            float dstBit = mod(floor(out_id/bitPos), 2.0);
            result += (dstBit + srcBit - dstBit * srcBit * 2.0) * bitPos;
            bitPos *= 2.0;
        }
        return result;`);

XorGates.XorAFamily = Gate.buildFamily(1, 16, (span, builder) => builder.
    setSerializedId("^=A" + span).
    setSymbol("⊕A").
    setTitle("Xor Gate [input A]").
    setBlurb("Xors input A into the qubits covered by this gate.").
    setRequiredContextKeys("Input Range A").
    setKnownEffectToParametrizedPermutation((t, a) => t ^ (a & ((1<<span)-1))).
    setActualEffectToShaderProvider(ctx => XOR_SHADER.withArgs(...ketArgs(ctx, span, ['A']))));

XorGates.all = [
    ...XorGates.XorAFamily.all,
{'fraction_non_alphanumeric': 0.15668016194331985, 'fraction_numerical': 0.014979757085020242, 'mean_word_length': 3.070840197693575, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3910512', 'n_tokens_mistral': 905, 'n_tokens_neox': 866, 'n_words': 190}