Let A be a real symmetric matrix of size N such that the number of the non-zero entries in each row is polylogarithmic in N and the positions and the values of these entries are specified by an efficiently computable function. We consider the problem of estimating an arbitrary diagonal entry (A^m)_jj of the matrix A^m up to an error of \epsilon b^m, where b is an a priori given upper bound on the norm of A, m and \epsilon are polylogarithmic and inverse polylogarithmic in N, respectively. We show that this problem is BQP-complete. It can be solved efficiently on a quantum computer by repeatedly applying measurements of A to the jth basis vector and raising the outcome to the mth power. Conversely, every quantum circuit that solves a problem in BQP can be encoded into a sparse matrix such that some basis vector |j> corresponding to the input induces two different spectral measures depending on whether the input is accepted or not. These measures can be distinguished by estimating the mth statistical moment for some appropriately chosen m, i.e., by the jth diagonal entry of A^m. The problem is still in BQP when generalized to off-diagonal entries and it remains BQP-hard if A has only -1, 0, and 1 as entries.