Arithmetic Types
Arithmetic types that can be used in funcy have to fulfil the following requirements:
Requirements
- Copyable:
T must be CopyConstructible and CopyAssignable.
- Multiplication with arithmetic types:
Given:
- An object t of type T.
- An object a of an arithmetic type, such as double or int.
At least one of the following expressions must be valid:
- Summation:
Objects t and s of type T must be summable, i.e. at least one of the following expressions must be valid:
- Multiplication (for matrix types only):
Compatible matrices t and s must be multipliable, i.e. at least one of the following expressions must be valid:
auto r = t*s;
t*=s;
(for square matrices)
auto r = t.rightmultiplany(s);
(for DUNE matrices)
- Access to data:
Access to the entries of a matrix or vector t via at least one of the following expressions:
auto a = t[1][2];
(for matrices) or auto a = t[1];
(for vectors).
auto a = t(1,2);
(for matrices) or auto a = t(1);
(for vectors).
- Access to number of rows and columns (matrices and vectors):
- Fixed size:
A specialization of the template classes
template <class Matrix, class> struct NumberOfRows;
and
template <class Matrix, class> struct NumberOfColumns;
must be provided. For the cases that, for some scalar type S and n,m of type unsigned or int, the employed matrix class is of the form
Matrix<n,m>
Matrix<S,n,m>
suitable specializations are available and access to the number of rows and columns is supported without need to do anything. Similar specializations exist for vectors.
- Dynamic size:
Access to the number of rows and columns of an object t must be supported via at least one of the following expressions:
t.rows()
resp. t.cols()
t.n_rows
resp. t.n_cols
Optional
- Default-constructible:
If T is DefaultConstructible then functions that take arguments of type T also a default constructor, else the default constructor is deleted.
- Construction of the zero matrix:
If you want to use the functions zero<Matrix>()
and unitMatrix<Matrix>()
, a specialization of
template <class Matrix,class> struct Zero;
must be provided. Suitable implementations exist for the cases that a zero matrix can be created by one of the following expressions:
auto zeroMatrix = Matrix(0.);
auto zeroMatrix;
zeroMatrix.zeroes();
back