Fix Matrix block function bug.
This commit is contained in:
@@ -476,11 +476,15 @@ namespace Aurora {
|
||||
double& Matrix::operator[](size_t index) { return getData()[index];}
|
||||
double Matrix::operator[](size_t index) const { return getData()[index];}
|
||||
|
||||
Matrix Matrix::block(int aDim,int aBeginIndex, int aEndIndex){
|
||||
Matrix Matrix::block(int aDim,int aBeginIndex, int aEndIndex) const{
|
||||
if(aDim>2 ){
|
||||
std::cerr<<"block only support 1D-3D data!"<<std::endl;
|
||||
return Matrix();
|
||||
}
|
||||
//横向vector,切面为0,为1,都强制设置aDim为1来处理
|
||||
if (isVector() && aDim == 0 && getDimSize(1)>1){
|
||||
aDim = 1;
|
||||
}
|
||||
if (aBeginIndex>=getDimSize(aDim) || aBeginIndex<0){
|
||||
std::cerr<<"block BeginIndx error!BeginIndx:"<<aBeginIndex<<std::endl;
|
||||
return Matrix();
|
||||
@@ -494,7 +498,6 @@ namespace Aurora {
|
||||
double * dataOutput = malloc(dataSize);
|
||||
int colStride = getDimSize(0);
|
||||
int sliceStride = getDimSize(0)*getDimSize(1);
|
||||
|
||||
switch (aDim) {
|
||||
case 0:{
|
||||
int colStride2 = dimLength;
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Aurora {
|
||||
* @param aEndIndex 终止索引,包含
|
||||
* @return Matrix 返回矩阵
|
||||
*/
|
||||
Matrix block(int aDim,int aBeginIndx, int aEndIndex);
|
||||
Matrix block(int aDim,int aBeginIndx, int aEndIndex) const;
|
||||
|
||||
/**
|
||||
* 矩阵乘法
|
||||
|
||||
Reference in New Issue
Block a user