MathGroup Archive 2011

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

Search the Archive

Re: Finding Clusters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117220] Re: Finding Clusters
  • From: Oliver Ruebenkoenig <ruebenko at wolfram.com>
  • Date: Fri, 11 Mar 2011 04:42:09 -0500 (EST)
  • References: <201103102104.QAA11362@smc.vnet.net>

On Thu, 10 Mar 2011, Yves Klett wrote:

> Hi,
>
> using Part[] is probably faster for large lists:
>
> tst = {{x -> 9.95043, y -> 0.201587}, {x -> -0.0507389,
>    y -> 0.39451}, {x -> -0.0502288 + 0.192544 I,
>    y -> 0.199992 - 2.42154*10^-6 I}, {x -> -0.0502288 - 0.192544 I,
>    y -> 0.199992 + 2.42154*10^-6 I}, {x -> -0.0507405,
>    y -> 0.394519}, {x -> -0.0502287 + 0.192544 I,
>    y -> 0.2}, {x -> -0.0502287 - 0.192544 I,
>    y -> 0.2}, {x -> -0.0507405, y -> 0.00548135}};
> tst[[All, All, 2]] == ({x, y} /. tst)
> tst[[All, All, 2]]
>
> The All and Span (est. V6) operators are incredibly useful, have a look
> at them.
>
> Regards,
> Yves


Yes, Yves, that is a good point. You could go further, for example in this 
case the list is a mixture of _Real and _Complex. If we convert the _Real 
to _Complex then we could pack the array

Developer`PackedArrayQ@tst[[All, All, 2]]
False

Developer`PackedArrayQ@(tst[[All, All, 2]] /.
     x_Real :> Complex[x, 0.])
False

Developer`PackedArrayQ@
   Developer`ToPackedArray[(tst[[All, All, 2]] /.
      x_Real :> Complex[x, 0.])]
True

Regards,
Oliver


>
> Am 09.03.2011 13:03, schrieb Martin VavpotiÄ?:
>> Hello everyone.
>>
>> I have a large array of numbers (1000 =D72). I wish to find clusters in
>> that mesh of numbers but the FindClusters method is giving me a hard
>> time. I think it's because of those non-numeric leftovers from NSolve
>> (x -> and y ->).
>>
>> {{x -> 9.95043, y -> 0.201587}, {x -> -0.0507389,
>>   y -> 0.39451}, {x -> -0.0502288 + 0.192544 I,
>>   y -> 0.199992 - 2.42154*10^-6 I}, {x -> -0.0502288 - 0.192544 I,
>>   y -> 0.199992 + 2.42154*10^-6 I}, <<992>>, {x -> -0.0507405,
>>   y -> 0.394519}, {x -> -0.0502287 + 0.192544 I,
>>   y -> 0.2}, {x -> -0.0502287 - 0.192544 I,
>>   y -> 0.2}, {x -> -0.0507405, y -> 0.00548135}}
>>
>> I know that if you write something like %[[1,2,2]] you get only the
>> numbers but I have a whole array here. How do I get the whole array to
>> lose those y -> ?
>>
>> Help anyone?
>>
>
>


  • Prev by Date: Re: How to kill slave kernel securely?
  • Next by Date: Re: determining boundary of a region in n-dimensional
  • Previous by thread: Re: Finding Clusters
  • Next by thread: Contour line colors from z coord of a 3D plot