本文整理汇总了C++中compute函数的典型用法代码示例。如果您正苦于以下问题:C++ compute函数的具体用法?C++ compute怎么用?C++ compute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(ComputeRandomPermutation, ComputeSingle)
{
std::vector<int> expectedData{ 0 };
EXPECT_EQ(expectedData, compute(1));
}
开发者ID:rdiachenko,项目名称:black-box,代码行数:5,代码来源:ComputeRandomPermutation.cpp
示例2: compute
void HelloWorld::set(double r1_, double r2_)
{
r1 = r1_;
r2 = r2_;
compute(); // compute s
}
开发者ID:KajaStene,项目名称:code_snippets,代码行数:6,代码来源:HelloWorld.cpp
示例3: compute
void XListBox::mouseWheelUp(X_Event *event)
{
compute(6);
onPaint(X_UPDATE);
showWidget();
}
开发者ID:dulton,项目名称:XGUI,代码行数:6,代码来源:XListBox.cpp
示例4: main
//main program
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
int size, rank;
long t1, t2;
static int ranks[1] = { 0 };
MPI_Request request1, request2, request3, request4;
MPI_Status status, status1, status2, status3, status4;
MPI_Group MPI_GROUP_WORLD, grprem;
MPI_Comm commslave, newcomm;
MPI_Comm commsp;
MPI_Comm_group(MPI_COMM_WORLD, &MPI_GROUP_WORLD);
MPI_Group_excl(MPI_GROUP_WORLD, 1, ranks, &grprem);
MPI_Comm_create(MPI_COMM_WORLD, grprem, &commslave);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
printf("Node %d in %d is ready\n", rank, size);
//Initialize
double *grid0 = creat_grid(x_size, y_size, z_size, size, rank, GRID0);
double *grid1 = creat_grid(x_size, y_size, z_size, size, rank, GRID1);
MPI_Barrier(MPI_COMM_WORLD);
if (size != 1)
{
if (rank == 0)
{
for (int i = 1; i < size; i++)
{
int len = (i == size - 1) ? (x_size / (size - 1)) : (x_size / (size - 1) + x_size % (size - 1));
MPI_Isend(grid0 + (i - 1)*x_size / (size - 1), len*y_size*z_size, MPI_DOUBLE, i, i, MPI_COMM_WORLD, &request1);
MPI_Wait(&request1, &status1);
}
}
else
{
for (int i = 1; i < size; i++)
{
if (rank == i)
{
int len = (i == size - 1) ? (x_size / (size - 1)) : (x_size / (size - 1) + x_size % (size - 1));
MPI_Irecv(grid0 + y_size*z_size, len*y_size*z_size, MPI_DOUBLE, 0, i, MPI_COMM_WORLD, &request2);
MPI_Wait(&request2, &status2);
}
}
}
}
//Compute
if (rank == 0) printf("Start computing...\n");
if (rank != 0 && size > 1)
{
for (int t = 0; t < stepnum; t++)
{
compute(grid0, grid1, rank, size);
//send right slice of data to next node, then receieve right slice of data form next node
if (rank < size - 1)
{
MPI_Isend(grid1 + (1 + x_size / (size - 1))*y_size*z_size,
y_size*z_size, MPI_DOUBLE, rank + 1, rank, MPI_COMM_WORLD, &request1);
MPI_Irecv(grid1 + (1 + x_size / (size - 1))*y_size*z_size,
y_size*z_size, MPI_DOUBLE, rank + 1, rank + 1, MPI_COMM_WORLD, &request2);
MPI_Wait(&request1, &status1);
MPI_Wait(&request2, &status2);
}
//receieve left slice of data from perior node, then send left slice of data to perior node
if (rank > 1)
{
MPI_Irecv(grid1, y_size*z_size, MPI_DOUBLE, rank - 1, rank - 1, MPI_COMM_WORLD, &request3);
MPI_Isend(grid1, y_size*z_size, MPI_DOUBLE, rank - 1, rank, MPI_COMM_WORLD, &request4);
MPI_Wait(&request3, &status3);
MPI_Wait(&request4, &status4);
}
double *temp;
temp = grid0;
grid0 = grid1;
grid1 = temp;
MPI_Barrier(commslave);
}
}
else if (size == 1)
{
for (int t = 0; t < stepnum; t++)
{
compute(grid0, grid1, rank, size);
double *temp;
temp = grid0;
grid0 = grid1;
grid1 = temp;
}
}
else { ; }
MPI_Barrier(MPI_COMM_WORLD);
printf("Rank %d finished computing!\n", rank);
//Gather data form nodes to host
if (size != 1)
{
if (stepnum % 2)
{
double *temp;
temp = grid0;
//.........这里部分代码省略.........
开发者ID:Luohaothu,项目名称:homework3,代码行数:101,代码来源:isend.cpp
示例5: passThrough
void passThrough(int *p) {
use2(p, compute());
// [email protected] {{Passing null pointer value via 1st parameter 'ptr'}}
// [email protected] {{Calling 'use2'}}
}
开发者ID:keryell,项目名称:clang-1,代码行数:5,代码来源:eager-reclamation-path-notes.c
示例6: __declspec
__declspec(dllexport) long Multiplicate(long arg1, long arg2)
{
return compute(arg1, arg2);
}
开发者ID:MarianoGamo,项目名称:TestXLL,代码行数:4,代码来源:UDFs.cpp
示例7: compute
MatrixXf Permutohedral::compute ( const MatrixXf & in, bool reverse ) const
{
MatrixXf r;
compute( r, in, reverse );
return r;
}
开发者ID:Kamnitsask,项目名称:dense3dCrf,代码行数:6,代码来源:permutohedral.cpp
示例8: compute
const_shared_ptr<Result> BinaryExpression::compute(const std::uint8_t& left,
const double& right, yy::location left_position,
yy::location right_position) const {
double converted_left = left;
return compute(converted_left, right, left_position, right_position);
}
开发者ID:cqcallaw,项目名称:newt,代码行数:6,代码来源:binary_expression.cpp
示例9: compute
SUMOReal
HelpersHBEFA::computeFuel(SUMOEmissionClass c, double v, double a) {
return compute(c, FUEL_OFFSET, v, a) / 790.;
}
开发者ID:namnatulco,项目名称:sumo-complete,代码行数:4,代码来源:HelpersHBEFA.cpp
示例10: mexFunction
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
int atria_preprocessing_given = 0; // flag wheter preprocessing is already given on command line
long opt_flag = 0; // 0 => eucl.norm, upper triangle matrix, 1 => max.norm, utm, 2 => eucl,full matrix, 3 => max.,full matrix
be_verbose = 0; // Don't spit out feedback to user by default
// try to see if the first parameter given is an atria structure
// If this is true, the order of input parameters is shifted by one
if ((nrhs > 0) && mxIsStruct(prhs[0])) {
atria_preprocessing_given = 1;
prhs++; // these two lines enable us to use the old argument parsing block without changing it
nrhs--;
}
/* check input args */
if (nrhs < 3)
{
mexErrMsgTxt("Correlation sum : Data set of points (row vectors), reference points and relative range (relative to attractor diameter) must be given, number of bins is optional");
return;
}
if (nrhs > 4) opt_flag = (long) *((double *)mxGetPr(prhs[4]));
if (opt_flag & (long) 2)
be_verbose = 0;
if (atria_preprocessing_given) {
#ifdef MATLAB_MEX_FILE
char* metric = 0;
if (mxIsChar(mxGetField(prhs[-1], 0, "optional"))) {
long buflen = (mxGetM(mxGetField(prhs[-1], 0, "optional")) * mxGetN(mxGetField(prhs[-1], 0, "optional"))) + 1;
metric = (char*) mxMalloc(buflen);
mxGetString(mxGetField(prhs[-1], 0, "optional"), metric, buflen);
}
if ((metric == 0) || (!strncmp("euclidian", metric, strlen(metric)))) {
euclidian_distance dummy;
if (be_verbose)
mexPrintf("Using euclidian metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 1, dummy);
}
else if ((!strncmp("maximum", metric, strlen(metric)))) {
maximum_distance dummy;
if (be_verbose)
mexPrintf("Using maximum metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 1, dummy);
}
else
printf("ATRIA preprocessing structure was not created using a supported metric; doing preprocessing again\n");
mxFree(metric);
#endif
} else {
if (opt_flag & (long)1) {
maximum_distance dummy;
if (be_verbose)
mexPrintf("Using maximum metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 0, dummy);
} else {
euclidian_distance dummy;
if (be_verbose)
mexPrintf("Using euclidian metric to calculated distances\n");
compute(nlhs, plhs, nrhs, prhs, 0, dummy);
}
}
}
开发者ID:Apollonius,项目名称:hctsa,代码行数:74,代码来源:crosscorrsum.cpp
示例11: compute
/**
* \ingroup Stimulus
* Set the angular aperture of the cylinder in radians
* \param _startAngle Starting angle in radians
* \param _endAngle End angle in radians
**/
void CylinderPointsStimulus::setAperture(double _startAngle, double _endAngle )
{ startAngle = _startAngle;
endAngle = _endAngle;
compute();
}
开发者ID:guendas,项目名称:cncsvision,代码行数:11,代码来源:CylinderPointsStimulus.cpp
示例12: compute
void LMMNormalDriftCalculator::compute(const LMMCurveState& cs,
std::vector<Real>& drifts) const {
compute(cs.forwardRates(), drifts);
}
开发者ID:androidYibo,项目名称:documents,代码行数:4,代码来源:lmmnormaldriftcalculator.cpp
示例13: GetLeft
const_shared_ptr<Result> BinaryExpression::Evaluate(
const shared_ptr<ExecutionContext> context,
const shared_ptr<ExecutionContext> closure) const {
ErrorListRef errors = ErrorList::GetTerminator();
const_shared_ptr<Expression> left = GetLeft();
const_shared_ptr<Expression> right = GetRight();
const_shared_ptr<Result> left_result = left->Evaluate(context, closure);
if (!ErrorList::IsTerminator(left_result->GetErrors())) {
return left_result;
}
const_shared_ptr<Result> right_result = right->Evaluate(context, closure);
if (!ErrorList::IsTerminator(right_result->GetErrors())) {
return right_result;
}
auto left_type_specifier_result = left->GetTypeSpecifier(context);
auto right_type_specifier_result = right->GetTypeSpecifier(context);
errors = left_type_specifier_result.GetErrors();
if (ErrorList::IsTerminator(errors)) {
errors = right_type_specifier_result.GetErrors();
if (ErrorList::IsTerminator(errors)) {
yy::location left_position = left->GetLocation();
yy::location right_position = right->GetLocation();
auto type_table = context->GetTypeTable();
auto left_type = left_type_specifier_result.GetData();
auto right_type = right_type_specifier_result.GetData();
// This logic is essentially a big muxer.
// It works in tandem with C++ type widening to convert operands to the same data type
if (left_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetBoolean(), type_table)
== EQUIVALENT) {
bool left_value = *(left_result->GetData<bool>());
if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetBoolean(), type_table)
== EQUIVALENT) {
bool right_value = *(right_result->GetData<bool>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetByte(), type_table)
== EQUIVALENT) {
auto right_value = *(right_result->GetData<std::uint8_t>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetInt(), type_table)
== EQUIVALENT) {
int right_value = *(right_result->GetData<int>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetDouble(), type_table)
== EQUIVALENT) {
double right_value = *(right_result->GetData<double>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetString(), type_table)
== EQUIVALENT) {
string right_value = *(right_result->GetData<string>());
return compute(left_value, right_value, left_position,
right_position);
} else {
assert(false);
}
} else if (left_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetByte(), type_table)
== EQUIVALENT) {
auto left_value = *(left_result->GetData<std::uint8_t>());
if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetBoolean(), type_table)
== EQUIVALENT) {
bool right_value = *(right_result->GetData<bool>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetByte(), type_table)
== EQUIVALENT) {
auto right_value = *(right_result->GetData<std::uint8_t>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetInt(), type_table)
== EQUIVALENT) {
int right_value = *(right_result->GetData<int>());
return compute(left_value, right_value, left_position,
right_position);
} else if (right_type->AnalyzeAssignmentTo(
PrimitiveTypeSpecifier::GetDouble(), type_table)
== EQUIVALENT) {
double right_value = *(right_result->GetData<double>());
return compute(left_value, right_value, left_position,
//.........这里部分代码省略.........
开发者ID:cqcallaw,项目名称:newt,代码行数:101,代码来源:binary_expression.cpp
示例14: main
long main()
{
printf("compute=%d\n", compute(1, 2, 3));
}
开发者ID:vsinha,项目名称:simple_c_compiler,代码行数:4,代码来源:test2.c
示例15: log_notice
//.........这里部分代码省略.........
"\tBudget\tUsed Budget\n");
if (data->ind == 0) {
clock_gettime(CLOCK_MONOTONIC, &t_zero);
#ifdef TRACE_SETS_ZERO_TIME
if (opts.ftrace)
log_ftrace(ft_data.marker_fd,
"[%d] sets zero time",
data->ind);
#endif
}
pthread_barrier_wait(&threads_barrier);
/*
* Set the task to SCHED_DEADLINE as far as possible touching its
* budget as little as possible for the first iteration.
*/
if (data->sched_policy == SCHED_DEADLINE) {
ret = sched_setattr(tid, &attr, flags);
if (ret != 0) {
log_critical("[%d] sched_setattr "
"returned %d", data->ind, ret);
errno = ret;
perror("sched_setattr");
exit(EXIT_FAILURE);
}
}
t = t_zero;
t_next = msec_to_timespec(1000LL);
t_next = timespec_add(&t, &t_next);
clock_nanosleep(CLOCK_MONOTONIC,
TIMER_ABSTIME,
&t_next,
NULL);
data->deadline = timespec_add(&t_next, &data->deadline);
while (continue_running) {
int pn;
struct timespec t_start, t_end, t_diff, t_slack, t_resp;
/* Thread numeration reported starts with 1 */
#ifdef TRACE_BEGINS_LOOP
if (opts.ftrace)
log_ftrace(ft_data.marker_fd, "[%d] begins job %d", data->ind+1, i);
#endif
clock_gettime(CLOCK_MONOTONIC, &t_start);
if (data->nphases == 0) {
compute(data->ind, &data->min_et, NULL, 0);
} else {
for (pn = 0; pn < data->nphases; pn++) {
log_notice("[%d] phase %d start", data->ind+1, pn);
exec_phase(data, pn);
log_notice("[%d] phase %d end", data->ind+1, pn);
}
}
clock_gettime(CLOCK_MONOTONIC, &t_end);
t_diff = timespec_sub(&t_end, &t_start);
t_slack = timespec_sub(&data->deadline, &t_end);
t_resp = timespec_sub(&t_end, &t_next);
t_start_usec = timespec_to_usec(&t_start);
if (i < nperiods) {
if (timings)
curr_timing = &timings[i];
else
curr_timing = &tmp_timing;
curr_timing->ind = data->ind;
curr_timing->period = timespec_to_usec(&data->period);
curr_timing->min_et = timespec_to_usec(&data->min_et);
curr_timing->max_et = timespec_to_usec(&data->max_et);
curr_timing->rel_start_time =
t_start_usec - timespec_to_usec(&data->main_app_start);
curr_timing->abs_start_time = t_start_usec;
curr_timing->end_time = timespec_to_usec(&t_end);
curr_timing->deadline = timespec_to_usec(&data->deadline);
curr_timing->duration = timespec_to_usec(&t_diff);
curr_timing->slack = timespec_to_lusec(&t_slack);
curr_timing->resp_time = timespec_to_usec(&t_resp);
}
if (!timings)
log_timing(data->log_handler, curr_timing);
t_next = timespec_add(&t_next, &data->period);
data->deadline = timespec_add(&data->deadline, &data->period);
#ifdef TRACE_END_LOOP
if (opts.ftrace)
log_ftrace(ft_data.marker_fd, "[%d] end loop %d", data->ind, i);
#endif
if (curr_timing->slack < 0)
log_notice("[%d] DEADLINE MISS !!!", data->ind+1);
i++;
}
free(timings);
}
开发者ID:martinamaggio,项目名称:rt-muse,代码行数:101,代码来源:rt-bench.c
示例16: switch
bool PhTimeCodeEdit::eventFilter(QObject *, QEvent *event)
{
switch (event->type()) {
case QEvent::KeyPress:
{
QKeyEvent *keyEvent = (QKeyEvent*)event;
switch (keyEvent->key()) {
case Qt::Key_0:
case Qt::Key_1:
case Qt::Key_2:
case Qt::Key_3:
case Qt::Key_4:
case Qt::Key_5:
case Qt::Key_6:
case Qt::Key_7:
case Qt::Key_8:
case Qt::Key_9:
_addedNumbers.push(keyEvent->key());
compute(true);
return true;
case Qt::Key_Backspace:
if(_addedNumbers.length()) {
_addedNumbers.pop();
compute(false);
}
return true;
case Qt::Key_Escape:
case Qt::Key_Enter:
case Qt::Key_Return:
return false;
default:
return true;
}
}
case QEvent::MouseButtonPress:
QApplication::setOverrideCursor(Qt::SizeVerCursor);
_mousePressed = true;
_mousePressedLocation = static_cast<QMouseEvent *>(event)->pos();
_selectedIndex = (cursorPositionAt(_mousePressedLocation) / 3) * 3;
return true;
case QEvent::MouseButtonRelease:
QApplication::setOverrideCursor(Qt::ArrowCursor);
_mousePressed = false;
return true;
case QEvent::MouseMove:
{
if(_mousePressed) {
int y = static_cast<QMouseEvent *>(event)->pos().y();
PhFrame currentFrame = PhTimeCode::frameFromString(this->text(), _tcType);
PhFrame fps = PhTimeCode::getFps(_tcType);
PhFrame offset = 0;
switch(_selectedIndex) {
case 0:
offset = fps * 60 * 60;
break;
case 3:
offset = fps * 60;
break;
case 6:
offset = fps;
break;
case 9:
offset = 1;
break;
}
if(_mousePressedLocation.y() > y)
currentFrame += offset;
else
currentFrame -= offset;
_mousePressedLocation.setY(y);
this->setText(PhTimeCode::stringFromFrame(currentFrame, _tcType));
if(text().contains("-"))
setSelection(_selectedIndex + 1, 2);
else
setSelection(_selectedIndex, 2);
return true;
}
return false;
}
default:
return false;
}
}
开发者ID:FeodorFitsner,项目名称:Joker,代码行数:89,代码来源:PhTimeCodeEdit.cpp
示例17: compute
void SingleChannelHistogram::compute(
const sensor_msgs::Image::ConstPtr& msg)
{
compute(msg, sensor_msgs::Image::ConstPtr());
}
开发者ID:rkoyama1623,项目名称:jsk_recognition,代码行数:5,代码来源:single_channel_histogram.cpp
示例18: QDoubleValidator
Form::Form()
{
this->setObjectName(QString::fromUtf8("Form"));
this->resize(QSize(370, 139).expandedTo(this->minimumSizeHint()));
validator = new QDoubleValidator(this);
widget = new QWidget(this);
widget->setObjectName(QString::fromUtf8("widget"));
widget->setGeometry(QRect(10, 50, 351, 26));
hboxLayout = new QHBoxLayout(widget);
hboxLayout->setSpacing(6);
hboxLayout->setMargin(0);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
lineEdit_a = new QLineEdit(widget);
lineEdit_a->setObjectName(QString::fromUtf8("lineEdit_a"));
lineEdit_a->setValidator(validator);
hboxLayout->addWidget(lineEdit_a);
comboBox = new QComboBox(widget);
comboBox->setObjectName(QString::fromUtf8("comboBox"));
hboxLayout->addWidget(comboBox);
lineEdit_b = new QLineEdit(widget);
lineEdit_b->setObjectName(QString::fromUtf8("lineEdit_b"));
lineEdit_b->setValidator(validator);
hboxLayout->addWidget(lineEdit_b);
label_eauql = new QLabel(widget);
label_eauql->setObjectName(QString::fromUtf8("label_eauql"));
hboxLayout->addWidget(label_eauql);
lineEdit_c = new QLineEdit(widget);
lineEdit_c->setObjectName(QString::fromUtf8("lineEdit_c"));
lineEdit_c->setReadOnly(true);
hboxLayout->addWidget(lineEdit_c);
layoutWidget = new QWidget(this);
layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
layoutWidget->setGeometry(QRect(100, 100, 182, 30));
hboxLayout1 = new QHBoxLayout(layoutWidget);
hboxLayout1->setSpacing(6);
hboxLayout1->setMargin(0);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
pushButton_ok = new QPushButton(layoutWidget);
pushButton_ok->setObjectName(QString::fromUtf8("pushButton_ok"));
hboxLayout1->addWidget(pushButton_ok);
pushButton_close = new QPushButton(layoutWidget);
pushButton_close->setObjectName(QString::fromUtf8("pushButton_close"));
hboxLayout1->addWidget(pushButton_close);
label_compute = new QLabel(this);
label_compute->setObjectName(QString::fromUtf8("label_compute"));
label_compute->setGeometry(QRect(10, 20, 71, 16));
retranslateUi();
QObject::connect(pushButton_close, SIGNAL(clicked()), this, SLOT(close()));
QObject::connect(pushButton_ok, SIGNAL(clicked()), this, SLOT(compute()));
QMetaObject::connectSlotsByName(this);
} // setupUi
开发者ID:bahamut8348,项目名称:xkcode,代码行数:67,代码来源:form.cpp
示例19: compute
double StandardUptakeValueMeasureHandler::computePreferredFormula(double activityConcentrationValueInImageUnits)
{
return compute(activityConcentrationValueInImageUnits, getPreferredFormula());
}
开发者ID:151706061,项目名称:starviewer,代码行数:4,代码来源:standarduptakevaluemeasurehandler.cpp
示例20: compute
bool HashFunction::verify(const std::string& msg,
const std::string& salt,
const std::string& hash) const
{
return compute(msg, salt) == hash;
}
开发者ID:ineron,项目名称:iAdmin,代码行数:6,代码来源:HashFunction.cpp
注:本文中的compute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论