void vctDeterminantTest::TestDeterminant2x2ByInverse(const vctFixedSizeMatrix<ElementType, 2, 2> & inputMatrix) { const ElementType determinant = vctDeterminant<2>::Compute(inputMatrix); const ElementType tolerance = cmnTypeTraits<ElementType>::Tolerance(); if (fabs(determinant) < tolerance) { vctFixedSizeVector<ElementType, 2> rowRatio; rowRatio.ElementwiseRatioOf( inputMatrix.Row(0), inputMatrix.Row(1) ); CPPUNIT_ASSERT_DOUBLES_EQUAL( rowRatio[0], rowRatio[1], tolerance ); vctFixedSizeVector<ElementType, 2> columnRatio; columnRatio.ElementwiseRatioOf( inputMatrix.Column(0), inputMatrix.Column(1) ); CPPUNIT_ASSERT_DOUBLES_EQUAL( columnRatio[0], columnRatio[1], tolerance ); return; } const vctFixedSizeMatrix<ElementType, 2, 2> inverse( inputMatrix[1][1] / determinant, -inputMatrix[0][1] / determinant, -inputMatrix[1][0] / determinant, inputMatrix[0][0] / determinant ); /* gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 crashes with internal error on ubuntu 64 - Ubuntu 10.04.1 LTS with const */ /* const */ vctFixedSizeMatrix<ElementType, 2, 2> product( inputMatrix * inverse ); const vctFixedSizeMatrix<ElementType, 2, 2> identity( ElementType(1), ElementType(0), ElementType(0), ElementType(1) ); const vctFixedSizeMatrix<ElementType, 2, 2> difference = product - identity; ElementType diffNorm = difference.Norm(); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, diffNorm, tolerance ); }
MatrixX<ElementType> projective_transform( const MatrixX<ElementType>& image, const Matrix33d& transform, const ElementType fill_value = ElementType(0)) { // 1. Figure out sizes of new matrix auto c0 = homogenize(transform * Vector3d{-0.5, -0.5, 1}); auto c1 = homogenize(transform * Vector3d{-0.5, image.dims[0] - 0.5, 1}); auto c2 = homogenize(transform * Vector3d{image.dims[1] - 0.5, -0.5, 1}); auto c3 = homogenize(transform * Vector3d{image.dims[1] - 0.5, image.dims[0] - 0.5, 1}); // Raise or lower values as needed auto xs = Vector4d{c0[0], c1[0], c2[0], c3[0]}; auto ys = Vector4d{c0[1], c1[1], c2[1], c3[1]}; // Create new matrix Matrix33d inverse = inv(transform); MatrixX<ElementType> new_image(int32_t(ys.max() - ys.min()), int32_t(xs.max() - xs.min())); // Do interpolation for each output pixel Interpolator interp; for (int32_t i = 0; i < new_image.dims[0]; ++i) { for (int32_t j = 0; j < new_image.dims[1]; ++j) { Vector3d uv{j + xs.min(), i + ys.min(), 1}; Vector3d xy = homogenize(inverse * uv); new_image(i, j) = interp(image, xy[0], xy[1], fill_value); } } return new_image; }
// --------------------------------------------------------------------------- // CMMCScBkupReadDataTransferRequestBase::ProcessChunkOfDataL() // // // --------------------------------------------------------------------------- TBool CMMCScBkupReadDataTransferRequestBase::ProcessChunkOfDataL() { __ASSERT_ALWAYS( iCurrentIndex >= 0, User::Invariant() ); TBool callAgain = EFalse; // Do we need to move to the next entry? TBool entryAvailable = ( iCurrentIndex < iEntries->Count() ); if ( entryAvailable ) { // At least one more entry left to process.. but have we finished // the current entry? If we've read all the data, then the // answer is yes... const TMMCScBkupArchiveDriveAndVector& entry = (*iEntries)[ iCurrentIndex ]; const TInt endOffset = entry.iVector.EndOffset(); #ifdef __MMCSCBKUPLOGGING_ENABLED__ if ( ElementType() == EMMCScBkupOwnerDataTypeJavaData ) { HBufC* hash = MMCScBkupSBEUtils::JavaHashFromGenericLC( DataOwner().Owner().Identifier() ); __LOG6("CMMCScBkupReadDataTransferRequestBase::ProcessChunkOfDataL() - START - JavaHash: %S, ElementType: %S, offset: %8d, length: %8d, endOffset: %8d, drive: %c:", hash, &MMCScBkupLogger::DataType( ElementType() ), entry.iVector.Offset(), entry.iVector.Length(), endOffset, entry.iDrive + 'A' ); CleanupStack::PopAndDestroy( hash ); } else { __LOG6("CMMCScBkupReadDataTransferRequestBase::ProcessChunkOfDataL() - START - DO: 0x%08x, ElementType: %S, offset: %8d, length: %8d, endOffset: %8d, drive: %c:", DataOwner().SecureId().iId, &MMCScBkupLogger::DataType( ElementType() ), entry.iVector.Offset(), entry.iVector.Length(), endOffset, entry.iDrive + 'A' ); } #endif // Check bounds if ( CurrentOffset() < 0 || CurrentOffset() > endOffset ) { ASSERT( EFalse ); User::Leave( KErrCorrupt ); } // if ( iCurrentOffset == endOffset ) { // We're done with this entry - move to the next entryAvailable = PrepareForNextEntry(); } } // if ( entryAvailable ) { // We need to read more archive data in order to transfer this // entry to the SBE callAgain = DoProcessChunkOfDataL(); } else { // No more left to process - we're finished! SetState( EFinished ); CompleteSelf(); } // return callAgain; }
Ms::Element* QmlPlugin::newElement(int t) { Score* score = curScore(); if (score == 0) return 0; Element* e = Element::create(ElementType(t), score); Ms::MScore::qml()->setObjectOwnership(e, QQmlEngine::CppOwnership); return e; }
boost::shared_ptr<std::vector<joblist::ElementType> > Joiner::getSmallSide() { boost::shared_ptr<vector<ElementType> > ret; iterator it; ret.reset(new vector<ElementType>()); for (it = begin(); it != end(); ++it) ret->push_back(ElementType(it->second & ~MSB, it->first)); return ret; }
boost::shared_ptr<vector<ElementType> > Joiner::getSortedMatches() { boost::shared_ptr<vector<ElementType> > ret; iterator it; ret.reset(new vector<ElementType>()); for (it = begin(); it != end(); ++it) if (it->second & MSB) ret->push_back(ElementType(it->second & ~MSB, it->first)); sort<vector<ElementType>::iterator>(ret->begin(), ret->end()); return ret; }
void CMMCScBkupReadDataTransferRequestBase::DumpTransferDataL( RFs& aFsSession, const TDesC8& aData ) const { TPtrC subDirectory( KNullDesC ); // switch( ElementType() ) { case EMMCScBkupOwnerDataTypeJavaData: subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataJava); break; case EMMCScBkupOwnerDataTypeSystemData: subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataSystem); break; case EMMCScBkupOwnerDataTypePassiveData: subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataPassive); break; case EMMCScBkupOwnerDataTypeActiveData: subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataActive); break; default: User::Leave( KErrNotSupported ); break; } // const TSecureId secureId = DataOwner().SecureId(); _LIT(KMMCScBkupFormatDes, "%S%S"); TFileName transferDumpFileName; const TDesC& path = PathInfo::MemoryCardRootPath(); transferDumpFileName.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot); transferDumpFileName.Append( subDirectory ); transferDumpFileName.Append( KMMCScBkupDataTransferDebuggingPathDataRestore ); transferDumpFileName.AppendFormat( KMMCScBkupDataTransferDebuggingFileName, secureId.iId, 'a' + CurrentDrive() ); // RFile64 file; TInt error = KErrNone; TEntry entry; if ( aFsSession.Entry( transferDumpFileName, entry ) == KErrNone ) { // Already exists - append data error = file.Open( aFsSession, transferDumpFileName, EFileWrite | EFileStream | EFileShareExclusive ); } else { entry.iSize = 0; error = file.Create( aFsSession, transferDumpFileName, EFileWrite | EFileStream | EFileShareExclusive ); } // User::LeaveIfError( error ); CleanupClosePushL( file ); error = file.Write( entry.iSize, aData ); CleanupStack::PopAndDestroy( &file ); }
void vctDeterminantTest::TestDeterminant2x2ByLinearCombination(const vctFixedSizeVector<ElementType, 2> & row0) { const ElementType tolerance = cmnTypeTraits<ElementType>::Tolerance(); const vctFixedSizeVector<ElementType, 2> row1 = ElementType(2) * row0; const vctFixedSizeMatrix<ElementType, 2, 2> matrix2x2( row0[0], row0[1], row1[0], row1[1] ); const ElementType determinant = vctDeterminant<2>::Compute(matrix2x2); CPPUNIT_ASSERT_DOUBLES_EQUAL(0, determinant, tolerance); TestDeterminant2x2ByInverse( matrix2x2 ); }
ARingZZpFFPACK::ElementType ARingZZpFFPACK::computeGenerator() const { for (UTT currIntElem=2; currIntElem < mCharac; currIntElem++) { ElementType currElem; set_from_int(currElem, currIntElem); bool found = true; ElementType tmpElem = currElem; for (UTT count=0;count < mCharac-2; count++) { mult(tmpElem, tmpElem, currElem); if (is_equal(currElem, tmpElem)) found = false; } if (found) { std::cerr << "generator = " << currElem << std::endl; return currElem; } } M2_ASSERT(false); // we should not get here, if the program logic is OK return ElementType(1); }
// --------------------------------------------------------------------------- // CMMCScBkupReadDataTransferRequestBase::RequestL() // // // --------------------------------------------------------------------------- void CMMCScBkupReadDataTransferRequestBase::RequestL( CMMCScBkupDataOwnerInfo& aOwner, TRequestStatus& aObserver, const RArray<TMMCScBkupArchiveDriveAndVector>& aEntries ) { #ifdef __MMCSCBKUPLOGGING_ENABLED__ if ( ElementType() == EMMCScBkupOwnerDataTypeJavaData ) { HBufC* hash = MMCScBkupSBEUtils::JavaHashFromGenericLC( aOwner.Owner().Identifier() ); __LOG2("CMMCScBkupReadDataTransferRequestBase::RequestL() - START - reading data from SBE for JavaHash: %S, ElementType: %S", hash, &MMCScBkupLogger::DataType( ElementType() )); CleanupStack::PopAndDestroy( hash ); } else { __LOG2("CMMCScBkupReadDataTransferRequestBase::RequestL() - START - reading data from SBE for DO: 0x%08x, ElementType: %S", aOwner.SecureId().iId, &MMCScBkupLogger::DataType( ElementType() )); } #endif CMMCScBkupTransferRequestBase::RequestL( aOwner, aObserver ); // if ( !iTemporaryTransferSink ) { iTemporaryTransferSink = HBufC8::NewL( iReadChunkSize ); } // iEntries = &aEntries; iCurrentIndex = -1; // Increased by one in PrepareForNextEntry // TState nextState = EProcessData; const TBool entryAvailable = PrepareForNextEntry(); if ( !entryAvailable ) { nextState = EFinished; } // SetState( nextState ); CompleteSelf(); __LOG1("CMMCScBkupReadDataTransferRequestBase::RequestL() - END - nextState: %d", nextState); }
template <class ElementType> ElementType A<ElementType>::get() const { return ElementType(0); }
QueryAttributes::ElementType QueryAttributes::GetElementType() const { return ElementType(elementType); }
void QueryAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("QueryAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("name")) != 0) SetName(node->AsString()); if((node = searchNode->GetNode("variables")) != 0) SetVariables(node->AsStringVector()); if((node = searchNode->GetNode("resultsMessage")) != 0) SetResultsMessage(node->AsString()); if((node = searchNode->GetNode("worldPoint")) != 0) SetWorldPoint(node->AsDoubleArray()); if((node = searchNode->GetNode("domain")) != 0) SetDomain(node->AsInt()); if((node = searchNode->GetNode("element")) != 0) SetElement(node->AsInt()); if((node = searchNode->GetNode("resultsValue")) != 0) SetResultsValue(node->AsDoubleVector()); if((node = searchNode->GetNode("elementType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetElementType(ElementType(ival)); } else if(node->GetNodeType() == STRING_NODE) { ElementType value; if(ElementType_FromString(node->AsString(), value)) SetElementType(value); } } if((node = searchNode->GetNode("timeStep")) != 0) SetTimeStep(node->AsInt()); if((node = searchNode->GetNode("varTypes")) != 0) SetVarTypes(node->AsIntVector()); if((node = searchNode->GetNode("dataType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetDataType(DataType(ival)); } else if(node->GetNodeType() == STRING_NODE) { DataType value; if(DataType_FromString(node->AsString(), value)) SetDataType(value); } } if((node = searchNode->GetNode("pipeIndex")) != 0) SetPipeIndex(node->AsInt()); if((node = searchNode->GetNode("useGlobalId")) != 0) SetUseGlobalId(node->AsBool()); if((node = searchNode->GetNode("xUnits")) != 0) SetXUnits(node->AsString()); if((node = searchNode->GetNode("yUnits")) != 0) SetYUnits(node->AsString()); if((node = searchNode->GetNode("darg1")) != 0) SetDarg1(node->AsDoubleVector()); if((node = searchNode->GetNode("darg2")) != 0) SetDarg2(node->AsDoubleVector()); if((node = searchNode->GetNode("floatFormat")) != 0) SetFloatFormat(node->AsString()); if((node = searchNode->GetNode("xmlResult")) != 0) SetXmlResult(node->AsString()); }
QList<QDomElement> Entry::unhandledElements() const { // TODO: do not hardcode this list here QList<ElementType> handled; handled.append(ElementType(QLatin1String("author"), atom1Namespace())); handled.append(ElementType(QLatin1String("contributor"), atom1Namespace())); handled.append(ElementType(QLatin1String("category"), atom1Namespace())); handled.append(ElementType(QLatin1String("id"), atom1Namespace())); handled.append(ElementType(QLatin1String("link"), atom1Namespace())); handled.append(ElementType(QLatin1String("rights"), atom1Namespace())); handled.append(ElementType(QLatin1String("source"), atom1Namespace())); handled.append(ElementType(QLatin1String("published"), atom1Namespace())); handled.append(ElementType(QLatin1String("updated"), atom1Namespace())); handled.append(ElementType(QLatin1String("summary"), atom1Namespace())); handled.append(ElementType(QLatin1String("title"), atom1Namespace())); handled.append(ElementType(QLatin1String("content"), atom1Namespace())); QList<QDomElement> notHandled; QDomNodeList children = element().childNodes(); for (int i = 0; i < children.size(); ++i) { QDomElement el = children.at(i).toElement(); if (!el.isNull() && !handled.contains(ElementType(el.localName(), el.namespaceURI()))) { notHandled.append(el); } } return notHandled; }
void DecodeISDNMessage(ofstream f, CString message ) { sGlobalDefs gvars; gvars.GlobalCallReference = false; bool decodeOk = true; int bi=0; message.TrimLeft(); message.TrimRight(); BYTE Protocol=0; try { Protocol=GetByte(message,bi++); SetFont(f,ElementType(0,IE_PROTOCOL_DISCRIMINATOR)); decodeOk=DecodeProtocol(f,INDENT_SIZE,Protocol); f<<eFont; f<<Break<<endl; } catch (CPException se) { decodeOk=false; } BYTE crefl; if ( decodeOk ) { try { crefl = GetByte(message,bi++); } catch (CPException se) { decodeOk=false; } } if ( decodeOk ) { SetFont(f,ElementType(0,IE_CALL_REFERENCE)); decodeOk=DecodeCallReferenceLength(f,3,crefl); if (decodeOk) { int callRefLen = (crefl & 0x0f); // should be one or two only if ( callRefLen != 0 ) { BYTE CallRef[2] = { 0,0 }; for (int j=0; j<crefl; j++) try { CallRef[j]=GetByte(message,bi++); } catch (CPException se) { f<<"**Not enough Call Reference data**"<<Break<<endl; decodeOk = false; } if ( decodeOk ) DecodeCallReference(f,INDENT_SIZE,crefl,CallRef[0],CallRef[1]); } } f<<eFont; f<<Break<<endl; } BYTE MessageType; if ( decodeOk ) { try { MessageType = GetByte(message,bi++); } catch (CPException se) { decodeOk=false; } } CBitSet elements; if ( decodeOk ) { SetFont(f,ElementType(MessageType,IE_MESSAGE_TYPE)); DecodeMessageType(f,INDENT_SIZE,Protocol,MessageType); f<<eFont<<endl; } gvars.ActiveCodeSet = 0; int LastActiveCodeSet=0; bool decodeDone=false; while ( decodeOk && !decodeDone) { int ie; try { ie = GetByte(message,bi++); } catch (CPException se) { decodeDone=true; continue; } f << Break << endl; if ( (ie & 0x80) == 0x80 ) { // single octet Information Element SetFont(f,ElementType(MessageType,ie)); if (ie==IE_SENDING_COMPLETE) { f << "ie=" << HexOutput(ie) << Break << "IE="<<IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; } else if (ie==IE_MORE_DATA) { f << "ie=" << HexOutput(ie) << Break << "IE="<<IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; } else { BYTE d[1]; switch (ie&0xf0) { case IE_RESERVED: f << "ie=" << HexOutput(ie) << Break << "IE=" << IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; break; case IE_SHIFT: f << "ie=" << HexOutput(ie) << Break << "IE=" << IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; d[0]=ie; DecodeShift(f,3,&gvars,d); break; case IE_CONGESTION_LEVEL: f << "ie=" << HexOutput(ie) << Break << "IE=" << IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; d[0]=ie; DecodeCongestionLevel(f,3,&gvars,d); break; case IE_REPEAT_INDICATOR: f << "ie=" << HexOutput(ie) << Break << "IE=" << IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; d[0]=ie; DecodeRepeatIndication(f,3,&gvars,d); break; default: f << "**invalid Single Octet IE** (" << HexOutput(ie) << ")" << Break << endl; decodeOk = false; } } f<<eFont<<endl; } else { // multiple octet Information Element SetFont(f,ElementType(MessageType,ie)); int ielen; try { ielen = GetByte(message,bi++); } catch (CPException se ) { // IE is missing its length f << "No IE Length for ie=" << HexOutput(ie) << Break << endl; decodeOk = false; continue; } if ( ielen == 0 ) { f << "IE length cannot be zero for ie=" << HexOutput(ie) << Break << endl; decodeOk = false; continue; } f << "ie=" << HexOutput(ie) << " len=" << HexOutput(ielen) << " data="; int dstat = bi; BYTE iea[64]; memset(iea,0,sizeof(iea)); try { iea[0]=0xff; for (int i=0; i<ielen; i++) { int ieb = GetByte(message,dstat++); f << " " << HexOutput(ieb); iea[i+1]=ieb; iea[0]=i+1; } } catch (CPException se) { f << " **more expected**"; decodeOk=false; } f << Break << endl; if ( decodeOk ) { elements.setBit(ie); f << "IE=" << IEname(MAKE_FULLIE(gvars.ActiveCodeSet,ie)) << Break << endl; psIEDecoderEntry p = &IEDecoders[0]; if ( p != NULL ) { while (p->DecodeFunction!=NULL) { if ((p->CodeSet==gvars.ActiveCodeSet) && ((p->IEid&p->IEidMask)==(ie&p->IEidMask))) { (p->DecodeFunction)(f,INDENT_SIZE,&gvars,iea); break; } p++; } if ( p->DecodeFunction == NULL ) f<<DrawIndent(INDENT_SIZE)<<"!!!NO DECODERS INSTALLED FOR codeset="<<HexOutput(gvars.ActiveCodeSet)<<" ie="<<HexOutput(ie)<<"!!!"<<Break<<endl; } else f<<DrawIndent(INDENT_SIZE)<<"!!!NO DECODERS INSTALLED!!!"<<Break<<endl; } f << eFont; bi = dstat; } // decrement the vars->LockCount. If its zero, restore the ActiveCodeSet if ( gvars.LockCount > 0 ) { gvars.LockCount--; if ( gvars.LockCount == 0 ) gvars.ActiveCodeSet = gvars.LastCodeSet; } } /* if ( decodeOk ) { // Can add some sanity check here to ensure that all the mandatory fields were entered if ( Protocol == PROTOCOL_Q931) { switch (MessageType) { case MESSAGE_ALERTING: break; case MESSAGE_CALL_PROCEEDING: break; case MESSAGE_CONNECT: break; case MESSAGE_CONNECT_ACKNOWLEDGE: break; case MESSAGE_PROGRESS: break; case MESSAGE_SETUP: break; case MESSAGE_SETUP_ACKNOWLEDGE: break; case MESSAGE_RESUME: break; case MESSAGE_RESUME_ACKNOWLEDGE: break; case MESSAGE_RESUME_REJECT: break; case MESSAGE_SUSPEND: break; case MESSAGE_SUSPEND_ACKNOWLEDGE: break; case MESSAGE_SUSPEND_REJECT: break; case MESSAGE_USER_INFORMATION: break; case MESSAGE_DISCONNECT: break; case MESSAGE_RELEASE: break; case MESSAGE_RELEASE_COMPLETE: break; case MESSAGE_RESTART: break; case MESSAGE_RESTART_ACKNOWLEDGE: break; case MESSAGE_SEGMENT: break; case MESSAGE_CONGESTION_CONTROL: break; case MESSAGE_INFORMATION: break; case MESSAGE_FACILITY: break; case MESSAGE_FACILITY_REJECT: break; case MESSAGE_NOTIFY: break; case MESSAGE_STATUS: break; case MESSAGE_STATUS_ENQUIRY: break; default: decodeOk=false; break; } } if ( Protocol == PROTOCOL_MAINTENANCE ) { switch (MessageType) { case MESSAGE_SERVICE: break; case MESSAGE_SERVICE_ACKNOWLEDGE: break; default: decodeOk=false; break; } } } */ }
QList<QDomElement> Item::unhandledElements() const { // TODO: do not hardcode this list here QList<ElementType> handled; handled.append(ElementType(QLatin1String("title"))); handled.append(ElementType(QLatin1String("link"))); handled.append(ElementType(QLatin1String("description"))); handled.append(ElementType(QLatin1String("pubDate"))); handled.append(ElementType(QLatin1String("expirationDate"))); handled.append(ElementType(QLatin1String("rating"))); handled.append(ElementType(QLatin1String("source"))); handled.append(ElementType(QLatin1String("guid"))); handled.append(ElementType(QLatin1String("comments"))); handled.append(ElementType(QLatin1String("author"))); handled.append(ElementType(QLatin1String("date"), dublinCoreNamespace())); QList<QDomElement> notHandled; QDomNodeList children = element().childNodes(); for (int i = 0; i < children.size(); ++i) { QDomElement el = children.at(i).toElement(); if (!el.isNull() && !handled.contains(ElementType(el.localName(), el.namespaceURI()))) { notHandled.append(el); } } return notHandled; }