$search
00001 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au) 00002 // Copyright (C) 2010-2011 Conrad Sanderson 00003 // 00004 // This file is part of the Armadillo C++ library. 00005 // It is provided without any warranty of fitness 00006 // for any purpose. You can redistribute this file 00007 // and/or modify it under the terms of the GNU 00008 // Lesser General Public License (LGPL) as published 00009 // by the Free Software Foundation, either version 3 00010 // of the License or (at your option) any later version. 00011 // (see http://www.opensource.org/licenses for more info) 00012 00013 00016 00017 00018 00019 // structures for template based restrictions of input/output arguments 00020 // (part of the SFINAE approach) 00021 // http://en.wikipedia.org/wiki/SFINAE 00022 00023 00024 template<typename T> struct arma_scalar_only { }; 00025 00026 template<> struct arma_scalar_only<u8> { typedef u8 result; }; 00027 template<> struct arma_scalar_only<s8> { typedef s8 result; }; 00028 template<> struct arma_scalar_only<u16> { typedef u16 result; }; 00029 template<> struct arma_scalar_only<s16> { typedef s16 result; }; 00030 template<> struct arma_scalar_only<u32> { typedef u32 result; }; 00031 template<> struct arma_scalar_only<s32> { typedef s32 result; }; 00032 #if defined(ARMA_64BIT_WORD) 00033 template<> struct arma_scalar_only<u64> { typedef u64 result; }; 00034 template<> struct arma_scalar_only<s64> { typedef s64 result; }; 00035 #endif 00036 template<> struct arma_scalar_only<float> { typedef float result; }; 00037 template<> struct arma_scalar_only<double> { typedef double result; }; 00038 00039 00040 template<typename T> 00041 struct arma_scalar_only< std::complex<T> > { typedef std::complex<T> result; }; 00042 00043 00044 00045 template<typename T> struct arma_integral_only { }; 00046 00047 template<> struct arma_integral_only<u8> { typedef u8 result; }; 00048 template<> struct arma_integral_only<s8> { typedef s8 result; }; 00049 template<> struct arma_integral_only<u16> { typedef u16 result; }; 00050 template<> struct arma_integral_only<s16> { typedef s16 result; }; 00051 template<> struct arma_integral_only<u32> { typedef u32 result; }; 00052 template<> struct arma_integral_only<s32> { typedef s32 result; }; 00053 #if defined(ARMA_64BIT_WORD) 00054 template<> struct arma_integral_only<u64> { typedef u64 result; }; 00055 template<> struct arma_integral_only<s64> { typedef s64 result; }; 00056 #endif 00057 00058 00059 00060 template<typename T> struct arma_unsigned_integral_only { }; 00061 00062 template<> struct arma_unsigned_integral_only<u8> { typedef u8 result; }; 00063 template<> struct arma_unsigned_integral_only<u16> { typedef u16 result; }; 00064 template<> struct arma_unsigned_integral_only<u32> { typedef u32 result; }; 00065 #if defined(ARMA_64BIT_WORD) 00066 template<> struct arma_unsigned_integral_only<u64> { typedef u64 result; }; 00067 #endif 00068 00069 00070 00071 template<typename T> struct arma_signed_integral_only { }; 00072 00073 template<> struct arma_signed_integral_only<s8> { typedef s8 result; }; 00074 template<> struct arma_signed_integral_only<s16> { typedef s16 result; }; 00075 template<> struct arma_signed_integral_only<s32> { typedef s32 result; }; 00076 #if defined(ARMA_64BIT_WORD) 00077 template<> struct arma_signed_integral_only<s64> { typedef s64 result; }; 00078 #endif 00079 00080 00081 00082 template<typename T> struct arma_signed_only { }; 00083 00084 template<> struct arma_signed_only<s8> { typedef s8 result; }; 00085 template<> struct arma_signed_only<s16> { typedef s16 result; }; 00086 template<> struct arma_signed_only<s32> { typedef s32 result; }; 00087 #if defined(ARMA_64BIT_WORD) 00088 template<> struct arma_signed_only<s64> { typedef s64 result; }; 00089 #endif 00090 template<> struct arma_signed_only<float> { typedef float result; }; 00091 template<> struct arma_signed_only<double> { typedef double result; }; 00092 00093 template<typename T> struct arma_signed_only< std::complex<T> > { typedef std::complex<T> result; }; 00094 00095 00096 00097 template<typename T> struct arma_float_only { }; 00098 00099 template<> struct arma_float_only<float> { typedef float result; }; 00100 template<> struct arma_float_only<double> { typedef double result; }; 00101 00102 00103 00104 template<typename T> struct arma_float_or_cx_only { }; 00105 00106 template<> struct arma_float_or_cx_only< float > { typedef float result; }; 00107 template<> struct arma_float_or_cx_only< double > { typedef double result; }; 00108 template<> struct arma_float_or_cx_only< std::complex<float> > { typedef std::complex<float> result; }; 00109 template<> struct arma_float_or_cx_only< std::complex<double> > { typedef std::complex<double> result; }; 00110 00111 00112 00113 template<typename T> struct arma_cx_only { }; 00114 00115 template<> struct arma_cx_only< std::complex<float> > { typedef std::complex<float> result; }; 00116 template<> struct arma_cx_only< std::complex<double> > { typedef std::complex<double> result; }; 00117 00118 00119 00120 template<typename T> struct arma_not_cx { typedef T result; }; 00121 template<typename T> struct arma_not_cx< std::complex<T> > { }; 00122 00123 00124 00125 template<typename T> struct arma_blas_type_only { }; 00126 00127 template<> struct arma_blas_type_only< float > { typedef float result; }; 00128 template<> struct arma_blas_type_only< double > { typedef double result; }; 00129 template<> struct arma_blas_type_only< std::complex<float> > { typedef std::complex<float> result; }; 00130 template<> struct arma_blas_type_only< std::complex<double> > { typedef std::complex<double> result; }; 00131 00132 00133 00134 template<typename T> struct arma_op_rel_only { }; 00135 00136 template<> struct arma_op_rel_only< op_rel_lt_pre > { typedef int result; }; 00137 template<> struct arma_op_rel_only< op_rel_lt_post > { typedef int result; }; 00138 template<> struct arma_op_rel_only< op_rel_gt_pre > { typedef int result; }; 00139 template<> struct arma_op_rel_only< op_rel_gt_post > { typedef int result; }; 00140 template<> struct arma_op_rel_only< op_rel_lteq_pre > { typedef int result; }; 00141 template<> struct arma_op_rel_only< op_rel_lteq_post > { typedef int result; }; 00142 template<> struct arma_op_rel_only< op_rel_gteq_pre > { typedef int result; }; 00143 template<> struct arma_op_rel_only< op_rel_gteq_post > { typedef int result; }; 00144 template<> struct arma_op_rel_only< op_rel_eq > { typedef int result; }; 00145 template<> struct arma_op_rel_only< op_rel_noteq > { typedef int result; }; 00146 00147 00148 00149 template<typename T> struct arma_not_op_rel { typedef int result; }; 00150 00151 template<> struct arma_not_op_rel< op_rel_lt_pre > { }; 00152 template<> struct arma_not_op_rel< op_rel_lt_post > { }; 00153 template<> struct arma_not_op_rel< op_rel_gt_pre > { }; 00154 template<> struct arma_not_op_rel< op_rel_gt_post > { }; 00155 template<> struct arma_not_op_rel< op_rel_lteq_pre > { }; 00156 template<> struct arma_not_op_rel< op_rel_lteq_post > { }; 00157 template<> struct arma_not_op_rel< op_rel_gteq_pre > { }; 00158 template<> struct arma_not_op_rel< op_rel_gteq_post > { }; 00159 template<> struct arma_not_op_rel< op_rel_eq > { }; 00160 template<> struct arma_not_op_rel< op_rel_noteq > { }; 00161 00162 00163 00164 template<typename T> struct arma_glue_rel_only { }; 00165 00166 template<> struct arma_glue_rel_only< glue_rel_lt > { typedef int result; }; 00167 template<> struct arma_glue_rel_only< glue_rel_gt > { typedef int result; }; 00168 template<> struct arma_glue_rel_only< glue_rel_lteq > { typedef int result; }; 00169 template<> struct arma_glue_rel_only< glue_rel_gteq > { typedef int result; }; 00170 template<> struct arma_glue_rel_only< glue_rel_eq > { typedef int result; }; 00171 template<> struct arma_glue_rel_only< glue_rel_noteq > { typedef int result; }; 00172 00173 00174 00175 template<typename T> struct arma_Mat_Col_Row_only { }; 00176 00177 template<typename eT> struct arma_Mat_Col_Row_only< Mat<eT> > { typedef Mat<eT> result; }; 00178 template<typename eT> struct arma_Mat_Col_Row_only< Col<eT> > { typedef Col<eT> result; }; 00179 template<typename eT> struct arma_Mat_Col_Row_only< Row<eT> > { typedef Row<eT> result; }; 00180 00181 00182 00183 template<typename T> struct arma_Cube_only { }; 00184 template<typename eT> struct arma_Cube_only< Cube<eT> > { typedef Cube<eT> result; }; 00185 00186 00187