1- #ifndef LCAO_MATRIX_HPP
2- #define LCAO_MATRIX_HPP
3-
4- #include " LCAO_matrix.h"
5-
6- // ------------------------------------------------------
7- // DESCRIPTION:
8- // set 'dtype' matrix element (iw1_all, iw2_all) with
9- // an input value 'v'
10- // ------------------------------------------------------
11- template <typename T>
12- void LCAO_Matrix::set_mat2d (
13- const int & global_ir, // index i for atomic orbital (row)
14- const int & global_ic, // index j for atomic orbital (column)
15- const T& v, // value for matrix element (i,j)
16- const Parallel_Orbitals& pv,
17- T* HSloc) // input pointer for store the matrix
18- {
19- // use iw1_all and iw2_all to set Hloc
20- // becareful! The ir and ic may be < 0 !!!
21- const int ir = pv.global2local_row (global_ir);
22- const int ic = pv.global2local_col (global_ic);
23-
24- const long index =
25- ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER ()
26- ? ic * static_cast <long >(pv.nrow ) + ir
27- : ir * static_cast <long >(pv.ncol ) + ic;
28-
29- if (index >= pv.nloc )
30- {
31- std::cout << " iw1_all = " << global_ir << std::endl;
32- std::cout << " iw2_all = " << global_ic << std::endl;
33- std::cout << " ir = " << ir << std::endl;
34- std::cout << " ic = " << ic << std::endl;
35- std::cout << " index = " << index << std::endl;
36- std::cout << " ParaV->nloc = " << pv.nloc << std::endl;
37- ModuleBase::WARNING_QUIT (" LCAO_Matrix" , " set_mat2d" );
38- }
39-
40- // using input pointer HSloc
41- HSloc[index] += v;
42- }
43-
44- #endif
1+ #include " module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h"
2+
3+ namespace LCAO_domain
4+ {
5+
6+ // ------------------------------------------------------
7+ // DESCRIPTION:
8+ // set 'dtype' matrix element (iw1_all, iw2_all) with
9+ // an input value 'v'
10+ // ------------------------------------------------------
11+ template <typename T>
12+ void set_mat2d (
13+ const int & global_ir, // index i for atomic orbital (row)
14+ const int & global_ic, // index j for atomic orbital (column)
15+ const T& v, // value for matrix element (i,j)
16+ const Parallel_Orbitals& pv,
17+ T* HSloc) // input pointer for store the matrix
18+ {
19+ // use iw1_all and iw2_all to set Hloc
20+ // becareful! The ir and ic may be < 0 !!!
21+ const int ir = pv.global2local_row (global_ir);
22+ const int ic = pv.global2local_col (global_ic);
23+
24+ const long index =
25+ ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER ()
26+ ? ic * static_cast <long >(pv.nrow ) + ir
27+ : ir * static_cast <long >(pv.ncol ) + ic;
28+
29+ if (index >= pv.nloc )
30+ {
31+ std::cout << " iw1_all = " << global_ir << std::endl;
32+ std::cout << " iw2_all = " << global_ic << std::endl;
33+ std::cout << " ir = " << ir << std::endl;
34+ std::cout << " ic = " << ic << std::endl;
35+ std::cout << " index = " << index << std::endl;
36+ std::cout << " ParaV->nloc = " << pv.nloc << std::endl;
37+ ModuleBase::WARNING_QUIT (" LCAO_Matrix" , " set_mat2d" );
38+ }
39+
40+ // using input pointer HSloc
41+ HSloc[index] += v;
42+ }
43+
44+ template void set_mat2d<double >(
45+ const int & global_ir,
46+ const int & global_ic,
47+ const double & v,
48+ const Parallel_Orbitals& pv,
49+ double * HSloc);
50+
51+ template void set_mat2d<std::complex <double >>(
52+ const int & global_ir,
53+ const int & global_ic,
54+ const std::complex <double >& v,
55+ const Parallel_Orbitals& pv,
56+ std::complex <double >* HSloc);
57+
58+ } // namespace LCAO_domain
0 commit comments