You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Lance Norskog <go...@gmail.com> on 2010/11/19 10:28:45 UTC
Matrix and Vector classes: Read-only semantics
I'm writing classes for read-only, repeatable random vector and and
matrix. V[i] always returns the same number. M[i,j] always returns the
same random number. I'm making a patch and will contribute when it
gets some real-world testing.
These are the first read-only Vector and Matrix classes. There were a
few hiccups. The only real problem I encountered was Vector.like() and
Matrix.like().
The javadoc is:
Return an empty vector/matrix of the same underlying class
as the receiver.
Here's the problem: "empty" means writable. A read-only class cannot
do this. I think the semantics meant are: "return a writable Vector
with the same dense/sparse styleas this Vector": a dense read-only
vector class would create a DenseVector, for example.
Yes? No?
--
Lance Norskog
goksron@gmail.com
Re: Matrix and Vector classes: Read-only semantics
Posted by Grant Ingersoll <gs...@apache.org>.
On Nov 19, 2010, at 4:28 AM, Lance Norskog wrote:
> I'm writing classes for read-only, repeatable random vector and and
> matrix. V[i] always returns the same number. M[i,j] always returns the
> same random number. I'm making a patch and will contribute when it
> gets some real-world testing.
>
> These are the first read-only Vector and Matrix classes. There were a
> few hiccups. The only real problem I encountered was Vector.like() and
> Matrix.like().
>
> The javadoc is:
> Return an empty vector/matrix of the same underlying class
> as the receiver.
>
> Here's the problem: "empty" means writable. A read-only class cannot
> do this. I think the semantics meant are: "return a writable Vector
> with the same dense/sparse styleas this Vector": a dense read-only
> vector class would create a DenseVector, for example.
>
> Yes? No?
I believe so, but it also is the same size as the original, too, and has the same other properties w/ the exception of the actual data.
Re: Matrix and Vector classes: Read-only semantics
Posted by Ted Dunning <te...@gmail.com>.
The current implementation that you have uses up space with a cache matrix.
It shouldn't since
otherwise, you can just initialize a matrix with random values in a single
line and get faster performance.
On Sat, Nov 20, 2010 at 8:49 PM, Lance Norskog <go...@gmail.com> wrote:
> Ok. The use case is read-only random Vector & Matrix classes. They
> return the same value for each position. They take no space.
> Matrix.like() could make whatever you want: Dense, Sparse, whatever.
>
>
Re: Matrix and Vector classes: Read-only semantics
Posted by Ted Dunning <te...@gmail.com>.
On Sat, Nov 20, 2010 at 8:58 PM, Lance Norskog <go...@gmail.com> wrote:
> To explain that better, with an example:
>
> public Matrix Matrix.times(Matrix input);
>
> The standard implementation uses this.like() to create an output
> matrix and populates it. If the input matrix is sparse, the output
> should have the same sparse implementation because X times 0 = 0. So,
> RandomVector and RandomMatrix should use input.like() in this case.
>
> On Sat, Nov 20, 2010 at 8:49 PM, Lance Norskog <go...@gmail.com> wrote:
> > Ok. The use case is read-only random Vector & Matrix classes. They
> > return the same value for each position. They take no space.
> > Matrix.like() could make whatever you want: Dense, Sparse, whatever.
> >
> > https://issues.apache.org/jira/browse/MAHOUT-550
> >
> > Please have a look and tell me if this is on the right track.
> >
> > On Fri, Nov 19, 2010 at 8:44 AM, Jeff Eastman <je...@narus.com>
> wrote:
> >> +1 Seems sensible to me too
> >>
> >> -----Original Message-----
> >> From: Ted Dunning [mailto:ted.dunning@gmail.com]
> >> Sent: Friday, November 19, 2010 8:12 AM
> >> To: user@mahout.apache.org
> >> Subject: Re: Matrix and Vector classes: Read-only semantics
> >>
> >> What it really means is fail or return something sensible. I think your
> >> interpretation
> >> is pretty sensible.
> >>
> >> On Fri, Nov 19, 2010 at 1:28 AM, Lance Norskog <go...@gmail.com>
> wrote:
> >>
> >>> Here's the problem: "empty" means writable. A read-only class cannot
> >>> do this. I think the semantics meant are: "return a writable Vector
> >>> with the same dense/sparse styleas this Vector": a dense read-only
> >>> vector class would create a DenseVector, for example.
> >>>
> >>> Yes? No?
> >>>
> >>
> >
> >
> >
> > --
> > Lance Norskog
> > goksron@gmail.com
> >
>
>
>
> --
> Lance Norskog
> goksron@gmail.com
>
Re: Matrix and Vector classes: Read-only semantics
Posted by Lance Norskog <go...@gmail.com>.
To explain that better, with an example:
public Matrix Matrix.times(Matrix input);
The standard implementation uses this.like() to create an output
matrix and populates it. If the input matrix is sparse, the output
should have the same sparse implementation because X times 0 = 0. So,
RandomVector and RandomMatrix should use input.like() in this case.
On Sat, Nov 20, 2010 at 8:49 PM, Lance Norskog <go...@gmail.com> wrote:
> Ok. The use case is read-only random Vector & Matrix classes. They
> return the same value for each position. They take no space.
> Matrix.like() could make whatever you want: Dense, Sparse, whatever.
>
> https://issues.apache.org/jira/browse/MAHOUT-550
>
> Please have a look and tell me if this is on the right track.
>
> On Fri, Nov 19, 2010 at 8:44 AM, Jeff Eastman <je...@narus.com> wrote:
>> +1 Seems sensible to me too
>>
>> -----Original Message-----
>> From: Ted Dunning [mailto:ted.dunning@gmail.com]
>> Sent: Friday, November 19, 2010 8:12 AM
>> To: user@mahout.apache.org
>> Subject: Re: Matrix and Vector classes: Read-only semantics
>>
>> What it really means is fail or return something sensible. I think your
>> interpretation
>> is pretty sensible.
>>
>> On Fri, Nov 19, 2010 at 1:28 AM, Lance Norskog <go...@gmail.com> wrote:
>>
>>> Here's the problem: "empty" means writable. A read-only class cannot
>>> do this. I think the semantics meant are: "return a writable Vector
>>> with the same dense/sparse styleas this Vector": a dense read-only
>>> vector class would create a DenseVector, for example.
>>>
>>> Yes? No?
>>>
>>
>
>
>
> --
> Lance Norskog
> goksron@gmail.com
>
--
Lance Norskog
goksron@gmail.com
Re: Matrix and Vector classes: Read-only semantics
Posted by Lance Norskog <go...@gmail.com>.
Ok. The use case is read-only random Vector & Matrix classes. They
return the same value for each position. They take no space.
Matrix.like() could make whatever you want: Dense, Sparse, whatever.
https://issues.apache.org/jira/browse/MAHOUT-550
Please have a look and tell me if this is on the right track.
On Fri, Nov 19, 2010 at 8:44 AM, Jeff Eastman <je...@narus.com> wrote:
> +1 Seems sensible to me too
>
> -----Original Message-----
> From: Ted Dunning [mailto:ted.dunning@gmail.com]
> Sent: Friday, November 19, 2010 8:12 AM
> To: user@mahout.apache.org
> Subject: Re: Matrix and Vector classes: Read-only semantics
>
> What it really means is fail or return something sensible. I think your
> interpretation
> is pretty sensible.
>
> On Fri, Nov 19, 2010 at 1:28 AM, Lance Norskog <go...@gmail.com> wrote:
>
>> Here's the problem: "empty" means writable. A read-only class cannot
>> do this. I think the semantics meant are: "return a writable Vector
>> with the same dense/sparse styleas this Vector": a dense read-only
>> vector class would create a DenseVector, for example.
>>
>> Yes? No?
>>
>
--
Lance Norskog
goksron@gmail.com
RE: Matrix and Vector classes: Read-only semantics
Posted by Jeff Eastman <je...@Narus.com>.
+1 Seems sensible to me too
-----Original Message-----
From: Ted Dunning [mailto:ted.dunning@gmail.com]
Sent: Friday, November 19, 2010 8:12 AM
To: user@mahout.apache.org
Subject: Re: Matrix and Vector classes: Read-only semantics
What it really means is fail or return something sensible. I think your
interpretation
is pretty sensible.
On Fri, Nov 19, 2010 at 1:28 AM, Lance Norskog <go...@gmail.com> wrote:
> Here's the problem: "empty" means writable. A read-only class cannot
> do this. I think the semantics meant are: "return a writable Vector
> with the same dense/sparse styleas this Vector": a dense read-only
> vector class would create a DenseVector, for example.
>
> Yes? No?
>
Re: Matrix and Vector classes: Read-only semantics
Posted by Ted Dunning <te...@gmail.com>.
What it really means is fail or return something sensible. I think your
interpretation
is pretty sensible.
On Fri, Nov 19, 2010 at 1:28 AM, Lance Norskog <go...@gmail.com> wrote:
> Here's the problem: "empty" means writable. A read-only class cannot
> do this. I think the semantics meant are: "return a writable Vector
> with the same dense/sparse styleas this Vector": a dense read-only
> vector class would create a DenseVector, for example.
>
> Yes? No?
>