0
$\begingroup$

Suppose I have a given $10 \times 12$ matrix T, a $12 \times 1$ vector Subscript[\[Xi], 0], a $4 \times 12$ matrix R, a $10 \times 10$ matrix Vn, and a $4 \times 1$ vector rt.

Having specified the above, I write the following code:

Gv1 = Vn.T;


fk = SuperPlus[R].rt + Subscript[\[Xi], 0];

pt1 = Gv1.fk;

s = 0.0;
Cs = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
Ss = {1, 1, 1, -1, 1, 1, 1, -1, 1, 1};

\[Phi] = Vn[[All, Cs]];
\[Psi] = \[Phi].DiagonalMatrix[Ss];


v1 = -\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]pt1\) /. t -> s;


\[CapitalSigma] = 
  ConicHullRegion[ConstantArray[0, 10], ConstantArray[0, {10, 10}], 
   Transpose[\[Psi]]];


RegionMember[\[CapitalSigma], Flatten[v1]]


Running the above code gives either "true" or "false", depending whether the vector v1 belongs to the conical hull or not.

I want it now to run for all possible combinations of $-1$ and $1$ of size 10. That is, I want to check all possible tuples given by Tuples[{-1, 1}, 10]. This is my variable Ss.

I would ideally want it to output a table whose first column is the tuple in question and on the other whether the result is true or false.

Is there a way of implementing this in Mathematica? Any suggestions are most welcome.

$\endgroup$
5
  • 1
    $\begingroup$ Usually you can create a region member function with f = RegionMember[\[CapitalSigma]] which can be applied to vectors. This should be more effcient than calling RegionMember[\[CapitalSigma], Flatten[v1]] repeatedly. Then Map[{#, f[#]} &, Tuples[{-1, 1}, 10]] should yield what you want. $\endgroup$ Apr 19 at 6:15
  • $\begingroup$ Thanks! This seems to work for me. However, I have a silly question-how does the second statement check the conic hull for the given v1? I don't see v1 being referenced anywhere. $\endgroup$ Apr 19 at 7:32
  • 1
    $\begingroup$ The RegionMemberFunction f is supposed to do the check. If you wonder about # and &, then I suggest to read about Function and Map. $\endgroup$ Apr 19 at 7:55
  • $\begingroup$ @HenrikSchumacher I'm still a bit confused. Can you please clarify what the two lines of code are supposed to do? Does it a) check whether v1 belongs to the conic hull for the 1024 combinations (size 10 tuples of {-1,1}) or b) checks whether the tuples belong to the conic hull? I'm just trying to understand what exactly it does. $\endgroup$ Apr 19 at 9:19
  • 1
    $\begingroup$ The Function {#, f[#]} & takes a vector as its argument and and returns a list whose first entry is the input vector and the second either True or False, depending on what the RegionMemberFunction f decides. Map[{#, f[#]} &, Tuples[{-1, 1}, 10]] takes this function and applies it to each element of the list Tuples[{-1, 1}, 10]. $\endgroup$ Apr 19 at 9:30

Your Answer

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

Browse other questions tagged or ask your own question.