Algorithms and generalization for large-scale matrices and tensors