26#if defined (HAVE_CONFIG_H)
51 return (octave::math::x_nint (
x) ==
x
52 && ((
x >= 0 &&
x < std::numeric_limits<int>::max ())
53 || (x <= 0 && x > std::numeric_limits<int>::min ())));
67 if (nr == 0 || nc == 0)
72 error (
"for A^b, A must be a square matrix. Use .^ for elementwise power.");
75 error (
"use full(a) ^ full(b)");
77 int btmp =
static_cast<int> (b);
105 atmp = a.
inverse (mattyp, info, rcond, 1);
108 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
113 if (atmp.
nnz () == 0)
143 uint64_t sparsity = atmp.
numel () / atmp.
nnz ();
144 int threshold = (sparsity >= 1000) ? 40
145 : (sparsity >= 100) ? 20
148 if (btmp > threshold)
153 result = result * atmp;
163 for (
int i = 0; i < btmp; i++)
164 result = result * atmp;
181 if (nr == 0 || nc == 0)
186 error (
"for A^b, A must be a square matrix. Use .^ for elementwise power.");
189 error (
"use full(a) ^ full(b)");
191 int btmp =
static_cast<int> (b);
216 atmp = a.
inverse (mattyp, info, rcond, 1);
219 warning (
"inverse: matrix singular to machine precision, rcond = %g", rcond);
224 if (atmp.
nnz () == 0)
237 uint64_t sparsity = atmp.
numel () / atmp.
nnz ();
238 int threshold = (sparsity >= 1000) ? 40
239 : (sparsity >= 100) ? 20
242 if (btmp > threshold)
247 result = result * atmp;
257 for (
int i = 0; i < btmp; i++)
258 result = result * atmp;
302template <
typename S,
typename SM>
364 result(i, j) = std::pow (atmp, b(i, j));
379 result(i, j) = std::pow (a, b(i, j));
404 result(i, j) = std::pow (atmp, b(i, j));
443 result(a.
ridx (i), j) = std::pow (atmp, btmp);
450 Matrix result (nr, nc, (std::pow (0.0, b)));
456 result(a.
ridx (i), j) = std::pow (a.
data (i), b);
476 result.
data (i) = std::pow (atmp, btmp);
490 result.
data (i) = std::pow (a.
data (i), b);
516 if (nr != b_nr || nc != b_nc)
517 octave::err_nonconformant (
"operator .^", nr, nc, b_nr, b_nc);
519 int convert_to_complex = 0;
525 double btmp = b (a.
ridx (i), j);
528 convert_to_complex = 1;
541 if (convert_to_complex)
555 retval = complex_result;
618 if (nr != b_nr || nc != b_nc)
619 octave::err_nonconformant (
"operator .^", nr, nc, b_nr, b_nc);
650 double btmp = b (i, j);
652 result (i, j) = std::pow (a,
static_cast<int> (btmp));
654 result (i, j) = std::pow (a, btmp);
673 result (i, j) = std::pow (a, b (i, j));
698 result (a.
ridx (i), j)
699 = std::pow (a.
data (i),
static_cast<int> (b));
708 result (a.
ridx (i), j) = std::pow (a.
data (i), b);
725 result.
data (i) = std::pow (a.
data (i),
static_cast<int> (b));
733 result.
data (i) = std::pow (a.
data (i), b);
758 if (nr != b_nr || nc != b_nc)
759 octave::err_nonconformant (
"operator .^", nr, nc, b_nr, b_nc);
767 double btmp = b(a.
ridx (i), j);
771 static_cast<int> (btmp));
801 result.
data (i) = std::pow (a.
data (i), b);
825 if (nr != b_nr || nc != b_nc)
826 octave::err_nonconformant (
"operator .^", nr, nc, b_nr, b_nc);
844OCTAVE_END_NAMESPACE(octave)
SparseComplexMatrix inverse() const
bool all_integers(double &max_val, double &min_val) const
SparseMatrix inverse() const
bool any_element_is_negative(bool=false) const
octave_idx_type cols() const
octave_idx_type numel() const
Sparse< T, Alloc > maybe_compress(bool remove_zeros=false)
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
T & xelem(octave_idx_type n)
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
Matrix matrix_value(bool frc_str_conv=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void warning(const char *fmt,...)
void error(const char *fmt,...)
F77_RET_T const F77_DBLE * x
std::complex< double > Complex
octave_value xpow(const SparseMatrix &a, double b)
octave_value elem_xpow(double a, const SparseMatrix &b)
octave_value scalar_xpow(const S &a, const SM &b)