0 Replies Latest reply on Jun 9, 2014 11:49 AM by user13113244

    How to use Jace to create 2D arrays

    user13113244

      Hi all,

       

      I'm using Jace 1.1.1 to generate proxies for C++ to call back into Java.  I've generated a few proxies that require 2D arrays of float for some of the method parameters, however, I can't seem to create a 2D array of float using JArray.  I saw Toby Reyelts example (Returning a Matrix from a C++ native method, possible?), but it crashes my system.  Below is the example I'm using:

       

      typedef JArray< JArray<JFloat> > FloatMatrix;

      typedef JArray< JFloat > FloatRow

       

      // Create a 10x5 matrix

      const int rows = 10;

      const int cols = 5;

      FloatMatrix matrix( rows );

       

      for ( int i = 0; i < rows; ++i ) {

      matrix[ i ] = FloatRow( cols );    // <----Crash here

      }

       

      // Set some values

      matrix[ 0 ][ 4 ] = 52.2;

      matrix[ 9 ][ 2 ] = 11.5;

       

      // Read some values

      int a = matrix[ 1 ][ 3 ];

      int b = matrix[ 6 ][ 2 ];


      Any help would be greatly appreciated.


      Kind regards,

      Kyle