void _m(int t, int l, int r, int ll, int rr) { if (ll > rr) return ; if (ll == rr) { sum[t] = laz[t] = 0; return ; } if (sum[t] == 0) return; if (l == ll && r == rr) { sum[t] = 0; laz[t] = 1; } push_down(t); int mi = (ll+rr) / 2; if (r <= mi) { _m(lc(t), l, r, ll, mi); } else if (l > mi) { _m(rc(t), l, r, mi+1, rr); } else { _m(lc(t), l, mi, ll, mi); _m(rc(t), mi+1, r, mi+1, rr); } update(t); }
bool is_on_back (struct anim *k0, struct anim *k1) { struct coord m0, m1; _m (&k0->f, &m0); _m (&k1->f, &m1); coord2room (&m1, m0.room, &m1); return m1.room == m0.room && ((k0->f.dir == LEFT && m1.x > m0.x) || (k0->f.dir == RIGHT && m1.x < m0.x)); }
bool is_near (struct anim *k0, struct anim *k1) { struct coord m0, m1; struct pos p0, p1; survey (_m, pos, &k0->f, &m0, &p0, NULL); survey (_m, pos, &k1->f, &m1, &p1, NULL); _m (&k0->f, &m0); _m (&k1->f, &m1); coord2room (&m1, m0.room, &m1); return m1.room == m0.room && p1.floor == p0.floor && abs (m1.x - m0.x) < PLACE_WIDTH && abs (m1.y - m0.y) < PLACE_HEIGHT; }
void cw__test_helpers_check_enum_map(DjinniObjectHandle * m) { djinni::Handle<DjinniObjectHandle> _m(m, map_enum_color_string___delete); try { ::testsuite::TestHelpers::check_enum_map(DjinniMapEnumColorString::toCpp(std::move(_m))); } CW_TRANSLATE_EXCEPTIONS_RETURN(); }
bool cw__test_helpers_check_map(DjinniObjectHandle * m) { djinni::Handle<DjinniObjectHandle> _m(m, map_string_int64_t___delete); try { return ::testsuite::TestHelpers::check_map(DjinniMapStringInt64T::toCpp(std::move(_m))); } CW_TRANSLATE_EXCEPTIONS_RETURN(0); }
bool cw__test_helpers_check_map_list_record(DjinniRecordHandle * m) { djinni::Handle<DjinniRecordHandle> _m(m, map_list_record___delete); try { return ::testsuite::TestHelpers::check_map_list_record(DjinniMapListRecord::toCpp(std::move(_m))); } CW_TRANSLATE_EXCEPTIONS_RETURN(0); }
struct coord * nframe (struct frame *f, struct coord *c) { struct dim d; dim (f, &d); struct coord ml; _m (f, &ml); struct coord mr = ml; ml.x += -3; mr.x += +3; struct coord nml; ncoord (&ml, &nml); struct coord nmr; ncoord (&mr, &nmr); if (nml.room == nmr.room || (f->c.room != nml.room && f->c.room != nmr.room)) { if ((f->dir == LEFT && ! nml.room) || (f->dir == RIGHT && ! nmr.room)) return c; *c = (f->dir == LEFT) ? nml : nmr; int dx = (f->dir == LEFT) ? +3 : -3; c->x -= d.w / 2 - dx; c->y -= d.h / 2; } else *c = f->c; return c; }
int dist_enemy (struct anim *k) { struct anim *k1 = get_anim_by_id (k->enemy_id); if (! k1) return INT_MAX; struct frame f1 = k1->f; frame2room (&f1, k->f.c.room, &f1.c); struct coord m0, m1; _m (&k->f, &m0); _m (&f1, &m1); if (m0.room != m1.room) return INT_MAX; return abs (m1.x - m0.x); }
SpriteController::SpriteImpl::~SpriteImpl() { AutoMutex _m(mController->mLock); // Let the controller take care of deleting the last reference to sprite // surfaces so that we do not block the caller on an IPC here. if (mLocked.state.surfaceControl != NULL) { mController->disposeSurfaceLocked(mLocked.state.surfaceControl); mLocked.state.surfaceControl.clear(); } }
bool is_pos_seeing (struct pos *p0, struct anim *k1, enum dir dir) { struct coord m0, m1, mt1, mb1; struct pos p, p1, pk, pke; con_m (p0, &m0); coord_f cf; if (is_kid_climb (&k1->f) || is_anim_fall (&k1->f)) { coord2room (_mt (&k1->f, &mt1), m0.room, &mt1); coord2room (_m (&k1->f, &m1), m0.room, &m1); coord2room (_mbo (&k1->f, &mb1), m0.room, &mb1); double dt, dm, db; dt = (mt1.room == m0.room) ? dist_coord (&m0, &mt1) : INFINITY; dm = (m1.room == m0.room) ? dist_coord (&m0, &m1) : INFINITY; db = (mb1.room == m0.room) ? dist_coord (&m0, &mb1) : INFINITY; if (dt <= dm && dt <= db) cf = (dir == LEFT) ? _tr : _tl; else if (db <= dt && db <= dm) cf = (dir == LEFT) ? _br : _bl; else cf = (dir == LEFT) ? _mr : _ml; } else cf = (dir == LEFT) ? _mr : _ml; surveyo (cf, -8, +0, pos, &k1->f, &m1, NULL, NULL); coord2room (&m0, p0->room, &m0); coord2room (&m1, p0->room, &m1); pos (&m1, &p1); if (dir == LEFT) { if (is_opaque_at_left (p0)) return false; if (is_opaque_at_right (&p1)) return false; if (peqr (&p1, p0, +0, -1)) return true; prel (p0, &pk, +0, -1); prel (&p1, &pke, +0, +1); } else { if (is_opaque_at_right (p0)) return false; if (is_opaque_at_left (&p1)) return false; if (peqr (&p1, p0, +0, +1)) return true; prel (p0, &pk, +0, +1); prel (&p1, &pke, +0, -1); } if (peq (p0, &p1)) return true; first_confg (&pk, &pke, opaque_cs, &p); return p0->room == p1.room && m1.room == m0.room && p1.floor == p0->floor && ! (dir == LEFT && m1.x > m0.x) && ! (dir == RIGHT && m1.x < m0.x) && p.room == -1; }
void ViewDependence::computeCameraPosition(void) { glGetDoublev(GL_MODELVIEW_MATRIX,mModelview); gmMatrix4 _m(mModelview[0], mModelview[4], mModelview[8], mModelview[12], mModelview[1], mModelview[5], mModelview[9], mModelview[13], mModelview[2], mModelview[6], mModelview[10], mModelview[14], mModelview[3], mModelview[7], mModelview[11], mModelview[15]); gmMatrix4 _m_inv = _m.inverse(); (*mCameraPosition)[0] = _m_inv[0][3]; (*mCameraPosition)[1] = _m_inv[1][3]; (*mCameraPosition)[2] = _m_inv[2][3]; }// end ViewDependence::computeCameraPosition()
double SQFitting::qualityOfFit(pcl::PointCloud<pcl::PointXYZ>& cloud, SQParameters& sqParams) { pcl::PointXYZ _pnt; Eigen::MatrixXd m(3, 3), _m(3, 3); m(0, 0) = cos(sqParams.phi) * cos(sqParams.theta) * cos(sqParams.psi) - sin(sqParams.phi) * sin(sqParams.psi); m(0, 1) = -cos(sqParams.phi) * cos(sqParams.theta) * sin(sqParams.psi) - sin(sqParams.phi) * cos(sqParams.psi); m(0, 2) = cos(sqParams.phi) * sin(sqParams.theta); m(1, 0) = sin(sqParams.phi) * cos(sqParams.theta) * cos(sqParams.psi) + cos(sqParams.phi) * sin(sqParams.psi); m(1, 1) = -sin(sqParams.phi) * cos(sqParams.theta) * sin(sqParams.psi) + cos(sqParams.phi) * cos(sqParams.psi); m(1, 2) = sin(sqParams.phi) * sin(sqParams.theta); m(2, 0) = -sin(sqParams.theta) * cos(sqParams.psi); m(2, 1) = sin(sqParams.theta) * sin(sqParams.psi); m(2, 2) = cos(sqParams.theta); _m = m.inverse(); double f, a, b, c, d, e, error = 0; for (int i = 0; i < (int) cloud.points.size(); i++) { Eigen::MatrixXd pntMove(3, 1); Eigen::MatrixXd pnt(3, 1); Eigen::MatrixXd _pnt(3, 1); pntMove(0, 0) = (double) cloud.points[i].x - sqParams.px; pntMove(1, 0) = (double) cloud.points[i].y - sqParams.py; pntMove(2, 0) = (double) cloud.points[i].z - sqParams.pz; _pnt = _m * pntMove; _pnt(0, 0) = _pnt(0, 0) / (sqParams.kx * _pnt(2, 0) / sqParams.a3 + 1); _pnt(1, 0) = _pnt(1, 0) / (sqParams.ky * _pnt(2, 0) / sqParams.a3 + 1); a = pow(fabs(_pnt(0, 0) / sqParams.a1), 2.0 / sqParams.e2); b = pow(fabs(_pnt(1, 0) / sqParams.a2), 2.0 / sqParams.e2); c = pow(fabs(_pnt(2, 0) / sqParams.a3), 2.0 / sqParams.e1); d = pow(a + b, (double) (sqParams.e2 / sqParams.e1)); e = d + c; f = pow(e, (double) (sqParams.e1)); double tempError = pow((f - 1), 2.0); error += exp(-tempError * 10000); } error = sqrt(error); return (error); }
void LightPosition::prepare() { if (!_lightIsInWorldCoords) { glGetLightfv(GL_LIGHT0, GL_POSITION, _lightPositionf); gmVector4 eyeLP; for(size_t i = 0; i < 4; i++) eyeLP[i] = _lightPositionf[i]; GLdouble modelview[16]; glGetDoublev(GL_MODELVIEW_MATRIX,modelview); gmMatrix4 _m(modelview[0], modelview[4], modelview[8], modelview[12], modelview[1], modelview[5], modelview[9], modelview[13], modelview[2], modelview[6], modelview[10], modelview[14], modelview[3], modelview[7], modelview[11], modelview[15]); gmMatrix4 _m_inv = _m.inverse(); _lightPosition = _m_inv * eyeLP; } else { _lightPosition = _lightPositionInput; } }
void ZViewpoint::zviewpointHandleMsgTrackball( ZMsg *msg ) { static float viewpointMouseLast[2]; static int dragging = 0; float newzviewpointScale = 0.f; int scaleChange = 0; if( (zmsgIs(type,ZUIMouseClickOn) || zmsgIs(type,MouseClick)) && zmsgIs(dir,D) && (zmsgIs(which,R) || zmsgIs(which,M)) && zmsgI(shift) && zmsgI(ctrl) && zmsgI(alt) ) { // RESET memset( &zviewpointTrans, 0, sizeof(zviewpointTrans) ); zviewpointRotQuat.fromAxisAngle( FVec3::XAxis, 0.f ); zviewpointScale = 1.f; } char button = msg->getS( "which", "X" ) [0]; // if( (zmsgIs(type,ZUIMouseClickOn) || zmsgIs(type,MouseClick)) && zmsgIs(dir,D) && ( ( zmsgIs(which,M) && (zviewpointPermitRotX||zviewpointPermitRotY||zviewpointPermitRotZ) ) || zmsgIs(which,R) ) ) { if( (zmsgIs(type,ZUIMouseClickOn) || zmsgIs(type,MouseClick)) && zmsgIs(dir,D) && ( ( button==zviewpointRotateButton && (zviewpointPermitRotX||zviewpointPermitRotY||zviewpointPermitRotZ) ) || button==zviewpointTranslateButton ) ) { // I added the checks on permitrot but I think that this is probably temporay. I probably need to put in // some kind of better mapping system so that calling code can assign the mappings that they want // I had commented out the M button for some reason probably because // it conflicted with something. But I need it in Jarle. So this probably // needs to turn into a option but I will leave it on until // I see what it is that needs it turned off. Of course the // higher level thing could trap it and "zmsgUsed" to make ti disappear viewpointMouseLast[0] = zmsgF(x); viewpointMouseLast[1] = zmsgF(y); dragging = zMouseMsgRequestExclusiveDrag( "type=Viewpoint_MouseDrag" ); if( dragging ) { zviewpointRotating = button == zviewpointRotateButton; zviewpointTranslating = button == zviewpointTranslateButton; } zMsgUsed(); } else if( zmsgIs( type, KeyDown ) ) { if( zmsgIs( which, down ) ) { zviewpointRotateTrackball( 0.f, -zviewpointRotateStep ); zMsgUsed(); } if( zmsgIs( which, up ) ) { zviewpointRotateTrackball( 0.f, +zviewpointRotateStep ); zMsgUsed(); } if( zmsgIs( which, left ) ) { zviewpointRotateTrackball( +zviewpointRotateStep, 0.f ); zMsgUsed(); } if( zmsgIs( which, right ) ) { zviewpointRotateTrackball( -zviewpointRotateStep, 0.f ); zMsgUsed(); } } else if( (zmsgIs(type,Key) && zmsgIs(which,wheelforward)) || (zmsgIs(type,Key) && !strcmp(msg->getS("which"),",") ) ) { newzviewpointScale = zviewpointScale * 0.8f; scaleChange = 1; zMsgUsed(); } else if( (zmsgIs(type,Key) && zmsgIs(which,wheelbackward)) || (zmsgIs(type,Key) && !strcmp(msg->getS("which"),".") ) ) { newzviewpointScale = zviewpointScale * 1.2f; scaleChange = 1; zMsgUsed(); } if( scaleChange && zviewpointPermitScale ) { float x = (float)zMouseMsgX; float y = (float)zMouseMsgY; // I want the world coord at which the mouse is pointing before the zoom // to be the same as the world coord at which the mouse is pointing after the zoom // @TODO: convert his mess into a single function DMat4 preScale = zviewpointReferenceModel; DMat4 preScaleMat( scale3D( DVec3(zviewpointScale, zviewpointScale, zviewpointScale) ) ); preScale.cat( preScaleMat ); DVec3 pre0, pre1; gluUnProject( x, y, 0.f, preScale, zviewpointReferenceProj, zviewpointReferenceViewport, &pre0.x, &pre0.y, &pre0.z ); gluUnProject( x, y, 1.f, preScale, zviewpointReferenceProj, zviewpointReferenceViewport, &pre1.x, &pre1.y, &pre1.z ); FVec3 wp0 = zviewpointLinePlaneIntersect( FVec3::Origin, FVec3::ZAxis, FVec3((float)pre0.x,(float)pre0.y,(float)pre0.z), FVec3((float)pre1.x,(float)pre1.y,(float)pre1.z) ); DMat4 postScale = zviewpointReferenceModel; DMat4 postScaleMat = ( scale3D( DVec3(newzviewpointScale, newzviewpointScale, newzviewpointScale) ) ); postScale.cat( postScaleMat ); DVec3 post0, post1; gluUnProject( x, y, 0.f, postScale, zviewpointReferenceProj, zviewpointReferenceViewport, &post0.x, &post0.y, &post0.z ); gluUnProject( x, y, 1.f, postScale, zviewpointReferenceProj, zviewpointReferenceViewport, &post1.x, &post1.y, &post1.z ); FVec3 wp1 = zviewpointLinePlaneIntersect( FVec3::Origin, FVec3::ZAxis, FVec3((float)post0.x,(float)post0.y,(float)post0.z), FVec3((float)post1.x,(float)post1.y,(float)post1.z) ); wp1.sub( wp0 ); zviewpointTrans.add( wp1 ); zviewpointScale = newzviewpointScale; } if( zmsgIs(type,Viewpoint_MouseDrag) ) { if( zmsgI(releaseDrag) ) { zMouseMsgCancelExclusiveDrag(); zviewpointRotating = zviewpointTranslating = 0; } else { if( zviewpointRotating ) { float dx = +0.01f * ( viewpointMouseLast[0] - zmsgF(x) ); float dy = -0.01f * ( viewpointMouseLast[1] - zmsgF(y) ); float side = zmsgI( shift ) ? ( (zmsgF(localX) < zmsgF(w)/2) ? -1.f : 1.f ) : 0.f; // note: the side doesn't really work if the object is being rendered in a ZUI because the // w here refers to the screen, and not the ZUI. zviewpointRotateTrackball( dx, dy, side ); viewpointMouseLast[0] = zmsgF(x); viewpointMouseLast[1] = zmsgF(y); zMsgUsed(); } // else if( zmsgI(r) ) { else if( zviewpointTranslating ) { // COMPUTE how big is one pixel at the world z-plane of interest // For now, this plane normal to the camera and passes-though the origin // Do this by unprojecting rays at the mouse current and last and then // solving for the world position at the intersection of that plane // CAT in tranforms which take place before the translate DMat4 m = zviewpointReferenceModel; DMat4 _m( scale3D( DVec3(zviewpointScale, zviewpointScale, zviewpointScale) ) ); m.cat( _m ); DMat4 _m1( trans3D( DVec3(zviewpointTrans )) ); m.cat( _m1 ); DVec3 p0, p1, p2, p3; gluUnProject( zmsgF(x), zmsgF(y), 0.f, m, zviewpointReferenceProj, zviewpointReferenceViewport, &p0.x, &p0.y, &p0.z ); gluUnProject( zmsgF(x), zmsgF(y), 1.f, m, zviewpointReferenceProj, zviewpointReferenceViewport, &p1.x, &p1.y, &p1.z ); gluUnProject( viewpointMouseLast[0], viewpointMouseLast[1], 0.f, m, zviewpointReferenceProj, zviewpointReferenceViewport, &p2.x, &p2.y, &p2.z ); gluUnProject( viewpointMouseLast[0], viewpointMouseLast[1], 1.f, m, zviewpointReferenceProj, zviewpointReferenceViewport, &p3.x, &p3.y, &p3.z ); FVec3 wp0 = zviewpointLinePlaneIntersect( FVec3::Origin, FVec3::ZAxis, FVec3((float)p0.x,(float)p0.y,(float)p0.z), FVec3((float)p1.x,(float)p1.y,(float)p1.z) ); FVec3 wp1 = zviewpointLinePlaneIntersect( FVec3::Origin, FVec3::ZAxis, FVec3((float)p2.x,(float)p2.y,(float)p2.z), FVec3((float)p3.x,(float)p3.y,(float)p3.z) ); wp0.sub( wp1 ); FVec3 delta( wp0.x, wp0.y, 0.f ); if( zmsgI(shift) ) { delta.x = 0.f; delta.y = 0.f; delta.z = wp0.y * 4.f; } zviewpointTrans.add( delta ); viewpointMouseLast[0] = zmsgF(x); viewpointMouseLast[1] = zmsgF(y); zMsgUsed(); } } } }
unsigned __stdcall MatchThread(void *pParam) { int FLEN; int n = 0, n1, i; dbQuery sql; ControlFlowGraph *target_cfg; db.attach(); dbCursor<LibM> cursor1; int thread_id = (int)pParam; instruction_count[thread_id] = 0; fn[thread_id] = 0; while ((i = GetM()) != -1) { int startEA = f_info[i].startEA; FLEN = f_info[i].len; // disasm byte *bin = (byte *)RvaToPtr(pImageNtH, stMapFile.ImageBase, startEA - pOH->ImageBase); if (bin == NULL) { continue; } target_cfg = (ControlFlowGraph *)disasm(bin, FLEN, false, NULL); if (target_cfg == NULL || target_cfg->instructions.size() < MIN_INS_LENGTH) { clean(target_cfg); continue; } fn[thread_id]++; instruction_count[thread_id] += target_cfg->instructions.size(); target_cfg->build(); { sql = "MOV_COUNT<=", target_cfg->MOV_COUNT, " and CTI_COUNT<=", target_cfg->CTI_COUNT, " and ARITHMETIC_COUNT<=", target_cfg->ARITHMETIC_COUNT, " and LOGI_COUNT<=", target_cfg->LOGI_COUNT, " and STRING_COUNT<=", target_cfg->STRING_COUNT, " and ETC_COUNT<=", target_cfg->ETC_COUNT, " and instruction_size<=", target_cfg->instructions.size(), "and block_size<=", target_cfg->bb_len, "order by instruction_size desc"; } n1 = cursor1.select(sql); if (n1 == 0) { clean(target_cfg); continue; } CBitSet lib_info(target_cfg->instructions.size()); do { ControlFlowGraph *library_cfg = (ControlFlowGraph *)(cursor1->cfg); target_cfg->buildDepGraph(false); library_cfg->buildDepGraph(true); library_cfg->serialize(); library_cfg->buildVLibGraph(); target_cfg->serialize(); target_cfg->buildVLibGraph(); //r0[thread_id]++; Graph _g(&target_cfg->vlibARGEdit); Graph _m(&library_cfg->vlibARGEdit); _m.SetNodeComparator(new InstructionComparator3); VF2SubState s0(&_m, &_g); int d[4]; d[0] = (int)target_cfg; d[1] = startEA; d[2] = (int)cursor1->lib_name; d[3] = (int)&lib_info; Match m(&s0, my_visitor2, &d); m.match_serial(); } while (cursor1.next()); clean(target_cfg); } db.detach(); printf("#%d done.\n", thread_id); return 0; }
// // process thread // unsigned __stdcall MatchThreadForFull(void *pParam) { int FLEN; int n = 0, n1, i; dbQuery sql; ControlFlowGraph *target_cfg; db.attach(); dbCursor<LibM> cursor1; int thread_id = (int)pParam; instruction_count[thread_id] = 0; fn[thread_id] = 0; while ((i = GetM()) != -1) { int startEA = f_info[i].startEA; FLEN = f_info[i].len; // disasm byte *bin = (byte *)RvaToPtr(pImageNtH, stMapFile.ImageBase, startEA - pOH->ImageBase); if (bin == NULL) { continue; } target_cfg = (ControlFlowGraph *)disasm(bin, FLEN, false, NULL); if (target_cfg == NULL || target_cfg->instructions.size() < MIN_INS_LENGTH) { clean(target_cfg); continue; } fn[thread_id]++; instruction_count[thread_id] += target_cfg->instructions.size(); target_cfg->build(); { sql = "MOV_COUNT=", target_cfg->MOV_COUNT, " and CTI_COUNT=", target_cfg->CTI_COUNT, " and ARITHMETIC_COUNT=", target_cfg->ARITHMETIC_COUNT, " and LOGI_COUNT=", target_cfg->LOGI_COUNT, " and STRING_COUNT=", target_cfg->STRING_COUNT, " and ETC_COUNT=", target_cfg->ETC_COUNT, " and instruction_size=", target_cfg->instructions.size(), "and block_size=", target_cfg->bb_len, "order by instruction_size desc"; } n1 = cursor1.select(sql); if (n1 == 0) { clean(target_cfg); continue; } CBitSet lib_info(target_cfg->instructions.size()); do { ControlFlowGraph *library_cfg = (ControlFlowGraph *)(cursor1->cfg); // BBLR bitset<10240> t = target_cfg->bblen_set; t.flip(); t &= library_cfg->bblen_set; if (t.any()) { continue; } target_cfg->buildDepGraph(false); library_cfg->buildDepGraph(true); //if (bSerialize) { // rule5: BBSR if (!matchBBSF(target_cfg, library_cfg)) { //r5[thread_id]++; continue; } } library_cfg->serialize(); library_cfg->buildVLibGraph(); target_cfg->serialize(); target_cfg->buildVLibGraph(); //r0[thread_id]++; Graph _g(&target_cfg->vlibARGEdit); Graph _m(&library_cfg->vlibARGEdit); _m.SetNodeComparator(new InstructionComparator3); VF2SubState s0(&_m, &_g); Match m(&s0, my_visitor1, &lib_info); m.match_par(); if (m.foundFlg) { printf("%d\t1\t%X\t%s\n", thread_id, startEA, cursor1->lib_name); } } while (cursor1.next()); clean(target_cfg); } db.detach(); printf("#%d done.\n", thread_id); return 0; }
shared_ptr<tnmmatrix<TYPE> > tOLS<TYPE>::GetB() { if (B) { return B; } this->misc.clear(); TYPE minDeterminant = _typeOpt::read(this->options.get(), "minDeterminant"); bool _DB_PRINT_DET = _boolOpt::read(this->options.get(), "_DB_PRINT_DET"); bool _DB_PRINT_XTX = _boolOpt::read(this->options.get(), "_DB_PRINT_XTX"); int MM = this->GetX()->GetCols(); int NN = this->GetX()->GetRows(); int KK = this->GetK(); TYPE rcond; TYPE det; _m Xtrp(MM,NN); _m Qinv(MM,MM); _m Xtrpyvec(MM,KK); _m I(NN,NN); B.reset(new _m(MM,KK)); _mVec bCov; _m matrixM(NN,NN); _m e(NN,KK); _m eTrp(KK,NN); _m s2(KK,KK); TYPE cond = 0; I.I(); if ( MM > 0 ) { // tMathTools<TYPE>::PrintMatrix( std::cout , X , 6 , "" , "" , "X: " ); // std::cout << std::flush; this->GetX()->Trp( &Xtrp ); Qinv.Mul( Xtrp , *this->GetX() ); if (_DB_PRINT_XTX) tMathTools<TYPE>::PrintMatrix( std::cout , Qinv , 6 , "" , "" , "X'X: " ); try { if ( minDeterminant >= 0 ) { det = Qinv.Det(); if (_DB_PRINT_DET ) std::cout << "|X'X| = " << det << std::endl << std::flush; if ( det <= minDeterminant ) throw aException(tOLS<TYPE>, "X'X is singular."); } Qinv.Inv( &rcond ); } catch ( ... ) { throw aException(tOLS<TYPE>, "Inversion failed!"); }; assert( rcond != 0.0 ); cond = 1.0 / rcond; Xtrpyvec.Mul( Xtrp , *this->GetY() ); B->Mul(Qinv , Xtrpyvec); matrixM = I - (*this->GetX()) * Qinv * Xtrp; e = matrixM * (*this->GetY()); e.Trp( &eTrp ); s2 = (TYPE)( 1.0 / ( NN - MM ) ) * eTrp * e; for ( int col = 1 ; col <= KK ; col++ ) { bCov.emplace_back(s2(col,col) * Qinv); } } else B->Cpy(0.0); //Relay non standard fit data to owner this->misc["e"] = _mVec(1, e); this->misc["s2"] = _mVec(1, s2); this->misc["determinant"] = _mVec(1, _m(1,1,det)); this->misc["conditionNumber"] = _mVec(1, _m(1,1,cond)); this->misc["bCov"] = _mVec(bCov); return B; }
void modify(int t, int l, int r) { return _m(t, l, r, 1, n); }
// checks the T0A0 flags and sets T0A0 interrupt flag to true void MSP430::runTimer0(bool is_mclk) { // Queue local variables to save operations unsigned int TA0CTL_ = _m16(TA0CTL); unsigned int TA0CCTL0_ = _m16(TA0CCTL0); unsigned int TA0CCTL1_ = _m16(TA0CCTL1); unsigned int TA0CCTL2_ = _m16(TA0CCTL2); unsigned int TA0CCR0_ = _m16(TA0CCR0); unsigned int TA0CCR1_ = _m16(TA0CCR1); unsigned int TA0CCR2_ = _m16(TA0CCR2); unsigned int TA0R_ = _m16(TA0R); int clkSelect = (TA0CTL_ & 0x50|0x60) >> 8; // test for mclk or smclk (based on input bool variable) // test using TASSELx if((is_mclk && (clkSelect==0)) || // TACLK == mclk (!is_mclk && (clkSelect==2)) ) { // SMCLK // if IDx bit set, Divide by 2^n (1/2/4/8) int clkDiv = (TA0CTL_ & 0x30|0x40) >> 6; const int MCx = (TA0CTL_ & 0x10|0x20) >> 4; // Test for MCx >= 1 (1 for 0->TACCR0, 2 for 0->0FFFF, 3 for 0->TACCR0->0) if(MCx > 0) { switch(MCx) { case 1: // up to TACCR0 mode TA0R_ = (TA0R_ >= TA0CCR0_) ? 0 : TA0R_+1; _setTo16Value1(TA0R, TA0R_); break; case 2: // up to 0xffff (continuous) mode TA0R_ = (TA0R_ >= 0xFFFF) ? 0 : TA0R_+1; _setTo16Value1(TA0R, TA0R_); break; case 3: // up/down mode TA0R_ = (T0_up) ? TA0R_+1 : TA0R_-1; _setTo16Value1(TA0R, TA0R_); T0_up = (TA0R_ >= TA0CCR0_ || TA0R_ <= 0) ? ~T0_up : T0_up; break; } // test A0 CCR0 (Basic set) // test capture or compare if(!(TA0CCTL0_ & CAP)) { // compare mode // if compare, just compare TACCR0 with TA0R if(TA0R_ >= TACCR0_) { // interrupt enabled? if(TA0CCTL0_ & CCIE) { TA0CCTL0_ |= CCIFG; // interrupt! } // Output pins: // TA0.0 p1.1, p1.5 // TA0.1 // TA0.2 // if Output Mode (OUTMODx) is used // if OUTMODx == 00, then OUT is used instead of timer output... switch((TA0CCTL0_ & 0x20|0x30|0x40) >> 5) { case 0: _m(P1OUT) = TA0CCTL0_ & OUT; // direct output mode (follower) break; case 1: _m(P1OUT) |= BIT5; // set break; case 2: _m(P1OUT) ^= BIT5; // toggle on TACCRx / reset on TACCR0 break; case 3: _m(P1OUT) ^= BIT5; // set on TACCRx / reset on TACCR0 break; case 4: _m(P1OUT) ^= BIT5; // toggle break; case 5: _m(P1OUT) &= ~BIT5; // reset break; case 6: _m(P1OUT) ^= ~BIT5; // toggle on TACCRx / set on TACCR0 break; case 7: _m(P1OUT) ^= ~BIT5; // toggle on TACCRx / set on TACCR0 break; } } } else { // capture mode } // test A1 CCR1 // test A3 CCR2 }