Skip to content

Commit

Permalink
- Fix indentation (no tabs!)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8561 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 9, 2011
1 parent 455641d commit ae30379
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 83 deletions.
10 changes: 5 additions & 5 deletions c_runtime/read_matlab4.c
Expand Up @@ -195,7 +195,7 @@ double omc_matlab4_read_single_val(double *res, ModelicaMatReader *reader, int v
if (1 != fread(res, sizeof(double), 1, reader->file))
return 1;
if (varIndex < 0)
*res = -(*res);
*res = -(*res);
return 0;
}

Expand Down Expand Up @@ -248,10 +248,10 @@ double omc_matlab4_stopTime(ModelicaMatReader *reader)
int omc_matlab4_val(double *res, ModelicaMatReader *reader, ModelicaMatVariable_t *var, double time)
{
if (var->isParam) {
if (var->index < 0)
*res = -reader->params[abs(var->index)-1];
else
*res = reader->params[var->index-1];
if (var->index < 0)
*res = -reader->params[abs(var->index)-1];
else
*res = reader->params[var->index-1];
} else {
double w1,w2,y1,y2;
int i1,i2;
Expand Down
157 changes: 79 additions & 78 deletions c_runtime/simulation_result_mat.cpp
Expand Up @@ -44,28 +44,28 @@ static int calcDataSize(map<void*,int> &indx_map)
int sz = 1; // time
for (int i = 0; i < globalData->nStates; i++)
if (!globalData->statesFilterOutput[i]) {
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->states[i]),sz));
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->states[i]),sz));
sz++;
}
for (int i = 0; i < globalData->nStates; i++)
if (!globalData->statesDerivativesFilterOutput[i]) {
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->statesDerivatives[i]),sz));
sz++;
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->statesDerivatives[i]),sz));
sz++;
}
for (int i = 0; i < globalData->nAlgebraic; i++)
if (!globalData->algebraicsFilterOutput[i]) {
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->algebraics[i]),sz));
sz++;
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->algebraics[i]),sz));
sz++;
}
for (int i = 0; i < globalData->intVariables.nAlgebraic; i++)
if (!globalData->intVariables.algebraicsFilterOutput[i]){
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->intVariables.algebraics[i]),sz));
sz++;
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->intVariables.algebraics[i]),sz));
sz++;
}
for (int i = 0; i < globalData->boolVariables.nAlgebraic; i++)
if (!globalData->boolVariables.algebraicsFilterOutput[i]) {
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->boolVariables.algebraics[i]),sz));
sz++;
indx_map.insert(simulation_result_mat::indx_type((void*)(&globalData->boolVariables.algebraics[i]),sz));
sz++;
}
for (int i = 0; i < globalData->nAlias; i++)
if (!globalData->aliasFilterOutput[i]) sz++;
Expand Down Expand Up @@ -154,7 +154,7 @@ simulation_result_mat::simulation_result_mat(const char* filename,
delete[] stringMatrix; stringMatrix = NULL;

// generate dataInfo table
generateDataInfo(doubleMatrix, rows, cols, globalData, numVars, nParams,indx_map,indx_parammap);
generateDataInfo(doubleMatrix, rows, cols, globalData, numVars, nParams,indx_map,indx_parammap);
// write `dataInfo' matrix
writeMatVer4Matrix("dataInfo", cols, rows, doubleMatrix, false);
delete[] doubleMatrix; doubleMatrix = NULL;
Expand Down Expand Up @@ -356,79 +356,80 @@ void simulation_result_mat::generateDataInfo(double* &dataInfo,
ccol = ccol+4*indx_map.size();
// alias variables
for (int i = 0; i < globalData->nAlias; i++) if (!globalData->aliasFilterOutput[i]) {
double table = 0;
map<void*,int>::iterator it = indx_map.find((void*)globalData->realAlias[i].alias);
if (it == indx_map.end()) {
it = indx_parammap.find((void*)globalData->realAlias[i].alias);
if (it == indx_parammap.end())
continue;
else
table = 1.0;
}
else
table = 2.0;
// row 1 - which table
dataInfo[ccol] = table;
// row 2 - index of var in table (variable 'Time' have index 1)
if (((globalData->realAlias)[i]).negate)
dataInfo[ccol+1] = -(it->second+1.0);
else
dataInfo[ccol+1] = it->second+1.0;
// row 3 - linear interpolation == 0
dataInfo[ccol+2] = 0.0;
// row 4 - not defined outside of the defined time range == -1
dataInfo[ccol+3] = -1.0;
ccol += 4;
double table = 0;
map<void*,int>::iterator it = indx_map.find((void*)globalData->realAlias[i].alias);
if (it == indx_map.end()) {
it = indx_parammap.find((void*)globalData->realAlias[i].alias);
if (it == indx_parammap.end())
continue;
else
table = 1.0;
} else {
table = 2.0;
}
// row 1 - which table
dataInfo[ccol] = table;
// row 2 - index of var in table (variable 'Time' have index 1)
if (((globalData->realAlias)[i]).negate)
dataInfo[ccol+1] = -(it->second+1.0);
else
dataInfo[ccol+1] = it->second+1.0;
// row 3 - linear interpolation == 0
dataInfo[ccol+2] = 0.0;
// row 4 - not defined outside of the defined time range == -1
dataInfo[ccol+3] = -1.0;
ccol += 4;
}
for (int i = 0; i < globalData->intVariables.nAlias; i++) if (!globalData->intVariables.aliasFilterOutput[i]) {
double table = 0;
map<void*,int>::iterator it = indx_map.find((void*)globalData->intVariables.alias[i].alias);
if (it == indx_map.end()) {
it = indx_parammap.find((void*)globalData->intVariables.alias[i].alias);
if (it == indx_parammap.end())
continue;
else
table = 1.0;
}
else
table = 2.0;
// row 1 - which table
dataInfo[ccol] = table;
// row 2 - index of var in table (variable 'Time' have index 1)
if (globalData->intVariables.alias[i].negate)
dataInfo[ccol+1] = -(it->second+1.0);
else
dataInfo[ccol+1] = it->second+1.0;
// row 3 - linear interpolation == 0
dataInfo[ccol+2] = 0.0;
// row 4 - not defined outside of the defined time range == -1
dataInfo[ccol+3] = -1.0;
ccol += 4;
double table = 0;
map<void*,int>::iterator it = indx_map.find((void*)globalData->intVariables.alias[i].alias);
if (it == indx_map.end()) {
it = indx_parammap.find((void*)globalData->intVariables.alias[i].alias);
if (it == indx_parammap.end())
continue;
else
table = 1.0;
} else {
table = 2.0;
}
// row 1 - which table
dataInfo[ccol] = table;
// row 2 - index of var in table (variable 'Time' have index 1)
if (globalData->intVariables.alias[i].negate)
dataInfo[ccol+1] = -(it->second+1.0);
else
dataInfo[ccol+1] = it->second+1.0;
// row 3 - linear interpolation == 0
dataInfo[ccol+2] = 0.0;
// row 4 - not defined outside of the defined time range == -1
dataInfo[ccol+3] = -1.0;
ccol += 4;
}
for (int i = 0; i < globalData->boolVariables.nAlias; i++) if (!globalData->boolVariables.aliasFilterOutput[i]) {
double table = 0;
map<void*,int>::iterator it = indx_map.find((void*)globalData->boolVariables.alias[i].alias);
if (it == indx_map.end()) {
it = indx_parammap.find((void*)globalData->boolVariables.alias[i].alias);
if (it == indx_parammap.end())
continue;
else
table = 1.0;
double table = 0;
map<void*,int>::iterator it = indx_map.find((void*)globalData->boolVariables.alias[i].alias);
if (it == indx_map.end()) {
it = indx_parammap.find((void*)globalData->boolVariables.alias[i].alias);
if (it == indx_parammap.end())
continue;
else
table = 1.0;
}
else
table = 2.0;
// row 1 - which table
dataInfo[ccol] = table;
// row 2 - index of var in table (variable 'Time' have index 1)
if (globalData->boolVariables.alias[i].negate)
dataInfo[ccol+1] = -(it->second+1.0);
else
dataInfo[ccol+1] = it->second+1.0;
// row 3 - linear interpolation == 0
dataInfo[ccol+2] = 0.0;
// row 4 - not defined outside of the defined time range == -1
dataInfo[ccol+3] = -1.0;
ccol += 4;
else {
table = 2.0;
}
// row 1 - which table
dataInfo[ccol] = table;
// row 2 - index of var in table (variable 'Time' have index 1)
if (globalData->boolVariables.alias[i].negate)
dataInfo[ccol+1] = -(it->second+1.0);
else
dataInfo[ccol+1] = it->second+1.0;
// row 3 - linear interpolation == 0
dataInfo[ccol+2] = 0.0;
// row 4 - not defined outside of the defined time range == -1
dataInfo[ccol+3] = -1.0;
ccol += 4;
}
// parameters and constants
for(size_t i = 0; i < (size_t)nParams; ++i) {
Expand Down

0 comments on commit ae30379

Please sign in to comment.