static complex * c_tan(complex *cc, int length) { complex *c; int i; c = alloc_c(length); for (i = 0; i < length; i++) { double u, v; rcheck(cos(degtorad(realpart(&cc[i]))) * cosh(degtorad(imagpart(&cc[i]))), "tan"); rcheck(sin(degtorad(realpart(&cc[i]))) * sinh(degtorad(imagpart(&cc[i]))), "tan"); u = degtorad(realpart(&cc[i])); v = degtorad(imagpart(&cc[i])); /* The Lattice C compiler won't take multi-line macros, and * CMS won't take >80 column lines.... */ #define xx1 sin(u) * cosh(v) #define xx2 cos(u) * sinh(v) #define xx3 cos(u) * cosh(v) #define xx4 sin(u) * sinh(v) cdiv(xx1, xx2, xx3, xx4, realpart(&c[i]), imagpart(&c[i])); } return c; }
void * cx_mean(void *data, short int type, int length, int *newlength, short int *newtype, ...) { *newlength = 1; rcheck(length > 0, "mean"); if (type == VF_REAL) { double *d; double *dd = (double *) data; int i; d = alloc_d(1); *newtype = VF_REAL; for (i = 0; i < length; i++) *d += dd[i]; *d /= length; return ((void *) d); } else { complex *c; complex *cc = (complex *) data; int i; c = alloc_c(1); *newtype = VF_COMPLEX; for (i = 0; i < length; i++) { realpart(c) += realpart(cc + i); imagpart(c) += imagpart(cc + i); } realpart(c) /= length; imagpart(c) /= length; return ((void *) c); } }
T as_int() const { int64_t i = as_int(); T t = static_cast<T>(i); rcheck(static_cast<int64_t>(t) == i, base_exc_t::LOGIC, strprintf("Integer too large: %" PRIi64, i)); return t; }
static double * d_tan(double *dd, int length) { double *d; int i; d = alloc_d(length); for (i = 0; i < length; i++) { rcheck(cos(degtorad(dd[i])) != 0, "tan"); d[i] = sin(degtorad(dd[i])) / cos(degtorad(dd[i])); } return d; }
void * cx_mod(void *data1, void *data2, short int datatype1, short int datatype2, int length, ...) { double *dd1 = (double *) data1; double *dd2 = (double *) data2; double *d; complex *cc1 = (complex *) data1; complex *cc2 = (complex *) data2; complex *c, c1, c2; int i, r1, r2, i1, i2, r3, i3; if ((datatype1 == VF_REAL) && (datatype2 == VF_REAL)) { d = alloc_d(length); for (i = 0; i < length; i++) { r1 = floor(FTEcabs(dd1[i])); rcheck(r1 > 0, "mod"); r2 = floor(FTEcabs(dd2[i])); rcheck(r2 > 0, "mod"); r3 = r1 % r2; d[i] = (double) r3; } return ((void *) d); } else { c = alloc_c(length); for (i = 0; i < length; i++) { if (datatype1 == VF_REAL) { realpart(&c1) = dd1[i]; imagpart(&c1) = 0.0; } else { realpart(&c1) = realpart(&cc1[i]); imagpart(&c1) = imagpart(&cc1[i]); } if (datatype2 == VF_REAL) { realpart(&c2) = dd2[i]; imagpart(&c2) = 0.0; } else { realpart(&c2) = realpart(&cc2[i]); imagpart(&c2) = imagpart(&cc2[i]); } r1 = floor(FTEcabs(realpart(&c1))); rcheck(r1 > 0, "mod"); r2 = floor(FTEcabs(realpart(&c2))); rcheck(r2 > 0, "mod"); i1 = floor(FTEcabs(imagpart(&c1))); rcheck(i1 > 0, "mod"); i2 = floor(FTEcabs(imagpart(&c2))); rcheck(i2 > 0, "mod"); r3 = r1 % r2; i3 = i1 % i2; realpart(&c[i]) = (double) r3; imagpart(&c[i]) = (double) i3; } return ((void *) c); } }
bool SuifValidater::is_valid( SuifObject* root) { if (root == NULL) SUIF_THROW(SuifException("Cannot validate NULL.")); bool ok_stat = is_valid_ownership(root); RefChecker rcheck(root->get_suif_env(), this); root->walk(rcheck); ok_stat &= rcheck.is_ok(); for (Iter<SymbolTable> it = object_iterator<SymbolTable>(root); it.is_valid(); it.next()) { ok_stat &= is_valid_SymbolTable(&(it.current())); } return ok_stat; }
void * cx_d(void *data, short int type, int length, int *newlength, short int *newtype, ...) { *newlength = length; /* test if length >0 et affiche un message d'erreur */ rcheck(length > 0, "deriv"); if (type == VF_REAL) { double *d; double *dd = (double *) data; int i; d = alloc_d(length); *newtype = VF_REAL; d[0]=dd[1]-dd[0]; d[length-1]=dd[length-1]-dd[length-2]; for (i = 1; i < length-1; i++) d[i]=dd[i+1]-dd[i-1]; return ((void *) d); } else { complex *c; complex *cc = (complex *) data; int i; c = alloc_c(length); *newtype = VF_COMPLEX; realpart(c)=realpart(cc+1)-realpart(cc); imagpart(c)=imagpart(cc+1)-imagpart(cc); realpart(c+length-1)=realpart(cc+length-1)-realpart(cc+length-2); imagpart(c+length-1)=imagpart(cc+length-1)-imagpart(cc+length-2); for (i = 1; i < (length-1); i++) { realpart(c+i)=realpart(cc+i+1)-realpart(cc+i-1); imagpart(c+i)=imagpart(cc+i+1)-imagpart(cc+i-1); } return ((void *) c); } }
void * cx_min(void *data, short int type, int length, int *newlength, short int *newtype, ...) { *newlength = 1; /* test if length >0 et affiche un message d'erreur */ rcheck(length > 0, "mean"); if (type == VF_REAL) { double smallest; double *d; double *dd = (double *) data; int i; d = alloc_d(1); *newtype = VF_REAL; smallest=dd[0]; for (i = 1; i < length; i++) if (dd[i]<smallest) smallest=dd[i]; *d=smallest; return ((void *) d); } else { double smallest_real; double smallest_complex; complex *c; complex *cc = (complex *) data; int i; c = alloc_c(1); *newtype = VF_COMPLEX; smallest_real=realpart(cc); smallest_complex=imagpart(cc); for (i = 1; i < length; i++) { if (realpart(cc + i)<smallest_real) smallest_real=realpart(cc + i); if (imagpart(cc + i)<smallest_complex) smallest_complex=imagpart(cc + i); } realpart(c) = smallest_real; imagpart(c) = smallest_complex; return ((void *) c); } }