* @return
*/
public static Tensor factor(Tensor tensor, boolean factorScalars, FactorizationEngine factorizationEngine) {
if (factorScalars) {
Expression[] replacementsOfScalars = TensorUtils.generateReplacementsOfScalars(tensor,
new LocalSymbolsProvider(tensor, "sclr"));
for (Expression e : replacementsOfScalars)
tensor = e.transform(tensor);
tensor = factorSymbolicTerms(tensor, factorizationEngine);
for (Expression e : replacementsOfScalars)
tensor = e.transpose().transform(tensor);