Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-16 09:21:42

0001 #ifndef TMVA_EXPERIMENTAL_SOFIE_ROPERATOR_NOT
0002 #define TMVA_EXPERIMENTAL_SOFIE_ROPERATOR_NOT
0003 
0004 #include <TMVA/ROperator.hxx>
0005 #include <TMVA/RModel.hxx>
0006 #include <TMVA/SOFIE_common.hxx>
0007 
0008 namespace TMVA {
0009 namespace Experimental {
0010 namespace SOFIE {
0011 
0012 
0013 class ROperator_Not final : public ROperator {
0014 private:
0015    std::string fNX;
0016    std::string fNY;
0017 
0018    std::vector<Dim> fShapeX;
0019    std::vector<Dim> fShapeY;
0020 
0021 public:
0022    ROperator_Not() {}
0023 
0024    ROperator_Not(std::string nameX, std::string nameY)
0025       : fNX(UTILITY::Clean_name(nameX)), fNY(UTILITY::Clean_name(nameY))
0026    {
0027          fInputTensorNames =  { fNX };
0028          fOutputTensorNames = { fNY };
0029    }
0030 
0031 
0032    void Initialize(RModel& model) override {
0033       if (!model.CheckIfTensorAlreadyExist(fNX)) {
0034          throw std::runtime_error("TMVA::SOFIE - Tensor " + fNX + " not found.");
0035       }
0036       fShapeX = model.GetDimTensorShape(fNX);
0037       fShapeY = fShapeX;
0038       model.AddIntermediateTensor(fNY, model.GetTensorType(fNX), fShapeY);
0039    }
0040 
0041    std::string Generate(std::string opName) override
0042    {
0043       opName = "op_" + opName;
0044       std::stringstream out;
0045 
0046       out << SP << "\n//---- Operator Not  " << opName << "\n";
0047       auto length = ConvertDimShapeToLength(fShapeX);
0048       out << SP << "for (size_t i = 0; i < " << length << "; i++) {\n";
0049       out << SP << SP << "tensor_" << fNY << "[i] = !tensor_" + fNX + "[i];\n";
0050       out << SP << "}\n";
0051       return out.str();
0052    }
0053 
0054 };
0055 
0056 } // namespace SOFIE
0057 } // namespace Experimental
0058 } // namespace TMVA
0059 
0060 #endif