VMPS++
Loading...
Searching...
No Matches
DmrgConglutinations.h
Go to the documentation of this file.
1#ifndef STRAWBERRY_DMRGCONGLUTINATIONS
2#define STRAWBERRY_DMRGCONGLUTINATIONS
3
8template<typename MatrixType1, typename MatrixType2>
9void addBottomRight (const MatrixType1 &Min, MatrixType2 &Mout)
10{
11 int r1 = Mout.rows();
12 int c1 = Mout.cols();
13 int r2 = Min.rows();
14 int c2 = Min.cols();
15
16 Mout.conservativeResize(r1+r2, c1+c2);
17
18 Mout.bottomLeftCorner(r2,c1).setZero();
19 Mout.topRightCorner(r1,c2).setZero();
20 Mout.bottomRightCorner(r2,c2) = Min;
21}
22
28template<typename MatrixType1, typename MatrixType2>
29void addRight (const MatrixType1 &Min, MatrixType2 &Mout)
30{
31 int r1 = Mout.rows();
32 int c1 = Mout.cols();
33 int c2 = Min.cols();
34
36 if (r1 == 0 and c2 != 0)
37 {
38 Mout = Min;
39 }
40 else
41 {
43 if (c2 != 0)
44 {
45 assert(Min.rows() == Mout.rows());
46 Mout.conservativeResize(r1, c1+c2);
47 Mout.rightCols(c2) = Min;
48 }
49 }
50}
51
52template<typename MatrixType1, typename MatrixType2>
53void addRight_makeSquare (const MatrixType1 &Min, MatrixType2 &Mout)
54{
55 int r = Mout.rows();
56 int c1 = Mout.cols();
57 int c2 = Min.cols();
58
60 if (r == 0 and c2 != 0)
61 {
62 Mout = Min;
63 }
64 else
65 {
67 if (c2 != 0)
68 {
69 assert(Min.rows() == Mout.rows());
70 Mout.conservativeResize(c1+c2, c1+c2);
71 Mout.block(0,c1, r,c2) = Min;
72 Mout.bottomRows(c1+c2-r).setZero();
73 }
74 }
75}
76
82template<typename MatrixType1, typename MatrixType2>
83void addBottom (const MatrixType1 &Min, MatrixType2 &Mout)
84{
85 int r1 = Mout.rows();
86 int c1 = Mout.cols();
87 int r2 = Min.rows();
88
90 if (r1 == 0 and r2 != 0)
91 {
92 Mout = Min;
93 }
94 else
95 {
97 if (r2 != 0)
98 {
99 assert(Min.cols() == Mout.cols());
100 Mout.conservativeResize(r1+r2, c1);
101 Mout.bottomRows(r2) = Min;
102 }
103 }
104}
105
106template<typename MatrixType1, typename MatrixType2>
107void addBottom_makeSquare (const MatrixType1 &Min, MatrixType2 &Mout)
108{
109 int r1 = Mout.rows();
110 int c = Mout.cols();
111 int r2 = Min.rows();
112
114 if (r1 == 0 and r2 != 0)
115 {
116 Mout = Min;
117 }
118 else
119 {
121 if (r2 != 0)
122 {
123 assert(Min.cols() == Mout.cols());
124 Mout.conservativeResize(r1+r2, r1+r2);
125 Mout.block(r1,0, r2,c) = Min;
126 Mout.rightCols(r1+r2-c).setZero();
127 }
128 }
129}
130
132
133template<typename MatrixType1, typename MatrixType2>
134void addPos (const MatrixType1 &Min, MatrixType2 &Mout, BLOCK_POSITION POS)
135{
136 assert(POS != SAME_PLACE);
137 if (POS == BOTTOM_RIGHT) {addBottomRight(Min,Mout);}
138 else if (POS == RIGHT) {addRight(Min,Mout);}
139 else if (POS == BOTTOM) {addBottom(Min,Mout);}
140}
141
145template<typename MatrixType>
146void remove_col (size_t i, MatrixType &M)
147{
148 size_t Mrows = M.rows();
149 size_t Mcols = M.cols()-1;
150
151 if (i<Mcols)
152 {
153 M.block(0,i,Mrows,Mcols-i) = M.block(0,i+1,Mrows,Mcols-i);
154 }
155 M.conservativeResize(Mrows,Mcols);
156}
157
161template<typename MatrixType>
162void remove_row (size_t i, MatrixType &M)
163{
164 size_t Mrows = M.rows()-1;
165 size_t Mcols = M.cols();
166
167 if (i<Mcols)
168 {
169 M.block(0,i,Mrows-i,Mcols) = M.block(i+1,0,Mrows-i,Mcols);
170 }
171 M.conservativeResize(Mrows,Mcols);
172}
173
174#endif
void addBottom(const MatrixType1 &Min, MatrixType2 &Mout)
void addBottomRight(const MatrixType1 &Min, MatrixType2 &Mout)
void addBottom_makeSquare(const MatrixType1 &Min, MatrixType2 &Mout)
void remove_row(size_t i, MatrixType &M)
void addRight(const MatrixType1 &Min, MatrixType2 &Mout)
void addPos(const MatrixType1 &Min, MatrixType2 &Mout, BLOCK_POSITION POS)
void remove_col(size_t i, MatrixType &M)
void addRight_makeSquare(const MatrixType1 &Min, MatrixType2 &Mout)
BLOCK_POSITION
@ BOTTOM_RIGHT
@ SAME_PLACE