Skip to content

Commit 5528ecc

Browse files
committed
modify some variable names
1 parent 6ffabc5 commit 5528ecc

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

source/module_elecstate/module_dm/density_matrix.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR(const int ik_in)
8282
// get global indexes of whole matrix for each atom in this process
8383
int row_ap = this->_paraV->atom_begin_row[iat1];
8484
int col_ap = this->_paraV->atom_begin_col[iat2];
85+
const int row_size = this->_paraV->get_row_size(iat1);
86+
const int col_size = this->_paraV->get_col_size(iat2);
87+
const int r_size = target_ap.get_R_size();
8588
if (row_ap == -1 || col_ap == -1)
8689
{
8790
throw std::string("Atom-pair not belong this process");
@@ -91,7 +94,7 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR(const int ik_in)
9194
{
9295
tmp_DMR.resize(target_ap.get_size());
9396
}
94-
for (int ir = 0; ir < target_ap.get_R_size(); ++ir)
97+
for (int ir = 0; ir < r_size; ++ir)
9598
{
9699
const ModuleBase::Vector3<int> r_index = target_ap.get_R_index(ir);
97100
hamilt::BaseMatrix<double>* target_mat = target_ap.find_matrix(r_index);
@@ -124,25 +127,25 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR(const int ik_in)
124127
// jump DMK to fill DMR
125128
// DMR is row-major, DMK is column-major
126129
DMK_ptr += col_ap * this->_paraV->nrow + row_ap;
127-
for (int mu = 0; mu < this->_paraV->get_row_size(iat1); ++mu)
130+
for (int mu = 0; mu < row_size; ++mu)
128131
{
129132
DMK_real_ptr = (double*)DMK_ptr;
130133
DMK_imag_ptr = DMK_real_ptr + 1;
131-
BlasConnector::axpy(this->_paraV->get_col_size(iat2),
134+
BlasConnector::axpy(col_size,
132135
kphase.real(),
133136
DMK_real_ptr,
134137
ld_hk2,
135138
target_DMR_ptr,
136139
1);
137140
// "-" since i^2 = -1
138-
BlasConnector::axpy(this->_paraV->get_col_size(iat2),
141+
BlasConnector::axpy(col_size,
139142
-kphase.imag(),
140143
DMK_imag_ptr,
141144
ld_hk2,
142145
target_DMR_ptr,
143146
1);
144147
DMK_ptr += 1;
145-
target_DMR_ptr += this->_paraV->get_col_size(iat2);
148+
target_DMR_ptr += col_size;
146149
}
147150
}
148151
}
@@ -247,7 +250,10 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR_full(hamilt::HContaine
247250
// get global indexes of whole matrix for each atom in this process
248251
int row_ap = this->_paraV->atom_begin_row[iat1];
249252
int col_ap = this->_paraV->atom_begin_col[iat2];
250-
for (int ir = 0; ir < target_ap.get_R_size(); ++ir)
253+
const int row_size = this->_paraV->get_row_size(iat1);
254+
const int col_size = this->_paraV->get_col_size(iat2);
255+
const int r_size = target_ap.get_R_size();
256+
for (int ir = 0; ir < r_size; ++ir)
251257
{
252258
const ModuleBase::Vector3<int> r_index = target_ap.get_R_index(ir);
253259
auto* target_mat = target_ap.find_matrix(r_index);
@@ -277,16 +283,16 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR_full(hamilt::HContaine
277283
// jump DMK to fill DMR
278284
// DMR is row-major, DMK is column-major
279285
DMK_ptr += col_ap * this->_paraV->nrow + row_ap;
280-
for (int mu = 0; mu < this->_paraV->get_row_size(iat1); ++mu)
286+
for (int mu = 0; mu < row_size; ++mu)
281287
{
282-
BlasConnector::axpy(this->_paraV->get_col_size(iat2),
288+
BlasConnector::axpy(col_size,
283289
kphase,
284290
DMK_ptr,
285291
ld_hk,
286292
target_DMR_ptr,
287293
1);
288294
DMK_ptr += 1;
289-
target_DMR_ptr += this->_paraV->get_col_size(iat2);
295+
target_DMR_ptr += col_size;
290296
}
291297
}
292298
}
@@ -331,14 +337,17 @@ void DensityMatrix<double, double>::cal_DMR(const int ik_in)
331337
// get global indexes of whole matrix for each atom in this process
332338
int row_ap = this->_paraV->atom_begin_row[iat1];
333339
int col_ap = this->_paraV->atom_begin_col[iat2];
340+
const int row_size = this->_paraV->get_row_size(iat1);
341+
const int col_size = this->_paraV->get_col_size(iat2);
342+
const int r_size = target_ap.get_R_size();
334343
if (row_ap == -1 || col_ap == -1)
335344
{
336345
throw std::string("Atom-pair not belong this process");
337346
}
338347
// R index
339348
const ModuleBase::Vector3<int> r_index = target_ap.get_R_index(0);
340349
#ifdef __DEBUG
341-
assert(target_ap.get_R_size() == 1);
350+
assert(r_size == 1);
342351
assert(r_index.x == 0 && r_index.y == 0 && r_index.z == 0);
343352
#endif
344353
hamilt::BaseMatrix<double>* target_mat = target_ap.find_matrix(r_index);
@@ -356,16 +365,16 @@ void DensityMatrix<double, double>::cal_DMR(const int ik_in)
356365
double* DMK_ptr = this->_DMK[0 + ik_begin].data();
357366
// transpose DMK col=>row
358367
DMK_ptr += col_ap * this->_paraV->nrow + row_ap;
359-
for (int mu = 0; mu < this->_paraV->get_row_size(iat1); ++mu)
368+
for (int mu = 0; mu < row_size; ++mu)
360369
{
361-
BlasConnector::axpy(this->_paraV->get_col_size(iat2),
370+
BlasConnector::axpy(col_size,
362371
kphase,
363372
DMK_ptr,
364373
ld_hk,
365374
target_DMR_ptr,
366375
1);
367376
DMK_ptr += 1;
368-
target_DMR_ptr += this->_paraV->get_col_size(iat2);
377+
target_DMR_ptr += col_size;
369378
}
370379
}
371380
}

0 commit comments

Comments
 (0)