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 
160 
161 
170  friend SpectrumValue operator+ (const SpectrumValue& lhs, const SpectrumValue& rhs);
171 
172 
181  friend SpectrumValue operator+ (const SpectrumValue& lhs, double rhs);
182 
191  friend SpectrumValue operator+ (double lhs, const SpectrumValue& rhs);
192 
193 
202  friend SpectrumValue operator- (const SpectrumValue& lhs, const SpectrumValue& rhs);
203 
212  friend SpectrumValue operator- (const SpectrumValue& lhs, double rhs);
213 
222  friend SpectrumValue operator- (double lhs, const SpectrumValue& rhs);
223 
232  friend SpectrumValue operator* (const SpectrumValue& lhs, const SpectrumValue& rhs);
233 
242  friend SpectrumValue operator* (const SpectrumValue& lhs, double rhs);
243 
252  friend SpectrumValue operator* (double lhs, const SpectrumValue& rhs);
253 
262  friend SpectrumValue operator/ (const SpectrumValue& lhs, const SpectrumValue& rhs);
263 
272  friend SpectrumValue operator/ (const SpectrumValue& lhs, double rhs);
273 
282  friend SpectrumValue operator/ (double lhs, const SpectrumValue& rhs);
283 
290  friend SpectrumValue operator+ (const SpectrumValue& rhs);
291 
298  friend SpectrumValue operator- (const SpectrumValue& rhs);
299 
300 
310  SpectrumValue operator<< (int n) const;
311 
321  SpectrumValue operator>> (int n) const;
322 
323 
324 
333 
342 
351 
360 
369  SpectrumValue& operator+= (double rhs);
370 
379  SpectrumValue& operator-= (double rhs);
380 
389  SpectrumValue& operator*= (double rhs);
390 
399  SpectrumValue& operator/= (double rhs);
400 
401 
410  SpectrumValue& operator= (double rhs);
411 
412 
413 
421  friend double Norm (const SpectrumValue& x);
422 
423 
431  friend double Sum (const SpectrumValue& x);
432 
433 
440  friend double Prod (const SpectrumValue& x);
441 
442 
451  friend SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
452 
453 
461  friend SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
462 
470  friend SpectrumValue Log10 (const SpectrumValue& arg);
471 
472 
480  friend SpectrumValue Log2 (const SpectrumValue& arg);
481 
489  friend SpectrumValue Log (const SpectrumValue& arg);
490 
498  friend double Integral (const SpectrumValue& arg);
499 
504  Ptr<SpectrumValue> Copy () const;
505 
514  typedef void (* TracedCallback)(Ptr<SpectrumValue> value);
515 
516 
517 private:
522  void Add (const SpectrumValue& x);
527  void Add (double s);
532  void Subtract (const SpectrumValue& x);
537  void Subtract (double s);
542  void Multiply (const SpectrumValue& x);
547  void Multiply (double s);
552  void Divide (const SpectrumValue& x);
557  void Divide (double s);
561  void ChangeSign ();
565  void ShiftLeft (int n);
569  void ShiftRight (int n);
575  void Pow (double exp);
582  void Exp (double base);
586  void Log10 ();
590  void Log2 ();
594  void Log ();
595 
597 
598 
607 
608 
609 };
610 
611 std::ostream& operator << (std::ostream& os, const SpectrumValue& pvf);
612 
613 double Norm (const SpectrumValue& x);
614 double Sum (const SpectrumValue& x);
615 double Prod (const SpectrumValue& x);
616 SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
617 SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
618 SpectrumValue Log10 (const SpectrumValue& arg);
619 SpectrumValue Log2 (const SpectrumValue& arg);
620 SpectrumValue Log (const SpectrumValue& arg);
621 double Integral (const SpectrumValue& arg);
622 
623 
624 } // namespace ns3
625 
626 #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
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.
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)