Logo MTL4
Other Matrix Functions

For setting up tests quickly, we implemented some convenience functions that initialize matrices:

#include <iostream>
#include <boost/numeric/mtl/mtl.hpp>

int main(int, char**)
{
    using namespace mtl;
    
    const unsigned n= 10;
    compressed2D<double>                           A(n, n);
    dense2D<float, matrix::parameters<col_major> > B(n, n);
    morton_dense<double, 0x55555555>               C(n, n);
    morton_dense<double, 0x555555f0>               D(n, n);

    matrix::hessian_setup(B, 1.0);
    matrix::hessian_setup(C, 2.0);
    matrix::hessian_setup(D, 3.0);
    
    std::cout << "one_norm(B) is " << one_norm(B)<< "\n";
    std::cout << "infinity_norm(B) is " << infinity_norm(B)<< "\n";
    std::cout << "frobenius_norm(B) is " << frobenius_norm(B)<< "\n";
    
    return 0;
}

Hessian matrices are scaled by a factor, i.e. matrix::hessian_setup(A, alpha) is:

\[ A= [a_{ij}] = [\alpha * (i + j)] \]

The funciton is intended for dense matrices. It works on sparse matrices but it is very expensive for large matrices.

The Laplacian setup matrix::laplacian(A, m, n) initializes a matrices with the same values as a finite difference method for a Laplace (Poisson) equation on an $m\times n$ grid. The matrix size is changed to $(m\cdot n)\times (m\cdot n)$. After the setup the diagonal is 4 and four off-diagonals are mostly set to -1, i.e. a simple five-point-stencil. It is intended for sparse matrices but also works on dense ones.

Return to Rank-One and Rank-Two Update                                Table of Content                                Proceed to Triangular Solvers


Other Matrix Functions -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine -- Gen. with rev. 7542 on Sat Aug 11 2012 by doxygen 1.7.6.1 -- © 2010 by SimuNova UG.