Developing Classes for Linear Algebra Calculations

  • Pitt-Francis J
  • Whiteley J
N/ACitations
Citations of this article
5Readers
Mendeley users who have this article in their library.
Get full text

Abstract

In this chapter, we will apply the ideas introduced earlier in this book to develop a collection of classes that allow us to perform linear algebra calculations. We will describe the design of a class of vectors in the body of this chapter. The exercises at the end of the chapter will focus on developing this class further, developing a companion class of matrices, and developing a linear system class that allows us to solve matrix equations. 10.1 Requirements of the Linear Algebra Classes As explained above, we will develop a class of vectors called Vector, a class of matrices called Matrix and a linear system class called LinearSystem. The vector and matrix classes will include constructors and destructors that handle mem-ory management. These classes will overload the assignment, addition, subtraction and multiplication operators, allowing us to write code such as " u = A * v; " where u and v are vectors, and A is a matrix: these overloaded operators will include checks that the vectors and matrices are of the correct size. The square bracket op-erator will be overloaded for the vector class to provide a check that the index of the array lies within the correct range, and the round bracket operator will be over-loaded to allow the entries of the vector or matrix to be accessed using MATLAB style notation, indexing from 1 rather than from zero. The remainder of this chapter will focus on the development of a class of vectors. The header file for this class is given in Listing 10.1, and the implementation of the methods is given in Listing 10.2. The two variables that each instance of the class are built upon are a pointer to a double precision floating point variable, mData, and the size of the array, mSize. We have made both of these private members of the class. We clearly need to write methods to both access and set values of the array. We shall insist that the size of the array is set through a constructor. As such, we shall not allow the user to change this variable through any method, but will write a public method that allows us to access the size of a given vector.

Cite

CITATION STYLE

APA

Pitt-Francis, J., & Whiteley, J. (2012). Developing Classes for Linear Algebra Calculations (pp. 151–164). https://doi.org/10.1007/978-1-4471-2736-9_10

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free