Skip to content

Commit

Permalink
use boolean vector to see what types an xform supports - #511
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 26, 2024
1 parent d712a4d commit 0425f1b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/PDL/Core/pdlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,6 @@ static inline pdl_error pdl__transtype_select(
) {
pdl_error PDL_err = {0, NULL, 0};
*retval = PDL_INVALID;
pdl_datatypes last_dtype = PDL_INVALID;
PDL_Indx i;
pdl_transvtable *vtable = trans->vtable;
for (i=0; i<vtable->npdls; i++) {
Expand All @@ -1104,8 +1103,11 @@ static inline pdl_error pdl__transtype_select(
"%s: ndarray %s must be real, but is type %s",
vtable->name, vtable->par_names[i], PDL_TYPENAME(dtype));
}
if (vtable->gentypes[0] != PDL_INVALID &&
vtable->gentypes[1] == PDL_INVALID) {
char type_avail[PDL.ntypes]; for (i=0; i<PDL.ntypes; i++) type_avail[i] = 0;
pdl_datatypes last_dtype = PDL_INVALID;
for (i=0; vtable->gentypes[i]!=-1; i++)
type_avail[last_dtype = vtable->gentypes[i]] = 1;
if (vtable->gentypes[0] == last_dtype) {
*retval = vtable->gentypes[0]; /* only one allowed type, use that */
return PDL_err;
}
Expand All @@ -1130,12 +1132,7 @@ static inline pdl_error pdl__transtype_select(
))
*retval = new_transtype;
}
for (i=0; vtable->gentypes[i]!=-1; i++) {
last_dtype = vtable->gentypes[i];
if (*retval != last_dtype) continue;
return PDL_err;
}
*retval = last_dtype;
if (!type_avail[*retval]) *retval = last_dtype;
return PDL_err;
}

Expand Down

0 comments on commit 0425f1b

Please sign in to comment.