668 |
|
return(dnew); |
669 |
|
} |
670 |
|
|
671 |
+ |
/* Replace data in first matrix with data from second */ |
672 |
+ |
int |
673 |
+ |
rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int dometa) |
674 |
+ |
{ |
675 |
+ |
if (!rdst | !rsrc || (rdst->nrows != rsrc->nrows) | |
676 |
+ |
(rdst->ncols != rsrc->ncols) | |
677 |
+ |
(rdst->ncomp != rsrc->ncomp)) |
678 |
+ |
return(0); |
679 |
+ |
|
680 |
+ |
if (dometa) { /* transfer everything? */ |
681 |
+ |
rmx_reset(rdst); |
682 |
+ |
*rdst = *rsrc; |
683 |
+ |
rsrc->info = NULL; rsrc->mapped = NULL; rsrc->mtx = NULL; |
684 |
+ |
return(1); |
685 |
+ |
} |
686 |
+ |
if (rdst->mapped) |
687 |
+ |
return(0); /* XXX can't handle this case */ |
688 |
+ |
/* just matrix data -- leave metadata */ |
689 |
+ |
if (rdst->mtx) free(rdst->mtx); |
690 |
+ |
rdst->mtx = rsrc->mtx; |
691 |
+ |
rsrc->mtx = NULL; |
692 |
+ |
return(1); |
693 |
+ |
} |
694 |
+ |
|
695 |
|
/* Allocate and assign transposed matrix */ |
696 |
|
RMATRIX * |
697 |
|
rmx_transpose(const RMATRIX *rm) |