Skip to content

Commit

Permalink
- get rid of matrix.h
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15170 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed Feb 14, 2013
1 parent 6f22385 commit df59133
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 240 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -2586,7 +2586,7 @@ template equationNonlinear(SimEqSystem eq, Context context, Text &varDecls /*BUF
<<
data->simulationInfo.nonlinearSystemData[<%indexNonLinearSystem%>].nlsx[<%i0%>] = <%namestr%>;
data->simulationInfo.nonlinearSystemData[<%indexNonLinearSystem%>].nlsxOld[<%i0%>] = _<%namestr%>(1) /*old*/;
data->simulationInfo.nonlinearSystemData[<%indexNonLinearSystem%>].nlsxExtrapolation[<%i0%>] = extraPolate(<%namestr%>, _<%namestr%>(1) /*old*/, _<%namestr%>(2) /*old2*/);
data->simulationInfo.nonlinearSystemData[<%indexNonLinearSystem%>].nlsxExtrapolation[<%i0%>] = extraPolate(data, _<%namestr%>(1) /*old*/, _<%namestr%>(2) /*old2*/);
>>
;separator="\n"%>
solve_nonlinear_system(data, <%indexNonLinearSystem%>);
Expand Down
1 change: 0 additions & 1 deletion SimulationRuntime/c/Makefile.common
Expand Up @@ -15,7 +15,6 @@ FFLAGS = -O -fexceptions
RUNTIME_HEADERS = $(LIBF2CHEADER) \
./omc_inline.h \
./math-support/blaswrap.h \
./math-support/matrix.h \
./meta/gc/common.h \
./meta/gc/mmc_gc.h \
./meta/gc/generational.h \
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/math-support/CMakeLists.txt
Expand Up @@ -8,7 +8,7 @@ SET(math_support_sources bigden.c biglag.c dgesv_aux.c dogleg.c dpmpar.c
nelmead.c newuoa.c newuob.c pivot.c qform.c qrfac.c r1mpyq.c
r1updt.c trsapp.c update.c)

SET(math_support_headers blaswrap.h matrix.h)
SET(math_support_headers blaswrap.h)

# Library util
ADD_LIBRARY(math-support ${math_support_sources} ${math_support_headers})
Expand Down
222 changes: 0 additions & 222 deletions SimulationRuntime/c/math-support/matrix.h

This file was deleted.

1 change: 0 additions & 1 deletion SimulationRuntime/c/math-support/pivot.c
Expand Up @@ -6,7 +6,6 @@

#include <math.h>
#include <assert.h>
//#include "matrix.h"

/* Matrixes using column major order (as in Fortran) */
#ifndef set_matrix_elt
Expand Down
3 changes: 1 addition & 2 deletions SimulationRuntime/c/math-support/test/test_pivot.c
@@ -1,5 +1,4 @@
#include <math.h>
//#include "matrix.h"
#include <math.h>

/* Matrixes using column major order (as in Fortran) */
#ifndef set_matrix_elt
Expand Down
1 change: 0 additions & 1 deletion SimulationRuntime/c/openmodelica_func.h
Expand Up @@ -51,7 +51,6 @@ extern "C" {
#include "real_array.h"
#include "string_array.h"
#include "modelica_string.h"
#include "matrix.h"
#include "division.h"
#include "utility.h"

Expand Down
6 changes: 4 additions & 2 deletions SimulationRuntime/c/simulation/solver/mixedSearchSolver.c
Expand Up @@ -256,10 +256,11 @@ int solveMixedSearch(DATA *data, int sysNumber)
/* debug output */
if (ACTIVE_STREAM(LOG_NLS))
{
const char * __name;
for (i = 0; i < systemData->size; i++)
{
ix = (systemData->iterationVarsPtr[i]-data->localData[0]->booleanVars);
const char *__name = data->modelData.booleanVarsData[ix].info.name;
__name = data->modelData.booleanVarsData[ix].info.name;
DEBUG3(LOG_NLS, "%s changed : %d -> %d", __name, solverData->iterationVars[i], *(systemData->iterationVarsPtr[i]));
}
}
Expand All @@ -285,10 +286,11 @@ int solveMixedSearch(DATA *data, int sysNumber)
if (ACTIVE_STREAM(LOG_NLS))
{
DEBUG1(LOG_NLS, "#### SOLUTION FOUND! (system %d)", eqSystemNumber);
const char * __name;
for (i = 0; i < systemData->size; i++)
{
ix = (systemData->iterationVarsPtr[i]-data->localData[0]->booleanVars);
const char *__name = data->modelData.booleanVarsData[ix].info.name;
__name = data->modelData.booleanVarsData[ix].info.name;
DEBUG4(LOG_NLS, "%s = %d pre(%s)= %d", __name, *systemData->iterationVarsPtr[i], __name,
*systemData->iterationPreVarsPtr[i]);
}
Expand Down
1 change: 0 additions & 1 deletion SimulationRuntime/c/simulation/solver/mixedSearchSolver.h
Expand Up @@ -38,7 +38,6 @@
#include "simulation_data.h"



int allocateMixedSearchData(int size, void **data);
int freeMixedSearchData(void **data);
int solveMixedSearch(DATA *data, int sysNumber);
Expand Down
24 changes: 24 additions & 0 deletions SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Expand Up @@ -233,3 +233,27 @@ int check_nonlinear_solutions(DATA *data)

return returnValue;
}

/*! \fn extraPolate
* This function extrapolates linear next value from
* the both old values,
*
* \param [in] [data]
*
* \author wbraun
*/
double extraPolate(DATA *data, double old1, double old2)
{
double retValue;

if (data->localData[1]->timeValue == data->localData[2]->timeValue)
{
retValue = old1;
}
else
{
retValue = old2 + ((data->localData[0]->timeValue - data->localData[2]->timeValue)/(data->localData[1]->timeValue - data->localData[2]->timeValue)) * (old1-old2);
}

return retValue;
}
1 change: 1 addition & 0 deletions SimulationRuntime/c/simulation/solver/nonlinearSystem.h
Expand Up @@ -70,5 +70,6 @@ int allocateNonlinearSystem(DATA *data);
int freeNonlinearSystem(DATA *data);
int solve_nonlinear_system(DATA *data, int sysNumber);
int check_nonlinear_solutions(DATA *data);
double extraPolate(DATA *data, double old1, double old2);

#endif
5 changes: 2 additions & 3 deletions SimulationRuntime/c/simulation/solver/stateset.c
Expand Up @@ -30,7 +30,6 @@
*/

#include "stateset.h"
#include "matrix.h"
#include "omc_error.h"

#include <memory.h>
Expand Down Expand Up @@ -93,7 +92,7 @@ void initializeStateSetPivoting(DATA *data)
set->colPivot[n] = set->nCandidates-n-1;

for(n=0; n<set->nStates; n++)
set_matrix_elt(A, n, n, set->nStates, 1); /* set A[row, col] */
A[n + n *set->nStates] = 1; /* set A[row, col] */
}
}

Expand Down Expand Up @@ -231,7 +230,7 @@ static void setAMatrix(modelica_integer* newEnable, modelica_integer nCandidates
unsigned int sid = states[row]->id-firstrealid;
INFO1(LOG_DSS, "select %s", statecandidates[col]->name);
/* set A[row, col] */
set_matrix_elt(A, row, col, nStates, 1);
A[row + col * nStates] = 1;
/* reinit state */
data->localData[0]->realVars[sid] = data->localData[0]->realVars[id];
row++;
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/util/omc_error.h
Expand Up @@ -64,7 +64,7 @@ void omc_throw_function();
/* global JumpBuffer */
extern jmp_buf globalJmpbuf;

/* #define USE_DEBUG_OUTPUT */
#define USE_DEBUG_OUTPUT

enum LOG_STREAM
{
Expand Down

0 comments on commit df59133

Please sign in to comment.