Problem 1, Block matrix construction of A
help kron
KRON Kronecker tensor product.
KRON(X,Y) is the Kronecker tensor product of X and Y.
The result is a large matrix formed by taking all possible
products between the elements of X and those of Y. For
example, if X is 2 by 3, then KRON(X,Y) is
[ X(1,1)*Y X(1,2)*Y X(1,3)*Y
X(2,1)*Y X(2,2)*Y X(2,3)*Y ]
If either X or Y is sparse, only nonzero elements are multiplied
in the computation, and the result is sparse.
So the first argument X in kron(X,Y) specifies the (outer) matrix whose
"elementblocks" are the matrices X(i,j)*Y.
Try the following (perhaps first without "sparse"):
n=3;
mI=-speye(n,n)
B=sparse(4*diag(ones(1,n))-diag(ones(1,n-1),1)-diag(ones(1,n-1),-1))
D=sparse(diag(ones(1,n)))
UD=sparse(diag(ones(1,n-1),1))
LD=sparse(diag(ones(1,n-1),-1))
A=sparse(kron(D,B))+sparse(kron(UD,mI))+sparse(kron(LD,mI))