26 #if defined (HAVE_CONFIG_H)
41 template <
typename Matrix>
47 const element_type zero = element_type ();
49 bool singular =
false;
70 element_type *colj = Tp +
n*j;
72 colj[j] = sqrt (colj[j]);
78 const element_type *coli = Tp +
n*i;
79 const element_type colji = colj[i] /= (coli[i] + colj[j]);
81 colj[k] -= coli[k] * colji;
87 "sqrtm: matrix is singular, may not have a square root");
90 template <
typename Matrix,
typename ComplexMatrix,
typename ComplexSCHUR>
103 real_type cutoff = 0;
105 real_type
eps = std::numeric_limits<real_type>::epsilon ();
118 if (!
x.diag ().any_element_is_negative ())
130 if (!
x.diag ().any_element_is_negative ())
147 cutoff = 10 *
x.rows () *
eps *
xnorm (
x, one);
179 ComplexSCHUR schur_fact (
x,
"",
true);
180 x = schur_fact.schur_matrix ();
181 u = schur_fact.unitary_matrix ();
190 if (cutoff > 0 &&
xnorm (
imag (res), one) <= cutoff)
202 DEFUN (sqrtm, args, nargout,
214 if (args.length () != 1)
222 if (
n != nc || arg.
ndims () > 2)
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
octave_idx_type rows(void) const
const T * fortran_vec(void) const
Size of the specified dimension.
bool is_unknown(void) const
int type(bool quiet=true)
MatrixType matrix_type(void) const
octave_idx_type rows(void) const
bool isnumeric(void) const
bool is_diag_matrix(void) const
octave_idx_type columns(void) const
octave_value sqrt(void) const
bool is_single_type(void) const
bool iscomplex(void) const
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning_with_id(const char *id, const char *fmt,...)
void err_square_matrix_required(const char *fcn, const char *name)
F77_RET_T const F77_DBLE * x
OCTAVE_API double xfrobnorm(const Matrix &x)
OCTAVE_API double xnorm(const ColumnVector &x, double p)
octave_value::octave_value(const Array< char > &chm, char type) return retval
ComplexMatrix octave_value_extract< ComplexMatrix >(const octave_value &v)
Matrix octave_value_extract< Matrix >(const octave_value &v)
static octave_value do_sqrtm(const octave_value &arg)
static void sqrtm_utri_inplace(Matrix &T)