# Applying a gate to all line qubits without explicitly listing them in Cirq

Say we have a custom gate CG, defined by a unitary matrix U, and line qubits qubits in Cirq. Something like this:

import numpy
import cirq

U = np.eye(8)    # The custom unitary matrix goes here
CG = cirq.MatrixGate(U)
qubits = cirq.LineQubit.range(3)


We build the circuit as follows:

circuit = cirq.Circuit()
circuit.append(CG(qubits[0], qubits[1], qubits[2]))


Is it possible to build the circuit without explicitly specifying all the qubits? Something like circuit.append(CG(qubits)), which would apply the CG gate to all the qubits?

In Python you can say callable(*args) instead of callable(args[0], args[1], args[2]).
• i.e. in your example you could write CG(*qubits) – dabacon Jul 30 '20 at 21:35
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8437744379043579, "perplexity": 4652.651582727744}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-21/segments/1620243991659.54/warc/CC-MAIN-20210516013713-20210516043713-00020.warc.gz"}