Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/jyhmiinlin/pynufft
17 November 2025, 15:03:09 UTC
  • Code
  • Branches (16)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/gh-pages
    • refs/heads/master
    • refs/tags/0.3.1.7
    • refs/tags/0.3.1.8
    • refs/tags/2020.0.0
    • refs/tags/2020.1.2
    • refs/tags/2020.2.1
    • refs/tags/2020.2.3
    • refs/tags/2022.2.1
    • refs/tags/2022.2.2
    • refs/tags/2022.2.3
    • refs/tags/2022.2.3rc1
    • refs/tags/2024.1.2
    • refs/tags/v0.3.1.8
    • refs/tags/v2020.0.0
    • refs/tags/v2020.1.2
    No releases to show
  • 958a8c3
  • /
  • nufft
  • /
  • __init__.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:566130f8bd54dca92cf5ca238c779dec86775521
origin badgedirectory badge Iframe embedding
swh:1:dir:c4d2e9d23ad7aa1d24d216e23d963dec412f9e94
origin badgerevision badge
swh:1:rev:fd2bca8beca742517794bef0efb1f5014e494586
origin badgesnapshot badge
swh:1:snp:9e6a516ae08502c5b52293d1d32fc5bd59ed3b2a

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: fd2bca8beca742517794bef0efb1f5014e494586 authored by Jyh-Miin Lin on 26 September 2020, 04:17:59 UTC
change the version to 2020.1.2
Tip revision: fd2bca8
__init__.py
from __future__ import absolute_import
import numpy
import warnings
import scipy.sparse
import numpy.fft
import scipy.signal
import scipy.linalg
import scipy.special
from functools import wraps as _wraps
# from ..linalg.nufft_cpu import NUFFT_cpu
# from ..linalg.nufft_hsa import NUFFT_hsa





def push_cuda_context(hsa_method):
    """
    Decorator: Push cude context to the top of the stack for current use
    Add @push_cuda_context before the methods of NUFFT_device()
    """
    @_wraps(hsa_method)
    def wrapper(*args, **kwargs):
        try:
            args[0].thr._context.push()
        except:
            pass
        return hsa_method(*args, **kwargs)
    return wrapper



