You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Daniel Price <da...@gmail.com> on 2016/01/03 18:37:27 UTC

Apache Commons Math and Groovy -- Argument Type?

Got this 2.4.5 Groovy error trying to perform a covariance calc:

groovy.lang.MissingMethodException: No signature of method:
org.apache.commons.math3.stat.correlation.Covariance.covariance() is
applicable for argument types: ([Ljava.lang.Double;, [Ljava.lang.Double;)

covariance() requires two double arrays, and that's what I provided, so
what gives?

Do I need to cast the Groovy/Java array into another type?

Any advice is much appreciated!

D

Re: Apache Commons Math and Groovy -- Argument Type?

Posted by Daniel Price <da...@gmail.com>.
That did it, thanks!  Thought I tried primitives earlier, but apparently
not...
On Jan 3, 2016 4:01 PM, "Schalk Cronjé" <ys...@gmail.com> wrote:

> Change to double[] instead of Double[].
>
>
> On 03/01/2016 20:50, Daniel Price wrote:
>
> Sorry, code sample:
>
> import org.apache.commons.math3.stat.correlation.Covariance
> import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
> import org.apache.commons.math3.util.*
>
> Double[] dblArray1 =
> [0.00995630918100443,0.00425329233495364,-0.01227651365617033,0.015574186166315451]
> as Double[]
> Double[] dblArray2 =
> [0.004630842339633734,0.003451971610807014,-0.008004809261582091,0.04068026756946197]
> as Double[]
> def cov = new Covariance().covariance(dblArray1, dblArray2)
> println "cov: $cov"
>
> Result:
> Exception in thread "main" groovy.lang.MissingMethodException: No
> signature of method:
> org.apache.commons.math3.stat.correlation.Covariance.covariance() is
> applicable for argument types: ([Ljava.lang.Double;, [Ljava.lang.Double;)
> values: [[0.00995630918100443, 0.00425329233495364,...
> Possible solutions: covariance([D, [D), covariance([D, [D, boolean)
>
> So, how would I create the proper array argument: [D,[D ?  Some Apache
> Commons Math type I need to cast my java.lang.Double to?
>
> Any suggestions much appreciated!
> D
>
> On Sun, Jan 3, 2016 at 10:43 AM, Eric MacAdie <em...@gmail.com> wrote:
>
>> Could you give a code sample?
>>
>> = Eric MacAdie
>>
>>
>> On Sun, Jan 3, 2016 at 11:37 AM, Daniel Price <da...@gmail.com>
>> wrote:
>>
>>> Got this 2.4.5 Groovy error trying to perform a covariance calc:
>>>
>>> groovy.lang.MissingMethodException: No signature of method:
>>> org.apache.commons.math3.stat.correlation.Covariance.covariance() is
>>> applicable for argument types: ([Ljava.lang.Double;, [Ljava.lang.Double;)
>>>
>>> covariance() requires two double arrays, and that's what I provided, so
>>> what gives?
>>>
>>> Do I need to cast the Groovy/Java array into another type?
>>>
>>> Any advice is much appreciated!
>>>
>>> D
>>>
>>>
>>>
>>
>
>
> --
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
>
>

Re: Apache Commons Math and Groovy -- Argument Type?

Posted by Schalk Cronjé <ys...@gmail.com>.
Change to double[] instead of Double[].


On 03/01/2016 20:50, Daniel Price wrote:
> Sorry, code sample:
>
> import org.apache.commons.math3.stat.correlation.Covariance
> import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
> import org.apache.commons.math3.util.*
>
> Double[] dblArray1 = 
> [0.00995630918100443,0.00425329233495364,-0.01227651365617033,0.015574186166315451] 
> as Double[]
> Double[] dblArray2 = 
> [0.004630842339633734,0.003451971610807014,-0.008004809261582091,0.04068026756946197] 
> as Double[]
> def cov = new Covariance().covariance(dblArray1, dblArray2)
> println "cov: $cov"
>
> Result:
> Exception in thread "main" groovy.lang.MissingMethodException: No 
> signature of method: 
> org.apache.commons.math3.stat.correlation.Covariance.covariance() is 
> applicable for argument types: ([Ljava.lang.Double;, 
> [Ljava.lang.Double;) values: [[0.00995630918100443, 
> 0.00425329233495364,...
> Possible solutions: covariance([D, [D), covariance([D, [D, boolean)
>
> So, how would I create the proper array argument: [D,[D ? Some Apache 
> Commons Math type I need to cast my java.lang.Double to?
>
> Any suggestions much appreciated!
> D
>
> On Sun, Jan 3, 2016 at 10:43 AM, Eric MacAdie <emacadie@gmail.com 
> <ma...@gmail.com>> wrote:
>
>     Could you give a code sample?
>
>     = Eric MacAdie
>
>
>     On Sun, Jan 3, 2016 at 11:37 AM, Daniel Price
>     <danprice303@gmail.com <ma...@gmail.com>> wrote:
>
>         Got this 2.4.5 Groovy error trying to perform a covariance calc:
>
>         groovy.lang.MissingMethodException: No signature of method:
>         org.apache.commons.math3.stat.correlation.Covariance.covariance()
>         is applicable for argument types: ([Ljava.lang.Double;,
>         [Ljava.lang.Double;)
>
>         covariance() requires two double arrays, and that's what I
>         provided, so what gives?
>
>         Do I need to cast the Groovy/Java array into another type?
>
>         Any advice is much appreciated!
>
>         D
>
>
>
>


-- 
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r


Re: Apache Commons Math and Groovy -- Argument Type?

Posted by Daniel Price <da...@gmail.com>.
Sorry, code sample:

import org.apache.commons.math3.stat.correlation.Covariance
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
import org.apache.commons.math3.util.*

Double[] dblArray1 =
[0.00995630918100443,0.00425329233495364,-0.01227651365617033,0.015574186166315451]
as Double[]
Double[] dblArray2 =
[0.004630842339633734,0.003451971610807014,-0.008004809261582091,0.04068026756946197]
as Double[]
def cov = new Covariance().covariance(dblArray1, dblArray2)
println "cov: $cov"

Result:
Exception in thread "main" groovy.lang.MissingMethodException: No signature
of method:
org.apache.commons.math3.stat.correlation.Covariance.covariance() is
applicable for argument types: ([Ljava.lang.Double;, [Ljava.lang.Double;)
values: [[0.00995630918100443, 0.00425329233495364,...
Possible solutions: covariance([D, [D), covariance([D, [D, boolean)

So, how would I create the proper array argument: [D,[D ?  Some Apache
Commons Math type I need to cast my java.lang.Double to?

Any suggestions much appreciated!
D

On Sun, Jan 3, 2016 at 10:43 AM, Eric MacAdie <em...@gmail.com> wrote:

> Could you give a code sample?
>
> = Eric MacAdie
>
>
> On Sun, Jan 3, 2016 at 11:37 AM, Daniel Price <da...@gmail.com>
> wrote:
>
>> Got this 2.4.5 Groovy error trying to perform a covariance calc:
>>
>> groovy.lang.MissingMethodException: No signature of method:
>> org.apache.commons.math3.stat.correlation.Covariance.covariance() is
>> applicable for argument types: ([Ljava.lang.Double;, [Ljava.lang.Double;)
>>
>> covariance() requires two double arrays, and that's what I provided, so
>> what gives?
>>
>> Do I need to cast the Groovy/Java array into another type?
>>
>> Any advice is much appreciated!
>>
>> D
>>
>>
>>
>

Re: Apache Commons Math and Groovy -- Argument Type?

Posted by Eric MacAdie <em...@gmail.com>.
Could you give a code sample?

= Eric MacAdie


On Sun, Jan 3, 2016 at 11:37 AM, Daniel Price <da...@gmail.com> wrote:

> Got this 2.4.5 Groovy error trying to perform a covariance calc:
>
> groovy.lang.MissingMethodException: No signature of method:
> org.apache.commons.math3.stat.correlation.Covariance.covariance() is
> applicable for argument types: ([Ljava.lang.Double;, [Ljava.lang.Double;)
>
> covariance() requires two double arrays, and that's what I provided, so
> what gives?
>
> Do I need to cast the Groovy/Java array into another type?
>
> Any advice is much appreciated!
>
> D
>
>
>