v2DM-DOCI  1.0
Matrix.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 MATRIX_H
25 #define MATRIX_H
26 
27 #include <iostream>
28 #include <cstdlib>
29 #include <memory>
30 
31 namespace doci2DM
32 {
33 
41 class Vector;
42 
43 class Matrix
44 {
54  friend std::ostream &operator<<(std::ostream &,const doci2DM::Matrix &);
55 
56  public:
57 
58  //constructor
59  Matrix(int n);
60 
61  //copy constructor
62  Matrix(const Matrix &);
63 
64  Matrix(Matrix &&);
65 
66  //destructor
67  virtual ~Matrix();
68 
69  //overload equality operator
70  Matrix &operator=(const Matrix &);
71 
72  Matrix &operator=(Matrix &&);
73 
74  Matrix &operator=(double );
75 
76  //overload += operator
77  Matrix &operator+=(const Matrix &);
78 
79  //overload -= operator
80  Matrix &operator-=(const Matrix &);
81 
82  Matrix &daxpy(double alpha,const Matrix &);
83 
84  Matrix &operator*=(double);
85 
86  Matrix &operator/=(double);
87 
88  Matrix &mprod(const Matrix &,const Matrix &);
89 
90  //easy to change the numbers
91  double &operator()(int i,int j);
92 
93  //easy to access the numbers
94  double operator()(int i,int j) const;
95 
96  //get the pointer to the matrix
97  double *gMatrix();
98 
99  const double *gMatrix() const;
100 
101  int gn() const;
102 
103  double trace() const;
104 
106 
108 
109  double ddot(const Matrix &) const;
110 
111  void invert();
112 
113  void invert_2x2();
114 
115  void dscal(double alpha);
116 
117  void fill_Random();
118 
119  void fill_Random(int seed);
120 
121  //positieve of negatieve vierkantswortel uit de matrix
122  void sqrt(int option);
123 
124  void sqrt_2x2(int option);
125 
126  void mdiag(const Vector &);
127 
128  void L_map(const Matrix &,const Matrix &);
129 
130  void L_map_2x2(const Matrix &,const Matrix &);
131 
132  void symmetrize();
133 
134  void SaveRawToFile(const std::string) const;
135 
136  void sep_pm(Matrix &,Matrix &);
137 
138  void sep_pm_2x2(Matrix &,Matrix &);
139 
140  void unit();
141 
142  private:
143 
145  std::unique_ptr<double []> matrix;
146 
148  int n;
149 };
150 
151 }
152 
153 #endif
154 
155 /* vim: set ts=3 sw=3 expandtab :*/
double trace() const
Definition: Matrix.cpp:244
void SaveRawToFile(const std::string) const
Definition: Matrix.cpp:606
void L_map(const Matrix &, const Matrix &)
Definition: Matrix.cpp:508
void invert()
Definition: Matrix.cpp:335
Matrix & operator=(const Matrix &)
Definition: Matrix.cpp:92
Matrix & mprod(const Matrix &, const Matrix &)
Definition: Matrix.cpp:558
Vector diagonalize_2x2()
Definition: Matrix.cpp:285
void symmetrize()
Definition: Matrix.cpp:573
double * gMatrix()
Definition: Matrix.cpp:223
void mdiag(const Vector &)
Definition: Matrix.cpp:494
void invert_2x2()
Definition: Matrix.cpp:358
double & operator()(int i, int j)
Definition: Matrix.cpp:199
void sep_pm_2x2(Matrix &, Matrix &)
Definition: Matrix.cpp:758
Matrix & operator/=(double)
Definition: Matrix.cpp:185
Matrix & operator*=(double)
Definition: Matrix.cpp:171
friend std::ostream & operator<<(std::ostream &, const doci2DM::Matrix &)
Definition: Matrix.cpp:581
virtual ~Matrix()
Definition: Matrix.cpp:84
double ddot(const Matrix &) const
Definition: Matrix.cpp:324
int n
dimension of the matrix
Definition: Matrix.h:148
Vector diagonalize()
Definition: Matrix.cpp:259
Matrix & operator-=(const Matrix &)
Definition: Matrix.cpp:141
void dscal(double alpha)
Definition: Matrix.cpp:381
int gn() const
Definition: Matrix.cpp:236
void L_map_2x2(const Matrix &, const Matrix &)
Definition: Matrix.cpp:533
void sqrt(int option)
Definition: Matrix.cpp:414
void sqrt_2x2(int option)
Definition: Matrix.cpp:448
Matrix & operator+=(const Matrix &)
Definition: Matrix.cpp:126
void fill_Random()
Definition: Matrix.cpp:392
std::unique_ptr< double[]> matrix
pointer of doubles, contains the numbers, the matrix
Definition: Matrix.h:145
void sep_pm(Matrix &, Matrix &)
Definition: Matrix.cpp:649
Matrix(int n)
Definition: Matrix.cpp:54
Matrix & daxpy(double alpha, const Matrix &)
Definition: Matrix.cpp:157