Files
blis/cpp/blis_util.hh
Chithra Sankar c195d9a576 CPP template wrapper implementation done for all BLASroutines
Change-Id: I1692988b81971379f2ba2e8f7bd126c8ccccb926
2019-08-28 12:11:53 +05:30

74 lines
2.6 KiB
C++

/******************************************************************************
* Copyright (c) 2019 - present Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*******************************************************************************/
/*! @file blis_util.hh
* blis_util.hh defines all the utility functions to be invoked in CPP template
* interfaces
* */
#ifndef BLIS_UTIL_HH
#define BLIS_UTIL_HH
namespace blis {
// -----------------------------------------------------------------------------
// for any combination of types, determine associated real, scalar,
// and complex types.
//
// real_type< float > is float
// real_type< float, double, complex<float> > is double
//
// scalar_type< float > is float
// scalar_type< float, complex<float> > is complex<float>
// scalar_type< float, double, complex<float> > is complex<double>
//
// complex_type< float > is complex<float>
// complex_type< float, double > is complex<double>
// complex_type< float, double, complex<float> > is complex<double>
// for zero types
template< typename... Types >
struct real_type_traits;
// define real_type<> type alias
template< typename... Types >
using real_type = typename real_type_traits< Types... >::real_t;
// for one type
template< typename T >
struct real_type_traits<T>
{
using real_t = T;
};
// for one complex type, strip complex
template< typename T >
struct real_type_traits< std::complex<T> >
{
using real_t = T;
};
} // namespace blis
#endif // #ifndef BLIS_UTIL_HH