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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. using complex template functions

using complex template functions

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
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.
  • O Offline
    O Offline
    oRion
    wrote on last edited by
    #1

    I have stumbled across this function "conjg" in the complex class template. But I don't seems to be able to access it. Any kind soul can tell me how to access this function? Thanks in advance! :confused:

    P S 2 Replies Last reply
    0
    • O oRion

      I have stumbled across this function "conjg" in the complex class template. But I don't seems to be able to access it. Any kind soul can tell me how to access this function? Thanks in advance! :confused:

      P Offline
      P Offline
      peterchen
      wrote on last edited by
      #2

      #include void foo()
      {
      using namespace std;
      complex cX(1.0, 1.0);
      complex double cY = cX.conjg();
      _ASSERTE(cX.imag() == -cY.imag());
      }


      You don't need to sleep to see a nightmare  Anne Clark   [sighist]

      O 1 Reply Last reply
      0
      • P peterchen

        #include void foo()
        {
        using namespace std;
        complex cX(1.0, 1.0);
        complex double cY = cX.conjg();
        _ASSERTE(cX.imag() == -cY.imag());
        }


        You don't need to sleep to see a nightmare  Anne Clark   [sighist]

        O Offline
        O Offline
        oRion
        wrote on last edited by
        #3

        Thanks for the reply. I can't seems to get it compile under VC++ 6.0 Here's what I have attempted to do. #include #include using namespace std; void main() { complex abc; double myvar = abc.conjg(); cout << myvar; } When I tried complied it... the error is as follows.. error C2039: 'conjg' : is not a member of 'complex' What's wrong here? It's seems that conjg is not visible in the class? :confused::confused:

        1 Reply Last reply
        0
        • O oRion

          I have stumbled across this function "conjg" in the complex class template. But I don't seems to be able to access it. Any kind soul can tell me how to access this function? Thanks in advance! :confused:

          S Offline
          S Offline
          Sijin
          wrote on last edited by
          #4

          From MSDN// complex_conj.cpp // compile with: /EHsc #include #include int main( ) { using namespace std; complex c1 ( 4.0 , 3.0 ); cout << "The complex number c1 = " << c1 << endl; double dr1 = real ( c1 ); cout << "The real part of c1 is real ( c1 ) = " << dr1 << "." << endl; double di1 = imag ( c1 ); cout << "The imaginary part of c1 is imag ( c1 ) = " << di1 << "." << endl; complex c2 = conj ( c1 ); cout << "The complex conjugate of c1 is c2 = conj ( c1 )= " << c2 << endl; double dr2 = real ( c2 ); cout << "The real part of c2 is real ( c2 ) = " << dr2 << "." << endl; double di2 = imag ( c2 ); cout << "The imaginary part of c2 is imag ( c2 ) = " << di2 << "." << endl; // The real part of the product of a complex number // and its conjugate is the norm of the number complex c3 = c1 * c2; cout << "The norm of (c1 * conj (c1) ) is c1 * c2 = " << real( c3 ) << endl; } Output The complex number c1 = (4,3) The real part of c1 is real ( c1 ) = 4. The imaginary part of c1 is imag ( c1 ) = 3. The complex conjugate of c1 is c2 = conj ( c1 )= (4,-3) The real part of c2 is real ( c2 ) = 4. The imaginary part of c2 is imag ( c2 ) = -3. The norm of (c1 * conj (c1) ) is c1 * c2 = 25
          May the Source be with you Sonork ID 100.9997 sijinjoseph

          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