Heidelberg Educational Numerics Library Version 0.27 (from 15 March 2021)
Public Types | Public Member Functions | Related Symbols | List of all members
hdnum::DenseMatrix< REAL > Class Template Reference

Class with mathematical matrix operations. More...

#include <densematrix.hh>

Public Types

typedef std::size_t size_type
 Type used for array indices.
 
typedef std::vector< REALVType
 
typedef VType::const_iterator ConstVectorIterator
 
typedef VType::iterator VectorIterator
 

Public Member Functions

 DenseMatrix ()
 default constructor (empty Matrix)
 
 DenseMatrix (const std::size_t _rows, const std::size_t _cols, const REAL def_val=0)
 constructor
 
 DenseMatrix (const std::initializer_list< std::initializer_list< REAL > > &v)
 constructor from initializer list
 
 DenseMatrix (const hdnum::SparseMatrix< REAL > &other)
 constructor from hdnum::SparseMatrix
 
void addNewRow (const hdnum::Vector< REAL > &rowvector)
 
size_t rowsize () const
 get number of rows of the matrix
 
size_t colsize () const
 get number of columns of the matrix
 
bool scientific () const
 
void scientific (bool b) const
 Switch between floating point (default=true) and fixed point (false) display.
 
std::size_t iwidth () const
 get index field width for pretty-printing
 
std::size_t width () const
 get data field width for pretty-printing
 
std::size_t precision () const
 get data precision for pretty-printing
 
void iwidth (std::size_t i) const
 set index field width for pretty-printing
 
void width (std::size_t i) const
 set data field width for pretty-printing
 
void precision (std::size_t i) const
 set data precision for pretty-printing
 
REALoperator() (const std::size_t row, const std::size_t col)
 (i,j)-operator for accessing entries of a (m x n)-matrix directly
 
const REALoperator() (const std::size_t row, const std::size_t col) const
 read-access on matrix element A_ij using A(i,j)
 
const ConstVectorIterator operator[] (const std::size_t row) const
 read-access on matrix element A_ij using A[i][j]
 
VectorIterator operator[] (const std::size_t row)
 write-access on matrix element A_ij using A[i][j]
 
DenseMatrixoperator= (const DenseMatrix &A)
 assignment operator
 
DenseMatrixoperator= (const REAL value)
 assignment from a scalar value
 
DenseMatrix sub (size_type i, size_type j, size_type rows, size_type cols)
 Submatrix extraction.
 
DenseMatrix transpose () const
 Transposition.
 
DenseMatrixoperator+= (const DenseMatrix &B)
 Addition assignment.
 
DenseMatrixoperator-= (const DenseMatrix &B)
 Subtraction assignment.
 
DenseMatrixoperator*= (const REAL s)
 Scalar multiplication assignment.
 
DenseMatrixoperator/= (const REAL s)
 Scalar division assignment.
 
void update (const REAL s, const DenseMatrix &B)
 Scaled update of a Matrix.
 
template<class V >
void mv (Vector< V > &y, const Vector< V > &x) const
 matrix vector product y = A*x
 
template<class V >
void umv (Vector< V > &y, const Vector< V > &x) const
 update matrix vector product y += A*x
 
template<class V >
void umv (Vector< V > &y, const V &s, const Vector< V > &x) const
 update matrix vector product y += sA*x
 
void mm (const DenseMatrix< REAL > &A, const DenseMatrix< REAL > &B)
 assign to matrix product C = A*B to matrix C
 
void umm (const DenseMatrix< REAL > &A, const DenseMatrix< REAL > &B)
 add matrix product A*B to matrix C
 
void sc (const Vector< REAL > &x, std::size_t k)
 set column: make x the k'th column of A
 
void sr (const Vector< REAL > &x, std::size_t k)
 set row: make x the k'th row of A
 
REAL norm_infty () const
 compute row sum norm
 
REAL norm_1 () const
 compute column sum norm
 
Vector< REALoperator* (const Vector< REAL > &x) const
 vector = matrix * vector
 
DenseMatrix operator* (const DenseMatrix &x) const
 matrix = matrix * matrix
 
DenseMatrix operator+ (const DenseMatrix &x) const
 matrix = matrix + matrix
 
DenseMatrix operator- (const DenseMatrix &x) const
 matrix = matrix - matrix
 

Related Symbols

(Note that these are not member symbols.)

template<class T >
void identity (DenseMatrix< T > &A)
 
template<typename REAL >
void spd (DenseMatrix< REAL > &A)
 
