// Copyright (C) 2008-2015 National ICT Australia (NICTA) // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // ------------------------------------------------------------------- // // Written by Conrad Sanderson - http://conradsanderson.id.au //! \addtogroup traits //! @{ template struct get_pod_type { typedef T1 result; }; template struct get_pod_type< std::complex > { typedef T2 result; }; template struct is_Mat_fixed_only { typedef char yes[1]; typedef char no[2]; template static yes& check(typename X::Mat_fixed_type*); template static no& check(...); static const bool value = ( sizeof(check(0)) == sizeof(yes) ); }; template struct is_Row_fixed_only { typedef char yes[1]; typedef char no[2]; template static yes& check(typename X::Row_fixed_type*); template static no& check(...); static const bool value = ( sizeof(check(0)) == sizeof(yes) ); }; template struct is_Col_fixed_only { typedef char yes[1]; typedef char no[2]; template static yes& check(typename X::Col_fixed_type*); template static no& check(...); static const bool value = ( sizeof(check(0)) == sizeof(yes) ); }; template struct is_Mat_fixed { static const bool value = ( is_Mat_fixed_only::value || is_Row_fixed_only::value || is_Col_fixed_only::value ); }; template struct is_Mat_only { static const bool value = is_Mat_fixed_only::value; }; template struct is_Mat_only< Mat > { static const bool value = true; }; template struct is_Mat_only< const Mat > { static const bool value = true; }; template struct is_Mat { static const bool value = ( is_Mat_fixed_only::value || is_Row_fixed_only::value || is_Col_fixed_only::value ); }; template struct is_Mat< Mat > { static const bool value = true; }; template struct is_Mat< const Mat > { static const bool value = true; }; template struct is_Mat< Row > { static const bool value = true; }; template struct is_Mat< const Row > { static const bool value = true; }; template struct is_Mat< Col > { static const bool value = true; }; template struct is_Mat< const Col > { static const bool value = true; }; template struct is_Row { static const bool value = is_Row_fixed_only::value; }; template struct is_Row< Row > { static const bool value = true; }; template struct is_Row< const Row > { static const bool value = true; }; template struct is_Col { static const bool value = is_Col_fixed_only::value; }; template struct is_Col< Col > { static const bool value = true; }; template struct is_Col< const Col > { static const bool value = true; }; template struct is_diagview { static const bool value = false; }; template struct is_diagview< diagview > { static const bool value = true; }; template struct is_diagview< const diagview > { static const bool value = true; }; template struct is_subview { static const bool value = false; }; template struct is_subview< subview > { static const bool value = true; }; template struct is_subview< const subview > { static const bool value = true; }; template struct is_subview_row { static const bool value = false; }; template struct is_subview_row< subview_row > { static const bool value = true; }; template struct is_subview_row< const subview_row > { static const bool value = true; }; template struct is_subview_col { static const bool value = false; }; template struct is_subview_col< subview_col > { static const bool value = true; }; template struct is_subview_col< const subview_col > { static const bool value = true; }; template struct is_subview_elem1 { static const bool value = false; }; template struct is_subview_elem1< subview_elem1 > { static const bool value = true; }; template struct is_subview_elem1< const subview_elem1 > { static const bool value = true; }; template struct is_subview_elem2 { static const bool value = false; }; template struct is_subview_elem2< subview_elem2 > { static const bool value = true; }; template struct is_subview_elem2< const subview_elem2 > { static const bool value = true; }; // // // template struct is_Cube { static const bool value = false; }; template struct is_Cube< Cube > { static const bool value = true; }; template struct is_subview_cube { static const bool value = false; }; template struct is_subview_cube< subview_cube > { static const bool value = true; }; // // // template struct is_Gen { static const bool value = false; }; template struct is_Gen< Gen > { static const bool value = true; }; template struct is_Gen< const Gen > { static const bool value = true; }; template struct is_Op { static const bool value = false; }; template struct is_Op< Op > { static const bool value = true; }; template struct is_Op< const Op > { static const bool value = true; }; template struct is_eOp { static const bool value = false; }; template struct is_eOp< eOp > { static const bool value = true; }; template struct is_eOp< const eOp > { static const bool value = true; }; template struct is_mtOp { static const bool value = false; }; template struct is_mtOp< mtOp > { static const bool value = true; }; template struct is_mtOp< const mtOp > { static const bool value = true; }; template struct is_Glue { static const bool value = false; }; template struct is_Glue< Glue > { static const bool value = true; }; template struct is_Glue< const Glue > { static const bool value = true; }; template struct is_eGlue { static const bool value = false; }; template struct is_eGlue< eGlue > { static const bool value = true; }; template struct is_eGlue< const eGlue > { static const bool value = true; }; template struct is_mtGlue { static const bool value = false; }; template struct is_mtGlue< mtGlue > { static const bool value = true; }; template struct is_mtGlue< const mtGlue > { static const bool value = true; }; // // template struct is_glue_times { static const bool value = false; }; template struct is_glue_times< Glue > { static const bool value = true; }; template struct is_glue_times< const Glue > { static const bool value = true; }; template struct is_glue_times_diag { static const bool value = false; }; template struct is_glue_times_diag< Glue > { static const bool value = true; }; template struct is_glue_times_diag< const Glue > { static const bool value = true; }; template struct is_op_diagmat { static const bool value = false; }; template struct is_op_diagmat< Op > { static const bool value = true; }; template struct is_op_diagmat< const Op > { static const bool value = true; }; template struct is_op_strans { static const bool value = false; }; template struct is_op_strans< Op > { static const bool value = true; }; template struct is_op_strans< const Op > { static const bool value = true; }; template struct is_op_htrans { static const bool value = false; }; template struct is_op_htrans< Op > { static const bool value = true; }; template struct is_op_htrans< const Op > { static const bool value = true; }; template struct is_op_htrans2 { static const bool value = false; }; template struct is_op_htrans2< Op > { static const bool value = true; }; template struct is_op_htrans2< const Op > { static const bool value = true; }; // // template struct is_Mat_trans { static const bool value = false; }; template struct is_Mat_trans< Op > { static const bool value = is_Mat::value; }; template struct is_Mat_trans< Op > { static const bool value = is_Mat::value; }; // // template struct is_GenCube { static const bool value = false; }; template struct is_GenCube< GenCube > { static const bool value = true; }; template struct is_OpCube { static const bool value = false; }; template struct is_OpCube< OpCube > { static const bool value = true; }; template struct is_eOpCube { static const bool value = false; }; template struct is_eOpCube< eOpCube > { static const bool value = true; }; template struct is_mtOpCube { static const bool value = false; }; template struct is_mtOpCube< mtOpCube > { static const bool value = true; }; template struct is_GlueCube { static const bool value = false; }; template struct is_GlueCube< GlueCube > { static const bool value = true; }; template struct is_eGlueCube { static const bool value = false; }; template struct is_eGlueCube< eGlueCube > { static const bool value = true; }; template struct is_mtGlueCube { static const bool value = false; }; template struct is_mtGlueCube< mtGlueCube > { static const bool value = true; }; // // // template struct is_op_rel { static const bool value = false; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; template struct is_op_rel< mtOp > { static const bool value = true; }; // // // template struct is_basevec { static const bool value = ( is_Row_fixed_only::value || is_Col_fixed_only::value ); }; template struct is_basevec< Row > { static const bool value = true; }; template struct is_basevec< const Row > { static const bool value = true; }; template struct is_basevec< Col > { static const bool value = true; }; template struct is_basevec< const Col > { static const bool value = true; }; template struct is_basevec< subview_row > { static const bool value = true; }; template struct is_basevec< const subview_row > { static const bool value = true; }; template struct is_basevec< subview_col > { static const bool value = true; }; template struct is_basevec< const subview_col > { static const bool value = true; }; template struct is_basevec< diagview > { static const bool value = true; }; template struct is_basevec< const diagview > { static const bool value = true; }; template struct is_basevec< subview_elem1 > { static const bool value = true; }; template struct is_basevec< const subview_elem1 > { static const bool value = true; }; // // // template struct is_arma_type { static const bool value = is_Mat::value || is_Gen::value || is_Op::value || is_Glue::value || is_eOp::value || is_eGlue::value || is_mtOp::value || is_mtGlue::value || is_diagview::value || is_subview::value || is_subview_row::value || is_subview_col::value || is_subview_elem1::value || is_subview_elem2::value ; }; template struct is_arma_cube_type { static const bool value = is_Cube::value || is_GenCube::value || is_OpCube::value || is_eOpCube::value || is_mtOpCube::value || is_GlueCube::value || is_eGlueCube::value || is_mtGlueCube::value || is_subview_cube::value ; }; // // // template struct is_SpMat { static const bool value = false; }; template struct is_SpMat< SpMat > { static const bool value = true; }; template struct is_SpMat< SpCol > { static const bool value = true; }; template struct is_SpMat< SpRow > { static const bool value = true; }; template struct is_SpRow { static const bool value = false; }; template struct is_SpRow< SpRow > { static const bool value = true; }; template struct is_SpCol { static const bool value = false; }; template struct is_SpCol< SpCol > { static const bool value = true; }; template struct is_SpSubview { static const bool value = false; }; template struct is_SpSubview< SpSubview > { static const bool value = true; }; template struct is_SpOp { static const bool value = false; }; template struct is_SpOp< SpOp > { static const bool value = true; }; template struct is_SpGlue { static const bool value = false; }; template struct is_SpGlue< SpGlue > { static const bool value = true; }; template struct is_mtSpOp { static const bool value = false; }; template struct is_mtSpOp< mtSpOp > { static const bool value = true; }; template struct is_arma_sparse_type { static const bool value = is_SpMat::value || is_SpSubview::value || is_SpOp::value || is_SpGlue::value || is_mtSpOp::value ; }; // // // template struct is_same_type { static const bool value = false; static const bool yes = false; static const bool no = true; }; template struct is_same_type { static const bool value = true; static const bool yes = true; static const bool no = false; }; // // // template struct is_u8 { static const bool value = false; }; template<> struct is_u8 { static const bool value = true; }; template struct is_s8 { static const bool value = false; }; template<> struct is_s8 { static const bool value = true; }; template struct is_u16 { static const bool value = false; }; template<> struct is_u16 { static const bool value = true; }; template struct is_s16 { static const bool value = false; }; template<> struct is_s16 { static const bool value = true; }; template struct is_u32 { static const bool value = false; }; template<> struct is_u32 { static const bool value = true; }; template struct is_s32 { static const bool value = false; }; template<> struct is_s32 { static const bool value = true; }; #if defined(ARMA_USE_U64S64) template struct is_u64 { static const bool value = false; }; template<> struct is_u64 { static const bool value = true; }; template struct is_s64 { static const bool value = false; }; template<> struct is_s64 { static const bool value = true; }; #endif template struct is_ulng_t { static const bool value = false; }; template<> struct is_ulng_t { static const bool value = true; }; template struct is_slng_t { static const bool value = false; }; template<> struct is_slng_t { static const bool value = true; }; template struct is_ulng_t_32 { static const bool value = false; }; template<> struct is_ulng_t_32 { static const bool value = (sizeof(ulng_t) == 4); }; template struct is_slng_t_32 { static const bool value = false; }; template<> struct is_slng_t_32 { static const bool value = (sizeof(slng_t) == 4); }; template struct is_ulng_t_64 { static const bool value = false; }; template<> struct is_ulng_t_64 { static const bool value = (sizeof(ulng_t) == 8); }; template struct is_slng_t_64 { static const bool value = false; }; template<> struct is_slng_t_64 { static const bool value = (sizeof(slng_t) == 8); }; template struct is_uword { static const bool value = false; }; template<> struct is_uword { static const bool value = true; }; template struct is_sword { static const bool value = false; }; template<> struct is_sword { static const bool value = true; }; template struct is_float { static const bool value = false; }; template<> struct is_float { static const bool value = true; }; template struct is_double { static const bool value = false; }; template<> struct is_double { static const bool value = true; }; template struct is_real { static const bool value = false; }; template<> struct is_real { static const bool value = true; }; template<> struct is_real { static const bool value = true; }; template struct is_not_complex { static const bool value = true; }; template struct is_not_complex< std::complex > { static const bool value = false; }; template struct is_complex { static const bool value = false; }; // template<> template struct is_complex< std::complex > { static const bool value = true; }; template struct is_complex_float { static const bool value = false; }; template<> struct is_complex_float< std::complex > { static const bool value = true; }; template struct is_complex_double { static const bool value = false; }; template<> struct is_complex_double< std::complex > { static const bool value = true; }; template struct is_complex_strict { static const bool value = false; }; template<> struct is_complex_strict< std::complex > { static const bool value = true; }; template<> struct is_complex_strict< std::complex > { static const bool value = true; }; template struct is_cx { static const bool value = false; static const bool yes = false; static const bool no = true; }; // template<> template struct is_cx< std::complex > { static const bool value = true; static const bool yes = true; static const bool no = false; }; //! check for a weird implementation of the std::complex class template struct is_supported_complex { static const bool value = false; }; //template<> template struct is_supported_complex< std::complex > { static const bool value = ( sizeof(std::complex) == 2*sizeof(eT) ); }; template struct is_supported_complex_float { static const bool value = false; }; template<> struct is_supported_complex_float< std::complex > { static const bool value = ( sizeof(std::complex) == 2*sizeof(float) ); }; template struct is_supported_complex_double { static const bool value = false; }; template<> struct is_supported_complex_double< std::complex > { static const bool value = ( sizeof(std::complex) == 2*sizeof(double) ); }; template struct is_supported_elem_type { static const bool value = \ is_u8::value || is_s8::value || is_u16::value || is_s16::value || is_u32::value || is_s32::value || #if defined(ARMA_USE_U64S64) is_u64::value || is_s64::value || #endif #if defined(ARMA_ALLOW_LONG) is_ulng_t::value || is_slng_t::value || #endif is_float::value || is_double::value || is_supported_complex_float::value || is_supported_complex_double::value; }; template struct is_supported_blas_type { static const bool value = \ is_float::value || is_double::value || is_supported_complex_float::value || is_supported_complex_double::value; }; template struct is_signed { static const bool value = true; }; template<> struct is_signed { static const bool value = false; }; template<> struct is_signed { static const bool value = false; }; template<> struct is_signed { static const bool value = false; }; #if defined(ARMA_USE_U64S64) template<> struct is_signed { static const bool value = false; }; #endif #if defined(ARMA_ALLOW_LONG) template<> struct is_signed { static const bool value = false; }; #endif template struct is_non_integral { static const bool value = false; }; template<> struct is_non_integral< float > { static const bool value = true; }; template<> struct is_non_integral< double > { static const bool value = true; }; template<> struct is_non_integral< std::complex > { static const bool value = true; }; template<> struct is_non_integral< std::complex > { static const bool value = true; }; // class arma_junk_class; template struct force_different_type { typedef T1 T1_result; typedef T2 T2_result; }; template struct force_different_type { typedef T1 T1_result; typedef arma_junk_class T2_result; }; // template struct resolves_to_vector_default { static const bool value = false; }; template struct resolves_to_vector_test { static const bool value = T1::is_col || T1::is_row; }; template struct resolves_to_vector_redirect {}; template struct resolves_to_vector_redirect { typedef resolves_to_vector_default result; }; template struct resolves_to_vector_redirect { typedef resolves_to_vector_test result; }; template struct resolves_to_vector : public resolves_to_vector_redirect::value>::result {}; template struct resolves_to_sparse_vector : public resolves_to_vector_redirect::value>::result {}; // template struct resolves_to_rowvector_default { static const bool value = false; }; template struct resolves_to_rowvector_test { static const bool value = T1::is_row; }; template struct resolves_to_rowvector_redirect {}; template struct resolves_to_rowvector_redirect { typedef resolves_to_rowvector_default result; }; template struct resolves_to_rowvector_redirect { typedef resolves_to_rowvector_test result; }; template struct resolves_to_rowvector : public resolves_to_rowvector_redirect::value>::result {}; // template struct resolves_to_colvector_default { static const bool value = false; }; template struct resolves_to_colvector_test { static const bool value = T1::is_col; }; template struct resolves_to_colvector_redirect {}; template struct resolves_to_colvector_redirect { typedef resolves_to_colvector_default result; }; template struct resolves_to_colvector_redirect { typedef resolves_to_colvector_test result; }; template struct resolves_to_colvector : public resolves_to_colvector_redirect::value>::result {}; template struct is_glue_mixed_times { static const bool value = false; }; template<> struct is_glue_mixed_times { static const bool value = true; }; template struct is_glue_mixed_elem { static const bool value = false; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template<> struct is_glue_mixed_elem { static const bool value = true; }; template struct is_op_mixed_elem { static const bool value = false; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template<> struct is_op_mixed_elem { static const bool value = true; }; template struct is_spop_elem { static const bool value = false; }; template<> struct is_spop_elem { static const bool value = true; }; template struct is_spglue_elem { static const bool value = false; }; template<> struct is_spglue_elem { static const bool value = true; }; template<> struct is_spglue_elem { static const bool value = true; }; template<> struct is_spglue_elem { static const bool value = true; }; template<> struct is_spglue_elem { static const bool value = true; }; template struct is_spglue_times { static const bool value = false; }; template<> struct is_spglue_times { static const bool value = true; }; template struct is_spglue_times2 { static const bool value = false; }; template<> struct is_spglue_times { static const bool value = true; }; template struct is_outer_product { static const bool value = false; }; template struct is_outer_product< Glue > { static const bool value = (resolves_to_colvector::value && resolves_to_rowvector::value); }; template struct has_op_inv { static const bool value = false; }; template struct has_op_inv< Op > { static const bool value = true; }; template struct has_op_inv< Glue, T2, glue_times> > { static const bool value = true; }; template struct has_op_inv< Glue, glue_times> > { static const bool value = true; }; //! @}