Skip to content

Commit

Permalink
- Fixes for CombiTable1Ds
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8994 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 13, 2011
1 parent b49347f commit b93a1ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion c_runtime/ModelicaExternalC/ModelicaTablesImpl.c
Expand Up @@ -54,7 +54,7 @@ int ModelicaTables_CombiTable1D_init(const char* tableName, const char* fileName
double const *table, int nRow, int nColumn,
int smoothness)
{
return omcTableTimeIni(0.0, 0.0, smoothness, 2 /* extrapolate based on two first/last values */, tableName, fileName, table, nRow, nColumn, 0);
return omcTableTimeIni(*table, *table, smoothness, 2 /* extrapolate based on two first/last values */, tableName, fileName, table, nRow, nColumn, 0);
}

void ModelicaTables_CombiTable1D_close(int tableID)
Expand Down
8 changes: 5 additions & 3 deletions c_runtime/tables.cpp
Expand Up @@ -645,15 +645,17 @@ double InterpolationTable::interpolate(double time, size_t col) const
if (!data) return 0.0;

// substract time offset
time -= startTime;
//fprintf(stderr, "time %g startTime %g\n", time, startTime);

if (time < 0.0)
if (time < minTime())
return extrapolate(time,col,time <= minTime());

for(size_t i = 1; i < lastIdx; ++i)
for(size_t i = 0; i < lastIdx; ++i) {
//fprintf(stderr, "getElt: %d %g->%g\n", i, getElt(i,0), getElt(i,1));
if (getElt(i,0) > time) {
return interpolateLin(time, i-1,col);
}
}
return extrapolate(time,col,time <= minTime());
}
bool InterpolationTable::compare(const char* fname, const char* tname,
Expand Down

0 comments on commit b93a1ba

Please sign in to comment.