template<typename REAL >
void vandermonde (DenseMatrix< REAL > &A, const Vector< REAL > x)
 
template<typename REAL >
void readMatrixFromFileDat (const std::string &filename, DenseMatrix< REAL > &A)
 Read matrix from a text file.
 
template<typename REAL >
void readMatrixFromFileMatrixMarket (const std::string &filename, DenseMatrix< REAL > &A)
 Read matrix from a matrix market file.
 

Detailed Description

template<typename REAL>
class hdnum::DenseMatrix< REAL >

Class with mathematical matrix operations.

Member Function Documentation

◆ colsize()

template<typename REAL >
size_t hdnum::DenseMatrix< REAL >::colsize ( ) const
inline

get number of columns of the matrix

Example:

size_t nColumns = A.colsize();
std::cout << "Matrix A has " << nColumns << " columns." << std::endl;
Class with mathematical matrix operations.
Definition densematrix.hh:33
size_t colsize() const
get number of columns of the matrix
Definition densematrix.hh:153

Output:

Matrix A has 5 columns.

◆ mm()

template<typename REAL >
void hdnum::DenseMatrix< REAL >::mm ( const DenseMatrix< REAL > & A,
const DenseMatrix< REAL > & B )
inline

assign to matrix product C = A*B to matrix C

Implements C = A*B where A and B are matrices

Parameters
[in]Aconstant reference to a DenseMatrix
[in]Bconstant reference to a DenseMatrix

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(6); // use at least 6 columns for displaying
matrix entries A.precision(3); // display 3 digits behind the point
std::cout << "A =" << A << std::endl;
std::cout << "B =" << B << std::endl;
C.mm(A,B);
std::cout << "C = A*B =" << C << std::endl;
DenseMatrix()
default constructor (empty Matrix)
Definition densematrix.hh:71
std::size_t precision() const
get data precision for pretty-printing
Definition densematrix.hh:188
void mm(const DenseMatrix< REAL > &A, const DenseMatrix< REAL > &B)
assign to matrix product C = A*B to matrix C
Definition densematrix.hh:719
std::size_t width() const
get data field width for pretty-printing
Definition densematrix.hh:185

Output:

A =
0      1      2      3      4      5
0   1.000  1.000  1.000  1.000  1.000  1.000
1   1.000  1.000  1.000  1.000  1.000  1.000

B =
0      1      2
0  -1.000 -1.000 -1.000
1  -1.000 -1.000 -1.000
2  -1.000 -1.000 -1.000
3  -1.000 -1.000 -1.000
4  -1.000 -1.000 -1.000
5  -1.000 -1.000 -1.000

C = A*B =
0      1      2
0  -6.000 -6.000 -6.000
1  -6.000 -6.000 -6.000

◆ mv()

template<typename REAL >
template<class V >
void hdnum::DenseMatrix< REAL >::mv ( Vector< V > & y,
const Vector< V > & x ) const
inline

matrix vector product y = A*x

Implements y = A*x where x and y are a vectors and A is a matrix

Parameters
[in]yreference to the resulting Vector
[in]xconstant reference to a Vector

Example:

x.scientific(false); // fixed point representation for all Vector objects
A.scientific(false); // fixed point representation for all DenseMatrix
std::cout << "A =" << A << std::endl;
std::cout << "x =" << x << std::endl;
A.mv(y,x);
std::cout << "y = A*x =" << y << std::endl;
void mv(Vector< V > &y, const Vector< V > &x) const
matrix vector product y = A*x
Definition densematrix.hh:538

Output:

A =
0          1          2
0       1.000      1.000      1.000
1       1.000      1.000      1.000

x =
[ 0]     10.0000000
[ 1]     10.0000000
[ 2]     10.0000000

y = A*x =
[ 0]     30.0000000
[ 1]     30.0000000

◆ operator()()

template<typename REAL >
REAL & hdnum::DenseMatrix< REAL >::operator() ( const std::size_t row,
const std::size_t col )
inline

(i,j)-operator for accessing entries of a (m x n)-matrix directly

Parameters
[in]rowrow index (0...m-1)
[in]colcolumn index (0...n-1)

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(3);
identity(A); // Defines the identity matrix of the same dimension
std::cout << "A=" << A << std::endl;
std::cout << "reading A(0,0)=" << A(0,0) << std::endl;
std::cout << "resetting A(0,0) and A(2,3)..." << std::endl;
A(0,0) = 1.234;
A(2,3) = 432.1;
std::cout << "A=" << A << std::endl;
void identity(DenseMatrix< T > &A)
Definition densematrix.hh:1238

