- Index
- » Programming
- » Modelica Language
- » Matrix inversion
Matrix inversion
Re: Matrix inversion
If you have the Modelica Standard Library, you can simply make a function call to Modelica.Matrices.inv
- sjoelund.se
- 1700 Posts
Re: Matrix inversion
Thank you very much for your answer.
I try what yopu said to me but i am getting this message:
{"",""}
"Error: Class Modelica.Matrices.inv (its type) not found in scope tucermodel.
Error: No matching function found for Modelica.Matrices.inv
Error: Class Modelica.Matrices.inv not found in scope tucermodel.
Error: Error occured while flattening model tucermodel
"
...
What does this means?
Re: Matrix inversion
It sometimes means that MSL was not loaded. To solve, call loadModel(Modelica). Also, it might mean that I forgot to copy down the full path: Modelica.Math.Matrices.inv ...
- sjoelund.se
- 1700 Posts
Re: Matrix inversion
I write to OMshell " loadModel(Modelica) " and i get true.
I also fix the call to Modelica.Math.Matrices.inv(M).
My full call was:
Real s [7,7] = Modelica.Math.Matrices.inv(M);
and i get the next message:
{"",""}
"Error: Error building simulator. Buildlog: g++ -I"C:\OpenModelica1.5.0/include" -msse2 -mfpmath=sse -I. -I"C:/Users/Tassos/Desktop/tucer/Modelica" -o tucermodel.exe tucermodel.cpp -L"C:/Users/Tassos/Desktop/tucer/Modelica" -lsim -L"C:\OpenModelica1.5.0/lib" -lc_runtime -lf2c -lsendData -lQtNetwork-mingw -lQtCore-mingw -lQtGui-mingw -luuid -lole32 -lws2_32 Lapack
In file included from tucermodel.cpp:13:
tucermodel_functions.cpp: In function `int in_Modelica_Math_Matrices_LAPACK_dgetrf(type_description*, type_description*)':
tucermodel_functions.cpp:91: warning: converting to `modelica_integer' from `const double'
tucermodel_functions.cpp:99: error: cannot convert `real_array*' to `const int*' for argument `1' to `void dgetrf_(const int*, const int*, double*, const int*, int*, int*)'
tucermodel_functions.cpp: In function `Modelica_Math_Matrices_LAPACK_dgetrf_rettype _Modelica_Math_Matrices_LAPACK_dgetrf(real_array)':
tucermodel_functions.cpp:130: warning: converting to `modelica_integer' from `const double'
tucermodel_functions.cpp:137: error: cannot convert `real_array*' to `const int*' for argument `1' to `void dgetrf_(const int*, const int*, double*, const int*, int*, int*)'
tucermodel_functions.cpp: In function `int in_Modelica_Math_Matrices_LAPACK_dgetri(type_description*, type_description*)':
tucermodel_functions.cpp:174: warning: converting to `modelica_integer' from `const double'
tucermodel_functions.cpp:183: error: cannot convert `real_array*' to `const int*' for argument `1' to `void dgetri_(const int*, double*, const int*, const int*, double*, int*, int*)'
tucermodel_functions.cpp: In function `Modelica_Math_Matrices_LAPACK_dgetri_rettype _Modelica_Math_Matrices_LAPACK_dgetri(real_array, integer_array)':
tucermodel_functions.cpp:209: error: `work' was not declared in this scope
tucermodel_functions.cpp:210: error: `lwork' was not declared in this scope
tucermodel_functions.cpp:210: error: `info' was not declared in this scope
g++: Lapack: No such file or directory
mingw32-make: *** [tucermodel] Error 1
Error: Error building simulator. Buildlog: command g++ not found. Check $OPENMODELICAHOME
Error: Error building simulator. Buildlog: command "C:\OpenModelica1.5.0/bin/Compile" not found. Check $OPENMODELICAHOME
"
I am sorry if my questions are annoying to you but i am lost...
Thank you again...
Re: Matrix inversion
I would upgrade to a more recent OpenModelica (say 1.7) as it has a lot better support of external Fortran functions and Lapack than 1.5 did.
- sjoelund.se
- 1700 Posts
Re: Matrix inversion
Hello again.
I made a clean install of modellica 1.7.0.
I create a new model in OMEdit. I haven't insert any component.
I just wrote the next code to test the inverse function:
model dikimh
Real M[2,2] = {{4,3},{3,2}};
Real invM[2,2] = Modelica.Math.Matrices.inv(M);
end dikimh;
And still i am getting the message:
Simulation failed for model: dikimh
Error: Error building simulator. Buildlog: The syntax of the command is incorrect.
g++ -I. -o dikimh.exe dikimh.cpp -L\"C:/OpenModelica1.7.0/tmp\" \"-LC:/OpenModelica1.7.0/lib/omlibrary/msl31/Resources/Library/mingw32\" \"-LC:/OpenModelica1.7.0/lib/omlibrary/msl31/Resources/Library/win32\" \"-LC:/OpenModelica1.7.0/lib/omlibrary/msl31/Resources/Library\" -llapack-mingw -ltmglib-mingw -lblas-mingw -lf2c -lsim -linteractive -I\"C:/OpenModelica1.7.0//include/omc\" -O3 -falign-functions -msse2 -mfpmath=sse -lsendData -lQtNetwork-mingw -lQtCore-mingw -lQtGui-mingw -luuid -lole32 -lws2_32 -L\"C:/OpenModelica1.7.0//lib/omc\" -lc_runtime -lregex -Wl,-Bstatic -lf2c -Wl,-Bdynamic dikimh_records.c
C:/OpenModelica1.7.0//lib/omc/libsim.a(simulation_runtime.o):simulation_runtime.cpp:(.text+0x44d0): multiple definition of `_main'
C:/OpenModelica1.7.0//lib/omc/libf2c.a(main.o).text+0x70): first defined here
C:/OpenModelica1.7.0//lib/omc/libc_runtime.a(dlinpk.o):dlinpk.c.text+0x240): multiple definition of `_dscal_'
C:/OpenModelica1.7.0//lib/omc/libblas-mingw.a(dscal.o):dscal.f.text+0x0): first defined here
C:/OpenModelica1.7.0//lib/omc/libc_runtime.a(dlinpk.o):dlinpk.c.text+0x0): multiple definition of `_idamax_'
C:/OpenModelica1.7.0//lib/omc/libblas-mingw.a(idamax.o):idamax.f.text+0x0): first defined here
C:/OpenModelica1.7.0//lib/omc/libf2c.a(main.o).text+0x113): undefined reference to `_MAIN__'
collect2: ld returned 1 exit status
\\MinGW\\bin\\mingw32-make: *** [dikimh] Error 1
Could you please inform what i made wrong???
Thank you.
Re: Matrix inversion
Windows issues are so funny to look at. I'm assuming you installed the 1.7 release; the nightly build should work better http://build.openmodelica.org/omc/build … ly-builds/
- sjoelund.se
- 1700 Posts
- Index
- » Programming
- » Modelica Language
- » Matrix inversion