Forum Stats

  • 3,827,137 Users
  • 2,260,744 Discussions
  • 7,897,181 Comments

Discussions

How to use Jace to create 2D arrays

user13113244
user13113244 Member Posts: 1
edited Jun 9, 2014 7:49AM in Java Native Interface (JNI)

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

Tagged:
This discussion has been closed.