Math 157: Assignment 5

Assigned Friday, Jan. 30, 2009, due Friday, Feb. 6, 2009

Midterm Friday February 6, 2009, closed book, closed notes.


Written Problems

[1] In this course we are building an application that uses numerical methods to solve differential equations and display the solutions to a user. These methods are used because they work for very general types of differential equations. However, if one restricts the types of differential equations that a user can specify it's possible to create an application that uses "analytical" techniques (methods that you learned about in Math 33B) to solve the differential equations. In this problem you will be creating a class structure that enables one to create applications that use an "analytic" technique to solve nth order, linear, homogeneous, constant coefficient differential equations. The analytic solution technique is that described on the sheet "Problem [1] background information".

[a] Give a class description (indicating data members and member functions) for a class that represents an nth order, linear, homogeneous, constant coefficient differential equation. Your class description may include associations to other classes.

[b] Give a class description (indicating data members and member functions) for a polynomial function class that possesses the functionality required by an application that will use the analytic solution procedure to construct solutions of the differential equation. Your class description may include associations to other classes.

[c] Give a class description (indicating data members and member functions) for a matrix class that possess the functionality required by an application that will use the analytic solution procedure to construct solutions of the differential equation. Your class description may include associations to other classes.

[d] Give a class diagram that would enable you to create a console program that allows a user to specify an nth order linear, constant coefficient, homogenous, ODE and display the results. In addition to the classes you identified in [1][a]-[c], you may (and should) introduce additional classes.

[2] True or False

(a) _____Class diagrams indicate the computations within a system.

(b) _____When you assign a derived class pointer to a base class pointer, you can access the derived class's member functions using that base class pointer.

(c) _____If a member function of a derived class overrides a base class member function for which the keyword virtual is not specified, then the derived class will not compile.

(d) _____The location of header files incorporated with the #include pre-processor directive can be specified by setting the include file path.

[3] Short Answer :

(a) Why isn't a listing of C++ class declarations equivalent to a class diagram?

(b) One has to make choices when implementing associations in C++. Often one must choose between creating an ordinary association or a composite association.

  1. Give one reason for creating an ordinary association between classes.
  2. Give one reason against creating an ordinary association between classes.
  3. Give one reason for creating a composite association between classes.
  4. Give one reason against creating a composite association between classes.



Computational Work

[Discussion/Preliminaries] The point of this assignment is to familiarize you with the build process that's required when you are using the Qt software from Trolltech for developing user interfaces. In Math 157 we will be using the "open source" version of Qt. This version is not completely integrated into the Visual Studio Integrated Development Environment (IDE) and thus requires a bit of extra effort to use. However, because we are using the open source version, the instructions and procedures described in the class will be the same as the instructions and procedures you will follow if you install the open-source version of Qt on your own computer. Notes concerning the installation of Qt and a link to a cached copy of the Qt source code will be made available on the Math 157 course announcements page.

To do this assignment you will need to download the QtConsoleGraphics repository from https://www.math.ucla.edu/~anderson/157support/ . To use these files, you will need to be on a machine where Qt has been installed. Currently, Qt is only installed on the machines in the back part of the PIC lab. You can tell if Qt is installed by opening up a command prompt window and just typing "assistant". This will bring up the Qt documentation browser.

(a) Build and run the test program using the Qt development tools

  1. Download the repository QtConsoleGraphics to a directory in your course directory.
  2. Download the test program QtConsoleGraphicsTest.cpp into the QtConsoleGraphics directory
  3. Open up a Visual Studio 2005 Command Prompt window. This program usually has a link in the Start/Programs/Microsoft Visual Studio 2005/Visual Studio Tools pull down menu. You can also invoke the command prompt window by opening up the Visual Studio IDE and selecting "Visual Studio 2005 Command Prompt" from the Tools menu.
  4. In the command prompt window, cd to the QtConsoleGraphics directory and create a Qt ".pro" file by executing the command
    qmake -project
  5. Create the makefiles by executing the command
    qmake
  6. Build the executable using Visual Studio* by executing the command
    nmake
    Note that it is nmake, not make.
    An executable with the prefix QtConsoleGraphics should appear in the subdirectory debug.
  7. Run the executable.
  8. Print a copy of the output, either by saving it to a file in a particular format, or by printing directly.

(b) Rebuild the test program using the QtConsoleGraphics packaged into a library

  1. Create a directory (e.g. Assign5) in your course directory for the test program.
  2. Move the test program QtConsoleGraphicsTest.cpp to the created test program directory.
  3. Build a QtConsoleGraphics support library by opening up a Visual Studio Command Prompt window, cd'ing to the QtConsoleGraphics library and executing the commands
    1. qmake -project -t lib "CONFIG += staticlib"
    2. qmake
    3. nmake

    The result of this process should be a file QtConsoleGraphics.lib in the debug subdirectory of QtConsoleGraphics.

  4. Cd to the directory containing QtConsoleGraphics test program (e.g. Assign 5) and execute the command
    qmake -project
  5. Edit the project file that results (the file with the extension .pro) and specify an additional include path, the library location and the name of the library for the QtConsoleGraphics library. Assuming that your QtConsoleGraphics library is located at the relative location ..\QtConsoleGraphics you would add the lines

    INCLUDEPATH += ..\QtConsoleGraphics
    LIBS += -L..\QtConsoleGraphics\debug -lQtConsoleGraphics


    to your .pro file*.
  6. Execute nmake to build the program
  7. Run the executable to verify that you have built the program correctly.

What You Should Turn In (*) Linux/Max users with Qt installed, just use the command make to build executables and libraries. Linux/Unix builds do not place executables and constructed libraries in a debug or release subdirectory. Also, when one builds a static library using Linux/Unix it is given the ".a" extension, so when hunting for the location of the QtConsoleGraphics library file (in order to specify it in the .pro file), look for a file called QtConsoleGraphics.a.