Would this work? (+/a),a=:*:i.10 285 0 1 4 9 16 25 36 49 64 81 Lihda
Sent from my Verizon, Samsung Galaxy smartphone -------- Original message -------- From: Ben Gorte <[email protected]> Date: 11/18/18 1:22 AM (GMT-05:00) To: [email protected] Subject: [Jprogramming] j807 cd - pass array arguments Dear All, Long ago I made quite a lot of c-functions that I am calling from J using the cd mechanism (load 'dll') in linux. They stopped working in j64-807. I see in the release notes that indeed something has changed, but I cannot quite relate that to my case (but maybe I should - I'm not sure I entirely understand the story). In the simplest form it looks like this: First the c-code, sqr.c : int sqr (int n, int a[], int b[]) { int i, sumsqr=0; for (i=0; i<n; i++) sumsqr += b[i] = a[i] * a[i]; return sumsqr; } which I compile with gcc -O3 -shared -fPIC -o sql.so -Wl,--no-as-needed sqr.c (omitting -O3 does not make a difference). In J I go like: load 'dll' sqrdll =: jpath '~user/ext/sqr.so ' sqr =: 3 : 0 res =. (#y)#4 NB. make sure it's integer ret =. (sqrdll, 'sqr > i i *i *i') cd (#y);y;res ret, res ) Up until j806 I would get: sqr i.10 285 0 1 4 9 16 25 36 49 64 81 But in j807: sqr i.10 285 4 4 4 4 4 4 4 4 4 4 So my DLL 'reads' an array alright, but seems to be not 'writing' it. For completeness: JVERSION Engine: j807/j64/linux Release: commercial/2018-10-04T15:00:41 Library: 8.07.20 Qt IDE: 1.7.7/5.5.1 Platform: Linux 64 Installer: J807 install InstallPath: /home/ben/j64-807 Contact: https://nam03.safelinks.protection.outlook.com/?url=www.jsoftware.com&data=02%7C01%7C%7Caea74eef88cc4956f52408d64d1e2ea8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636781189351421900&sdata=ceCMEPnvicK08EirS1wRbf6cY9KsNvJipaklCDhhOtE%3D&reserved=0 Perhaps I'm overlooking something trivial; any help is highly appreciated! Ben ---------------------------------------------------------------------- For information about J forums see https://nam03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7Caea74eef88cc4956f52408d64d1e2ea8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636781189351421900&sdata=Y1K4erjYAGeTEFhAoZ4wCzdEFUrlTSFFk8MM3%2FQqOEg%3D&reserved=0 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
