From: <dd...@us...> - 2003-01-31 03:08:08
|
Update of /cvsroot/babylonlib/_SrcPool/Cpp/Samples/Complex/Src In directory sc8-pr-cvs1:/tmp/cvs-serv22909/Cpp/Samples/Complex/Src Modified Files: StdAfx.h TestApp.cpp TsComplex.cpp Log Message: Replaced BOOL with bool Index: StdAfx.h =================================================================== RCS file: /cvsroot/babylonlib/_SrcPool/Cpp/Samples/Complex/Src/StdAfx.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StdAfx.h 28 Jan 2003 05:46:55 -0000 1.1 --- StdAfx.h 31 Jan 2003 03:08:05 -0000 1.2 *************** *** 1,20 **** ! // StdAfx.h : include file for standard system include files, ! // or project specific include files that are used frequently, but ! // are changed infrequently ! // ! ! #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers ! #define _AFX_NO_BSTR_SUPPORT //Bug fix: BSTR Redefinition generates error C2371 (article Q132966) ! ! #include <AfxWin.h> // MFC core and standard components ! #include <AfxExt.h> // MFC extensions ! #ifndef _AFX_NO_AFXCMN_SUPPORT ! #include <AfxCmn.h> // MFC support for Windows 95 Common Controls ! #endif // _AFX_NO_AFXCMN_SUPPORT ! ! #pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ ) ! ! /////////////////////////////////////////////////////////////////////////////// ! //Function declarations ! BOOL TestComplex(); ! void TestPointToComplex(CPoint& ptPos); --- 1,20 ---- ! // StdAfx.h : include file for standard system include files, ! // or project specific include files that are used frequently, but ! // are changed infrequently ! // ! ! #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers ! #define _AFX_NO_BSTR_SUPPORT //Bug fix: BSTR Redefinition generates error C2371 (article Q132966) ! ! #include <AfxWin.h> // MFC core and standard components ! #include <AfxExt.h> // MFC extensions ! #ifndef _AFX_NO_AFXCMN_SUPPORT ! #include <AfxCmn.h> // MFC support for Windows 95 Common Controls ! #endif // _AFX_NO_AFXCMN_SUPPORT ! ! #pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ ) ! ! /////////////////////////////////////////////////////////////////////////////// ! //Function declarations ! bool TestComplex(); ! void TestPointToComplex(CPoint& ptPos); Index: TestApp.cpp =================================================================== RCS file: /cvsroot/babylonlib/_SrcPool/Cpp/Samples/Complex/Src/TestApp.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestApp.cpp 28 Jan 2003 05:46:55 -0000 1.1 --- TestApp.cpp 31 Jan 2003 03:08:05 -0000 1.2 *************** *** 1,134 **** ! // Test.cpp : Defines the class behaviors for the application. ! // ! // Darko Kolakovic ! // Jan. 2k ! ! #include "StdAfx.h" ! #include "TestApp.h" ! ! #include "MainFrm.h" ! #include "TestDoc.h" ! #include "TestView.h" ! ! #ifdef _DEBUG ! #define new DEBUG_NEW ! #undef THIS_FILE ! static char THIS_FILE[] = __FILE__; ! #endif ! ! #if _MSC_VER == 1000 ! #pragma message ("Microsoft Visual C++ 4.0") ! #if _MFC_VER == 0x400 ! #pragma message ("MFC 4.0") ! #pragma message ("Support for Win32s included") ! #endif ! #endif ! ! #if _MSC_VER == 1200 ! #pragma message ("Microsoft Visual C++ 6.0") ! #if _MFC_VER == 0x600 ! #pragma message ("MFC 4.2") ! #endif ! #endif ! ! ///////////////////////////////////////////////////////////////////////////// ! // CTestApp ! ! BEGIN_MESSAGE_MAP(CTestApp, CWinApp) ! //{{AFX_MSG_MAP(CTestApp) ! ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ! //}}AFX_MSG_MAP ! // Standard file based document commands ! END_MESSAGE_MAP() ! ! ///////////////////////////////////////////////////////////////////////////// ! ! //::CTestApp()------------------------------------------------------------- ! /*CTestApp construction ! */ ! CTestApp::CTestApp() ! { ! } ! ! ///////////////////////////////////////////////////////////////////////////// ! // The one and only CTestApp object ! CTestApp theApp; ! ! ///////////////////////////////////////////////////////////////////////////// ! // CTestApp initialization ! ! //::InitInstance()------------------------------------------------------------- ! /*Instance initialization that runs each time a copy of the program runs, ! including the first time. The frameworks implementation of WinMain calls ! this function. ! ! Note: The following Win32 features are not currently supported for Win32s ! ! MAPI ! RPC ! Console APIs ! Unicode APIs (Win32s does support Code Page/Unicode translation APIs) ! Security APIs ! Comm APIs ! Asynchronous File I/O ! Threads ! Paths (graphics object) ! Enhanced Metafiles ! Bezier curves ! */ ! BOOL CTestApp::InitInstance() ! { ! // Standard initialization ! ! LoadStdProfileSettings(0); // Load standard INI file options (including MRU) ! ! // Register document templates ! ! CSingleDocTemplate* pDocTemplate; ! pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME, ! RUNTIME_CLASS(CTestDoc), ! RUNTIME_CLASS(CMainFrame), // main SDI frame window ! RUNTIME_CLASS(CTestView)); ! AddDocTemplate(pDocTemplate); ! EnableShellOpen(); //Enable DDE Execute open ! // Parse command line for standard shell commands, DDE, file open ! CCommandLineInfo cmdInfo; ! ParseCommandLine(cmdInfo); ! ! // Dispatch commands specified on the command line ! // Create new document, main frame and view object, initialize m_pMainWnd ! if (!ProcessShellCommand(cmdInfo)) ! return FALSE; ! //Execute initial testing ! if (!DoTestInit()) ! return FALSE; ! return TRUE; ! } ! ! ! /////////////////////////////////////////////////////////////////////////////// ! // Operations ! ! //::DoTestInit()--------------------------------------------------------------- ! /*Execute a test during instance initialization. ! Returns FALSE if testing is unsuccesfull. ! */ ! BOOL CTestApp::DoTestInit() ! { ! //Evaluate complex numbers operations ! return TestComplex(); ! } ! ! ///////////////////////////////////////////////////////////////////////////// ! // CTestApp commands ! ! ! //::OnAppAbout()---------------------------------------------------------------- ! #include "TestAbout.h" //CAboutDlg class ! /*Open About dialog box ! */ ! void CTestApp::OnAppAbout() ! { ! CAboutDlg aboutDlg; ! aboutDlg.DoModal(); ! } --- 1,141 ---- ! // Test.cpp : Defines the class behaviors for the application. ! // ! // Darko Kolakovic ! // Jan. 2k ! ! #include "StdAfx.h" ! #include "TestApp.h" ! ! #include "MainFrm.h" ! #include "TestDoc.h" ! #include "TestView.h" ! ! #ifdef _DEBUG ! #define new DEBUG_NEW ! #undef THIS_FILE ! static char THIS_FILE[] = __FILE__; ! #endif ! ! #if _MSC_VER == 1000 ! #pragma message ("Microsoft Visual C++ 4.0") ! #if _MFC_VER == 0x400 ! #pragma message ("MFC 4.0") ! #pragma message ("Support for Win32s included") ! #endif ! #endif ! ! #if _MSC_VER == 1200 ! #pragma message ("Microsoft Visual C++ 6.0") ! #if _MFC_VER == 0x600 ! #pragma message ("MFC 4.2") ! #endif ! #endif ! ! #if _MSC_VER == 1300 ! #pragma message ("Microsoft Visual C++.Net 7.0") ! #if _MFC_VER == 0x600 ! #pragma message ("MFC 4.2") ! #endif ! #endif ! ! ///////////////////////////////////////////////////////////////////////////// ! // CTestApp ! ! BEGIN_MESSAGE_MAP(CTestApp, CWinApp) ! //{{AFX_MSG_MAP(CTestApp) ! ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ! //}}AFX_MSG_MAP ! // Standard file based document commands ! END_MESSAGE_MAP() ! ! ///////////////////////////////////////////////////////////////////////////// ! ! //::CTestApp()------------------------------------------------------------- ! /*CTestApp construction ! */ ! CTestApp::CTestApp() ! { ! } ! ! ///////////////////////////////////////////////////////////////////////////// ! // The one and only CTestApp object ! CTestApp theApp; ! ! ///////////////////////////////////////////////////////////////////////////// ! // CTestApp initialization ! ! //::InitInstance()------------------------------------------------------------- ! /*Instance initialization that runs each time a copy of the program runs, ! including the first time. The frameworks implementation of WinMain calls ! this function. ! ! Note: The following Win32 features are not currently supported for Win32s ! ! MAPI ! RPC ! Console APIs ! Unicode APIs (Win32s does support Code Page/Unicode translation APIs) ! Security APIs ! Comm APIs ! Asynchronous File I/O ! Threads ! Paths (graphics object) ! Enhanced Metafiles ! Bezier curves ! */ ! BOOL CTestApp::InitInstance() ! { ! // Standard initialization ! ! LoadStdProfileSettings(0); // Load standard INI file options (including MRU) ! ! // Register document templates ! ! CSingleDocTemplate* pDocTemplate; ! pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME, ! RUNTIME_CLASS(CTestDoc), ! RUNTIME_CLASS(CMainFrame), // main SDI frame window ! RUNTIME_CLASS(CTestView)); ! AddDocTemplate(pDocTemplate); ! EnableShellOpen(); //Enable DDE Execute open ! // Parse command line for standard shell commands, DDE, file open ! CCommandLineInfo cmdInfo; ! ParseCommandLine(cmdInfo); ! ! // Dispatch commands specified on the command line ! // Create new document, main frame and view object, initialize m_pMainWnd ! if (!ProcessShellCommand(cmdInfo)) ! return FALSE; ! //Execute initial testing ! if (!DoTestInit()) ! return FALSE; ! return TRUE; ! } ! ! ! /////////////////////////////////////////////////////////////////////////////// ! // Operations ! ! //::DoTestInit()--------------------------------------------------------------- ! /*Execute a test during instance initialization. ! Returns FALSE if testing is unsuccesfull. ! */ ! BOOL CTestApp::DoTestInit() ! { ! //Evaluate complex numbers operations ! return TestComplex(); ! } ! ! ///////////////////////////////////////////////////////////////////////////// ! // CTestApp commands ! ! ! //::OnAppAbout()---------------------------------------------------------------- ! #include "TestAbout.h" //CAboutDlg class ! /*Open About dialog box ! */ ! void CTestApp::OnAppAbout() ! { ! CAboutDlg aboutDlg; ! aboutDlg.DoModal(); ! } Index: TsComplex.cpp =================================================================== RCS file: /cvsroot/babylonlib/_SrcPool/Cpp/Samples/Complex/Src/TsComplex.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TsComplex.cpp 30 Jan 2003 03:39:44 -0000 1.2 --- TsComplex.cpp 31 Jan 2003 03:08:05 -0000 1.3 *************** *** 12,15 **** --- 12,16 ---- #include "stdafx.h" #include "KComplex.h" //CComplex class + #include "KTestLog.h" //TESTENTRY struct #ifdef _DEBUG *************** *** 32,39 **** bool TestComplex() { ! CString strResult; ! #ifdef _COMPLEX_DEFINED //included <Math.h> ! //Complex number as structure defined in <Math.h> TsWriteToView(_T("_cabs() calculates the absolute value of a _complex number.\r\n")); _complex B; --- 33,45 ---- bool TestComplex() { ! TCHAR szText[512]; ! bool bRes = true; ! TESTENTRY logEntry = ! {_T("CComplex"), _T("KComplex.h"), false}; ! TESTENTRY logEntryBase = ! {_T("TComplexBase"), _T("KComplxB.h"), false}; ! #ifdef _COMPLEX_DEFINED //included <math.h> ! //Complex number as structure defined in <math.h> TsWriteToView(_T("_cabs() calculates the absolute value of a _complex number.\r\n")); _complex B; *************** *** 45,56 **** if ( dRho != HUGE_VAL) //Check for overflow { ! strResult.Format(_T("|B| = |%.2f+i%.2f| = %.2f\r\n"),B.x,B.y,dRho); ! TsWriteToView((LPCTSTR)strResult); } #else //<Math.h> not included TsWriteToView(_T("Complex numbers are not supported.\r\n")); TComplexBase<double>B(3.2,4.2); //Initialize B = x +iy #endif //_COMPLEX_DEFINED #ifdef __STD_COMPLEX //included <complex> --- 51,68 ---- if ( dRho != HUGE_VAL) //Check for overflow { ! _stprintf(szText, _T("|B| = |%.2f+i%.2f| = %.2f\r\n"),B.x,B.y,dRho); ! TsWriteToView(szText); } + + logEntryBase.m_bResult = true; + logEntryBase.m_szObjectName = _T("_complex"); #else //<Math.h> not included TsWriteToView(_T("Complex numbers are not supported.\r\n")); TComplexBase<double>B(3.2,4.2); //Initialize B = x +iy + + logEntryBase.m_bResult = true; #endif //_COMPLEX_DEFINED + LogTest(&logEntryBase); #ifdef __STD_COMPLEX //included <complex> *************** *** 60,68 **** std::complex<int> A(5,6); A << B; //Copy complex numbers ! strResult.Format(_T("std::complex<int> A = (int)B = %d+i%d\r\n"),A.real(),A.imag()); ! TsWriteToView((LPCTSTR)strResult); //The std::abs(A) function returns the magnitude of A ! strResult.Format(_T("|%d+i%d| = %d\r\n"),A.real(),A.imag(),std::abs(A)); ! TsWriteToView((LPCTSTR)strResult); #else //<complex> not included TComplexBase<double>A(5,6); //Initialize A = x +iy --- 72,82 ---- std::complex<int> A(5,6); A << B; //Copy complex numbers ! _stprintf(szText, _T("std::complex<int> A = (int)B = %d+i%d\r\n"),A.real(),A.imag()); ! TsWriteToView(szText); //The std::abs(A) function returns the magnitude of A ! _stprintf(szText, _T("|%d+i%d| = %d\r\n"),A.real(),A.imag(),std::abs(A)); ! TsWriteToView(szText); ! logEntryBase.m_szObjectName = _T("std::complex"); ! logEntryBase.m_bResult = true; #else //<complex> not included TComplexBase<double>A(5,6); //Initialize A = x +iy *************** *** 71,78 **** A1 = 56; //A1 = CONST + i0 A1 /= 4; ! strResult.Format(_T("|%.2f+i%.2f| = %.2f\r\n"),A1.real(),A1.imag(),abs(A1)); ! TsWriteToView((LPCTSTR)strResult); #endif //__STD_COMPLEX CComplex C(B.x, B.y); C = B; --- 85,95 ---- A1 = 56; //A1 = CONST + i0 A1 /= 4; ! _stprintf(szText, _T("|%.2f+i%.2f| = %.2f\r\n"),A1.real(),A1.imag(),abs(A1)); ! TsWriteToView(szText); ! logEntryBase.m_bResult = true; #endif //__STD_COMPLEX + LogTest(&logEntryBase); + CComplex C(B.x, B.y); C = B; *************** *** 80,92 **** CComplex D(-4.3,6.1); ! strResult.Format(_T("C = %f+i%f D = %f+i%f "),C.real(),C.imag(),D.real(),D.imag()); ! TsWriteToView((LPCTSTR)strResult); C = D / C ; ! strResult.Format(_T("D/C = %f+i%f\r\n"),C.real(),C.imag()); ! TsWriteToView((LPCTSTR)strResult); ! C = exp10(D); //The function returns exponential of D, for base 10. ! strResult.Format(_T("D E(10) = %f+i%f\r\n"),C.real(),C.imag()); ! TsWriteToView((LPCTSTR)strResult); TComplex<int> A2(-1,7); --- 97,113 ---- CComplex D(-4.3,6.1); ! _stprintf(szText, _T("C = %f+i%f D = %f+i%f "),C.real(),C.imag(),D.real(),D.imag()); ! TsWriteToView(szText); C = D / C ; ! _stprintf(szText, _T("D/C = %f+i%f\r\n"),C.real(),C.imag()); ! TsWriteToView(szText); ! logEntry.m_bResult = true; ! LogTest(&logEntry); ! ! //The function returns exponential of D, for base 10. ! C = exp10(D); ! _stprintf(szText, _T("D E(10) = %f+i%f\r\n"),C.real(),C.imag()); ! TsWriteToView(szText); TComplex<int> A2(-1,7); *************** *** 95,141 **** TRACE2(_T(" A E(10) = %d +j%d\n"),A2.real(),A2.imag()); ! D = CComplex(1.2,2.8); ! strResult.Format(_T("D = %f+i%f\r\n"),D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); ! C = cos(D); //The function returns cosine of D ! strResult.Format(_T("cos(D) = %f+i%f "),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C = acos(C); ! strResult.Format(_T("acos(C) = %f+i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C = sin(D); //The function returns sine of D ! strResult.Format(_T("sin(D) = %f+i%f "),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C = asin(C); ! strResult.Format(_T("asin(C) = %f+i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); TComplex<float> Phi(.94F,1.78F); ! strResult.Format(_T("Phi = %f+i%f\r\n"),Phi.real(),Phi.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); TComplex<float> X = tan(Phi); //The function returns tangent of Phi ! strResult.Format(_T("tan(Phi) = %f+i%f "),X.real(),X.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); X = atan(X); ! strResult.Format(_T("atan(X) = %f+i%f\r\n"),X.real(),X.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); X = tanh(Phi); //The function returns hyperbolic tangent of Phi ! strResult.Format(_T("tanh(Phi) = %f+i%f "),X.real(),X.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); X = atanh(X); ! strResult.Format(_T("atanh(X) = %f+i%f\r\n"),X.real(),X.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); //Dividing two complex numbers --- 116,200 ---- TRACE2(_T(" A E(10) = %d +j%d\n"),A2.real(),A2.imag()); ! logEntry.m_bResult = true; ! logEntry.m_szObjectName = _T("exp10()"); ! LogTest(&logEntry); ! ! //Test acos ! D = CComplex(1.2,2.8); //The function returns cosine of D ! _stprintf(szText, _T("D = %f+i%f\r\n"),D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! C = cos(D); ! _stprintf(szText, _T("cos(D) = %f+i%f "),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); C = acos(C); ! _stprintf(szText, _T("acos(C) = %f+i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! ! bRes = bRes && (C.real() > 1.19999) && (C.real() < 1.20001) && ! (C.imag() > 2.79999) && (C.imag() < 2.80001); //result and previous result ! logEntry.m_bResult = bRes; ! logEntry.m_szObjectName = _T("acos()"); ! LogTest(&logEntry); + //Test asine + D = CComplex(1.2,2.8); C = sin(D); //The function returns sine of D ! _stprintf(szText, _T("sin(D) = %f+i%f "),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); C = asin(C); ! _stprintf(szText, _T("asin(C) = %f+i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! ! bRes = bRes && (C.real() > 1.19999) && (C.real() < 1.20001) && ! (C.imag() > 2.79999) && (C.imag() < 2.80001); //result and previous result ! logEntry.m_bResult = bRes; ! logEntry.m_szObjectName = _T("asin()"); ! LogTest(&logEntry); + //Test atan TComplex<float> Phi(.94F,1.78F); ! _stprintf(szText, _T("Phi = %f+i%f\r\n"),Phi.real(),Phi.imag()); ! TRACE0(szText); ! TsWriteToView(szText); TComplex<float> X = tan(Phi); //The function returns tangent of Phi ! _stprintf(szText, _T("tan(Phi) = %f+i%f "),X.real(),X.imag()); ! TRACE0(szText); ! TsWriteToView(szText); X = atan(X); ! _stprintf(szText, _T("atan(X) = %f+i%f\r\n"),X.real(),X.imag()); ! TRACE0(szText); ! TsWriteToView(szText); + bRes = bRes && (X.real() > 0.93999) && (X.real() < 0.94001) && + (X.imag() > 1.77999) && (X.imag() < 1.78001); //result and previous result + logEntry.m_bResult = bRes; + logEntry.m_szObjectName = _T("tan()"); + LogTest(&logEntry); + logEntry.m_szObjectName = _T("atan()"); + LogTest(&logEntry); + + //Test atanh X = tanh(Phi); //The function returns hyperbolic tangent of Phi ! _stprintf(szText, _T("tanh(Phi) = %f+i%f "),X.real(),X.imag()); ! TRACE0(szText); ! TsWriteToView(szText); X = atanh(X); ! _stprintf(szText, _T("atanh(X) = %f+i%f\r\n"),X.real(),X.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! ! bRes = bRes && (X.real() > 0.93999) && (X.real() < 0.94001) && ! (X.imag() > 1.77999) && (X.imag() < 1.78001); //result and previous result ! logEntry.m_bResult = bRes; ! logEntry.m_szObjectName = _T("tanh()"); ! LogTest(&logEntry); ! logEntry.m_szObjectName = _T("atanh()"); ! LogTest(&logEntry); ! //Dividing two complex numbers *************** *** 144,155 **** D.real( .4); D.imag(- .4); ! strResult.Format(_T("C = %.3f + i%.3f D = %.3f + i%.3f\r\n"), C.real(),C.imag(),D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C/=D; ! strResult.Format(_T("C / D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C.real(-3.2); --- 203,214 ---- D.real( .4); D.imag(- .4); ! _stprintf(szText, _T("C = %.3f + i%.3f D = %.3f + i%.3f\r\n"), C.real(),C.imag(),D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); C/=D; ! _stprintf(szText, _T("C / D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); C.real(-3.2); *************** *** 158,164 **** C *= conj(D); C /= dTemp; ! strResult.Format(_T("C / D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); //Multiplying two complex numbers --- 217,223 ---- C *= conj(D); C /= dTemp; ! _stprintf(szText, _T("C / D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); //Multiplying two complex numbers *************** *** 166,172 **** C.imag(-4.8); C *= D; ! strResult.Format(_T("C * D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C.real(-3.2); --- 225,231 ---- C.imag(-4.8); C *= D; ! _stprintf(szText, _T("C * D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); C.real(-3.2); *************** *** 175,193 **** C.imag(C.imag()*D.real() + C.real()*D.imag()); C.real(dTemp); ! strResult.Format(_T("C * D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); if (C != D) //Test comparison { D = sqrt(C); //Test square root function ! strResult.Format(_T("D = C**0.5 = %f + i%f\r\n"),D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); C = pow(D,2); ! strResult.Format(_T("D**2 = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); } --- 234,252 ---- C.imag(C.imag()*D.real() + C.real()*D.imag()); C.real(dTemp); ! _stprintf(szText, _T("C * D = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); if (C != D) //Test comparison { D = sqrt(C); //Test square root function ! _stprintf(szText, _T("D = C**0.5 = %f + i%f\r\n"),D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); C = pow(D,2); ! _stprintf(szText, _T("D**2 = %f + i%f\r\n"),C.real(),C.imag()); ! TRACE0(szText); ! TsWriteToView(szText); } *************** *** 195,218 **** double dEff = 48; D = polar(dEff); ! strResult.Format(_T("Rho = %.0f D = %f + i%f\r\n"),dEff,D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); dEff = 220; int iNom = 3; double dPhi = CST_PI/iNom; D = polar(dEff,dPhi); //D = 220*e(i*60[deg]) ! strResult.Format(_T("D = %.0fe**(i3.14/%d) = %f + i%f\r\n"),dEff,iNom,D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); D = logN(C,2); //Returns the logarithm to base 2 ! strResult.Format(_T("D = log2(C) = %f + i%f\r\n"),D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); D = acoth(C); //Returns the hyperbolic arcus cosecant ! strResult.Format(_T("acoth(C) = %f + i%f\r\n"),D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); //Calculate line input impedance --- 254,287 ---- double dEff = 48; D = polar(dEff); ! _stprintf(szText, _T("Rho = %.0f D = %f + i%f\r\n"),dEff,D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); dEff = 220; int iNom = 3; double dPhi = CST_PI/iNom; D = polar(dEff,dPhi); //D = 220*e(i*60[deg]) ! _stprintf(szText, _T("D = %.0fe**(i3.14/%d) = %f + i%f\r\n"),dEff,iNom,D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); + //Test log2 D = logN(C,2); //Returns the logarithm to base 2 ! _stprintf(szText, _T("D = log2(C) = %f + i%f\r\n"),D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! logEntryBase.m_bResult = true; ! logEntryBase.m_szObjectName = _T("logN()"); ! logEntryBase.m_szFileName = _T("KMathCst.inl"); ! LogTest(&logEntryBase); + //Test acoth D = acoth(C); //Returns the hyperbolic arcus cosecant ! _stprintf(szText, _T("acoth(C) = %f + i%f\r\n"),D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! ! logEntry.m_bResult = bRes; ! logEntry.m_szObjectName = _T("acoth()"); ! LogTest(&logEntry); //Calculate line input impedance *************** *** 223,257 **** D = GetLineZin(C, CComplex(50.0,0), 2.5,CST_PI/2.,10); ! strResult.Format(_T("Load = %f + i%f, Zin = %f + i%f\r\n"), C.real(),C.imag(),D.real(),D.imag()); ! TRACE0((LPCTSTR)strResult); ! TsWriteToView((LPCTSTR)strResult); ! return TRUE; ! } //TestPointToComplex()------------------------------------------------------ /*Test conversion from CPoint to complex number */ ! void TestPointToComplex(CPoint& ptPos) ! { ! CComplex ccPos = ptPos; ! double dRho; //magnitude ! double dAngle; //phase angle ! dRho = ccPos.Rho(); //The function returns the magnitude of ccPos ! dAngle = ccPos.Angle(); //The function returns the phase angle of ccPos ! TRACE2(_T("ccPos = %f e(j%f)\n"),abs(ccPos),arg(ccPos)); ! TsWriteToView(_T("Mouse position is ")); ! CString strResult; ! strResult.Format(_T("%.2f+i%.2f = %.2fe(i%.2f)\r\n"),ccPos.real(),ccPos.imag(),dRho,dAngle); ! TsWriteToView((LPCTSTR)strResult); ! } /////////////////////////////////////////////////////////////////////////////// /***************************************************************************** * $Log: * 4 Biblioteka1.3 22/01/2003 10:22:35 PMDarko * 3 Biblioteka1.2 20/01/2003 3:15:32 AMDarko Replaced BOOL --- 292,370 ---- D = GetLineZin(C, CComplex(50.0,0), 2.5,CST_PI/2.,10); ! _stprintf(szText, _T("Load = %f + i%f, Zin = %f + i%f\r\n"), C.real(),C.imag(),D.real(),D.imag()); ! TRACE0(szText); ! TsWriteToView(szText); ! logEntryBase.m_bResult = (D.real() > 49.68300) && (D.real() < 49.68500) && ! (D.imag() > -0.00001) && (D.imag() < 0.00001); //result and previous result ! logEntryBase.m_bResult = true; ! logEntryBase.m_szObjectName = _T("GetLineZin()"); ! logEntryBase.m_szFileName = _T("KZLineIn.cpp"); ! LogTest(&logEntryBase); ! bRes = bRes && logEntryBase.m_bResult; + return bRes; + } //TestPointToComplex()------------------------------------------------------ /*Test conversion from CPoint to complex number */ ! #ifndef _CONSOLE //GUI application ! bool TestPointToComplex(CPoint& ptPos //[in] current pointer position ! ) ! { ! bool bRes = true; ! CComplex ccPos = ptPos; ! double dRho; //magnitude ! double dAngle; //phase angle ! dRho = ccPos.Rho(); //The function returns the magnitude of ccPos ! dAngle = ccPos.Angle(); //The function returns the phase angle of ccPos ! TRACE2(_T("ccPos = %f e(j%f)\n"),abs(ccPos),arg(ccPos)); ! TsWriteToView(_T("Mouse position is ")); ! TCHAR szText[512]; ! _stprintf(szText, _T("%.2f+i%.2f = %.2fe(i%.2f)\r\n"),ccPos.real(),ccPos.imag(),dRho,dAngle); ! TsWriteToView(szText); ! return bRes; ! } ! #else ! bool TestPointToComplex() ! { ! bool bRes = true; ! TESTENTRY logEntry = ! {_T("CComplex"), _T("KComplex.h"), false}; ! ! CComplex ccPos(220,50); ! double dRho; //magnitude ! double dAngle; //phase angle ! ! dRho = ccPos.Rho(); //The function returns the magnitude of ccPos ! bRes = (dRho > 225.61028) && (dRho < 225.610285); ! logEntry.m_bResult = bRes; ! logEntry.m_szObjectName = _T("Rho()"); ! LogTest(&logEntry); ! ! dAngle = ccPos.Angle(); //The function returns the phase angle of ccPos ! logEntry.m_bResult = (dAngle > 0.22340) && (dAngle < 0.22349); ! logEntry.m_szObjectName = _T("Angle()"); ! LogTest(&logEntry); ! bRes = bRes && logEntry.m_bResult; ! ! TRACE2(_T("ccPos = %f e(j%f)\n"),abs(ccPos),arg(ccPos)); ! TsWriteToView(_T("Coordinates are ")); ! TCHAR szText[512]; ! _stprintf(szText, _T("%.2f+i%.2f = %.2fe(i%.2f)\r\n"),ccPos.real(),ccPos.imag(),dRho,dAngle); ! TsWriteToView(szText); ! return bRes; ! } ! #endif //_CONSOLE /////////////////////////////////////////////////////////////////////////////// /***************************************************************************** * $Log: + * 5 Biblioteka1.4 30/01/2003 9:47:32 PMDarko Write results + * to the test log * 4 Biblioteka1.3 22/01/2003 10:22:35 PMDarko * 3 Biblioteka1.2 20/01/2003 3:15:32 AMDarko Replaced BOOL |