op_repmat_meat.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 // - Dimitrios Bouzas (dimitris dot mpouzas at gmail dot com)
00007 // 
00008 // This file is part of the Armadillo C++ library.
00009 // It is provided without any warranty of fitness
00010 // for any purpose. You can redistribute this file
00011 // and/or modify it under the terms of the GNU
00012 // Lesser General Public License (LGPL) as published
00013 // by the Free Software Foundation, either version 3
00014 // of the License or (at your option) any later version.
00015 // (see http://www.opensource.org/licenses for more info)
00016 
00017 
00018 
00019 //! \addtogroup op_repmat
00020 //! @{
00021 
00022 
00023 
00024 //! \brief
00025 //! implementation of the 'repeat matrix' operation, used for constructing matrices
00026 template<typename T1>
00027 inline
00028 void
00029 op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>& in)
00030   {
00031   arma_extra_debug_sigprint();
00032   
00033   typedef typename T1::elem_type eT;
00034   
00035   const unwrap_check<T1> tmp(in.m, out);
00036   const Mat<eT>& X     = tmp.M;
00037   
00038   arma_debug_check( (X.n_elem == 0), "op_repmat::apply(): given object has no elements" );
00039 
00040   const u32 copies_per_row = in.aux_u32_a;
00041   const u32 copies_per_col = in.aux_u32_b;
00042   
00043   out.set_size(X.n_rows * copies_per_row, X.n_cols * copies_per_col);
00044   
00045   for(u32 col = 0; col < out.n_cols; col += X.n_cols)
00046     {
00047     for(u32 row = 0; row < out.n_rows; row += X.n_rows)
00048       {
00049       out.submat(row, col, row+X.n_rows-1, col+X.n_cols-1) = X;
00050       }
00051     }
00052   }
00053 
00054 
00055 
00056 //! @}