mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd::math: Add vector fallbacks for standard exp.
This commit is contained in:
parent
480722b3b8
commit
31425a5ca0
2 changed files with 68 additions and 0 deletions
67
include/ircd/math/exp.h
Normal file
67
include/ircd/math/exp.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2021 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_MATH_EXP_H
|
||||
|
||||
namespace ircd::math
|
||||
{
|
||||
template<class T>
|
||||
typename std::enable_if<simd::is<T>(), T>::type
|
||||
exp(T);
|
||||
|
||||
template<class T>
|
||||
typename std::enable_if<simd::is<T>(), T>::type
|
||||
expf(T);
|
||||
|
||||
template<class T>
|
||||
typename std::enable_if<simd::is<T>(), T>::type
|
||||
expl(T);
|
||||
}
|
||||
|
||||
namespace ircd
|
||||
{
|
||||
using ::exp;
|
||||
using ::expf;
|
||||
using ::expl;
|
||||
using math::exp;
|
||||
using math::expf;
|
||||
using math::expl;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename std::enable_if<ircd::simd::is<T>(), T>::type
|
||||
ircd::math::expl(T a)
|
||||
{
|
||||
for(uint i(0); i < simd::lanes<T>(); ++i)
|
||||
a[i] = ::expl(a[i]);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename std::enable_if<ircd::simd::is<T>(), T>::type
|
||||
ircd::math::expf(T a)
|
||||
{
|
||||
for(uint i(0); i < simd::lanes<T>(); ++i)
|
||||
a[i] = ::expf(a[i]);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename std::enable_if<ircd::simd::is<T>(), T>::type
|
||||
ircd::math::exp(T a)
|
||||
{
|
||||
for(uint i(0); i < simd::lanes<T>(); ++i)
|
||||
a[i] = std::exp(a[i]);
|
||||
|
||||
return a;
|
||||
}
|
|
@ -16,5 +16,6 @@
|
|||
#include "mean.h"
|
||||
#include "tanh.h"
|
||||
#include "pow.h"
|
||||
#include "exp.h"
|
||||
#include "fmma.h"
|
||||
#include "norm.h"
|
||||
|
|
Loading…
Reference in a new issue