Ejemplo n.º 1
0
 def _create_spline_tf(self, father, problem):
     defines = Export._create_spline_tf(self, father, problem)
     for child, q_i in problem.q_i.items():
         for name, ind in q_i.items():
             if name in child._splines_prim:
                 basis = child._splines_prim[name]['basis']
                 for l in range(len(basis)):
                     sl_min = l * len(basis)
                     sl_max = (l + 1) * len(basis)
                     if set(range(sl_min, sl_max)) <= set(ind):
                         spl = child._splines_prim[name]
                         if spl['init'] is not None:
                             tf = '{'
                             for k in range(spl['init'].shape[0]):
                                 tf += '{' + ','.join([
                                     str(t)
                                     for t in spl['init'][k].tolist()
                                 ]) + '},'
                             tf = tf[:-1] + '}'
                             defines.update({
                                 ('XVAR_%s_TF') % name.upper():
                                 tf
                             })
                         break
     return defines
Ejemplo n.º 2
0
 def _create_spline_tf(self, father, problem):
     constants = Export._create_spline_tf(self, father, problem)
     for child, q_i in problem.q_i.items():
         for name, ind in q_i.items():
             if name in child._splines_prim:
                 basis = child._splines_prim[name]['basis']
                 for l in range(len(basis)):
                     sl_min = l*len(basis)
                     sl_max = (l+1)*len(basis)
                     if set(range(sl_min, sl_max)) <= set(ind):
                         spl = child._splines_prim[name]
                         if spl['init'] is not None:
                             tf = '{'
                             for k in range(spl['init'].shape[0]):
                                 tf += '{'+','.join([str(t) for t in spl['init'][k].tolist()])+'},'
                             tf = tf[:-1]+'}'
                             constants.update({('std::vector<std::vector<double>> XVAR_%s_TF') % name.upper(): tf})
                         break
     return constants