I have written some code to deal with lists, But the speed of the code is slow, Could Someone help me to speed up it?
Probably could rewrite it with Functional Programming!
Give me some ideas!
The whole code is located on
Find sublists of a list match conditions (2)
CountTrue[list_] := Module[
{},
Count[list, True] >= 1
];
ProjectedElemsIndex[ElemPtsCoord_, ElemElemsMadeofPtsIndex_, Acen_,
Bcen_, Ccen_, R1_, RetainElementsIndex_] := Module[
{RELPtsIndex, temp1, temp2},
RELPtsIndex = ElemElemsMadeofPtsIndex[[RetainElementsIndex]];
temp1 =
Reap[Do[Sow[ ElemPtsCoord[[RELPtsIndex[[i]] ]] ], {i, 1,
Length[RELPtsIndex]} ] ][[2, 1]];
temp2 = Table[Table[{Acen, Bcen, Ccen}, {4}], {Length[temp1]}];
Flatten[
Position[
Map[
CountTrue,
Negative[
Map[Norm, temp1 - temp2, {2}] -
Table[Table[R1, {4}], {Length[temp1 - temp2]}]
]
],
True]
]
];
Length[ProjectedElemsIndex[ElemPtsCoord, ElemElemsMadeofPtsIndex, 40,
40, 40, 10, RetainElementsIndex]] // Timing