Hi,

I've found the answers to my questions:

1. For sort function, here are some macros defined in Rinternal.h:

/* ALTREP sorting support */

enum {SORTED_DECR_NA_1ST = -2,

SORTED_DECR = -1,

UNKNOWN_SORTEDNESS = INT_MIN, /*INT_MIN is NA_INTEGER! */

SORTED_INCR = 1,

SORTED_INCR_NA_1ST = 2,

KNOWN_UNSORTED = 0};

The macro names are pretty self-explanatory. The current implementation

only supports the ascending sort.

2. For anyNA, it goes to(Real SEXP)

===========coerce.c===========

if(REAL_NO_NA(x))

return FALSE;

ITERATE_BY_REGION(x, xD, i, nbatch, double, REAL, {

for (int k = 0; k < nbatch; k++)

if (ISNAN(xD[k]))

return TRUE;

});

===========altrep.c===========

int REAL_NO_NA(SEXP x)

{

return ALTREP(x) ? ALTREAL_DISPATCH(No_NA, x) : 0;

}

If the argument x is not an ALTREP, the function will return 0, and a

default method will be used, so there is no way to return true without loop

over the argument x right now. I hope this could be changed in the future.

Best,

Jiefei

On Tue, Sep 3, 2019 at 2:49 PM Wang Jiefei <

[hidden email]> wrote:

> Hi,

>

>

>

> I would like to figure out the meaning of the return value of these two

> functions. Here are the default definitions I find from R source code:

>

>

>

> static int altreal_Is_sorted_default(SEXP x) { return UNKNOWN_SORTEDNESS;

> }

>

> static int altreal_No_NA_default(SEXP x) { return 0; }

>

> I guess the macro *UNKNOWN_SORTEDNESS *in *Is_sorted* and 0 in *No_NA *simply means

> unknown sorted/NA status of the vector, so R will loop over the vector and

> find the answer. However, what should we return in these functions to

> indicate whether the vector has been sorted/ contains NA? My initial guess

> is 0/1 but since *NA_NA *uses 0 as its default value so it will be

> ambiguous. Are there any macros to define yes/no return values for these

> functions? I would appreciate any thought here.

>

>

>

> Best,

>

> Jiefei

>

>

>

[[alternative HTML version deleted]]

______________________________________________

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel