Jpp
20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
software
JMath
JVectorND.hh
Go to the documentation of this file.
1
#ifndef __JMATH__JVECTORND__
2
#define __JMATH__JVECTORND__
3
4
#include <vector>
5
#include <ostream>
6
7
#include "
JLang/JManip.hh
"
8
9
/**
10
* \author mdejong
11
*/
12
13
namespace
JMATH
{}
14
namespace
JPP
{
using namespace
JMATH
; }
15
16
namespace
JMATH
{
17
18
/**
19
* Nx1 matrix.
20
*/
21
struct
JVectorND
:
22
public
std::vector
<double>
23
{
24
/**
25
* Default constructor.
26
*/
27
JVectorND
() :
28
std
::vector<double>()
29
{}
30
31
32
/**
33
* Constructor.
34
*
35
* \param size size
36
*/
37
JVectorND
(
size_t
size) :
38
std
::vector<double>(size, 0.0)
39
{}
40
41
42
/**
43
* Reset.
44
*/
45
void
reset
()
46
{
47
for
(iterator i = this->begin(); i != this->end(); ++i) {
48
*i = 0.0;
49
}
50
}
51
52
53
/**
54
* Get dot product.
55
*
56
* \param vector vector
57
* \return dot product
58
*/
59
double
getDot
(
const
JVectorND
& vector)
const
60
{
61
double
dot = 0.0;
62
63
const
double
* p = this-> data();
64
const
double
* q = vector.data();
65
66
for
(
size_t
i = this->size(); i != 0; --i, ++p, ++q) {
67
dot += (*p) * (*q);
68
}
69
70
return
dot;
71
}
72
73
74
/**
75
* Print ASCII formatted output.
76
*
77
* \param out output stream
78
* \param object Nx1 matrix
79
* \return output stream
80
*/
81
friend
inline
std::ostream&
operator<<
(std::ostream& out,
const
JVectorND
&
object
)
82
{
83
using namespace
std
;
84
85
const
JFormat
format(out, getFormat<JVectorND>(
JFormat_t
(9, 3, std::ios::fixed | std::ios::showpos)));
86
87
for
(JVectorND::const_iterator i =
object
.begin(); i !=
object
.end(); ++i) {
88
out << format << *i <<
' '
;
89
}
90
91
out << endl;
92
93
return
out;
94
}
95
};
96
}
97
98
#endif
JManip.hh
I/O manipulators.
std::vector
Definition
JSTDTypes.hh:15
JMATH
Definition
JEigen3D.hh:88
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition
JAAnetToolkit.hh:45
std
Definition
JSTDTypes.hh:14
JFormat_t
Data structure for format specifications.
Definition
JManip.hh:524
JFormat
Auxiliary class to temporarily define format specifications.
Definition
JManip.hh:636
JMATH::JVectorND
Nx1 matrix.
Definition
JVectorND.hh:23
JMATH::JVectorND::JVectorND
JVectorND()
Default constructor.
Definition
JVectorND.hh:27
JMATH::JVectorND::reset
void reset()
Reset.
Definition
JVectorND.hh:45
JMATH::JVectorND::operator<<
friend std::ostream & operator<<(std::ostream &out, const JVectorND &object)
Print ASCII formatted output.
Definition
JVectorND.hh:81
JMATH::JVectorND::getDot
double getDot(const JVectorND &vector) const
Get dot product.
Definition
JVectorND.hh:59
JMATH::JVectorND::JVectorND
JVectorND(size_t size)
Constructor.
Definition
JVectorND.hh:37
Generated by
1.10.0