24 #if defined (HAVE_CONFIG_H) 39 template <
typename Matrix>
45 const element_type
zero = element_type ();
47 bool singular =
false;
68 element_type *colj = Tp + n*j;
70 colj[j] =
sqrt (colj[j]);
76 const element_type *coli = Tp + n*
i;
77 const element_type colji = colj[
i] /= (coli[
i] + colj[j]);
79 colj[
k] -= coli[
k] * colji;
85 "sqrtm: matrix is singular, may not have a square root");
88 template <
typename Matrix,
typename ComplexMatrix,
typename ComplexSCHUR>
101 real_type cutoff = 0;
103 real_type
eps = std::numeric_limits<real_type>::epsilon ();
116 if (!
x.diag ().any_element_is_negative ())
128 if (!
x.diag ().any_element_is_negative ())
145 cutoff = 10 *
x.rows () *
eps *
xnorm (
x, one);
177 ComplexSCHUR schur_fact (
x,
"",
true);
178 x = schur_fact.schur_matrix ();
179 u = schur_fact.unitary_matrix ();
188 if (cutoff > 0 &&
xnorm (
imag (res), one) <= cutoff)
212 if (args.length () != 1)
octave_value sqrt(void) const
octave_idx_type rows(void) const
void warning_with_id(const char *id, const char *fmt,...)
static octave_value do_sqrtm(const octave_value &arg)
OCTINTERP_API void print_usage(void)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by zero($0/0$)
const T * fortran_vec(void) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
bool is_unknown(void) const
void err_square_matrix_required(const char *fcn, const char *name)
int type(bool quiet=true)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
octave_idx_type columns(void) const
bool is_single_type(void) const
octave_idx_type rows(void) const
OCTAVE_API double xnorm(const ColumnVector &x, double p)
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
MatrixType matrix_type(void) const
OCTAVE_API double xfrobnorm(const Matrix &x)
bool iscomplex(void) const
ColumnVector imag(const ComplexColumnVector &a)
bool is_diag_matrix(void) const
static void sqrtm_utri_inplace(Matrix &T)
ComplexMatrix octave_value_extract< ComplexMatrix >(const octave_value &v)
ColumnVector real(const ComplexColumnVector &a)
Matrix octave_value_extract< Matrix >(const octave_value &v)
bool isnumeric(void) const
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 const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x