Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming Lecture # 43. Math Library Complex number Matrix Quadratic equation and their solution …………….…

Similar presentations


Presentation on theme: "Introduction to Programming Lecture # 43. Math Library Complex number Matrix Quadratic equation and their solution …………….…"— Presentation transcript:

1 Introduction to Programming Lecture # 43

2 Math Library Complex number Matrix Quadratic equation and their solution …………….…

3 Design Recipe To design a program properly, we must : To design a program properly, we must : –Analyze a problem statement, typically expressed as a word problem expressed as a word problem –Express its essence, abstractly and with examples examples –Formulate statements and comments in a precise language i.e. code precise language i.e. code –Evaluate and revise the activities in light of checks and tests and –PAY ATTENTION TO DETAIL

4 Matrix Matrix is nothing but a two dimensional array of numbers Normally, represented in the form of : Rows Columns

5 Example 1234 5678 9101112 A = Three Rows Four Columns

6 i & j are two Integers i representing the Row number j representing the Column number

7 Operations Performed with Matrix Addition of two matrices. Addition of a scalar and a matrix Subtraction of two matrices Subtraction of a scalar from a matrix Multiplication of two matrices Multiplication of a scalar with a matrix Division of a scalar with a matrix Transpose of a matrix

8 Interface

9 Addition of two Matrices A ij + B C =

10 Size of two matrices must be same Number of rows and columns must be identical for the matrices to be addable Addition of two Matrices

11 Example 123 567 91011 - 36 8 74 7 910 1 = -2-4 -5 -22 0 00 10 A ij - B C =

12 Ordinary number added to every element of the matrix Adding a Scalar to the Matrix

13 Ordinary number subtracted from every element of the matrix Subtracting a Scalar from a Matrix

14 Divide every element of Matrix by a scalar number Division of Matrix by a Scalar

15 Example Let : X be a Scalar number A be a Matrix A ij C = X

16 Multiplication of a scalar with a Matrix : Example Let : X is a Scalar number A is a Matrix A ij C = X * X * A

17 Multiply two Matrices 1 2 5 6 = * 2 4 1 2 ( 1 ) ( 2 ) + ( 2 ) ( 1 )( 1 ) ( 4 ) + ( 2 ) ( 2 ) ( 5 ) ( 2 ) + ( 6 ) ( 1 ) ( 5 ) ( 4 ) + ( 6 ) ( 2 )

18 Number of columns of the 1 st Matrix = Number of rows of the 2nd Matrix Rules Regarding Matrix Multiplication

19 Rules regarding Matrix Multiplication First matrix has First matrix has –M rows –N columns Second matrix has Second matrix has –N rows –P columns Resultant matrix will have Resultant matrix will have –M rows –P columns

20 Transpose of a Matrix Interchange of rows and columns

21 Transpose of a Matrix Example 123 567 91011 159 2610 3711

22 Transpose of a Non Square Matrix A A T 3 ( Rows ) * 4 ( Columns ) Before 4 ( Rows ) * 3 ( Columns ) After Size of matrix change after transpose

23 Next Phase of Analysis Determine the Constants Memory Allocation What is it’s user interface

24 Interface

25 Interface Constructor : Parameters are Number of rows Number of rows Number of columns Number of columns Display function Plus operator : member operator of the class Subtraction operator : member operator of the class Plus operator : friend of the class Subtraction operator : friend of the class

26 Plus Operator A + X X + A

27 Subtraction Operator A - X X – A

28 *

29 Interface Multiplication Operator : Member of the Class Multiplication Operator : Friend of the Class Division Operator : Member of the Class Transpose Function : Member of the Class Assignment Operator : Member of the Class +=, -= : Members of the Class

30 Multiplication Operator A * X X * A

31 Assignment Operator A = BA = B ( Member Operator )

32 >> Extraction Operator : Friend Operator << Stream Insertion Operator : Friend Operator Interface

33 Copy Constructor

34 Copy Constructor Copy Constructor Assignment Operator Assignment Operator Memory Allocation Memory Allocation Memory Deallocation Memory Deallocation


Download ppt "Introduction to Programming Lecture # 43. Math Library Complex number Matrix Quadratic equation and their solution …………….…"

Similar presentations


Ads by Google