{"id":21695934,"url":"https://github.com/dedztbh/kuantumcircuitsim","last_synced_at":"2025-08-17T10:04:09.150Z","repository":{"id":160032865,"uuid":"297601599","full_name":"dedztbh/KuantumCircuitSim","owner":"dedztbh","description":"A Fast \u0026 Lightweight Quantum Circuit Simulator \u0026 Analyzer implemented in Kotlin.","archived":false,"fork":false,"pushed_at":"2020-11-14T06:15:09.000Z","size":186,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T14:49:25.817Z","etag":null,"topics":["blas","circuit","circuit-matrix","csv","ejml","jar","jblas","kotlin","matrices","measure","probabilistic-programming","quantum","quantum-algorithm","quantum-circuit","quantum-circuit-simulator","quantum-computing","qubits","simulation"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dedztbh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-22T09:33:43.000Z","updated_at":"2024-12-14T03:57:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec40f5ed-b593-4180-b554-b55dd5356b47","html_url":"https://github.com/dedztbh/KuantumCircuitSim","commit_stats":{"total_commits":64,"total_committers":1,"mean_commits":64.0,"dds":0.0,"last_synced_commit":"7d4503dad2f6218ba162360d6a9a9fad997f2263"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/dedztbh/KuantumCircuitSim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedztbh%2FKuantumCircuitSim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedztbh%2FKuantumCircuitSim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedztbh%2FKuantumCircuitSim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedztbh%2FKuantumCircuitSim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dedztbh","download_url":"https://codeload.github.com/dedztbh/KuantumCircuitSim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedztbh%2FKuantumCircuitSim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270831777,"owners_count":24653412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blas","circuit","circuit-matrix","csv","ejml","jar","jblas","kotlin","matrices","measure","probabilistic-programming","quantum","quantum-algorithm","quantum-circuit","quantum-circuit-simulator","quantum-computing","qubits","simulation"],"created_at":"2024-11-25T19:17:34.667Z","updated_at":"2025-08-17T10:04:09.119Z","avatar_url":"https://github.com/dedztbh.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KuantumCircuitSim\n\n![EPR](https://raw.githubusercontent.com/DEDZTBH/KuantumCircuitSim/master/EPR.gif)\n\u003c/br\u003e\n\u003csub\u003eMaking an EPR pair\u003c/sub\u003e\n\nA Fast \u0026 Lightweight Quantum Circuit Simulator \u0026 Analyzer implemented in Kotlin.\n\nQuantum Computing is no coin-flipping!\n\nAnother 15-459 Assignment(-ish).\n\nThere are 2 versions with identical usage implemented with different libraries:    \n- EJML version: No native dependencies, super lightweight, good for small input (small N, like \u003c4)\n- JBLAS version: Accelerated with BLAS, good for big input (big N)\n    - JBLAS comes with default BLAS library for major OS's so it works right out of the box. For extreme performance, you can build JBLAS with custom BLAS library (like OpenBlas, ATLAS, cuBLAS) and put the library file(s) under library load path (for example, current working directory). See [JBLAS github page](https://github.com/jblas-project/jblas) for more detail.\n\n### Table of Contents\n- [KuantumCircuitSim](#kuantumcircuitsim)\n    - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n    - [Simulate A Quantum Circuit](#simulate-a-quantum-circuit)\n    - [N-Qubit System](#n-qubit-system)\n    - [Generate Circuit Matrix](#generate-circuit-matrix)\n    - [Parallelism](#parallelism)\n    - [Acceleration with BLAS](#acceleration-with-blas)\n  - [Usage](#usage)\n  - [Operators](#operators)\n  - [Commands](#commands)\n  - [Note](#note)\n    - [Notation](#notation)\n    - [Matrix File Format](#matrix-file-format)\n    - [OutOfMemoryError](#outofmemoryerror)\n\n## Features\n#### Simulate A Quantum Circuit\nOf course, it says \"Quantum Circuit Simulator\"! See below for all supported gates and operations, including measurement!\n\n#### N-Qubit System\nYou can use any number of qubits you want! Just make sure your computer is powerful enough if N is large. Time/Space complexity is exponential on classical computers!\n\n#### Generate Circuit Matrix\nThe power of Linear Algebra! You can save the matrix after the simulation. Next time, just load it and one matrix multiplication gets you the result of running the entire circuit!\n\n#### Parallelism\nCPU0 is not alone! Concurrent command processing provides significantly performance boost on multi-core machines, especially for big N and large number of commands!\n- Note that concurrent implementation isn't always faster than sequential (with -s flag). Sequential is often faster in scenarios such as:\n    - Small N (like \u003c4)\n    - Intensive use of multiple core causes thermal throttling (like when I run JBLAS version on my laptop)\n\n#### Acceleration with BLAS\nNow with JBLAS! EJML is great for small matrices but for not big ones (matrices have size 2^N x 2^N). Thus I added a JBLAS version that uses hardware-optimized BLAS library and can really speed things up!\n\n## Usage\n\n```\nUsage: java -jar Kuantum.jar options_list\nArguments: \n    input -\u003e Input file { String }\n    operator -\u003e Operator name { String }\n    N [5] -\u003e Number of qubits (optional) { Int }\nOptions: \n    --output, -o [] -\u003e Output file to save circuit matrix (csv) if specified { String }\n    --input_matrix, -m [] -\u003e Read circuit matrix (csv) as initial matrix if specified { String }\n    --no_t, -q [false] -\u003e Do not print circuit matrix in commandline after simulation if present \n    --sequential, -s [false] -\u003e Use sequential instead of concurrent implementation if present \n    --init_state, -i [] -\u003e Read custom initial joint state from csv if specified { String }\n    --binary_matrix, -b [false] -\u003e Use binary format instead of csv for read/save circuit matrix if present (EJML version only) \n    --disable_cache, -d [false] -\u003e Disable cache to save memory (same gates will need to be recomputed every time) \n    --help, -h -\u003e Usage info \n```\n\nexample: ```java -jar KuantumCircuitSim.jar example.txt Tester 3 -o output.csv -i init.csv```\n\nWhere example.txt contains list of commands and circuit matrix (csv) will be stored to output.csv and initial state is read from init.csv\n\nSome examples for input command file, initial state (-i), and initial matrix (-m) are located in the example folder.\n\n## Operators\n\nTFinder: Generate the circuit's matrix and print it.\n\nTester: Similar to TFinder but also run |00..0\u003e (or custom initial state with -i option) through circuit and print result.\n- Supports Measure, MeasAll, MeasOne\n\nAllInit: Similar to TFinder but also run every possible initial states (2^N of them) through circuit and print results.\n\n## Commands\ni, j, k are indices of qubit. (0-indexed, left-to-right)\n\nIn the input file, each command should be separated by new line or space.\n\nCommands are case-insensitive.\n\n##### Single-Qubit Gates\n- Not i\n- Hadamard i\n    + You can also use \"H\" instead of \"Hadamard\"\n- Y i\n- Z i\n- S i\n- T i\n- TDag i\n- SqrtNot i\n- SqrtNotDag i\n- Rot i angle\n    + Rotate qubit counterclockwise by angle (in radian)\n- U i phi\n    + Phase shift by phi (mapping |1\u003e to e^(i*phi)|1\u003e)\n    + You can also use \"R\" instead of \"U\"\n\n##### Parallel Mode\nYou can enclose the above single-qubit gates that can run in parallel between \"ParStart\" and \"ParEnd\" commands. This can speed up the simulation a lot. Make sure you are using only above single-qubit gates and no two gates are acting on the same qubit.\n\n##### Multi-Qubit Gates\nNote: Control qubit(s) followed by target qubit(s)\n- CNot i j\n- Swap i j\n- CZ i j\n    + Controlled Z gate\n- SqrtSwap i j\n    + Not implemented yet\n- CU i j phi\n    + Controlled phase shift\n    + You can also use \"CR\" instead of \"CU\"\n- CCNot i j k\n- CSwap i j k\n\n##### Measurement (Only works when using Tester)\n- Measure n\n    + \"Magically\" measures all qubit state n times in standard basis and print results\n    + Will NOT change qubit state or circuit matrix\n    + Not saved in circuit matrix\n- MeasAll\n    + Measure all qubits in standard basis and print measure result\n    + Will cause qubit state to collapse\n    + Will make circuit matrix unavailable to print or save\n- MeasOne i\n    + Measure one qubits in standard basis and print measure result\n    + Will cause qubit state to collapse\n    + Will make circuit matrix unavailable to print or save\n    \n## Note\n\n### Notation\n\nIn a joint state, qubits are represented from left to right. For example, |100\u003e means the first qubit (index 0) is |1\u003e and the second (index 1) and third (index 2) are |0\u003e.\n\n### Matrix File Format\n\nA matrix in CSV format is represented with alternating real and imaginary parts in row-major fashion.\nFor example, the matrix\n```\n[[1+0i, 0+1i],\n [0-1i, 1+0i]]\n```\nis stored in CSV file like\n```\n1,0,0,1\n0,-1,1,0\n```\n(EJML version only) Alternatively, circuit matrix can be saved/loaded in Java binary format (with -b option). It might be faster to save/load but it is not human readable. In case you want to read it, it is a `org.ejml.data.ZMatrixRMaj`.\n\n### OutOfMemoryError\n\nIf you encountered OOM, try giving JVM more memory (with JVM argument -Xmx) and/or try program arguments -d (disable cache) and -s (sequential mode).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedztbh%2Fkuantumcircuitsim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdedztbh%2Fkuantumcircuitsim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedztbh%2Fkuantumcircuitsim/lists"}