A Discrete-Event Network Simulator
API
spectrum-value.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 CTTC
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program 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. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
20 #ifndef SPECTRUM_VALUE_H
21 #define SPECTRUM_VALUE_H
22 
23 #include <ns3/ptr.h>
24 #include <ns3/simple-ref-count.h>
25 #include <ns3/spectrum-model.h>
26 
27 #include <ostream>
28 #include <vector>
29 
30 namespace ns3
31 {
32 
34 typedef std::vector<double> Values;
35 
59 class SpectrumValue : public SimpleRefCount<SpectrumValue>
60 {
61  public:
80 
81  SpectrumValue();
82 
90  double& operator[](size_t index);
91 
99  const double& operator[](size_t index) const;
100 
106 
112 
118  Bands::const_iterator ConstBandsBegin() const;
119 
125  Bands::const_iterator ConstBandsEnd() const;
126 
132  Values::const_iterator ConstValuesBegin() const;
133 
139  Values::const_iterator ConstValuesEnd() const;
140 
146  Values::iterator ValuesBegin();
147 
153  Values::iterator ValuesEnd();
154 
159  uint32_t GetValuesN() const;
160 
166  const double& ValuesAt(uint32_t pos) const;
167 
176  friend SpectrumValue operator+(const SpectrumValue& lhs, const SpectrumValue& rhs);
177 
186  friend SpectrumValue operator+(const SpectrumValue& lhs, double rhs);
187 
196  friend SpectrumValue operator+(double lhs, const SpectrumValue& rhs);
197 
206  friend SpectrumValue operator-(const SpectrumValue& lhs, const SpectrumValue& rhs);
207 
216  friend SpectrumValue operator-(const SpectrumValue& lhs, double rhs);
217 
226  friend SpectrumValue operator-(double lhs, const SpectrumValue& rhs);
227 
236  friend SpectrumValue operator*(const SpectrumValue& lhs, const SpectrumValue& rhs);
237 
246  friend SpectrumValue operator*(const SpectrumValue& lhs, double rhs);
247 
256  friend SpectrumValue operator*(double lhs, const SpectrumValue& rhs);
257 
266  friend SpectrumValue operator/(const SpectrumValue& lhs, const SpectrumValue& rhs);
267 
276  friend SpectrumValue operator/(const SpectrumValue& lhs, double rhs);
277 
286  friend SpectrumValue operator/(double lhs, const SpectrumValue& rhs);
287 
294  friend SpectrumValue operator+(const SpectrumValue& rhs);
295 
302  friend SpectrumValue operator-(const SpectrumValue& rhs);
303 
313  SpectrumValue operator<<(int n) const;
314 
324  SpectrumValue operator>>(int n) const;
325 
334 
343 
352 
361 
370  SpectrumValue& operator+=(double rhs);
371 
380  SpectrumValue& operator-=(double rhs);
381 
390  SpectrumValue& operator*=(double rhs);
391 
400  SpectrumValue& operator/=(double rhs);
401 
410  SpectrumValue& operator=(double rhs);
411 
419  friend double Norm(const SpectrumValue& x);
420 
428  friend double Sum(const SpectrumValue& x);
429 
436  friend double Prod(const SpectrumValue& x);
437 
446  friend SpectrumValue Pow(const SpectrumValue& lhs, double rhs);
447 
455  friend SpectrumValue Pow(double lhs, const SpectrumValue& rhs);
456 
464  friend SpectrumValue Log10(const SpectrumValue& arg);
465 
473  friend SpectrumValue Log2(const SpectrumValue& arg);
474 
482  friend SpectrumValue Log(const SpectrumValue& arg);
483 
491  friend double Integral(const SpectrumValue& arg);
492 
497  Ptr<SpectrumValue> Copy() const;
498 
508 
509  private:
514  void Add(const SpectrumValue& x);
519  void Add(double s);
524  void Subtract(const SpectrumValue& x);
529  void Subtract(double s);
534  void Multiply(const SpectrumValue& x);
539  void Multiply(double s);
544  void Divide(const SpectrumValue& x);
549  void Divide(double s);
553  void ChangeSign();
558  void ShiftLeft(int n);
563  void ShiftRight(int n);
569  void Pow(double exp);
576  void Exp(double base);
580  void Log10();
584  void Log2();
588  void Log();
589 
591 
600 };
601 
602 std::ostream& operator<<(std::ostream& os, const SpectrumValue& pvf);
603 
604 double Norm(const SpectrumValue& x);
605 double Sum(const SpectrumValue& x);
606 double Prod(const SpectrumValue& x);
607 SpectrumValue Pow(const SpectrumValue& lhs, double rhs);
608 SpectrumValue Pow(double lhs, const SpectrumValue& rhs);
609 SpectrumValue Log10(const SpectrumValue& arg);
610 SpectrumValue Log2(const SpectrumValue& arg);
611 SpectrumValue Log(const SpectrumValue& arg);
612 double Integral(const SpectrumValue& arg);
613 
614 } // namespace ns3
615 
616 #endif /* SPECTRUM_VALUE_H */
A template-based reference counting class.
Set of values corresponding to a given SpectrumModel.
friend SpectrumValue operator-(const SpectrumValue &lhs, const SpectrumValue &rhs)
subtraction operator
double & operator[](size_t index)
Access value at given frequency index.
void Subtract(const SpectrumValue &x)
Subtracts a SpectrumValue (element by element subtraction)
Values::const_iterator ConstValuesBegin() const
friend SpectrumValue operator+(const SpectrumValue &lhs, const SpectrumValue &rhs)
addition operator
friend double Prod(const SpectrumValue &x)
Bands::const_iterator ConstBandsEnd() const
void Divide(const SpectrumValue &x)
Divides by a SpectrumValue (element to element division)
friend double Norm(const SpectrumValue &x)
friend double Integral(const SpectrumValue &arg)
SpectrumValue & operator=(double rhs)
Assign each component of *this to the value of the Right Hand Side of the operator.
Values::iterator ValuesBegin()
void Exp(double base)
Modifies each element so that it is the base raised to each element value.
Bands::const_iterator ConstBandsBegin() const
void ChangeSign()
Change the values sign.
SpectrumValue operator<<(int n) const
left shift operator
void ShiftLeft(int n)
Shift the values to the left.
Ptr< SpectrumValue > Copy() const
friend SpectrumValue operator/(const SpectrumValue &lhs, const SpectrumValue &rhs)
division component-by-component
Values m_values
Set of values which implement the codomain of the functions in the Function Space defined by Spectrum...
uint32_t GetValuesN() const
Get the number of values stored in the array.
Values::iterator ValuesEnd()
Ptr< const SpectrumModel > GetSpectrumModel() const
SpectrumValue & operator*=(const SpectrumValue &rhs)
Multiply *this by the Right Hand Side of the operator, component by component.
Ptr< const SpectrumModel > m_spectrumModel
The spectrum model.
void ShiftRight(int n)
Shift the values to the right.
friend SpectrumValue operator*(const SpectrumValue &lhs, const SpectrumValue &rhs)
multiplication component-by-component (Schur product)
friend double Sum(const SpectrumValue &x)
void Add(const SpectrumValue &x)
Add a SpectrumValue (element to element addition)
void Multiply(const SpectrumValue &x)
Multiplies for a SpectrumValue (element to element multiplication)
void Log()
Applies a Log to each the elements.
void Log2()
Applies a Log2 to each the elements.
SpectrumModelUid_t GetSpectrumModelUid() const
SpectrumValue & operator/=(const SpectrumValue &rhs)
Divide *this by the Right Hand Side of the operator, component by component.
SpectrumValue & operator+=(const SpectrumValue &rhs)
Add the Right Hand Side of the operator to *this, component by component.
Values::const_iterator ConstValuesEnd() const
SpectrumValue & operator-=(const SpectrumValue &rhs)
Subtract the Right Hand Side of the operator from *this, component by component.
SpectrumValue operator>>(int n) const
right shift operator
friend SpectrumValue Pow(const SpectrumValue &lhs, double rhs)
void Log10()
Applies a Log10 to each the elements.
const double & ValuesAt(uint32_t pos) const
Get the value element at the position.
Forward calls to a chain of Callback.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SpectrumValue Pow(double lhs, const SpectrumValue &rhs)
double Integral(const SpectrumValue &arg)
uint32_t SpectrumModelUid_t
Uid for SpectrumModels.
SpectrumValue Log2(const SpectrumValue &arg)
SpectrumValue Log10(const SpectrumValue &arg)
double Norm(const SpectrumValue &x)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
SpectrumValue Log(const SpectrumValue &arg)
double Prod(const SpectrumValue &x)
std::vector< double > Values
Container for element values.
double Sum(const SpectrumValue &x)
value
Definition: second.py:41