cppmat::view

cppmat::view::array

[map_regular_array.h, map_regular_array.hpp]

This class can be used to ‘view’ a const external pointer. This can be useful to refer to a part of a bigger array. For example:

#include <cppmat/cppmat.h>

int main()
{
    cppmat::array<double> container = cppmat::array<double>::Arange({100,4,2});

    cppmat::view::array<double,2,4,2> view;

    view.setMap(&container(10)); // equivalent to "view.setMap(&container(10,0,0));"

    std::cout << view << std::endl;
}

This prints:

80, 81;
82, 83;
84, 85;
86, 87;

Warning

Since C++ performs garbage collection you should use cppmat::view with care. You are responsible that pointers do not go out of scope.

Tip

One can also use the Map constructor instead of the setMap method:

using Mat = cppmat::view::matrix<double,4,2>;

Mat view = Mat::Map(&container(10));

Note

This function cannot make any modification to the view. Its usage is thus somewhat limited. To get a wider functionality use cppmat::tiny::array. For example:

#include <cppmat/cppmat.h>

int main()
{
    cppmat::array<double> container = cppmat::array<double>::Arange({100,4,2});

    cppmat::tiny::array<double,2,4,2> copy;

    copy.setCopy(container.item(10), container.item(10)+copy.size());

    std::cout << copy << std::endl;
}

Note that copy is now a copy. I.e. any modification to copy will not result in a modification in container.

Note that the following syntax could also have been used:

using Mat = cppmat::tiny::matrix<double,4,2>;

Mat copy = Mat::Copy(container.item(10), container.item(10)+8);

Or the following:

using Mat = cppmat::tiny::matrix<double,4,2>;

Mat copy = Mat::Copy(container.item(10));

Or the following:

std::copy(container.item(10), container.item(10)+copy.size(), copy.data());

cppmat::view::matrix

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::matrix<double,10,10> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::matrix.

cppmat::view::vector

[map_regular_vector.h, map_regular_vector.hpp]

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::vector<double,10> A;

    A.setMap(...)

    ... = A(0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::vector.

cppmat::view::symmetric::matrix

[map_symmetric_matrix.h, map_symmetric_matrix.hpp]

Class to view a pointer to a fixed size, symmetric, matrices. For example:

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::symmetric::matrix<double,10,10> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::symmetric::matrix.

cppmat::view::diagonal::matrix

[map_diagonal_matrix.h, map_diagonal_matrix.hpp]

Class to view a pointer to a fixed size, symmetric, matrices. For example:

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::diagonal::matrix<double,10,10> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::diagonal::matrix.

cppmat::view::cartesian

cppmat::view::cartesian::tensor4

[map_cartesian_tensor4.h, map_cartesian_tensor4.hpp]

Class to view a pointer to a fixed size, fourth order tensors. For a 3-d tensor

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::cartesian::tensor4<double,3> A;

    A.setMap(...)

    ... = A(0,0,0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::cartesian::tensor4.

cppmat::view::cartesian::tensor2

[map_cartesian_tensor2.h, map_cartesian_tensor2.hpp]

Class to view a pointer to a fixed size, second order tensors. For a 3-d tensor

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::cartesian::tensor2<double,3> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::cartesian::tensor2.

cppmat::view::cartesian::tensor2s

[map_cartesian_tensor2s.h, map_cartesian_tensor2s.hpp]

Class to view a pointer to a fixed size, symmetric, second order tensors. For a 3-d tensor

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::cartesian::tensor2s<double,3> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::cartesian::tensor2s.

cppmat::view::cartesian::tensor2d

[map_cartesian_tensor2d.h, map_cartesian_tensor2d.hpp]

Class to view a pointer to a fixed size, diagonal, second order tensors. For a 3-d tensor

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::cartesian::tensor2d<double,3> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::cartesian::tensor2d.

cppmat::view::cartesian::vector

[map_cartesian_vector.h, map_cartesian_vector.hpp]

Class to view a pointer to a fixed size, vector. For a 3-d vector

#include <cppmat/cppmat.h>

int main()
{
    cppmat::view::cartesian::vector<double,3> A;

    A.setMap(...)

    ... = A(0,0)

    ...

    return 0;
}

Most methods are the same as for cppmat::tiny::cartesian::vector.