本文整理汇总了C++中exp2函数的典型用法代码示例。如果您正苦于以下问题:C++ exp2函数的具体用法?C++ exp2怎么用?C++ exp2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exp2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: exp2l
long double exp2l(long double x)
{
return exp2(x);
}
开发者ID:5kg,项目名称:osv,代码行数:4,代码来源:exp2l.c
示例2: exp2f
float exp2f (float x)
{
return (float) exp2( (double)x );
}
开发者ID:ystk,项目名称:debian-uclibc,代码行数:4,代码来源:float_wrappers.c
示例3: ipmi_sensor_decode_raw_value
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);
//.........这里部分代码省略.........
开发者ID:webrulon,项目名称:freeipmi-debian,代码行数:101,代码来源:ipmi-sensor-util.c
示例4: fun
static inline T fun(const T& x) {
return exp2(x);
}
开发者ID:stan-dev,项目名称:math,代码行数:3,代码来源:exp2.hpp
示例5: exp
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;
}
开发者ID:kylelin47,项目名称:COP-Project,代码行数:68,代码来源:E.cpp
示例6: __attribute__
__attribute__((weak)) long double exp2l(long double x) { return exp2((double)x); }
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_ndk,代码行数:1,代码来源:math_support.c
示例7: doBuildNode
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
开发者ID:petersohn,项目名称:sokoban,代码行数:63,代码来源:NodeBuilder.hpp
示例8: ags_note_edit_reset_horizontally
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);
//.........这里部分代码省略.........
开发者ID:weedlight,项目名称:ags,代码行数:101,代码来源:ags_note_edit.c
示例9: cents_to_Hz
double cents_to_Hz(double cents)
{
assert(isfinite(cents));
return exp2(cents / 1200.0) * 440;
}
开发者ID:EdwardBetts,项目名称:kunquat,代码行数:5,代码来源:conversions.c
示例10: exp2l
/*
* 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 {
//.........这里部分代码省略.........
开发者ID:CoryXie,项目名称:BarrelfishOS,代码行数:101,代码来源:s_exp2l.c
示例11: dB_to_scale
double dB_to_scale(double dB)
{
assert(isfinite(dB) || (dB == -INFINITY));
return exp2(dB / 6.0);
}
开发者ID:EdwardBetts,项目名称:kunquat,代码行数:5,代码来源:conversions.c
示例12: A21
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;
//.........这里部分代码省略.........
开发者ID:tcoppex,项目名称:cudaraster-linux,代码行数:101,代码来源:CudaModule.cpp
示例13: main
int main(int argc, char **argv) {
float x = 7;
return (int) exp2(x);
}
开发者ID:alexjordan,项目名称:singlepass,代码行数:4,代码来源:454-flt-exp2.c
示例14: main
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;
}
开发者ID:drpowell,项目名称:Alignment_Prob,代码行数:86,代码来源:markov_pred.c
示例15: ags_note_edit_draw_segment
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;
}
}
}
开发者ID:weedlight,项目名称:ags,代码行数:66,代码来源:ags_note_edit.c
示例16: new_Module
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;
}
开发者ID:kagu,项目名称:kunquat,代码行数:68,代码来源:Module.c
示例17: Event_channel_arpeggio_on_process
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;
}
开发者ID:cyberixae,项目名称:kunquat,代码行数:99,代码来源:Event_channel_arpeggio.c
示例18: F
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));
//.........这里部分代码省略.........
开发者ID:francois-wellenreiter,项目名称:glibc,代码行数:101,代码来源:test-tgmath.c
示例19: to_wig_by_blocks
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);
//.........这里部分代码省略.........
开发者ID:brushyy,项目名称:smallWig,代码行数:101,代码来源:to_wig_by_blocks.c
示例20: print_ntp_status_info
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
|
请发表评论