31 |
|
return(NULL); |
32 |
|
|
33 |
|
dnew = (RMATRIX *)calloc(1, sizeof(RMATRIX)); |
34 |
< |
if (dnew) { |
35 |
< |
dnew->dtype = DTdouble; |
36 |
< |
dnew->nrows = nr; |
37 |
< |
dnew->ncols = nc; |
38 |
< |
dnew->ncomp = n; |
39 |
< |
setcolor(dnew->cexp, 1.f, 1.f, 1.f); |
40 |
< |
memcpy(dnew->wlpart, WLPART, sizeof(dnew->wlpart)); |
41 |
< |
} |
34 |
> |
if (!dnew) |
35 |
> |
return(NULL); |
36 |
> |
|
37 |
> |
dnew->dtype = DTdouble; |
38 |
> |
dnew->nrows = nr; |
39 |
> |
dnew->ncols = nc; |
40 |
> |
dnew->ncomp = n; |
41 |
> |
setcolor(dnew->cexp, 1.f, 1.f, 1.f); |
42 |
> |
memcpy(dnew->wlpart, WLPART, sizeof(dnew->wlpart)); |
43 |
> |
|
44 |
|
return(dnew); |
45 |
|
} |
46 |
|
|
642 |
|
return(rid); |
643 |
|
} |
644 |
|
|
645 |
< |
/* Duplicate the given matrix */ |
645 |
> |
/* Duplicate the given matrix (may be unallocated) */ |
646 |
|
RMATRIX * |
647 |
|
rmx_copy(const RMATRIX *rm) |
648 |
|
{ |
649 |
|
RMATRIX *dnew; |
650 |
|
|
651 |
< |
if (!rm || !rm->mtx) |
651 |
> |
if (!rm) |
652 |
|
return(NULL); |
653 |
< |
dnew = rmx_alloc(rm->nrows, rm->ncols, rm->ncomp); |
653 |
> |
dnew = rmx_new(rm->nrows, rm->ncols, rm->ncomp); |
654 |
|
if (!dnew) |
655 |
|
return(NULL); |
656 |
+ |
if (rm->mtx) { |
657 |
+ |
if (!rmx_prepare(dnew)) { |
658 |
+ |
rmx_free(dnew); |
659 |
+ |
return(NULL); |
660 |
+ |
} |
661 |
+ |
memcpy(dnew->mtx, rm->mtx, array_size(dnew)); |
662 |
+ |
} |
663 |
|
rmx_addinfo(dnew, rm->info); |
664 |
|
dnew->dtype = rm->dtype; |
665 |
|
copycolor(dnew->cexp, rm->cexp); |
666 |
|
memcpy(dnew->wlpart, rm->wlpart, sizeof(dnew->wlpart)); |
658 |
– |
memcpy(dnew->mtx, rm->mtx, array_size(dnew)); |
667 |
|
return(dnew); |
668 |
|
} |
669 |
|
|