Peano
Loading...
Searching...
No Matches
Matrix.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5
6namespace tarch {
7 namespace la {
8 template<int Rows, int Cols, typename Scalar>
9 class Matrix;
10 }
11}
12
13
18
20
21
22#include <string>
23#include <initializer_list>
24
25
26
30template<int Rows, int Cols, typename Scalar>
32 private:
36 Scalar _values[Rows*Cols];
37
38 public:
39
43 Matrix();
47 Matrix( const Scalar& value);
48 Matrix( std::initializer_list<Scalar> values );
49
53 int rows() const;
54
58 int cols() const;
59
63 int size() const;
64
70 inline Scalar & operator() (
71 int rowIndex,
72 int colIndex
73 )
74 #ifdef UseManualInlining
75 __attribute__((always_inline))
76 #endif
77 {
78 assertion5( rowIndex >= 0, Rows, Cols, rowIndex, colIndex, toString() );
79 assertion5( colIndex >= 0, Rows, Cols, rowIndex, colIndex, toString() );
80 assertion5( rowIndex < Rows, Rows, Cols, rowIndex, colIndex, toString() );
81 assertion5( colIndex < Cols, Rows, Cols, rowIndex, colIndex, toString() );
82 return _values[rowIndex * Cols + colIndex];
83 }
84
88 inline const Scalar & operator() (
89 int rowIndex,
90 int colIndex
91 ) const
92 #ifdef UseManualInlining
93 __attribute__((always_inline))
94 #endif
95 {
96 assertion5( rowIndex >= 0, Rows, Cols, rowIndex, colIndex, toString() );
97 assertion5( colIndex >= 0, Rows, Cols, rowIndex, colIndex, toString() );
98 assertion5( rowIndex < Rows, Rows, Cols, rowIndex, colIndex, toString() );
99 assertion5( colIndex < Cols, Rows, Cols, rowIndex, colIndex, toString() );
100 return _values[rowIndex * Cols + colIndex];
101 }
102
103 std::string toString() const;
104
105 std::string toPrettyString(int numberOfDigits=4) const;
106
107 template <typename NewScalarType>
109
115 Scalar* data() {
116 return _values;
117 }
118
119 const Scalar * data() const {
120 return _values;
121 }
122};
123
124
125
126#include "tarch/la/Matrix.cpph"
127
#define assertion5(expr, param0, param1, param2, param3, param4)
int __attribute__((optimize("O0"))) toolbox
Static (i.e.
Definition Matrix.h:31
std::string toString() const
Definition Matrix.cpph:51
std::string toPrettyString(int numberOfDigits=4) const
Definition Matrix.cpph:73
Scalar _values[Rows *Cols]
Values of the matrix components.
Definition Matrix.h:36
int cols() const
Returns the number of columns in the matrix.
Definition Matrix.cpph:39
Matrix()
Constructs a non-initialized matrix.
Definition Matrix.cpph:8
Scalar & operator()(int rowIndex, int colIndex)
Returns element at given row and column index (from 0..size-1).
Definition Matrix.h:70
int size() const
Returns the number of total elements in the matrix.
Definition Matrix.cpph:45
tarch::la::Matrix< Rows, Cols, NewScalarType > convertScalar() const
Definition Matrix.cpph:100
const Scalar * data() const
Definition Matrix.h:119
int rows() const
Returns the number of rows in the matrix.
Definition Matrix.cpph:33
Scalar * data()
This routine returns a pointer to the first data element.
Definition Matrix.h:115
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:19