Raise a "Mathematic error" if the real or imaginary part of a complex number is not finite.
[GB.COMPLEX] * NEW: Raise a "Mathematic error" if the real or imaginary part of a complex number is not finite.
This commit is contained in:
parent
50e5bba9df
commit
0fcacdebdf
2 changed files with 13 additions and 0 deletions
|
@ -40,6 +40,12 @@ CCOMPLEX *COMPLEX_create(double re, double im)
|
|||
static GB_CLASS CLASS_Complex = (GB_CLASS)NULL;
|
||||
CCOMPLEX *c;
|
||||
|
||||
if (!isfinite(re) || !isfinite(im))
|
||||
{
|
||||
GB.Error(GB_ERR_MATH);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CLASS_Complex)
|
||||
CLASS_Complex = GB.FindClass("Complex");
|
||||
|
||||
|
@ -56,6 +62,12 @@ static inline CCOMPLEX *COMPLEX_make(CCOMPLEX *a, const double re, const double
|
|||
{
|
||||
if (a->ob.ref <= 1)
|
||||
{
|
||||
if (!isfinite(re) || !isfinite(im))
|
||||
{
|
||||
GB.Error(GB_ERR_MATH);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
a->v[0] = re;
|
||||
a->v[1] = im;
|
||||
return a;
|
||||
|
|
|
@ -331,6 +331,7 @@ typedef
|
|||
#define GB_ERR_NOBJECT ((char *)12)
|
||||
#define GB_ERR_NWRITE ((char *)16)
|
||||
#define GB_ERR_NPROPERTY ((char *)17)
|
||||
#define GB_ERR_MATH ((char *)19)
|
||||
#define GB_ERR_ARG ((char *)20)
|
||||
#define GB_ERR_BOUND ((char *)21)
|
||||
#define GB_ERR_ZERO ((char *)26)
|
||||
|
|
Loading…
Reference in a new issue