Output:

A=
0        1        2        3
0     1.000    0.000    0.000    0.000
1     0.000    1.000    0.000    0.000
2     0.000    0.000    1.000    0.000
3     0.000    0.000    0.000    1.000

reading A(0,0)=1.000
resetting A(0,0) and A(2,3)...
A=
0        1        2        3
0     1.234    0.000    0.000    0.000
1     0.000    1.000    0.000    0.000
2     0.000    0.000    1.000  432.100
3     0.000    0.000    0.000    1.000

◆ operator*() [1/2]

matrix = matrix * matrix

Parameters
[in]xconstant reference to a DenseMatrix

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(1);
std::cout << "A=" << A << std::endl;
std::cout << "B=" << B << std::endl;
C=A*B;
std::cout << "C=A*B=" << C << std::endl;

Output:

A=
0        1        2
0       2.0      2.0      2.0
1       2.0      2.0      2.0
2       2.0      2.0      2.0

B=
0        1        2
0       4.0      4.0      4.0
1       4.0      4.0      4.0
2       4.0      4.0      4.0

C=A*B=
0        1        2
0      24.0     24.0     24.0
1      24.0     24.0     24.0
2      24.0     24.0     24.0

◆ operator*() [2/2]

template<typename REAL >
Vector< REAL > hdnum::DenseMatrix< REAL >::operator* ( const Vector< REAL > & x) const
inline

vector = matrix * vector

Parameters
[in]xconstant reference to a Vector

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(1);
x.scientific(false); // fixed point representation for all Vector objects
x.width(8);
x.precision(1);
std::cout << "A=" << A << std::endl;
std::cout << "x=" << x << std::endl;
y=A*x;
std::cout << "y=A*x" << y << std::endl;

Output:

A=
0        1        2
0       2.0      2.0      2.0
1       2.0      2.0      2.0
2       2.0      2.0      2.0

x=
[ 0]     4.0
[ 1]     4.0
[ 2]     4.0

y=A*x
[ 0]    24.0
[ 1]    24.0
[ 2]    24.0

◆ operator*=()

Scalar multiplication assignment.

Implements A *= s where s is a scalar

Parameters
[in]sscalar value to multiply with

Example:

double s = 0.5;
std::cout << "A=" << A << std::endl;
A *= s;
std::cout << "A=" << A << std::endl;

Output:

A=
0          1          2
0   1.000e+00  1.000e+00  1.000e+00
1   1.000e+00  1.000e+00  1.000e+00

0.5*A =
0          1          2
0   5.000e-01  5.000e-01  5.000e-01
1   5.000e-01  5.000e-01  5.000e-01

◆ operator+()

matrix = matrix + matrix

Parameters
[in]xconstant reference to a DenseMatrix

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(1);
std::cout << "A=" << A << std::endl;
std::cout << "B=" << B << std::endl;
C=A+B;
std::cout << "C=A+B=" << C << std::endl;

Output:

A=
0        1        2
0       2.0      2.0      2.0
1       2.0      2.0      2.0
2       2.0      2.0      2.0

B=
0        1        2
0       4.0      4.0      4.0
1       4.0      4.0      4.0
2       4.0      4.0      4.0

C=A+B=
0        1        2
0       6.0      6.0      6.0
1       6.0      6.0      6.0
2       6.0      6.0      6.0

◆ operator+=()

Addition assignment.

Implements A += B matrix addition

Parameters
[in]Banother Matrix

◆ operator-()

matrix = matrix - matrix

Parameters
[in]xconstant reference to a DenseMatrix

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(1);
std::cout << "A=" << A << std::endl;
std::cout << "B=" << B << std::endl;
C=A-B;
std::cout << "C=A-B=" << C << std::endl;

Output:

A=
0        1        2
0       2.0      2.0      2.0
1       2.0      2.0      2.0
2       2.0      2.0      2.0

B=
0        1        2
0       4.0      4.0      4.0
1       4.0      4.0      4.0
2       4.0      4.0      4.0

C=A-B=
0        1        2
0      -2.0     -2.0     -2.0
1      -2.0     -2.0     -2.0
2      -2.0     -2.0     -2.0

◆ operator-=()

Subtraction assignment.

Implements A -= B matrix subtraction

Parameters
[in]Banother matrix

◆ operator/=()

