Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Quantum Computing sim ?

Quantum Computing sim ?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bluatigro
    wrote on last edited by
    #1

    this is verry interesting :

    Quote:

    https://quantumexperience.ng.bluemix.net/qx/experience

    i tryed to get it in c++ its a start i been programming clasical computers for +-30 year's i not even shure i wil understad this [ if ever ]

    // bluatigro 8 nov 2017
    // QC sim
    // see :
    // https://quantumexperience.ng.bluemix.net/qx/experience

    #include #include #include 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;
    }

    CPalliniC D 2 Replies Last reply
    0
    • B bluatigro

      this is verry interesting :

      Quote:

      https://quantumexperience.ng.bluemix.net/qx/experience

      i tryed to get it in c++ its a start i been programming clasical computers for +-30 year's i not even shure i wil understad this [ if ever ]

      // bluatigro 8 nov 2017
      // QC sim
      // see :
      // https://quantumexperience.ng.bluemix.net/qx/experience

      #include #include #include 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;
      }

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Well it is a bunch of strange and unused stuff and then the classical C++ greeting to the world. :-D

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • B bluatigro

        this is verry interesting :

        Quote:

        https://quantumexperience.ng.bluemix.net/qx/experience

        i tryed to get it in c++ its a start i been programming clasical computers for +-30 year's i not even shure i wil understad this [ if ever ]

        // bluatigro 8 nov 2017
        // QC sim
        // see :
        // https://quantumexperience.ng.bluemix.net/qx/experience

        #include #include #include 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;
        }

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Okay, and? :confused:

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        B 1 Reply Last reply
        0
        • D David Crow

          Okay, and? :confused:

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          B Offline
          B Offline
          bluatigro
          wrote on last edited by
          #4

          this is what i understand of does it look right / match what the site gives ? if error's : where / what else i have NO experiance whit a QC how to use my c++ stuf whit a example from the ibm site ?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups