Y
Yudan Yi
I have a problem to copy (assign) a matrix to another matrix. Curreny, I
know copy the number using loops, while it will take some time, I wonder if
there have faster method. The following code explain my situation detailed.
double ** matrixa, **matrixb;
int nrow = 10, mcol = 10;
matrixa = initmatrix(nrow, mcol); // allocate memory a
matrixb = initmatrix(nrow, mcol); // allocate memory b
// copy a => b
for (int i=0;i<nrow;i++)
for (int j=0;j<mcol;j++)
matrixb[j] = matrixa[j];
freematrix(matrixa, nrow, mcol); // free memory
freematrix(matrixb, nrwo, mcol); // free memory
I want to find another way to copy the data from a => b without loop all the
data.
Thanks
know copy the number using loops, while it will take some time, I wonder if
there have faster method. The following code explain my situation detailed.
double ** matrixa, **matrixb;
int nrow = 10, mcol = 10;
matrixa = initmatrix(nrow, mcol); // allocate memory a
matrixb = initmatrix(nrow, mcol); // allocate memory b
// copy a => b
for (int i=0;i<nrow;i++)
for (int j=0;j<mcol;j++)
matrixb[j] = matrixa[j];
freematrix(matrixa, nrow, mcol); // free memory
freematrix(matrixb, nrwo, mcol); // free memory
I want to find another way to copy the data from a => b without loop all the
data.
Thanks