def remove_zeros(data, idx, length) -> int: idx_length = trtc.DVInt64(idx.size()) # Warning: (potential bug source): reading from outside of array AlgorithmicMethods.__remove_zeros_body.launch_n(length, [data, idx, idx_length]) trtc.Sort(idx) result = idx.size() - trtc.Count(idx, idx_length) return result
def remove_zeros(data, idx, length) -> int: idx_length = trtc.DVInt64(idx.size()) # Warning: (potential bug source): reading from outside of array AlgorithmicMethods.__remove_zeros_body.launch_n( length, [data, idx, idx_length]) trtc.Sort(idx) # result = trtc.Find(idx, idx_length) # if result is None: # result = length result = idx.size() - trtc.Count(idx, idx_length) if result < idx.size(): print("undertaker") return result
import ThrustRTC as trtc op = trtc.Functor( {}, ['x'], ''' return x % 100; ''') darr = trtc.device_vector('int32_t', 2000) trtc.Transform(trtc.DVCounter(trtc.DVInt32(0), 2000), darr, op) print(trtc.Count(darr, trtc.DVInt32(47))) op2 = trtc.Functor({}, ['x'], ''' return (x % 100)==47; ''') trtc.Sequence(darr) print(trtc.Count_If(darr, op2))