[3] The Matrix
The Matrix
[3] The Matrix
What is a matrix? Traditional answer
Neo: What is the Matrix? Trinity: The answer is out there, Neo, and it's looking for you, and it will find you if you want it to. The Matrix, 1999 Traditional notion of a matrix: two-dimensional array.
123 10 20 30
Two rows: [1, 2, 3] and [10, 20, 30]. Three columns: [1, 10], [2, 20], and [3, 30]. A 2 ? 3 matrix. For a matrix A, the i, j element of A is the element in row i, column j is traditionally written Ai,j but we will use A[i, j]
List of row-lists, list of column-lists (Quiz)
One obvious Python representation for a matrix: a list of row-lists:
123 10 20 30
represented by [[1,2,3],[10,20,30]].
Another: a list of column-lists:
123 10 20 30
represented by [[1,10],[2,20],[3,30]].
List of row-lists, list of column-lists
Quiz: Write a nested comprehension whose value is list-of-row-list representation of a 3 ? 4 matrix all of whose elements are zero:
0 0 0 0 0 0 0 0
0000
Hint: first write a comprehension for a typical row, then use that expression in a comprehension for the list of lists. Answer:
>>> [[0 for j in range(4)] for i in range(3)] [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
List of row-lists, list of column-lists (Quiz)
Quiz: Write a nested comprehension whose value is list-of-column-lists representation of a 3 ? 4 matrix whose i, j element is i - j:
0 -1 -2 -3 1 0 -1 -2
2 1 0 -1
Hint: First write a comprension for column j, assuming j is bound to an integer. Then use that expression in a comprehension in which j is the control variable. Answer:
>>> [[i-j for i in range(3)] for j in range(4)] [[0, 1, 2], [-1, 0, 1], [-2, -1, 0], [-3, -2, -1]]
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- 8.3 the process of photosynthesis
- 8 3 the process of photosynthesis
- 8 3 the process of photosynthesis key
- 3 by 3 matrix solver
- 3 by 3 matrix calculator
- the matrix production team
- 8 3 the process of photosynthesis answer key
- find the determinant of the matrix calculator
- the matrix questions
- 93 3 the bus columbus ohio
- 12 3 the slave system
- 12 3 the slave system pages 386 391