aimstil  5.0.5
scalar_matrix.h
Go to the documentation of this file.
1 #ifndef SCALARMATRIX_H_
2 #define SCALARMATRIX_H_
3 
4 // includes from TIL
5 #include "til/numeric_array.h"
6 
7 namespace til
8 {
9 
10  //---------------------------------------------------------------------------
11 
15  template < typename T >
17  {
18  public: // typedefs
19  typedef T value_type;
20  public: // constructors
21  explicit ScalarMatrix(prec_type value) : m_value(value) {}
22  public: // operators
23  value_type operator()(const numeric_array<std::size_t,2> & pos)
24  {
25  return (pos[0] == pos[1] ? m_value : 0);
26  }
27  public: // set & get
28  value_type value() const { return m_value; }
29  value_type & value() { return m_value; }
30  private: // data
31  value_type m_value;
32  };
33 
34  //---------------------------------------------------------------------------
35 
37  template < typename T, typename TArray >
38  T matdot(ScalarMatrix<T> m, const TArray & x)
39  {
40  return norm2<T>(n) * m.value();
41  }
42 
43  //---------------------------------------------------------------------------
44 
45 }
46 
47 
48 #endif /*SCALARMATRIX_H_*/
A scalar matrix.
Definition: scalar_matrix.h:16
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
value_type operator()(const numeric_array< std::size_t, 2 > &pos)
Definition: scalar_matrix.h:23
value_type value() const
Definition: scalar_matrix.h:28
T matdot(ScalarMatrix< T > m, const TArray &x)
Compute x^T.M.x.
Definition: scalar_matrix.h:38
ScalarMatrix(prec_type value)
Definition: scalar_matrix.h:21
value_type & value()
Definition: scalar_matrix.h:29