class NUFFT:
    """
    A super class of cpu and gpu NUFFT functions. 
    Note: NUFFT does NOT inherit NUFFT_cpu and NUFFT_hsa.
    Multi-coil or single-coil memory reduced NUFFT.

    """
    #import cpu codes
    from ._nufft_class_methods_cpu import _init__cpu, _plan_cpu, _precompute_sp_cpu, _reset_sense_cpu, _set_sense_cpu, _forward_one2many_cpu, _adjoint_many2one_cpu, _solve_cpu, _forward_cpu, _adjoint_cpu, _selfadjoint_one2many2one_cpu, _selfadjoint_cpu, _selfadjoint2_cpu, _x2xx_cpu, _xx2k_cpu, _xx2k_one2one_cpu, _k2vec_cpu, _vec2y_cpu, _k2y_cpu, _y2vec_cpu, _vec2k_cpu, _y2k_cpu, _k2xx_cpu, _k2xx_one2one_cpu, _xx2x_cpu, _k2y2k_cpu
    # import host codes
    from ._nufft_class_methods_cpu import  _forward_host,  _adjoint_host, _selfadjoint_host,  _solve_host, _xx2k_host, _k2xx_host, _x2xx_host, _xx2x_host, _k2y_host,  _y2k_host, _adjoint_many2one_host, _forward_one2many_host, _selfadjoint_one2many2one_host, _reset_sense_host, _set_sense_host
    # import device codes
    from ._nufft_class_methods_device import _init__device, _plan_device,  _set_wavefront_device, _offload_device, _reset_sense_device, _set_sense_device, to_device, to_host, _s2x_device, _x2xx_device, _xx2k_device, _k2y_device, _y2k_device, _k2xx_device, _xx2x_device, _x2s_device, _selfadjoint_one2many2one_device,  _selfadjoint_device, _forward_device, _forward_one2many_device, _adjoint_many2one_device, _adjoint_device, release, _solve_device, release
    
    # legacy codes (csr format for device)
    from ._nufft_class_methods_device import _y2k_legacy, _k2y_legacy, _forward_legacy, _adjoint_legacy, _selfadjoint_legacy, _forward_one2many_legacy, _adjoint_many2one_legacy, _selfadjoint_one2many2one_legacy, _plan_legacy, _offload_legacy, _solve_legacy
    from ._nufft_class_methods_cpu import _k2y_legacy_host,  _y2k_legacy_host, _selfadjoint_legacy_host, _forward_legacy_host, _adjoint_legacy_host, _selfadjoint_one2many2one_legacy_host, _forward_one2many_legacy_host, _adjoint_many2one_legacy_host, _solve_legacy_host
    
    def __init__(self, device_indx=None, legacy=None):
        if device_indx is None:
            self._init__cpu()
            self.processor = 'cpu'
        else:
            if legacy is True:
                self._init__device(device_indx)
                self.processor = 'hsa_legacy'
            else:
                self._init__device(device_indx)
                self.processor = 'hsa'
            
    def __del__(self):
        if self.processor is 'hsa' or 'hsa_legacy':
            self.release()
        else:
            pass
                
    def plan(self,  *args, **kwargs):
        func = {'cpu': self._plan_cpu,
                    'hsa': self._plan_device,
                    'hsa_legacy': self._plan_legacy}
        return func.get(self.processor)(*args, **kwargs)
    
    def forward(self, *args, **kwargs):
        func = {'cpu': self._forward_cpu, 
                    'hsa': self._forward_host,
                    'hsa_legacy': self._forward_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def adjoint(self, *args, **kwargs):
        func = {'cpu': self._adjoint_cpu,
                'hsa': self._adjoint_host,
                'hsa_legacy': self._adjoint_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def selfadjoint(self, *args, **kwargs):
        func = {'cpu': self._selfadjoint_cpu,
                'hsa': self._selfadjoint_host,
                'hsa_legacy': self._selfadjoint_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def solve(self, *args, **kwargs):
        func = {'cpu': self._solve_cpu,
                'hsa': self._solve_host,
                'hsa_legacy': self._solve_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def xx2k(self, *args, **kwargs):
        func = {'cpu': self._xx2k_cpu,
                'hsa': self._xx2k_host,
                'hsa_legacy': self._xx2k_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def k2xx(self, *args, **kwargs):
        func = {'cpu': self._k2xx_cpu,
                'hsa': self._k2xx_host,
                'hsa_legacy': self._k2xx_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def x2xx(self, *args, **kwargs):
        func = {'cpu': self._x2xx_cpu,
                'hsa': self._x2xx_host,
                'hsa_legacy': self._x2xx_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def xx2x(self, *args, **kwargs):
        func = {'cpu': self._xx2x_cpu,
                'hsa': self._xx2x_host,
                'hsa_legacy': self._xx2x_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def k2y(self, *args, **kwargs):
        func = {'cpu': self._k2y_cpu,
                'hsa': self._k2y_host,
                'hsa_legacy': self._k2y_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def y2k(self, *args, **kwargs):
        func = {'cpu': self._y2k_cpu,
                'hsa': self._y2k_host,
                'hsa_legacy': self._y2k_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def k2yk2(self, *args, **kwargs):
        func = {'cpu': self._k2yk2_cpu,
                'hsa': self._k2yk2_host,
                'hsa_legacy': self._k2yk2_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def adjoint_many2one(self, *args, **kwargs):
        func = {'cpu': self._adjoint_many2one_cpu,
                'hsa': self._adjoint_many2one_host,
                'hsa_legacy': self._adjoint_many2one_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def forward_one2many(self, *args, **kwargs):
        func = {'cpu': self._forward_one2many_cpu,
                'hsa': self._forward_one2many_host,
                'hsa_legacy': self._forward_one2many_legacy_host}
        return func.get(self.processor)(*args, **kwargs)
    
    def selfadjoint_one2many2one(self, *args, **kwargs):
        func = {'cpu': self._selfadjoint_one2many2one_cpu,
                'hsa': self._selfadjoint_one2many2one_host,
                'hsa_legacy': self._selfadjoint_one2many2one_legacy_host}
        return func.get(self.processor)(*args, **kwargs)   
    
    def k2xx_one2one(self, *args, **kwargs):
        func = {'cpu':self._k2xx_one2one_cpu}
        return func.get(self.processor)(*args, **kwargs)
    
    def xx2k_one2one(self, *args, **kwargs):
        func = {'cpu':self._xx2k_one2one_cpu}
        return func.get(self.processor)(*args, **kwargs) 
    
    def k2y2k(self, *args, **kwargs):
        func = {'cpu': self._k2y2k_cpu}
        return func.get(self.processor)(*args, **kwargs)
    def set_sense(self, *args, **kwargs):
        func = {'cpu': self._set_sense_cpu,
                'hsa': self._set_sense_host,
                'hsa_legacy': self._set_sense_host}
        return func.get(self.processor)(*args, **kwargs)
    def reset_sense(self, *args, **kwargs):
        func = {'cpu': self._reset_sense_cpu,
                'hsa': self._reset_sense_host,
                'hsa_legacy': self._reset_sense_host}
        return func.get(self.processor)(*args, **kwargs)
    

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API