Repository navigation
Expand file tree
/
Copy pathdocs.html
More file actions
224 lines (206 loc) · 14.6 KB
/
Copy pathdocs.html
File metadata and controls
224 lines (206 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en" data-i18n-lang>
<head>
<meta charset="UTF-8">
<meta name="author" content="Faruk Hilmi AKPINAR" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="manifest.webmanifest">
<link rel="icon" type="image/png" sizes="48x48" href="img/favicon-48.png">
<link rel="apple-touch-icon" sizes="180x180" href="img/icon-180.png">
<meta name="theme-color" content="#0b0c0e">
<meta name="robots" content="index, follow">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<script>
window.__qc={};
(function(){
try{window.__qc.c=JSON.parse(localStorage.getItem('qc_consent')||'null')||{}}catch(e){window.__qc.c={}}
if(window.__qc.c.a===true){
var s=document.createElement('script');s.async=true;
s.src='https://www.googletagmanager.com/gtag/js?id=G-HR4Z4E0JLK';
document.head.appendChild(s);
}
})();
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
if(window.__qc.c.a===true){
gtag('js', new Date());
gtag('config', 'G-HR4Z4E0JLK');
}
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;1,400&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400;1,6..72,500&display=swap" rel="stylesheet" media="print" onload="this.media='all'">
<noscript><link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;1,400&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400;1,6..72,500&display=swap" rel="stylesheet"></noscript>
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="style.css">
<title>quantro-js · Quantum Circuit Simulator API — Documentation</title>
<meta name="description" content="quantro-js — a clean-room, dependency-free quantum circuit simulator written in pure JavaScript. API reference, install guide and runnable Bell/GHZ examples with exact outputs.">
<meta property="og:title" content="quantro-js · API Documentation">
<meta property="og:description" content="Pure-JavaScript quantum circuit simulator — install, API reference and runnable Bell/GHZ examples. MIT, zero dependencies.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://quantro-1.vercel.app/docs.html">
<meta property="og:image" content="https://quantro-1.vercel.app/img/og-quantro.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="quantro-js · API Documentation">
<meta name="twitter:description" content="Dependency-free quantum circuit simulator for JavaScript: state-vector simulation, Bell/GHZ entanglement, seeded sampling.">
<meta name="twitter:image" content="https://quantro-1.vercel.app/img/og-quantro.png">
<link rel="canonical" href="https://quantro-1.vercel.app/docs.html">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareSourceCode",
"name": "quantro-js",
"applicationCategory": "DeveloperApplication / Simulation",
"description": "A clean-room, zero-dependency quantum circuit simulator written in pure JavaScript. State-vector simulation, H·X·Y·Z·RY gates, CX/CZ entanglement, Bell/GHZ state preparation, seeded sampling.",
"codeRepository": "https://github.com/Lennebraha38/quantro",
"downloadUrl": "https://www.npmjs.com/package/quantro-js",
"license": "https://opensource.org/licenses/MIT",
"operatingSystem": "Any (browser & Node.js)",
"programmingLanguage": "JavaScript",
"size": "single file (~8 KB)"
}
</script>
</head>
<body>
<a href="#main-content" class="skip-link">Skip to content</a>
<!-- ══ NAV ══ -->
<nav id="nav">
<div class="nav-inner">
<a href="index.html" class="nav-logo" aria-label="Quantro — ana sayfa">
<span class="nav-mark" aria-hidden="true"
><svg viewBox="0 0 32 32" fill="none">
<circle cx="16" cy="16" r="9.4" stroke="currentColor" stroke-width="1.7" />
<ellipse
cx="16"
cy="16"
rx="14.2"
ry="5.6"
stroke="currentColor"
stroke-width="1.25"
opacity=".45"
transform="rotate(-30 16 16)"
/>
<circle cx="26.4" cy="9.6" r="2.2" fill="var(--cyan)" />
</svg></span
>
<span class="nav-word">Quantro</span>
</a>
<ul class="nav-links">
<li><a href="docs.html">Docs</a></li>
<li><a href="hakkimizda.html" data-i18n="nav.about">Hakkımızda</a></li>
<li><a href="basarilar.html" data-i18n="nav.achievements">Başarılarımız</a></li>
<li><a href="arastirma.html" data-i18n="nav.research">Araştırma</a></li>
<li><a href="simulasyon.html" data-i18n="nav.sim">Simülasyon</a></li>
<li><a href="blog.html" data-i18n="nav.blog">Blog</a></li>
<li><a href="quantro-lab.html" data-i18n="nav.lab">Lab ⚗</a></li>
</ul>
<div class="tubelight" id="tubelight">
<span class="tubelight-glow" id="tlglow" aria-hidden="true"></span>
<button class="nb" id="langbtn" onclick="toggleLang()">EN</button>
<a href="iletisim.html" class="nav-cta" data-i18n="nav.contact">İletişim</a>
</div>
<button class="nav-burger" id="burger" aria-label="Menu" aria-expanded="false">
<span></span><span></span><span></span>
</button>
</div>
</nav>
<main id="main-content">
<nav class="crumbs" aria-label="breadcrumb"><a href="index.html">Quantro</a><span class="csep">›</span><span aria-current="page">Docs</span></nav>
<section class="page-head"><div class="container">
<div class="ph-eyebrow">quantro-js · API Reference</div>
<h1>Quantum Circuit Simulator <span style="color:var(--cyan)">for JavaScript</span></h1>
<p class="ph-sub">A clean-room, <strong>zero-dependency</strong> state-vector quantum circuit simulator, written in pure JavaScript. Runs in the browser via plain <code><script></code> or in Node.js via <code>require()</code>. MIT licensed.</p>
<p class="ph-sub"><a href="quantro-lab.html" style="color:var(--cyan)">→ Live interactive demo (Lab)</a> · <a href="https://www.npmjs.com/package/quantro-js" style="color:var(--cyan)" target="_blank" rel="noopener">npm</a> · <a href="https://github.com/Lennebraha38/quantro" style="color:var(--cyan)" target="_blank" rel="noopener">source</a></p>
</div></section>
<section class="docs" style="padding:60px 0">
<div class="container" style="max-width:880px">
<h2 class="sec-h2" style="text-align:left">Install</h2>
<pre><code>npm install quantro-js</code></pre>
<p class="sec-sub"> — or load straight from unpkg in any page:</p>
<pre><code><script src="https://unpkg.com/quantro-js"></script></code></pre>
<h2 class="sec-h2" style="text-align:left">Quick start — a Bell pair</h2>
<p class="sec-sub">Two qubits, an H gate and a CNOT: that is entanglement. This is a real, reproducible run (seed <code>42</code>):</p>
<pre><code>const { QuantumCircuit, bellState, sampleDistribution } = require('quantro-js');
const qc = new QuantumCircuit(2);
bellState(qc); // |00> + |11>
console.log(qc.probabilities());
// [ 0.4999999999999999, 0, 0, 0.4999999999999999 ]
const counts = sampleDistribution(qc, 1024, 42);
console.log(counts);
// { 0: 494, 3: 530 } → measured half in |00>, half in |11></code></pre>
<h2 class="sec-h2" style="text-align:left">GHZ three-qubit state</h2>
<p class="sec-sub">Gates chain, and every method returns the circuit:</p>
<pre><code>const qc = new QuantumCircuit(3);
qc.h(0).cx(0, 1).cx(0, 2); // GHZ state (|000> + |111>) / √2
console.log(qc.probabilities());
// [ 0.4999999999999999, 0, 0, 0, 0, 0, 0, 0.4999999999999999 ]</code></pre>
<h2 class="sec-h2" style="text-align:left">Single measurement</h2>
<pre><code>const qc = new QuantumCircuit(1);
qc.h(0); // superposition
qc.measureAll(() => 0.1); // → 0
qc.measureAll(() => 0.9); // → 1</code></pre>
<h2 class="sec-h2" style="text-align:left">API reference</h2>
<div style="overflow-x:auto">
<table style="width:100%;border-collapse:collapse;font-family:var(--fm);font-size:13px">
<thead><tr><th style="text-align:left;padding:10px;border-bottom:1px solid rgba(0,200,240,.3)">API</th><th style="text-align:left;padding:10px;border-bottom:1px solid rgba(0,200,240,.3)">Description</th></tr></thead>
<tbody>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>new QuantumCircuit(n)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">n-qubit circuit (1 ≤ n ≤ 12, full 2ⁿ state vector)</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>.h(q) · .x(q) · .y(q) · .z(q)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">single-qubit gates (chainable)</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>.ry(theta, q)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">rotation around Y by <code>theta</code> radians</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>.cx(c, t) · .cz(c, t)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">controlled-X / controlled-Z (entanglement gates)</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>.probabilities()</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">measurement probability distribution over the 2ⁿ basis states</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>.measureAll(rng)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">one sampled measurement (integer); <code>rng</code> = <code>() => [0,1)</code></td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>bellState(qc)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">prepare |00> + |11> (Bell pair)</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>ghzState(qc, qubits)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">prepare |0…0> + |1…1> (GHZ)</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>sampleDistribution(qc, shots[, seed])</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">sample counts; seeded → fully reproducible</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>mulberry32(seed)</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">seeded PRNG generator</td></tr>
<tr><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)"><code>H · X · Y · Z · I2</code></td><td style="padding:8px;border-bottom:1px solid rgba(255,255,255,.06)">gate matrices (complex-array form)</td></tr>
</tbody>
</table>
</div>
<h2 class="sec-h2" style="text-align:left">Why it exists</h2>
<p class="sec-sub">quantro-js is the engine behind this site's <a href="quantro-lab.html" style="color:var(--cyan)">13 interactive tools</a>. It was written from scratch as a community critique of the assumption that "quantum computing needs big frameworks": the whole simulator fits in one MIT-licensed, dependency-free JavaScript file, and it is deliberately kept humble and inspectable so that anyone — student, developer, researcher — can read, run and extend it.</p>
<h2 class="sec-h2" style="text-align:left">Companion project: ZENAI (4 brains)</h2>
<p class="sec-sub">The same author maintains <a href="https://github.com/Lennebraha38/ZENAI" target="_blank" rel="noopener" style="color:var(--cyan)">ZENAI</a> — a Turkish, local-first AI assistant built on a two-tier brain setup (a local Ollama 7B/14B code model + a cloud "mega brain"), with a four-brain deliberation layer: majority vote, a 12-criteria jury referee, verification, and self-correction. The badge below tracks its repository automatically, so what you see always reflects the latest upstream commit.</p>
<p style="margin:14px 0 0">
<a href="https://github.com/Lennebraha38/ZENAI/commits/main" target="_blank" rel="noopener" style="display:inline-block;padding:7px 14px;border:1px solid rgba(0,200,240,.35);border-radius:8px;font-family:var(--mono);font-size:13px;color:var(--cyan);text-decoration:none;background:rgba(0,200,240,.06)">ZENAI · <span id="zenai-sha" title="latest commit on main">…</span></a>
<span class="sec-sub" style="display:inline-block;margin-left:10px" id="zenai-date"></span>
</p>
</div>
</section>
</main>
<script>
// ZENAI rozeti — data/zenai.json build'de (scripts/zenai-sync.mjs) güncel
// tutulur; site her yüklemede en güncel SHA'yı gösterir.
(async function () {
try {
const r = await fetch("data/zenai.json", { cache: "no-store" });
if (!r.ok) return;
const z = await r.json();
const sha = document.getElementById("zenai-sha");
const dt = document.getElementById("zenai-date");
if (sha) sha.textContent = z.sha;
if (dt) dt.textContent = "last upstream commit: " + String(z.date || "").slice(0, 10);
} catch {
/* rozet sessizce atlanır */
}
})();
</script>
<!-- ══ FOOTER ══ -->
<footer>
<div class="footer-inner">
<a href="index.html" class="footer-logo">Q<span>U</span>ANTRO</a>
<span class="footer-founder">Kurucu · <a href="hakkimizda.html#founder" rel="author">Faruk Hilmi AKPINAR</a></span>
<span class="footer-copy">© <span id="fyear">2025</span> Quantro · R&D Center</span>
<span class="footer-sys">ARŞİV :: QTR-2026 · MONOGRAFİ</span>
<span class="footer-sys"><a href="https://github.com/Lennebraha38/quantro/issues/new" target="_blank" rel="noopener" style="color:rgba(0,200,240,.7)">Report an issue / Suggest →</a></span>
</div>
</footer>
<button class="btt" id="btt" aria-label="Back to top" title="Back to top">↑</button>
<script src="js/nav-data.js"></script>
<script src="js/entropy.js"></script>
<script src="app.js"></script>
<script src="js/chat-widget.js" defer></script>
</body>
</html>