本文整理汇总了C++中MatrixPtr::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixPtr::getValue方法的具体用法?C++ MatrixPtr::getValue怎么用?C++ MatrixPtr::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixPtr
的用法示例。
在下文中一共展示了MatrixPtr::getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void FullGateWriterImpl::write(GatePtr pGate, std::ostream& outputStream) {
std::string delimeter = "*";
outputStream << "Gate:";
unsigned int nbSeq = pGate->getLabelSeq().size();
for(unsigned int i = 0; i < nbSeq; i++) {
outputStream << pGate->getLabelSeq()[i];
if(i < nbSeq - 1) {
outputStream << delimeter;
}
}
outputStream << std::endl;
outputStream << "--Gate cost:" << pGate->getCost();
outputStream << std::endl;
outputStream << "--Gate matrix:" << std::endl;
MatrixPtr pMatrix = pGate->getMatrix();
int nbRows, nbColumns;
pMatrix->getSize(nbRows, nbColumns);
for(int i = 0; i < nbRows; i++) {
for(int j = 0; j < nbColumns; j++) {
char printfBuffer[PRINT_BUFFER_LENGTH];
ComplexVal val = pMatrix->getValue(i,j);
printVal(printfBuffer, val);
outputStream << printfBuffer;
}
outputStream << std::endl;
}
}
示例2: checkIdentity
bool checkIdentity(MatrixPtr pMatrix) {
int nbRows, nbColums;
pMatrix->getSize(nbRows, nbColums);
for(int row = 0; row < nbRows; row++) {
for(int column = 0; column < nbColums; column++) {
ComplexVal v = pMatrix->getValue(row, column);
ComplexVal identityElement = (row == column) ? (ComplexVal)1.0 : (ComplexVal)0.0;
//If matrix[row][column] differs from I[row][column], consider matrix is not identity
mreal_t err = std::norm(v - identityElement);
if(err > IDENTITY_NOISE_THRESOLD) {
return true;
}
}
}
return false;
}