Exemple #1
0
Fichier : exp2l.c Projet : 5kg/osv
long double exp2l(long double x)
{
	return exp2(x);
}
Exemple #2
0
float exp2f (float x)
{
	return (float) exp2( (double)x );
}
int
ipmi_sensor_decode_raw_value (int8_t r_exponent,
                              int8_t b_exponent,
                              int16_t m,
                              int16_t b,
                              uint8_t linearization,
                              uint8_t analog_data_format,
                              double value,
                              uint8_t *raw_data)
{
  double dval;
  uint8_t rval;

  if (!raw_data
      || !IPMI_SDR_ANALOG_DATA_FORMAT_VALID (analog_data_format)
      || !IPMI_SDR_LINEARIZATION_IS_LINEAR (linearization))
    {
      SET_ERRNO (EINVAL);
      return (-1);
    }

  dval = value;

  /* achu:
   *
   * b/c I always forget:
   *
   * y = log_b(x) == x = b^y
   *
   * log_b(x) = log_k(x)/log(k(b)
   */
  /* achu: the macros M_E or M_El for 'e' is questionably portable.
   * Folks online suggest just using exp(1.0) in its place.  Sounds
   * good to me.
   */
  switch (linearization)
    {
    case IPMI_SDR_LINEARIZATION_LN:
      dval = exp (dval);
      break;
    case IPMI_SDR_LINEARIZATION_LOG10:
      dval = exp10 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_LOG2:
      dval = exp2 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_E:
      dval = (log (dval)/log (exp (1.0)));
      break;
    case IPMI_SDR_LINEARIZATION_EXP10:
      dval = (log (dval)/log (10));
      break;
    case IPMI_SDR_LINEARIZATION_EXP2:
      dval = (log (dval)/log (2));
      break;
    case IPMI_SDR_LINEARIZATION_INVERSE:
      if (dval != 0.0)
        dval = 1.0 / dval;
      break;
    case IPMI_SDR_LINEARIZATION_SQR:
      dval = sqrt (dval);
      break;
    case IPMI_SDR_LINEARIZATION_CUBE:
      dval = cbrt (dval);
      break;
    case IPMI_SDR_LINEARIZATION_SQRT:
      dval = pow (dval, 2.0);
      break;
    case IPMI_SDR_LINEARIZATION_CUBERT:
      dval = pow (dval, 3.0);
      break;
    }

  dval = (dval / pow (10, r_exponent));
  dval = (dval - (b * pow (10, b_exponent)));
  if (m)
    dval = (dval / m);

  /* Floating point arithmetic cannot guarantee us a perfect
   * conversion of raw to value and back to raw.  This can
   * fix things.
   */
  if ((dval - (int)dval) >= 0.5)
    dval = ceil (dval);
  else
    dval = floor (dval);

  if (analog_data_format == IPMI_SDR_ANALOG_DATA_FORMAT_UNSIGNED)
    rval = (uint8_t) dval;
  else if (analog_data_format == IPMI_SDR_ANALOG_DATA_FORMAT_1S_COMPLEMENT)
    {
      rval = (char)dval;
      if (rval & 0x80)
        rval--;
    }
  else /* analog_data_format == IPMI_SDR_ANALOG_DATA_FORMAT_2S_COMPLEMENT */
    rval = (char)dval;

  *raw_data = rval;
  return (0);
}
Exemple #4
0
 static inline T fun(const T& x) {
   return exp2(x);
 }
Exemple #5
0
tr1::shared_ptr<AbstractNumber> E::multiply(tr1::shared_ptr<AbstractNumber>number){
    char newSign = '-';
    if (getSign() == number->getSign())
    {
        newSign = '+';
    }

    if(number -> getName() == "E")
	{
	    if (newSign == '+')
        {
            tr1::shared_ptr<AbstractNumber> exp(new SmartInteger(2));
            tr1::shared_ptr<AbstractNumber> me(new E());
            tr1::shared_ptr<AbstractNumber> ans(new Exponent(me, exp));
            return ans;
        }
        else
        {
            tr1::shared_ptr<AbstractNumber> exp(new SmartInteger(-2));
            tr1::shared_ptr<AbstractNumber> me(new E());
            tr1::shared_ptr<AbstractNumber> ans(new Exponent(me, exp));
            return ans;
        }
	}

	else if (number -> getName() == "Exponent")
	{
	    tr1::shared_ptr<Exponent> numExp = tr1::static_pointer_cast<Exponent>(number);
		if (numExp -> getValue("base") -> getName() == "E")
		{
			tr1::shared_ptr<AbstractNumber> exp = numExp->getValue("power");
			tr1::shared_ptr<AbstractNumber> exp2(new SmartInteger(1));
			tr1::shared_ptr<AbstractNumber> me(new E());

			tr1::shared_ptr<AbstractNumber> ans2(new Exponent(me, exp -> add(exp2), newSign));
			return ans2;
		}
	}
	else if (number->getName() == "Radical") {
		 if (abs(number->getValue("value")->toDouble() - toDouble()) < 0.000001 )
		 {
			 tr1::shared_ptr<AbstractNumber> one(new SmartInteger(1));
			 tr1::shared_ptr<AbstractNumber> invertedRoot(new MultExpression(one, number->getValue("root"), '+'));
			 tr1::shared_ptr<AbstractNumber> me(new E());
			 tr1::shared_ptr<AbstractNumber> output(new Exponent(me, invertedRoot->add(one), newSign));
			 return output;
		 }
		 else
         {
            vector<tr1::shared_ptr<AbstractNumber> > M;
            M.push_back(number);
            M.push_back(shared_from_this());
            tr1::shared_ptr<AbstractNumber> ans3(new MultExpression(M, '+'));
            return ans3;
         }
	 }

    else if(number->getName() == "MultExpression")
    {
        return number->multiply(shared_from_this());
    }
    vector<tr1::shared_ptr<AbstractNumber> > M;
    M.push_back(number);
    M.push_back(shared_from_this());
    tr1::shared_ptr<AbstractNumber> ans3(new MultExpression(M, '+'));
    return ans3;

}
Exemple #6
0
/*
 * The bits are decoded from the signal using an exponential low-pass filter in
 * conjunction with a Schmitt trigger. The idea and the initial implementation
 * for this come from Udo Klein, with permission.
 * http://blog.blinkenlight.net/experiments/dcf77/binary-clock/#comment-5916
 */
