Algorithm and Hardness for Kernel Matrices in Numerical Linear Algebra and Machine Learning