Symplectic classification of quadratic forms, and general Mehler formulas