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 typedef Cube<unsigned char> uchar_cube;
00075 
00076 typedef Mat<u32>  umat;
00077 typedef Col<u32>  uvec;
00078 typedef Col<u32>  ucolvec;
00079 typedef Row<u32>  urowvec;
00080 typedef Cube<u32> ucube;
00081 
00082 typedef Mat<s32>  imat;
00083 typedef Col<s32>  ivec;
00084 typedef Col<s32>  icolvec;
00085 typedef Row<s32>  irowvec;
00086 typedef Cube<s32> icube;
00087 
00088 typedef Mat<float>  fmat;
00089 typedef Col<float>  fvec;
00090 typedef Col<float>  fcolvec;
00091 typedef Row<float>  frowvec;
00092 typedef Cube<float> fcube;
00093 
00094 typedef Mat<double>  mat;
00095 typedef Col<double>  vec;
00096 typedef Col<double>  colvec;
00097 typedef Row<double>  rowvec;
00098 typedef Cube<double> cube;
00099 
00100 typedef Mat<cx_float>  cx_fmat;
00101 typedef Col<cx_float>  cx_fvec;
00102 typedef Col<cx_float>  cx_fcolvec;
00103 typedef Row<cx_float>  cx_frowvec;
00104 typedef Cube<cx_float> cx_fcube;
00105 
00106 typedef Mat<cx_double>  cx_mat;
00107 typedef Col<cx_double>  cx_vec;
00108 typedef Col<cx_double>  cx_colvec;
00109 typedef Row<cx_double>  cx_rowvec;
00110 typedef Cube<cx_double> cx_cube;
00111 
00112 
00113 
00114 namespace junk
00115   {
00116   struct arma_elem_size_test
00117     {
00118   
00119     arma_static_assert<sizeof(u8) == 1> ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZE;
00120     arma_static_assert<sizeof(s8) == 1> ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZE;
00121     
00122     arma_static_assert<sizeof(u16) == 2> ERROR___TYPE_U16_HAS_UNSUPPORTED_SIZE;
00123     arma_static_assert<sizeof(s16) == 2> ERROR___TYPE_S16_HAS_UNSUPPORTED_SIZE;
00124     
00125     arma_static_assert<sizeof(u32) == 4> ERROR___TYPE_U32_HAS_UNSUPPORTED_SIZE;
00126     arma_static_assert<sizeof(s32) == 4> ERROR___TYPE_S32_HAS_UNSUPPORTED_SIZE;
00127     
00128     arma_static_assert<sizeof(float)  == 4> ERROR___TYPE_FLOAT_HAS_UNSUPPORTED_SIZE;
00129     arma_static_assert<sizeof(double) == 8> ERROR___TYPE_DOUBLE_HAS_UNSUPPORTED_SIZE;
00130     
00131     arma_static_assert<sizeof(std::complex<float>)  == 8>  ERROR___TYPE_COMPLEX_FLOAT_HAS_UNSUPPORTED_SIZE;
00132     arma_static_assert<sizeof(std::complex<double>) == 16> ERROR___TYPE_COMPLEX_DOUBLE_HAS_UNSUPPORTED_SIZE;
00133   
00134     };
00135   }
00136 
00137 //! @}