MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathematica SparseArray Access Non-Default Values

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108385] Re: Mathematica SparseArray Access Non-Default Values
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 15 Mar 2010 07:02:30 -0500 (EST)
  • Reply-to: hanlonr at cox.net

test = SparseArray[{
    {1, 1} -> 3, {1, 5} -> 2, {5, 3} -> 1}];

Count[ArrayRules[test], {1, _} -> _]

2

Count[ArrayRules[test], {1, _}, 2]

2


Bob Hanlon

---- wima <tba2 at gmx.de> wrote: 

=============
Hi,

I am currently dealing with really huge (~ 80,000 x 80,000) sparse matrices. I this context I need to read the number of non-default values in each row.
When Accessing the i-th row of a SparseArray, this information is given.
E.g.
test = SparseArray[{{1, 1} -> 3, {1, 5} -> 2, {5, 3} -> 1}];
test[[1]]
returns SparseArray[<2>, {5}]
However, I fail to access the number of entries (here 2) to assign it to a variable.
I did not find any information in the documentation so far.
Does anyone have an idea?

Thx



  • Prev by Date: Re: Pi day
  • Next by Date: Re: How to define a statistical distribution?
  • Previous by thread: Re: Mathematica SparseArray Access Non-Default Values
  • Next by thread: Re: apparently simple graphic won't print when SaveAs[] PDF