memutils.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Neural Network Framework. *
3  * Copyright (C) 2005-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #ifndef MEMUTILS_H
21 #define MEMUTILS_H
22 
26 #include "nnfwconfig.h"
27 
28 namespace farsa {
29 
33 template<class T>
34 inline FARSA_NNFW_TEMPLATE void memoryCopy( T* dest, const T* src, unsigned int size ) {
35  for( unsigned int i=0; i<size; i++ ) {
36  dest[i] = src[i];
37  };
38 };
39 
43 template<class T>
44 inline FARSA_NNFW_TEMPLATE void memoryZeroing( T* data, unsigned int size ) {
45  for( unsigned int i=0; i<size; i++ ) {
46  data[i] = T();
47  };
48 };
49 
53 inline FARSA_NNFW_TEMPLATE void memoryCopy( float* dest, const float* src, unsigned int size ) {
54  memcpy( dest, src, sizeof(float)*size );
55 };
56 
60 inline FARSA_NNFW_TEMPLATE void memoryZeroing( float* data, unsigned int size ) {
61  memset( data, 0, sizeof(float)*size );
62 };
63 
67 inline FARSA_NNFW_TEMPLATE void memoryCopy( double* dest, const double* src, unsigned int size ) {
68  memcpy( dest, src, sizeof(double)*size );
69 };
70 
74 inline FARSA_NNFW_TEMPLATE void memoryZeroing( double* data, unsigned int size ) {
75  memset( data, 0, sizeof(double)*size );
76 };
77 
81 inline FARSA_NNFW_TEMPLATE void memoryCopy( bool* dest, const bool* src, unsigned int size ) {
82  memcpy( dest, src, sizeof(bool)*size );
83 };
84 
88 inline FARSA_NNFW_TEMPLATE void memoryZeroing( bool* data, unsigned int size ) {
89  memset( data, 0, sizeof(bool)*size );
90 };
91 
92 }
93 
94 #endif