Scalar division assignment.

Implements A /= s where s is a scalar

Parameters
[in]sscalar value to multiply with

Example:

double s = 0.5;
std::cout << "A=" << A << std::endl;
A /= s;
std::cout << "A=" << A << std::endl;

Output:

A=
0          1          2
0   1.000e+00  1.000e+00  1.000e+00
1   1.000e+00  1.000e+00  1.000e+00

A/0.5 =
0          1          2
0   2.000e+00  2.000e+00  2.000e+00
1   2.000e+00  2.000e+00  2.000e+00

◆ operator=() [1/2]

assignment operator

Example:

spd(A);
B = A;
std::cout << "B=" << B << std::endl;
void spd(DenseMatrix< REAL > &A)
Definition densematrix.hh:1283

Output:

B=
0          1          2          3
0   4.000e+00 -1.000e+00 -2.500e-01 -1.111e-01
1  -1.000e+00  4.000e+00 -1.000e+00 -2.500e-01
2  -2.500e-01 -1.000e+00  4.000e+00 -1.000e+00
3  -1.111e-01 -2.500e-01 -1.000e+00  4.000e+00

◆ operator=() [2/2]

assignment from a scalar value

Example:

A = 5.432;
A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(3); std::cout << "A=" << A << std::endl;

Output:

A=
0        1        2
0     5.432    5.432    5.432
1     5.432    5.432    5.432

◆ rowsize()

template<typename REAL >
size_t hdnum::DenseMatrix< REAL >::rowsize ( ) const
inline

get number of rows of the matrix

Example:

size_t nRows = A.rowsize();
std::cout << "Matrix A has " << nRows << " rows." << std::endl;
size_t rowsize() const
get number of rows of the matrix
Definition densematrix.hh:136

Output:

Matrix A has 4 rows.

◆ sc()

template<typename REAL >
void hdnum::DenseMatrix< REAL >::sc ( const Vector< REAL > & x,
std::size_t k )
inline

set column: make x the k'th column of A

Parameters
[in]xconstant reference to a Vector
[in]knumber of the column of A to be set

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(1);
std::cout << "original A=" << A << std::endl;
A.sc(x,3); // redefine fourth column of the matrix
std::cout << "modified A=" << A << std::endl;

Output:

original A=
0        1        2        3        4        5
0       0.0      0.0      0.0      0.0      0.0      0.0
1       0.0      0.0      0.0      0.0      0.0      0.0

modified A=
0        1        2        3        4        5
0       0.0      0.0      0.0    434.0      0.0      0.0
1       0.0      0.0      0.0    434.0      0.0      0.0

◆ scientific()

template<typename REAL >
void hdnum::DenseMatrix< REAL >::scientific ( bool b) const
inline

Switch between floating point (default=true) and fixed point (false) display.

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(3); identity(A); // Defines the identity
matrix of the same dimension std::cout << "A=" << A << std::endl;

Output:

A=
0        1        2        3
0     1.000    0.000    0.000    0.000
1     0.000    1.000    0.000    0.000
2     0.000    0.000    1.000    0.000
3     0.000    0.000    0.000    1.000

◆ sr()

template<typename REAL >
void hdnum::DenseMatrix< REAL >::sr ( const Vector< REAL > & x,
std::size_t k )
inline

set row: make x the k'th row of A

Parameters
[in]xconstant reference to a Vector
[in]knumber of the row of A to be set

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(8); A.precision(1);
std::cout << "original A=" << A << std::endl;
A.sr(x,1); // redefine second row of the matrix
std::cout << "modified A=" << A << std::endl;

Output:

original A=
0        1        2
0       0.0      0.0      0.0
1       0.0      0.0      0.0
2       0.0      0.0      0.0

modified A=
0        1        2
0       0.0      0.0      0.0
1     434.0    434.0    434.0
2       0.0      0.0      0.0

◆ sub()

template<typename REAL >
DenseMatrix hdnum::DenseMatrix< REAL >::sub ( size_type i,
size_type j,
size_type rows,
size_type cols )
inline

Submatrix extraction.

Returns a new matrix that is a subset of the components of the given matrix.

Parameters
[in]ifirst row index of the new matrix
[in]jfirst column index of the new matrix
[in]rowsrow size of the new matrix, i.e. it has components [i,i+rows-1]
[in]colscolumn size of the new matrix, i.e. it has components [j,j+cols-1]

◆ transpose()

template<typename REAL >
DenseMatrix hdnum::DenseMatrix< REAL >::transpose ( ) const
inline

