本文整理汇总了C++中op函数的典型用法代码示例。如果您正苦于以下问题:C++ op函数的具体用法?C++ op怎么用?C++ op使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了op函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ml
HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) {
GCCause::Cause next_cause = GCCause::_permanent_generation_full;
GCCause::Cause prev_cause = GCCause::_no_gc;
unsigned int gc_count_before, full_gc_count_before;
HeapWord* obj;
for (;;) {
{
MutexLocker ml(Heap_lock);
if ((obj = gen->allocate(size, false)) != NULL) {
return obj;
}
if (gen->capacity() < _capacity_expansion_limit ||
prev_cause != GCCause::_no_gc) {
obj = gen->expand_and_allocate(size, false);
}
if (obj != NULL || prev_cause == GCCause::_last_ditch_collection) {
return obj;
}
if (GC_locker::is_active_and_needs_gc()) {
// If this thread is not in a jni critical section, we stall
// the requestor until the critical section has cleared and
// GC allowed. When the critical section clears, a GC is
// initiated by the last thread exiting the critical section; so
// we retry the allocation sequence from the beginning of the loop,
// rather than causing more, now probably unnecessary, GC attempts.
JavaThread* jthr = JavaThread::current();
if (!jthr->in_critical()) {
MutexUnlocker mul(Heap_lock);
// Wait for JNI critical section to be exited
GC_locker::stall_until_clear();
continue;
} else {
if (CheckJNICalls) {
fatal("Possible deadlock due to allocating while"
" in jni critical section");
}
return NULL;
}
}
// Read the GC count while holding the Heap_lock
gc_count_before = SharedHeap::heap()->total_collections();
full_gc_count_before = SharedHeap::heap()->total_full_collections();
}
// Give up heap lock above, VMThread::execute below gets it back
VM_GenCollectForPermanentAllocation op(size, gc_count_before, full_gc_count_before,
next_cause);
VMThread::execute(&op);
if (!op.prologue_succeeded() || op.gc_locked()) {
assert(op.result() == NULL, "must be NULL if gc_locked() is true");
continue; // retry and/or stall as necessary
}
obj = op.result();
assert(obj == NULL || SharedHeap::heap()->is_in_reserved(obj),
"result not in heap");
if (obj != NULL) {
return obj;
}
prev_cause = next_cause;
next_cause = GCCause::_last_ditch_collection;
}
}
示例2: op
void CClientFrameGenerator::generate( DataSerializer & serializer )
{
DataSerializer::WriteOp op( serializer );
mFrameData.serialize( op );
}
示例3: isControlFlow
bool IRInstruction::isEssential() const {
return isControlFlow() ||
opcodeHasFlags(op(), Essential);
}
示例4: op
request::request(const char *headln)
{
char type[10];
#define op(a) a = NULL
op(this->header.accept.accept);
op(this->header.accept.charset);
op(this->header.accept.encoding);
op(this->header.accept.language);
op(this->header.clientinfo.referer);
op(this->header.clientinfo.te);
op(this->header.clientinfo.user_agent);
op(this->header.hostinfo.authorization);
op(this->header.hostinfo.expect);
op(this->header.hostinfo.from);
op(this->header.hostinfo.host);
op(this->header.netinfo.max_forwards);
op(this->header.netinfo.proxy_authorization);
op(this->header.netinfo.range);
op(this->header.sectif.match);
op(this->header.sectif.modified_since);
op(this->header.sectif.none_match);
op(this->header.sectif.range);
op(this->header.sectif.unmodified_since);
#undef op
sscanf(headln, "%s %s HTTP/1.%d", type, this->URI, &this->protocolversion);
#define op(a) (strcmp(type, a) == 0)
if (op("OPTIONS"))
this->requesttype = kOPTIONS;
if (op("GET"))
this->requesttype = kGET;
if (op("HEAD"))
this->requesttype = kHEAD;
if (op("POST"))
this->requesttype = kPOST;
if (op("PUT"))
this->requesttype = kPUT;
if (op("DELETE"))
this->requesttype = kDELETE;
if (op("TRACE"))
this->requesttype = kTRACE;
if (op("CONNECT"))
this->requesttype = kCONNECT;
#undef op
this->parseHTTPHeader(headln);
}
示例5: switch
void
mitk::SlicedGeometry3D::ExecuteOperation(Operation* operation)
{
switch ( operation->GetOperationType() )
{
case OpNOTHING:
break;
case OpROTATE:
if ( m_EvenlySpaced )
{
// Need a reference frame to align the rotation
if ( m_ReferenceGeometry )
{
// Clear all generated geometries and then rotate only the first slice.
// The other slices will be re-generated on demand
// Save first slice
PlaneGeometry::Pointer geometry2D = m_PlaneGeometries[0];
RotationOperation *rotOp = dynamic_cast< RotationOperation * >( operation );
// Generate a RotationOperation using the dataset center instead of
// the supplied rotation center. This is necessary so that the rotated
// zero-plane does not shift away. The supplied center is instead used
// to adjust the slice stack afterwards.
Point3D center = m_ReferenceGeometry->GetCenter();
RotationOperation centeredRotation(
rotOp->GetOperationType(),
center,
rotOp->GetVectorOfRotation(),
rotOp->GetAngleOfRotation()
);
// Rotate first slice
geometry2D->ExecuteOperation( ¢eredRotation );
// Clear the slice stack and adjust it according to the center of
// the dataset and the supplied rotation center (see documentation of
// ReinitializePlanes)
this->ReinitializePlanes( center, rotOp->GetCenterOfRotation() );
geometry2D->SetSpacing(this->GetSpacing());
if ( m_SliceNavigationController )
{
m_SliceNavigationController->SelectSliceByPoint(
rotOp->GetCenterOfRotation() );
m_SliceNavigationController->AdjustSliceStepperRange();
}
BaseGeometry::ExecuteOperation( ¢eredRotation );
}
else
{
// we also have to consider the case, that there is no reference geometry available.
if ( m_PlaneGeometries.size() > 0 )
{
// Reach through to all slices in my container
for (auto iter = m_PlaneGeometries.begin();
iter != m_PlaneGeometries.end();
++iter)
{
// Test for empty slices, which can happen if evenly spaced geometry
if ((*iter).IsNotNull())
{
(*iter)->ExecuteOperation(operation);
}
}
// rotate overall geometry
RotationOperation *rotOp = dynamic_cast< RotationOperation * >( operation );
BaseGeometry::ExecuteOperation( rotOp);
}
}
}
else
{
// Reach through to all slices
for (auto iter = m_PlaneGeometries.begin();
iter != m_PlaneGeometries.end();
++iter)
{
(*iter)->ExecuteOperation(operation);
}
}
break;
case OpORIENT:
if ( m_EvenlySpaced )
{
// get operation data
PlaneOperation *planeOp = dynamic_cast< PlaneOperation * >( operation );
// Get first slice
PlaneGeometry::Pointer planeGeometry = m_PlaneGeometries[0];
// Need a PlaneGeometry, a PlaneOperation and a reference frame to
// carry out the re-orientation. If not all avaialble, stop here
//.........这里部分代码省略.........
示例6: operator
// Operators to make my life easier
int operator() (int const x, int const y) const {
return op(x, y);
}
示例7: indiceMenorPrecedencia
NodoArbol<Elemento *> * Operacion::descomponer() {
Elemento * resultado;
NodoArbol<Elemento *> * resultadoNodo;
int indice = indiceMenorPrecedencia(operacion);
string cen = operacion.substr(indice, 1);
if (indice == -1) {
resultado = new Operando(stod(operacion));
//return new NodoArbol<Elemento *>(resultado);
}
else {
if (cen == "f"){
resultado = new OperadorFunction();
string a = operacion.substr(indice + 2, operacion.length() - indice - 1);
istringstream op(a);
string operando;
while (getline(op, operando, ',')){
resultadoNodo->setNode(new NodoArbol<Elemento *>(resultado));
return resultadoNodo;
}
}
else {
if (cen == "s" || cen == "c" || cen == "t" || cen == "l"){
string a = operacion.substr(indice, 1);
string b = operacion.substr(indice + 1, operacion.length() - indice - 1);
switch (cen[0]) {
case 's':
resultado = new OperadorSeno();
resultadoNodo = new NodoArbol<Elemento *>(resultado);// debe agregar nuevo nodo que contenga la operacion
break;
case 'c':
resultado = new OperadorCoseno();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
case 't':
resultado = new OperadorTangente();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
case 'l':
resultado = new OperadorLogNatural();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
default:
resultado = NULL;
break;
}
resultadoNodo->setNode(new NodoArbol<Elemento *>(procesarStringHijo(b)));
return resultadoNodo;
}
else {
string a = operacion.substr(0, indice);
string b = operacion.substr(indice, 1);
string c = operacion.substr(indice + 1, operacion.length() - indice - 1);
switch (cen[0]) {
case '+':
resultado = new OperadorSuma();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
case '-':
resultado = new OperadorResta();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
case'*':
resultado = new OperadorMultiplicacion();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
case '/':
resultado = new OperadorDivision();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
case '^':
resultado = new OperadorExponencial();
resultadoNodo = new NodoArbol<Elemento *>(resultado);
break;
default:
resultado = NULL;
break;
}
resultadoNodo->setNode(new NodoArbol<Elemento *>(procesarStringHijo(a)));
resultadoNodo->setNode(new NodoArbol<Elemento *>(procesarStringHijo(c)));
}
}
}
return resultadoNodo;
}
示例8: selectTraceletLegacy
RegionDescPtr selectTraceletLegacy(const Transl::Tracelet& tlet) {
typedef RegionDesc::Block Block;
auto region = std::make_shared<RegionDesc>();
SrcKey sk(tlet.m_sk);
auto unit = tlet.func()->unit();
const Func* topFunc = nullptr;
Block* curBlock = nullptr;
auto newBlock = [&](const Func* func, SrcKey start) {
assert(curBlock == nullptr || curBlock->length() > 0);
region->blocks.push_back(
std::make_shared<Block>(func, start.offset(), 0));
curBlock = region->blocks.back().get();
};
newBlock(tlet.func(), sk);
for (auto ni = tlet.m_instrStream.first; ni; ni = ni->next) {
assert(sk == ni->source);
assert(ni->unit() == unit);
curBlock->addInstruction();
if ((curBlock->length() == 1 && ni->funcd != nullptr) ||
ni->funcd != topFunc) {
topFunc = ni->funcd;
curBlock->setKnownFunc(sk, topFunc);
}
if (ni->calleeTrace && !ni->calleeTrace->m_inliningFailed) {
assert(ni->op() == OpFCall);
assert(ni->funcd == ni->calleeTrace->func());
// This should be translated as an inlined call. Insert the blocks of the
// callee in the region.
auto const& callee = *ni->calleeTrace;
curBlock->setInlinedCallee(ni->funcd);
SrcKey cSk = callee.m_sk;
Unit* cUnit = callee.func()->unit();
newBlock(callee.func(), cSk);
for (auto cni = callee.m_instrStream.first; cni; cni = cni->next) {
assert(cSk == cni->source);
assert(cni->op() == OpRetC ||
cni->op() == OpContRetC ||
cni->op() == OpNativeImpl ||
!instrIsNonCallControlFlow(cni->op()));
curBlock->addInstruction();
cSk.advance(cUnit);
}
if (ni->next) {
sk.advance(unit);
newBlock(tlet.func(), sk);
}
continue;
}
if (!ni->noOp && isFPassStar(ni->op())) {
curBlock->setParamByRef(sk, ni->preppedByRef);
}
if (ni->next && ni->op() == OpJmp) {
// A Jmp that isn't the final instruction in a Tracelet means we traced
// through a forward jump in analyze. Update sk to point to the next NI
// in the stream.
auto dest = ni->offset() + ni->imm[0].u_BA;
assert(dest > sk.offset()); // We only trace for forward Jmps for now.
sk.setOffset(dest);
// The Jmp terminates this block.
newBlock(tlet.func(), sk);
} else {
sk.advance(unit);
}
}
auto& frontBlock = *region->blocks.front();
// Add tracelet guards as predictions on the first instruction. Predictions
// and known types from static analysis will be applied by
// Translator::translateRegion.
for (auto const& dep : tlet.m_dependencies) {
if (dep.second->rtt.isVagueValue() ||
dep.second->location.isThis()) continue;
typedef RegionDesc R;
auto addPred = [&](const R::Location& loc) {
auto type = Type::fromRuntimeType(dep.second->rtt);
frontBlock.addPredicted(tlet.m_sk, {loc, type});
};
switch (dep.first.space) {
case Transl::Location::Stack:
addPred(R::Location::Stack{uint32_t(-dep.first.offset - 1)});
break;
case Transl::Location::Local:
addPred(R::Location::Local{uint32_t(dep.first.offset)});
break;
//.........这里部分代码省略.........
示例9: op
ex basic::operator[](size_t i) const
{
return op(i);
}
示例10: is_equal
/** Check whether the expression matches a given pattern. For every wildcard
* object in the pattern, a pair with the wildcard as a key and matching
* expression as a value is added to repl_lst. */
bool basic::match(const ex & pattern, exmap& repl_lst) const
{
/*
Sweet sweet shapes, sweet sweet shapes,
That's the key thing, right right.
Feed feed face, feed feed shapes,
But who is the king tonight?
Who is the king tonight?
Pattern is the thing, the key thing-a-ling,
But who is the king of Pattern?
But who is the king, the king thing-a-ling,
Who is the king of Pattern?
Bog is the king, the king thing-a-ling,
Bog is the king of Pattern.
Ba bu-bu-bu-bu bu-bu-bu-bu-bu-bu bu-bu
Bog is the king of Pattern.
*/
if (is_exactly_a<wildcard>(pattern)) {
// Wildcard matches anything, but check whether we already have found
// a match for that wildcard first (if so, the earlier match must be
// the same expression)
for (exmap::const_iterator it = repl_lst.begin(); it != repl_lst.end(); ++it) {
if (it->first.is_equal(pattern))
return is_equal(ex_to<basic>(it->second));
}
repl_lst[pattern] = *this;
return true;
} else {
// Expression must be of the same type as the pattern
if (typeid(*this) != typeid(ex_to<basic>(pattern)))
return false;
// Number of subexpressions must match
if (nops() != pattern.nops())
return false;
// No subexpressions? Then just compare the objects (there can't be
// wildcards in the pattern)
if (nops() == 0)
return is_equal_same_type(ex_to<basic>(pattern));
// Check whether attributes that are not subexpressions match
if (!match_same_type(ex_to<basic>(pattern)))
return false;
// Even if the expression does not match the pattern, some of
// its subexpressions could match it. For example, x^5*y^(-1)
// does not match the pattern $0^5, but its subexpression x^5
// does. So, save repl_lst in order to not add bogus entries.
exmap tmp_repl = repl_lst;
// Otherwise the subexpressions must match one-to-one
for (size_t i=0; i<nops(); i++)
if (!op(i).match(pattern.op(i), tmp_repl))
return false;
// Looks similar enough, match found
repl_lst = tmp_repl;
return true;
}
}
示例11: vnl_cross_3d
void SlicesRotator::RotateToPoint( SliceNavigationController *rotationPlaneSNC,
SliceNavigationController *rotatedPlaneSNC,
const Point3D &point, bool linked )
{
MITK_WARN << "Deprecated function! Use SliceNavigationController::ReorientSlices() instead";
SliceNavigationController *thirdSNC = NULL;
SNCVector::iterator iter;
for ( iter = m_RotatableSNCs.begin(); iter != m_RotatableSNCs.end(); ++iter )
{
if ( ((*iter) != rotationPlaneSNC)
&& ((*iter) != rotatedPlaneSNC) )
{
thirdSNC = *iter;
break;
}
}
if ( thirdSNC == NULL )
{
return;
}
const PlaneGeometry *rotationPlane = rotationPlaneSNC->GetCurrentPlaneGeometry();
const PlaneGeometry *rotatedPlane = rotatedPlaneSNC->GetCurrentPlaneGeometry();
const PlaneGeometry *thirdPlane = thirdSNC->GetCurrentPlaneGeometry();
if ( (rotationPlane == NULL) || (rotatedPlane == NULL)
|| (thirdPlane == NULL) )
{
return;
}
if ( rotatedPlane->DistanceFromPlane( point ) < 0.001 )
{
// Skip irrelevant rotations
return;
}
Point3D projectedPoint;
Line3D intersection;
Point3D rotationCenter;
if ( !rotationPlane->Project( point, projectedPoint )
|| !rotationPlane->IntersectionLine( rotatedPlane, intersection )
|| !thirdPlane->IntersectionPoint( intersection, rotationCenter ) )
{
return;
}
// All pre-requirements are met; execute the rotation
Point3D referencePoint = intersection.Project( projectedPoint );
Vector3D toProjected = referencePoint - rotationCenter;
Vector3D toCursor = projectedPoint - rotationCenter;
// cross product: | A x B | = |A| * |B| * sin(angle)
Vector3D axisOfRotation;
vnl_vector_fixed< ScalarType, 3 > vnlDirection =
vnl_cross_3d( toCursor.GetVnlVector(), toProjected.GetVnlVector() );
axisOfRotation.SetVnlVector( vnlDirection );
// scalar product: A * B = |A| * |B| * cos(angle)
// tan = sin / cos
ScalarType angle = - atan2(
(double)(axisOfRotation.GetNorm()),
(double)(toCursor * toProjected) );
angle *= 180.0 / vnl_math::pi;
// create RotationOperation and apply to all SNCs that should be rotated
RotationOperation op(OpROTATE, rotationCenter, axisOfRotation, angle);
if ( !linked )
{
BaseRenderer *renderer = rotatedPlaneSNC->GetRenderer();
if ( renderer == NULL )
{
return;
}
DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry();
Point2D point2DWorld, point2DDisplayPre, point2DDisplayPost;
displayGeometry->Map( rotationCenter, point2DWorld );
displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPre );
TimeGeometry *timeGeometry= rotatedPlaneSNC->GetCreatedWorldGeometry();
if ( !timeGeometry )
{
return;
}
timeGeometry->ExecuteOperation( &op );
displayGeometry->Map( rotationCenter, point2DWorld );
displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPost );
Vector2D vector2DDisplayDiff = point2DDisplayPost - point2DDisplayPre;
//.........这里部分代码省略.........
示例12: PEG_METHOD_ENTER
CIMHandleIndicationResponseMessage*
IndicationHandlerService::_handleIndication(
CIMHandleIndicationRequestMessage* request)
{
PEG_METHOD_ENTER(TRC_IND_HANDLER,
"IndicationHandlerService::_handleIndication()");
Boolean handleIndicationSuccess = true;
CIMException cimException =
PEGASUS_CIM_EXCEPTION(CIM_ERR_SUCCESS, String::EMPTY);
CIMName className = request->handlerInstance.getClassName();
CIMNamespaceName nameSpace = request->nameSpace;
CIMInstance indication = request->indicationInstance;
CIMInstance handler = request->handlerInstance;
PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
"Handler service received %s Indication %s for %s:%s.%s Handler",
(const char*)(indication.getClassName().getString().getCString()),
(const char*)(request->messageId.getCString()),
(const char*)(request->nameSpace.getString().getCString()),
(const char*)(handler.getClassName().getString().getCString()),
(const char*)(handler.getProperty(handler.findProperty(
PEGASUS_PROPERTYNAME_NAME)).getValue().toString().getCString())));
Uint32 pos = PEG_NOT_FOUND;
if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) ||
className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML))
{
pos = handler.findProperty(PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION);
if (pos == PEG_NOT_FOUND)
{
cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
MessageLoaderParms(
"HandlerService.IndicationHandlerService."
"CIMXML_HANDLER_WITHOUT_DESTINATION",
"CIMXml Handler missing Destination property"));
handleIndicationSuccess = false;
}
else
{
CIMProperty prop = handler.getProperty(pos);
String destination = prop.getValue().toString();
if (destination.size() == 0)
{
cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
MessageLoaderParms(
"HandlerService.IndicationHandlerService."
"INVALID_DESTINATION",
"invalid destination"));
handleIndicationSuccess = false;
}
//compared index 10 is not :
else if (destination.subString(0, 10) == String("localhost/"))
{
Uint32 exportServer =
find_service_qid(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER);
// Listener is build with Cimom, so send message to ExportServer
AutoPtr<CIMExportIndicationRequestMessage> exportmessage(
new CIMExportIndicationRequestMessage(
XmlWriter::getNextMessageId(),
//taking localhost/CIMListener portion out from reg
destination.subString(21),
indication,
QueueIdStack(exportServer, getQueueId()),
String::EMPTY,
String::EMPTY));
exportmessage->operationContext.insert(
IdentityContainer(String::EMPTY));
exportmessage->operationContext.set(
request->operationContext.get(
ContentLanguageListContainer::NAME));
AutoPtr<AsyncOpNode> op( this->get_op());
AutoPtr<AsyncLegacyOperationStart> asyncRequest(
new AsyncLegacyOperationStart(
op.get(),
exportServer,
exportmessage.get()));
exportmessage.release();
PEG_TRACE((TRC_IND_HANDLER, Tracer::LEVEL4,
"Indication handler forwarding message to %s",
((MessageQueue::lookup(exportServer)) ?
((MessageQueue::lookup(exportServer))->
getQueueName()):
"BAD queue name")));
PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
"Sending %s Indication %s to destination %s",
(const char*) (indication.getClassName().getString().
getCString()),
(const char*)(request->messageId.getCString()),
(const char*) destination.getCString()));
//.........这里部分代码省略.........
示例13: mexFunction
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
{
double* m_dict;
double* m_x;
check_num_input_args(nrhs, 2, 6);
check_num_output_args(nlhs, 0,1);
check_is_double_matrix(A_IN, func_name, "A");
check_is_double_matrix(B_IN, func_name, "b");
int max_iters = 0;
if (nrhs > 2){
check_is_double_scalar(ITER_IN, func_name, "max_iters");
// Read the value of max_iters
max_iters = mxGetScalar(ITER_IN);
}
double tolerance = 0;
if (nrhs > 3){
check_is_double_scalar(EPS_IN, func_name, "tolerance");
tolerance = mxGetScalar(EPS_IN);
}
int sparse_output = 1;
if (nrhs > 4){
check_is_double_scalar(SPARSE_IN, func_name,"sparse");
sparse_output = (int) mxGetScalar(SPARSE_IN);
}
int verbose = 0;
if (nrhs > 5){
check_is_double_scalar(VERBOSE, func_name, "verbose");
verbose = (int) mxGetScalar(VERBOSE);
}
m_dict = mxGetPr(A_IN);
m_x = mxGetPr(B_IN);
size_t M, N, S;
// Number of signal space dimension
M = mxGetM(A_IN);
// Number of atoms
N = mxGetN(A_IN);
if (M != mxGetM(B_IN)){
mexErrMsgTxt("Dimensions mismatch");
}
if (M != N) {
mexErrMsgTxt("A must be symmetric positive definite");
}
// Number of signals
S = mxGetN(B_IN);
if (S != 1) {
mexErrMsgTxt("Only one vector supported at the moment");
}
if(verbose){
mexPrintf("M: %d, N:%d, S: %d, max_iters: %d, tolerance: %e, sparse: %d, verbose: %d\n",
M, N, S, max_iters, tolerance, sparse_output, verbose);
}
// Create Sparse Representation Vector
spx::MxArray op(A_IN);
spx::CongugateGradients cg (op);
if (max_iters > 0) {
cg.set_max_iterations(max_iters);
}
if (tolerance > 0) {
cg.set_tolerance(tolerance);
}
if (verbose > 0){
cg.set_verbose( (spx::VERBOSITY) verbose);
}
cg(m_x);
X_OUT = spx::d_vec_to_mx_array(cg.get_x());
}
示例14: mainTest
int mainTest(int argNumber, char* argString[])
{
//Init Logger
Logger::getInstance()->setLoggingLevel(eINFO);
//We create a folder for background substraction configuration file. BGSLib will crash if that folder doesn't exist.
boost::filesystem::create_directory("config");
//We load the tracking configuration
po::options_description fileConfig("Configuration file options");
po::variables_map vm = LoadConfigurationSettings(argNumber, argString, fileConfig);
if(vm.count("logging-level") >0)
{
unsigned int level = vm["logging-level"].as<unsigned int>();
if(level >= 0 && level <= eNONE)
Logger::getInstance()->setLoggingLevel(ELoggingLevel(level));
}
//We load the video
bool overrideTotalNbFrame = false;
unsigned int lastFrame = -1;
InputFrameProviderIface* vfm = LoadVideo(vm, overrideTotalNbFrame, lastFrame);
try
{
if(vfm && vfm->isOpen())
{
LOGINFO("Starting tracker");
bool success = true;
DrawableTimer dt;
float pixelByMeter = 1;
if(vm.count("scaleratio-filename") > 0 && vm["scaleratio-filename"].as<std::string>() != "none" && vm["scaleratio-filename"].as<std::string>() != "None")
{
success = Utils::IO::LoadScalar<float>(vm["scaleratio-filename"].as<std::string>(), pixelByMeter);
if(!success)
{
pixelByMeter = 1;
LOGWARNING("Can't load scale ratio file. Using 1px/m ratio");
}
}
cv::Mat homography = cv::Mat::eye(3,3, CV_32FC1);
if(vm.count("homography-filename") > 0 && vm["homography-filename"].as<std::string>() != "none" && vm["homography-filename"].as<std::string>() != "None")
{
success = Utils::IO::LoadMatrix<double>(vm["homography-filename"].as<std::string>(), homography);
if(!success)
{
homography = cv::Mat::eye(3,3, CV_32FC1);
LOGWARNING("Can't load homography file. Using identity.");
}
}
cv::Mat mask;
if(vm.count("mask-filename") > 0 && vm["mask-filename"].as<std::string>() != "none" && vm["mask-filename"].as<std::string>() != "None")
{
mask = cv::imread(vm["mask-filename"].as<std::string>());
cv::cvtColor(mask, mask, CV_BGR2GRAY);
}
else
{
mask = cv::Mat(vfm->getHeight(), vfm->getWidth(), CV_8UC1);
mask.setTo(cv::Scalar(255,255,255));
}
/*if(vm.count("aerialview-filename") > 0)
{
std::string aerialfn(vm["aerialview-filename"].as<std::string>());
const cv::Mat aerialView = cv::imread(aerialfn);
}*/
DrawingFlags drawFlags = LoadDrawingFlags(vm);
BlobTrackerAlgorithmParams algoParams = LoadTrackerParams(vm);
DisplayInstruction();
ApplicationContext context(mask, homography,(float)vfm->getNbFPS(), pixelByMeter, drawFlags, algoParams, vm["record-bgs"].as<bool>(), vfm);
TrackerPersistance op(&context, vm["object-sqlite-filename"].as<std::string>());
op.init();
std::string bgsRecord = vm["bgs-filepath"].as<std::string>();
context.setBGSPath(bgsRecord);
std::string bgsType = vm["bgs-type"].as<std::string>();
Tracker t(&context, bgsType);
if(bgsType == "PlaybackBGS" && vm.count("bgs-filepath") > 0)
{
IBGS* bgs = t.getBlobDetector()->getBGS();
PlaybackBGS* pbBGS = dynamic_cast<PlaybackBGS*>(bgs);
if(pbBGS)
pbBGS->setPath(bgsRecord);
// std::cout<<"remove playBackBgs\n";
// exit(-1);
}
//bgs-filepath
cv::Mat m;
bool stepByStep = false;
//.........这里部分代码省略.........
示例15: method_id
method_id("add");
ret(ieval(begin_splat(),
arg(1), op("+"), arg(2),
end_splat()));
comment("see http://jsfiddle.net/4MmvW/1/");