Thanks a lot, Igor. Here is a slightly larger example. The X10 main function calls a native C++ function providing a 1D local array (Rail[double]) and gets back some scalar value (a norm of the input vector).
It seems to work well : I used "x10aux::ref<x10::lang::Rail<double> >" for the vector parameter and a reference for the result (double &). Could you or anyone take a look on the code to see if I used the proper way to write it ? Thanks in advance. Mark // test7.x10 import x10.compiler.Native; public class test7 { @Native("c++", "void compute(x10aux::ref<x10::lang::Rail<double> >, double, double &); compute(#1, #2, #3)") public native def compute(val x:Rail[double], val p:Double, var r:Double): Void; public static def main(a: Rail[String]) : void { for(var j:int =0; j<Place.MAX_PLACES; j++) async(here.next(j)) { var H:test7 = new test7(); Console.OUT.println("Place " + (here.id + 1) + " ( of "+Place.MAX_PLACES+" )"); val n : int = 5; val u : Rail[Double] = Rail.makeVal[Double](n); for (var i:int = 0; i<n; i++) u(i) = here.id+i; val r:Double = 0.0; H.compute(u, 1.0, r); Console.OUT.println("r = " + r); H.compute(u, 2.0, r); Console.OUT.println("r = " + r); } } } // compute.cc #include "test7.h" #include <math.h> void compute(x10aux::ref<x10::lang::Rail<double> > u, double p, double &r) { double s = 0.0; x10::lang::Rail<double>::Iterator i(u); for (; i.hasNext(); ) s += pow(i.next(), p); r = pow(s, 1.0/p); } ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users