Commit 462d4155 authored by Powers, Sarah's avatar Powers, Sarah
Browse files

First upload NoiseAwareTransformation.cpp

parent b3f8f6bd
Loading
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
//placeholder
 No newline at end of file
#include noiseAwareTransformation.hpp
//#include SWAP.hpp??
//#include "LibIntWrapper.hpp"
//#include "xacc_service.hpp"

#include <iostream>

namespace qcor {
    namespace tranformations {
        
        std::shared_ptr<IR> NoiseAwareTransform::transform(std::shared_ptr<IR> ir) {
            
            // TODO: expand to handle more than 1 function
            auto function = ir->getKernels()[0];
            
            // do stuff with that function
            
            // TODO:FIX: check that function is not null
            if (function == NULL) return;
            
            // iterate to get instructions in the function
            for (int i = 0; i < function->nInstructions(); i++) {
                auto inst = function->getInstruction(i);
                
                // Get index of qubit involved - vector<int>
                auto param = inst->bits()
                
                //increase index by 1
                for (int j = 0; j < param.size(); j++) {
                    param[j]++;
                }
                
                //set the new bits
                setBits(param);
            } 
            
        return ir;
        }
        
    } //namespace transformations
} // namespace qcor