demoII5_6.cpp
Upload User: husern
Upload Date: 2018-01-20
Package Size: 42486k
Code Size: 2k
Category:

Game Program

Development Platform:

Visual C++

  1. // DEMOII5_6.CPP - Linear System Equation solver
  2. // INCLUDES ///////////////////////////////////////////////////
  3. #define WIN32_LEAN_AND_MEAN  
  4. #ifndef INITGUID
  5. #define INITGUID       // you need this or DXGUID.LIB
  6. #endif
  7. #include <windows.h>   // include important windows stuff
  8. #include <windowsx.h> 
  9. #include <mmsystem.h>
  10. #include <objbase.h>
  11. #include <iostream.h> // include important C/C++ stuff
  12. #include <conio.h>
  13. #include <stdlib.h>
  14. #include <malloc.h>
  15. #include <memory.h>
  16. #include <string.h>
  17. #include <stdarg.h>
  18. #include <stdio.h>
  19. #include <math.h>
  20. #include <io.h>
  21. #include <fcntl.h>
  22. #include <direct.h>
  23. #include <wchar.h>
  24. #include <ddraw.h>      // needed for defs in T3DLIB1.H 
  25. #include "T3DLIB1.H"    // T3DLIB4 is based on some defs in this 
  26. #include "T3DLIB4.H"
  27. // DEFINES ////////////////////////////////////////////////////
  28. // TYPES //////////////////////////////////////////////////////
  29. // CLASSES ////////////////////////////////////////////////////
  30. // GLOBALS ////////////////////////////////////////////////////
  31. // define vars expected by graphics engine to compile
  32. HWND main_window_handle;
  33. // FUNCTIONS //////////////////////////////////////////////////
  34. void main()
  35. {
  36. MATRIX2X2 mA;
  37. MATRIX1X2 mB;
  38. MATRIX1X2 mX; 
  39. // open the error system, so we can see output
  40. // notice the last parameter "stdout" this tell the error
  41. // system that we don't want to write errors to a text file
  42. // but straight out to the screen!
  43. Open_Error_File("", stdout);
  44. while(1) {
  45. printf("n2D Linear System Solvern");
  46. // get matrix A
  47. printf("nEnter the values for the matrix A (2x2)");
  48. printf("nin row major form m00, m01, m10, m11?");
  49. scanf("%f, %f, %f, %f", &mA.M00, &mA.M01, &mA.M10, &mA.M11);
  50. printf("nEnter the values for matrix B (2x1)");
  51. printf("nin column major form m00, m10?");
  52. scanf("%f, %f", &mB.M00, &mB.M01);
  53. // techically you can't multiply a 2x2 * 1x2, 
  54. // but you can multiply is a 2x2 * (1x2)t
  55. // that is the transpose of a 1x2 is a 2x1, 
  56. // bottom line is the B matrix is just 2 numbers!
  57. // now solve the system
  58. if (Solve_2X2_System(&mA, &mX, &mB))
  59.    {
  60.    // now print results
  61.    VECTOR2D_Print((VECTOR2D_PTR)&mX, "Solution matrix mX");
  62.    } // end if
  63. else
  64.     printf("nNo Solution!");
  65. } // end while
  66. // close the error system
  67. Close_Error_File();
  68. } // end main