| 54 | } |
| 55 | |
| 56 | void CoefficientFunction :: GenerateCode(Code &code, FlatArray<int> inputs, int index) const |
| 57 | { |
| 58 | string mycode = |
| 59 | string("// GenerateCode() not overloaded for: ") + Demangle(typeid(*this).name()) + "\n" |
| 60 | + R"CODE_( typedef {scal_type} TStack{index}; |
| 61 | STACK_ARRAY(TStack{index}, hmem{index}, mir.Size()*{dim}); |
| 62 | {values_type} {values}({rows}, {cols}, reinterpret_cast<{scal_type}*>(&hmem{index}[0])); |
| 63 | { |
| 64 | const CoefficientFunction & cf = *reinterpret_cast<CoefficientFunction*>({this}); |
| 65 | {values} = {scal_type}(0.0); |
| 66 | cf.Evaluate(mir, {values}); |
| 67 | } |
| 68 | )CODE_"; |
| 69 | auto values = Var("values", index); |
| 70 | string scal_type = code.res_type; |
| 71 | string rows = ToString(Dimension()); |
| 72 | string cols = "mir.IR().Size()"; |
| 73 | |
| 74 | std::map<string,string> variables; |
| 75 | variables["scal_type"] = scal_type; |
| 76 | variables["values_type"] = "FlatMatrix<"+scal_type+">"; |
| 77 | variables["values"] = values.S(); |
| 78 | variables["this"] = code.AddPointer(this); |
| 79 | variables["dim"] = ToString(Dimension()); |
| 80 | variables["index"] = ToString(index); |
| 81 | variables["rows"] = code.is_simd ? rows : cols; |
| 82 | variables["cols"] = code.is_simd ? cols : rows; |
| 83 | code.header += Code::Map(mycode, variables); |
| 84 | |
| 85 | // code.Declare(code.res_type, index, Dimensions()); |
| 86 | code.Declare(index, Dimensions(), IsComplex()); |
| 87 | if(code.is_simd) |
| 88 | { |
| 89 | for (int i = 0; i < Dimension(); i++) |
| 90 | code.body += Var(index,i,Dimensions()).Assign(values.S()+"("+ToString(i)+",i)", false); |
| 91 | } |
| 92 | else |
| 93 | { |
| 94 | for (int i = 0; i < Dimension(); i++) |
| 95 | code.body += Var(index,i,Dimensions()).Assign(values.S()+"(i,"+ToString(i)+")", false); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | void CoefficientFunction :: PrintReport (ostream & ost) const |
| 100 | { |
nothing calls this directly
no test coverage detected