Download presentation
Presentation is loading. Please wait.
1
A Color (picture) is worth 1000 words
Dafna Minster July 2012
2
introduction Matrices have many uses in mathematics and computer science. Matrices allow storage of large amount of information regarding variables and also allow methods that define operations upon themselves. Students who are learning the subject of matrices have some difficulties. One difficulty is: understanding the ways of scanning the matrix. The difficulty lies within the fact that a nested loop (loop inside a loop) is required. Other problems include scanning the matrix' diagonals and all items above/bellow the diagonals. One operation that is especially difficult is to transpose – to swap between rows and columns. This tip shows visual methods on how to scan a matrix step by step. The first part of the tip will shows the outer loop by coloring the rows, and the second part will describe the inner loop by using a different color. This tip will help teachers to better convey the subject matrices using a graphical approach. As said in the title: A Color (picture) is worth 1000 words. All rights reserved to Dafna Minster
3
Matrix - rows Start row for ( int i = 0 ; i < matrix.length ; i++ )
End row All rights reserved to Dafna Minster
4
Matrix - columns Start column End column
for ( int i = 0 ; i < matrix.length ; i++ ) for ( int j = 0 ; j < matrix[i].length ; j++ ) command ( matrix [ i ] [ j ] ); End column All rights reserved to Dafna Minster
5
Matrix – main diagonal for ( int i = 0 ; i < matrix.length ; i++ )
command ( matrix [ i ] [ i ] ) ; All rights reserved to Dafna Minster
6
Matrix – secondary diagonal
for ( int i = 0 ; i < matrix.length ; i++ ) command(matrix[i] [matrix.length-1-i]); All rights reserved to Dafna Minster
7
Matrix – above main diagonal
j = i +1 j = i j = i -1 All rights reserved to Dafna Minster
8
Matrix – above main diagonal
j = i +1 j = i j = i -1 Start row for ( int i = 0 ; i < matrix.length - 1 ; i++ ) End row All rights reserved to Dafna Minster
9
Matrix – above main diagonal
j = i +1 Start column j = i j = i -1 for ( int i = 0 ; i < matrix.length - 1 ; i++ ) for ( int j = i +1 ; j < matrix[i].length ; j++ ) command ( matrix [ i ] [ j ] ); End column
10
Matrix – Below main diagonal
j = i +1 j = i j = i -1 All rights reserved to Dafna Minster
11
Matrix – Below main diagonal
j = i +1 j = i j = i -1 Start row for ( int i = 1 ; i < matrix.length ; i++ ) End row
12
Matrix – Below main diagonal
End column j = i +1 j = i j = i -1 for ( int i = 1 ; i < matrix.length ; i++ ) for ( int j = 0 ; j < i ; j++ ) command ( matrix [ i ] [ j ] ) ; Start column
13
Matrix – above secondary diagonal
j = matrix[i].length - 1- i j = matrix[i].length - i j = matrix[i].length - 2- i All rights reserved to Dafna Minster
14
Matrix – above secondary diagonal
j = matrix[i].length - 1- i j = matrix[i].length - 2- i Start row for ( int i = 0 ; i < matrix.length - 1 ; i++ ) End row All rights reserved to Dafna Minster
15
Matrix – above secondary diagonal
j = matrix[i].length - 1- i j = matrix[i].length - 2- i End column for ( int i = 0 ; i < matrix.length - 1 ; i++ ) for ( int j = 0; j < matrix[i].length - 1- i ; j++) command (matrix[i] j]); Start column
16
Matrix – Below secondary diagonal
j = matrix[i].length - 1- i j = matrix[i].length - i j = matrix[i].length - 2- i All rights reserved to Dafna Minster
17
Matrix – below secondary diagonal
j = matrix[i].length - 1- i j = matrix[i].length - i Start row for ( int i = 1 ; i < matrix.length ; i++ ) End row All rights reserved to Dafna Minster
18
Matrix – above secondary diagonal
j = matrix[i].length - 1- i j = matrix[i].length - i Start column for ( int i = 1 ; i < matrix.length ; i++ ) for ( int j = matrix[i].length - i ; j < matrix[i].length ; j++) command (matrix[ i ] [ j ]); End column
19
The end Dafna Minster July 2012 All rights reserved to Dafna Minster
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.