static int capella_cm3602_disable(struct capella_cm3602_data *data) { int rc = -EIO; int irq = data->pdata->irq; IPS("%s\n", __func__); if (!data->enabled) { DPS("%s: already disabled\n", __func__); return 0; } disable_irq(irq); rc = irq_set_irq_wake(irq, 0); if (rc < 0) EPS("%s: failed to set irq %d as a non-wake interrupt\n", __func__, irq); rc = gpio_direction_output(data->pdata->p_en, 1); if (rc < 0) return rc; data->pdata->power(PS_PWR_ON, 0); data->enabled = 0; input_event(data->input_dev, EV_SYN, SYN_CONFIG, 0); return rc; }
dualquat<value_t> log () const { assert(isunit()); if ((w*w-1)*(w*w-1) < EPS(value_t)) return dualquat<value_t>(0, 0, 0, 0, 0, X, Y, Z); const value_t theta = 2.0*std::acos(w); const value_t invvv = 0.5/std::sqrt(x*x+y*y+z*z); const value_t pitch = -4.0*W*invvv; const value_t alpha = pitch*w; const value_t lx = x*invvv; const value_t ly = y*invvv; const value_t lz = z*invvv; const value_t mx = (X-lx*alpha)*invvv; const value_t my = (Y-ly*alpha)*invvv; const value_t mz = (Z-lz*alpha)*invvv; assert((lx*mx+ly*my+lz*mz)*(lx*mx+ly*my+lz*mz) < EPS(value_t)); return dualquat<value_t> (0, theta*lx, theta*ly, theta*lz, 0, (pitch*lx+theta*mx), (pitch*ly+theta*my), (pitch*lz+theta*mz)); }
dualquat<value_t> exp() const { assert(w*w < EPS(value_t) && W*W < EPS(value_t)); if (x*x+y*y+z*z < EPS(value_t)) return dualquat<value_t>(1, 0, 0, 0, 0, X, Y, Z); const value_t theta = 2.0*std::sqrt(x*x+y*y+z*z); const value_t invvv = 2.0/theta; const value_t lx = x*invvv; const value_t ly = y*invvv; const value_t lz = z*invvv; const value_t pitch = 2.0*(lx*X+ly*Y+lz*Z); const value_t mx = (2.0*X-pitch*lx)/theta; const value_t my = (2.0*Y-pitch*ly)/theta; const value_t mz = (2.0*Z-pitch*lz)/theta; assert((lx*mx+ly*my+lz*mz)*(lx*mx+ly*my+lz*mz) < EPS(value_t)); const value_t cost2 = std::cos(0.5*theta); const value_t sint2 = std::sin(0.5*theta); const value_t alpha = 0.5*pitch*cost2; return dualquat<value_t> (cost2, sint2*lx, sint2*ly, sint2*lz, -0.5*pitch*sint2, sint2*mx+alpha*lx, sint2*my+alpha*ly, sint2*mz+alpha*lz); }
bool isunit() const { const value_t residue0 = w*w+x*x+y*y+z*z-1.0; const value_t residue1 = w*W+x*X+y*Y+z*Z; return residue0*residue0 < EPS(value_t) && residue1*residue1 < EPS(value_t); }
static int capella_cm3602_setup(struct capella_cm3602_data *ip) { int rc = -EIO; struct capella_cm3602_platform_data *pdata = ip->pdata; int irq = pdata->irq; IPS("%s\n", __func__); if (pdata->p_out == 0 || pdata->p_en == 0) { EPS("%s: gpio == 0!!\n", __func__); rc = -1; goto done; } rc = gpio_request(pdata->p_out, "gpio_proximity_out"); if (rc < 0) { EPS("%s: gpio %d request failed (%d)\n", __func__, pdata->p_out, rc); goto done; } rc = gpio_request(pdata->p_en, "gpio_proximity_en"); if (rc < 0) { EPS("%s: gpio %d request failed (%d)\n", __func__, pdata->p_en, rc); goto fail_free_p_out; } rc = gpio_direction_input(pdata->p_out); if (rc < 0) { EPS("%s: failed to set gpio %d as input (%d)\n", __func__, pdata->p_out, rc); goto fail_free_p_en; } set_irq_flags(irq, IRQF_VALID | IRQF_NOAUTOEN); rc = request_irq(irq, capella_cm3602_irq_handler, IRQF_TRIGGER_LOW | IRQF_TRIGGER_HIGH, "capella_cm3602", ip); if (rc < 0) { EPS("%s: request_irq(%d) failed for gpio %d (%d)\n", __func__, irq, pdata->p_out, rc); goto fail_free_p_en; } goto done; fail_free_p_en: gpio_free(pdata->p_en); fail_free_p_out: gpio_free(pdata->p_out); done: return rc; }
bool WebExtensionPolicy::Disable() { MOZ_ASSERT(mActive); MOZ_ASSERT(EPS().GetByID(Id()) == this); if (!EPS().UnregisterExtension(*this)) { return false; } Unused << Proto()->SetSubstitution(MozExtensionHostname(), nullptr); mActive = false; return true; }
static int capella_cm3602_enable(struct capella_cm3602_data *data) { int rc; int irq = data->pdata->irq; IPS("%s\n", __func__); if (data->enabled) { DPS("%s: already enabled\n", __func__); return 0; } /* dummy report */ input_report_abs(data->input_dev, ABS_DISTANCE, -1); input_sync(data->input_dev); data->pdata->power(PS_PWR_ON, 1); rc = gpio_direction_output(data->pdata->p_en, 0); msleep(220); data->enabled = !rc; if (!rc) capella_cm3602_report(data); enable_irq(irq); rc = irq_set_irq_wake(irq, 1); if (rc < 0) EPS("%s: failed to set irq %d as a wake interrupt\n", __func__, irq); return rc; }
static int capella_cm3602_report(struct capella_cm3602_data *data) { int val = gpio_get_value(data->pdata->p_out); int value1, value2; int retry_limit = 10; int irq = data->pdata->irq; do { value1 = gpio_get_value(data->pdata->p_out); irq_set_irq_type(irq, value1 ? IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH); value2 = gpio_get_value(data->pdata->p_out); } while (value1 != value2 && retry_limit-- > 0); if (val < 0) { EPS("%s: gpio_get_value error %d\n", __func__, val); return val; } IPS("proximity %s\n", val ? "FAR" : "NEAR"); /* 0 is close, 1 is far */ input_report_abs(data->input_dev, ABS_DISTANCE, val); input_sync(data->input_dev); wake_lock_timeout(&proximity_wake_lock, 2*HZ); return val; }
quat<value_t> QIB (const std::vector<quat<value_t>>& quats, const std::vector<value_t>& weights) { assert(quats.size() == weights.size()); quat<value_t> b = QLB(quats, weights); auto logmean = [&]() { quat<value_t> avg(0); for (size_t i = 0; i < quats.size(); i++) avg += ((b.C())*quats[i]).log()*weights[i]; return avg; }; auto x = logmean(); auto norm = x.dot(x); for(;;){ b *= x.exp(); auto xnew = logmean(); const auto newnorm = xnew.dot(xnew); if(norm < newnorm || newnorm < EPS(value_t)) break; else { x = xnew; norm = newnorm; } } return b; }
dualquat<value_t> DIA (const std::vector<dualquat<value_t>>& quats) { dualquat<value_t> b = DLA(quats); auto logmean = [&]() { dualquat<value_t> avg(0); for (size_t i = 0; i < quats.size(); i++) avg += (b.C()*quats[i]).log(); return avg/quats.size(); }; auto x = logmean(); auto norm = x.dot(x); for(;;){ b *= x.numexp(); auto xnew = logmean(); const auto newnorm = xnew.dot(xnew); if(norm < newnorm || newnorm < EPS(value_t)) break; else { x = xnew; norm = newnorm; } } // std::cout << "precision: " << norm << std::endl; return b; }
quat<value_t> QIA (const std::vector<quat<value_t>>& quats) { quat<value_t> b = QLA(quats); auto logmean = [&]() { quat<value_t> avg(0); for (size_t i = 0; i < quats.size(); i++) avg += (b.C()*quats[i]).log(); return avg/quats.size(); }; auto x = logmean(); auto norm = x.dot(x); for(;;){ b *= x.exp(); auto xnew = logmean(); const auto newnorm = xnew.dot(xnew); if(norm < newnorm || newnorm < EPS(value_t)) break; else { x = xnew; norm = newnorm; } } return b; }
quat<value_t> exp () const { assert(w*w < EPS(value_t)); value_t dst = std::sqrt(x*x+y*y+z*z); value_t fac = std::sin(dst)/dst; return quat<value_t>(std::cos(dst), x*fac, y*fac, z*fac); }
void HowAnalyser::visit_simple_effect(simple_effect * se) { extended_pred_symbol * e = EPS(se->prop->head); if(epss.find(e) == epss.end()) { ag->addInitialFact(e); epss.insert(e); }; };
quat<value_t> log () const { assert(isunit()); if ((w*w-1)*(w*w-1) < EPS(value_t)) return quat<value_t>(0); const value_t inv = 1.0/std::sqrt(x*x+y*y+z*z); const value_t fac = std::acos(w)*inv; return quat<value_t> (0, x*fac, y*fac, z*fac); }
quat<value_t> numexp (value_t eps = EPS(value_t)) const { quat<value_t> pow; quat<value_t> sum; size_t i = 1; while (pow.dot(pow) > eps) { pow *= (*this)/i++; sum += pow; } return sum; }
dualquat<value_t> N() const { const value_t qq = w*w+x*x+y*y+z*z+EPS(value_t); const value_t qQ = w*W+x*X+y*Y+z*Z; const value_t invqq = 1.0/qq; const value_t invsq = 1.0/std::sqrt(qq); const value_t alpha = qQ*invqq*invsq; return dualquat<value_t>(w*invsq, x*invsq, y*invsq, z*invsq, W*invsq-w*alpha, X*invsq-x*alpha, Y*invsq-y*alpha, Z*invsq-z*alpha); }
bool WebExtensionPolicy::Enable() { MOZ_ASSERT(!mActive); if (!EPS().RegisterExtension(*this)) { return false; } Unused << Proto()->SetSubstitution(MozExtensionHostname(), mBaseURI); mActive = true; return true; }
/* static */ bool WebExtensionPolicy::UseRemoteWebExtensions(GlobalObject& aGlobal) { return EPS().UseRemoteExtensions(); }
static int capella_cm3602_probe(struct platform_device *pdev) { int rc = -EIO; struct input_dev *input_dev; struct capella_cm3602_data *ip; struct capella_cm3602_platform_data *pdata; IPS("%s: probe\n", __func__); pdata = dev_get_platdata(&pdev->dev); if (!pdata) { EPS("%s: missing pdata!\n", __func__); goto done; } if (!pdata->power) { EPS("%s: incomplete pdata!\n", __func__); goto done; } ip = &the_data; platform_set_drvdata(pdev, ip); /*DPS("%s: allocating input device\n", __func__);*/ input_dev = input_allocate_device(); if (!input_dev) { EPS("%s: could not allocate input device\n", __func__); rc = -ENOMEM; goto done; } ip->input_dev = input_dev; ip->pdata = pdata; input_set_drvdata(input_dev, ip); input_dev->name = "proximity"; set_bit(EV_ABS, input_dev->evbit); input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1, 0, 0); /*DPS("%s: registering input device\n", __func__);*/ rc = input_register_device(input_dev); if (rc < 0) { EPS("%s: could not register input device\n", __func__); goto err_free_input_device; } /*DPS("%s: registering misc device\n", __func__);*/ rc = misc_register(&capella_cm3602_misc); if (rc < 0) { EPS("%s: could not register misc device\n", __func__); goto err_unregister_input_device; } wake_lock_init(&proximity_wake_lock, WAKE_LOCK_SUSPEND, "proximity"); rc = capella_cm3602_setup(ip); if (!rc) goto done; misc_deregister(&capella_cm3602_misc); err_unregister_input_device: input_unregister_device(input_dev); err_free_input_device: input_free_device(input_dev); done: return rc; }
/* static */ already_AddRefed<WebExtensionPolicy> WebExtensionPolicy::GetByURI(dom::GlobalObject& aGlobal, nsIURI* aURI) { return do_AddRef(EPS().GetByURL(aURI)); }
/* static */ already_AddRefed<WebExtensionPolicy> WebExtensionPolicy::GetByHostname(dom::GlobalObject& aGlobal, const nsACString& aHostname) { return do_AddRef(EPS().GetByHost(aHostname)); }
/* static */ already_AddRefed<WebExtensionPolicy> WebExtensionPolicy::GetByID(dom::GlobalObject& aGlobal, const nsAString& aID) { return do_AddRef(EPS().GetByID(aID)); }
bool isunit () const { const value_t residue = w*w+x*x+y*y+z*z-1.0; return residue*residue < EPS(value_t); }
/* static */ bool WebExtensionPolicy::IsExtensionProcess(GlobalObject& aGlobal) { return EPS().IsExtensionProcess(); }
$PARAM KA = 0.5, TVCL = 1, TVVC = 30, WT=70 $CMT GUT CENT $SET end=36, delta=0.5 $MAIN double CLi = exp(log(TVCL) + 0.75*log(WT/70) + ECL); double VCi = exp(log(TVVC) + log(WT/70) + EVC); $ODE dxdt_GUT = -KA*GUT; dxdt_CENT = KA*GUT - (CLi/VCi)*CENT; $OMEGA labels=s(ECL,EVC) 0 0 $SIGMA 0 $TABLE double IPRED = CENT/VCi; double DV = IPRED*exp(EPS(1)); $CAPTURE CLi VCi IPRED DV ECL
int main(int argc, char **argv) { // first build our error handler g3ErrorHandler = new ConsoleErrorHandler(); // // now create a domain and a modelbuilder // and build the model // // Domain *theDomain = new Domain(); MapOfTaggedObjects theStorage; // ArrayOfTaggedObjects theStorage(32); Domain *theDomain = new Domain(theStorage); // create the nodes using constructor: // Node(tag, ndof, crd1, crd2) // and then add them to the domain Node *node1 = new Node(1, 3, 1.0, 1.0, 0.0 ); Node *node2 = new Node(2, 3, 0.0, 1.0, 0.0 ); Node *node3 = new Node(3, 3, 0.0, 0.0, 0.0 ); Node *node4 = new Node(4, 3, 1.0, 0.0, 0.0 ); Node *node5 = new Node(5, 3, 1.0, 1.0, 1.0 ); Node *node6 = new Node(6, 3, 0.0, 1.0, 1.0 ); Node *node7 = new Node(7, 3, 0.0, 0.0, 1.0 ); Node *node8 = new Node(8, 3, 1.0, 0.0, 1.0 ); theDomain->addNode(node1); theDomain->addNode(node2); theDomain->addNode(node3); theDomain->addNode(node4); theDomain->addNode(node5); theDomain->addNode(node6); theDomain->addNode(node7); theDomain->addNode(node8); // create an elastic material using constriuctor: // ElasticMaterialModel(tag, E) //UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000); double PIo3 = PI/3.0; PIo3 = 0.0; //Drucker-Prager Model DPYieldSurface DP_YS; DPPotentialSurface DP_PS(0.05); //EvolutionLaw_NL_Eeq DP_ELS1; EvolutionLaw_L_Eeq DP_ELS1(10.0); EvolutionLaw_T DP_ELT; double scalars[] = {0.3, 0.0}; //alfa1, k double NOS = 2; //Number of scalar vars double NOT = 1; //Number of tensorial vars stresstensor startstress; straintensor startstrain, otherstrain; startstrain = startstrain.pqtheta2strain( 0.000, 0.0000, 0.0); otherstrain = otherstrain.pqtheta2strain( 0.000, 0.0000, 0.0); stresstensor *tensors = new stresstensor[1]; EPState EPS(3000.0, 3000.0, 0.3, 0.0, startstress, otherstrain, otherstrain, otherstrain, NOS, scalars, NOT, tensors); Template3Dep MP(1, &DP_YS, &DP_PS, &EPS, &DP_ELS1, &DP_ELT); NDMaterial *theMaterial = &MP; //NDMaterial *theMaterial = new ElasticIsotropic3D(1, 3000, 0.3); // create the truss elements using constructor: // Truss(tag, dim, nd1, nd2, Material &,A) // and then add them to the domain //Truss *truss1 = new Truss(1, 2, 1, 4, *theMaterial, 10.0); //Truss *truss2 = new Truss(2, 2, 2, 4, *theMaterial, 5.0); //EPState *eps = 0; EightNodeBrick *brick = new EightNodeBrick(1, 5, 6, 7, 8, 1, 2, 3, 4, theMaterial, "Template3Dep", 0.0, 0.0, 0.0, 1.8, &EPS); //theDomain->addElement(truss1); //theDomain->addElement(truss2); theDomain->addElement( brick ); // create the single-point constraint objects using constructor: // SP_Constraint(tag, nodeTag, dofID, value) // and then add them to the domain SP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 0.0259999); SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 0.0259999); SP_Constraint *sp3 = new SP_Constraint(3, 1, 2, -0.1213350); SP_Constraint *sp4 = new SP_Constraint(4, 2, 0, -0.0259999); SP_Constraint *sp5 = new SP_Constraint(5, 2, 1, 0.0259999); SP_Constraint *sp6 = new SP_Constraint(6, 2, 2, -0.1213350); SP_Constraint *sp7 = new SP_Constraint(7, 3, 0, -0.0259999); SP_Constraint *sp8 = new SP_Constraint(8, 3, 1, -0.0259999); SP_Constraint *sp9 = new SP_Constraint(9, 3, 2, -0.1213350); SP_Constraint *sp10 = new SP_Constraint(10, 4, 0, 0.0259999); SP_Constraint *sp11 = new SP_Constraint(11, 4, 1, -0.0259999); SP_Constraint *sp12 = new SP_Constraint(12, 4, 2, -0.1213350); SP_Constraint *sp13 = new SP_Constraint(13, 5, 0, 0.0); SP_Constraint *sp14 = new SP_Constraint(14, 5, 1, 0.0); SP_Constraint *sp15 = new SP_Constraint(15, 5, 2, 0.0); SP_Constraint *sp16 = new SP_Constraint(16, 6, 0, 0.0); SP_Constraint *sp17 = new SP_Constraint(17, 6, 1, 0.0); SP_Constraint *sp18 = new SP_Constraint(18, 6, 2, 0.0); SP_Constraint *sp19 = new SP_Constraint(19, 7, 0, 0.0); SP_Constraint *sp20 = new SP_Constraint(20, 7, 1, 0.0); SP_Constraint *sp21 = new SP_Constraint(21, 7, 2, 0.0); SP_Constraint *sp22 = new SP_Constraint(22, 8, 0, 0.0); SP_Constraint *sp23 = new SP_Constraint(23, 8, 1, 0.0); SP_Constraint *sp24 = new SP_Constraint(24, 8, 2, 0.0); //Add penalty constraint theDomain->addSP_Constraint(sp1 ); theDomain->addSP_Constraint(sp2 ); theDomain->addSP_Constraint(sp3 ); theDomain->addSP_Constraint(sp4 ); theDomain->addSP_Constraint(sp5 ); theDomain->addSP_Constraint(sp6 ); theDomain->addSP_Constraint(sp7 ); theDomain->addSP_Constraint(sp8 ); theDomain->addSP_Constraint(sp9 ); theDomain->addSP_Constraint(sp10); theDomain->addSP_Constraint(sp11); theDomain->addSP_Constraint(sp12); theDomain->addSP_Constraint(sp13); theDomain->addSP_Constraint(sp14); theDomain->addSP_Constraint(sp15); theDomain->addSP_Constraint(sp16); theDomain->addSP_Constraint(sp17); theDomain->addSP_Constraint(sp18); theDomain->addSP_Constraint(sp19); theDomain->addSP_Constraint(sp20); theDomain->addSP_Constraint(sp21); theDomain->addSP_Constraint(sp22); theDomain->addSP_Constraint(sp23); theDomain->addSP_Constraint(sp24); // construct a linear time series object using constructor: // LinearSeries() TimeSeries *theSeries = new LinearSeries(); // construct a load pattren using constructor: // LoadPattern(tag) // and then set it's TimeSeries and add it to the domain LoadPattern *theLoadPattern = new LoadPattern(1); theLoadPattern->setTimeSeries(theSeries); theDomain->addLoadPattern(theLoadPattern); // construct a nodal load using constructor: // NodalLoad(tag, nodeID, Vector &) // first construct a Vector of size 2 and set the values NOTE C INDEXING // then construct the load and add it to the domain Vector theLoadValues(3); theLoadValues(0) = 0.0; theLoadValues(1) = 0.0; //theLoadValues(2) = -100.0; theLoadValues(2) = 0.0; NodalLoad *theLoad = new NodalLoad(1, 5, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(2, 6, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(3, 7, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(4, 8, theLoadValues); theDomain->addNodalLoad(theLoad, 1); // create an Analysis object to perform a static analysis of the model // - constructs: // AnalysisModel of type AnalysisModel, // EquiSolnAlgo of type Linear // StaticIntegrator of type LoadControl // ConstraintHandler of type Penalty // DOF_Numberer which uses RCM // LinearSOE of type Band SPD // and then the StaticAnalysis object AnalysisModel *theModel = new AnalysisModel(); EquiSolnAlgo *theSolnAlgo = new Linear(); StaticIntegrator *theIntegrator = new LoadControl(1.0, 1.0, 1.0, 1.0); ConstraintHandler *theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8); RCM *theRCM = new RCM(); DOF_Numberer *theNumberer = new DOF_Numberer(*theRCM); BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver(); LinearSOE *theSOE = new BandSPDLinSOE(*theSolver); StaticAnalysis theAnalysis(*theDomain, *theHandler, *theNumberer, *theModel, *theSolnAlgo, *theSOE, *theIntegrator); // perform the analysis & print out the results for the domain int numSteps = 1; theAnalysis.analyze(numSteps); cerr << *theDomain; //brick->displaySelf(); exit(0); }