Re: [R] R C API resize matrice

2019-06-15 Thread King Jiefei
Hi Morgan, In the example, please ignore `C_set_altrep_subset_method("compressedMatrix", get_subset_func)`. You do not have to define it to run the example. Best, Jiefei On Sat, Jun 15, 2019 at 11:45 AM King Jiefei wrote: > Hi Morgan, > > Thanks for the context, it seems like you want to compr

Re: [R] R C API resize matrice

2019-06-15 Thread King Jiefei
Hi Morgan, Thanks for the context, it seems like you want to compress your matrix and you expect the "new" matrix should contain the same amount of information as the "old" one, it is correct? If this is the case, since you are using C++ code, a safer but imperfect solution is to find a C++ data

Re: [R] R C API resize matrice

2019-06-15 Thread Morgan Morgan
Hi Jiedei, Thank you for your reply. To give you a bit more context, I wrote a function that find all the positions (index) of all small matrices inside a larger matrix. At the beginning I pre-allocate let's say a 100 by 2 matrix. However a lot of values might remain empty in this matrix of posti

Re: [R] R C API resize matrice

2019-06-14 Thread King Jiefei
Hi, I don't think there is a native R API to do what you want here, but if the matrix is only used by you and not be exported to the other user, you can hack R data structure to achieve that goal. Because there is not too much context of your question, I will assume the whole point of resizing a

Re: [R] R C API resize matrice

2019-06-14 Thread Bert Gunter
Please do not re-post -- you have asked this before here. As this list is about R programming help, it is perhaps not surprising that you did not receive a reply. You might try R-devel instead where " Questions likely to prompt discussion unintelligible to non-programmers or topics that are too te

[R] R C API resize matrice

2019-06-14 Thread Morgan Morgan
Hi, Is there a way to resize a matrix defined as follows: SEXP a = PROTECT(allocMatrix(INTSXP, 10, 2)); int *pa = INTEGER(a) To row = 5 and col = 1 or do I have to allocate a second matrix "b" with pointer *pb and do a "for" loop to transfer the value of a to b? Thank you Best regards Morgan