本文整理汇总了C++中TestData::aeqb方法的典型用法代码示例。如果您正苦于以下问题:C++ TestData::aeqb方法的具体用法?C++ TestData::aeqb怎么用?C++ TestData::aeqb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestData
的用法示例。
在下文中一共展示了TestData::aeqb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: of
void sa_nto_analysis_test::test_1() throw(libtest::test_exception) {
static const char *testname = "sa_nto_analysis_test::test_1()";
try {
std::ofstream of("sa_nto_analysis_test", std::ofstream::app);
// Prepare input data:
size_t nao = TestData::k_nao;
size_t nmo = TestData::k_nmo;
TestData data;
mat s(nao, nao);
read_matrix(data, testname, "s", s);
ab_matrix c(data.aeqb());
c.alpha() = mat(nao, nmo);
if (! data.aeqb()) c.beta() = mat(nao, nmo);
read_ab_matrix(data, testname, "c", c);
ab_matrix hdm_av(data.aeqb()), edm_av(data.aeqb());
hdm_av.alpha() = mat(nao, nao, fill::zeros);
edm_av.alpha() = mat(nao, nao, fill::zeros);
if (! data.aeqb()) {
hdm_av.beta() = mat(nao, nao, fill::zeros);
edm_av.beta() = mat(nao, nao, fill::zeros);
}
// Form state-averaged hole and particle densities
for (size_t istate = 1; istate <= data.nstates(); istate++) {
ab_matrix tdm(data.aeqb());
tdm.alpha() = mat(nao, nao);
if (! data.aeqb()) tdm.beta() = mat(nao, nao);
std::ostringstream ssdm; ssdm << "tdm" << istate;
read_ab_matrix(data, testname, ssdm.str().c_str(), tdm);
ab_matrix hdm, edm;
nto_analysis::form_eh(s, tdm.t(), edm, hdm);
hdm_av += hdm;
edm_av += edm;
}
// Form spin-traced hole and particle densities
ab_matrix edm_av_s(true), hdm_av_s(true);
edm_av_s.alpha() = 0.5 * (edm_av.alpha() + edm_av.beta());
hdm_av_s.alpha() = 0.5 * (hdm_av.alpha() + hdm_av.beta());
// Construct SA-NTOs
sa_nto_analysis sa_nto1(s, nto_analysis(s, c, edm_av, hdm_av));
sa_nto_analysis sa_nto2(s, nto_analysis(s, c, edm_av_s, hdm_av_s));
const ab_matrix &u1 = sa_nto1.get_transf_l();
const ab_matrix &v1 = sa_nto1.get_transf_r();
const ab_matrix &u2 = sa_nto2.get_transf_l();
const ab_matrix &v2 = sa_nto2.get_transf_r();
if (accu(abs(u1.alpha().t() * u1.alpha() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "U(1,alpha) not unitary.");
if (accu(abs(u1.beta().t() * u1.beta() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "U(1,beta) not unitary.");
if (accu(abs(v1.alpha() * v1.alpha().t() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "V(1,alpha) not unitary.");
if (accu(abs(v1.beta() * v1.beta().t() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "V(1,beta) not unitary.");
if (! u2.is_alpha_eq_beta() || ! v2.is_alpha_eq_beta())
fail_test(testname, __FILE__, __LINE__, "SA-NTO(2): Alpha != beta.");
if (accu(abs(u2.alpha().t() * u2.alpha() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "U(2,alpha) not unitary.");
if (accu(abs(u2.beta().t() * u2.beta() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "U(2,beta) not unitary.");
if (accu(abs(v2.alpha() * v2.alpha().t() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "V(2,alpha) not unitary.");
if (accu(abs(v2.beta() * v2.beta().t() - s) > 1e-12) != 0)
fail_test(testname, __FILE__, __LINE__, "V(1,beta) not unitary.");
// Loop to decompose TDM for each state
for (size_t istate = 1; istate <= data.nstates(); istate++) {
ab_matrix tdm(data.aeqb());
tdm.alpha() = mat(nao, nao);
if (! data.aeqb()) tdm.beta() = mat(nao, nao);
std::ostringstream ssdm; ssdm << "tdm" << istate;
read_ab_matrix(data, testname, ssdm.str().c_str(), tdm);
tdm = tdm.t();
sa_nto_analysis sa_nto0(s, nto_analysis(s, c, tdm));
ab_matrix x0, x1, x2;
sa_nto0.analyse(of, tdm, x0);
of << std::endl;
sa_nto1.analyse(of, tdm, x1);
of << std::endl;
sa_nto2.analyse(of, tdm, x2);
of << std::endl << std::endl;
//.........这里部分代码省略.........