You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ziqi Zhang <zi...@sheffield.ac.uk> on 2016/02/23 11:18:40 UTC
RealVector iterator
Hi,
I would like to iterate through the non-zero values in a RealVector object. I notice that the method RealVector.sparseIterator() can do this:
"Create a sparse iterator over the vector, which may omit some entries. The ommitted entries are either exact zeroes (for dense implementations) or are the entries which are not stored (for real sparse vectors). No guarantees are made about order of iteration."
However, the method returns an Iterator<RealVector.Entry> object, where "Entry" is a protected class and therefore I cannot really use it outside of the RealVector class.
Have I misunderstood something? Is there anyway to iterate through the values in the RealVector object without converting them to double[], because the vector is very high dimensional and very sparse.
Many thanks!
Re: RealVector iterator
Posted by Gilles <gi...@harfang.homelinux.org>.
Hello.
On Thu, 25 Feb 2016 23:03:13 +0000, Ziqi Zhang wrote:
> Thanks Giles
> I have created an issue
> https://issues.apache.org/jira/browse/MATH-1329
> <https://issues.apache.org/jira/browse/MATH-1329>
>
> Hope it gets fixed.
>
There are issues with sparse vectors/matrices in Commons Math.
https://issues.apache.org/jira/browse/MATH-656
https://issues.apache.org/jira/browse/MATH-765
https://issues.apache.org/jira/browse/MATH-766
What you stumbled upon clearly shows that those features are not used
much.
I've asked on the "dev" ML about the MATH-1329 issue.
Are you subscribed to that ML?
You could then submit a patch that would solve the problem in your
case.
Maybe it'll start a discussion on the still pending issues which I
mention
above.
Thanks,
Gilles
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: RealVector iterator
Posted by Ziqi Zhang <zi...@sheffield.ac.uk>.
Thanks Giles
I have created an issue
https://issues.apache.org/jira/browse/MATH-1329 <https://issues.apache.org/jira/browse/MATH-1329>
Hope it gets fixed.
> On 25 Feb 2016, at 01:30, Gilles <gi...@harfang.homelinux.org> wrote:
>
>> RealVector.sparseIterator()
Re: RealVector iterator
Posted by Gilles <gi...@harfang.homelinux.org>.
Hi.
On Tue, 23 Feb 2016 10:18:40 +0000, Ziqi Zhang wrote:
> Hi,
>
> I would like to iterate through the non-zero values in a RealVector
> object. I notice that the method RealVector.sparseIterator() can do
> this:
>
> "Create a sparse iterator over the vector, which may omit some
> entries. The ommitted entries are either exact zeroes (for dense
> implementations) or are the entries which are not stored (for real
> sparse vectors). No guarantees are made about order of iteration."
>
> However, the method returns an Iterator<RealVector.Entry> object,
> where "Entry" is a protected class and therefore I cannot really use
> it outside of the RealVector class.
That looks like a bug indeed.
The unit tests for "RealVector" did not detect the problem because
"RealVector.Entry" can be accessed from "RealVectorTest" (as it is
defined in the same package).
Could you file a report on the issue tracking system?
Thanks,
Gilles
> Have I misunderstood something? Is there anyway to iterate through
> the values in the RealVector object without converting them to
> double[], because the vector is very high dimensional and very
> sparse.
>
> Many thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org