GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-norm.cc File Reference
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include "Array.h"
#include "CColVector.h"
#include "CMatrix.h"
#include "CRowVector.h"
#include "CSparse.h"
#include "MArray.h"
#include "dColVector.h"
#include "dDiagMatrix.h"
#include "dMatrix.h"
#include "dRowVector.h"
#include "dSparse.h"
#include "fCColVector.h"
#include "fCMatrix.h"
#include "fCRowVector.h"
#include "fColVector.h"
#include "fDiagMatrix.h"
#include "fMatrix.h"
#include "fRowVector.h"
#include "lo-error.h"
#include "lo-ieee.h"
#include "lo-mappers.h"
#include "mx-cm-s.h"
#include "mx-fcm-fs.h"
#include "mx-fs-fcm.h"
#include "mx-s-cm.h"
#include "oct-cmplx.h"
#include "oct-norm.h"
#include "quit.h"
#include "svd.h"

Go to the source code of this file.

Macros

#define DEFINE_COLROW_NORM_FCNS(PREFIX, RPREFIX, RTYPE)
 
#define DEFINE_DISPATCHER(FCN_NAME, ARG_TYPE, RES_TYPE)
 
#define DEFINE_XNORM_FCNS(PREFIX, RTYPE)
 
#define DEFINE_XNORM_SPARSE_FCNS(PREFIX, RTYPE)
 

Functions

template<typename T , typename R >
void array_norm_2 (const T *v, octave_idx_type n, R &res)
 
template<typename T , typename R , typename ACC >
void column_norms (const MArray< T > &m, MArray< R > &res, ACC acc)
 
template<typename T , typename R >
MArray< R > column_norms (const MArray< T > &v, R p)
 
template<typename T , typename R , typename ACC >
void column_norms (const MSparse< T > &m, MArray< R > &res, ACC acc)
 
template<typename T , typename R >
MArray< R > column_norms (const MSparse< T > &v, R p)
 
template<typename VectorT , typename R >
VectorT dual_p (const VectorT &x, R p, R q)
 
template<typename T , typename R >
elem_dual_p (T x, R p)
 
template<typename MatrixT , typename VectorT , typename R >
higham (const MatrixT &m, R p, R tol, int maxiter, VectorT &x)
 
template<typename MatrixT , typename VectorT , typename R >
matrix_norm (const MatrixT &m, R p, VectorT)
 
template<typename T , typename R , typename ACC >
void row_norms (const MArray< T > &m, MArray< R > &res, ACC acc)
 
template<typename T , typename R >
MArray< R > row_norms (const MArray< T > &v, R p)
 
template<typename T , typename R , typename ACC >
void row_norms (const MSparse< T > &m, MArray< R > &res, ACC acc)
 
template<typename T , typename R >
MArray< R > row_norms (const MSparse< T > &v, R p)
 
template<typename MatrixT , typename VectorT , typename R >
svd_matrix_norm (const MatrixT &m, R p, VectorT)
 
template<typename T , typename R , typename ACC >
void vector_norm (const Array< T > &v, R &res, ACC acc)
 
template<typename T , typename R >
vector_norm (const MArray< T > &v, R p)
 
RowVector xcolnorms (const ComplexMatrix &m, double p)
 
FloatRowVector xcolnorms (const FloatComplexMatrix &m, float p)
 
FloatRowVector xcolnorms (const FloatMatrix &m, float p)
 
RowVector xcolnorms (const Matrix &m, double p)
 
RowVector xcolnorms (const SparseComplexMatrix &m, double p)
 
RowVector xcolnorms (const SparseMatrix &m, double p)
 
double xfrobnorm (const ComplexMatrix &x)
 
float xfrobnorm (const FloatComplexMatrix &x)
 
float xfrobnorm (const FloatMatrix &x)
 
double xfrobnorm (const Matrix &x)
 
double xfrobnorm (const SparseComplexMatrix &x)
 
double xfrobnorm (const SparseMatrix &x)
 
double xnorm (const ColumnVector &x, double p)
 
double xnorm (const ComplexColumnVector &x, double p)
 
double xnorm (const ComplexMatrix &x, double p)
 
double xnorm (const ComplexRowVector &x, double p)
 
float xnorm (const FloatColumnVector &x, float p)
 
float xnorm (const FloatComplexColumnVector &x, float p)
 
float xnorm (const FloatComplexMatrix &x, float p)
 
float xnorm (const FloatComplexRowVector &x, float p)
 
float xnorm (const FloatMatrix &x, float p)
 
float xnorm (const FloatRowVector &x, float p)
 
double xnorm (const Matrix &x, double p)
 
