typedef.hpp

Go to the documentation of this file.
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 typedef
00018 //! @{
00019 
00020 
00021 #if UCHAR_MAX == 0xff
00022   //! unsigned 8 bit type
00023   typedef unsigned char u8;
00024   typedef          char s8;
00025 #else
00026   #error "don't know how to typedef 'u8' on this system"
00027 #endif
00028 
00029 // NOTE:
00030 // "signed char" is not the same as "char". 
00031 // see http://www.embedded.com/columns/programmingpointers/206107018
00032 
00033 #if USHRT_MAX == 0xffff
00034   //! unsigned 16 bit type  
00035   typedef unsigned short u16;
00036   typedef          short s16;
00037 #else
00038   #error "don't know how to typedef 'u16' on this system"
00039 #endif
00040 
00041 
00042 #if   UINT_MAX  == 0xffffffff
00043   typedef unsigned int  u32;
00044   typedef          int  s32;
00045 #elif ULONG_MAX == 0xffffffff
00046   typedef unsigned long u32;
00047   typedef          long s32;
00048 #else
00049   #error "don't know how to typedef 'u32' on this system"
00050 #endif
00051 
00052 // //
00053 // // only supported by C++0x, via #include <cstdint>, or by C99, via #include <stdint.h>
00054 // 
00055 // //! unsigned 8 bit type
00056 // typedef uint8_t u8;
00057 // 
00058 // //! unsigned 16 bit type  
00059 // typedef uint16_t u16;
00060 // 
00061 // //! unsigned 32 bit type
00062 // typedef uint32_t u32;
00063 //
00064 // //! signed 32 bit type
00065 // typedef int32_t s32;
00066 
00067 
00068 typedef std::complex<float>  cx_float;
00069 typedef std::complex<double> cx_double;
00070 
00071 typedef Mat<unsigned char>  uchar_mat;
00072 typedef Col<unsigned char>  uchar_vec;
00073 typedef Col<unsigned char>  uchar_colvec;
00074 typedef Row<unsigned char>  uchar_rowvec;
00075 typedef Cube<unsigned char> uchar_cube;
00076 
00077 typedef Mat<u32>  umat;
00078 typedef Col<u32>  uvec;
00079 typedef Col<u32>  ucolvec;
00080 typedef Row<u32>  urowvec;
00081 typedef Cube<u32> ucube;
00082 
00083 typedef Mat<s32>  imat;
00084 typedef Col<s32>  ivec;
00085 typedef Col<s32>  icolvec;
00086 typedef Row<s32>  irowvec;
00087 typedef Cube<s32> icube;
00088 
00089 typedef Mat<float>  fmat;
00090 typedef Col<float>  fvec;
00091 typedef Col<float>  fcolvec;
00092 typedef Row<float>  frowvec;
00093 typedef Cube<float> fcube;
00094 
00095 typedef Mat<double>  mat;
00096 typedef Col<double>  vec;
00097 typedef Col<double>  colvec;
00098 typedef Row<double>  rowvec;
00099 typedef Cube<double> cube;
00100 
00101 typedef Mat<cx_float>  cx_fmat;
00102 typedef Col<cx_float>  cx_fvec;
00103 typedef Col<cx_float>  cx_fcolvec;
00104 typedef Row<cx_float>  cx_frowvec;
00105 typedef Cube<cx_float> cx_fcube;
00106 
00107 typedef Mat<cx_double>  cx_mat;
00108 typedef Col<cx_double>  cx_vec;
00109 typedef Col<cx_double>  cx_colvec;
00110 typedef Row<cx_double>  cx_rowvec;
00111 typedef Cube<cx_double> cx_cube;
00112 
00113 
00114 
00115 namespace junk
00116   {
00117   struct arma_elem_size_test
00118     {
00119   
00120     arma_static_assert<sizeof(u8) == 1> ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZE;
00121     arma_static_assert<sizeof(s8) == 1> ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZE;
00122     
00123     arma_static_assert<sizeof(u16) == 2> ERROR___TYPE_U16_HAS_UNSUPPORTED_SIZE;
00124     arma_static_assert<sizeof(s16) == 2> ERROR___TYPE_S16_HAS_UNSUPPORTED_SIZE;
00125     
00126     arma_static_assert<sizeof(u32) == 4> ERROR___TYPE_U32_HAS_UNSUPPORTED_SIZE;
00127     arma_static_assert<sizeof(s32) == 4> ERROR___TYPE_S32_HAS_UNSUPPORTED_SIZE;
00128     
00129     arma_static_assert<sizeof(float)  == 4> ERROR___TYPE_FLOAT_HAS_UNSUPPORTED_SIZE;
00130     arma_static_assert<sizeof(double) == 8> ERROR___TYPE_DOUBLE_HAS_UNSUPPORTED_SIZE;
00131     
00132     arma_static_assert<sizeof(std::complex<float>)  == 8>  ERROR___TYPE_COMPLEX_FLOAT_HAS_UNSUPPORTED_SIZE;
00133     arma_static_assert<sizeof(std::complex<double>) == 16> ERROR___TYPE_COMPLEX_DOUBLE_HAS_UNSUPPORTED_SIZE;
00134   
00135     };
00136   }
00137 
00138 //! @}