Solution of certain matrix equations