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