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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ test/python/test_qasm_python_simulator.pdf

doc/_build/*

doc/_autodoc/*
doc/**/_autodoc

qiskit/bin/*

Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ profile:

doc:
export PYTHONPATH=$(PWD); \
better-apidoc -f -o doc/_autodoc -d 5 -e -t doc/_templates/better-apidoc qiskit qiskit/tools "qiskit/extensions/standard/[a-z]*"; \
sphinx-autogen -t doc/_templates doc/_autodoc/*; \
make -C doc html
for LANGUAGE in "." "ja"; do \
better-apidoc -f -o doc/$$LANGUAGE/_autodoc -d 5 -e -t doc/_templates/better-apidoc qiskit qiskit/tools "qiskit/extensions/standard/[a-z]*"; \
sphinx-autogen -t doc/_templates doc/$$LANGUAGE/_autodoc/*; \
make -C doc -e BUILDDIR="_build/$$LANGUAGE" -e SOURCEDIR="./$$LANGUAGE" html; \
done

clean:
make -C doc clean
make -C doc -e BUILDDIR="_build/ja" -e SOURCEDIR="./ja" clean
6 changes: 5 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ BUILDDIR = _build
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
.PHONY: help Makefile clean

clean:
rm -rf "$(BUILDDIR)"
rm -rf "$(SOURCEDIR)/_autodoc"

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '_autodoc/modules.rst']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '_autodoc/modules.rst', 'ja']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
Expand Down
19 changes: 19 additions & 0 deletions doc/ja/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Language specific configuration file, inheriting from the main /doc
conf.py file and adjusting the variables that depend on the language.
"""

import os
import sys

sys.path.insert(0, os.path.abspath('..'))
from conf import *

language = 'ja'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '_autodoc/modules.rst']

html_theme_path = ['../']
html_logo = '../theme/static/qiskit-logo-white-no-margin.gif'
html_favicon = '../theme/static/favicon.ico'
64 changes: 64 additions & 0 deletions doc/ja/dev_introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
ライブラリの構成
=============

プログラミング インターフェース
--------------------------

*qiskit* ディレクトリがメインのPythonモジュールで
:py:class:`QuantumProgram <qiskit.QuantumProgram>`、
:py:class:`QuantumRegister <qiskit.QuantumRegister>`、
:py:class:`ClassicalRegister <qiskit.ClassicalRegister>`、
:py:class:`QuantumCircuit <qiskit.QuantumCircuit>`のインターフェースを含みます。

実行手順は次の通りです。ユーザーは *QuantumProgram* (量子プログラム)を作成しそれに
複数の量子回路の生成、変更、コンパイル、と実行ができます。
各 *QuantumCircuit* (量子回路)には *QuantumRegister* (量子レジスター)か
*ClassicalRegister* (古典レジスター)があります。
これらのオブジェクトのメソッドを通じて、量子ゲートを適用して量子回路を定義します。
*QuantumCircuit* は **OpenQASM** コードを出力することができます。
このコードは *qiskit* ディレクトリの他のコンポーネントに流すことができます。

:py:mod:`extensions <qiskit.extensions>` ディレクトリは他の量子ゲートやアルゴリズムのサポートに必要な
量子回路の拡張のモジュールを含みます。
現在は典型的な量子ゲートを定義した :py:mod:`standard <qiskit.extensions.standard>` 拡張が存在します。

内部モジュール
------------

以下のディレクトリは開発中の内部モジュールを含みます:

- :py:mod:`qasm <qiskit.qasm>` モジュールは **OpenQASM** ファイルを解析します。
- :py:mod:`unroll <qiskit.unroll>` モジュールはターゲットのゲートに応じて **OpenQASM** の翻訳と“unroll(展開)”を行います。
(ゲート文のサブルーチンやループの展開も必要に応じて行います)
- :py:mod:`dagcircuit <qiskit.dagcircuit>` モジュールは量子回路をグラフとして処理します。
- :py:mod:`mapper <qiskit.mapper>` モジュールは、量子回路をカップリング(直接操作可能な量子ビットのペア)の制限がないバックエンドから制限のある実機で実行するために量子回路の変換を行います。
- :py:mod:`backends <qiskit.backends>` モジュールは量子回路のシミュレーターを含みます。
- *tools* ディレクトリはアプリケーション、分析、可視化のメソッドを含みます。

量子回路は以下の様にコンポーネントの間を流れます。
プログラミングインターフェースを用いて生成した **OpenQASM** 量子回路はテキストか *QuantumCircuit* オブジェクトです。
**OpenQASM** ソースコードはファイルか文字列で、 *Qasm* オブジェクトに渡されます。
そして、ソースコードはparseメソッドで分析されて抽象構文木(abstract syntax tree, **AST**)が生成されます。
**AST** は *Unroller* に渡されます。*Unroller* は異なる *UnrollerBackend* のいずれかを取り付けることができます。
テキストを出力する *PrinterBackend*、シミュレーターと実機のバックエンドの入力を生成する *JsonBackend*、
*DAGCircuit* を生成する *DAGBackend*、 *QuantumCircuit* オブジェクトを生成する *CircuitBackend* があります。
*DAGCircuit* は「展開された」**OpenQASM** の回路を有向非巡回グラフ(directed acyclic graph, DAG)として持ちます。
*DAGCircuit* は回路構成の表現、変換、性質の計算、結果を **OpenQASM** で出力するメソッドがあります。
この全体の流れは*mapper* モジュールが量子回路を、*CouplingGraph* で定義されたカップリング(直接操作可能な量子ビットのペア)の実機で実行するために変換するために行われます。
このコンポーネントの構成は将来的に変更の可能性があります。

量子回路が現在のモジュールでどのように変換されるかを以下の図にまとめます。



.. image:: ../images/circuit_representations.png
:width: 600px
:align: center

いくつかの unroller バックエンドとその出力は以下にまとめます:



.. image:: ../images/unroller_backends.png
:width: 600px
:align: center
40 changes: 40 additions & 0 deletions doc/ja/example_real_backend.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
実機バックエンドの例
^^^^^^^^^^^^^^^^^

.. code-block:: python
:linenos:

from qiskit import QuantumProgram

# 初めてのQuantumProgramオブジェクトのインスタンス生成
Q_program = QuantumProgram()

# APIトークンの設定
# トークンは次のURLから入手可能です。 https://quantumexperience.ng.bluemix.net/qx/account,
# "Personal Access Token"のセクションを参照してください。
QX_TOKEN = "API_TOKEN"
QX_URL = "https://quantumexperience.ng.bluemix.net/api"

# APIをセットアップしてプログラムの実行。
# APIトークンとQXのURLが必要です。
Q_program.set_api(QX_TOKEN, QX_URL)

# 2量子ビットの量子レジスターを生成して"qr"と名づけます。
qr = Q_program.create_quantum_register("qr", 2)
# 2ビットの古典レジスターを生成して"cr"と名づけます。
cr = Q_program.create_classical_register("cr", 2)
# 量子レジスター"qr"と古典レジスター"cr"を使った量子回路"qc"を生成ます。
qc = Q_program.create_circuit("superposition", [qr], [cr])

# Hゲートを量子ビット0に適用して量子重ね合わせを作ります。
qc.h(qr[0])

# "qr"の量子状態を観測し、その結果を"cr"に格納します。
qc.measure(qr, cr)

# 量子回路をコンパイルして実機のバックエンドibmqx2で実行します。
result = Q_program.execute(["superposition"], backend='ibmqx2', shots=1024)

# 結果を表示します。
print(result)
print(result.get_data("superposition"))
54 changes: 54 additions & 0 deletions doc/ja/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.. QISKit documentation master file, created by
sphinx-quickstart on Tue Jul 25 18:13:28 2017.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

========================
QISKit マニュアル
========================

Quantum Information Software Kit (QISKit, 量子情報ソフトウェアキット)は
`OpenQASM <https://github.com/QISKit/openqasm>`_ とIBM Q Experience(QX)
を利用してプログラミングをするためのPythonソフトウェア開発キット(SDK)です。


目次
=====

.. toctree::
:maxdepth: 2

インストール<install>
入門 <quickstart>
QISKit概要 <qiskit>
開発マニュアル <dev_introduction>
SDKリファレンス <_autodoc/qiskit>

Python モジュール
===============

主要モジュール
------------

.. autosummary::
:nosignatures:

qiskit.QuantumProgram
qiskit.QuantumCircuit

:ref:`modindex`

開発者 (アルファベット順)
======================

Jim Challenger, Andrew Cross, Ismael Faro, Jay Gambetta, Juan Gomez,
Paco Martin, Antonio Mezzacapo, Jesus Perez, and John Smolin, Erick Winston,
Chris Wood.

将来のリリースでこのプロジェクトにコードの貢献をした方の名前を追加します。

翻訳者(順不同)
=============

今道 貴司
ルディー・レイモンド
144 changes: 144 additions & 0 deletions doc/ja/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
======================
インストールとセットアップ
======================

インストール
============

1. ツールの入手
----------------

QISKitを利用するには少なくとも`Python 3.5か以降 <https://www.python.org/downloads/>`__ と
`Jupyter Notebooks <https://jupyter.readthedocs.io/en/latest/install.html>`__ を
インストールしておく必要があります。
(後者はチュートリアルで対話的に操作することをお勧めします)。

一般ユーザーにQISKitが依存する多くのライブラリが含まれている
`Anaconda 3 <https://www.continuum.io/downloads>`__ という
Python ディストリビューションをお勧めします。

Mac OS Xのユーザーに、Xcodeが役に立ちます: https://developer.apple.com/xcode/

QISKitに貢献したいか拡張したいユーザーにはGitもインストールする必要があります: https://git-scm.com/download/.


2. PIP インストール
-----------------

QISKitをインストールする最も簡単な方法はPIP tool(Pythonのパッケージマネージャー)を利用することです。

.. code:: sh

pip install qiskit

3. レポジトリのインストール
-----------------------

それ以外にもローカルにQISKit SDKのレポジトリのクローンを作成してそのディレクトリで作業するのも一般的です:

- もしGitをインストールしている場合は、以下のコマンドを実行してください:

.. code:: sh

git clone https://github.com/QISKit/qiskit-sdk-py
cd qiskit-sdk-py

- もしGitをインストールしていない場合は、
  `QISKit SDK GitHub repo <https://github.com/QISKit/qiskit-sdk-py>`__ の
  "Clone or download"ボタンをクリックして、
 その後ダウンロードしたファイルを展開し、そのディレクトリーに移動し作業を開始します。

3.1 環境の設定
^^^^^^^^^^^^^^^^^^^^^^^^^

QISKitを単独で機能するライブラリとして使うには全ての依存するライブラリもインストールする必要があります。

.. code:: sh

# システムに依存しますが, 必要に応じて "sudo -H" をコマンドの前に追加します。
pip install -r requires.txt

チュートリアルを利用するにはAnacondaの環境をセットアップして依存するライブラリをインストールします。:

- LinuxかMac OS X (Xcodeインストール済み)の場合、以下のコマンドを実行します。

.. code:: sh

make env

- Mac OS X (Xcodeなし)の場合, 以下のコマンドを実行します:

.. code:: sh

conda create -y -n QISKitenv python=3 pip scipy
activate QISKitenv
pip install -r requires.txt

- Windowsの場合、Anacondaのプロンプトで以下のコマンドを実行します:

.. code:: sh

.\make env


4. APIトークンの設定
---------------------------

- `IBM Q Experience <https://quantumexperience.ng.bluemix.net>`__
のアカウントがない場合は作成します。
- IBM Q Experienceのウェブサイトの“My Account” > “Personal Access Token”
からAPIトークンを取得します。
- Qconfig.pyというファイルにAPIトークンを書き込きます。
まずデフォルトのQconfig.pyをコピーします。
   (Windowsの場合 ``cp`` を ``copy`` で置き換えます):

.. code:: sh

cp Qconfig.py.default Qconfig.py

- Qconfig.pyをエディターで開き、``#APItoken``で始まる行の``#``を取り除き、
あなたのAPIトークンを記入して保存します。

Jupyterのチュートリアルのインストール
================================

QISKitプロジェクトはチュートリアルをJupyterノートブックの形式で提供します。
ノートブックはPythonのコードが埋め込まれたウェブページのようなものです。
埋め込まれたコードを実行するには``Shift+Enter``を押すか、
ページ上部のツールバーを使います。
出力は即座にページの下に表示されます。多くの場合埋め込まれたコードは上から順に実行します。
チュートリアルを使いはじめるには以下の通りにします。


1.1 インストール
----------------------
- チュートリアルのダウンロード: https://github.com/QISKit/qiskit-tutorial/archive/master.zip
- zipファイルの展開
- ターミナルで"qiskit-tutorial-master"のディレクトリーに移動し、以下を実行する:

.. code:: sh

jupyter notebook index.ipynb

チュートリアルに関する詳しい説明は
`qiskit-tutorial repository <https://github.com/QISKit/qiskit-tutorial>`__
を参照してください。

FAQ
===

もし依存ライブラリを更新してエラーが発生した場合以下のコマンドを試してみてください:

- システムに依存しますが, 必要に応じて "sudo -H" をコマンドの前に追加してください。

.. code:: sh

pip install -U --no-cache-dir IBMQuantumExperience

- 修正: 以下のコマンドを実行します。

.. code:: sh

curl https://bootstrap.pypa.io/ez_setup.py -o - | python

プロジェクトのGitHubのWikiのQISKit troubleshootingのページにさらに情報があります。
Loading