template
stringlengths 20
4.72k
|
---|
template<typename DataType, typename T>
void populate_ParentGainFilter(py::module& m, const char* type, T& parent)
{
py::class_<ParentGainFilter<DataType>>(m, type, parent)
.def_property("threshold", &ParentGainFilter<DataType>::get_threshold, &ParentGainFilter<DataType>::set_threshold)
.def_property("ratio", &ParentGainFilter<DataType>::get_ratio, &ParentGainFilter<DataType>::set_ratio);
} |
template<typename Filter>
void populate_SimpleGainFilter(py::module& m, const char* type)
{
py::class_<Filter, typename Filter::Parent>(m, type)
.def_property("softness", &Filter::get_softness, &Filter::set_softness);
} |
template<typename Filter>
void populate_ColoredGainFilter(py::module& m, const char* type)
{
py::class_<Filter, typename Filter::Parent>(m, type)
.def_property("softness", &Filter::get_softness, &Filter::set_softness)
.def_property("color", &Filter::get_color, &Filter::set_color)
.def_property("quality", &Filter::get_quality, &Filter::set_quality);
} |
template<typename Filter>
void populate_MaxColoredGainFilter(py::module& m, const char* type)
{
py::class_<Filter, typename Filter::Parent>(m, type)
.def_property("softness", &Filter::get_softness, &Filter::set_softness)
.def_property("color", &Filter::get_color, &Filter::set_color)
.def_property("quality", &Filter::get_quality, &Filter::set_quality)
.def_property("max_reduction", &Filter::get_max_reduction, &Filter::set_max_reduction);
} |
template<typename Filter>
void populate_MaxGainFilter(py::module& m, const char* type)
{
py::class_<Filter, typename Filter::Parent>(m, type)
.def_property("softness", &Filter::get_softness, &Filter::set_softness)
.def_property("max_reduction", &Filter::get_max_reduction, &Filter::set_max_reduction);
} |
template<typename Numeric>
PyObject* get_array(const std::vector<Numeric>& v)
{
detail::_interpreter::get(); //interpreter needs to be initialized for the numpy commands to work
NPY_TYPES type = select_npy_type<Numeric>::type;
if (type == NPY_NOTYPE)
{
std::vector<double> vd(v.size());
npy_intp vsize = v.size();
std::copy(v.begin(),v.end(),vd.begin());
PyObject* varray = PyArray_SimpleNewFromData(1, &vsize, NPY_DOUBLE, (void*)(vd.data()));
return varray;
}
npy_intp vsize = v.size();
PyObject* varray = PyArray_SimpleNewFromData(1, &vsize, type, (void*)(v.data()));
return varray;
} |
template<typename Numeric>
PyObject* get_2darray(const std::vector<::std::vector<Numeric>>& v)
{
detail::_interpreter::get(); //interpreter needs to be initialized for the numpy commands to work
if (v.size() < 1) throw std::runtime_error("get_2d_array v too small");
npy_intp vsize[2] = {static_cast<npy_intp>(v.size()), static_cast<npy_intp>(v[0].size())};
PyArrayObject *varray = (PyArrayObject *)PyArray_SimpleNew(2, vsize, NPY_DOUBLE);
double *vd_begin = static_cast<double *>(PyArray_DATA(varray));
for (const ::std::vector<Numeric> &v_row : v) {
if (v_row.size() != static_cast<size_t>(vsize[1]))
throw std::runtime_error("Missmatched array size");
std::copy(v_row.begin(), v_row.end(), vd_begin);
vd_begin += vsize[1];
}
return reinterpret_cast<PyObject *>(varray);
} |
template<typename Numeric>
PyObject* get_array(const std::vector<Numeric>& v)
{
PyObject* list = PyList_New(v.size());
for(size_t i = 0; i < v.size(); ++i) {
PyList_SetItem(list, i, PyFloat_FromDouble(v.at(i)));
}
return list;
} |
template< typename Numeric>
bool hist(const std::vector<Numeric>& y, long bins=10,std::string color="b",
double alpha=1.0, bool cumulative=false)
{
PyObject* yarray = get_array(y);
PyObject* kwargs = PyDict_New();
PyDict_SetItemString(kwargs, "bins", PyLong_FromLong(bins));
PyDict_SetItemString(kwargs, "color", PyString_FromString(color.c_str()));
PyDict_SetItemString(kwargs, "alpha", PyFloat_FromDouble(alpha));
PyDict_SetItemString(kwargs, "cumulative", cumulative ? Py_True : Py_False);
PyObject* plot_args = PyTuple_New(1);
PyTuple_SetItem(plot_args, 0, yarray);
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_hist, plot_args, kwargs);
Py_DECREF(plot_args);
Py_DECREF(kwargs);
if(res) Py_DECREF(res);
return res;
} |
template<typename NumericX, typename NumericY>
bool scatter(const std::vector<NumericX>& x,
const std::vector<NumericY>& y,
const double s=1.0, // The marker size in points**2
const std::unordered_map<std::string, std::string> & keywords = {} |
template <typename Numeric>
bool bar(const std::vector<Numeric> & x,
const std::vector<Numeric> & y,
std::string ec = "black",
std::string ls = "-",
double lw = 1.0,
const std::map<std::string, std::string> & keywords = {} |
template <typename Numeric>
bool bar(const std::vector<Numeric> & y,
std::string ec = "black",
std::string ls = "-",
double lw = 1.0,
const std::map<std::string, std::string> & keywords = {} |
template<typename NumericX, typename NumericY>
bool plot(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = "")
{
assert(x.size() == y.size());
PyObject* xarray = get_array(x);
PyObject* yarray = get_array(y);
PyObject* pystring = PyString_FromString(s.c_str());
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xarray);
PyTuple_SetItem(plot_args, 1, yarray);
PyTuple_SetItem(plot_args, 2, pystring);
// fffffffffffffffff关键就是这一步怎么运行的
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_plot, plot_args);
Py_DECREF(plot_args);
if(res) Py_DECREF(res);
return res;
} |
template<typename NumericX, typename NumericY>
bool stem(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = "")
{
assert(x.size() == y.size());
PyObject* xarray = get_array(x);
PyObject* yarray = get_array(y);
PyObject* pystring = PyString_FromString(s.c_str());
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xarray);
PyTuple_SetItem(plot_args, 1, yarray);
PyTuple_SetItem(plot_args, 2, pystring);
PyObject* res = PyObject_CallObject(
detail::_interpreter::get().s_python_function_stem, plot_args);
Py_DECREF(plot_args);
if (res)
Py_DECREF(res);
return res;
} |
template<typename NumericX, typename NumericY>
bool semilogx(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = "")
{
assert(x.size() == y.size());
PyObject* xarray = get_array(x);
PyObject* yarray = get_array(y);
PyObject* pystring = PyString_FromString(s.c_str());
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xarray);
PyTuple_SetItem(plot_args, 1, yarray);
PyTuple_SetItem(plot_args, 2, pystring);
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_semilogx, plot_args);
Py_DECREF(plot_args);
if(res) Py_DECREF(res);
return res;
} |
template<typename NumericX, typename NumericY>
bool semilogy(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = "")
{
assert(x.size() == y.size());
PyObject* xarray = get_array(x);
PyObject* yarray = get_array(y);
PyObject* pystring = PyString_FromString(s.c_str());
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xarray);
PyTuple_SetItem(plot_args, 1, yarray);
PyTuple_SetItem(plot_args, 2, pystring);
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_semilogy, plot_args);
Py_DECREF(plot_args);
if(res) Py_DECREF(res);
return res;
} |
template<typename NumericX, typename NumericY>
bool loglog(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = "")
{
assert(x.size() == y.size());
PyObject* xarray = get_array(x);
PyObject* yarray = get_array(y);
PyObject* pystring = PyString_FromString(s.c_str());
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xarray);
PyTuple_SetItem(plot_args, 1, yarray);
PyTuple_SetItem(plot_args, 2, pystring);
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_loglog, plot_args);
Py_DECREF(plot_args);
if(res) Py_DECREF(res);
return res;
} |
template<typename Numeric>
bool named_plot(const std::string& name, const std::vector<Numeric>& y, const std::string& format = "")
{
PyObject* kwargs = PyDict_New();
PyDict_SetItemString(kwargs, "label", PyString_FromString(name.c_str()));
PyObject* yarray = get_array(y);
PyObject* pystring = PyString_FromString(format.c_str());
PyObject* plot_args = PyTuple_New(2);
PyTuple_SetItem(plot_args, 0, yarray);
PyTuple_SetItem(plot_args, 1, pystring);
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_plot, plot_args, kwargs);
Py_DECREF(kwargs);
Py_DECREF(plot_args);
if (res) Py_DECREF(res);
return res;
} |
template<typename Numeric>
bool plot(const std::vector<Numeric>& y, const std::string& format = "")
{
std::vector<Numeric> x(y.size());
for(size_t i=0; i<x.size(); ++i) x.at(i) = i;
return plot(x,y,format);
} |
template<typename Numeric>
bool plot(const std::vector<Numeric>& y, const std::map<std::string, std::string>& keywords)
{
std::vector<Numeric> x(y.size());
for(size_t i=0; i<x.size(); ++i) x.at(i) = i;
return plot(x,y,keywords);
} |
template<typename Numeric>
bool stem(const std::vector<Numeric>& y, const std::string& format = "")
{
std::vector<Numeric> x(y.size());
for (size_t i = 0; i < x.size(); ++i) x.at(i) = i;
return stem(x, y, format);
} |
template<typename Numeric>
void text(Numeric x, Numeric y, const std::string& s = "")
{
PyObject* args = PyTuple_New(3);
PyTuple_SetItem(args, 0, PyFloat_FromDouble(x));
PyTuple_SetItem(args, 1, PyFloat_FromDouble(y));
PyTuple_SetItem(args, 2, PyString_FromString(s.c_str()));
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_text, args);
if(!res) throw std::runtime_error("Call to text() failed.");
Py_DECREF(args);
Py_DECREF(res);
} |
template<typename Numeric>
void ylim(Numeric left, Numeric right)
{
PyObject* list = PyList_New(2);
PyList_SetItem(list, 0, PyFloat_FromDouble(left));
PyList_SetItem(list, 1, PyFloat_FromDouble(right));
PyObject* args = PyTuple_New(1);
PyTuple_SetItem(args, 0, list);
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_ylim, args);
if(!res) throw std::runtime_error("Call to ylim() failed.");
Py_DECREF(args);
Py_DECREF(res);
} |
template<typename Numeric>
void xlim(Numeric left, Numeric right)
{
PyObject* list = PyList_New(2);
PyList_SetItem(list, 0, PyFloat_FromDouble(left));
PyList_SetItem(list, 1, PyFloat_FromDouble(right));
PyObject* args = PyTuple_New(1);
PyTuple_SetItem(args, 0, list);
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_xlim, args);
if(!res) throw std::runtime_error("Call to xlim() failed.");
Py_DECREF(args);
Py_DECREF(res);
} |
template<typename Numeric>
inline void xticks(const std::vector<Numeric> &ticks, const std::vector<std::string> &labels = {} |
template<typename Numeric>
inline void xticks(const std::vector<Numeric> &ticks, const std::map<std::string, std::string>& keywords)
{
xticks(ticks, {}, keywords);
} |
template<typename Numeric>
inline void yticks(const std::vector<Numeric> &ticks, const std::vector<std::string> &labels = {} |
template<typename Numeric>
inline void yticks(const std::vector<Numeric> &ticks, const std::map<std::string, std::string>& keywords)
{
yticks(ticks, {}, keywords);
} |
template<typename Numeric>
inline void pause(Numeric interval)
{
PyObject* args = PyTuple_New(1);
PyTuple_SetItem(args, 0, PyFloat_FromDouble(interval));
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_pause, args);
if(!res) throw std::runtime_error("Call to pause() failed.");
Py_DECREF(args);
Py_DECREF(res);
} |
template<typename IterableX, typename IterableY>
bool operator()(const IterableX& x, const IterableY& y, const std::string& format)
{
// 2-phase lookup for distance, begin, end
using std::distance;
using std::begin;
using std::end;
auto xs = distance(begin(x), end(x));
auto ys = distance(begin(y), end(y));
assert(xs == ys && "x and y data must have the same number of elements!");
PyObject* xlist = PyList_New(xs);
PyObject* ylist = PyList_New(ys);
PyObject* pystring = PyString_FromString(format.c_str());
auto itx = begin(x), ity = begin(y);
for(size_t i = 0; i < xs; ++i) {
PyList_SetItem(xlist, i, PyFloat_FromDouble(*itx++));
PyList_SetItem(ylist, i, PyFloat_FromDouble(*ity++));
}
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xlist);
PyTuple_SetItem(plot_args, 1, ylist);
PyTuple_SetItem(plot_args, 2, pystring);
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_plot, plot_args);
Py_DECREF(plot_args);
if(res) Py_DECREF(res);
return res;
} |
template<typename Iterable, typename Callable>
bool operator()(const Iterable& ticks, const Callable& f, const std::string& format)
{
if(begin(ticks) == end(ticks)) return true;
// We could use additional meta-programming to deduce the correct element type of y,
// but all values have to be convertible to double anyways
std::vector<double> y;
for(auto x : ticks) y.push_back(f(x));
return plot_impl<std::false_type>()(ticks,y,format);
} |
template<typename... Args>
bool plot() { return true; } |
template<typename A, typename B, typename... Args>
bool plot(const A& a, const B& b, const std::string& format, Args... args)
{
return detail::plot_impl<typename detail::is_callable<B>::type>()(a,b,format) && plot(args...);
} |
template<typename Numeric>
bool update(const std::vector<Numeric>& x, const std::vector<Numeric>& y) {
assert(x.size() == y.size());
if(set_data_fct)
{
PyObject* xarray = get_array(x);
PyObject* yarray = get_array(y);
PyObject* plot_args = PyTuple_New(2);
PyTuple_SetItem(plot_args, 0, xarray);
PyTuple_SetItem(plot_args, 1, yarray);
PyObject* res = PyObject_CallObject(set_data_fct, plot_args);
if (res) Py_DECREF(res);
return res;
}
return false;
} |
template <typename T, typename... Ts>
std::size_t size_helper(const T& first, const Ts&...)
{
return first.size();
} |
template <typename... Ts>
void multi_apply_permutation(std::vector<std::size_t>& perm, Ts&... ranges)
{
const std::size_t size = detail::size_helper(ranges...);
for (std::size_t i = 0; i < size; ++i)
{
std::size_t current = i;
auto permIt = perm.begin();
while (i != permIt[current])
{
const std::size_t next = permIt[current];
((void)std::swap(ranges[current], ranges[next]), ...);
permIt[current] = current;
current = next;
}
permIt[current] = current;
}
} |
template <typename Prim>
object
py_rotate( tuple args, dict kwargs)
{
Prim* This = extract<Prim*>( args[0]);
if (!kwargs.has_key("angle")) {
// This exception is more useful than the keyerror exception below.
throw std::invalid_argument(
"primitive.rotate(): angle of rotation must be specified.");
}
double angle = extract<double>(kwargs["angle"]);
// The rotation axis, which defaults to the body axis.
vector r_axis;
if (kwargs.has_key("axis"))
r_axis = tovector(kwargs["axis"]);
else
r_axis = This->get_axis();
// The rotation origin, which defaults to the body position.
vector origin;
if (kwargs.has_key("origin"))
origin = tovector(kwargs["origin"]);
else
origin = This->get_pos();
This->rotate( angle, r_axis, origin);
return object();
} |
template<DeviceType device_type, typename T, typename K>
void GetReduceSumWorkspaceSizeInBytes(int64_t n, int64_t m, int64_t* workspace_size_in_bytes) {
IndexedSlicesReduceSumKernelUtil<device_type, K, T, int64_t>::GetReduceSumWorkspaceSizeInBytes(
nullptr, n, m, workspace_size_in_bytes);
} |
template<class T>
constexpr const T& max(const T& a, const T& b)
{
return a < b ? b : a;
} |
template<class T>
constexpr T max(std::initializer_list<T> ilist)
{
assert(ilist.size() > 0 && "initializer list must not be empty");
const T* x = ilist.begin();
for(auto it = begin(ilist) + 1; it != end(ilist); ++it)
x = *x < *it ? it : x;
return *x;
} |
template<class T>
constexpr const T& min(const T& a, const T& b)
{
return a > b ? b : a;
} |
template<class T>
constexpr T min(std::initializer_list<T> ilist)
{
assert(ilist.size() > 0 && "initializer list must not be empty");
const T* x = ilist.begin();
for(auto it = begin(ilist) + 1; it != end(ilist); ++it)
x = *x > *it ? it : x;
return *x;
} |
template<typename TSizedRangeAtoms>
void build_vertex_buffers(TSizedRangeAtoms&& atoms)
{
auto sphere_mesh_attrs =
detail::make_reserved_vector<sphere_mesh_attribute>(atoms.size());
atoms_to_sphere_attrs(std::forward<TSizedRangeAtoms>(atoms),
std::back_inserter(sphere_mesh_attrs),
{radius_type, radius_size, 1.});
atom_sphere_buffers.build_buffers(sphere_mesh_attrs);
} |
template<typename TAtomElement>
auto atom_radius(TAtomElement element) const noexcept -> double
{
switch(radius_type) {
case atom_radius_kind::van_der_waals:
return element.rvdw;
case atom_radius_kind::covalent:
return element.rcov;
default:
return radius_size;
}
} |
template<typename A>
decltype(auto) generateSourceFromSql =
[](const string& sqlstmt){
return [&](shared_ptr<BaseClient<A>> client){
auto a = client->runQueryJson(sqlstmt);
return Rx::observable<>::iterate(a);
};
} |
template<typename A>
decltype(auto) generateSourceFromSharedCollection =
[](vector<shared_ptr<A>> a){
return Rx::observable<>::iterate(a);
} |
template<typename A>
decltype(auto) generateSourceFromCollection =
[](const vector<A>& a){
return Rx::observable<>::iterate(a);
} |
template<typename A>
decltype(auto) generateEvent =
[](const string& streamType) {
// e could be shared_ptr<json> or shared_ptr<A>
return [&](auto& e) -> shared_ptr<Event<A>> {
if (!e)
return nullptr;
auto ev = make_shared<Event<A>>();
ev->streamId = generate_uuid_v3(streamType.c_str());
ev->type = streamType;
ev->data = *e;
return ev;
};
} |
template<typename A>
decltype(auto) onNextEvent =
[](EventStore& publisher) {
return [&](shared_ptr<Event<A>> ev){
if (ev)
publisher.Append(*ev);
};
} |
template<typename A, typename B>
decltype(auto) onNextPgSqlModel =
[](const string& schema) {
return [&](shared_ptr<pgsql::Client<A>> publisher) {
return [&](shared_ptr<B> obj){
if (obj)
publisher->save(schema, *obj);
};
};
} |
template<typename B>
decltype(auto) onNextIgnore =
[]() {
return [](const B& a) {
// No op.
};
} |
template<typename B>
decltype(auto) onNextSharedIgnore =
[]() {
return [](shared_ptr<B> a) {
// No op.
};
} |
template <class T, class... Args>
void publish(T&& data, Args&&... args)
{
using type = typename std::decay<T>::type;
get<TPublisher<type>>(m_params).publish(std::move(data), std::forward<Args>(args)...);
m_current_type = TypeInfo(typeid(T));
} |
template< typename T > static constexpr T&& apply( T&& v )
{
return std::forward< T >( v );
} |
template< typename T > static constexpr auto apply( T&& v )
-> decltype( _relation::apply( std::forward< T >( v ) ) )
{
return _relation::apply( std::forward< T >( v ) );
} |
template< typename T > static constexpr auto apply( T&& v )
-> decltype(
_first_convertible::apply(
static_cast< remove_cvref_t< T > >( 1 )
) * convertible_by_impl_applier<
typename ToList::rest_type,
typename FromList::rest_type
>::apply( std::forward< T >( v ) )
)
{
return (
_first_convertible::apply(
static_cast< remove_cvref_t< T > >( 1 )
) * convertible_by_impl_applier<
typename ToList::rest_type,
typename FromList::rest_type
>::apply( std::forward< T >( v ) )
);
} |
template< typename T > static constexpr T&& apply( T&& v )
{
return std::forward< T >( v );
} |
template< typename T > static constexpr auto apply( T&& v )
-> decltype( convertible_by_impl_applier<
typename Sorted:: first_list,
typename Sorted::second_list
>::apply( std::forward< T >( v ) ) )
{
return convertible_by_impl_applier<
typename Sorted:: first_list,
typename Sorted::second_list
>::apply( std::forward< T >( v ) );
} |
template< typename T > static constexpr auto apply( T&& v )
-> decltype(
_numer_convertible::apply( std::forward< T >( v ) )
/ _denom_convertible::apply( static_cast<
remove_cvref_t< T >
>( 1 ) )
)
{
return (
_numer_convertible::apply( std::forward< T >( v ) )
/ _denom_convertible::apply( static_cast<
remove_cvref_t< T >
>( 1 ) )
);
} |
template< typename T > static constexpr T&& apply( T&& v )
{
return std::forward< T >( v );
} |
template<typename T>
static T randint(T lo, T hi){
return uniform_int_distribution<T>(lo, hi)(rng);
} |
template<typename T>
T check_oal( const char *file, int line, const T &t )
{
check_oal( file, line );
return t;
} |
template <class T>
Expr ExprSimplifier::BinaryMutate(const T *op, const Expr &e) {
auto ret_a = Mutate(op->a);
auto ret_b = Mutate(op->b);
if (is_retrieval_) return T::make(ret_a, ret_b);
// simplify each child
ArithExprSimplifier simplifier(highest_cast_type_);
ret_a = simplifier.Simplify(ret_a);
ret_b = simplifier.Simplify(ret_b);
return T::make(ret_a, ret_b);
} |
template <class T>
Expr ExprSimplifier::BinaryBoolMutate(const T *op, const Expr &e) {
auto ret_a = Mutate(op->a);
auto ret_b = Mutate(op->b);
if (is_retrieval_) return T::make(ret_a, ret_b);
// simplify each child
ArithExprSimplifier simplifier(op->type);
ret_a = simplifier.Simplify(ret_a);
ret_b = simplifier.Simplify(ret_b);
return T::make(ret_a, ret_b);
} |
template <class OP>
void
noexec_error( OP const& op )
{
// std::cerr << "error: no execute method in `" << typeid(op).name() << "'\n" << std::hex << op.address << ":\t";
// op.disasm( std::cerr );
// std::cerr << '\n';
throw ProcessorBase::Unimplemented();
} |
template <typename Derived, typename ProblemT>
statespace::dart::ConstMetaSkeletonStateSpacePtr
SingleProblemPlanner<Derived, ProblemT>::getMetaSkeletonStateSpace() const
{
return mMetaSkeletonStateSpace;
} |
template <typename Derived, typename ProblemT>
::dart::dynamics::MetaSkeletonPtr
SingleProblemPlanner<Derived, ProblemT>::getMetaSkeleton()
{
return mMetaSkeleton;
} |
template<int Chip>
uint8_t towns_state::towns_dma_r(offs_t offset)
{
logerror("DMA#%01x: read register %i\n",Chip,offset);
return m_dma[Chip]->read(offset);
} |
template<int Chip>
void towns_state::towns_dma_w(offs_t offset, uint8_t data)
{
logerror("DMA#%01x: wrote 0x%02x to register %i\n",Chip,data,offset);
m_dma[Chip]->write(offset, data);
} |
template<size_t nbits, size_t es>
void TestULP()
{
using namespace std;
using namespace sw::universal;
posit<nbits, es> a(1.0f);
cout << typeid(a).name() << '\n';
// double da(1.0);
cout << "posit at 1.0 : " << to_binary(a) << " : ULP : " << to_binary(ulp(a)) << '\n';
// cout << "double at 1.0 : " << to_binary(da) << " : ULP : " << to_binary(ulp(da)) << '\n';
a = std::numeric_limits< posit<64, 3> >::epsilon();
cout << "posit epsilon : " << to_binary(a) << " : " << a << '\n';
} |
template <typename Dur>
auto round_down(TimePoint time) {
return std::chrono::floor<Dur>(time);
} |
template <typename Dur>
auto round_up(TimePoint time) {
return std::chrono::ceil<Dur>(time);
} |
template<typename T>
inline void Mat3<T>::Set(const Vec3<T>& diagonal)
{
Set(diagonal.x, diagonal.y, diagonal.z);
} |
template<typename T>
inline void Mat3<T>::Set(const T& d00, const T& d11, const T& d22)
{
elements[0] = d00;
elements[4] = d11;
elements[8] = d22;
} |
template<typename T>
inline Mat3<T>& Mat3<T>::operator+=(const Mat3<T>& right)
{
for (uint8_t i = 0; i < 9; ++i)
elements[i] += right.elements[i];
return *this;
} |
template<typename T>
inline Mat3<T>& Mat3<T>::operator-=(const Mat3<T>& right)
{
for (uint8_t i = 0; i < 9; ++i)
elements[i] -= right.elements[i];
return *this;
} |
template<typename T>
inline Mat3<T>& Mat3<T>::operator*=(const Mat3<T>& right)
{
for (uint8_t i = 0; i < 9; ++i)
elements[i] *= right.elements[i];
return *this;
} |
template<typename T>
inline Mat3<T>& Mat3<T>::operator*=(const T& value)
{
for (uint8_t i = 0; i < 9; ++i)
elements[i] *= value;
return *this;
} |
template<typename T>
inline Mat3<T> Mat3<T>::Rotate(const Vec3<T>& axis, const T& radian)
{
Mat3<T> tmp;
float radian_cos = MathUtils::Cos(radian);
float radian_sin = MathUtils::Sin(radian);
float tmpNum = 1 - radian_cos;
tmp.elements[0] = axis.x * axis.x * tmpNum + radian_cos;
tmp.elements[1] = axis.y * axis.x * tmpNum + axis.z * radian_sin;
tmp.elements[2] = axis.x * axis.z * tmpNum - axis.y * radian_sin;
tmp.elements[3] = axis.y * axis.x * tmpNum - axis.z * radian_sin;
tmp.elements[4] = axis.y * axis.y * tmpNum + radian_cos;
tmp.elements[5] = axis.z * axis.y * tmpNum + axis.x * radian_sin;
tmp.elements[6] = axis.x * axis.z * tmpNum + axis.y * radian_sin;
tmp.elements[7] = axis.z * axis.y * tmpNum - axis.x * radian_sin;
tmp.elements[8] = axis.z * axis.z * tmpNum + radian_cos;
return tmp;
} |
template<typename T>
inline Mat3<T> Mat3<T>::Scale(const T& factor)
{
Mat3<T> tmp;
tmp.Set(Vec3<T>(factor));
return tmp;
} |
template<typename T>
inline Mat3<T> Mat3<T>::Scale(const Vec3<T>& factor)
{
Mat3<T> tmp;
tmp.Set(factor);
return tmp;
} |
template<typename T>
inline Mat3<T> Mat3<T>::Transpose(const Mat3<T>& right)
{
Mat3<T> tmp = right;
tmp.elements[1] = right.elements[3];
tmp.elements[2] = right.elements[6];
tmp.elements[3] = right.elements[1];
tmp.elements[5] = right.elements[7];
tmp.elements[6] = right.elements[2];
tmp.elements[7] = right.elements[5];
return tmp;
} |
template<typename T>
inline Mat3<T> Mat3<T>::Inverse(const Mat3<T>& right)
{
return Mat3<T>::Adjoint(right) / Mat3<T>::Determinant(right);
} |
template<typename T>
inline T Mat3<T>::Determinant(const Mat3<T>& right)
{
return right.elements[0] * right.elements[4] * right.elements[8] +
right.elements[3] * right.elements[7] * right.elements[2] +
right.elements[6] * right.elements[1] * right.elements[5] -
right.elements[6] * right.elements[4] * right.elements[2] -
right.elements[5] * right.elements[7] * right.elements[0] -
right.elements[8] * right.elements[1] * right.elements[3];
} |
template<typename T>
inline Mat4<T> Mat3<T>::ToMat4(const Mat3<T>& matrix)
{
Mat4<T> tmp;
tmp.col[0] = _mm_set_ps(static_cast<T>(0.0f), matrix.elements[2], matrix.elements[1], matrix.elements[0]);
tmp.col[1] = _mm_set_ps(static_cast<T>(0.0f), matrix.elements[5], matrix.elements[4], matrix.elements[3]);
tmp.col[2] = _mm_set_ps(static_cast<T>(0.0f), matrix.elements[8], matrix.elements[7], matrix.elements[6]);
tmp.col[3] = _mm_set_ps(static_cast<T>(1.0f), static_cast<T>(0.0f), static_cast<T>(0.0f), static_cast<T>(0.0f));
return tmp;
} |
template<typename T>
inline Mat3<T> operator+(const Mat3<T>& left, const Mat3<T>& right)
{
Mat3<T> tmp;
for (uint8_t i = 0; i < 9; ++i)
tmp.elements[i] = left.elements[i] + right.elements[i];
return tmp;
} |
template<typename T>
inline Mat3<T> operator-(const Mat3<T>& left, const Mat3<T>& right)
{
Mat3<T> tmp;
for (uint8_t i = 0; i < 9; ++i)
tmp.elements[i] = left.elements[i] - right.elements[i];
return tmp;
} |
template<typename T>
inline Mat3<T> operator*(const Mat3<T>& left, const Mat3<T>& right)
{
Mat3<T> tmp;
for (uint32_t i = 0; i < 9; ++i)
tmp.elements[i] = left.elements[i] + right.elements[i];
return tmp;
} |
template<typename T>
inline Mat3<T> operator/(const Mat3<T>& left, const T& value)
{
if (!MathUtils::IsNearZero(value))
{
Mat3<T> tmp;
for (uint8_t i = 0; i < 9; ++i)
tmp.elements[i] /= value;
return tmp;
}
return left;
} |
template<typename T>
inline Mat3<T> operator*(const Mat3<T>& left, const T& value)
{
Mat3<T> tmp;
for (uint8_t i = 0; i < 9; ++i)
tmp.elements[i] *= value;
return tmp;
} |
template<typename T>
inline Mat3<T> operator*(const T& value, const Mat3<T>& right)
{
return right * value;
} |
template<typename T>
inline bool operator==(const Mat3<T>& left, const Mat3<T>& right)
{
for (uint8_t i = 0; i < 9; ++i)
if (left.elements[i] != right.elements[i])
return false;
return true;
} |
template<typename K, typename V> inline static void map_put(map<K, V>& m, const K& k, const V& v)
{
m.insert(typename map<K, V>::value_type(k, v));
} |
template<typename K, typename V> inline static V * map_get(const map<K, V>& m, const K& k, bool raise = true)
{
typename map<K, V>::const_iterator it = m.find(k);
if (it == m.end()) {
if (raise) {
THROW_FORMATTED(std::out_of_range, "key not found: " << k << ", map type = " << typeid(m).name());
}
else {
return NULL;
}
}
return const_cast<V*>(&it->second);
} |
template<typename K, typename V> inline static bool map_contains(map<K, V>& m, const K& k)
{
typename map<K, V>::const_iterator it = m.find(k);
return it != m.end();
} |
template <typename T> void operator()(T*) {} |
template <class ToDuration, class FromDuration>
__host__ __device__
void
test(const FromDuration& f, const ToDuration& d)
{
{
typedef decltype(cuda::std::chrono::duration_cast<ToDuration>(f)) R;
static_assert((cuda::std::is_same<R, ToDuration>::value), "");
assert(cuda::std::chrono::duration_cast<ToDuration>(f) == d);
}
} |
template<typename MapPair, typename T>
void operator()(MapPair& where, const T&) const
{
++where.second;
} |
template <typename Vertex, typename Map>
void operator()(Vertex v, Map m) const
{
typedef analysis_map_insert insert_func;
size_t cc = v.property().get_cc();
m[cc] += 1;
} |
template <typename Map>
result_type operator()(Map m) const
{
double max = -1.;
size_t m_size = m.size();
if (m_size == 0) {
return 0.;
}
for (auto&& i : m) {
if (i.second > max) {
max = i.second;
}
}
return max;
} |
End of preview. Expand
in Dataset Viewer.
No dataset card yet
- Downloads last month
- 2