fml  0.1-0
Fused Matrix Library
diag.hh
1 // This file is part of fml which is released under the Boost Software
2 // License, Version 1.0. See accompanying file LICENSE or copy at
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #ifndef FML_CPU_FUTURE_DIAG_H
6 #define FML_CPU_FUTURE_DIAG_H
7 #pragma once
8 
9 
10 #include <cmath>
11 #include <stdexcept>
12 
13 #include "../cpumat.hh"
14 #include "../cpuvec.hh"
15 
16 
17 namespace diag
18 {
19  template <typename REAL>
20  bool is_diag(const cpumat<REAL> &x)
21  {
22  if (!x.is_square())
23  return false;
24 
25  const len_t m = x.nrows();
26  x_d = x.data_ptr();
27  for (len_t j=0; j<x.ncols(); j++)
28  {
29  for (len_t i=0; i<m; i++)
30  {
31  if (i == j)
32  continue;
33 
34  if (fabs(x_d[i + m*j]) > (REAL)0.0)
35  return false;
36  }
37  }
38 
39  return true;
40  }
41 
42 
43  template <typename REAL>
44  void make_diag(cpumat<REAL> &x, const cpuvec<REAL> &v)
45  {
46 
47  }
48 }
49 
50 
51 #endif