Opened 12 years ago

Closed 11 years ago

#1941 closed defect (fixed)

outerProduct not implemented

Reported by: Christian Schubert Owned by: Martin Sjölund
Priority: normal Milestone: 1.9.1
Component: Backend Version: trunk
Keywords: outerProduct Cc: Christian Schubert

Description (last modified by Martin Sjölund)

I wrote a simple model using the outerProduct function

model outerProductTest
 Real n[3] = {1,2,3};
 Real a[3,3];
equation
 a = outerProduct(n,n);
end outerProductTest;

Unfortunately, it does not flatten giving the following errormessages:

[ModelicaBuiltin.mo:780:3-790:22:writable] Error: The lhs (result) of the external function declaration has array type (Integer[size(v1, 1), size(v2, 1)]), but this is not allowed in the specification. You need to pass it as an input to the function (preferably also with a size()-expression to avoid out-of-bounds errors in the external call).
[ModelicaBuiltin.mo:339:1-343:11:writable] Error: Internal error OpenModelica.Internal.outerProductInt not found in scope: <global scope>
[ModelicaBuiltin.mo:780:3-790:22:writable] Error: The lhs (result) of the external function declaration has array type (Integer[size(v1, 1), size(v2, 1)]), but this is not allowed in the specification. You need to pass it as an input to the function (preferably also with a size()-expression to avoid out-of-bounds errors in the external call).
[ModelicaBuiltin.mo:339:1-343:11:writable] Error: Internal error OpenModelica.Internal.outerProductInt not found in scope: <global scope>
[ModelicaBuiltin.mo:780:3-790:22:writable] Error: The lhs (result) of the external function declaration has array type (Integer[size(v1, 1), size(v2, 1)]), but this is not allowed in the specification. You need to pass it as an input to the function (preferably also with a size()-expression to avoid out-of-bounds errors in the external call).
[ModelicaBuiltin.mo:339:1-343:11:writable] Error: Internal error OpenModelica.Internal.outerProductInt not found in scope: <global scope>
[outerProductTest.mo:5:2-5:23:writable] Error: Class outerProduct not found in scope outerProductTest (looking for a function or record).
Error: Error occurred while flattening model outerProductTest

Attachments (2)

outerProductTest.mo (120 bytes ) - added by Christian Schubert 12 years ago.
outerProductTest2.mo (186 bytes ) - added by Christian Schubert 12 years ago.

Download all attachments as: .zip

Change History (12)

by Christian Schubert, 12 years ago

Attachment: outerProductTest.mo added

comment:1 by Martin Sjölund, 12 years ago

Description: modified (diff)

comment:2 by Martin Sjölund, 12 years ago

Resolution: fixed
Status: newclosed

Fixed in r13932

comment:3 by Christian Schubert, 12 years ago

Cc: Christian Schubert added
Resolution: fixed
Status: closedreopened

Now the model survives the frontend, but compilation fails.

Simulation failed for model: outerProductTestError: Error building simulator. Buildlog: gcc -falign-functions -msse2 -mfpmath=sse -I\"C:/OpenModelica1.9.0//include/omc\" -I. -c -o outerProductTest.o outerProductTest.c

outerProductTest.c: In function 'eqFunction_2':

outerProductTest.c:210: warning: passing argument 1 of 'copy_real_array_data_mem' from incompatible pointer type

C:/OpenModelica1.9.0//include/omc/real_array.h:76: note: expected 'const struct real_array_t *' but argument is of type 'modelica_real *'

gcc -falign-functions -msse2 -mfpmath=sse -I\"C:/OpenModelica1.9.0//include/omc\" -I. -c -o outerProductTest_records.o outerProductTest_records.c

g++ -I. -o outerProductTest.exe outerProductTest.o outerProductTest_records.o -I\"C:/OpenModelica1.9.0//include/omc\" -I. -falign-functions -msse2 -mfpmath=sse -L\"C:/OpenModelica1.9.0//lib/omc\" -lSimulationRuntimeC -linteractive -lregex -lexpat -static-libgcc -luuid -lole32 -lws2_32 -lsundials_kinsol -lsundials_nvecserial -llapack-mingw -Wl,-Bstatic -lf2c -Wl,-Bdynamic

outerProductTest.o:outerProductTest.c:(.text+0x5a0): undefined reference to `outerProduct'

collect2: ld returned 1 exit status

mingw32-make: * [omc_main_target] Error 1

comment:4 by Christian Schubert, 12 years ago

Another problem occurs when compiling the slightly more complicated model

model outerProductTest2
 Real n[3] = {1,2,3};
 Real b[3,3] = identity(3);
 Real a[3,3];
 Real phi = 0;
equation
 a = (outerProduct(n, n) + identity(3))*b;
end outerProductTest2;

Then we get an error from the frontend saying:

[outerProductTest.mo:7:2-7:42:writable] Error: Incompatible argument types to operation matrix multiplication in component <NO COMPONENT>, left type: Real[:, :], right type: Real[3, 3]
[outerProductTest.mo:7:2-7:42:writable] Error: Cannot resolve type of expression (outerProduct(n, n) + identity(3)) * b. The operands have types Real[:, :], Real[3, 3] in component <NO COMPONENT>.
Error: Error occurred while flattening model outerProductTest

Last edited 12 years ago by Martin Sjölund (previous) (diff)

by Christian Schubert, 12 years ago

Attachment: outerProductTest2.mo added

comment:5 by Martin Sjölund, 12 years ago

r13955 fixed the issue with code generation. Will look at the last part.

comment:6 by Martin Sjölund, 12 years ago

See if r13961 works, then add a testcase for it and close the bug.

comment:7 by Martin Sjölund, 12 years ago

Or wait for the commit that fixes all the problems... *Sigh*

comment:8 by Martin Sjölund, 12 years ago

Ok, r13983 should work for sure. Add a testcase if it does.

comment:9 by Martin Sjölund, 11 years ago

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:10 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.