Added dst, idst, dstn and idstn

master
Per A Brodtkorb 8 years ago
parent a1dbe3bbfb
commit 12414e46e2

@ -1,10 +1,10 @@
import numpy as np import numpy as np
from scipy.fftpack import dct as _dct from scipy.fftpack import dct as _dct, idct as _idct
from scipy.fftpack import idct as _idct from scipy.fftpack import dst as _dst, idst as _idst
import os import os
path = os.path.dirname(os.path.realpath(__file__)) path = os.path.dirname(os.path.realpath(__file__))
__all__ = ['dct', 'idct', 'dctn', 'idctn'] __all__ = ['dct', 'idct', 'dctn', 'idctn', 'dst', 'idst', 'dstn', 'idstn']
def dct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment def dct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
@ -112,6 +112,10 @@ def dct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
return _dct(x, type, n, axis, norm) return _dct(x, type, n, axis, norm)
def dst(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
return _dst(x, type, n, axis, norm)
def idct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment def idct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
''' '''
Return the Inverse Discrete Cosine Transform of an arbitrary type sequence. Return the Inverse Discrete Cosine Transform of an arbitrary type sequence.
@ -152,6 +156,10 @@ def idct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
return _idct(x, type, n, axis, norm) return _idct(x, type, n, axis, norm)
def idst(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
return _idst(x, type, n, axis, norm)
def _get_shape(y, shape, axes): def _get_shape(y, shape, axes):
if shape is None: if shape is None:
if axes is None: if axes is None:
@ -268,6 +276,12 @@ def dctn(x, type=2, shape=None, axes=None, # @ReservedAssignment
return _raw_dctn(y, type, shape, axes, norm, dct) return _raw_dctn(y, type, shape, axes, norm, dct)
def dstn(x, type=2, shape=None, axes=None, # @ReservedAssignment
norm='ortho'):
y = np.atleast_1d(x)
return _raw_dctn(y, type, shape, axes, norm, dst)
def idctn(x, type=2, shape=None, axes=None, # @ReservedAssignment def idctn(x, type=2, shape=None, axes=None, # @ReservedAssignment
norm='ortho'): norm='ortho'):
'''Return inverse N-D Discrete Cosine Transform of array x. '''Return inverse N-D Discrete Cosine Transform of array x.
@ -282,6 +296,12 @@ def idctn(x, type=2, shape=None, axes=None, # @ReservedAssignment
return _raw_dctn(y, type, shape, axes, norm, idct) return _raw_dctn(y, type, shape, axes, norm, idct)
def idstn(x, type=2, shape=None, axes=None, # @ReservedAssignment
norm='ortho'):
y = np.atleast_1d(x)
return _raw_dctn(y, type, shape, axes, norm, idst)
def num_leading_ones(x): def num_leading_ones(x):
first = 0 first = 0
for i, xi in enumerate(x): for i, xi in enumerate(x):

Loading…
Cancel
Save