We give canonical matrices of a pair ( A , B ) consisting of a nondegenerate form B and a linear operator A satisfying B ( Ax , Ay ) = B ( x , y ) on a vector space over F in the following cases: • F is an algebraically closed field of characteristic different from 2 or a real closed field, and B is symmetric or skew-symmetric; • F is an algebraically closed field of characteristic 0 or the skew field of quaternions over a real closed field, and B is Hermitian or skew-Hermitian with respect to any nonidentity involution on F . These classification problems are wild if B may be degenerate. We use a method that admits to reduce the problem of classifying an arbitrary system of forms and linear mappings to the problem of classifying representations of some quiver. This method was described in [V.V. Sergeichuk, Classification problems for systems of forms and linear mappings, Math. USSR-Izv. 31 (3) (1988) 481–501].