Skip to content

Commit

Permalink
Merge pull request #374 from ax3l/topic-mathTan
Browse files Browse the repository at this point in the history
Add support for `math::tan`
  • Loading branch information
psychocoderHPC committed Apr 28, 2014
2 parents 045f572 + 00f168f commit 81faeab
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 64 deletions.
71 changes: 45 additions & 26 deletions src/libPMacc/include/algorithms/math/defines/trigo.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
/**
* Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch
* Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch, Axel Huebl
*
* This file is part of libPMacc.
*
* libPMacc is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* libPMacc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with libPMacc.
* If not, see <http://www.gnu.org/licenses/>.
*/

* This file is part of libPMacc.
*
* libPMacc is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libPMacc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with libPMacc.
* If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

Expand All @@ -36,6 +36,9 @@ struct Sin;
template<typename Type>
struct Cos;

template<typename Type>
struct Tan;

template<typename ArgType, typename SinType, typename CosType>
struct SinCos;

Expand All @@ -44,29 +47,45 @@ struct Sinc;


template<typename T1>
HDINLINE static typename Sin< T1 >::result sin(const T1& value)
HDINLINE static
typename Sin< T1 >::result
sin(const T1& value)
{
return Sin< T1 > ()(value);
}

template<typename T1>
HDINLINE static typename Cos<T1>::result cos(const T1& value)
HDINLINE static
typename Cos<T1>::result
cos(const T1& value)
{
return Cos< T1 > ()(value);
}

template<typename T1>
HDINLINE static
typename Tan<T1>::result
tan(const T1& value)
{
return Tan< T1 > ()(value);
}

template<typename ArgType, typename SinType, typename CosType>
HDINLINE static typename SinCos< ArgType, SinType, CosType >::result sincos(ArgType arg, SinType& sinValue, CosType& cosValue)
HDINLINE static
typename SinCos< ArgType, SinType, CosType >::result
sincos(ArgType arg, SinType& sinValue, CosType& cosValue)
{
return SinCos< ArgType, SinType, CosType > ()(arg, sinValue, cosValue);
}

template<typename T1>
HDINLINE static typename Sinc<T1>::result sinc(const T1& value)
HDINLINE static
typename Sinc<T1>::result
sinc(const T1& value)
{
return Sinc< T1 > ()(value);
}

} //namespace math
} //namespace algorithms
}//namespace PMacc
} /* namespace math */
} /* namespace algorithms */
} /* namespace PMacc */
49 changes: 30 additions & 19 deletions src/libPMacc/include/algorithms/math/doubleMath/trigo.tpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
/**
* Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch
* Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch, Axel Huebl
*
* This file is part of libPMacc.
*
* libPMacc is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* libPMacc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with libPMacc.
* If not, see <http://www.gnu.org/licenses/>.
*/

* This file is part of libPMacc.
*
* libPMacc is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libPMacc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with libPMacc.
* If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

Expand Down Expand Up @@ -54,6 +54,17 @@ struct Cos<double>
}
};

template<>
struct Tan<double>
{
typedef double result;

HDINLINE double operator( )(const double& value )
{
return ::tan( value );
}
};

template<>
struct SinCos<double, double, double>
{
Expand Down
50 changes: 31 additions & 19 deletions src/libPMacc/include/algorithms/math/floatMath/trigo.tpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
/**
* Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch
* Copyright 2013-2014 Heiko Burau, Rene Widera, Richard Pausch, Axel Huebl
*
* This file is part of libPMacc.
*
* libPMacc is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* libPMacc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with libPMacc.
* If not, see <http://www.gnu.org/licenses/>.
*/

* This file is part of libPMacc.
*
* libPMacc is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libPMacc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with libPMacc.
* If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "types.h"
Expand Down Expand Up @@ -53,6 +54,17 @@ struct Cos<float>
}
};

template<>
struct Tan<float>
{
typedef float result;

HDINLINE float operator( )(const float& value )
{
return ::tanf( value );
}
};

template<>
struct SinCos<float, float, float>
{
Expand Down

0 comments on commit 81faeab

Please sign in to comment.