@karlnapf I realized this while trying to change this part. Only processing feature matrix part is redundant. matrix multiplication call by eigen3 are different for the two (one uses block on same matrix m other strores result in a new matrix ret). Similarly, set_feature_matrix call is also different (sets m in one case ret in other). Only the processing feature matrix part is common but taking it out puts too many if-elses in between. So, IMO there is no point to make the code complex just to reduce this single redundancy.
Please let me know without any worries if I am missing something!