Transposition.

Return the transposed as a new matrix.

◆ umm()

template<typename REAL >
void hdnum::DenseMatrix< REAL >::umm ( const DenseMatrix< REAL > & A,
const DenseMatrix< REAL > & B )
inline

add matrix product A*B to matrix C

Implements C += A*B where A, B and C are matrices

Parameters
[in]Aconstant reference to a DenseMatrix
[in]Bconstant reference to a DenseMatrix

Example:

A.scientific(false); // fixed point representation for all DenseMatrix
objects A.width(6); A.precision(3);
std::cout << "C =" << C << std::endl;
std::cout << "A =" << A << std::endl;
std::cout << "B =" << B << std::endl;
C.umm(A,B);
std::cout << "C + A*B =" << C << std::endl;
void umm(const DenseMatrix< REAL > &A, const DenseMatrix< REAL > &B)
add matrix product A*B to matrix C
Definition densematrix.hh:787

Output:

C =
0      1      2
0   0.500  0.500  0.500
1   0.500  0.500  0.500

A =
0      1      2      3      4      5
0   1.000  1.000  1.000  1.000  1.000  1.000
1   1.000  1.000  1.000  1.000  1.000  1.000

B =
0      1      2
0  -1.000 -1.000 -1.000
1  -1.000 -1.000 -1.000
2  -1.000 -1.000 -1.000
3  -1.000 -1.000 -1.000
4  -1.000 -1.000 -1.000
5  -1.000 -1.000 -1.000

C + A*B =
0      1      2
0  -5.500 -5.500 -5.500
1  -5.500 -5.500 -5.500

◆ umv() [1/2]

template<typename REAL >
template<class V >
void hdnum::DenseMatrix< REAL >::umv ( Vector< V > & y,
const V & s,
const Vector< V > & x ) const
inline

update matrix vector product y += sA*x

Implements y += sA*x where s is a scalar value, x and y are a vectors and A is a matrix

Parameters
[in]yreference to the resulting Vector
[in]sconstant reference to a number type
[in]xconstant reference to a Vector

Example:

double s=0.5;
x.scientific(false); // fixed point representation for all Vector objects
A.scientific(false); // fixed point representation for all DenseMatrix
std::cout << "y =" << y << std::endl;
std::cout << "A =" << A << std::endl;
std::cout << "x =" << x << std::endl;
A.umv(y,s,x);
std::cout << "y = s*A*x =" << y << std::endl;
void umv(Vector< V > &y, const Vector< V > &x) const
update matrix vector product y += A*x
Definition densematrix.hh:598

Output:

y =
[ 0]      5.0000000
[ 1]      5.0000000

A =
0          1          2
0       1.000      1.000      1.000
1       1.000      1.000      1.000

x =
[ 0]     10.0000000
[ 1]     10.0000000
[ 2]     10.0000000

y = s*A*x =
[ 0]     20.0000000
[ 1]     20.0000000

◆ umv() [2/2]

template<typename REAL >
template<class V >
void hdnum::DenseMatrix< REAL >::umv ( Vector< V > & y,
const Vector< V > & x ) const
inline

update matrix vector product y += A*x

Implements y += A*x where x and y are a vectors and A is a matrix

Parameters
[in]yreference to the resulting Vector
[in]xconstant reference to a Vector

Example:

x.scientific(false); // fixed point representation for all Vector objects
A.scientific(false); // fixed point representation for all DenseMatrix
std::cout << "y =" << y << std::endl;
std::cout << "A =" << A << std::endl;
std::cout << "x =" << x << std::endl;
A.umv(y,x);
std::cout << "y = A*x =" << y << std::endl;

Output:

y =
[ 0]      5.0000000
[ 1]      5.0000000

A =
0          1          2
0       1.000      1.000      1.000
1       1.000      1.000      1.000

x =
[ 0]     10.0000000
[ 1]     10.0000000
[ 2]     10.0000000

y + A*x =
[ 0]     35.0000000
[ 1]     35.0000000

◆ update()

template<typename REAL >
void hdnum::DenseMatrix< REAL >::update ( const REAL s,
const DenseMatrix< REAL > & B )
inline

Scaled update of a Matrix.

Implements A += s*B where s is a scalar and B a matrix

Parameters
[in]sscalar value to multiply with
[in]Banother matrix

Example:

double s = 0.5;
A.update(s,B);
std::cout << "A + s*B =" << A << std::endl;

