Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 template<typename eT>
00024 inline
00025 void
00026 op_trans::apply_noalias(Mat<eT>& out, const Mat<eT>& A)
00027 {
00028 arma_extra_debug_sigprint();
00029
00030 const u32 A_n_cols = A.n_cols;
00031 const u32 A_n_rows = A.n_rows;
00032
00033 out.set_size(A_n_cols, A_n_rows);
00034
00035 if( (A_n_cols == 1) || (A_n_rows == 1) )
00036 {
00037 syslib::copy_elem( out.memptr(), A.mem, A.n_elem );
00038 }
00039 else
00040 {
00041 for(u32 in_row = 0; in_row<A_n_rows; ++in_row)
00042 {
00043 const u32 out_col = in_row;
00044
00045 for(u32 in_col = 0; in_col<A_n_cols; ++in_col)
00046 {
00047 const u32 out_row = in_col;
00048 out.at(out_row, out_col) = A.at(in_row, in_col);
00049 }
00050 }
00051 }
00052
00053 }
00054
00055
00056
00057 template<typename eT>
00058 inline
00059 void
00060 op_trans::apply(Mat<eT>& out, const Mat<eT>& A)
00061 {
00062 arma_extra_debug_sigprint();
00063
00064 if(&out != &A)
00065 {
00066 op_trans::apply_noalias(out, A);
00067 }
00068 else
00069 {
00070 if(out.n_rows == out.n_cols)
00071 {
00072 arma_extra_debug_print("op_trans::apply(): doing in-place transpose of a square matrix");
00073
00074 const u32 n_rows = out.n_rows;
00075 const u32 n_cols = out.n_cols;
00076
00077 for(u32 col=0; col<n_cols; ++col)
00078 {
00079 eT* coldata = out.colptr(col);
00080
00081 for(u32 row=(col+1); row<n_rows; ++row)
00082 {
00083 std::swap( out.at(col,row), coldata[row] );
00084 }
00085 }
00086 }
00087 else
00088 {
00089 const Mat<eT> A_copy = A;
00090 op_trans::apply_noalias(out, A_copy);
00091 }
00092 }
00093 }
00094
00095
00096
00097 template<typename T1>
00098 inline
00099 void
00100 op_trans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trans>& in)
00101 {
00102 arma_extra_debug_sigprint();
00103
00104 typedef typename T1::elem_type eT;
00105
00106 const unwrap<T1> tmp(in.m);
00107 const Mat<eT>& A = tmp.M;
00108
00109 op_trans::apply(out, A);
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 template<typename T1>
00159 inline
00160 void
00161 op_trans2::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trans2>& in)
00162 {
00163 arma_extra_debug_sigprint();
00164
00165 typedef typename T1::elem_type eT;
00166
00167 const unwrap<T1> tmp(in.m);
00168
00169 op_trans::apply(out, tmp.M);
00170
00171 eT* out_mem = out.memptr();
00172 const u32 n_elem = out.n_elem;
00173 const eT k = in.aux;
00174
00175 for(u32 i=0; i<n_elem; ++i)
00176 {
00177 out_mem[i] *= k;
00178 }
00179
00180 }
00181
00182
00183
00184