From 6cc1fb07532bf72b0152f9f5fdfe3ac95fe2bf55 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 23 Aug 2006 15:24:45 +0000 Subject: [PATCH] Copy constructor : faster memcpy instead of slow 'for' cycle empty constructor --- vcg/math/matrix.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/vcg/math/matrix.h b/vcg/math/matrix.h index 6eac53eb..a8e5efec 100644 --- a/vcg/math/matrix.h +++ b/vcg/math/matrix.h @@ -22,6 +22,9 @@ ****************************************************************************/ /*************************************************************************** $Log: not supported by cvs2svn $ +Revision 1.7 2006/04/29 10:26:04 fiorin +Added some utility methods (swapping of columns and rows, matrix-vector multiplication) + Revision 1.6 2006/04/11 08:09:35 zifnab1974 changes necessary for gcc 3.4.5 on linux 64bit. Please take note of case-sensitivity of filenames @@ -30,6 +33,11 @@ added diagonal matrix, outer produce and namespace ***************************************************************************/ +// marco +// Copy constructor : memcpy instead of 'for' cycle +// empty constructor + + #ifndef MATRIX_VCGLIB #define MATRIX_VCGLIB @@ -106,6 +114,17 @@ namespace vcg{ // _data[i] = values[i]; }; + /*! + * Empty constructor + * Just create the object + */ + Matrix() + { + _rows = 0; + _columns = 0; + _data = NULL; + }; + /*! * Copy constructor * The matrix elements are initialized with the value of the corresponding element in \i m @@ -116,8 +135,12 @@ namespace vcg{ _rows = m._rows; _columns = m._columns; _data = new ScalarType[_rows*_columns]; - for (unsigned int i=0; i<_rows*_columns; i++) - _data[i] = m._data[i]; + + unsigned int dim = _rows * _columns; + memcpy(_data, m._data, dim * sizeof(ScalarType)); + +// for (unsigned int i=0; i<_rows*_columns; i++) +// _data[i] = m._data[i]; }; /*!