Example #1
0
let fromJson_Gate_Matrix = props => {
    let mat = _parseGateMatrix(props.matrix);

    // Special case the mystery gate.
    if (props.id === MysteryGateSymbol) {
        return MysteryGateMakerWithMatrix(mat);
    }

    let height = Math.round(Math.log2(mat.height()));
    let width = props.symbol === '' ? height : 1;
    let matrix = _parseGateMatrix(props.matrix);

    let builder = new GateBuilder().
        setSerializedId(props.id).
        setSymbol(props.symbol).
        setTitle(props.name).
        setHeight(height).
        setWidth(width).
        setDrawer(props.symbol === "" ? matrixDrawer
            : matrix.isIdentity() ? labelDrawer
            : matrix.isScaler() ? locationIndependentDrawer
            : undefined).
        setKnownEffectToMatrix(matrix);
    if (matrix.isIdentity()) {
        builder.markAsNotInterestedInControls();
    }
    return builder.gate;
};
Example #2
0
         QuarterTurnGates.SqrtXForward, QuarterTurnGates.SqrtXBackward
     ]
 },
 {
     hint: "Eighth Turns",
     gates: [
         VariousZGates.Z4, VariousZGates.Z4i,
         VariousYGates.Y4, VariousYGates.Y4i,
         VariousXGates.X4, VariousXGates.X4i
     ]
 },
 {
     hint: 'Misc',
     gates: [
         PhaseGradientGates.PhaseGradientFamily.ofSize(2),       PhaseGradientGates.PhaseDegradientFamily.ofSize(2),
         undefined,                                              MysteryGateMaker(),
         FourierTransformGates.FourierTransformFamily.ofSize(2), SpacerGate
     ]
 },
 {
     hint: 'Arithmetic',
     gates: [
         CountingGates.CountingFamily.ofSize(2),    CountingGates.UncountingFamily.ofSize(2),
         ArithmeticGates.AdditionFamily.ofSize(4),  ArithmeticGates.SubtractionFamily.ofSize(4),
         ArithmeticGates.IncrementFamily.ofSize(2), ArithmeticGates.DecrementFamily.ofSize(2)
     ]
 },
 {
     hint: "Raising",
     gates: [
         PoweringGates.ZForward, PoweringGates.ZBackward,