Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5794
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: count the number of sub-list in a list |
| Date | 2011-10-22 10:19 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j7u5ar$13$1@smc.vnet.net> (permalink) |
| References | <201110211128.HAA18658@smc.vnet.net> <524BB95F-6A5A-4EFE-AFFD-CCEFCB07FDDE@trm.uni-leipzig.de> <CAF+B5XZRVLeHB1SKsBW0=aohepPu5_CeH3Gs_bA+C3TRR39Sqg@mail.gmail.com> |
Sorry,
as always I read too sloppy, but you can just adopt my example:
Count[m, {
{_Real, _Real, _Real},
{_Real, _Real, _Real},
{_Real,_Real, _Real} }, Infinity]
but you can shorten this to
Count[m, {{_Real ..} ..}, Infinity]
Cheers
Patrick
On Oct 21, 2011, at 1:51 PM, Gy Peng wrote:
> Dear Patrick,
>
> Thanks a lot for your kind reply.
>
> Sorry, what I want to count is not {_Real, _Real, _Real} but {{_Real, _Real, _Real},{_Real, _Real, _Real},{_Real, _Real, _Real}}, which is a matrix.
>
> "Count[m, {_Real, _Real, _Real}, -1]" only gave me the number of {_Real, _Real, _Real}, in my list.
>
> I tired Count[m, {_Real, _Real, _Real}, -2] or Count[m, {_Real, _Real, _Real}, 1] or Count[m, {_Real, _Real, _Real}, 2], they all gave me output=0
> I do not know what is the problem.
>
> I would appreciate if you could give some further help. Thanks for your time!
>
> Best regards,
> Gy Peng
>
>
> 2011/10/21 Patrick Scheibe <pscheibe@trm.uni-leipzig.de>
> Hi,
>
> in your tensor m the elements you want to count have the Form {_Real, _Real, _Real}
> and they are in the last level (-1) of your structure:
>
> Count[m, {_Real, _Real, _Real}, -1]
>
> or you just use the Dimension of m with the last level droped and multiply them
>
> Times @@ Most@Dimensions[m]
>
> both should give the same result.
>
> Cheers
> Patrick
>
>
> On Oct 21, 2011, at 1:28 PM, Gy Peng wrote:
>
> > Dear All,
> >
> > I have a list like:
> >
> > {{{{-0.00201671, 0.87571, 0.482832}, {-0.839678,
> > 0.260735, -0.476401}, {-0.543081, -0.406384,
> > 0.734789}}, {{-0.87571, -0.00201671,
> > 0.482832}, {-0.260735, -0.839678, -0.476401}, {0.406384, -0.543081,
> > 0.734789}}, {{0.00201671, -0.87571,
> > 0.482832}, {0.839678, -0.260735, -0.476401}, {0.543081, 0.406384,
> > 0.734789}}, {{0.87571, 0.00201671, 0.482832}, {0.260735,
> > 0.839678, -0.476401}, {-0.406384, 0.543081,
> > 0.734789}}}, {{{0.839678, -0.260735, 0.476401}, {-0.00201671,
> > 0.87571, 0.482832}, {-0.543081, -0.406384, 0.734789}}, {{0.260735,
> > 0.839678, 0.476401}, {-0.87571, -0.00201671,
> > 0.482832}, {0.406384, -0.543081, 0.734789}}, {{-0.839678,
> > 0.260735, 0.476401}, {0.00201671, -0.87571, 0.482832}, {0.543081,
> > 0.406384, 0.734789}}, {{-0.260735, -0.839678, 0.476401}, {0.87571,
> > 0.00201671, 0.482832}, {-0.406384, 0.543081,
> > 0.734789}}}, {{{0.00201671, -0.87571, -0.482832}, {0.839678, -0.260735,
> > 0.476401}, {-0.543081, -0.406384, 0.734789}}, {{0.87571,
> > 0.00201671, -0.482832}, {0.260735, 0.839678,
> > 0.476401}, {0.406384, -0.543081, 0.734789}}, {{-0.00201671,
> > 0.87571, -0.482832}, {-0.839678, 0.260735, 0.476401}, {0.543081,
> > 0.406384,
> > 0.734789}}, {{-0.87571, -0.00201671, -0.482832}, {-0.260735, -0.839678,
> > 0.476401}, {-0.406384, 0.543081, 0.734789}}}, {{{-0.839678,
> > 0.260735, -0.476401}, {0.00201671, -0.87571, -0.482832}, {-0.543081,
> > -0.406384,
> > 0.734789}}, {{-0.260735, -0.839678, -0.476401}, {0.87571,
> > 0.00201671, -0.482832}, {0.406384, -0.543081,
> > 0.734789}}, {{0.839678, -0.260735, -0.476401}, {-0.00201671,
> > 0.87571, -0.482832}, {0.543081, 0.406384, 0.734789}}, {{0.260735,
> > 0.839678, -0.476401}, {-0.87571, -0.00201671, -0.482832}, {-0.406384,
> > 0.543081, 0.734789}}}}
> >
> > I consider each of {{*, *, *}, {*, *, *}, {*,*,*}} is one single element, so
> > how could I count how many element in the whole list? Thank you very much!
> >
> > G
> >
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: count the number of sub-list in a list Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2011-10-22 10:19 +0000
csiph-web