Mercurial > hg > octave-nkf
diff src/xpow.cc @ 8958:6ccc12cc65ef
implement raising a permutation matrix to integer power
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 11 Mar 2009 14:07:24 +0100 |
parents | eb63fbe60fab |
children | 93f18f166aba |
line wrap: on
line diff
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -38,6 +38,7 @@ #include "dDiagMatrix.h" #include "fDiagMatrix.h" #include "dMatrix.h" +#include "PermMatrix.h" #include "mx-cm-cdm.h" #include "oct-cmplx.h" #include "quit.h" @@ -296,6 +297,18 @@ return retval; } +// -*- 5p -*- +octave_value +xpow (const PermMatrix& a, double b) +{ + octave_value retval; + int btmp = static_cast<int> (b); + if (btmp == b) + return a.power (btmp); + else + return xpow (Matrix (a), b); +} + // -*- 6 -*- octave_value xpow (const Matrix& a, const Complex& b) @@ -1576,6 +1589,18 @@ return retval; } +// -*- 5p -*- +octave_value +xpow (const PermMatrix& a, float b) +{ + octave_value retval; + int btmp = static_cast<int> (b); + if (btmp == b) + return octave_value (a.power (btmp), true); + else + return xpow (FloatMatrix (a), b); +} + // -*- 6 -*- octave_value xpow (const FloatMatrix& a, const FloatComplex& b)