本文整理汇总了C++中special函数的典型用法代码示例。如果您正苦于以下问题:C++ special函数的具体用法?C++ special怎么用?C++ special使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了special函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: socialServerStart
bool socialServerStart(SocialServer *self) {
special("======================");
special("==== Social server ===");
special("======================");
if (!(serverStart(self->server))) {
error("Cannot start the Server.");
return false;
}
return true;
}
示例2: main
int
main (int argc, char *argv[])
{
tests_start_mpfr ();
special ();
test_specialz (mpfr_add_z, mpz_add, "add");
test_specialz (mpfr_sub_z, mpz_sub, "sub");
test_specialz (mpfr_mul_z, mpz_mul, "mul");
test_genericz (2, 100, 100, mpfr_add_z, "add");
test_genericz (2, 100, 100, mpfr_sub_z, "sub");
test_genericz (2, 100, 100, mpfr_mul_z, "mul");
test_genericz (2, 100, 100, mpfr_div_z, "div");
test_genericq (2, 100, 100, mpfr_add_q, "add");
test_genericq (2, 100, 100, mpfr_sub_q, "sub");
test_genericq (2, 100, 100, mpfr_mul_q, "mul");
test_genericq (2, 100, 100, mpfr_div_q, "div");
test_specialq (2, 100, 100, mpfr_mul_q, mpq_mul, "mul");
test_specialq (2, 100, 100, mpfr_div_q, mpq_div, "div");
test_specialq (2, 100, 100, mpfr_add_q, mpq_add, "add");
test_specialq (2, 100, 100, mpfr_sub_q, mpq_sub, "sub");
test_cmp_z (2, 100, 100);
test_cmp_q (2, 100, 100);
test_cmp_f (2, 100, 100);
check_for_zero ();
tests_end_mpfr ();
return 0;
}
示例3: main
int
main(int argc, char *argv[])
{
int *pr_arr, pr_len, n_found;
int max = 1; /* max number of prime search. this grows '*10' */
int i, tmp;
long sum;
n_found = 0;
sum = 0L;
tmp = 4; /* for skip 2,3,5,7 */
while (1) {
/* we grow search range to 10,100,1000.. */
max *= 10;
if (primes_under(max, &pr_arr, &pr_len))
errx(1, "fail primes_under(%d)", max);
for (i = tmp; i < pr_len; i++) {
if (special(pr_arr[i], pr_arr, pr_len)) {
sum += pr_arr[i];
n_found++;
if (n_found == NEED_NFOUND)
break; /* out to for-loop */
}
}
if (n_found == NEED_NFOUND)
break; /* out to while-loop */
tmp = pr_len; /* skip already checked for next loop */
free(pr_arr);
}
printf("%ld\n", sum);
return 0;
}
示例4: main
int
main (int argc, char **argv)
{
mpfr_t x;
tests_start_mpfr ();
special ();
check_inexact ();
check("1.0", 3, MPFR_RNDN, "3.3333333333333331483e-1");
check("1.0", 3, MPFR_RNDZ, "3.3333333333333331483e-1");
check("1.0", 3, MPFR_RNDU, "3.3333333333333337034e-1");
check("1.0", 3, MPFR_RNDD, "3.3333333333333331483e-1");
check("1.0", 2116118, MPFR_RNDN, "4.7256343927890600483e-7");
check("1.098612288668109782", 5, MPFR_RNDN, "0.21972245773362195087");
mpfr_init2 (x, 53);
mpfr_set_ui (x, 3, MPFR_RNDD);
mpfr_log (x, x, MPFR_RNDD);
mpfr_div_ui (x, x, 5, MPFR_RNDD);
if (mpfr_cmp_str1 (x, "0.21972245773362189536"))
{
printf ("Error in mpfr_div_ui for x=ln(3), u=5\n");
exit (1);
}
mpfr_clear (x);
test_generic_ui (2, 200, 100);
tests_end_mpfr ();
return 0;
}
示例5: fillstruct
glui32 fillstruct(strid_t stream, const unsigned *info, glui32 *dest,
glui32 (*special)(strid_t))
{
unsigned char buffer[4];
unsigned e;
glui32 len = 0;;
for(e = 0; info[e]; e++) {
if(info[e] == 0x8000) {
*dest++ = special(stream);
len++;
}
else if(info[e] > 4) {
unsigned i;
for(i = 0; i < info[e]; i++) {
*dest++ = glk_get_char_stream(stream);
len++;
}
} else {
glk_get_buffer_stream(stream, (char *) buffer, info[e]);
switch(info[e]) {
case 1: *dest = MSBdecode1(buffer); break;
case 2: *dest = MSBdecode2(buffer); break;
case 3: *dest = MSBdecode3(buffer); break;
case 4: *dest = MSBdecode4(buffer); break;
}
dest++;
len+=info[e];
}
}
return len;
}
示例6: assert
ReservedSpace
ReservedSpace::last_part(size_t partition_size, size_t alignment) {
assert(partition_size <= size(), "partition failed");
ReservedSpace result(base() + partition_size, size() - partition_size,
alignment, special(), executable());
return result;
}
示例7:
//! This function is called once per simulation step, allowing the
//! constraint to be "motorized" according to some response.
void OscHinge2ODE::simulationCallback()
{
ODEConstraint& me = *static_cast<ODEConstraint*>(special());
dReal angle1 = dJointGetHinge2Angle1(me.joint());
dReal rate1 = dJointGetHinge2Angle1Rate(me.joint());
dReal addtorque1 =
- m_response->m_stiffness.m_value*angle1
- m_response->m_damping.m_value*rate1;
#if 0 // TODO: dJointGetHinge2Angle2 is not yet available in ODE.
dReal angle2 = dJointGetHinge2Angle2(me.joint());
#else
dReal angle2 = 0;
#endif
dReal rate2 = dJointGetHinge2Angle2Rate(me.joint());
dReal addtorque2 =
- m_response->m_stiffness.m_value*angle2
- m_response->m_damping.m_value*rate2;
m_torque1.m_value = addtorque1;
m_torque2.m_value = addtorque2;
dJointAddHinge2Torques(me.joint(), addtorque1, addtorque2);
}
示例8: simulationCallback
void OscFreeODE::simulationCallback()
{
ODEConstraint& me = *static_cast<ODEConstraint*>(special());
const dReal *pos1 = dBodyGetPosition(me.body1());
const dReal *pos2 = dBodyGetPosition(me.body2());
const dReal *vel1 = dBodyGetLinearVel(me.body1());
const dReal *vel2 = dBodyGetLinearVel(me.body2());
dReal force[3];
force[0] =
- ((pos2[0]-pos1[0]-m_initial_distance[0])
* m_response->m_stiffness.m_value)
- (vel2[0]-vel1[0]) * m_response->m_damping.m_value;
force[1] =
- ((pos2[1]-pos1[1]-m_initial_distance[1])
* m_response->m_stiffness.m_value)
- (vel2[1]-vel1[1]) * m_response->m_damping.m_value;
force[2] =
- ((pos2[2]-pos1[2]-m_initial_distance[2])
* m_response->m_stiffness.m_value)
- (vel2[2]-vel1[2]) * m_response->m_damping.m_value;
dBodyAddForce(me.body1(), -force[0], -force[1], -force[2]);
dBodyAddForce(me.body2(), force[0], force[1], force[2]);
}
示例9: main
int
main (void)
{
mp_prec_t p;
MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
particular_cases ();
check_pow_ui ();
check_pow_si ();
check_special_pow_si ();
pow_si_long_min ();
for (p = 2; p < 100; p++)
check_inexact (p);
underflows ();
overflows ();
x_near_one ();
test_generic (2, 100, 100);
test_generic_ui (2, 100, 100);
test_generic_si (2, 100, 100);
data_check ("data/pow275", mpfr_pow275, "mpfr_pow275");
tests_end_mpfr ();
return 0;
}
示例10: actual_committed_size
size_t VirtualSpace::actual_committed_size() const {
// Special VirtualSpaces commit all reserved space up front.
if (special()) {
return reserved_size();
}
size_t committed_low = pointer_delta(_lower_high, _low_boundary, sizeof(char));
size_t committed_middle = pointer_delta(_middle_high, _lower_high_boundary, sizeof(char));
size_t committed_high = pointer_delta(_upper_high, _middle_high_boundary, sizeof(char));
#ifdef ASSERT
size_t lower = pointer_delta(_lower_high_boundary, _low_boundary, sizeof(char));
size_t middle = pointer_delta(_middle_high_boundary, _lower_high_boundary, sizeof(char));
size_t upper = pointer_delta(_upper_high_boundary, _middle_high_boundary, sizeof(char));
if (committed_high > 0) {
assert(committed_low == lower, "Must be");
assert(committed_middle == middle, "Must be");
}
if (committed_middle > 0) {
assert(committed_low == lower, "Must be");
}
if (committed_middle < middle) {
assert(committed_high == 0, "Must be");
}
if (committed_low < lower) {
assert(committed_high == 0, "Must be");
assert(committed_middle == 0, "Must be");
}
#endif
return committed_low + committed_middle + committed_high;
}
示例11: assert
size_t PSVirtualSpaceHighToLow::expand_into(PSVirtualSpace* other_space,
size_t bytes) {
assert(is_aligned(bytes), "arg not aligned");
assert(grows_down(), "this space must grow down");
assert(other_space->grows_up(), "other space must grow up");
assert(reserved_low_addr() == other_space->reserved_high_addr(),
"spaces not contiguous");
assert(special() == other_space->special(), "one space is special in memory, the other is not");
DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
DEBUG_ONLY(PSVirtualSpaceVerifier other_verifier(other_space));
size_t bytes_needed = bytes;
// First use the uncommitted region in this space.
size_t tmp_bytes = MIN2(uncommitted_size(), bytes_needed);
if (tmp_bytes > 0) {
if (expand_by(tmp_bytes)) {
bytes_needed -= tmp_bytes;
} else {
return 0;
}
}
// Next take from the uncommitted region in the other space, and commit it.
tmp_bytes = MIN2(other_space->uncommitted_size(), bytes_needed);
if (tmp_bytes > 0) {
char* const commit_base = committed_low_addr() - tmp_bytes;
if (other_space->special() ||
os::commit_memory(commit_base, tmp_bytes, alignment(), !ExecMem)) {
// Reduce the reserved region in the other space.
other_space->set_reserved(other_space->reserved_low_addr(),
other_space->reserved_high_addr() - tmp_bytes,
other_space->special());
// Grow both reserved and committed in this space.
_reserved_low_addr -= tmp_bytes;
_committed_low_addr -= tmp_bytes;
bytes_needed -= tmp_bytes;
} else {
return bytes - bytes_needed;
}
}
// Finally take from the already committed region in the other space.
tmp_bytes = bytes_needed;
if (tmp_bytes > 0) {
// Reduce both committed and reserved in the other space.
other_space->set_committed(other_space->committed_low_addr(),
other_space->committed_high_addr() - tmp_bytes);
other_space->set_reserved(other_space->reserved_low_addr(),
other_space->reserved_high_addr() - tmp_bytes,
other_space->special());
// Grow both reserved and committed in this space.
_reserved_low_addr -= tmp_bytes;
_committed_low_addr -= tmp_bytes;
}
return bytes;
}
示例12: OscFree
OscFreeODE::OscFreeODE(dWorldID odeWorld, dSpaceID odeSpace,
const char *name, OscBase* parent,
OscObject *object1, OscObject *object2)
: OscFree(name, parent, object1, object2)
{
m_response = new OscResponse("response",this);
// The "Free" constraint is not actually an ODE constraint.
// However, we need an ODEConstraint to remember the objects so
// that they can receive forces and torques.
m_pSpecial = new ODEConstraint(this, NULL, odeWorld, odeSpace,
object1, object2);
ODEConstraint& cons = *static_cast<ODEConstraint*>(special());
const dReal *pos1 = dBodyGetPosition(cons.body1());
const dReal *pos2 = dBodyGetPosition(cons.body2());
m_initial_distance[0] = pos2[0] - pos1[0];
m_initial_distance[1] = pos2[1] - pos1[1];
m_initial_distance[2] = pos2[2] - pos1[2];
printf("[%s] Free constraint created between %s and %s.\n",
simulation()->type_str(),
object1->c_name(), object2->c_name());
}
示例13: main
int main(int argc, char ** argv){
int option = -1;
if( argc <= 1 || ( (option = atoi(argv[1])) < 0 ) ){
print_usage();
}
int count = 0;
if(argc >= 3)
count = atoi(argv[2]);
printf("Welcome to effectTest, option %d, count %d\n", option, count);
switch(option){
case 0:
functional(count);
break;
case 1:
left();
break;
case 2:
right();
break;
case 3:
duplicate();
break;
case 4:
invalid();
break;
case 5:
special();
break;
case 9:
other();
break;
}
return 0;
}
示例14: on_density
void OscSphereODE::on_density()
{
ODEObject *ode_object = static_cast<ODEObject*>(special());
dMassSetSphere(&ode_object->mass(), m_density.m_value, m_radius.m_value);
dBodySetMass(ode_object->body(), &ode_object->mass());
m_mass.m_value = ode_object->mass().mass;
}
示例15:
void G1PageBasedVirtualSpace::print_on(outputStream* out) {
out->print ("Virtual space:");
if (special()) out->print(" (pinned in memory)");
out->cr();
out->print_cr(" - committed: " SIZE_FORMAT, committed_size());
out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size());
out->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", p2i(_low_boundary), p2i(_high_boundary));
}