อ่าน 3 นาที
Quantum Computation Language
Quantum Computation Language (QCL) is one of the first implemented quantum programminglanguages.
Quantum Computation Language
Quantum Computation Language (QCL) is one of the first implemented quantum programminglanguages.[1] The most important feature of QCL is the support for user-defined operators and functions. Its syntax resembles the syntax of the C programming language and its classical data types are similar to primitive data types in C. One can combine classical code and quantum code in the same program.
The language was created before there were multi-qubit quantum computers and the only implementation of QCL uses an interpreter with a built-in classically simulated quantum computer.
QCL was created to explore programming concepts for quantum computers.[2][3][4]
The QCL library provides standard quantum operators used in quantum algorithms such as:[5]
- Controlled-not with many target qubits,
- Hadamard operation on many qubits,
- Phase and controlled phase.
- Quantum algorithms for addition, multiplication and exponentiation with binary constants (all modulus n)
- The quantum fourier transform
Syntax
- Data types
- Quantum - qureg, quvoid, quconst, quscratch, qucond
- Classical - int, real, complex, boolean, string, vector, matrix, tensor
- Function types
- qufunct - Pseudo-classic operators. Can only change the permutation of basis states.
- operator - General unitary operators. Can change the amplitude.
- procedure - Can call measure, print, and dump inside this function. This function is non-invertible.
- Built-in functions
- Quantum
- qufunct - Fanout, Swap, Perm2, Perm4, Perm8, Not, CNot
- operator - Matrix2x2, Matrix4x4, Matrix8x8, Rot, Mix, H, CPhase, SqrtNot, X, Y, Z, S, T
- procedure - measure, dump, reset
- Classical
- Arithmetic - sin, cos, tan, log, sqrt, ...
- Complex - Re, Im, conj
- Quantum
Examples
The basic built-in quantum data type in QCL is the qureg (quantum register). It can be interpreted as an array of qubits (quantum bits).
qureg x1 [ 2 ]; // รีจิสเตอร์ควอนตัม 2 คิวบิต x1 qureg x2 [ 2 ]; // รีจิสเตอร์ควอนตัม 2 คิวบิต x2 H ( x1 ); // การดำเนินการ Hadamard บน x1 H ( x2 [ 1 ]); // การดำเนินการ Hadamard บนคิวบิตแรกของรีจิสเตอร์ x2เนื่องจากตัวแปลภาษา qcl ใช้ไลบรารีการจำลอง qlib จึงสามารถสังเกตสถานะภายในของเครื่องควอนตัมได้ในระหว่างการประมวลผลโปรแกรมควอนตัม
qcl> dump สถานะ: จัดสรรคิวบิตไปแล้ว 4/32 คิวบิต ว่าง 28/32 คิวบิต 0.35355 |0> + 0.35355 |1> + 0.35355 |2> + 0.35355 |3> + 0.35355 |8> + 0.35355 |9> + 0.35355 |10> + 0.35355 |11> โปรดทราบว่าการดำเนินการดัมพ์ข้อมูลนั้นแตกต่างจากการวัด เนื่องจากไม่มีผลต่อสถานะของเครื่องควอนตัม และสามารถทำได้โดยใช้โปรแกรมจำลองเท่านั้น
เช่นเดียวกับในภาษาโปรแกรมสมัยใหม่ เราสามารถกำหนดการดำเนินการใหม่ๆ ที่สามารถนำมาใช้ในการจัดการข้อมูลควอนตัมได้ ตัวอย่างเช่น:
operator diffuse ( qureg q ) { H ( q ); // การแปลง Hadamard Not ( q ); // กลับเฟส q CPhase ( pi , q ); // หมุนถ้า q=1111.. ! Not ( q ); // ยกเลิกการกลับเฟส! H ( q ); // ยกเลิกการแปลง Hadamard }นิยามตัวดำเนินการผกผันเกี่ยวกับค่าเฉลี่ยที่ใช้ในอัลกอริทึมของโกรเวอร์ (บางครั้งเรียกว่าตัวดำเนินการแพร่กระจายของโกรเวอร์ ) ซึ่งช่วยให้สามารถกำหนดอัลกอริทึมในระดับนามธรรมที่สูงขึ้นและขยายคลังฟังก์ชันที่มีให้สำหรับโปรแกรมเมอร์ได้
สรุปเนื้อหา
ข้อมูลสำคัญจากบทความ
ข้อมูลสำคัญเกี่ยวกับ Quantum Computation Language
Quantum Computation Language (QCL) is one of the first implemented quantum programminglanguages.
Syntax
Data types Quantum - qureg, quvoid, quconst, quscratch, qucond Classical - int, real, complex, boolean, string, vector, matrix, tensor Function types qufunct - Pseudo-classic operators. Can only change the permutation of basis states.
Examples
The basic built-in quantum data type in QCL is the qureg (quantum register). It can be interpreted as an array of qubits (quantum bits).