Skip to content

Commit 360349e

Browse files
1041176461jiyuangQianruipkuESROAMERmaki49
authored andcommitted
Fix: support negative value in parse_expression (deepmodeling#5826)
* Use template to reconstruct parse_expression * Feature: output R matrix at each MD step * Modify'matrix_HS' to 'matrix' for R matrix output * Merge branches 'develop' and 'develop' of https://github.com/1041176461/abacus-develop into develop * Fix: modify index in parse_expression * Fix: add regfree for parse_expression * Doc: update phonopy doc * Doc: update phonopy doc * fix tdos plot for nspin=2 * optimize dosplot for nspin=2 * fix legend for dosplot * Add files via upload * Update cal_edm_tddft.cpp * Refactor: modify exx loop for relax/md * Update result.ref * Fix wrong parameters in integrate test * Update result.ref * Update result.ref * Update result.ref * Update result.ref * Update result.ref * Update result.ref * Update result.ref * Update result.ref * add exx when istep>0 * Update dos.py * Update esolver_sdft_pw.cpp * Update lcao_before_scf.cpp * Update Exx_LRI_interface.h * Update Exx_LRI_interface.hpp * Fix: compile error * Fix: compile error * Fix: change HSE relax/md result.ref for new framework * Fix: compile error * compatible with exx_iter_finish * Add files via upload * Update esolver_ks_lcao_tddft.h * Update esolver_ks_lcao_tddft.cpp * Fix: support negative value in parse_expression * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: jiyuang <[email protected]> Co-authored-by: Qianrui <[email protected]> Co-authored-by: HTZhao <[email protected]> Co-authored-by: maki49 <[email protected]> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent fedc0fa commit 360349e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

source/module_io/input_conv.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <iomanip>
1313
#include <iostream>
1414
#include <regex.h>
15-
#include <stdio.h>
16-
#include <string.h>
15+
#include <cstdio>
16+
#include <cstring>
1717
#include <string>
1818
#include <vector>
1919
#include <algorithm>
@@ -31,7 +31,7 @@ void tmp_convert();
3131
* @brief Pass the data members from the INPUT instance(defined in
3232
* module_io/input.cpp) to GlobalV and GlobalC.
3333
*/
34-
void Convert(void);
34+
void Convert();
3535

3636
/**
3737
* @brief To parse input parameters as expressions into vectors
@@ -47,7 +47,7 @@ void parse_expression(const std::string& fn, std::vector<T>& vec)
4747
{
4848
ModuleBase::TITLE("Input_Conv", "parse_expression");
4949
int count = 0;
50-
std::string pattern("([0-9]+\\*[0-9.]+|[0-9,.]+)");
50+
std::string pattern("([-+]?[0-9]+\\*[-+]?[0-9.]+|[-+]?[0-9,.]+)");
5151
std::vector<std::string> str;
5252
std::stringstream ss(fn);
5353
std::string section;
@@ -103,6 +103,7 @@ void parse_expression(const std::string& fn, std::vector<T>& vec)
103103
{
104104
size_t pos = sub_str.find("*");
105105
int num = stoi(sub_str.substr(0, pos));
106+
assert(num>=0);
106107
T occ = stof(sub_str.substr(pos + 1, sub_str.size()));
107108
// std::vector<double> ocp_temp(num, occ);
108109
// const std::vector<double>::iterator dest = vec.begin() + count;

0 commit comments

Comments
 (0)