help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java array conversion


From: Robert A. Smith
Subject: Re: Java array conversion
Date: Sun, 4 Mar 2012 23:06:32 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

That works perfectly. Many Thanks for the help.

Rob

On 20/02/12 11:07, Michael Goffioul wrote:
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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]