Skip to content

Commit

Permalink
Merge branch 'main' into add-sparse-dense
Browse files Browse the repository at this point in the history
  • Loading branch information
Glacialte committed Sep 11, 2024
2 parents d951e3b + 1e2ae52 commit 090a67f
Show file tree
Hide file tree
Showing 52 changed files with 2,448 additions and 1,791 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ AccessModifierOffset: -4
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 100
DerivePointerAlignment: false
PointerAlignment: Left
5 changes: 5 additions & 0 deletions .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ jobs:
- name: Test in Ubuntu
run: |
OMP_PROC_BIND=false ninja test -C build -j $(nproc)
- name: Test if stub exists
run: |
echo -e "from scaluq import StateVector\nfrom scaluq.gate import I" > /tmp/stub_sample.py
mypy /tmp/stub_sample.py
nvcc-build:
name: NVCC build
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int main() {
circuit.add_gate(scaluq::gate::X(0));
circuit.add_gate(scaluq::gate::CNot(0, 1));
circuit.add_gate(scaluq::gate::Y(1));
circuit.add_gate(scaluq::gate::RX(1, M_PI / 2));
circuit.add_gate(scaluq::gate::RX(1, std::numbers::pi / 2));
circuit.update_quantum_state(state);

scaluq::Operator observable(n_qubits);
Expand Down
32 changes: 26 additions & 6 deletions exe/main.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
#include <gtest/gtest.h>

#include <Eigen/Core>
#include <functional>
#include <iostream>
#include <types.hpp>
#include <util/random.hpp>

#include "../scaluq/all.hpp"
#include "../scaluq/util/utility.hpp"

using namespace scaluq;
using namespace std;

void run() {
std::uint64_t n_qubits = 5;
auto state = StateVector::Haar_random_state(n_qubits);
auto y_gate = gate::Y(2);
std::cout << y_gate->to_string() << "\n\n";

auto cx_gate = gate::CX(0, 2);
std::cout << cx_gate << "\n\n";

auto swap_gate = gate::Swap(2, 3, {4, 6});
std::cout << swap_gate << "\n\n";

auto rx_gate = gate::RX(2, 0.5);
std::cout << rx_gate << "\n\n";

auto prob_gate = gate::Probablistic({0.1, 0.1, 0.8}, {cx_gate, y_gate, swap_gate});
std::cout << prob_gate << "\n\n";

auto prob_prob_gate = gate::Probablistic({0.5, 0.5}, {cx_gate, prob_gate});
std::cout << prob_prob_gate << "\n\n";

auto prx_gate = gate::ParamRX(2);
std::cout << prx_gate << "\n\n";

auto pry_gate = gate::ParamRY(2, 2.5, {1, 3});
std::cout << pry_gate << "\n\n";

auto pprob_gate = gate::ParamProbablistic({0.7, 0.3}, {prx_gate, pry_gate});
std::cout << pprob_gate << std::endl;
}

int main() {
Expand Down
12 changes: 4 additions & 8 deletions exe/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from scaluq import *
# from scaluq.gate import S

def main():
state = StateVector(2)
gate = SWAP(0, 1)
gate = SWAPGate(gate)
mat = gate.get_matrix()
print(mat)
t = type(mat[0][0])
print(t)
swap_gate = gate.Swap(0, 1)
print(state)
print(swap_gate)

if __name__ == "__main__":
initialize(InitializationSettings().set_num_threads(8))
main()
finalize()
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ homepage = "http://www.scaluq.org"

[project.optional-dependencies]
dev = [
"mypy == 1.11.2",
"scikit-build == 0.17.6",
"typing_extensions == 4.12.0",
"numpy == 1.26.0",
"nanobind == 2.0.0"
]

ci = [
"mypy == 1.11.2",
"scikit-build == 0.17.6",
"typing_extensions == 4.12.0",
"numpy == 1.26.0",
Expand Down
Loading

0 comments on commit 090a67f

Please sign in to comment.