From eb98e532b9bf714e8d881cb28ae8cf8087116f1f Mon Sep 17 00:00:00 2001 From: kradchen Date: Mon, 29 May 2023 14:28:23 +0800 Subject: [PATCH] Add setBlock method to Matrix. --- src/Matrix.cpp | 107 ++++++++++++++++++++++++++++++++++++++++--- src/Matrix.h | 2 + test/Matrix_Test.cpp | 47 ++++++++++++++++++- 3 files changed, 148 insertions(+), 8 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index aec01ea..5e9fccb 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -620,7 +620,7 @@ namespace Aurora { bool Matrix::setBlockValue(int aDim,int aBeginIndex, int aEndIndex, double value) { if(aDim>2 ){ - std::cerr<<"block only support 1D-3D data!"<=getDimSize(aDim) || aBeginIndex<0){ - std::cerr<<"block BeginIndx error!BeginIndx:"<=getDimSize(aDim) || aEndIndex<0){ - std::cerr<<"block EndIndex error!EndIndex:"<2 ){ + std::cerr<<"setBlock only support 1D-3D data!"<1){ + aDim = 1; + } + if (aBeginIndex>=getDimSize(aDim) || aBeginIndex<0){ + std::cerr<<"setBlock BeginIndx error!BeginIndx:"<=getDimSize(aDim) || aEndIndex<0){ + std::cerr<<"block EndIndex error!EndIndex:"<9?1.0:0.0); + } + } \ No newline at end of file