typedef.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup typedef
00017 //! @{
00018 
00019 
00020 #if UCHAR_MAX == 0xff
00021   //! unsigned 8 bit type
00022   typedef unsigned char u8;
00023   typedef          char s8;
00024 #else
00025   #error "don't know how to typedef 'u8' on this system"
00026 #endif
00027 
00028 // NOTE:
00029 // "signed char" is not the same as "char". 
00030 // see http://www.embedded.com/columns/programmingpointers/206107018
00031 
00032 #if USHRT_MAX == 0xffff
00033   //! unsigned 16 bit type  
00034   typedef unsigned short u16;
00035   typedef          short s16;
00036 #else
00037   #error "don't know how to typedef 'u16' on this system"
00038 #endif
00039 
00040 
00041 #if   UINT_MAX  == 0xffffffff
00042   typedef unsigned int  u32;
00043   typedef          int  s32;
00044 #elif ULONG_MAX == 0xffffffff
00045   typedef unsigned long u32;
00046   typedef          long s32;
00047 #else
00048   #error "don't know how to typedef 'u32' on this system"
00049 #endif
00050 
00051 // //
00052 // // only supported by C++0x, via #include <cstdint>, or by C99, via #include <stdint.h>
00053 // 
00054 // //! unsigned 8 bit type
00055 // typedef uint8_t u8;
00056 // 
00057 // //! unsigned 16 bit type  
00058 // typedef uint16_t u16;
00059 // 
00060 // //! unsigned 32 bit type
00061 // typedef uint32_t u32;
00062 //
00063 // //! signed 32 bit type
00064 // typedef int32_t s32;
00065 
00066 
00067 typedef std::complex<float>  cx_float;
00068 typedef std::complex<double> cx_double;
00069 
00070 typedef Mat<unsigned char> uchar_mat;
00071 typedef Col<unsigned char> uchar_vec;
00072 typedef Col<unsigned char> uchar_colvec;
00073 typedef Row<unsigned char> uchar_rowvec;
00074 
00075 typedef Mat<u32> umat;
00076 typedef Col<u32> uvec;
00077 typedef Col<u32> ucolvec;
00078 typedef Row<u32> urowvec;
00079 
00080 typedef Mat<s32> imat;
00081 typedef Col<s32> ivec;
00082 typedef Col<s32> icolvec;
00083 typedef Row<s32> irowvec;
00084 
00085 typedef Mat<float> fmat;
00086 typedef Col<float> fvec;
00087 typedef Col<float> fcolvec;
00088 typedef Row<float> frowvec;
00089 
00090 typedef Mat<double> mat;
00091 typedef Col<double> vec;
00092 typedef Col<double> colvec;
00093 typedef Row<double> rowvec;
00094 
00095 typedef Mat<cx_float> cx_fmat;
00096 typedef Col<cx_float> cx_fvec;
00097 typedef Col<cx_float> cx_fcolvec;
00098 typedef Row<cx_float> cx_frowvec;
00099 
00100 typedef Mat<cx_double> cx_mat;
00101 typedef Col<cx_double> cx_vec;
00102 typedef Col<cx_double> cx_colvec;
00103 typedef Row<cx_double> cx_rowvec;
00104 
00105 
00106 
00107 namespace junk
00108   {
00109   struct arma_elem_size_test
00110     {
00111   
00112     arma_static_assert<sizeof(u8) == 1> ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZE;
00113     arma_static_assert<sizeof(s8) == 1> ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZE;
00114     
00115     arma_static_assert<sizeof(u16) == 2> ERROR___TYPE_U16_HAS_UNSUPPORTED_SIZE;
00116     arma_static_assert<sizeof(s16) == 2> ERROR___TYPE_S16_HAS_UNSUPPORTED_SIZE;
00117     
00118     arma_static_assert<sizeof(u32) == 4> ERROR___TYPE_U32_HAS_UNSUPPORTED_SIZE;
00119     arma_static_assert<sizeof(s32) == 4> ERROR___TYPE_S32_HAS_UNSUPPORTED_SIZE;
00120     
00121     arma_static_assert<sizeof(float)  == 4> ERROR___TYPE_FLOAT_HAS_UNSUPPORTED_SIZE;
00122     arma_static_assert<sizeof(double) == 8> ERROR___TYPE_DOUBLE_HAS_UNSUPPORTED_SIZE;
00123     
00124     arma_static_assert<sizeof(std::complex<float>)  == 8>  ERROR___TYPE_COMPLEX_FLOAT_HAS_UNSUPPORTED_SIZE;
00125     arma_static_assert<sizeof(std::complex<double>) == 16> ERROR___TYPE_COMPLEX_DOUBLE_HAS_UNSUPPORTED_SIZE;
00126   
00127     };
00128   }
00129 
00130 //! @}