More Related Content Similar to CS201- Introduction to Programming- Lecture 43 (20) More from Bilal Ahmed (20) CS201- Introduction to Programming- Lecture 432. Math Library
Complex number
Matrix
Quadratic equation and their solution
…………….…
3. DDeessiiggnn RReecciippee
TToo ddeessiiggnn aa pprrooggrraamm pprrooppeerrllyy,, wwee mmuusstt ::
– AAnnaallyyzzee aa pprroobblleemm ssttaatteemmeenntt,, ttyyppiiccaallllyy
eexxpprreesssseedd aass aa wwoorrdd pprroobblleemm
– EExxpprreessss iittss eesssseennccee,, aabbssttrraaccttllyy aanndd wwiitthh
eexxaammpplleess
– FFoorrmmuullaattee ssttaatteemmeennttss aanndd ccoommmmeennttss iinn aa
pprreecciissee llaanngguuaaggee ii..ee.. ccooddee
– EEvvaalluuaattee aanndd rreevviissee tthhee aaccttiivviittiieess iinn lliigghhtt
ooff cchheecckkss aanndd tteessttss aanndd
– PPAAYY AATTTTEENNTTIIOONN TTOO DDEETTAAIILL
4. Matrix
• Matrix is nothing but a two
dimensional array of numbers
• Normally, represented in the
form of :
• Rows
• Columns
5. Example
1 2 3 4
5 6 7 8
9 10 11 12
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
10. Addition of two Matrices
Size of two matrices must be
same
Number of rows and columns
must be identical for the
matrices to be addable
11. Example
1 2 3
5 6 7
9 10 11
-
3 6 8
7 4 7
9 10 1
=
-2 -4 -5
-2 2 0
0 0 10
Cij = Aij - Bij
12. Adding a Scalar to
the Matrix
Ordinary number
added to every
element of the
matrix
15. Example
Let :
X be a Scalar number
A be a Matrix
C =
Aij ij
X
16. Multiplication of a scalar with a Matrix Example
Let :
X is a Scalar number
A is a Matrix
X * A
X * Aij = Cij
17. Multiply two
Matrices
1 2
* 2 4
5 6 1 2
= ( 1 ) ( 2 ) + ( 2 ) ( 1 ) ( 1 ) ( 4 ) + ( 2 ) ( 2 )
( 5 ) ( 2 ) + ( 6 ) ( 1 ) ( 5 ) ( 4 ) + ( 6 ) ( 2 )
18. Rules Regarding
Matrix Multiplication
Number of columns of the 1st Matrix
=
Number of rows of the 2nd Matrix
19. Rules rreeggaarrddiinngg MMaattrriixx
MMuullttiipplliiccaattiioonn
FFiirrsstt mmaattrriixx hhaass
– MM rroowwss
– NN ccoolluummnnss
SSeeccoonndd mmaattrriixx hhaass
– NN rroowwss
– PP ccoolluummnnss
RReessuullttaanntt mmaattrriixx wwiillll hhaavvee
– MM rroowwss
– PP ccoolluummnnss
21. Transpose of a Matrix
Example
1 2 3
5 6 7
9 10 11
1 5 9
2 6 10
3 7 11
22. Transpose of a Non
Square Matrix
Size of matrix change after transpose
A AT
3 ( Rows ) * 4 ( Columns )
Before
4 ( Rows ) * 3 ( Columns )
After
23. Next Phase of
Analysis
• Determine the Constants
• Memory Allocation
• What is it’s user interface
25. IInntteerrffaaccee
CCoonnssttrruuccttoorr :: PPaarraammeetteerrss aarree
NNuummbbeerr ooff rroowwss
NNuummbbeerr ooff ccoolluummnnss
DDiissppllaayy ffuunnccttiioonn
PPlluuss ooppeerraattoorr :: mmeemmbbeerr ooppeerraattoorr ooff tthhee ccllaassss
SSuubbttrraaccttiioonn ooppeerraattoorr :: mmeemmbbeerr ooppeerraattoorr ooff tthhee
ccllaassss
PPlluuss ooppeerraattoorr :: ffrriieenndd ooff tthhee ccllaassss
SSuubbttrraaccttiioonn ooppeerraattoorr :: ffrriieenndd ooff tthhee ccllaassss
29. IInntteerrffaaccee
MMuullttiipplliiccaattiioonn OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss
MMuullttiipplliiccaattiioonn OOppeerraattoorr :: FFrriieenndd ooff tthhee CCllaassss
DDiivviissiioonn OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss
TTrraannssppoossee FFuunnccttiioonn :: MMeemmbbeerr ooff tthhee CCllaassss
AAssssiiggnnmmeenntt OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss
++== ,, --== :: MMeemmbbeerrss ooff tthhee CCllaassss