Code_TYMPAN  4.4.0
Industrial site acoustic simulation
spectrum_matrix.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef TY_MODELS_COMMON_MATRIX
17 #define TY_MODELS_COMMON_MATRIX
18 
19 #include <vector>
20 
22 
23 namespace tympan
24 {
26 
33 {
34 public:
35  typedef std::vector<std::vector<Spectrum>> impl_matrix_t;
36 
40  SpectrumMatrix(size_t nb_receptors, size_t nb_sources);
42  SpectrumMatrix(const SpectrumMatrix& matrix);
44  virtual ~SpectrumMatrix(){};
45 
47  size_t nb_sources() const
48  {
49  return _nb_sources;
50  };
52  size_t nb_receptors() const
53  {
54  return data.size();
55  };
56 
58  const Spectrum& operator()(size_t receptor_idx, size_t sources_idx) const;
59  Spectrum& operator()(size_t receptor_idx, size_t sources_idx);
61  void setSpectre(size_t receptor_idx, size_t sources_idx, Spectrum spectrum);
62 
64  const std::vector<Spectrum>& by_receptor(size_t receptor_idx) const;
65 
67  void clearReceptor(size_t receptor_idx);
68 
70  void clear()
71  {
72  data.clear();
73  };
74 
76  void resize(size_t nb_receptors, size_t nb_sources);
77 
78 protected:
80 
81 private:
82  size_t _nb_sources;
83 
84 }; // class SpectrumMatrix
85 
86 } // namespace tympan
87 
88 #endif
Spectrum matrix N*M used to store results. N is the number of receptors. M is the number of sources.
const std::vector< Spectrum > & by_receptor(size_t receptor_idx) const
Return a vector of Spectrum for a receptor.
void clear()
Clear the matrix.
size_t nb_sources() const
Number of columns (sources) of the matrix.
SpectrumMatrix()
Default constructor.
void clearReceptor(size_t receptor_idx)
Clear the matrix for the a given receptor.
size_t nb_receptors() const
Number of rows (receptors) of the matrix.
void setSpectre(size_t receptor_idx, size_t sources_idx, Spectrum spectrum)
Set a Spectrum into the matrix.
virtual ~SpectrumMatrix()
Destructor.
const Spectrum & operator()(size_t receptor_idx, size_t sources_idx) const
operator()
impl_matrix_t data
Matrix.
std::vector< std::vector< Spectrum > > impl_matrix_t
void resize(size_t nb_receptors, size_t nb_sources)
Resize the matrix (data is cleared)
OSpectre Spectrum
size_t receptor_idx
Definition: entities.hpp:426