struct GB_result
get_bit_live(void)
{
	char outch;
	bool newminute = false;
	unsigned stv = 1;
	int p;
	struct timespec slp;
#if !defined(MACOS)
	struct timespec tp0, tp1;
#endif
	unsigned sec2;
	long long a, y = 1000000000;
	long long twait;
	static int init_bit = 2;
	bool is_eom = gb_res.marker == emark_minute ||
	    gb_res.marker == emark_late;

	bit.freq_reset = false;
	bit.bitlen_reset = false;

	set_new_state();

	/*
	 * One period is either 1000 ms or 2000 ms long (normal or padding for
	 * last). The active part is either 100 ms ('0') or 200 ms ('1') long.
	 * The maximum allowed values as percentage of the second length are
	 * specified as half the value and the whole value of the lengths of
	 * bit 0 and bit 20 respectively.
	 *
	 *  ~A > 3/2 * realfreq: end-of-minute
	 *  ~A > 5/2 * realfreq: timeout
	 */

	if (init_bit == 2) {
		bit.realfreq = hw.freq * 1000000;
		bit.bit0 = bit.realfreq / 10;
		bit.bit20 = bit.realfreq / 5;
	}
	sec2 = 1000000000 / (hw.freq * hw.freq);
	/*
	 * Set up filter, reach 50% after realfreq/20 samples (i.e. 50 ms)
	 */
	a = 1000000000 - (long long)(1000000000 * exp2(-2e7 / bit.realfreq));
	bit.tlow = -1;
	bit.tlast0 = -1;

	for (bit.t = 0; bit.t != 0xFFFFFFFF; bit.t++) {
#if !defined(MACOS)
		(void)clock_gettime(CLOCK_MONOTONIC, &tp0);
#endif
		p = get_pulse();
		if (p == 2) {
			gb_res.bad_io = true;
			outch = '*';
			goto report;
		}
		if (bit.signal != NULL) {
			if ((bit.t & 7) == 0)
				bit.signal[bit.t / 8] = 0;
				/* clear data from previous second */
			bit.signal[bit.t / 8] |= p << (unsigned char)(bit.t & 7);
		}

		if (y >= 0 && y < a / 2)
			bit.tlast0 = (int)bit.t;
		y += a * (p * 1000000000 - y) / 1000000000;

		/*
		 * Prevent algorithm collapse during thunderstorms
		 * or scheduler abuse
		 */
		if (bit.realfreq <= hw.freq * 500000 ||
		    bit.realfreq >= hw.freq * 1500000)
			reset_frequency();

		if (bit.t > bit.realfreq * 2500000) {
			bit.realfreq += ((long long)
			    (bit.t * 2500000 - bit.realfreq) / 20);
			a = 1000000000 - (long long)(1000000000 *
			     exp2(-2e7 / bit.realfreq));
			if (bit.tlow * 100 / bit.t < 1) {
				gb_res.hwstat = ehw_receive;
				outch = 'r';
			} else if (bit.tlow * 100 / bit.t >= 99) {
				gb_res.hwstat = ehw_transmit;
				outch = 'x';
			} else {
				gb_res.hwstat = ehw_random;
				outch = '#';
			}
			goto report; /* timeout */
		}

		/*
		 * Schmitt trigger, maximize value to introduce
		 * hysteresis and to avoid infinite memory.
		 */
		if (y < 500000000 && stv == 1) {
			/* end of high part of second */
			y = 0;
			stv = 0;
			bit.tlow = (int)bit.t;
		}
		if (y > 500000000 && stv == 0) {
			/* end of low part of second */
			y = 1000000000;
			stv = 1;

			newminute = bit.t * 2000000 > bit.realfreq * 3;
			if (init_bit == 2)
				init_bit--;
			else {
				if (newminute)
					bit.realfreq += ((long long)(bit.t *
					    500000 - bit.realfreq) / 20);
				else
					bit.realfreq += ((long long)(bit.t *
					    1000000 - bit.realfreq) / 20);
				a = 1000000000 - (long long)(1000000000 *
				    exp2(-2e7 / bit.realfreq));
			}

			if (newminute) {
				/*
				 * Reset the frequency and the EOM flag if two
				 * consecutive EOM markers come in, which means
				 * something is wrong.
				 */
				if (is_eom) {
					if (gb_res.marker == emark_minute)
						gb_res.marker = emark_none;
					else if (gb_res.marker == emark_late)
						gb_res.marker = emark_toolong;
					reset_frequency();
				} else {
					if (gb_res.marker == emark_none)
						gb_res.marker = emark_minute;
					else if (gb_res.marker == emark_toolong)
						gb_res.marker = emark_late;
				}
			}
			break; /* start of new second */
		}
		twait = (long long)(sec2 * bit.realfreq / 1000000);
#if !defined(MACOS)
		(void)clock_gettime(CLOCK_MONOTONIC, &tp1);
		twait = twait - (tp1.tv_sec - tp0.tv_sec) * 1000000000 -
		   (tp1.tv_nsec - tp0.tv_nsec);
#endif
		slp.tv_sec = twait / 1000000000;
		slp.tv_nsec = twait % 1000000000;
		while (twait > 0 && nanosleep(&slp, &slp))
			;
	}

	if (2 * bit.realfreq * bit.tlow * (1 + (newminute ? 1 : 0)) <
	    (bit.bit0 + bit.bit20) * bit.t) {
		/* zero bit, ~100 ms active signal */
		gb_res.bitval = ebv_0;
		outch = '0';
		buffer[bitpos] = 0;
	} else if (bit.realfreq * bit.tlow * (1 + (newminute ? 1 : 0)) <
	    (bit.bit0 + bit.bit20) * bit.t) {
		/* one bit, ~200 ms active signal */
		gb_res.bitval = ebv_1;
		outch = '1';
		buffer[bitpos] = 1;
	} else {
		/* bad radio signal, retain old value */
		gb_res.bitval = ebv_none;
		outch = '_';
		/* force bit 20 to be 1 to recover from too low b20 value */
		if (bitpos == 20) {
			gb_res.bitval = ebv_1;
			outch = '1';
			buffer[20] = 1;
		}
	}
	if (init_bit == 1)
		init_bit--;
	else if (gb_res.hwstat == ehw_ok && gb_res.marker == emark_none) {
		if (bitpos == 0 && gb_res.bitval == ebv_0)
			bit.bit0 += ((long long)
			    (bit.tlow * 1000000 - bit.bit0) / 2);
		if (bitpos == 20 && gb_res.bitval == ebv_1)
			bit.bit20 += ((long long)
			    (bit.tlow * 1000000 - bit.bit20) / 2);
		/* During a thunderstorm the value of bit20 might underflow */
		if (bit.bit20 < bit.bit0)
			reset_bitlen();
	}
report:
	acc_minlen += 1000000 * bit.t / (bit.realfreq / 1000);
	if (logfile != NULL) {
		fprintf(logfile, "%c", outch);
		if (gb_res.marker == emark_minute ||
		    gb_res.marker == emark_late)
			fprintf(logfile, "a%uc%6.4f\n", acc_minlen,
			    (double)((bit.t * 1e6) / bit.realfreq));
	}
	if (gb_res.marker == emark_minute || gb_res.marker == emark_late)
		cutoff = bit.t * 1000000 / (bit.realfreq / 10000);
	return gb_res;
}
__attribute__((weak)) long double exp2l(long double x) { return exp2((double)x); }
Exemple #8
0
        void doBuildNode(
            const typename NodeTypes<Status, T>::ValueList& valueList,
            const PointList& pointList,
            int depthRemaining,
            bool trueBranch,
            const State& collectedState,
            Node<Status, T>& result)
        {
            typedef typename NodeTypes<Status, T>::ValuePtr ValuePtr;
            typedef typename NodeTypes<Status, T>::ValueList ValueList;

            if (valueList.empty() ||
                    pointList.empty() ||
                    depthRemaining == 0) {
                result = createLeaf<Status, T>(valueList, depthRemaining, collectedState);
                return;
            }
            assert(!valueList.empty());
            if (checker_ && !checkState(
                    *checker_,
                    valueList.front()->first.table(),
                    collectedState)) {
                {
                    boost::unique_lock<MutexType> lock(progressMutex_);
                    ++numLeafsSaved_;
                    numLeafsSavedExp_ += static_cast<int>(exp2(depthRemaining));
                }
                result = createLeaf<Status, T>(ValueList(), depthRemaining, collectedState);
                return;
            }

            std::vector<Point> newFunctorList;
            boost::optional<Point> point;
            State newCollectedState(collectedState);
            if (trueBranch) {
                point = fastFilterPointList(
                        pointList, newFunctorList);
                assert(point);
            } else {
                point = filterPointList(
                        valueList, pointList, newFunctorList);
            }
            if (!point) {
                result = createLeaf<Status, T>(valueList, depthRemaining, collectedState);
                return;
            }
            newCollectedState.addStone(*point);

            ValueList falseValues;
            boost::remove_copy_if(valueList,
                    std::back_inserter(falseValues),
                    [&point](const ValuePtr& value)
                    { return isStone(value->first, *point); });

            assert(falseValues.size() != valueList.size());
            result = DecisionNode<Status, T, Node<Status, T>>(*point);
            buildDecisionChildren<Status, T, PointList>(
                    falseValues, valueList,
                    newFunctorList, depthRemaining - 1,
                    collectedState, newCollectedState,
                    result);

        } // doBuildNode
Exemple #9
0
void
ags_note_edit_reset_horizontally(AgsNoteEdit *note_edit, guint flags)
{
  AgsEditor *editor;

  editor = (AgsEditor *) gtk_widget_get_ancestor(GTK_WIDGET(note_edit),
						 AGS_TYPE_EDITOR);

  if(editor->selected_machine != NULL){
    cairo_t *cr;
    gdouble value;
    double tact_factor, zoom_factor;
    double tact;

    value = GTK_RANGE(note_edit->hscrollbar)->adjustment->value;

    zoom_factor = 0.25;

    tact_factor = exp2(8.0 - (double) gtk_combo_box_get_active(editor->toolbar->zoom));
    tact = exp2((double) gtk_combo_box_get_active(editor->toolbar->zoom) - 4.0);

    if((AGS_NOTE_EDIT_RESET_WIDTH & flags) != 0){
      note_edit->control_unit.control_width = (guint) (((double) note_edit->control_width * zoom_factor * tact));

      note_edit->control_current.control_count = (guint) ((double) note_edit->control_unit.control_count * tact);
      note_edit->control_current.control_width = (note_edit->control_width * zoom_factor * tact_factor * tact);

      note_edit->map_width = (guint) ((double) note_edit->control_current.control_count * (double) note_edit->control_current.control_width);
    }

    if((AGS_NOTE_EDIT_RESET_HSCROLLBAR & flags) != 0){
      GtkWidget *widget;
      GtkAdjustment *adjustment;
      guint width;

      widget = GTK_WIDGET(note_edit->drawing_area);
      adjustment = GTK_RANGE(note_edit->hscrollbar)->adjustment;

      if(note_edit->map_width > widget->allocation.width){
	width = widget->allocation.width;
	//	gtk_adjustment_set_upper(adjustment, (double) (note_edit->map_width - width));
	gtk_adjustment_set_upper(adjustment,
				 (gdouble) (note_edit->map_width - width));

	if(adjustment->value > adjustment->upper)
	  gtk_adjustment_set_value(adjustment, adjustment->upper);
      }else{
	width = note_edit->map_width;

	gtk_adjustment_set_upper(adjustment, 0.0);
	gtk_adjustment_set_value(adjustment, 0.0);
      }

      note_edit->width = width;
    }

    /* reset AgsNoteEditControlCurrent */
    if(note_edit->map_width > note_edit->width){
      note_edit->control_current.x0 = ((guint) round((double) value)) % note_edit->control_current.control_width;

      if(note_edit->control_current.x0 != 0){
	note_edit->control_current.x0 = note_edit->control_current.control_width - note_edit->control_current.x0;
      }

      note_edit->control_current.x1 = (note_edit->width - note_edit->control_current.x0) % note_edit->control_current.control_width;

      note_edit->control_current.nth_x = (guint) ceil((double)(value) / (double)(note_edit->control_current.control_width));
    }else{
      note_edit->control_current.x0 = 0;
      note_edit->control_current.x1 = 0;
      note_edit->control_current.nth_x = 0;
    }

    /* reset AgsNoteEditControlUnit */
    if(note_edit->map_width > note_edit->width){
      note_edit->control_unit.x0 = ((guint)round((double) value)) % note_edit->control_unit.control_width;

      if(note_edit->control_unit.x0 != 0)
	note_edit->control_unit.x0 = note_edit->control_unit.control_width - note_edit->control_unit.x0;
      
      note_edit->control_unit.x1 = (note_edit->width - note_edit->control_unit.x0) % note_edit->control_unit.control_width;
      
      note_edit->control_unit.nth_x = (guint) ceil(round((double) value) / (double) (note_edit->control_unit.control_width));
      note_edit->control_unit.stop_x = note_edit->control_unit.nth_x + (note_edit->width - note_edit->control_unit.x0 - note_edit->control_unit.x1) / note_edit->control_unit.control_width;
    }else{
      note_edit->control_unit.x0 = 0;
      note_edit->control_unit.x1 = 0;
      note_edit->control_unit.nth_x = 0;
    }

    /* refresh display */
    if(GTK_WIDGET_VISIBLE(editor)){
      gdouble position;
      
      cr = gdk_cairo_create(GTK_WIDGET(note_edit->drawing_area)->window);
      cairo_push_group(cr);

      ags_note_edit_draw_segment(note_edit, cr);
      ags_note_edit_draw_notation(note_edit, cr);

      if(editor->toolbar->selected_edit_mode == editor->toolbar->position){
	ags_note_edit_draw_position(note_edit, cr);
      }

      //TODO:JK: implement me
      //      position = gtk_range_get_value(GTK_RANGE(note_edit->hscrollbar));
      //      position -= floor(position / note_edit->control_current.control_width);
      //      ags_note_edit_draw_scroll(note_edit, cr,
      //				position);

      cairo_pop_group_to_source(cr);
      cairo_paint(cr);
    }
  }
}
Exemple #10
0
double cents_to_Hz(double cents)
{
    assert(isfinite(cents));
    return exp2(cents / 1200.0) * 440;
}
Exemple #11
0
/*
 * exp2l(x): compute the base 2 exponential of x
 *
 * Accuracy: Peak error < 0.511 ulp.
 *
 * Method: (equally-spaced tables)
 *
 *   Reduce x:
 *     x = 2**k + y, for integer k and |y| <= 1/2.
 *     Thus we have exp2l(x) = 2**k * exp2(y).
 *
 *   Reduce y:
 *     y = i/TBLSIZE + z for integer i near y * TBLSIZE.
 *     Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
 *     with |z| <= 2**-(TBLBITS+1).
 *
 *   We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
 *   degree-6 minimax polynomial with maximum error under 2**-69.
 *   The table entries each have 104 bits of accuracy, encoded as
 *   a pair of double precision values.
 */
