September 30, 2022

SwissQuantumPi: Introducing QCSimulator

The code for the QCSimulator package is also available at Github QCSimulator. QCSimulator is also on CRAN. Thanks to Tinniam.

The first you have to do is to install the QCSimulator R Package. As it’s on CRAN, it’s as easy in R as an apt-get in Debian:

pi@SwissQuantumPi:~ $ R
R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: arm-unknown-linux-gnueabihf (32-bit)
> install.packages("QCSimulator")

If you get the message:

Warning in install.packages("QCSimulator") :
  'lib = "/usr/local/lib/R/site-library"' can't be opened in write mode
Would you like to use a personal library instead? (yes/No/cancel)

Answer ‘yes’ twice.

Would you like to create a personal library
‘~/R/arm-unknown-linux-gnueabihf-library/3.5’
to install packages into? (yes/No/cancel) yes

Take a seat because the installation and compilation take time! After a dozen minutes, you should get the message:

* DONE (QCSimulator)
>

Then, in R, load the QCSimulator library and standard ggplot2 as well.

>library(QCSimulator)
>library(ggplot2)
>

Take a deep breath, and test he QCSimulator environment :

> rm(list=ls())
> init()
> ls()

If everything went fine, you should have this display:

[1] "I16"     "I2"      "I32"     "I4"      "I8"      "q0_"     "q00_"
[8] "q000_"   "q0000_"  "q00000_" "q00001_" "q0001_"  "q00010_" "q00011_"
[15] "q001_"   "q0010_"  "q00100_" "q00101_" "q0011_"  "q00110_" "q00111_"
[22] "q01_"    "q010_"   "q0100_"  "q01000_" "q01001_" "q0101_"  "q01010_"
[29] "q01011_" "q011_"   "q0110_"  "q01100_" "q01101_" "q0111_"  "q01111_"
[36] "q1_"     "q10_"    "q100_"   "q1000_"  "q10000_" "q10001_" "q1001_"
[43] "q10010_" "q10011_" "q101_"   "q1010_"  "q10100_" "q10101_" "q1011_"
[50] "q10110_" "q10111_" "q11_"    "q110_"   "q1100_"  "q11000_" "q11001_"
[57] "q1101_"  "q11010_" "q11011_" "q111_"   "q1110_"  "q11100_" "q11101_"
[64] "q1111_"  "q11110_" "q11111_"
> 

Kudos, you did it! Now your Raspberry Pi is a 5-qubit quantum simulator.