Exact block-wise optimization in group lasso and sparse group lasso for linear regression