﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4890	strange power	Vitalij Ruge	somebody	"the following simple model create for simple power operation
{{{#!modelica
model pow_test
 Real x = time^(1/3);
end pow_test;  
}}}
about 60 lines C-Code:

{{{#!C
/*
 equation index: 2
 type: SIMPLE_ASSIGN
 x = time ^ 0.3333333333333333
 */
void pow_test_eqFunction_2(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,2};
  modelica_real tmp0;
  modelica_real tmp1;
  modelica_real tmp2;
  modelica_real tmp3;
  modelica_real tmp4;
  modelica_real tmp5;
  modelica_real tmp6;
  tmp0 = data->localData[0]->timeValue;
  tmp1 = 0.3333333333333333;
  if(tmp0 < 0.0 && tmp1 != 0.0)
  {
    tmp3 = modf(tmp1, &tmp4);
    
    if(tmp3 > 0.5)
    {
      tmp3 -= 1.0;
      tmp4 += 1.0;
    }
    else if(tmp3 < -0.5)
    {
      tmp3 += 1.0;
      tmp4 -= 1.0;
    }
    
    if(fabs(tmp3) < 1e-10)
      tmp2 = pow(tmp0, tmp4);
    else
    {
      tmp6 = modf(1.0/tmp1, &tmp5);
      if(tmp6 > 0.5)
      {
        tmp6 -= 1.0;
        tmp5 += 1.0;
      }
      else if(tmp6 < -0.5)
      {
        tmp6 += 1.0;
        tmp5 -= 1.0;
      }
      if(fabs(tmp6) < 1e-10 && ((unsigned long)tmp5 & 1))
      {
        tmp2 = -pow(-tmp0, tmp3)*pow(tmp0, tmp4);
      }
      else
      {
        throwStreamPrint(threadData, ""%s:%d: Invalid root: (%g)^(%g)"", __FILE__, __LINE__, tmp0, tmp1);
      }
    }
  }
  else
  {
    tmp2 = pow(tmp0, tmp1);
  }
  if(isnan(tmp2) || isinf(tmp2))
  {
    throwStreamPrint(threadData, ""%s:%d: Invalid root: (%g)^(%g)"", __FILE__, __LINE__, tmp0, tmp1);
  }
  data->localData[0]->realVars[0] /* x variable */ = tmp2;
  TRACE_POP
}

}}}

Line: https://github.com/OpenModelica/OMCompiler/blob/master/Compiler/Template/CodegenCFunctions.tpl#L4938

related commits:
https://github.com/OpenModelica/OMCompiler/commit/63d57dd2ca84c3e72641edba77fde0494bc56b73

https://github.com/OpenModelica/OMCompiler/commit/cb732fc280ac2d8940713d8a104c18952a0634da"	defect	new	high	Future	Backend				Francesco Casella Willi Braun
