Skip to content

Commit aad6c8e

Browse files
author
alexeev-dev
committed
fix/refactor: fix bug in computerscience/core module, improve formatting
1 parent 67cd872 commit aad6c8e

File tree

21 files changed

+713
-715
lines changed

21 files changed

+713
-715
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app
33+
34+
build/

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
> [!CAUTION]
1515
> At the moment, libnumerixpp is under active development (alpha), many things may not work, and this version is not recommended for use (all at your own risk).
1616
17-
> [!CAUTION]
18-
> libnumerixpp in development (alpha), many things may not work, and this version is not recommended for use (all at your own risk).
19-
2017
libnumerixpp is a powerful, cross-platofrm C++ library designed for high-performance numerical computing in the domains of physics, mathematics, and computer science.
2118

2219
You can join to our [small russian telegram blog](https://t.me/hex_warehouse).

examples/example-1.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ auto main() -> int {
2121
double const final_velocity = physics::kinematics::calculate_final_velocity(10.0, 10.0, 10.0);
2222
std::cout << "final velocity (10.0, 10.0, 10.0) = " << final_velocity << '\n';
2323

24-
double const final_position = physics::kinematics::calculate_final_position(10.0, 10.0, 10.0, 10.0);
24+
double const final_position =
25+
physics::kinematics::calculate_final_position(10.0, 10.0, 10.0, 10.0);
2526
std::cout << "final position (10.0, 10.0, 10.0, 10.0) = " << final_velocity << '\n';
2627

2728
return 0;

examples/example-2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ auto main() -> int {
5050

5151
double const best_pow_val = 100;
5252
double const pow_results[5] = { mathematics::oldApproximatePower(10.0, 2.0),
53-
mathematics::anotherApproximatePower(10.0, 2.0),
54-
mathematics::binaryPower(10.0, 2),
55-
mathematics::fastPowerDividing(10.0, 2.0),
56-
mathematics::fastPowerFractional(10.0, 2.0) };
53+
mathematics::anotherApproximatePower(10.0, 2.0),
54+
mathematics::binaryPower(10.0, 2),
55+
mathematics::fastPowerDividing(10.0, 2.0),
56+
mathematics::fastPowerFractional(10.0, 2.0) };
5757

5858
std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << '\n';
5959
std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << '\n';

examples/example-3.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ auto main() -> int {
1414
int const decimal_number2 = computerscience::convertBinaryToDecimal(binary_number);
1515
std::string hexadecimal_number = computerscience::convertDecimalToHexadecimal(decimal_number);
1616
int const decimal_number3 = computerscience::convertHexadecimalToDecimal(hexadecimal_number);
17-
std::string const hexadecimal_number2 = computerscience::convertBinaryToHexadecimal(binary_number);
18-
std::string const binary_number2 = computerscience::convertHexadecimalToBinary(hexadecimal_number);
17+
std::string const hexadecimal_number2 =
18+
computerscience::convertBinaryToHexadecimal(binary_number);
19+
std::string const binary_number2 =
20+
computerscience::convertHexadecimalToBinary(hexadecimal_number);
1921
long long const bytes = 1024 * 1024;
2022

2123
std::cout << "Convert decimal " << decimal_number << " to binary: " << binary_number << '\n';
22-
std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2
23-
<< '\n';
24+
std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2 << '\n';
2425
std::cout << "Convert decimal " << decimal_number << " to hexadecimal: " << hexadecimal_number
2526
<< '\n';
2627
std::cout << "Convert hexadecimal " << hexadecimal_number << " to decimal: " << decimal_number3
@@ -29,8 +30,7 @@ auto main() -> int {
2930
<< '\n';
3031
std::cout << "Convert hexadecimal " << hexadecimal_number << " to binary: " << binary_number2
3132
<< '\n';
32-
std::cout << "Convert " << bytes << ": " << computerscience::humanizeBytesSize(bytes)
33-
<< '\n';
33+
std::cout << "Convert " << bytes << ": " << computerscience::humanizeBytesSize(bytes) << '\n';
3434

3535
return 0;
3636
}

examples/example-4.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "libnumerixpp/libnumerixpp.hpp"
77
#include "libnumerixpp/mathematics/equations.hpp"
88

9-
void test_eq_sa(double (*f_eq)(double), double x0, const std::string& eq) {
9+
void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) {
1010
int const iterations = 100;
1111

1212
double z = NAN;

format-code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def main():
9393
for file in files:
9494
if file.endswith(cpp_extensions):
9595
print(f"{BOLD}Format {file}: {root}/{file}{NC}")
96-
os.system(f"{CLANG_FORMAT} -i -style=file {root}/{file}")
97-
os.system(f'clang-tidy --fix {root}/{file}')
9896
os.system(f'codespell -w {root}/{file}')
97+
os.system(f'clang-tidy --fix {root}/{file}')
98+
os.system(f"{CLANG_FORMAT} -i -style=file {root}/{file}")
9999
print(f"{GREEN}Formatting completed successfully: {root}/{file}{NC}")
100100
convert_file(f'{root}/{file}', "4", "tabs")
101101

include/libnumerixpp/computerscience/core.hpp

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,69 @@
1616
*/
1717
namespace computerscience {
1818

19-
/**
20-
* @brief convert decimal to binary
21-
*
22-
* @param[in] decimal The decimal
23-
*
24-
* @return binary number string
25-
*/
26-
auto convert_decimal_to_binary(int decimal) -> std::string;
19+
/**
20+
* @brief convert decimal to binary
21+
*
22+
* @param[in] decimal The decimal
23+
*
24+
* @return binary number string
25+
*/
26+
auto convert_decimal_to_binary(int decimal) -> std::string;
2727

28-
/**
29-
* @brief convert binary to decimal
30-
*
31-
* @param binary The binary
32-
*
33-
* @return decimal integer
34-
*/
35-
auto convert_binary_to_decimal(std::string &binary) -> int;
28+
/**
29+
* @brief convert binary to decimal
30+
*
31+
* @param binary The binary
32+
*
33+
* @return decimal integer
34+
*/
35+
auto convert_binary_to_decimal(std::string &binary) -> int;
3636

37-
/**
38-
* @brief convert decimal to hexadecimal
39-
*
40-
* @param[in] decimal The decimal
41-
*
42-
* @return hexadecimal number string
43-
*/
44-
auto convert_decimal_to_hexadecimal(int decimal) -> std::string;
37+
/**
38+
* @brief convert decimal to hexadecimal
39+
*
40+
* @param[in] decimal The decimal
41+
*
42+
* @return hexadecimal number string
43+
*/
44+
auto convert_decimal_to_hexadecimal(int decimal) -> std::string;
4545

46-
/**
47-
* @brief convert hexadecimal to decimal
48-
*
49-
* @param hexadecimal The hexadecimal
50-
*
51-
* @return decimal integer
52-
*/
53-
auto convert_hexadecimal_to_decimal(std::string &hexadecimal) -> int;
46+
/**
47+
* @brief convert hexadecimal to decimal
48+
*
49+
* @param hexadecimal The hexadecimal
50+
*
51+
* @return decimal integer
52+
*/
53+
auto convert_hexadecimal_to_decimal(std::string &hexadecimal) -> int;
5454

55-
/**
56-
* @brief convert binary to hexadecimal
57-
*
58-
* @param binary The binary
59-
*
60-
* @return hexadecimal number string
61-
*/
62-
auto convert_binary_to_hexadecimal(std::string &binary) -> std::string;
55+
/**
56+
* @brief convert binary to hexadecimal
57+
*
58+
* @param binary The binary
59+
*
60+
* @return hexadecimal number string
61+
*/
62+
auto convert_binary_to_hexadecimal(std::string &binary) -> std::string;
6363

64-
/**
65-
* @brief convert hexadecimal to binary
66-
*
67-
* @param[in] hexadecimal The hexadecimal
68-
*
69-
* @return binary number string
70-
*/
71-
auto convert_hexadecimal_to_binary(std::string hexadecimal) -> std::string;
64+
/**
65+
* @brief convert hexadecimal to binary
66+
*
67+
* @param[in] hexadecimal The hexadecimal
68+
*
69+
* @return binary number string
70+
*/
71+
auto convert_hexadecimal_to_binary(std::string hexadecimal) -> std::string;
7272

73-
/**
74-
* @brief Scale bytes to its proper format
75-
*
76-
* @param[in] bytes The bytes
77-
* @param[in] suffix The suffix
78-
*
79-
* @return humanized size
80-
*/
81-
auto humanize_bytes_size(long long bytes, const std::string &suffix = "B") -> std::string;
73+
/**
74+
* @brief Scale bytes to its proper format
75+
*
76+
* @param[in] bytes The bytes
77+
* @param[in] suffix The suffix
78+
*
79+
* @return humanized size
80+
*/
81+
auto humanize_bytes_size(long long bytes, const std::string &suffix = "B") -> std::string;
8282
} // namespace computerscience
8383

8484
#endif // LIBNUMERIXPP_COMPUTERSCIENCE_CORE_HPP

0 commit comments

Comments
 (0)