long double
exp2l(long double x)
{
	union IEEEl2bits u, v;
	long double r, z;
	long double twopk = 0, twopkp10000 = 0;
	uint32_t hx, ix, i0;
	int k;

	/* Filter out exceptional cases. */
	u.e = x;
	hx = u.xbits.expsign;
	ix = hx & EXPMASK;
	if (ix >= BIAS + 14) {		/* |x| >= 16384 or x is NaN */
		if (ix == BIAS + LDBL_MAX_EXP) {
			if (u.xbits.man != 1ULL << 63 || (hx & 0x8000) == 0)
				return (x + x);	/* x is +Inf or NaN */
			else
				return (0.0);	/* x is -Inf */
		}
		if (x >= 16384)
			return (huge * huge);	/* overflow */
		if (x <= -16446)
			return (twom10000 * twom10000);	/* underflow */
	} else if (ix <= BIAS - 66) {		/* |x| < 0x1p-66 */
		return (1.0 + x);
	}

#ifdef __i386__
	/*
	 * The default precision on i386 is 53 bits, so long doubles are
	 * broken. Call exp2() to get an accurate (double precision) result.
	 */
	if (fpgetprec() != FP_PE)
		return (exp2(x));
#endif

	/*
	 * Reduce x, computing z, i0, and k. The low bits of x + redux
	 * contain the 16-bit integer part of the exponent (k) followed by
	 * TBLBITS fractional bits (i0). We use bit tricks to extract these
	 * as integers, then set z to the remainder.
	 *
	 * Example: Suppose x is 0xabc.123456p0 and TBLBITS is 8.
	 * Then the low-order word of x + redux is 0x000abc12,
	 * We split this into k = 0xabc and i0 = 0x12 (adjusted to
	 * index into the table), then we compute z = 0x0.003456p0.
	 *
	 * XXX If the exponent is negative, the computation of k depends on
	 *     '>>' doing sign extension.
	 */
	u.e = x + redux;
	i0 = u.bits.manl + TBLSIZE / 2;
	k = (int)i0 >> TBLBITS;
	i0 = (i0 & (TBLSIZE - 1)) << 1;
	u.e -= redux;
	z = x - u.e;
	v.xbits.man = 1ULL << 63;
	if (k >= LDBL_MIN_EXP) {
		v.xbits.expsign = LDBL_MAX_EXP - 1 + k;
		twopk = v.e;
	} else {
		v.xbits.expsign = LDBL_MAX_EXP - 1 + k + 10000;
		twopkp10000 = v.e;
	}

	/* Compute r = exp2l(y) = exp2lt[i0] * p(z). */
	long double t_hi = tbl[i0];
	long double t_lo = tbl[i0 + 1];
	/* XXX This gives > 1 ulp errors outside of FE_TONEAREST mode */
	r = t_lo + (t_hi + t_lo) * z * (P1 + z * (P2 + z * (P3 + z * (P4
	    + z * (P5 + z * P6))))) + t_hi;

	/* Scale by 2**k. */
	if (k >= LDBL_MIN_EXP) {
		if (k == LDBL_MAX_EXP)
			return (r * 2.0 * 0x1p16383L);
		return (r * twopk);
	} else {
		return (r * twopkp10000 * twom10000);
	}
}
Exemple #12
0
double dB_to_scale(double dB)
{
    assert(isfinite(dB) || (dB == -INFINITY));
    return exp2(dB / 6.0);
}
void CudaModule::printDeviceInfo(CUdevice device)
{
    static const struct
    {
        CUdevice_attribute  attrib;
        const char*         name;
    } attribs[] =
    {
#define A21(ENUM, NAME) { CU_DEVICE_ATTRIBUTE_ ## ENUM, NAME },
#if (CUDA_VERSION >= 4000)
#   define A40(ENUM, NAME) A21(ENUM, NAME)
#else
#   define A40(ENUM, NAME) // TODO: Some of these may exist in earlier versions, too.
#endif

        A21(CLOCK_RATE,                         "Clock rate")
        A40(MEMORY_CLOCK_RATE,                  "Memory clock rate")
        A21(MULTIPROCESSOR_COUNT,               "Number of SMs")
//      A40(GLOBAL_MEMORY_BUS_WIDTH,            "DRAM bus width")
//      A40(L2_CACHE_SIZE,                      "L2 cache size")

        A21(MAX_THREADS_PER_BLOCK,              "Max threads per block")
        A40(MAX_THREADS_PER_MULTIPROCESSOR,     "Max threads per SM")
        A21(REGISTERS_PER_BLOCK,                "Registers per block")
//      A40(MAX_REGISTERS_PER_BLOCK,            "Max registers per block")
        A21(SHARED_MEMORY_PER_BLOCK,            "Shared mem per block")
//      A40(MAX_SHARED_MEMORY_PER_BLOCK,        "Max shared mem per block")
        A21(TOTAL_CONSTANT_MEMORY,              "Constant memory")
//      A21(WARP_SIZE,                          "Warp size")

        A21(MAX_BLOCK_DIM_X,                    "Max blockDim.x")
//      A21(MAX_BLOCK_DIM_Y,                    "Max blockDim.y")
//      A21(MAX_BLOCK_DIM_Z,                    "Max blockDim.z")
        A21(MAX_GRID_DIM_X,                     "Max gridDim.x")
//      A21(MAX_GRID_DIM_Y,                     "Max gridDim.y")
//      A21(MAX_GRID_DIM_Z,                     "Max gridDim.z")
//      A40(MAXIMUM_TEXTURE1D_WIDTH,            "Max tex1D.x")
//      A40(MAXIMUM_TEXTURE2D_WIDTH,            "Max tex2D.x")
//      A40(MAXIMUM_TEXTURE2D_HEIGHT,           "Max tex2D.y")
//      A40(MAXIMUM_TEXTURE3D_WIDTH,            "Max tex3D.x")
//      A40(MAXIMUM_TEXTURE3D_HEIGHT,           "Max tex3D.y")
//      A40(MAXIMUM_TEXTURE3D_DEPTH,            "Max tex3D.z")
//      A40(MAXIMUM_TEXTURE1D_LAYERED_WIDTH,    "Max layerTex1D.x")
//      A40(MAXIMUM_TEXTURE1D_LAYERED_LAYERS,   "Max layerTex1D.y")
//      A40(MAXIMUM_TEXTURE2D_LAYERED_WIDTH,    "Max layerTex2D.x")
//      A40(MAXIMUM_TEXTURE2D_LAYERED_HEIGHT,   "Max layerTex2D.y")
//      A40(MAXIMUM_TEXTURE2D_LAYERED_LAYERS,   "Max layerTex2D.z")
//      A40(MAXIMUM_TEXTURE2D_ARRAY_WIDTH,      "Max array.x")
//      A40(MAXIMUM_TEXTURE2D_ARRAY_HEIGHT,     "Max array.y")
//      A40(MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES,  "Max array.z")

//      A21(MAX_PITCH,                          "Max memcopy pitch")
//      A21(TEXTURE_ALIGNMENT,                  "Texture alignment")
//      A40(SURFACE_ALIGNMENT,                  "Surface alignment")

        A40(CONCURRENT_KERNELS,                 "Concurrent launches supported")
        A21(GPU_OVERLAP,                        "Concurrent memcopy supported")
        A40(ASYNC_ENGINE_COUNT,                 "Max concurrent memcopies")
//      A40(KERNEL_EXEC_TIMEOUT,                "Kernel launch time limited")
//      A40(INTEGRATED,                         "Integrated with host memory")
        A40(UNIFIED_ADDRESSING,                 "Unified addressing supported")
        A40(CAN_MAP_HOST_MEMORY,                "Can map host memory")
        A40(ECC_ENABLED,                        "ECC enabled")

//      A40(TCC_DRIVER,                         "Driver is TCC")
//      A40(COMPUTE_MODE,                       "Compute exclusivity mode")

//      A40(PCI_BUS_ID,                         "PCI bus ID")
//      A40(PCI_DEVICE_ID,                      "PCI device ID")
//      A40(PCI_DOMAIN_ID,                      "PCI domain ID")

#undef A21
#undef A40
    };

    char name[256];
    int major;
    int minor;
    size_t memory;

    checkError("cuDeviceGetName", cuDeviceGetName(name, FW_ARRAY_SIZE(name) - 1, device));
    checkError("cuDeviceComputeCapability", cuDeviceComputeCapability(&major, &minor, device));
    checkError("cuDeviceTotalMem", cuDeviceTotalMem(&memory, device));
    name[FW_ARRAY_SIZE(name) - 1] = '\0';

    printf("\n");
    char deviceIdStr[16];
    sprintf( deviceIdStr, "CUDA device %d", device);
    printf("%-32s%s\n",deviceIdStr, name);
        
    printf("%-32s%s\n", "---", "---");
    
    int version = getDriverVersion();
    printf("%-32s%d.%d\n", "CUDA driver API version", version/10, version%10);
    printf("%-32s%d.%d\n", "Compute capability", major, minor);
    printf("%-32s%.0f megs\n", "Total memory", (F32)memory * exp2(-20));

    for (int i = 0; i < (int)FW_ARRAY_SIZE(attribs); i++)
    {
        int value;
        if (cuDeviceGetAttribute(&value, attribs[i].attrib, device) == CUDA_SUCCESS)
            printf("%-32s%d\n", attribs[i].name, value);
    }
    printf("\n");
}
Exemple #14
0
int main(int argc, char **argv) {
	float x = 7;
	return (int) exp2(x);
}
Exemple #15
0
int main(int argc, char **argv)
{
  char *exeName = argv[0];
  char *seqA;
  int lenA;
  int markovOrder = 0;
  char *markovFile = NULL;
  char *markovSaveFile = NULL;

  while (1) {
    int c = getopt(argc, argv, "m:f:s:h");
    if (c==-1)
      break;
    switch (c) {
    case 'm':
      markovOrder = atoi(optarg);
      break;
    case 'f':
      markovFile = optarg;
      break;
    case 's':
      markovSaveFile = optarg;
      break;
    case 'h':
    default:
      usage(exeName);
    }
  }
	
  argc -= optind-1;
  argv += optind-1;

  if (argc != 2) {
    usage(exeName);
  } else {
    seqA = read_fasta(argv[1]);
  } 

  lenA = strlen(seqA);

  printf("# Character prediction probability for FASTA file '%s'\n", argv[1]);
  printf("# Markov order = %d\n", markovOrder);
  printf("# Column order = [%s]\n", alphabet);

  {
    int i,j;
    unsigned char seqA_i[lenA];
    DOUBLE seqA_enc[lenA][ALPHA_SIZE];

    // Convert DNA sequence to only an A G C or T
    strict_DNA_seq(seqA, lenA);

    // First convert strings to numbers representing the characters
    for (i=0; i<lenA; i++) seqA_i[i] = char2int(seqA[i]);
  

    markov_init(ALPHA_SIZE, markovOrder);
    if (markovFile)
      markov_load(markovFile);
    else
      markov_fit(lenA, seqA_i);
    
    markov_predict(lenA, seqA_i, (DOUBLE*)seqA_enc);


    for (i=0; i<lenA; i++) {
      for (j=0; j<ALPHA_SIZE; j++) {
	printf("%f ", exp2(-seqA_enc[i][j]));
      }
      printf("\n");
    }

    if (markovSaveFile) {
      FILE *f = fopen(markovSaveFile, "w");
      if (!f) {
        fprintf(stderr, "Unable to open file '%s' for writing.\n", markovSaveFile);
      } else {
        fprintf(stderr, "Saving Markov Model parameters to file '%s'\n", markovSaveFile);
        markov_save(f);
      }
    }

  }

  return 0;
}
Exemple #16
0
void
ags_note_edit_draw_segment(AgsNoteEdit *note_edit, cairo_t *cr)
{
  AgsEditor *editor;
  GtkWidget *widget;
  double tact;
  guint i, j;
  guint j_set;

  widget = (GtkWidget *) note_edit->drawing_area;

  editor = (AgsEditor *) gtk_widget_get_ancestor(GTK_WIDGET(note_edit),
						 AGS_TYPE_EDITOR);

  cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
  cairo_rectangle(cr, 0.0, 0.0, (double) widget->allocation.width, (double) widget->allocation.height);
  cairo_fill(cr);

  cairo_set_line_width(cr, 1.0);

  cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);

  for(i = note_edit->y0 ; i < note_edit->height;){
    cairo_move_to(cr, 0.0, (double) i);
    cairo_line_to(cr, (double) note_edit->width, (double) i);
    cairo_stroke(cr);

    i += note_edit->control_height;
  }

  tact = exp2((double) gtk_combo_box_get_active(editor->toolbar->zoom) - 4.0);

  i = note_edit->control_current.x0;
  
  if(i < note_edit->width &&
     tact > 1.0 ){
    j_set = note_edit->control_current.nth_x % ((guint) tact);
    cairo_set_source_rgb(cr, 0.6, 0.6, 0.6);

    if(j_set != 0){
      j = j_set;
      goto ags_note_edit_draw_segment0;
    }
  }

  for(; i < note_edit->width; ){
    cairo_set_source_rgb(cr, 1.0, 1.0, 0.0);
    
    cairo_move_to(cr, (double) i, 0.0);
    cairo_line_to(cr, (double) i, (double) note_edit->height);
    cairo_stroke(cr);
    
    i += note_edit->control_current.control_width;
    
    cairo_set_source_rgb(cr, 0.6, 0.6, 0.6);
    
    for(j = 1; i < note_edit->width && j < tact; j++){
    ags_note_edit_draw_segment0:
      cairo_move_to(cr, (double) i, 0.0);
      cairo_line_to(cr, (double) i, (double) note_edit->height);
      cairo_stroke(cr);
      
      i += note_edit->control_current.control_width;
    }
  }
}
Exemple #17
0
Module* new_Module(void)
{
    Module* module = memory_alloc_item(Module);
    if (module == NULL)
        return NULL;

    if (!Device_init(&module->parent, false))
    {
        memory_free(module);
        return NULL;
    }

    Device_set_existent(&module->parent, true);

    // Clear fields
    module->random_seed = 0;
    module->songs = NULL;
    module->album_is_existent = false;
    module->track_list = NULL;
    module->ch_defs = NULL;
    module->pats = NULL;
    module->au_map = NULL;
    module->au_controls = NULL;
    module->au_table = NULL;
    module->connections = NULL;
    module->is_dc_blocker_enabled = true;
    module->mix_vol_dB = COMP_DEFAULT_MIX_VOL;
    module->mix_vol = exp2(module->mix_vol_dB / 6);
    module->force_shift = 0;
    module->env = NULL;
    module->bind = NULL;
    for (int i = 0; i < KQT_SONGS_MAX; ++i)
        module->order_lists[i] = NULL;
    for (int i = 0; i < KQT_TUNING_TABLES_MAX; ++i)
        module->tuning_tables[i] = NULL;

    // Create fields
    module->songs = new_Song_table();
    module->pats = new_Pat_table(KQT_PATTERNS_MAX);
    module->au_controls = new_Bit_array(KQT_CONTROLS_MAX);
    module->au_table = new_Au_table(KQT_AUDIO_UNITS_MAX);
    if (module->songs == NULL           ||
            module->pats == NULL        ||
            module->au_controls == NULL ||
            module->au_table == NULL)
    {
        del_Module(module);
        return NULL;
    }

    module->env = new_Environment();
    if (module->env == NULL)
    {
        del_Module(module);
        return NULL;
    }

    Streader* conn_sr = Streader_init(STREADER_AUTO, NULL, 0);
    module->connections =
        new_Connections_from_string(conn_sr, false, module->au_table, &module->parent);
    if (module->connections == NULL)
    {
        del_Module(module);
        return NULL;
    }

    return module;
}
bool Event_channel_arpeggio_on_process(
        Channel* ch,
        Device_states* dstates,
        const Value* value)
{
    assert(ch != NULL);
    assert(dstates != NULL);
    (void)dstates;
    (void)value;

    for (int i = 0; i < KQT_GENERATORS_MAX; ++i)
    {
        Event_check_voice(ch, i);
        Voice* voice = ch->fg[i];
        Voice_state* vs = voice->state;
        //pitch_t orig_pitch = -1;
        if (vs->arpeggio || voice->gen->ins_params->pitch_locks[i].enabled)
            continue;

#if 0
        if (voice->gen->ins_params->scale != NULL &&
                *voice->gen->ins_params->scale != NULL &&
                **voice->gen->ins_params->scale != NULL)
        {
            orig_pitch = Scale_get_pitch_from_cents(
                         **voice->gen->ins_params->scale, vs->orig_cents);
        }
        else
        {
            orig_pitch = exp2(vs->orig_cents / 1200) * 440;
        }
        if (orig_pitch <= 0)
        {
            vs->arpeggio = false;
            continue;
        }
#endif
        if (isnan(ch->arpeggio_ref))
            ch->arpeggio_ref = vs->orig_cents;

        if (isnan(ch->arpeggio_tones[0]))
            ch->arpeggio_tones[0] = ch->arpeggio_ref;

        vs->arpeggio_ref = ch->arpeggio_ref;
        memcpy(vs->arpeggio_tones, ch->arpeggio_tones,
                KQT_ARPEGGIO_NOTES_MAX * sizeof(double));
#if 0
        int last_nonzero = -1;
        for (int k = 0; k < KQT_ARPEGGIO_NOTES_MAX; ++k)
        {
            if (data[k + 1].field.double_type != 0)
            {
                last_nonzero = k;
            }
            pitch_t new_pitch = -1;
            if (voice->gen->ins_params->scale != NULL &&
                    *voice->gen->ins_params->scale != NULL &&
                    **voice->gen->ins_params->scale != NULL)
            {
                Scale* scale = **voice->gen->ins_params->scale;
                new_pitch = Scale_get_pitch_from_cents(scale,
                            vs->orig_cents + data[k + 1].field.double_type);
            }
            else
            {
                new_pitch = vs->orig_cents + data[k + 1].field.double_type;
            }
            if (new_pitch <= 0)
            {
                last_nonzero = -1;
                break;
            }
            else
            {
                vs->arpeggio_factors[k] = new_pitch / orig_pitch;
            }
        }
        if (last_nonzero == -1)
        {
            vs->arpeggio = false;
            continue;
        }
        else if (last_nonzero < KQT_ARPEGGIO_NOTES_MAX - 1)
        {
            vs->arpeggio_factors[last_nonzero + 1] = -1;
        }
#endif
        const double unit_len = Tstamp_toframes(
                Tstamp_set(TSTAMP_AUTO, 1, 0),
                *ch->tempo,
                *ch->freq);
        vs->arpeggio_length = unit_len / ch->arpeggio_speed;
        vs->arpeggio_frames = 0;
        vs->arpeggio_note = 0;
        vs->arpeggio = true;
    }

    return true;
}
static void
F(compile_test) (void)
{
  TYPE a, b, c = 1.0;
  complex TYPE d;
  int i;
  int saved_count;
  long int j;
  long long int k;

  a = cos (cos (x));
  b = acos (acos (a));
  a = sin (sin (x));
  b = asin (asin (a));
  a = tan (tan (x));
  b = atan (atan (a));
  c = atan2 (atan2 (a, c), atan2 (b, x));
  a = cosh (cosh (x));
  b = acosh (acosh (a));
  a = sinh (sinh (x));
  b = asinh (asinh (a));
  a = tanh (tanh (x));
  b = atanh (atanh (a));
  a = exp (exp (x));
  b = log (log (a));
  a = log10 (log10 (x));
  b = ldexp (ldexp (a, 1), 5);
  a = frexp (frexp (x, &i), &i);
  b = expm1 (expm1 (a));
  a = log1p (log1p (x));
  b = logb (logb (a));
  a = exp2 (exp2 (x));
  b = log2 (log2 (a));
  a = pow (pow (x, a), pow (c, b));
  b = sqrt (sqrt (a));
  a = hypot (hypot (x, b), hypot (c, a));
  b = cbrt (cbrt (a));
  a = ceil (ceil (x));
  b = fabs (fabs (a));
  a = floor (floor (x));
  b = fmod (fmod (a, b), fmod (c, x));
  a = nearbyint (nearbyint (x));
  b = round (round (a));
  a = trunc (trunc (x));
  b = remquo (remquo (a, b, &i), remquo (c, x, &i), &i);
  j = lrint (x) + lround (a);
  k = llrint (b) + llround (c);
  a = erf (erf (x));
  b = erfc (erfc (a));
  a = tgamma (tgamma (x));
  b = lgamma (lgamma (a));
  a = rint (rint (x));
  b = nextafter (nextafter (a, b), nextafter (c, x));
  a = nextdown (nextdown (a));
  b = nexttoward (nexttoward (x, a), c);
  a = nextup (nextup (a));
  b = remainder (remainder (a, b), remainder (c, x));
  a = scalb (scalb (x, a), (TYPE) (6));
  k = scalbn (a, 7) + scalbln (c, 10l);
  i = ilogb (x);
  j = llogb (x);
  a = fdim (fdim (x, a), fdim (c, b));
  b = fmax (fmax (a, x), fmax (c, b));
  a = fmin (fmin (x, a), fmin (c, b));
  b = fma (sin (a), sin (x), sin (c));
  a = totalorder (totalorder (x, b), totalorder (c, x));
  b = totalordermag (totalordermag (x, a), totalordermag (c, x));

#ifdef TEST_INT
  a = atan2 (i, b);
  b = remquo (i, a, &i);
  c = fma (i, b, i);
  a = pow (i, c);
#endif
  x = a + b + c + i + j + k;

  saved_count = count;
  if (ccount != 0)
    ccount = -10000;

  d = cos (cos (z));
  z = acos (acos (d));
  d = sin (sin (z));
  z = asin (asin (d));
  d = tan (tan (z));
  z = atan (atan (d));
  d = cosh (cosh (z));
  z = acosh (acosh (d));
  d = sinh (sinh (z));
  z = asinh (asinh (d));
  d = tanh (tanh (z));
  z = atanh (atanh (d));
  d = exp (exp (z));
  z = log (log (d));
  d = sqrt (sqrt (z));
  z = conj (conj (d));
  d = fabs (conj (a));
  z = pow (pow (a, d), pow (b, z));
  d = cproj (cproj (z));
  z += fabs (cproj (a));
  a = carg (carg (z));
  b = creal (creal (d));
  c = cimag (cimag (z));
  x += a + b + c + i + j + k;
  z += d;

  if (saved_count != count)
    count = -10000;

  if (0)
    {
      a = cos (y);
      a = acos (y);
      a = sin (y);
      a = asin (y);
      a = tan (y);
      a = atan (y);
      a = atan2 (y, y);
      a = cosh (y);
      a = acosh (y);
      a = sinh (y);
      a = asinh (y);
      a = tanh (y);
      a = atanh (y);
      a = exp (y);
      a = log (y);
      a = log10 (y);
      a = ldexp (y, 5);
      a = frexp (y, &i);
      a = expm1 (y);
      a = log1p (y);
      a = logb (y);
      a = exp2 (y);
      a = log2 (y);
      a = pow (y, y);
      a = sqrt (y);
      a = hypot (y, y);
      a = cbrt (y);
      a = ceil (y);
      a = fabs (y);
      a = floor (y);
      a = fmod (y, y);
      a = nearbyint (y);
      a = round (y);
      a = trunc (y);
      a = remquo (y, y, &i);
      j = lrint (y) + lround (y);
      k = llrint (y) + llround (y);
      a = erf (y);
      a = erfc (y);
      a = tgamma (y);
      a = lgamma (y);
      a = rint (y);
      a = nextafter (y, y);
      a = nexttoward (y, y);
      a = remainder (y, y);
      a = scalb (y, (const TYPE) (6));
      k = scalbn (y, 7) + scalbln (y, 10l);
      i = ilogb (y);
      j = llogb (y);
      a = fdim (y, y);
      a = fmax (y, y);
      a = fmin (y, y);
      a = fma (y, y, y);
      a = totalorder (y, y);
      a = totalordermag (y, y);

#ifdef TEST_INT
      a = atan2 (i, y);
      a = remquo (i, y, &i);
      a = fma (i, y, i);
      a = pow (i, y);
#endif

      d = cos ((const complex TYPE) z);
      d = acos ((const complex TYPE) z);
      d = sin ((const complex TYPE) z);
      d = asin ((const complex TYPE) z);
      d = tan ((const complex TYPE) z);
      d = atan ((const complex TYPE) z);
      d = cosh ((const complex TYPE) z);
      d = acosh ((const complex TYPE) z);
      d = sinh ((const complex TYPE) z);
      d = asinh ((const complex TYPE) z);
      d = tanh ((const complex TYPE) z);
      d = atanh ((const complex TYPE) z);
      d = exp ((const complex TYPE) z);
      d = log ((const complex TYPE) z);
      d = sqrt ((const complex TYPE) z);
      d = pow ((const complex TYPE) z, (const complex TYPE) z);
      d = fabs ((const complex TYPE) z);
      d = carg ((const complex TYPE) z);
      d = creal ((const complex TYPE) z);
      d = cimag ((const complex TYPE) z);
      d = conj ((const complex TYPE) z);
      d = cproj ((const complex TYPE) z);
    }
}
Exemple #20
0
int to_wig_by_blocks(char * argv[], int nproc, int iproc){
	
	clock_t start = clock();
	SPAM(("================\nto_wig_by_blocks.c start!\n"));
	
	char FileName[400];//name of processed Wig file
	strcpy(FileName, argv[1]);
	
	
	//for parallel
	int First; //first chrm to read
	//int Last;
	//int pflag; //indicate whether should start read
	if (nproc<=0){
		First = 0;
		//Last = 32;//assume no more than 32 chrm
		//pflag=1;
	}
	else{
		First = (24/nproc)*iproc; 
		/*if (iproc < nproc-1)
			Last = (24/nproc)*(iproc+1); 
		else
			Last = 32;*/
		//pflag=0; 
	}
	
	int Nd = 18;
	int SetMaxDiff = exp2(Nd); //set max alphabet size
	double Map[SetMaxDiff]; //maps each consecutive integer to the actual alphabet
	memset(Map,0,SetMaxDiff*sizeof(double)); 
	double LenMap[SetMaxDiff]; 
	memset(LenMap,0,SetMaxDiff*sizeof(double));  
	char ChrmNames[8*32]; //every chrm has a name less than 8 characters, assume no more than 32 chrm 
	memset(ChrmNames,0,8*32*sizeof(char));
	int ChrmCount=0;
	
	//int type;
	//char Type[40];
	
	double PreValue=-2;
	double Value=0;
	double Diff;//difference of values of contigs
	//int NextDiff=1;
	double PreLocation=-1;
	double Location=-1;
	double Contig = 1; //length of current contig
	double PreContig = 1; //length of previous contig
	double LenDiff; //length difference of two consecutive contigs
	char str[200];
	char tmpFileName[400];
	int i,j;
	int tmpint,tmp;
	int pcount=0;
	long long lcount=0; //count number of lines in wig file
	
	
	//for blocks use
	int SetBlockSize = exp2(BlockSize); //number of diff that are encoded together
	int IndexAux[32]; //(the last location of a chrm)>>SearchBlock, assume no more than 32 chrm
	memset(IndexAux,0,32*sizeof(unsigned int));
	int bcount=0; //counter inside each block
	//int BlockCount=0; //counter for number of blocks
	
	
	//read from count files
	strcpy(tmpFileName,FileName);
	strcat(tmpFileName,"Diff");
	FILE *fpDiff = fopen(tmpFileName,"r");
	if (fpDiff == NULL) {
		fprintf(stderr,"Can't open output Count file!\n");
		exit(1);
	}
	strcpy(tmpFileName,FileName);
	strcat(tmpFileName,"LenDiff");
	FILE *fpLenDiff = fopen(tmpFileName,"r");
	if (fpLenDiff == NULL) {
		fprintf(stderr,"Can't open output LenDiff file!\n");
		exit(1);
	}
	//skip annotation
	fgets(str,sizeof(str),fpDiff);
	fgets(str,sizeof(str),fpLenDiff);
	//change consecutive alphabet to the actual alphabet
	i=0;
	while (fread(&Map[i],sizeof(double),1,fpDiff)==1){
		//fscanf(fpDiff,"%d\t%*u\n", &Map[i]);
		fread(&tmpint,sizeof(int),1,fpDiff);
		i ++;
	}
	i=0;
	while (fread(&LenMap[i],sizeof(double),1,fpLenDiff)==1){
		//fscanf(fpLenDiff,"%d\t%*u\n", &LenMap[i]);
		fread(&tmpint,sizeof(int),1,fpLenDiff);
		i ++;
	}
			
		
	fclose(fpDiff);
	fclose(fpLenDiff);
	/*printf("map done!\n");
	for (j=0; j<80; j++)
		printf("j=%d, %d %d\n",j, Map[j],LenMap[j]);*/
	
	
	///////////////matlab seq to seq	
	//open matlab seq
	strcpy(tmpFileName,FileName);
	strcat(tmpFileName,"DiffSeqMatlabDecode");
	if (nproc>0){
		tmpint = sprintf(str,"%02d",iproc);
		strcat(tmpFileName,str);
	}
	FILE *fpDiffSeqMatlab = fopen(tmpFileName, "r");
	if (fpDiffSeqMatlab  == NULL) {
		fprintf(stderr, "Can't open file %s!\n",tmpFileName);
		exit(1);
	}
	//open matlab len seq
	strcpy(tmpFileName,FileName);
	strcat(tmpFileName,"LenDiffSeqMatlabDecode");
	if (nproc>0){
		tmpint = sprintf(str,"%02d",iproc);
		strcat(tmpFileName,str);
	}
	FILE *fpLenDiffSeqMatlab = fopen(tmpFileName, "r");
	if (fpLenDiffSeqMatlab  == NULL) {
		fprintf(stderr, "Can't open file %s!\n",tmpFileName);
		exit(1);
	}
	//output wig
	strcpy(tmpFileName,argv[2]);
	if (nproc>0){
		tmpint = sprintf(str,"%02d",iproc);
		strcat(tmpFileName,str);
	}
	FILE *fp;
	fp = fopen(tmpFileName, "w");
	if (fp == NULL) {
		fprintf(stderr, "Can't open output file %s!\n",tmpFileName);
		exit(1);
	}
	
	//chrm names
	strcpy(tmpFileName,FileName);
	strcat(tmpFileName,"ChrmName");
	FILE *fpName = fopen(tmpFileName, "r");
	if (fpName == NULL) {
		fprintf(stderr, "Can't open input file %s!\n",tmpFileName);
		exit(1);
	}
    while(!feof(fpName)){
        fscanf(fpName,"%8s",&ChrmNames[8*ChrmCount]);
        ChrmCount++;
    }
	
	
	int StartBlockIndex=0;
	//int EndBlockIndex=0;
	
	//fpBlockAux
	strcpy(tmpFileName,FileName);
	strcat(tmpFileName,"BlockAux");
	FILE *fpBlockAux = fopen(tmpFileName, "r");
	if (fpBlockAux == NULL) {
		fprintf(stderr, "Can't open file %s!\n",tmpFileName);
		exit(1);
	}
	for(i=0; i<First+1 && !feof(fpBlockAux); i++)
		fscanf(fpBlockAux,"%d ",&tmp);
	StartBlockIndex = tmp ;
	/*for (i; i<Last+1 && !feof(fpBlockAux); i++)
		fscanf(fpBlockAux,"%d ",&tmp);
	EndBlockIndex = tmp + 1;*/
	fclose(fpBlockAux);
	
	
	j=0;
	i = First; //Chrm count
	pcount = 1024; //count to print annotation
	bcount = 0;
	Diff=1;
	LenDiff=1;
	while(!feof(fpDiffSeqMatlab) && !feof(fpLenDiffSeqMatlab)){
			
		/*if (Location==3839085){ //(j<100){ 
			printf("PreLocation=%lu Location=%lu Contig=%ld LenDiff=%ld Value=%d Diff=%d\n", PreLocation,Location, Contig, LenDiff,Value,Diff);
		    printf("bcount=%d\n",bcount);
		}*/
		
		if (bcount==SetBlockSize)
			bcount = 0;
		bcount++;
		
		if (pcount==1024){
			fprintf(fp,"variableStep chrom=%s span=1\n", &ChrmNames[i*8]);
			pcount = 0;
			lcount++;
		}
		fscanf(fpDiffSeqMatlab,"%d ",&tmpint);
		Diff = Map[tmpint];
		fscanf(fpLenDiffSeqMatlab,"%d ",&tmpint);
		LenDiff = LenMap[tmpint];
	 
		
						
		if (Diff == -(1<<30)){//end of a chrm
			i++;
			pcount = 1024;
			PreValue = -2;
			PreContig = 1;
			PreLocation = -1;
			//printf("chrm %d finished\n",i);
			//remove padded 0s
			tmpint=(SetBlockSize-bcount)%SetBlockSize; //number of padded 0s
			for (j=0; j<tmpint; j++){
				fscanf(fpDiffSeqMatlab,"%d ",&tmp);
				fscanf(fpLenDiffSeqMatlab,"%d ",&tmp);
			}
			bcount=0;
			continue;
		}
				
		//write to wig	
		Value = PreValue + Diff;
		Contig = PreContig + LenDiff;
		
		
		if (Contig < 0){
			printf("Contig=%lg out of range! Check input file please!\n", Contig);
			printf("Location=%lg PreLocation=%lg Value=%lg PreValue=%lg ChrmName=%s\n",Location,PreLocation,Value,PreValue,&ChrmNames[i*8]);
			printf("Line # in wig is %lld\n",lcount);
			exit(1);
		}
			
		if ((Value>1e-8 || Value<-1e-8) && PreLocation!=-1){
			for (Location=PreLocation; Location < PreLocation + Contig; Location++ ){
				//fprintf(fp,"%ld\t%lg\n", Location,(double)(Value)/SetFloatSize);
				fprintf(fp,"%ld\t%lg\n", (long int)Location,Value);
				lcount ++;
				pcount ++;
			}
		}
		else
			Location = PreLocation + Contig;
		
		//reset
		PreValue = Value;
		PreContig = Contig;
		PreLocation = Location;
		//Diff = NextDiff;
		
	}
	clock_t end = clock();

    FILE *fpResult = fopen("result","a");
	if (fpResult == NULL) {
		fprintf(stderr,"Can't open output Count file!\n");
		exit(1);
	}
    SPAMR((fpResult,"//%s to_wig\n",FileName));
	SPAMR((fpResult,"Time for processing file in decode %2.3f sec.\n", (double)(end-start)/CLOCKS_PER_SEC));
	
	if (!feof(fpDiffSeqMatlab) || !feof(fpLenDiffSeqMatlab)){
		printf("two matlab seq files not same sizes!\n");
		exit(1);
	}
	
	fclose(fp);
	fclose(fpDiffSeqMatlab);
	fclose(fpLenDiffSeqMatlab);
	fclose(fpName);
	fclose(fpResult);

	return 1;
}
Exemple #21
0
static void print_ntp_status_info(NTPStatusInfo *i) {
        char ts[FORMAT_TIMESPAN_MAX], tmin[FORMAT_TIMESPAN_MAX], tmax[FORMAT_TIMESPAN_MAX];
        usec_t delay, t14, t23, offset, root_distance;
        bool offset_sign;

        assert(i);

        /*
         * "Timestamp Name          ID   When Generated
         *  ------------------------------------------------------------
         *  Originate Timestamp     T1   time request sent by client
         *  Receive Timestamp       T2   time request received by server
         *  Transmit Timestamp      T3   time reply sent by server
         *  Destination Timestamp   T4   time reply received by client
         *
         *  The round-trip delay, d, and system clock offset, t, are defined as:
         *  d = (T4 - T1) - (T3 - T2)     t = ((T2 - T1) + (T3 - T4)) / 2"
         */

        printf("       Server: %s (%s)\n",
               i->server_address, i->server_name);
        printf("Poll interval: %s (min: %s; max %s)\n",
               format_timespan(ts, sizeof(ts), i->poll_interval, 0),
               format_timespan(tmin, sizeof(tmin), i->poll_min, 0),
               format_timespan(tmax, sizeof(tmax), i->poll_max, 0));

        if (i->packet_count == 0) {
                printf(" Packet count: 0\n");
                return;
        }

        if (i->dest < i->origin || i->trans < i->recv || i->dest - i->origin < i->trans - i->recv) {
                log_error("Invalid NTP response");
                return;
        }

        delay = (i->dest - i->origin) - (i->trans - i->recv);

        t14 = i->origin + i->dest;
        t23 = i->recv + i->trans;
        offset_sign = t14 < t23;
        offset = (offset_sign ? t23 - t14 : t14 - t23) / 2;

        root_distance = i->root_delay / 2 + i->root_dispersion;

        printf("         Leap: %s\n"
               "      Version: %" PRIu32 "\n"
               "      Stratum: %" PRIu32 "\n",
               ntp_leap_to_string(i->leap),
               i->version,
               i->stratum);
        if (i->stratum <= 1)
                printf("    Reference: %s\n", i->reference.str);
        else
                printf("    Reference: %" PRIX32 "\n", be32toh(i->reference.val));
        printf("    Precision: %s (%" PRIi32 ")\n",
               format_timespan(ts, sizeof(ts), DIV_ROUND_UP((nsec_t) (exp2(i->precision) * NSEC_PER_SEC), NSEC_PER_USEC), 0),
               i->precision);
        printf("Root distance: %s (max: %s)\n",
               format_timespan(ts, sizeof(ts), root_distance, 0),
               format_timespan(tmax, sizeof(tmax), i->root_distance_max, 0));
        printf("       Offset: %s%s\n",
               offset_sign ? "+" : "-",
               format_timespan(ts, sizeof(ts), offset, 0));
        printf("        Delay: %s\n",
               format_timespan(ts, sizeof(ts), delay, 0));
        printf("       Jitter: %s\n",
               format_timespan(ts, sizeof(ts), i->jitter, 0));
        printf(" Packet count: %" PRIu64 "\n", i->packet_count);

        if (!i->spike)
                printf("    Frequency: %+.3fppm\n",
                       (double) i->freq / 0x10000);
}
Exemple #22
0
void generate3(double& a,double& b,double& c,double& d,double& e,
			   double& f,double& g,double& h,double& i, char type)
{
  double cxx,cyy;
   switch (type) {
  case 'r' :              // random
    a = rnd(51);
    b = rnd(51);
	c = rnd(51);
    d = rnd(51);
    e = rnd(51);
    f = rnd(51);
    g = rnd(51);
	h = rnd(51);
    i = rnd(51);
	break;

  case 'q' :            // aU bV cU+dV
    cxx = rnd(25);
    cyy = rnd(25);
    a =   rnd(25);
    b =   rnd(25);
    c =   cxx * a + cyy * b;
    d =   rnd(26);
    e =   rnd(26);
    f =   cxx * d + cyy * e;
    g =   rnd(25);
    h =   rnd(25);
    i =   cxx * g + cyy * h;
    cxx = rnd(25);
    cyy = rnd(25);
	a *= cxx;
	d *= cxx;
	g *= cxx;
	b *= cyy;
	e *= cyy;
	h *= cyy;
    break;

  case 'p' :              // x+y+z=0
    a = rnd(50);
    b = rnd(50);
	c = -a -b;
    d = rnd(50);
    e = rnd(50);
    f = -d -e;
    g = rnd(50);
	h = rnd(50);
    i = -g -h;
    break;

  case 'f' :              // z = floor( t*x + u*y )     t,u in [0,1]
    cxx = rnd(51);
	cyy = rnd(51);
    a = rnd(51);
    b = rnd(51);
	c = floor((-a*cxx-b*cyy)/exp2(52));
    d = rnd(51);
    e = rnd(51);
    f = floor((-d*cxx-e*cyy)/exp2(52));
	g = rnd(51);
	h = rnd(51);
	i = floor((-g*cxx-h*cyy)/exp2(52));
	break;

  case 'c' :             // all entries equal
    a = b = c = d = e = f = g = h = i = rnd(51);
	break;
}}
Exemple #23
0
float exp2f( float x)
{
    return (float)exp2( x );
}
Exemple #24
0
void ray_intersect_pdm( inout vec3 p, inout vec3 v )
{	
	const float EPSILON = 0.001;
	const int MAX_LEVEL = 8;
	const float NODE_COUNT = 256.0;	// displacement map resolution
	const float TEXEL_SPAN_HALF = 1.0 / NODE_COUNT / 2.0;	

	float fDeltaNC = TEXEL_SPAN_HALF * .1; //d_factor;	// offset for node crossing

	vec3 p2 = p;		// current position	
	int level = MAX_LEVEL;	// current level
	while ( level >= 0 )
	{
//		vec4 uv = vec4( p2.xyz, level );
//		float d = texture2DLod( pyramid_map, uv.xy, (float)level).w;

		float d = texture2DLod(pyramid_map, p2.xy, float(level)).w;
		if ( d > p2.z + EPSILON )
		{
			vec3 tmpP2 = p + v * d;	// new point ( predictive )

			// test node IDs
			float nodeCount = exp2(float(MAX_LEVEL - level));
			vec4 nodeID = vec4( p2.xy, tmpP2.xy );	
			nodeID = floor( nodeID * nodeCount );
			vec2 test = abs( nodeID.xy - nodeID.zw );

			if ( test.x + test.y > EPSILON )
			{
				float texelSpan = 1.0 / nodeCount;

				vec2 dirSign = ( sign(v.xy ) + 1.0 ) * 0.5;

				// distance to the next node's boundary
				vec2 a = p2.xy - p.xy;
				vec2 p3 = ( nodeID.xy + dirSign ) * texelSpan;
				vec2 b = p3.xy - p.xy;

				// node crossing
				vec2 dNC = ( b.xy * p2.z ) / a.xy;                
				d = min( d, min( dNC.x, dNC.y ) ) + fDeltaNC;

				++level;
			}

			p2 = p + v * d;
		}


		
#if 1

//TESTING

		// refinement with linearly filtered depth
		if ( level <= 0 )
		{
			vec2 ray2D =  p2.xy - p.xy;
			float rayLength = length( ray2D );
			
			float depthb = p2.z * ( rayLength + TEXEL_SPAN_HALF ) / rayLength;
			vec4 p2b = vec4( p + v * depthb, level );
			float depth2b = texture2DLod(depth_map, p2b.xy, float(level)).w;		// linearly filtered sampler
			if ( depth2b > p2b.z + EPSILON )
			{
				p2 = p2b.xyz;
				level++;
			}	
		}

//~TESTING
#endif
		count++;
		if (count>100) break;  // DEBUGGED: without this, couple of pixels may result in INFINITE LOOP =>fps=0.01

		--level;
	} // end loop
	p = p2;
}
Exemple #25
0
/**
 * parser an IfEvent to an Input, Output, or Delay
 */
