added questions for matrices.
authorAnoop Jacob Thomas<anoop@fossee.in>
Mon, 11 Oct 2010 12:49:08 +0530
changeset 287 d9507624eb8f
parent 286 44f06ae0d957
child 288 a3b98b4c371e
child 296 641a6ee868c0
added questions for matrices.
matrices/questions.rst
matrices/script.rst
--- a/matrices/questions.rst	Mon Oct 11 11:40:43 2010 +0530
+++ b/matrices/questions.rst	Mon Oct 11 12:49:08 2010 +0530
@@ -3,6 +3,82 @@
 
 .. A mininum of 8 questions here (along with answers)
 
+1. ``matrix(A) * matrix(B)`` and ``array(A) * array(B)`` are the same.
+
+    a. True
+    #. False
+
+Answer: False
+
+2. ``matrix(A) * array(B)`` does,
+
+   a. Element wise multiplication.
+   #. Matrix multiplication.
+   #. Cannot multiply a matrix object and array object.
+   #. Depends on the shape of A and B, if compatible matrix
+      multiplication will be done, otherwise element wise
+      multiplication.
+
+Answer: Matrix multiplication
+
+3. A and B are two matrix objects. Element wise multiplication in
+   matrices are done by,
+
+   a. A * B
+   #. ``multiply(A, B)``
+   #. ``dot(A, B)``
+   #. ``element_multiply(A,B)``
+
+Answer: multiply(A, B)
+
+4. ``norm(A)`` method determines the,
+
+   a. Frobenius norm
+   #. Infinity norm
+   #. Induced norm
+   #. Schatten norm
+
+Answer: Frobenius norm
+
+5. ``eig(A)[1]`` and ``eigvals(A)`` are the same.
+
+   a. True
+   #. False
+
+Answer: False
+
+6. The code snippet will work without an error,
+   ::
+
+       A = matrix([[1, 2, 3, 4], [5, 6, 7, 8]])
+       inv(A)
+
+   a. True
+   #. False
+
+Answer: False
+
+7. What is the output of the following code,
+   ::
+
+      x = matrix([[1, 2, 3], ['a', 2, 'c']])
+      identity(x.shape)
+
+   a. Will create an identity matrix of shape (2, 3).
+   #. ``identity()`` function takes an integer as argument and a tuple
+      is passed.
+   #. Will return, matrix([[1,0,1],[0,1,0]])
+   #. Will return, matrix([[0,1,0],[0,1,0]])
+
+Answer: ``identity()`` function takes an integer as argument and a
+      	tuple is passed.
+
+8. ``norm(A,ord='fro')`` is the same as ``norm(A)``
+
+   a. True
+   #. False
+
+Answer: True
 
 Larger Questions
 ----------------
@@ -30,3 +106,11 @@
    What will be the array after 22 such operations starting with [1,
    2, 3, 4, 5, 6, 7, 8, 9, 10]
 
+2. Find the infinity norm and the determinant of the inverse of the
+   product of matrices A and B. 
+   ::
+
+      A = [[ 1,  2,  3,  4],     B = [[16, 15, 14, 13],
+      	   [ 5,  6,  7,  8],          [12, 11, 10,  9],
+	   [ 9, 10, 11, 12],          [ 8,  7,  6,  5],
+	   [13, 14, 15, 16]]          [ 4,  3,  2,  1]]
--- a/matrices/script.rst	Mon Oct 11 11:40:43 2010 +0530
+++ b/matrices/script.rst	Mon Oct 11 12:49:08 2010 +0530
@@ -70,6 +70,8 @@
 
 it does matrix subtraction, that is element by element
 subtraction. Now let us try,
+
+{{{ Switch to next slide, Matrix multiplication }}}
 ::
 
     m3 * m2
@@ -120,9 +122,9 @@
 
 Matrix name dot capital T will give the transpose of a matrix
 
-{{{ switch to next slide, Euclidean norm of inverse of matrix }}}
+{{{ switch to next slide, Frobenius norm of inverse of matrix }}}
 
-Now let us try to find out the Euclidean norm of inverse of a 4 by 4
+Now let us try to find out the Frobenius norm of inverse of a 4 by 4
 matrix, the matrix being,
 ::
 
@@ -131,17 +133,17 @@
 
 The inverse of a matrix A, A raise to minus one is also called the
 reciprocal matrix such that A multiplied by A inverse will give 1. The
-Euclidean norm or the Frobenius norm of a matrix is defined as square
-root of sum of squares of elements in the matrix. Pause here and try
-to solve the problem yourself, the inverse of a matrix can be found
-using the function ``inv(A)``.
+Frobenius norm of a matrix is defined as square root of sum of squares
+of elements in the matrix. Pause here and try to solve the problem
+yourself, the inverse of a matrix can be found using the function
+``inv(A)``.
 
 And here is the solution, first let us find the inverse of matrix m5.
 ::
 
     im5 = inv(m5)
 
-And the euclidean norm of the matrix ``im5`` can be found out as,
+And the Frobenius norm of the matrix ``im5`` can be found out as,
 ::
 
     sum = 0
@@ -166,16 +168,18 @@
 
 {{{ switch to slide the ``norm()`` method }}}
 
-Well! to find the Euclidean norm and Infinity norm we have an even easier
+Well! to find the Frobenius norm and Infinity norm we have an even easier
 method, and let us see that now.
 
 The norm of a matrix can be found out using the method
-``norm()``. Inorder to find out the Euclidean norm of the matrix im5,
+``norm()``. Inorder to find out the Frobenius norm of the matrix im5,
 we do,
 ::
 
     norm(im5)
 
+Euclidean norm is also called Frobenius norm.
+
 And to find out the Infinity norm of the matrix im5, we do,
 ::