CUSP
Loading...
Searching...
No Matches
cusp::reciprocal_functor< T > Struct Template Reference

#include <functional.h>

Public Methods

_CCCL_HOST_DEVICE T operator() (const T &v) const
 Return the reciprocal of v.
 

Detailed description

template<typename T>
struct cusp::reciprocal_functor< T >

reciprocal_functor is a function object computes the reciprocal, 1/x, of a given element.

Parameters
Tis a model of Assignable, and if x is an object of type T, then x=c must be defined and must have a return type that is convertible to T.
Overview
reciprocal_functor is a function object. Specifically, it is an Adaptable Unary Function. If f(c) is an object of class reciprocal_functor<T>, and x is an object of class T, then f(x) returns 1.0/x.
Example
#include <cusp/array1d.h>
#include <cusp/print.h>
int main()
{
// create an array with 5 entries from 1 to 5
// allocate size of transformed output array
// compute output vector as transform of tens
thrust::transform(count.begin(), count.end(), v.begin(), cusp::reciprocal_functor<float>());
// v = [1, 0.5, 0.33, 0.25, 0.2]
}
1D array of elements that may reside in "host" or "device" memory space
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
Definition array1d.h:99
Specialized array1d_view wrapping thrust::counting_iterator.
Definition array1d.h:566
Defines templated convenience functors analogous to what is found in thrust's functional.
void print(const Printable &p)
print a textual representation of an object
Print textual representation of an object.
reciprocal_functor is a function object computes the reciprocal, 1/x, of a given element.
Definition functional.h:578

Definition at line 577 of file functional.h.

Member Function Documentation

◆ operator()()

template<typename T >
_CCCL_HOST_DEVICE T cusp::reciprocal_functor< T >::operator() ( const T &  v) const
inline

Return the reciprocal of v.

Definition at line 581 of file functional.h.