Abstract

We want to approximate the deflection of a loaded beam at one inch intervals. Solutions will be found using both Matlab and C + +. The solution requires solving the matrix equation Aw=b where A is a tridiagonal matrix. The beam problem affords an excellent example for introducing the reader to object oriented programming. With much of commercial software being written using object oriented techniques, a knowledge of such techniques is important for computer scientists, mathematicians, and scientists. In a numerical analysis course, the author gives projects where the students have an option of using either Maple, Matlab, or C + + (an object oriented language). Also in the course, some discussion and examples in C+ + are provided. Before solving our beam problem, we will consider solving a system of linear equations. First a Matlab solution is provided, then a brief overview of an object oriented solution will be developed where the added features of C++ are discussed. Matlab has an interface which allows C++ programs to be used within the Matlab environment. Therefore, a knowledge of both C + + and Matlab is required for such an application. A SYSTEM OF LINEAR EQUATIONS AW = B WHERE A IS A TRIDIAGONAL MATRIX HISTORY OF OBJECT ORIENTED PROGRAMMING Before providing a C+ + solution to the linear system, let us consider the reason why object oriented concepts were developed. Research activity in the 1960s resulted in the evolution of structured programming - a disciplined approach to writing programs that are clearer than unstructured programs, easier to test and debug, and easier to modify. This led to the development of Pascal in 1971 which became the preferred language at most universities. Unfortunately, many of the features required in commercial, industrial, and government applications were lacking in Pascal. Object oriented programming was developed to include many of the needed features. Objects are essentially reusable software components that model items in the real world. In contrast with structured programming, a modular, object-oriented design and implementation approach can make software development groups more productive. Object oriented programs are easier to understand, correct and modify [4]. However, there is a level of complexity involved. Our intent is to develop a simple mathematical object for solving a system of linear equations and explain the advantages gained with details relegated to programs available at ftp://ftp.etsu.edu/pubdata/kerleyl/Articlel. Then we will add more complexity by discussing the solution to the beam problem. C + + SOLUTION OF AW = B WHERE A IS A TRIDIAGONAL MATRIX Classes and objects Before creating our Gaussian equation object, we discuss a concept called a class. A class is simply a blueprint for creating an object [1]. From a class, an object will be created. In many structured programming languages such as Pascal or C, the unit of programming is the function. Data exist primarily in support of the actions the functions perform. However in C + +, data (attributes) and functions (behavior) are bound together in what is called an object [4]. To develop an object, a userdefined type called a class must first be created. In our case, a gauss class will be developed. From it, an object will be created which describes Example 1. The data components of the class will be called data members and the function components of the class will be called member functions. The following code which is from the file brief cpp and is available from ftp://ftp.etsu.edu/pubdata/kerleyl/Articlel/Cplus solves Example 1. Inheritance and virtual functions The class triDiag is called a base class. No objects are created from it. All three functions in the class triDiag also appear in the class gauss and have the same name. The class gauss is called a derived class and is said to be inherited from triDiag. The keyword virtual which appears on each of the three functions in class triDiag describes what are called virtual functions. …

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call