12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241 |
- // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
- // Copyright 2008-2016 National ICT Australia (NICTA)
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- // ------------------------------------------------------------------------
- //! \addtogroup traits
- //! @{
- template<typename T1>
- struct get_pod_type
- { typedef T1 result; };
- template<typename T2>
- struct get_pod_type< std::complex<T2> >
- { typedef T2 result; };
- template<typename T>
- struct is_Mat_fixed_only
- {
- typedef char yes[1];
- typedef char no[2];
-
- template<typename X> static yes& check(typename X::Mat_fixed_type*);
- template<typename> static no& check(...);
-
- static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
- };
- template<typename T>
- struct is_Row_fixed_only
- {
- typedef char yes[1];
- typedef char no[2];
-
- template<typename X> static yes& check(typename X::Row_fixed_type*);
- template<typename> static no& check(...);
-
- static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
- };
- template<typename T>
- struct is_Col_fixed_only
- {
- typedef char yes[1];
- typedef char no[2];
-
- template<typename X> static yes& check(typename X::Col_fixed_type*);
- template<typename> static no& check(...);
-
- static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
- };
- template<typename T>
- struct is_Mat_fixed
- { static const bool value = ( is_Mat_fixed_only<T>::value || is_Row_fixed_only<T>::value || is_Col_fixed_only<T>::value ); };
- template<typename T>
- struct is_Mat_only
- { static const bool value = is_Mat_fixed_only<T>::value; };
- template<typename eT>
- struct is_Mat_only< Mat<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Mat_only< const Mat<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_Mat
- { static const bool value = ( is_Mat_fixed_only<T>::value || is_Row_fixed_only<T>::value || is_Col_fixed_only<T>::value ); };
- template<typename eT>
- struct is_Mat< Mat<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Mat< const Mat<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Mat< Row<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Mat< const Row<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Mat< Col<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Mat< const Col<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_Row
- { static const bool value = is_Row_fixed_only<T>::value; };
- template<typename eT>
- struct is_Row< Row<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Row< const Row<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_Col
- { static const bool value = is_Col_fixed_only<T>::value; };
- template<typename eT>
- struct is_Col< Col<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Col< const Col<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_diagview
- { static const bool value = false; };
- template<typename eT>
- struct is_diagview< diagview<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_diagview< const diagview<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview
- { static const bool value = false; };
- template<typename eT>
- struct is_subview< subview<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_subview< const subview<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview_row
- { static const bool value = false; };
- template<typename eT>
- struct is_subview_row< subview_row<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_subview_row< const subview_row<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview_col
- { static const bool value = false; };
- template<typename eT>
- struct is_subview_col< subview_col<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_subview_col< const subview_col<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview_elem1
- { static const bool value = false; };
- template<typename eT, typename T1>
- struct is_subview_elem1< subview_elem1<eT, T1> >
- { static const bool value = true; };
- template<typename eT, typename T1>
- struct is_subview_elem1< const subview_elem1<eT, T1> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview_elem2
- { static const bool value = false; };
- template<typename eT, typename T1, typename T2>
- struct is_subview_elem2< subview_elem2<eT, T1, T2> >
- { static const bool value = true; };
- template<typename eT, typename T1, typename T2>
- struct is_subview_elem2< const subview_elem2<eT, T1, T2> >
- { static const bool value = true; };
- //
- //
- //
- template<typename T>
- struct is_Cube
- { static const bool value = false; };
- template<typename eT>
- struct is_Cube< Cube<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_Cube< const Cube<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview_cube
- { static const bool value = false; };
- template<typename eT>
- struct is_subview_cube< subview_cube<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_subview_cube< const subview_cube<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_subview_cube_slices
- { static const bool value = false; };
- template<typename eT, typename T1>
- struct is_subview_cube_slices< subview_cube_slices<eT,T1> >
- { static const bool value = true; };
- template<typename eT, typename T1>
- struct is_subview_cube_slices< const subview_cube_slices<eT,T1> >
- { static const bool value = true; };
- //
- //
- //
- template<typename T>
- struct is_Gen
- { static const bool value = false; };
-
- template<typename T1, typename gen_type>
- struct is_Gen< Gen<T1,gen_type> >
- { static const bool value = true; };
-
- template<typename T1, typename gen_type>
- struct is_Gen< const Gen<T1,gen_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_Op
- { static const bool value = false; };
-
- template<typename T1, typename op_type>
- struct is_Op< Op<T1,op_type> >
- { static const bool value = true; };
-
- template<typename T1, typename op_type>
- struct is_Op< const Op<T1,op_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_CubeToMatOp
- { static const bool value = false; };
-
- template<typename T1, typename op_type>
- struct is_CubeToMatOp< CubeToMatOp<T1,op_type> >
- { static const bool value = true; };
-
- template<typename T1, typename op_type>
- struct is_CubeToMatOp< const CubeToMatOp<T1,op_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpToDOp
- { static const bool value = false; };
-
- template<typename T1, typename op_type>
- struct is_SpToDOp< SpToDOp<T1,op_type> >
- { static const bool value = true; };
-
- template<typename T1, typename op_type>
- struct is_SpToDOp< const SpToDOp<T1,op_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_eOp
- { static const bool value = false; };
-
- template<typename T1, typename eop_type>
- struct is_eOp< eOp<T1,eop_type> >
- { static const bool value = true; };
-
- template<typename T1, typename eop_type>
- struct is_eOp< const eOp<T1,eop_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_mtOp
- { static const bool value = false; };
-
- template<typename eT, typename T1, typename op_type>
- struct is_mtOp< mtOp<eT, T1, op_type> >
- { static const bool value = true; };
-
- template<typename eT, typename T1, typename op_type>
- struct is_mtOp< const mtOp<eT, T1, op_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_Glue
- { static const bool value = false; };
-
- template<typename T1, typename T2, typename glue_type>
- struct is_Glue< Glue<T1,T2,glue_type> >
- { static const bool value = true; };
- template<typename T1, typename T2, typename glue_type>
- struct is_Glue< const Glue<T1,T2,glue_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_eGlue
- { static const bool value = false; };
-
- template<typename T1, typename T2, typename eglue_type>
- struct is_eGlue< eGlue<T1,T2,eglue_type> >
- { static const bool value = true; };
- template<typename T1, typename T2, typename eglue_type>
- struct is_eGlue< const eGlue<T1,T2,eglue_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_mtGlue
- { static const bool value = false; };
-
- template<typename eT, typename T1, typename T2, typename glue_type>
- struct is_mtGlue< mtGlue<eT, T1, T2, glue_type> >
- { static const bool value = true; };
- template<typename eT, typename T1, typename T2, typename glue_type>
- struct is_mtGlue< const mtGlue<eT, T1, T2, glue_type> >
- { static const bool value = true; };
- //
- //
- template<typename T>
- struct is_glue_times
- { static const bool value = false; };
- template<typename T1, typename T2>
- struct is_glue_times< Glue<T1,T2,glue_times> >
- { static const bool value = true; };
- template<typename T1, typename T2>
- struct is_glue_times< const Glue<T1,T2,glue_times> >
- { static const bool value = true; };
- template<typename T>
- struct is_glue_times_diag
- { static const bool value = false; };
- template<typename T1, typename T2>
- struct is_glue_times_diag< Glue<T1,T2,glue_times_diag> >
- { static const bool value = true; };
- template<typename T1, typename T2>
- struct is_glue_times_diag< const Glue<T1,T2,glue_times_diag> >
- { static const bool value = true; };
- template<typename T>
- struct is_op_diagmat
- { static const bool value = false; };
-
- template<typename T1>
- struct is_op_diagmat< Op<T1,op_diagmat> >
- { static const bool value = true; };
- template<typename T1>
- struct is_op_diagmat< const Op<T1,op_diagmat> >
- { static const bool value = true; };
- //
- //
- template<typename T>
- struct is_Mat_trans
- { static const bool value = false; };
- template<typename T1>
- struct is_Mat_trans< Op<T1,op_htrans> >
- { static const bool value = is_Mat<T1>::value; };
- template<typename T1>
- struct is_Mat_trans< Op<T1,op_htrans2> >
- { static const bool value = is_Mat<T1>::value; };
- //
- //
- template<typename T>
- struct is_GenCube
- { static const bool value = false; };
-
- template<typename eT, typename gen_type>
- struct is_GenCube< GenCube<eT,gen_type> >
- { static const bool value = true; };
-
- template<typename T>
- struct is_OpCube
- { static const bool value = false; };
-
- template<typename T1, typename op_type>
- struct is_OpCube< OpCube<T1,op_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_eOpCube
- { static const bool value = false; };
-
- template<typename T1, typename eop_type>
- struct is_eOpCube< eOpCube<T1,eop_type> >
- { static const bool value = true; };
-
- template<typename T>
- struct is_mtOpCube
- { static const bool value = false; };
-
- template<typename eT, typename T1, typename op_type>
- struct is_mtOpCube< mtOpCube<eT, T1, op_type> >
- { static const bool value = true; };
-
- template<typename T>
- struct is_GlueCube
- { static const bool value = false; };
-
- template<typename T1, typename T2, typename glue_type>
- struct is_GlueCube< GlueCube<T1,T2,glue_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_eGlueCube
- { static const bool value = false; };
-
- template<typename T1, typename T2, typename eglue_type>
- struct is_eGlueCube< eGlueCube<T1,T2,eglue_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_mtGlueCube
- { static const bool value = false; };
-
- template<typename eT, typename T1, typename T2, typename glue_type>
- struct is_mtGlueCube< mtGlueCube<eT, T1, T2, glue_type> >
- { static const bool value = true; };
- //
- //
- //
- template<typename T1>
- struct is_arma_type2
- {
- static const bool value
- = is_Mat<T1>::value
- || is_Gen<T1>::value
- || is_Op<T1>::value
- || is_CubeToMatOp<T1>::value
- || is_SpToDOp<T1>::value
- || is_Glue<T1>::value
- || is_eOp<T1>::value
- || is_eGlue<T1>::value
- || is_mtOp<T1>::value
- || is_mtGlue<T1>::value
- || is_diagview<T1>::value
- || is_subview<T1>::value
- || is_subview_row<T1>::value
- || is_subview_col<T1>::value
- || is_subview_elem1<T1>::value
- || is_subview_elem2<T1>::value
- ;
- };
- // due to rather baroque C++ rules for proving constant expressions,
- // certain compilers may get confused with the combination of conditional inheritance, nested classes and the shenanigans in is_Mat_fixed_only.
- // below we explicitly ensure the type is forced to be const, which seems to eliminate the confusion.
- template<typename T1>
- struct is_arma_type
- {
- static const bool value = is_arma_type2<const T1>::value;
- };
- template<typename T1>
- struct is_arma_cube_type
- {
- static const bool value
- = is_Cube<T1>::value
- || is_GenCube<T1>::value
- || is_OpCube<T1>::value
- || is_eOpCube<T1>::value
- || is_mtOpCube<T1>::value
- || is_GlueCube<T1>::value
- || is_eGlueCube<T1>::value
- || is_mtGlueCube<T1>::value
- || is_subview_cube<T1>::value
- || is_subview_cube_slices<T1>::value
- ;
- };
- //
- //
- //
- template<typename T>
- struct is_SpMat
- { static const bool value = false; };
- template<typename eT>
- struct is_SpMat< SpMat<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_SpMat< SpCol<eT> >
- { static const bool value = true; };
- template<typename eT>
- struct is_SpMat< SpRow<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpRow
- { static const bool value = false; };
- template<typename eT>
- struct is_SpRow< SpRow<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpCol
- { static const bool value = false; };
- template<typename eT>
- struct is_SpCol< SpCol<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpSubview
- { static const bool value = false; };
- template<typename eT>
- struct is_SpSubview< SpSubview<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpSubview_col
- { static const bool value = false; };
- template<typename eT>
- struct is_SpSubview_col< SpSubview_col<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpSubview_row
- { static const bool value = false; };
- template<typename eT>
- struct is_SpSubview_row< SpSubview_row<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_spdiagview
- { static const bool value = false; };
- template<typename eT>
- struct is_spdiagview< spdiagview<eT> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpOp
- { static const bool value = false; };
-
- template<typename T1, typename op_type>
- struct is_SpOp< SpOp<T1,op_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_SpGlue
- { static const bool value = false; };
-
- template<typename T1, typename T2, typename glue_type>
- struct is_SpGlue< SpGlue<T1,T2,glue_type> >
- { static const bool value = true; };
-
- template<typename T>
- struct is_mtSpOp
- { static const bool value = false; };
-
- template<typename eT, typename T1, typename spop_type>
- struct is_mtSpOp< mtSpOp<eT, T1, spop_type> >
- { static const bool value = true; };
- template<typename T>
- struct is_mtSpGlue
- { static const bool value = false; };
-
- template<typename eT, typename T1, typename T2, typename spglue_type>
- struct is_mtSpGlue< mtSpGlue<eT, T1, T2, spglue_type> >
- { static const bool value = true; };
- template<typename T1>
- struct is_arma_sparse_type
- {
- static const bool value
- = is_SpMat<T1>::value
- || is_SpSubview<T1>::value
- || is_SpSubview_col<T1>::value
- || is_SpSubview_row<T1>::value
- || is_spdiagview<T1>::value
- || is_SpOp<T1>::value
- || is_SpGlue<T1>::value
- || is_mtSpOp<T1>::value
- || is_mtSpGlue<T1>::value
- ;
- };
- //
- //
- //
- template<typename T1, typename T2>
- struct is_same_type
- {
- static const bool value = false;
- static const bool yes = false;
- static const bool no = true;
- };
- template<typename T1>
- struct is_same_type<T1,T1>
- {
- static const bool value = true;
- static const bool yes = true;
- static const bool no = false;
- };
- //
- //
- //
- template<typename T1>
- struct is_u8
- { static const bool value = false; };
- template<>
- struct is_u8<u8>
- { static const bool value = true; };
- template<typename T1>
- struct is_s8
- { static const bool value = false; };
- template<>
- struct is_s8<s8>
- { static const bool value = true; };
- template<typename T1>
- struct is_u16
- { static const bool value = false; };
- template<>
- struct is_u16<u16>
- { static const bool value = true; };
- template<typename T1>
- struct is_s16
- { static const bool value = false; };
- template<>
- struct is_s16<s16>
- { static const bool value = true; };
- template<typename T1>
- struct is_u32
- { static const bool value = false; };
- template<>
- struct is_u32<u32>
- { static const bool value = true; };
- template<typename T1>
- struct is_s32
- { static const bool value = false; };
- template<>
- struct is_s32<s32>
- { static const bool value = true; };
- #if defined(ARMA_USE_U64S64)
- template<typename T1>
- struct is_u64
- { static const bool value = false; };
- template<>
- struct is_u64<u64>
- { static const bool value = true; };
-
-
- template<typename T1>
- struct is_s64
- { static const bool value = false; };
- template<>
- struct is_s64<s64>
- { static const bool value = true; };
- #endif
- template<typename T1>
- struct is_ulng_t
- { static const bool value = false; };
- template<>
- struct is_ulng_t<ulng_t>
- { static const bool value = true; };
- template<typename T1>
- struct is_slng_t
- { static const bool value = false; };
- template<>
- struct is_slng_t<slng_t>
- { static const bool value = true; };
- template<typename T1>
- struct is_ulng_t_32
- { static const bool value = false; };
- template<>
- struct is_ulng_t_32<ulng_t>
- { static const bool value = (sizeof(ulng_t) == 4); };
- template<typename T1>
- struct is_slng_t_32
- { static const bool value = false; };
- template<>
- struct is_slng_t_32<slng_t>
- { static const bool value = (sizeof(slng_t) == 4); };
- template<typename T1>
- struct is_ulng_t_64
- { static const bool value = false; };
- template<>
- struct is_ulng_t_64<ulng_t>
- { static const bool value = (sizeof(ulng_t) == 8); };
- template<typename T1>
- struct is_slng_t_64
- { static const bool value = false; };
- template<>
- struct is_slng_t_64<slng_t>
- { static const bool value = (sizeof(slng_t) == 8); };
- template<typename T1>
- struct is_uword
- { static const bool value = false; };
- template<>
- struct is_uword<uword>
- { static const bool value = true; };
- template<typename T1>
- struct is_sword
- { static const bool value = false; };
- template<>
- struct is_sword<sword>
- { static const bool value = true; };
- template<typename T1>
- struct is_float
- { static const bool value = false; };
- template<>
- struct is_float<float>
- { static const bool value = true; };
- template<typename T1>
- struct is_double
- { static const bool value = false; };
- template<>
- struct is_double<double>
- { static const bool value = true; };
- template<typename T1>
- struct is_real
- { static const bool value = false; };
- template<>
- struct is_real<float>
- { static const bool value = true; };
-
- template<>
- struct is_real<double>
- { static const bool value = true; };
- template<typename T1>
- struct is_cx
- {
- static const bool value = false;
- static const bool yes = false;
- static const bool no = true;
- };
- // template<>
- template<typename T>
- struct is_cx< std::complex<T> >
- {
- static const bool value = true;
- static const bool yes = true;
- static const bool no = false;
- };
- template<typename T1>
- struct is_cx_float
- {
- static const bool value = false;
- static const bool yes = false;
- static const bool no = true;
- };
- template<>
- struct is_cx_float< std::complex<float> >
- {
- static const bool value = true;
- static const bool yes = true;
- static const bool no = false;
- };
- template<typename T1>
- struct is_cx_double
- {
- static const bool value = false;
- static const bool yes = false;
- static const bool no = true;
- };
- template<>
- struct is_cx_double< std::complex<double> >
- {
- static const bool value = true;
- static const bool yes = true;
- static const bool no = false;
- };
- template<typename T1>
- struct is_supported_elem_type
- {
- static const bool value = \
- is_u8<T1>::value ||
- is_s8<T1>::value ||
- is_u16<T1>::value ||
- is_s16<T1>::value ||
- is_u32<T1>::value ||
- is_s32<T1>::value ||
- #if defined(ARMA_USE_U64S64)
- is_u64<T1>::value ||
- is_s64<T1>::value ||
- #endif
- #if defined(ARMA_ALLOW_LONG)
- is_ulng_t<T1>::value ||
- is_slng_t<T1>::value ||
- #endif
- is_float<T1>::value ||
- is_double<T1>::value ||
- is_cx_float<T1>::value ||
- is_cx_double<T1>::value;
- };
- template<typename T1>
- struct is_supported_blas_type
- {
- static const bool value = \
- is_float<T1>::value ||
- is_double<T1>::value ||
- is_cx_float<T1>::value ||
- is_cx_double<T1>::value;
- };
- template<typename T>
- struct is_signed
- {
- static const bool value = true;
- };
- template<> struct is_signed<u8> { static const bool value = false; };
- template<> struct is_signed<u16> { static const bool value = false; };
- template<> struct is_signed<u32> { static const bool value = false; };
- #if defined(ARMA_USE_U64S64)
- template<> struct is_signed<u64> { static const bool value = false; };
- #endif
- #if defined(ARMA_ALLOW_LONG)
- template<> struct is_signed<ulng_t> { static const bool value = false; };
- #endif
- template<typename T>
- 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<float> > { static const bool value = true; };
- template<> struct is_non_integral< std::complex<double> > { static const bool value = true; };
- //
- class arma_junk_class;
- template<typename T1, typename T2>
- struct force_different_type
- {
- typedef T1 T1_result;
- typedef T2 T2_result;
- };
-
- template<typename T1>
- struct force_different_type<T1,T1>
- {
- typedef T1 T1_result;
- typedef arma_junk_class T2_result;
- };
-
-
- //
- template<typename T1>
- struct resolves_to_vector_default
- {
- static const bool value = false;
- static const bool yes = false;
- static const bool no = true;
- };
- template<typename T1>
- struct resolves_to_vector_test
- {
- static const bool value = (T1::is_col || T1::is_row || T1::is_xvec);
- static const bool yes = (T1::is_col || T1::is_row || T1::is_xvec);
- static const bool no = ((T1::is_col || T1::is_row || T1::is_xvec) == false);
- };
- template<typename T1, bool condition>
- struct resolves_to_vector_redirect {};
- template<typename T1>
- struct resolves_to_vector_redirect<T1, false> { typedef resolves_to_vector_default<T1> result; };
- template<typename T1>
- struct resolves_to_vector_redirect<T1, true> { typedef resolves_to_vector_test<T1> result; };
- template<typename T1>
- struct resolves_to_vector : public resolves_to_vector_redirect<T1, is_arma_type<T1>::value>::result {};
- template<typename T1>
- struct resolves_to_sparse_vector : public resolves_to_vector_redirect<T1, is_arma_sparse_type<T1>::value>::result {};
- //
- template<typename T1>
- struct resolves_to_rowvector_default { static const bool value = false; };
- template<typename T1>
- struct resolves_to_rowvector_test { static const bool value = T1::is_row; };
- template<typename T1, bool condition>
- struct resolves_to_rowvector_redirect {};
- template<typename T1>
- struct resolves_to_rowvector_redirect<T1, false> { typedef resolves_to_rowvector_default<T1> result; };
- template<typename T1>
- struct resolves_to_rowvector_redirect<T1, true> { typedef resolves_to_rowvector_test<T1> result; };
- template<typename T1>
- struct resolves_to_rowvector : public resolves_to_rowvector_redirect<T1, is_arma_type<T1>::value>::result {};
- //
- template<typename T1>
- struct resolves_to_colvector_default { static const bool value = false; };
- template<typename T1>
- struct resolves_to_colvector_test { static const bool value = T1::is_col; };
- template<typename T1, bool condition>
- struct resolves_to_colvector_redirect {};
- template<typename T1>
- struct resolves_to_colvector_redirect<T1, false> { typedef resolves_to_colvector_default<T1> result; };
- template<typename T1>
- struct resolves_to_colvector_redirect<T1, true> { typedef resolves_to_colvector_test<T1> result; };
- template<typename T1>
- struct resolves_to_colvector : public resolves_to_colvector_redirect<T1, is_arma_type<T1>::value>::result {};
- template<typename T1>
- struct is_outer_product
- { static const bool value = false; };
- template<typename T1, typename T2>
- struct is_outer_product< Glue<T1,T2,glue_times> >
- { static const bool value = (resolves_to_colvector<T1>::value && resolves_to_rowvector<T2>::value); };
- template<typename T1>
- struct has_op_inv
- { static const bool value = false; };
- template<typename T1>
- struct has_op_inv< Op<T1,op_inv> >
- { static const bool value = true; };
- template<typename T1, typename T2>
- struct has_op_inv< Glue<Op<T1,op_inv>, T2, glue_times> >
- { static const bool value = true; };
- template<typename T1, typename T2>
- struct has_op_inv< Glue<T1, Op<T2,op_inv>, glue_times> >
- { static const bool value = true; };
- template<typename T1>
- struct has_op_inv_sympd
- { static const bool value = false; };
- template<typename T1>
- struct has_op_inv_sympd< Op<T1,op_inv_sympd> >
- { static const bool value = true; };
- template<typename T1, typename T2>
- struct has_op_inv_sympd< Glue<Op<T1,op_inv_sympd>, T2, glue_times> >
- { static const bool value = true; };
- template<typename T1, typename T2>
- struct has_op_inv_sympd< Glue<T1, Op<T2,op_inv_sympd>, glue_times> >
- { static const bool value = true; };
- template<typename T>
- struct has_nested_op_traits
- {
- typedef char yes[1];
- typedef char no[2];
-
- template<typename X> static yes& check(typename X::template traits<void>*);
- template<typename> static no& check(...);
-
- static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
- };
- template<typename T>
- struct has_nested_glue_traits
- {
- typedef char yes[1];
- typedef char no[2];
-
- template<typename X> static yes& check(typename X::template traits<void,void>*);
- template<typename> static no& check(...);
-
- static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
- };
- //! @}
|