  Let $\Phi:V\to V\otimes U$ be an intertwining operator between
representations of a simple Lie algebra (quantum group, affine Lie algebra). We
define its generalized character to be the following function on the Cartan
subalgebra with values in $U$:
  $\chi_\Phi(h)=\Tr_V (\Phi e^h)$.
  These generalized characters are a rich source of special functions,
possessing many interesting properties; for example, they are common
eigenfunctions of a family of commuting differential (difference) operators. We
show that the special functions that can be obtained this way include
Macdonald's polynomials of type $A$, and this technique allows to prove inner
product and symmetry identities for these polynomials (though proved earlier by
other methods).
  Generalized characters for affine Lie algebras are closely related with
so-called correlation functions on the torus in the Wess-Zumino-Witten (WZW)
model of conformal field theory. We derive differential equations satisfied by
these correlation functions (elliptic Knizhnik-Zamolodchikov, or
Knizhnik-Zamolodchikov-Bernard equations) and study their monodromies.
