I wrote a code in MATLAB and then I trnaslated it to c++. when the size of my matrices are less than 600*600, my c++ code is faster than my matlab code. For matrices bigger than 600*600, I only changed the type of memory allocation and instead of stack I used heap.
For example, for vectors, Instead of:
int *fb; fb = (int*) malloc(NB*sizeof(int));
and the same for matrices. I don't know why my c++ code is now a lot slower than MATLAB.
I also get an error when I used delete function to delete the arrays on hep, so I removed all delete from my code. I'm not getting that error anymore, but It is weird because as I know, I have to delete those memories.
Can anyone help me please.
Does the way that I define my array change the result? it should not, but my result is different when I use malloc and NEW.