25 #if defined (HAVE_CONFIG_H) 57 #include "mx-fcm-fs.h" 58 #include "mx-fs-fcm.h" 106 template <
typename U>
126 template <
typename R>
155 operator R () {
return scl * std::sqrt (
sum); }
159 template <
typename R>
165 template <
typename U>
170 operator R () {
return sum; }
174 template <
typename R>
180 template <
typename U>
188 operator R () {
return max; }
192 template <
typename R>
198 template <
typename U>
206 operator R () {
return min; }
210 template <
typename R>
216 template <
typename U>
219 if (
val != static_cast<U> (0)) ++
num;
221 operator R () {
return num; }
226 template <
typename T,
typename R,
typename ACC>
236 template <
typename T,
typename R,
typename ACC>
244 accj.accum (m(
i, j));
246 res.
xelem (j) = accj;
250 template <
typename T,
typename R,
typename ACC>
254 std::vector<ACC> acci (m.
rows (), acc);
258 acci[
i].accum (m(
i, j));
266 template <
typename T,
typename R,
typename ACC>
274 accj.accum (m.
data (
k));
276 res.
xelem (j) = accj;
280 template <
typename T,
typename R,
typename ACC>
284 std::vector<ACC> acci (m.
rows (), acc);
296 #define DEFINE_DISPATCHER(FUNC_NAME, ARG_TYPE, RES_TYPE) \ 297 template <typename T, typename R> \ 298 RES_TYPE FUNC_NAME (const ARG_TYPE& v, R p) \ 302 FUNC_NAME (v, res, norm_accumulator_2<R> ()); \ 304 FUNC_NAME (v, res, norm_accumulator_1<R> ()); \ 305 else if (lo_ieee_isinf (p)) \ 308 FUNC_NAME (v, res, norm_accumulator_inf<R> ()); \ 310 FUNC_NAME (v, res, norm_accumulator_minf<R> ()); \ 313 FUNC_NAME (v, res, norm_accumulator_0<R> ()); \ 315 FUNC_NAME (v, res, norm_accumulator_p<R> (p)); \ 317 FUNC_NAME (v, res, norm_accumulator_mp<R> (p)); \ 330 template <typename ColVectorT, typename R>
339 R
fi =
i *
static_cast<R
> (M_PI) / nsamp;
340 R lambda1 = cos (
fi);
344 lambda1 /= lmnr; mu1 /= lmnr;
358 template <
typename ColVectorT,
typename R>
362 std::complex<R>& lambda, std::complex<R>& mu)
364 typedef std::complex<R> CR;
367 CR lamcu = lambda /
std::abs (lambda);
372 R
fi =
i *
static_cast<R
> (M_PI) / nsamp;
373 R lambda1 = cos (
fi);
377 lambda1 /= lmnr; mu1 /= lmnr;
381 lambda = lambda1 * lamcu;
391 R
fi =
i *
static_cast<R
> (M_PI) / nsamp;
392 lamcu = CR (cos (
fi), sin (
fi));
396 lambda = lama * lamcu;
403 template <
typename T,
typename R>
413 template <
typename VectorT,
typename R>
416 VectorT res (
x.dims ());
423 template <
typename MatrixT,
typename VectorT,
typename R>
424 R
higham (
const MatrixT& m, R
p, R tol,
int maxiter,
427 x.resize (m.columns (), 1);
429 VectorT
y(m.rows (), 1, 0), z(m.rows (), 1);
430 typedef typename VectorT::element_type RR;
436 VectorT col (m.column (
k));
442 y = lambda *
y + mu * col;
451 while (iter < maxiter)
483 template <
typename MatrixT,
typename VectorT,
typename R>
500 const R sqrteps = std::sqrt (std::numeric_limits<R>::epsilon ());
510 template <
typename MatrixT,
typename VectorT,
typename R>
521 const R sqrteps = std::sqrt (std::numeric_limits<R>::epsilon ());
532 #define DEFINE_XNORM_FUNCS(PREFIX, RTYPE) \ 533 OCTAVE_API RTYPE xnorm (const PREFIX##ColumnVector& x, RTYPE p) \ 535 return vector_norm (x, p); \ 537 OCTAVE_API RTYPE xnorm (const PREFIX##RowVector& x, RTYPE p) \ 539 return vector_norm (x, p); \ 541 OCTAVE_API RTYPE xnorm (const PREFIX##Matrix& x, RTYPE p) \ 543 return svd_matrix_norm (x, p, PREFIX##Matrix ()); \ 545 OCTAVE_API RTYPE xfrobnorm (const PREFIX##Matrix& x) \ 547 return vector_norm (x, static_cast<RTYPE> (2)); \ 556 template <typename T, typename R>
566 #define DEFINE_XNORM_SPARSE_FUNCS(PREFIX, RTYPE) \ 567 OCTAVE_API RTYPE xnorm (const Sparse##PREFIX##Matrix& x, RTYPE p) \ 569 return matrix_norm (x, p, PREFIX##Matrix ()); \ 571 OCTAVE_API RTYPE xfrobnorm (const Sparse##PREFIX##Matrix& x) \ 574 array_norm_2 (x.data (), x.nnz (), res); \ 581 #define DEFINE_COLROW_NORM_FUNCS(PREFIX, RPREFIX, RTYPE) \ 582 extern OCTAVE_API RPREFIX##RowVector \ 583 xcolnorms (const PREFIX##Matrix& m, RTYPE p) \ 585 return column_norms (m, p); \ 587 extern OCTAVE_API RPREFIX##ColumnVector \ 588 xrownorms (const PREFIX##Matrix& m, RTYPE p) \ 590 return row_norms (m, p); \ octave_idx_type rows(void) const
OCTAVE_API ColumnVector xrownorms(const Matrix &m, double p)
#define DEFINE_XNORM_FUNCS(PREFIX, RTYPE)
Template for N-dimensional array classes with like-type math operators.
#define DEFINE_DISPATCHER(FUNC_NAME, ARG_TYPE, RES_TYPE)
DM_T singular_values(void) const
identity matrix If supplied two scalar respectively For allows like xample val
VectorT dual_p(const VectorT &x, R p, R q)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
octave_idx_type columns(void) const
octave_idx_type * cidx(void)
octave_idx_type columns(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
static void higham_subp(const ColVectorT &y, const ColVectorT &col, octave_idx_type nsamp, R p, R &lambda, R &mu)
#define DEFINE_COLROW_NORM_FUNCS(PREFIX, RPREFIX, RTYPE)
OCTAVE_API RowVector xcolnorms(const Matrix &m, double p)
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
octave_idx_type * ridx(void)
R matrix_norm(const MatrixT &m, R p, VectorT)
static const char * p_less1_gripe
void accum(std::complex< R > val)
T & xelem(octave_idx_type n)
N Dimensional Array with copy-on-write semantics.
charNDArray max(char d, const charNDArray &m)
#define DEFINE_XNORM_SPARSE_FUNCS(PREFIX, RTYPE)
norm_accumulator_mp(R pp)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number). NaN is the result of operations which do not produce a well defined 0 result. Common operations which produce a NaN are arithmetic with infinity ex($\infty - \infty$)
void array_norm_2(const T *v, octave_idx_type n, R &res)
void row_norms(const MArray< T > &m, MArray< R > &res, ACC acc)
the element is set to zero In other the statement xample y
void vector_norm(const Array< T > &v, R &res, ACC acc)
R svd_matrix_norm(const MatrixT &m, R p, VectorT)
void column_norms(const MArray< T > &m, MArray< R > &res, ACC acc)
std::complex< float > FloatComplex
R higham(const MatrixT &m, R p, R tol, int maxiter, VectorT &x)
std::complex< double > Complex
octave_idx_type numel(void) const
Number of elements in the array.
Vector representing the dimensions (size) of an Array.
octave_idx_type rows(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
charNDArray min(char d, const charNDArray &m)