Event* Event::parser(IfEvent *ev){

	//contain signals in an IF file
	static vector<Interaction *> SIGNALS;
	static bool readSignalroute = false;
	if (readSignalroute == false){
		readSignalroute = true;
		//file name is the same with the one in getSignalRoute.C
		char *filename = "/tmp/if-signalroute.XXXXXX";
		ifstream in(filename);

		if (!in.fail()){
			string line;
			cout <<line <<endl;
			while (getline(in, line)){
				vector<string> str = tsp::Tool::split(line, ';');
				int n = str.size();
				if (n >= 4){
					string sender = str[1];
					string receiver = str[2];
					for (int i=3; i<n; i++){
						SIGNALS.push_back(new Interaction(sender, str[i], receiver));
					}
				}
			}
			//remove(filename);
		}
	}

	unsigned k = ev->getKind();
	string pid, partner, label;

	if (k == IfEvent::INPUT || k == IfEvent::OUTPUT){
		label = string(ev->getValue());

		string str = ev->string();
		//e.g., str = <<{client}0 ?Input{p1=1}{client}0>>

		//remove << and >>
		str = str.substr(2, str.length()-5);
		str.erase(str.find(label), label.length());

		int d = str.find(' ');
		//not found
		pid = str.substr(0, d);
		partner = str.substr(d+1+1);	//remove space and ? or !
		if (partner.empty())
			partner = "env";

		//IF simulator always put partner := pid for any IfEvent::INPUT
		//However we need to distinguish that an IfEvent::INPUT comes from ENV or from another IfProcess

		if (partner.compare(pid) == 0){
			partner = "env";
			int n = SIGNALS.size();
			for (int i=0; i<n; i++){
				Interaction *ite = SIGNALS.at(i);
				if (label.find(ite->label) != string::npos){

					if (pid.find(ite->sender) != string::npos){
						partner = ite->receiver;
						break;
					}else if (pid.find(ite->receiver) != string::npos){
						partner = ite->sender;
						break;
					}
				}
			}
		}

		//label = p1={distance=1, speed=2},p2=3
		//remove p1=, p2= .. from label
		std::regex exp ("p(\\d+)=");
		label = std::regex_replace(label, exp, "");

		//label = {distance=1, speed=2},3
		//remove distance=, speed=, ..
		std::regex exp2("(\\w+)=");
		label = std::regex_replace(label, exp2, "");
	}


	if (k == IfEvent::INPUT){
		return new Input(partner, label, pid);
	}else if (k == IfEvent::OUTPUT){
		return new Output(pid, label, partner);
	}else if (k == IfEvent::TICK){
		int delay = atoi(ev->getValue());
		return new Delay(delay);
	}
	return NULL;
}
Exemple #26
0
        fr.m_wstr.push_back(ch);

    fr.m_lexiconStates.push_back(TLexiconState(i, wid));
}

