Skip to content

Instantly share code, notes, and snippets.

@OXPHOS
Last active July 24, 2016 11:56
Show Gist options
  • Save OXPHOS/8f2d048e71df1dfc98bb7e2f0953c30e to your computer and use it in GitHub Desktop.
Save OXPHOS/8f2d048e71df1dfc98bb7e2f0953c30e to your computer and use it in GitHub Desktop.
class LinalgBackendBase
{
public:
/**
* Wrapper method that computes mean of SGVectors and SGMatrices.
*
* @see linalg::mean
*/
#define BACKEND_GENERIC_COMPLEX_MEAN(Type, Container) \
virtual typename std::enable_if<std::is_same<Type, complex128_t>::type, complex128_t>::type \
mean_test(const Container<Type>& a) const \
{ \
SG_SNOTIMPLEMENTED; \
}
BACKEND_GENERIC_COMPLEX_MEAN(int8_t, SGVector)
#undef BACKEND_GENERIC_COMPLEX_MEAN
}
template<typename T, template <typename> class Container>
typename std::enable_if<std::is_same<T, complex128_t>::type, complex128_t>::type
mean_test(const Container<T>& a)
{
REQUIRE(a.size() > 0, "Vector/Matrix cannot be empty!\n");
return infer_backend(a)->mean(a);
}
template <typename T, template <typename> class Container>
typename std::enable_if<!std::is_same<T, complex128_t>::type, complex128_t>::type
mean_test(const Container<T>& a)
{
REQUIRE(a.size() > 0, "Vector/Matrix cannot be empty!\n");
return infer_backend(a)->mean(a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment