- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to convert from COO to CSR without making a new copy of my matrix. Is it OK to have actual arguments point to the same arrays, i.e. acsr and acoo are the same array and similar for the index arrays ? The help file does not specify.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In general, unless the documentation says so explicitly, it is not safe to have aliased arguments passed to library subroutines. Furthermore, In Fortran there is a restriction on procedure arguments being aliased:
12.5.2.13 Restrictions on entities associated with dummy arguments
1 While an entity is associated with a dummy argument, the following restrictions hold.
....
(3) Action that affects the value of the entity or any subobject of it shall be taken only through the dummy argument
The compiler may not be able to detect if your code violates this requirement, and it is hard to catch associated bugs at run time.
In the case that you mentioned, the COO representation contains two index arrays of size Nnz, whereas the CSR representation contains an index array of size Nnz and a row-pointer array of size N+1, so one output array does not match any corresponding input array in size.
Why take the risk? If the arrays are dynamically allocated, it is easy enough to discard the COO arrays once the conversion is completed, or to reuse the allocated memory for some other useful purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrew,
Right, as micej noted that the aliasing pointers is not supported unless explicitly mentioned in the documentation.
Regards,
Ying
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page