本文整理汇总了C++中s1函数的典型用法代码示例。如果您正苦于以下问题:C++ s1函数的具体用法?C++ s1怎么用?C++ s1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bmc_state_decision
/* State decision algorithm 9.3.3 Fig 26 */
static int bmc_state_decision(struct pp_instance *ppi,
struct pp_frgn_master *m)
{
int cmpres;
struct pp_frgn_master myself;
if (ppi->master_only)
goto master;
if (ppi->slave_only)
goto slave;
if ((!ppi->frgn_rec_num) && (ppi->state == PPS_LISTENING))
return PPS_LISTENING;
/* copy local information to a foreign_master structure */
copy_d0(ppi, &myself);
/* dataset_cmp is "a - b" but lower values win */
cmpres = bmc_dataset_cmp(ppi, &myself, m);
if (DSDEF(ppi)->clockQuality.clockClass < 128) {
if (cmpres < 0)
goto master;
if (cmpres > 0)
goto passive;
}
if (cmpres < 0)
goto master;
if (cmpres > 0) {
if (DSDEF(ppi)->numberPorts == 1)
goto slave; /* directly skip to ordinary clock handling */
else
goto check_boundary_clk;
}
pp_diag(ppi, bmc, 1,"%s: error\n", __func__);
/* MB: Is this the return code below correct? */
/* Anyway, it's a valid return code. */
return PPS_FAULTY;
check_boundary_clk:
if (ppi->port_idx == GLBS(ppi)->ebest_idx) /* This port is the Ebest */
goto slave;
/* If idcmp returns 0, it means that this port is not the best because
* Ebest is better by topology than Erbest */
if (!idcmp(&myself.ann.grandmasterIdentity,
&m->ann.grandmasterIdentity))
goto passive;
else
goto master;
passive:
p1(ppi, &m->hdr, &m->ann);
pp_diag(ppi, bmc, 1,"%s: passive\n", __func__);
return PPS_PASSIVE;
master:
m1(ppi);
pp_diag(ppi, bmc, 1,"%s: master\n", __func__);
return PPS_MASTER;
slave:
s1(ppi, &m->hdr, &m->ann);
pp_diag(ppi, bmc, 1,"%s: slave\n", __func__);
return PPS_SLAVE;
}
示例2: s1
void RegionalTerrain_3r::SigPopEdge(QuadEdge::Edge* e) {
Segment_3r s1(e->Org()->pos, e->Dest()->pos);
Segment_3r s2(e->Dest()->pos, e->Org()->pos);
SigPopVisualSegment_3r(s1);
SigPopVisualSegment_3r(s2);
}
示例3: computeConstraints
NOX::Abstract::Group::ReturnType
LOCA::TurningPoint::MinimallyAugmented::Constraint::
computeConstraints()
{
if (isValidConstraints)
return NOX::Abstract::Group::Ok;
std::string callingFunction =
"LOCA::TurningPoint::MinimallyAugmented::Constraint::computeConstraints()";
NOX::Abstract::Group::ReturnType status;
NOX::Abstract::Group::ReturnType finalStatus = NOX::Abstract::Group::Ok;
// Compute J
status = grpPtr->computeJacobian();
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// Set up bordered systems
Teuchos::RCP<const LOCA::BorderedSolver::JacobianOperator> op =
Teuchos::rcp(new LOCA::BorderedSolver::JacobianOperator(grpPtr));
borderedSolver->setMatrixBlocksMultiVecConstraint(op,
a_vector,
b_vector,
Teuchos::null);
// Create RHS
NOX::Abstract::MultiVector::DenseMatrix one(1,1);
if (nullVecScaling == NVS_OrderN)
one(0,0) = dn;
else
one(0,0) = 1.0;
// Get linear solver parameters
Teuchos::RCP<Teuchos::ParameterList> linear_solver_params =
parsedParams->getSublist("Linear Solver");
// Compute sigma_1 and right null vector v
NOX::Abstract::MultiVector::DenseMatrix s1(1,1);
status = borderedSolver->initForSolve();
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
status = borderedSolver->applyInverse(*linear_solver_params,
NULL,
&one,
*v_vector,
s1);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
// Compute sigma_2 and left null vector w
NOX::Abstract::MultiVector::DenseMatrix s2(1,1);
if (!isSymmetric) {
status = borderedSolver->initForTransposeSolve();
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
status = borderedSolver->applyInverseTranspose(*linear_solver_params,
NULL,
&one,
*w_vector,
s2);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
else {
*w_vector = *v_vector;
s2.assign(s1);
}
// Compute sigma = -w^T*J*v
status = grpPtr->applyJacobianMultiVector(*v_vector, *Jv_vector);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
if (!isSymmetric) {
status = grpPtr->applyJacobianTransposeMultiVector(*w_vector, *Jtw_vector);
finalStatus =
globalData->locaErrorCheck->combineAndCheckReturnTypes(status,
finalStatus,
callingFunction);
}
else
*Jtw_vector = *Jv_vector;
Jv_vector->multiply(-1.0, *w_vector, constraints);
// Scale sigma
double w_norm = (*w_vector)[0].norm();
double v_norm = (*v_vector)[0].norm();
double Jv_norm = (*Jv_vector)[0].norm();
//.........这里部分代码省略.........
示例4: switch
String AirDC::OutputSerial(int mode)
{
String StreamOut;
switch(mode)
{
case 1: //Measurements output
{
//_p,_T,_RH,_qc,AOA,AOS
String s1(_p, 6);
String s2(_T, 6);
String s3(_RH, 6);
String s4(_qc, 6);
String s5(_AOA, 6);
String s6(_AOS, 6);
StreamOut="$TMO,"+s1+','+s2+','+s3+','+s4+','+s5+','+s6;
//To read string on the other side
/*
if (Serial.find("$TMO,")) {
_p = Serial.parseFloat(); //
_T = Serial.parseFloat();//
_RH = Serial.parseFloat();//
_qc = Serial.parseFloat();//
*/
break;
}
case 2: //Air data output
//_Rho,_IAS,_CAS,_TAS,_TASPCorrected,_M,_TAT,_h,_mu,_Re
{
String s1(_Rho, 6);
String s2(_IAS, 6);
String s3(_CAS, 6);
String s4(_TAS, 6);
String s5(_TASPCorrected, 6);
String s6(_M, 6);
String s7(_TAT, 6);
String s8(_h, 6);
String s9(_mu, 8);
String s10(_Re, 6);
StreamOut="$TAD,"+s1+','+s2+','+s3+','+s4+','+s5+','+s6+','+s7+','+s8+','+s9+','+s10;
break;
}
case 3: //Measurements uncertainty output
//_up,_uT,_uRH,_uqc
{
String s1(_up, 6);
String s2(_uT, 6);
String s3(_uRH, 6);
String s4(_uqc, 6);
StreamOut="$TMU,"+s1+','+s2+','+s3+','+s4;
break;
}
case 4: //Air data uncertainty output
//_uRho,_uIAS,_uCAS,_uTAS,_uTAT,_uh;
{
String s1(_uRho, 6);
String s2(_uIAS, 6);
String s3(_uCAS, 6);
String s4(_uTAS, 6);
String s5(_uTAT, 6);
String s6(_uh, 6);
StreamOut="$TAU,"+s1+','+s2+','+s3+','+s4+','+s5+','+s6;
break;
}
case 51: //Output for Temperature Logger Example
{
String s1(_Rho, 6);
String s2(_TAT, 2);
String s3(_TAT-273.15, 2);
String s4(_uTAT, 2);
String s5(_p, 2);
String s6(_mu, 6);
String s7(hour());
String s8(minute());
String s9(second());
String s10(month());
String s11(day());
String s12(year());
String s13(millis());
StreamOut="$TEX,"+s1+','+s2+','+s3+','+s4+','+s5+','+s6+','+s7+','+s8+','+s9+','+s10+','+s11+','+s12+','+s13;
break;
}
return StreamOut;
}
}
示例5: TestStores3
void TestStores3() {
B(s20, View outlives storage, 0)W(s20a);
{
c4_IntProp p1("p1");
c4_View v1;
{
c4_Storage s1("s20a", 1);
v1 = s1.GetAs("a[p1:I,p2:S]");
v1.Add(p1[123]);
}
// 19990916 - semantics changed, rows kept but no properties
//A(p1 (v1[0]) == 123);
A(v1.GetSize() == 1);
A(v1.NumProperties() == 0);
}
D(s20a);
R(s20a);
E;
B(s21, Test demo scenario, 0)W(s21a);
{
c4_StringProp p1("p1"), p2("p2");
{
c4_Storage storage("s21a", 1);
storage.SetStructure("a[p1:S,p2:S]");
c4_View v1;
c4_Row r1;
p1(r1) = "One";
p2(r1) = "Un";
v1.Add(r1);
A(v1.GetSize() == 1);
p1(r1) = "Two";
p2(r1) = "Deux";
v1.Add(r1);
A(v1.GetSize() == 2);
// changed 2000-03-15: Store is gone
//v1 = storage.Store("a", v1);
v1 = storage.View("a") = v1;
A(v1.GetSize() == 2);
A(p1(v1[1]) == (c4_String)"Two");
A(p2(v1[1]) == (c4_String)"Deux");
A(p1(v1[0]) == (c4_String)"One");
A(p2(v1[0]) == (c4_String)"Un");
storage.Commit();
A(v1.GetSize() == 2);
A(p1(v1[1]) == (c4_String)"Two");
A(p2(v1[1]) == (c4_String)"Deux");
A(p1(v1[0]) == (c4_String)"One");
A(p2(v1[0]) == (c4_String)"Un");
c4_String s1(p1(v1[1]));
c4_String s2(p2(v1[1]));
A(s1 == "Two");
A(s2 == "Deux");
storage.Commit();
v1.Add(p1["Three"] + p2["Trois"]);
storage.Commit();
A(v1.GetSize() == 3);
A(p2(v1[2]) == (c4_String)"Trois");
v1 = storage.GetAs("a[p1:S,p2:S,p3:I]");
A(v1.GetSize() == 3);
A(p2(v1[2]) == (c4_String)"Trois");
c4_IntProp p3("p3");
p3(v1[1]) = 123;
storage.Commit();
A(v1.GetSize() == 3);
A(p2(v1[2]) == (c4_String)"Trois");
c4_View v2 = storage.GetAs("b[p4:I]");
c4_IntProp p4("p4");
v2.Add(p4[234]);
storage.Commit();
A(v1.GetSize() == 3);
A(p2(v1[2]) == (c4_String)"Trois");
c4_IntProp p4a("p4");
v1.InsertAt(2, p1["Four"] + p4a[345]);
storage.Commit();
A(v1.GetSize() == 4);
A(p1(v1[0]) == (c4_String)"One");
A(p1(v1[1]) == (c4_String)"Two");
A(p1(v1[2]) == (c4_String)"Four");
A(p1(v1[3]) == (c4_String)"Three");
//.........这里部分代码省略.........
示例6: main
int main(int argc, char* argv[])
{
// Load the mesh.
Mesh basemesh;
H2DReader mloader;
mloader.load("GAMM-channel.mesh", &basemesh);
// Initialize the meshes.
Mesh mesh_flow, mesh_concentration;
mesh_flow.copy(&basemesh);
mesh_concentration.copy(&basemesh);
for(unsigned int i = 0; i < INIT_REF_NUM_CONCENTRATION; i++)
mesh_concentration.refine_all_elements();
mesh_concentration.refine_towards_boundary(BDY_DIRICHLET_CONCENTRATION, INIT_REF_NUM_CONCENTRATION_BDY);
mesh_flow.refine_towards_boundary(BDY_DIRICHLET_CONCENTRATION, INIT_REF_NUM_CONCENTRATION_BDY);
for(unsigned int i = 0; i < INIT_REF_NUM_FLOW; i++)
mesh_flow.refine_all_elements();
// Initialize boundary condition types and spaces with default shapesets.
// For the concentration.
EssentialBCs bcs_concentration;
bcs_concentration.add_boundary_condition(new ConcentrationTimedepEssentialBC(BDY_DIRICHLET_CONCENTRATION, CONCENTRATION_EXT, CONCENTRATION_EXT_STARTUP_TIME));
bcs_concentration.add_boundary_condition(new ConcentrationTimedepEssentialBC(BDY_SOLID_WALL_TOP, 0.0, CONCENTRATION_EXT_STARTUP_TIME));
L2Space space_rho(&mesh_flow, P_INIT_FLOW);
L2Space space_rho_v_x(&mesh_flow, P_INIT_FLOW);
L2Space space_rho_v_y(&mesh_flow, P_INIT_FLOW);
L2Space space_e(&mesh_flow, P_INIT_FLOW);
// Space for concentration.
H1Space space_c(&mesh_concentration, &bcs_concentration, P_INIT_CONCENTRATION);
int ndof = Space::get_num_dofs(Hermes::vector<Space*>(&space_rho, &space_rho_v_x, &space_rho_v_y, &space_e, &space_c));
info("ndof: %d", ndof);
// Initialize solutions, set initial conditions.
InitialSolutionEulerDensity prev_rho(&mesh_flow, RHO_EXT);
InitialSolutionEulerDensityVelX prev_rho_v_x(&mesh_flow, RHO_EXT * V1_EXT);
InitialSolutionEulerDensityVelY prev_rho_v_y(&mesh_flow, RHO_EXT * V2_EXT);
InitialSolutionEulerDensityEnergy prev_e(&mesh_flow, QuantityCalculator::calc_energy(RHO_EXT, RHO_EXT * V1_EXT, RHO_EXT * V2_EXT, P_EXT, KAPPA));
InitialSolutionConcentration prev_c(&mesh_concentration, 0.0);
// Numerical flux.
OsherSolomonNumericalFlux num_flux(KAPPA);
// Initialize weak formulation.
EulerEquationsWeakFormSemiImplicitCoupled wf(&num_flux, KAPPA, RHO_EXT, V1_EXT, V2_EXT, P_EXT, BDY_SOLID_WALL_BOTTOM,
BDY_SOLID_WALL_TOP, BDY_INLET, BDY_OUTLET, BDY_NATURAL_CONCENTRATION, &prev_rho, &prev_rho_v_x, &prev_rho_v_y, &prev_e, &prev_c, EPSILON, (P_INIT_FLOW == 0));
wf.set_time_step(time_step);
// Initialize the FE problem.
DiscreteProblem dp(&wf, Hermes::vector<Space*>(&space_rho, &space_rho_v_x, &space_rho_v_y, &space_e, &space_c));
// If the FE problem is in fact a FV problem.
//if(P_INIT == 0) dp.set_fvm();
// Filters for visualization of Mach number, pressure and entropy.
MachNumberFilter Mach_number(Hermes::vector<MeshFunction*>(&prev_rho, &prev_rho_v_x, &prev_rho_v_y, &prev_e), KAPPA);
PressureFilter pressure(Hermes::vector<MeshFunction*>(&prev_rho, &prev_rho_v_x, &prev_rho_v_y, &prev_e), KAPPA);
EntropyFilter entropy(Hermes::vector<MeshFunction*>(&prev_rho, &prev_rho_v_x, &prev_rho_v_y, &prev_e), KAPPA, RHO_EXT, P_EXT);
/*
ScalarView pressure_view("Pressure", new WinGeom(0, 0, 600, 300));
ScalarView Mach_number_view("Mach number", new WinGeom(700, 0, 600, 300));
ScalarView entropy_production_view("Entropy estimate", new WinGeom(0, 400, 600, 300));
ScalarView s5("Concentration", new WinGeom(700, 400, 600, 300));
*/
ScalarView s1("1", new WinGeom(0, 0, 600, 300));
ScalarView s2("2", new WinGeom(700, 0, 600, 300));
ScalarView s3("3", new WinGeom(0, 400, 600, 300));
ScalarView s4("4", new WinGeom(700, 400, 600, 300));
ScalarView s5("Concentration", new WinGeom(350, 200, 600, 300));
// Set up the solver, matrix, and rhs according to the solver selection.
SparseMatrix* matrix = create_matrix(matrix_solver);
Vector* rhs = create_vector(matrix_solver);
Solver* solver = create_linear_solver(matrix_solver, matrix, rhs);
// Set up CFL calculation class.
CFLCalculation CFL(CFL_NUMBER, KAPPA);
// Set up Advection-Diffusion-Equation stability calculation class.
ADEStabilityCalculation ADES(ADVECTION_STABILITY_CONSTANT, DIFFUSION_STABILITY_CONSTANT, EPSILON);
int iteration = 0; double t = 0;
for(t = 0.0; t < 100.0; t += time_step) {
info("---- Time step %d, time %3.5f.", iteration++, t);
// Set the current time step.
wf.set_time_step(time_step);
Space::update_essential_bc_values(&space_c, t);
// Assemble stiffness matrix and rhs.
info("Assembling the stiffness matrix and right-hand side vector.");
dp.assemble(matrix, rhs);
//.........这里部分代码省略.........
示例7: TestStores1
void TestStores1()
{
B(s00, Simple storage, 0) W(s00a);
{
c4_Storage s1 ("s00a", 1);
s1.SetStructure("a[p1:I]");
s1.Commit();
} D(s00a); R(s00a); E;
B(s01, Integer storage, 0) W(s01a);
{
c4_IntProp p1 ("p1");
c4_Storage s1 ("s01a", 1);
s1.SetStructure("a[p1:I]");
c4_View v1 = s1.View("a");
v1.Add(p1 [123]);
v1.Add(p1 [456]);
v1.InsertAt(1, p1 [789]);
A(v1.GetSize() == 3);
s1.Commit();
A(v1.GetSize() == 3);
} D(s01a); R(s01a); E;
#if !q4_TINY
B(s02, Float storage, 0) W(s02a);
{
c4_FloatProp p1 ("p1");
c4_Storage s1 ("s02a", 1);
s1.SetStructure("a[p1:F]");
c4_View v1 = s1.View("a");
v1.Add(p1 [12.3]);
v1.Add(p1 [45.6]);
v1.InsertAt(1, p1 [78.9]);
s1.Commit();
} D(s02a); R(s02a); E;
#endif
B(s03, String storage, 0) W(s03a);
{
c4_StringProp p1 ("p1");
c4_Storage s1 ("s03a", 1);
s1.SetStructure("a[p1:S]");
c4_View v1 = s1.View("a");
v1.Add(p1 ["one"]);
v1.Add(p1 ["two"]);
v1.InsertAt(1, p1 ["three"]);
s1.Commit();
} D(s03a); R(s03a); E;
B(s04, View storage, 0) W(s04a);
{
c4_StringProp p1 ("p1");
c4_ViewProp p2 ("p2");
c4_IntProp p3 ("p3");
c4_Storage s1 ("s04a", 1);
s1.SetStructure("a[p1:S,p2[p3:I]]");
c4_View v1 = s1.View("a");
v1.Add(p1 ["one"]);
v1.Add(p1 ["two"]);
c4_View v2 = p2 (v1[0]);
v2.Add(p3 [1]);
v2 = p2 (v1[1]);
v2.Add(p3 [11]);
v2.Add(p3 [22]);
v1.InsertAt(1, p1 ["three"]);
v2 = p2 (v1[1]);
v2.Add(p3 [111]);
v2.Add(p3 [222]);
v2.Add(p3 [333]);
s1.Commit();
} D(s04a); R(s04a); E;
B(s05, Store and reload, 0) W(s05a);
{
c4_IntProp p1 ("p1");
{
c4_Storage s1 ("s05a", 1);
s1.SetStructure("a[p1:I]");
c4_View v1 = s1.View("a");
v1.Add(p1 [123]);
s1.Commit();
}
{
c4_Storage s1 ("s05a", 0);
c4_View v1 = s1.View("a");
A(v1.GetSize() == 1);
A(p1 (v1[0]) == 123);
}
} D(s05a); R(s05a); E;
B(s06, Commit twice, 0) W(s06a);
{
c4_IntProp p1 ("p1");
{
c4_Storage s1 ("s06a", 1);
s1.SetStructure("a[p1:I]");
c4_View v1 = s1.View("a");
v1.Add(p1 [123]);
s1.Commit();
v1.Add(p1 [234]);
//.........这里部分代码省略.........
示例8: tr
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
if ( !QStandardItemModel::setData( idx, value, role ) )
return false;
if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
{
QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt();
QString tip;
if ( wkbType == QgsWkbTypes::Unknown )
{
tip = tr( "Specify a geometry type in the '%1' column" ).arg( tr( "Data Type" ) );
}
else if ( wkbType != QgsWkbTypes::NoGeometry )
{
bool ok;
int srid = idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );
if ( !ok || srid == std::numeric_limits<int>::min() )
tip = tr( "Enter a SRID into the '%1' column" ).arg( tr( "SRID" ) );
}
QStringList pkCols = idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
if ( tip.isEmpty() && !pkCols.isEmpty() )
{
QSet<QString> s0( idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 2 ).toStringList().toSet() );
QSet<QString> s1( pkCols.toSet() );
if ( !s0.intersects( s1 ) )
tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) );
}
for ( int i = 0; i < DbtmColumns; i++ )
{
QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
if ( tip.isEmpty() )
{
if ( i == DbtmSchema )
{
item->setData( QVariant(), Qt::DecorationRole );
}
item->setFlags( item->flags() | Qt::ItemIsSelectable );
item->setToolTip( QString() );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( i == DbtmSchema )
item->setData( QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ), Qt::DecorationRole );
if ( i == DbtmSchema || i == DbtmTable || i == DbtmGeomCol )
{
item->setFlags( item->flags() );
item->setToolTip( tip );
}
}
}
}
return true;
}
示例9: QgsDebugMsg
QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &connInfo, bool useEstimatedMetadata )
{
if ( !index.isValid() )
{
QgsDebugMsg( QStringLiteral( "invalid index" ) );
return QString();
}
QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) itemFromIndex( index.sibling( index.row(), DbtmType ) )->data( Qt::UserRole + 2 ).toInt();
if ( wkbType == QgsWkbTypes::Unknown )
{
QgsDebugMsg( QStringLiteral( "unknown geometry type" ) );
// no geometry type selected
return QString();
}
QStandardItem *pkItem = itemFromIndex( index.sibling( index.row(), DbtmPkCol ) );
QSet<QString> s0( pkItem->data( Qt::UserRole + 1 ).toStringList().toSet() );
QSet<QString> s1( pkItem->data( Qt::UserRole + 2 ).toStringList().toSet() );
if ( !s0.isEmpty() && !s0.intersects( s1 ) )
{
// no valid primary candidate selected
QgsDebugMsg( QStringLiteral( "no pk candidate selected" ) );
return QString();
}
QString schemaName = index.sibling( index.row(), DbtmSchema ).data( Qt::DisplayRole ).toString();
QString tableName = index.sibling( index.row(), DbtmTable ).data( Qt::DisplayRole ).toString();
QString geomColumnName;
QString srid;
if ( wkbType != QgsWkbTypes::NoGeometry )
{
geomColumnName = index.sibling( index.row(), DbtmGeomCol ).data( Qt::DisplayRole ).toString();
srid = index.sibling( index.row(), DbtmSrid ).data( Qt::DisplayRole ).toString();
bool ok;
srid.toInt( &ok );
if ( !ok )
{
QgsDebugMsg( QStringLiteral( "srid not numeric" ) );
return QString();
}
}
bool selectAtId = itemFromIndex( index.sibling( index.row(), DbtmSelectAtId ) )->checkState() == Qt::Checked;
QString sql = index.sibling( index.row(), DbtmSql ).data( Qt::DisplayRole ).toString();
bool checkPrimaryKeyUnicity = itemFromIndex( index.sibling( index.row(), DbtmCheckPkUnicity ) )->checkState() == Qt::Checked;
QgsDataSourceUri uri( connInfo );
QStringList cols;
const auto constS1 = s1;
for ( const QString &col : constS1 )
{
cols << QgsPostgresConn::quotedIdentifier( col );
}
QgsSettings().setValue( QStringLiteral( "/PostgreSQL/connections/%1/keys/%2/%3" ).arg( mConnName, schemaName, tableName ), QVariant( s1.toList() ) );
uri.setDataSource( schemaName, tableName, geomColumnName, sql, cols.join( ',' ) );
uri.setUseEstimatedMetadata( useEstimatedMetadata );
uri.setWkbType( wkbType );
uri.setSrid( srid );
uri.disableSelectAtId( !selectAtId );
uri.setParam( QStringLiteral( "checkPrimaryKeyUnicity" ), checkPrimaryKeyUnicity ? QLatin1Literal( "1" ) : QLatin1Literal( "0" ) );
QgsDebugMsg( QStringLiteral( "returning uri %1" ).arg( uri.uri( false ) ) );
return uri.uri( false );
}
示例10: setupAndSolveQP
int setupAndSolveQP(NewQPControllerData *pdata, std::shared_ptr<drake::lcmt_qp_controller_input> qp_input, double t, Map<VectorXd> &q, Map<VectorXd> &qd, const Ref<Matrix<bool, Dynamic, 1>> &b_contact_force, QPControllerOutput *qp_output, std::shared_ptr<QPControllerDebugData> debug) {
// The primary solve loop for our controller. This constructs and solves a Quadratic Program and produces the instantaneous desired torques, along with reference positions, velocities, and accelerations. It mirrors the Matlab implementation in atlasControllers.InstantaneousQPController.setupAndSolveQP(), and more documentation can be found there.
// Note: argument `debug` MAY be set to NULL, which signals that no debug information is requested.
// look up the param set by name
AtlasParams *params;
std::map<string,AtlasParams>::iterator it;
it = pdata->param_sets.find(qp_input->param_set_name);
if (it == pdata->param_sets.end()) {
mexWarnMsgTxt("Got a param set I don't recognize! Using standing params instead");
it = pdata->param_sets.find("standing");
if (it == pdata->param_sets.end()) {
mexErrMsgTxt("Could not fall back to standing parameters either. I have to give up here.");
}
}
// cout << "using params set: " + it->first + ", ";
params = &(it->second);
// mexPrintf("Kp_accel: %f, ", params->Kp_accel);
int nu = pdata->B.cols();
int nq = pdata->r->num_positions;
// zmp_data
Map<Matrix<double, 4, 4, RowMajor>> A_ls(&qp_input->zmp_data.A[0][0]);
Map<Matrix<double, 4, 2, RowMajor>> B_ls(&qp_input->zmp_data.B[0][0]);
Map<Matrix<double, 2, 4, RowMajor>> C_ls(&qp_input->zmp_data.C[0][0]);
Map<Matrix<double, 2, 2, RowMajor>> D_ls(&qp_input->zmp_data.D[0][0]);
Map<Matrix<double, 4, 1>> x0(&qp_input->zmp_data.x0[0][0]);
Map<Matrix<double, 2, 1>> y0(&qp_input->zmp_data.y0[0][0]);
Map<Matrix<double, 2, 1>> u0(&qp_input->zmp_data.u0[0][0]);
Map<Matrix<double, 2, 2, RowMajor>> R_ls(&qp_input->zmp_data.R[0][0]);
Map<Matrix<double, 2, 2, RowMajor>> Qy(&qp_input->zmp_data.Qy[0][0]);
Map<Matrix<double, 4, 4, RowMajor>> S(&qp_input->zmp_data.S[0][0]);
Map<Matrix<double, 4, 1>> s1(&qp_input->zmp_data.s1[0][0]);
Map<Matrix<double, 4, 1>> s1dot(&qp_input->zmp_data.s1dot[0][0]);
// // whole_body_data
if (qp_input->whole_body_data.num_positions != nq) mexErrMsgTxt("number of positions doesn't match num_dof for this robot");
Map<VectorXd> q_des(qp_input->whole_body_data.q_des.data(), nq);
Map<VectorXd> condof(qp_input->whole_body_data.constrained_dofs.data(), qp_input->whole_body_data.num_constrained_dofs);
PIDOutput pid_out = wholeBodyPID(pdata, t, q, qd, q_des, ¶ms->whole_body);
qp_output->q_ref = pid_out.q_ref;
// mu
// NOTE: we're using the same mu for all supports
double mu;
if (qp_input->num_support_data == 0) {
mu = 1.0;
} else {
mu = qp_input->support_data[0].mu;
for (int i=1; i < qp_input->num_support_data; i++) {
if (qp_input->support_data[i].mu != mu) {
mexWarnMsgTxt("Currently, we assume that all supports have the same value of mu");
}
}
}
const int dim = 3, // 3D
nd = 2*m_surface_tangents; // for friction cone approx, hard coded for now
assert(nu+6 == nq);
vector<DesiredBodyAcceleration> desired_body_accelerations;
desired_body_accelerations.resize(qp_input->num_tracked_bodies);
Vector6d body_pose_des, body_v_des, body_vdot_des;
Vector6d body_vdot;
for (int i=0; i < qp_input->num_tracked_bodies; i++) {
int body_id0 = qp_input->body_motion_data[i].body_id - 1;
double weight = params->body_motion[body_id0].weight;
desired_body_accelerations[i].body_id0 = body_id0;
Map<Matrix<double, 6, 4,RowMajor>>coefs_rowmaj(&qp_input->body_motion_data[i].coefs[0][0]);
Matrix<double, 6, 4> coefs = coefs_rowmaj;
evaluateCubicSplineSegment(t - qp_input->body_motion_data[i].ts[0], coefs, body_pose_des, body_v_des, body_vdot_des);
desired_body_accelerations[i].body_vdot = bodyMotionPD(pdata->r, q, qd, body_id0, body_pose_des, body_v_des, body_vdot_des, params->body_motion[body_id0].Kp, params->body_motion[body_id0].Kd);
desired_body_accelerations[i].weight = weight;
desired_body_accelerations[i].accel_bounds = params->body_motion[body_id0].accel_bounds;
// mexPrintf("body: %d, vdot: %f %f %f %f %f %f weight: %f\n", body_id0,
// desired_body_accelerations[i].body_vdot(0),
// desired_body_accelerations[i].body_vdot(1),
// desired_body_accelerations[i].body_vdot(2),
// desired_body_accelerations[i].body_vdot(3),
// desired_body_accelerations[i].body_vdot(4),
// desired_body_accelerations[i].body_vdot(5),
// weight);
// mexPrintf("tracking body: %d, coefs[:,0]: %f %f %f %f %f %f coefs(", body_id0,
}
int n_body_accel_eq_constraints = 0;
for (int i=0; i < desired_body_accelerations.size(); i++) {
if (desired_body_accelerations[i].weight < 0)
n_body_accel_eq_constraints++;
}
MatrixXd R_DQyD_ls = R_ls + D_ls.transpose()*Qy*D_ls;
pdata->r->doKinematics(q,false,qd);
//---------------------------------------------------------------------
//.........这里部分代码省略.........
示例12: deseval
KTYPE
deseval (
const KTYPE *p,
const KTYPE *c,
const KTYPE *k
) {
aligned register KTYPE result = KCONST_1;
aligned register KTYPE l0 = p[6];
aligned register KTYPE l1 = p[14];
aligned register KTYPE l2 = p[22];
aligned register KTYPE l3 = p[30];
aligned register KTYPE l4 = p[38];
aligned register KTYPE l5 = p[46];
aligned register KTYPE l6 = p[54];
aligned register KTYPE l7 = p[62];
aligned register KTYPE l8 = p[4];
aligned register KTYPE l9 = p[12];
aligned register KTYPE l10 = p[20];
aligned register KTYPE l11 = p[28];
aligned register KTYPE l12 = p[36];
aligned register KTYPE l13 = p[44];
aligned register KTYPE l14 = p[52];
aligned register KTYPE l15 = p[60];
aligned register KTYPE l16 = p[2];
aligned register KTYPE l17 = p[10];
aligned register KTYPE l18 = p[18];
aligned register KTYPE l19 = p[26];
aligned register KTYPE l20 = p[34];
aligned register KTYPE l21 = p[42];
aligned register KTYPE l22 = p[50];
aligned register KTYPE l23 = p[58];
aligned register KTYPE l24 = p[0];
aligned register KTYPE l25 = p[8];
aligned register KTYPE l26 = p[16];
aligned register KTYPE l27 = p[24];
aligned register KTYPE l28 = p[32];
aligned register KTYPE l29 = p[40];
aligned register KTYPE l30 = p[48];
aligned register KTYPE l31 = p[56];
aligned register KTYPE r0 = p[7];
aligned register KTYPE r1 = p[15];
aligned register KTYPE r2 = p[23];
aligned register KTYPE r3 = p[31];
aligned register KTYPE r4 = p[39];
aligned register KTYPE r5 = p[47];
aligned register KTYPE r6 = p[55];
aligned register KTYPE r7 = p[63];
aligned register KTYPE r8 = p[5];
aligned register KTYPE r9 = p[13];
aligned register KTYPE r10 = p[21];
aligned register KTYPE r11 = p[29];
aligned register KTYPE r12 = p[37];
aligned register KTYPE r13 = p[45];
aligned register KTYPE r14 = p[53];
aligned register KTYPE r15 = p[61];
aligned register KTYPE r16 = p[3];
aligned register KTYPE r17 = p[11];
aligned register KTYPE r18 = p[19];
aligned register KTYPE r19 = p[27];
aligned register KTYPE r20 = p[35];
aligned register KTYPE r21 = p[43];
aligned register KTYPE r22 = p[51];
aligned register KTYPE r23 = p[59];
aligned register KTYPE r24 = p[1];
aligned register KTYPE r25 = p[9];
aligned register KTYPE r26 = p[17];
aligned register KTYPE r27 = p[25];
aligned register KTYPE r28 = p[33];
aligned register KTYPE r29 = p[41];
aligned register KTYPE r30 = p[49];
aligned register KTYPE r31 = p[57];
s1 (r31 ^ k[47], r0 ^ k[11], r1 ^ k[26], r2 ^ k[3], r3 ^ k[13],
r4 ^ k[41], &l8, &l16, &l22, &l30);
s2 (r3 ^ k[27], r4 ^ k[6], r5 ^ k[54], r6 ^ k[48], r7 ^ k[39],
r8 ^ k[19], &l12, &l27, &l1, &l17);
s3 (r7 ^ k[53], r8 ^ k[25], r9 ^ k[33], r10 ^ k[34], r11 ^ k[17],
r12 ^ k[5], &l23, &l15, &l29, &l5);
s4 (r11 ^ k[4], r12 ^ k[55], r13 ^ k[24], r14 ^ k[32], r15 ^ k[40],
r16 ^ k[20], &l25, &l19, &l9, &l0);
s5 (r15 ^ k[36], r16 ^ k[31], r17 ^ k[21], r18 ^ k[8], r19 ^ k[23],
r20 ^ k[52], &l7, &l13, &l24, &l2);
s6 (r19 ^ k[14], r20 ^ k[29], r21 ^ k[51], r22 ^ k[9], r23 ^ k[35],
r24 ^ k[30], &l3, &l28, &l10, &l18);
s7 (r23 ^ k[2], r24 ^ k[37], r25 ^ k[22], r26 ^ k[0], r27 ^ k[42],
r28 ^ k[38], &l31, &l11, &l21, &l6);
s8 (r27 ^ k[16], r28 ^ k[43], r29 ^ k[44], r30 ^ k[1], r31 ^ k[7],
r0 ^ k[28], &l4, &l26, &l14, &l20);
s1 (l31 ^ k[54], l0 ^ k[18], l1 ^ k[33], l2 ^ k[10], l3 ^ k[20],
l4 ^ k[48], &r8, &r16, &r22, &r30);
s2 (l3 ^ k[34], l4 ^ k[13], l5 ^ k[4], l6 ^ k[55], l7 ^ k[46],
l8 ^ k[26], &r12, &r27, &r1, &r17);
s3 (l7 ^ k[3], l8 ^ k[32], l9 ^ k[40], l10 ^ k[41], l11 ^ k[24],
l12 ^ k[12], &r23, &r15, &r29, &r5);
s4 (l11 ^ k[11], l12 ^ k[5], l13 ^ k[6], l14 ^ k[39], l15 ^ k[47],
l16 ^ k[27], &r25, &r19, &r9, &r0);
s5 (l15 ^ k[43], l16 ^ k[38], l17 ^ k[28], l18 ^ k[15], l19 ^ k[30],
l20 ^ k[0], &r7, &r13, &r24, &r2);
s6 (l19 ^ k[21], l20 ^ k[36], l21 ^ k[31], l22 ^ k[16], l23 ^ k[42],
l24 ^ k[37], &r3, &r28, &r10, &r18);
//.........这里部分代码省略.........
示例13: polyhedron_ptr
int Scene::add_mesh(QString filename, int loadType, typeFuncOpenSave f, Viewer* viewer)
{
int res = 0;
m_loadType = loadType;
PolyhedronPtr polyhedron_ptr(new Polyhedron());
if (filename == EMPTY_MESH)
{
// nothing
}
else if (filename == INTERNAL_MESH)
{
Point3d p1( -0.5, -0.5, -0.5);
Point3d q1( 0.5, -0.5, -0.5);
Point3d r1( 0.0, -0.5, 0.5);
Point3d s1( 0.0, 0.5, 0.0);
Halfedge_handle h = polyhedron_ptr->make_tetrahedron(p1, q1, r1, s1);
if (!polyhedron_ptr->is_tetrahedron(h))
res = -3;
}
else
{
if (f != NULL)
res = f(polyhedron_ptr, filename, viewer);
else
{
QString ext = QFileInfo(filename).suffix();
if (ext == "off")
res = polyhedron_ptr->load_mesh_off(filename.toStdString());
else if (ext == "obj")
res = polyhedron_ptr->load_mesh_obj(filename.toStdString());
else if (ext == "smf")
res = polyhedron_ptr->load_mesh_smf(filename.toStdString());
else if (ext == "ply")
res = polyhedron_ptr->load_mesh_ply(filename.toStdString());
else if (ext == "x3d")
res = polyhedron_ptr->load_mesh_x3d(filename.toStdString());
else
res = 1;
}
}
if (!res)
{
if (get_nb_polyhedrons()>0)
{
PolyhedronPtr p = get_polyhedron();
//if (!p->empty())
{
viewer->camera()->setPosition(p->pInitialCameraPosition);
viewer->camera()->setOrientation(p->pInitialCameraOrientation);
}
}
if (!polyhedron_ptr->empty())
{
polyhedron_ptr->compute_bounding_box();
polyhedron_ptr->compute_normals();
polyhedron_ptr->compute_type();
(void)polyhedron_ptr->calc_nb_components();
(void)polyhedron_ptr->calc_nb_boundaries();
}
add_polyhedron(polyhedron_ptr);
set_current_polyhedron(get_nb_polyhedrons()-1);
setcurrentFile(filename);
setVisible(true);
// if mode Space
todoIfModeSpace(viewer, viewer->getYStep());
viewer->showAllScene();
}
return res;
}
示例14: main
int main()
{
long i;
JSubset s1(10); // constructor
cout << "subset s1 created" << endl << endl;
cout << "s1 itemCount should be 0" << endl;
cout << "s1 itemCount = " << s1.GetElementCount() << endl << endl;
s1.AddRange(3,4);
s1.Add(9);
cout << "s1 itemCount should be 3" << endl;
cout << "s1 itemCount = " << s1.GetElementCount() << endl << endl;
cout << "s1 should contain: 10FFTTFFFFTF" << endl;
cout << "s1 contains : " << s1 << endl;
cout << "using Contains() : ";
for (i=1; i<=10; i++)
{
cout << s1.Contains(i);
}
cout << endl;
JSubset s2 = s1;
cout << endl;
cout << "subset s2 created" << endl << endl;
s2.Remove(1);
cout << "s1 should equal s2" << endl;
cout << "s1 equals s2? " << (s1 == s2) << endl;
s2.Remove(4);
s2.Add(2);
cout << "s2 should contain: 10FTTFFFFFTF" << endl;
cout << "s2 contains : " << s2 << endl;
cout << "s1 should not equal s2" << endl;
cout << "s1 equals s2? " << (s1 == s2) << endl;
JWaitForReturn();
JSubset s3 = s1 + s2;
JSubset s4 = s1 - s2;
JSubset s5 = s2 - s1;
JSubset s7 = JIntersection(s4, s5);
cout << "s3 should contain: 10FTTTFFFFTF" << endl;
cout << "s3 contains : " << s3 << endl << endl;
cout << "s4 should contain: 10FFFTFFFFFF" << endl;
cout << "s4 contains : " << s4 << endl << endl;
cout << "s5 should contain: 10FTFFFFFFFF" << endl;
cout << "s5 contains : " << s5 << endl << endl;
cout << "s7 should contain: 10FFFTFFFFFF" << endl;
cout << "s7 contains : " << s4 << endl << endl;
JWaitForReturn();
s3.RemoveAll();
s3.AddRange(3,8);
s3.RemoveRange(4,6);
cout << "s3 should contain: 10FFTFFFTTFF" << endl;
cout << "s3 contains : " << s3 << endl << endl;
JSubsetIterator iter = s3.NewIterator();
JIndex index;
cout << "s3 contains: ";
while (iter.Next(&index))
{
cout << ' ' << index;
}
cout << endl << endl;
JSubset s6 = s3.Complement();
cout << "s6 should contain: 10TTFTTTFFTT" << endl;
cout << "s6 contains : " << s6 << endl << endl;
s6 = s3; // assignment operator
cout << "s6 assigned from s3" << endl << endl;
cout << "s6 itemCount should be 3" << endl;
cout << "s6 itemCount=" << s6.GetElementCount() << endl << endl;
cout << "s6 should contain: 10FFTFFFTTFF" << endl;
cout << "s6 contains : " << s6 << endl << endl;
//.........这里部分代码省略.........
示例15: resourcePath
screen_1::screen_1(void)
{
// Loads in spritesheet
texture1.loadFromFile( resourcePath() + "spritesheet.png");
texture2.loadFromFile( resourcePath() + "vehicles.png");
texture3.loadFromFile( resourcePath() + "timer.png" );
hearts.loadFromFile( resourcePath() + "hearts.png");
// *******************************************************************
// Sets texture to sprites, scale, and pos
//
// Create(sf::Sprite &sprite, sf::IntRect &rect, sf::Texture &texture, int left, int top, int width,
// int height, double sizeX, double sizeY, double posX, double posY)
// *******************************************************************
Create t1(truck, rectSourceSprite, texture2, 0, 24, 130, 73, 1.5, 1.5, 130, 420);
Create t2(truck2, rectSourceSprite, texture2, 148, 0, 120, 159, 1.5, 1.5, 550, 290);
Create c1(car, rectSourceSprite, texture2, 310, 0, 146, 149, 1.7, 1.7, -230, 420);
Create c2(car2, rectSourceSprite, texture2, 460, 0, 146, 149, 1.7, 1.7, 280, 289);
Create c3(car3, rectSourceSprite, texture2, 460, 0, 146, 149, 1.7, 1.7, 0, 289);
Create s1(shortLog, rectSourceSprite, texture1, 289, 0, 146, 196, 1, 1, 0, 129);
Create s2(shortLog2, rectSourceSprite, texture1, 435, 0, 141, 196, 1, 1, 200, 65);
Create s3(shortLog3, rectSourceSprite, texture1, 289, 0, 146, 196, 1, 1, 300, 8);
Create l1(longLog, rectSourceSprite, texture1, 577, 0, 205, 196, 1, 1, 799, 8.3);
Create l2(longLog2, rectSourceSprite, texture1, 577, 0, 205, 196, 1, 1, 500, 138);
Create leaf(lillypad, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 0, -32);
Create leaf2(lillypad2, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 167.5, -32);
Create leaf3(lillypad3, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 335, -32);
Create leaf4(lillypad4, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 502.5, -32);
Create leaf5(lillypad5, rectSourceSprite, texture2, 610, 0, 115, 196, 1, 1, 670, -32);
Create hearts123(life, rectSource, hearts, 0, 0, 116, 30, 1, 1, 10, 600);
//Player ( aka stats )
mainPlayer.setNumLives(3);
mainPlayer.setIsHit(false);
// Frogger Sprite
Create grogger(frogger, rectSourceSprite, texture1, 0, 70, 75, 70, 1, 1, 320, 605);
// Sets texture to frogs that will go on occupied lilypads
occupied1.setTexture(texture1);
occupied1.setTextureRect(rectSourceSprite);
occupied2.setTexture(texture1);
occupied2.setTextureRect(rectSourceSprite);
occupied3.setTexture(texture1);
occupied3.setTextureRect(rectSourceSprite);
occupied4.setTexture(texture1);
occupied4.setTextureRect(rectSourceSprite);
occupied5.setTexture(texture1);
occupied5.setTextureRect(rectSourceSprite);
// Sets pos of above frogs
occupied1.setPosition(-100, -100);
occupied2.setPosition(-100, -100);
occupied3.setPosition(-100, -100);
occupied4.setPosition(-100, -100);
occupied5.setPosition(-100, -100);
death.setPosition(-100, -100);
// Timer Rect
timeRect.left = 297;
timeRect.top = 43;
timeRect.width = 143;
timeRect.height = 14;
timer.setScale(1.5, 1.5);
timer.setTexture(texture3, true);
timer.setTextureRect(timeRect);
timer.setPosition(10, 648);
// Loads Background Pic
bg.loadFromFile( resourcePath() + "background.jpg" );
background.setTexture(bg, true);
// Log Checking
isOnLog = false;
isOnLog2 = false;
isOnLog3 = false;
isOnLog4 = false;
isOnLog5 = false;
// Lily Checking
isOnLily = false;
isOnLily2 = false;
isOnLily3 = false;
isOnLily4 = false;
isOnLily5 = false;
froggerLanded = false;
// Frogger Theme
if (!froggerTheme.openFromFile(resourcePath() + "froggerLeche_Remix.ogg"))
return -1; // error
froggerTheme.setLoop(true);
// Hop Sound
if (!hopFile.loadFromFile(resourcePath() + "froggerHop.ogg"))
return -1;
// Coin Sound
if (!intro.openFromFile(resourcePath() + "froggerCoin.ogg"))
//.........这里部分代码省略.........