[mlpack-svn] r13470 - mlpack/trunk/src/mlpack/core/arma_extend

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Aug 29 11:31:06 EDT 2012


Author: rcurtin
Date: 2012-08-29 11:31:05 -0400 (Wed, 29 Aug 2012)
New Revision: 13470

Added:
   mlpack/trunk/src/mlpack/core/arma_extend/fn_inplace_reshape.hpp
Modified:
   mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp
Log:
Add inplace_reshape() for reshaping matrices without doing anything to the data.


Modified: mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp	2012-08-29 15:17:56 UTC (rev 13469)
+++ mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp	2012-08-29 15:31:05 UTC (rev 13470)
@@ -86,6 +86,9 @@
   #include "glue_ccov_proto.hpp"
   #include "glue_ccov_meat.hpp"
   #include "fn_ccov.hpp"
+
+  // inplace_reshape()
+  #include "fn_inplace_reshape.hpp"
 };
 
 #endif

Added: mlpack/trunk/src/mlpack/core/arma_extend/fn_inplace_reshape.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/fn_inplace_reshape.hpp	                        (rev 0)
+++ mlpack/trunk/src/mlpack/core/arma_extend/fn_inplace_reshape.hpp	2012-08-29 15:31:05 UTC (rev 13470)
@@ -0,0 +1,42 @@
+// Copyright (C) 2010 NICTA and the authors listed below
+// http://nicta.com.au
+//
+// Authors:
+// - Ryan Curtin (ryan at igglybob dot com)
+//
+// This file is part of the Armadillo C++ library.
+// It is provided without any warranty of fitness
+// for any purpose. You can redistribute this file
+// and/or modify it under the terms of the GNU
+// Lesser General Public License (LGPL) as published
+// by the Free Software Foundation, either version 3
+// of the License or (at your option) any later version.
+// (see http://www.opensource.org/licenses for more info)
+
+
+//! \addtogroup fn_inplace_reshape
+//! @{
+
+
+
+template<typename eT>
+inline
+Mat<eT>&
+inplace_reshape(Mat<eT>& X,
+                const uword new_n_rows,
+                const uword new_n_cols)
+  {
+  arma_extra_debug_sigprint();
+
+  arma_debug_check((new_n_rows * new_n_cols) != X.n_elem,
+      "inplace_reshape(): cannot add or remove elements");
+
+  access::rw(X.n_rows) = new_n_rows;
+  access::rw(X.n_cols) = new_n_cols;
+
+  return X;
+  }
+
+
+
+//! @}




More information about the mlpack-svn mailing list