# How to extract positions of a set of linear independent components of a matrix / tensor?

Given a in general non-symmetric matrix / tensor of arbitrary shape A, I want to obtain efficiently the positions of a set of linear independent components of A. My approach until now is slowly start with the first component and adding linear independent components after checking linear independency (with ForAll components comp, Exists some linear combinations with coefficients c and Resolve for a boolean statement).

LinearIndependentComponents[A_] := Module[
{comp, li, c, cs, q},
comp = Flatten@A;
li = {comp[[1]]};
Do[
c = Array[cs, Length@li];
q = Resolve[
Exists[Evaluate@c,
ForAll[Evaluate@Variables@comp, c.li == comp[[j]]]]];
If[Not@q, AppendTo[li, comp[[j]]]]
, {j, 2, Length@comp}
];
Do[
li[[i]] = First@Position[A, li[[i]]];
, {i, Length@li}
];
li
];


My approach is horribly slow for large matrices and tensors. Do you know how to do this more efficiently? I dont use Variables, since for some expressions, see Example 2 and Example 4 down below, the list of variables of Mathematica is not the right answer.

Example 1: non-symmetric matrix

A = {{a, b, 4 b - a}, {c, a - 5 b, a}, {d, b + c + a, b}};
MatrixForm@A
LinearIndependentComponents@A


Example 2: symmetrized matrix

A = Array[a, {3, 3}];
B = A + Transpose@A;
Length@LinearIndependentComponents@B
Length@Variables@B


6

9

Example 3: partly symmetrized fourth-order tensor

A = Normal@
SymmetrizedArray[
pos_ :> Subscript[a, pos], {3, 3, 3, 3}, {Symmetric[{1, 2}],
Symmetric[{3, 4}]}];
Length@Variables@A
Length@LinearIndependentComponents@A


36

36

Example 4: slightly twisted expression

A=Array[a, {3,3}];
A=2*(A+Transpose@A);
A=A+Reverse@A;
LinearIndependentComponents@A


{{1,1}, {1,2}, {1,3}, {2,1}, {2,2}}