1
$\begingroup$

I would like to test if 16 matrices (4X4) that I created are linearly independent. The straight-forward solution would be to check if the equation

$\sum_{k=1}^N \alpha_k A_k = 0$ (1) (N=16 in the current settings)

has a non-trivial solution. The problem is now that these 16 matrices are stored in one matrix with dimennsions 4x64, e.g. the first matrix is saved in colums 1-4, the second in 5-8 and so on. Later, I would like to test the linear independence for a set of 64 8x8 matrices and maybe even for 256 16x16 matrices. Therefore, simply writing down the equation and using a function like Solve is not a solution. Therefore, I would like to be able to somehow generate this equation (1) dynamically, e.g. with a variable N.

I don't even have an idea on how I could implement this.

EDIT: Ok, I tried now to save all the matrices in one list, e.g.

The 16 matrices are saved in NewMatrices

MatrixList= ConstantArray[0, {16, 1}];
For [ii = 1, ii <= 16, ii++,
 MatrixList[[ii]] = NewMatrices[[ All, 4*(ii - 1) + 1 ;; 4*ii]];
 ] 

I then tried treating MatrixList as a vector and tried to solve it using

LinearSolve[MatrixList,ConstantArray[0,{4,4}]]

Somehow, this does now work.

$\endgroup$
3
  • $\begingroup$ It is enough, ist it? 16x16=256 entries, same as 4x64=256 entries. $\endgroup$
    – anonymous
    Commented Apr 15, 2021 at 16:03
  • $\begingroup$ It would help if your provided the matrices in the question. I wasn't entirely sure of the dimensions. $\endgroup$
    – flinty
    Commented Apr 15, 2021 at 16:09
  • $\begingroup$ NullSpace[Flatten/@matrices]=!={} will tell you if there is a dependency. $\endgroup$ Commented Apr 15, 2021 at 19:22

1 Answer 1

3
$\begingroup$

If you have got all your matrices in matrices then use ResourceFunction["LinearlyIndependent"] for example:

LinearlyIndependent = ResourceFunction["LinearlyIndependent"];
matrices = RandomInteger[20, {16, 4, 4}];
LinearlyIndependent[Flatten /@ matrices]

To extract your matrices you can do this:

onebigmatrix = RandomInteger[20, {4, 64}];
matrices = Partition[onebigmatrix, {4, 4}][[1]];
LinearlyIndependent[Flatten /@ matrices]
$\endgroup$
1
  • $\begingroup$ That works nicely. Thanks a lot! $\endgroup$
    – anonymous
    Commented Apr 15, 2021 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.