~ubuntu-branches/ubuntu/wily/pyopencl/wily

« back to all changes in this revision

Viewing changes to pyopencl/clmath.py

  • Committer: Package Import Robot
  • Author(s): Tomasz Rybak
  • Date: 2012-06-21 21:18:03 UTC
  • mfrom: (2.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20120621211803-424gma7uil7lje4u
* New upstream release.
* Depend on free ocl-icd-libopencl1 instead of non-free libraries.
* Add NEWS entry describing OpenCL library dependencies.
* Change my email.
* Move python-pyopengl from Recommends to Suggests because package
  can be used for computations without any graphical environment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
def _make_unary_array_func(name):
5
5
    @cl_array.elwise_kernel_runner
6
6
    def knl_runner(result, arg):
 
7
        if arg.dtype.kind == "c":
 
8
            from pyopencl.elementwise import complex_dtype_to_name
 
9
            fname = "%s_%s" % (complex_dtype_to_name(arg.dtype), name)
 
10
        else:
 
11
            fname = name
 
12
 
7
13
        return elementwise.get_unary_func_kernel(
8
 
                result.context, name, arg.dtype)
 
14
                result.context, fname, arg.dtype)
9
15
 
10
16
    def f(array, queue=None):
11
17
        result = array._new_like_me(queue=queue)
14
20
 
15
21
    return f
16
22
 
17
 
# See table 6.8 in the CL spec
 
23
# See table 6.8 in the CL 1.1 spec
18
24
acos = _make_unary_array_func("acos")
19
25
acosh = _make_unary_array_func("acosh")
20
26
acospi = _make_unary_array_func("acospi")
115
121
    """Return a tuple `(fracpart, intpart)` of arrays containing the
116
122
    integer and fractional parts of `arg`.
117
123
    """
118
 
 
119
124
    intpart = arg._new_like_me(queue=queue)
120
125
    fracpart = arg._new_like_me(queue=queue)
121
126
    _modf(intpart, fracpart, arg, queue=queue)
144
149
tgamma = _make_unary_array_func("tgamma")
145
150
trunc = _make_unary_array_func("trunc")
146
151
 
 
152
 
147
153
# no point wrapping half_ or native_
148
154
 
149
155
# TODO: table 6.10, integer functions
150
156
# TODO: table 6.12, clamp et al
 
157
 
 
158
@cl_array.elwise_kernel_runner
 
159
def _bessel_jn(result, sig, exp):
 
160
    return elementwise.get_bessel_jn_kernel(result.context)
 
161
 
 
162
def bessel_jn(n, x, queue=None):
 
163
    """Return a new array of floating point values composed from the
 
164
    entries of `significand` and `exponent`, paired together as
 
165
    `result = significand * 2**exponent`.
 
166
    """
 
167
    result = x._new_like_me(queue=queue)
 
168
    _bessel_jn(result, n, x)
 
169
    return result