Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
# Welcome to Mklorum
# 欢迎使用 Quantum Algorithm (qalgo)

For full documentation visit [mkdocs.org](https://www.mkdocs.org).
这是 Quantum Algorithm 项目的文档。本项目基于量子虚拟机实现了一些量子算法。

## Commands
并且本项目还提供了大量用于组成量子算法的组件,例如量子逻辑门,量子算术运算,QRAM,量子态制备,量子傅里叶变换,量子测量等。

* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.
## 安装

## Project layout
### 系统需求

mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
- 操作系统:Windows、Linux 或 macOS
- Python 版本:3.9 或以上,推荐3.10+

### 安装方式

```python
pip install qalgo
```

## 快速开始

```python
import qalgo

## TODO:

# 打印结果
print(result)
```

## 算法列表

### 已实现
- 线性求解器 (Quantum Linear System Solver),基于离散绝热定理

### 待实现
- Shor算法
- 线性求解器 (Quantum Linear System Solver),基于Quantum Walk
- 线性求解器 (Quantum Linear System Solver),基于HHL算法
- 量子态制备


## 关于
本项目由 USTC-IAI 量子人工智能团队开发,主要成员为:

TODO.
53 changes: 36 additions & 17 deletions qalgo/qda/fundamental.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,42 @@ def get_mid_eigenstate(self) -> NDArray[np.float64]:
print(f"fs = {self.fs}")
n = self.row_size

match self.fs:
case 0:
vec = self.get_vector_0b()
case 1:
sol = np.linalg.solve(self.matrix_A, self.vector_b)
sol /= np.linalg.norm(sol)
vec = np.concatenate([np.zeros(n), sol])
case _ if 0 < self.fs < 1:
Af = self.get_matrix_Af()
b = self.get_vector_0b()
sol = np.linalg.solve(Af, b)
sol /= np.linalg.norm(sol)
vec = sol
case _:
raise RuntimeError(
f"Invalid fs value: {self.fs}. Expected 0 <= fs <= 1."
)
# match self.fs:
# case 0:
# vec = self.get_vector_0b()
# case 1:
# sol = np.linalg.solve(self.matrix_A, self.vector_b)
# sol /= np.linalg.norm(sol)
# vec = np.concatenate([np.zeros(n), sol])
# case _ if 0 < self.fs < 1:
# Af = self.get_matrix_Af()
# b = self.get_vector_0b()
# sol = np.linalg.solve(Af, b)
# sol /= np.linalg.norm(sol)
# vec = sol
# case _:
# raise RuntimeError(
# f"Invalid fs value: {self.fs}. Expected 0 <= fs <= 1."
# )

# match statement only works for python 3.10+
# Fix this by using if-else statements
if self.fs == 0:
vec = self.get_vector_0b()
elif self.fs == 1:
sol = np.linalg.solve(self.matrix_A, self.vector_b)
sol /= np.linalg.norm(sol)
vec = np.concatenate([np.zeros(n), sol])
elif 0 < self.fs < 1:
Af = self.get_matrix_Af()
b = self.get_vector_0b()
sol = np.linalg.solve(Af, b)
sol /= np.linalg.norm(sol)
vec = sol
else:
raise RuntimeError(
f"Invalid fs value: {self.fs}. Expected 0 <= fs <= 1."
)

return np.concatenate([vec, np.zeros(2 * n)], dtype=np.float64)

Expand Down