Please use code blocks when posting code.
Your program doesn't free the memory it allocates. The free() call is after the return statement so will never be executed. Obviously it can't be in GEN() otherwise you can't return it to the calling function. So it needs to be in the calling function, which in this case is main().
Also it doesn't free all the memory it allocates. You free X itself, but you don't free X[n]. To avoid leaks, ALL malloc statements must be exactly matched with equivalent free statements. You have two mallocs and one free - a clear indication that there is a leak.
for (int NT=0; NT<100; NT++)
for (int i=0; i<3; i++)
Finally X should consistute pointers to float, not float. So:
and then X[n] is correctly of type float*.