You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Ritesh Kumar Singh <ri...@gmail.com> on 2014/11/17 00:14:53 UTC

Returning breeze.linalg.DenseMatrix from method

Hi,

I have a method that returns DenseMatrix:
def func(str: String): DenseMatrix = {
    ...
    ...
}

But I keep getting this error:
*class DenseMatrix takes type parameters*

I tried this too:
def func(str: String): DenseMatrix(Int, Int, Array[Double]) = {
    ...
    ...
}
But this gives me this error:
*'=' expected but '(' found*

Any possible fixes?

Re: Returning breeze.linalg.DenseMatrix from method

Posted by Ritesh Kumar Singh <ri...@gmail.com>.
Yeah, it works.

Although when I try to define a var of type DenseMatrix, like this:

var mat1: DenseMatrix[Double]

It gives an error saying we need to initialise the matrix mat1 at the time
of declaration.
Had to initialise it as :
var mat1: DenseMatrix[Double] = DenseMatrix.zeros[Double](1,1)

Anyways, it works now
Thanks for helping :)

On Mon, Nov 17, 2014 at 4:56 PM, tribhuvanesh@gmail.com <
tribhuvanesh@gmail.com> wrote:

> This should fix it --
>
> def func(str: String): DenseMatrix*[Double]* = {
>     ...
>     ...
> }
>
> So, why is this required?
> Think of it like this -- If you hadn't explicitly mentioned Double, it
> might have been that the calling function expected a
> DenseMatrix[SomeOtherType], and performed a SomeOtherType-specific
> operation which may have not been supported by the returned
> DenseMatrix[Double]. (I'm also assuming that SomeOtherType has no subtype
> relations with Double).
>
> On 17 November 2014 00:14, Ritesh Kumar Singh <
> riteshoneinamillion@gmail.com> wrote:
>
>> Hi,
>>
>> I have a method that returns DenseMatrix:
>> def func(str: String): DenseMatrix = {
>>     ...
>>     ...
>> }
>>
>> But I keep getting this error:
>> *class DenseMatrix takes type parameters*
>>
>> I tried this too:
>> def func(str: String): DenseMatrix(Int, Int, Array[Double]) = {
>>     ...
>>     ...
>> }
>> But this gives me this error:
>> *'=' expected but '(' found*
>>
>> Any possible fixes?
>>
>
>
>
> --
> *Tribhuvanesh Orekondy*
>

Re: Returning breeze.linalg.DenseMatrix from method

Posted by "tribhuvanesh@gmail.com" <tr...@gmail.com>.
This should fix it --

def func(str: String): DenseMatrix*[Double]* = {
    ...
    ...
}

So, why is this required?
Think of it like this -- If you hadn't explicitly mentioned Double, it
might have been that the calling function expected a
DenseMatrix[SomeOtherType], and performed a SomeOtherType-specific
operation which may have not been supported by the returned
DenseMatrix[Double]. (I'm also assuming that SomeOtherType has no subtype
relations with Double).

On 17 November 2014 00:14, Ritesh Kumar Singh <riteshoneinamillion@gmail.com
> wrote:

> Hi,
>
> I have a method that returns DenseMatrix:
> def func(str: String): DenseMatrix = {
>     ...
>     ...
> }
>
> But I keep getting this error:
> *class DenseMatrix takes type parameters*
>
> I tried this too:
> def func(str: String): DenseMatrix(Int, Int, Array[Double]) = {
>     ...
>     ...
> }
> But this gives me this error:
> *'=' expected but '(' found*
>
> Any possible fixes?
>



-- 
*Tribhuvanesh Orekondy*