v2DM-DOCI  1.0
Vector.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Copyright (C) 2014-2015 Ward Poelmans
5  *
6  * This file is part of v2DM-DOCI.
7  *
8  * v2DM-DOCI is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Foobar is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * @END LICENSE
22  */
23 
24 #ifndef VECTOR_H
25 #define VECTOR_H
26 
27 #include <iostream>
28 
29 #include "Matrix.h"
30 
31 
32 namespace doci2DM
33 {
34 
42 class Vector
43 {
44 
54  friend std::ostream &operator<<(std::ostream &output,const doci2DM::Vector &vector_p);
55 
56  public:
57 
58  //construct with as input a dimension
59  Vector(int);
60 
61  //construct with as input a Matrix
62  Vector(Matrix &);
63 
64  //copy constructor
65  Vector(const Vector &);
66 
67  Vector(Vector &&);
68 
69  //destructor
70  virtual ~Vector();
71 
72  //overload equality operator
73  Vector &operator=(const Vector &);
74 
75  Vector &operator=(Vector &&);
76 
77  Vector &operator=(double);
78 
79  //overload += operator
80  Vector &operator+=(const Vector &);
81 
82  //overload -= operator
83  Vector &operator-=(const Vector &);
84 
85  Vector &daxpy(double alpha,const Vector &);
86 
87  Vector &operator/=(double);
88 
89  Vector &operator*=(double);
90 
91  void diagonalize(Matrix &);
92 
93  //easy to change the numbers
94  double &operator[](int i);
95 
96  //easy to access the numbers
97  double operator[](int i) const;
98 
99  void fill_Random();
100 
101  void fill_Random(int seed);
102 
103  //get the pointer to the vector
104  double *gVector();
105 
106  //const version
107  const double *gVector() const;
108 
109  int gn() const;
110 
111  double sum() const;
112 
113  double trace() const;
114 
115  double log_product() const;
116 
117  double ddot(const Vector &) const;
118 
119  void dscal(double alpha);
120 
121  double min() const;
122 
123  double max() const;
124 
125  void invert();
126 
127  void sqrt(int);
128 
129  void symmetrize();
130 
131  void L_map(const Vector &,const Vector &);
132 
133  Vector &mprod(const Vector &,const Vector &);
134 
135  void sort();
136 
137  void sep_pm(Vector &, Vector &);
138 
139  private:
140 
142  std::unique_ptr<double []> vector;
143 
145  int n;
146 };
147 
148 }
149 
150 #endif
151 
152 /* vim: set ts=3 sw=3 expandtab :*/
virtual ~Vector()
Definition: Vector.cpp:90
double & operator[](int i)
Definition: Vector.cpp:190
Vector & operator+=(const Vector &)
Definition: Vector.cpp:131
Vector & daxpy(double alpha, const Vector &)
Definition: Vector.cpp:154
std::unique_ptr< double[]> vector
pointer of doubles, contains the numbers, the vector
Definition: Vector.h:142
int gn() const
Definition: Vector.cpp:237
void invert()
Definition: Vector.cpp:356
Vector & operator-=(const Vector &)
Definition: Vector.cpp:142
friend std::ostream & operator<<(std::ostream &output, const doci2DM::Vector &vector_p)
Definition: Vector.cpp:317
void sqrt(int)
Definition: Vector.cpp:362
Vector & operator/=(double)
Definition: Vector.cpp:167
int n
dimension of the vector
Definition: Vector.h:145
double min() const
Definition: Vector.cpp:330
double ddot(const Vector &) const
Definition: Vector.cpp:277
void symmetrize()
Definition: Vector.cpp:372
double log_product() const
Definition: Vector.cpp:263
void L_map(const Vector &, const Vector &)
Definition: Vector.cpp:376
double * gVector()
Definition: Vector.cpp:221
Vector & operator=(const Vector &)
Definition: Vector.cpp:98
void dscal(double alpha)
Definition: Vector.cpp:288
Vector & operator*=(double)
Definition: Vector.cpp:178
void sep_pm(Vector &, Vector &)
Definition: Vector.cpp:402
Vector & mprod(const Vector &, const Vector &)
Definition: Vector.cpp:384
double trace() const
Definition: Vector.cpp:255
double sum() const
Definition: Vector.cpp:245
double max() const
Definition: Vector.cpp:345
void diagonalize(Matrix &)
Definition: Vector.cpp:213
void fill_Random()
Definition: Vector.cpp:298