Complex Conjugate Sinusoids in Forward DFT
Really the DFT is just the inner product of your signal with complex exponentially of various frequencies.

Taking the inner product of complex vectors requires taking the complex conjugate.



Reading your code, I do not believe this is correct:

cp_sin = complex(generate_sine(k, 0, 1, Fs, N) / (N/2), generate_sine(k, pi/2, 1, Fs, N) / (N/2));     


shouldn't it make a complex conjugate:

cp_sin = complex(generate_sine(k, 0, 1, Fs, N) / (N/2), -generate_sine(k, pi/2, 1, Fs, N) / (N/2));     


where I've placed a "-" in front of the second generate_sine call.

Also, can you let us know what the arguments to generate_sine do. I'm not sure what the third and fourth arguments achieve?