mlpack 3.4.2
arma_util.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_BINDINGS_GO_GONUM_ARMA_UTIL_HPP
13#define MLPACK_BINDINGS_GO_GONUM_ARMA_UTIL_HPP
14
15// Include Armadillo via mlpack.
17#include <mlpack/core.hpp>
18
19namespace mlpack {
20
26template<typename T>
27inline typename T::elem_type* GetMemory(T& m)
28{
29 if (m.mem && m.n_elem <= arma::arma_config::mat_prealloc)
30 {
31 // We need to allocate new memory.
32 typename T::elem_type* mem =
33 arma::memory::acquire<typename T::elem_type>(m.n_elem);
34 arma::arrayops::copy(mem, m.memptr(), m.n_elem);
35 return mem;
36 }
37 else
38 {
39 arma::access::rw(m.mem_state) = 1;
40 return m.memptr();
41 }
42}
43
44} // namespace mlpack
45
46#endif
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
T::elem_type * GetMemory(T &m)
Return the matrix's allocated memory pointer, unless the matrix is using its internal preallocated me...
Definition: arma_util.hpp:27