26 #if defined (HAVE_CONFIG_H)
46 #include "mx-cm-cdm.h"
47 #include "mx-fcm-fcdm.h"
63 error (
"Failed to diagonalize matrix while calculating matrix exponential");
69 error (
"for x^y, only square matrix arguments are permitted and one " \
70 "argument must be scalar. Use .^ for elementwise power.");
101 if (a < 0.0 && !
xisint (b))
122 if (nr == 0 || nc == 0 || nr != nc)
148 catch (
const octave::execution_exception&)
173 if (nr == 0 || nc == 0 || nr != nc)
195 catch (
const octave::execution_exception&)
212 if (nr == 0 || nc == 0 || nr != nc)
217 int bint =
static_cast<int> (b);
236 atmp = a.
inverse (mattype, info, rcond, 1);
239 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
253 result = atmp * result;
274 lambda(i) =
std::pow (lambda(i), b);
280 catch (
const octave::execution_exception&)
298 if (nr == 0 || nc == 0 || nr != nc)
324 return a.
power (
static_cast<int> (b));
338 if (nr == 0 || nc == 0 || nr != nc)
349 lambda(i) =
std::pow (lambda(i), b);
355 catch (
const octave::execution_exception&)
370 result =
std::pow (a,
static_cast<int> (b));
386 if (nr == 0 || nc == 0 || nr != nc)
408 catch (
const octave::execution_exception&)
434 if (nr == 0 || nc == 0 || nr != nc)
456 catch (
const octave::execution_exception&)
473 if (nr == 0 || nc == 0 || nr != nc)
478 int bint =
static_cast<int> (b);
497 atmp = a.
inverse (mattype, info, rcond, 1);
500 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
514 result = atmp * result;
535 lambda(i) =
std::pow (lambda(i), b);
541 catch (
const octave::execution_exception&)
559 if (nr == 0 || nc == 0 || nr != nc)
570 lambda(i) =
std::pow (lambda(i), b);
576 catch (
const octave::execution_exception&)
593 if (nr == 0 || nc == 0 || nr != nc)
665 result(i, j) =
std::pow (atmp, b(i, j));
678 result(i, j) =
std::pow (a, b(i, j));
701 result(i, j) =
std::pow (atmp, b(i, j));
710 return (a >= 0 && b >= 0) || (a <= 0 && b <= 0);
720 if (
r.numel () > 1 &&
r.all_elements_are_ints ()
731 result(i) = (base *= inc);
736 double limit =
std::pow (a,
r.base () + (
n-1) *
r.inc ());
740 result(i) = (limit *= inc);
784 result(i, j) =
std::pow (a(i, j), b);
805 if (nr != b_nr || nc != b_nc)
808 bool convert_to_complex =
false;
813 double atmp = a(i, j);
814 double btmp = b(i, j);
815 if (atmp < 0.0 && !
xisint (btmp))
817 convert_to_complex =
true;
824 if (convert_to_complex)
834 complex_result(i, j) =
std::pow (atmp, btmp);
847 result(i, j) =
std::pow (a(i, j), b(i, j));
885 if (nr != b_nr || nc != b_nc)
913 double btmp = b(i, j);
915 result(i, j) =
std::pow (a,
static_cast<int> (btmp));
936 result(i, j) =
std::pow (a, b(i, j));
949 if (
r.numel () > 1 &&
r.all_elements_are_ints ()
961 result(i) = (base *= inc);
970 result(i) = (limit *= inc);
992 int bint =
static_cast<int> (b);
997 result(i, j) =
std::pow (a(i, j), bint);
1006 result(i, j) =
std::pow (a(i, j), b);
1023 if (nr != b_nr || nc != b_nc)
1032 double btmp = b(i, j);
1034 result(i, j) =
std::pow (a(i, j),
static_cast<int> (btmp));
1036 result(i, j) =
std::pow (a(i, j), btmp);
1055 result(i, j) =
std::pow (a(i, j), b);
1071 if (nr != b_nr || nc != b_nc)
1080 result(i, j) =
std::pow (a(i, j), b(i, j));
1199 int ib =
static_cast<int> (b);
1203 result.
xelem (i) = a(i) * a(i);
1208 result.
xelem (i) = a(i) * a(i) * a(i);
1213 result.
xelem (i) = 1.0 / a(i);
1239 if (a_dims != b_dims)
1255 bool convert_to_complex =
false;
1262 if (atmp < 0.0 && !
xisint (btmp))
1264 convert_to_complex =
true;
1271 if (convert_to_complex)
1279 complex_result(i) =
std::pow (atmp, b(i));
1322 if (a_dims != b_dims)
1352 result(i) =
std::pow (a,
static_cast<int> (btmp));
1383 int bint =
static_cast<int> (b);
1387 result.
xelem (i) = 1.0 / a(i);
1417 if (a_dims != b_dims)
1432 result(i) =
std::pow (a(i),
static_cast<int> (btmp));
1462 if (a_dims != b_dims)
1500 if (a < 0.0 && !
xisint (b))
1521 if (nr == 0 || nc == 0 || nr != nc)
1548 catch (
const octave::execution_exception&)
1573 if (nr == 0 || nc == 0 || nr != nc)
1595 catch (
const octave::execution_exception&)
1612 if (nr == 0 || nc == 0 || nr != nc)
1617 int bint =
static_cast<int> (b);
1636 atmp = a.
inverse (mattype, info, rcond, 1);
1639 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
1653 result = atmp * result;
1674 lambda(i) =
std::pow (lambda(i), b);
1680 catch (
const octave::execution_exception&)
1698 if (nr == 0 || nc == 0 || nr != nc)
1728 if (nr == 0 || nc == 0 || nr != nc)
1739 lambda(i) =
std::pow (lambda(i), b);
1745 catch (
const octave::execution_exception&)
1760 result =
std::pow (a,
static_cast<int> (b));
1776 if (nr == 0 || nc == 0 || nr != nc)
1798 catch (
const octave::execution_exception&)
1824 if (nr == 0 || nc == 0 || nr != nc)
1846 catch (
const octave::execution_exception&)
1863 if (nr == 0 || nc == 0 || nr != nc)
1868 int bint =
static_cast<int> (b);
1887 atmp = a.
inverse (mattype, info, rcond, 1);
1890 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
1904 result = atmp * result;
1925 lambda(i) =
std::pow (lambda(i), b);
1931 catch (
const octave::execution_exception&)
1949 if (nr == 0 || nc == 0 || nr != nc)
1960 lambda(i) =
std::pow (lambda(i), b);
1966 catch (
const octave::execution_exception&)
1983 if (nr == 0 || nc == 0 || nr != nc)
2055 result(i, j) =
std::pow (atmp, b(i, j));
2068 result(i, j) =
std::pow (a, b(i, j));
2091 result(i, j) =
std::pow (atmp, b(i, j));
2130 result(i, j) =
std::pow (a(i, j), b);
2151 if (nr != b_nr || nc != b_nc)
2154 bool convert_to_complex =
false;
2159 float atmp = a(i, j);
2160 float btmp = b(i, j);
2161 if (atmp < 0.0 && !
xisint (btmp))
2163 convert_to_complex =
true;
2170 if (convert_to_complex)
2180 complex_result(i, j) =
std::pow (atmp, btmp);
2193 result(i, j) =
std::pow (a(i, j), b(i, j));
2231 if (nr != b_nr || nc != b_nc)
2259 float btmp = b(i, j);
2261 result(i, j) =
std::pow (a,
static_cast<int> (btmp));
2282 result(i, j) =
std::pow (a, b(i, j));
2299 int bint =
static_cast<int> (b);
2304 result(i, j) =
std::pow (a(i, j), bint);
2313 result(i, j) =
std::pow (a(i, j), b);
2330 if (nr != b_nr || nc != b_nc)
2339 float btmp = b(i, j);
2341 result(i, j) =
std::pow (a(i, j),
static_cast<int> (btmp));
2343 result(i, j) =
std::pow (a(i, j), btmp);
2362 result(i, j) =
std::pow (a(i, j), b);
2378 if (nr != b_nr || nc != b_nc)
2387 result(i, j) =
std::pow (a(i, j), b(i, j));
2508 int ib =
static_cast<int> (b);
2512 result.
xelem (i) = a(i) * a(i);
2517 result.
xelem (i) = a(i) * a(i) * a(i);
2522 result.
xelem (i) = 1.0f / a(i);
2548 if (a_dims != b_dims)
2564 bool convert_to_complex =
false;
2571 if (atmp < 0.0 && !
xisint (btmp))
2573 convert_to_complex =
true;
2580 if (convert_to_complex)
2588 complex_result(i) =
std::pow (atmp, b(i));
2631 if (a_dims != b_dims)
2661 result(i) =
std::pow (a,
static_cast<int> (btmp));
2692 int bint =
static_cast<int> (b);
2696 result.
xelem (i) = 1.0f / a(i);
2726 if (a_dims != b_dims)
2741 result(i) =
std::pow (a(i),
static_cast<int> (btmp));
2771 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)
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type cols(void) const
octave_idx_type rows(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
ComplexMatrix inverse(void) const
T dgelem(octave_idx_type i) const
octave_idx_type cols(void) const
octave_idx_type rows(void) const
ComplexMatrix right_eigenvectors(void) const
ComplexColumnVector eigenvalues(void) const
FloatComplexMatrix inverse(void) const
FloatComplexColumnVector eigenvalues(void) const
FloatComplexMatrix right_eigenvectors(void) const
FloatMatrix inverse(void) const
bool any_element_is_negative(bool=false) const
bool all_integers(float &max_val, float &min_val) const
Matrix inverse(void) const
bool all_integers(double &max_val, double &min_val) const
bool any_element_is_negative(bool=false) const
PermMatrix power(octave_idx_type n) const
Vector representing the dimensions (size) of an Array.
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
void warning(const char *fmt,...)
void error(const char *fmt,...)
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
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
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()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
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)