24 #if defined (HAVE_CONFIG_H)
61 error (
"Failed to diagonalize matrix while calculating matrix exponential");
67 error (
"for x^A, A must be a square matrix. Use .^ for elementwise power.");
97 if (a < 0.0 && !
xisint (b))
118 if (nr == 0 || nc == 0 || nr != nc)
144 catch (
const octave::execution_exception&)
169 if (nr == 0 || nc == 0 || nr != nc)
191 catch (
const octave::execution_exception&)
208 if (nr == 0 || nc == 0 || nr != nc)
211 if (static_cast<int> (b) == b)
213 int btmp =
static_cast<int> (
b);
232 atmp = a.
inverse (mattype, info, rcond, 1);
235 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
247 result = result * atmp;
274 catch (
const octave::execution_exception&)
292 if (nr == 0 || nc == 0 || nr != nc)
295 if (static_cast<int> (b) == b)
317 int btmp =
static_cast<int> (
b);
319 return a.
power (btmp);
333 if (nr == 0 || nc == 0 || nr != nc)
350 catch (
const octave::execution_exception&)
365 result =
std::pow (a, static_cast<int> (b));
381 if (nr == 0 || nc == 0 || nr != nc)
403 catch (
const octave::execution_exception&)
429 if (nr == 0 || nc == 0 || nr != nc)
451 catch (
const octave::execution_exception&)
468 if (nr == 0 || nc == 0 || nr != nc)
471 if (static_cast<int> (b) == b)
473 int btmp =
static_cast<int> (
b);
492 atmp = a.
inverse (mattype, info, rcond, 1);
495 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
507 result = result * atmp;
534 catch (
const octave::execution_exception&)
552 if (nr == 0 || nc == 0 || nr != nc)
569 catch (
const octave::execution_exception&)
586 if (nr == 0 || nc == 0 || nr != nc)
601 return xpow (a, static_cast<Complex> (b));
703 return (a >= 0 && b >= 0) || (a <= 0 && b <= 0);
798 if (nr != b_nr || nc != b_nc)
801 int convert_to_complex = 0;
806 double atmp =
a (
i, j);
807 double btmp =
b (
i, j);
808 if (atmp < 0.0 && static_cast<int> (btmp) != btmp)
810 convert_to_complex = 1;
817 if (convert_to_complex)
827 complex_result (
i, j) =
std::pow (atmp, btmp);
830 retval = complex_result;
878 if (nr != b_nr || nc != b_nc)
906 double btmp =
b (
i, j);
1015 if (nr != b_nr || nc != b_nc)
1024 double btmp =
b (
i, j);
1063 if (nr != b_nr || nc != b_nc)
1193 int ib =
static_cast<int> (
b);
1233 if (a_dims != b_dims)
1247 int len = a.
numel ();
1249 bool convert_to_complex =
false;
1256 if (atmp < 0.0 && static_cast<int> (btmp) != btmp)
1258 convert_to_complex =
true;
1265 if (convert_to_complex)
1276 retval = complex_result;
1316 if (a_dims != b_dims)
1410 if (a_dims != b_dims)
1455 if (a_dims != b_dims)
1501 if (a < 0.0 && !
xisint (b))
1522 if (nr == 0 || nc == 0 || nr != nc)
1549 catch (
const octave::execution_exception&)
1574 if (nr == 0 || nc == 0 || nr != nc)
1596 catch (
const octave::execution_exception&)
1613 if (nr == 0 || nc == 0 || nr != nc)
1616 if (static_cast<int> (b) == b)
1618 int btmp =
static_cast<int> (
b);
1637 atmp = a.
inverse (mattype, info, rcond, 1);
1640 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
1652 result = result * atmp;
1679 catch (
const octave::execution_exception&)
1697 if (nr == 0 || nc == 0 || nr != nc)
1700 if (static_cast<int> (b) == b)
1728 if (nr == 0 || nc == 0 || nr != nc)
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)
1866 if (static_cast<int> (b) == b)
1868 int btmp =
static_cast<int> (
b);
1887 atmp = a.
inverse (mattype, info, rcond, 1);
1890 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
1902 result = result * atmp;
1929 catch (
const octave::execution_exception&)
1947 if (nr == 0 || nc == 0 || nr != nc)
1964 catch (
const octave::execution_exception&)
1981 if (nr == 0 || nc == 0 || nr != nc)
1996 return xpow (a, static_cast<FloatComplex> (b));
2149 if (nr != b_nr || nc != b_nc)
2152 int convert_to_complex = 0;
2157 float atmp =
a (
i, j);
2158 float btmp =
b (
i, j);
2159 if (atmp < 0.0 && static_cast<int> (btmp) != btmp)
2161 convert_to_complex = 1;
2168 if (convert_to_complex)
2178 complex_result (
i, j) =
std::pow (atmp, btmp);
2181 retval = complex_result;
2229 if (nr != b_nr || nc != b_nc)
2257 float btmp =
b (
i, j);
2327 if (nr != b_nr || nc != b_nc)
2336 float btmp =
b (
i, j);
2375 if (nr != b_nr || nc != b_nc)
2505 int ib =
static_cast<int> (
b);
2545 if (a_dims != b_dims)
2559 int len = a.
numel ();
2561 bool convert_to_complex =
false;
2568 if (atmp < 0.0 && static_cast<int> (btmp) != btmp)
2570 convert_to_complex =
true;
2577 if (convert_to_complex)
2588 retval = complex_result;
2628 if (a_dims != b_dims)
2722 if (a_dims != b_dims)
2767 if (a_dims != b_dims)
bool any_element_is_negative(bool=false) const
static void err_nonsquare_matrix(void)
FloatNDArray octave_value_extract< FloatNDArray >(const octave_value &v)
octave_value elem_xpow(double a, const Matrix &b)
ComplexMatrix inverse(void) const
octave_idx_type numel(void) const
Number of elements in the array.
void error(const char *fmt,...)
octave_idx_type rows(void) const
FloatComplexMatrix inverse(void) const
FloatComplexColumnVector eigenvalues(void) const
octave_idx_type rows(void) const
ComplexColumnVector eigenvalues(void) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
T dgelem(octave_idx_type i) const
NDArray octave_value_extract< NDArray >(const octave_value &v)
bool all_integers(double &max_val, double &min_val) const
octave_value xpow(double a, double b)
octave_idx_type numel(void) const
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
Matrix matrix_value(void) const
bool any_element_is_negative(bool=false) const
ComplexNDArray bsxfun_pow(const ComplexNDArray &x, const ComplexNDArray &y)
With real return the complex result
void warning(const char *fmt,...)
octave_idx_type cols(void) const
charNDArray max(char d, const charNDArray &m)
FloatMatrix inverse(void) const
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
=val(i)}if ode{val(i)}occurs in table i
static int xisint(double x)
FloatComplexMatrix right_eigenvectors(void) const
static bool same_sign(double a, double b)
static void err_failed_diagonalization(void)
bool all_integers(float &max_val, float &min_val) const
bool all_elements_are_ints(void) const
ComplexMatrix right_eigenvectors(void) const
ColumnVector imag(const ComplexColumnVector &a)
std::complex< float > FloatComplex
std::complex< double > Complex
bool is_valid_bsxfun(const std::string &name, const dim_vector &dx, const dim_vector &dy)
ColumnVector real(const ComplexColumnVector &a)
octave_idx_type cols(void) const
Vector representing the dimensions (size) of an Array.
PermMatrix power(octave_idx_type n) const
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
Matrix inverse(void) const
charNDArray min(char d, const charNDArray &m)
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