Hi, I thought that a good way to get good performance is to formulate all the calculations somehow vectorized but I'm not sure if I have chosen the best way because the code performs badly. The matrices are big, about 10k \times 10k in size.
My code is below. Maybe you can give me some suggestions about how to do that fast. Basically, in `mat_column_mult`, I want to multiply a certain column of a matrix. Currently, I multiply with 0, maybe that is a special case where I can do even faster. In `layerActivity_addBiasTerm`, I want to add a left scalar column to a matrix. Thanks and Regards, Albert --- typedef float Float; typedef viennacl::vector<Float> Vec; typedef viennacl::matrix<Float> Mat; typedef Mat LayerActivity; template<typename T1, typename T2> auto operator*(const T1& a, const T2& b) -> decltype(viennacl::linalg::prod(a, b)) { return viennacl::linalg::prod(a, b); } inline Mat mat_column_mult(const Mat& mat, int column, Float factor) { using namespace viennacl; using namespace viennacl::linalg; Mat mult_mat = identity_matrix<Float>(mat.size2()); mult_mat(column, column) = factor; return mat * mult_mat; } static LayerActivity layerActivity_addBiasTerm(const LayerActivity& act, Float bias = 1.0) { Mat mult_mat(act.size2(), act.size2() + 1); range mm_rows(0, act.size2()); range mm_cols(1, act.size2() + 1); matrix_range<Mat> mm_sub(mult_mat, mm_rows, mm_cols); mm_sub = identity_matrix<Float>(act.size2()); LayerActivity act_new = act * mult_mat; // added left zero-column range am_rows(0, act_new.size1()); range am_cols(0, 1); matrix_range<Mat> am_sub(act_new, am_rows, am_cols); am_sub = scalar_matrix<Float>(act_new.size1(), 1, bias); return act_new; } ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ ViennaCL-devel mailing list ViennaCL-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viennacl-devel