update linalg lib. refactor learning code