function [MM, d] = cs3734s05p0102_(n)
% cs3734s05p0102_.m
% CS3734 spring 2005
% Assignment 1,  problem 2
% INPUT: n, the dimension of each of the submatrices.
% OUTPUT: MM, matrix M formed from 4 submatrices.
%         d, determinant of (I+M)
% K. Ming Leung, 01/16/05

% Here n is the dimension of matrices A, B, C, and D.
% Creates a row vector [1 2 ... n]
RowVec = 1:n;

% Creates matrix A by multiplying a colum vector with a row vector
AA = transpose(RowVec)*(RowVec+2);

% Creates matrix B
BB = repmat(7,n,n); % can also use: 7*ones(n,n)
% Replace the second element up to the next-to-the-last element 
% of the first row to 1's
BB(1,2:end-1) = ones(1,n-2);

% Place these 4 matrices together to form matrix M
MM = [AA BB; transpose(BB) eye(n)];

% find the determinant of matrix (I+M),
% where I is the (2n) by (2n) identity matrix.
d = det(eye(2*n)+MM);


