From e491ce88c240432820dc7887eb46387f2aff0d87 Mon Sep 17 00:00:00 2001 From: Krad Date: Wed, 19 Apr 2023 11:30:05 +0800 Subject: [PATCH] Add operation ^ to Matrix class. --- src/Matrix.cpp | 6 ++++++ src/Matrix.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index b25326a..57dd81b 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -281,6 +281,12 @@ namespace Aurora { Matrix operator/(Matrix &&aMatrix, const Matrix &aOther) { return operatorMxM_RR(&vdDivI,&vzDivI,aOther,std::forward(aMatrix)); } + + //operator ^ (pow) + Matrix Matrix::operator^(int times) const { return operatorMxA(&vdPowI, times, *this);} + Matrix operator^( Matrix &&matrix,int times) { + return operatorMxA(&vdPowI, times, std::forward(matrix)); + } diff --git a/src/Matrix.h b/src/Matrix.h index 3f87952..885b04c 100644 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -88,6 +88,10 @@ namespace Aurora { Matrix operator/(Matrix &&matrix) const; friend Matrix operator/(Matrix &&aMatrix,const Matrix &aOther); + // pow + Matrix operator^(int times) const; + friend Matrix operator^(Matrix &&matrix,int times); + /** * print matrix , only support 2d matrix now */