Skip to content

Commit 1ec42c0

Browse files
authored
use a.size()
1 parent 47b67e0 commit 1ec42c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contents/thomas_algorithm/code/c++/thomas.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#include <vector>
33
#include <cstring>
44

5-
void thomas(std::vector<double> const a, std::vector<double> const b, std::vector<double> const c, std::vector<double>& x, const size_t size) {
6-
7-
std::vector<double> y(size);
8-
memset(y.data(), 0, size * sizeof(double));
5+
void thomas(std::vector<double> const a, std::vector<double> const b, std::vector<double> const c, std::vector<double>& x) {
6+
int size = a.size();
7+
double y[size];
8+
memset(y, 0, size * sizeof(double));
99

1010
y[0] = c[0] / b[0];
1111
x[0] = x[0] / b[0];
@@ -33,7 +33,7 @@ int main() {
3333
std::cout << "[0.0 3.0 6.0][z] = [3.0]" << std::endl;
3434
std::cout << "has the solution" << std::endl;
3535

36-
thomas(a, b, c, x, 3);
36+
thomas(a, b, c, x);
3737

3838
for (size_t i = 0; i < 3; ++i) {
3939
std::cout << "[" << x[i] << "]" << std::endl;

0 commit comments

Comments
 (0)