← all packages

clue

native: 22 functions analysed · 22 typed · 0 untypeable · 0 timed out · 10 entry points (10 typed) · R: 453 definitions, 102 typed strict, 369 gradual, prelude debt 138 · fuzzing: 93 definitions, 0 unsound, 83 accept calls outside their domain · tyr dc7f1a7 · Rsem 5c142d7 · NativeSem 770a1eb · rstt 2b2696f unpinned

Native functions

C functions reachable from an entry point
22 / 22 (100.0%)
typed
22 / 22 (100.0%)

Native → R

entry points
10 / 10 (100.0%)
defined in src/
10 / 10 (100.0%)
typed
10 / 10 (100.0%)
bound in R
10 / 10 (100.0%)

R definitions

named top-level definitions
453 / 453 (100.0%)
not blocked by an unbound native symbol
453 / 453 (100.0%)
typed, gradual
369 / 453 (81.5%)
typed, strict
102 / 453 (22.5%)
138 of the strict failures are a name missing from the prelude.
side
mode
531 / 531

Native functions 22

ap_assignment typed

([*struct AP, *c_int_na] -> c_int_na)&([c_null, *c_int_na] -> empty)
timing: 0.345 s
source
int ap_assignment(AP *p, int *res)
{
    int i;

    if(p->s == NULL)
	ap_hungarian(p);

    for(i = 0; i < p->n; i++)
	res[i] = p->s[i];
    
    return p->n;
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:69

ap_create_problem typed

[*c_double, c_int_na] -> *struct AP
timing: 2.29 s
source
AP *ap_create_problem(double *t, int n)
{
    int i,j;
    AP *p;
    
    p = (AP*) malloc(sizeof(AP)); 
    if(p == NULL)
	return NULL;
    
    p->n = n;

    p->C  = (double **) malloc((n + 1) * sizeof(double *));
    p->c  = (double **) malloc((n + 1) * sizeof(double *));
    if(p->C == NULL || p->c == NULL)
	return NULL;
    
    for(i = 1; i <= n; i++){
	p->C[i] = (double *) calloc(n + 1, sizeof(double));
	p->c[i] = (double *) calloc(n + 1, sizeof(double));
	if(p->C[i] == NULL || p->c[i] == NULL)
	    return NULL;
    }
    
    
    for(i = 1; i <= n; i++)
	for( j = 1; j <= n; j++){
	    p->C[i][j] = t[n*(j - 1) + i - 1];
	    p->c[i][j] = t[n*(j - 1) + i - 1];
	}
    p->cost = 0;
    p->s = NULL;
    p->f = NULL;
    return p;
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:209

ap_free typed

([*struct AP] -> ())&([c_null] -> empty)
timing: 0.715 s
source
void ap_free(AP *p)
{
    int i;

    free(p->s);
    free(p->f);

    for(i = 1; i <= p->n; i++){
	free(p->C[i]);
	free(p->c[i]);
    }
    
    free(p->C);
    free(p->c);
    free(p);
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:245

ap_hungarian typed

([*struct AP] -> ())&([c_null] -> empty)
timing: 1.54 s
source
void ap_hungarian(AP *p)
{
    int      n;            /* size of problem */
    int    *ri;            /* covered rows    */
    int    *ci;            /* covered columns */
    time_t start, end;     /* timer           */ 
    int i, j, ok;

    start = time(0);

    n = p->n;
    p->runs = 0;

    /* allocate memory */
    p->s = calloc(1 + n, sizeof(int));
    p->f = calloc(1 + n, sizeof(int));
    
    ri = calloc(1 + n, sizeof(int));
    ci = calloc(1 + n, sizeof(int));
    
    if(ri == NULL || ci == NULL || p->s == NULL || p->f == NULL)
	error("ap_hungarian: could not allocate memory!");

    preprocess(p);
    preassign(p);

    while(p->na < n){
	if(REDUCE == cover(p, ri, ci))
	    reduce(p, ri, ci);
	++p->runs;
    }

    end = time(0);  
  
    p->rtime = end - start;
  
    /* check if assignment is a permutation of (1..n) */
    for(i = 1; i <= n; i++){
	ok = 0;
	for(j = 1; j <= n; j++)
	    if(p->s[j] == i)
		++ok;
	if(ok != 1)
	    error("ap_hungarian: error in assigment, is not a permutation!");
    }

    /* calculate cost of assignment */
    p->cost = 0;
    for(i = 1; i <= n; i++)
	p->cost+= p->C[i][p->s[i]];
    
    /* reset result back to base-0 indexing */
    for(i = 1; i <= n; i++)
	p->s[i - 1] = p->s[i] - 1;
    
    /* free memory */
    
    free(ri);
    free(ci);
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:7

clue_dissimilarity_count_inversions typed entry .C

[DBL, DBL, INT, DBL] --> c_void
timing: 0.003 s
source
clue_dissimilarity_count_inversions(double *x, double *y, Sint *n,
				    double *count)
{
    Sint i, j;
    for(i = 0; i < *n; i++)
	for(j = 0; j < *n; j++)
	    if((clue_sign(x[i] - x[j]) * clue_sign(y[i] - y[j])) < 0)
		(*count)++;
}
/__w/r-typing/r-typing/work/sources/clue/src/clue.c:28

clue_sign typed

[c_double] -> c(-1)
timing: 0.005 s
source
clue_sign(double x)
{
    if(x == 0) return(0);
    return((x > 0) ? 1 : -1);
}
/__w/r-typing/r-typing/work/sources/clue/src/clue.c:21

clue_vector_to_square_matrix typed

[*c_double, c_int] -> *(*c_double)
timing: 0.459 s
source
double **clue_vector_to_square_matrix(double *x, Sint n)
{
    double **data, *val;
    Sint i, j;
    data = (double **) R_alloc(n, sizeof(double));
    for(i = 0; i < n; i++) {
        data[i] = (double *) R_alloc(n, sizeof(double));
        val = x + i;
        for(j = 0; j < n; j++, val += n)
            data[i][j] = *val;
    }
    return(data);
}
/__w/r-typing/r-typing/work/sources/clue/src/clue.c:6

cover typed

([*struct AP, *c_int_na, *c_int_na] -> c_true)&([c_null, *c_int_na, *c_int_na] -> empty)
timing: 1.84 s
source
int cover(AP *p, int *ri, int *ci)
{
    int *mr, i, r;
    int n;
    
    n = p->n;
    mr = calloc(1 + p->n, sizeof(int));
    
    /* reset cover indices */
    for(i = 1; i <= n; i++){
	if(p->s[i] == UNASSIGNED){
	    ri[i] = UNCOVERED;
	    mr[i] = MARKED;
	}
	else
	    ri[i] = COVERED;
	ci[i] = UNCOVERED;
    }

    while(TRUE){
	/* find marked row */
	r = 0;
	for(i = 1; i <= n; i++)
	    if(mr[i] == MARKED){
		r = i;
		break;
	    }

	if(r == 0)
	    break;
	for(i = 1; i <= n; i++)
	    if(p->c[r][i] == 0 && ci[i] == UNCOVERED){
		if(p->f[i]){
		    ri[p->f[i]] = UNCOVERED;
		    mr[p->f[i]] = MARKED;
		    ci[i] = COVERED;
		}else{
		    if(p->s[r] == UNASSIGNED)
			++p->na;
		    
		    p->f[p->s[r]] = 0;
		    p->f[i] = r;
		    p->s[r] = i;
		    
		    free(mr);
		    return NOREDUCE;
		}
	    }
	mr[r] = UNMARKED;
    }
    free(mr);
    return REDUCE;
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:351

deviation_from_additivity typed entry .C

[DBL, INT, DBL, LGL] --> c_void
timing: 0.005 s
source
deviation_from_additivity(double *x, int *n, double *v, int *max)
{
    double **D, p, delta, A, B, C;
    int i, j, k, l;

    D = clue_vector_to_square_matrix(x, *n);

    p = 0;
    for(i = 0; i < *n - 3; i++)
	for(j = i + 1; j < *n - 2; j++)
	    for(k = j + 1; k < *n - 1; k++)
		for(l = k + 1; l < *n; l++) {
		    A = D[i][j] + D[k][l];
		    B = D[i][k] + D[j][l];
		    C = D[i][l] + D[j][k];
		    if((A <= B) && (A <= C))
			delta = (C - B);
		    else if(B <= C)
			delta = (A - C);
		    else
			delta = (B - A);
		    if(*max)
			p = fmax2(p, fabs(delta));
		    else
			p += delta * delta;
		}

    *v = p;
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:106

deviation_from_additivity_gradient typed entry .C

[DBL, INT, DBL] --> c_void
timing: 0.003 s
source
deviation_from_additivity_gradient(double *x, int *n, double *out)
{
    double **D, **G, A, B, C, delta;
    int i, j, k, l;

    D = clue_vector_to_square_matrix(x, *n);
    G = clue_vector_to_square_matrix(out, *n);

    for(i = 0; i < *n - 3; i++)
	for(j = i + 1; j < *n - 2; j++)
	    for(k = j + 1; k < *n - 1; k++)
		for(l = k + 1; l < *n; l++) {
		    A = D[i][j] + D[k][l];
		    B = D[i][k] + D[j][l];
		    C = D[i][l] + D[j][k];
		    if((A <= B) && (A <= C)) {
			delta = 2 * (B - C);
			G[i][l] -= delta;
			G[j][k] -= delta;
			G[i][k] += delta;
			G[j][l] += delta;
		    }
		    else if(B <= C) {
			delta = 2 * (C - A);
			G[i][l] += delta;
			G[j][k] += delta;
			G[i][j] -= delta;
			G[k][l] -= delta;
		    }
		    else {
			delta = 2 * (A - B);
			G[i][k] -= delta;
			G[j][l] -= delta;
			G[i][j] += delta;
			G[k][l] += delta;
		    }
		}

    for(i = 0; i < *n; i++)
	for(j = 0; j < *n; j++)
	    *out++ = G[i][j];

}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:137

deviation_from_ultrametricity typed entry .C

[DBL, INT, DBL, LGL] --> c_void
timing: 0.005 s
source
deviation_from_ultrametricity(double *x, int *n, double *v, int *max)
{
    double **D, p, delta, A, B, C;
    int i, j, k;

    D = clue_vector_to_square_matrix(x, *n);

    p = 0;
    for(i = 0; i < *n - 2; i++)
        for(j = i + 1; j < *n - 1; j++) {
	    A = D[i][j];
            for(k = j + 1; k < *n; k++) {
		B = D[i][k];
		C = D[j][k];
		if((A <= B) && (A <= C))
		    delta = C - B;
		else if(B <= C)
		    delta = A - C;
		else
		    delta = B - A;
		if(*max)
		    p = fmax2(p, fabs(delta));
		else
		    p += delta * delta;
	    }
	}

    *v = p;
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:36

deviation_from_ultrametricity_gradient typed entry .C

[DBL, INT, DBL] --> c_void
timing: 0.003 s
source
deviation_from_ultrametricity_gradient(double *x, int *n, double *out)
{
    double **D, **G, A, B, C, delta;
    int i, j, k;

    D = clue_vector_to_square_matrix(x, *n);
    G = clue_vector_to_square_matrix(out, *n);

    for(i = 0; i < *n - 2; i++)
        for(j = i + 1; j < *n - 1; j++) {
	    A = D[i][j];
            for(k = j + 1; k < *n; k++) {
		B = D[i][k];
		C = D[j][k];
		if((A <= B) && (A <= C)) {
		    delta = 2 * (B - C);
		    G[i][k] += delta;
		    G[j][k] -= delta;
		}
		else if(B <= C) {
		    delta = 2 * (C - A);
		    G[j][k] += delta;
		    G[i][j] -= delta;
		}
		else {
		    delta = 2 * (A - B);
		    G[i][j] += delta;
		    G[i][k] -= delta;
		}
	    }
	}

    for(i = 0; i < *n; i++)
	for(j = 0; j < *n; j++)
	    *out++ = G[i][j];

}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:67

isort3 typed

([*c_int_na, *c_int_na, *c_int_na] -> ())&([*c_int_na, *c_int_na, c_null] | [*c_int_na, c_null, *c_int_na] | [c_null, *c_int_na, *c_int_na] -> empty)
timing: 0.141 s
source
isort3(int *i, int *j, int *k)
{
    iwork3[0] = *i;
    iwork3[1] = *j;
    iwork3[2] = *k;
    R_isort(iwork3, 3);
    *i = iwork3[0];
    *j = iwork3[1];
    *k = iwork3[2];
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:10

isort4 typed

([*c_int_na, *c_int_na, *c_int_na, *c_int_na] -> ())&([*c_int_na, *c_int_na, *c_int_na, c_null] | [*c_int_na, *c_int_na, c_null, *c_int_na] | [*c_int_na, c_null, *c_int_na, *c_int_na] | [c_null, *c_int_na, *c_int_na, *c_int_na] -> empty)
timing: 0.198 s
source
isort4(int *i, int *j, int *k, int *l)
{
    iwork4[0] = *i;
    iwork4[1] = *j;
    iwork4[2] = *k;
    iwork4[3] = *l;
    R_isort(iwork4, 4);
    *i = iwork4[0];
    *j = iwork4[1];
    *k = iwork4[2];
    *l = iwork4[3];
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:22

ls_fit_addtree_by_iterative_projection typed entry .C

[DBL, INT, INT, INT, INT, DBL, LGL] --> c_void
timing: 0.006 s
source
ls_fit_addtree_by_iterative_projection(double *d, int *n, int *order,
				       int *maxiter, int *iter,
				       double *tol, int *verbose)
{
    double A, B, C, **D, DQ, delta;
    int i, i1, j, j1, k, k1, l, l1;

    D = clue_vector_to_square_matrix(d, *n);

    for(*iter = 0; *iter < *maxiter; (*iter)++) {
	delta = 0;
	if(*verbose) Rprintf("Iteration: %d, ", *iter);
	for(i1 = 0; i1 < *n - 3; i1++)
	    for(j1 = i1 + 1; j1 < *n - 2; j1++)
		for(k1 = j1 + 1; k1 < *n - 1; k1++)
		    for(l1 = k1 + 1; l1 < *n; l1++) {
			i = order[i1];
			j = order[j1];
			k = order[k1];
			l = order[l1];
			isort4(&i, &j, &k, &l);
			A = D[i][j] + D[k][l];
			B = D[i][k] + D[j][l];
			C = D[i][l] + D[j][k];
			if((A <= B) && (A <= C)) {
			    DQ = (C - B) / 4;
			    D[i][l] -= DQ;
			    D[j][k] -= DQ;
			    D[i][k] += DQ;
			    D[j][l] += DQ;
			    delta += fabs(C - B);
			}
			else if(B <= C) {
			    DQ = (A - C) / 4;
			    D[i][l] += DQ;
			    D[j][k] += DQ;
			    D[i][j] -= DQ;
			    D[k][l] -= DQ;
			    delta += fabs(A - C);
			}
			else {
			    DQ = (B - A) / 4;
			    D[i][k] -= DQ;
			    D[j][l] -= DQ;
			    D[i][j] += DQ;
			    D[k][l] += DQ;
			    delta += fabs(B - A);
			}
		    }
	
	if(*verbose) Rprintf("change: %f\n", delta);	
	if(delta < *tol)
	    break;
	   
    }

    for(i = 0; i < *n - 1; i++)
	for(j = i + 1; j < *n; j++)
	    D[j][i] = D[i][j];

    /* And now write results back.
       Could make this more efficient, of course ...
    */
    for(j = 0; j < *n; j++)
	for(i = 0; i < *n; i++)
	    *d++ = D[i][j];
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:407

ls_fit_addtree_by_iterative_reduction typed entry .C

[DBL, INT, INT, INT, INT, DBL, LGL] --> c_void
timing: 0.006 s
source
ls_fit_addtree_by_iterative_reduction(double *d, int *n, int *order,
				      int *maxiter, int *iter,
				      double *tol, int *verbose)
{
    /* Once we have ls_fit_ultrametric_by_iterative_reduction() we can
       always do this as well ...

       See page 67f in Barthelemy and Guenoche.
     
     */
    
    double A, B, C, **D, DQ, delta, tmp, N3;
    int i, i1, j, j1, k, k1, l, l1;

    D = clue_vector_to_square_matrix(d, *n);
    /* And initialize the upper half of D ("work array") to 0.
       (Yes, this could be done more efficiently by just propagating the
       veclh dist representation.)
    */
    for(i = 0; i < *n - 1; i++)
	for(j = i + 1; j < *n; j++)
	    D[i][j] = 0;

    N3 = (*n - 2) * (*n - 3) / 2;

    for(*iter = 0; *iter < *maxiter; (*iter)++) {
	if(*verbose) Rprintf("Iteration: %d, ", *iter);
	for(i1 = 0; i1 < *n - 3; i1++)
	    for(j1 = i1 + 1; j1 < *n - 2; j1++)
		for(k1 = j1 + 1; k1 < *n - 1; k1++)
		    for(l1 = k1 + 1; l1 < *n; l1++) {
			i = order[i1];
			j = order[j1];
			k = order[k1];
			l = order[l1];
			isort4(&i, &j, &k, &l);
			A = D[j][i] + D[l][k];
			B = D[k][i] + D[l][j];
			C = D[l][i] + D[k][j];
			if((A <= B) && (A <= C)) {
			    /* Case 1: 5090 */
			    DQ = (C - B) / 4;
			    D[i][l] -= DQ;
			    D[j][k] -= DQ;
			    D[i][k] += DQ;
			    D[j][l] += DQ;
			}
			else if(B <= C) {
			    /* Case 2: 5120 */
			    DQ = (A - C) / 4;
			    D[i][l] += DQ;
			    D[j][k] += DQ;
			    D[i][j] -= DQ;
			    D[k][l] -= DQ;
			}
			else {
			    /* Case 3: 5150 */
			    DQ = (B - A) / 4;
			    D[i][k] -= DQ;
			    D[j][l] -= DQ;
			    D[i][j] += DQ;
			    D[k][l] += DQ;
			}
		    }
	
	delta = 0;
	for(i = 0; i < *n - 1; i++)
	    for(j = i + 1; j < *n; j++) {
		tmp = D[i][j] / N3;
		D[j][i] += tmp;
		D[i][j] = 0;
		delta += fabs(tmp);
	    }

	if(*verbose) Rprintf("change: %f\n", delta);	
	if(delta < *tol)
	    break;
	   
    }

    /* And now write results back.
       Could make this more efficient, of course ...
    */
    for(j = 0; j < *n; j++)
	for(i = 0; i < *n; i++)
	    *d++ = D[i][j];
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:318

ls_fit_ultrametric_by_iterative_projection typed entry .C

[DBL, INT, INT, INT, INT, DBL, LGL] --> c_void
timing: 0.005 s
source
ls_fit_ultrametric_by_iterative_projection(double *d, int *n, int *order,
					   int *maxiter, int *iter,
					   double *tol, int *verbose)
{
    double A, B, C, **D, delta;
    int i, i1, j, j1, k, k1;    

    D = clue_vector_to_square_matrix(d, *n);

    for(*iter = 0; *iter < *maxiter; (*iter)++) {
	if(*verbose) Rprintf("Iteration: %d, ", *iter);
	delta = 0;
	for(i1 = 0; i1 < *n - 2; i1++)
	    for(j1 = i1 + 1; j1 < *n - 1; j1++)
		for(k1 = j1 + 1; k1 < *n; k1++) {
		    i = order[i1];
		    j = order[j1];
		    k = order[k1];
		    isort3(&i, &j, &k);
		    A = D[i][j];		    
		    B = D[i][k];
		    C = D[j][k];
		    if((A <= B) && (A <= C)) {
			D[i][k] = D[j][k] = (B + C) / 2;
			delta += fabs(B - C);
		    }
		    else if(B <= C) {
			D[i][j] = D[j][k] = (C + A) / 2;
			delta += fabs(C - A);
		    }
		    else {
			D[i][j] = D[i][k] = (A + B) / 2;
			delta += fabs(A - B);
		    }

		}
	
	if(*verbose) Rprintf("change: %f\n", delta);
	if(delta < *tol)
	    break;
    }
	
    for(i = 0; i < *n - 1; i++)
	for(j = i + 1; j < *n; j++)
	    D[j][i] = D[i][j];

    /* And now write results back.
       Could make this more efficient, of course ...
    */
    for(j = 0; j < *n; j++)
	for(i = 0; i < *n; i++)
	    *d++ = D[i][j];
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:263

ls_fit_ultrametric_by_iterative_reduction typed entry .C

[DBL, INT, INT, INT, INT, DBL, LGL] --> c_void
timing: 0.006 s
source
ls_fit_ultrametric_by_iterative_reduction(double *d, int *n, int *order,
					  int *maxiter, int *iter,
					  double *tol, int *verbose)
{
    double A, B, C, **D, DQ, delta, tmp;
    int i, i1, j, j1, k, k1, N3;

    D = clue_vector_to_square_matrix(d, *n);
    /* And initialize the upper half of D ("work array") to 0.
       (Yes, this could be done more efficiently by just propagating the
       veclh dist representation.)
    */
    for(i = 0; i < *n - 1; i++)
	for(j = i + 1; j < *n; j++)
	    D[i][j] = 0;

    N3 = (*n - 2);

    for(*iter = 0; *iter < *maxiter; (*iter)++) {
	if(*verbose) Rprintf("Iteration: %d, ", *iter);
	for(i1 = 0; i1 < *n - 2; i1++)
	    for(j1 = i1 + 1; j1 < *n - 1; j1++)
		for(k1 = j1 + 1; k1 < *n; k1++) {
		    i = order[i1];
		    j = order[j1];
		    k = order[k1];
		    isort3(&i, &j, &k);
		    A = D[j][i];
		    B = D[k][i];
		    C = D[k][j];
		    /*
		      <FIXME>
		      B & G have a divisor of 2 for case 1 and 4 for
		      cases 2 and 3 ... clearly, we should use the same
		      in all cases, but should it be 2 or 4?
		      </FIXME>
		    */
		    if((A <= B) && (A <= C)) {
			/* Case 1: 5080 */
			DQ = (C - B) / 2;
			D[i][k] += DQ;
			D[j][k] -= DQ;
		    }
		    else if(B <= C) {
			/* Case 2: 5100 */
			DQ = (C - A) / 2;
			D[i][j] += DQ;
			D[j][k] -= DQ;
		    }
		    else {
			/* Case 3: 5120 */
			DQ = (B - A) / 2;
			D[i][j] += DQ;
			D[i][k] -= DQ;
		    }
		}

	delta = 0;
	for(i = 0; i < *n - 1; i++)
	    for(j = i + 1; j < *n; j++) {
		tmp = D[i][j] / N3;
		D[j][i] += tmp;
		D[i][j] = 0;
		delta += fabs(tmp);
	    }

	if(*verbose) Rprintf("change: %f\n", delta);
	if(delta < *tol)
	    break;
	   
    }

    /* And now write results back.
       Could make this more efficient, of course ...
    */
    for(j = 0; j < *n; j++)
	for(i = 0; i < *n; i++)
	    *d++ = D[i][j];
}
/__w/r-typing/r-typing/work/sources/clue/src/trees.c:182

preassign typed

([*struct AP] -> ())&([c_null] -> empty)
timing: 3.70 s
source
void preassign(AP *p)
{
    int i, j, min, r, c, n, count;
    int *ri, *ci, *rz, *cz;
    
    n = p->n;
    p->na = 0;
    
    /* row and column markers */
    ri = calloc(1 + n, sizeof(int));
    ci = calloc(1 + n, sizeof(int));
    
    /* row and column counts of zeroes */
    rz = calloc(1 + n, sizeof(int));
    cz = calloc(1 + n, sizeof(int));
    
    for(i = 1; i <= n; i++){
	count = 0;
	for(j = 1; j <= n; j++)
	    if(p->c[i][j] == 0)
		++count;
	rz[i] = count;
    }
    
    for(i = 1; i <= n; i++){
	count = 0;
	for(j = 1; j <= n; j++)
	    if(p->c[j][i] == 0)
		++count;
	cz[i] = count;
    }
    
    while(TRUE){
	/* find unassigned row with least number of zeroes > 0 */
	min = INT_MAX;
	r = 0;
	for(i = 1; i <= n; i++)
	    if(rz[i] > 0 && rz[i] < min && ri[i] == UNASSIGNED){
		min = rz[i];
		r = i;
	    }
	/* check if we are done */
	if(r == 0)
	    break;
	
	/* find unassigned column in row r with least number of zeroes */
	c = 0;
	min = INT_MAX;
	for(i = 1; i <= n; i++)
	    if(p->c[r][i] == 0 && cz[i] < min && ci[i] == UNASSIGNED){
		min = cz[i];
		c = i;
	    }
	
	if(c){
	    ++p->na;
	    p->s[r] = c;
	    p->f[c] = r;
	    
	    ri[r] = ASSIGNED;
	    ci[c] = ASSIGNED;
	    
	    /* adjust zero counts */
	    cz[c] = 0;
	    for(i = 1; i <= n; i++)
		if(p->c[i][c] == 0)
		    --rz[i];
	}
    }
    
    /* free memory */
    free(ri);
    free(ci);
    free(rz);
    free(cz);
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:432

preprocess typed

([*struct AP] -> ())&([c_null] -> empty)
timing: 2.34 s
source
void preprocess(AP *p)
{
    int i, j, n;
    double min;
    
    n = p->n;
    
    /* subtract column minima in each row */
    for(i = 1; i <= n; i++){
	min = p->c[i][1];
	for(j = 2; j <= n; j++)
	    if(p->c[i][j] < min)
		min = p->c[i][j];
	for(j = 1; j <= n; j++)
	    p->c[i][j]-= min;
    }
    
    /* subtract row minima in each column */
    for(i = 1; i <= n; i++){
	min = p->c[1][i];
	for(j = 2; j <= n; j++)
	    if(p->c[j][i] < min)
		min = p->c[j][i];
	for(j = 1; j <= n; j++)
	    p->c[j][i]-= min;
    }
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:509

reduce typed

([*struct AP, *c_int_na, *c_int_na] -> ())&([c_null, *c_int_na, *c_int_na] -> empty)
timing: 3.05 s
source
void reduce(AP *p, int *ri, int *ci)
{
    int i, j, n;
    double min;
    
    n = p->n;
    
    /* find minimum in uncovered c-matrix */
    min = DBL_MAX;
    for(i = 1; i <= n; i++)
	for(j = 1; j <= n; j++)
	    if(ri[i] == UNCOVERED && ci[j] == UNCOVERED){
		if(p->c[i][j] < min)
		    min = p->c[i][j];
	    }
    
    /* subtract min from each uncovered element and add it to each element */
    /* which is covered twice                                              */
    for(i = 1; i <= n; i++)
	for(j = 1; j <= n; j++){
	    if(ri[i] == UNCOVERED && ci[j] == UNCOVERED)
		p->c[i][j]-= min;
	    if(ri[i] == COVERED && ci[j] == COVERED)
		p->c[i][j]+= min;
	}
}
/__w/r-typing/r-typing/work/sources/clue/src/assignment.c:405

solve_LSAP typed entry .C

[DBL, INT, INT] --> c_void
timing: 0.003 s
source
solve_LSAP(double *c, Sint *n, Sint *p)
{
    AP *ap;
    ap = ap_create_problem(c, *n);
    ap_hungarian(ap);
    ap_assignment(ap, p);
    ap_free(ap);
}
/__w/r-typing/r-typing/work/sources/clue/src/lsap.c:6

R definitions 509

R/AAA.R

.false typed any: x accepts outside

((x: any) -> ff<>)<>
timing: 0.007 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.false()ff<> with { }
source
.false <- function(x) FALSE
R/AAA.R:5

.true typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.008 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.true()tt<> with { }
source
.true <- function(x) TRUE
R/AAA.R:6

.structure untypeabletyped

unbound variable (line 11)
unbound: attributes<- — a name the prelude does not declare
error detail
name: attributes<-
gradual mode: typed
((x: <...> | <> with { }, ...: any) | (x: <> with (list & ~{ }), ...: any) -> any)<>
timing: 0.456 s
source
.structure <-
function(x, ...)
    `attributes<-`(x, c(attributes(x), list(...)))
R/AAA.R:9
R/lsap.R

solve_LSAP untypeable

untypeable application of base::> (line 9)
error detail
argument: @(INT1<> | null, INT1<> | null)
failing call: base::>(NULL, NULL)
timing: 0.171 s
source
solve_LSAP <-
function(x, maximum = FALSE)
{
    if(!is.matrix(x) || any(x < 0))
        stop("x must be a matrix with nonnegative entries.")

    nr <- nrow(x)
    nc <- ncol(x)
    if(nr > nc)
        stop("x must not have more rows than columns.")
    if(nc > nr)
        x <- rbind(x, matrix(2 * sum(x), nc - nr, nc))

    if(maximum) x <- max(x) - x

    storage.mode(x) <- "double"
    out <- .C(C_solve_LSAP,
              x,
              as.integer(nc),
              p = integer(nc))$p + 1
    out <- out[seq_len(nr)]
    class(out) <- "solve_LSAP"
    out
}
R/lsap.R:1

print.solve_LSAP untypeabletyped

unbound variable (line 31)
unbound: strwrap — a name the prelude does not declare
error detail
name: strwrap
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.028 s
source
print.solve_LSAP <-
function(x, ...)
{
    writeLines(c("Optimal assignment:",
                 gsub("x", " ",
                      strwrap(paste(seq_along(x), x,
                                    sep = "x=>x", collapse = ", ")))))
    invisible(x)
}
R/lsap.R:26
R/utilities.R

.dist_from_vector untypeable

unbound variable (line 11)
unbound: sqrt — a name the prelude does not declare
error detail
name: sqrt
timing: 0.112 s
source
.dist_from_vector <-
function(x, n = NULL, labels = NULL)
{
    ## This might be useful as as.dist.vector, perhaps without the extra
    ## argument n then which we only have for minimal performance gains.
    if(is.null(n))
        n <- as.integer((sqrt(1 + 8 * length(x)) + 1) / 2)
    attr(x, "Size") <- n
    if(!is.null(labels))
        attr(x, "Labels") <- labels
    class(x) <- "dist"
    x
}
R/utilities.R:5

.one_entry_per_column untypeable

untypeable application of base::seq_len (line 35)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.023 s
source
.one_entry_per_column <-
function(x, j)
{
    ## For a matrix x and a vector of column indices j_1, ..., j_n where
    ## n is the number of rows of x, get x[1,j_1], ..., x[n,j_n].

    ## <NOTE>
    ## This used to have
    ##   if(!is.matrix(x))
    ##     stop("Argument 'x' must be a matrix.")
    ## but that will fail for sparse matrix classes.
    ## So let us hope for the best ...
    ## </NOTE>

    x[cbind(seq_len(nrow(x)), j)]
}
R/utilities.R:21

.one_entry_per_column<- untypeable

untypeable application of base::seq_len (line 49)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.031 s
source
".one_entry_per_column<-" <-
function(x, j, value)
{
    ## <NOTE>
    ## This used to have
    ##   if(!is.matrix(x))
    ##     stop("Argument 'x' must be a matrix.")
    ## but that will fail for sparse matrix classes.
    ## So let us hope for the best ...
    ## </NOTE>

    x[cbind(seq_len(nrow(x)), j)] <- value
    x
}
R/utilities.R:38

.symmetric_matrix_from_veclh untypeable

unbound variable (line 61)
unbound: sqrt — a name the prelude does not declare
error detail
name: sqrt
timing: 0.086 s
source
.symmetric_matrix_from_veclh <-
function(x, n = NULL)
{
    ## In essence the same as as.matrix.dist, but without handling the
    ## additional attributes that dist objects might have.
    if(is.null(n))
        n <- as.integer((sqrt(1 + 8 * length(x)) + 1) / 2)
    M <- matrix(0, n, n)
    M[row(M) > col(M)] <- x
    M + t(M)
}
R/utilities.R:55

.weighted_mean_of_object_dissimilarities untypeabletyped

unbound variable (line 73)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
gradual mode: typed
((x: any, w: null?) -> any)<>
timing: 0.780 s
source
.weighted_mean_of_object_dissimilarities <-
function(x, w = NULL)
{
    w <- if(is.null(w)) {
        rep.int(1, length(x))
    } else {
        rep_len(w, length(x))
    }
    ## (Need the latter because we want w / sum(w) ...)
    dissimilarities <- lapply(x, cl_object_dissimilarities)
    m <- rowSums(mapply(`*`, dissimilarities, w / sum(w)))
    labels <- attr(dissimilarities[[1L]], "Labels")
    .dist_from_vector(m, labels = labels)
}
R/utilities.R:69

.weighted_sum_of_matrices untypeable

unbound variable (line 93)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
timing: 0.194 s
source
.weighted_sum_of_matrices <-
function(x, w = NULL, nr = NULL)
{
    ## Quite often we need to compute weighted sums \sum_b w_b X_b of
    ## conforming matrices \{ X_b \}.  If x is a list containing the
    ## matrices and w the vector of weights, it seems that one
    ## reasonably efficient way of doing this is the following.
    if(is.null(w)) w <- rep.int(1, length(x))
    if(is.null(nr)) nr <- NROW(x[[1L]])
    matrix(rowSums(mapply(`*`, x, w)), nr)
}
R/utilities.R:86

.weighted_sum_of_vectors untypeable

unbound variable (line 104)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
timing: 0.144 s
source
.weighted_sum_of_vectors <-
function(x, w = NULL)
{
    ## See above.
    if(is.null(w)) w <- rep.int(1, length(x))
    rowSums(mapply(`*`, x, w))
}
R/utilities.R:100

.make_container untypeabletyped

unbound variable (line 116)
unbound: unique — a name the prelude does not declare
error detail
name: unique
gradual mode: typed
((x: any, classes: any, properties: any?) -> any)<>
timing: 0.017 s
source
.make_container <-
function(x, classes, properties = NULL)
{
    out <- list(.Data = x, .Meta = properties)
    class(out) <- unique(classes)
    out
}
R/utilities.R:112

.get_representation typed accepts outside

∀'a. ((x: { .Data: 'a, any }) -> 'a)<>
timing: 0.019 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { .Data: 'I6569, any }) -> 'I6569)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:env.get_representation("x" = new.env())null
xkind:lang.get_representation("x" = quote(f(x)))null
source
.get_representation <-
function(x)
    x$.Data
R/utilities.R:122

.get_properties typed accepts outside

∀'a. ((x: { .Meta: 'a, any }) -> 'a)<>
timing: 0.024 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { .Meta: 'I6577, any }) -> 'I6577)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:null.get_properties(NULL)null
source
.get_properties <-
function(x)
    x$.Meta
R/utilities.R:125

.get_property typed any: which fuzz ok

∀'a,'b,'c. (((x: { .Meta: <@"[[", ...>, any }, which: any) -> any) & ((x: { .Meta: v('c)<~@"[[", ...>, any }, which: CHR | DBL | INT | LGL | RAW) -> v1('c)<>) & ((x: { .Meta: { 'a }<~@"[[", ...>, any }, which: CHR) -> null | 'a) & ((x: { .Meta: { 'b }<~@"[[", ...>, any }, which: dbl) -> 'b))<>
timing: 0.351 s
fuzzing: 18 inside (3 ok, 15 error type) · 8 outside (8 rejected)
type drawn from: (((x: { .Meta: <@"[[", ...>, any }, which: any) -> any) & ((x: { .Meta: v('I6603)<~@"[[", ...>, any }, which: CHR | DBL | INT | LGL | RAW) -> v1('I6603)<>) & ((x: { .Meta: { 'I6589 }<~@"[[", ...>, any }, which: CHR) -> null | 'I6589) & ((x: { .Meta: { 'I6590 }<~@"[[", ...>, any }, which: dbl) -> 'I6590))<>

Other calls inside the domain

callverdicterror
.get_property(list(".Meta" = "a"), "which" = NA_character_)error_typebase::[[: subscript out of bounds
.get_property(list(".Meta" = list(), NULL), FALSE)error_typebase::[[: attempt to select less than one element in integerOneIndex
.get_property(list(".Meta" = logical(0), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })), "which" = as.raw(c(255)))error_typebase::[[: invalid subscript type 'raw'
.get_property(list(".Meta" = list(1L, integer(0)), as.name("x"), function(...) function(...) NULL), c("NA", "a"))error_typebase::[[: no such index at level 1
.get_property("x" = list(".Meta" = list(c("NA", "a", "NA", "NA", "x y"))), "which" = as.raw(c(0, 255, 0, 0, 255)))error_typebase::[[: invalid subscript type 'raw'
.get_property(list(".Meta" = NA_complex_, new.env()), "é")error_typebase::[[: subscript out of bounds
and 9 more
source
.get_property <-
function(x, which)
    x$.Meta[[which]]
R/utilities.R:128

.has_property typed accepts outside

(((x: { .Meta: any, any }, which: vec | null) -> LGL<>)&((x: { .Meta: any, any }, which: vec1) -> LGL1<>))<>
timing: 0.084 s
fuzzing: 8 inside (8 ok) · 8 outside (5 rejected, 3 accepted)

Accepted outside the domain which: 3

parameterchangecallreturned
whichwrap.has_property(list(".Meta" = new.env(), new.env(), list()), list(NULL))ff<> with { }
whichwrap.has_property(list(".Meta" = function(...) NULL, quote(f(x)), list(as.name("x"))), list("NA"))ff<> with { }
whichwrap.has_property(list(".Meta" = new.env(), quote(f(x))), list(FALSE))ff<> with { }
source
.has_property <-
function(x, which)
    which %in% names(x$.Meta)
R/utilities.R:131

.get_property_from_object_or_representation untypeable

untypeable projection (line 141)
error detail
argument: any
argument may be: new.env()
timing: 4.46 s
source
.get_property_from_object_or_representation <-
function(x, which, getter)
{
    if(.has_property(x, which))
        .get_property(x, which)
    else {
        if(missing(getter)) getter <- get(which)
        getter(.get_representation(x))
    }
}
R/utilities.R:134

.print_container untypeabletyped

unbound variable (line 150)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, cls: any, ...: any) -> 'a)<>
timing: 0.008 s
source
.print_container <-
function(x, cls, ...)
{
    writeLines(gettextf("An object of virtual class '%s', with representation:\n",
                        cls))
    print(.get_representation(x), ...)
    invisible(x)
}
R/utilities.R:147

weighted_median untypeable

unbound variable (line 161)
unbound: rep_len — a name the prelude does not declare
error detail
name: rep_len
timing: 0.123 s
source
weighted_median <-
function(x, w = 1, na.rm = FALSE)
{
    w <- rep_len(w, length(x))
    if(na.rm && any(ind <- is.na(x))) {
        x <- x[!ind]
        w <- w[!ind]
    }
    if(any(is.na(x)) || !length(x))
        return(NA)
    w <- w / sum(w)    
    ind <- order(x)
    x <- x[ind]
    w <- w[ind]
    x[which.min(x * (cumsum(w) - 0.5) - cumsum(w * x))]
}
R/utilities.R:158
R/membership.R

cl_membership untypeabletyped

unbound variable (line 25)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.006 s
source
cl_membership <-
function(x, k = n_of_classes(x))
{
    if(k < n_of_classes(x))
        stop("k cannot be less than the number of classes in x.")
    UseMethod("cl_membership")
}
R/membership.R:24

.make_cl_membership untypeabletyped

unbound variable (line 109)
unbound: attr<- — a name the prelude does not declare
error detail
name: attr<-
gradual mode: typed
((x: any, n_of_classes: any, is_cl_hard_partition: any, meta: any?) -> any)<>
timing: 0.014 s
source
.make_cl_membership <-
function(x, n_of_classes, is_cl_hard_partition, meta = NULL)
{
    attr(x, "n_of_classes") <- n_of_classes
    attr(x, "is_cl_hard_partition") <- is_cl_hard_partition
    attr(x, "meta") <- meta
    class(x) <- "cl_membership"
    x
}
R/membership.R:106

.cl_membership_from_class_ids untypeable

untypeable assignment (line 125)
error detail
variable: k
expected: null
given: INT1<>
expression may be: NA_integer_
timing: 0.093 s
source
.cl_membership_from_class_ids <-
function(x, k = NULL, meta = NULL)
{
    x <- factor(x)
    n_of_objects <- length(x)
    n_of_classes <- nlevels(x)
    if(is.null(k))
        k <- n_of_classes
    else if(k < n_of_classes)
        stop("k cannot be less than the number of classes in x.")
    ## <TODO>
    ## Should really use a sparse encoding of this ...
    M <- matrix(0, n_of_objects, k)
    ## (Could also use .one_entry_per_column(M, as.numeric(x)) <- 1 for
    ## the time being.)
    M[cbind(seq_len(n_of_objects), as.numeric(x))] <- 1
    ## But note that we also need to handle NAs ...
    M[is.na(x), ] <- NA
    ## </TODO>
    if(nlevels(x) == k)
        colnames(M) <- levels(x)
    if(!is.null(nm <- names(x)))
        rownames(M) <- nm
    .make_cl_membership(M, n_of_classes, TRUE, meta)
}
R/membership.R:118

cl_membership.default untypeabletyped

unbound variable (line 34)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.005 s
source
cl_membership.default <-
function(x, k = n_of_classes(x))
    .cl_membership_from_class_ids(cl_class_ids(x), k)
R/membership.R:33

cl_membership.kmeans untypeabletyped

unbound variable (line 38)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.kmeans <- cl_membership.default
R/membership.R:38

.cl_membership_from_memberships untypeabletyped

unbound variable (line 155)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: typed
((x: any, k: null?, meta: any?) -> any)<>
timing: 0.045 s
source
.cl_membership_from_memberships <-
function(x, k = NULL, meta = NULL)
{
    ## <NOTE>
    ## Dropping and re-filling of ## zero columns in case k is given may
    ## seem unnecessary, but really canonicalizes by moving zero columns
    ## last ...
    ## </NOTE>
    
    x <- x[ , colSums(x, na.rm = TRUE) > 0, drop = FALSE]
    n_of_classes <- ncol(x)
    if(!is.null(k)) {
        if(k < n_of_classes)
            stop("k cannot be less than the number of classes in x.")
        if(k > n_of_classes) {
            ## Fill up with zero columns.
            x <- cbind(x, matrix(0, nrow(x), k - n_of_classes))
            ## Handle NAs if necessary.
            x[apply(is.na(x), 1, any), ] <- NA
        }
    }
    .make_cl_membership(x, n_of_classes,
                        all(rowSums(x == 1, na.rm = TRUE) > 0),
                        meta)
}
R/membership.R:146

cl_membership.fanny untypeabletyped

unbound variable (line 43)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { membership: any, any }, k: null?) -> any)<>
timing: 0.005 s
source
cl_membership.fanny <-
function(x, k = n_of_classes(x))
    .cl_membership_from_memberships(x$membership, k)
R/membership.R:42

cl_membership.partition untypeabletyped

unbound variable (line 45)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.partition <- cl_membership.default
R/membership.R:45

cl_membership.cclust untypeabletyped

unbound variable (line 48)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.cclust <- cl_membership.default
R/membership.R:48

cl_membership.fclust untypeabletyped

unbound variable (line 51)
unbound: cl_membership.fanny — one of the package’s own names, itself untyped
error detail
name: cl_membership.fanny
gradual mode: typed
((x: { membership: any, any }, k: null?) -> any)<>
timing: 0.000 s
source
cl_membership.fclust <- cl_membership.fanny
R/membership.R:51

cl_membership.cshell untypeabletyped

unbound variable (line 53)
unbound: cl_membership.fanny — one of the package’s own names, itself untyped
error detail
name: cl_membership.fanny
gradual mode: typed
((x: { membership: any, any }, k: null?) -> any)<>
timing: 0.000 s
source
cl_membership.cshell <- cl_membership.fanny
R/membership.R:53

cl_membership.bclust untypeabletyped

unbound variable (line 55)
unbound: cl_membership.default — one of the package’s own names, itself untyped
error detail
name: cl_membership.default
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.000 s
source
cl_membership.bclust <- cl_membership.default
R/membership.R:55

cl_membership.flexmix untypeabletyped

unbound variable (line 64)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: any?) -> any)<>
timing: 0.005 s
source
cl_membership.flexmix <-
function(x, k = n_of_classes(x))
    .cl_membership_from_memberships(modeltools::posterior(x), k)
R/membership.R:63

cl_membership.Mclust untypeabletyped

unbound variable (line 69)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { z: any, any }, k: null?) -> any)<>
timing: 0.005 s
source
cl_membership.Mclust <-
function(x, k = n_of_classes(x))
    .cl_membership_from_memberships(x$z, k)
R/membership.R:68

cl_membership.cl_membership untypeabletyped

unbound variable (line 74)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, k: null?) -> any)<>
timing: 0.004 s
source
cl_membership.cl_membership <-
function(x, k = n_of_classes(x))
    .cl_membership_from_memberships(x, k)
R/membership.R:73

cl_membership.pclust untypeabletyped

unbound variable (line 81)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { membership: any, cluster: any, any }, k: any?) -> any)<>
timing: 0.013 s
source
cl_membership.pclust <-
function(x, k = n_of_classes(x))
{
    ## We should really have a suitable "sparse matrix" class for
    ## representing the memberships of hard partitions.  In case we
    ## decide not to fill the membership "slot" for such:
    if(is.null(m <- x$membership))
        .cl_membership_from_class_ids(x$cluster, k)
    else
        .cl_membership_from_memberships(m, k)
}
R/membership.R:80

cl_membership.cl_partition untypeabletyped

unbound variable (line 94)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { .Data: any, any }, k: any?) -> any)<>
timing: 0.004 s
source
cl_membership.cl_partition <-
function(x, k = n_of_classes(x))
    cl_membership(.get_representation(x), k)
R/membership.R:93

cl_membership.movMF untypeabletyped

unbound variable (line 99)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { P: any, any }, k: null?) -> any)<>
timing: 0.005 s
source
cl_membership.movMF <-
function(x, k = n_of_classes(x))
    .cl_membership_from_memberships(x$P, k)
R/membership.R:98

as.cl_membership untypeabletyped

unbound variable (line 176)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_membership <-
function(x)
    UseMethod("as.cl_membership")
R/membership.R:174

as.cl_membership.default untypeabletyped

unbound variable (line 182)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: any) -> any)<>
timing: 0.017 s
source
as.cl_membership.default <-
function(x)
{
    if(inherits(x, "cl_membership"))
        x
    else if(is.atomic(x))
        .cl_membership_from_class_ids(x)
    else
        cl_membership(x)
}
R/membership.R:177

as.cl_membership.matrix untypeabletyped

unbound variable (line 189)
unbound: .cl_membership_from_memberships — one of the package’s own names, itself untyped
error detail
name: .cl_membership_from_memberships
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_membership.matrix <-
function(x)
    .cl_membership_from_memberships(x)
R/membership.R:187

.memberships_from_cross_dissimilarities untypeable

untypeable application of base::matrix (line 209)
error detail
argument: @(0.<>, INT1<> | null, INT1<> | null)
failing call: base::matrix(0, NA_integer_, NULL)
timing: 0.968 s
source
.memberships_from_cross_dissimilarities <-
function(d, power = 2)
{
    ## For a given matrix of cross-dissimilarities [d_{bj}], return a
    ## matrix [u_{bj}] such that \sum_{b,j} u_{bj}^p d_{bj}^q => min!
    ## under the constraint that u is a stochastic matrix.
    ## If only one power is given, it is taken as p, with q as 1.
    ## <NOTE>
    ## This returns a plain matrix of membership values and not a
    ## cl_membership object (so that it does not deal with possibly
    ## dropping or re-introducing unused classes).
    ## </NOTE>
    exponent <- if(length(power) == 1L)
        1 / (1 - power)
    else
        power[2L] / (1 - power[1L])
    u <- matrix(0, nrow(d), ncol(d))
    zero_incidences <- !(d > 0)
    n_of_zeroes <- rowSums(zero_incidences)
    if(any(ind <- (n_of_zeroes > 0)))
        u[ind, ] <-
            zero_incidences[ind, , drop = FALSE] / n_of_zeroes[ind]
    if(any(!ind)) {
        ## Compute d_{bj}^e / \sum_k d_{bk}^e without overflow from very
        ## small d_{bj} values.
        d <- exponent * log(d[!ind, , drop = FALSE])
        d <- exp(d - d[cbind(seq_len(nrow(d)), max.col(d))])
        u[!ind, ] <- d / rowSums(d)
    }
    u
}
R/membership.R:193

print.cl_membership untypeabletyped

unbound variable (line 230)
unbound: writeLines — a name the prelude does not declare
error detail
name: writeLines
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.005 s
source
print.cl_membership <-
function(x, ...)
{
    writeLines("Memberships:")
    print(matrix(as.vector(x), nrow = nrow(x), dimnames = dimnames(x)),
          ...)
    invisible(x)
}
R/membership.R:227

.has_object_memberships untypeabletyped

unbound variable (line 246)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
gradual mode: typed
((x: any) -> ff<> | tt<>)<>
timing: 0.012 s
source
.has_object_memberships <-
function(x)
    (is.cl_partition(x)
     || inherits(x, "cl_membership")
     || inherits(x, "cl_class_ids"))
R/membership.R:244

.stochastify untypeabletyped

unbound variable (line 256)
unbound: pmax — a name the prelude does not declare
error detail
name: pmax
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
.stochastify <-
function(x)
{
    ## Try to ensure that a stochastic matrix is returned.
    x <- pmax(x, 0)
    x / rowSums(x)
}
R/membership.R:252
R/proximity.R

cl_proximity untypeable

unbound variable (line 30)
unbound: diag — a name the prelude does not declare
error detail
name: diag
timing: 1.49 s
source
cl_proximity <-
function(x, description, class = NULL, labels = NULL,
         self = NULL, size = NULL)
{
    ## Similar to as.dist(), in a way.
    ## Currently, as.dist() is not generic, so we cannot provide a
    ## cl_proximity method for it.  Hence, we have our dissimilarities
    ## and ultrametrics extend dist, and we use capitalized names for
    ## the attributes provided for compatibility with dist (Size and
    ## Labels).
    
    if(inherits(x, "dist")) {
        ## Explicitly deal with dist objects.
        ## Useful in particular because cophenetic() returns them.
        out <- x
        if(is.null(size))
            size <- attr(x, "Size")
        if(is.null(labels))
            labels <- attr(x, "Labels")
    }
    else if(inherits(x, "cl_proximity") ||
            !(is.matrix(x) && (nrow(x) == ncol(x))))
        out <- x
    else {
        ## Actually, x should really be a square symmetric matrix.
        ## The "self-proximities" in the main diagonal must be stored
        ## provided there is one non-zero entry.
        self <- diag(x)
        if(all(self == 0)) self <- NULL
        out <- x[row(x) > col(x)]
        if(is.null(labels)) {
            if(!is.null(rownames(x))) 
                labels <- rownames(x)
            else if(!is.null(colnames(x))) 
                labels <- colnames(x)
        }
    }
    if(is.null(size))
        size <- as.integer((sqrt(1 + 8 * length(out)) + 1) / 2)
    attributes(out) <-
        list(Size = size, Labels = labels, description = description,
             self = self)
    class(out) <- unique(c(class, "cl_proximity"))
    out
}
R/proximity.R:3

names.cl_proximity typed any: x accepts outside

((x: any) -> null)<>
timing: 0.019 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropnames.cl_proximity()null
source
names.cl_proximity <-
function(x)
    NULL
R/proximity.R:51

print.cl_proximity untypeabletyped

unbound variable (line 71)
unbound: as.matrix — a name the prelude does not declare
error detail
name: as.matrix
gradual mode: typed
∀'a. ((x: 'a & any with { self: ~null, description: any, any }, ...: any) -> 'a)<>
timing: 0.132 s
source
print.cl_proximity <-
function(x, ...)
{
    description <- attr(x, "description")
    if(length(description) > 0L) {
        ## Could make this generic ...
        kind <- if(inherits(x, "cl_dissimilarity"))
            "Dissimilarities"
        else if(inherits(x, "cl_agreement"))
            "Agreements"
        else
            "Proximities"
        cat(sprintf("%s using %s", kind, description), ":\n", sep = "")
    }
    m <- format(as.matrix(x))
    if(is.null(self <- attr(x, "self")))
        m[row(m) <= col(m)] <- ""
    else
        m[row(m) < col(m)] <- ""
    print(if(is.null(self)) m[-1, -attr(x, "Size")] else m,
          quote = FALSE, right = TRUE, ...)
    invisible(x)
}
R/proximity.R:57

as.matrix.cl_proximity untypeabletyped

unbound variable (line 88)
unbound: row — a name the prelude does not declare
error detail
name: row
gradual mode: typed
((x: any with { Labels: any, self: any, Size: dbl1, any }, ...: any) -> any)<>
timing: 0.079 s
source
as.matrix.cl_proximity <-
function(x, ...)
{
    size <- attr(x, "Size")
    m <- matrix(0, size, size)
    m[row(m) > col(m)] <- x
    m <- m + t(m)
    if(!is.null(self <- attr(x, "self"))) {
        diag(m) <- self
    }
    ## <NOTE>
    ## stats:::as.matrix.dist() provides default dimnames
    ## (seq_len(size)) if no labels are available.
    ## We used to do this too, but ...
    if(!is.null(labels <- attr(x, "Labels")))
        dimnames(m) <- list(labels, labels)
    ## </NOTE>
    m
}
R/proximity.R:83

cl_cross_proximity untypeabletyped

unbound variable (line 147)
unbound: attr<- — a name the prelude does not declare
error detail
name: attr<-
gradual mode: typed
((x: any, description: any?, class: (vec | null)?) -> any)<>
timing: 0.014 s
source
cl_cross_proximity <-
function(x, description = NULL, class = NULL)
{
    attr(x, "description") <- description
    class(x) <- c(class, "cl_cross_proximity")
    x
}
R/proximity.R:144

[.cl_proximity untypeable

unbound variable (line 133)
unbound: as.matrix — a name the prelude does not declare
error detail
name: as.matrix
timing: 0.213 s
source
"[.cl_proximity" <-
function(x, i, j)
{
    ## Subscripting proximity objects.
    ## Basically matrix-like, but proximity objects are always
    ## "matrices", hence no 'drop' argument.
    ## For double-index subscripting, if i and j are identical,
    ## structure and class are preserved.  Otherwise, a cross-proximity
    ## object is returned (and methods for classes inheriting from
    ## proximity need to readjust the class info as needed).
    ## For single-index subscripting, no attempty is currently made at
    ## preserving structure and class where possible.  (We might also
    ## change this to select objects, i.e., the same rows and columns.)
    size <- attr(x, "Size")
    if(missing(j)) {
        if(missing(i))
            return(x)
        else
            j <- seq_len(size)
    }
    if(missing(i))
        i <- seq_len(size)
    description <- attr(x, "description")
    ## RG's graph:::[.dist avoids as.matrix() in noting that for dist
    ## objects, entry (i,j) is at n(i-1) - i(i-1)/2 + j - i (in the
    ## veclh dist representation).  We could do something similar, but
    ## note that not all proximities have zero diagonals (i.e., NULL
    ## "self" attributes).
    y <- as.matrix(x)[i, j, drop = FALSE]
    if(identical(i, j)) {
        ## Testing using identical() is rather defensive ...
        return(cl_proximity(y, description = description,
                            class = class(x)))
    }
    cl_cross_proximity(y, description = description)
}
R/proximity.R:105

print.cl_cross_proximity untypeabletyped

unbound variable (line 168)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
∀'a. ((x: 'a & any with { description: any, any }, ...: any) -> 'a)<>
timing: 0.101 s
source
print.cl_cross_proximity <-
function(x, ...)
{
    description <- attr(x, "description")
    if(length(description) > 0L) {
        ## Could make this generic ...
        kind <- if(inherits(x, "cl_cross_dissimilarity"))
            "Cross-dissimilarities"
        else if(inherits(x, "cl_cross_agreement"))
            "Cross-agreements"
        else
            "Cross-proximities"
        cat(sprintf("%s using %s", kind, description), ":\n", sep = "")
    }
    print(matrix(as.vector(x), nrow = nrow(x), dimnames = dimnames(x)),
          ...)
    invisible(x)
}
R/proximity.R:154
R/registration.R

.make_db_key typed any: name, type fuzz ok

(((name: any, type: any) -> CHR<>)&((name: vec1, type: vec1) -> CHR1<>))<>
timing: 0.044 s
fuzzing: 8 inside (6 ok, 2 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
.make_db_key("name" = function(...) NULL, "type" = NULL)error_typebase::paste: cannot coerce type 'closure' to vector of type 'character'
.make_db_key(function(...) NULL, "type" = as.name("x"))error_typebase::paste: cannot coerce type 'closure' to vector of type 'character'
source
.make_db_key <- function(name, type) paste(type, name, sep = "_")
R/registration.R:9

get_methods_from_db untypeabletyped

unbound variable (line 23)
unbound: objects — a name the prelude does not declare
error detail
name: objects
gradual mode: typed
((db: any, type: vec | null) -> any)<>
timing: 0.041 s
source
get_methods_from_db <- function(db, type) {
    type <- match.arg(type, c("partition", "hierarchy"))
    
    pattern <- sprintf("^%s_", type)
    sub(pattern, "",
        grep(pattern, objects(db), value = TRUE))
}
R/registration.R:18

get_method_from_db untypeabletyped

unbound variable (line 32)
unbound: objects — a name the prelude does not declare
error detail
name: objects
gradual mode: typed
((db: any, type: vec | null, name: vec, msg: any) -> any)<>
timing: 0.060 s
source
get_method_from_db <- function(db, type, name, msg) {
    ## <NOTE>
    ## Keep 'msg' here so that gettext()ing could work ...
    ## </NOTE>
    type <- match.arg(type, c("partition", "hierarchy"))

    db_keys <- objects(db)
    ind <- pmatch(.make_db_key(tolower(name), type), tolower(db_keys))
    if(is.na(ind))
        stop(msg, call. = FALSE, domain = NA)
    
    db[[db_keys[ind]]]
}
R/registration.R:26

put_method_into_db typed any: name, value fuzz ok

((db: list, type: vec | null, name: any, value: any) | (db: vec, type: vec | null, name: any, value: vec) -> null)<>
timing: 0.335 s
fuzzing: 8 inside (6 error pkg, 2 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
put_method_into_db(list(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), NULL), "type" = -Inf, "name" = function(...) as.name("x"), "value" = function(...) quote(f(x)))error_pkgbase::match.arg: 'arg' must be NULL or a character vector
put_method_into_db("db" = list(), "type" = c(NA_integer_, NA_integer_), "name" = as.name("x"), "value" = as.name("x"))error_pkgbase::match.arg: 'arg' must be NULL or a character vector
put_method_into_db(list(function(...) quote(f(x)), quote(f(x))), integer(0), NULL, NULL)error_pkgbase::match.arg: 'arg' must be NULL or a character vector
put_method_into_db(list(), c(2L, 42L, -2147483647L, NA_integer_, -1L), new.env(), as.name("x"))error_pkgbase::match.arg: 'arg' must be NULL or a character vector
put_method_into_db(list(c(2L, -2147483647L), function(...) local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })), as.raw(c(0)), list(function(...) new.env()), "value" = quote(f(x)))error_pkgbase::match.arg: 'arg' must be NULL or a character vector
put_method_into_db(c(FALSE, TRUE), "type" = NULL, "name" = as.name("x"), "value" = c(42L, 2147483647L, -2147483647L, 2147483647L, 1000000L))error_typebase::<-: more elements supplied than there are to replace
and 2 more
source
put_method_into_db <- function(db, type, name, value) {
    type <- match.arg(type, c("partition", "hierarchy"))
    db[[.make_db_key(name, type)]] <- value
}
R/registration.R:40

cl_consensus_methods_db typed

env
timing: 0.003 s
source
cl_consensus_methods_db <- new.env()
R/registration.R:47

get_cl_consensus_methods untypeabletyped

unbound variable (line 50)
unbound: get_methods_from_db — one of the package’s own names, itself untyped
error detail
name: get_methods_from_db
gradual mode: typed
((type: vec | null) -> any)<>
timing: 0.002 s
source
get_cl_consensus_methods <- function(type)
    get_methods_from_db(cl_consensus_methods_db, type)
R/registration.R:49

get_cl_consensus_method untypeabletyped

unbound variable (line 53)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
((name: any, type: any) -> any)<>
timing: 0.004 s
source
get_cl_consensus_method <- function(name, type) {
    get_method_from_db(cl_consensus_methods_db, type, name,
                       gettextf("Invalid consensus method '%s'.", name))
}
R/registration.R:51

set_cl_consensus_method untypeable

unbound variable (line 65)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
timing: 0.068 s
source
set_cl_consensus_method <-
function(name, type, definition, ...)
{
    ## Register a @code{type} consensus method called @code{name} with
    ## definition @code{definition}.  Provide more information where
    ## appropriate, e.g., @code{dissimilarity} d and @code{exponent} e
    ## for methods minimizing \sum_b d(x_b, x) ^ e.

    put_method_into_db(cl_consensus_methods_db, type, name,
                       .structure(c(list(definition = definition),
                                    list(...)),
                                  class = "cl_consensus_method"))
}
R/registration.R:56

<statement> untypeabletyped

unbound variable (line 71)
unbound: .cl_consensus_partition_DWH — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_DWH
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("DWH", "partition",
                        .cl_consensus_partition_DWH,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:70

<statement> untypeabletyped

unbound variable (line 75)
unbound: .cl_consensus_partition_soft_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("soft/euclidean", "partition",
                        .cl_consensus_partition_soft_euclidean,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:74

<statement> untypeabletyped

unbound variable (line 79)
unbound: .cl_consensus_partition_soft_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("SE", "partition",
                        .cl_consensus_partition_soft_euclidean,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:78

<statement> untypeabletyped

unbound variable (line 83)
unbound: .cl_consensus_partition_hard_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("hard/euclidean", "partition",
                        .cl_consensus_partition_hard_euclidean,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:82

<statement> untypeabletyped

unbound variable (line 87)
unbound: .cl_consensus_partition_hard_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("HE", "partition",
                        .cl_consensus_partition_hard_euclidean,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:86

<statement> untypeabletyped

unbound variable (line 91)
unbound: .cl_consensus_partition_soft_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("soft/manhattan", "partition",
                        .cl_consensus_partition_soft_manhattan,
                        dissimilarity = "manhattan",
                        exponent = 1)
R/registration.R:90

<statement> untypeabletyped

unbound variable (line 95)
unbound: .cl_consensus_partition_soft_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("SM", "partition",
                        .cl_consensus_partition_soft_manhattan,
                        dissimilarity = "manhattan",
                        exponent = 1)
R/registration.R:94

<statement> untypeabletyped

unbound variable (line 99)
unbound: .cl_consensus_partition_hard_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("hard/manhattan", "partition",
                        .cl_consensus_partition_hard_manhattan,
                        dissimilarity = "manhattan",
                        exponent = 1)
R/registration.R:98

<statement> untypeabletyped

unbound variable (line 103)
unbound: .cl_consensus_partition_hard_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("HM", "partition",
                        .cl_consensus_partition_hard_manhattan,
                        dissimilarity = "manhattan",
                        exponent = 1)
R/registration.R:102

<statement> untypeabletyped

unbound variable (line 107)
unbound: .cl_consensus_partition_GV1 — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_GV1
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("GV1", "partition",
                        .cl_consensus_partition_GV1,
                        dissimilarity = "GV1",
                        exponent = 2)
R/registration.R:106

<statement> untypeabletyped

unbound variable (line 111)
unbound: .cl_consensus_partition_GV3 — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_GV3
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("GV3", "partition",
                        .cl_consensus_partition_GV3,
                        dissimilarity = "comemberships",
                        exponent = 2)
R/registration.R:110

<statement> untypeabletyped

unbound variable (line 115)
unbound: .cl_consensus_partition_soft_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_soft_symdiff
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("soft/symdiff", "partition",
                        .cl_consensus_partition_soft_symdiff,
                        dissimilarity = "symdiff",
                        exponent = 1)
R/registration.R:114

<statement> untypeabletyped

unbound variable (line 119)
unbound: .cl_consensus_partition_hard_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_hard_symdiff
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("hard/symdiff", "partition",
                        .cl_consensus_partition_hard_symdiff,
                        dissimilarity = "symdiff",
                        exponent = 1)
R/registration.R:118

<statement> untypeabletyped

unbound variable (line 124)
unbound: .cl_consensus_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_cophenetic
gradual mode: typed
timing: 0.001 s
source
set_cl_consensus_method("cophenetic", "hierarchy",
                        .cl_consensus_hierarchy_cophenetic,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:123

<statement> untypeabletyped

unbound variable (line 128)
unbound: .cl_consensus_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_cophenetic
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("euclidean", "hierarchy",
                        .cl_consensus_hierarchy_cophenetic,
                        dissimilarity = "euclidean",
                        exponent = 2)
R/registration.R:127

<statement> untypeabletyped

unbound variable (line 132)
unbound: .cl_consensus_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("manhattan", "hierarchy",
                        .cl_consensus_hierarchy_manhattan,
                        dissimilarity = "manhattan",
                        exponent = 1)
R/registration.R:131

<statement> untypeabletyped

unbound variable (line 136)
unbound: .cl_consensus_hierarchy_majority — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_hierarchy_majority
gradual mode: typed
timing: 0.000 s
source
set_cl_consensus_method("majority", "hierarchy",
                        .cl_consensus_hierarchy_majority,
                        dissimilarity = "symdiff",
                        exponent = 1)
R/registration.R:135

cl_dissimilarity_methods_db typed

env
timing: 0.002 s
source
cl_dissimilarity_methods_db <- new.env()
R/registration.R:142

get_cl_dissimilarity_methods untypeabletyped

unbound variable (line 145)
unbound: get_methods_from_db — one of the package’s own names, itself untyped
error detail
name: get_methods_from_db
gradual mode: typed
((type: vec | null) -> any)<>
timing: 0.002 s
source
get_cl_dissimilarity_methods <- function(type)
    get_methods_from_db(cl_dissimilarity_methods_db, type)
R/registration.R:144

get_cl_dissimilarity_method untypeabletyped

unbound variable (line 148)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
((name: any, type: any) -> any)<>
timing: 0.004 s
source
get_cl_dissimilarity_method <- function(name, type)
    get_method_from_db(cl_dissimilarity_methods_db, type, name,
                       gettextf("Invalid dissimilarity method '%s'.",
                                name))
R/registration.R:146

set_cl_dissimilarity_method untypeable

unbound variable (line 153)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
timing: 0.105 s
source
set_cl_dissimilarity_method <-
    function(name, type, definition, description, ...)
    put_method_into_db(cl_dissimilarity_methods_db, type, name,
                       .structure(c(list(definition = definition,
                                         description = description),
                                    list(...)),
                                  class = "cl_dissimilarity_method"))
R/registration.R:150

<statement> untypeabletyped

unbound variable (line 159)
unbound: .cl_dissimilarity_partition_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_euclidean
gradual mode: typed
timing: 0.001 s
source
set_cl_dissimilarity_method("euclidean", "partition",
                            .cl_dissimilarity_partition_euclidean,
                            "minimal Euclidean membership distance")
R/registration.R:158

<statement> untypeabletyped

unbound variable (line 162)
unbound: .cl_dissimilarity_partition_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("manhattan", "partition",
                            .cl_dissimilarity_partition_manhattan,
                            "minimal Manhattan membership distance")
R/registration.R:161

<statement> untypeabletyped

unbound variable (line 165)
unbound: .cl_dissimilarity_partition_comemberships — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_comemberships
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("comemberships", "partition",
                            .cl_dissimilarity_partition_comemberships,
                            "Euclidean comembership distance")
R/registration.R:164

<statement> untypeabletyped

unbound variable (line 168)
unbound: .cl_dissimilarity_partition_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_symdiff
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("symdiff", "partition",
                            .cl_dissimilarity_partition_symdiff,
                            "symmetric difference distance")
R/registration.R:167

<statement> untypeabletyped

unbound variable (line 171)
unbound: .cl_dissimilarity_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_Rand
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Rand", "partition",
                            .cl_dissimilarity_partition_Rand,
                            "Rand distance")
R/registration.R:170

<statement> untypeabletyped

unbound variable (line 174)
unbound: .cl_dissimilarity_partition_GV1 — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_GV1
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("GV1", "partition",
                            .cl_dissimilarity_partition_GV1,
                            "Gordon-Vichi Delta_1 dissimilarity")
R/registration.R:173

<statement> untypeabletyped

unbound variable (line 177)
unbound: .cl_dissimilarity_partition_BA_A — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_A
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/A", "partition",
                            .cl_dissimilarity_partition_BA_A,
                            "Boorman/Arabie minimum element moves distance")
R/registration.R:176

<statement> untypeabletyped

unbound variable (line 180)
unbound: .cl_dissimilarity_partition_BA_C — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_C
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/C", "partition",
                            .cl_dissimilarity_partition_BA_C,
                            "Boorman/Arabie minimum lattice moves distance")
R/registration.R:179

<statement> untypeabletyped

unbound variable (line 183)
unbound: .cl_dissimilarity_partition_BA_D — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_D
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/D", "partition",
                            .cl_dissimilarity_partition_BA_D,
                            "Boorman/Arabie pair-bonds distance")
R/registration.R:182

<statement> untypeabletyped

unbound variable (line 186)
unbound: .cl_dissimilarity_partition_BA_E — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_BA_E
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BA/E", "partition",
                            .cl_dissimilarity_partition_BA_E,
                            "Boorman/Arabie normalized information distance")
R/registration.R:185

<statement> untypeabletyped

unbound variable (line 189)
unbound: .cl_dissimilarity_partition_VI — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_VI
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("VI", "partition",
                            .cl_dissimilarity_partition_VI,
                            "Variation of information")
R/registration.R:188

<statement> untypeabletyped

unbound variable (line 192)
unbound: .cl_dissimilarity_partition_Mallows — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_Mallows
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Mallows", "partition",
                            .cl_dissimilarity_partition_Mallows,
                            "Mallows dissimilarity")
R/registration.R:191

<statement> untypeabletyped

unbound variable (line 195)
unbound: .cl_dissimilarity_partition_CSSD — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_CSSD
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("CSSD", "partition",
                            .cl_dissimilarity_partition_CSSD,
                            "Cluster Similarity Sensitive Distance")
R/registration.R:194

<statement> untypeabletyped

unbound variable (line 199)
unbound: .cl_dissimilarity_hierarchy_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("euclidean", "hierarchy",
                            .cl_dissimilarity_hierarchy_euclidean,
                            "Euclidean ultrametric distance")
R/registration.R:198

<statement> untypeabletyped

unbound variable (line 202)
unbound: .cl_dissimilarity_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("manhattan", "hierarchy",
                            .cl_dissimilarity_hierarchy_manhattan,
                            "Manhattan ultrametric distance")
R/registration.R:201

<statement> untypeabletyped

unbound variable (line 205)
unbound: .cl_dissimilarity_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_cophenetic
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("cophenetic", "hierarchy",
                            .cl_dissimilarity_hierarchy_cophenetic,
                            "cophenetic correlations")
R/registration.R:204

<statement> untypeabletyped

unbound variable (line 208)
unbound: .cl_dissimilarity_hierarchy_gamma — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_gamma
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("gamma", "hierarchy",
                            .cl_dissimilarity_hierarchy_gamma,
                            "rate of inversions")
R/registration.R:207

<statement> untypeabletyped

unbound variable (line 211)
unbound: .cl_dissimilarity_hierarchy_symdiff — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_symdiff
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("symdiff", "hierarchy",
                            .cl_dissimilarity_hierarchy_symdiff,
                            "symmetric difference distance")
R/registration.R:210

<statement> untypeabletyped

unbound variable (line 214)
unbound: .cl_dissimilarity_hierarchy_Chebyshev — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_Chebyshev
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Chebyshev", "hierarchy",
                            .cl_dissimilarity_hierarchy_Chebyshev,
                            "Chebyshev distance")
R/registration.R:213

<statement> untypeabletyped

unbound variable (line 217)
unbound: .cl_dissimilarity_hierarchy_Lyapunov — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_Lyapunov
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("Lyapunov", "hierarchy",
                            .cl_dissimilarity_hierarchy_Lyapunov,
                            "Lyapunov distance")
R/registration.R:216

<statement> untypeabletyped

unbound variable (line 220)
unbound: .cl_dissimilarity_hierarchy_BO — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_BO
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("BO", "hierarchy",
                            .cl_dissimilarity_hierarchy_BO,
                            "Boorman/Olivier m_delta tree distance")
R/registration.R:219

<statement> untypeabletyped

unbound variable (line 223)
unbound: .cl_dissimilarity_hierarchy_spectral — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_spectral
gradual mode: typed
timing: 0.000 s
source
set_cl_dissimilarity_method("spectral", "hierarchy",
                            .cl_dissimilarity_hierarchy_spectral,
                            "spectral ultrametric distance")
R/registration.R:222

cl_agreement_methods_db typed

env
timing: 0.002 s
source
cl_agreement_methods_db <- new.env()
R/registration.R:228

get_cl_agreement_methods untypeabletyped

unbound variable (line 231)
unbound: get_methods_from_db — one of the package’s own names, itself untyped
error detail
name: get_methods_from_db
gradual mode: typed
((type: vec | null) -> any)<>
timing: 0.002 s
source
get_cl_agreement_methods <-
function(type)
    get_methods_from_db(cl_agreement_methods_db, type)
R/registration.R:229

get_cl_agreement_method untypeabletyped

unbound variable (line 235)
unbound: gettextf — a name the prelude does not declare
error detail
name: gettextf
gradual mode: typed
((name: any, type: any) -> any)<>
timing: 0.004 s
source
get_cl_agreement_method <-
function(name, type)
    get_method_from_db(cl_agreement_methods_db, type, name,
                       gettextf("Invalid agreement method '%s'.",
                                name))
R/registration.R:232

set_cl_agreement_method untypeable

unbound variable (line 240)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
timing: 0.115 s
source
set_cl_agreement_method <-
function(name, type, definition, description, ...)
    put_method_into_db(cl_agreement_methods_db, type, name,
                       .structure(c(list(definition = definition,
                                         description = description),
                                    list(...)),
                                  class = "cl_agreement_method"))
R/registration.R:237

<statement> untypeabletyped

unbound variable (line 246)
unbound: .cl_agreement_partition_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("euclidean", "partition",
                        .cl_agreement_partition_euclidean,
                        "minimal euclidean membership distance")
R/registration.R:245

<statement> untypeabletyped

unbound variable (line 249)
unbound: .cl_agreement_partition_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("manhattan", "partition",
                        .cl_agreement_partition_manhattan,
                        "minimal manhattan membership distance")
R/registration.R:248

<statement> untypeabletyped

unbound variable (line 252)
unbound: .cl_agreement_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_Rand
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("Rand", "partition",
                        .cl_agreement_partition_Rand,
                        "Rand index")
R/registration.R:251

<statement> untypeabletyped

unbound variable (line 255)
unbound: .cl_agreement_partition_cRand — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_cRand
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("cRand", "partition",
                        .cl_agreement_partition_cRand,
                        "corrected Rand index")
R/registration.R:254

<statement> untypeabletyped

unbound variable (line 258)
unbound: .cl_agreement_partition_NMI — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_NMI
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("NMI", "partition",
                        .cl_agreement_partition_NMI,
                        "normalized mutual information")
R/registration.R:257

<statement> untypeabletyped

unbound variable (line 261)
unbound: .cl_agreement_partition_KP — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_KP
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("KP", "partition",
                        .cl_agreement_partition_KP,
                        "Katz-Powell index")
R/registration.R:260

<statement> untypeabletyped

unbound variable (line 264)
unbound: .cl_agreement_partition_angle — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_angle
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("angle", "partition",
                        .cl_agreement_partition_angle,
                        "maximal angle between memberships")
R/registration.R:263

<statement> untypeabletyped

unbound variable (line 267)
unbound: .cl_agreement_partition_diag — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_diag
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("diag", "partition",
                        .cl_agreement_partition_diag,
                        "maximal co-classification rate")
R/registration.R:266

<statement> untypeabletyped

unbound variable (line 270)
unbound: .cl_agreement_partition_FM — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_FM
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("FM", "partition",
                        .cl_agreement_partition_FM,
                        "Fowlkes-Mallows index")
R/registration.R:269

<statement> untypeabletyped

unbound variable (line 273)
unbound: .cl_agreement_partition_Jaccard — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_Jaccard
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("Jaccard", "partition",
                        .cl_agreement_partition_Jaccard,
                        "Jaccard index")
R/registration.R:272

<statement> untypeabletyped

unbound variable (line 276)
unbound: .cl_agreement_partition_purity — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_purity
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("purity", "partition",
                        .cl_agreement_partition_purity,
                        "purity")
R/registration.R:275

<statement> untypeabletyped

unbound variable (line 279)
unbound: .cl_agreement_partition_PS — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_PS
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("PS", "partition",
                        .cl_agreement_partition_PS,
                        "Prediction Strength")
R/registration.R:278

<statement> untypeabletyped

unbound variable (line 283)
unbound: .cl_agreement_hierarchy_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_euclidean
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("euclidean", "hierarchy",
                        .cl_agreement_hierarchy_euclidean,
                        "euclidean ultrametric distance")
R/registration.R:282

<statement> untypeabletyped

unbound variable (line 286)
unbound: .cl_agreement_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_manhattan
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("manhattan", "hierarchy",
                        .cl_agreement_hierarchy_manhattan,
                        "manhattan ultrametric distance")
R/registration.R:285

<statement> untypeabletyped

unbound variable (line 289)
unbound: .cl_agreement_hierarchy_cophenetic — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_cophenetic
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("cophenetic", "hierarchy",
                        .cl_agreement_hierarchy_cophenetic,
                        "cophenetic correlations")
R/registration.R:288

<statement> untypeabletyped

unbound variable (line 292)
unbound: .cl_agreement_hierarchy_angle — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_angle
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("angle", "hierarchy",
                        .cl_agreement_hierarchy_angle,
                        "angle between ultrametrics")
R/registration.R:291

<statement> untypeabletyped

unbound variable (line 295)
unbound: .cl_agreement_hierarchy_gamma — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_hierarchy_gamma
gradual mode: typed
timing: 0.000 s
source
set_cl_agreement_method("gamma", "hierarchy",
                        .cl_agreement_hierarchy_gamma,
                        "rate of inversions")
R/registration.R:294
R/agreement.R

cl_agreement untypeable

unbound variable (line 11)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.131 s
source
cl_agreement <-
function(x, y = NULL, method = "euclidean", ...)
{
    ## <NOTE>
    ## This code is repeated from cl_dissimilarity(), mutatis mutandis.
    ## Not really a big surprise ...
    ## </NOTE>
    
    x <- as.cl_ensemble(x)
    is_partition_ensemble <-
        (inherits(x, "cl_partition_ensemble")
         || all(vapply(x, .has_object_memberships, NA)))

    ## Be nice.
    if(is.character(y) || is.function(y)) {
        method <- y
        y <- NULL
    }

    if(is.function(method))
        method_name <- "user-defined method"
    else {
        if(!inherits(method, "cl_agreement_method")) {
            ## Get the method definition and description from the
            ## registry. 
            type <- ifelse(is_partition_ensemble,
                           "partition", "hierarchy")
            method <- get_cl_agreement_method(method, type)
        }
        method_name <- method$description
        method <- method$definition
    }

    if(!is.null(y)) {
        y <- as.cl_ensemble(y)
        is_partition_ensemble_y <-
            (inherits(y, "cl_partition_ensemble")
             || all(vapply(x, .has_object_memberships, NA)))
        if(!identical(is_partition_ensemble, is_partition_ensemble_y))
            stop("Cannot mix partitions and hierarchies.")
        if(n_of_objects(x) != n_of_objects(y))
            stop("All clusterings must have the same number of objects.")
        ## Build a cross-proximity object of cross-agreements.
        d <- matrix(0, length(x), length(y))
        for(j in seq_along(y))
            d[, j] <- sapply(x, method, y[[j]], ...)
        dimnames(d) <- list(names(x), names(y))
        return(cl_cross_proximity(d, method_name,
                                  class = "cl_cross_agreement"))
    }
    
    ## Otherwise, build a proximity object of dissimilarities.
    n <- length(x)
    d <- vector("list", length = n - 1L)
    ind <- seq_len(n)
    while(length(ind) > 1L) {
        j <- ind[1L]
        ind <- ind[-1L]
        d[[j]] <- sapply(x[ind], method, x[[j]], ...)
    }

    ## <NOTE>
    ## We assume that self-agreements are always one ...
    ## </NOTE>
    cl_proximity(unlist(d),
                 method_name,
                 labels = names(x),
                 self = rep.int(1, length(x)),
                 size = n, class = "cl_agreement")
}
R/agreement.R:3

.cl_agreement_partition_euclidean untypeabletyped

unbound variable (line 81)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.006 s
source
.cl_agreement_partition_euclidean <-
function(x, y)
{
    ## <NOTE>
    ## Upper bound for maximal dissimilarity, maybe improve eventually.
    d_max <- sqrt(2 * n_of_objects(x))
    ## </NOTE>
    1 - .cl_dissimilarity_partition_euclidean(x, y) / d_max
}
R/agreement.R:76

.cl_agreement_partition_manhattan untypeabletyped

unbound variable (line 93)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.006 s
source
.cl_agreement_partition_manhattan <-
function(x, y)
{
    ## <NOTE>
    ## Upper bound for maximal dissimilarity, maybe improve eventually.
    d_max <- 2 * n_of_objects(x)
    ## </NOTE>
    1 - .cl_dissimilarity_partition_manhattan(x, y) / d_max
}
R/agreement.R:88

.cl_agreement_partition_Rand untypeabletyped

unbound variable (line 103)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.017 s
source
.cl_agreement_partition_Rand <-
function(x, y)
{
    n <- n_of_objects(x)
    
    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)
    x <- table(cl_class_ids(x), cl_class_ids(y))

    ## <NOTE>
    ## The number A of concordant pairs is given by
    ##   A = choose(n,2) + \sum_{i,j} x_{ij}^2
    ##       - (1/2) * (\sum_i x_{i.}^2 + \sum_j x_{.j}^2)
    ##     = choose(n,2) + 2 \sum_{i,j} choose(x_{ij},2)
    ##       - (\sum_i choose(x_{i.},2) + \sum_j choose(x_{.j},2)
    ## with the first version certainly much faster to compute.
    ## </NOTE>
    1 + (sum(x^2) -
         (sum(rowSums(x)^2) + sum(colSums(x)^2)) / 2) / choose(n, 2)
}
R/agreement.R:100

.cl_agreement_partition_cRand untypeabletyped

unbound variable (line 126)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.035 s
source
.cl_agreement_partition_cRand <-
function(x, y)
{
    if(!is.cl_hard_partition(x) || !is.cl_hard_partition(y))
        stop("Can only handle hard partitions.")

    n <- n_of_objects(x)    
    x <- table(cl_class_ids(x), cl_class_ids(y))

    ## <NOTE>
    ## The basic formula is
    ##   (Sxy - E) / ((Sx. + S.y) / 2 - E)
    ## where
    ##   Sxy = \sum_{i,j} choose(x_{ij}, 2)
    ##   Sx. = \sum_i     choose(x_{i.}, 2)
    ##   S.y = \sum_j     choose(x_{.j}, 2)
    ## and
    ##   E = Sx. * S.y / choose(n, 2)
    ## We replace the bincoefs by the corresponding sums of squares,
    ## getting
    ##   (Txy - F) / ((Tx. + T.y) / 2 - F)
    ## where
    ##   Txy = \sum_{i,j} x_{ij}^2 - n
    ##   Tx. = \sum_i     x_{i.}^2 - n
    ##   T.y = \sum_j     x_{.j}^2 - n
    ## and
    ##   F = Tx. * T.y / (n^2 - n)
    ## </NOTE>
    Txy <- sum(x ^ 2) - n
    Tx. <- sum(rowSums(x) ^ 2) - n
    T.y <- sum(colSums(x) ^ 2) - n
    F <- Tx. * T.y / (n ^ 2 - n)
    (Txy - F) / ((Tx. + T.y) / 2 - F)
}
R/agreement.R:123

.cl_agreement_partition_NMI untypeabletyped

unbound variable (line 164)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.040 s
source
.cl_agreement_partition_NMI <-
function(x, y)
{
    if(!is.cl_hard_partition(x) || !is.cl_hard_partition(y))
        stop("Can only handle hard partitions.")
    x <- table(cl_class_ids(x), cl_class_ids(y))
    x <- x / sum(x)
    
    m_x <- rowSums(x)
    m_y <- colSums(x)
    y <- outer(m_x, m_y)

    i <- which((x > 0) & (y > 0))
    out <- sum(x[i] * log(x[i] / y[i]))
    e_x <- sum(m_x * log(ifelse(m_x > 0, m_x, 1)))
    e_y <- sum(m_y * log(ifelse(m_y > 0, m_y, 1)))

    out / sqrt(e_x * e_y)
}
R/agreement.R:161

.cl_agreement_partition_KP untypeabletyped

unbound variable (line 189)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.024 s
source
.cl_agreement_partition_KP <-
function(x, y)
{
    ## Agreement measure due to Katz & Powell (1953, Psychometrika), see
    ## also Messatfa (1992, Journal of Classification).

    n <- n_of_objects(x)    

    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)
    x <- table(cl_class_ids(x), cl_class_ids(y))

    A_xy <- sum(x ^ 2)
    A_x. <- sum(rowSums(x) ^ 2)
    A_.y <- sum(colSums(x) ^ 2)

    (n^2 * A_xy - A_x. * A_.y) /
        sqrt(A_x. * (n^2 - A_x.) * A_.y * (n^2 - A_.y))
}
R/agreement.R:183

.cl_agreement_partition_angle untypeabletyped

unbound variable (line 210)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.014 s
source
.cl_agreement_partition_angle <-
function(x, y)
{
    ## Maximal angle between the matched memberships.

    k <- max(n_of_classes(x), n_of_classes(y))
    M_x <- cl_membership(x, k)
    M_y <- cl_membership(y, k)
    ## Match classes from conforming memberships.
    ind <- solve_LSAP(crossprod(M_x, M_y), maximum = TRUE)
    sum(M_x * M_y[, ind]) / sqrt(sum(M_x ^ 2) * sum(M_y ^ 2))
}
R/agreement.R:205

.cl_agreement_partition_diag untypeabletyped

unbound variable (line 225)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.009 s
source
.cl_agreement_partition_diag <-
function(x, y)
{
    ## Maximal co-classification rate.

    k <- max(n_of_classes(x), n_of_classes(y))
    M_x <- cl_membership(x, k)
    M_y <- cl_membership(y, k)
    ## Match classes from conforming memberships.
    ind <- solve_LSAP(crossprod(M_x, M_y), maximum = TRUE)
    sum(M_x * M_y[, ind]) / n_of_objects(x)
}
R/agreement.R:220

.cl_agreement_partition_FM untypeabletyped

unbound variable (line 240)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.017 s
source
.cl_agreement_partition_FM <-
function(x, y)
{
    ## Fowlkes-Mallows index.

    n <- n_of_objects(x)    

    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)
    x <- table(cl_class_ids(x), cl_class_ids(y))

    (sum(x ^ 2) - n) /
        sqrt((sum(rowSums(x) ^ 2) - n) * (sum(colSums(x) ^ 2) - n))
    
}
R/agreement.R:235

.cl_agreement_partition_Jaccard untypeabletyped

unbound variable (line 258)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.017 s
source
.cl_agreement_partition_Jaccard <-
function(x, y)
{
    ## Jaccard index.

    n <- n_of_objects(x)    

    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)
    x <- table(cl_class_ids(x), cl_class_ids(y))

    Z <- sum(x ^ 2)

    (Z - n) / (sum(rowSums(x) ^ 2) + sum(colSums(x) ^ 2) - n - Z)
    
}
R/agreement.R:253

.cl_agreement_partition_purity untypeabletyped

unbound variable (line 279)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.017 s
source
.cl_agreement_partition_purity <-
function(x, y)
{
    ## Purity of classes of x with respect to those of y: relative
    ## fraction of "optimally matched and collapsed" joint class
    ## frequencies, i.e., \sum_i \max_j c_{ij} / n.

    n <- n_of_objects(x)    

    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)
    x <- table(cl_class_ids(x), cl_class_ids(y))

    sum(apply(x, 1L, max)) / n
}
R/agreement.R:272

.cl_agreement_partition_PS untypeabletyped

unbound variable (line 299)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.010 s
source
.cl_agreement_partition_PS <-
function(x, y)
{
    ## Prediction Strength as used in Tibshirani and Walter (2005),
    ## "Cluster Validation by Prediction Strength", JCGS.

    ## See Eqn 2.1 in the reference: this is
    ##   min_l rate of different objects in the same class in partition
    ##         A and in class l in partition B,
    ## where the min is taken over all classes l of partition B.

    x <- table(cl_class_ids(x), cl_class_ids(y))
    s <- rowSums(x)

    min((rowSums(x ^ 2) - s) / (s * (s - 1)), na.rm = TRUE)
}   
R/agreement.R:288

.cl_agreement_hierarchy_euclidean untypeabletyped

unbound variable (line 352)
unbound: .cl_dissimilarity_hierarchy_euclidean — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_euclidean
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.006 s
source
.cl_agreement_hierarchy_euclidean <-
function(x, y)
    1 / (1 + .cl_dissimilarity_hierarchy_euclidean(x, y))
R/agreement.R:350

.cl_agreement_hierarchy_manhattan untypeabletyped

unbound variable (line 358)
unbound: .cl_dissimilarity_hierarchy_manhattan — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_manhattan
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.005 s
source
.cl_agreement_hierarchy_manhattan <-
function(x, y)
    1 / (1 + .cl_dissimilarity_hierarchy_manhattan(x, y))
R/agreement.R:356

.cl_agreement_hierarchy_cophenetic untypeabletyped

unbound variable (line 366)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.077 s
source
.cl_agreement_hierarchy_cophenetic <-
function(x, y)
{
    ## Cophenetic correlation.
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    cor(cl_object_dissimilarities(x), cl_object_dissimilarities(y))
}
R/agreement.R:362

.cl_agreement_hierarchy_angle untypeabletyped

unbound variable (line 378)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.093 s
source
.cl_agreement_hierarchy_angle <-
function(x, y)
{
    ## Angle between ultrametrics.
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u_x <- cl_object_dissimilarities(x)
    u_y <- cl_object_dissimilarities(y)
    sum(u_x * u_y) / sqrt(sum(u_x ^ 2) * sum(u_y ^ 2))
}
R/agreement.R:374

.cl_agreement_hierarchy_gamma untypeabletyped

unbound variable (line 390)
unbound: .cl_dissimilarity_hierarchy_gamma — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_hierarchy_gamma
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.005 s
source
.cl_agreement_hierarchy_gamma <-
function(x, y)
    1 - .cl_dissimilarity_hierarchy_gamma(x, y)
R/agreement.R:388

[.cl_agreement untypeabletyped

unbound variable (line 397)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any with { description: any, any }, i: any, j: any) -> any)<>
timing: 0.030 s
source
"[.cl_agreement" <-
function(x, i, j)
{
    y <- NextMethod("[")
    if(!inherits(y, "cl_agreement")) {
        description <- attr(x, "description")
        return(cl_cross_proximity(y, description = description,
                                  class = "cl_cross_agreement"))
    }
    y
}
R/agreement.R:394
R/prototypes.R

cl_prototypes untypeabletyped

unbound variable (line 3)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_prototypes <-
function(x)
    UseMethod("cl_prototypes")
R/prototypes.R:1

cl_prototypes.kmeans typed accepts outside

∀'a. ((x: { centers: 'a, any }) -> 'a)<>
timing: 0.021 s
fuzzing: 20 inside (20 ok) · 8 outside (5 rejected, 3 accepted)
type drawn from: ((x: { centers: 'I8100, any }) -> 'I8100)<>

Accepted outside the domain x: 3

parameterchangecallreturned
xkind:envcl_prototypes.kmeans(new.env())null
xkind:nullcl_prototypes.kmeans(NULL)null
xkind:nullcl_prototypes.kmeans("x" = NULL)null
source
cl_prototypes.kmeans <-
function(x)
    x$centers
R/prototypes.R:8

cl_prototypes.clara typed fuzz ok

∀'a. ((x: { medoids: 'a, any }) -> 'a)<>
timing: 0.022 s
fuzzing: 20 inside (20 ok) · 8 outside (8 rejected)
type drawn from: ((x: { medoids: 'I8108, any }) -> 'I8108)<>
source
cl_prototypes.clara <-
function(x)
    x$medoids
R/prototypes.R:13

cl_prototypes.pam typed fuzz ok

∀'a. ((x: { medoids: 'a, any }) -> 'a)<>
timing: 0.052 s
fuzzing: 20 inside (1 ok, 19 error pkg) · 8 outside (8 rejected)
type drawn from: ((x: { medoids: 'I8116, any }) -> 'I8116)<>

Other calls inside the domain

callverdicterror
cl_prototypes.pam("x" = list("medoids" = logical(0), function(...) local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), as.name("x")))error_pkgclue::cl_prototypes.pam: Cannot determine prototypes.
cl_prototypes.pam("x" = list("medoids" = integer(0), as.name("x")))error_pkgclue::cl_prototypes.pam: Cannot determine prototypes.
cl_prototypes.pam(list("medoids" = c(-1, 1000000), quote(f(x))))error_pkgclue::cl_prototypes.pam: Cannot determine prototypes.
cl_prototypes.pam(list("medoids" = complex(real = 1, imaginary = -2)))error_pkgclue::cl_prototypes.pam: Cannot determine prototypes.
cl_prototypes.pam("x" = list("medoids" = c("NA", "x y", "é", "NA", "x y"), NULL))error_pkgclue::cl_prototypes.pam: Cannot determine prototypes.
cl_prototypes.pam(list("medoids" = as.raw(c(255, 255)), as.raw(c(255, 255, 0, 255, 0)), NULL))error_pkgclue::cl_prototypes.pam: Cannot determine prototypes.
and 13 more
source
cl_prototypes.pam <-
function(x)
{
    p <- x$medoids
    if(!is.matrix(p))
        stop("Cannot determine prototypes.")
    p
}
R/prototypes.R:19

cl_prototypes.ccfkms typed accepts outside

∀'a. ((x: { centers: 'a, any }) -> 'a)<>
timing: 0.006 s
fuzzing: 20 inside (20 ok) · 8 outside (5 rejected, 3 accepted)
type drawn from: ((x: { centers: 'I8131, any }) -> 'I8131)<>

Accepted outside the domain x: 3

parameterchangecallreturned
xkind:envcl_prototypes.ccfkms(new.env())null
xkind:nullcl_prototypes.ccfkms(NULL)null
xunwrapcl_prototypes.ccfkms("x" = NULL)null
source
cl_prototypes.ccfkms <- cl_prototypes.kmeans
R/prototypes.R:29

cl_prototypes.cclust typed accepts outside

∀'a. ((x: { centers: 'a, any }) -> 'a)<>
timing: 0.007 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { centers: 'I8134, any }) -> 'I8134)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:langcl_prototypes.cclust("x" = quote(f(x)))null
source
cl_prototypes.cclust <- cl_prototypes.kmeans
R/prototypes.R:32

cl_prototypes.fclust typed accepts outside

∀'a. ((x: { centers: 'a, any }) -> 'a)<>
timing: 0.006 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { centers: 'I8137, any }) -> 'I8137)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:langcl_prototypes.fclust("x" = quote(f(x)))null
xkind:langcl_prototypes.fclust(quote(f(x)))null
source
cl_prototypes.fclust <- cl_prototypes.kmeans
R/prototypes.R:35

cl_prototypes.cshell typed accepts outside

∀'a. ((x: { centers: 'a, any }) -> 'a)<>
timing: 0.006 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { centers: 'I8140, any }) -> 'I8140)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:langcl_prototypes.cshell("x" = quote(f(x)))null
source
cl_prototypes.cshell <- cl_prototypes.kmeans
R/prototypes.R:37

cl_prototypes.bclust typed accepts outside

∀'a. ((x: { centers: 'a, any }) -> 'a)<>
timing: 0.006 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { centers: 'I8143, any }) -> 'I8143)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:nullcl_prototypes.bclust(NULL)null
source
cl_prototypes.bclust <- cl_prototypes.kmeans
R/prototypes.R:39

cl_prototypes.kcca untypeabletyped

unbound variable (line 45)
unbound: methods::slot — a name the prelude does not declare
error detail
name: methods::slot
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_prototypes.kcca <-
function(x)
    methods::slot(x, "centers")
R/prototypes.R:43

cl_prototypes.specc untypeabletyped

unbound variable (line 51)
unbound: kernlab::centers — a name the prelude does not declare
error detail
name: kernlab::centers
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_prototypes.specc <-
function(x)
    kernlab::centers(x)
R/prototypes.R:49

cl_prototypes.Mclust untypeabletyped

unbound variable (line 62)
unbound: t — a name the prelude does not declare
error detail
name: t
gradual mode: typed
((x: { mu: any, any }) -> any)<>
timing: 0.024 s
source
cl_prototypes.Mclust <-
function(x)
{
    p <- x$mu
    ## For multidimensional models, we get a matrix whose columns are
    ## the means of each group in the best model, and hence needs to be
    ## transposed.
    if(is.matrix(p))
        p <- t(p)
    p
}
R/prototypes.R:54

cl_prototypes.cl_pam typed accepts outside

∀'a. ((x: { prototypes: 'a, any }) -> 'a)<>
timing: 0.019 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { prototypes: 'I8176, any }) -> 'I8176)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:langcl_prototypes.cl_pam(quote(f(x)))null
xunwrapcl_prototypes.cl_pam("x" = NULL)null
source
cl_prototypes.cl_pam <-
function(x)
    x$prototypes
R/prototypes.R:67

cl_prototypes.cl_partition untypeabletyped

unbound variable (line 73)
unbound: cl_prototypes — one of the package’s own names, itself untyped
error detail
name: cl_prototypes
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.009 s
source
cl_prototypes.cl_partition <-
function(x)
    cl_prototypes(.get_representation(x))
R/prototypes.R:71

cl_prototypes.pclust typed fuzz ok

∀'a. ((x: { prototypes: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (8 rejected)
type drawn from: ((x: { prototypes: 'I8191, any }) -> 'I8191)<>
source
cl_prototypes.pclust <-
function(x)
    x$prototypes
R/prototypes.R:75
R/pava.R

pava skipped

error detail
Failure("Invalid left value.")
timing: 0.000 s
source
pava <-
function(x, w = NULL, solver = weighted.mean, merger = c)
{
    n <- length(x)
    if(is.null(w)) {
        w <- if(is.list(x))
            lapply(lengths(x), function(u) rep.int(1, u))
        else
            rep.int(1, n)
    } else if(is.list(x)) 
        w <- as.list(w)
    inds <- as.list(seq_len(n))    
    vals <- mapply(solver, x, w)

    ## Combine blocks i and i + 1.    
    combine <- if(is.list(x)) {
        ## In the repeated data case, we explicitly merge the data (and
        ## weight) lists.
        function(i) {
            ## Merge the data and indices, solve, and put things back
            ## into position i, dropping position i + 1.
            j <- i + 1L
            x[[i]] <<- merger(x[[i]], x[[j]])
            w[[i]] <<- c(w[[i]], w[[j]])
            vals[i] <<- solver(x[[i]], w[[i]])
            inds[[i]] <<- c(inds[[i]], inds[[j]])
            keep <- seq_len(n)[-j]
            x <<- x[keep]
            w <<- w[keep]
            vals <<- vals[keep]
            inds <<- inds[keep]
            n <<- n - 1L
        }
    } else {
        function(i) {
            ## In the "simple" case, merge only indices and values.
            j <- i + 1L
            inds[[i]] <<- c(inds[[i]], inds[[j]])
            vals[i] <<- solver(x[inds[[i]]], w[inds[[i]]])
            keep <- seq_len(n)[-j]
            vals <<- vals[keep]
            inds <<- inds[keep]
            n <<- n - 1L
        }
    }
        
    i <- 1L
    repeat {
        if(i < n) {
            if((vals[i] > vals[i + 1])) {
                combine(i)
                while((i > 1L) && (vals[i - 1L] > vals[i])) {
                    combine(i - 1L)
                    i <- i - 1L
                }
            }
            else
                i <- i + 1L
            }
        else break
    }
    rep.int(vals, lengths(inds))
}
R/pava.R:17
R/sumt.R

sumt untypeable

unbound variable (line 7)
unbound: sqrt — a name the prelude does not declare
error detail
name: sqrt
timing: 1.50 s
source
sumt <-
function(x0, L, P, grad_L = NULL, grad_P = NULL, method = NULL,
         eps = NULL, q = NULL, verbose = NULL, control = list())
{
    ## Default values: make it nice for others to call us.

    if(is.null(eps)) eps <- sqrt(.Machine$double.eps)
    if(is.null(method)) method <- "CG"
    if(is.null(q)) q <- 10
    if(is.null(verbose)) verbose <- getOption("verbose")
    
    Phi <- function(rho, x) L(x) + rho * P(x)

    if(is.null(grad_L) || is.null(grad_P)) {
        make_Phi <- function(rho) { function(x) Phi(rho, x) }
        make_grad_Phi <- function(rho) NULL
    }
    else {
        grad_Phi <- function(rho, x) grad_L(x) + rho * grad_P(x)
        make_Phi <- if(method == "nlm") {
            function(rho) {
                function(x)
                .structure(Phi(rho, x), gradient = grad_Phi(rho, x))
            }
        }
        else
            function(rho) {
                function(x)
                Phi(rho, x)
            }
        make_grad_Phi <- function(rho) { function(x) grad_Phi(rho, x) }
    }

    ## <NOTE>
    ## For the penalized minimization, the Newton-type nlm() may be
    ## computationally infeasible (although it works much faster for
    ## fitting ultrametrics to the Phonemes data).
    ## De Soete recommends using Conjugate Gradients.
    ## We provide a simple choice: by default, optim(method = "CG") is
    ## used.  If method is non-null and not "nlm", we use optim() with
    ## this method.  In both cases, control gives the control parameters
    ## for optim().
    ## If method is "nlm", nlm() is used, in which case control is
    ## ignored.  Note that we call nlm() with checking analyticals
    ## turned off, as in some cases (e.g. when fitting ultrametrics) the
    ## penalty function is not even continuous ...
    optimize_with_penalty <- if(method == "nlm")
        function(rho, x)
            nlm(make_Phi(rho), x, check.analyticals = FALSE) $ estimate
    else {
        function(rho, x)
            optim(x, make_Phi(rho), gr = make_grad_Phi(rho),
                  method = method, control = control) $ par
    }
    ## Note also that currently we do not check whether optimization was
    ## "successful" ...
    ## </NOTE>

    ## We currently require that x0 be a *list* of start values, the
    ## length of which gives the number of SUMT runs.  But as always,
    ## let's be nice to users and developers, just in case ...
    if(!is.list(x0))
        x0 <- list(x0)

    v_opt <- Inf
    x_opt <- NULL
    rho_opt <- NULL
    for(run in seq_along(x0)) {
        if(verbose)
            message(gettextf("SUMT run: %d", run))            
        x <- x0[[run]]
        ## <TODO>
        ## Better upper/lower bounds for rho?
        rho <- max(L(x), 0.00001) / max(P(x), 0.00001)
        ## </TODO>
        if(verbose)
            message(gettextf("Iteration: 0 Rho: %g P: %g", rho, P(x)))
        iter <- 1L
        repeat {
            ## <TODO>
            ## Shouldnt't we also have maxiter, just in case ...?
            ## </TODO>
            if(verbose)
                message(gettextf("Iteration: %d Rho: %g P: %g",
                                 iter, rho, P(x)))
            x_old <- x
            x <- optimize_with_penalty(rho, x)
            if(max(abs(x_old - x)) < eps)
                break
            iter <- iter + 1L
            rho <- q * rho
        }
        v <- Phi(rho, x)
        if(v < v_opt) {
            v_opt <- v
            x_opt <- x
            rho_opt <- rho
        }
        if(verbose)
            message(gettextf("Minimum: %g", v_opt))
    }

    .structure(list(x = x_opt, L = L(x_opt), P = P(x_opt), rho = rho_opt,
                    call = match.call()),
               class = "sumt")
}
R/sumt.R:1
R/ultrametric.R

.non_ultrametricity untypeable

unbound variable (line 798)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
timing: 0.046 s
source
.non_ultrametricity <-
function(x, max = FALSE)
{
    if(!is.matrix(x))
        x <- .symmetric_matrix_from_veclh(x)
    .C(C_deviation_from_ultrametricity,
       as.double(x),
       as.integer(nrow(x)),
       fn = double(1L),
       as.logical(max))$fn
}
R/ultrametric.R:794

.cl_ultrametric_from_veclh untypeabletyped

unbound variable (line 34)
unbound: .non_ultrametricity — one of the package’s own names, itself untyped
error detail
name: .non_ultrametricity
gradual mode: typed
((x: any, size: any?, labels: any?, meta: null?) -> any)<>
timing: 0.034 s
source
.cl_ultrametric_from_veclh <-
function(x, size = NULL, labels = NULL, meta = NULL)
{
    if(.non_ultrametricity(x) > 0)
        stop("Not a valid ultrametric.")
    u <- cl_proximity(x, "Ultrametric distances",
                      labels = labels, size = size,
                      class = c("cl_ultrametric", "cl_dissimilarity",
                      "cl_proximity", "dist"))
    if(!is.null(meta))
        attr(u, "meta") <- meta
    u
}
R/ultrametric.R:31

cl_ultrametric untypeabletyped

unbound variable (line 10)
unbound: cl_ultrametric — one of the package’s own names, itself untyped
error detail
name: cl_ultrametric
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }, size: any?, labels: null?) -> any)<>
timing: 0.086 s
source
cl_ultrametric <-
function(x, size = NULL, labels = NULL) 
{
    if(inherits(x, "cl_hierarchy")) {
        ## <NOTE>
        ## Strictly, not every hierarchy corresponds to an ultrametric.
        ## </NOTE>
        return(cl_ultrametric(.get_representation(x),
                              size = size, labels = labels))
    }
    else if(!inherits(x, "cl_ultrametric")) {
        ## Try using cophenetic().
        ## This starts by coercing to hclust, which has methods for all
        ## currently supported hierarchical classification methods.
        ## To support others, either provide as.hclust methods for
        ## these, or make cl_ultrametric() generic and add methods.
        ## Or use the fact that in R >= 2.1.0, stats::cophenetic() is
        ## generic.
        out <- cophenetic(x)
    }
    else {
        out <- x
        if(is.null(labels))
            labels <- attr(x, "Labels")
    }
    .cl_ultrametric_from_veclh(out, labels = labels, size = size)
}
R/ultrametric.R:3

as.cl_ultrametric untypeabletyped

unbound variable (line 49)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_ultrametric <-
function(x)
    UseMethod("as.cl_ultrametric")
R/ultrametric.R:47

as.cl_ultrametric.default untypeabletyped

unbound variable (line 55)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }) -> any)<>
timing: 0.015 s
source
as.cl_ultrametric.default <-
function(x)
{
    if(inherits(x, "cl_ultrametric"))
        x
    else if(is.atomic(x))
        .cl_ultrametric_from_veclh(x)
    else
        cl_ultrametric(x)
}
R/ultrametric.R:50

as.cl_ultrametric.matrix untypeabletyped

unbound variable (line 62)
unbound: row — a name the prelude does not declare
error detail
name: row
gradual mode: typed
((x: any) -> any)<>
timing: 0.006 s
source
as.cl_ultrametric.matrix <-
function(x)
    .cl_ultrametric_from_veclh(x[row(x) > col(x)],
                               labels = rownames(x))
R/ultrametric.R:60

as.dendrogram.cl_ultrametric untypeabletyped

unbound variable (line 69)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((object: any, ...: any) -> any)<>
timing: 0.003 s
source
as.dendrogram.cl_ultrametric <-
function(object, ...)
    as.dendrogram(as.hclust(object), ...)
R/ultrametric.R:67

as.hclust.cl_ultrametric untypeabletyped

unbound variable (line 81)
unbound: hclust — a name the prelude does not declare
error detail
name: hclust
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
as.hclust.cl_ultrametric <-
function(x, ...)
{
    ## Hierarchical clustering with single linkage gives the minimal
    ## ultrametric dominated by a dissimilarity, see e.g. Bock (1974,
    ## Theorem 39.2).  Hence, hclust(method = "single") on an
    ## ultrametric gives the hclust representation of the associated
    ## dendrogram.
    hclust(x, "single")
}
R/ultrametric.R:73

cophenetic.cl_ultrametric untypeabletyped

unbound variable (line 88)
unbound: as.dist — a name the prelude does not declare
error detail
name: as.dist
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cophenetic.cl_ultrametric <-
function(x)
    as.dist(x)
R/ultrametric.R:86

plot.cl_ultrametric untypeabletyped

unbound variable (line 94)
unbound: as.dendrogram — a name the prelude does not declare
error detail
name: as.dendrogram
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
plot.cl_ultrametric <-
function(x, ...)
    plot(as.dendrogram(x), ...)
R/ultrametric.R:92

.cl_ultrametric_with_meta_added untypeabletyped

unbound variable (line 859)
unbound: attr<- — a name the prelude does not declare
error detail
name: attr<-
gradual mode: typed
((x: any, meta: any?) -> any)<>
timing: 0.005 s
source
.cl_ultrametric_with_meta_added <-
function(x, meta = NULL)
{
    ## An alternative to adding a 'meta' argument to cl_ultrametric().
    attr(x, "meta") <- meta
    x
}
R/ultrametric.R:855

.make_penalty_function_ultrametric untypeabletyped

unbound variable (line 244)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: any) -> ((d: any) -> any)<>)<>
timing: 0.011 s
source
.make_penalty_function_ultrametric <-
function(n)
    function(d) {
        ## Smooth penalty function measuring the extent of violation of
        ## the ultrametricity constraint.  Also ensure nonnegativity ...
        (.non_ultrametricity(.symmetric_matrix_from_veclh(d, n))
         + sum(pmin(d, 0) ^ 2))
    }
R/ultrametric.R:239

.make_penalty_gradient_ultrametric untypeabletyped

unbound variable (line 252)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: dbl1<~@"*", ...>) -> ((d: any) -> any)<>)<>
timing: 0.019 s
source
.make_penalty_gradient_ultrametric <-
function(n)
    function(d) {
        gr <- matrix(.C(C_deviation_from_ultrametricity_gradient,
                        as.double(.symmetric_matrix_from_veclh(d, n)),
                        as.integer(n),
                        gr = double(n * n))$gr,
                     n, n)
        gr[row(gr) > col(gr)] + 2 * sum(pmin(d, 0))
    }
R/ultrametric.R:248

.ultrametrify untypeabletyped

unbound variable (line 877)
unbound: .dist_from_vector — one of the package’s own names, itself untyped
error detail
name: .dist_from_vector
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
.ultrametrify <-
function(x)
{
    ## Ensure ultrametricity.
    ## In earlier versions, function
    ## .cl_ultrametric_from_ultrametric_approximation() tried rounding
    ## to non-ultrametric significance, using
    ##   round(x, floor(abs(log10(.non_ultrametricity(x, max = TRUE)))))
    ## which is nice but does not guarantee ultrametricity (and may
    ## result in poorer approximations than what we use now).
    ## Hence, let us use single linkage hierarchical clustering which
    ## gives the best dominated ultrametric approximation.
    cophenetic(hclust(.dist_from_vector(x), "single"))
}
R/ultrametric.R:865

.ls_fit_ultrametric_by_SUMT untypeable

untypeable application of base::$ (line 175)
error detail
argument: @({  }<> | 'control, "nruns"<>)
failing call: base::$(list(), "nruns")
timing: 0.291 s
source
.ls_fit_ultrametric_by_SUMT <-
function(x, weights = 1, control = list())
{
    ## Fit an ultrametric to a dissimilarity by minimizing euclidean
    ## dissimilarity subject to the ultrametric constraint, using the
    ## sequential algorithm of de Soete (1984) with a slight change: we
    ## try to ensure that what we obtain satisfies the constraints
    ## "exactly" rather than approximately.  We (currently?) do that via
    ## rounding ...

    ## <NOTE>
    ## This fits and hence returns an ultrametric, *not* the hierarchy
    ## corresponding to the ultrametric.
    ## </NOTE>

    w <- weights / sum(weights)

    ## Control parameters:
    ## nruns,
    nruns <- control$nruns
    ## start.
    start <- control$start

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else if(is.null(nruns)) {
        ## Use nruns only if start is not given.
        nruns <- 1L
    }

    ## If x is an ultrametric, or satisfies the ultrametricity
    ## constraints, return it.
    if(inherits(x, "cl_ultrametric")
       || (.non_ultrametricity(x, max = TRUE) == 0))
        return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
                                               list(objval = 0)))

    ## For the time being, use a simple minimizer.

    n <- attr(x, "Size")
    labels <- attr(x, "Labels")

    ## Handle missing values in x along the lines of de Soete (1984):
    ## set the corresponding weights to 0, and impute by the weighted
    ## mean.
    ind <- which(is.na(x))
    if(any(ind)) {
        w[ind] <- 0
        x[ind] <- weighted.mean(x, w, na.rm = TRUE)
    }
    
    ## We follow de Soete's notation, and use the veclh's (vector of
    ## lower half, in S the same as x[lower.tri(x)]) of the respective
    ## proximity objects.

    L <- function(d) sum(w * (x - d) ^ 2)
    P <- .make_penalty_function_ultrametric(n)
    grad_L <- function(d) 2 * w * (d - x)
    grad_P <- .make_penalty_gradient_ultrametric(n)

    if(is.null(start)) {
        ## Initialize by "random shaking".  Use sd() for simplicity.
        start <- replicate(nruns,  
                           x + rnorm(length(x), sd = sd(x) / sqrt(3)),
                           simplify = FALSE)
    }
    
    ## And now ...
    out <- sumt(start, L, P, grad_L, grad_P,
                method = control$method, eps = control$eps,
                q = control$q, verbose = control$verbose,
                control = as.list(control$control))

    d <- .ultrametrify(out$x)
    meta <- list(objval = L(d))

    .cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:156

.ls_fit_ultrametric_by_iterative_projection untypeable

unbound variable (line 273)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.167 s
source
.ls_fit_ultrametric_by_iterative_projection <-
function(x, weights = 1, control = list())
{
    if(any(diff(weights) != 0))
        warning("Non-identical weights currently not supported.")

    labels <- attr(x, "Labels")
    n <- attr(x, "Size")

    x <- as.matrix(x)

    ## Control parameters:
    ## maxiter,
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 10000L
    ## nruns,
    nruns <- control$nruns
    ## order,
    order <- control$order
    ## tol,
    tol <- control$tol
    if(is.null(tol))
        tol <- 1e-8
    ## verbose.
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    ## Handle order and nruns.
    if(!is.null(order)) {
        if(!is.list(order))
            order <- as.list(order)
        if(!all(vapply(order,
                       function(o) all(sort(o) == seq_len(n)),
                       NA)))
            stop("All given orders must be valid permutations.")
    }
    else {
        if(is.null(nruns))
            nruns <- 1L
        order <- replicate(nruns, sample(n), simplify = FALSE)
    }

    ## <NOTE>
    ## Adjust in case support for non-identical weights is added.
    L <- function(d) sum((x - d) ^ 2)
    ## </NOTE>

    d_opt <- NULL
    v_opt <- Inf
    for(run in seq_along(order)) {
        if(verbose)
            message(gettextf("Iterative projection run: %d", run))
        d <- .C(C_ls_fit_ultrametric_by_iterative_projection,
                as.double(x),
                as.integer(n),
                as.integer(order[[run]] - 1L),
                as.integer(maxiter),
                iter = integer(1L),
                as.double(tol),
                as.logical(verbose))[[1L]]
        v <- L(d)
        if(v < v_opt) {
            v_opt <- v
            d_opt <- d
        }
    }
        
    d <- .ultrametrify(as.dist(matrix(d_opt, n)))
    meta <- list(objval = L(d))
    
    .cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:270

.ls_fit_ultrametric_by_iterative_reduction untypeable

unbound variable (line 350)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.163 s
source
.ls_fit_ultrametric_by_iterative_reduction <-
function(x, weights = 1, control = list())
{
    if(any(diff(weights) != 0))
        warning("Non-identical weights currently not supported.")

    labels <- attr(x, "Labels")
    n <- attr(x, "Size")

    x <- as.matrix(x)

    ## Control parameters:
    ## maxiter,
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 10000L
    ## nruns,
    nruns <- control$nruns
    ## order,
    order <- control$order
    ## tol,
    tol <- control$tol
    if(is.null(tol))
        tol <- 1e-8
    ## verbose.
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    ## Handle order and nruns.
    if(!is.null(order)) {
        if(!is.list(order))
            order <- as.list(order)
        if(!all(vapply(order,
                       function(o) all(sort(o) == seq_len(n)),
                       NA)))
            stop("All given orders must be valid permutations.")
    }
    else {
        if(is.null(nruns))
            nruns <- 1L
        order <- replicate(nruns, sample(n), simplify = FALSE)
    }

    ## <NOTE>
    ## Adjust in case support for non-identical weights is added.
    L <- function(d) sum((x - d) ^ 2)
    ## </NOTE>

    d_opt <- NULL
    v_opt <- Inf
    for(run in seq_along(order)) {
        if(verbose)
            message(gettextf("Iterative reduction run: %d", run))
        d <- .C(C_ls_fit_ultrametric_by_iterative_reduction,
                as.double(x),
                as.integer(n),
                as.integer(order[[run]] - 1L),
                as.integer(maxiter),
                iter = integer(1L),
                as.double(tol),
                as.logical(verbose))[[1L]]
        v <- L(d)
        if(v < v_opt) {
            v_opt <- v
            d_opt <- d
        }
    }

    d <- .ultrametrify(as.dist(matrix(d_opt, n)))
    meta <- list(objval = L(d))
    
    .cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:347

ls_fit_ultrametric untypeable

unbound variable (line 103)
unbound: .cl_ultrametric_with_meta_added — one of the package’s own names, itself untyped
error detail
name: .cl_ultrametric_with_meta_added
timing: 0.187 s
source
ls_fit_ultrametric <-
function(x, method = c("SUMT", "IP", "IR"), weights = 1,
         control = list())
{
    if(inherits(x, "cl_ultrametric")) {
        return(.cl_ultrametric_with_meta_added(x, list(objval = 0)))
    } else if(is.cl_ensemble(x) || is.list(x)) {
        ## Might be given a list/ensemble of object dissimilarities.
        ## In this case, compute the suitably weighted average and
        ## proceed.
        if(length(x) == 0L)
            stop("Given ensemble contains no dissimilarities.")
        ## Let's be nice as usual ...
        ind <- !vapply(x, .has_object_dissimilarities, NA)
        if(any(ind))
            x[ind] <- lapply(x[ind], as.dist)
        x <- .weighted_mean_of_object_dissimilarities(x,
                                                      control$weights)
    } else if(!inherits(x, "dist"))
        x <- as.dist(x)

    ## Catch some special cases right away.
    if(attr(x, "Size") <= 2L)
        return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
                                               list(objval = 0)))
    if(.non_ultrametricity(x, max = TRUE) == 0)
        return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
                                               list(objval = 0)))

    ## Handle weights.
    ## This is somewhat tricky ...
    if(is.matrix(weights)) {
        weights <- as.dist(weights)
        if(length(weights) != length(x))
            stop("Argument 'weights' must be compatible with 'x'.")
    }
    else
        weights <- rep_len(weights, length(x))
    if(any(weights < 0))
        stop("Argument 'weights' has negative elements.")
    if(!any(weights > 0))
        stop("Argument 'weights' has no positive elements.")

    method <- match.arg(method)
    switch(method,
           SUMT = .ls_fit_ultrametric_by_SUMT(x, weights, control),
           IP = {
               .ls_fit_ultrametric_by_iterative_projection(x, weights,
                                                           control)
           },
           IR = {
               .ls_fit_ultrametric_by_iterative_reduction(x, weights,
                                                          control)
           })
}
R/ultrametric.R:98

.handle_weights_for_ultrametric_target_fitters untypeable

unbound variable (line 502)
unbound: rep_len — a name the prelude does not declare
error detail
name: rep_len
timing: 0.215 s
source
.handle_weights_for_ultrametric_target_fitters <-
function(weights, x)
{
    ## Handle weights for the ultrametric target fitters.
    ## This is somewhat tricky ...
    if(is.matrix(weights)) {
        if(any(dim(weights) != attr(x, "Size")))
            stop("Argument 'weights' must be compatible with 'x'.")
    }
    else
        weights <-
            as.matrix(.dist_from_vector(rep_len(weights, length(x))))
    if(any(weights < 0))
        stop("Argument 'weights' has negative elements.")
    if(!any(weights > 0))
        stop("Argument 'weights' has no positive elements.")
    weights
}
R/ultrametric.R:491

.fit_ultrametric_target untypeabletyped

unbound variable (line 455)
unbound: .handle_weights_for_ultrametric_target_fitters — one of the package’s own names, itself untyped
error detail
name: .handle_weights_for_ultrametric_target_fitters
gradual mode: typed
((x: any, y: any, w: any, fitter: any, distfun: null?) -> any)<>
timing: 0.174 s
source
.fit_ultrametric_target <-
function(x, y, w, fitter, distfun = NULL)
{
    w <- .handle_weights_for_ultrametric_target_fitters(w, x)
    ## The documentation says that x should inherit from dist, so coerce
    ## to this if needed but if not a matrix (as we will coerce back to
    ## a matrix right away).
    if(!inherits(x, "dist") && !is.matrix(x))
        x <- as.dist(x)
    x <- as.matrix(x)
    y <- as.hclust(y)
    n <- length(y$order)
    ilist <- vector("list", n)
    out <- matrix(0, n, n)
    mat <- xlist <- wlist <- vector("list", n - 1L)
    for(i in seq_len(n - 1L)) {
        inds <- y$merge[i, ]
        ids1 <- if(inds[1L] < 0) -inds[1L] else ilist[[inds[1L]]]
        ids2 <- if(inds[2L] < 0) -inds[2L] else ilist[[inds[2L]]]
        ilist[[i]] <- c(ids1, ids2)
        mat[[i]] <- cbind(rep.int(ids1,
                                  rep.int(length(ids2), length(ids1))), 
                          rep.int(ids2, length(ids1)))
        xlist[[i]] <- x[mat[[i]]]
        wlist[[i]] <- w[mat[[i]]]
    }
    values <- pava(xlist, wlist, fitter)
    for(i in seq_len(n - 1L))
        out[mat[[i]]] <- values[i]
    rownames(out) <- y$labels
    u <- as.cl_ultrametric(out + t(out))
    if(!is.null(distfun))
        attr(u, "meta") <-
            list(objval = distfun(as.dist(x), u, as.dist(w)))
    u
}
R/ultrametric.R:452

ls_fit_ultrametric_target untypeable

unbound variable (line 430)
unbound: mean — a name the prelude does not declare
error detail
name: mean
timing: 0.028 s
source
ls_fit_ultrametric_target <-
function(x, y, weights = 1)
{
    fitter <- if(identical(weights, 1)) # Default.
        function(x, w) mean(x)
    else
        function(x, w) weighted.mean(x, w)
    distfun <- function(x, u, w) sqrt(sum(w * (x - u) ^ 2))
    .fit_ultrametric_target(x, y, weights, fitter, distfun)
}
R/ultrametric.R:426

l1_fit_ultrametric_target untypeable

unbound variable (line 443)
unbound: median — a name the prelude does not declare
error detail
name: median
timing: 0.027 s
source
l1_fit_ultrametric_target <-
function(x, y, weights = 1)
{
    fitter <- if(identical(weights, 1)) # Default.
        function(x, w) median(x)
    else
        function(x, w) weighted_median(x, w)
    distfun <- function(x, u, w) sum(w * abs(x - u))
    .fit_ultrametric_target(x, y, weights, fitter, distfun)
}
R/ultrametric.R:439

.l1_fit_ultrametric_by_IRIP untypeable

untypeable application of base::$ (line 630)
error detail
argument: @({  }<> | 'control, "MIN"<>)
failing call: base::$(list(), "MIN")
timing: 0.317 s
source
.l1_fit_ultrametric_by_IRIP <-
function(x, weights = 1, control = list())
{
    ## An attempt of implementing "Iteratively Reweighted Iterative
    ## Projection" as described in Smith (2000, 2001), Journal of
    ## Classification.  Note that this suggests using the Iterative
    ## Projection of Hubert and Arabie (1995), which we cannot as we
    ## have not (yet?) implemented this for the weighted case.  Hence,
    ## we use our SUMT least squares ultrametric fitter instead.
    ##
    ## However, we never got this to converge properly ...
    
    w <- weights / sum(weights)
    
    ## Control parameters:
    ## MIN,
    MIN <- control$MIN
    if(is.null(MIN))
        MIN <- 1e-3
    ## (A rather small cut-off which worked best in the cases we tried.)
    ## eps,
    eps <- control$eps
    if(is.null(eps))
        eps <- 1e-6
    ## maxiter,
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 100L
    ## reltol,
    reltol <- control$reltol
    if(is.null(reltol))
        reltol <- 1e-6
    ## start,
    start <- control$start
    ## verbose.
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    n <- attr(x, "Size")
    labels <- attr(x, "Labels")

    L <- function(d) sum(w * abs(x - d))

    ## Initialize by "random shaking" as for the L2 SUMT, but perhaps we
    ## should not do this?  [Or do it differently?]
    u <- if(is.null(start))
        x + rnorm(length(x), sd = sd(x) / 3)
    else
        start
    ## (No multiple runs for the time being.)
    L_new <- L(u)

    iter <- 1L
    while(iter <= maxiter) {
        if(verbose)
            message(gettextf("Outer iteration: %d", iter))
        L_old <- L_new
        u_old <- u
        weights <- w / pmax(abs(u - x), MIN)
        u <- .ls_fit_ultrametric_by_SUMT(x,
                                         weights = weights,
                                         control = as.list(control$control))
        ## Use some control arguments lateron ...
        L_new <- L(u)
        delta_L <- L_old - L_new
        delta_u <- max(abs(u_old - u))
        if(verbose)
            message(gettextf("Change: u: %g L: %g", delta_u, delta_L))
        if((delta_u < eps) ||
           ((delta_L >= 0) &&
            (delta_L <= reltol * (abs(L_old) + reltol))))
            break
        iter <- iter + 1L
    }

    d <- .ultrametrify(u)
    meta <- list(objval = L(d), status = as.integer(iter == maxiter))

    .cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:614

.l1_fit_ultrametric_by_SUMT untypeable

untypeable application of base::$ (line 561)
error detail
argument: @({  }<> | 'control, "gradient"<>)
failing call: base::$(list(), "gradient")
timing: 0.243 s
source
.l1_fit_ultrametric_by_SUMT <-
function(x, weights = 1, control = list())
{
    ## Try a SUMT with "pseudo-gradients".

    w <- weights / sum(weights)

    ## Control parameters:
    ## gradient,
    gradient <- control$gradient
    if(is.null(gradient))
        gradient <- TRUE
    ## nruns,
    nruns <- control$nruns
    ## start.
    start <- control$start

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else if(is.null(nruns)) {
        ## Use nruns only if start is not given.
        nruns <- 1L
    }

    ## For the time being, use a simple minimizer.

    n <- attr(x, "Size")
    labels <- attr(x, "Labels")

    L <- function(d) sum(w * abs(d - x))
    P <- .make_penalty_function_ultrametric(n)
    if(gradient) {
        grad_L <- function(d) w * sign(d - x)
        grad_P <- .make_penalty_gradient_ultrametric(n)
    } else
        grad_L <- grad_P <- NULL

    if(is.null(start)) {
        ## Initialize by "random shaking".  Use sd() for simplicity.
        start <- replicate(nruns,  
                           x + rnorm(length(x), sd = sd(x) / sqrt(3)),
                           simplify = FALSE)
    }

    ## And now ...
    out <- sumt(start, L, P, grad_L, grad_P,
                method = control$method, eps = control$eps,
                q = control$q, verbose = control$verbose,
                control = as.list(control$control))

    d <- .ultrametrify(out$x)
    meta <- list(objval = L(d))

    .cl_ultrametric_from_veclh(d, n, labels, meta)
}
R/ultrametric.R:552

l1_fit_ultrametric untypeable

unbound variable (line 517)
unbound: .cl_ultrametric_with_meta_added — one of the package’s own names, itself untyped
error detail
name: .cl_ultrametric_with_meta_added
timing: 0.146 s
source
l1_fit_ultrametric <-
function(x, method = c("SUMT", "IRIP"), weights = 1,
         control = list())
{
    if(inherits(x, "cl_ultrametric"))
        return(.cl_ultrametric_with_meta_added(x, list(objval = 0)))

    if(!inherits(x, "dist"))
        x <- as.dist(x)

    ## Catch some special cases right away.
    if(attr(x, "Size") <= 2L)
        return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
                                               list(objval = 0)))
    if(.non_ultrametricity(x, max = TRUE) == 0)
        return(.cl_ultrametric_with_meta_added(as.cl_ultrametric(x),
                                               list(objval = 0)))

    ## Handle weights.
    ## This is somewhat tricky ...
    if(is.matrix(weights)) {
        weights <- as.dist(weights)
        if(length(weights) != length(x))
            stop("Argument 'weights' must be compatible with 'x'.")
    }
    else
        weights <- rep_len(weights, length(x))
    if(any(weights < 0))
        stop("Argument 'weights' has negative elements.")
    if(!any(weights > 0))
        stop("Argument 'weights' has no positive elements.")

    method <- match.arg(method)
    switch(method,
           SUMT = .l1_fit_ultrametric_by_SUMT(x, weights, control),
           IRIP = .l1_fit_ultrametric_by_IRIP(x, weights, control))
}
R/ultrametric.R:512

ls_fit_sum_of_ultrametrics untypeable

unbound variable (line 702)
unbound: as.dist — a name the prelude does not declare
error detail
name: as.dist
timing: 0.304 s
source
ls_fit_sum_of_ultrametrics <-
function(x, nterms = 1, weights = 1, control = list())
{
    if(!inherits(x, "dist"))
        x <- as.dist(x)

    ## We could catch some special cases right away: if x already is an
    ## ultrametric then the fit would be a list with x and nterms - 1
    ## zero ultrametrics ...
    
    ## Control parameters:
    ## eps,
    eps <- control$eps
    if(is.null(eps))
        eps <- 1e-6
    ## maxiter,
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 100L
    ## method,
    method <- control$method
    if(is.null(method))
        method <- "SUMT"
    ## reltol,
    reltol <- control$reltol
    if(is.null(reltol))
        reltol <- 1e-6
    ## verbose.
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")
    ## Do this at last.
    control <- as.list(control$control)
    ## And be nice ...
    if(identical(method, "SUMT") && is.null(control$nruns))
        control$nruns <- 10L

    L <- function(u)
        sum((x - rowSums(matrix(unlist(u), ncol = nterms))) ^ 2)
    
    ## Init.
    u <- rep.int(list(as.cl_ultrametric(0 * x)), nterms)
    L_new <- L(u)

    ## Loop.
    iter <- 1L
    while(iter <= maxiter) {
        if(verbose)
            message(gettextf("Iteration: %d", iter))
        L_old <- L_new
        delta_u <- 0
        for(i in seq_len(nterms)) {
            if(verbose)
                message(gettextf("Term: %d", i))
            u_old <- u[[i]]
            ## Compute residual r = x - \sum_{j: j \ne i} u(j)
            r <- x - rowSums(matrix(unlist(u[-i]), ncol = nterms - 1L))
            ## Fit residual.
            u[[i]] <- ls_fit_ultrametric(r, method, weights, control)
            ## Accumulate change.
            change <- max(abs(u[[i]] - u_old))
            if(verbose)
                message(gettextf("Change: %g", change))
            delta_u <- max(delta_u, change)
        }
        L_new <- L(u)
        delta_L <- L_old - L_new
        if(verbose)
            message(gettextf("Overall change: u: %g L: %g\n",
                             delta_u, delta_L))
        if((delta_u < eps) ||
           ((delta_L >= 0) &&
            (delta_L <= reltol * (abs(L_old) + reltol))))
            break
        iter <- iter + 1L
    }
    
    .structure(u, objval = L_new, status = as.integer(iter == maxiter))
}
R/ultrametric.R:698

as.matrix.hclust untypeabletyped

unbound variable (line 790)
unbound: cophenetic — a name the prelude does not declare
error detail
name: cophenetic
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
as.matrix.hclust <-
function(x, ...)
    as.matrix(cophenetic(x))
R/ultrametric.R:788

.cl_ultrametric_from_classes untypeable

unbound variable (line 817)
unbound: duplicated — a name the prelude does not declare
error detail
name: duplicated
timing: 0.051 s
source
.cl_ultrametric_from_classes <-
function(x)
{
    ## Compute an ultrametric from a hierarchy of classes (i.e., an
    ## n-tree).

    labels <- attr(x, "labels")

    ## Ensure we have no duplicates.
    x <- x[!duplicated(x)]
    
    ## .get_classes_in_hierarchy() orders according to cardinality, but
    ## a consensus method may forget to ...
    x[] <- x[order(lengths(x))]

    ## Get the objects (unique codes in the classes).
    objects <- sort(unique(unlist(x)))
    ## (Could also look at the classes of length 1.)

    ## Recursively compute the heights of the classes.
    heights <- double(length = length(x))
    for(i in which(lengths(x) > 1L)) {
        ## Find the relevant classes.
        j <- sapply(x[seq_len(i - 1L)],
                    function(s) all(s %in% x[[i]]))
        heights[i] <- max(heights[j]) + 1
    }

    ## Next, create an incidence matrix (objects by classes).
    incidences <- sapply(x, function(s) objects %in% s)

    ## Now that we have the heights and incidences, we can compute
    ## distances, using the idea that
    ##     distance(i, j) = min(height(A): A contains i and j)
    n <- length(objects)
    d <- matrix(0, n, n)
    for(i in objects)
        d[i, ] <- heights[apply((rep(incidences[i, ], each = n)
                                 & incidences),
                                1L, which.max)]
    dimnames(d) <- rep.int(list(labels), 2L)

    as.cl_ultrametric(d)
}
R/ultrametric.R:808
R/dissimilarity.R

cl_dissimilarity untypeable

unbound variable (line 6)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.135 s
source
cl_dissimilarity <-
function(x, y = NULL, method = "euclidean", ...)
{
    x <- as.cl_ensemble(x)
    is_partition_ensemble <-
        (inherits(x, "cl_partition_ensemble")
         || all(vapply(x, .has_object_memberships, NA)))

    ## Be nice.
    if(is.character(y) || is.function(y)) {
        method <- y
        y <- NULL
    }

    if(is.function(method))
        method_name <- "user-defined method"
    else {
        if(!inherits(method, "cl_dissimilarity_method")) {
            ## Get the method definition and description from the
            ## registry. 
            type <- ifelse(is_partition_ensemble,
                           "partition", "hierarchy")
            method <- get_cl_dissimilarity_method(method, type)
        }
        method_name <- method$description
        method <- method$definition
    }
              
    if(!is.null(y)) {
        y <- as.cl_ensemble(y)
        is_partition_ensemble_y <-
            (inherits(y, "cl_partition_ensemble")
             || all(vapply(x, .has_object_memberships, NA)))
        if(!identical(is_partition_ensemble, is_partition_ensemble_y))
            stop("Cannot mix partitions and hierarchies.")
        if(n_of_objects(x) != n_of_objects(y))
            stop("All clusterings must have the same number of objects.")
        ## Build a cross-proximity object of cross-dissimilarities.
        d <- matrix(0, length(x), length(y))
        for(j in seq_along(y))
            d[, j] <- sapply(x, method, y[[j]], ...)
        dimnames(d) <- list(names(x), names(y))
        return(cl_cross_proximity(d, method_name,
                                  class = "cl_cross_dissimilarity"))
    }
    
    ## Otherwise, build a proximity object of dissimilarities.
    n <- length(x)
    d <- vector("list", length = n - 1L)
    ind <- seq_len(n)
    while(length(ind) > 1L) {
        j <- ind[1L]
        ind <- ind[-1L]
        d[[j]] <- sapply(x[ind], method, x[[j]], ...)
    }
    
    cl_proximity(unlist(d),
                 method_name,
                 labels = names(x),
                 size = n,
                 class = c("cl_dissimilarity", "cl_proximity", "dist"))
}
R/dissimilarity.R:3

.cl_dissimilarity_partition_euclidean untypeabletyped

unbound variable (line 71)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.013 s
source
.cl_dissimilarity_partition_euclidean <-
function(x, y)
{
    k <- max(n_of_classes(x), n_of_classes(y))
    M_x <- cl_membership(x, k)
    M_y <- cl_membership(y, k)
    ## Match classes from conforming memberships.
    ind <- solve_LSAP(crossprod(M_x, M_y), maximum = TRUE)
    sqrt(sum((M_x - M_y[, ind]) ^ 2))
}
R/dissimilarity.R:68

.cxdist untypeabletimeout

unbound variable (line 555)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: timeout
timing: 0.125 s
source
.cxdist <-
function(A, B, method = c("euclidean", "manhattan", "minkowski"), ...)
{
    ## Return the column cross distance matrix of A and B.
    ## I.e., the matrix C = [c_{j,k}] with
    ##   c_{j,k} = distance(A[, j], B[, k])
    ## Currently, only Manhattan (L1) distances are provided.
    ## Extensions to Minkowski or even more distances (a la dist())
    ## could be added eventually.

    ## <NOTE>
    ## Possible implementations include
    ##
    ## foo_a <- function(A, B)
    ##   apply(B, 2, function(u) colSums(abs(A - u)))
    ## foo_d <- function(A, B) {
    ##   out <- as.matrix(dist(rbind(t(A), t(B)), "manhattan"))
    ##   dimnames(out) <- NULL
    ##   nc_B <- NCOL(B)
    ##   out[seq(from = NCOL(A) + 1, length.out = nc_B), seq_len(nc_B)]
    ## }
    ## foo_f <- function(A, B) {
    ##   out <- matrix(0, NCOL(A), NCOL(B))
    ##   for(j in seq_len(NCOL(A)))
    ##     for(k in seq_len(NCOL(B)))
    ##       out[j, k] = sum(abs(A[, j] - B[, k]))
    ##   out
    ## }
    ##
    ## The one actually used seems to be the best performer, with the
    ## "for" version a close second (note that "typically", A and B have
    ## much fewer columns than rows).
    ## only few columns

    method <- match.arg(method)
    
    ## Workhorse.
    FOO <- switch(method,
                  "euclidean" =
                  function(M) sqrt(colSums(M ^ 2)),
                  "manhattan" = 
                  function(M) colSums(abs(M)),
                  "minkowski" = {
                      ## Power needs to be given.
                      p <- list(...)[[1L]]
                      function(M)
                          (colSums(abs(M) ^ p)) ^ (1 / p)
                  })
    
    
    out <- matrix(0, NCOL(A), NCOL(B))
    for(k in seq_len(NCOL(B)))
        out[, k] <- FOO(A - B[, k])
    out
}
R/dissimilarity.R:516

.cl_dissimilarity_partition_manhattan untypeabletyped

unbound variable (line 84)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.008 s
source
.cl_dissimilarity_partition_manhattan <-
function(x, y)
{
    k <- max(n_of_classes(x), n_of_classes(y))
    M_x <- cl_membership(x, k)
    M_y <- cl_membership(y, k)
    C <- .cxdist(M_x, M_y, "manhattan")
    ind <- solve_LSAP(C)
    sum(C[cbind(seq_along(ind), ind)])
}    
R/dissimilarity.R:81

.cl_dissimilarity_partition_comemberships untypeabletyped

unbound variable (line 108)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.019 s
source
.cl_dissimilarity_partition_comemberships <-
function(x, y)
{
    ## We used to have the straightforward
    ##   C_x <- tcrossprod(cl_membership(x)) # M_x M_x'
    ##   C_y <- tcrossprod(cl_membership(y)) # M_y M_y'
    ##   sum((C_x - C_y) ^ 2) / n_of_objects(x) ^ 2
    ## But note that
    ##   \| AA' - BB' \|^2
    ##      = tr((AA' - BB')'(AA' - BB')
    ##      = tr(A'A A'A) - 2 tr(A'B B'A) + tr(B'B B'B)
    ##      = \| A'A \|^2 - 2 \| A'B \|^2 + \| B'B \|^2
    ## which can be computed much more efficiently as all involved cross
    ## product matrices are "small" ...
    k <- max(n_of_classes(x), n_of_classes(y))
    M_x <- cl_membership(x, k)
    M_y <- cl_membership(y, k)
    sqrt(sum(crossprod(M_x) ^ 2)
         - 2 * sum(crossprod(M_x, M_y) ^ 2)
         + sum(crossprod(M_y) ^ 2))
}
R/dissimilarity.R:94

.cl_dissimilarity_partition_Rand untypeable

unbound variable (line 140)
unbound: .cl_agreement_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_agreement_partition_Rand
timing: 0.005 s
source
.cl_dissimilarity_partition_Rand <-
function(x, y)    
{
    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)

    1 - .cl_agreement_partition_Rand(x, y)
}
R/dissimilarity.R:134

.cl_dissimilarity_partition_symdiff untypeabletyped

unbound variable (line 128)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.005 s
source
.cl_dissimilarity_partition_symdiff <-
function(x, y)
{
    ## Cardinality of the symmetric difference of the partitions
    ## regarded as binary equivalence relations, i.e., the number of
    ## discordant pairs.

    ## Handle soft partitions using the corresponding hard ones.
    ## (At least, for the time being.)

    n <- n_of_objects(x)
    .cl_dissimilarity_partition_Rand(x, y) * choose(n, 2)
}
R/dissimilarity.R:118

.cl_dissimilarity_partition_GV1 untypeabletyped

unbound variable (line 148)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 6.56 s
source
.cl_dissimilarity_partition_GV1 <-
function(x, y)
{    
    k_x <- n_of_classes(x)
    k_y <- n_of_classes(y)
    M_x <- cl_membership(x, k_x)
    M_y <- cl_membership(y, k_y)
    C <- outer(colSums(M_x ^ 2), colSums(M_y ^ 2), `+`) -
        2 * crossprod(M_x, M_y)
    if(k_x < k_y)
        C <- rbind(C, matrix(0, nrow = k_y - k_x, ncol = k_y))
    else if(k_x > k_y)
        C <- cbind(C, matrix(0, nrow = k_x, ncol = k_x - k_y))
    ind <- solve_LSAP(C)
    sqrt(sum(C[cbind(seq_along(ind), ind)]))
    ## (Note that this sum really only includes matched non-dummy
    ## classes.)
}
R/dissimilarity.R:145

.cl_dissimilarity_partition_BA_A untypeabletyped

unbound variable (line 169)
unbound: as.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: as.cl_hard_partition
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.004 s
source
.cl_dissimilarity_partition_BA_A <-
function(x, y)
{
    .cl_dissimilarity_partition_manhattan(as.cl_hard_partition(x),
                                          as.cl_hard_partition(y)) / 2
    ## Could to this more efficiently, of course ...
}
R/dissimilarity.R:166

.cl_dissimilarity_partition_BA_C untypeabletyped

unbound variable (line 179)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.007 s
source
.cl_dissimilarity_partition_BA_C <-
function(x, y)
{
    n_of_classes(x) + n_of_classes(y) - 2 * n_of_classes(cl_join(x, y))
}
R/dissimilarity.R:176

.cl_dissimilarity_partition_BA_D untypeabletyped

unbound variable (line 185)
unbound: .cl_dissimilarity_partition_Rand — one of the package’s own names, itself untyped
error detail
name: .cl_dissimilarity_partition_Rand
gradual mode: typed
any
timing: 0.000 s
source
.cl_dissimilarity_partition_BA_D <-
    .cl_dissimilarity_partition_Rand
R/dissimilarity.R:184

.cl_dissimilarity_partition_BA_E untypeabletyped

unbound variable (line 192)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.024 s
source
.cl_dissimilarity_partition_BA_E <-
function(x, y)
{
    z <- table(cl_class_ids(x), cl_class_ids(y))
    z <- z / sum(z)

    ## Average mutual information between the partitions.
    y <- outer(rowSums(z), colSums(z))
    i <- which((z > 0) & (y > 0))
    I <- sum(z[i] * log(z[i] / y[i]))

    ## Entropy of meet(x, y).
    i <- which(z > 0)
    H <- - sum(z[i] * log(z[i]))

    1 - I / H
}
R/dissimilarity.R:189

.cl_dissimilarity_partition_VI untypeabletyped

unbound variable (line 214)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
((x: any, y: any, weights: any?) -> any)<>
timing: 0.037 s
source
.cl_dissimilarity_partition_VI <-
function(x, y, weights = 1)
{
    ## Variation of information for general "soft clusterings", cf
    ## Section 5.2. in Meila (2002). 
    weights <- rep_len(weights, n_of_objects(x))
    weights <- weights / sum(weights)
    M_x <- cl_membership(x)
    ## Weighted marginal distribution of x:
    m_x <- colSums(weights * M_x)
    M_y <- cl_membership(y)
    ## Weighted marginal distribution of y:
    m_y <- colSums(weights * M_y)
    gamma <- crossprod(weights * M_x, M_y)
    delta <- outer(m_x, m_y)
    ## Entropy of x:
    H_x <- - sum(m_x * log(ifelse(m_x > 0, m_x, 1)))
    ## Entropy of y:
    H_y <- - sum(m_y * log(ifelse(m_y > 0, m_y, 1)))
    ## VI is H_x + H_y minus twice the (weighted) joint information.
    i <- which((gamma > 0) & (delta > 0))
    H_x + H_y - 2 * sum(gamma[i] * log(gamma[i] / delta[i]))
}
R/dissimilarity.R:209

.cl_dissimilarity_partition_Mallows untypeable

unbound variable (line 256)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
timing: 0.044 s
source
.cl_dissimilarity_partition_Mallows <-
function(x, y, p = 1, alpha = NULL, beta = NULL)
{
    ## Currently, no "real" primal-dual solver for minimum cost flow
    ## problems, and lpSolve::lp.transport() seems to work only for
    ## integer bounds.  Hence, rather than using
    ##
    ##   C <- .cxdist(cl_membership(x), cl_membership(y),
    ##                "minkowski", p) ^ p
    ##   n_x <- nrow(C)
    ##   n_y <- ncol(C)
    ##   if(is.null(alpha))
    ##       alpha <- rep.int(1 / n_x, n_x)
    ##   else {
    ##       alpha <- rep_len(alpha, n_x)
    ##       alpha <- alpha / sum(alpha)
    ##   }
    ##
    ## etc right away, ensure a square cost matrix so that we can have
    ## integer bounds for at least the default case.

    k <- max(n_of_classes(x), n_of_classes(y))
    M_x <- cl_membership(x, k)
    M_y <- cl_membership(y, k)
    C <- .cxdist(M_x, M_y, "minkowski", p) ^ p
    if(is.null(alpha)) alpha <- rep.int(1, k)
    if(is.null(beta)) beta <- rep.int(1, k)
    lpSolve::lp.transport(C, "min",
                          rep.int("==", k), alpha,
                          rep.int("==", k), beta,
                          integers = NULL)$objval ^ (1 / p)
}
R/dissimilarity.R:235

.rxdist untypeabletyped

unbound variable (line 595)
unbound: sweep — a name the prelude does not declare
error detail
name: sweep
gradual mode: typed
(((A: any, B: any, method: (vec | null)?) -> empty)&((A: any, B: any, method: (vec | null)?, ...: dbl) -> any))<>
timing: 0.215 s
source
.rxdist <-
function(A, B, method = c("euclidean", "manhattan", "minkowski"), ...)
{
    ## Return the row cross distance matrix of A and B.
    ## I.e., the matrix C = [c_{j,k}] with
    ##   c_{j,k} = distance(A[j, ], B[k, ])
    
    ## <NOTE>
    ## Could also do something like
    ##   ind <- seq_len(NROW(B))
    ##   as.matrix(dist(rbind(B, A)))[-ind, ind]
    ## but that is *very* inefficient for the "usual" data by prototype
    ## case (where NROW(B) << NROW(A)).
    ## </NOTE>
    
    ## No fancy pmatching for methods for the time being.
    method <- match.arg(method)
    
    ## Workhorse: Full A, single row of b.
    FOO <- switch(method,
                  "euclidean" =
                  function(A, b) sqrt(rowSums(sweep(A, 2, b) ^ 2)),
                  "manhattan" = 
                  function(A, b) rowSums(abs(sweep(A, 2, b))),
                  "minkowski" = {
                      ## Power needs to be given.
                      p <- list(...)[[1L]]
                      function(A, b)
                          (rowSums(abs(sweep(A, 2, b)) ^ p)) ^ (1 / p)
                  })
                      
    out <- matrix(0, NROW(A), NROW(B))
    ## Be nice: thanks to Wael Salem ZRAFI <zrafi.w.s@gmail.com> for
    ## suggesting this improvement.
    if(!is.null(cnA <- colnames(A)) &&
       !is.null(cnB <- colnames(B)) &&
       !identical(cnA, cnB))
        A <- A[, cnB, drop = FALSE]
    for(k in seq_len(NROW(B)))
        out[, k] <- FOO(A, B[k, ])
    out
}
R/dissimilarity.R:574

.cl_dissimilarity_partition_CSSD untypeable

unbound variable (line 287)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
timing: 2.89 s
source
.cl_dissimilarity_partition_CSSD <-
function(x, y, L = NULL, alpha = NULL, beta = NULL, ...)
{
    ## Cluster Similarity Sensitive Distance.
    ## Reference:  D. Zhou, J. Li and H. Zha (2005),
    ##  A new Mallows distance based metric for comparing clusterings.
    ## See .cl_dissimilarity_partition_Mallows() re solving cost flow
    ## problems.

    ## Dissimilarity is defined by minimizing
    ##   \sum_{k,l} (1 - 2 w_{kl} / (alpha_k + beta_l)) L_{kl}
    ## where
    ##   L_{kl} = \sum_i m_{x;ik} m_{y;il} distance(p_{x;k}, p_{y;l})
    ## with m and p the memberships and prototypes, respectively.
    ## If we get matrices of prototypes, use .rxdist; otherwise, the
    ## user needs to specify an L function or matrix.

    k_x <- n_of_classes(x)
    k_y <- n_of_classes(y)
    M_x <- cl_membership(x, k_x)
    M_y <- cl_membership(y, k_y)
    if(!is.matrix(L)) {
        p_x <- cl_prototypes(x)
        p_y <- cl_prototypes(y)
        if(is.matrix(p_x) && is.matrix(p_y) && is.null(L))
            L <- .rxdist(p_x, p_y, ...)
        else if(is.function(L))
            L <- L(p_x, p_y)
        else
            stop("Cannot compute prototype distances.")
    }
    C <- crossprod(M_x, M_y) * L
    if(is.null(alpha)) alpha <- rep.int(1, k_x)
    if(is.null(beta)) beta <- rep.int(1, k_y)
    sum(C) - 2 * lpSolve::lp.transport(C / outer(alpha, beta, `+`),
                                       "max",
                                       rep.int("==", k_x), alpha,
                                       rep.int("==", k_y), beta,
                                       integers = NULL)$objval
}
R/dissimilarity.R:270

.cl_dissimilarity_hierarchy_euclidean untypeabletyped

unbound variable (line 316)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any, weights: any?) -> any)<>
timing: 0.083 s
source
.cl_dissimilarity_hierarchy_euclidean <-
function(x, y, weights = 1)
{
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u <- cl_object_dissimilarities(x)
    v <- cl_object_dissimilarities(y)
    sqrt(sum(weights * (u - v) ^ 2))
}
R/dissimilarity.R:313

.cl_dissimilarity_hierarchy_manhattan untypeabletyped

unbound variable (line 329)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any, weights: any?) -> any)<>
timing: 0.082 s
source
.cl_dissimilarity_hierarchy_manhattan <-
function(x, y, weights = 1)
{
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u <- cl_object_dissimilarities(x)
    v <- cl_object_dissimilarities(y)
    sum(weights * abs(u - v))
}
R/dissimilarity.R:326

.cl_dissimilarity_hierarchy_cophenetic untypeabletyped

unbound variable (line 342)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.073 s
source
.cl_dissimilarity_hierarchy_cophenetic <-
function(x, y)
{
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u <- cl_object_dissimilarities(x)
    v <- cl_object_dissimilarities(y)
    1 - cor(u, v) ^ 2
}
R/dissimilarity.R:339

.cl_dissimilarity_hierarchy_gamma untypeabletyped

unbound variable (line 360)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.079 s
source
.cl_dissimilarity_hierarchy_gamma <-
function(x, y)
{
    ## <NOTE>
    ## This is a dissimilarity measure that works for arbitrary
    ## dissimilarities, see e.g. Bock.
    ## (And the current implementation finally respects this ...)
    ## </NOTE>
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u <- cl_object_dissimilarities(x)
    v <- cl_object_dissimilarities(y)
    n <- length(u)
    .C(C_clue_dissimilarity_count_inversions,
       as.double(u),
       as.double(v),
       as.integer(n),
       count = double(1L)) $ count / choose(n, 2)
}
R/dissimilarity.R:352

.cl_dissimilarity_hierarchy_symdiff untypeabletyped

unbound variable (line 381)
unbound: cl_classes — one of the package’s own names, itself untyped
error detail
name: cl_classes
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.008 s
source
.cl_dissimilarity_hierarchy_symdiff <-
function(x, y)
{
    ## Cardinality of the symmetric difference of the n-trees when
    ## regarded as sets of subsets (classes) of the set of objects.

    x <- cl_classes(x)
    y <- cl_classes(y)
    sum(is.na(match(x, y))) + sum(is.na(match(y, x)))
}
R/dissimilarity.R:375

.cl_dissimilarity_hierarchy_Chebyshev untypeabletyped

unbound variable (line 391)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.074 s
source
.cl_dissimilarity_hierarchy_Chebyshev <-
function(x, y)
{
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u <- cl_object_dissimilarities(x)
    v <- cl_object_dissimilarities(y)
    max(abs(u - v))
}
R/dissimilarity.R:388

.cl_dissimilarity_hierarchy_Lyapunov untypeable

unbound variable (line 404)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
timing: 0.077 s
source
.cl_dissimilarity_hierarchy_Lyapunov <-
function(x, y)
{
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    q <- cl_object_dissimilarities(x) / cl_object_dissimilarities(y)
    if(is.matrix(q)) q <- q[lower.tri(q)]
    log(max(q) / min(q))
}
R/dissimilarity.R:401

.cl_dissimilarity_hierarchy_BO untypeabletyped

unbound variable (line 456)
unbound: is.unsorted — a name the prelude does not declare
error detail
name: is.unsorted
gradual mode: typed
((x: { .Data: any, height: list | null, any } with { Labels: null, any }, y: { .Data: any, height: list | null, any } with { Labels: null, any }, delta: any, ...: any) | (x: { .Data: any, height: vec | null, any } with { Labels: null, any }, y: { .Data: any, height: vec | null, any } with { Labels: null, any }, delta: any, ...: any) -> any)<>
timing: 0.385 s
source
.cl_dissimilarity_hierarchy_BO <-
function(x, y, delta, ...)
{
    ## Compute Boorman-Olivier (1973) dendrogram ("valued tree")
    ## dissimilarities of the form
    ##
    ##    m_\delta(T_1, T_2)
    ##      = \int_0^\infty \delta(P_1(\alpha), P_2(\alpha)) d\alpha
    ##
    ## where the trees (dendrograms) are defined as right-continuous
    ## maps from [0, \Infty) to the partition lattice.

    ## We can compute this as follows.  Take the ultrametrics and use
    ## as.hclust() to detemine the heights \alpha_1(k) and \alpha_2(l)
    ## of the splits.  Let \alpha_i be the sequence obtained by
    ## combining these two.  Then
    ##
    ##   m_\delta
    ##     = \sum_{i=0}^{L-1} (\alpha_{i+1} - \alpha_i)
    ##                        \delta(P_1(\alpha_i), P_2(\alpha_i))
    ##
    ## We use cutree() for computing the latter partitions.  As we
    ## already have the hclust representations, we should be able to do
    ## things more efficiently ...

    if(inherits(x, "hclust"))
        t_x <- x
    else if(inherits(x, "cl_ultrametric"))
        t_x <- as.hclust(x)
    else if(is.cl_dendrogram(x))
        t_x <- as.hclust(cl_ultrametric(x))
    else
        return(NA)
    if(inherits(y, "hclust"))
        t_y <- y
    else if(inherits(y, "cl_ultrametric"))
        t_y <- as.hclust(y)
    else if(is.cl_dendrogram(y))
        t_y <- as.hclust(cl_ultrametric(y))
    else
        return(NA)

    if(is.unsorted(t_x$height) || is.unsorted(t_y$height))
        return(NA)
    
    alpha <- sort(unique(c(t_x$height, t_y$height)))
    cuts_x <- cutree(t_x, h = alpha)
    cuts_y <- cutree(t_y, h = alpha)
    deltas <- mapply(cl_dissimilarity,
                     lapply(split(cuts_x, col(cuts_x)),
                            as.cl_partition),
                     lapply(split(cuts_y, col(cuts_y)),
                            as.cl_partition),
                     MoreArgs = list(delta, ...))
    sum(diff(alpha) * deltas[-length(deltas)])
}
R/dissimilarity.R:414

.cl_dissimilarity_hierarchy_spectral untypeabletyped

unbound variable (line 476)
unbound: .has_object_dissimilarities — one of the package’s own names, itself untyped
error detail
name: .has_object_dissimilarities
gradual mode: typed
((x: any, y: any) -> any)<>
timing: 0.076 s
source
.cl_dissimilarity_hierarchy_spectral <-
function(x, y)
{
    if(!.has_object_dissimilarities(x) ||
       !.has_object_dissimilarities(y))
        return(NA)
    u <- cl_object_dissimilarities(x)
    v <- cl_object_dissimilarities(y)
    svd(as.matrix(u - v))$d[1L]
}
R/dissimilarity.R:473

as.dist.cl_dissimilarity untypeabletyped

unbound variable (line 493)
unbound: match.call — a name the prelude does not declare
error detail
name: match.call
gradual mode: typed
((m: list<...>, diag: any?, upper: any?) | (m: list<> with (list & ~{ }), diag: any?, upper: any?) | (m: vec<...>, diag: any?, upper: any?) | (m: vec<> with (list & ~{ }), diag: any?, upper: any?) -> any)<>
timing: 3.31 s
source
as.dist.cl_dissimilarity <-
function(m, diag = FALSE, upper = FALSE)
{
    y <- c(m)
    ## Fill non-inherited attributes with default values.
    attributes(y) <- c(attributes(m)[c("Size", "Labels")],
                       Diag = diag, Upper = upper, call = match.call())
    ## (Note that as.dist.default() does not automatically add
    ## 'method'.)
    class(y) <- "dist"
    y
}
R/dissimilarity.R:487

[.cl_dissimilarity untypeabletyped

unbound variable (line 505)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any with { description: any, any }, i: any, j: any) -> any)<>
timing: 0.026 s
source
"[.cl_dissimilarity" <-
function(x, i, j)
{
    y <- NextMethod("[")
    if(!inherits(y, "cl_dissimilarity")) {
        description <- attr(x, "description")
        return(cl_cross_proximity(y, description = description,
                                  class = "cl_cross_dissimilarity"))
    }
    y
}
R/dissimilarity.R:502
R/consensus.R

.cl_consensus_method_default skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
.cl_consensus_method_default <-
function(type)
{
    switch(type, partition = "SE", hierarchy = "euclidean", NULL)
}
R/consensus.R:1089

cl_consensus untypeable

unbound variable (line 17)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.055 s
source
cl_consensus <-
function(x, method = NULL, weights = 1, control = list())
{
    ## <NOTE>
    ## Interfaces are a matter of taste.
    ## E.g., one might want to have a 'type' argument indication whether
    ## hard or soft partitions are sought.  One could then do
    ##   cl_consensus(x, method = "euclidean", type = "hard")
    ## to look for an optimal median (or least squares) hard partition
    ## (for euclidean dissimilarity).
    ## For us, "method" really indicates a certain algorithm, with its
    ## bells and whistles accessed via the 'control' argument.
    ## </NOTE>

    clusterings <- as.cl_ensemble(x)

    if(!length(clusterings))
        stop("Cannot compute consensus of empty ensemble.")

    weights <- rep_len(weights, length(clusterings))
    if(any(weights < 0))
        stop("Argument 'weights' has negative elements.")
    if(!any(weights > 0))
        stop("Argument 'weights' has no positive elements.")

    if(!is.function(method)) {
        if(!inherits(method, "cl_consensus_method")) {
            ## Get the method definition from the registry.
            type <- .cl_ensemble_type(clusterings)
            if(is.null(method))
                method <- .cl_consensus_method_default(type)                
            method <- get_cl_consensus_method(method, type)            
        }
        method <- method$definition
    }

    method(clusterings, weights, control)
}
R/consensus.R:3

.project_to_leading_columns untypeable

unbound variable (line 1104)
unbound: rowSums — a name the prelude does not declare
error detail
name: rowSums
timing: 0.066 s
source
.project_to_leading_columns <-
function(x, k)
{
    ## For a given matrix stochastic matrix x, return the stochastic
    ## matrix y which has columns from k+1 on all zero which is closest
    ## to x in the Frobenius distance.
    y <- x[, seq_len(k), drop = FALSE]
    y <- cbind(pmax(y + (1 - rowSums(y)) / k, 0),
               matrix(0, nrow(y), ncol(x) - k))
    ## (Use the pmax to ensure that entries remain nonnegative.)
}
R/consensus.R:1097

.cl_consensus_partition_DWH untypeable

unbound variable (line 54)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
timing: 0.060 s
source
.cl_consensus_partition_DWH <-
function(clusterings, weights, control)
{
    ## <TODO>
    ## Could make things more efficient by subscripting on positive
    ## weights.
    ## (Note that this means control$order has to be subscripted as
    ## well.)
    ## </TODO>
    
    max_n_of_classes <- max(sapply(clusterings, n_of_classes))

    ## Control parameters.
    k <- control$k
    if(is.null(k))
        k <- max_n_of_classes
    order <- control$order
    if(is.null(order))
        order <- sample(seq_along(clusterings))

    clusterings <- clusterings[order]
    weights <- weights[order]

    k_max <- max(k, max_n_of_classes)
    s <- weights / cumsum(weights)
    s[is.na(s)] <- 0                    # Division by zero ...
    
    M <- cl_membership(clusterings[[1L]], k_max)
    for(b in seq_along(clusterings)[-1L]) {
        mem <- cl_membership(clusterings[[b]], k_max)
        ## Match classes from conforming memberships.
        ind <- solve_LSAP(crossprod(M, mem), maximum = TRUE)
        M <- (1 - s[b]) * M + s[b] * mem[, ind]
        if(k < k_max)
            M <- .project_to_leading_columns(M, k)
    }

    M <- .cl_membership_from_memberships(M[, seq_len(k), drop = FALSE], k)

    as.cl_partition(M)
}
R/consensus.R:44

.l1_fit_M untypeabletimeout

unbound variable (line 315)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
gradual mode: timeout
timing: 0.936 s
source
.l1_fit_M <-
function(memberships, w, k)
{
    ## Determine stochastic matrix M with at most k leading nonzero
    ## columns such that
    ##
    ##    \sum_b w_b \sum_{i,j} | m_{ij}(b) - m_{ij} | => min
    ##
    ## where the sum over j goes from 1 to k.
    ##
    ## Clearly, this can be done separately for each row, where we need
    ## to minimize
    ##
    ##    \sum_b w_b \sum_j | y_j(b) - x_j | => min
    ##
    ## over all probability vectors x.  Such problems can e.g. be solved
    ## via the following linear program:
    ##
    ##    \sum_b \sum_j w_b e'(u(b) + v(b)) => min
    ##
    ## subject to
    ##
    ##    u(1), v(1), ..., u(B), v(B), x >= 0
    ##                   x + u(b) - v(b)  = y(b),    b = 1, ..., B
    ##                               e'x  = 1
    ##
    ## (where e = [1, ..., 1]).
    ##
    ## So we have one long vector z of "variables":
    ##
    ##    z = [u(1)', v(1)', ..., u(B)', v(B)', x']'
    ##
    ## of length (2B + 1) k, with x the object of interest.
    
    ## Rather than providing a separate function for weighted L1 fitting
    ## of probability vectors we prefer doing "everything" at once, in
    ## order to avoid recomputing the coefficients and constraints of
    ## the associated linear program.

    B <- length(memberships)
    L <- (2 * B + 1) * k

    ## Set up associated linear program.

    ## Coefficients in the objective function.
    objective_in <- c(rep(w, each = 2 * k), rep.int(0, k))
    
    ## Constraints.
    constr_mat <- rbind(diag(1, L),
                        cbind(kronecker(diag(1, B),
                                        cbind(diag(1, k),
                                              diag(-1, k))),
                              kronecker(rep.int(1, B),
                                        diag(1, k))),
                        c(rep.int(0, 2 * B * k), rep.int(1, k)))
    constr_dir <- c(rep.int(">=", L), rep.int("==", B * k + 1L))

    ind <- seq.int(from = 2 * B * k + 1L, length.out = k)
    nr <- NROW(memberships[[1L]])
    nc <- NCOL(memberships[[1L]])
    M <- matrix(0, nrow = nr, ncol = k)

    ## Put the memberships into one big array so that we can get their
    ## rows more conveniently (and efficiently):

    memberships <- array(unlist(memberships), c(nr, nc, B))

    for(i in seq_len(nr)) {
        out <- lpSolve::lp("min",
                           objective_in,
                           constr_mat,
                           constr_dir,
                           c(rep.int(0, L), memberships[i, seq_len(k), ], 1))
        M[i, ] <- out$solution[ind]
    }

    ## Add zero columns if necessary.
    if(k < nc)
        M <- cbind(M, matrix(0, nr, nc - k))

    M
}
R/consensus.R:270

.random_stochastic_matrix untypeabletyped

unbound variable (line 266)
unbound: runif — a name the prelude does not declare
error detail
name: runif
gradual mode: typed
((n: <@"*", ...>, k: any) | (n: dbl<~@"*", ...>, k: dbl) -> any)<>
timing: 1.10 s
source
.random_stochastic_matrix <-
function(n, k)
{
    M <- matrix(runif(n * k), n, k)
    M / rowSums(M)
}
R/consensus.R:263

.cl_consensus_partition_AOS untypeabletimeout

unbound variable (line 129)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: timeout
timing: 0.577 s
source
.cl_consensus_partition_AOS <-
function(clusterings, weights, control,
         type = c("SE", "HE", "SM", "HM"))
{
    ## The start of a general purpose optimizer for determining
    ## consensus partitions by minimizing
    ##   \sum_b w_b d(M, M_b) ^ e
    ##     = \sum_b \min_{P_b} w_b f(M, M_b P_b) ^ e
    ## for the special case where the criterion function is based on
    ## M and M_b P_b (i.e., column permutations of M_b), as opposed to
    ## the general case where d(M, M_b) = \min_{P_b} f(M, P_b, M_b)
    ## handled by .cl_consensus_partition_AOG().
    ##
    ## The AO ("alternative optimization") proceeds by alternatively
    ## matching the M_b to M by minimizing f(M, M_b P_b) over P_b, and
    ## fitting M by minimizing \sum_b w_b f(M, M_b P_b) ^ e for fixed
    ## matchings.
    ##
    ## Such a procedure requires three ingredients: a function for
    ## matching M_b to M (in fact simply replacing M_b by the matched
    ## M_b P_b); a function for fitting M to the \{M_b P_b\}, and a
    ## function for computing the value of the criterion function
    ## corresponding to this fit (so that one can stop if the relative
    ## improvement is small enough).
    ##
    ## For the time being, we only use this to determine soft and hard
    ## Euclidean least squares consensus partitions (soft and hard
    ## Euclidean means), so the interface does not yet reflect the
    ## generality of the approach (which would either pass the three
    ## functions, or even set up family objects encapsulating the three
    ## functions).
    ##
    ## This special case is provided for efficiency and convenience.
    ## Using the special form of the criterion function, we can simply
    ## always work memberships with the same maximal number of columns,
    ## and with the permuted \{ M_b P_b \}.

    ## For the time being ...
    type <- match.arg(type)

    w <- weights / sum(weights)    
    n <- n_of_objects(clusterings)
    k_max <- max(sapply(clusterings, n_of_classes))

    ## Control parameters.
    k <- control$k
    if(is.null(k))
        k <- k_max
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 100
    nruns <- control$nruns
    reltol <- control$reltol
    if(is.null(reltol))
        reltol <- sqrt(.Machine$double.eps)
    start <- control$start
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
        nruns <- length(start)
    } else {
        if(is.null(nruns)) {
            ## Use nruns only if start is not given.
            nruns <- 1L
        }
        start <- replicate(nruns,
                           .random_stochastic_matrix(n, k),
                           simplify = FALSE)
    }

    ## The maximal (possible) number of classes in M and the \{ M_b \}.
    k_all <- max(k, k_max)

    value <-
        switch(type,
               SE = , HE = function(M, memberships, w) {
                   sum(w * sapply(memberships,
                                  function(u) sum((u - M) ^ 2)))
               },
               SM = , HM = function(M, memberships, w) {
                   sum(w * sapply(memberships,
                                  function(u) sum(abs(u - M))))
               })
    ## Return the M[, ind] column permutation of M optimally matching N.
    match_memberships <-
        switch(type,
               SE = , HE = function(M, N) {
                   M[, solve_LSAP(crossprod(N, M), maximum = TRUE),
                     drop = FALSE]
               },
               SM = , HM = function(M, N) {
                   M[, solve_LSAP(.cxdist(N, M, "manhattan")),
                     drop = FALSE]
               })
    ## Function for fitting M to (fixed) memberships \{ M_b P_b \}.
    ## As we use a common number of columns for all membership matrices
    ## involved, we need to pass the desired 'k' ...
    fit_M <-
        switch(type,
               SE = function(memberships, w, k) {
                   ## Update M as \sum w_b M_b P_b.
                   M <- .weighted_sum_of_matrices(memberships, w, nrow(M))
                   ## If k < k_all, "project" as indicated in Gordon &
                   ## Vichi (2001), p. 238.
                   if(k < ncol(M))
                       M <- .project_to_leading_columns(M, k)
                   M
               },
               HE = , HM = function(memberships, w, k) {
                   ## Compute M as \sum w_b M_b P_b.
                   M <- .weighted_sum_of_matrices(memberships, w, nrow(M))
                   ## And compute a closest hard partition H(M) from
                   ## that, using the first k columns of M.
                   ids <- max.col(M[ , seq_len(k), drop = FALSE])
                   .cl_membership_from_class_ids(ids, ncol(M))
               },
               SM = .l1_fit_M)

    memberships <- lapply(clusterings, cl_membership, k_all)

    V_opt <- Inf
    M_opt <- NULL
    for(run in seq_along(start)) {
        if(verbose && (nruns > 1L))
            message(gettextf("AOS run: %d", run))
        M <- start[[run]]
        if(k < k_all)
            M <- cbind(M, matrix(0, nrow(M), k_all - k))
        memberships <- lapply(memberships, match_memberships, M)
        old_value <- value(M, memberships, w)
        if(verbose)
            message(gettextf("Iteration: 0 *** value: %g", old_value))
        iter <- 1L
        while(iter <= maxiter) {
            ## Fit M to the M_b P_b.
            M <- fit_M(memberships, w, k)
            ## Match the \{ M_b P_b \} to M.
            memberships <- lapply(memberships, match_memberships, M)
            ## Update value.
            new_value <- value(M, memberships, w)
            if(verbose)
                message(gettextf("Iteration: %d *** value: %g",
                                 iter, new_value))
            if(abs(old_value - new_value)
               < reltol * (abs(old_value) + reltol))
                break
            old_value <- new_value
            iter <- iter + 1L
        }
        if(new_value < V_opt) {
            converged <- (iter <= maxiter)
            V_opt <- new_value
            M_opt <- M
        }
        if(verbose)
            message(gettextf("Minimum: %g", V_opt))
    }

    M <- .stochastify(M_opt)
    rownames(M) <- rownames(memberships[[1L]])
    meta <- list(objval = value(M, memberships, w),
                 converged = converged)
    M <- .cl_membership_from_memberships(M[, seq_len(k), drop = FALSE],
                                         k, meta)
    
    as.cl_partition(M)
}
R/consensus.R:88

.cl_consensus_partition_soft_euclidean untypeabletyped

unbound variable (line 357)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.007 s
source
.cl_consensus_partition_soft_euclidean <-
function(clusterings, weights, control)
    .cl_consensus_partition_AOS(clusterings, weights, control, "SE")
R/consensus.R:355

.cl_consensus_partition_hard_euclidean untypeabletyped

unbound variable (line 363)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.007 s
source
.cl_consensus_partition_hard_euclidean <-
function(clusterings, weights, control)
    .cl_consensus_partition_AOS(clusterings, weights, control, "HE")
R/consensus.R:361

.cl_consensus_partition_soft_manhattan untypeabletyped

unbound variable (line 369)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.008 s
source
.cl_consensus_partition_soft_manhattan <-
function(clusterings, weights, control)
    .cl_consensus_partition_AOS(clusterings, weights, control, "SM")
R/consensus.R:367

.cl_consensus_partition_hard_manhattan untypeabletyped

unbound variable (line 375)
unbound: .cl_consensus_partition_AOS — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOS
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.007 s
source
.cl_consensus_partition_hard_manhattan <-
function(clusterings, weights, control)
    .cl_consensus_partition_AOS(clusterings, weights, control, "HM")
R/consensus.R:373

.cscale untypeable

untypeable application of base::* (line 1136)
error detail
argument: @(v('I10982), 'A)
failing call: base::*(as.raw(0), new.env())
timing: 0.495 s
source
.cscale <-
function(A, x)
{
    ## Scale the columns of matrix A by the elements of vector x.
    ## Formally, A %*% diag(x), but faster.
    ## Could also use sweep(A, 2, x, "*")
    rep(x, each = nrow(A)) * A
}
R/consensus.R:1134

.n_of_nonzero_columns untypeabletyped

unbound variable (line 1127)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: typed
((x: any) -> any)<>
timing: 0.004 s
source
.n_of_nonzero_columns <-
function(x)
    sum(colSums(x) > 0)
R/consensus.R:1125

.cl_consensus_partition_AOG untypeabletimeout

unbound variable (line 412)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: timeout
timing: 1.65 s
source
.cl_consensus_partition_AOG <-
function(clusterings, weights, control, type = c("GV1"))
{
    ## The start of a general purpose optimizer for determining
    ## consensus partitions by minimizing
    ##   \sum_b w_b d(M, M_b) ^ p
    ##     = \sum_b \min_{P_b} w_b f(M, M_b, P_b) ^ e
    ## for general dissimilarity matrices which involve class matching
    ## via permutation matrices P_b.
    ##
    ## The AO ("Alternative Optimization") proceeds by alternating
    ## between determining the optimal permutations P_b by minimizing
    ##   f(M, M_b, P_b)
    ## for fixed M, and fitting M by minimizing
    ##   \sum_b w_b f(M, M_b, P_b) ^ e
    ## for fixed \{ P_b \}.
    ##
    ## We encapsulate this into functions fit_P() and fit_M() (and a
    ## value() function for the criterion function to be minimized with
    ## respect to both M and \{ P_b \}, even though the current
    ## interface does not yet reflect the generality of the approach.
    ##
    ## Note that rather than passing on information about the numbers of
    ## classes (e.g., needed for GV1) and representing all involved
    ## membership matrices with the same maximal number of columns, we
    ## use "minimal" representations with no dummy classes (strictly
    ## speaking, with the possible exception of M, for which the given k
    ## is used).

    ## For the time being ...
    type <- match.arg(type)

    w <- weights / sum(weights)    
    n <- n_of_objects(clusterings)
    k_max <- max(sapply(clusterings, n_of_classes))
    
    ## Control parameters.
    k <- control$k
    if(is.null(k))
        k <- k_max
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 100L
    nruns <- control$nruns
    reltol <- control$reltol
    if(is.null(reltol))
        reltol <- sqrt(.Machine$double.eps)
    start <- control$start
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
        nruns <- length(start)
    } else {
        if(is.null(nruns)) {
            ## Use nruns only if start is not given.
            nruns <- 1L
        }
        start <- replicate(nruns,
                           .random_stochastic_matrix(n, k),
                           simplify = FALSE)
    }

    ## <NOTE>
    ## For the given memberships, we can simply use ncol() in the
    ## computations (rather than n_of_classes(), because we used
    ## cl_membership() to create them.  For M, the number of classes
    ## could be smaller than the given k "target".
    ## </NOTE>
    
    value <- function(M, permutations, memberships, w) {

        k <- .n_of_nonzero_columns(M)
        d <- function(u, p) {
            ## Compute the squared GV1 dissimilarity between M and u
            ## based on the M->u class matching p.
            nc_u <- ncol(u)
            if(nc_u == k) {
                ## Simple case: all classes are matched.
                sum((u[, p] - M) ^ 2)
            }
            else {
                ## Only include the matched non-dummy classes of M ..
                ind <- seq_len(k)
                ## ... which are matched to non-dummy classes of u.
                ind <- ind[p[ind] <= nc_u]
                sum((u[, p[ind]] - M[, ind]) ^ 2)
            }
        }
        
        sum(w * mapply(d, memberships, permutations))
    }

    fit_P <- function(u, M) {
        
        ## Return a permutation representing a GV1 optimal matching of
        ## the columns of M to the columns of u (note the order of the
        ## arguments), using a minimal number of dummy classes (i.e., p
        ## has max(.n_of_nonzero_columns(M), n_of_classes(u)) entries).

        ## See also .cl_dissimilarity_partition_GV1().
        
        C <- outer(colSums(M ^ 2), colSums(u ^ 2), `+`) -
            2 * crossprod(M, u)
        nc_M <- .n_of_nonzero_columns(M)
        nc_u <- ncol(u)
        ## (See above for ncol() vs n_of_classes().)
        if(nc_M < nc_u)
            C <- rbind(C, matrix(0, nrow = nc_u - nc_M, ncol = nc_u))
        else if(nc_M > nc_u)
            C <- cbind(C, matrix(0, nrow = nc_M, ncol = nc_M - nc_u))
        
        solve_LSAP(C)
    }

    fit_M <- function(permutations, memberships, w) {
        
        ## Here comes the trickiest part ...
        ##
        ## In general, M = [m_{iq}] is determined as follows.
        ## Write value(M, permutations, memberships, w) as
        ##   \sum_b \sum_i \sum_{p=1}^{k_b} \sum_{q=1}^k
        ##      w_b (u_{ip}(b) - m_{iq})^2 x_{pq}(b)
        ## where U(b) and X(b) are the b-th membership matrix and the
        ## permutation matrix representing the M->U(b) non-dummy class
        ## matching (as always, note the order of the arguments).
        ##
        ## Let
        ##   \beta_{iq} = \sum_b \sum_{p=1}^{k_b} w_b u_{ip}(b) x_{pq}(b)
        ##   \alpha_q   = \sum_b \sum_{p=1}^{k_b} w_b x_{pq}(b)
        ## and
        ##   \bar{m}_{iq} =
        ##     \cases{\beta_{iq}/\alpha_q, & $\alpha_q > 0$ \cr
        ##            0                    & otherwise}.
        ## Then, as the cross-product terms cancel out, the value
        ## function rewrites as
        ##   \sum_b \sum_i \sum_{p=1}^{k_b} \sum_{q=1}^k
        ##      w_b (u_{ip}(b) - \bar{m}_{iq})^2 x_{pq}(b)
        ##   + \sum_i \sum_q \alpha_q (\bar{m}_{iq} - m_{iq}) ^ 2,
        ## where the first term is a constant, and the minimum is found
        ## by solving
        ##   \sum_q \alpha_q (\bar{m}_{iq} - m_{iq}) ^ 2 => min!
        ## s.t.
        ##   m_{i1}, ..., m_{ik} >= 0, \sum_{iq} m_{iq} = 1.
        ##
        ## We can distinguish three cases.
        ## A. If S_i = \sum_q \bar{m}_{iq} = 1, things are trivial.
        ## B. If S_i = \sum_q \bar{m}_{iq} < 1.
        ##    B1. If some \alpha_q are zero, then we can choose
        ##        m_{iq} = \bar{m}_{iq} for those q with \alpha_q = 0;
        ##        m_{iq} = 1 / number of zero \alpha's, otherwise.
        ##    B2. If all \alpha_q are positive, we can simply
        ##        equidistribute 1 - S_i over all classes as written
        ##        in G&V.
        ## C. If S_i > 1, things are not so clear (as equidistributing
        ##    will typically result in violations of the non-negativity
        ##    constraint).  We currently revert to using solve.QP() from
        ##    package quadprog, as constrOptim() already failed in very
        ##    simple test cases.
        ##
        ## Now consider \sum_{p=1}^{k_b} x_{pq}(b).  If k <= k_b for all
        ## b, all M classes from 1 to k are matched to one of the k_b
        ## classes in U(b), hence the sum and also \alpha_q are one.
        ## But then
        ##    \sum_q \bar{m}_{iq}
        ##      =  \sum_b \sum_{p=1}^{k_b} w_b u_{ip}(b) x_{pq}(b)
        ##      <= \sum_b \sum_{p=1}^{k_b} w_b u_{ip}(b)
        ##      =  1
        ## with equality if k = k_b for all b.  I.e.,
        ## * If k = \min_b k_b = \max k_b, we are in case A.
        ## * If k <= \min_b k_b, we are in case B2.
        ## And it makes sense to handle these cases explicitly for
        ## efficiency reasons.

        ## And now for something completely different ... the code.

        k <- .n_of_nonzero_columns(M)
        nr_M <- nrow(M)
        nc_M <- ncol(M)
        nc_memberships <- sapply(memberships, ncol)

        if(k <= min(nc_memberships)) {
            ## Compute the weighted means \bar{M}.
            M <- .weighted_sum_of_matrices(mapply(function(u, p)
                                                  u[ , p[seq_len(k)]],
                                                  memberships,
                                                  permutations,
                                                  SIMPLIFY = FALSE),
                                           w, nr_M)
            ## And add dummy classes if necessary.
            if(k < nc_M)
                M <- cbind(M, matrix(0, nr_M, nc_M - k))
            ## If we always got the same number of classes, we are
            ## done.  Otherwise, equidistribute ...
            if(k < max(nc_memberships))
R/consensus.R:379

.cl_consensus_partition_GV1 untypeabletyped

unbound variable (line 711)
unbound: .cl_consensus_partition_AOG — one of the package’s own names, itself untyped
error detail
name: .cl_consensus_partition_AOG
gradual mode: typed
((clusterings: any, weights: any, control: any) -> any)<>
timing: 0.007 s
source
.cl_consensus_partition_GV1 <-
function(clusterings, weights, control)
    .cl_consensus_partition_AOG(clusterings, weights, control, "GV1")
R/consensus.R:709

.make_penalty_function_membership untypeabletyped

unbound variable (line 1149)
unbound: pmin — a name the prelude does not declare
error detail
name: pmin
gradual mode: typed
((nr: dbl1, nc: any) -> ((m: vec) -> any)<>)<>
timing: 0.019 s
source
.make_penalty_function_membership <-
function(nr, nc)
    function(m) {
        sum(pmin(m, 0) ^ 2) + sum((rowSums(matrix(m, nr)) - 1) ^ 2)
    }
R/consensus.R:1146

.make_penalty_gradient_membership untypeabletyped

unbound variable (line 1157)
unbound: pmin — a name the prelude does not declare
error detail
name: pmin
gradual mode: typed
((nr: dbl1, nc: any) -> ((m: vec) -> any)<>)<>
timing: 0.019 s
source
.make_penalty_gradient_membership <-
function(nr, nc)
    function(m) {
        2 * (pmin(m, 0) + rep.int(rowSums(matrix(m, nr)) - 1, nc))
    }
R/consensus.R:1154

.cl_consensus_partition_GV3 untypeabletimeout

unbound variable (line 723)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: timeout
timing: 0.136 s
source
.cl_consensus_partition_GV3 <-
function(clusterings, weights, control)
{
    ## Use a SUMT to solve
    ##   \| Y - M M' \|_F^2 => min
    ## where M is a membership matrix and Y = \sum_b w_b M_b M_b'.

    n <- n_of_objects(clusterings)
    max_n_of_classes <- max(sapply(clusterings, n_of_classes))

    ## Control parameters:
    ## k,
    k <- control$k
    if(is.null(k))
        k <- max_n_of_classes
    ## nruns,
    nruns <- control$nruns
    ## start.
    start <- control$start

    w <- weights / sum(weights)

    comemberships <-
        lapply(clusterings, function(x) {
            ## No need to force a common k here.
            tcrossprod(cl_membership(x))
        })

    Y <- .weighted_sum_of_matrices(comemberships, w, n)

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else {
        if(is.null(nruns)) {
            ## Use nruns only if start is not given.
            nruns <- 1L
        }
        e <- eigen(Y, symmetric = TRUE)
        ## Use M <- U_k \lambda_k^{1/2}, or random perturbations
        ## thereof.
        M <- e$vectors[, seq_len(k), drop = FALSE] *
            rep(sqrt(e$values[seq_len(k)]), each = n)
        m <- c(M)
        start <- c(list(m),
                   replicate(nruns - 1L,
                             m + rnorm(length(m), sd = sd(m) / sqrt(3)),
                             simplify = FALSE))
    }

    y <- c(Y)

    L <- function(m) sum((y - tcrossprod(matrix(m, n))) ^ 2)
    P <- .make_penalty_function_membership(n, k)
    grad_L <- function(m) {
        M <- matrix(m, n)
        4 * c((tcrossprod(M) - Y) %*% M)
    }
    grad_P <- .make_penalty_gradient_membership(n, k)

    out <- sumt(start, L, P, grad_L, grad_P,
                method = control$method, eps = control$eps,
                q = control$q, verbose = control$verbose,
                control = as.list(control$control))

    M <- .stochastify(matrix(out$x, n))
    rownames(M) <- rownames(cl_membership(clusterings[[1L]]))
    meta <- list(objval = L(c(M)))
    M <- .cl_membership_from_memberships(M, k, meta)

    as.cl_partition(M)
}
R/consensus.R:716

.cl_consensus_partition_soft_symdiff untypeabletimeout

unbound variable (line 825)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: timeout
timing: 1.19 s
source
.cl_consensus_partition_soft_symdiff <-
function(clusterings, weights, control)
{
    ## Use a SUMT to solve
    ##   \sum_b w_b \sum_{ij} | c_{ij}(b) - c_{ij} | => min
    ## where C(b) = comembership(M(b)) and C = comembership(M) and M is
    ## a membership matrix.

    ## Control parameters:
    ## gradient,
    gradient <- control$gradient
    if(is.null(gradient))
        gradient <- TRUE
    ## k,
    k <- control$k
    ## nruns,
    nruns <- control$nruns
    ## start.
    start <- control$start

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else if(is.null(nruns)) {
        ## Use nruns only if start is not given.
        nruns <- 1L
    }
    
    max_n_of_classes <- max(sapply(clusterings, n_of_classes))
    if(is.null(k))
        k <- max_n_of_classes

    B <- length(clusterings)    
    n <- n_of_objects(clusterings)
    
    w <- weights / sum(weights)

    comemberships <-
        lapply(clusterings, function(x) {
            ## No need to force a common k here.
            tcrossprod(cl_membership(x))
        })

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else {
        if(is.null(nruns)) {
            ## Use nruns only if start is not given.
            nruns <- 1L
        }
        ## Try using a rank k "root" of the weighted median of the
        ## comemberships as starting value.
        Y <- apply(array(unlist(comemberships), c(n, n, B)), c(1, 2),
                   weighted_median, w)
        e <- eigen(Y, symmetric = TRUE)
        ## Use M <- U_k \lambda_k^{1/2}, or random perturbations
        ## thereof.
        M <- e$vectors[, seq_len(k), drop = FALSE] *
            rep(sqrt(e$values[seq_len(k)]), each = n)
        m <- c(M)
        start <- c(list(m),
                   replicate(nruns - 1L,
                             m + rnorm(length(m), sd = sd(m) / sqrt(3)),
                             simplify = FALSE))
    }

    L <- function(m) {
        M <- matrix(m, n)
        C_M <- tcrossprod(M)
        ## Note that here (as opposed to hard/symdiff) we take soft
        ## partitions as is without replacing them by their closest hard
        ## partitions.
        sum(w * sapply(comemberships,
                       function(C) sum(abs(C_M - C))))
    }
    P <- .make_penalty_function_membership(n, k)
    if(gradient) {
        grad_L <- function(m) {
            M <- matrix(m, n)
            C_M <- tcrossprod(M)
            .weighted_sum_of_matrices(lapply(comemberships,
                                             function(C)
                                             2 * sign(C_M - C) %*% M),
                                      w, n)
        }
        grad_P <- .make_penalty_gradient_membership(n, k)
    }
    else
        grad_L <- grad_P <- NULL

    out <- sumt(start, L, P, grad_L, grad_P,
                method = control$method, eps = control$eps,
                q = control$q, verbose = control$verbose,
                control = as.list(control$control))

    M <- .stochastify(matrix(out$x, n))
    rownames(M) <- rownames(cl_membership(clusterings[[1L]]))
    meta <- list(objval = L(c(M)))
    M <- .cl_membership_from_memberships(M, k, meta)

    as.cl_partition(M)
}
R/consensus.R:794

.cl_consensus_partition_hard_symdiff untypeabletyped

unbound variable (line 920)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((clusterings: list, weights: any, control: { k: null, control: list, any }) | (clusterings: list, weights: any, control: { k: ~null, control: list, any }) | (clusterings: vec, weights: any, control: { k: null, control: list, any }) | (clusterings: vec, weights: any, control: { k: ~null, control: list, any }) -> any)<>
timing: 0.042 s
source
.cl_consensus_partition_hard_symdiff <-
function(clusterings, weights, control)
{
    ## <NOTE>
    ## This is mostly duplicated from relations.
    ## Once this is on CRAN, we could consider having clue suggest
    ## relations ...
    ## </NOTE>
    
    comemberships <-
        lapply(clusterings,
               function(x) {
                   ## Here, we always turn possibly soft partitions to
                   ## their closest hard partitions.
                   ids <- cl_class_ids(x)
                   outer(ids, ids, `==`)
                   ## (Simpler than using tcrossprod() on
                   ## cl_membership().)
               })

    ## Could also create a relation ensemble from the comemberships and
    ## call relation_consensus().

    B <- relations:::.make_fit_relation_symdiff_B(comemberships,
                                                  weights)
    k <- control$k
    control <- control$control
    ## Note that currently we provide no support for finding *all*
    ## consensus partitions (but allow for specifying the solver).
    control$all <- FALSE
    I <- if(!is.null(k)) {
        ## <NOTE>
        ## We could actually get the memberships directly in this case.
        relations:::fit_relation_LP_E_k(B, k, control)
        ## </NOTE>
    }
    else
        relations:::fit_relation_LP(B, "E", control)

    ids <- relations:::get_class_ids_from_incidence(I)
    names(ids) <- cl_object_names(clusterings)

    as.cl_hard_partition(ids)
}
R/consensus.R:906

.cl_consensus_hierarchy_cophenetic untypeabletyped

unbound variable (line 960)
unbound: ls_fit_ultrametric — one of the package’s own names, itself untyped
error detail
name: ls_fit_ultrametric
gradual mode: typed
((clusterings: any, weights: any, control: list | null) -> any)<>
timing: 0.047 s
source
.cl_consensus_hierarchy_cophenetic <-
function(clusterings, weights, control)
{
    ## d <- .weighted_mean_of_object_dissimilarities(clusterings, weights)
    ## Alternatively:
    ## as.cl_dendrogram(ls_fit_ultrametric(d, control = control))
    control <- c(list(weights = weights), control)
    as.cl_dendrogram(ls_fit_ultrametric(clusterings, control = control))
}
R/consensus.R:953

.cl_consensus_hierarchy_manhattan untypeabletimeout

unbound variable (line 991)
unbound: cl_ultrametric — one of the package’s own names, itself untyped
error detail
name: cl_ultrametric
gradual mode: timeout
timing: 5.23 s
source
.cl_consensus_hierarchy_manhattan <-
function(clusterings, weights, control)
{
    ## Control parameters:
    ## gradient,
    gradient <- control$gradient
    if(is.null(gradient))
        gradient <- TRUE
    ## nruns,
    nruns <- control$nruns
    ## start.
    start <- control$start

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else if(is.null(nruns)) {
        ## Use nruns only if start is not given.
        nruns <- 1L
    }
    
    w <- weights / sum(weights)
    B <- length(clusterings)
    ultrametrics <- lapply(clusterings, cl_ultrametric)
    
    if(B == 1L)
        return(as.cl_dendrogram(ultrametrics[[1L]]))

    n <- n_of_objects(ultrametrics[[1L]])
    labels <- cl_object_names(ultrametrics[[1L]])

    ## We need to do
    ##
    ##   \sum_b w_b \sum_{i,j} | u_{ij}(b) - u_{ij} | => min
    ##
    ## over all ultrametrics u.  Let's use a SUMT (for which "gradients"
    ## can optionally be switched off) ...
    
    L <- function(d) {
        sum(w * sapply(ultrametrics, function(u) sum(abs(u - d))))
        ## Could also do something like
        ##   sum(w * sapply(ultrametrics, cl_dissimilarity, d,
        ##                  "manhattan"))
    }
    P <- .make_penalty_function_ultrametric(n)
    if(gradient) {
        grad_L <- function(d) {
            ## "Gradient" is \sum_b w_b sign(d - u(b)).
            .weighted_sum_of_vectors(lapply(ultrametrics,
                                            function(u) sign(d - u)),
                                     w)
        }
        grad_P <- .make_penalty_gradient_ultrametric(n)
    } else
        grad_L <- grad_P <- NULL
            
    if(is.null(start)) {
        ## Initialize by "random shaking" of the weighted median of the
        ## ultrametrics.  Any better ideas?
        ## <NOTE>
        ## Using var(x) / 3 is really L2 ...
        ## </NOTE>
        x <- apply(matrix(unlist(ultrametrics), ncol = B), 1, 
                   weighted_median, w)
        start <- replicate(nruns,  
                           x + rnorm(length(x), sd = sd(x) / sqrt(3)),
                           simplify = FALSE)
    }

    out <- sumt(start, L, P, grad_L, grad_P,
                method = control$method, eps = control$eps,
                q = control$q, verbose = control$verbose,
                control = as.list(control$control))

    d <- .ultrametrify(out$x)
    meta <- list(objval = L(d))
    d <- .cl_ultrametric_from_veclh(d, n, labels, meta)
    
    as.cl_dendrogram(d)
}
R/consensus.R:965

.cl_consensus_hierarchy_majority typed empty return any: clusterings

((clusterings: any, weights: dbl<@"/", ...>, control: { p: ~((DBL | INT) | null), any }) | (clusterings: any, weights: dbl<~@"/", ...>, control: { p: ~((DBL | INT) | null), any }) -> empty)<>
timing: 5.07 s
source
.cl_consensus_hierarchy_majority <-
function(clusterings, weights, control)
{
    w <- weights / sum(weights)

    p <- control$p
    if(is.null(p))
        p <- 1 / 2
    else if(!is.numeric(p) || (length(p) != 1) || (p < 1 / 2) || (p > 1))
        stop("Parameter 'p' must be in [1/2, 1].")

    classes <- lapply(clusterings, cl_classes)
    all_classes <- unique(unlist(classes, recursive = FALSE))
    gamma <- double(length = length(all_classes))
    for(i in seq_along(classes))
        gamma <- gamma + w[i] * !is.na(match(all_classes, classes[[i]]))
    ## Rescale to [0, 1].
    gamma <- gamma / max(gamma)

    maj_classes <- if(p == 1) {
        ## Strict consensus tree.
        all_classes[gamma == 1]
    }
    else
        all_classes[gamma > p]
    attr(maj_classes, "labels") <- attr(classes[[1L]], "labels")

    ## <FIXME>
    ## Stop auto-coercing that to dendrograms once we have suitable ways
    ## of representing n-trees.
    as.cl_hierarchy(.cl_ultrametric_from_classes(maj_classes))
    ## </FIXME>
}
R/consensus.R:1051

.make_X_from_p untypeabletyped

unbound variable (line 1117)
unbound: cbind — a name the prelude does not declare
error detail
name: cbind
gradual mode: typed
((p: <@"[", ...>) | (p: list<~@"[", ...>) | (p: vec<~@"[", ...>) -> any)<>
timing: 0.059 s
source
.make_X_from_p <-
function(p) {
    ## X matrix corresponding to permutation p as needed for the AO
    ## algorithms.  I.e., x_{ij} = 1 iff j->p(j)=i.
    X <- matrix(0, length(p), length(p))
    i <- seq_along(p)
    X[cbind(p[i], i)] <- 1
    X
}
R/consensus.R:1111
R/lattice.R

.cl_meet_dendrogram untypeabletyped

unbound variable (line 49)
unbound: pmin — a name the prelude does not declare
error detail
name: pmin
gradual mode: typed
((x: { { .Data: any, any } with { Labels: null, any } }) -> any)<>
timing: 0.003 s
source
.cl_meet_dendrogram <-
function(x)
{
    ## Meet of an ensemble of dendrograms.
    ## We need the maximal ultrametric dominated by the given ones,
    ## which can be obtained by hierarchical clustering with single
    ## linkage on the pointwise minima of the ultrametrics.
    as.cl_dendrogram(hclust(as.dist(do.call(pmin,
                                            lapply(x, cl_ultrametric))),
                            "single"))
}
R/lattice.R:42

.cl_meet_hierarchy untypeabletyped

unbound variable (line 60)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
gradual mode: typed
((x: any) -> any)<>
timing: 0.006 s
source
.cl_meet_hierarchy <-
function(x)
{
    ## Meet of an ensemble of n-trees.
    ## Need to find the classes in *all* n-trees.
    ## Equivalent to computing a strict majority tree.
    .cl_consensus_hierarchy_majority(x, rep.int(1, length(x)),
                                     list(p = 1))
}
R/lattice.R:54

.cl_meet_partition untypeabletyped

unbound variable (line 27)
unbound: unique — a name the prelude does not declare
error detail
name: unique
gradual mode: typed
((x: any) -> any)<>
timing: 0.018 s
source
.cl_meet_partition <-
function(x)    
{
    x <- unique(x)
    if(length(x) == 1L)
        return(cl_partition_by_class_ids(cl_class_ids(x[[1L]])))

    ids <- seq_len(n_of_objects(x[[1L]]))
    ## Cross-classify the objects.
    z <- split(ids, lapply(x, cl_class_ids))
    ## Subscript on the non-empty cells to get adjacent class ids.
    lens <- lengths(z)
    pos <- which(lens > 0)
    ids[unlist(z, use.names = FALSE)] <-
        rep.int(seq_along(z[pos]), lens[pos])
    cl_partition_by_class_ids(ids)
}
R/lattice.R:24

cl_meet untypeable

unbound variable (line 9)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
timing: 0.049 s
source
cl_meet <-
function(x, y)
{
    ## General case.
    ## x either an ensemble, or x and y two clusterings with the same
    ## number of objects.
    if(!inherits(x, "cl_ensemble")) {
        ## Be nice about error messages.
        if(n_of_objects(x) != n_of_objects(y))
            stop("Arguments 'x' and 'y' must have the same number of objects.")
        x <- cl_ensemble(x, y)
    }

    if(inherits(x, "cl_partition_ensemble"))
        .cl_meet_partition(x)
    else if(inherits(x, "cl_dendrogram_ensemble"))
        .cl_meet_dendrogram(x)
    else if(inherits(x, "cl_hierarchy_ensemble"))
        .cl_meet_hierarchy(x)
    else
        stop("Cannot compute meet of given clusterings.")
}
R/lattice.R:1

.cl_join_dendrogram untypeabletyped

unbound variable (line 151)
unbound: pmax — a name the prelude does not declare
error detail
name: pmax
gradual mode: typed
((x: { { .Data: any, any } with { Labels: null, any } }) -> any)<>
timing: 0.002 s
source
.cl_join_dendrogram <-
function(x)
{
    ## Join of an ensemble of dendrograms.
    as.cl_dendrogram(do.call(pmax, lapply(x, cl_ultrametric)))
}
R/lattice.R:147

.cl_join_hierarchy untypeabletyped

unbound variable (line 160)
unbound: cl_classes — one of the package’s own names, itself untyped
error detail
name: cl_classes
gradual mode: typed
((x: any) -> any)<>
timing: 0.042 s
source
.cl_join_hierarchy <-
function(x)
{
    ## Join of an ensemble of n-trees.
    ## Only exists if the union of all classes of the n-trees is itself
    ## an n-tree (see Barthelemy et al).
    classes <- unique(unlist(lapply(x, cl_classes), recursive = FALSE))
    ## Now check if this is an n-tree.
    ## We must verify that for all classes A and B, their intersection
    ## is A, B, or empty.
    check <- function(A, B) {
        m_AB <- match(A, B)
        m_BA <- match(B, A)
        ((all(is.na(m_AB)) && all(is.na(m_BA)))
         || all(is.finite(m_AB))
         || all(is.finite(m_BA)))
    }
    for(i in seq_along(classes)) {
        A <- classes[[i]]
        for(j in seq_along(classes))
            if(!check(A, classes[[j]]))
                stop("Join of given n-trees does not exist.")
    }
    as.cl_hierarchy(.cl_ultrametric_from_classes(classes))
}
R/lattice.R:154

.cl_join_partition untypeable

unbound variable (line 90)
unbound: unique — a name the prelude does not declare
error detail
name: unique
timing: 0.043 s
source
.cl_join_partition <-
function(x)
{
    x <- unique(x)
    if(length(x) == 1)
        return(cl_partition_by_class_ids(cl_class_ids(x[[1L]])))

    ## Canonicalize: ensure that class ids are always the integers from
    ## one to the number of classes.
    n <- sapply(x, n_of_classes)
    ids <- mapply(function(p, ncp) match(cl_class_ids(p),
                                         seq_len(ncp)),
                  x, n, SIMPLIFY = FALSE)
    ## Order according to the number of classes.
    ids <- ids[order(n)]

    ## And now incrementally build the join.
    jcids <- ids[[1L]]                  # Class ids of the current join.
    jnc <- length(unique(jcids))        # Number of classes of this.
    for(b in seq.int(from = 2, to = length(x))) {
        z <- table(jcids, ids[[b]])
        ## It is faster to work on the smaller partition, but this
        ## should be ensured by the reordering ...
        ## We need to "join all elements in the same class in at least
        ## one of the partitions".  In the matrix
        ##   C <- (tcrossprod(z) > 0)
        ## entry i,j is true/one iff z_{ik} z_{jk} > 0 for classes
        ## i and j in the current join (ids jcids) and some class k in
        ## the partition with ids[[b]], so that i and j must be joined.
        ## I.e., C indicates which classes need to be joined directly.
        ## We need to determine the transitive closure of this relation,
        ## which can be performed by repeating
        ##   C_{t+1} <- ((C_t %*% C) > 0)
        ## with C_1 = C until C_t does not change.
        C_new <- C_old <- C <- (tcrossprod(z) > 0)
        repeat {
            C_new <- (C_old %*% C) > 0
            if(all(C_new == C_old)) break
            C_old <- C_new
        }
        C <- C_new
        ## This should now have the connected components.
        ## Next, compute the map of the join class ids to the ids of
        ## these components. 
        cnt <- 0
        map <- remaining_ids <- seq_len(jnc)
        while(length(remaining_ids)) {
            cnt <- cnt + 1
            pos <- which(C[remaining_ids[1L], remaining_ids] > 0)
            map[remaining_ids[pos]] <- cnt
            remaining_ids <- remaining_ids[-pos]
        }
        ## And update the join:
        jcids <- map[jcids]
        jnc <- cnt
    }

    cl_partition_by_class_ids(jcids)    
}
R/lattice.R:87

cl_join untypeable

unbound variable (line 72)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
timing: 0.047 s
source
cl_join <-
function(x, y)
{
    ## General case.
    ## x either an ensemble, or x and y two clusterings with the same
    ## number of objects.
    if(!inherits(x, "cl_ensemble")) {
        ## Be nice about error messages.
        if(n_of_objects(x) != n_of_objects(y))
            stop("Arguments 'x' and 'y' must have the same number of objects.")
        x <- cl_ensemble(x, y)
    }

    if(inherits(x, "cl_partition_ensemble"))
        .cl_join_partition(x)
    else if(inherits(x, "cl_dendrogram_ensemble"))
        .cl_join_dendrogram(x)
    else if(inherits(x, "cl_hierarchy_ensemble"))
        .cl_join_hierarchy(x)
    else
        stop("Cannot compute join of given clusterings.")
}
R/lattice.R:64
R/ensemble.R

cl_ensemble untypeabletyped

unbound variable (line 10)
unbound: attr<- — a name the prelude does not declare
error detail
name: attr<-
gradual mode: typed
((...: any, list: (list | null)?) -> any)<>
timing: 0.089 s
source
cl_ensemble <-
function(..., list = NULL)
{
    clusterings <- c(list(...), list)

    if(!length(clusterings)) {
        ## Return an empty cl_ensemble.
        ## In this case, we cannot additionally know whether it contains
        ## partitions or hierarchies ...
        attr(clusterings, "n_of_objects") <- as.integer(NA)
        class(clusterings) <- "cl_ensemble"
        return(clusterings)
    }

    ## Previously, we used to require that the elements of the ensemble
    ## either all be partitions, or all be hierarchies.  We no longer do
    ## this, as it makes sense to also allow e.g. object dissimilarities
    ## (raw "dist" objects or additive distances) as elements (e.g.,
    ## when computing proximities), and it is rather cumbersome to
    ## decide in advance which combinations of elements might be useful
    ## and hence should be allowed.  All we enforce is that all elements
    ## correspond to the same number of objects (as we typically cannot
    ## verify that they relate to the *same* objects).  For "pure"
    ## ensembles of partitions or hierarchies we add additional class
    ## information.

    if(all(vapply(clusterings, is.cl_partition, NA)))
        class(clusterings) <- c("cl_partition_ensemble", "cl_ensemble")
    else if(all(vapply(clusterings, is.cl_dendrogram, NA)))
        class(clusterings) <- c("cl_dendrogram_ensemble",
                                "cl_hierarchy_ensemble", "cl_ensemble")
    else if(all(vapply(clusterings, is.cl_hierarchy, NA)))
        class(clusterings) <- c("cl_hierarchy_ensemble", "cl_ensemble")
    else
        class(clusterings) <- "cl_ensemble"

    n <- sapply(clusterings, n_of_objects)
    if(any(diff(n)))
        stop("All elements must have the same number of objects.")
    attr(clusterings, "n_of_objects") <- as.integer(n[1L])

    clusterings
}
R/ensemble.R:1

is.cl_ensemble typed any: x fuzz ok

((x: any) -> LGL1<>)<>
timing: 0.012 s
fuzzing: 7 inside (7 ok) · 8 outside (8 rejected)
source
is.cl_ensemble <-
function(x)
    inherits(x, "cl_ensemble")
R/ensemble.R:45

as.cl_ensemble untypeabletyped

unbound variable (line 57)
unbound: is.object — a name the prelude does not declare
error detail
name: is.object
gradual mode: typed
((x: list | null) -> any)<>
timing: 0.063 s
source
as.cl_ensemble <-
function(x)
{
    if(is.cl_ensemble(x)) x
    else if(is.list(x) && !is.object(x)) cl_ensemble(list = x)
    else cl_ensemble(x)
}
R/ensemble.R:53

c.cl_ensemble untypeable

unbound variable (line 65)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.011 s
source
c.cl_ensemble <-
function(..., recursive = FALSE)
{
    clusterings <- unlist(lapply(list(...), as.cl_ensemble),
                          recursive = FALSE)
    cl_ensemble(list = clusterings)
}
R/ensemble.R:62

[.cl_ensemble untypeabletyped

unbound variable (line 75)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any, i: any) -> any)<>
timing: 0.021 s
source
"[.cl_ensemble" <-
function(x, i)
{
    ## Make subscripting empty ensembles a noop.
    if(length(x) == 0L) return(x)
    cl_ensemble(list = NextMethod("["))
}
R/ensemble.R:70

rep.cl_ensemble untypeabletyped

unbound variable (line 80)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any, times: any, ...: any) -> any)<>
timing: 0.005 s
source
rep.cl_ensemble <-
function(x, times, ...)
    cl_ensemble(list = NextMethod("rep"))
R/ensemble.R:78

print.cl_partition_ensemble untypeabletyped

unbound variable (line 85)
unbound: ngettext — a name the prelude does not declare
error detail
name: ngettext
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.011 s
source
print.cl_partition_ensemble <-
function(x, ...)
{
    msg <- sprintf(ngettext(length(x),
                            "An ensemble of %d partition of %d objects.",
                            "An ensemble of %d partitions of %d objects."),
                   length(x), n_of_objects(x))
    writeLines(strwrap(msg))
    invisible(x)
}
R/ensemble.R:82

Summary.cl_partition_ensemble skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.003 s
source
Summary.cl_partition_ensemble <-
function(..., na.rm = FALSE)
{
    ok <- switch(.Generic, max = , min = , range = TRUE, FALSE)
    if(!ok)
        stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)
    args <- list(...)
    ## Combine the given partition ensembles.
    x <- do.call(c, args)
    switch(.Generic,
           "min" = cl_meet(x),
           "max" = cl_join(x),
           "range" = cl_ensemble(min = cl_meet(x), max = cl_join(x)))
}
R/ensemble.R:93

print.cl_dendrogram_ensemble untypeabletyped

unbound variable (line 113)
unbound: ngettext — a name the prelude does not declare
error detail
name: ngettext
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.011 s
source
print.cl_dendrogram_ensemble <-
function(x, ...)
{
    msg <- sprintf(ngettext(length(x),
                            "An ensemble of %d dendrogram of %d objects.",
                            "An ensemble of %d dendrograms of %d objects."),
                   length(x), n_of_objects(x))
    writeLines(strwrap(msg))
    invisible(x)
}
R/ensemble.R:110

print.cl_hierarchy_ensemble untypeabletyped

unbound variable (line 124)
unbound: ngettext — a name the prelude does not declare
error detail
name: ngettext
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.010 s
source
print.cl_hierarchy_ensemble <-
function(x, ...)
{
    msg <- sprintf(ngettext(length(x),
                            "An ensemble of %d hierarchy of %d objects.",
                            "An ensemble of %d hierarchies of %d objects."),
                   length(x), n_of_objects(x))
    writeLines(strwrap(msg))
    invisible(x)
}
R/ensemble.R:121

print.cl_ensemble untypeabletyped

unbound variable (line 135)
unbound: ngettext — a name the prelude does not declare
error detail
name: ngettext
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.010 s
source
print.cl_ensemble <-
function(x, ...)
{
    writeLines(sprintf(ngettext(length(x),
                                "An ensemble with %d element.",
                                "An ensemble with %d elements."),
                       length(x)))
    invisible(x)
}
R/ensemble.R:132

plot.cl_ensemble untypeable

unbound variable (line 164)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
timing: 0.123 s
source
plot.cl_ensemble <-
function(x, ..., main = NULL, layout = NULL)
{
    if(!is.cl_ensemble(x))
        stop("Wrong class.")

    ## What we can definitely plot is are cl_addtree, cl_dendrogram and
    ## cl_ultrametric objects.  (We could also add simple methods for
    ## plotting raw dissimilarities, but of course seriation::dissplot()
    ## would be the thing to use.)  What we cannot reasonably plot is
    ## partitions (in particular, as these do not know about the
    ## underlying dissimilarities.  But then we could perhaps provide
    ## silhoutte plots etc for ensembles of partitions ...
    ## <FIXME>
    ## Think about this.
    ## </FIXME>
    ## So let us check for the things we can plot.

    ## (Note that currently there is neither is.cl_ultrametric() nor
    ## is.cl_addtree().)
    ok <- vapply(x,
                 function(e)
                 (is.cl_dendrogram(e) ||
                  inherits(e, c("cl_addtree", "cl_ultrametric"))),
                 NA)
    if(!all(ok))
        stop(gettextf("Plotting not available for elements %s of the ensemble.",
                      paste(which(!ok), collapse = " ")),
             domain = NA)

    ## Prefer dendrogram plot methods to those for hclust objects.
    ind <- vapply(x, is.cl_dendrogram, NA)
    if(any(ind))
        x[ind] <- lapply(x, as.cl_dendrogram)

    ## Now the usual layouting ... same as for plotting relation
    ## ensembles.

    ## Number of elements.
    n <- length(x)
    ## Layout.
    byrow <- TRUE
    if(is.null(layout)) {
        nc <- ceiling(sqrt(n))
        nr <- ceiling(n / nc)
    }
    else {
        layout <- c(as.list(layout), byrow)[seq_len(3)]
        if(is.null(names(layout)))
            names(layout) <- c("nr", "nc", "byrow")
        nr <- layout[["nr"]]
        nc <- layout[["nc"]]
        byrow <- layout[["byrow"]]
    }
    op <- if(byrow)
        par(mfrow = c(nr, nc))
    else
        par(mfcol = c(nr, nc))
    on.exit(par(op))

    ## Try recycling main (might want the same for others as well).
    if(!is.list(main)) {
        main <- if(is.null(main))
            vector("list", length = n)
        else
            rep.int(as.list(main), n)
    }
    
    for(i in seq_along(x))
        plot(x[[i]], main = main[[i]], ...)
}
R/ensemble.R:142

unique.cl_ensemble untypeabletyped

unbound variable (line 216)
unbound: NextMethod — a name the prelude does not declare
error detail
name: NextMethod
gradual mode: typed
((x: any, incomparables: any?, ...: any) -> any)<>
timing: 0.006 s
source
unique.cl_ensemble <-
function(x, incomparables = FALSE, ...)
    cl_ensemble(list = NextMethod("unique"))
R/ensemble.R:214

.cl_ensemble_type typed any: x fuzz ok

((x: any) -> ("hierarchy"<> | "partition"<>) | null)<>
timing: 0.025 s
fuzzing: 6 inside (6 ok) · 7 outside (7 rejected)
source
.cl_ensemble_type <-
function(x)
{
    if(inherits(x, "cl_partition_ensemble"))
        "partition"
    else if(inherits(x, "cl_hierarchy_ensemble"))
        "hierarchy"
    else
        NULL
}
R/ensemble.R:218
R/partition.R

n_of_classes untypeabletyped

unbound variable (line 14)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
n_of_classes <-
function(x)
    UseMethod("n_of_classes")
R/partition.R:12

cl_class_ids untypeabletyped

unbound variable (line 72)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids <-
function(x)
    UseMethod("cl_class_ids")
R/partition.R:70

n_of_classes.default untypeabletyped

unbound variable (line 19)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.002 s
source
n_of_classes.default <-
function(x)
    length(unique(cl_class_ids(x)))
R/partition.R:17

n_of_classes.kmeans untypeabletyped

unbound variable (line 22)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.kmeans <- n_of_classes.default
R/partition.R:22

n_of_classes.fanny untypeabletyped

unbound variable (line 28)
unbound: colSums — a name the prelude does not declare
error detail
name: colSums
gradual mode: typed
((x: { membership: any, any }) -> any)<>
timing: 0.014 s
source
n_of_classes.fanny <-
function(x)
    sum(colSums(x$membership, na.rm = TRUE) > 0)
R/partition.R:26

n_of_classes.partition untypeabletyped

unbound variable (line 29)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.partition <- n_of_classes.default
R/partition.R:29

n_of_classes.cclust untypeabletyped

unbound variable (line 32)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.cclust <- n_of_classes.default
R/partition.R:32

n_of_classes.fclust untypeabletyped

unbound variable (line 35)
unbound: n_of_classes.fanny — one of the package’s own names, itself untyped
error detail
name: n_of_classes.fanny
gradual mode: typed
((x: { membership: any, any }) -> any)<>
timing: 0.000 s
source
n_of_classes.fclust <- n_of_classes.fanny
R/partition.R:35

n_of_classes.cshell untypeabletyped

unbound variable (line 37)
unbound: n_of_classes.fanny — one of the package’s own names, itself untyped
error detail
name: n_of_classes.fanny
gradual mode: typed
((x: { membership: any, any }) -> any)<>
timing: 0.000 s
source
n_of_classes.cshell <- n_of_classes.fanny
R/partition.R:37

n_of_classes.bclust untypeabletyped

unbound variable (line 39)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.bclust <- n_of_classes.default
R/partition.R:39

n_of_classes.Mclust untypeabletyped

unbound variable (line 42)
unbound: n_of_classes.default — one of the package’s own names, itself untyped
error detail
name: n_of_classes.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_classes.Mclust <- n_of_classes.default
R/partition.R:42

n_of_classes.cl_membership typed accepts outside

∀'a. ((x: any with { n_of_classes: 'a, any }) -> 'a)<>
timing: 0.021 s
fuzzing: 20 inside (20 ok) · 8 outside (2 rejected, 6 accepted)
type drawn from: ((x: any with { n_of_classes: 'I12329, any }) -> 'I12329)<>

Accepted outside the domain x: 6

parameterchangecallreturned
xattr:drop:n_of_classesn_of_classes.cl_membership("x" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))null
xkind:envn_of_classes.cl_membership("x" = new.env())null
xkind:funn_of_classes.cl_membership(function(...) NULL)null
xkind:symn_of_classes.cl_membership("x" = as.name("x"))null
xwrapn_of_classes.cl_membership(list(structure(complex(real = 0, imaginary = 0), "n_of_classes" = "")))null
xwrapn_of_classes.cl_membership(list(structure(list(NULL, NULL), "n_of_classes" = NULL)))null
source
n_of_classes.cl_membership <-
function(x)
    attr(x, "n_of_classes")
R/partition.R:45

n_of_classes.pclust untypeabletyped

unbound variable (line 53)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: { membership: any, any }) -> INT1<>)<>
timing: 0.030 s
source
n_of_classes.pclust <-
function(x)
{
    if(is.null(m <- x$membership)) 
        length(unique(cl_class_ids(x)))
    else
        sum(colSums(m, na.rm = TRUE) > 0)
}
R/partition.R:49

n_of_classes.cl_partition untypeabletyped

unbound variable (line 60)
unbound: n_of_classes — one of the package’s own names, itself untyped
error detail
name: n_of_classes
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.009 s
source
n_of_classes.cl_partition <-
function(x)
    n_of_classes(.get_representation(x))
R/partition.R:58

cl_class_ids.default typed empty return any: x

((x: any) -> empty)<>
timing: 0.005 s
source
cl_class_ids.default <-
function(x)
{
    stop("Cannot infer class ids from given object.")
}
R/partition.R:75

as.cl_class_ids untypeabletyped

unbound variable (line 198)
unbound: .structure — one of the package’s own names, itself untyped
error detail
name: .structure
gradual mode: typed
((x: <...>) -> any)<>
timing: 0.008 s
source
as.cl_class_ids <-
function(x)
{
    ## For the time being, handle only "raw" class ids.
    ## Maybe add methods handling factors lateron (if necessary).
    ## <NOTE>
    ## This could also be used to canonicalize returned class ids
    ## according to the docs (vector of integers with the class ids),
    ## using someting like
    ##   match(ids, unique(ids))
    ## </NOTE>
    .structure(unclass(x), class = "cl_class_ids")
}
R/partition.R:187

cl_class_ids.kmeans untypeabletyped

unbound variable (line 84)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.kmeans <-
function(x)
    as.cl_class_ids(x$cluster)
R/partition.R:82

cl_class_ids.partition untypeabletyped

unbound variable (line 90)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { clustering: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.partition <-
function(x)
    as.cl_class_ids(x$clustering)
R/partition.R:88

cl_class_ids.Weka_clusterer untypeabletyped

unbound variable (line 96)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { class_ids: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.Weka_clusterer <-
function(x)
    as.cl_class_ids(x$class_ids)
R/partition.R:94

cl_class_ids.ccfkms untypeabletyped

unbound variable (line 101)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: { cl: any, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.ccfkms <-
function(x)
    as.cl_class_ids(as.vector(x$cl))
R/partition.R:99

cl_class_ids.rock untypeabletyped

unbound variable (line 105)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: { cl: any, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.rock <-
function(x)
    as.cl_class_ids(as.vector(x$cl))
R/partition.R:103

cl_class_ids.cclust untypeabletyped

unbound variable (line 108)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.cclust <- cl_class_ids.kmeans
R/partition.R:108

cl_class_ids.fclust untypeabletyped

unbound variable (line 111)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.fclust <- cl_class_ids.kmeans
R/partition.R:111

cl_class_ids.cshell untypeabletyped

unbound variable (line 113)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.cshell <- cl_class_ids.kmeans
R/partition.R:113

cl_class_ids.bclust untypeabletyped

unbound variable (line 115)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.bclust <- cl_class_ids.kmeans
R/partition.R:115

cl_class_ids.kcca untypeabletyped

unbound variable (line 126)
unbound: modeltools::clusters — a name the prelude does not declare
error detail
name: modeltools::clusters
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids.kcca <-
function(x)
    as.cl_class_ids(modeltools::clusters(x))
R/partition.R:124

cl_class_ids.flexmix untypeabletyped

unbound variable (line 136)
unbound: modeltools::clusters — a name the prelude does not declare
error detail
name: modeltools::clusters
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids.flexmix <-
function(x)
    as.cl_class_ids(modeltools::clusters(x))
R/partition.R:134

cl_class_ids.specc untypeabletyped

unbound variable (line 144)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: <...>) -> any)<>
timing: 0.008 s
source
cl_class_ids.specc <-
function(x)
{
    tmp <- unclass(x)
    as.cl_class_ids(.structure(as.vector(tmp), names = names(tmp)))
}
R/partition.R:140

cl_class_ids.Mclust untypeabletyped

unbound variable (line 150)
unbound: as.cl_class_ids — one of the package’s own names, itself untyped
error detail
name: as.cl_class_ids
gradual mode: typed
((x: { classification: <...>, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.Mclust <-
function(x)
    as.cl_class_ids(x$classification)
R/partition.R:148

cl_class_ids.relation untypeabletyped

unbound variable (line 155)
unbound: relations::relation_class_ids — a name the prelude does not declare
error detail
name: relations::relation_class_ids
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_ids.relation <-
function(x)
    as.cl_class_ids(relations::relation_class_ids(x))
R/partition.R:153

cl_class_ids.cl_class_ids typed fuzz ok

∀'a. (x: 'a) -> 'a
timing: 0.005 s
fuzzing: 20 inside (20 ok) · 8 outside (8 rejected)
type drawn from: (x: 'I12477) -> 'I12477
source
cl_class_ids.cl_class_ids <- identity
R/partition.R:158

cl_class_ids.cl_membership untypeabletyped

unbound variable (line 162)
unbound: max.col — a name the prelude does not declare
error detail
name: max.col
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
cl_class_ids.cl_membership <-
function(x)
    as.cl_class_ids(.structure(max.col(x), names = rownames(x)))
R/partition.R:160

cl_class_ids.cl_pam untypeabletyped

unbound variable (line 166)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.cl_pam <- cl_class_ids.kmeans
R/partition.R:166

cl_class_ids.cl_partition_by_class_ids typed accepts outside

∀'a. ((x: { .Data: 'a, any }) -> 'a)<>
timing: 0.016 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { .Data: 'I12492, any }) -> 'I12492)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:langcl_class_ids.cl_partition_by_class_ids(quote(f(x)))null
source
cl_class_ids.cl_partition_by_class_ids <-
function(x)
    .get_representation(x)
R/partition.R:168

cl_class_ids.kmedoids untypeabletyped

unbound variable (line 172)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.kmedoids <- cl_class_ids.kmeans
R/partition.R:172

cl_class_ids.pclust untypeabletyped

unbound variable (line 174)
unbound: cl_class_ids.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_class_ids.kmeans
gradual mode: typed
((x: { cluster: <...>, any }) -> any)<>
timing: 0.000 s
source
cl_class_ids.pclust <- cl_class_ids.kmeans
R/partition.R:174

cl_class_ids.cl_partition untypeabletyped

unbound variable (line 178)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.009 s
source
cl_class_ids.cl_partition <-
function(x)
    cl_class_ids(.get_representation(x))
R/partition.R:176

cl_class_ids.movMF untypeabletyped

unbound variable (line 183)
unbound: max.col — a name the prelude does not declare
error detail
name: max.col
gradual mode: typed
((x: { P: any, any }) -> any)<>
timing: 0.011 s
source
cl_class_ids.movMF <-
function(x)
    as.cl_class_ids(max.col(x$P))
R/partition.R:181

print.cl_class_ids untypeabletyped

unbound variable (line 206)
unbound: writeLines — a name the prelude does not declare
error detail
name: writeLines
gradual mode: typed
∀'a. ((x: 'a & <...>, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_class_ids <-
function(x, ...)
{
    writeLines("Class ids:")
    print(unclass(x), ...)
    invisible(x)
}
R/partition.R:203

cl_class_labels untypeabletyped

unbound variable (line 215)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_class_labels <-
function(x)
    UseMethod("cl_class_labels")
R/partition.R:213

is.cl_partition untypeabletyped

unbound variable (line 225)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_partition <-
function(x)
    UseMethod("is.cl_partition")
R/partition.R:223

is.cl_partition.default typed any: x accepts outside

((x: any) -> ff<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.default()ff<> with { }
source
is.cl_partition.default <- .false
R/partition.R:228

is.cl_partition.kmeans typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 8 inside (8 ok) · 6 outside (5 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.kmeans()tt<> with { }
source
is.cl_partition.kmeans <- .true
R/partition.R:231

is.cl_partition.partition typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.partition()tt<> with { }
source
is.cl_partition.partition <- .true
R/partition.R:235

is.cl_partition.Weka_clusterer typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 5 inside (5 ok) · 6 outside (5 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.Weka_clusterer()tt<> with { }
source
is.cl_partition.Weka_clusterer <- .true
R/partition.R:241

is.cl_partition.ccfkms typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.ccfkms()tt<> with { }
source
is.cl_partition.ccfkms <- .true
R/partition.R:244

is.cl_partition.rock typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.008 s
fuzzing: 8 inside (8 ok) · 5 outside (4 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.rock()tt<> with { }
source
is.cl_partition.rock <- .true
R/partition.R:246

is.cl_partition.cclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.cclust()tt<> with { }
source
is.cl_partition.cclust <- .true
R/partition.R:249

is.cl_partition.fclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 8 inside (8 ok) · 6 outside (5 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.fclust()tt<> with { }
source
is.cl_partition.fclust <- .true
R/partition.R:252

is.cl_partition.cshell typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.cshell()tt<> with { }
source
is.cl_partition.cshell <- .true
R/partition.R:254

is.cl_partition.bclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.bclust()tt<> with { }
source
is.cl_partition.bclust <- .true
R/partition.R:256

is.cl_partition.kcca typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.kcca()tt<> with { }
source
is.cl_partition.kcca <- .true
R/partition.R:260

is.cl_partition.flexmix typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.flexmix()tt<> with { }
source
is.cl_partition.flexmix <- .true
R/partition.R:263

is.cl_partition.specc typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.006 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.specc()tt<> with { }
source
is.cl_partition.specc <- .true
R/partition.R:267

is.cl_partition.Mclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.Mclust()tt<> with { }
source
is.cl_partition.Mclust <- .true
R/partition.R:270

is.cl_partition.cl_partition typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.007 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.cl_partition()tt<> with { }
source
is.cl_partition.cl_partition <- .true
R/partition.R:275

is.cl_partition.kmedoids typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.004 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.kmedoids()tt<> with { }
source
is.cl_partition.kmedoids <- .true
R/partition.R:277

is.cl_partition.pclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.pclust()tt<> with { }
source
is.cl_partition.pclust <- .true
R/partition.R:279

is.cl_partition.movMF typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 2 outside (1 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_partition.movMF()tt<> with { }
source
is.cl_partition.movMF <- .true
R/partition.R:282

.cl_partition_classes typed

"cl_partition"<>
timing: 0.002 s
source
.cl_partition_classes <- "cl_partition"
R/partition.R:289

cl_partition_by_memberships untypeabletyped

unbound variable (line 440)
unbound: rowSums — a name the prelude does not declare
error detail
name: rowSums
gradual mode: typed
((x: vec, labels: any?) -> any)<>
timing: 0.142 s
source
cl_partition_by_memberships <-
function(x, labels = NULL)
{
    if(!is.matrix(x)
       || any(x < 0, na.rm = TRUE)
       || any(x > 1, na.rm = TRUE))
        stop("Not a valid membership matrix.")
    ## Be nice.
    x <- x / rowSums(x, na.rm = TRUE)
    ## (Note that this does not imply all(rowSums(x) == 1).  If we
    ## wanted to test for this, something like
    ##    .is_stochastic_matrix <- function(x)
    ##       identical(all.equal(rowSums(x), rep(1, nrow(x))), TRUE))
    ## should do.)
    if(is.null(rownames(x)))
        rownames(x) <- labels
    .make_container(as.cl_membership(x),
                    c("cl_partition_by_memberships",
                      .cl_partition_classes),
                    list(n_of_objects = nrow(x)))
}
R/partition.R:432

as.cl_partition untypeable

unbound variable (line 294)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
timing: 0.024 s
source
as.cl_partition <-
function(x)
{
    if(is.cl_partition(x)) {
        if(!inherits(x, "cl_partition"))
            .make_container(x, .cl_partition_classes)
        else
            x
    }
    else
        cl_partition_by_memberships(as.cl_membership(x))
}
R/partition.R:291

print.cl_partition untypeabletyped

unbound variable (line 308)
unbound: .print_container — one of the package’s own names, itself untyped
error detail
name: .print_container
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, ...: any) -> 'a)<>
timing: 0.005 s
source
print.cl_partition <-
function(x, ...)
    .print_container(x, "cl_partition", ...)
R/partition.R:306

print.cl_partition_by_class_ids untypeabletyped

unbound variable (line 316)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_partition_by_class_ids <-
function(x, ...)
{
    writeLines(gettextf("A hard partition of %d objects.",
                        n_of_objects(x)))
    print(cl_class_ids(x), ...)
    invisible(x)
}
R/partition.R:312

print.cl_partition_by_memberships untypeabletyped

unbound variable (line 327)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
∀'a. ((x: 'a, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_partition_by_memberships <-
function(x, ...)
{
    writeLines(gettextf("A partition of %d objects.",
                        n_of_objects(x)))
    print(cl_membership(x), ...)
    invisible(x)
}
R/partition.R:323

Complex.cl_partition untypeabletyped

unbound variable (line 337)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((z: any) -> empty)<>
timing: 0.002 s
source
Complex.cl_partition <-
function(z)
    stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                  .Generic, .Class),
         domain = NA)
R/partition.R:334

Math.cl_partition untypeabletyped

unbound variable (line 345)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((x: any, ...: any) -> empty)<>
timing: 0.003 s
source
Math.cl_partition <-
function(x, ...)
    stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                  .Generic, .Class),
         domain = NA)
R/partition.R:342

Ops.cl_partition untypeabletyped

unbound variable (line 353)
unbound: nargs — a name the prelude does not declare
error detail
name: nargs
gradual mode: typed
((e1: any, e2: any) -> any)<>
timing: 0.044 s
source
Ops.cl_partition <-
function(e1, e2)
{
    if(nargs() == 1L)
        stop(gettextf("Unary '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)

    ## Only comparisons are supprorted.
    if(!(as.character(.Generic) %in% c("<", "<=", ">", ">=",
                                       "==", "!=")))
        stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)

    ci1 <- cl_class_ids(e1)
    ci2 <- cl_class_ids(e2)
    if(length(ci1) != length(ci2))
        stop("Partitions must have the same number of objects.")
    z <- table(ci1, ci2) > 0
    switch(.Generic,
           "<=" = all(rowSums(z) == 1),
           "<"  = all(rowSums(z) == 1) && any(colSums(z) > 1),
           ">=" = all(colSums(z) == 1),
           ">"  = all(colSums(z) == 1) && any(rowSums(z) > 1),
           "==" = all(rowSums(z) == 1) && all(colSums(z) == 1),
           "!=" = any(rowSums(z) > 1) || any(colSums(z) > 1))

}
R/partition.R:350

Summary.cl_partition skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.002 s
source
Summary.cl_partition <-
function(..., na.rm = FALSE)
{
    ok <- switch(.Generic, max = , min = , range = TRUE, FALSE)
    if(!ok)
        stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)
    args <- list(...)
    switch(.Generic,
           "min" = cl_meet(cl_ensemble(list = args)),
           "max" = cl_join(cl_ensemble(list = args)),
           "range" = {
               cl_ensemble(min = cl_meet(cl_ensemble(list = args)),
                           max = cl_join(cl_ensemble(list = args)))
           })
}
R/partition.R:382

is.cl_hard_partition.default typed any: x accepts outside

((x: any) -> ff<>)<>
timing: 0.004 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.default()ff<> with { }
source
is.cl_hard_partition.default <- .false
R/partition.R:463

is.cl_hard_partition.kmeans typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.kmeans()tt<> with { }
source
is.cl_hard_partition.kmeans <- .true
R/partition.R:466

is.cl_hard_partition.partition typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.partition()tt<> with { }
source
is.cl_hard_partition.partition <- .true
R/partition.R:478

is.cl_hard_partition.Weka_clusterer typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.Weka_clusterer()tt<> with { }
source
is.cl_hard_partition.Weka_clusterer <- .true
R/partition.R:482

is.cl_hard_partition.ccfkms typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.ccfkms()tt<> with { }
source
is.cl_hard_partition.ccfkms <- .true
R/partition.R:485

is.cl_hard_partition.rock typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.rock()tt<> with { }
source
is.cl_hard_partition.rock <- .true
R/partition.R:487

is.cl_hard_partition.cclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.cclust()tt<> with { }
source
is.cl_hard_partition.cclust <- .true
R/partition.R:490

is.cl_hard_partition.fanny untypeabletyped

unbound variable (line 475)
unbound: cl_membership — one of the package’s own names, itself untyped
error detail
name: cl_membership
gradual mode: typed
((x: any) -> any)<>
timing: 0.005 s
source
is.cl_hard_partition.fanny <-
function(x)
{
    all(rowSums(cl_membership(x) == 1, na.rm = TRUE) > 0)
}
R/partition.R:472

is.cl_hard_partition.fclust untypeabletyped

unbound variable (line 493)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.fclust <- is.cl_hard_partition.fanny
R/partition.R:493

is.cl_hard_partition.cshell untypeabletyped

unbound variable (line 495)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.cshell <- is.cl_hard_partition.fanny
R/partition.R:495

is.cl_hard_partition.bclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.bclust()tt<> with { }
source
is.cl_hard_partition.bclust <- .true
R/partition.R:497

is.cl_hard_partition.kcca typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.004 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.kcca()tt<> with { }
source
is.cl_hard_partition.kcca <- .true
R/partition.R:501

is.cl_hard_partition.flexmix untypeabletyped

unbound variable (line 504)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.flexmix <- is.cl_hard_partition.fanny
R/partition.R:504

is.cl_hard_partition.specc typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.004 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.specc()tt<> with { }
source
is.cl_hard_partition.specc <- .true
R/partition.R:508

is.cl_hard_partition.Mclust untypeabletyped

unbound variable (line 511)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.Mclust <- is.cl_hard_partition.fanny
R/partition.R:511

is.cl_hard_partition.cl_hard_partition typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 5 outside (4 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.cl_hard_partition()tt<> with { }
source
is.cl_hard_partition.cl_hard_partition <- .true
R/partition.R:514

is.cl_hard_partition.kmedoids typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hard_partition.kmedoids()tt<> with { }
source
is.cl_hard_partition.kmedoids <- .true
R/partition.R:538

is.cl_hard_partition.pclust untypeabletyped

unbound variable (line 540)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.pclust <- is.cl_hard_partition.fanny
R/partition.R:540

is.cl_hard_partition.movMF untypeabletyped

unbound variable (line 543)
unbound: is.cl_hard_partition.fanny — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition.fanny
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
is.cl_hard_partition.movMF <- is.cl_hard_partition.fanny
R/partition.R:543

.cl_hard_partition_classes typed

CHR<>
timing: 0.015 s
source
.cl_hard_partition_classes <- c("cl_hard_partition", "cl_partition")
R/partition.R:547

cl_partition_by_class_ids untypeabletyped

unbound variable (line 405)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: <...>, labels: (vec | null)?) -> any)<>
timing: 0.020 s
source
cl_partition_by_class_ids <-
function(x, labels = NULL)
{
    if(!is.atomic(x))
        stop("Class ids must be atomic.")
    if(is.null(names(x)))
        names(x) <- labels
    ## <FIXME>
    ## Perhaps give the raw class ids more structure?
    ## E.g, class "cl_class_ids"?
    ## Problem is that we used to say about extensibility that all there
    ## is to do for a hard partitioner is to add a cl_class_ids() method
    ## and two predicates, but *not* to have the former give a suitably
    ## classed object.  On the other hand, the recipe would need to be
    ## extended for soft partitioners, for which it would be necessary
    ## to provide a cl_membership() method which really returns an
    ## object of class cl_membership.  Note that we can do this using
    ## as.cl_membership(m), where m is the raw membership matrix.  So
    ## maybe we should ask for using as.cl_class_ids() to coerce raw
    ## class ids ...
    .make_container(as.cl_class_ids(x),
                    c("cl_partition_by_class_ids",
                      .cl_hard_partition_classes),
                    list(n_of_objects = length(x),
                         n_of_classes = length(unique(x))))
    ## </FIXME>
}
R/partition.R:402

is.cl_hard_partition untypeabletyped

unbound variable (line 460)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_hard_partition <-
function(x)
    UseMethod("is.cl_hard_partition")
R/partition.R:458

is.cl_hard_partition.cl_partition untypeabletyped

unbound variable (line 535)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
gradual mode: typed
((x: { .Data: any with { is_cl_hard_partition: any, any }, any }) -> any)<>
timing: 0.043 s
source
is.cl_hard_partition.cl_partition <-
function(x)
{
    ## If the object has a cl_membership representation ...
    y <- .get_representation(x)
    if(inherits(y, "cl_membership"))
        attr(y, "is_cl_hard_partition")
    ## Other representations, e.g. for "definitely" hard partitions via
    ## vectors of class ids or class labels, or a list of classes, may
    ## be added in future versions.
    ## In any case, this must be kept in sync with what is handled by
    ## as.cl_partition() [which currently runs as.cl_membership() in
    ## case is.cl_partition() gives false].
    else
        is.cl_hard_partition(y)
}
R/partition.R:521

as.cl_hard_partition untypeable

unbound variable (line 552)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
timing: 0.032 s
source
as.cl_hard_partition <-
function(x)
{
    if(is.cl_hard_partition(x)) {
        if(!inherits(x, "cl_partition"))
            .make_container(x, .cl_hard_partition_classes)
        else
            x
    }
    else if(is.cl_partition(x)) {
        ## A soft cl_partition ...
        ids <- cl_class_ids(x)
        cl_partition_by_class_ids(ids, names(ids))
    }
    else if(is.matrix(x)) {
        ## A matrix of raw memberships, hopefully ...
        cl_partition_by_class_ids(max.col(x), rownames(x))
    }
    else if(is.atomic(x)) {
        ## A vector of raw class ids, hopefully ...
        cl_partition_by_class_ids(x, names(x))
    }
    else
        stop("Cannot coerce to 'cl_hard_partition'.")
}
R/partition.R:549

is.cl_soft_partition untypeable

unbound variable (line 581)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
timing: 0.008 s
source
is.cl_soft_partition <-
function(x)
    is.cl_partition(x) && ! is.cl_hard_partition(x)
R/partition.R:579

.maybe_is_proper_soft_partition untypeabletyped

unbound variable (line 591)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
.maybe_is_proper_soft_partition <-
function(x)
    UseMethod(".maybe_is_proper_soft_partition")
R/partition.R:589

.maybe_is_proper_soft_partition.default typed any: x accepts outside

((x: any) -> ff<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.maybe_is_proper_soft_partition.default()ff<> with { }
source
.maybe_is_proper_soft_partition.default <- .false
R/partition.R:592

.maybe_is_proper_soft_partition.fanny typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.maybe_is_proper_soft_partition.fanny()tt<> with { }
source
.maybe_is_proper_soft_partition.fanny <- .true
R/partition.R:593

.maybe_is_proper_soft_partition.fclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.maybe_is_proper_soft_partition.fclust()tt<> with { }
source
.maybe_is_proper_soft_partition.fclust <- .true
R/partition.R:594

.maybe_is_proper_soft_partition.cshell typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.maybe_is_proper_soft_partition.cshell()tt<> with { }
source
.maybe_is_proper_soft_partition.cshell <- .true
R/partition.R:595

.maybe_is_proper_soft_partition.flexmix typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.maybe_is_proper_soft_partition.flexmix()tt<> with { }
source
.maybe_is_proper_soft_partition.flexmix <- .true
R/partition.R:596

.maybe_is_proper_soft_partition.Mclust typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdrop.maybe_is_proper_soft_partition.Mclust()tt<> with { }
source
.maybe_is_proper_soft_partition.Mclust <- .true
R/partition.R:597

.maybe_is_proper_soft_partition.cl_partition untypeabletyped

unbound variable (line 611)
unbound: .maybe_is_proper_soft_partition — one of the package’s own names, itself untyped
error detail
name: .maybe_is_proper_soft_partition
gradual mode: typed
((x: { .Data: any with { is_cl_hard_partition: dbl, any }, any }) -> any)<>
timing: 0.144 s
source
.maybe_is_proper_soft_partition.cl_partition <-
function(x)
{
    y <- .get_representation(x)
    if(inherits(y, "cl_membership"))
        !attr(y, "is_cl_hard_partition")
    else
        .maybe_is_proper_soft_partition(y)
}
R/partition.R:604

.maybe_is_proper_soft_partition.pclust typed accepts outside

(((x: { m: vec, any }) -> LGL<>)&((x: { m: vec1, any }) -> LGL1<>))<>
timing: 0.066 s
fuzzing: 8 inside (3 ok, 5 error type) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xwrap.maybe_is_proper_soft_partition.pclust(list(list("m" = NA_character_, function(...) new.env(), new.env())))(LGL & ~vec1)<> with { }

Other calls inside the domain

callverdicterror
.maybe_is_proper_soft_partition.pclust("x" = list("m" = NA_complex_, as.name("x")))error_typebase::>: invalid comparison with complex values
.maybe_is_proper_soft_partition.pclust("x" = list("m" = c(complex(real = 0, imaginary = 0), NA_complex_, complex(real = 0, imaginary = 0), complex(real = 1, imaginary = -2), complex(real = 1, imaginary = -2))))error_typebase::>: invalid comparison with complex values
.maybe_is_proper_soft_partition.pclust(list("m" = complex(real = 1, imaginary = -2), function(...) NULL, local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })))error_typebase::>: invalid comparison with complex values
.maybe_is_proper_soft_partition.pclust("x" = list("m" = complex(real = 1, imaginary = -2)))error_typebase::>: invalid comparison with complex values
.maybe_is_proper_soft_partition.pclust("x" = list("m" = complex(real = 0, imaginary = 0), quote(f(x))))error_typebase::>: invalid comparison with complex values
source
.maybe_is_proper_soft_partition.pclust <-
function(x)
    x$m > 1
R/partition.R:613
R/objects.R

n_of_objects untypeabletyped

unbound variable (line 7)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
n_of_objects <-
function(x)
    UseMethod("n_of_objects")
R/objects.R:5

n_of_objects.default untypeabletyped

unbound variable (line 13)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.002 s
source
n_of_objects.default <-
function(x)
    length(cl_class_ids(x))
R/objects.R:11

n_of_objects.kmeans untypeabletyped

unbound variable (line 22)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.kmeans <- n_of_objects.default
R/objects.R:22

n_of_objects.partition untypeabletyped

unbound variable (line 26)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.partition <- n_of_objects.default
R/objects.R:26

n_of_objects.cclust untypeabletyped

unbound variable (line 29)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.cclust <- n_of_objects.default
R/objects.R:29

n_of_objects.fclust typed accepts outside

((x: { membership: any, any }) -> INT1<> | null)<>
timing: 0.030 s
fuzzing: 8 inside (8 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:nulln_of_objects.fclust(NULL)null
source
n_of_objects.fclust <-
function(x)
    nrow(x$membership)
R/objects.R:32

n_of_objects.cshell typed accepts outside

((x: { membership: any, any }) -> INT1<> | null)<>
timing: 0.011 s
fuzzing: 8 inside (8 ok) · 8 outside (6 rejected, 2 accepted)

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:langn_of_objects.cshell("x" = quote(f(x)))null
xunwrapn_of_objects.cshell("x" = NULL)null
source
n_of_objects.cshell <- n_of_objects.fclust
R/objects.R:36

n_of_objects.bclust untypeabletyped

unbound variable (line 38)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.bclust <- n_of_objects.default
R/objects.R:38

n_of_objects.Mclust untypeabletyped

unbound variable (line 41)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.Mclust <- n_of_objects.default
R/objects.R:41

n_of_objects.hclust typed accepts outside

((x: { order: any, any }) -> INT1<>)<>
timing: 0.030 s
fuzzing: 8 inside (8 ok) · 4 outside (2 rejected, 2 accepted)

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:envn_of_objects.hclust(new.env())0L<> with { }
xkind:nulln_of_objects.hclust("x" = NULL)0L<> with { }
source
n_of_objects.hclust <-
function(x)
    length(x$order)
R/objects.R:46

n_of_objects.twins typed accepts outside

((x: { order: any, any }) -> INT1<>)<>
timing: 0.010 s
fuzzing: 8 inside (8 ok) · 6 outside (4 rejected, 2 accepted)

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:envn_of_objects.twins("x" = new.env())0L<> with { }
xkind:langn_of_objects.twins("x" = quote(f(x)))0L<> with { }
source
n_of_objects.twins <- n_of_objects.hclust
R/objects.R:52

n_of_objects.mona typed accepts outside

((x: { order: any, any }) -> INT1<>)<>
timing: 0.010 s
fuzzing: 8 inside (8 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:langn_of_objects.mona("x" = quote(f(x)))0L<> with { }
source
n_of_objects.mona <- n_of_objects.hclust
R/objects.R:54

n_of_objects.phylo typed accepts outside

((x: { tip.label: any, any }) -> INT1<>)<>
timing: 0.030 s
fuzzing: 8 inside (8 ok) · 8 outside (6 rejected, 2 accepted)

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:envn_of_objects.phylo("x" = new.env())0L<> with { }
xunwrapn_of_objects.phylo(list())0L<> with { }
source
n_of_objects.phylo <-
function(x)
    length(x$tip.label)
R/objects.R:57

n_of_objects.dist typed accepts outside

∀'a. ((x: any with { Size: 'a, any }) -> 'a)<>
timing: 0.027 s
fuzzing: 20 inside (20 ok) · 8 outside (4 rejected, 4 accepted)
type drawn from: ((x: any with { Size: 'I12893, any }) -> 'I12893)<>

Accepted outside the domain x: 4

parameterchangecallreturned
xattr:drop:Sizen_of_objects.dist(new.env())null
xattr:drop:Sizen_of_objects.dist("x" = list(as.name("x"), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p })))null
xattr:drop:Sizen_of_objects.dist("x" = quote(f(x)))null
xkind:chrn_of_objects.dist("x" = "fuzz")null
source
n_of_objects.dist <-
function(x)
    attr(x, "Size")
R/objects.R:64

n_of_objects.cl_ensemble typed accepts outside

∀'a. ((x: any with { n_of_objects: 'a, any }) -> 'a)<>
timing: 0.025 s
fuzzing: 20 inside (20 ok) · 8 outside (1 rejected, 7 accepted)
type drawn from: ((x: any with { n_of_objects: 'I12901, any }) -> 'I12901)<>

Accepted outside the domain x: 7

parameterchangecallreturned
xkind:dbln_of_objects.cl_ensemble(1.5)null
xkind:listn_of_objects.cl_ensemble("x" = list())null
xkind:nulln_of_objects.cl_ensemble(NULL)null
xkind:nulln_of_objects.cl_ensemble("x" = NULL)null
xkind:symn_of_objects.cl_ensemble(as.name("x"))null
xwrapn_of_objects.cl_ensemble("x" = list(structure(quote(f(x)), "n_of_objects" = -2147483647)))null
and 1 more
source
n_of_objects.cl_ensemble <-
function(x)
    attr(x, "n_of_objects")
R/objects.R:69

n_of_objects.cl_membership typed any: x fuzz ok

(x: any) -> INT1<> | null
timing: 0.008 s
fuzzing: 7 inside (7 ok) · 8 outside (8 rejected)
source
n_of_objects.cl_membership <- nrow
R/objects.R:73

n_of_objects.pclust untypeabletyped

unbound variable (line 75)
unbound: n_of_objects.default — one of the package’s own names, itself untyped
error detail
name: n_of_objects.default
gradual mode: typed
((x: any) -> INT1<>)<>
timing: 0.000 s
source
n_of_objects.pclust <- n_of_objects.default
R/objects.R:75

n_of_objects.cl_ultrametric typed accepts outside

∀'a. ((x: any with { Size: 'a, any }) -> 'a)<>
timing: 0.007 s
fuzzing: 20 inside (20 ok) · 8 outside (1 rejected, 7 accepted)
type drawn from: ((x: any with { Size: 'I12905, any }) -> 'I12905)<>

Accepted outside the domain x: 7

parameterchangecallreturned
xattr:drop:Sizen_of_objects.cl_ultrametric("x" = as.raw(c(0, 255)))null
xattr:drop:Sizen_of_objects.cl_ultrametric("x" = quote(f(x)))null
xkind:chrn_of_objects.cl_ultrametric("fuzz")null
xkind:chrn_of_objects.cl_ultrametric("x" = "fuzz")null
xkind:nulln_of_objects.cl_ultrametric(NULL)null
xkind:symn_of_objects.cl_ultrametric(as.name("x"))null
and 1 more
source
n_of_objects.cl_ultrametric <- n_of_objects.dist
R/objects.R:77

n_of_objects.cl_partition untypeabletyped

unbound variable (line 81)
unbound: .get_property_from_object_or_representation — one of the package’s own names, itself untyped
error detail
name: .get_property_from_object_or_representation
gradual mode: typed
((x: any) -> any)<>
timing: 0.003 s
source
n_of_objects.cl_partition <-
function(x)
    .get_property_from_object_or_representation(x, "n_of_objects")
R/objects.R:79

n_of_objects.cl_hierarchy untypeabletyped

unbound variable (line 85)
unbound: .get_property_from_object_or_representation — one of the package’s own names, itself untyped
error detail
name: .get_property_from_object_or_representation
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
n_of_objects.cl_hierarchy <-
function(x)
    .get_property_from_object_or_representation(x, "n_of_objects")
R/objects.R:83

cl_object_names untypeabletyped

unbound variable (line 96)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_object_names <- 
function(x)
    UseMethod("cl_object_names")
R/objects.R:94

cl_object_names.default untypeabletyped

unbound variable (line 100)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any) -> CHR<> | null)<>
timing: 0.002 s
source
cl_object_names.default <- function(x) names(cl_class_ids(x))
R/objects.R:100

cl_object_names.hclust typed accepts outside

∀'a. ((x: { labels: 'a, any }) -> 'a)<>
timing: 0.019 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { labels: 'I12931, any }) -> 'I12931)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:envcl_object_names.hclust(new.env())null
xkind:nullcl_object_names.hclust(NULL)null
source
cl_object_names.hclust <- function(x) x$labels
R/objects.R:122

cl_object_names.twins typed accepts outside

((x: { order.lab: null, any }) -> null)<>
timing: 0.066 s
fuzzing: 7 inside (7 ok) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain x: 4

parameterchangecallreturned
xkind:envcl_object_names.twins("x" = new.env())null
xkind:nullcl_object_names.twins(NULL)null
xunwrapcl_object_names.twins("x" = NULL)null
xwrapcl_object_names.twins("x" = list(list("order.lab" = NULL, NULL, quote(f(x)))))null
source
cl_object_names.twins <-
function(x)
{
    if(!is.null(x$order.lab)) {
        out <- character(length = n_of_objects(x))
        out[x$order] <- x$order.lab
        out
    }
    else
        NULL
}
R/objects.R:129

cl_object_names.mona typed accepts outside

((x: { order.lab: null, any }) -> null)<>
timing: 0.005 s
fuzzing: 5 inside (5 ok) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain x: 4

parameterchangecallreturned
xwrapcl_object_names.mona(list(list("order.lab" = NULL)))null
xwrapcl_object_names.mona("x" = list(list("order.lab" = NULL)))null
xwrapcl_object_names.mona("x" = list(list("order.lab" = NULL, c(FALSE, FALSE))))null
xwrapcl_object_names.mona(list(list("order.lab" = NULL, new.env(), NULL)))null
source
cl_object_names.mona <- cl_object_names.twins
R/objects.R:140

cl_object_names.phylo typed accepts outside

∀'a. ((x: { tip.label: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { tip.label: 'I12964, any }) -> 'I12964)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:envcl_object_names.phylo("x" = new.env())null
source
cl_object_names.phylo <-
function(x)
    x$tip.label
R/objects.R:143

cl_object_names.dist typed accepts outside

∀'a. ((x: any with { Labels: 'a, any }) -> 'a)<>
timing: 0.021 s
fuzzing: 20 inside (20 ok) · 8 outside (1 rejected, 7 accepted)
type drawn from: ((x: any with { Labels: 'I12972, any }) -> 'I12972)<>

Accepted outside the domain x: 7

parameterchangecallreturned
xattr:drop:Labelscl_object_names.dist(new.env())null
xattr:drop:Labelscl_object_names.dist("x" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))null
xkind:funcl_object_names.dist(function(...) NULL)null
xkind:langcl_object_names.dist("x" = quote(f(x)))null
xkind:nullcl_object_names.dist("x" = NULL)null
xwrapcl_object_names.dist("x" = list(structure(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "Labels" = c(-2147483647, 0.5))))null
and 1 more
source
cl_object_names.dist <-
function(x)
    attr(x, "Labels")
R/objects.R:151

cl_object_names.cl_membership untypeabletyped

unbound variable (line 158)
unbound: rownames — a name the prelude does not declare
error detail
name: rownames
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_object_names.cl_membership <-
function(x)
    rownames(x)
R/objects.R:156

cl_object_names.cl_ultrametric typed accepts outside

∀'a. ((x: any with { Labels: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (3 rejected, 5 accepted)
type drawn from: ((x: any with { Labels: 'I12984, any }) -> 'I12984)<>

Accepted outside the domain x: 5

parameterchangecallreturned
xattr:drop:Labelscl_object_names.cl_ultrametric("x" = complex(0))null
xattr:drop:Labelscl_object_names.cl_ultrametric("x" = c(NA, FALSE))null
xkind:chrcl_object_names.cl_ultrametric("x" = "fuzz")null
xkind:listcl_object_names.cl_ultrametric(list())null
xwrapcl_object_names.cl_ultrametric("x" = list(structure(as.raw(c(255)), "Labels" = "")))null
source
cl_object_names.cl_ultrametric <-
function(x)
    attr(x, "Labels")
R/objects.R:160

cl_object_names.cl_partition untypeabletyped

unbound variable (line 166)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.009 s
source
cl_object_names.cl_partition <-
function(x)
    cl_object_names(.get_representation(x))
R/objects.R:164

cl_object_names.cl_hierarchy untypeabletyped

unbound variable (line 170)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
gradual mode: typed
((x: { .Data: any, any }) -> any)<>
timing: 0.009 s
source
cl_object_names.cl_hierarchy <-
function(x)
    cl_object_names(.get_representation(x))
R/objects.R:168

cl_object_names.cl_ensemble untypeabletyped

unbound variable (line 175)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
gradual mode: typed
((x: list) | (x: vec) -> any)<>
timing: 0.007 s
source
cl_object_names.cl_ensemble <-
function(x)
{
    nms <- lapply(x, cl_object_names)
    ind <- which(lengths(nms) > 0L)
    if(any(ind)) nms[[ind[1L]]] else NULL
}
R/objects.R:172

cl_object_labels untypeable

unbound variable (line 185)
unbound: cl_object_names — one of the package’s own names, itself untyped
error detail
name: cl_object_names
timing: 0.007 s
source
cl_object_labels <-
function(x)
{
    if(is.null(out <- cl_object_names(x)))
        out <- as.character(seq_len(n_of_objects(x)))
    out
}
R/objects.R:182

cl_object_dissimilarities untypeabletyped

unbound variable (line 200)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }) -> any)<>
timing: 0.007 s
source
cl_object_dissimilarities <-
function(x)
{
    ## Keep this in sync with .has_object_dissimilarities().
    if(is.cl_dendrogram(x))
        cl_ultrametric(x)
    else if(inherits(x, "dist"))
        x
    else
        stop("Cannot extract object dissimilarities")
}
R/objects.R:196

.has_object_dissimilarities untypeabletyped

unbound variable (line 212)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
gradual mode: typed
((x: any) -> ff<> | tt<>)<>
timing: 0.003 s
source
.has_object_dissimilarities <-
function(x)
{
    ## Keep this in sync with cl_object_dissimilarities().
    is.cl_dendrogram(x) || inherits(x, "dist")
}
R/objects.R:208
R/classes.R

cl_classes untypeabletyped

unbound variable (line 3)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_classes <-
function(x)
    UseMethod("cl_classes")
R/classes.R:1

cl_classes.default untypeabletyped

unbound variable (line 9)
unbound: is.cl_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_partition
gradual mode: typed
((x: any) -> any)<>
timing: 0.005 s
source
cl_classes.default <-
function(x)
{
    ## Be nice to users ...
    if(is.cl_partition(x))
        cl_classes(as.cl_partition(x))
    else if(is.cl_dendrogram(x))
        cl_classes(as.cl_dendrogram(x))
    else
        stop("Can only determine classes of partitions or hierarchies.")
}
R/classes.R:5

cl_classes.cl_partition untypeable

unbound variable (line 20)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
timing: 0.005 s
source
cl_classes.cl_partition <-
function(x)
{
    n <- n_of_objects(x)
    out <- split(seq_len(n), cl_class_ids(x))
    class(out) <- c("cl_classes_of_partition_of_objects",
                    "cl_classes_of_objects")
    attr(out, "n_of_objects") <- n
    attr(out, "labels") <- cl_object_labels(x)
    out
}
R/classes.R:17

cl_classes.cl_hierarchy untypeabletyped

unbound variable (line 33)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((x: any) -> any)<>
timing: 0.015 s
source
cl_classes.cl_hierarchy <-
function(x)
{
    ## Assume a valid hierarchy/dendrogram.
    x <- as.hclust(x)
    n <- n_of_objects(x)
    labels <- seq_len(n)
    ## Only use the "maximal" partitions for each height (relevant in
    ## case of non-binary trees).
    groups <- cutree(x, h = unique(c(0, x$height)))
    ## Give a list with the (unique) sets of numbers of the objects.
    ## Note that objects may already be merged at height zero.
    out <- unique(unlist(c(as.list(labels),
                           lapply(split(groups, col(groups)),
                                  function(k) split(labels, k))),
                         recursive = FALSE,
                         use.names = FALSE))
    ## Preserve labels if possible, and re-order according to
    ## cardinality.
    out <- out[order(lengths(out))]
    class(out) <- c("cl_classes_of_hierarchy_of_objects",
                    "cl_classes_of_objects")
    attr(out, "n_of_objects") <- n
    attr(out, "labels") <- cl_object_labels(x)
    out
}
R/classes.R:29

cl_classes.cl_ultrametric untypeabletyped

unbound variable (line 58)
unbound: cl_classes.cl_hierarchy — one of the package’s own names, itself untyped
error detail
name: cl_classes.cl_hierarchy
gradual mode: typed
((x: any) -> any)<>
timing: 0.000 s
source
cl_classes.cl_ultrametric <- cl_classes.cl_hierarchy
R/classes.R:58

print.cl_classes_of_partition_of_objects untypeabletyped

unbound variable (line 65)
unbound: formatDL — a name the prelude does not declare
error detail
name: formatDL
gradual mode: typed
∀'a. (((x: 'a & (CHR | DBL | INT | LGL | RAW) with { labels: list<~@"[", ...>, any }, ...: any) | (x: 'a & (CHR | DBL | INT | LGL | RAW) with { labels: vec<~@"[", ...>, any }, ...: any) | (x: 'a & list with { labels: <@"[", ...>, any }, ...: any) | (x: 'a & vec with { labels: <@"[", ...>, any }, ...: any) | (x: 'a & { CHR | DBL | INT | LGL | RAW } with { labels: list<~@"[", ...>, any }, ...: any) | (x: 'a & { CHR | DBL | INT | LGL | RAW } with { labels: vec<~@"[", ...>, any }, ...: any) -> 'a) & ((x: 'a & { } with { labels: <@"[", ...>, any }, ...: any) | (x: 'a & { } with { labels: list<~@"[", ...>, any }, ...: any) | (x: 'a & { } with { labels: vec<~@"[", ...>, any }, ...: any) -> empty))<>
timing: 1.05 s
source
print.cl_classes_of_partition_of_objects <-
function(x, ...)
{
    labels <- attr(x, "labels")
    y <- lapply(x, function(i) paste(labels[i], collapse = ", "))
    writeLines(formatDL(names(x), sprintf("{%s}", unlist(y)),
                        style = "list", ...))
    invisible(x)
}
R/classes.R:60

print.cl_classes_of_hierarchy_of_objects untypeabletyped

unbound variable (line 75)
unbound: strwrap — a name the prelude does not declare
error detail
name: strwrap
gradual mode: typed
∀'a. (((x: 'a & (CHR | DBL | INT | LGL | RAW) with { labels: list<~@"[", ...>, any }, ...: any) | (x: 'a & (CHR | DBL | INT | LGL | RAW) with { labels: vec<~@"[", ...>, any }, ...: any) | (x: 'a & list with { labels: <@"[", ...>, any }, ...: any) | (x: 'a & vec with { labels: <@"[", ...>, any }, ...: any) | (x: 'a & { CHR | DBL | INT | LGL | RAW } with { labels: list<~@"[", ...>, any }, ...: any) | (x: 'a & { CHR | DBL | INT | LGL | RAW } with { labels: vec<~@"[", ...>, any }, ...: any) -> 'a) & ((x: 'a & { } with { labels: <@"[", ...>, any }, ...: any) | (x: 'a & { } with { labels: list<~@"[", ...>, any }, ...: any) | (x: 'a & { } with { labels: vec<~@"[", ...>, any }, ...: any) -> empty))<>
timing: 0.692 s
source
print.cl_classes_of_hierarchy_of_objects <-
function(x, ...)
{
    labels <- attr(x, "labels")
    y <- lapply(x, function(i) paste(labels[i], collapse = ", "))
    y <- strwrap(sprintf("{%s},", unlist(y)), exdent = 2)
    y[length(y)] <- sub(",$", "", y[length(y)])
    writeLines(y)
    invisible(x)
}
R/classes.R:70
R/hierarchy.R

is.cl_hierarchy untypeabletyped

unbound variable (line 16)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_hierarchy <-
function(x)
    UseMethod("is.cl_hierarchy")
R/hierarchy.R:14

is.cl_hierarchy.default typed any: x accepts outside

((x: any) -> ff<>)<>
timing: 0.004 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hierarchy.default()ff<> with { }
source
is.cl_hierarchy.default <- .false
R/hierarchy.R:19

is.cl_hierarchy.hclust untypeabletyped

unbound variable (line 24)
unbound: is.unsorted — a name the prelude does not declare
error detail
name: is.unsorted
gradual mode: typed
((x: { height: any, any }) -> any)<>
timing: 0.014 s
source
is.cl_hierarchy.hclust <-
function(x)
    !is.unsorted(x$height)
R/hierarchy.R:22

is.cl_hierarchy.twins typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.004 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hierarchy.twins()tt<> with { }
source
is.cl_hierarchy.twins <- .true
R/hierarchy.R:28

is.cl_hierarchy.mona typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hierarchy.mona()tt<> with { }
source
is.cl_hierarchy.mona <- .true
R/hierarchy.R:30

is.cl_hierarchy.phylo untypeabletyped

unbound variable (line 35)
unbound: ape::is.ultrametric — a name the prelude does not declare
error detail
name: ape::is.ultrametric
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_hierarchy.phylo <-
function(x)
    ape::is.ultrametric(x)
R/hierarchy.R:33

is.cl_hierarchy.cl_hierarchy typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 5 inside (5 ok) · 6 outside (5 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_hierarchy.cl_hierarchy()tt<> with { }
source
is.cl_hierarchy.cl_hierarchy <- .true
R/hierarchy.R:44

.cl_hierarchy_classes typed

"cl_hierarchy"<>
timing: 0.003 s
source
.cl_hierarchy_classes <- "cl_hierarchy"
R/hierarchy.R:51

as.cl_hierarchy untypeabletyped

unbound variable (line 56)
unbound: is.cl_hierarchy — one of the package’s own names, itself untyped
error detail
name: is.cl_hierarchy
gradual mode: typed
((x: any) -> any)<>
timing: 0.024 s
source
as.cl_hierarchy <-
function(x)
{
    if(is.cl_hierarchy(x)) {
        if(!inherits(x, "cl_hierarchy"))
            .make_container(x, .cl_hierarchy_classes)
        else
            x
    }
    else
        .make_container(as.cl_ultrametric(x),
                        .cl_hierarchy_classes)
}
R/hierarchy.R:53

print.cl_hierarchy untypeabletyped

unbound variable (line 71)
unbound: .print_container — one of the package’s own names, itself untyped
error detail
name: .print_container
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_hierarchy <-
function(x, ...)
    .print_container(x, "cl_hierarchy", ...)
R/hierarchy.R:69

Complex.cl_hierarchy untypeabletyped

unbound variable (line 79)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((z: any) -> empty)<>
timing: 0.002 s
source
Complex.cl_hierarchy <-
function(z)
    stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                  .Generic, .Class),
         domain = NA)
R/hierarchy.R:76

Math.cl_hierarchy untypeabletyped

unbound variable (line 88)
unbound: .Generic — a name the prelude does not declare
error detail
name: .Generic
gradual mode: typed
((x: any, ...: any) -> empty)<>
timing: 0.003 s
source
Math.cl_hierarchy <-
function(x, ...)
    stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                  .Generic, .Class),
         domain = NA)
R/hierarchy.R:85

Ops.cl_hierarchy untypeabletyped

unbound variable (line 96)
unbound: nargs — a name the prelude does not declare
error detail
name: nargs
gradual mode: typed
((e1: any, e2: any) -> any)<>
timing: 0.044 s
source
Ops.cl_hierarchy <-
function(e1, e2)
{
    if(nargs() == 1L)
        stop(gettextf("Unary '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)

    ## Only comparisons are supprorted.
    if(!(as.character(.Generic) %in% c("<", "<=", ">", ">=",
                                       "==", "!=")))
        stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)

    if(n_of_objects(e1) != n_of_objects(e2))
        stop("Hierarchies must have the same number of objects.")

    c1 <- cl_classes(e1)
    c2 <- cl_classes(e2)

    switch(.Generic,
           "<=" = all(is.finite(match(c1, c2))),
           "<"  = all(is.finite(match(c1, c2))) && any(is.na(match(c2, c1))),
           ">=" = all(is.finite(match(c2, c1))),
           ">"  = all(is.finite(match(c2, c1))) && any(is.na(match(c1, c2))),
           "==" = all(is.finite(match(c1, c2))) && all(is.finite(match(c2, c1))),
           "!=" = any(is.na(match(c1, c2))) || any(is.na(match(c2, c1))))
}
R/hierarchy.R:93

Summary.cl_hierarchy skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.003 s
source
Summary.cl_hierarchy <-
function(..., na.rm = FALSE)
{
    ok <- switch(.Generic, max = , min = , range = TRUE, FALSE)
    if(!ok)
        stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)
    args <- list(...)
    switch(.Generic,
           "min" = cl_meet(cl_ensemble(list = args)),
           "max" = cl_join(cl_ensemble(list = args)),
           "range" = {
               cl_ensemble(min = cl_meet(cl_ensemble(list = args)),
                           max = cl_join(cl_ensemble(list = args)))
           })
}
R/hierarchy.R:129

as.hclust.cl_hierarchy untypeabletyped

unbound variable (line 151)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((x: { .Data: any, any }, ...: any) -> any)<>
timing: 0.012 s
source
as.hclust.cl_hierarchy <-
function(x, ...)
    as.hclust(.get_representation(x), ...)
R/hierarchy.R:149

is.cl_dendrogram untypeabletyped

unbound variable (line 165)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_dendrogram <-
function(x)
    UseMethod("is.cl_dendrogram")
R/hierarchy.R:163

is.cl_dendrogram.default typed any: x accepts outside

((x: any) -> ff<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 5 outside (4 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_dendrogram.default()ff<> with { }
source
is.cl_dendrogram.default <- .false
R/hierarchy.R:167

is.cl_dendrogram.hclust untypeabletyped

unbound variable (line 171)
unbound: is.unsorted — a name the prelude does not declare
error detail
name: is.unsorted
gradual mode: typed
((x: { height: any, any }) -> any)<>
timing: 0.013 s
source
is.cl_dendrogram.hclust <-
function(x)
    !is.unsorted(x$height)
R/hierarchy.R:169

is.cl_dendrogram.twins typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 6 inside (6 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_dendrogram.twins()tt<> with { }
source
is.cl_dendrogram.twins <- .true
R/hierarchy.R:174

is.cl_dendrogram.mona typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 8 inside (8 ok) · 4 outside (3 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_dendrogram.mona()tt<> with { }
source
is.cl_dendrogram.mona <- .true
R/hierarchy.R:176

is.cl_dendrogram.phylo untypeabletyped

unbound variable (line 180)
unbound: ape::is.ultrametric — a name the prelude does not declare
error detail
name: ape::is.ultrametric
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
is.cl_dendrogram.phylo <-
function(x)
    ape::is.ultrametric(x)
R/hierarchy.R:178

is.cl_dendrogram.cl_dendrogram typed any: x accepts outside

((x: any) -> tt<>)<>
timing: 0.005 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xdropis.cl_dendrogram.cl_dendrogram()tt<> with { }
source
is.cl_dendrogram.cl_dendrogram <- .true
R/hierarchy.R:184

.cl_dendrogram_classes typed

CHR<>
timing: 0.016 s
source
.cl_dendrogram_classes <- c("cl_dendrogram", "cl_hierarchy")
R/hierarchy.R:188

as.cl_dendrogram untypeabletyped

unbound variable (line 193)
unbound: is.cl_dendrogram — one of the package’s own names, itself untyped
error detail
name: is.cl_dendrogram
gradual mode: typed
((x: any) -> any)<>
timing: 0.025 s
source
as.cl_dendrogram <-
function(x)
{
    if(is.cl_dendrogram(x)) {
        if(!inherits(x, "cl_dendrogram"))
            .make_container(x, .cl_dendrogram_classes)
        else
            x
    }
    else
        .make_container(as.cl_ultrametric(x),
                        .cl_dendrogram_classes)
}
R/hierarchy.R:190

print.cl_dendrogram untypeabletyped

unbound variable (line 208)
unbound: .print_container — one of the package’s own names, itself untyped
error detail
name: .print_container
gradual mode: typed
∀'a. ((x: 'a & { .Data: any, any }, ...: any) -> 'a)<>
timing: 0.004 s
source
print.cl_dendrogram <-
function(x, ...)
    .print_container(x, "cl_dendrogram", ...)
R/hierarchy.R:206

plot.cl_dendrogram untypeabletyped

unbound variable (line 214)
unbound: cl_ultrametric — one of the package’s own names, itself untyped
error detail
name: cl_ultrametric
gradual mode: typed
((x: { .Data: { .Data: any, any } with { Labels: null, any }, any }, ...: any) -> any)<>
timing: 0.012 s
source
plot.cl_dendrogram <-
function(x, ...)
    plot(cl_ultrametric(.get_representation(x)), ...)
R/hierarchy.R:212

Ops.cl_dendrogram untypeable

unbound variable (line 221)
unbound: nargs — a name the prelude does not declare
error detail
name: nargs
timing: 0.036 s
source
Ops.cl_dendrogram <-
function(e1, e2)
{
    if(nargs() == 1L)
        stop(gettextf("Unary '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)

    ## Only comparisons are supprorted.
    if(!(as.character(.Generic) %in% c("<", "<=", ">", ">=",
                                       "==", "!=")))
        stop(gettextf("Generic '%s' not defined for \"%s\" objects.",
                      .Generic, .Class),
             domain = NA)

    u1 <- cl_ultrametric(e1)
    u2 <- cl_ultrametric(e2)
    if(length(u1) != length(u2))
        stop("Dendrograms must have the same number of objects.")
    switch(.Generic,
           "<=" = all(u1 <= u2),
           "<"  = all(u1 <= u2) && any(u1 < u2),
           ">=" = all(u1 >= u2),
           ">"  = all(u1 >= u2) && any(u1 > u2),
           "==" = all(u1 == u2),
           "!=" = any(u1 != u2))
}
R/hierarchy.R:218

cut.cl_dendrogram untypeabletyped

unbound variable (line 293)
unbound: as.hclust — a name the prelude does not declare
error detail
name: as.hclust
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
cut.cl_dendrogram <-
function(x, ...)
    cutree(as.hclust(x), ...)
R/hierarchy.R:291

cophenetic.mona skipped

error detail
File "Rsem/lang/PAst.ml", line 210, characters 14-20: Assertion failed
timing: 0.000 s
source
cophenetic.mona <-
function(x)
{
    no <- length(x$order)
    ns <- max(x$step) + 1

    m <- matrix(NA, no, no)
    FOO <- function(ind, step, s) {
        if(length(ind) <= 1) return()
        grp <- c(0, cumsum(step == s))
        ind <- split(ind, grp)
        len <- length(ind)
        for(a in seq_len(len)) {
            for(b in seq_len(a - 1L)) {
                ## Need both as we currently cannot assume that the
                ## indices are sorted.  Alternatively, work with the
                ## sequence from one to the number of objects, and
                ## reorder at the end ...
                m[ind[[a]], ind[[b]]] <<- s
                m[ind[[b]], ind[[a]]] <<- s
            }
        }
        ind <- ind[lengths(ind) > 1L]
        pos <- which(step == s)
        step <- split(step[-pos], grp[-1][-pos])
        if(is.null(step)) return()
        for(a in seq_along(ind))
            FOO(ind[[a]], step[[a]], s + 1)
    }
    
    FOO(x$order, x$step, 1)
    m[is.na(m)] <- ns
    m <- ns - m
    rownames(m) <- rownames(x$data)
    as.dist(m)
}
R/hierarchy.R:300

as.hclust.mona untypeabletyped

unbound variable (line 342)
unbound: cophenetic — a name the prelude does not declare
error detail
name: cophenetic
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
as.hclust.mona <-
function(x, ...)
    hclust(cophenetic(x), "single")
R/hierarchy.R:340
R/addtree.R

.cl_addtree_from_veclh untypeabletyped

unbound variable (line 374)
unbound: cl_proximity — one of the package’s own names, itself untyped
error detail
name: cl_proximity
gradual mode: typed
((x: any, size: any?, labels: any?) -> any)<>
timing: 0.028 s
source
.cl_addtree_from_veclh <-
function(x, size = NULL, labels = NULL)
{
    cl_proximity(x, "Additive tree distances",
                 labels = labels, size = size,
                 class = c("cl_addtree", "cl_dissimilarity",
                 "cl_proximity", "dist"))
}
R/addtree.R:371

.non_additivity untypeable

unbound variable (line 290)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
timing: 0.039 s
source
.non_additivity <-
function(x, max = FALSE)
{
    if(!is.matrix(x))
        x <- .symmetric_matrix_from_veclh(x)
    .C(C_deviation_from_additivity,
       as.double(x),
       as.integer(nrow(x)),
       fn = double(1L),
       as.logical(max))$fn
}
R/addtree.R:286

.cl_addtree_from_addtree_approximation untypeabletyped

unbound variable (line 387)
unbound: .non_additivity — one of the package’s own names, itself untyped
error detail
name: .non_additivity
gradual mode: typed
((x: any, size: any?, labels: any?) -> any)<>
timing: 0.015 s
source
.cl_addtree_from_addtree_approximation <-
function(x, size = NULL, labels = NULL)
{
    ## Turn x into an addtree after possibly rounding to non-additivity
    ## significance (note that this is not guaranteed to work ...).
    mnum <- .non_additivity(x, max = TRUE)
    x <- round(x, floor(abs(log10(mnum))))
    .cl_addtree_from_veclh(x, size = size, labels = labels)
}
R/addtree.R:382

.make_penalty_function_addtree untypeabletyped

unbound variable (line 113)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: any) -> ((d: any) -> any)<>)<>
timing: 0.011 s
source
.make_penalty_function_addtree <-
function(n)
    function(d) {
        (.non_additivity(.symmetric_matrix_from_veclh(d, n))
         + sum(pmin(d, 0) ^ 2))
    }
R/addtree.R:110

.make_penalty_gradient_addtree untypeabletyped

unbound variable (line 121)
unbound: .symmetric_matrix_from_veclh — one of the package’s own names, itself untyped
error detail
name: .symmetric_matrix_from_veclh
gradual mode: typed
((n: dbl1<~@"*", ...>) -> ((d: any) -> any)<>)<>
timing: 0.020 s
source
.make_penalty_gradient_addtree <-
function(n)
    function(d) {
        gr <- matrix(.C(C_deviation_from_additivity_gradient,
                        as.double(.symmetric_matrix_from_veclh(d, n)),
                        as.integer(n),
                        gr = double(n * n))$gr,
                     n, n)
        gr[row(gr) > col(gr)] + 2 * sum(pmin(d, 0))
    }
R/addtree.R:117

.ls_fit_addtree_by_SUMT untypeable

untypeable application of base::$ (line 50)
error detail
argument: @({  }<> | 'control, "gradient"<>)
failing call: base::$(list(), "gradient")
timing: 0.163 s
source
.ls_fit_addtree_by_SUMT <-
function(x, weights = 1, control = list())
{
    ## Control parameters:
    ## gradient,
    gradient <- control$gradient
    if(is.null(gradient))
        gradient <- TRUE
    ## nruns,
    nruns <- control$nruns
    ## start,
    start <- control$start

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
    } else if(is.null(nruns)) {
        ## Use nruns only if start is not given.
        nruns <- 1L
    }

    w <- weights / sum(weights)
    n <- attr(x, "Size")
    labels <- attr(x, "Labels")    

    ## Handle missing values in x along the lines of de Soete (1984):
    ## set the corresponding weights to 0, and impute by the weighted
    ## mean.
    ind <- which(is.na(x))
    if(any(ind)) {
        w[ind] <- 0
        x[ind] <- weighted.mean(x, w, na.rm = TRUE)
    }

    L <- function(d) sum(w * (d - x) ^ 2)
    P <- .make_penalty_function_addtree(n)
    if(gradient) {
        grad_L <- function(d) 2 * w * (d - x)
        grad_P <- .make_penalty_gradient_addtree(n)
    }
    else {
        grad_L <- grad_P <- NULL
    }

    if(is.null(start)) {
        ## Initialize by "random shaking".  Use sd() for simplicity.
        start <- replicate(nruns,  
                           x + rnorm(length(x), sd = sd(x) / sqrt(3)),
                           simplify = FALSE)
    }

    ## And now ...
    d <- sumt(start, L, P, grad_L, grad_P,
              method = control$method, eps = control$eps,
              q = control$q, verbose = control$verbose,
              control = as.list(control$control))$x

    ## Round to enforce additivity, and hope for the best ...
    .cl_addtree_from_addtree_approximation(d, n, labels)    

}
R/addtree.R:45

.ls_fit_addtree_by_iterative_projection untypeable

unbound variable (line 143)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.193 s
source
.ls_fit_addtree_by_iterative_projection <-
function(x, weights = 1, control = list())
{
    if(any(diff(weights)))
        warning("Non-identical weights currently not supported.")

    labels <- attr(x, "Labels")
    x <- as.matrix(x)
    n <- nrow(x)

    ## Control parameters:
    ## maxiter,
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 10000L
    ## nruns,
    nruns <- control$nruns
    ## order,
    order <- control$order
    ## tol,
    tol <- control$tol
    if(is.null(tol))
        tol <- 1e-8
    ## verbose.
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    ## Handle order and nruns.
    if(!is.null(order)) {
        if(!is.list(order))
            order <- as.list(order)
        if(!all(vapply(order,
                       function(o) all(sort(o) == seq_len(n)),
                       NA)))
            stop("All given orders must be valid permutations.")
    }
    else {
        if(is.null(nruns))
            nruns <- 1L
        order <- replicate(nruns, sample(n), simplify = FALSE)
    }

    ind <- lower.tri(x)
    L <- function(d) sum(weights * (x - d)[ind] ^ 2)

    d_opt <- NULL
    v_opt <- Inf
    for(run in seq_along(order)) {
        if(verbose)
            message(gettextf("Iterative projection run: %d", run))
        d <- .C(C_ls_fit_addtree_by_iterative_projection,
                as.double(x),
                as.integer(n),
                as.integer(order[[run]] - 1L),
                as.integer(maxiter),
                iter = integer(1L),
                as.double(tol),
                as.logical(verbose))[[1L]]
        v <- L(d)
        if(v < v_opt) {
            v_opt <- v
            d_opt <- d
        }
    }

    d <- matrix(d_opt, n)
    dimnames(d) <- list(labels, labels)
    .cl_addtree_from_addtree_approximation(as.dist(d))
}
R/addtree.R:140

.ls_fit_addtree_by_iterative_reduction untypeable

unbound variable (line 216)
unbound: diff — a name the prelude does not declare
error detail
name: diff
timing: 0.181 s
source
.ls_fit_addtree_by_iterative_reduction <-
function(x, weights = 1, control = list())
{
    if(any(diff(weights)))
        warning("Non-identical weights currently not supported.")

    labels <- attr(x, "Labels")
    x <- as.matrix(x)
    n <- nrow(x)

    ## Control parameters:
    ## maxiter,
    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 10000L
    ## nruns,
    nruns <- control$nruns
    ## order,
    order <- control$order
    ## tol,
    tol <- control$tol
    if(is.null(tol))
        tol <- 1e-8
    ## verbose.
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")

    ## Handle order and nruns.
    if(!is.null(order)) {
        if(!is.list(order))
            order <- as.list(order)
        if(!all(vapply(order,
                       function(o) all(sort(o) == seq_len(n)),
                       NA)))
            stop("All given orders must be valid permutations.")
    }
    else {
        if(is.null(nruns))
            nruns <- 1L
        order <- replicate(nruns, sample(n), simplify = FALSE)
    }

    ind <- lower.tri(x)
    L <- function(d) sum(weights * (x - d)[ind] ^ 2)

    d_opt <- NULL
    v_opt <- Inf
    for(run in seq_along(order)) {
        if(verbose)
            message(gettextf("Iterative reduction run: %d", run))
        d <- .C(C_ls_fit_addtree_by_iterative_reduction,
                as.double(x),
                as.integer(n),
                as.integer(order[[run]] - 1L),
                as.integer(maxiter),
                iter = integer(1L),
                as.double(tol),
                as.logical(verbose))[[1L]]
        v <- L(d)
        if(v < v_opt) {
            v_opt <- v
            d_opt <- d
        }
    }

    d <- matrix(d_opt, n)
    dimnames(d) <- list(labels, labels)
    .cl_addtree_from_addtree_approximation(as.dist(d))
}
R/addtree.R:213

as.cl_addtree untypeabletyped

unbound variable (line 343)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_addtree <-
function(x)
    UseMethod("as.cl_addtree")
R/addtree.R:341

ls_fit_addtree untypeable

unbound variable (line 8)
unbound: as.dist — a name the prelude does not declare
error detail
name: as.dist
timing: 0.156 s
source
ls_fit_addtree <-
function(x, method = c("SUMT", "IP", "IR"), weights = 1,
         control = list())
{
    if(!inherits(x, "dist"))
        x <- as.dist(x)

    ## Catch some special cases right away.
    if(attr(x, "Size") <= 3L)
        return(as.cl_addtree(x))
    if(.non_additivity(x, max = TRUE) == 0)
        return(as.cl_addtree(x))

    ## Handle argument 'weights'.
    ## This is somewhat tricky ...
    if(is.matrix(weights)) {
        weights <- as.dist(weights)
        if(length(weights) != length(x))
            stop("Argument 'weights' must be compatible with 'x'.")
    }
    else
        weights <- rep_len(weights, length(x))
    if(any(weights < 0))
        stop("Argument 'weights' has negative elements.")
    if(!any(weights > 0))
        stop("Argument 'weights' has no positive elements.")

    method <- match.arg(method)
    switch(method,
           SUMT = .ls_fit_addtree_by_SUMT(x, weights, control),
           IP = {
               .ls_fit_addtree_by_iterative_projection(x, weights,
                                                       control)
           },
           IR = {
               .ls_fit_addtree_by_iterative_reduction(x, weights,
                                                      control)
           })
}
R/addtree.R:3

.make_centroid_matrix untypeabletyped

unbound variable (line 334)
unbound: outer — a name the prelude does not declare
error detail
name: outer
gradual mode: typed
((g: any) -> any)<>
timing: 4.03 s
source
.make_centroid_matrix <-
function(g)
{
    y <- outer(g, g, `+`)
    diag(y) <- 0
    y
}
R/addtree.R:331

ls_fit_centroid untypeabletyped

unbound variable (line 324)
unbound: as.cl_addtree — one of the package’s own names, itself untyped
error detail
name: as.cl_addtree
gradual mode: typed
((x: dbl with { Size: dbl<~@"-", ~@"*", ...>, any }) | (x: dbl with { Size: vec<@"-", ...>, any }) -> any)<>
timing: 0.452 s
source
ls_fit_centroid <-
function(x)
{
    ## Fit a centroid additive tree distance along the lines of Carroll
    ## & Pruzansky (1980).  In fact, solving
    ##
    ##    \sum_{i,j: i \ne j} (\delta_{ij} - (g_i + g_j)) ^ 2 => min_g
    ##
    ## gives \sum_{j: j \ne i} (g_i + g_j - \delta_{ij}) = 0, or (also
    ## in Barthemely & Guenoche)
    ##
    ##    (n - 2) g_i + \sum_j g_j = \sum_{j: j \ne i} \delta_{ij}
    ##
    ## which after summing over all i and some manipulations eventually
    ## gives
    ##
    ##    g_i = \frac{1}{n-2} (v_i - m),
    ##
    ##    v_i = \sum_{j: j \ne i} \delta_{ij}
    ##    s   = \frac{1}{2(n-1)} \sum_{i,j: j \ne i} \delta_{ij}

    n <- attr(x, "Size")

    if(n <= 2L)
        return(as.cl_addtree(0 * x))

    x <- as.matrix(x)
    g <- rowSums(x) / (n - 2) - sum(x) / (2 * (n - 1) * (n - 2))
    as.cl_addtree(as.dist(.make_centroid_matrix(g)))
}
R/addtree.R:300

as.cl_addtree.default untypeabletyped

unbound variable (line 350)
unbound: is.atomic — a name the prelude does not declare
error detail
name: is.atomic
gradual mode: typed
((x: { .Data: any, any } with { Labels: null, any }) -> any)<>
timing: 0.040 s
source
as.cl_addtree.default <-
function(x)    
{
    if(inherits(x, "cl_addtree"))
        x
    else if(is.atomic(x) || inherits(x, "cl_ultrametric"))
        .cl_addtree_from_veclh(x)
    else if(is.matrix(x)) {
        ## Should actually check whether the matrix is symmetric, >= 0
        ## and satisfies the 4-point conditions ...
        .cl_addtree_from_veclh(as.dist(x))
    }
    else if(is.cl_dendrogram(x))
        .cl_addtree_from_veclh(cl_ultrametric(x))
    else
        stop("Cannot coerce to 'cl_addtree'.")
}
R/addtree.R:345

as.cl_addtree.phylo untypeabletyped

unbound variable (line 365)
unbound: cophenetic — a name the prelude does not declare
error detail
name: cophenetic
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
as.cl_addtree.phylo <-
function(x)
    .cl_addtree_from_veclh(as.dist(cophenetic(x)))
R/addtree.R:363

.decompose_addtree untypeabletyped

unbound variable (line 409)
unbound: as.matrix — a name the prelude does not declare
error detail
name: as.matrix
gradual mode: typed
((x: any, const: null?) -> any)<>
timing: 0.065 s
source
.decompose_addtree <-
function(x, const = NULL)
{
    ## Decompose an addtree into an ultrametric and a centroid
    ## distance.

    ## If 'const' is not given, we take the root as half way between the
    ## diameter of the addtree, and choose a minimal constant to ensure
    ## non-negativity (but not positivity) of the ultrametric.

    ## As this is all slightly dubious and it is not quite clear how
    ## much positivity we want in the ultrametric of the decomposition,
    ## we keep this hidden.  For plotting addtrees, the choice of the
    ## constant does not seem to matter.

    x <- as.matrix(x)
    n <- nrow(x)

    ## Determine diameter.
    ind <- which.max(x) - 1
    u <- ind %% n + 1
    v <- ind %/% n + 1

    if(!is.null(const))
        g <- pmax(x[u, ], x[v, ]) - const
    else {
        g <- pmax(x[u, ], x[v, ]) - x[u, v] / 2
        u <- x - .make_centroid_matrix(g)
        k <- - min(u)
        g <- g - k / 2
    }
    u <- x - .make_centroid_matrix(g)

    names(g) <- rownames(x)

    ## Ensure a valid ultrametric.
    d <- .ultrametrify(as.dist(u))
    u <- .cl_ultrametric_from_veclh(d, nrow(x), rownames(x))

    ## Note that we return the centroid distances to the root, and not
    ## between the objects (as.dist(.make_centroid_matrix(g))) ...
    list(Ultrametric = as.cl_ultrametric(u), Centroid = g)
}
R/addtree.R:394

plot.cl_addtree untypeable

unbound variable (line 445)
unbound: .decompose_addtree — one of the package’s own names, itself untyped
error detail
name: .decompose_addtree
timing: 0.055 s
source
plot.cl_addtree <-
function(x, ...)
{
    ## Construct a dendrogram-style representation of the addtree with
    ## the root half way between the diameter, and plot.
    y <- .decompose_addtree(x, max(x))
    u <- y$Ultrametric
    g <- y$Centroid
    ## We halve the scale of the ultrametric, and add the maximal g from
    ## the centroid.
    h <- hclust(as.dist(u / 2), "single")
    h$height <- h$height + max(g)
    d <- as.dendrogram(h)
    ## Now modify the heights of the leaves so that the objects giving
    ## the diameter of the addtree end up with height zero.
    g <- max(g) - g
    names(g) <- labels(g)
    d <- dendrapply(d, function(n) {
        if(!is.leaf(n)) return(n)
        attr(n, "height") <- g[attr(n, "label")]
        n
    })
    ## And finally plot
    plot(d, ...)
}
R/addtree.R:440
R/predict.R

cl_predict untypeabletyped

unbound variable (line 9)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((object: any, newdata: any?, type: any?, ...: any) -> any)<>
timing: 0.029 s
source
cl_predict <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
    UseMethod("cl_predict")
R/predict.R:6

.as_cl_class_ids_or_membership untypeabletyped

unbound variable (line 307)
unbound: max.col — a name the prelude does not declare
error detail
name: max.col
gradual mode: typed
((x: <...>, type: (vec | null)?) -> any)<>
timing: 0.066 s
source
.as_cl_class_ids_or_membership <-
function(x, type = c("class_ids", "memberships"))
{
    type <- match.arg(type)

    if(type == "class_ids") {
        if(is.matrix(x)) {
            ## Same as for cl_class_ids.cl_membership().
            as.cl_class_ids(.structure(max.col(x), names = rownames(x)))
        }
        else
            as.cl_class_ids(x)
    }
    else
        as.cl_membership(x)
}
R/predict.R:299

cl_predict.default untypeabletyped

unbound variable (line 16)
unbound: predict — a name the prelude does not declare
error detail
name: predict
gradual mode: typed
((object: any, newdata: any?, type: any?, ...: any) -> any)<>
timing: 0.027 s
source
cl_predict.default <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
    .as_cl_class_ids_or_membership(predict(object, newdata, ...), type)
R/predict.R:13

.cl_class_ids_or_membership untypeabletyped

unbound variable (line 294)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
((x: any, type: (vec | null)?) -> any)<>
timing: 0.046 s
source
.cl_class_ids_or_membership <-
function(x, type = c("class_ids", "memberships"))
{
    type <- match.arg(type)

    if(type == "class_ids")
        cl_class_ids(x)
    else
        cl_membership(x)
}
R/predict.R:288

cl_predict.kmeans untypeabletyped

unbound variable (line 24)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.055 s
source
cl_predict.kmeans <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    d <- .rxdist(newdata, object$centers)
    .as_cl_class_ids_or_membership(max.col(-d), type)
}
R/predict.R:19

cl_predict.fanny untypeabletyped

unbound variable (line 49)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.049 s
source
cl_predict.fanny <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    stop("Cannot make new predictions.")
}
R/predict.R:44

cl_predict.clara untypeabletyped

unbound variable (line 58)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.079 s
source
cl_predict.clara <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    ## <FIXME>
    ## Add support eventually ...
    if(identical(object$call$stand, TRUE))
        warning("Standardization is currently not supported.")
    ## </FIXME>
    method <- object$call$metric
    if(is.null(method)) {
        ## Not given in the call, hence use default value.
        method <- eval(formals(clara)$metric)[1L]
        ## (Or hard-wire the default value: "euclidean".)
    }
    d <- .rxdist(newdata, object$medoids, method)
    .as_cl_class_ids_or_membership(max.col(-d), type)
}
R/predict.R:53

cl_predict.pam untypeabletyped

unbound variable (line 79)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.083 s
source
cl_predict.pam <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    prototypes <- object$medoids
    if(!is.matrix(prototypes))
        stop("Cannot make new predictions.")
    ## <FIXME>
    ## Add support eventually ...
    if(identical(object$call$stand, TRUE))
        warning("Standardization is currently not supported.")
    ## </FIXME>
    method <- object$call$metric
    if(is.null(method)) {
        ## Not given in the call, hence use default value.
        method <- eval(formals(pam)$metric)[1L]
        ## (Or hard-wire the default value: "euclidean".)
    }
    d <- .rxdist(newdata, object$medoids, method)
    .as_cl_class_ids_or_membership(max.col(-d), type)
}
R/predict.R:74

cl_predict.Weka_clusterer untypeabletyped

unbound variable (line 105)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.054 s
source
cl_predict.Weka_clusterer <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    .as_cl_class_ids_or_membership(predict(object, newdata = newdata,
                                           type = type, ...),
                                   type)
}
R/predict.R:100

cl_predict.ccfkms untypeabletyped

unbound variable (line 117)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.054 s
source
cl_predict.ccfkms <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    .as_cl_class_ids_or_membership(as.vector(predict(object,
                                                     newdata)$cl),
                                   type)
}
R/predict.R:112

cl_predict.rock untypeabletyped

unbound variable (line 134)
unbound: predict — a name the prelude does not declare
error detail
name: predict
gradual mode: typed
((object: { x: null, any }, newdata: null?, type: any?, ...: any) -> any)<>
timing: 0.103 s
source
cl_predict.rock <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata)) newdata <- object$x
    ids <- as.vector(predict(object, newdata, ...)$cl)
    .as_cl_class_ids_or_membership(ids, type)
}
R/predict.R:129

cl_predict.cclust untypeabletyped

unbound variable (line 147)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.052 s
source
cl_predict.cclust <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    ## Package cclust provides predict.cclust() which returns (again) an
    ## object of class "cclust", but does not give the labels of the
    ## original data in case no new data are given.
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    .as_cl_class_ids_or_membership(predict(object, newdata), type)
}
R/predict.R:139

cl_predict.fclust untypeabletyped

unbound variable (line 157)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.076 s
source
cl_predict.fclust <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))

    ## Note that the 'fclust' objects returned by cmeans() do not always
    ## directly contain the information on the fuzzification parameter m
    ## and the distance (Euclidean/Manhattan) employed, so we have to
    ## engineer this from the matched call and the default arguments.
    nms <- names(object$call)
    ## Note that we cannot directly use object$call$m, as this could
    ## give the 'method' argument if 'm' was not given.
    m <- if("m" %in% nms)
        object$call$m
    else {
        ## Not given in the call, hence use default value.
        formals(e1071::cmeans)$m
        ## (Or hard-wire the default value: 2.)
    }
    method <- if("dist" %in% nms)
        object$call$dist
    else {
        ## Not given in the call, hence use default value.
        formals(e1071::cmeans)$dist
        ## (Or hard-wire the default value: "euclidean".)
    }

    d <- .rxdist(newdata, object$centers, method)
    power <- c(m, if(method == "euclidean") 2 else 1)
    M <- .memberships_from_cross_dissimilarities(d, power)
    .as_cl_class_ids_or_membership(M, type)
}
R/predict.R:152

cl_predict.cshell untypeabletyped

unbound variable (line 193)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.090 s
source
cl_predict.cshell <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))

    ## Not surprisingly, this is rather similar to what we do for fclust
    ## objects.  Only dissimiliraties (and exponents) need to be
    ## computed differently ...
    nms <- names(object$call)
    m <- if("m" %in% nms)
        object$call$m
    else {
        ## Not given in the call, hence use default value.
        formals(e1071::cshell)$m
        ## (Or hard-wire the default value: 2.)
    }
    method <- if("dist" %in% nms)
        object$call$dist
    else {
        ## Not given in the call, hence use default value.
        formals(e1071::cshell)$dist
        ## (Or hard-wire the default value: "euclidean".)
    }

    d <- .rxdist(newdata, object$centers, method)
    d <- sweep(d, 2, object$radius) ^ 2
    M <- .memberships_from_cross_dissimilarities(d, m)
    .as_cl_class_ids_or_membership(M, type)
}
R/predict.R:188

cl_predict.bclust untypeabletyped

unbound variable (line 225)
unbound: cl_predict.kmeans — one of the package’s own names, itself untyped
error detail
name: cl_predict.kmeans
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.000 s
source
cl_predict.bclust <- cl_predict.kmeans
R/predict.R:225

cl_predict.kcca untypeabletyped

unbound variable (line 230)
unbound: cl_predict.default — one of the package’s own names, itself untyped
error detail
name: cl_predict.default
gradual mode: typed
((object: any, newdata: any?, type: any?, ...: any) -> any)<>
timing: 0.000 s
source
cl_predict.kcca <- cl_predict.default
R/predict.R:230

cl_predict.flexmix untypeabletyped

unbound variable (line 238)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.054 s
source
cl_predict.flexmix <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))
    .as_cl_class_ids_or_membership(modeltools::posterior(object,
                                                         newdata,
                                                         ...),
                                   type)
}
R/predict.R:233

cl_predict.Mclust untypeabletyped

unbound variable (line 251)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.066 s
source
cl_predict.Mclust <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))

    pred <- predict(object, newdata, ...)
    type <- match.arg(type)
    if(type == "class_ids")
        as.cl_class_ids(pred$classification)
    else
        as.cl_membership(pred$z)
}
R/predict.R:246

cl_predict.movMF untypeabletyped

unbound variable (line 263)
unbound: cl_predict.Weka_clusterer — one of the package’s own names, itself untyped
error detail
name: cl_predict.Weka_clusterer
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.000 s
source
cl_predict.movMF <- cl_predict.Weka_clusterer
R/predict.R:263

cl_predict.pclust untypeabletyped

unbound variable (line 271)
unbound: .cl_class_ids_or_membership — one of the package’s own names, itself untyped
error detail
name: .cl_class_ids_or_membership
gradual mode: typed
((object: any, newdata: null?, type: (vec | null)?, ...: any) -> any)<>
timing: 0.060 s
source
cl_predict.pclust <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
{
    if(is.null(newdata))
        return(.cl_class_ids_or_membership(object, type))

    d <- object$family$D(newdata, object$prototypes)
    power <- c(object$m, object$family$e)
    M <- .memberships_from_cross_dissimilarities(d, power)
    .as_cl_class_ids_or_membership(M, type)
}
R/predict.R:266

cl_predict.cl_partition skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
cl_predict.cl_partition <-
function(object, newdata = NULL,
         type = c("class_ids", "memberships"), ...)
    cl_predict(.get_representation(object), newdata = newdata, type, ...)
R/predict.R:280
R/boot.R

cl_boot untypeabletyped

unbound variable (line 7)
unbound: rep.int — a name the prelude does not declare
error detail
name: rep.int
gradual mode: typed
((x: any, B: any, k: null?, algorithm: any?, parameters: any?, resample: dbl?) -> any)<>
timing: 0.641 s
source
cl_boot <-
function(x, B, k = NULL, 
         algorithm = if(is.null(k)) "hclust" else "kmeans",
         parameters = list(), resample = FALSE)
{
    clusterings <- if(!resample) {
        x <- rep.int(list(x), B)        
        eval(as.call(c(list(as.name("lapply"), x, algorithm),
                       if(!is.null(k)) list(k),
                       parameters)))
    }
    else {
        replicate(B,
                  expr = {
                      algorithm <- match.fun(algorithm)
                      ## <NOTE>
                      ## This is not quite perfect.  We have
                      ## cl_predict() to encapsulate the process of
                      ## assigning objects to classes, but for sampling
                      ## from the objects we assume that they correspond
                      ## to the *rows* of 'x'.  Argh.
                      ## </NOTE>
                      ind <- sample(NROW(x), replace = TRUE)
                      train <- if(length(dim(x)) == 2) x[ind, ] else x[ind]
                      out <- eval(as.call(c(list(algorithm, train),
                                            if(!is.null(k)) list(k),
                                            parameters)))
                      as.cl_partition(cl_predict(out, x, "memberships"))
                  },
                  simplify = FALSE)
    }

    cl_ensemble(list = clusterings)
}
R/boot.R:1
R/bag.R

cl_bag untypeable

unbound variable (line 10)
unbound: match.fun — a name the prelude does not declare
error detail
name: match.fun
timing: 0.094 s
source
cl_bag <-
function(x, B, k = NULL,
         algorithm = "kmeans", parameters = NULL,
         method = "DFBC1", control = NULL)
{
    ## Currently, method 'DFBC1' (Dudoit-Fridlyand BagClust1) is the
    ## only one available, and argument 'control' is ignored.
    
    ## Construct reference partition.
    algorithm <- match.fun(algorithm)
    reference <- eval(as.call(c(list(algorithm, x),
                                if(!is.null(k)) list(k),
                                parameters)))

    ## Construct bootstrap ensemble.
    clusterings <-
        cl_boot(x, B, k, algorithm, parameters, resample = TRUE)

    ## Construct Dudoit-Fridlyand BagClust1 consensus partitions,
    ## suitably generalized ...
    ## <NOTE>
    ## In principle, this could be turned into a "constructive" method
    ## for cl_consensus(), also allowing for weights (straightforward).
    ## E.g.,
    ##    .cl_consensus_partition_DFBC1(clusterings, weights, control)
    ## where either 'control specifies a reference partition, or the
    ## first element of 'clusterings' is taken as such.
    ## </NOTE>
    k <- max(sapply(c(clusterings, reference), n_of_classes))
    M_ref <- cl_membership(reference, k)
    M <- matrix(0, NROW(M_ref), k)
    for(b in seq_len(B)) {
        mem <- cl_membership(clusterings[[b]], k)
        ## Match classes to reference partition.
        ind <- solve_LSAP(crossprod(M_ref, mem), maximum = TRUE)
        M <- M + mem[, ind]
    }
    as.cl_partition(cl_membership(as.cl_membership(M / B), k))
}
R/bag.R:1
R/fuzziness.R

cl_fuzziness untypeable

unbound variable (line 4)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.112 s
source
cl_fuzziness <-
function(x, method = NULL, normalize = TRUE)
{
    x <- as.cl_ensemble(x)
    out <- double(length(x))
    ## <FIXME>
    ## The docs say that we should only have partitions ...
    attr(out, "description") <- "Fuzziness"
    class(out) <- "cl_fuzziness"
    parties <- vapply(x, is.cl_partition, NA)
    if(!(length(x) || any(parties))) {
        ## Currently, no fuzzy hierarchies ...
        return(out)
    }
    ## </FIXME>

    if(!is.function(method)) {
        builtin_methods <- c("PC", "PE")
        builtin_method_names <-
            c("partition coefficient", "partition entropy")
        if(is.null(method))
            ind <- 1
        else if(is.na(ind <- pmatch(tolower(method),
                                    tolower(builtin_methods))))
            stop(gettextf("Value '%s' is not a valid abbreviation for a fuzziness method.",
                          method),
                 domain = NA)
        method <- paste0(".cl_fuzziness_partition_", builtin_methods[ind])
        method_name <- builtin_method_names[ind]
        if(normalize)
            method_name <- paste("normalized", method_name)
    }
    else
        method_name <- "user-defined method"
    
    out[parties] <- as.numeric(sapply(x[parties], method, normalize))
    attr(out, "description") <- paste("Fuzziness using", method_name)
    out 
}
R/fuzziness.R:1

.cl_fuzziness_partition_PC untypeable

unbound variable (line 46)
unbound: .maybe_is_proper_soft_partition — one of the package’s own names, itself untyped
error detail
name: .maybe_is_proper_soft_partition
timing: 0.067 s
source
.cl_fuzziness_partition_PC <-
function(x, normalize = TRUE)
{
    ## Dunn's Partition Coefficient, see also ?fanny.
    ## Note that we normalize differently ...
    if(!.maybe_is_proper_soft_partition(x) && is.cl_hard_partition(x))
        return(1 - normalize)
    pc <- sum(cl_membership(x) ^ 2) / n_of_objects(x)
    if(normalize)
        pc <- (1 - pc) / (1 - 1 / n_of_classes(x))
    pc
}
R/fuzziness.R:41

.cl_fuzziness_partition_PE untypeable

unbound variable (line 59)
unbound: .maybe_is_proper_soft_partition — one of the package’s own names, itself untyped
error detail
name: .maybe_is_proper_soft_partition
timing: 0.061 s
source
.cl_fuzziness_partition_PE <-
function(x, normalize = TRUE)
{
    ## Bezdek's Partition Entropy.
    ## Note that we normalize differently ...
    if(!.maybe_is_proper_soft_partition(x) && is.cl_hard_partition(x))
        return(0)
    M <- cl_membership(x)
    pe <- - sum(ifelse(M > 0, M * log(M), 0)) / n_of_objects(x)
    if(normalize)
        pe <- pe / log(n_of_classes(x))
    pe
}
R/fuzziness.R:54

print.cl_fuzziness untypeabletyped

unbound variable (line 72)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
∀'a. ((x: 'a & any with { description: any, any }, ...: any) -> 'a)<>
timing: 0.026 s
source
print.cl_fuzziness <-
function(x, ...)
{
    cat(attr(x, "description"), ":\n", sep = "")
    print(as.vector(x), ...)
    invisible(x)
}
R/fuzziness.R:68
R/margin.R

cl_margin untypeable

unbound variable (line 4)
unbound: is.cl_hard_partition — one of the package’s own names, itself untyped
error detail
name: is.cl_hard_partition
timing: 0.012 s
source
cl_margin <-
function(x)
{
    if(is.cl_hard_partition(x))
        out <- rep.int(1, n_of_objects(x))
    else if(is.cl_partition(x)) {
        x <- cl_membership(x)
        i <- seq_len(nrow(x))
        j <- cbind(i, max.col(x))
        out <- x[j]
        x[j] <- 0
        out <- out - x[cbind(i, max.col(x))]
    }
    else
        stop("Argument 'x' must be a partition.")

    out
}
R/margin.R:1
R/medoid.R

cl_medoid untypeabletyped

unbound variable (line 10)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
gradual mode: typed
((x: list | null, method: any?) -> any)<>
timing: 0.009 s
source
cl_medoid <-
function(x, method = "euclidean")
{
    ## <NOTE>
    ## In principle we can get the same using pam(k = 1)$medoids.
    ## </NOTE>

    clusterings <- as.cl_ensemble(x)
    if(!length(clusterings))
        stop("Cannot compute medoid of empty ensemble.")
    dissimilarities <-
        as.matrix(cl_dissimilarity(clusterings, method = method))
    clusterings[[which.min(rowSums(dissimilarities))]]
}
R/medoid.R:3

cl_medoid_ids untypeabletyped

unbound variable (line 127)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any) -> any)<>
timing: 0.002 s
source
cl_medoid_ids <- function(x) UseMethod("cl_medoid_ids")
R/medoid.R:127

kmedoids untypeabletyped

unbound variable (line 144)
unbound: as.matrix — a name the prelude does not declare
error detail
name: as.matrix
gradual mode: typed
((x: any, k: any) -> any)<>
timing: 0.051 s
source
kmedoids <-
function(x, k)
{
    ## <FIXME>
    ## For the time being, 'x' is assumed a dissimilarity object or a
    ## matrix of dissimilarities.
    ## Let's worry about the interface later.
    ## </FIXME>

    x <- as.matrix(x)

    n <- nrow(x)

    ## Use the formulation in Gordon & Vichi (1998), Journal of
    ## Classification, [P4'], page 279, with variables c(vec(X), z), but
    ## with rows and cols interchanged (such that x_{ij} is one iff o_i
    ## has medoid o_j, and z_j is one iff o_j is a medoid).

    make_constraint_mat <- function(n) {
        nsq <- n * n
        rbind(cbind(kronecker(rbind(rep.int(1, n)), diag(1, n)),
                    matrix(0, n, n)),
              cbind(diag(1, nsq),
                    kronecker(diag(1, n), rep.int(-1, n))),
              c(double(nsq), rep.int(1, n)),
              cbind(matrix(0, n, nsq), diag(1, n)))
    }

    make_constraint_dir <- function(n)
        rep.int(c("=", "<=", "=", "<="), c(n, n * n, 1, n))

    make_constraint_rhs <- function(n, k)
        rep.int(c(1, 0, k, 1), c(n, n * n, 1, n))

    ## <NOTE>
    ## We could try a relaxation without integrality constraints first,
    ## which seems to "typically work" (and should be faster).  To test
    ## for integrality, use something like
    ##   if(identical(all.equal(y$solution, round(y$solution)), TRUE))
    ## </NOTE>

    y <- lpSolve::lp("min",
                     c(c(x), double(n)),
                     make_constraint_mat(n),
                     make_constraint_dir(n),
                     make_constraint_rhs(n, k),
                     int.vec = seq_len(n * (n + 1)))

    ## Now get the class ids and medoids.

    ind <- which(matrix(y$solution[seq_len(n * n)], n) > 0,
                 arr.ind = TRUE)
    medoid_ids <- unique(ind[, 2L])
    class_ids <- seq_len(n)
    class_ids[ind[, 1L]] <- match(ind[, 2L], medoid_ids)

    .structure(list(cluster = class_ids,
                    medoid_ids = medoid_ids,
                    criterion = y$objval),
               class = "kmedoids")
}
R/medoid.R:135

cl_pam untypeabletyped

unbound variable (line 24)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
gradual mode: typed
((x: list | null, k: 1, method: any?, solver: any?) | (x: list | null, k: ~1, method: any?, solver: (vec | null)?) -> any)<>
timing: 0.079 s
source
cl_pam <-
function(x, k, method = "euclidean", solver = c("pam", "kmedoids"))
{

    clusterings <- as.cl_ensemble(x)
    if(!length(clusterings))
        stop("Cannot compute medoid partition of empty ensemble.")

    ## Actually, we should have at least k distinct elements in the
    ## ensemble ...

    make_cl_pam <- function(class_ids, medoid_ids, medoids, criterion,
                            description)
        .structure(list(cluster = class_ids,
                        medoid_ids = medoid_ids,
                        prototypes = medoids,
                        criterion = criterion,
                        description = description),
                   class = "cl_pam")

    if(k == 1L) {
        ## Simplify matters if a global medoid is sought.
        dissimilarities <-
            cl_dissimilarity(clusterings, method = method)
        description <- attr(dissimilarities, "description")
        dissimilarities <- as.matrix(dissimilarities)
        row_sums <- rowSums(dissimilarities)
        medoid_id <- which.min(row_sums)
        criterion <- row_sums[medoid_id]
        return(make_cl_pam(as.cl_class_ids(seq_along(clusterings)),
                           medoid_id,
                           clusterings[medoid_id],
                           criterion,
                           description))
    }

    solver <- match.arg(solver)

    ## Argh.  We really want to run k-medoids for the unique elements of
    ## the ensemble, but pam() only works for symmetric dissimilarties.
    ## As computing cluster dissimilarities is typically expensive, use
    ## the unique elements for doing so in any case.
    
    values <- unique(clusterings)
    ## Positions of ensemble members in the unique values.
    positions <- match(clusterings, values)

    ## Dissimilarities between unique values.
    dissimilarities <- cl_dissimilarity(values, method = method)
    description <- attr(dissimilarities, "description")
    dissimilarities <- as.matrix(dissimilarities)

    ## For pam(), we need the dissimilarities for all objects.
    if(solver == "pam") {
        dissimilarities <- dissimilarities[positions, positions]
        party <- pam(as.dist(dissimilarities), k)
        class_ids <- cl_class_ids(party)
        medoid_ids <- cl_medoid_ids(party)
        medoids <- clusterings[medoid_ids]
        criterion <- sum(dissimilarities[cbind(seq_along(class_ids),
                                               medoid_ids[class_ids])])
    }
    else {
        ## Counts of unique values.
        counts <- tabulate(positions)

        ## Weigh according to the counts.  Should be straightforward to
        ## add "case weights" as well ...
        dissimilarities <- counts * dissimilarities

        ## Now partition.
        party <- kmedoids(dissimilarities, k)

        ## And build the solution from this ...
        criterion <- party$criterion        
        ## First, things for the unique values.
        medoid_ids <- cl_medoid_ids(party)
        medoids <- values[medoid_ids]
        class_ids <- cl_class_ids(party)
        ## Second, things for all objects.
        class_ids <- class_ids[positions]
        medoid_ids <- match(medoid_ids, positions)
    }

    make_cl_pam(class_ids, medoid_ids, medoids, criterion, description)
}
R/medoid.R:20

print.cl_pam untypeabletyped

unbound variable (line 110)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
∀'a. ((x: 'a & { description: any, criterion: any, any }, ...: any) -> 'a)<>
timing: 0.011 s
source
print.cl_pam <-
function(x, ...)
{
    class_ids <- cl_class_ids(x)
    fmt <- "A k-medoid partition of a cluster ensemble with %d elements into %d
classes (dissimilarity measure: %s)."
    writeLines(c(strwrap(gettextf(fmt,
                                  n_of_objects(x),
                                  n_of_classes(x),
                                  x$description))))
    writeLines(gettext("Class ids:"))
    print(class_ids, ...)
    writeLines(gettext("Criterion:"))
    print(x$criterion, ...)
    invisible(x)
}
R/medoid.R:107

cl_medoid_ids.cl_pam typed accepts outside

∀'a. ((x: { medoid_ids: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { medoid_ids: 'I14841, any }) -> 'I14841)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:langcl_medoid_ids.cl_pam(quote(f(x)))null
xkind:nullcl_medoid_ids.cl_pam("x" = NULL)null
source
cl_medoid_ids.cl_pam <- function(x) x$medoid_ids
R/medoid.R:128

cl_medoid_ids.kmedoids typed accepts outside

∀'a. ((x: { medoid_ids: 'a, any }) -> 'a)<>
timing: 0.019 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { medoid_ids: 'I14849, any }) -> 'I14849)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:nullcl_medoid_ids.kmedoids(NULL)null
source
cl_medoid_ids.kmedoids <- function(x) x$medoid_ids
R/medoid.R:129

cl_medoid_ids.clara typed accepts outside

∀'a. ((x: { i.med: 'a, any }) -> 'a)<>
timing: 0.019 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { i.med: 'I14857, any }) -> 'I14857)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:envcl_medoid_ids.clara(new.env())null
xkind:langcl_medoid_ids.clara("x" = quote(f(x)))null
source
cl_medoid_ids.clara <- function(x) x$i.med
R/medoid.R:130

cl_medoid_ids.pam typed accepts outside

∀'a. ((x: { id.med: 'a, any }) -> 'a)<>
timing: 0.020 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { id.med: 'I14865, any }) -> 'I14865)<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:langcl_medoid_ids.pam(quote(f(x)))null
xkind:nullcl_medoid_ids.pam(NULL)null
source
cl_medoid_ids.pam <- function(x) x$id.med
R/medoid.R:131

print.kmedoids untypeable

unbound variable (line 201)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
timing: 0.008 s
source
print.kmedoids <-
function(x, ...)
{
    fmt <- "A k-medoids clustering of %d objects into %d clusters."
    writeLines(gettextf(fmt, n_of_objects(x), n_of_classes(x)))
    writeLines(gettext("Medoid ids:"))
    print(cl_medoid_ids(x), ...)
    writeLines(gettext("Class ids:"))
    print(unclass(cl_class_ids(x)), ...)
    writeLines(gettext("Criterion:"))
    print(x$criterion, ...)
    invisible(x)
}
R/medoid.R:197
R/validity.R

cl_validity untypeabletyped

unbound variable (line 6)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any, ...: any) -> any)<>
timing: 0.003 s
source
cl_validity <-
function(x, ...)
    UseMethod("cl_validity")
R/validity.R:4

.cl_validity_hierarchy_deviance_a_f untypeabletyped

unbound variable (line 123)
unbound: median — a name the prelude does not declare
error detail
name: median
gradual mode: typed
((u: dbl, d: dbl<~@"-", ...>) | (u: any, d: <@"-", ...>) -> any)<>
timing: 2.64 s
source
.cl_validity_hierarchy_deviance_a_f <-
function(u, d)
{
    ## *Deviance accounted for* (i.e., absolute deviation).
    ## See e.g. Smith (2001), Constructing ultrametric and additive
    ## trees based on the ${L}_1$ norm, Journal of Classification.
    ## deviance_accounted_for = 
    ##   1 - \frac{\sum_{i < j} |d_{ij} - u_{ij}|}
    ##            {\sum_{i < j} |d_{ij} - median(d)|}
    ## As this can be arbitrarily negative, we cut at 0.

    max(1 - sum(abs(d - u)) / sum(abs(d - median(d))), 0)
}
R/validity.R:112

.cl_validity_hierarchy_variance_a_f untypeabletyped

unbound variable (line 109)
unbound: mean — a name the prelude does not declare
error detail
name: mean
gradual mode: typed
((u: dbl, d: dbl<~@"-", ...>) | (u: any, d: <@"-", ...>) -> any)<>
timing: 1.99 s
source
.cl_validity_hierarchy_variance_a_f <-
function(u, d)
{
    ## *Variance accounted for*.
    ## See e.g. Hubert, Arabie, & Meulman (2006), The structural
    ## representation of proximity matrices with MATLAB:
    ## variance_accounted_for = 
    ##   1 - \frac{\sum_{i < j} (d_{ij} - u_{ij}) ^ 2}
    ##            {\sum_{i < j} (d_{ij} - mean(d)) ^ 2}
    ## As this can be arbitrarily negative, we cut at 0.
    
    max(1 - sum((d - u) ^ 2) / sum((d - mean(d)) ^ 2), 0)
}
R/validity.R:98

.cl_validity_partition_d_a_f untypeable

untypeable application of base::seq_len (line 88)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.042 s
source
.cl_validity_partition_d_a_f <-
function(m, d)
{
    ## "Dissimilarity accounted for".
    ## Internal function for computing 1 - a / mean(d), where the
    ## "average within dissimilarity" a is given by
    ##   \frac{\sum_{i,j} \sum_k m_{ik}m_{jk} d(i,j)}
    ##        {\sum_{i,j} \sum_k m_{ik}m_{jk}}
    ## where m is the membership matrix and d a *symmetric* matrix of
    ## dissimilarities.
    within_sums <-
        rowSums(sapply(seq_len(ncol(m)),
                       function(k) {
                           z <- m[, k]
                           w <- outer(z, z)
                           c(sum(w * d), sum(w))
                       }))
    average_within_d <- within_sums[1L] / within_sums[2L]
    1 - average_within_d / mean(d)
}
R/validity.R:77

cl_validity.default untypeable

unbound variable (line 14)
unbound: .has_object_memberships — one of the package’s own names, itself untyped
error detail
name: .has_object_memberships
timing: 0.014 s
source
cl_validity.default <-
function(x, d, ...)
{
    ## Note that providing methods for classes "cl_partition" and
    ## "cl_hierarchy" is not good enough ...
    out <- list()
    if(.has_object_memberships(x)) {
        v <- .cl_validity_partition_d_a_f(cl_membership(x),
                                          as.matrix(d))
        out <- list("Dissimilarity accounted for" = v)
    }
    else if(.has_object_dissimilarities(x)) {
        x <- cl_object_dissimilarities(x)
        d <- as.dist(d)
        out <- list("Variance accounted for" =
                    .cl_validity_hierarchy_variance_a_f(x, d),
                    "Deviance accounted for" =
                    .cl_validity_hierarchy_deviance_a_f(x, d))
        ## Consider adding e.g. the Agglomerative Coefficient or
        ## Divisive Coeffcient for more than cluster::agnes() and
        ## cluster::diana(), respectively.
    }
    class(out) <- "cl_validity"
    out
}
R/validity.R:8

cl_validity.agnes typed accepts outside

∀'a. ((x: { ac: 'a, diss: any, any }, ...: any) -> { Agglomerative coefficient: 'a })<>
timing: 0.141 s
fuzzing: 20 inside (20 ok) · 8 outside (5 rejected, 3 accepted)
type drawn from: ((x: { ac: 'I15085, diss: any, any }, ...: any) -> { Agglomerative coefficient: 'I15085 })<>

Accepted outside the domain x: 3

parameterchangecallreturned
xkind:envcl_validity.agnes(new.env()){ Agglomerative coefficient: null }<cl_validity> with { names: "Agglomerative coefficient"<> with { } }
xkind:langcl_validity.agnes(quote(f(x)), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "fuzz_dot1" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "fuzz_dot2" = function(...) new.env()){ Agglomerative coefficient: null }<cl_validity> with { names: "Agglomerative coefficient"<> with { } }
xkind:langcl_validity.agnes("x" = quote(f(x))){ Agglomerative coefficient: null }<cl_validity> with { names: "Agglomerative coefficient"<> with { } }
source
cl_validity.agnes <-
function(x, ...)
{
    out <- list("Agglomerative coefficient" = x$ac)
    ## According to the docs, agnes objects always have a diss
    ## component, but let's be defensive ...
    if(!is.null(d <- x$diss))
        out <- c(out, cl_validity.default(x, d))
    class(out) <- "cl_validity"
    out
}
R/validity.R:35

cl_validity.diana typed accepts outside

∀'a. ((x: { diss: any, dc: 'a, any }, ...: any) -> { Divisive coefficient: 'a })<>
timing: 0.140 s
fuzzing: 20 inside (20 ok) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: { diss: any, dc: 'I15134, any }, ...: any) -> { Divisive coefficient: 'I15134 })<>

Accepted outside the domain x: 2

parameterchangecallreturned
xkind:langcl_validity.diana("x" = quote(f(x)), "fuzz_dot1" = as.name("x")){ Divisive coefficient: null }<cl_validity> with { names: "Divisive coefficient"<> with { } }
xkind:nullcl_validity.diana("x" = NULL, "fuzz_dot1" = NULL, "fuzz_dot2" = list(list(as.name("x")))){ Divisive coefficient: null }<cl_validity> with { names: "Divisive coefficient"<> with { } }
source
cl_validity.diana <-
function(x, ...)
{
    out <- list("Divisive coefficient" = x$dc)
    ## According to the docs, diana objects always have a diss
    ## component, but let's be defensive ...
    if(!is.null(d <- x$diss))
        out <- c(out, cl_validity.default(x, d))
    class(out) <- "cl_validity"
    out
}
R/validity.R:47

cl_validity.cl_partition untypeabletyped

unbound variable (line 62)
unbound: cl_validity — one of the package’s own names, itself untyped
error detail
name: cl_validity
gradual mode: typed
((x: { .Data: any, any }, ...: any) -> any)<>
timing: 0.013 s
source
cl_validity.cl_partition <-
function(x, ...)
    cl_validity(.get_representation(x), ...)
R/validity.R:60

cl_validity.pclust typed accepts outside

∀'a. ((x: { validity: 'a, any }, ...: any) -> 'a)<>
timing: 0.024 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { validity: 'I15185, any }, ...: any) -> 'I15185)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:langcl_validity.pclust("x" = quote(f(x)), "fuzz_dot1" = list(), "fuzz_dot2" = function(...) new.env())null
source
cl_validity.pclust <-
function(x, ...)
    x$validity
R/validity.R:65

print.cl_validity untypeable

untypeable application (line 72)
error detail
function: (v('I15196) --> v1('I15196)) & ({ 'I15197 } --> 'I15197)
argument: CHR<> | null
argument (not in the domain) may be: NULL
timing: 0.020 s
source
print.cl_validity <-
function(x, ...)
{
    for(nm in names(x))
        cat(nm, ": ", x[[nm]], "\n", sep = "")
    invisible(x)
}
R/validity.R:69

silhouette.cl_partition untypeabletyped

unbound variable (line 130)
unbound: silhouette — a name the prelude does not declare
error detail
name: silhouette
gradual mode: typed
((x: { .Data: any, any }, ...: any) -> any)<>
timing: 0.013 s
source
silhouette.cl_partition <-
function(x, ...)
    silhouette(.get_representation(x), ...)
R/validity.R:128

silhouette.cl_pclust typed accepts outside

∀'a. ((x: { silhouette: 'a, any }, ...: any) -> 'a)<>
timing: 0.024 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: { silhouette: 'I15211, any }, ...: any) -> 'I15211)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xdropsilhouette.cl_pclust(NULL, function(...) function(...) list(), "fuzz_dot1" = quote(f(x)))null
source
silhouette.cl_pclust <-
function(x, ...)
    x$silhouette
R/validity.R:132
R/pclust.R

pclust_object timeout

timing: 20.00 s
source
pclust_object <-
function(prototypes, membership, cluster, family, m = 1, value, ...,
         classes = NULL, attributes = NULL)
{
    out <- c(list(prototypes = prototypes,
                  membership = membership,
                  cluster = cluster,
                  family = family,
                  m = m,
                  value = value),
             list(...))
    attributes(out) <- c(attributes(out), attributes)
    classes <- unique(as.character(classes))
    class(out) <- c(classes[classes != "pclust"], "pclust")
    out
}
R/pclust.R:450

pclust untypeable

untypeable application of base::$ (line 170)
error detail
argument: @({  }<> | 'control, "maxiter"<>)
failing call: base::$(list(), "maxiter")
timing: 2.09 s
source
pclust <-
function(x, k, family, m = 1, weights = 1, control = list())
{
    ## A general purpose alternating optimization algorithm for
    ## prototype-based partitioning.
    
    ## For now, assume family specifies three functions:
    ## * A dissimilarity function D() for data and prototypes.
    ## * A consensus function C() for data, weights and control.
    ## * An init function init() of data and k giving an initial object
    ##   of k prototypes.
    ##
    ## We use k as the second argument as this seems to be common
    ## practice for partitioning algorithms.

    ## <NOTE>
    ## We assume that consensus functions can all handle WEIGHTS
    ## (formals: x, weights, control; only used positionally).
    ## <NOTE>
    
    ## <NOTE>
    ## We now allow for arbitrary representations/objects of prototypes.
    ## What is needed are functions to modify a *single* prototype and
    ## subset the prototypes.  By default, list and matrix (with the
    ## usual convention that rows are "objects") representations are
    ## supported.  Otherwise, the family needs to provide suitable
    ## .modify() and .subset() functions.
    ## The approach relies on having the initializer of the family
    ## (init()) return an appropriate object of prototypes.
    ## It would be possible to have default initializers as well to
    ## randomly subset the data (i.e., select elements of lists or rows
    ## of matrices, respectively).
    ## </NOTE>

    ## <NOTE>
    ## The 'prototypes' are not necessarily objects of the same kind as
    ## the data objects.  Therefore, D() is really a 2-argument
    ## cross-dissimilarity function.
    ## It would also be useful to have a way of computing the pairwise
    ## dissimilarities between objects: but this is something different
    ## from D() is objects and prototypes are not of the same kind.
    ## A "clean" solution could consist in specifying the family either
    ## via a (non-symmetric) cross-dissimilarity function X(), or a
    ## symmetric D() which when called with a single argument gives the
    ## pairwise object dissimilarities.
    ## I.e., 
    ##   pclust_family(D = NULL, C, init = NULL, X = NULL, ......)
    ## using
    ## * If both D and X are not given => TROUBLE.
    ## * If only D is given: use for X as well.
    ## * If only X is given: only use as such.
    ## Something for the future ...
    ## </NOTE>

    ## <NOTE>
    ## If people have code for computing cross-dissimilarities for the
    ## data and a *single* prototype (say, xd()), they can easily wrap
    ## into what is needed using
    ##   t(sapply(prototypes, function(p) xd(x, p)))
    ## Assuming symmetry of the dissimilarity, they could also do
    ##   t(sapply(prototypes, xd, x))
    ## </NOTE>

    ## Perhaps check whether 'family' is a feasible/suitable pclust
    ## family (object).
    D <- family$D
    C <- family$C
    e <- family$e
    .modify <- family$.modify
    .subset <- family$.subset

    maxiter <- control$maxiter
    if(is.null(maxiter))
        maxiter <- 100L
    nruns <- control$nruns
    reltol <- control$reltol
    if(is.null(reltol))
        reltol <- sqrt(.Machine$double.eps)
    start <- control$start
    verbose <- control$verbose
    if(is.null(verbose))
        verbose <- getOption("verbose")
    ## Do this at last ...
    control <- as.list(control$control)

    ## Handle start values and number of runs.
    if(!is.null(start)) {
        if(!is.list(start)) {
            ## Be nice to users.
            start <- list(start)
        }
        nruns <- length(start)
    } else {
        if(is.null(nruns)) {
            ## Use nruns only if start is not given.
            nruns <- 1L
        }
        start <- replicate(nruns, family$init(x, k), simplify = FALSE)
    }
    
    ## Initialize.
    ## We need to do this here because it is (currently) the only way to
    ## figure out the number B of objects to be partitioned (which is
    ## needed for getting the object weights to the right length).
    prototypes <- start[[1L]]
    dissimilarities <- D(x, prototypes) ^ e
    B <- NROW(dissimilarities)
    ## Also try to figure out (if necessary) how to modify a single
    ## prototype and to subset the prototypes.  Note that we can only
    ## check this *after* prototypes were obtained (and not when the
    ## family object is created).
    if(is.null(.modify)) {
        if(is.list(prototypes))
            .modify <- function(x, i, value) {
                x[[i]] <- value
                x
            }
        else if(is.matrix(prototypes))
            .modify <- function(x, i, value) {
                x[i, ] <- value
                x
            }
        else stop("Cannot determine how to modify prototypes.")
    } else if(!is.function(.modify) ||
            !identical(formals(args(.modify)), c("x", "i", "value")))
        stop("Invalid function to modify prototypes.")
    if(is.null(.subset)) {
        if(is.list(prototypes))
            .subset <- `[`
        else if(is.matrix(prototypes))                 
            .subset <- function(x, i)
                x[i, , drop = FALSE]
        else stop("Cannot determine how to subset prototypes.")
    } else if(!is.function(.subset) ||
            !identical(formals(args(.subset)), c("x", "i")))
        stop("Invalid function to subset prototypes.")

    weights <- rep_len(weights, B)
    if(any(weights < 0))
        stop("Argument 'weights' has negative elements.")
    if(!any(weights > 0))
        stop("Argument 'weights' has no positive elements.")

    ## A little helper.
    .make_unit_weights <- function(B, i) {
        out <- double(B)
        out[i] <- 1
        out
    }

    if(m == 1) {
        ## Hard partitions.
        value <- if(all(weights == 1))
            function(dissimilarities, ids)
                sum(.one_entry_per_column(dissimilarities, ids))
        else
            function(dissimilarities, ids)
                sum(weights *
                    .one_entry_per_column(dissimilarities, ids))
        opt_value <- Inf
        run <- 1L
        if(verbose && (nruns > 1L))
            message(gettextf("Pclust run: %d", run))
        repeat {
            class_ids <- max.col( - dissimilarities )
            old_value <- value(dissimilarities, class_ids)
            if(verbose)
                message(gettextf("Iteration: 0 *** value: %g", old_value))
            iter <- 1L
            while(iter <= maxiter) {
                class_ids_used <- unique(class_ids)
                for(j in class_ids_used)
                    prototypes <-
                        .modify(prototypes, j, 
                                C(x, weights * (class_ids %in% j),
                                  control))
                dissimilarities <- D(x, prototypes) ^ e
                class_ids <- max.col( - dissimilarities )
                ## Try avoiding degenerate solutions.
                if(length(class_ids_used) < k) {
                    ## Find the k - l largest
                    ## object-to-assigned-prototype dissimilarities.
                    o <- order(.one_entry_per_column(dissimilarities,
                                                     class_ids),
                               decreasing = TRUE)
                    ## Find and recompute unused prototypes.
                    unused <- setdiff(seq_len(k), class_ids_used)
                    for(j in seq_along(unused))
                        prototypes <-
                            .modify(prototypes, unused[j],
                                    C(x, .make_unit_weights(B, o[j]),
                                      control))
                    dissimilarities[, unused] <-
                        D(x, .subset(prototypes, unused)) ^ e
                    class_ids <- max.col( - dissimilarities )
                    ## For the time being, do not retry in case the
                    ## solution is still degenerate.
                }
                new_value <- value(dissimilarities, class_ids)
                if(verbose)
                    message(gettextf("Iteration: %d *** value: %g",
R/pclust.R:99

pclust_family untypeable

untypeable assignment (line 438)
error detail
variable: init
expected: null
given: (((x: DBL1 | INT1, k: 1) -> (DBL1 | INT1)<>) & ((x: DBL1 | INT1, k: dbl1) -> (DBL | INT)<>) & ((x: null, k: 1) -> empty) & ((x: v('I15537) & ~DBL1 & ~INT1, k: 1) -> v1('I15537)) & ((x: v('I15537) & ~DBL1 & ~INT1, k: dbl1) -> v('I15537)) & ((x: { 'I15536 }, k: dbl1) -> { 'I15536 }))<>
expression may be: function(...) NULL
timing: 0.623 s
source
pclust_family <-
function(D, C, init = NULL, description = NULL, e = 1,
         .modify = NULL, .subset = NULL)
{
    ## Add checking formals (lengths) eventually ...
    if(is.null(init)) {
        ## Works for list representations ...
        init <- function(x, k) sample(x, k)
    }
    .structure(list(description = description,
                    D = D, C = C, init = init, e = e,
                    .modify = .modify, .subset = .subset),
               class = "pclust_family")
}
R/pclust.R:433

cl_pclust untypeable

unbound variable (line 22)
unbound: as.cl_ensemble — one of the package’s own names, itself untyped
error detail
name: as.cl_ensemble
timing: 0.103 s
source
cl_pclust <-
function(x, k, method = NULL, m = 1, weights = 1, control = list())
{
    ## Partition a cluster ensemble x into (at most) k classes by
    ## minimizing
    ##   \sum_b \sum_j w_b u_{bj}^m d(x_b, p_j) ^ e
    ## for "suitable" prototypes p_1, ..., p_k, where 1 <= m < \infty,
    ## with 1 corresponding to hard (secondary) partitions, and d a
    ## dissimilarity measure (such as Euclidean dissimilarity of
    ## partitions or hierarchies).
    ##
    ## The algorithm works whenever there is a consensus method for
    ## solving
    ##   \sum_b u_{bj}^m d(x_b, p) ^ e => \min_p
    ##
    ## As we refer to consensus methods by their *name* (e.g., 'HBH'),
    ## we rely on the registration mechanism (set_cl_consensus_method())
    ## to provide the required information about d and e.

    clusterings <- as.cl_ensemble(x)

    type <- .cl_ensemble_type(clusterings)

    if(type == "partition") {
        ## Canonicalize by turning into an ensemble of partitions
        ## represented by membership matrices with the same (minimal)
        ## number of columns.
        memberships <-
            lapply(clusterings, cl_membership,
                   max(sapply(clusterings, n_of_classes)))
        clusterings <-
            cl_ensemble(list = lapply(memberships, as.cl_partition))
    }

    if(!inherits(method, "cl_consensus_method")) {
        ## Get required information on d and e from the registry.
        if(is.null(method))
            method <- .cl_consensus_method_default(type)
        method <- get_cl_consensus_method(method, type)
        ## Note that this avoids registry lookup in subsequent calls to
        ## cl_consensus().
        if(is.null(method$exponent))
            stop("No information on exponent in consensus method used.")
        e <- method$exponent
        if(is.null(method$dissimilarity))
            stop("No information on dissimilarity in consensus method used.")
        d <- function(x, y = NULL)
            cl_dissimilarity(x, y, method = method$dissimilarity)
    }

    family <- pclust_family(D = d, C = method$definition, e = e)
    out <- pclust(x, k, family, m, weights, control)

    ## Massage the results a bit.
    dissimilarities <- as.matrix(d(clusterings) ^ e)
    out$call <- match.call()
    out <- .structure(c(out,
                        list(silhouette =
                             silhouette(out$cluster,
                                        dmatrix = dissimilarities),
                             validity =
                             cl_validity(cl_membership(out),
                                         dissimilarities),
                             ## <NOTE>
                             ## Information about d and e is also in the
                             ## family returned, of course.  Trying to be
                             ## nice to users by "directly" providing d
                             ## and e is currently of limited usefulness
                             ## as the pclust representation is not
                             ## directly available to users.
                             d = d,
                             e = e
                             ## </NOTE>
                             )),
                      class = unique(c("cl_pclust", class(out))))

    as.cl_partition(out)
}
R/pclust.R:3

print.cl_pclust untypeabletyped

unbound variable (line 90)
unbound: n_of_objects — one of the package’s own names, itself untyped
error detail
name: n_of_objects
gradual mode: typed
∀'a. ((x: 'a & { m: 1, validity: any, any }, ...: any) | (x: 'a & { m: ~1, validity: any, any }, ...: any) -> 'a)<>
timing: 0.123 s
source
print.cl_pclust <-
function(x, ...)
{
    txt <- if(x$m == 1)
        gettextf("A hard partition of a cluster ensemble with %d elements into %d classes.",
                 n_of_objects(x), n_of_classes(x))
    else
        gettextf("A soft partition (degree m = %f) of a cluster ensemble with %d elements into %d classes.",
                x$m, n_of_objects(x), n_of_classes(x))
    writeLines(strwrap(txt))
    NextMethod("print", x, header = FALSE)
    print(x$validity, ...)
    invisible(x)
}
R/pclust.R:82

print.pclust untypeabletyped

unbound variable (line 408)
unbound: cl_class_ids — one of the package’s own names, itself untyped
error detail
name: cl_class_ids
gradual mode: typed
∀'a. ((x: 'a & { m: 1, any }, header: any?, ...: any) -> 'a)<>
timing: 0.141 s
source
print.pclust <-
function(x, header = TRUE, ...)
{
    is_hard <- (x$m == 1)
    class_ids <- cl_class_ids(x)
    if(header) {
        txt <- if(is_hard)
            gettextf("A hard partition of %d objects into %d classes.",
                     length(class_ids), n_of_classes(x))
        else
            gettextf("A soft partition (degree m = %f) of %d objects into %d classes.",
                     x$m, length(class_ids), n_of_classes(x))
        writeLines(strwrap(txt))
    }
    if(is_hard) {
        print(class_ids, ...)
    }
    else {
        writeLines("Class memberships:")
        print(cl_membership(x), ...)
        writeLines("Class ids of closest hard partition:")
        print(unclass(class_ids), ...)
    }
    invisible(x)
}
R/pclust.R:404
R/tabulate.R

cl_tabulate untypeabletyped

unbound variable (line 4)
unbound: unique — a name the prelude does not declare
error detail
name: unique
gradual mode: typed
((x: any) -> any)<>
timing: 0.004 s
source
cl_tabulate <-
function(x)
{
    values <- unique(x)
    counts <- tabulate(match(x, values))
    ## Still a bit tricky to create a data frame with a list "column"
    ## which is not protected by I(); otherwise, we oculd simply do
    ##   data.frame(values = I(values), counts = counts)
    out <- data.frame(values = double(length(values)), counts = counts)
    out$values <- values
    out
}
R/tabulate.R:1