Browse Source

use CMake, refactor simulator to seperate dir

master
watkinsr 1 year ago
parent
commit
baefd672bd
  1. 5
      CMakeLists.txt
  2. 43
      Makefile
  3. 0
      simulator/app/__init__.py
  4. 0
      simulator/app/quantum_adder/__init__.py
  5. 0
      simulator/app/quantum_gates/__init__.py
  6. 0
      simulator/app/quantum_multiplier/__init__.py
  7. 0
      simulator/app/quantum_register/__init__.py
  8. 0
      simulator/app/quantum_simulator/__init__.py
  9. 0
      simulator/app/service.py
  10. 0
      simulator/requirements.txt
  11. 20
      test.py

5
CMakeLists.txt

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.19.7)
project(sqint)
add_executable(${PROJECT_NAME} src/parse.cpp src/QReg.cpp)

43
Makefile

@ -1,43 +0,0 @@
##
# QPL Interpreter
#
# @file
# @version 0.1
IDIR=include
CPPFLAGS=-g -I$(IDIR) -lstdc++ -std=c++11 -Wall
LIBS=
ODIR=obj
LDIR=lib
BDIR=bin
_DEPS = parse.h QReg.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = parse.o QReg.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: src/%.cpp $(DEPS)
$(CXX) -c -o [email protected] $< $(CPPFLAGS)
MKDIR_P = mkdir -p
.PHONY: clean directories
all: directories parse
parse: $(OBJ)
$(CXX) -o $(BDIR)/[email protected] $^ $(CPPFLAGS)
directories: ${BDIR} ${ODIR}
${BDIR}:
${MKDIR_P} ${BDIR}
${ODIR}:
${MKDIR_P} ${ODIR}
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~

0
app/__init__.py → simulator/app/__init__.py

0
app/quantum_adder/__init__.py → simulator/app/quantum_adder/__init__.py

0
app/quantum_gates/__init__.py → simulator/app/quantum_gates/__init__.py

0
app/quantum_multiplier/__init__.py → simulator/app/quantum_multiplier/__init__.py

0
app/quantum_register/__init__.py → simulator/app/quantum_register/__init__.py

0
app/quantum_simulator/__init__.py → simulator/app/quantum_simulator/__init__.py

0
app/service.py → simulator/app/service.py

0
requirements.txt → simulator/requirements.txt

20
test.py

@ -1,20 +0,0 @@
class QuantumSimExample:
def __init__(
self,
n_qubits,
):
self.n_qubits = n_qubits
self.qubits = [0] * n_qubits
# in this classical simulation, we use 2^n_qubits complex numbers
self.amps = [0] * (1 << n_qubits)
self.amps[len(self.amps) - 1] = 1
def __repr__(self) -> str:
return f"TestQubits[{self.n_qubits}], amps: {self.amps}"
def main():
quantum_sim_example = QuantumSimExample(n_qubits=3)
print(quantum_sim_example)
if __name__ == '__main__':
main()
Loading…
Cancel
Save