1
$\begingroup$

First of all, I want to know if it is possible to make a constraint in a set of matrices that I have to obtain a subset. For example, if I have a set of square matrices A, can I build a set B formed by the elements of A that has no null determinant?

If the answer is yes, I would like do do the following.

With

m = Table[Table[1, {4}], {3}]
S = ReplacePart[m, #] & /@ Thread[Rest[Subsets@Position[m, 1]] -> -1]
MatrixForm /@ S
Length@S

We obtain from

m={{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}

the set of all matrices like m but changing the 1's to -1's. Now I want to add the line {1,1,1,1} to each matrix of the set S and obtain a set S1. Then I want to know how can I obtain the subset M of S1 formed by all matrices that have no null determinant.

The final effect of what I am trying to achieve is to obtain the set of all 4 x 4 invertible matrices with entries 1 or -1 and with the first line {1,1,1,1}.

$\endgroup$
2
$\begingroup$

The task in the last paragraph of your question can simply be achieved by the following:

Select[UnequalTo[0]@*Det]@Map[Prepend[{1, 1, 1, 1}]]@Tuples[{1, -1}, {3, 4}]

We first generate all possible $3\times 4$ matrices with 1/-1 as entries using Tuples, then we add the row of 1s using Prepend, and finally we select those that are invertible using Select

For your general question, I think Select is what you're after.

$\endgroup$
  • $\begingroup$ It says "prepend called with 1 argument; 2 arguments are expected" $\endgroup$ – Filburt Sep 25 '17 at 17:16
  • $\begingroup$ In that case your version of Mathematica is probably too old - You can replace Prepend[{1,1,1,1}] with Prepend[#,{1,1,1,1}]& to fix it by building the operator form "by hand " $\endgroup$ – Lukas Lang Sep 25 '17 at 17:20
1
$\begingroup$

Probably less efficient than Mathe172's answer, but with simpler logic:

Select[Tuples[{1, -1}, {4, 4}], Det[#] =!= 0 && #[[1]] == {1, 1, 1, 1} &]

This generates all 4x4 matrices with +/-1 entries, then selects all those with Det not zero and with the specified first row.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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