25 static std::ostream* stream_err1 = &(std::cout);
27 if(user_stream != NULL)
29 stream_err1 = user_stream;
42 static std::ostream* stream_err2 = &(std::cout);
44 if(user_stream != NULL)
46 stream_err2 = user_stream;
58 arma_stream_err1<char>(&user_stream);
67 arma_stream_err2<char>(&user_stream);
76 return arma_stream_err1<char>(NULL);
85 return arma_stream_err2<char>(NULL);
100 #if defined(ARMA_PRINT_LOGIC_ERRORS) 107 out <<
"error: " << x <<
'\n';
117 throw std::logic_error(
"");
122 template<
typename T1>
133 out <<
"error: " << x <<
'\n';
137 throw std::bad_alloc();
146 template<
typename T1>
152 #if defined(ARMA_PRINT_RUNTIME_ERRORS) 159 out <<
"error: " << x <<
'\n';
171 throw std::runtime_error(
"");
190 template<
typename T1>
201 template<
typename T1,
typename T2>
212 template<
typename T1,
typename T2,
typename T3>
254 template<
typename T1>
264 template<
typename T1,
typename T2>
294 template<
typename T1>
307 template<
typename T1,
typename T2>
320 template<
typename T1,
typename T2,
typename T3>
324 arma_warn(
const bool state,
const T1& x,
const T2& y,
const T3& z)
338 template<
typename T1>
351 template<
typename T1,
typename T2>
359 arma_stop( std::string(x) + std::string(y) );
364 template<
typename T1>
385 arma_set_error(
bool& err_state,
char*& err_msg,
const bool expression,
const char* message)
387 if(expression ==
true)
390 err_msg =
const_cast<char*
>(message);
405 std::stringstream tmp;
407 tmp << x <<
": incompatible matrix dimensions: " << A_n_rows <<
'x' << A_n_cols <<
" and " << B_n_rows <<
'x' << B_n_cols;
419 std::stringstream tmp;
421 tmp << x <<
": incompatible cube dimensions: " << A_n_rows <<
'x' << A_n_cols <<
'x' << A_n_slices <<
" and " << B_n_rows <<
'x' << B_n_cols <<
'x' << B_n_slices;
428 template<
typename eT>
434 std::stringstream tmp;
437 <<
": interpreting matrix as cube with dimenensions: " 443 <<
" is incompatible with cube dimensions: " 461 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
470 template<
typename eT1,
typename eT2>
482 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
491 template<
typename eT1,
typename eT2>
497 const uword A_n_rows = A.get_n_rows();
498 const uword A_n_cols = A.get_n_cols();
500 const uword B_n_rows = B.get_n_rows();
501 const uword B_n_cols = B.get_n_cols();
503 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
511 template<
typename eT1,
typename eT2>
523 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
531 template<
typename eT1,
typename eT2>
543 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
551 template<
typename eT1,
typename eT2>
563 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
571 template<
typename eT1,
typename eT2>
580 const uword B_n_rows = B.get_n_rows();
581 const uword B_n_cols = B.get_n_cols();
583 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
591 template<
typename eT1,
typename eT2>
597 const uword A_n_rows = A.get_n_rows();
598 const uword A_n_cols = A.get_n_cols();
603 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
611 template<
typename eT1,
typename eT2>
617 const uword A_n_rows = A.get_n_rows();
618 const uword A_n_cols = A.get_n_cols();
623 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
631 template<
typename eT1,
typename eT2>
640 const uword B_n_rows = B.get_n_rows();
641 const uword B_n_cols = B.get_n_cols();
643 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
661 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_n_slices) )
670 template<
typename eT1,
typename eT2>
684 template<
typename eT1,
typename eT2>
698 template<
typename eT1,
typename eT2>
712 template<
typename eT1,
typename eT2>
727 template<
typename eT1,
typename eT2>
733 const uword A_n_rows = A.get_n_rows();
734 const uword A_n_cols = A.get_n_cols();
735 const uword A_n_slices = A.get_n_slices();
737 const uword B_n_rows = B.get_n_rows();
738 const uword B_n_cols = B.get_n_cols();
739 const uword B_n_slices = B.get_n_slices();
741 if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) || (A_n_slices != B_n_slices))
754 template<
typename eT1,
typename eT2>
768 template<
typename eT1,
typename eT2>
782 template<
typename eT1,
typename eT2>
796 template<
typename eT1,
typename eT2>
810 template<
typename eT,
typename T1>
815 const uword Q_n_rows = Q.n_rows;
816 const uword Q_n_cols = Q.n_cols;
817 const uword Q_n_slices = Q.n_slices;
823 if( ( (Q_n_rows == 1) || (Q_n_cols == 1) || (Q_n_slices == 1) ) ==
false )
825 std::stringstream tmp;
828 <<
": can't interpret cube with dimensions " 829 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
830 <<
" as a matrix; one of the dimensions must be 1";
839 if( (M_vec_state == 1) && (Q_n_cols != 1) )
841 std::stringstream tmp;
844 <<
": can't interpret cube with dimensions " 845 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
846 <<
" as a column vector";
851 if( (M_vec_state == 2) && (Q_n_rows != 1) )
853 std::stringstream tmp;
856 <<
": can't interpret cube with dimensions " 857 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
858 <<
" as a row vector";
865 if( (Q_n_cols != 1) && (Q_n_rows != 1) )
867 std::stringstream tmp;
870 <<
": can't interpret cube with dimensions " 871 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
880 if(check_compat_size ==
true)
889 ( (Q_n_rows == M_n_rows) && (Q_n_cols == M_n_cols) )
891 ( (Q_n_rows == M_n_rows) && (Q_n_slices == M_n_cols) )
893 ( (Q_n_cols == M_n_rows) && (Q_n_slices == M_n_cols) )
898 std::stringstream tmp;
901 <<
": can't interpret cube with dimenensions " 902 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
903 <<
" as a matrix with dimensions " 904 << M_n_rows <<
'x' << M_n_cols;
913 if( (M_vec_state == 1) && (Q_n_rows != M_n_rows) )
915 std::stringstream tmp;
918 <<
": can't interpret cube with dimensions " 919 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
920 <<
" as a column vector with dimensions " 921 << M_n_rows <<
'x' << M_n_cols;
926 if( (M_vec_state == 2) && (Q_n_cols != M_n_cols) )
928 std::stringstream tmp;
931 <<
": can't interpret cube with dimensions " 932 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
933 <<
" as a row vector with dimensions " 934 << M_n_rows <<
'x' << M_n_cols;
941 if( ( (M_n_cols == Q_n_slices) || (M_n_rows == Q_n_slices) ) == false )
943 std::stringstream tmp;
946 <<
": can't interpret cube with dimensions " 947 << Q_n_rows <<
'x' << Q_n_cols <<
'x' << Q_n_slices
948 <<
" as a vector with dimensions " 949 << M_n_rows <<
'x' << M_n_cols;
970 if(A_n_cols != B_n_rows)
979 template<
typename eT1,
typename eT2>
988 if(A_n_cols != B_n_rows)
997 template<
typename eT1,
typename eT2>
1006 if(final_A_n_cols != final_B_n_rows)
1017 template<
typename eT1,
typename eT2>
1031 template<
typename eT1,
typename eT2>
1045 template<
typename eT1,
typename eT2>
1063 #define ARMA_STRING1(x) #x 1064 #define ARMA_STRING2(x) ARMA_STRING1(x) 1065 #define ARMA_FILELINE __FILE__ ": " ARMA_STRING2(__LINE__) 1068 #if defined (__GNUG__) 1069 #define ARMA_FNSIG __PRETTY_FUNCTION__ 1070 #elif defined (_MSC_VER) 1071 #define ARMA_FNSIG __FUNCSIG__ 1072 #elif defined (ARMA_USE_BOOST) 1073 #define ARMA_FNSIG BOOST_CURRENT_FUNCTION 1075 #define ARMA_FNSIG "(unknown)" 1080 #if !defined(ARMA_NO_DEBUG) && !defined(NDEBUG) 1082 #define arma_debug_print arma_print 1083 #define arma_debug_warn arma_warn 1084 #define arma_debug_check arma_check 1085 #define arma_debug_set_error arma_set_error 1086 #define arma_debug_assert_same_size arma_assert_same_size 1087 #define arma_debug_assert_mul_size arma_assert_mul_size 1088 #define arma_debug_assert_cube_as_mat arma_assert_cube_as_mat 1092 #undef ARMA_EXTRA_DEBUG 1094 #define arma_debug_print true ? (void)0 : arma_print 1095 #define arma_debug_warn true ? (void)0 : arma_warn 1096 #define arma_debug_check true ? (void)0 : arma_check 1097 #define arma_debug_set_error true ? (void)0 : arma_set_error 1098 #define arma_debug_assert_same_size true ? (void)0 : arma_assert_same_size 1099 #define arma_debug_assert_mul_size true ? (void)0 : arma_assert_mul_size 1100 #define arma_debug_assert_cube_as_mat true ? (void)0 : arma_debug_assert_cube_as_mat 1106 #if defined(ARMA_EXTRA_DEBUG) 1108 #define arma_extra_debug_sigprint arma_sigprint(ARMA_FNSIG); arma_bktprint 1109 #define arma_extra_debug_sigprint_this arma_sigprint(ARMA_FNSIG); arma_thisprint 1110 #define arma_extra_debug_print arma_print 1111 #define arma_extra_debug_warn arma_warn 1112 #define arma_extra_debug_check arma_check 1116 #define arma_extra_debug_sigprint true ? (void)0 : arma_bktprint 1117 #define arma_extra_debug_sigprint_this true ? (void)0 : arma_thisprint 1118 #define arma_extra_debug_print true ? (void)0 : arma_print 1119 #define arma_extra_debug_warn true ? (void)0 : arma_warn 1120 #define arma_extra_debug_check true ? (void)0 : arma_check 1127 #if defined(ARMA_EXTRA_DEBUG) 1131 class arma_first_extra_debug_message
1137 arma_first_extra_debug_message()
1142 unsigned char b[
sizeof(
unsigned short)];
1147 const bool little_endian = (endian_test.b[0] == 1);
1152 out <<
"@ ---" <<
'\n';
1153 out <<
"@ Armadillo " 1155 <<
" (" << nickname <<
")\n";
1165 out <<
"@ sizeof(void*) = " <<
sizeof(
void*) <<
'\n';
1166 out <<
"@ sizeof(uword) = " <<
sizeof(
uword) <<
'\n';
1167 out <<
"@ sizeof(int) = " <<
sizeof(int) <<
'\n';
1168 out <<
"@ sizeof(long) = " <<
sizeof(long) <<
'\n';
1169 out <<
"@ sizeof(blas_int) = " <<
sizeof(
blas_int) <<
'\n';
1170 out <<
"@ little_endian = " << little_endian <<
'\n';
1171 out <<
"@ ---" << std::endl;
1176 static arma_first_extra_debug_message arma_first_extra_debug_message_run;
void arma_sigprint(const char *x)
void set_stream_err2(std::ostream &user_stream)
void set_stream_err1(std::ostream &user_stream)
static const uword mat_prealloc
void arma_hot arma_check_bad_alloc(const bool state, const T1 &x)
static const unsigned int major
const uword n_cols
number of columns in the matrix (read-only)
arma_inline void arma_hot arma_set_error(bool &err_state, char *&err_msg, const bool expression, const char *message)
void arma_cold arma_print()
const uword n_rows
number of rows in the matrix (read-only)
void arma_assert_cube_as_mat(const Mat< eT > &M, const T1 &Q, const char *x, const bool check_compat_size)
void arma_hot arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char *x)
const uword n_cols
number of columns in each slice (read-only)
static const unsigned int patch
static const bool good_comp
static const unsigned int minor
void arma_hot arma_assert_mul_size(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char *x)
std::ostream & get_stream_err1()
std::ostream & get_stream_err2()
std::string arma_cold arma_incompat_size_string(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char *x)
#define arma_ignore(variable)
std::ostream & arma_stream_err2(std::ostream *user_stream)
void arma_cold arma_stop(const T1 &x)
print a message to get_stream_err1() and/or throw a logic_error exception
#define ARMA_VERSION_NAME
std::ostream & arma_stream_err1(std::ostream *user_stream)
void arma_cold arma_bad(const T1 &x, const bool hurl=true)
print a message to get_stream_err2() and/or throw a run-time error exception
void arma_cold arma_warn(const bool state, const T1 &x)
print a message to the warn stream
static const bool boost_date
void arma_cold arma_stop_bad_alloc(const T1 &x)
void arma_thisprint(const void *this_ptr)
static const T1 & str_wrapper(const T1 &x, const typename string_only< T1 >::result *junk=0)
const uhword vec_state
0: matrix layout; 1: column vector layout; 2: row vector layout
static const bool extra_code
void arma_hot arma_check(const bool state, const T1 &x)
if state is true, abort program
const uword n_slices
number of slices in the cube (read-only)
const uword n_rows
number of rows in each slice (read-only)