void far *allocDOS (unsigned nbytes, short *pseg, short *psel) { unsigned npara = (nbytes + 15) / 16; void far *pprot; pprot = NULL; *pseg = 0; // assume will fail *psel = 0; // DPMI call 100h allocates DOS memory segread (&sregs); AX (regs) = 0x0100; // DPMI: Allocate DOS Memory BX (regs) = npara; // number of paragraphs to alloc int386( DPMI_INT, ®s, ®s); if (regs.w.cflag == 0) { *pseg = AX (regs); // the real-mode segment *psel = DX (regs); // equivalent protected-mode selector // pprot is the protected mode address of the same allocated block. // The Rational extender maps the 1 MB physical DOS memory into // the bottom of our virtual address space. pprot = (void far *) ((unsigned)*pseg << 4); } return pprot; }
void freeDOS (short sel) { AX(regs) = 0x0101; // DPMI free DOS memory DX(regs) = sel; int386( DPMI_INT, ®s, ®s); }
void expand_8bits(void *cpr, void *cpi, void *apr, void *api, mxComplexity complexity) { bit8 *Cpr = (bit8 *) cpr; bit8 *Cpi = (bit8 *) cpi; bit8 *Apr = (bit8 *) apr; bit8 *Api = (bit8 *) api; if( complexity == mxCOMPLEX ) { for( i12=0; i12<k12; i12++ ) for( i11=0; i11<k11; i11++ ) for( i10=0; i10<k10; i10++ ) for( i9=0; i9<k9; i9++ ) for( i8=0; i8<k8; i8++ ) for( i7=0; i7<k7; i7++ ) for( i6=0; i6<k6; i6++ ) for( i5=0; i5<k5; i5++ ) for( i4=0; i4<k4; i4++ ) for( i3=0; i3<k3; i3++ ) for( i2=0; i2<k2; i2++ ) for( i1=0; i1<k1; i1++ ) { *Cpr++ = AX(Apr,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12); *Cpi++ = AX(Api,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12); } } else { for( i12=0; i12<k12; i12++ ) for( i11=0; i11<k11; i11++ ) for( i10=0; i10<k10; i10++ ) for( i9=0; i9<k9; i9++ ) for( i8=0; i8<k8; i8++ ) for( i7=0; i7<k7; i7++ ) for( i6=0; i6<k6; i6++ ) for( i5=0; i5<k5; i5++ ) for( i4=0; i4<k4; i4++ ) for( i3=0; i3<k3; i3++ ) for( i2=0; i2<k2; i2++ ) for( i1=0; i1<k1; i1++ ) { *Cpr++ = AX(Apr,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12); } } }
void MouseInt (struct rminfo *prmi) { memset (&sregs, 0, sizeof (sregs)); AX (regs) = 0x0300; // DPMI: simulate interrupt BX (regs) = MOUSE_INT; CX (regs) = 0; DI (regs) = FP_OFF (prmi); sregs.es = FP_SEG (prmi); int386x( DPMI_INT, ®s, ®s, &sregs ); }
/* http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/lookat.html http://msdn.microsoft.com/en-us/library/bb205343.aspx */ void RMtx4LookAtRH( RMtx4* out, const RVec3* eye, const RVec3* at, const RVec3* up ) { #define AX(i) RVec3GetElement( &axis_x, i ) #define AY(i) RVec3GetElement( &axis_y, i ) #define AZ(i) RVec3GetElement( &axis_z, i ) RVec3 axis_x, axis_y, axis_z; RMtx4Identity( out ); RVec3Sub( &axis_z, eye, at ); RVec3Normalize( &axis_z, &axis_z ); RVec3Cross( &axis_x, up, &axis_z ); RVec3Normalize( &axis_x, &axis_x ); RVec3Cross( &axis_y, &axis_z, &axis_x ); SET_ELEMENT( out, 0, 0, AX(0) ); SET_ELEMENT( out, 0, 1, AX(1) ); SET_ELEMENT( out, 0, 2, AX(2) ); SET_ELEMENT( out, 0, 3, -RVec3Dot(&axis_x, eye) ); SET_ELEMENT( out, 1, 0, AY(0) ); SET_ELEMENT( out, 1, 1, AY(1) ); SET_ELEMENT( out, 1, 2, AY(2) ); SET_ELEMENT( out, 1, 3, -RVec3Dot(&axis_y, eye) ); SET_ELEMENT( out, 2, 0, AZ(0) ); SET_ELEMENT( out, 2, 1, AZ(1) ); SET_ELEMENT( out, 2, 2, AZ(2) ); SET_ELEMENT( out, 2, 3, -RVec3Dot(&axis_z, eye) ); #undef AX #undef AY #undef AZ }
int AmesosBucklingOp::Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y ) const { // Storage for A*X Epetra_MultiVector AX(X.Map(),X.NumVectors()); // Apply A*X stiffMtx_->Apply(X, AX); Y.PutScalar(0.0); // Set the LHS and RHS problem_->SetRHS(&AX); problem_->SetLHS(&Y); // Solve the linear system (A-sigma*M)*Y = AX solver_->Solve(); return 0; }
cv::Mat_<int> cModel::__lbf_fast(const cv::Mat_<uchar>&img, const cv::Rect& bbox, const cv::Mat_<float>& shape,int markID, int stage) { int max_stage = m_Model.__head.__num_stage; int num_node = m_Model.__head.__num_leaf + m_Model.__head.__num_node; int num_point = m_Model.__head.__num_point; int num_tree_per_point = m_Model.__head.__num_tree_per_point; int num_leaf = m_Model.__head.__num_leaf; m_AX[stage].row(markID) *= bbox.width; m_AY[stage].row(markID) *= bbox.height; m_BX[stage].row(markID) *= bbox.width; m_BY[stage].row(markID) *= bbox.height; m_AX[stage].row(markID) += shape(markID, 0); m_AY[stage].row(markID) += shape(markID, 1); m_BX[stage].row(markID) += shape(markID, 0); m_BY[stage].row(markID) += shape(markID, 1); cv::Mat_<int> cind = cv::Mat::ones(m_AX[stage].cols, 1, CV_32SC1); cv::Mat_<float> AX = m_AX[stage].row(markID); cv::Mat_<float> AY = m_AY[stage].row(markID); cv::Mat_<float> BX = m_BX[stage].row(markID); cv::Mat_<float> BY = m_BY[stage].row(markID); cv::Mat_<float> Thresh = m_Thresh[stage].row(markID); int width = img.cols; int height = img.rows; for (int j = 0; j < AX.cols; j += num_node){ for (int index = 0; index < m_Model.__head.__num_node; index++){ int pos = j + index; int a_x = (int)(AX(0, pos) + 0.5); int a_y = (int)(AY(0, pos) + 0.5); int b_x = (int)(BX(0, pos) + 0.5); int b_y = (int)(BY(0, pos) + 0.5); a_x = MAX(0, MIN(a_x, width - 1)); a_y = MAX(0, MIN(a_y, height - 1)); b_x = MAX(0, MIN(b_x, width - 1)); b_y = MAX(0, MIN(b_y, height - 1)); float pixel_v_a = (float)img(cv::Point(a_x, a_y)); float pixel_v_b = (float)img(cv::Point(b_x, b_y)); float val = pixel_v_a - pixel_v_b; if (val < (float)Thresh(0, pos)){ cind(pos, 0) = 0; } } } cv::Mat_<int> binfeature = cv::Mat::zeros(1, (int)cv::sum(m_Isleaf).val[0], CV_32SC1); int cumnum_nodes = 0; int cumnum_leafnodes = 0; for (int t = 0; t < num_tree_per_point; t++){ int id_cnode = 0; while (1){ if (m_Isleaf(id_cnode + cumnum_nodes)){ binfeature(0, cumnum_leafnodes + __getindex(m_Idleafnodes, id_cnode)) = 1; cumnum_nodes = cumnum_nodes + num_node; cumnum_leafnodes = cumnum_leafnodes + num_leaf; break; } id_cnode = m_Cnodes(cumnum_nodes + id_cnode, cind(cumnum_nodes + id_cnode, 0)); } } return binfeature; }
void Workspace<EncodingT>::loadXML(DOMElement* xml_wrks) { DOMElement* xml_file = NULL; DOMText* xml_text = NULL; DOMNodeList* xml_list = NULL; if (!xml_wrks || string("Workspace") != A(xml_wrks->getTagName())) { m_logger->fatalStream() << "Workspace::loadXML() : XML workspace element expected"; //throw BadXmlFormatException("XML entity element expected"); } else { m_name = C(xml_wrks->getAttribute( AX("Name") )); m_author = C(xml_wrks->getAttribute( AX("Author") )); m_brief = C(xml_wrks->getAttribute( AX("Brief") )); m_version = C(xml_wrks->getAttribute( AX("Version") )); m_type = (A(xml_wrks->getAttribute( AX("Type") ))==string("File"))?WRK_FILE:WRK_PROJECT; m_option = ToInt::parse(A(xml_wrks->getAttribute( AX("Option") ))); m_comment = EncodingT::EMPTY; m_files.clear(); if (xml_wrks->hasChildNodes()) { xml_list = xml_wrks->getChildNodes(); for (unsigned int i=0; i<xml_list->getLength(); ++i) { xml_file = (DOMElement*) xml_list->item(i); if (xml_file && string("File") == A(xml_file->getTagName())) { File<EncodingT> fi; fi.loadXML(xml_file); m_files.push_back(fi); } if (xml_file && string("Comments") == A(xml_file->getTagName())) { try { xml_text = (DOMText*) xml_file->getFirstChild(); if (xml_text) { m_comment = C(xml_text->getData()); } } catch(DOMException & e) { m_logger->fatalStream() << "Workspace::loadXML() : XML wrk comments element error: " << A(e.getMessage()); //throw e; } } } } // Add wokspace file if it is not defined. if (m_type==WRK_FILE && (m_files.empty() || sizeFiles() != 1 || beginFiles()->getName() != getName())) { openFile(getName(), true); } m_logger->debugStream() << "set workspace : " << encode<EncodingT,ansi>(m_name) << ", " << encode<EncodingT,ansi>(m_comment); m_logger->debug("Workspace::loadXML() : XML workspace loaded"); } }
DOMNode* Workspace<EncodingT>::saveXML(DOMDocument* xml_doc) const { DOMElement* xml_wrks = NULL; DOMNode* xml_comment = NULL; DOMText* xml_text = NULL; try { xml_wrks = xml_doc->createElement( AX("Workspace") ); xml_wrks->setAttribute( AX("Name"), CX(m_name) ); xml_wrks->setAttribute( AX("Author"), CX(m_author) ); xml_wrks->setAttribute( AX("Brief"), CX(m_brief) ); xml_wrks->setAttribute( AX("Version"), CX(m_version) ); xml_wrks->setAttribute( AX("Type"), (m_type==WRK_FILE)?AX("File"):AX("Project") ); xml_wrks->setAttribute( AX("Option"), AX(ToString::parse(m_option))); if (hasComment()) { xml_comment = xml_doc->createElement( AX("Comments") ); xml_wrks->appendChild(xml_comment); xml_text = xml_doc->createTextNode( CX(m_comment) ); xml_comment->appendChild(xml_text); } for (const_file_iterator ite = beginFiles(); ite != endFiles(); ++ite) { xml_wrks->appendChild(ite->saveXML(xml_doc)); } m_logger->debug("Workspace::saveXML() : XML workspace saved"); } catch ( const DOMException& e ) { m_logger->fatalStream() << "Workspace::saveXML() : XML workspace save error: " << A(e.getMessage()); //throw e; } return xml_wrks; }
int SWIFT_Initialize (void) { SWIFT_StaticData sdBuf; int fSwift = 0; if (fActive) // SWIFT extensions already active { #ifdef DEGUB SoftError( "SWIFT_Initialize: Already active.\n"); SoftError( "SWIFT_Initialize: returns TRUE\n"); #endif return (1); } nAttached = SWIFT_DEV_NONE; if (_dos_getvect(0x33) == NULL) // No mouse driver loaded { #ifdef DBUG SoftError( "SWIFT_Initialize: No mouse driver loaded.\n"); SoftError( "SWIFT_Initialize: returns FALSE\n"); #endif return (0); } // Reset the mouse and driver AX (regs) = 0; int386( 0x33, ®s, ®s); if (AX (regs) == 0) { // no mouse #ifdef DBUG SoftError( "SWIFT_Initialize: No pointing device attached.\n"); SoftError( "SWIFT_Initialize: returns FALSE\n"); #endif return (0); } #ifdef DBUG AX (regs) = 36; // Get Mouse Information BX (regs) = 0xffff; CX (regs) = 0xffff; DX (regs) = 0xffff; int386 (0x33, ®s, ®s); SoftError( "SWIFT_Initialize: driver version %d.%02d\n", regs.h.bh, regs.h.bl); SoftError( "SWIFT_Initialize: %s mouse using IRQ %d\n", (regs.h.ch==1) ? "bus" : (regs.h.ch==2) ? "serial" : (regs.h.ch==3) ? "inport" : (regs.h.ch==4) ? "PS/2" : "unknown", regs.h.cl); #endif // allocate a DOS real-mode buffer pdosmem = allocDOS(DOSMEMSIZE, &segment, &selector); if (!pdosmem) { #ifdef DBUG SoftError( "SWIFT_Initialize: DOS Alloc failed!\n"); SoftError( "SWIFT_Initialize: returns FALSE\n"); #endif return (0); } // // SWIFT device supported and attached // if (SWIFT_GetStaticDeviceInfo (&sdBuf)) fSwift = 1; if (!fSwift) { // SWIFT functions not present #ifdef DBUG SoftError( "SWIFT_Initialize: no SWIFT support in mouse driver.\n"); #endif } else if (sdBuf.deviceType == SWIFT_DEV_NONE) { #ifdef DBUG SoftError( "SWIFT_Initialize: no SWIFT device connected.\n"); #endif } else { nAttached = sdBuf.deviceType; #ifdef DBUG SoftError( "SWIFT_Initialize: "); switch (nAttached) { case SWIFT_DEV_CYBERMAN: SoftError( "CyberMan %d.%02d connected.\n", sdBuf.majorVersion, sdBuf.minorVersion); break; default: SoftError( "Unknown SWIFT device (type %d) connected.\n", nAttached); break; } #endif fActive = 1; } if (!fActive) { // activation of SWIFT module failed for some reason if (pdosmem) { // if DOS buffer was allocated, free it freeDOS(selector); pdosmem = 0; } } #ifdef DBUG SoftError( "SWIFT_Initialize: returns %s.\n", (fActive ? "TRUE" : "FALSE")); #endif return fActive; }