26 #if defined (HAVE_CONFIG_H)
46 #include "mx-cm-cdm.h"
47 #include "mx-fcm-fcdm.h"
64 error (
"Failed to diagonalize matrix while calculating matrix exponential");
70 error (
"for x^y, only square matrix arguments are permitted and one " \
71 "argument must be scalar. Use .^ for elementwise power.");
86 static const float out_of_range_top
89 &&
x < out_of_range_top
112 if (a < 0.0 && !
xisint (b))
133 if (nr == 0 || nc == 0)
147 lambda(i) =
std::pow (a, lambda(i));
157 catch (
const octave::execution_exception&)
182 if (nr == 0 || nc == 0)
196 lambda(i) =
std::pow (a, lambda(i));
202 catch (
const octave::execution_exception&)
219 if (nr == 0 || nc == 0)
227 int bint =
static_cast<int> (b);
246 atmp = a.
inverse (mattype, info, rcond, 1);
249 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
263 result = atmp * result;
284 lambda(i) =
std::pow (lambda(i), b);
290 catch (
const octave::execution_exception&)
308 if (nr == 0 || nc == 0)
316 int bint =
static_cast<int> (b);
338 return a.
power (
static_cast<int> (b));
352 if (nr == 0 || nc == 0)
366 lambda(i) =
std::pow (lambda(i), b);
372 catch (
const octave::execution_exception&)
387 result =
std::pow (a,
static_cast<int> (b));
403 if (nr == 0 || nc == 0)
417 lambda(i) =
std::pow (a, lambda(i));
423 catch (
const octave::execution_exception&)
449 if (nr == 0 || nc == 0)
463 lambda(i) =
std::pow (a, lambda(i));
469 catch (
const octave::execution_exception&)
486 if (nr == 0 || nc == 0)
494 int bint =
static_cast<int> (b);
513 atmp = a.
inverse (mattype, info, rcond, 1);
516 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
530 result = atmp * result;
551 lambda(i) =
std::pow (lambda(i), b);
557 catch (
const octave::execution_exception&)
575 if (nr == 0 || nc == 0)
589 lambda(i) =
std::pow (lambda(i), b);
595 catch (
const octave::execution_exception&)
612 if (nr == 0 || nc == 0)
687 result(i, j) =
std::pow (acplx, b(i, j));
700 result(i, j) =
std::pow (a, b(i, j));
723 result(i, j) =
std::pow (acplx, b(i, j));
732 return (a >= 0 && b >= 0) || (a <= 0 && b <= 0);
742 if (
r.numel () > 1 &&
r.all_elements_are_ints ()
750 double inc =
std::pow (a,
r.increment ());
753 result(i) = (base *= inc);
757 double limit =
std::pow (a,
r.final_value ());
758 double inc =
std::pow (a, -
r.increment ());
761 result(i) = (limit *= inc);
808 result(i, j) =
std::pow (a(i, j), b);
829 if (nr != b_nr || nc != b_nc)
832 bool convert_to_complex =
false;
837 double atmp = a(i, j);
838 double btmp = b(i, j);
839 if (atmp < 0.0 && !
xisint (btmp))
841 convert_to_complex =
true;
848 if (convert_to_complex)
858 complex_result(i, j) =
std::pow (acplx, bcplx);
861 retval = complex_result;
871 result(i, j) =
std::pow (a(i, j), b(i, j));
909 if (nr != b_nr || nc != b_nc)
937 double btmp = b(i, j);
939 result(i, j) =
std::pow (a,
static_cast<int> (btmp));
960 result(i, j) =
std::pow (a, b(i, j));
973 if (
r.numel () > 1 &&
r.all_elements_are_ints ()
985 result(i) = (base *= inc);
993 result(i) = (limit *= inc);
1000 Matrix tmp =
r.array_value ();
1018 int bint =
static_cast<int> (b);
1023 result(i, j) =
std::pow (a(i, j), bint);
1032 result(i, j) =
std::pow (a(i, j), b);
1049 if (nr != b_nr || nc != b_nc)
1058 double btmp = b(i, j);
1060 result(i, j) =
std::pow (a(i, j),
static_cast<int> (btmp));
1062 result(i, j) =
std::pow (a(i, j), btmp);
1081 result(i, j) =
std::pow (a(i, j), b);
1097 if (nr != b_nr || nc != b_nc)
1106 result(i, j) =
std::pow (a(i, j), b(i, j));
1153 result(i) =
std::pow (acplx, b(i));
1198 int bint =
static_cast<int> (b);
1202 result.
xelem (i) = a(i) * a(i);
1207 result.
xelem (i) = a(i) * a(i) * a(i);
1209 else if (bint == -1)
1212 result.
xelem (i) = 1.0 / a(i);
1265 if (a_dims != b_dims)
1281 bool convert_to_complex =
false;
1288 if (atmp < 0.0 && !
xisint (btmp))
1290 convert_to_complex =
true;
1297 if (convert_to_complex)
1305 complex_result(i) =
std::pow (acplx, b(i));
1308 retval = complex_result;
1348 if (a_dims != b_dims)
1378 result(i) =
std::pow (a,
static_cast<int> (btmp));
1409 int bint =
static_cast<int> (b);
1413 result.
xelem (i) = 1.0 / a(i);
1443 if (a_dims != b_dims)
1458 result(i) =
std::pow (a(i),
static_cast<int> (btmp));
1488 if (a_dims != b_dims)
1526 if (a < 0.0 && !
xisint (b))
1547 if (nr == 0 || nc == 0)
1561 lambda(i) =
std::pow (a, lambda(i));
1572 catch (
const octave::execution_exception&)
1597 if (nr == 0 || nc == 0)
1611 lambda(i) =
std::pow (a, lambda(i));
1617 catch (
const octave::execution_exception&)
1634 if (nr == 0 || nc == 0)
1642 int bint =
static_cast<int> (b);
1661 atmp = a.
inverse (mattype, info, rcond, 1);
1664 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
1678 result = atmp * result;
1699 lambda(i) =
std::pow (lambda(i), b);
1705 catch (
const octave::execution_exception&)
1723 if (nr == 0 || nc == 0)
1731 int bint =
static_cast<int> (b);
1757 if (nr == 0 || nc == 0)
1771 lambda(i) =
std::pow (lambda(i), b);
1777 catch (
const octave::execution_exception&)
1792 result =
std::pow (a,
static_cast<int> (b));
1808 if (nr == 0 || nc == 0)
1822 lambda(i) =
std::pow (a, lambda(i));
1828 catch (
const octave::execution_exception&)
1854 if (nr == 0 || nc == 0)
1868 lambda(i) =
std::pow (a, lambda(i));
1874 catch (
const octave::execution_exception&)
1891 if (nr == 0 || nc == 0)
1899 int bint =
static_cast<int> (b);
1918 atmp = a.
inverse (mattype, info, rcond, 1);
1921 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
1935 result = atmp * result;
1956 lambda(i) =
std::pow (lambda(i), b);
1962 catch (
const octave::execution_exception&)
1980 if (nr == 0 || nc == 0)
1994 lambda(i) =
std::pow (lambda(i), b);
2000 catch (
const octave::execution_exception&)
2017 if (nr == 0 || nc == 0)
2092 result(i, j) =
std::pow (acplx, b(i, j));
2105 result(i, j) =
std::pow (a, b(i, j));
2128 result(i, j) =
std::pow (acplx, b(i, j));
2154 result(i, j) =
std::pow (acplx, b);
2167 result(i, j) =
std::pow (a(i, j), b);
2188 if (nr != b_nr || nc != b_nc)
2191 bool convert_to_complex =
false;
2196 float atmp = a(i, j);
2197 float btmp = b(i, j);
2198 if (atmp < 0.0 && !
xisint (btmp))
2200 convert_to_complex =
true;
2207 if (convert_to_complex)
2217 complex_result(i, j) =
std::pow (acplx, bcplx);
2220 retval = complex_result;
2230 result(i, j) =
std::pow (a(i, j), b(i, j));
2268 if (nr != b_nr || nc != b_nc)
2296 float btmp = b(i, j);
2298 result(i, j) =
std::pow (a,
static_cast<int> (btmp));
2319 result(i, j) =
std::pow (a, b(i, j));
2336 int bint =
static_cast<int> (b);
2341 result(i, j) =
std::pow (a(i, j), bint);
2350 result(i, j) =
std::pow (a(i, j), b);
2367 if (nr != b_nr || nc != b_nc)
2376 float btmp = b(i, j);
2378 result(i, j) =
std::pow (a(i, j),
static_cast<int> (btmp));
2380 result(i, j) =
std::pow (a(i, j), btmp);
2399 result(i, j) =
std::pow (a(i, j), b);
2415 if (nr != b_nr || nc != b_nc)
2424 result(i, j) =
std::pow (a(i, j), b(i, j));
2471 result(i) =
std::pow (acplx, b(i));
2516 int bint =
static_cast<int> (b);
2520 result.
xelem (i) = a(i) * a(i);
2525 result.
xelem (i) = a(i) * a(i) * a(i);
2527 else if (bint == -1)
2530 result.
xelem (i) = 1.0f / a(i);
2585 if (a_dims != b_dims)
2601 bool convert_to_complex =
false;
2608 if (atmp < 0.0 && !
xisint (btmp))
2610 convert_to_complex =
true;
2617 if (convert_to_complex)
2625 complex_result(i) =
std::pow (acplx, b(i));
2628 retval = complex_result;
2668 if (a_dims != b_dims)
2698 result(i) =
std::pow (a,
static_cast<int> (btmp));
2729 int bint =
static_cast<int> (b);
2733 result.
xelem (i) = 1.0f / a(i);
2763 if (a_dims != b_dims)
2778 result(i) =
std::pow (a(i),
static_cast<int> (btmp));
2808 if (a_dims != b_dims)
ComplexNDArray bsxfun_pow(const ComplexNDArray &x, const ComplexNDArray &y)
bool is_valid_bsxfun(const std::string &name, const dim_vector &xdv, const dim_vector &ydv)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type cols(void) const
OCTARRAY_OVERRIDABLE_FUNC_API T & xelem(octave_idx_type n)
Size of the specified dimension.
OCTAVE_API ComplexMatrix inverse(void) const
T & dgxelem(octave_idx_type i)
octave_idx_type cols(void) const
octave_idx_type rows(void) const
ComplexMatrix right_eigenvectors(void) const
ComplexColumnVector eigenvalues(void) const
OCTAVE_API FloatComplexMatrix inverse(void) const
FloatComplexColumnVector eigenvalues(void) const
FloatComplexMatrix right_eigenvectors(void) const
OCTAVE_API FloatMatrix inverse(void) const
OCTAVE_API bool any_element_is_negative(bool=false) const
OCTAVE_API bool all_integers(float &max_val, float &min_val) const
OCTAVE_API Matrix inverse(void) const
OCTAVE_API bool all_integers(double &max_val, double &min_val) const
OCTAVE_API bool any_element_is_negative(bool=false) const
OCTAVE_API PermMatrix power(octave_idx_type n) const
Vector representing the dimensions (size) of an Array.
ColumnVector real(const ComplexColumnVector &a)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void warning(const char *fmt,...)
void error(const char *fmt,...)
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Q
F77_RET_T const F77_DBLE * x
class OCTAVE_API FloatDiagMatrix
class OCTAVE_API DiagMatrix
class OCTAVE_API ComplexMatrix
class OCTAVE_API FloatComplexMatrix
class OCTAVE_API FloatMatrix
std::complex< double > Complex
std::complex< float > FloatComplex
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
NDArray octave_value_extract< NDArray >(const octave_value &v)
FloatNDArray octave_value_extract< FloatNDArray >(const octave_value &v)
static bool same_sign(double a, double b)
static void err_nonsquare_matrix(void)
static void err_failed_diagonalization(void)
octave_value elem_xpow(double a, const Matrix &b)
octave_value xpow(double a, double b)