L
laclac01
I have developed my own copy function for coping my own dynamic memory
structure. It works, but I feel its not too efficient. There must be
a quicker way to copy the data. In some of the routines I have
developed the copy function gets called several hundreds of times, with
very large data structures. This can take some time....
If you can't tell by the code the data structure is a matrix for
storing complex numbers.
Attached is the code.
struct complexMatrix
{
float r;
float i;
};
typedef complexMatrix** ComplexMatrix;
typedef complexMatrix Complex;
ComplexMatrix Cmxcopy(ComplexMatrix mat, int rows, int cols)
{
int i;
int j;
ComplexMatrix temp;
temp=CmxAlloc(rows,cols);
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
{
temp[j].r=mat[0][0].r;
temp[j].i=mat[0][0].i;
}
return temp;
}
All suggesting, comments, emails, faxes, post-its and memos welcome.
structure. It works, but I feel its not too efficient. There must be
a quicker way to copy the data. In some of the routines I have
developed the copy function gets called several hundreds of times, with
very large data structures. This can take some time....
If you can't tell by the code the data structure is a matrix for
storing complex numbers.
Attached is the code.
struct complexMatrix
{
float r;
float i;
};
typedef complexMatrix** ComplexMatrix;
typedef complexMatrix Complex;
ComplexMatrix Cmxcopy(ComplexMatrix mat, int rows, int cols)
{
int i;
int j;
ComplexMatrix temp;
temp=CmxAlloc(rows,cols);
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
{
temp[j].r=mat[0][0].r;
temp[j].i=mat[0][0].i;
}
return temp;
}
All suggesting, comments, emails, faxes, post-its and memos welcome.