Skip to content

Commit

Permalink
Removed comments. Fixed can_cast so that 64-bit integer can be cast s…
Browse files Browse the repository at this point in the history
…afely to a double precision.
  • Loading branch information
teoliphant committed Oct 11, 2005
1 parent 9edde60 commit 3fc25bb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
38 changes: 34 additions & 4 deletions scipy/base/src/arrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5514,8 +5514,6 @@ PyArray_CanCastSafely(int fromtype, int totype)
case PyArray_BYTE:
case PyArray_SHORT:
case PyArray_INT:
case PyArray_LONG:
case PyArray_LONGLONG:
if (PyTypeNum_ISINTEGER(totype)) {
if (PyTypeNum_ISUNSIGNED(totype)) {
return (to->elsize > from->elsize);
Expand All @@ -5531,11 +5529,26 @@ PyArray_CanCastSafely(int fromtype, int totype)
return ((to->elsize >> 1) > from->elsize);
}
else return totype > fromtype;
case PyArray_LONG:
case PyArray_LONGLONG:
if (PyTypeNum_ISINTEGER(totype)) {
if (PyTypeNum_ISUNSIGNED(totype)) {
return (to->elsize > from->elsize);
}
else {
return (to->elsize >= from->elsize);
}
}
else if (PyTypeNum_ISFLOAT(totype)) {
return (to->elsize >= from->elsize);
}
else if (PyTypeNum_ISCOMPLEX(totype)) {
return ((to->elsize >> 1) >= from->elsize);
}
else return totype > fromtype;
case PyArray_UBYTE:
case PyArray_USHORT:
case PyArray_UINT:
case PyArray_ULONG:
case PyArray_ULONGLONG:
if (PyTypeNum_ISINTEGER(totype)) {
if (PyTypeNum_ISSIGNED(totype)) {
return (to->elsize > from->elsize);
Expand All @@ -5551,6 +5564,23 @@ PyArray_CanCastSafely(int fromtype, int totype)
return ((to->elsize >> 1) > from->elsize);
}
else return totype > fromtype;
case PyArray_ULONG:
case PyArray_ULONGLONG:
if (PyTypeNum_ISINTEGER(totype)) {
if (PyTypeNum_ISSIGNED(totype)) {
return (to->elsize > from->elsize);
}
else {
return (to->elsize >= from->elsize);
}
}
else if (PyTypeNum_ISFLOAT(totype)) {
return (to->elsize >= from->elsize);
}
else if (PyTypeNum_ISCOMPLEX(totype)) {
return ((to->elsize >> 1) >= from->elsize);
}
else return totype > fromtype;
case PyArray_FLOAT:
case PyArray_DOUBLE:
case PyArray_LONGDOUBLE:
Expand Down
10 changes: 3 additions & 7 deletions scipy/base/src/ufuncobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,8 @@ PyUFunc_g_g(char **args, intp *dimensions, intp *steps, void *func)
intp n=dimensions[0];
char *ip1=args[0], *op=args[1];
for(i=0; i<n; i++, ip1+=steps[0], op+=steps[1]) {
fprintf(stderr, "expl = %p, sqrtl = %p\n", expl, sqrtl);
fprintf(stderr, "Called %p with %Lf: ",
func, *(longdouble *)ip1);
*(longdouble *)op = ((LongdoubleUnaryFunc *)func)(*(longdouble *)ip1);
fprintf(stderr, "Answer was %Lf.\n",
*(longdouble *)op);
*(longdouble *)op = ((LongdoubleUnaryFunc *)func)\
(*(longdouble *)ip1);
}
}

Expand Down Expand Up @@ -2034,7 +2030,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind,
for (i=0; i<nn; i++) {
if ((*ptr < 0) || (*ptr > mm)) {
PyErr_Format(PyExc_IndexError,
"index out-of-bounds (0, %d)", mm);
"index out-of-bounds (0, %d)", (int) mm);
return NULL;
}
ptr++;
Expand Down

0 comments on commit 3fc25bb

Please sign in to comment.