I will try Hans. Here we go
Do[ m={{a1,a2},{a3,a4}}; (*2x2 matrix*)
a1 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}]; a3 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}];
a2 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}]; a4 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}];
If[a1>a2 && a3>a4,PutAppend[{a1,a2,a3,a4,m},"list"]],{100}]
At this point we stored the values for a1, a2, a3 ,a4 and m that satisfy the condition of the first Do loop. Now we are going to calculate the value for a matrix M, that is,
dn=ReadList["list"]; (*here I'm calling the list because I need the values found previously*)
Do[ M[i_]:= {{b1,b2},{b3.b4}}*dn[[i,3]]+dn[[i,5]]*b1 (*2x2 matrix where I'm using the data from l"ist"*)
b1 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}]; b3 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}];
b2 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}]; b4 = RandomReal[{0, 1.}]*RandomChoice[{-1., 1.}];
If[Eigenvalues[M[i]][[1]]> 0 && b1> dn[[i,1]] && 0<Eigenvectors[M[i]][[1,1]]<0.5,
PutAppend[{M[i],b1,b2,b3,b4,dn[[i,1]],dn[[i,2]],m},"list2"],{i,1,Length[dn]}]
In the second Do loop, I used the values from the first one, this is a simple example. But think about what if in the first Do loop I need to do 100000 iterations in order to get a lot of data and then use them in the second Do loop, It's not good for the memory of the code. How can I make that in every iteration that the first Do loop finds a set of values, go immediately to the second one to evaluate it?
In the case of a bigger matrix, with more conditions, and more restrictive constraints, what would be the better way to optimize it in time and memory?