[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java array conversion
From: |
Michael Goffioul |
Subject: |
Re: Java array conversion |
Date: |
Mon, 20 Feb 2012 11:07:11 +0000 |
On Fri, Feb 17, 2012 at 5:49 PM, Robert Smith <address@hidden> wrote:
> Hi,
>
> I'm just starting out with Octave and have been trying to import large arrays
> of data using a Java API and the Octave-Java package. Arrays of doubles and
> Strings seem to be well catered for and I am able to convert them easily to
> Octave's native types. Where X is a java String[]:
>
> octave_strs_cell = char(X)
>
> Where Y is a java double[]:
>
> octave_dbls_matrix = java2mat(Y)
>
> Then octave functions are able to work with the arrays e.g.
> hist(octave_dbls_matrix) works whereas hist(Y) would not. I haven't been able
> to do the same with a java int[]. Is this possible? I had assumed that where
> Z is a java int[], this would work:
>
> octave_ints_matrix = java2mat(Z)
>
> However this simply returns the original java int[]. Attempting to use the
> java array in a function call fails with some variation of the error:
>
> "… wrong type argument `octave_java' ".
>
> Does anyone know the list of java primitives and classes that are supported
> out of the box by Octave-Java? Is conversion of java int[] a not yet
> implemented or never will be implemented? Or is this a bug?
Such conversion is not done automatically, but you can wrap your array
into a org.octave.Matrix object (see
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/extra/java/src/org/octave/Matrix.java?revision=4592&view=markup)
then use the java_convert_matrix flag to enable conversion:
java_convert_matrix(1)
Michael.