Opened 11 years ago

Closed 10 years ago

#1941 closed defect (fixed)

outerProduct not implemented

Reported by: cschubert Owned by: sjoelund.se
Priority: normal Milestone: 1.9.1
Component: Backend Version: trunk
Keywords: outerProduct Cc: cschubert

Description (last modified by sjoelund.se)

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 cschubert 11 years ago.
outerProductTest2.mo (186 bytes) - added by cschubert 11 years ago.

Download all attachments as: .zip

Change History (12)

Changed 11 years ago by cschubert

comment:1 Changed 11 years ago by sjoelund.se

  • Description modified (diff)

comment:2 Changed 11 years ago by sjoelund.se

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r13932

comment:3 Changed 11 years ago by cschubert

  • Cc cschubert added
  • Resolution fixed deleted
  • Status changed from closed to reopened

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 Changed 11 years ago by cschubert

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 11 years ago by sjoelund.se (previous) (diff)

Changed 11 years ago by cschubert

comment:5 Changed 11 years ago by sjoelund.se

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

comment:6 Changed 11 years ago by sjoelund.se

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

comment:7 Changed 11 years ago by sjoelund.se

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

comment:8 Changed 11 years ago by sjoelund.se

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

comment:9 Changed 11 years ago by sjoelund.se

  • Milestone changed from 1.9.0 to 1.9.1

Postponed until 1.9.1

comment:10 Changed 10 years ago by sjoelund.se

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.