A Discrete-Event Network Simulator
API
spectrum-value.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 CTTC
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #ifndef SPECTRUM_VALUE_H
22 #define SPECTRUM_VALUE_H
23 
24 #include <ns3/ptr.h>
25 #include <ns3/simple-ref-count.h>
26 #include <ns3/spectrum-model.h>
27 #include <ostream>
28 #include <vector>
29 
30 namespace ns3 {
31 
32 
34 typedef std::vector<double> Values;
35 
58 class SpectrumValue : public SimpleRefCount<SpectrumValue>
59 {
60 public:
79 
80 
81  SpectrumValue ();
82 
83 
91  double& operator[] (size_t index);
92 
100  const double& operator[] (size_t index) const;
101 
102 
108 
109 
115 
116 
122  Bands::const_iterator ConstBandsBegin () const;
123 
129  Bands::const_iterator ConstBandsEnd () const;
130 
131 
137  Values::const_iterator ConstValuesBegin () const;
138 
144  Values::const_iterator ConstValuesEnd () const;
145 
151  Values::iterator ValuesBegin ();
152 
158  Values::iterator ValuesEnd ();
159 
164  uint32_t GetValuesN () const;
165 
171  const double & ValuesAt (uint32_t pos) const;
172 
181  friend SpectrumValue operator+ (const SpectrumValue& lhs, const SpectrumValue& rhs);
182 
183 
192  friend SpectrumValue operator+ (const SpectrumValue& lhs, double rhs);
193 
202  friend SpectrumValue operator+ (double lhs, const SpectrumValue& rhs);
203 
204 
213  friend SpectrumValue operator- (const SpectrumValue& lhs, const SpectrumValue& rhs);
214 
223  friend SpectrumValue operator- (const SpectrumValue& lhs, double rhs);
224 
233  friend SpectrumValue operator- (double lhs, const SpectrumValue& rhs);
234 
243  friend SpectrumValue operator* (const SpectrumValue& lhs, const SpectrumValue& rhs);
244 
253  friend SpectrumValue operator* (const SpectrumValue& lhs, double rhs);
254 
263  friend SpectrumValue operator* (double lhs, const SpectrumValue& rhs);
264 
273  friend SpectrumValue operator/ (const SpectrumValue& lhs, const SpectrumValue& rhs);
274 
283  friend SpectrumValue operator/ (const SpectrumValue& lhs, double rhs);
284 
293  friend SpectrumValue operator/ (double lhs, const SpectrumValue& rhs);
294 
301  friend SpectrumValue operator+ (const SpectrumValue& rhs);
302 
309  friend SpectrumValue operator- (const SpectrumValue& rhs);
310 
311 
321  SpectrumValue operator<< (int n) const;
322 
332  SpectrumValue operator>> (int n) const;
333 
334 
335 
344 
353 
362 
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 
412 
421  SpectrumValue& operator= (double rhs);
422 
423 
424 
432  friend double Norm (const SpectrumValue& x);
433 
434 
442  friend double Sum (const SpectrumValue& x);
443 
444 
451  friend double Prod (const SpectrumValue& x);
452 
453 
462  friend SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
463 
464 
472  friend SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
473 
481  friend SpectrumValue Log10 (const SpectrumValue& arg);
482 
483 
491  friend SpectrumValue Log2 (const SpectrumValue& arg);
492 
500  friend SpectrumValue Log (const SpectrumValue& arg);
501 
509  friend double Integral (const SpectrumValue& arg);
510 
515  Ptr<SpectrumValue> Copy () const;
516 
525  typedef void (* TracedCallback)(Ptr<SpectrumValue> value);
526 
527 
528 private:
533  void Add (const SpectrumValue& x);
538  void Add (double s);
543  void Subtract (const SpectrumValue& x);
548  void Subtract (double s);
553  void Multiply (const SpectrumValue& x);
558  void Multiply (double s);
563  void Divide (const SpectrumValue& x);
568  void Divide (double s);
572  void ChangeSign ();
576  void ShiftLeft (int n);
580  void ShiftRight (int n);
586  void Pow (double exp);
593  void Exp (double base);
597  void Log10 ();
601  void Log2 ();
605  void Log ();
606 
608 
609 
618 
619 
620 };
621 
622 std::ostream& operator << (std::ostream& os, const SpectrumValue& pvf);
623 
624 double Norm (const SpectrumValue& x);
625 double Sum (const SpectrumValue& x);
626 double Prod (const SpectrumValue& x);
627 SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
628 SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
629 SpectrumValue Log10 (const SpectrumValue& arg);
630 SpectrumValue Log2 (const SpectrumValue& arg);
631 SpectrumValue Log (const SpectrumValue& arg);
632 double Integral (const SpectrumValue& arg);
633 
634 
635 } // namespace ns3
636 
637 #endif /* SPECTRUM_VALUE_H */
SpectrumValue & operator*=(const SpectrumValue &rhs)
Multiply *this by the Right Hand Side of the operator, component by component.
uint32_t SpectrumModelUid_t
Uid for SpectrumModels.
void ChangeSign()
Change the values sign.
SpectrumValue & operator/=(const SpectrumValue &rhs)
Divide *this by the Right Hand Side of the operator, component by component.
double Integral(const SpectrumValue &arg)
void Subtract(const SpectrumValue &x)
Subtracts a SpectrumValue (element by element subtraction)
SpectrumValue & operator+=(const SpectrumValue &rhs)
Add the Right Hand Side of the operator to *this, component by component.
Forward calls to a chain of Callback.
friend SpectrumValue operator-(const SpectrumValue &lhs, const SpectrumValue &rhs)
subtraction operator
SpectrumValue operator>>(int n) const
right shift operator
std::vector< double > Values
Container for element values.
Values::iterator ValuesEnd()
void Divide(const SpectrumValue &x)
Divides by a SpectrumValue (element to element division)
Values::const_iterator ConstValuesBegin() const
const double & ValuesAt(uint32_t pos) const
Get the value element at the position.
void Multiply(const SpectrumValue &x)
Multiplies for a SpectrumValue (element to element multiplication)
friend SpectrumValue operator+(const SpectrumValue &lhs, const SpectrumValue &rhs)
addition operator
SpectrumValue & operator-=(const SpectrumValue &rhs)
Subtract the Right Hand Side of the operator from *this, component by component.
friend SpectrumValue Pow(const SpectrumValue &lhs, double rhs)
void Add(const SpectrumValue &x)
Add a SpectrumValue (element to element addition)
SpectrumValue Pow(double lhs, const SpectrumValue &rhs)
Ptr< const SpectrumModel > m_spectrumModel
The spectrum model.
void ShiftRight(int n)
Shift the values to the right.
friend double Prod(const SpectrumValue &x)
Ptr< SpectrumValue > Copy() const
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
void Log2()
Applies a Log2 to each the elements.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Values::const_iterator ConstValuesEnd() const
Ptr< const SpectrumModel > GetSpectrumModel() const
void Log()
Applies a Log to each the elements.
uint32_t GetValuesN() const
Get the number of values stored in the array.
friend SpectrumValue operator/(const SpectrumValue &lhs, const SpectrumValue &rhs)
division component-by-component
void Log10()
Applies a Log10 to each the elements.
SpectrumValue Log10(const SpectrumValue &arg)
Values m_values
Set of values which implement the codomain of the functions in the Function Space defined by Spectrum...
double & operator[](size_t index)
Access value at given frequency index.
Values::iterator ValuesBegin()
SpectrumValue Log(const SpectrumValue &arg)
double Norm(const SpectrumValue &x)
SpectrumValue & operator=(double rhs)
Assign each component of *this to the value of the Right Hand Side of the operator.
void ShiftLeft(int n)
Shift the values to the left.
double Sum(const SpectrumValue &x)
Bands::const_iterator ConstBandsEnd() const
friend double Integral(const SpectrumValue &arg)
friend double Sum(const SpectrumValue &x)
friend double Norm(const SpectrumValue &x)
SpectrumValue operator<<(int n) const
left shift operator
friend SpectrumValue operator*(const SpectrumValue &lhs, const SpectrumValue &rhs)
multiplication component-by-component (Schur product)
SpectrumValue Log2(const SpectrumValue &arg)
Set of values corresponding to a given SpectrumModel.
A template-based reference counting class.
void Exp(double base)
Modifies each element so that it is the base raised to each element value.
SpectrumModelUid_t GetSpectrumModelUid() const
Bands::const_iterator ConstBandsBegin() const
double Prod(const SpectrumValue &x)