From b8cd3040b41742c9daf29e2eb6e7769d2e0ad8fc Mon Sep 17 00:00:00 2001 From: Krad Date: Thu, 11 May 2023 16:21:01 +0800 Subject: [PATCH 1/2] Add sub2ind comment. --- .gitignore | 2 +- src/Function2D.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 51fa643..46b1663 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .idea/ -cmake-build-debug/* +cmake-*/* cmake-build-debug-wsl/* build*/ .vscode/ diff --git a/src/Function2D.h b/src/Function2D.h index 3a3bbec..1429e95 100644 --- a/src/Function2D.h +++ b/src/Function2D.h @@ -148,6 +148,13 @@ namespace Aurora Matrix dot(const Matrix &aMatrix, const Matrix &aOther, FunctionDirection direction = Column); + /** + * 转换下标为索引值 + * @attention 索引值按照其实为1与matlab对应,在C++中使用需要-1 + * @param aVMatrixSize + * @param aSliceIdxs + * @return + */ Matrix sub2ind(const Matrix &aVMatrixSize, std::initializer_list aSliceIdxs); }; From 1f9f5fc82a2f056af629d1741d6fb53ccddbc10e Mon Sep 17 00:00:00 2001 From: kradchen Date: Fri, 12 May 2023 09:44:25 +0800 Subject: [PATCH 2/2] Fix matrix slice bug --- src/Matrix.cpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index 4f43156..ea24216 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -915,23 +915,45 @@ namespace Aurora { std::cerr <<"Assign value fail!Src data pointer is null!"; return *this; } - if (matrix.getDims()!=mSliceMode) { - std::cerr <<"Assign value fail!Src matrix(dims count:"<< matrix.getDims() <<"), not match of des(dims count:"<