MCPcopy Create free account
hub / github.com/SZAILAB/MaterialDFT-Demo / normalize_vector

Function normalize_vector

cpp_core/src/eigensolver.cpp:84–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84bool normalize_vector(std::vector<Complex>* v) {
85 if (!v) {
86 throw std::invalid_argument("normalize_vector: null vector pointer");
87 }
88 const double nrm = l2_norm(*v);
89 if (!(nrm > kOrthoEps)) {
90 return false;
91 }
92 const double inv = 1.0 / nrm;
93 for (Complex& vi : *v) {
94 vi *= inv;
95 }
96 return true;
97}
98
99std::vector<Complex> dense_matvec(
100 const std::vector<Complex>& h_col_major,

Callers 1

Calls 1

l2_normFunction · 0.85

Tested by

no test coverage detected