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
30namespace ns3 {
31
32
34typedef std::vector<double> Values;
35
58class SpectrumValue : public SimpleRefCount<SpectrumValue>
59{
60public:
79
80
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
528private:
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 ();
577 void ShiftLeft (int n);
582 void ShiftRight (int n);
588 void Pow (double exp);
595 void Exp (double base);
599 void Log10 ();
603 void Log2 ();
607 void Log ();
608
610
611
620
621
622};
623
624std::ostream& operator << (std::ostream& os, const SpectrumValue& pvf);
625
626double Norm (const SpectrumValue& x);
627double Sum (const SpectrumValue& x);
628double Prod (const SpectrumValue& x);
629SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
630SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
632SpectrumValue Log2 (const SpectrumValue& arg);
633SpectrumValue Log (const SpectrumValue& arg);
634double Integral (const SpectrumValue& arg);
635
636
637} // namespace ns3
638
639#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)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139
double Integral(const SpectrumValue &arg)
SpectrumValue Log2(const SpectrumValue &arg)
SpectrumValue Log10(const SpectrumValue &arg)
double Norm(const SpectrumValue &x)
SpectrumValue Log(const SpectrumValue &arg)
double Prod(const SpectrumValue &x)
std::vector< double > Values
Container for element values.
double Sum(const SpectrumValue &x)