function retval = cosm(A) 
  retval = .5 * (expm(i*A) + expm(-i*A));
endfunction