void
CIMIContext::_forwardTail(unsigned i, unsigned j)
{
    CLatticeFrame &fr = m_lattice[j];
    fr.m_type = CLatticeFrame::TAIL;

    fr.m_lexiconStates.push_back(TLexiconState(i, ENDING_WORD_ID));
}

static double exp2_tbl[32] = {
    exp2(-0), exp2(-1), exp2(-2), exp2(-3), exp2(-4), exp2(-5), exp2(-6), exp2(-7),
    exp2(-8), exp2(-9), exp2(-10), exp2(-11), exp2(-12), exp2(-13), exp2(-14),
    exp2(-15), exp2(-16), exp2(-17), exp2(-18), exp2(-19), exp2(-20), exp2(-21),
    exp2(-22), exp2(-23), exp2(-24), exp2(-25), exp2(-26), exp2(-27), exp2(-28),
    exp2(-29), exp2(-30), exp2(-31)
};

bool
CIMIContext::searchFrom(unsigned idx)
{
    bool affectCandidates = (idx <= m_candiEnds);

    for (; idx <= m_tailIdx; ++idx) {
        CLatticeFrame &fr = m_lattice[idx];

        if (fr.m_type == CLatticeFrame::UNUSED)
int
ipmi_sensor_decode_value (int8_t r_exponent,
                          int8_t b_exponent,
                          int16_t m,
                          int16_t b,
                          uint8_t linearization,
                          uint8_t analog_data_format,
                          uint8_t raw_data,
                          double *value)
{
  double dval = 0.0;

  if (!value
      || !IPMI_SDR_ANALOG_DATA_FORMAT_VALID (analog_data_format)
      || !IPMI_SDR_LINEARIZATION_IS_LINEAR (linearization))
    {
      SET_ERRNO (EINVAL);
      return (-1);
    }

  if (analog_data_format == IPMI_SDR_ANALOG_DATA_FORMAT_UNSIGNED)
    dval = (double) raw_data;
  else if (analog_data_format == IPMI_SDR_ANALOG_DATA_FORMAT_1S_COMPLEMENT)
    {
      if (raw_data & 0x80)
        raw_data++;
      dval = (double)((char) raw_data);
    }
  else /* analog_data_format == IPMI_SDR_ANALOG_DATA_FORMAT_2S_COMPLEMENT */
    dval = (double)((char) raw_data);

  dval *= (double) m;
  dval += (b * pow (10, b_exponent));
  dval *= pow (10, r_exponent);

  switch (linearization)
    {
    case IPMI_SDR_LINEARIZATION_LN:
      dval = log (dval);
      break;
    case IPMI_SDR_LINEARIZATION_LOG10:
      dval = log10 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_LOG2:
      dval = log2 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_E:
      dval = exp (dval);
      break;
    case IPMI_SDR_LINEARIZATION_EXP10:
      dval = exp10 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_EXP2:
      dval = exp2 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_INVERSE:
      if (dval != 0.0)
	dval = 1.0 / dval;
      break;
    case IPMI_SDR_LINEARIZATION_SQR:
      dval = pow (dval, 2.0);
      break;
    case IPMI_SDR_LINEARIZATION_CUBE:
      dval = pow (dval, 3.0);
      break;
    case IPMI_SDR_LINEARIZATION_SQRT:
      dval = sqrt (dval);
      break;
    case IPMI_SDR_LINEARIZATION_CUBERT:
      dval = cbrt (dval);
      break;
    }

  *value = dval;
  return (0);
}
Exemple #28
0
//=======================================================================
//function : GetMinDistance
//purpose  : 
//=======================================================================
Standard_Real GEOMUtils::GetMinDistance
                               (const TopoDS_Shape& theShape1,
                                const TopoDS_Shape& theShape2,
                                gp_Pnt& thePnt1, gp_Pnt& thePnt2)
{
  Standard_Real aResult = 1.e9;

  // Issue 0020231: A min distance bug with torus and vertex.
  // Make GetMinDistance() return zero if a sole VERTEX is inside any of SOLIDs

  // which of shapes consists of only one vertex?
  TopExp_Explorer exp1(theShape1,TopAbs_VERTEX), exp2(theShape2,TopAbs_VERTEX);
  TopoDS_Shape V1 = exp1.More() ? exp1.Current() : TopoDS_Shape();
  TopoDS_Shape V2 = exp2.More() ? exp2.Current() : TopoDS_Shape();
  exp1.Next(); exp2.Next();
  if ( exp1.More() ) V1.Nullify();
  if ( exp2.More() ) V2.Nullify();
  // vertex and container of solids
  TopoDS_Shape V = V1.IsNull() ? V2 : V1;
  TopoDS_Shape S = V1.IsNull() ? theShape1 : theShape2;
  if ( !V.IsNull() ) {
    // classify vertex against solids
    gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( V ) );
    for ( exp1.Init( S, TopAbs_SOLID ); exp1.More(); exp1.Next() ) {
      BRepClass3d_SolidClassifier classifier( exp1.Current(), p, 1e-6);
      if ( classifier.State() == TopAbs_IN ) {
        thePnt1 = p;
        thePnt2 = p;
        return 0.0;
      }
    }
  }
  // End Issue 0020231

  // skl 30.06.2008
  // additional workaround for bugs 19899, 19908 and 19910 from Mantis
  double dist = GEOMUtils::GetMinDistanceSingular
      (theShape1, theShape2, thePnt1, thePnt2);

  if (dist > -1.0) {
    return dist;
  }

  BRepExtrema_DistShapeShape dst (theShape1, theShape2);
  if (dst.IsDone()) {
    gp_Pnt P1, P2;

    for (int i = 1; i <= dst.NbSolution(); i++) {
      P1 = dst.PointOnShape1(i);
      P2 = dst.PointOnShape2(i);

      Standard_Real Dist = P1.Distance(P2);
      if (aResult > Dist) {
        aResult = Dist;
        thePnt1 = P1;
        thePnt2 = P2;
      }
    }
  }

  return aResult;
}
int
ipmi_sensor_decode_tolerance (int8_t r_exponent,
                              int16_t m,
                              uint8_t linearization,
                              uint8_t raw_data,
                              double *value)
{
  double dval = 0.0;

  if (!value
      || !IPMI_SDR_LINEARIZATION_IS_LINEAR (linearization))
    {
      SET_ERRNO (EINVAL);
      return (-1);
    }

  /* note no analog_data format, tolerance always stored as unsigned */

  dval = (double) raw_data;

  dval *= (double) m;
  dval /= 2.0;
  dval += (dval * pow (10, r_exponent));

  switch (linearization)
    {
    case IPMI_SDR_LINEARIZATION_LN:
      dval = log (dval);
      break;
    case IPMI_SDR_LINEARIZATION_LOG10:
      dval = log10 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_LOG2:
      dval = log2 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_E:
      dval = exp (dval);
      break;
    case IPMI_SDR_LINEARIZATION_EXP10:
      dval = exp10 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_EXP2:
      dval = exp2 (dval);
      break;
    case IPMI_SDR_LINEARIZATION_INVERSE:
      if (dval != 0.0)
	dval = 1.0 / dval;
      break;
    case IPMI_SDR_LINEARIZATION_SQR:
      dval = pow (dval, 2.0);
      break;
    case IPMI_SDR_LINEARIZATION_CUBE:
      dval = pow (dval, 3.0);
      break;
    case IPMI_SDR_LINEARIZATION_SQRT:
      dval = sqrt (dval);
      break;
    case IPMI_SDR_LINEARIZATION_CUBERT:
      dval = cbrt (dval);
      break;
    }

  *value = dval;
  return (0);
}
TEST(Decimal128Test, TestDoubleConstructorQuantFailPoorLog10Of2Estimate) {
    double dbl = exp2(1000);
    Decimal128 d(dbl);
    ASSERT_EQUALS(d.toString(), "1.07150860718627E+301");
}