PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
removing_nan.hpp
Go to the documentation of this file.
1// Copyright (c) 2024 Andrea Enrico Franzoni (andreaenrico.franzoni@gmail.com)
2//
3// This file is part of PPCKO
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of PPCKO and associated documentation files (the PPCKO software), to deal
7// PPCKO without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of PPCKO, and to permit persons to whom PPCKO is
10// furnished to do so, subject to the following conditions:
11//
12// PPCKO IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17// OUT OF OR IN CONNECTION WITH PPCKO OR THE USE OR OTHER DEALINGS IN
18// PPCKO.
19
20#ifndef KO_REMOVE_NAN_HPP
21#define KO_REMOVE_NAN_HPP
22
23#include <Eigen/Dense>
24#include <iostream>
25#include <algorithm>
26#include <iterator>
27#include <numeric>
28#include <functional>
29#include <vector>
30#include <set>
31#include <type_traits>
32#include <string>
33#include <stdexcept>
34
36#include "traits_ko.hpp"
37
38
39
45
46
47
52template <REM_NAN MA_t>
53using MAT = std::integral_constant<REM_NAN, MA_t>;
54
55
62template<typename T,REM_NAN MA_t>
64{
65
66private:
70 std::size_t m_m;
72 std::size_t m_n;
73
77 void row_removal(Eigen::Block<Eigen::Matrix<T,-1,-1>,1>& row, MAT<REM_NAN::MR>);
81 void row_removal(Eigen::Block<Eigen::Matrix<T,-1,-1>,1>& row, MAT<REM_NAN::ZR>);
82
83public:
84
90 template<typename STOR_OBJ>
91 removing_nan(STOR_OBJ&& data)
92 :
93 m_data{std::forward<STOR_OBJ>(data)}
94 {
95 m_m = m_data.rows();
96 m_n = m_data.cols();
97 }
98
103 inline KO_Traits::StoringMatrix data() const {return m_data;};
104
110 void row_removal(Eigen::Block<Eigen::Matrix<T,-1,-1>,1>& row) { return row_removal(row, MAT<MA_t>{});};
111
115 inline void remove_nan(){ for(auto row : m_data.rowwise()){ row_removal(row);} };
116};
117
118
119#include "removing_nan_imp.hpp"
121
122#endif /*KO_REMOVE_NAN_HPP*/
void remove_nan()
Function to remove the row (dummy NaNs)
Definition removing_nan.hpp:115
void row_removal(Eigen::Block< Eigen::Matrix< T,-1,-1 >, 1 > &row)
Substituting non-dummy NaNs. Tag-dispacther.
Definition removing_nan.hpp:110
removing_nan(STOR_OBJ &&data)
Constructor taking the matrix from which NaNs have to be removed.
Definition removing_nan.hpp:91
KO_Traits::StoringMatrix data() const
Getter for the data matrix.
Definition removing_nan.hpp:103
Contains methods to check and wrap R-inputs into PPCKO-coherent ones.
std::integral_constant< REM_NAN, MA_t > MAT
Definition removing_nan.hpp:53
Implementation of dummy NaNs removal.
Implementation of non-dummy NaNs removal.
Eigen::MatrixXd StoringMatrix
Matrix data structure.
Definition traits_ko.hpp:49
Contains customized types and enumerator for customized template parameters, exploited in the algorit...