Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change pointers to vectors #3980

Merged
merged 27 commits into from
Apr 16, 2024
Merged
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
84e685c
initialize some variables
DylanWRh Mar 29, 2024
e7e0c3c
fix a semicolon
DylanWRh Mar 29, 2024
d7b6d50
Merge branch 'develop' into develop
DylanWRh Mar 29, 2024
97ef279
Merge branch 'develop' into develop
DylanWRh Mar 31, 2024
fa37082
Merge branch 'develop' into develop
DylanWRh Mar 31, 2024
c51b87d
Update sincos.cpp
DylanWRh Apr 2, 2024
3eb45c2
Update mathzone_add1.cpp
DylanWRh Apr 2, 2024
84e3da6
Update mathzone_add1.cpp
DylanWRh Apr 2, 2024
0346eb8
Update opt_DCsrch.cpp
DylanWRh Apr 2, 2024
0b060ad
Update broyden_mixing.cpp
DylanWRh Apr 2, 2024
0d2eb24
Update pulay_mixing.cpp
DylanWRh Apr 2, 2024
bba21b6
Update math_sphbes_test.cpp
DylanWRh Apr 2, 2024
263a85f
Update ORB_gen_tables.cpp
DylanWRh Apr 2, 2024
7019e68
Update ORB_table_phi.cpp
DylanWRh Apr 2, 2024
5410464
Merge branch 'develop' into develop
DylanWRh Apr 2, 2024
3930ce5
Update math_sphbes_test.cpp
DylanWRh Apr 2, 2024
6ce77ac
Merge branch 'deepmodeling:develop' into develop
DylanWRh Apr 14, 2024
47c7330
Change some pointers to vectors
DylanWRh Apr 14, 2024
35920dd
Update formatter_contextfmt_test.cpp
DylanWRh Apr 14, 2024
c141f54
Change pointers to vectors
DylanWRh Apr 14, 2024
e572d51
Change pointers to vectors
DylanWRh Apr 14, 2024
c688532
Rollback
DylanWRh Apr 15, 2024
4d6c7c7
Replace some pointers with vectors
DylanWRh Apr 15, 2024
967b598
Merge branch 'develop' into develop
DylanWRh Apr 15, 2024
fbf048d
Change some pointers to vectors
DylanWRh Apr 15, 2024
6380de0
Merge branch 'develop' of https://github.com/DylanWRh/abacus-develop …
DylanWRh Apr 15, 2024
def4d84
Merge branch 'develop' into develop
DylanWRh Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions source/module_base/cubic_spline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cmath>
#include <cstring>
#include <functional>
#include <vector>

namespace ModuleBase
{
Expand Down Expand Up @@ -124,13 +125,18 @@ void CubicSpline::build(const int n,
}
else
{
double* dx = new double[n - 1];
DylanWRh marked this conversation as resolved.
Show resolved Hide resolved
double* dd = new double[n - 1];
// double* dx = new double[n - 1];
// double* dd = new double[n - 1];
std::vector<double> dx(n - 1);
std::vector<double> dd(n - 1);

// tridiagonal linear system (cyclic if using the periodic boundary condition)
double* diag = new double[n];
double* subdiag = new double[n - 1];
double* supdiag = new double[n - 1];
// double* diag = new double[n];
// double* subdiag = new double[n - 1];
// double* supdiag = new double[n - 1];
std::vector<double> diag(n);
std::vector<double> subdiag(n - 1);
std::vector<double> supdiag(n - 1);

for (int i = 0; i != n - 1; ++i)
{
Expand All @@ -154,7 +160,7 @@ void CubicSpline::build(const int n,
supdiag[0] = dx[n - 2];
subdiag[n - 2] = dx[0];
s[0] = 3.0 * (dd[0] * dx[n - 2] + dd[n - 2] * dx[0]);
solve_cyctri(n - 1, diag, supdiag, subdiag, s);
solve_cyctri(n - 1, diag.data(), supdiag.data(), subdiag.data(), s);
s[n - 1] = s[0];
}
else
Expand Down Expand Up @@ -202,14 +208,8 @@ void CubicSpline::build(const int n,
int INFO = 0;
int N = n;

dgtsv_(&N, &NRHS, subdiag, diag, supdiag, s, &LDB, &INFO);
dgtsv_(&N, &NRHS, subdiag.data(), diag.data(), supdiag.data(), s, &LDB, &INFO);
}

delete[] diag;
delete[] subdiag;
delete[] supdiag;
delete[] dx;
delete[] dd;
}
}

Expand Down