Posts

Showing posts from October 18, 2018

Get container directory more easily

Image
Clash Royale CLAN TAG #URR8PPP up vote 0 down vote favorite I have a bash script here: $GOPATH/ src/ build.sh and in build.sh I have: export GOPATH="$(cd $(dirname "$BASH_SOURCE") && pwd)" is there a shorter way to get the containing dir of build.sh? bash shell pwd basename dirname share asked 3 mins ago Alexander Mills 2,067 11 33 add a comment  |  up vote 0 down vote favorite I have a bash script here: $GOPATH/ src/ build.sh and in build.sh I have: export GOPATH="$(cd $(dirname "$BASH_SOURCE") && pwd)" is there a shorter way to get the containing dir of build.sh? bash shell pwd basename dirname share asked 3 mins ago Alexander Mills 2,067 11 33 add a comment  |  up vote 0 down vote favorite up vote 0 down vote favorite I have a bash script here: $GOPATH/ src/ build.sh and in build.sh I have: export GOPAT

What is the matrix for the operator that implements a function to tell the parity of its argument?

Image
Clash Royale CLAN TAG #URR8PPP up vote 2 down vote favorite 1 $newcommandqr[1]$ I gave myself the task of building an operator that implements the following function: $f(0) = 0$ , $f(1) = 1$ , $f(2) = 1$ , $f(3) = 0$ . I restricted myself to $x$ up to 2 bits. That is, $f$ tells the parity of its argument. I read that in order to be reversible, a circuit $U_f$ could be defined to have the following effect: $U_fqrx_2 qr0_1 to qrx_2qr0 oplus f(x)_1$ . After doing my calculations, I think the following matrix represents $U_f$ $$beginbmatrix 1 & 0 & 0 & 0\ 0 & 1 & 1 & 0\ 0 & 0 & 0 & 0\ 0 & 0 & 0 & 0 endbmatrix otimes I_2$$ However, I'm really not sure. I once read that this definition isn't complete, that I should also define the behavior for the input $qrx_2qr1$ . (I'm not too clear on that.) So --- though confused ---, I went ahead and defined $$U_fqrx_2 qr1_1 to qrx_2qr1 oplus f(x)_1.$$ Doing my calculations ag