double xnorm (const RowVector &x, double p)
 
double xnorm (const SparseComplexMatrix &x, double p)
 
double xnorm (const SparseMatrix &x, double p)
 
ColumnVector xrownorms (const ComplexMatrix &m, double p)
 
FloatColumnVector xrownorms (const FloatComplexMatrix &m, float p)
 
FloatColumnVector xrownorms (const FloatMatrix &m, float p)
 
ColumnVector xrownorms (const Matrix &m, double p)
 
ColumnVector xrownorms (const SparseComplexMatrix &m, double p)
 
ColumnVector xrownorms (const SparseMatrix &m, double p)
 

Macro Definition Documentation

◆ DEFINE_COLROW_NORM_FCNS

#define DEFINE_COLROW_NORM_FCNS (   PREFIX,
  RPREFIX,
  RTYPE 
)
Value:
RPREFIX##RowVector \
xcolnorms (const PREFIX##Matrix& m, RTYPE p) \
{ \
return column_norms (m, p); \
} \
xrownorms (const PREFIX##Matrix& m, RTYPE p) \
{ \
return row_norms (m, p); \
} \
const char * PREFIX
Definition: build-env.cc:230
Definition: dMatrix.h:42
T octave_idx_type m
Definition: mx-inlines.cc:781
RowVector xcolnorms(const Matrix &m, double p)
Definition: oct-norm.cc:653
void column_norms(const MArray< T > &m, MArray< R > &res, ACC acc)
Definition: oct-norm.cc:289
ColumnVector xrownorms(const Matrix &m, double p)
Definition: oct-norm.cc:653
void row_norms(const MArray< T > &m, MArray< R > &res, ACC acc)
Definition: oct-norm.cc:304

Definition at line 641 of file oct-norm.cc.

◆ DEFINE_DISPATCHER

#define DEFINE_DISPATCHER (   FCN_NAME,
  ARG_TYPE,
  RES_TYPE 
)
Value:
template <typename T, typename R> \
RES_TYPE FCN_NAME (const ARG_TYPE& v, R p) \
{ \
RES_TYPE res; \
if (p == 2) \
FCN_NAME (v, res, norm_accumulator_2<R> ()); \
else if (p == 1) \
FCN_NAME (v, res, norm_accumulator_1<R> ()); \
else if (lo_ieee_isinf (p)) \
{ \
if (p > 0) \
FCN_NAME (v, res, norm_accumulator_inf<R> ()); \
else \
FCN_NAME (v, res, norm_accumulator_minf<R> ()); \
} \
else if (p == 0) \
FCN_NAME (v, res, norm_accumulator_0<R> ()); \
else if (p > 0) \
FCN_NAME (v, res, norm_accumulator_p<R> (p)); \
else \
FCN_NAME (v, res, norm_accumulator_mp<R> (p)); \
return res; \
}
#define lo_ieee_isinf(x)
Definition: lo-ieee.h:124

Definition at line 351 of file oct-norm.cc.

◆ DEFINE_XNORM_FCNS

#define DEFINE_XNORM_FCNS (   PREFIX,
  RTYPE 
)
Value:
RTYPE xnorm (const PREFIX##ColumnVector& x, RTYPE p) \
{ \
return vector_norm (x, p); \
} \
RTYPE xnorm (const PREFIX##RowVector& x, RTYPE p) \
{ \
return vector_norm (x, p); \
} \
RTYPE xnorm (const PREFIX##Matrix& x, RTYPE p) \
{ \
return svd_matrix_norm (x, p, PREFIX##Matrix ()); \
} \
RTYPE xfrobnorm (const PREFIX##Matrix& x) \
{ \
return vector_norm (x, static_cast<RTYPE> (2)); \
}
F77_RET_T const F77_DBLE * x
double xfrobnorm(const Matrix &x)
Definition: oct-norm.cc:610
double xnorm(const ColumnVector &x, double p)
Definition: oct-norm.cc:610
void vector_norm(const Array< T > &v, R &res, ACC acc)
Definition: oct-norm.cc:278
R svd_matrix_norm(const MatrixT &m, R p, VectorT)
Definition: oct-norm.cc:544

Definition at line 592 of file oct-norm.cc.

◆ DEFINE_XNORM_SPARSE_FCNS

#define DEFINE_XNORM_SPARSE_FCNS (   PREFIX,
  RTYPE 
)
Value:
RTYPE xnorm (const Sparse##PREFIX##Matrix& x, RTYPE p) \
{ \
return matrix_norm (x, p, PREFIX##Matrix ()); \
} \
RTYPE xfrobnorm (const Sparse##PREFIX##Matrix& x) \
{ \
RTYPE res; \
array_norm_2 (x.data (), x.nnz (), res); \
return res; \
}
Definition: Sparse.h:49
R matrix_norm(const MatrixT &m, R p, VectorT)
Definition: oct-norm.cc:571

Definition at line 626 of file oct-norm.cc.

Function Documentation

◆ array_norm_2()

template<typename T , typename R >
void array_norm_2 ( const T *  v,
octave_idx_type  n,
R &  res 
)
inline

Definition at line 617 of file oct-norm.cc.

References n.

◆ column_norms() [1/4]

template<typename T , typename R , typename ACC >
void column_norms ( const MArray< T > &  m,
MArray< R > &  res,
ACC  acc 
)

Definition at line 289 of file oct-norm.cc.

References m, and Array< T, Alloc >::xelem().

◆ column_norms() [2/4]

template<typename T , typename R >
MArray<R> column_norms ( const MArray< T > &  v,
p 
)

Definition at line 377 of file oct-norm.cc.

◆ column_norms() [3/4]

template<typename T , typename R , typename ACC >
void column_norms ( const MSparse< T > &  m,
MArray< R > &  res,
ACC  acc 
)

Definition at line 321 of file oct-norm.cc.

References m, and Array< T, Alloc >::xelem().

◆ column_norms() [4/4]

template<typename T , typename R >
MArray<R> column_norms ( const MSparse< T > &  v,
p 
)

Definition at line 379 of file oct-norm.cc.

◆ dual_p()

template<typename VectorT , typename R >
VectorT dual_p ( const VectorT &  x,
p,
q 
)

Definition at line 472 of file oct-norm.cc.

References elem_dual_p(), vector_norm(), and x.

◆ elem_dual_p()

template<typename T , typename R >
T elem_dual_p ( x,
p 
)
inline

Definition at line 461 of file oct-norm.cc.

References pow(), signum(), and x.

Referenced by dual_p().

◆ higham()

template<typename MatrixT , typename VectorT , typename R >
R higham ( const MatrixT &  m,
p,
tol,
int  maxiter,
VectorT &  x 
)

Definition at line 483 of file oct-norm.cc.

References m, and x.

Referenced by matrix_norm(), and svd_matrix_norm().

◆ matrix_norm()

template<typename MatrixT , typename VectorT , typename R >
R matrix_norm ( const MatrixT &  m,
p,
VectorT   
)

◆ row_norms() [1/4]

template<typename T , typename R , typename ACC >
void row_norms ( const MArray< T > &  m,
MArray< R > &  res,
ACC  acc 
)

Definition at line 304 of file oct-norm.cc.

References m, and Array< T, Alloc >::xelem().

◆ row_norms() [2/4]

template<typename T , typename R >
MArray<R> row_norms ( const MArray< T > &  v,
p 
)

Definition at line 378 of file oct-norm.cc.

◆ row_norms() [3/4]

template<typename T , typename R , typename ACC >
void row_norms ( const MSparse< T > &  m,
MArray< R > &  res,
ACC  acc 
)

Definition at line 336 of file oct-norm.cc.

References m, and Array< T, Alloc >::xelem().

◆ row_norms() [4/4]

template<typename T , typename R >
MArray<R> row_norms ( const MSparse< T > &  v,
p 
)

Definition at line 380 of file oct-norm.cc.

◆ svd_matrix_norm()

template<typename MatrixT , typename VectorT , typename R >
R svd_matrix_norm ( const MatrixT &  m,
p,
VectorT   
)

◆ vector_norm() [1/2]

template<typename T , typename R , typename ACC >
void vector_norm ( const Array< T > &  v,
R &  res,
ACC  acc 
)
inline

Definition at line 278 of file oct-norm.cc.

References Array< T, Alloc >::numel().

Referenced by dual_p().

◆ vector_norm() [2/2]

template<typename T , typename R >
R vector_norm ( const MArray< T > &  v,
p 
)

Definition at line 376 of file oct-norm.cc.

◆ xcolnorms() [1/6]

RowVector xcolnorms ( const ComplexMatrix m,
double  p 
)

Definition at line 654 of file oct-norm.cc.

◆ xcolnorms() [2/6]

FloatRowVector xcolnorms ( const FloatComplexMatrix m,
float  p 
)

Definition at line 656 of file oct-norm.cc.

◆ xcolnorms() [3/6]

FloatRowVector xcolnorms ( const FloatMatrix m,
float  p 
)

Definition at line 655 of file oct-norm.cc.

◆ xcolnorms() [4/6]

RowVector xcolnorms ( const Matrix m,
double  p 
)

Definition at line 653 of file oct-norm.cc.

Referenced by F__icholt__(), F__iluc__(), F__ilutp__(), Fnorm(), matrix_norm(), and svd_matrix_norm().

◆ xcolnorms() [5/6]

RowVector xcolnorms ( const SparseComplexMatrix m,
double  p 
)

Definition at line 659 of file oct-norm.cc.

◆ xcolnorms() [6/6]

RowVector xcolnorms ( const SparseMatrix m,
double  p 
)

Definition at line 658 of file oct-norm.cc.

◆ xfrobnorm() [1/6]

double xfrobnorm ( const ComplexMatrix x)

Definition at line 611 of file oct-norm.cc.

◆ xfrobnorm() [2/6]

float xfrobnorm ( const FloatComplexMatrix x)

Definition at line 613 of file oct-norm.cc.

◆ xfrobnorm() [3/6]

float xfrobnorm ( const FloatMatrix x)

Definition at line 612 of file oct-norm.cc.

◆ xfrobnorm() [4/6]

double xfrobnorm ( const Matrix x)

Definition at line 610 of file oct-norm.cc.

Referenced by Fnorm().

◆ xfrobnorm() [5/6]

double xfrobnorm ( const SparseComplexMatrix x)

Definition at line 639 of file oct-norm.cc.

◆ xfrobnorm() [6/6]

double xfrobnorm ( const SparseMatrix x)

Definition at line 638 of file oct-norm.cc.

◆ xnorm() [1/14]

double xnorm ( const ColumnVector x,
double  p 
)

Definition at line 610 of file oct-norm.cc.

Referenced by Fnorm().

◆ xnorm() [2/14]

double xnorm ( const ComplexColumnVector x,
double  p 
)

Definition at line 611 of file oct-norm.cc.

◆ xnorm() [3/14]

double xnorm ( const ComplexMatrix x,
double  p 
)

Definition at line 611 of file oct-norm.cc.

◆ xnorm() [4/14]

double xnorm ( const ComplexRowVector x,
double  p 
)

Definition at line 611 of file oct-norm.cc.

◆ xnorm() [5/14]

float xnorm ( const FloatColumnVector x,
float  p 
)

Definition at line 612 of file oct-norm.cc.

◆ xnorm() [6/14]

float xnorm ( const FloatComplexColumnVector x,
float  p 
)

Definition at line 613 of file oct-norm.cc.

◆ xnorm() [7/14]

float xnorm ( const FloatComplexMatrix x,
float  p 
)

Definition at line 613 of file oct-norm.cc.

◆ xnorm() [8/14]

float xnorm ( const FloatComplexRowVector x,
float  p 
)

Definition at line 613 of file oct-norm.cc.

◆ xnorm() [9/14]

float xnorm ( const FloatMatrix x,
float  p 
)

Definition at line 612 of file oct-norm.cc.

◆ xnorm() [10/14]

float xnorm ( const FloatRowVector x,
float  p 
)

Definition at line 612 of file oct-norm.cc.

◆ xnorm() [11/14]

double xnorm ( const Matrix x,
double  p 
)

Definition at line 610 of file oct-norm.cc.

◆ xnorm() [12/14]

double xnorm ( const RowVector x,
double  p 
)

Definition at line 610 of file oct-norm.cc.

◆ xnorm() [13/14]

double xnorm ( const SparseComplexMatrix x,
double  p 
)

Definition at line 639 of file oct-norm.cc.

◆ xnorm() [14/14]

double xnorm ( const SparseMatrix x,
double  p 
)

Definition at line 638 of file oct-norm.cc.

◆ xrownorms() [1/6]

ColumnVector xrownorms ( const ComplexMatrix m,
double  p 
)

Definition at line 654 of file oct-norm.cc.

◆ xrownorms() [2/6]

FloatColumnVector xrownorms ( const FloatComplexMatrix m,
float  p 
)

Definition at line 656 of file oct-norm.cc.

◆ xrownorms() [3/6]

FloatColumnVector xrownorms ( const FloatMatrix m,
float  p 
)

Definition at line 655 of file oct-norm.cc.

◆ xrownorms() [4/6]

ColumnVector xrownorms ( const Matrix m,
double  p 
)

Definition at line 653 of file oct-norm.cc.

Referenced by F__iluc__(), F__ilutp__(), Fnorm(), matrix_norm(), and svd_matrix_norm().

◆ xrownorms() [5/6]

ColumnVector xrownorms ( const SparseComplexMatrix m,
double  p 
)

Definition at line 659 of file oct-norm.cc.

◆ xrownorms() [6/6]

ColumnVector xrownorms ( const SparseMatrix m,
double  p 
)

Definition at line 658 of file oct-norm.cc.