Re: Relatively prime integers in NumPy

Liste des GroupesRevenir à cl python 
Sujet : Re: Relatively prime integers in NumPy
De : dpopov (at) *nospam* anl.gov (Popov, Dmitry Yu)
Groupes : comp.lang.python
Date : 11. Jul 2024, 21:25:37
Autres entêtes
Message-ID : <mailman.34.1720791996.2981.python-list@python.org>
References : 1 2 3
Thank you for your interest. My explanation is too concise indeed, sorry. So far, I have used Python code with three enclosed 'for' loops for this purpose which is pretty time consuming. I'm trying to develop a NumPy based code to make this procedure faster. This routine is kind of 'heart' of the algorithm to index of X-ray Laue diffraction patterns. In our group we have to process huge amount of such patterns. They are collected at a synchrotron radiation facility. Faster indexation routine would help a lot.

This is the code I'm currently using. Any prompts how to implement it in NumPy would be highly appreciated.

for h in range(0, max_h):
      for k in range(0, max_k):
            for l in range(0, max_l):
                  chvec=1
                  maxmult=2
                  if h > 1:                     
                        maxmult=h
                  if k > 1:
                        maxmult=k
                  if l > 1:
                        maxmult=l
                  if h > 1:
                        if maxmult > h:
                              maxmult=h
                  if k > 1:
                        if maxmult > k:
                              maxmult=k
                  if l > 1:
                        if maxmult > l:
                              maxmult=l
                  maxmult=maxmult+1
                  for innen in range(2, maxmult):
                        if h in range(0, (max_h+1), innen):
                              if k in range(0, (max_k+1), innen):
                                    if l in range(0, (max_l+1), innen):
                                          chvec=0
                  if chvec==1:
                        # Only relatively prime integers h,k,l pass to this block of the code


________________________________
From: avi.e.gross@gmail.com <avi.e.gross@gmail.com>
Sent: Thursday, July 11, 2024 1:22 PM
To: Popov, Dmitry Yu <dpopov@anl.gov>; 'Popov, Dmitry Yu via Python-list' <python-list@python.org>
Subject: RE: Relatively prime integers in NumPy

Дмитрий, You may think you explained what you wanted but I do not see what result you expect from your examples. Your request is a bit too esoteric to be a great candidate for being built into a module like numpy for general purpose se but
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.

ZjQcmQRYFpfptBannerEnd

Дмитрий,

You may think you explained what you wanted but I do not see what result you
expect from your examples.

Your request is a bit too esoteric to be a great candidate for being built
into a module like numpy for general purpose se but I can imagine it could
be available in modules build on top of numpy.

Is there a reason you cannot solve this mostly outside numpy?

It looks like you could use numpy to select the numbers you want to compare,
then call one of many methods you can easily search for to see  how to use
python to make some list or other data structure for divisors of each number
involved and then use standard methods to compare the lists and exact common
divisors. If needed, you could then put the results back into your original
data structure using numpy albeit the number of matches can vary.

Maybe a better explanation is needed as I cannot see what your latter words
about -1 and 1 are about. Perhaps someone else knows.




-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Popov, Dmitry Yu via Python-list
Sent: Monday, July 8, 2024 3:10 PM
To: Popov, Dmitry Yu via Python-list <python-list@python.org>
Subject: Relatively prime integers in NumPy

Dear Sirs.

Does NumPy provide a simple mechanism to identify relatively prime integers,
i.e. integers which don't have a common factor other than +1 or -1? For
example, in case of this array:
[[1,5,8],
  [2,4,8],
  [3,3,9]]
I can imagine a function which would return array of common factors along
axis 0: [1,2,3]. Those triples of numbers along axis 1 with the factor of1
or -1 would be relatively prime integers.

Regards,
Dmitry Popov

Argonne, IL
USA

--
https://urldefense.us/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!G_uCfscf7eWS!ZGK1ZXYgmC6cpNa1xTXVTNklhunjYiinwaDe_xE3sJyVs4ZcVgUB_v2FKvDzDspx7IzFCZI7JpFsiV5iH58P$



Date Sujet#  Auteur
11 Jul 24 o Re: Relatively prime integers in NumPy1Popov, Dmitry Yu

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal