From 094828d59df3931dfced69c59cbb538d6b0f1d99 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Mon, 14 Apr 2014 10:25:54 +0800 Subject: make const compatible --- src/CuBaseLib/cumatrix.h | 4 ++-- src/CuBaseLib/cumatrix.tcc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CuBaseLib/cumatrix.h b/src/CuBaseLib/cumatrix.h index 887b92d..dd76bb2 100644 --- a/src/CuBaseLib/cumatrix.h +++ b/src/CuBaseLib/cumatrix.h @@ -76,9 +76,9 @@ namespace TNet { /// Allocate the memory ThisType& Init(size_t rows, size_t cols); /// Copy the ptr of rSrc starting at x with span of cols - ThisType& Init(CuMatrix<_ElemT>& rSrc, size_t x, size_t cols); + ThisType& Init(const CuMatrix<_ElemT>& rSrc, size_t x, size_t cols); /// Copy the settings of rSrc - ThisType& Init(CuMatrix<_ElemT>& rSrc); + ThisType& Init(const CuMatrix<_ElemT>& rSrc); /// Deallocate the memory void Destroy(); diff --git a/src/CuBaseLib/cumatrix.tcc b/src/CuBaseLib/cumatrix.tcc index 7d6a136..66e335d 100644 --- a/src/CuBaseLib/cumatrix.tcc +++ b/src/CuBaseLib/cumatrix.tcc @@ -41,13 +41,13 @@ namespace TNet { template CuMatrix<_ElemT>& CuMatrix<_ElemT>:: - Init(CuMatrix<_ElemT>& rSrc, size_t x, size_t cols) + Init(const CuMatrix<_ElemT>& rSrc, size_t x, size_t cols) { mRows = rSrc.Rows(); mCols = cols; mStride = rSrc.Stride(); - mpCUData = rSrc.pCUData() + x; - isOwn=false; + mpCUData = const_cast<_ElemT*>(rSrc.pCUData()) + x; + isOwn = false; return *this; } @@ -57,13 +57,13 @@ namespace TNet { template CuMatrix<_ElemT>& CuMatrix<_ElemT>:: - Init(CuMatrix<_ElemT>& rSrc) + Init(const CuMatrix<_ElemT>& rSrc) { mRows = rSrc.Rows(); mCols = rSrc.Cols(); mStride = rSrc.Stride(); - mpCUData = rSrc.pCUData(); - isOwn=false; + mpCUData = const_cast<_ElemT*>(rSrc.pCUData()); + isOwn = false; return *this; } -- cgit v1.2.3-70-g09d2