add function to compute power spectrum
bug fix for handling muti-dimensional matrices