blua tigro
Gebruiker
- Lid geworden
- 21 apr 2009
- Berichten
- 48
ik vond dit op internet :
https://quantumexperience.ng.bluemix.net/qx/experience
ik vind t erg interessant
ik wil dit in c++ maken
ik weet echter niet of ik dit [ ooit ] begijpen zal
ik programeer al +-30 jaar klasieke computer's
ik heb nu dit :
https://quantumexperience.ng.bluemix.net/qx/experience
ik vind t erg interessant
ik wil dit in c++ maken
ik weet echter niet of ik dit [ ooit ] begijpen zal
ik programeer al +-30 jaar klasieke computer's
ik heb nu dit :
Code:
// bluatigro 8 nov 2017
// QC sim
// see :
// https://quantumexperience.ng.bluemix.net/qx/experience
#include <iostream>
#include <string>
#include <math.h>
void rot( double & k , double & l , double r)
{
double s , c , hk , hl ;
s = sin( r ) ;
c = cos( r ) ;
hk = k * c - l * s ;
hl = k * s + l * c ;
k = hk ;
l = hl ;
}
const double PI = atn( 1.0 ) * 4.0 ;
class Qbit
{
public :
double x , y , z ;
Qbit() // |0>
{
x = 0.0 ;
y = 0.0 ;
z = 1.0 ;
}
Qbit( double a , double b , double c )
{
x = a ;
y = b ;
z = c ;
}
void X()
{
rot( y , z , PI ) ;
}
void Y()
{
rot( x , z , PI ) ;
}
void Z()
{
rot( x , y , PI ) ;
}
void H() // |+>
{
;
}
void S()
{
rot( x , y , PI / 2 ) ;
}
void S1()
{
rot( x , y , -PI / 2 ) ;
}
void T()
{
rot( x , y , PI / 4 ) ;
}
void T1()
{
rot( x , y , -PI / 4 ) ;
}
double get_state()
{
return z < 0.0 ? 1.0 : 0.0 ;
}
} ;
void cnot( Qbit & control , Qbit & target )
{
if ( control.get_state() == 1.0 )
target.z = 1.0 - target.z ;
}
using namespace std ;
int main()
{
cout << "Hello world!" << endl;
return 0;
}