Beispiel #1
0
        def remove_zeros(data, idx, length) -> int:
            idx_length = trtc.DVInt64(idx.size())

            loop = trtc.For(['data', 'idx', 'idx_length'], "i", '''
                if (data[idx[i]] == 0)
                    idx[i] = idx_length;
                ''')
            loop.launch_n(length, [data, idx, idx_length])

            trtc.Sort(idx.range(0, length))

            result = trtc.Find(idx.range(0, length), idx_length)
            if result == -1:
                result = length

            return result
Beispiel #2
0
import ThrustRTC as trtc

d_values = trtc.device_vector_from_list([0, 5, 3, 7], 'int32_t')
print(trtc.Find(d_values, trtc.DVInt32(3)))
print(trtc.Find(d_values, trtc.DVInt32(5)))
print(trtc.Find(d_values, trtc.DVInt32(9)))
print(trtc.Find_If(d_values, trtc.Functor({}, ['x'], '        return x>4;\n')))
print(trtc.Find_If(d_values, trtc.Functor({}, ['x'],
                                          '        return x>10;\n')))
print(
    trtc.Find_If_Not(d_values, trtc.Functor({}, ['x'],
                                            '        return x>4;\n')))
print(
    trtc.Find_If_Not(d_values, trtc.Functor({}, ['x'],
                                            '        return x>10;\n')))