matrices/questions.rst
author anand
Fri, 12 Nov 2010 01:00:49 +0530
changeset 493 62b93bfac3cd
parent 397 4aea9ed09983
permissions -rw-r--r--
internal review not done for `getting started with symbolics`

Objective Questions
-------------------

.. A mininum of 8 questions here (along with answers)

1. ``array(A) * array(B)`` does matrix multiplication.

    a. True
    #. False

Answer: False

2. ``array(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: Element wise multiplication.

3. A and B are two array objects. Element wise multiplication in
   matrices are done by,

   a. A * B
   #. ``multiply(A, B)``
   #. ``dot(A, B)``
   #. ``element_multiply(A,B)``

Answer: dot(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 = array([[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
----------------

.. A minimum of 2 questions here (along with answers)

1. Consider an array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].  A fold and add
   operation consist of two phases, a right fold and add and a left
   fold and add.

   Say in first fold and add, we take the right fold of the array and
   add it to the left like,

   [1+10, 2+9, 3+8, 4+7, 5+6, 6, 7, 8, 9, 10]

   and it becomes

   [11, 11, 11, 11, 11, 6, 7, 8, 9, 10]

   and in the second fold and add, we take the left fold of the new
   array and add it to the right and it becomes,

   [11, 11, 11, 11, 11, 17, 18, 19, 20, 21].

   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]]