Output:

A + s*B =
0          1          2
0       1.500      1.500      1.500
1       1.500      1.500      1.500

Friends And Related Symbol Documentation

◆ identity()

template<class T >
void identity ( DenseMatrix< T > & A)
related


Function: make identity matrix

template<class T>
inline void identity (DenseMatrix<T> &A)
Parameters
[in]Areference to a DenseMatrix that shall be filled with entries

Example:

A.scientific(false); // fixed point representation for all DenseMatrix objects
A.width(10);
A.precision(5);
std::cout << "A=" << A << std::endl;

Output:

A=
0          1          2          3
0     1.00000    0.00000    0.00000    0.00000
1     0.00000    1.00000    0.00000    0.00000
2     0.00000    0.00000    1.00000    0.00000
3     0.00000    0.00000    0.00000    1.00000

◆ readMatrixFromFileDat()

template<typename REAL >
void readMatrixFromFileDat ( const std::string & filename,
DenseMatrix< REAL > & A )
related

Read matrix from a text file.

Parameters
[in]filenamename of the text file
[in,out]Areference to a DenseMatrix

Example:

readMatrixFromFile("matrixL.dat", L );
std::cout << "L=" << L << std::endl;

Output:

Contents of "matrixL.dat":
1.000e+00  0.000e+00  0.000e+00
2.000e+00  1.000e+00  0.000e+00
3.000e+00  2.000e+00  1.000e+00

would give:
L=
0          1          2
0   1.000e+00  0.000e+00  0.000e+00
1   2.000e+00  1.000e+00  0.000e+00
2   3.000e+00  2.000e+00  1.000e+00

◆ readMatrixFromFileMatrixMarket()

template<typename REAL >
void readMatrixFromFileMatrixMarket ( const std::string & filename,
DenseMatrix< REAL > & A )
related

Read matrix from a matrix market file.

Parameters
[in]filenamename of the text file
[in,out]Areference to a DenseMatrix

Example:

readMatrixFromFile("matrixL.mtx", L );
std::cout << "L=" << L << std::endl;

Output:

Contents of "matrixL.mtx":
3 3 6
1 1 1
2 1 2
2 2 1
3 1 3
3 2 2
3 3 1

would give:
L=
0          1          2
0   1.000e+00  0.000e+00  0.000e+00
1   2.000e+00  1.000e+00  0.000e+00
2   3.000e+00  2.000e+00  1.000e+00

◆ spd()

template<typename REAL >
void spd ( DenseMatrix< REAL > & A)
related


Function: make a symmetric and positive definite matrix

template<typename REAL>
inline void spd (DenseMatrix<REAL> &A)
Parameters
[in]Areference to a DenseMatrix that shall be filled with entries

Example:

spd(A);
A.scientific(false); // fixed point representation for all DenseMatrix objects
A.width(10);
A.precision(5);
std::cout << "A=" << A << std::endl;

Output:

A=
0          1          2          3
0     4.00000   -1.00000   -0.25000   -0.11111
1    -1.00000    4.00000   -1.00000   -0.25000
2    -0.25000   -1.00000    4.00000   -1.00000
3    -0.11111   -0.25000   -1.00000    4.00000

◆ vandermonde()

template<typename REAL >
void vandermonde ( DenseMatrix< REAL > & A,
const Vector< REAL > x )
related


Function: make a vandermonde matrix

template<typename REAL>
inline void vandermonde (DenseMatrix<REAL> &A, const Vector<REAL> x)
void vandermonde(DenseMatrix< REAL > &A, const Vector< REAL > x)
Definition densematrix.hh:1344
Parameters
[in]Areference to a DenseMatrix that shall be filled with entries
[in]xconstant reference to a Vector

Example:

fill(x,2.0,1.0);
A.scientific(false); // fixed point representation for all DenseMatrix objects
A.width(10);
A.precision(5);
x.scientific(false); // fixed point representation for all Vector objects
x.width(10);
x.precision(5);
std::cout << "x=" << x << std::endl;
std::cout << "A=" << A << std::endl;

Output:

x=
[ 0]   2.00000
[ 1]   3.00000
[ 2]   4.00000
[ 3]   5.00000

A=
0          1          2          3
0     1.00000    2.00000    4.00000    8.00000
1     1.00000    3.00000    9.00000   27.00000
2     1.00000    4.00000   16.00000   64.00000
3     1.00000    5.00000   25.00000  125.00000

The documentation for this class was generated from the following file: