Hi

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;

I'm using:

and the same for matrices. I don't know why my c++ code is now a lot slower than MATLAB.

another things,

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.

Thkans

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`));

I'm using:

`int` *fb=`new` `int`[NB];

and the same for matrices. I don't know why my c++ code is now a lot slower than MATLAB.

another things,

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.

Thkans

> and the same for matrices

You mean

> I also get an error when I used delete function to delete the arrays on hep,

¿Could you be more obscure?

You mean

`int` *matrix = `new` `int`[row*col];

¿right?> I also get an error when I used delete function to delete the arrays on hep,

¿Could you be more obscure?

Topic archived. No new replies allowed.