void sipg_sem_1d<FLOAT_TYPE>::compute_nodes_and_weights() { const int nop = sem_function<FLOAT_TYPE>::_qt.nop(); _x.resize(_vec_size); _w.resize(_vec_size); for (int e = 0; e < _noe; ++e) for (int i = 0; i < nop; ++i) { _x[e*nop + i] = (SEM_FUNC::_qt.node(i)/_noe) - (FLOAT_TYPE(_noe-1)/FLOAT_TYPE(_noe)) + 2.*e*(1./FLOAT_TYPE(_noe)) ; _w[e*nop + i] = SEM_FUNC::_qt.weight(i)/_noe; } }
int APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, int *sign, char *buf, size_t len) { int exponent = 0; if (!ISNAN (value) && !ISINF (value) && value != 0.0) { FLOAT_TYPE (*log10_function) (FLOAT_TYPE) = &LOG10; if (log10_function) { /* Use the reasonable code if -lm is included. */ FLOAT_TYPE dexponent; dexponent = FLOOR (LOG10 (FABS (value))); value *= EXP (dexponent * -M_LN10); exponent = (int) dexponent; } else { /* Slow code that doesn't require -lm functions. */ FLOAT_TYPE d; if (value < 0.0) d = -value; else d = value; if (d < 1.0) { do { d *= 10.0; --exponent; } while (d < 1.0); } else if (d >= 10.0) { do { d *= 0.1; ++exponent; } while (d >= 10.0); } if (value < 0.0) value = -d; else value = d; } } else if (value == 0.0) /* SUSv2 leaves it unspecified whether *DECPT is 0 or 1 for 0.0. * This could be changed to -1 if we want to return 0. */ exponent = 0; if (ndigit <= 0 && len > 0) { buf[0] = '\0'; *decpt = 1; if (!ISINF (value) && !ISNAN (value)) *sign = value < 0.0; else *sign = 0; } else if (APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit - 1, decpt, sign, buf, len)) return -1; *decpt += exponent; return 0; }